/share/man/man9/DECLARE_MODULE.9

https://bitbucket.org/freebsd/freebsd-head/ · Unknown · 112 lines · 112 code · 0 blank · 0 comment · 0 complexity · be7b7647dcd2280dd652d4206a1798b7 MD5 · raw file

  1. .\" -*- nroff -*-
  2. .\"
  3. .\" Copyright (c) 2000 Alexander Langer
  4. .\"
  5. .\" All rights reserved.
  6. .\"
  7. .\" This program is free software.
  8. .\"
  9. .\" Redistribution and use in source and binary forms, with or without
  10. .\" modification, are permitted provided that the following conditions
  11. .\" are met:
  12. .\" 1. Redistributions of source code must retain the above copyright
  13. .\" notice, this list of conditions and the following disclaimer.
  14. .\" 2. Redistributions in binary form must reproduce the above copyright
  15. .\" notice, this list of conditions and the following disclaimer in the
  16. .\" documentation and/or other materials provided with the distribution.
  17. .\"
  18. .\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
  19. .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  20. .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  21. .\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
  22. .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  23. .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  24. .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  25. .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  26. .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  27. .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  28. .\"
  29. .\" $FreeBSD$
  30. .\"
  31. .Dd January 6, 2005
  32. .Dt DECLARE_MODULE 9
  33. .Os
  34. .Sh NAME
  35. .Nm DECLARE_MODULE
  36. .Nd kernel module declaration macro
  37. .Sh SYNOPSIS
  38. .In sys/param.h
  39. .In sys/kernel.h
  40. .In sys/module.h
  41. .Fn DECLARE_MODULE "name" "moduledata_t data" "sub" "order"
  42. .Sh DESCRIPTION
  43. The
  44. .Fn DECLARE_MODULE
  45. macro declares a generic kernel module.
  46. It is used to register the module with the system, using the
  47. .Fn SYSINIT
  48. macro.
  49. .Fn DECLARE_MODULE
  50. is usually used within other macros, such as
  51. .Xr DRIVER_MODULE 9 ,
  52. .Xr DEV_MODULE 9
  53. and
  54. .Xr SYSCALL_MODULE 9 .
  55. Of course, it can also be called directly, for example in
  56. order to implement dynamic sysctls.
  57. .Pp
  58. The arguments it expects are:
  59. .Bl -tag -width indent
  60. .It Fa name
  61. The module name, which will be used in the
  62. .Fn SYSINIT
  63. call to identify the module.
  64. .It Fa data
  65. A
  66. .Vt moduledata_t
  67. structure, which contains two main items, the official name of the
  68. module name, which will be used in the
  69. .Vt module_t
  70. structure and a pointer to the event handler function of type
  71. .Vt modeventhand_t .
  72. .It Fa sub
  73. An argument directed to the
  74. .Fn SYSINIT
  75. macro.
  76. Valid values for this are contained in the
  77. .Vt sysinit_sub_id
  78. enumeration
  79. (see
  80. .In sys/kernel.h )
  81. and specify the type of system startup interfaces.
  82. The
  83. .Xr DRIVER_MODULE 9
  84. macro uses a value of
  85. .Dv SI_SUB_DRIVERS
  86. here for example, since these modules contain a driver for a device.
  87. For kernel modules that are loaded at runtime, a value of
  88. .Dv SI_SUB_EXEC
  89. is common.
  90. .It Fa order
  91. An argument for
  92. .Fn SYSINIT .
  93. It represents the KLDs order of initialization within the subsystem.
  94. Valid values are defined in the
  95. .Vt sysinit_elem_order
  96. enumeration
  97. .Pq In sys/kernel.h .
  98. .El
  99. .Sh SEE ALSO
  100. .Xr DEV_MODULE 9 ,
  101. .Xr DRIVER_MODULE 9 ,
  102. .Xr module 9 ,
  103. .Xr SYSCALL_MODULE 9
  104. .Pp
  105. .Pa /usr/include/sys/kernel.h ,
  106. .Pa /usr/share/examples/kld
  107. .Sh AUTHORS
  108. .An -nosplit
  109. This manual page was written by
  110. .An Alexander Langer Aq alex@FreeBSD.org ,
  111. inspired by the KLD Facility Programming Tutorial by
  112. .An Andrew Reiter Aq arr@watson.org .