]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - share/man/man9/DRIVER_MODULE.9
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.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 August 21, 2012
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" "devclass_t devclass" "modeventhand_t evh" "void *arg"
46 .Fn DRIVER_MODULE_ORDERED name busname "driver_t driver" "devclass_t devclass" "modeventhand_t evh" "void *arg" "int order"
47 .Fn EARLY_DRIVER_MODULE name busname "driver_t driver" "devclass_t devclass" "modeventhand_t evh" "void *arg" "enum sysinit_elem_order order" "int pass"
48 .Fn EARLY_DRIVER_MODULE_ORDERED name busname "driver_t driver" "devclass_t devclass" "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 busses,
73 which is a pretty clean way of making front ends for different cards
74 using the same driver on the same or different busses.
75 For example, the following is allowed:
76 .Pp
77 .Fn DRIVER_MODULE foo isa foo_driver foo_devclass NULL NULL ;
78 .Pp
79 .Fn DRIVER_MODULE foo pci foo_driver foo_devclass 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 devclass
90 argument contains the kernel-internal information about the device,
91 which will be used within the kernel driver module.
92 .Pp
93 The
94 .Fa evh
95 argument is the event handler which is called when the driver (or module)
96 is loaded or unloaded (see
97 .Xr module 9 ) .
98 .Pp
99 The
100 .Fa arg
101 is unused at this time and should be a
102 .Dv NULL
103 pointer.
104 .Pp
105 The
106 .Fn DRIVER_MODULE_ORDERED
107 macro allows a driver to be registered in a specific order.
108 This can be useful if a single kernel module contains multiple drivers
109 that are inter-dependent.
110 The
111 .Fa order
112 argument should be one of the
113 .Xr SYSINIT 9
114 initialization ordering constants
115 .Pq Dv SI_ORDER_* .
116 The default order for a driver module is
117 .Dv SI_ORDER_MIDDLE .
118 Typically a module will specify an order of
119 .Dv SI_ORDER_ANY
120 for a single driver to ensure it is registered last.
121 .Pp
122 The
123 .Fn EARLY_DRIVER_MODULE
124 macro allows a driver to be registered for a specific pass level.
125 The boot time probe and attach process makes multiple passes over the
126 device tree.
127 Certain critical drivers that provide basic services needed by other
128 devices are attach during earlier passes.
129 Most drivers are attached in a final general pass.
130 A driver that attaches during an early pass must register for a specific
131 pass level
132 .Pq BUS_PASS_*
133 via the
134 .Fa pass
135 argument.
136 Once a driver is registered it is available to attach to devices for
137 all subsequent passes.
138 .Pp
139 The
140 .Fn EARLY_DRIVER_MODULE_ORDERED
141 macro allows a driver to be registered both in a specific order and
142 for a specific pass level.
143 .Sh SEE ALSO
144 .Xr device 9 ,
145 .Xr driver 9 ,
146 .Xr module 9 ,
147 .Xr SYSINIT 9
148 .Sh AUTHORS
149 This manual page was written by
150 .An Alexander Langer Aq alex@FreeBSD.org .