]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/man/man9/MODULE_PNP_INFO.9
bhnd(9): Fix a few mandoc related issues
[FreeBSD/FreeBSD.git] / share / man / man9 / MODULE_PNP_INFO.9
1 .\" Copyright (c) 2018 Conrad Meyer <cem@FreeBSD.org>
2 .\" All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\"
13 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23 .\" SUCH DAMAGE.
24 .\"
25 .\" $FreeBSD$
26 .\"
27 .Dd May 23, 2019
28 .Dt MODULE_PNP_INFO 9
29 .Os
30 .Sh NAME
31 .Nm MODULE_PNP_INFO
32 .Nd register plug and play information for device matching
33 .\"
34 .Sh SYNOPSIS
35 .In sys/module.h
36 .Fo MODULE_PNP_INFO
37 .Fa "const char *descriptor_string"
38 .Fa "bus"
39 .Fa "module"
40 .Fa "void *table"
41 .Fa "size_t num_entries"
42 .Fc
43 .\"
44 .Sh DESCRIPTION
45 The
46 .Fn MODULE_PNP_INFO
47 macro registers a
48 .Fa table
49 of device-identifying data for use by
50 .Xr devmatch 8 .
51 Since it is built off module marking macros, it must follow a
52 .Xr DRIVER_MODULE 9
53 line.
54 .Pp
55 The macro takes a
56 .Fa descriptor_string
57 that describes the memory layout of table entries.
58 The string is a series of members separated by semi-colons.
59 Members are identified by a type and a name.
60 They are encoded in the descriptor string by concatenating the type with a
61 colon, followed by the name.
62 (The special type
63 .Vt W32
64 represents two members.
65 The first name is encoded like any other type.
66 The second name is encoded by appending a forward slash and the second
67 name after the first.)
68 .Pp
69 Types are one of the following:
70 .Bl -tag -width U16
71 .It Dq Vt U8
72 .Vt uint8_t
73 element.
74 .It Dq Vt V8
75 Same as
76 .Vt U8 ,
77 except that the sentinel value 0xFF matches any.
78 .It Dq Vt G16
79 .Vt uint16_t
80 element; any value greater than or equal matches.
81 .It Dq Vt L16
82 .Vt uint16_t
83 element; any value less than or equal matches.
84 .It Dq Vt M16
85 .Vt uint16_t
86 element; mask of which of the following fields to use.
87 .It Dq Vt U16
88 .Vt uint16_t
89 element.
90 .It Dq Vt V16
91 Same as
92 .Vt U16 ,
93 except that the sentinel value 0xFFFF matches any.
94 .It Dq Vt U32
95 .Vt uint32_t
96 element.
97 .It Dq Vt V32
98 Same as
99 .Vt U32 ,
100 except that the sentinel value 0xFFFFFFFF matches any.
101 .It Dq Vt W32
102 Two
103 .Vt uint16_t
104 values; the first named member is in the least significant word and the second
105 named member is in the most significant word.
106 .It Dq Vt Z
107 A pointer to a string to match exactly.
108 .It Dq Vt D
109 A pointer to a human readable description for the device.
110 .It Dq Vt P
111 A pointer that should be ignored.
112 .It Dq Vt E
113 EISA PNP Identifier.
114 .It Dq Vt T
115 PNP info that is true for the whole table.
116 The driver code checks for these condition pragmatically before using
117 this table to match devices.
118 This item must come last in the list.
119 .El
120 .Pp
121 The pseudo-name
122 .Dq #
123 is reserved for fields that should be ignored.
124 Any member that does not match the parent device's pnpinfo output must be
125 ignored.
126 .Pp
127 The
128 .Fa bus
129 parameter is an unquoted word naming the parent bus of the driver.
130 For example,
131 .Dq pci .
132 .Pp
133 The
134 .Fa module
135 parameter is also an unquoted word.
136 It must be unique to the driver.
137 Usually the driver's name is used.
138 .Pp
139 The
140 .Fa table
141 parameter points to the device matching data with entries matching the
142 .Fa descriptor_string .
143 .Pp
144 The
145 .Fa num_entries
146 parameter is the number of entries in the table, i.e.,
147 .Ql nitems(table) .
148 Note that only valid entries should be included.
149 If the table contains trailing zero or bogus values, they should not be
150 included in
151 .Fa num_entries .
152 .\"
153 .Sh EXAMPLES
154 .Bl -tag -width ""
155 .It Sy Example 1\&: No Using W32 for vendor/device pair
156 .Pp
157 The following example shows usage of
158 .Vt W32
159 type when vendor/device values are combined into single
160 .Vt uint32_t
161 value:
162 .Bd -literal
163 #include <sys/param.h>
164 #include <sys/module.h>
165
166 static struct my_pciids {
167         uint32_t devid;
168         const char *desc;
169 } my_ids[] = {
170         { 0x12345678, "Foo bar" },
171         { 0x9abcdef0, "Baz fizz" },
172 };
173
174 MODULE_PNP_INFO("W32:vendor/device;D:#", pci, my_driver, my_ids,
175     nitems(my_ids));
176 .Ed
177 .It Sy Example 2\&: No Using T for common vendor value
178 .Pp
179 The following example shows usage of
180 .Vt T
181 type when all entries in the table have the same vendor value:
182 .Bd -literal
183 #include <sys/param.h>
184 #include <sys/module.h>
185
186 static struct my_pciids {
187         uint16_t device;
188         const char *desc;
189 } my_ids[] = {
190         { 0x9abc, "Foo bar" },
191         { 0xdef0, "Baz fizz" },
192 };
193
194 MODULE_PNP_INFO("U16:device;D:#;T:vendor=0x1234", pci, my_driver,
195     my_ids, nitems(my_ids));
196 .Ed
197 .El
198 .\"
199 .Sh BUGS
200 The
201 .Nm
202 macro must follow
203 .Dv DRIVER_MODULE
204 invocations due to limitations in the
205 .Dv linker.hints
206 file format.
207 .Sh SEE ALSO
208 .Xr devmatch 8 ,
209 .Xr DRIVER_MODULE 9 ,
210 .Xr module 9
211 .Sh HISTORY
212 The macro
213 .Nm
214 appeared in
215 .Fx 11.0 .
216 .Sh AUTHORS
217 The PNP framework and
218 .Xr devmatch 8
219 utility were written by
220 .An Warner Losh Aq Mt imp@FreeBSD.org .