summaryrefslogtreecommitdiff
path: root/static/freebsd/man9/DECLARE_MODULE.9 3.html
blob: f0cd620a698518e25e16d47e2d5386c0c9467c8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<table class="head">
  <tr>
    <td class="head-ltitle">DECLARE_MODULE(9)</td>
    <td class="head-vol">Kernel Developer's Manual</td>
    <td class="head-rtitle">DECLARE_MODULE(9)</td>
  </tr>
</table>
<div class="manual-text">
<section class="Sh">
<h1 class="Sh" id="NAME"><a class="permalink" href="#NAME">NAME</a></h1>
<p class="Pp"><code class="Nm">DECLARE_MODULE</code> &#x2014;
    <span class="Nd">kernel module declaration macro</span></p>
</section>
<section class="Sh">
<h1 class="Sh" id="SYNOPSIS"><a class="permalink" href="#SYNOPSIS">SYNOPSIS</a></h1>
<p class="Pp"><code class="In">#include
    &lt;<a class="In">sys/param.h</a>&gt;</code>
  <br/>
  <code class="In">#include &lt;<a class="In">sys/kernel.h</a>&gt;</code>
  <br/>
  <code class="In">#include &lt;<a class="In">sys/module.h</a>&gt;</code></p>
<p class="Pp"><code class="Fn">DECLARE_MODULE</code>(<var class="Fa" style="white-space: nowrap;">name</var>,
    <var class="Fa" style="white-space: nowrap;">moduledata_t data</var>,
    <var class="Fa" style="white-space: nowrap;">sub</var>,
    <var class="Fa" style="white-space: nowrap;">order</var>);</p>
<p class="Pp"><code class="Fn">DECLARE_MODULE_TIED</code>(<var class="Fa" style="white-space: nowrap;">name</var>,
    <var class="Fa" style="white-space: nowrap;">moduledata_t data</var>,
    <var class="Fa" style="white-space: nowrap;">sub</var>,
    <var class="Fa" style="white-space: nowrap;">order</var>);</p>
</section>
<section class="Sh">
<h1 class="Sh" id="DESCRIPTION"><a class="permalink" href="#DESCRIPTION">DESCRIPTION</a></h1>
<p class="Pp">The
    <a class="permalink" href="#DECLARE_MODULE"><code class="Fn" id="DECLARE_MODULE">DECLARE_MODULE</code></a>()
    macro declares a generic kernel module. It is used to register the module
    with the system, using the <code class="Fn">SYSINIT</code>() macro.
    <code class="Fn">DECLARE_MODULE</code>() is usually used within other
    macros, such as <a class="Xr">DRIVER_MODULE(9)</a>,
    <a class="Xr">DEV_MODULE(9)</a> and <a class="Xr">SYSCALL_MODULE(9)</a>. Of
    course, it can also be called directly, for example in order to implement
    dynamic sysctls.</p>
<p class="Pp" id="DECLARE_MODULE_TIED">A module declared with
    <a class="permalink" href="#DECLARE_MODULE_TIED"><code class="Fn">DECLARE_MODULE_TIED</code></a>()
    will load only if the running kernel version (as specified by
    <code class="Dv">__FreeBSD_version</code>) is identical to that on which it
    was built. This declaration should be used by modules which depend on
    interfaces beyond the stable kernel KBI (such as ABI emulators or
    hypervisors that rely on internal kernel structures).
    <code class="Fn">DECLARE_MODULE</code>() will behave like
    <code class="Fn">DECLARE_MODULE_TIED</code>() when compiled with modules
    built with the kernel. This allows locks and other synchronization
    primitives to be inlined safely.</p>
<p class="Pp">The arguments are:</p>
<dl class="Bl-tag">
  <dt id="SYSINIT"><var class="Fa">name</var></dt>
  <dd>The module name, which will be used in the
      <a class="permalink" href="#SYSINIT"><code class="Fn">SYSINIT</code></a>()
      call to identify the module.</dd>
  <dt><var class="Fa">data</var></dt>
  <dd>A <var class="Vt">moduledata_t</var> structure, which contains two main
      items, the official name of the module name, which will be used in the
      <var class="Vt">module_t</var> structure and a pointer to the event
      handler function of type <var class="Vt">modeventhand_t</var>.</dd>
  <dt><var class="Fa">sub</var></dt>
  <dd>An argument directed to the <code class="Fn">SYSINIT</code>() macro. Valid
      values for this are contained in the <var class="Vt">sysinit_sub_id</var>
      enumeration (see
      <code class="In">&lt;<a class="In">sys/kernel.h</a>&gt;</code>) and
      specify the type of system startup interfaces. The
      <a class="Xr">DRIVER_MODULE(9)</a> macro uses a value of
      <code class="Dv">SI_SUB_DRIVERS</code> here for example, since these
      modules contain a driver for a device. For kernel modules that are loaded
      at runtime, a value of <code class="Dv">SI_SUB_EXEC</code> is common.</dd>
  <dt><var class="Fa">order</var></dt>
  <dd>An argument for <code class="Fn">SYSINIT</code>(). It represents the KLDs
      order of initialization within the subsystem. Valid values are defined in
      the <var class="Vt">sysinit_elem_order</var> enumeration
      (<code class="In">&lt;<a class="In">sys/kernel.h</a>&gt;</code>).</dd>
</dl>
</section>
<section class="Sh">
<h1 class="Sh" id="SEE_ALSO"><a class="permalink" href="#SEE_ALSO">SEE
  ALSO</a></h1>
<p class="Pp"><a class="Xr">DEV_MODULE(9)</a>,
    <a class="Xr">DRIVER_MODULE(9)</a>, <a class="Xr">module(9)</a>,
    <a class="Xr">SYSCALL_MODULE(9)</a></p>
<p class="Pp"><span class="Pa">/usr/include/sys/kernel.h</span>,
    <span class="Pa">/usr/share/examples/kld</span></p>
</section>
<section class="Sh">
<h1 class="Sh" id="AUTHORS"><a class="permalink" href="#AUTHORS">AUTHORS</a></h1>
<p class="Pp">This manual page was written by <span class="An">Alexander
    Langer</span>
    &lt;<a class="Mt" href="mailto:alex@FreeBSD.org">alex@FreeBSD.org</a>&gt;,
    inspired by the KLD Facility Programming Tutorial by <span class="An">Andrew
    Reiter</span>
    &lt;<a class="Mt" href="mailto:arr@watson.org">arr@watson.org</a>&gt;.</p>
</section>
</div>
<table class="foot">
  <tr>
    <td class="foot-date">February 13, 2018</td>
    <td class="foot-os">FreeBSD 15.0</td>
  </tr>
</table>