]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/man/man9/MODULE_PNP_INFO.9
MFV r331706:
[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 February 12, 2018
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 entry_len"
42 .Fa "size_t num_entries"
43 .Fc
44 .\"
45 .Sh DESCRIPTION
46 The
47 .Fn MODULE_PNP_INFO
48 macro registers a
49 .Fa table
50 of device-identifying data for use by
51 .Xr devmatch 8 .
52 Since it is built off module marking macros, it must follow a
53 .Xr DRIVER_MODULE 9
54 line.
55 .Pp
56 The macro takes a
57 .Fa descriptor_string
58 that describes the memory layout of table entries.
59 The string is a series of members separated by semi-colons.
60 Members are identified by a type and a name.
61 They are encoded in the descriptor string by concatenating the type with a
62 colon, followed by the name.
63 (The special type
64 .Vt W32
65 represents two members.
66 The first name is encoded like any other type.
67 The second name is encoded by appending a forward slash and the second
68 name after the first.)
69 .Pp
70 Types are one of the following:
71 .Bl -tag -width U16
72 .It Dq Vt U8
73 .Vt uint8_t
74 element.
75 .It Dq Vt V8
76 Same as
77 .Vt U8 ,
78 except that the sentinel value 0xFF matches any.
79 .It Dq Vt G16
80 .Vt uint16_t
81 element; any value greater than or equal matches.
82 .It Dq Vt L16
83 .Vt uint16_t
84 element; any value less than or equal matches.
85 .It Dq Vt M16
86 .Vt uint16_t
87 element; mask of which of the following fields to use.
88 .It Dq Vt U16
89 .Vt uint16_t
90 element.
91 .It Dq Vt V16
92 Same as
93 .Vt U16 ,
94 except that the sentinel value 0xFFFF matches any.
95 .It Dq Vt U32
96 .Vt uint32_t
97 element.
98 .It Dq Vt V32
99 Same as
100 .Vt U32 ,
101 except that the sentinel value 0xFFFFFFFF matches any.
102 .It Dq Vt W32
103 Two
104 .Vt uint16_t
105 values; the first named member is in the least significant word and the second
106 named member is in the most significant word.
107 .It Dq Vt Z
108 A pointer to a string to match exactly.
109 .It Dq Vt D
110 A pointer to a human readable description for the device.
111 .It Dq Vt P
112 A pointer that should be ignored.
113 .It Dq Vt E
114 EISA PNP Identifier.
115 .It Dq Vt T
116 PNP info that's true for the for the whole table.
117 The driver code checks for these condition pragmatically before using
118 this table to match devices.
119 This item must come last in the list.
120 .El
121 .Pp
122 The pseudo-name
123 .Dq #
124 is reserved for fields that should be ignored.
125 Any member that does not match the parent device's pnpinfo output must be
126 ignored.
127 .Pp
128 The
129 .Fa bus
130 parameter is an unquoted word naming the parent bus of the driver.
131 For example,
132 .Dq pci .
133 .Pp
134 The
135 .Fa module
136 parameter is also an unquoted word.
137 It must be unique to the driver.
138 Usually the driver's name is used.
139 .Pp
140 The
141 .Fa table
142 parameter points to the device matching data with entries matching the
143 .Fa descriptor_string .
144 .Pp
145 The
146 .Fa entry_len
147 parameter is the size of each table entry, i.e.,
148 .Ql sizeof(table[0]) .
149 .Pp
150 The
151 .Fa num_entries
152 parameter is the number of entries in the table, i.e.,
153 .Ql nitems(table) .
154 Note that only valid entries should be included.
155 If the table contains trailing zero or bogus values, they should not be
156 included in
157 .Fa num_entries .
158 .\"
159 .Sh EXAMPLES
160 .Bd -literal -offset indent -compact
161 #include <sys/param.h>
162 #include <sys/module.h>
163 static struct my_pciids {
164         uint32_t devid;
165         const char *desc;
166 } my_ids[] = {
167         { 0x12345678, "Foo bar" },
168         { 0x9abcdef0, "Baz fizz" },
169 };
170
171 MODULE_PNP_INFO("W32:vendor/device", pci, my_driver, my_ids, sizeof(my_ids[0]),
172     nitems(my_ids));
173 .Ed
174 .\"
175 .Sh SEE ALSO
176 .Xr module 9 ,
177 .Xr DRIVER_MODULE 9 ,
178 .Xr devmatch 8
179 .Sh HISTORY
180 The macro
181 .Nm
182 appeared in
183 .Fx 11.0 .
184 .Sh AUTHORS
185 The PNP framework and
186 .Xr devmatch 8
187 utility were written by
188 .An Warner Losh Aq Mt imp@FreeBSD.org .