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