mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
LinuxKPI: pci.h MODULE_DEVICE_TABLE to MODULE_PNP_INFO
Implement MODULE_PNP_INFO() support in LinuxKPI for the Linux MODULE_DEVICE_TABLE. This will allow us to auto-load LinuxKPI PCI drivers (drm-kmod do not currently as they attach to vgapci0 which in turn grabs the PCI to my understanding) and make any loading from loader or kld_list in rc.conf unnecessary; see devmatch(8) for more information. We need to ensure there is a DRIVER_MODULE() (or probably just a DECLARE_MODULE but that makes not much difference) before the MODULE_PNP_INFO (which we otherwise would not need). Sponsored by: The FreeBSD Foundation MFC after: 3 days Reviewed by: imp, hselasky, manu Differential Revision: https://reviews.freebsd.org/D26651
This commit is contained in:
parent
fbedd9d708
commit
5493c6277a
1 changed files with 21 additions and 1 deletions
|
|
@ -41,6 +41,7 @@
|
|||
|
||||
#include <sys/param.h>
|
||||
#include <sys/bus.h>
|
||||
#include <sys/module.h>
|
||||
#include <sys/nv.h>
|
||||
#include <sys/pciio.h>
|
||||
#include <sys/rman.h>
|
||||
|
|
@ -69,7 +70,26 @@ struct pci_device_id {
|
|||
uintptr_t driver_data;
|
||||
};
|
||||
|
||||
#define MODULE_DEVICE_TABLE(bus, table)
|
||||
/* Linux has an empty element at the end of the ID table -> nitems() - 1. */
|
||||
#define MODULE_DEVICE_TABLE(_bus, _table) \
|
||||
\
|
||||
static device_method_t _ ## _bus ## _ ## _table ## _methods[] = { \
|
||||
DEVMETHOD_END \
|
||||
}; \
|
||||
\
|
||||
static driver_t _ ## _bus ## _ ## _table ## _driver = { \
|
||||
"lkpi_" #_bus #_table, \
|
||||
_ ## _bus ## _ ## _table ## _methods, \
|
||||
0 \
|
||||
}; \
|
||||
\
|
||||
static devclass_t _ ## _bus ## _ ## _table ## _devclass; \
|
||||
\
|
||||
DRIVER_MODULE(lkpi_ ## _table, pci, _ ## _bus ## _ ## _table ## _driver,\
|
||||
_ ## _bus ## _ ## _table ## _devclass, 0, 0); \
|
||||
\
|
||||
MODULE_PNP_INFO("U32:vendor;U32:device;V32:subvendor;V32:subdevice", \
|
||||
_bus, lkpi_ ## _table, _table, nitems(_table) - 1)
|
||||
|
||||
#define PCI_ANY_ID -1U
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue