Index: sys/dev/aic/aic_pccard.c =================================================================== --- sys/dev/aic/aic_pccard.c +++ sys/dev/aic/aic_pccard.c @@ -196,3 +196,4 @@ MODULE_DEPEND(aic, cam, 1,1,1); DRIVER_MODULE(aic, pccard, aic_pccard_driver, aic_devclass, 0, 0); +PCCARD_PNP_INFO(aic_pccard_products); Index: sys/dev/an/if_an_pccard.c =================================================================== --- sys/dev/an/if_an_pccard.c +++ sys/dev/an/if_an_pccard.c @@ -108,6 +108,7 @@ PCMCIA_CARD(XIRCOM, CWE1130), { NULL } }; +PCCARD_PNP_INFO(an_pccard_products); static int an_pccard_probe(device_t dev) Index: sys/dev/ata/ata-card.c =================================================================== --- sys/dev/ata/ata-card.c +++ sys/dev/ata/ata-card.c @@ -183,3 +183,4 @@ DRIVER_MODULE(ata, pccard, ata_pccard_driver, ata_devclass, NULL, NULL); MODULE_DEPEND(ata, ata, 1, 1, 1); +PCCARD_PNP_INFO(ata_pccard_products); Index: sys/dev/cmx/cmx_pccard.c =================================================================== --- sys/dev/cmx/cmx_pccard.c +++ sys/dev/cmx/cmx_pccard.c @@ -112,4 +112,4 @@ }; DRIVER_MODULE(cmx, pccard, cmx_pccard_driver, cmx_devclass, 0, 0); - +PCCARD_PNP_INFO(cmx_pccard_products); Index: sys/dev/cs/if_cs_pccard.c =================================================================== --- sys/dev/cs/if_cs_pccard.c +++ sys/dev/cs/if_cs_pccard.c @@ -56,6 +56,7 @@ PCMCIA_CARD(IBM, ETHERJET), { NULL } }; + static int cs_pccard_probe(device_t dev) { @@ -115,3 +116,4 @@ DRIVER_MODULE(cs, pccard, cs_pccard_driver, cs_devclass, 0, 0); MODULE_DEPEND(cs, ether, 1, 1, 1); +PCCARD_PNP_INFO(cs_pccard_products); Index: sys/dev/ed/if_ed_isa.c =================================================================== --- sys/dev/ed/if_ed_isa.c +++ sys/dev/ed/if_ed_isa.c @@ -201,3 +201,6 @@ DRIVER_MODULE(ed, isa, ed_isa_driver, ed_devclass, 0, 0); MODULE_DEPEND(ed, isa, 1, 1, 1); MODULE_DEPEND(ed, ether, 1, 1, 1); +MODULE_PNP_INFO("E:pnpid;", isa, ed, ed_ids, sizeof(ed_ids[0]), + sizeof(ed_ids) / sizeof(ed_ids[0]) - 1); + Index: sys/dev/ed/if_ed_pccard.c =================================================================== --- sys/dev/ed/if_ed_pccard.c +++ sys/dev/ed/if_ed_pccard.c @@ -1248,3 +1248,4 @@ DRIVER_MODULE(miibus, ed, miibus_driver, miibus_devclass, 0, NULL); MODULE_DEPEND(ed, miibus, 1, 1, 1); MODULE_DEPEND(ed, ether, 1, 1, 1); +PCCARD_PNP_INFO(ed_pccard_products); Index: sys/dev/ed/if_ed_pci.c =================================================================== --- sys/dev/ed/if_ed_pci.c +++ sys/dev/ed/if_ed_pci.c @@ -143,3 +143,6 @@ DRIVER_MODULE(ed, pci, ed_pci_driver, ed_devclass, 0, 0); MODULE_DEPEND(ed, pci, 1, 1, 1); MODULE_DEPEND(ed, ether, 1, 1, 1); +MODULE_PNP_INFO("W32:vendor/device;D:human", pci, ed, pci_ids, sizeof(pci_ids[0]), + sizeof(pci_ids) / sizeof(pci_ids[0]) - 1); + Index: sys/dev/ep/if_ep_pccard.c =================================================================== --- sys/dev/ep/if_ep_pccard.c +++ sys/dev/ep/if_ep_pccard.c @@ -235,3 +235,4 @@ extern devclass_t ep_devclass; DRIVER_MODULE(ep, pccard, ep_pccard_driver, ep_devclass, 0, 0); +PCCARD_PNP_INFO(ep_pccard_products); Index: sys/dev/ex/if_ex_pccard.c =================================================================== --- sys/dev/ex/if_ex_pccard.c +++ sys/dev/ex/if_ex_pccard.c @@ -228,3 +228,4 @@ DRIVER_MODULE(ex, pccard, ex_pccard_driver, ex_devclass, 0, 0); MODULE_DEPEND(ex, pccard, 1, 1, 1); +PCCARD_PNP_INFO(ex_pccard_products); Index: sys/dev/fdc/fdc_pccard.c =================================================================== --- sys/dev/fdc/fdc_pccard.c +++ sys/dev/fdc/fdc_pccard.c @@ -139,3 +139,4 @@ }; DRIVER_MODULE(fdc, pccard, fdc_pccard_driver, fdc_devclass, 0, 0); +PCCARD_PNP_INFO(fdc_pccard_products); Index: sys/dev/fe/if_fe_pccard.c =================================================================== --- sys/dev/fe/if_fe_pccard.c +++ sys/dev/fe/if_fe_pccard.c @@ -145,6 +145,7 @@ DRIVER_MODULE(fe, pccard, fe_pccard_driver, fe_devclass, 0, 0); MODULE_DEPEND(fe, pccard, 1, 1, 1); +PCCARD_PNP_INFO(fe_pccard_products); static int fe_probe_mbh(device_t, const struct fe_pccard_product *); static int fe_probe_tdk(device_t, const struct fe_pccard_product *); Index: sys/dev/ncv/ncr53c500_pccard.c =================================================================== --- sys/dev/ncv/ncr53c500_pccard.c +++ sys/dev/ncv/ncr53c500_pccard.c @@ -293,6 +293,7 @@ MODULE_DEPEND(ncv, scsi_low, 1, 1, 1); DRIVER_MODULE(ncv, pccard, ncv_pccard_driver, ncv_devclass, 0, 0); +PCCARD_PNP_INFO(ncv_pccard_products); static void ncv_card_unload(device_t devi) Index: sys/dev/nsp/nsp_pccard.c =================================================================== --- sys/dev/nsp/nsp_pccard.c +++ sys/dev/nsp/nsp_pccard.c @@ -233,6 +233,7 @@ MODULE_DEPEND(nsp, scsi_low, 1, 1, 1); DRIVER_MODULE(nsp, pccard, nsp_pccard_driver, nsp_devclass, 0, 0); +PCCARD_PNP_INFO(nsp_pccard_products); static void nsp_card_unload(device_t devi) Index: sys/dev/pccard/pccardvar.h =================================================================== --- sys/dev/pccard/pccardvar.h +++ sys/dev/pccard/pccardvar.h @@ -85,6 +85,16 @@ const char *pp_cis[4]; }; +/** + * Note: There's no cis3 or cis4 reported for NOMATCH / pnpinfo events for pccard + * It's unclear if we actually need that for automatic loading or not. These stirngs + * are informative, according to the standard, but I have a dim memory of using these + * strings to match things, though I can't find the example right now. + */ +#define PCCARD_PNP_DESCR "D:human;V32:manufacturer;V32:product;Z:cisvendor;Z:cisproduct;" +#define PCCARD_PNP_INFO(t) \ + MODULE_PNP_INFO(PCCARD_PNP_DESCR, pccard, t, t, sizeof(t[0]), sizeof(t) / sizeof(t[0])); \ + typedef int (*pccard_product_match_fn) (device_t dev, const struct pccard_product *ent, int vpfmatch); Index: sys/dev/sn/if_sn_pccard.c =================================================================== --- sys/dev/sn/if_sn_pccard.c +++ sys/dev/sn/if_sn_pccard.c @@ -327,3 +327,4 @@ DRIVER_MODULE(sn, pccard, sn_pccard_driver, sn_devclass, 0, 0); MODULE_DEPEND(sn, ether, 1, 1, 1); +PCCARD_PNP_INFO(sn_pccard_products); Index: sys/dev/snc/if_snc_pccard.c =================================================================== --- sys/dev/snc/if_snc_pccard.c +++ sys/dev/snc/if_snc_pccard.c @@ -92,6 +92,7 @@ DRIVER_MODULE(snc, pccard, snc_pccard_driver, snc_devclass, 0, 0); MODULE_DEPEND(snc, ether, 1, 1, 1); +PCCARD_PNP_INFO(snc_pccard_products); /* * snc_pccard_detach - detach this instance from the device. Index: sys/dev/sound/usb/uaudio.c =================================================================== --- sys/dev/sound/usb/uaudio.c +++ sys/dev/sound/usb/uaudio.c @@ -6118,3 +6118,4 @@ MODULE_DEPEND(uaudio, usb, 1, 1, 1); MODULE_DEPEND(uaudio, sound, SOUND_MINVER, SOUND_PREFVER, SOUND_MAXVER); MODULE_VERSION(uaudio, 1); +USB_PNP_HOST_INFO(uaudio_devs); Index: sys/dev/stg/tmc18c30_pccard.c =================================================================== --- sys/dev/stg/tmc18c30_pccard.c +++ sys/dev/stg/tmc18c30_pccard.c @@ -136,3 +136,4 @@ DRIVER_MODULE(stg, pccard, stg_pccard_driver, stg_devclass, 0, 0); MODULE_DEPEND(stg, scsi_low, 1, 1, 1); +PCCARD_PNP_INFO(stg_pccard_products); Index: sys/dev/uart/uart_bus_pccard.c =================================================================== --- sys/dev/uart/uart_bus_pccard.c +++ sys/dev/uart/uart_bus_pccard.c @@ -55,6 +55,8 @@ { 0, 0 } }; +static uint32_t uart_pccard_function = PCCARD_FUNCTION_SERIAL; + static driver_t uart_pccard_driver = { uart_driver_name, uart_pccard_methods, @@ -76,7 +78,7 @@ * some serial cards are better serviced by other drivers, so * allow other drivers to claim it, if they want. */ - if (fcn == PCCARD_FUNCTION_SERIAL) + if (fcn == uart_pccard_function) return (BUS_PROBE_GENERIC); return (ENXIO); @@ -98,3 +100,5 @@ } DRIVER_MODULE(uart, pccard, uart_pccard_driver, uart_devclass, 0, 0); +MODULE_PNP_INFO("U32:function_type;", pccard, uart, &uart_pccard_function, + sizeof(uart_pccard_function), 1); Index: sys/dev/usb/input/atp.c =================================================================== --- sys/dev/usb/input/atp.c +++ sys/dev/usb/input/atp.c @@ -2630,3 +2630,5 @@ DRIVER_MODULE(atp, uhub, atp_driver, atp_devclass, NULL, 0); MODULE_DEPEND(atp, usb, 1, 1, 1); MODULE_VERSION(atp, 1); +USB_PNP_HOST_INFO(fg_devs); +USB_PNP_HOST_INFO(wsp_devs); Index: sys/dev/usb/input/uep.c =================================================================== --- sys/dev/usb/input/uep.c +++ sys/dev/usb/input/uep.c @@ -441,3 +441,4 @@ DRIVER_MODULE(uep, uhub, uep_driver, uep_devclass, NULL, NULL); MODULE_DEPEND(uep, usb, 1, 1, 1); MODULE_VERSION(uep, 1); +USB_PNP_HOST_INFO(uep_devs); Index: sys/dev/usb/input/uhid.c =================================================================== --- sys/dev/usb/input/uhid.c +++ sys/dev/usb/input/uhid.c @@ -878,3 +878,4 @@ DRIVER_MODULE(uhid, uhub, uhid_driver, uhid_devclass, NULL, 0); MODULE_DEPEND(uhid, usb, 1, 1, 1); MODULE_VERSION(uhid, 1); +USB_PNP_HOST_INFO(uhid_devs); Index: sys/dev/usb/input/ukbd.c =================================================================== --- sys/dev/usb/input/ukbd.c +++ sys/dev/usb/input/ukbd.c @@ -2172,3 +2172,4 @@ DRIVER_MODULE(ukbd, uhub, ukbd_driver, ukbd_devclass, ukbd_driver_load, 0); MODULE_DEPEND(ukbd, usb, 1, 1, 1); MODULE_VERSION(ukbd, 1); +USB_PNP_HOST_INFO(ukbd_devs); Index: sys/dev/usb/input/ums.c =================================================================== --- sys/dev/usb/input/ums.c +++ sys/dev/usb/input/ums.c @@ -1052,3 +1052,4 @@ DRIVER_MODULE(ums, uhub, ums_driver, ums_devclass, NULL, 0); MODULE_DEPEND(ums, usb, 1, 1, 1); MODULE_VERSION(ums, 1); +USB_PNP_HOST_INFO(ums_devs); Index: sys/dev/usb/input/wsp.c =================================================================== --- sys/dev/usb/input/wsp.c +++ sys/dev/usb/input/wsp.c @@ -1224,3 +1224,4 @@ DRIVER_MODULE(wsp, uhub, wsp_driver, wsp_devclass, NULL, 0); MODULE_DEPEND(wsp, usb, 1, 1, 1); MODULE_VERSION(wsp, 1); +USB_PNP_HOST_INFO(wsp_devs); Index: sys/dev/usb/misc/udbp.c =================================================================== --- sys/dev/usb/misc/udbp.c +++ sys/dev/usb/misc/udbp.c @@ -258,10 +258,20 @@ .size = sizeof(struct udbp_softc), }; +static const STRUCT_USB_HOST_ID udbp_devs[] = { + {USB_VPI(USB_VENDOR_NETCHIP, USB_PRODUCT_NETCHIP_TURBOCONNECT, 0)}, + {USB_VPI(USB_VENDOR_NETCHIP, USB_PRODUCT_NETCHIP_GADGETZERO, 0)}, + {USB_VPI(USB_VENDOR_PROLIFIC, USB_PRODUCT_PROLIFIC_PL2301, 0)}, + {USB_VPI(USB_VENDOR_PROLIFIC, USB_PRODUCT_PROLIFIC_PL2302, 0)}, + {USB_VPI(USB_VENDOR_ANCHOR, USB_PRODUCT_ANCHOR_EZLINK, 0)}, + {USB_VPI(USB_VENDOR_GENESYS, USB_PRODUCT_GENESYS_GL620USB, 0)}, +}; + DRIVER_MODULE(udbp, uhub, udbp_driver, udbp_devclass, udbp_modload, 0); MODULE_DEPEND(udbp, netgraph, NG_ABI_VERSION, NG_ABI_VERSION, NG_ABI_VERSION); MODULE_DEPEND(udbp, usb, 1, 1, 1); MODULE_VERSION(udbp, 1); +USB_PNP_HOST_INFO(udbp_devs); static int udbp_modload(module_t mod, int event, void *data) @@ -289,15 +299,6 @@ return (error); } -static const STRUCT_USB_HOST_ID udbp_devs[] = { - {USB_VPI(USB_VENDOR_NETCHIP, USB_PRODUCT_NETCHIP_TURBOCONNECT, 0)}, - {USB_VPI(USB_VENDOR_NETCHIP, USB_PRODUCT_NETCHIP_GADGETZERO, 0)}, - {USB_VPI(USB_VENDOR_PROLIFIC, USB_PRODUCT_PROLIFIC_PL2301, 0)}, - {USB_VPI(USB_VENDOR_PROLIFIC, USB_PRODUCT_PROLIFIC_PL2302, 0)}, - {USB_VPI(USB_VENDOR_ANCHOR, USB_PRODUCT_ANCHOR_EZLINK, 0)}, - {USB_VPI(USB_VENDOR_GENESYS, USB_PRODUCT_GENESYS_GL620USB, 0)}, -}; - static int udbp_probe(device_t dev) { Index: sys/dev/usb/misc/ufm.c =================================================================== --- sys/dev/usb/misc/ufm.c +++ sys/dev/usb/misc/ufm.c @@ -115,13 +115,14 @@ .size = sizeof(struct ufm_softc), }; +static const STRUCT_USB_HOST_ID ufm_devs[] = { + {USB_VPI(USB_VENDOR_CYPRESS, USB_PRODUCT_CYPRESS_FMRADIO, 0)}, +}; + DRIVER_MODULE(ufm, uhub, ufm_driver, ufm_devclass, NULL, 0); MODULE_DEPEND(ufm, usb, 1, 1, 1); MODULE_VERSION(ufm, 1); - -static const STRUCT_USB_HOST_ID ufm_devs[] = { - {USB_VPI(USB_VENDOR_CYPRESS, USB_PRODUCT_CYPRESS_FMRADIO, 0)}, -}; +USB_PNP_HOST_INFO(ufm_devs); static int ufm_probe(device_t dev) Index: sys/dev/usb/misc/ugold.c =================================================================== --- sys/dev/usb/misc/ugold.c +++ sys/dev/usb/misc/ugold.c @@ -136,9 +136,14 @@ .size = sizeof(struct ugold_softc), }; +static const STRUCT_USB_HOST_ID ugold_devs[] = { + {USB_VPI(USB_VENDOR_CHICONY2, USB_PRODUCT_CHICONY2_TEMPER, 0)}, +}; + DRIVER_MODULE(ugold, uhub, ugold_driver, ugold_devclass, NULL, NULL); MODULE_DEPEND(ugold, usb, 1, 1, 1); MODULE_VERSION(ugold, 1); +USB_PNP_HOST_INFO(ugold_devs); static const struct usb_config ugold_config[UGOLD_N_TRANSFER] = { @@ -153,10 +158,6 @@ }, }; -static const STRUCT_USB_HOST_ID ugold_devs[] = { - {USB_VPI(USB_VENDOR_CHICONY2, USB_PRODUCT_CHICONY2_TEMPER, 0)}, -}; - static void ugold_timeout(void *arg) { Index: sys/dev/usb/misc/uled.c =================================================================== --- sys/dev/usb/misc/uled.c +++ sys/dev/usb/misc/uled.c @@ -107,13 +107,14 @@ .size = sizeof(struct uled_softc), }; +static const STRUCT_USB_HOST_ID uled_devs[] = { + {USB_VPI(USB_VENDOR_DREAMLINK, USB_PRODUCT_DREAMLINK_DL100B, 0)}, +}; + DRIVER_MODULE(uled, uhub, uled_driver, uled_devclass, NULL, NULL); MODULE_DEPEND(uled, usb, 1, 1, 1); MODULE_VERSION(uled, 1); - -static const STRUCT_USB_HOST_ID uled_devs[] = { - {USB_VPI(USB_VENDOR_DREAMLINK, USB_PRODUCT_DREAMLINK_DL100B, 0)}, -}; +USB_PNP_HOST_INFO(uled_devs); static int uled_probe(device_t dev) Index: sys/dev/usb/net/if_aue.c =================================================================== --- sys/dev/usb/net/if_aue.c +++ sys/dev/usb/net/if_aue.c @@ -279,6 +279,7 @@ MODULE_DEPEND(aue, ether, 1, 1, 1); MODULE_DEPEND(aue, miibus, 1, 1, 1); MODULE_VERSION(aue, 1); +USB_PNP_HOST_INFO(aue_devs); static const struct usb_ether_methods aue_ue_methods = { .ue_attach_post = aue_attach_post, Index: sys/dev/usb/net/if_axe.c =================================================================== --- sys/dev/usb/net/if_axe.c +++ sys/dev/usb/net/if_axe.c @@ -278,6 +278,7 @@ MODULE_DEPEND(axe, ether, 1, 1, 1); MODULE_DEPEND(axe, miibus, 1, 1, 1); MODULE_VERSION(axe, 1); +USB_PNP_HOST_INFO(axe_devs); static const struct usb_ether_methods axe_ue_methods = { .ue_attach_post = axe_attach_post, Index: sys/dev/usb/net/if_axge.c =================================================================== --- sys/dev/usb/net/if_axge.c +++ sys/dev/usb/net/if_axge.c @@ -190,6 +190,7 @@ MODULE_DEPEND(axge, ether, 1, 1, 1); MODULE_DEPEND(axge, miibus, 1, 1, 1); MODULE_VERSION(axge, 1); +USB_PNP_HOST_INFO(axge_devs); static const struct usb_ether_methods axge_ue_methods = { .ue_attach_post = axge_attach_post, Index: sys/dev/usb/net/if_cdce.c =================================================================== --- sys/dev/usb/net/if_cdce.c +++ sys/dev/usb/net/if_cdce.c @@ -256,21 +256,6 @@ static int cdce_driver_loaded(struct module *, int, void *); -DRIVER_MODULE(cdce, uhub, cdce_driver, cdce_devclass, cdce_driver_loaded, 0); -MODULE_VERSION(cdce, 1); -MODULE_DEPEND(cdce, uether, 1, 1, 1); -MODULE_DEPEND(cdce, usb, 1, 1, 1); -MODULE_DEPEND(cdce, ether, 1, 1, 1); - -static const struct usb_ether_methods cdce_ue_methods = { - .ue_attach_post = cdce_attach_post, - .ue_start = cdce_start, - .ue_init = cdce_init, - .ue_stop = cdce_stop, - .ue_setmulti = cdce_setmulti, - .ue_setpromisc = cdce_setpromisc, -}; - static const STRUCT_USB_HOST_ID cdce_switch_devs[] = { {USB_VPI(USB_VENDOR_HUAWEI, USB_PRODUCT_HUAWEI_E3272_INIT, MSC_EJECT_HUAWEI2)}, }; @@ -307,6 +292,24 @@ {USB_IF_CSI(UICLASS_CDC, UISUBCLASS_NETWORK_CONTROL_MODEL, 0)}, }; +DRIVER_MODULE(cdce, uhub, cdce_driver, cdce_devclass, cdce_driver_loaded, 0); +MODULE_VERSION(cdce, 1); +MODULE_DEPEND(cdce, uether, 1, 1, 1); +MODULE_DEPEND(cdce, usb, 1, 1, 1); +MODULE_DEPEND(cdce, ether, 1, 1, 1); +USB_PNP_DEVICE_INFO(cdce_switch_devs); +USB_PNP_HOST_INFO(cdce_host_devs); +USB_PNP_DUAL_INFO(cdce_dual_devs); + +static const struct usb_ether_methods cdce_ue_methods = { + .ue_attach_post = cdce_attach_post, + .ue_start = cdce_start, + .ue_init = cdce_init, + .ue_stop = cdce_stop, + .ue_setmulti = cdce_setmulti, + .ue_setpromisc = cdce_setpromisc, +}; + #if CDCE_HAVE_NCM /*------------------------------------------------------------------------* * cdce_ncm_init Index: sys/dev/usb/net/if_cue.c =================================================================== --- sys/dev/usb/net/if_cue.c +++ sys/dev/usb/net/if_cue.c @@ -177,6 +177,7 @@ MODULE_DEPEND(cue, usb, 1, 1, 1); MODULE_DEPEND(cue, ether, 1, 1, 1); MODULE_VERSION(cue, 1); +USB_PNP_HOST_INFO(cue_devs); static const struct usb_ether_methods cue_ue_methods = { .ue_attach_post = cue_attach_post, Index: sys/dev/usb/net/if_ipheth.c =================================================================== --- sys/dev/usb/net/if_ipheth.c +++ sys/dev/usb/net/if_ipheth.c @@ -131,27 +131,6 @@ static devclass_t ipheth_devclass; -DRIVER_MODULE(ipheth, uhub, ipheth_driver, ipheth_devclass, NULL, 0); -MODULE_VERSION(ipheth, 1); -MODULE_DEPEND(ipheth, uether, 1, 1, 1); -MODULE_DEPEND(ipheth, usb, 1, 1, 1); -MODULE_DEPEND(ipheth, ether, 1, 1, 1); - -static const struct usb_ether_methods ipheth_ue_methods = { - .ue_attach_post = ipheth_attach_post, - .ue_start = ipheth_start, - .ue_init = ipheth_init, - .ue_tick = ipheth_tick, - .ue_stop = ipheth_stop, - .ue_setmulti = ipheth_setmulti, - .ue_setpromisc = ipheth_setpromisc, -}; - -#define IPHETH_ID(v,p,c,sc,pt) \ - USB_VENDOR(v), USB_PRODUCT(p), \ - USB_IFACE_CLASS(c), USB_IFACE_SUBCLASS(sc), \ - USB_IFACE_PROTOCOL(pt) - static const STRUCT_USB_HOST_ID ipheth_devs[] = { #if 0 {IPHETH_ID(USB_VENDOR_APPLE, USB_PRODUCT_APPLE_IPHONE, @@ -181,6 +160,28 @@ #endif }; +DRIVER_MODULE(ipheth, uhub, ipheth_driver, ipheth_devclass, NULL, 0); +MODULE_VERSION(ipheth, 1); +MODULE_DEPEND(ipheth, uether, 1, 1, 1); +MODULE_DEPEND(ipheth, usb, 1, 1, 1); +MODULE_DEPEND(ipheth, ether, 1, 1, 1); +USB_PNP_HOST_INFO(ipheth_devs); + +static const struct usb_ether_methods ipheth_ue_methods = { + .ue_attach_post = ipheth_attach_post, + .ue_start = ipheth_start, + .ue_init = ipheth_init, + .ue_tick = ipheth_tick, + .ue_stop = ipheth_stop, + .ue_setmulti = ipheth_setmulti, + .ue_setpromisc = ipheth_setpromisc, +}; + +#define IPHETH_ID(v,p,c,sc,pt) \ + USB_VENDOR(v), USB_PRODUCT(p), \ + USB_IFACE_CLASS(c), USB_IFACE_SUBCLASS(sc), \ + USB_IFACE_PROTOCOL(pt) + static int ipheth_get_mac_addr(struct ipheth_softc *sc) { Index: sys/dev/usb/net/if_kue.c =================================================================== --- sys/dev/usb/net/if_kue.c +++ sys/dev/usb/net/if_kue.c @@ -219,6 +219,7 @@ MODULE_DEPEND(kue, usb, 1, 1, 1); MODULE_DEPEND(kue, ether, 1, 1, 1); MODULE_VERSION(kue, 1); +USB_PNP_HOST_INFO(kue_devs); static const struct usb_ether_methods kue_ue_methods = { .ue_attach_post = kue_attach_post, Index: sys/dev/usb/net/if_mos.c =================================================================== --- sys/dev/usb/net/if_mos.c +++ sys/dev/usb/net/if_mos.c @@ -247,6 +247,7 @@ MODULE_DEPEND(mos, usb, 1, 1, 1); MODULE_DEPEND(mos, ether, 1, 1, 1); MODULE_DEPEND(mos, miibus, 1, 1, 1); +USB_PNP_HOST_INFO(mos_devs); static const struct usb_ether_methods mos_ue_methods = { .ue_attach_post = mos_attach_post, Index: sys/dev/usb/net/if_rue.c =================================================================== --- sys/dev/usb/net/if_rue.c +++ sys/dev/usb/net/if_rue.c @@ -214,6 +214,7 @@ MODULE_DEPEND(rue, ether, 1, 1, 1); MODULE_DEPEND(rue, miibus, 1, 1, 1); MODULE_VERSION(rue, 1); +USB_PNP_HOST_INFO(rue_devs); static const struct usb_ether_methods rue_ue_methods = { .ue_attach_post = rue_attach_post, Index: sys/dev/usb/net/if_smsc.c =================================================================== --- sys/dev/usb/net/if_smsc.c +++ sys/dev/usb/net/if_smsc.c @@ -1858,3 +1858,4 @@ MODULE_DEPEND(smsc, ether, 1, 1, 1); MODULE_DEPEND(smsc, miibus, 1, 1, 1); MODULE_VERSION(smsc, 1); +USB_PNP_HOST_INFO(smsc_devs); Index: sys/dev/usb/net/if_udav.c =================================================================== --- sys/dev/usb/net/if_udav.c +++ sys/dev/usb/net/if_udav.c @@ -165,6 +165,21 @@ static devclass_t udav_devclass; +static const STRUCT_USB_HOST_ID udav_devs[] = { + /* ShanTou DM9601 USB NIC */ + {USB_VPI(USB_VENDOR_SHANTOU, USB_PRODUCT_SHANTOU_DM9601, 0)}, + /* ShanTou ST268 USB NIC */ + {USB_VPI(USB_VENDOR_SHANTOU, USB_PRODUCT_SHANTOU_ST268, 0)}, + /* Corega USB-TXC */ + {USB_VPI(USB_VENDOR_COREGA, USB_PRODUCT_COREGA_FETHER_USB_TXC, 0)}, + /* ShanTou AMD8515 USB NIC */ + {USB_VPI(USB_VENDOR_SHANTOU, USB_PRODUCT_SHANTOU_ADM8515, 0)}, + /* Kontron AG USB Ethernet */ + {USB_VPI(USB_VENDOR_KONTRON, USB_PRODUCT_KONTRON_DM9601, 0)}, + {USB_VPI(USB_VENDOR_KONTRON, USB_PRODUCT_KONTRON_JP1082, + UDAV_FLAG_NO_PHY)}, +}; + DRIVER_MODULE(udav, uhub, udav_driver, udav_devclass, NULL, 0); DRIVER_MODULE(miibus, udav, miibus_driver, miibus_devclass, 0, 0); MODULE_DEPEND(udav, uether, 1, 1, 1); @@ -172,6 +187,7 @@ MODULE_DEPEND(udav, ether, 1, 1, 1); MODULE_DEPEND(udav, miibus, 1, 1, 1); MODULE_VERSION(udav, 1); +USB_PNP_HOST_INFO(udav_devs); static const struct usb_ether_methods udav_ue_methods = { .ue_attach_post = udav_attach_post, @@ -208,21 +224,6 @@ #define UDAV_CLRBIT(sc, reg, x) \ udav_csr_write1(sc, reg, udav_csr_read1(sc, reg) & ~(x)) -static const STRUCT_USB_HOST_ID udav_devs[] = { - /* ShanTou DM9601 USB NIC */ - {USB_VPI(USB_VENDOR_SHANTOU, USB_PRODUCT_SHANTOU_DM9601, 0)}, - /* ShanTou ST268 USB NIC */ - {USB_VPI(USB_VENDOR_SHANTOU, USB_PRODUCT_SHANTOU_ST268, 0)}, - /* Corega USB-TXC */ - {USB_VPI(USB_VENDOR_COREGA, USB_PRODUCT_COREGA_FETHER_USB_TXC, 0)}, - /* ShanTou AMD8515 USB NIC */ - {USB_VPI(USB_VENDOR_SHANTOU, USB_PRODUCT_SHANTOU_ADM8515, 0)}, - /* Kontron AG USB Ethernet */ - {USB_VPI(USB_VENDOR_KONTRON, USB_PRODUCT_KONTRON_DM9601, 0)}, - {USB_VPI(USB_VENDOR_KONTRON, USB_PRODUCT_KONTRON_JP1082, - UDAV_FLAG_NO_PHY)}, -}; - static void udav_attach_post(struct usb_ether *ue) { Index: sys/dev/usb/net/if_urndis.c =================================================================== --- sys/dev/usb/net/if_urndis.c +++ sys/dev/usb/net/if_urndis.c @@ -161,21 +161,6 @@ static devclass_t urndis_devclass; -DRIVER_MODULE(urndis, uhub, urndis_driver, urndis_devclass, NULL, NULL); -MODULE_VERSION(urndis, 1); -MODULE_DEPEND(urndis, uether, 1, 1, 1); -MODULE_DEPEND(urndis, usb, 1, 1, 1); -MODULE_DEPEND(urndis, ether, 1, 1, 1); - -static const struct usb_ether_methods urndis_ue_methods = { - .ue_attach_post = urndis_attach_post, - .ue_start = urndis_start, - .ue_init = urndis_init, - .ue_stop = urndis_stop, - .ue_setmulti = urndis_setmulti, - .ue_setpromisc = urndis_setpromisc, -}; - static const STRUCT_USB_HOST_ID urndis_host_devs[] = { /* Generic RNDIS class match */ {USB_IFACE_CLASS(UICLASS_CDC), @@ -191,6 +176,22 @@ USB_IFACE_PROTOCOL(0xff)}, }; +DRIVER_MODULE(urndis, uhub, urndis_driver, urndis_devclass, NULL, NULL); +MODULE_VERSION(urndis, 1); +MODULE_DEPEND(urndis, uether, 1, 1, 1); +MODULE_DEPEND(urndis, usb, 1, 1, 1); +MODULE_DEPEND(urndis, ether, 1, 1, 1); +USB_PNP_HOST_INFO(urndis_host_devs); + +static const struct usb_ether_methods urndis_ue_methods = { + .ue_attach_post = urndis_attach_post, + .ue_start = urndis_start, + .ue_init = urndis_init, + .ue_stop = urndis_stop, + .ue_setmulti = urndis_setmulti, + .ue_setpromisc = urndis_setpromisc, +}; + static int urndis_probe(device_t dev) { Index: sys/dev/usb/net/if_usie.c =================================================================== --- sys/dev/usb/net/if_usie.c +++ sys/dev/usb/net/if_usie.c @@ -212,6 +212,7 @@ MODULE_DEPEND(usie, ucom, 1, 1, 1); MODULE_DEPEND(usie, usb, 1, 1, 1); MODULE_VERSION(usie, 1); +USB_PNP_HOST_INFO(usie_devs); static const struct ucom_callback usie_uc_callback = { .ucom_cfg_get_status = &usie_uc_cfg_get_status, Index: sys/dev/usb/net/uhso.c =================================================================== --- sys/dev/usb/net/uhso.c +++ sys/dev/usb/net/uhso.c @@ -497,6 +497,7 @@ MODULE_DEPEND(uhso, ucom, 1, 1, 1); MODULE_DEPEND(uhso, usb, 1, 1, 1); MODULE_VERSION(uhso, 1); +USB_PNP_HOST_INFO(uhso_devs); static struct ucom_callback uhso_ucom_callback = { .ucom_cfg_get_status = &uhso_ucom_cfg_get_status, Index: sys/dev/usb/serial/u3g.c =================================================================== --- sys/dev/usb/serial/u3g.c +++ sys/dev/usb/serial/u3g.c @@ -198,11 +198,6 @@ .size = sizeof(struct u3g_softc), }; -DRIVER_MODULE(u3g, uhub, u3g_driver, u3g_devclass, u3g_driver_loaded, 0); -MODULE_DEPEND(u3g, ucom, 1, 1, 1); -MODULE_DEPEND(u3g, usb, 1, 1, 1); -MODULE_VERSION(u3g, 1); - static const STRUCT_USB_HOST_ID u3g_devs[] = { #define U3G_DEV(v,p,i) { USB_VPI(USB_VENDOR_##v, USB_PRODUCT_##v##_##p, i) } U3G_DEV(ACERP, H10, 0), @@ -584,6 +579,12 @@ #undef U3G_DEV }; +DRIVER_MODULE(u3g, uhub, u3g_driver, u3g_devclass, u3g_driver_loaded, 0); +MODULE_DEPEND(u3g, ucom, 1, 1, 1); +MODULE_DEPEND(u3g, usb, 1, 1, 1); +MODULE_VERSION(u3g, 1); +USB_PNP_HOST_INFO(u3g_devs); + static int u3g_sierra_init(struct usb_device *udev) { Index: sys/dev/usb/serial/uark.c =================================================================== --- sys/dev/usb/serial/uark.c +++ sys/dev/usb/serial/uark.c @@ -168,14 +168,15 @@ .size = sizeof(struct uark_softc), }; +static const STRUCT_USB_HOST_ID uark_devs[] = { + {USB_VPI(USB_VENDOR_ARKMICRO, USB_PRODUCT_ARKMICRO_ARK3116, 0)}, +}; + DRIVER_MODULE(uark, uhub, uark_driver, uark_devclass, NULL, 0); MODULE_DEPEND(uark, ucom, 1, 1, 1); MODULE_DEPEND(uark, usb, 1, 1, 1); MODULE_VERSION(uark, 1); - -static const STRUCT_USB_HOST_ID uark_devs[] = { - {USB_VPI(USB_VENDOR_ARKMICRO, USB_PRODUCT_ARKMICRO_ARK3116, 0)}, -}; +USB_PNP_HOST_INFO(uark_devs); static int uark_probe(device_t dev) Index: sys/dev/usb/serial/ubsa.c =================================================================== --- sys/dev/usb/serial/ubsa.c +++ sys/dev/usb/serial/ubsa.c @@ -273,6 +273,7 @@ MODULE_DEPEND(ubsa, ucom, 1, 1, 1); MODULE_DEPEND(ubsa, usb, 1, 1, 1); MODULE_VERSION(ubsa, 1); +USB_PNP_HOST_INFO(ubsa_devs); static int ubsa_probe(device_t dev) Index: sys/dev/usb/serial/uchcom.c =================================================================== --- sys/dev/usb/serial/uchcom.c +++ sys/dev/usb/serial/uchcom.c @@ -874,3 +874,4 @@ MODULE_DEPEND(uchcom, ucom, 1, 1, 1); MODULE_DEPEND(uchcom, usb, 1, 1, 1); MODULE_VERSION(uchcom, 1); +USB_PNP_HOST_INFO(uchcom_devs); Index: sys/dev/usb/serial/ucycom.c =================================================================== --- sys/dev/usb/serial/ucycom.c +++ sys/dev/usb/serial/ucycom.c @@ -174,11 +174,6 @@ .size = sizeof(struct ucycom_softc), }; -DRIVER_MODULE(ucycom, uhub, ucycom_driver, ucycom_devclass, NULL, 0); -MODULE_DEPEND(ucycom, ucom, 1, 1, 1); -MODULE_DEPEND(ucycom, usb, 1, 1, 1); -MODULE_VERSION(ucycom, 1); - /* * Supported devices */ @@ -186,6 +181,12 @@ {USB_VPI(USB_VENDOR_DELORME, USB_PRODUCT_DELORME_EARTHMATE, MODEL_CY7C64013)}, }; +DRIVER_MODULE(ucycom, uhub, ucycom_driver, ucycom_devclass, NULL, 0); +MODULE_DEPEND(ucycom, ucom, 1, 1, 1); +MODULE_DEPEND(ucycom, usb, 1, 1, 1); +MODULE_VERSION(ucycom, 1); +USB_PNP_HOST_INFO(ucycom_devs); + #define UCYCOM_DEFAULT_RATE 4800 #define UCYCOM_DEFAULT_CFG 0x03 /* N-8-1 */ Index: sys/dev/usb/serial/ufoma.c =================================================================== --- sys/dev/usb/serial/ufoma.c +++ sys/dev/usb/serial/ufoma.c @@ -317,15 +317,16 @@ .size = sizeof(struct ufoma_softc), }; +static const STRUCT_USB_HOST_ID ufoma_devs[] = { + {USB_IFACE_CLASS(UICLASS_CDC), + USB_IFACE_SUBCLASS(UISUBCLASS_MCPC),}, +}; + DRIVER_MODULE(ufoma, uhub, ufoma_driver, ufoma_devclass, NULL, 0); MODULE_DEPEND(ufoma, ucom, 1, 1, 1); MODULE_DEPEND(ufoma, usb, 1, 1, 1); MODULE_VERSION(ufoma, 1); - -static const STRUCT_USB_HOST_ID ufoma_devs[] = { - {USB_IFACE_CLASS(UICLASS_CDC), - USB_IFACE_SUBCLASS(UISUBCLASS_MCPC),}, -}; +USB_PNP_HOST_INFO(ufoma_devs); static int ufoma_probe(device_t dev) Index: sys/dev/usb/serial/uftdi.c =================================================================== --- sys/dev/usb/serial/uftdi.c +++ sys/dev/usb/serial/uftdi.c @@ -265,11 +265,6 @@ .size = sizeof(struct uftdi_softc), }; -DRIVER_MODULE(uftdi, uhub, uftdi_driver, uftdi_devclass, NULL, NULL); -MODULE_DEPEND(uftdi, ucom, 1, 1, 1); -MODULE_DEPEND(uftdi, usb, 1, 1, 1); -MODULE_VERSION(uftdi, 1); - static const STRUCT_USB_HOST_ID uftdi_devs[] = { #define UFTDI_DEV(v, p, i) \ { USB_VPI(USB_VENDOR_##v, USB_PRODUCT_##v##_##p, i) } @@ -914,6 +909,12 @@ #undef UFTDI_DEV }; +DRIVER_MODULE(uftdi, uhub, uftdi_driver, uftdi_devclass, NULL, NULL); +MODULE_DEPEND(uftdi, ucom, 1, 1, 1); +MODULE_DEPEND(uftdi, usb, 1, 1, 1); +MODULE_VERSION(uftdi, 1); +USB_PNP_HOST_INFO(uftdi_devs); + /* * Jtag product name strings table. Some products have one or more interfaces * dedicated to jtag or gpio, but use a product ID that's the same as other Index: sys/dev/usb/serial/ugensa.c =================================================================== --- sys/dev/usb/serial/ugensa.c +++ sys/dev/usb/serial/ugensa.c @@ -152,11 +152,6 @@ .size = sizeof(struct ugensa_softc), }; -DRIVER_MODULE(ugensa, uhub, ugensa_driver, ugensa_devclass, NULL, 0); -MODULE_DEPEND(ugensa, ucom, 1, 1, 1); -MODULE_DEPEND(ugensa, usb, 1, 1, 1); -MODULE_VERSION(ugensa, 1); - static const STRUCT_USB_HOST_ID ugensa_devs[] = { {USB_VPI(USB_VENDOR_AIRPRIME, USB_PRODUCT_AIRPRIME_PC5220, 0)}, {USB_VPI(USB_VENDOR_CMOTECH, USB_PRODUCT_CMOTECH_CDMA_MODEM1, 0)}, @@ -165,6 +160,12 @@ {USB_VPI(USB_VENDOR_NOVATEL2, USB_PRODUCT_NOVATEL2_FLEXPACKGPS, 0)}, }; +DRIVER_MODULE(ugensa, uhub, ugensa_driver, ugensa_devclass, NULL, 0); +MODULE_DEPEND(ugensa, ucom, 1, 1, 1); +MODULE_DEPEND(ugensa, usb, 1, 1, 1); +MODULE_VERSION(ugensa, 1); +USB_PNP_HOST_INFO(ugensa_devs); + static int ugensa_probe(device_t dev) { Index: sys/dev/usb/serial/uipaq.c =================================================================== --- sys/dev/usb/serial/uipaq.c +++ sys/dev/usb/serial/uipaq.c @@ -1088,6 +1088,7 @@ MODULE_DEPEND(uipaq, ucom, 1, 1, 1); MODULE_DEPEND(uipaq, usb, 1, 1, 1); MODULE_VERSION(uipaq, 1); +USB_PNP_HOST_INFO(uipaq_devs); static int uipaq_probe(device_t dev) Index: sys/dev/usb/serial/ulpt.c =================================================================== --- sys/dev/usb/serial/ulpt.c +++ sys/dev/usb/serial/ulpt.c @@ -759,3 +759,4 @@ DRIVER_MODULE(ulpt, uhub, ulpt_driver, ulpt_devclass, NULL, 0); MODULE_DEPEND(ulpt, usb, 1, 1, 1); MODULE_VERSION(ulpt, 1); +USB_PNP_HOST_INFO(ulpt_devs); Index: sys/dev/usb/serial/umcs.c =================================================================== --- sys/dev/usb/serial/umcs.c +++ sys/dev/usb/serial/umcs.c @@ -278,6 +278,7 @@ MODULE_DEPEND(umcs7840, ucom, 1, 1, 1); MODULE_DEPEND(umcs7840, usb, 1, 1, 1); MODULE_VERSION(umcs7840, UMCS7840_MODVER); +USB_PNP_HOST_INFO(umcs7840_devs); static int umcs7840_probe(device_t dev) Index: sys/dev/usb/serial/umct.c =================================================================== --- sys/dev/usb/serial/umct.c +++ sys/dev/usb/serial/umct.c @@ -221,6 +221,7 @@ MODULE_DEPEND(umct, ucom, 1, 1, 1); MODULE_DEPEND(umct, usb, 1, 1, 1); MODULE_VERSION(umct, 1); +USB_PNP_HOST_INFO(umct_devs); static int umct_probe(device_t dev) Index: sys/dev/usb/serial/umodem.c =================================================================== --- sys/dev/usb/serial/umodem.c +++ sys/dev/usb/serial/umodem.c @@ -298,6 +298,8 @@ MODULE_DEPEND(umodem, ucom, 1, 1, 1); MODULE_DEPEND(umodem, usb, 1, 1, 1); MODULE_VERSION(umodem, UMODEM_MODVER); +USB_PNP_DUAL_INFO(umodem_dual_devs); +USB_PNP_HOST_INFO(umodem_host_devs); static int umodem_probe(device_t dev) Index: sys/dev/usb/serial/umoscom.c =================================================================== --- sys/dev/usb/serial/umoscom.c +++ sys/dev/usb/serial/umoscom.c @@ -278,14 +278,15 @@ .size = sizeof(struct umoscom_softc), }; +static const STRUCT_USB_HOST_ID umoscom_devs[] = { + {USB_VPI(USB_VENDOR_MOSCHIP, USB_PRODUCT_MOSCHIP_MCS7703, 0)} +}; + DRIVER_MODULE(umoscom, uhub, umoscom_driver, umoscom_devclass, NULL, 0); MODULE_DEPEND(umoscom, ucom, 1, 1, 1); MODULE_DEPEND(umoscom, usb, 1, 1, 1); MODULE_VERSION(umoscom, 1); - -static const STRUCT_USB_HOST_ID umoscom_devs[] = { - {USB_VPI(USB_VENDOR_MOSCHIP, USB_PRODUCT_MOSCHIP_MCS7703, 0)} -}; +USB_PNP_HOST_INFO(umoscom_devs); static int umoscom_probe(device_t dev) Index: sys/dev/usb/serial/uplcom.c =================================================================== --- sys/dev/usb/serial/uplcom.c +++ sys/dev/usb/serial/uplcom.c @@ -326,6 +326,7 @@ MODULE_DEPEND(uplcom, ucom, 1, 1, 1); MODULE_DEPEND(uplcom, usb, 1, 1, 1); MODULE_VERSION(uplcom, UPLCOM_MODVER); +USB_PNP_HOST_INFO(uplcom_devs); static int uplcom_probe(device_t dev) Index: sys/dev/usb/serial/uslcom.c =================================================================== --- sys/dev/usb/serial/uslcom.c +++ sys/dev/usb/serial/uslcom.c @@ -382,6 +382,7 @@ MODULE_DEPEND(uslcom, ucom, 1, 1, 1); MODULE_DEPEND(uslcom, usb, 1, 1, 1); MODULE_VERSION(uslcom, 1); +USB_PNP_HOST_INFO(uslcom_devs); static void uslcom_watchdog(void *arg) Index: sys/dev/usb/serial/uvisor.c =================================================================== --- sys/dev/usb/serial/uvisor.c +++ sys/dev/usb/serial/uvisor.c @@ -251,11 +251,6 @@ .size = sizeof(struct uvisor_softc), }; -DRIVER_MODULE(uvisor, uhub, uvisor_driver, uvisor_devclass, NULL, 0); -MODULE_DEPEND(uvisor, ucom, 1, 1, 1); -MODULE_DEPEND(uvisor, usb, 1, 1, 1); -MODULE_VERSION(uvisor, 1); - static const STRUCT_USB_HOST_ID uvisor_devs[] = { #define UVISOR_DEV(v,p,i) { USB_VPI(USB_VENDOR_##v, USB_PRODUCT_##v##_##p, i) } UVISOR_DEV(ACEECA, MEZ1000, UVISOR_FLAG_PALM4), @@ -288,6 +283,12 @@ #undef UVISOR_DEV }; +DRIVER_MODULE(uvisor, uhub, uvisor_driver, uvisor_devclass, NULL, 0); +MODULE_DEPEND(uvisor, ucom, 1, 1, 1); +MODULE_DEPEND(uvisor, usb, 1, 1, 1); +MODULE_VERSION(uvisor, 1); +USB_PNP_HOST_INFO(uvisor_devs); + static int uvisor_probe(device_t dev) { Index: sys/dev/usb/serial/uvscom.c =================================================================== --- sys/dev/usb/serial/uvscom.c +++ sys/dev/usb/serial/uvscom.c @@ -268,6 +268,7 @@ MODULE_DEPEND(uvscom, ucom, 1, 1, 1); MODULE_DEPEND(uvscom, usb, 1, 1, 1); MODULE_VERSION(uvscom, UVSCOM_MODVER); +USB_PNP_HOST_INFO(uvscom_devs); static int uvscom_probe(device_t dev) Index: sys/dev/usb/storage/umass.c =================================================================== --- sys/dev/usb/storage/umass.c +++ sys/dev/usb/storage/umass.c @@ -706,20 +706,21 @@ .size = sizeof(struct umass_softc), }; +static const STRUCT_USB_HOST_ID __used umass_devs[] = { + /* generic mass storage class */ + {USB_IFACE_CLASS(UICLASS_MASS),}, +}; + DRIVER_MODULE(umass, uhub, umass_driver, umass_devclass, NULL, 0); MODULE_DEPEND(umass, usb, 1, 1, 1); MODULE_DEPEND(umass, cam, 1, 1, 1); MODULE_VERSION(umass, 1); +USB_PNP_HOST_INFO(umass_devs); /* * USB device probe/attach/detach */ -static const STRUCT_USB_HOST_ID __used umass_devs[] = { - /* generic mass storage class */ - {USB_IFACE_CLASS(UICLASS_MASS),}, -}; - static uint16_t umass_get_proto(struct usb_interface *iface) { Index: sys/dev/usb/storage/urio.c =================================================================== --- sys/dev/usb/storage/urio.c +++ sys/dev/usb/storage/urio.c @@ -195,16 +195,17 @@ .size = sizeof(struct urio_softc), }; -DRIVER_MODULE(urio, uhub, urio_driver, urio_devclass, NULL, 0); -MODULE_DEPEND(urio, usb, 1, 1, 1); -MODULE_VERSION(urio, 1); - static const STRUCT_USB_HOST_ID urio_devs[] = { {USB_VPI(USB_VENDOR_DIAMOND, USB_PRODUCT_DIAMOND_RIO500USB, 0)}, {USB_VPI(USB_VENDOR_DIAMOND2, USB_PRODUCT_DIAMOND2_RIO600USB, 0)}, {USB_VPI(USB_VENDOR_DIAMOND2, USB_PRODUCT_DIAMOND2_RIO800USB, 0)}, }; +DRIVER_MODULE(urio, uhub, urio_driver, urio_devclass, NULL, 0); +MODULE_DEPEND(urio, usb, 1, 1, 1); +MODULE_VERSION(urio, 1); +USB_PNP_HOST_INFO(urio_devs); + static int urio_probe(device_t dev) { Index: sys/dev/usb/usb_hub.c =================================================================== --- sys/dev/usb/usb_hub.c +++ sys/dev/usb/usb_hub.c @@ -1731,6 +1731,7 @@ if (iface && iface->idesc) { snprintf(buf, buflen, "vendor=0x%04x product=0x%04x " "devclass=0x%02x devsubclass=0x%02x " + "devproto=0x%02x " "sernum=\"%s\" " "release=0x%04x " "mode=%s " @@ -1740,6 +1741,7 @@ UGETW(res.udev->ddesc.idProduct), res.udev->ddesc.bDeviceClass, res.udev->ddesc.bDeviceSubClass, + res.udev->ddesc.bDeviceProtocol, usb_get_serial(res.udev), UGETW(res.udev->ddesc.bcdDevice), (res.udev->flags.usb_mode == USB_MODE_HOST) ? "host" : "device", Index: sys/dev/usb/usbdi.h =================================================================== --- sys/dev/usb/usbdi.h +++ sys/dev/usb/usbdi.h @@ -266,8 +266,38 @@ */ struct usb_device_id { - /* Hook for driver specific information */ - unsigned long driver_info; + /* Select which fields to match against */ +#if _BYTE_ORDER == _LITTLE_ENDIAN + uint16_t + match_flag_vendor:1, + match_flag_product:1, + match_flag_dev_lo:1, + match_flag_dev_hi:1, + + match_flag_dev_class:1, + match_flag_dev_subclass:1, + match_flag_dev_protocol:1, + match_flag_int_class:1, + + match_flag_int_subclass:1, + match_flag_int_protocol:1, + match_flag_unused:6; +#else + uint16_t + match_flag_unused:6, + match_flag_int_protocol:1, + match_flag_int_subclass:1, + + match_flag_int_class:1, + match_flag_dev_protocol:1, + match_flag_dev_subclass:1, + match_flag_dev_class:1, + + match_flag_dev_hi:1, + match_flag_dev_lo:1, + match_flag_product:1, + match_flag_vendor:1; +#endif /* Used for product specific matches; the BCD range is inclusive */ uint16_t idVendor; @@ -285,21 +315,13 @@ uint8_t bInterfaceSubClass; uint8_t bInterfaceProtocol; - /* Select which fields to match against */ - uint8_t match_flag_vendor:1; - uint8_t match_flag_product:1; - uint8_t match_flag_dev_lo:1; - uint8_t match_flag_dev_hi:1; + /* Hook for driver specific information */ + unsigned long driver_info; - uint8_t match_flag_dev_class:1; - uint8_t match_flag_dev_subclass:1; - uint8_t match_flag_dev_protocol:1; - uint8_t match_flag_int_class:1; - - uint8_t match_flag_int_subclass:1; - uint8_t match_flag_int_protocol:1; - uint8_t match_flag_unused:6; - +/* + * XXX can't currently participate in auto driver loading + * XXX making it a union with the match_flag_* above messes up init + */ #if USB_HAVE_COMPAT_LINUX /* which fields to match against */ uint16_t match_flags; @@ -316,6 +338,21 @@ #endif } __aligned(32); +#define USB_STD_PNP_INFO "M16:mask;U16:vendor;U16:product;L16:product;G16:product;" \ + "U8:devclass;U8:devsubclass;U8:devprotocol;" \ + "U8:intclass;U8:intsubclass;U8:intprotocol;" +#define USB_STD_PNP_HOST_INFO USB_STD_PNP_INFO "T:mode=host;" +#define USB_STD_PNP_DEVICE_INFO USB_STD_PNP_INFO "T:mode=device;" +#define USB_PNP_HOST_INFO(table) \ + MODULE_PNP_INFO(USB_STD_PNP_HOST_INFO, usb, table, table, sizeof(table[0]), \ + sizeof(table) / sizeof(table[0])) +#define USB_PNP_DEVICE_INFO(table) \ + MODULE_PNP_INFO(USB_STD_PNP_DEVICE_INFO, usb, table, table, sizeof(table[0]), \ + sizeof(table) / sizeof(table[0])) +#define USB_PNP_DUAL_INFO(table) \ + MODULE_PNP_INFO(USB_STD_PNP_INFO, usb, table, table, sizeof(table[0]), \ + sizeof(table) / sizeof(table[0])) + /* check that the size of the structure above is correct */ extern char usb_device_id_assert[(sizeof(struct usb_device_id) == 32) ? 1 : -1]; Index: sys/dev/usb/wlan/if_rsu.c =================================================================== --- sys/dev/usb/wlan/if_rsu.c +++ sys/dev/usb/wlan/if_rsu.c @@ -217,6 +217,7 @@ MODULE_DEPEND(rsu, usb, 1, 1, 1); MODULE_DEPEND(rsu, firmware, 1, 1, 1); MODULE_VERSION(rsu, 1); +USB_PNP_HOST_INFO(rsu_devs); static uint8_t rsu_wme_ac_xfer_map[4] = { [WME_AC_BE] = RSU_BULK_TX_BE_BK, Index: sys/dev/usb/wlan/if_rum.c =================================================================== --- sys/dev/usb/wlan/if_rum.c +++ sys/dev/usb/wlan/if_rum.c @@ -2324,3 +2324,4 @@ MODULE_DEPEND(rum, wlan, 1, 1, 1); MODULE_DEPEND(rum, usb, 1, 1, 1); MODULE_VERSION(rum, 1); +USB_PNP_HOST_INFO(rum_devs); Index: sys/dev/usb/wlan/if_run.c =================================================================== --- sys/dev/usb/wlan/if_run.c +++ sys/dev/usb/wlan/if_run.c @@ -6216,3 +6216,4 @@ MODULE_DEPEND(run, usb, 1, 1, 1); MODULE_DEPEND(run, firmware, 1, 1, 1); MODULE_VERSION(run, 1); +USB_PNP_HOST_INFO(run_devs); Index: sys/dev/usb/wlan/if_uath.c =================================================================== --- sys/dev/usb/wlan/if_uath.c +++ sys/dev/usb/wlan/if_uath.c @@ -2823,3 +2823,4 @@ MODULE_DEPEND(uath, wlan, 1, 1, 1); MODULE_DEPEND(uath, usb, 1, 1, 1); MODULE_VERSION(uath, 1); +USB_PNP_HOST_INFO(uath_devs); Index: sys/dev/usb/wlan/if_upgt.c =================================================================== --- sys/dev/usb/wlan/if_upgt.c +++ sys/dev/usb/wlan/if_upgt.c @@ -2353,3 +2353,4 @@ MODULE_DEPEND(if_upgt, usb, 1, 1, 1); MODULE_DEPEND(if_upgt, wlan, 1, 1, 1); MODULE_DEPEND(if_upgt, upgtfw_fw, 1, 1, 1); +USB_PNP_HOST_INFO(upgt_devs); Index: sys/dev/usb/wlan/if_ural.c =================================================================== --- sys/dev/usb/wlan/if_ural.c +++ sys/dev/usb/wlan/if_ural.c @@ -401,6 +401,7 @@ MODULE_DEPEND(ural, usb, 1, 1, 1); MODULE_DEPEND(ural, wlan, 1, 1, 1); MODULE_VERSION(ural, 1); +USB_PNP_HOST_INFO(ural_devs); static int ural_match(device_t self) Index: sys/dev/usb/wlan/if_urtw.c =================================================================== --- sys/dev/usb/wlan/if_urtw.c +++ sys/dev/usb/wlan/if_urtw.c @@ -4396,3 +4396,4 @@ MODULE_DEPEND(urtw, wlan, 1, 1, 1); MODULE_DEPEND(urtw, usb, 1, 1, 1); MODULE_VERSION(urtw, 1); +USB_PNP_HOST_INFO(urtw_devs); Index: sys/dev/usb/wlan/if_urtwn.c =================================================================== --- sys/dev/usb/wlan/if_urtwn.c +++ sys/dev/usb/wlan/if_urtwn.c @@ -3494,3 +3494,4 @@ MODULE_DEPEND(urtwn, wlan, 1, 1, 1); MODULE_DEPEND(urtwn, firmware, 1, 1, 1); MODULE_VERSION(urtwn, 1); +USB_PNP_HOST_INFO(urtwn_devs); Index: sys/dev/usb/wlan/if_zyd.c =================================================================== --- sys/dev/usb/wlan/if_zyd.c +++ sys/dev/usb/wlan/if_zyd.c @@ -2910,3 +2910,4 @@ MODULE_DEPEND(zyd, usb, 1, 1, 1); MODULE_DEPEND(zyd, wlan, 1, 1, 1); MODULE_VERSION(zyd, 1); +USB_PNP_HOST_INFO(zyd_devs); Index: sys/dev/wi/if_wi_pccard.c =================================================================== --- sys/dev/wi/if_wi_pccard.c +++ sys/dev/wi/if_wi_pccard.c @@ -153,6 +153,7 @@ PCMCIA_CARD(TDK, LAK_CD011WL), { NULL } }; +PCCARD_PNP_INFO(wi_pccard_products); static int wi_pccard_probe(device_t dev) Index: sys/dev/xe/if_xe_pccard.c =================================================================== --- sys/dev/xe/if_xe_pccard.c +++ sys/dev/xe/if_xe_pccard.c @@ -386,3 +386,4 @@ devclass_t xe_devclass; DRIVER_MODULE(xe, pccard, xe_pccard_driver, xe_devclass, 0, 0); +PCCARD_PNP_INFO(xe_pccard_products); Index: sys/kern/kern_linker.c =================================================================== --- sys/kern/kern_linker.c +++ sys/kern/kern_linker.c @@ -1403,7 +1403,7 @@ if (mp->md_type != MDT_VERSION) continue; modname = mp->md_cval; - ver = ((struct mod_version *)mp->md_data)->mv_version; + ver = ((const struct mod_version *)mp->md_data)->mv_version; if (modlist_lookup(modname, ver) != NULL) { printf("module %s already present!\n", modname); /* XXX what can we do? this is a build error. :-( */ @@ -1524,7 +1524,7 @@ if (mp->md_type != MDT_VERSION) continue; modname = mp->md_cval; - nver = ((struct mod_version *) + nver = ((const struct mod_version *) mp->md_data)->mv_version; if (modlist_lookup(modname, nver) != NULL) { @@ -2050,7 +2050,7 @@ if (mp->md_type != MDT_VERSION) continue; modname = mp->md_cval; - ver = ((struct mod_version *)mp->md_data)->mv_version; + ver = ((const struct mod_version *)mp->md_data)->mv_version; mod = modlist_lookup(modname, ver); if (mod != NULL) { printf("interface %s.%d already present in the KLD" Index: sys/netgraph/bluetooth/drivers/bt3c/ng_bt3c_pccard.c =================================================================== --- sys/netgraph/bluetooth/drivers/bt3c/ng_bt3c_pccard.c +++ sys/netgraph/bluetooth/drivers/bt3c/ng_bt3c_pccard.c @@ -584,14 +584,14 @@ * PC Card (PCMCIA) probe routine */ +static struct pccard_product const bt3c_pccard_products[] = { + PCMCIA_CARD(3COM, 3CRWB609), + { NULL, } +}; + static int bt3c_pccard_probe(device_t dev) { - static struct pccard_product const bt3c_pccard_products[] = { - PCMCIA_CARD(3COM, 3CRWB609), - { NULL, } - }; - struct pccard_product const *pp = NULL; pp = pccard_product_lookup(dev, bt3c_pccard_products, @@ -1222,4 +1222,4 @@ DRIVER_MODULE(bt3c, pccard, bt3c_pccard_driver, bt3c_devclass, bt3c_modevent,0); MODULE_VERSION(ng_bt3c, NG_BLUETOOTH_VERSION); MODULE_DEPEND(ng_bt3c, netgraph, NG_ABI_VERSION, NG_ABI_VERSION,NG_ABI_VERSION); - +PCCARD_PNP_INFO(bt3c_pccard_products); Index: sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c =================================================================== --- sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c +++ sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c @@ -1872,4 +1872,4 @@ MODULE_DEPEND(ng_ubt, netgraph, NG_ABI_VERSION, NG_ABI_VERSION, NG_ABI_VERSION); MODULE_DEPEND(ng_ubt, ng_hci, NG_BLUETOOTH_VERSION, NG_BLUETOOTH_VERSION, NG_BLUETOOTH_VERSION); MODULE_DEPEND(ng_ubt, usb, 1, 1, 1); - +USB_PNP_HOST_INFO(ubt_devs); Index: sys/netgraph/bluetooth/drivers/ubtbcmfw/ubtbcmfw.c =================================================================== --- sys/netgraph/bluetooth/drivers/ubtbcmfw/ubtbcmfw.c +++ sys/netgraph/bluetooth/drivers/ubtbcmfw/ubtbcmfw.c @@ -170,8 +170,15 @@ .size = sizeof(struct ubtbcmfw_softc), }; +static const STRUCT_USB_HOST_ID ubtbcmfw_devs[] = { +/* Broadcom BCM2033 devices only */ + { USB_VPI(USB_VENDOR_BROADCOM, USB_PRODUCT_BROADCOM_BCM2033, 0) }, +}; + + DRIVER_MODULE(ubtbcmfw, uhub, ubtbcmfw_driver, ubtbcmfw_devclass, NULL, 0); MODULE_DEPEND(ubtbcmfw, usb, 1, 1, 1); +USB_PNP_HOST_INFO(ubtbcmfw_devs); /* * Probe for a USB Bluetooth device @@ -180,11 +187,6 @@ static int ubtbcmfw_probe(device_t dev) { - static const STRUCT_USB_HOST_ID devs[] = { - /* Broadcom BCM2033 devices only */ - { USB_VPI(USB_VENDOR_BROADCOM, USB_PRODUCT_BROADCOM_BCM2033, 0) }, - }; - struct usb_attach_arg *uaa = device_get_ivars(dev); if (uaa->usb_mode != USB_MODE_HOST) @@ -193,7 +195,7 @@ if (uaa->info.bIfaceIndex != 0) return (ENXIO); - return (usbd_lookup_id_by_uaa(devs, sizeof(devs), uaa)); + return (usbd_lookup_id_by_uaa(ubtbcmfw_devs, sizeof(ubtbcmfw_devs), uaa)); } /* ubtbcmfw_probe */ /* Index: sys/sys/module.h =================================================================== --- sys/sys/module.h +++ sys/sys/module.h @@ -89,10 +89,19 @@ struct mod_metadata { int md_version; /* structure version MDTV_* */ int md_type; /* type of entry MDT_* */ - void *md_data; /* specific data */ + const void *md_data; /* specific data */ const char *md_cval; /* common string label */ }; +struct mod_pnp_match_info +{ + const char *descr; /* Description of the table */ + const char *bus; /* Name of the bus for this table */ + const void *table; /* Pointer to pnp table */ + int entry_len; /* Length of each entry in the table (may be */ + /* logner than descr descriebs). */ + int num_entry; /* Number of entries in the table */ +}; #ifdef _KERNEL #include @@ -155,6 +164,44 @@ MODULE_METADATA(_##module##_version, MDT_VERSION, \ &_##module##_version, #module) +/** + * Generic macros to create pnp info hints that modules may export + * to allow external tools to parse their intenral device tables + * to make an informed guess about what driver(s) to load. + */ +#define MODULE_PNP_INFO(d, b, unique, t, l, n) \ + static const struct mod_pnp_match_info _module_pnp_##b##_##unique = { \ + .descr = d, \ + .bus = #b, \ + .table = t, \ + .entry_len = l, \ + .num_entry = n \ + }; \ + MODULE_METADATA(_md_##b##_pnpinfo_##unique, MDT_PNP_INFO, \ + &_module_pnp_##b##_##unique, #b); +/** + * descr is a string that describes each entry in the table. The general + * form is (TYPE:pnp_name[/pnp_name];)* + * where TYPE is one of the following: + * U8 uint8_t element + * V8 like U8 and 0xff means match any + * G16 uint16_t element, any value >= matches + * L16 uint16_t element, any value <= matches + * M16 uint16_t element, mask of which of the following fields to use. + * U16 uint16_t element + * V16 like U16 and 0xffff means match any + * U32 uint32_t element + * V32 like U32 and 0xffffffff means match any + * W32 Two 16-bit values with first pnp_name in LSW and second in MSW. + * Z pointer to a string to match exactly + * D like Z, but is the string passed to device_set_descr() + * P A pointer that should be ignored + * E EISA PNP Identifier (in binary, but bus publishes string) + * K Key for whole table. pnp_name=value. must be last, if present. + * + * The pnp_name "#" is reserved for other fields that should be ignored. + */ + extern struct sx modules_sx; #define MOD_XLOCK sx_xlock(&modules_sx) Index: usr.sbin/kldxref/kldxref.c =================================================================== --- usr.sbin/kldxref/kldxref.c +++ usr.sbin/kldxref/kldxref.c @@ -34,6 +34,7 @@ #include #include +#include #include #include #include @@ -53,7 +54,7 @@ #include "ef.h" -#define MAXRECSIZE 8192 +#define MAXRECSIZE (64 << 10) /* 64k */ #define check(val) if ((error = (val)) != 0) break static int dflag; /* do not create a hint file, only write on stdout */ @@ -134,14 +135,244 @@ return record_buf(str, len); } +/* From sys/isa/pnp.c */ +static char * +pnp_eisaformat(uint32_t id) +{ + uint8_t *data; + static char idbuf[8]; + const char hextoascii[] = "0123456789abcdef"; + + id = htole32(id); + data = (uint8_t *)&id; + idbuf[0] = '@' + ((data[0] & 0x7c) >> 2); + idbuf[1] = '@' + (((data[0] & 0x3) << 3) + ((data[1] & 0xe0) >> 5)); + idbuf[2] = '@' + (data[1] & 0x1f); + idbuf[3] = hextoascii[(data[2] >> 4)]; + idbuf[4] = hextoascii[(data[2] & 0xf)]; + idbuf[5] = hextoascii[(data[3] >> 4)]; + idbuf[6] = hextoascii[(data[3] & 0xf)]; + idbuf[7] = 0; + return(idbuf); +} + +struct pnp_elt +{ + int pe_kind; /* What kind of entry */ +#define TYPE_SZ_MASK 0x0f +#define TYPE_FLAGGED 0x10 /* all f's is a wildcard */ +#define TYPE_INT 0x20 /* Is a number */ +#define TYPE_PAIRED 0x40 +#define TYPE_LE 0x80 /* Matches <= this value */ +#define TYPE_GE 0x100 /* Matches >= this value */ +#define TYPE_MASK 0x200 /* Specifies a mask to follow */ +#define TYPE_U8 (1 | TYPE_INT) +#define TYPE_V8 (1 | TYPE_INT | TYPE_FLAGGED) +#define TYPE_G16 (2 | TYPE_INT | TYPE_GE) +#define TYPE_L16 (2 | TYPE_INT | TYPE_LE) +#define TYPE_M16 (2 | TYPE_INT | TYPE_MASK) +#define TYPE_U16 (2 | TYPE_INT) +#define TYPE_V16 (2 | TYPE_INT | TYPE_FLAGGED) +#define TYPE_U32 (4 | TYPE_INT) +#define TYPE_V32 (4 | TYPE_INT | TYPE_FLAGGED) +#define TYPE_W32 (4 | TYPE_INT | TYPE_PAIRED) +#define TYPE_D 7 +#define TYPE_Z 8 +#define TYPE_P 9 +#define TYPE_E 10 +#define TYPE_T 11 + int pe_offset; /* Offset within the element */ + char * pe_key; /* pnp key name */ + TAILQ_ENTRY(pnp_elt) next; /* Link */ +}; +typedef TAILQ_HEAD(pnp_head, pnp_elt) pnp_list; + +/* + * this function finds the data from the pnp table, as described by the + * the description and creates a new output (new_desc). This output table + * is a form that's easier for the agent that's automatically loading the + * modules. + * + * The format output is the simplified string from this routine in the + * same basic format as the pnp string, as documented in sys/module.h. + * First a string describing the format is output, the a count of the + * number of records, then each record. The format string also describes + * the length of each entry (though it isn't a fixed length when strings + * are present). + * + * type Output Meaning + * I uint32_t Integer equality comparison + * J uint32_t Pair of uint16_t fields converted to native + byte order. The two fields both must match. + * G uint32_t Greater than or equal to + * L uint32_t Less than or equal to + * M uint32_t Mask of which fields to test. Fields that + take up space increment the count. This + field must be first, and resets the count. + * D string Description of the device this pnp info is for + * Z string pnp string must match this + * T nothing T fields set pnp values that must be true for + * the entire table. + * Values are packed the same way that other values are packed in this file. + * Strings and int32_t's start on a 32-bit boundary and are padded with 0 + * bytes. Objects that are smaller than uint32_t are converted, without + * sign extension to uint32_t to simplify parsing downstream. + */ +static int +parse_pnp_list(const char *desc, char **new_desc, pnp_list *list) +{ + const char *walker = desc, *ep = desc + strlen(desc); + const char *colon, *semi; + struct pnp_elt *elt; + char *nd; + char type[8], key[32]; + int off; + + off = 0; + nd = *new_desc = malloc(strlen(desc) + 1); + if (verbose > 1) + printf("Converting %s into a list\n", desc); + while (walker < ep) { + colon = strchr(walker, ':'); + semi = strchr(walker, ';'); + if (semi != NULL && semi < colon) + goto err; + if (colon - walker > sizeof(type)) + goto err; + strncpy(type, walker, colon - walker); + type[colon - walker] = '\0'; + if (semi) { + if (semi - colon >= sizeof(key)) + goto err; + strncpy(key, colon + 1, semi - colon - 1); + key[semi - colon - 1] = '\0'; + walker = semi + 1; + } else { + if (strlen(colon + 1) >= sizeof(key)) + goto err; + strcpy(key, colon + 1); + walker = ep; + } + if (verbose > 1) + printf("Found type %s for name %s\n", type, key); + /* Skip pointer place holders */ + if (strcmp(type, "P") == 0) { + off += sizeof(void *); + continue; + } + + /* + * Add a node of the appropriate type + */ + elt = malloc(sizeof(struct pnp_elt) + strlen(key) + 1); + TAILQ_INSERT_TAIL(list, elt, next); + elt->pe_key = (char *)(elt + 1); + elt->pe_offset = off; + if (strcmp(type, "U8") == 0) + elt->pe_kind = TYPE_U8; + else if (strcmp(type, "V8") == 0) + elt->pe_kind = TYPE_V8; + else if (strcmp(type, "G16") == 0) + elt->pe_kind = TYPE_G16; + else if (strcmp(type, "L16") == 0) + elt->pe_kind = TYPE_L16; + else if (strcmp(type, "M16") == 0) + elt->pe_kind = TYPE_M16; + else if (strcmp(type, "U16") == 0) + elt->pe_kind = TYPE_U16; + else if (strcmp(type, "V16") == 0) + elt->pe_kind = TYPE_V16; + else if (strcmp(type, "U32") == 0) + elt->pe_kind = TYPE_U32; + else if (strcmp(type, "V32") == 0) + elt->pe_kind = TYPE_V32; + else if (strcmp(type, "W32") == 0) + elt->pe_kind = TYPE_W32; + else if (strcmp(type, "D") == 0) /* description char * */ + elt->pe_kind = TYPE_D; + else if (strcmp(type, "Z") == 0) /* char * to match */ + elt->pe_kind = TYPE_Z; + else if (strcmp(type, "P") == 0) /* Pointer -- ignored */ + elt->pe_kind = TYPE_P; + else if (strcmp(type, "E") == 0) /* EISA PNP ID, as uint32_t */ + elt->pe_kind = TYPE_E; + else if (strcmp(type, "T") == 0) + elt->pe_kind = TYPE_T; + else + goto err; + /* + * Maybe the rounding here needs to be more nuanced and/or somehow + * architecture specific. Fortunately, most tables in the system + * have sane ordering of types. + */ + if (elt->pe_kind & TYPE_INT) { + elt->pe_offset = roundup2(elt->pe_offset, elt->pe_kind & TYPE_SZ_MASK); + off = elt->pe_offset + (elt->pe_kind & TYPE_SZ_MASK); + } else if (elt->pe_kind == TYPE_E) { + /* Type E stored as Int, displays as string */ + elt->pe_offset = roundup2(elt->pe_offset, sizeof(uint32_t)); + off = elt->pe_offset + sizeof(uint32_t); + } else if (elt->pe_kind == TYPE_T) { + /* doesn't actually consume space in the table */ + off = elt->pe_offset; + } else { + elt->pe_offset = roundup2(elt->pe_offset, sizeof(void *)); + off = elt->pe_offset + sizeof(void *); + } + if (elt->pe_kind & TYPE_PAIRED) { + char *word, *ctx; + + for (word = strtok_r(key, "/", &ctx); + word; word = strtok_r(NULL, "/", &ctx)) { + sprintf(nd, "%c:%s;", elt->pe_kind & TYPE_FLAGGED ? 'J' : 'I', + word); + nd += strlen(nd); + } + + } + else { + if (elt->pe_kind & TYPE_FLAGGED) + *nd++ = 'J'; + else if (elt->pe_kind & TYPE_GE) + *nd++ = 'G'; + else if (elt->pe_kind & TYPE_LE) + *nd++ = 'L'; + else if (elt->pe_kind & TYPE_MASK) + *nd++ = 'M'; + else if (elt->pe_kind & TYPE_INT) + *nd++ = 'I'; + else if (elt->pe_kind == TYPE_D) + *nd++ = 'D'; + else if (elt->pe_kind == TYPE_Z || elt->pe_kind == TYPE_E) + *nd++ = 'Z'; + else if (elt->pe_kind == TYPE_T) + *nd++ = 'T'; + else + errx(1, "Impossible type %x\n", elt->pe_kind); + *nd++ = ':'; + strcpy(nd, key); + nd += strlen(nd); + *nd++ = ';'; + } + } + *nd++ = '\0'; + return 0; +err: + errx(1, "Parse error of description string %s", desc); +} + static int parse_entry(struct mod_metadata *md, const char *cval, struct elf_file *ef, const char *kldname) { struct mod_depend mdp; struct mod_version mdv; + struct mod_pnp_match_info pnp; + char descr[1024]; Elf_Off data = (Elf_Off)md->md_data; - int error = 0; + int error = 0, i, len; + char *walker; + void *table; record_start(); switch (md->md_type) { @@ -173,9 +404,119 @@ } break; case MDT_PNP_INFO: + check(EF_SEG_READ_REL(ef, data, sizeof(pnp), &pnp)); + check(EF_SEG_READ(ef, (Elf_Off)pnp.descr, sizeof(descr), descr)); + descr[sizeof(descr) - 1] = '\0'; if (dflag) { - printf(" pnp info for bus %s\n", cval); + printf(" pnp info for bus %s format %s %d entries of %d bytes\n", + cval, descr, pnp.num_entry, pnp.entry_len); + } else { + pnp_list list; + struct pnp_elt *elt, *elt_tmp; + char *new_descr; + + if (verbose > 1) + printf(" pnp info for bus %s format %s %d entries of %d bytes\n", + cval, descr, pnp.num_entry, pnp.entry_len); + /* + * Parse descr to weed out the chaff and to create a list + * of offsets to output. + */ + TAILQ_INIT(&list); + parse_pnp_list(descr, &new_descr, &list); + record_int(MDT_PNP_INFO); + record_string(cval); + record_string(new_descr); + record_int(pnp.num_entry); + len = pnp.num_entry * pnp.entry_len; + walker = table = malloc(len); + check(EF_SEG_READ_REL(ef, (Elf_Off)pnp.table, len, table)); + + /* + * Walk the list and output things. We've collapsed all the + * variant forms of the table down to just ints and strings. + */ + for (i = 0; i < pnp.num_entry; i++) { + TAILQ_FOREACH(elt, &list, next) { + uint8_t v1; + uint16_t v2; + uint32_t v4; + int value; + char buffer[1024]; + + if (elt->pe_kind == TYPE_W32) { + memcpy(&v4, walker + elt->pe_offset, sizeof(v4)); + value = v4 & 0xffff; + record_int(value); + if (verbose > 1) + printf("W32:%#x", value); + value = (v4 >> 16) & 0xffff; + record_int(value); + if (verbose > 1) + printf(":%#x;", value); + } else if (elt->pe_kind & TYPE_INT) { + switch (elt->pe_kind & TYPE_SZ_MASK) { + case 1: + memcpy(&v1, walker + elt->pe_offset, sizeof(v1)); + if ((elt->pe_kind & TYPE_FLAGGED) && v1 == 0xff) + value = -1; + else + value = v1; + break; + case 2: + memcpy(&v2, walker + elt->pe_offset, sizeof(v2)); + if ((elt->pe_kind & TYPE_FLAGGED) && v2 == 0xffff) + value = -1; + else + value = v2; + break; + case 4: + memcpy(&v4, walker + elt->pe_offset, sizeof(v4)); + if ((elt->pe_kind & TYPE_FLAGGED) && v4 == 0xffffffff) + value = -1; + else + value = v4; + break; + default: + errx(1, "Invalid size somehow %#x", elt->pe_kind); + } + if (verbose > 1) + printf("I:%#x;", value); + record_int(value); + } else if (elt->pe_kind == TYPE_T) { + /* Do nothing */ + } else { /* E, Z or D -- P already filtered */ + if (elt->pe_kind == TYPE_E) { + memcpy(&v4, walker + elt->pe_offset, sizeof(v4)); + strcpy(buffer, pnp_eisaformat(v4)); + } else { + char *ptr; + + ptr = *(char **)(walker + elt->pe_offset); + buffer[0] = '\0'; + if (ptr != 0) { + EF_SEG_READ(ef, (Elf_Off)ptr, + sizeof(buffer), buffer); + buffer[sizeof(buffer) - 1] = '\0'; + } + } + if (verbose > 1) + printf("%c:%s;", elt->pe_kind == TYPE_E ? 'E' : (elt->pe_kind == TYPE_Z ? 'Z' : 'D'), buffer); + record_string(buffer); + } + } + if (verbose > 1) + printf("\n"); + walker += pnp.entry_len; + } + /* Now free it */ + TAILQ_FOREACH_SAFE(elt, &list, next, elt_tmp) { + TAILQ_REMOVE(&list, elt, next); + free(elt); + } + free(table); } + break; default: warnx("unknown metadata record %d in file %s", md->md_type, kldname); }