MODULE_PNP_INFO(9)
π MODULE_PNP_INFO(9) β the Kernel Developer's Manual, but make it cute π
Okay so bestie, welcome to the MODULE_PNP_INFO(9) page, which is literally from the Kernel Developer's Manual and it's all about registering plug and play information for device matching. No cap, this is the macro that makes your devices get recognized. Let's get into it.
β¨ SYNOPSIS β¨
#include <sys/module.h>
MODULE_PNP_INFO(const char *descriptor_string, bus, module, void *table,
size_t num_entries);
πΈ DESCRIPTION πΈ
So like, the MODULE_PNP_INFO() macro registers a table of device-identifying data for use by devmatch(8). Slay. But because it's built off module marking macros, it must follow a DRIVER_MODULE(9) line. No skipping that part, bestie.
The macro takes a 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 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.)
Types are one of the following:
"U8"βuint8_telement."V8"β Same asU8, except that the sentinel value0xFFmatches any."G16"βuint16_telement; any value greater than or equal matches."L16"βuint16_telement; any value less than or equal matches."M16"βuint16_telement; mask of which of the following fields to use."U16"βuint16_telement."V16"β Same asU16, except that the sentinel value0xFFFFmatches any."U32"βuint32_telement."V32"β Same asU32, except that the sentinel value0xFFFFFFFFmatches any."W32"β Twouint16_tvalues; the first named member is in the least significant word and the second named member is in the most significant word."Z"β A pointer to a string to match exactly."D"β A pointer to a human readable description for the device."P"β A pointer that should be ignored."E"β EISA PNP Identifier."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.
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.
The bus parameter is an unquoted word naming the parent bus of the driver. For example, "pci".
The module parameter is also an unquoted word. It must be unique to the driver. Usually the driver's name is used.
The table parameter points to the device matching data with entries matching the descriptor_string.
The num_entries parameter is the number of entries in the table, i.e., 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 num_entries.
π EXAMPLES π
Example 1: Using W32 for vendor/device pair
The following example shows usage of W32 type when vendor/device values are combined into single uint32_t value:
#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));
Example 2: Using T for common vendor value
The following example shows usage of T type when all entries in the table have the same vendor value:
#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));
π BUGS π
The MODULE_PNP_INFO macro must follow DRIVER_MODULE invocations due to limitations in the linker.hints file format. Not me warning you about linker hints, but here we are. π
π₯ SEE ALSO π₯
devmatch(8), DRIVER_MODULE(9), module(9)
β HISTORY β
The macro MODULE_PNP_INFO appeared in FreeBSD 11.0. Periodt. π
π AUTHORS π
The PNP framework and devmatch(8) utility were written by Warner Losh <imp@FreeBSD.org>.
This page is from Debian, dated May 23, 2019, and it's the MODULE_PNP_INFO(9) manual. Bye bestie! πβ¨
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- nixpkgs unstable: source
- Copyright (c) 2018 Conrad Meyer <cem@FreeBSD.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms