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