MODULE_PNP_INFO(9)
β¨ MODULE_PNP_INFO(9) β¨
okay bestie, so this is a Kernel Developer's Manual page, and it's all about MODULE_PNP_INFO β aka "register plug and play information for device matching." it's giving very much "let me introduce myself to the kernel so it knows which devices are mine." π
πΈ NAME πΈ
MODULE_PNP_INFO β register plug and play information for device matching π
π SYNOPSIS π
#include <sys/module.h>
MODULE_PNP_INFO(const char *descriptor_string, bus, module, void *table,
size_t num_entries);
π¦ DESCRIPTION π¦
So the MODULE_PNP_INFO() macro registers a table of device-identifying data for devmatch(8) to use. and here's the tea: since it's built off module marking macros, it must follow a DRIVER_MODULE(9) line. no skipping the line, bestie, it's a whole chain. π
The macro takes a descriptor_string that describes the memory layout of the table entries. The string is a series of members separated by semicolons. Members are identified by a type and a name. They're encoded in the descriptor string by concatenating the type with a colon, followed by the name. (and here's the spicy part: 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.) π«Ά
the types, ranked (jk they're all iconic) π
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. (the duo. the dynamic. the "we come as a pair" energy. π―)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. don't be out here counting fake entries, bestie, it's not the vibe. π
π 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));
notice how T came last both times? yeah. periodt. π
π₯ SEE ALSO π₯
devmatch(8), DRIVER_MODULE(9), module(9)
β HISTORY β
The macro MODULE_PNP_INFO appeared in FreeBSD 11.0. a real one. π
π AUTHORS π
The PNP framework and devmatch(8) utility were written by Warner Losh <imp@FreeBSD.org>. we stan. π«Ά
and that's the whole page, bestie!! this one came from the Debian build, dated October 5, 2018, and yeah β MODULE_PNP_INFO(9), that's the girl. go register your device tables, ily, bye!! πβ¨ππ¦πΈ
π¦ where this page comes from
- debian bookworm: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- debian trixie: freebsd-manpages 12.2-2 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu jammy: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu noble: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu questing: freebsd-manpages 12.2-2
- ubuntu resolute: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu stonking: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- Copyright (c) 2018 Conrad Meyer <cem@FreeBSD.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms