xref: /freebsd/share/man/man9/DECLARE_MODULE.9 (revision 55ed6718c2eab08cc7187dd986cfc022ba451a4a)
1b6a55e7aSAlexander Langer.\" -*- nroff -*-
2b6a55e7aSAlexander Langer.\"
3b6a55e7aSAlexander Langer.\" Copyright (c) 2000 Alexander Langer
4b6a55e7aSAlexander Langer.\"
5b6a55e7aSAlexander Langer.\" All rights reserved.
6b6a55e7aSAlexander Langer.\"
7b6a55e7aSAlexander Langer.\" This program is free software.
8b6a55e7aSAlexander Langer.\"
9b6a55e7aSAlexander Langer.\" Redistribution and use in source and binary forms, with or without
10b6a55e7aSAlexander Langer.\" modification, are permitted provided that the following conditions
11b6a55e7aSAlexander Langer.\" are met:
12b6a55e7aSAlexander Langer.\" 1. Redistributions of source code must retain the above copyright
13b6a55e7aSAlexander Langer.\"    notice, this list of conditions and the following disclaimer.
14b6a55e7aSAlexander Langer.\" 2. Redistributions in binary form must reproduce the above copyright
15b6a55e7aSAlexander Langer.\"    notice, this list of conditions and the following disclaimer in the
16b6a55e7aSAlexander Langer.\"    documentation and/or other materials provided with the distribution.
17b6a55e7aSAlexander Langer.\"
18b6a55e7aSAlexander Langer.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
19b6a55e7aSAlexander Langer.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20b6a55e7aSAlexander Langer.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21b6a55e7aSAlexander Langer.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
22b6a55e7aSAlexander Langer.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23b6a55e7aSAlexander Langer.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24b6a55e7aSAlexander Langer.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25b6a55e7aSAlexander Langer.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26b6a55e7aSAlexander Langer.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27b6a55e7aSAlexander Langer.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28b6a55e7aSAlexander Langer.\"
29b6a55e7aSAlexander Langer.\" $FreeBSD$
30b6a55e7aSAlexander Langer.\"
31920bdda8SEd Maste.Dd February 13, 2018
32b6a55e7aSAlexander Langer.Dt DECLARE_MODULE 9
33b6a55e7aSAlexander Langer.Os
34b6a55e7aSAlexander Langer.Sh NAME
35b6a55e7aSAlexander Langer.Nm DECLARE_MODULE
36b6a55e7aSAlexander Langer.Nd kernel module declaration macro
37b6a55e7aSAlexander Langer.Sh SYNOPSIS
38f16b3c0dSChad David.In sys/param.h
39f16b3c0dSChad David.In sys/kernel.h
4032eef9aeSRuslan Ermilov.In sys/module.h
41b6a55e7aSAlexander Langer.Fn DECLARE_MODULE "name" "moduledata_t data" "sub" "order"
42920bdda8SEd Maste.Fn DECLARE_MODULE_TIED "name" "moduledata_t data" "sub" "order"
43b6a55e7aSAlexander Langer.Sh DESCRIPTION
44b6a55e7aSAlexander LangerThe
45b6a55e7aSAlexander Langer.Fn DECLARE_MODULE
46b6a55e7aSAlexander Langermacro declares a generic kernel module.
47b6a55e7aSAlexander LangerIt is used to register the module with the system, using the
48b6a55e7aSAlexander Langer.Fn SYSINIT
49b6a55e7aSAlexander Langermacro.
50b6a55e7aSAlexander Langer.Fn DECLARE_MODULE
51b6a55e7aSAlexander Langeris usually used within other macros, such as
52b6a55e7aSAlexander Langer.Xr DRIVER_MODULE 9 ,
53a8ed195dSAlexander Langer.Xr DEV_MODULE 9
54b6a55e7aSAlexander Langerand
55b6a55e7aSAlexander Langer.Xr SYSCALL_MODULE 9 .
56c91b6b9eSGiorgos KeramidasOf course, it can also be called directly, for example in
57b6a55e7aSAlexander Langerorder to implement dynamic sysctls.
58b6a55e7aSAlexander Langer.Pp
59920bdda8SEd MasteA module declared with
60920bdda8SEd Maste.Fn DECLARE_MODULE_TIED
61920bdda8SEd Mastewill load only if the running kernel version
62920bdda8SEd Maste(as specified by
63920bdda8SEd Maste.Dv __FreeBSD_version )
64920bdda8SEd Masteis identical to that on which it was built.
65920bdda8SEd MasteThis declaration should be used by modules which depend on interfaces beyond
66920bdda8SEd Mastethe stable kernel KBI (such as ABI emulators or hypervisors that rely on
67920bdda8SEd Masteinternal kernel structures).
68345432aaSMatt Macy.Fn DECLARE_MODULE
69345432aaSMatt Macywill behave like
70345432aaSMatt Macy.Fn DECLARE_MODULE_TIED
71*55ed6718SBenedict Reuschlingwhen compiled with modules built with the kernel.
72*55ed6718SBenedict ReuschlingThis allows locks and other synchronization primitives
73*55ed6718SBenedict Reuschlingto be inlined safely.
74920bdda8SEd Maste.Pp
75920bdda8SEd MasteThe arguments are:
76c91b6b9eSGiorgos Keramidas.Bl -tag -width indent
77c91b6b9eSGiorgos Keramidas.It Fa name
78c91b6b9eSGiorgos KeramidasThe module name, which will be used in the
79b6a55e7aSAlexander Langer.Fn SYSINIT
80b6a55e7aSAlexander Langercall to identify the module.
81c91b6b9eSGiorgos Keramidas.It Fa data
82c91b6b9eSGiorgos KeramidasA
83b6a55e7aSAlexander Langer.Vt moduledata_t
84b6a55e7aSAlexander Langerstructure, which contains two main items, the official name of the
85b6a55e7aSAlexander Langermodule name, which will be used in the
86b6a55e7aSAlexander Langer.Vt module_t
87b6a55e7aSAlexander Langerstructure and a pointer to the event handler function of type
88b6a55e7aSAlexander Langer.Vt modeventhand_t .
89c91b6b9eSGiorgos Keramidas.It Fa sub
90c91b6b9eSGiorgos KeramidasAn argument directed to the
91b6a55e7aSAlexander Langer.Fn SYSINIT
92b6a55e7aSAlexander Langermacro.
93b6a55e7aSAlexander LangerValid values for this are contained in the
94f7fcafe1SChad David.Vt sysinit_sub_id
95b6a55e7aSAlexander Langerenumeration
96b6a55e7aSAlexander Langer(see
97743d5d51SRuslan Ermilov.In sys/kernel.h )
98b6a55e7aSAlexander Langerand specify the type of system startup interfaces.
99b6a55e7aSAlexander LangerThe
100b6a55e7aSAlexander Langer.Xr DRIVER_MODULE 9
101b6a55e7aSAlexander Langermacro uses a value of
102b6a55e7aSAlexander Langer.Dv SI_SUB_DRIVERS
103b6a55e7aSAlexander Langerhere for example, since these modules contain a driver for a device.
104b6a55e7aSAlexander LangerFor kernel modules that are loaded at runtime, a value of
105b6a55e7aSAlexander Langer.Dv SI_SUB_EXEC
106b6a55e7aSAlexander Langeris common.
107c91b6b9eSGiorgos Keramidas.It Fa order
108c91b6b9eSGiorgos KeramidasAn argument for
109b6a55e7aSAlexander Langer.Fn SYSINIT .
110b6a55e7aSAlexander LangerIt represents the KLDs order of initialization within the subsystem.
111b6a55e7aSAlexander LangerValid values are defined in the
112b6a55e7aSAlexander Langer.Vt sysinit_elem_order
113b6a55e7aSAlexander Langerenumeration
114743d5d51SRuslan Ermilov.Pq In sys/kernel.h .
115c91b6b9eSGiorgos Keramidas.El
116b6a55e7aSAlexander Langer.Sh SEE ALSO
117a8ed195dSAlexander Langer.Xr DEV_MODULE 9 ,
118b6a55e7aSAlexander Langer.Xr DRIVER_MODULE 9 ,
119b6a55e7aSAlexander Langer.Xr module 9 ,
1205521ff5aSRuslan Ermilov.Xr SYSCALL_MODULE 9
1215521ff5aSRuslan Ermilov.Pp
122b6a55e7aSAlexander Langer.Pa /usr/include/sys/kernel.h ,
123b6a55e7aSAlexander Langer.Pa /usr/share/examples/kld
124b6a55e7aSAlexander Langer.Sh AUTHORS
125b6a55e7aSAlexander Langer.An -nosplit
126b6a55e7aSAlexander LangerThis manual page was written by
1278a7314fcSBaptiste Daroussin.An Alexander Langer Aq Mt alex@FreeBSD.org ,
128b6a55e7aSAlexander Langerinspired by the KLD Facility Programming Tutorial by
1298a7314fcSBaptiste Daroussin.An Andrew Reiter Aq Mt arr@watson.org .
130