]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/man/man9/DRIVER_MODULE.9
dtrace: Add WITH_DTRACE_ASAN
[FreeBSD/FreeBSD.git] / share / man / man9 / DRIVER_MODULE.9
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 April 19, 2022
32 .Dt DRIVER_MODULE 9
33 .Os
34 .Sh NAME
35 .Nm DRIVER_MODULE ,
36 .Nm DRIVER_MODULE_ORDERED ,
37 .Nm EARLY_DRIVER_MODULE ,
38 .Nm EARLY_DRIVER_MODULE_ORDERED
39 .Nd kernel driver declaration macro
40 .Sh SYNOPSIS
41 .In sys/param.h
42 .In sys/kernel.h
43 .In sys/bus.h
44 .In sys/module.h
45 .Fn DRIVER_MODULE name busname "driver_t driver" "modeventhand_t evh" "void *arg"
46 .Fn DRIVER_MODULE_ORDERED name busname "driver_t driver" "modeventhand_t evh" "void *arg" "int order"
47 .Fn EARLY_DRIVER_MODULE name busname "driver_t driver" "modeventhand_t evh" "void *arg" "int pass"
48 .Fn EARLY_DRIVER_MODULE_ORDERED name busname "driver_t driver" "modeventhand_t evh" "void *arg" "enum sysinit_elem_order order" "int pass"
49 .Sh DESCRIPTION
50 The
51 .Fn DRIVER_MODULE
52 macro declares a kernel driver.
53 .Fn DRIVER_MODULE
54 expands to the real driver declaration, where the phrase
55 .Fa name
56 is used as the naming prefix for the driver and its functions.
57 Note that it is supplied as plain text, and not a
58 .Li char
59 or
60 .Li char * .
61 .Pp
62 .Fa busname
63 is the parent bus of the driver (PCI, ISA, PPBUS and others), e.g.\&
64 .Ql pci ,
65 .Ql isa ,
66 or
67 .Ql ppbus .
68 .Pp
69 The identifier used in
70 .Fn DRIVER_MODULE
71 can be different from the driver name.
72 Also, the same driver identifier can exist on different buses,
73 which is a pretty clean way of making front ends for different cards
74 using the same driver on the same or different buses.
75 For example, the following is allowed:
76 .Pp
77 .Fn DRIVER_MODULE foo isa foo_driver NULL NULL ;
78 .Pp
79 .Fn DRIVER_MODULE foo pci foo_driver NULL NULL ;
80 .Pp
81 .Fa driver
82 is the driver of type
83 .Li driver_t ,
84 which contains the information about the driver and is therefore one of the
85 two most important parts of the call to
86 .Fn DRIVER_MODULE .
87 .Pp
88 The
89 .Fa evh
90 argument is the event handler which is called when the driver (or module)
91 is loaded or unloaded (see
92 .Xr module 9 ) .
93 .Pp
94 The
95 .Fa arg
96 is unused at this time and should be a
97 .Dv NULL
98 pointer.
99 .Pp
100 The
101 .Fn DRIVER_MODULE_ORDERED
102 macro allows a driver to be registered in a specific order.
103 This can be useful if a single kernel module contains multiple drivers
104 that are inter-dependent.
105 The
106 .Fa order
107 argument should be one of the
108 .Xr SYSINIT 9
109 initialization ordering constants
110 .Pq Dv SI_ORDER_* .
111 The default order for a driver module is
112 .Dv SI_ORDER_MIDDLE .
113 Typically a module will specify an order of
114 .Dv SI_ORDER_ANY
115 for a single driver to ensure it is registered last.
116 .Pp
117 The
118 .Fn EARLY_DRIVER_MODULE
119 macro allows a driver to be registered for a specific pass level.
120 The boot time probe and attach process makes multiple passes over the
121 device tree.
122 Certain critical drivers that provide basic services needed by other
123 devices are attached during earlier passes.
124 Most drivers are attached in a final general pass.
125 A driver that attaches during an early pass must register for a specific
126 pass level
127 .Pq BUS_PASS_*
128 via the
129 .Fa pass
130 argument.
131 Once a driver is registered it is available to attach to devices for
132 all subsequent passes.
133 .Pp
134 The
135 .Fn EARLY_DRIVER_MODULE_ORDERED
136 macro allows a driver to be registered both in a specific order and
137 for a specific pass level.
138 .Sh SEE ALSO
139 .Xr device 9 ,
140 .Xr driver 9 ,
141 .Xr module 9 ,
142 .Xr MODULE_PNP_INFO 9 ,
143 .Xr SYSINIT 9
144 .Sh HISTORY
145 Prior to
146 .Fx 14.0 ,
147 these macros accepted an additional
148 .Vt devclass_t
149 argument after
150 .Fa driver .
151 .Sh AUTHORS
152 This manual page was written by
153 .An Alexander Langer Aq Mt alex@FreeBSD.org .