14777ab97SConrad Meyer.\" Copyright (c) 2018 Conrad Meyer <cem@FreeBSD.org> 24777ab97SConrad Meyer.\" All rights reserved. 34777ab97SConrad Meyer.\" 44777ab97SConrad Meyer.\" Redistribution and use in source and binary forms, with or without 54777ab97SConrad Meyer.\" modification, are permitted provided that the following conditions 64777ab97SConrad Meyer.\" are met: 74777ab97SConrad Meyer.\" 1. Redistributions of source code must retain the above copyright 84777ab97SConrad Meyer.\" notice, this list of conditions and the following disclaimer. 94777ab97SConrad Meyer.\" 2. Redistributions in binary form must reproduce the above copyright 104777ab97SConrad Meyer.\" notice, this list of conditions and the following disclaimer in the 114777ab97SConrad Meyer.\" documentation and/or other materials provided with the distribution. 124777ab97SConrad Meyer.\" 134777ab97SConrad Meyer.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 144777ab97SConrad Meyer.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 154777ab97SConrad Meyer.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 164777ab97SConrad Meyer.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 174777ab97SConrad Meyer.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 184777ab97SConrad Meyer.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 194777ab97SConrad Meyer.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 204777ab97SConrad Meyer.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 214777ab97SConrad Meyer.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 224777ab97SConrad Meyer.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 234777ab97SConrad Meyer.\" SUCH DAMAGE. 244777ab97SConrad Meyer.\" 25*ad018aa4SWarner Losh.Dd May 23, 2019 264777ab97SConrad Meyer.Dt MODULE_PNP_INFO 9 274777ab97SConrad Meyer.Os 284777ab97SConrad Meyer.Sh NAME 294777ab97SConrad Meyer.Nm MODULE_PNP_INFO 304777ab97SConrad Meyer.Nd register plug and play information for device matching 314777ab97SConrad Meyer.\" 324777ab97SConrad Meyer.Sh SYNOPSIS 334777ab97SConrad Meyer.In sys/module.h 344777ab97SConrad Meyer.Fo MODULE_PNP_INFO 354777ab97SConrad Meyer.Fa "const char *descriptor_string" 364777ab97SConrad Meyer.Fa "bus" 374777ab97SConrad Meyer.Fa "module" 384777ab97SConrad Meyer.Fa "void *table" 394777ab97SConrad Meyer.Fa "size_t num_entries" 404777ab97SConrad Meyer.Fc 414777ab97SConrad Meyer.\" 424777ab97SConrad Meyer.Sh DESCRIPTION 434777ab97SConrad MeyerThe 444777ab97SConrad Meyer.Fn MODULE_PNP_INFO 454777ab97SConrad Meyermacro registers a 464777ab97SConrad Meyer.Fa table 474777ab97SConrad Meyerof device-identifying data for use by 484777ab97SConrad Meyer.Xr devmatch 8 . 49e05b3850SWarner LoshSince it is built off module marking macros, it must follow a 50e05b3850SWarner Losh.Xr DRIVER_MODULE 9 51e05b3850SWarner Loshline. 524777ab97SConrad Meyer.Pp 534777ab97SConrad MeyerThe macro takes a 544777ab97SConrad Meyer.Fa descriptor_string 554777ab97SConrad Meyerthat describes the memory layout of table entries. 564777ab97SConrad MeyerThe string is a series of members separated by semi-colons. 574777ab97SConrad MeyerMembers are identified by a type and a name. 584777ab97SConrad MeyerThey are encoded in the descriptor string by concatenating the type with a 594777ab97SConrad Meyercolon, followed by the name. 604777ab97SConrad Meyer(The special type 614777ab97SConrad Meyer.Vt W32 624777ab97SConrad Meyerrepresents two members. 634777ab97SConrad MeyerThe first name is encoded like any other type. 644777ab97SConrad MeyerThe second name is encoded by appending a forward slash and the second 654777ab97SConrad Meyername after the first.) 664777ab97SConrad Meyer.Pp 674777ab97SConrad MeyerTypes are one of the following: 684777ab97SConrad Meyer.Bl -tag -width U16 694777ab97SConrad Meyer.It Dq Vt U8 704777ab97SConrad Meyer.Vt uint8_t 714777ab97SConrad Meyerelement. 724777ab97SConrad Meyer.It Dq Vt V8 734777ab97SConrad MeyerSame as 744777ab97SConrad Meyer.Vt U8 , 754777ab97SConrad Meyerexcept that the sentinel value 0xFF matches any. 764777ab97SConrad Meyer.It Dq Vt G16 774777ab97SConrad Meyer.Vt uint16_t 784777ab97SConrad Meyerelement; any value greater than or equal matches. 794777ab97SConrad Meyer.It Dq Vt L16 804777ab97SConrad Meyer.Vt uint16_t 814777ab97SConrad Meyerelement; any value less than or equal matches. 824777ab97SConrad Meyer.It Dq Vt M16 834777ab97SConrad Meyer.Vt uint16_t 844777ab97SConrad Meyerelement; mask of which of the following fields to use. 854777ab97SConrad Meyer.It Dq Vt U16 864777ab97SConrad Meyer.Vt uint16_t 874777ab97SConrad Meyerelement. 884777ab97SConrad Meyer.It Dq Vt V16 894777ab97SConrad MeyerSame as 904777ab97SConrad Meyer.Vt U16 , 914777ab97SConrad Meyerexcept that the sentinel value 0xFFFF matches any. 924777ab97SConrad Meyer.It Dq Vt U32 934777ab97SConrad Meyer.Vt uint32_t 944777ab97SConrad Meyerelement. 954777ab97SConrad Meyer.It Dq Vt V32 964777ab97SConrad MeyerSame as 974777ab97SConrad Meyer.Vt U32 , 984777ab97SConrad Meyerexcept that the sentinel value 0xFFFFFFFF matches any. 994777ab97SConrad Meyer.It Dq Vt W32 1004777ab97SConrad MeyerTwo 1014777ab97SConrad Meyer.Vt uint16_t 1024777ab97SConrad Meyervalues; the first named member is in the least significant word and the second 1034777ab97SConrad Meyernamed member is in the most significant word. 1044777ab97SConrad Meyer.It Dq Vt Z 1054777ab97SConrad MeyerA pointer to a string to match exactly. 1064777ab97SConrad Meyer.It Dq Vt D 1074777ab97SConrad MeyerA pointer to a human readable description for the device. 1084777ab97SConrad Meyer.It Dq Vt P 1094777ab97SConrad MeyerA pointer that should be ignored. 1104777ab97SConrad Meyer.It Dq Vt E 1114777ab97SConrad MeyerEISA PNP Identifier. 11248c1581dSWarner Losh.It Dq Vt T 1133ace1709SMateusz PiotrowskiPNP info that is true for the whole table. 11448c1581dSWarner LoshThe driver code checks for these condition pragmatically before using 11548c1581dSWarner Loshthis table to match devices. 11648c1581dSWarner LoshThis item must come last in the list. 1174777ab97SConrad Meyer.El 1184777ab97SConrad Meyer.Pp 1194777ab97SConrad MeyerThe pseudo-name 1204777ab97SConrad Meyer.Dq # 1214777ab97SConrad Meyeris reserved for fields that should be ignored. 1224777ab97SConrad MeyerAny member that does not match the parent device's pnpinfo output must be 1234777ab97SConrad Meyerignored. 1244777ab97SConrad Meyer.Pp 1254777ab97SConrad MeyerThe 1264777ab97SConrad Meyer.Fa bus 1274777ab97SConrad Meyerparameter is an unquoted word naming the parent bus of the driver. 1284777ab97SConrad MeyerFor example, 1294777ab97SConrad Meyer.Dq pci . 1304777ab97SConrad Meyer.Pp 1314777ab97SConrad MeyerThe 1324777ab97SConrad Meyer.Fa module 1334777ab97SConrad Meyerparameter is also an unquoted word. 1344777ab97SConrad MeyerIt must be unique to the driver. 1354777ab97SConrad MeyerUsually the driver's name is used. 1364777ab97SConrad Meyer.Pp 1374777ab97SConrad MeyerThe 1384777ab97SConrad Meyer.Fa table 1394777ab97SConrad Meyerparameter points to the device matching data with entries matching the 1404777ab97SConrad Meyer.Fa descriptor_string . 1414777ab97SConrad Meyer.Pp 1424777ab97SConrad MeyerThe 1434777ab97SConrad Meyer.Fa num_entries 1444777ab97SConrad Meyerparameter is the number of entries in the table, i.e., 1454777ab97SConrad Meyer.Ql nitems(table) . 1464777ab97SConrad MeyerNote that only valid entries should be included. 1474777ab97SConrad MeyerIf the table contains trailing zero or bogus values, they should not be 1484777ab97SConrad Meyerincluded in 1494777ab97SConrad Meyer.Fa num_entries . 1504777ab97SConrad Meyer.\" 1514777ab97SConrad Meyer.Sh EXAMPLES 152c6a3ec2bSMateusz Piotrowski.Bl -tag -width "" 153c6a3ec2bSMateusz Piotrowski.It Sy Example 1\&: No Using W32 for vendor/device pair 154c6a3ec2bSMateusz Piotrowski.Pp 155c6a3ec2bSMateusz PiotrowskiThe following example shows usage of 156c6a3ec2bSMateusz Piotrowski.Vt W32 157c6a3ec2bSMateusz Piotrowskitype when vendor/device values are combined into single 158c6a3ec2bSMateusz Piotrowski.Vt uint32_t 159c6a3ec2bSMateusz Piotrowskivalue: 160c6a3ec2bSMateusz Piotrowski.Bd -literal 1614777ab97SConrad Meyer#include <sys/param.h> 1624777ab97SConrad Meyer#include <sys/module.h> 163c6a3ec2bSMateusz Piotrowski 1644777ab97SConrad Meyerstatic struct my_pciids { 1654777ab97SConrad Meyer uint32_t devid; 1664777ab97SConrad Meyer const char *desc; 1674777ab97SConrad Meyer} my_ids[] = { 1684777ab97SConrad Meyer { 0x12345678, "Foo bar" }, 1694777ab97SConrad Meyer { 0x9abcdef0, "Baz fizz" }, 1704777ab97SConrad Meyer}; 171e05b3850SWarner Losh 172c6a3ec2bSMateusz PiotrowskiMODULE_PNP_INFO("W32:vendor/device;D:#", pci, my_driver, my_ids, 173e571849dSYuri Pankov nitems(my_ids)); 1744777ab97SConrad Meyer.Ed 175c6a3ec2bSMateusz Piotrowski.It Sy Example 2\&: No Using T for common vendor value 176c6a3ec2bSMateusz Piotrowski.Pp 177c6a3ec2bSMateusz PiotrowskiThe following example shows usage of 178c6a3ec2bSMateusz Piotrowski.Vt T 179c6a3ec2bSMateusz Piotrowskitype when all entries in the table have the same vendor value: 180c6a3ec2bSMateusz Piotrowski.Bd -literal 181c6a3ec2bSMateusz Piotrowski#include <sys/param.h> 182c6a3ec2bSMateusz Piotrowski#include <sys/module.h> 183c6a3ec2bSMateusz Piotrowski 184c6a3ec2bSMateusz Piotrowskistatic struct my_pciids { 185c6a3ec2bSMateusz Piotrowski uint16_t device; 186c6a3ec2bSMateusz Piotrowski const char *desc; 187c6a3ec2bSMateusz Piotrowski} my_ids[] = { 188c6a3ec2bSMateusz Piotrowski { 0x9abc, "Foo bar" }, 189c6a3ec2bSMateusz Piotrowski { 0xdef0, "Baz fizz" }, 190c6a3ec2bSMateusz Piotrowski}; 191c6a3ec2bSMateusz Piotrowski 192c6a3ec2bSMateusz PiotrowskiMODULE_PNP_INFO("U16:device;D:#;T:vendor=0x1234", pci, my_driver, 193e571849dSYuri Pankov my_ids, nitems(my_ids)); 194c6a3ec2bSMateusz Piotrowski.Ed 195c6a3ec2bSMateusz Piotrowski.El 1964777ab97SConrad Meyer.\" 197*ad018aa4SWarner Losh.Sh BUGS 198*ad018aa4SWarner LoshThe 199*ad018aa4SWarner Losh.Nm 200*ad018aa4SWarner Loshmacro must follow 201*ad018aa4SWarner Losh.Dv DRIVER_MODULE 202*ad018aa4SWarner Loshinvocations due to limitations in the 203*ad018aa4SWarner Losh.Dv linker.hints 204*ad018aa4SWarner Loshfile format. 2054777ab97SConrad Meyer.Sh SEE ALSO 206c6a3ec2bSMateusz Piotrowski.Xr devmatch 8 , 2074777ab97SConrad Meyer.Xr DRIVER_MODULE 9 , 208c6a3ec2bSMateusz Piotrowski.Xr module 9 2094777ab97SConrad Meyer.Sh HISTORY 2104777ab97SConrad MeyerThe macro 2114777ab97SConrad Meyer.Nm 2124777ab97SConrad Meyerappeared in 213e05b3850SWarner Losh.Fx 11.0 . 2144777ab97SConrad Meyer.Sh AUTHORS 2154777ab97SConrad MeyerThe PNP framework and 2164777ab97SConrad Meyer.Xr devmatch 8 2174777ab97SConrad Meyerutility were written by 2184777ab97SConrad Meyer.An Warner Losh Aq Mt imp@FreeBSD.org . 219