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
|
<table class="head">
<tr>
<td class="head-ltitle">MODULE_PNP_INFO(9)</td>
<td class="head-vol">Kernel Developer's Manual</td>
<td class="head-rtitle">MODULE_PNP_INFO(9)</td>
</tr>
</table>
<div class="manual-text">
<section class="Sh">
<h1 class="Sh" id="NAME"><a class="permalink" href="#NAME">NAME</a></h1>
<p class="Pp"><code class="Nm">MODULE_PNP_INFO</code> —
<span class="Nd">register plug and play information for device
matching</span></p>
</section>
<section class="Sh">
<h1 class="Sh" id="SYNOPSIS"><a class="permalink" href="#SYNOPSIS">SYNOPSIS</a></h1>
<p class="Pp"><code class="In">#include
<<a class="In">sys/module.h</a>></code></p>
<p class="Pp"><code class="Fn">MODULE_PNP_INFO</code>(<var class="Fa">const char
*descriptor_string</var>, <var class="Fa">bus</var>,
<var class="Fa">module</var>, <var class="Fa">void *table</var>,
<var class="Fa">size_t num_entries</var>);</p>
</section>
<section class="Sh">
<h1 class="Sh" id="DESCRIPTION"><a class="permalink" href="#DESCRIPTION">DESCRIPTION</a></h1>
<p class="Pp">The
<a class="permalink" href="#MODULE_PNP_INFO"><code class="Fn" id="MODULE_PNP_INFO">MODULE_PNP_INFO</code></a>()
macro registers a <var class="Fa">table</var> of device-identifying data for
use by <a class="Xr">devmatch(8)</a>. Since it is built off module marking
macros, it must follow a <a class="Xr">DRIVER_MODULE(9)</a> line.</p>
<p class="Pp">The macro takes a <var class="Fa">descriptor_string</var> 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
<var class="Vt">W32</var> 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.)</p>
<p class="Pp">Types are one of the following:</p>
<dl class="Bl-tag">
<dt>“<var class="Vt">U8</var>”</dt>
<dd><var class="Vt">uint8_t</var> element.</dd>
<dt>“<var class="Vt">V8</var>”</dt>
<dd>Same as <var class="Vt">U8</var>, except that the sentinel value 0xFF
matches any.</dd>
<dt>“<var class="Vt">G16</var>”</dt>
<dd><var class="Vt">uint16_t</var> element; any value greater than or equal
matches.</dd>
<dt>“<var class="Vt">L16</var>”</dt>
<dd><var class="Vt">uint16_t</var> element; any value less than or equal
matches.</dd>
<dt>“<var class="Vt">M16</var>”</dt>
<dd><var class="Vt">uint16_t</var> element; mask of which of the following
fields to use.</dd>
<dt>“<var class="Vt">U16</var>”</dt>
<dd><var class="Vt">uint16_t</var> element.</dd>
<dt>“<var class="Vt">V16</var>”</dt>
<dd>Same as <var class="Vt">U16</var>, except that the sentinel value 0xFFFF
matches any.</dd>
<dt>“<var class="Vt">U32</var>”</dt>
<dd><var class="Vt">uint32_t</var> element.</dd>
<dt>“<var class="Vt">V32</var>”</dt>
<dd>Same as <var class="Vt">U32</var>, except that the sentinel value
0xFFFFFFFF matches any.</dd>
<dt>“<var class="Vt">W32</var>”</dt>
<dd>Two <var class="Vt">uint16_t</var> values; the first named member is in
the least significant word and the second named member is in the most
significant word.</dd>
<dt>“<var class="Vt">Z</var>”</dt>
<dd>A pointer to a string to match exactly.</dd>
<dt>“<var class="Vt">D</var>”</dt>
<dd>A pointer to a human readable description for the device.</dd>
<dt>“<var class="Vt">P</var>”</dt>
<dd>A pointer that should be ignored.</dd>
<dt>“<var class="Vt">E</var>”</dt>
<dd>EISA PNP Identifier.</dd>
<dt>“<var class="Vt">T</var>”</dt>
<dd>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.</dd>
</dl>
<p class="Pp">The pseudo-name “#” is reserved for fields that
should be ignored. Any member that does not match the parent device's
pnpinfo output must be ignored.</p>
<p class="Pp">The <var class="Fa">bus</var> parameter is an unquoted word naming
the parent bus of the driver. For example, “pci”.</p>
<p class="Pp">The <var class="Fa">module</var> parameter is also an unquoted
word. It must be unique to the driver. Usually the driver's name is
used.</p>
<p class="Pp">The <var class="Fa">table</var> parameter points to the device
matching data with entries matching the
<var class="Fa">descriptor_string</var>.</p>
<p class="Pp">The <var class="Fa">num_entries</var> parameter is the number of
entries in the table, i.e.,
‘<code class="Li">nitems(table)</code>’. Note that only valid
entries should be included. If the table contains trailing zero or bogus
values, they should not be included in
<var class="Fa">num_entries</var>.</p>
</section>
<section class="Sh">
<h1 class="Sh" id="EXAMPLES"><a class="permalink" href="#EXAMPLES">EXAMPLES</a></h1>
<dl class="Bl-tag">
<dt id="Example"><a class="permalink" href="#Example"><b class="Sy">Example
1:</b></a> <span class="No">Using W32 for vendor/device pair</span></dt>
<dd>
<p class="Pp">The following example shows usage of <var class="Vt">W32</var>
type when vendor/device values are combined into single
<var class="Vt">uint32_t</var> value:</p>
<div class="Bd Pp Li">
<pre>#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));</pre>
</div>
</dd>
<dt id="Example~2"><a class="permalink" href="#Example~2"><b class="Sy">Example
2:</b></a> <span class="No">Using T for common vendor value</span></dt>
<dd>
<p class="Pp">The following example shows usage of <var class="Vt">T</var>
type when all entries in the table have the same vendor value:</p>
<div class="Bd Pp Li">
<pre>#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));</pre>
</div>
</dd>
</dl>
</section>
<section class="Sh">
<h1 class="Sh" id="BUGS"><a class="permalink" href="#BUGS">BUGS</a></h1>
<p class="Pp">The <code class="Nm">MODULE_PNP_INFO</code> macro must follow
<code class="Dv">DRIVER_MODULE</code> invocations due to limitations in the
<code class="Dv">linker.hints</code> file format.</p>
</section>
<section class="Sh">
<h1 class="Sh" id="SEE_ALSO"><a class="permalink" href="#SEE_ALSO">SEE
ALSO</a></h1>
<p class="Pp"><a class="Xr">devmatch(8)</a>, <a class="Xr">DRIVER_MODULE(9)</a>,
<a class="Xr">module(9)</a></p>
</section>
<section class="Sh">
<h1 class="Sh" id="HISTORY"><a class="permalink" href="#HISTORY">HISTORY</a></h1>
<p class="Pp">The macro <code class="Nm">MODULE_PNP_INFO</code> appeared in
<span class="Ux">FreeBSD 11.0</span>.</p>
</section>
<section class="Sh">
<h1 class="Sh" id="AUTHORS"><a class="permalink" href="#AUTHORS">AUTHORS</a></h1>
<p class="Pp">The PNP framework and <a class="Xr">devmatch(8)</a> utility were
written by <span class="An">Warner Losh</span>
<<a class="Mt" href="mailto:imp@FreeBSD.org">imp@FreeBSD.org</a>>.</p>
</section>
</div>
<table class="foot">
<tr>
<td class="foot-date">May 23, 2019</td>
<td class="foot-os">FreeBSD 15.0</td>
</tr>
</table>
|