From bb2b9030e84f6638c53379fa3061ee49bef5b868 Mon Sep 17 00:00:00 2001 From: Doug Rabson Date: Thu, 14 Oct 1999 21:03:03 +0000 Subject: * Add some verbose logging to the PnP parser and fix a couple of bugs. * Move pnp_eisaformat() to pnp.c, declared in . * Turn the pnpbios code into an enumerator for the isa bus. This allows all devices known to the bios to be probed automatically. Currently the pnpbios code is dependant on the PNPBIOS option. As the code is tested more and when more drivers are converted this will be made the default. I have PnP changes in the wings for fdc, atkbd, psm, pcaudio, and joy. Sio already works with pnpbios. --- sys/amd64/amd64/bios.c | 73 +++++++++++++++++++++++++++++++++----------------- 1 file changed, 48 insertions(+), 25 deletions(-) (limited to 'sys/amd64') diff --git a/sys/amd64/amd64/bios.c b/sys/amd64/amd64/bios.c index b66d87212226..63158c4686b7 100644 --- a/sys/amd64/amd64/bios.c +++ b/sys/amd64/amd64/bios.c @@ -31,10 +31,13 @@ * Code for dealing with the BIOS in x86 PC systems. */ +#include "opt_pnp.h" + #include #include #include #include +#include #include #include #include @@ -43,6 +46,8 @@ #include #include #include +#include +#include #define BIOS_START 0xe0000 #define BIOS_SIZE 0x20000 @@ -57,10 +62,6 @@ static u_int bios32_SDCI = 0; static void bios32_init(void *junk); SYSINIT(bios32, SI_SUB_CPU, SI_ORDER_ANY, bios32_init, NULL); -static void pnpbios_scan(void); -static char *pnp_eisaformat(u_int8_t *data); - - /* * bios32_init * @@ -127,7 +128,6 @@ bios32_init(void *junk) printf("pnpbios: OEM ID %x\n", pt->oemdevid); } - pnpbios_scan(); } else { printf("pnpbios: Bad PnP BIOS data checksum\n"); } @@ -450,6 +450,8 @@ bios16(struct bios_args *args, char *fmt, ...) return (i); } +#ifdef PNPBIOS /* remove conditional later */ + /* * PnP BIOS interface; enumerate devices only known to the system * BIOS and save information about them for later use. @@ -483,11 +485,20 @@ struct pnp_sysdevargs struct pnp_sysdev node; }; +/* + * This function is called after the bus has assigned resource + * locations for a logical device. + */ +static void +pnpbios_set_config(void *arg, struct isa_config *config, int enable) +{ +} + /* * Quiz the PnP BIOS, build a list of PNP IDs and resource data. */ static void -pnpbios_scan(void) +pnpbios_identify(driver_t *driver, device_t parent) { struct PnPBIOS_table *pt = PnPBIOStable; struct bios_args args; @@ -498,6 +509,7 @@ pnpbios_scan(void) u_int8_t *devnodebuf, tag; u_int32_t *devid, *compid; int idx, left; + device_t dev; /* no PnP BIOS information */ if (pt == NULL) @@ -542,6 +554,16 @@ pnpbios_scan(void) break; } + /* Add the device and parse its resources */ + dev = BUS_ADD_CHILD(parent, ISA_ORDER_PNP, NULL, -1); + isa_set_vendorid(dev, pd->devid); + isa_set_logicalid(dev, pd->devid); + ISA_SET_CONFIG_CALLBACK(parent, dev, pnpbios_set_config, 0); + pnp_parse_resources(dev, &pd->devdata[0], + pd->size - sizeof(struct pnp_sysdev)); + if (!device_get_desc(dev)) + device_set_desc_copy(dev, pnp_eisaformat(pd->devid)); + /* Find device IDs */ devid = &pd->devid; compid = NULL; @@ -572,29 +594,30 @@ pnpbios_scan(void) } if (bootverbose) { printf("pnpbios: handle %d device ID %s (%08x)", - pd->handle, pnp_eisaformat((u_int8_t *)devid), *devid); + pd->handle, pnp_eisaformat(*devid), *devid); if (compid != NULL) printf(" compat ID %s (%08x)", - pnp_eisaformat((u_int8_t *)compid), *compid); + pnp_eisaformat(*compid), *compid); printf("\n"); } } } -/* XXX should be somewhere else */ -static char * -pnp_eisaformat(u_int8_t *data) -{ - static char idbuf[8]; - const char hextoascii[] = "0123456789abcdef"; - - 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); -} +static device_method_t pnpbios_methods[] = { + /* Device interface */ + DEVMETHOD(device_identify, pnpbios_identify), + + { 0, 0 } +}; + +static driver_t pnpbios_driver = { + "pnpbios", + pnpbios_methods, + 1, /* no softc */ +}; + +static devclass_t pnpbios_devclass; + +DRIVER_MODULE(pnpbios, isa, pnpbios_driver, pnpbios_devclass, 0, 0); + +#endif /* PNPBIOS */ -- cgit v1.3