Clean up the docking-event related message, and make it possible to

debug docking events without having to debug the rest of PNPBIOS.
This commit is contained in:
thorpej 2000-04-26 20:33:46 +00:00
parent ce7f4dafe1
commit 43db473cbb
1 changed files with 43 additions and 32 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: pnpbios.c,v 1.13 2000/04/22 06:38:24 thorpej Exp $ */ /* $NetBSD: pnpbios.c,v 1.14 2000/04/26 20:33:46 thorpej Exp $ */
/* /*
* Copyright (c) 2000 Christian E. Hopps. All rights reserved. * Copyright (c) 2000 Christian E. Hopps. All rights reserved.
* Copyright (c) 1999 * Copyright (c) 1999
@ -67,6 +67,12 @@
#define DPRINTF(x) #define DPRINTF(x)
#endif #endif
#ifdef PNPBIOSEVENTSDEBUG
#define EDPRINTF(x) printf x
#else
#define EDPRINTF(x)
#endif
struct pnpbios_softc { struct pnpbios_softc {
struct device sc_dev; struct device sc_dev;
isa_chipset_tag_t sc_ic; isa_chipset_tag_t sc_ic;
@ -290,10 +296,8 @@ pnpbios_attach(parent, self, aux)
sc->sc_evaddr = pnpbios_mapit(evaddrp, NBPG, sc->sc_evaddr = pnpbios_mapit(evaddrp, NBPG,
VM_PROT_READ | VM_PROT_WRITE); VM_PROT_READ | VM_PROT_WRITE);
if (!sc->sc_evaddr) if (!sc->sc_evaddr)
printf("pnpbios: couldn't map event flag 0x%08x\n", printf("%s: couldn't map event flag 0x%08x\n",
evaddrp); sc->sc_dev.dv_xname, evaddrp);
DPRINTF(("pnpbios: event flag vaddr 0x%08x\n",
(int)sc->sc_evaddr));
} }
#endif #endif
#ifdef PNPBIOSVERBOSE #ifdef PNPBIOSVERBOSE
@ -332,6 +336,24 @@ pnpbios_attach(parent, self, aux)
printf(": nodes %d, max len %d\n", num, size); printf(": nodes %d, max len %d\n", num, size);
buf = malloc(size, M_DEVBUF, M_NOWAIT); buf = malloc(size, M_DEVBUF, M_NOWAIT);
#ifdef PNPBIOSEVENTS
EDPRINTF(("%s: event flag vaddr 0x%08x\n", sc->sc_dev.dv_xname,
(int)sc->sc_evaddr));
#endif
res = pnpbios_getdockinfo(&di);
if (res == PNP_RC_SYSTEM_NOT_DOCKED)
printf("%s: not docked\n", sc->sc_dev.dv_xname);
else if (res)
EDPRINTF(("%s: dockinfo fails 0x%02x\n",
sc->sc_dev.dv_xname, res));
else {
char idstr[8];
pnpbios_id_to_string(di.di_id, idstr);
printf("%s: dock id %s serial number %d capabilities 0x%04x\n",
sc->sc_dev.dv_xname, idstr, di.di_serial, di.di_cap);
}
idx = 0; idx = 0;
for (i = 0; i < num && idx != 0xff; i++) { for (i = 0; i < num && idx != 0xff; i++) {
int node = idx; int node = idx;
@ -353,19 +375,6 @@ pnpbios_attach(parent, self, aux)
free(buf, M_DEVBUF); free(buf, M_DEVBUF);
#ifdef PNPBIOSVERBOSE
res = pnpbios_getdockinfo(&di);
if (res == PNP_RC_SYSTEM_NOT_DOCKED)
printf("%s: not docked\n", sc->sc_dev.dv_xname);
else if (res)
DPRINTF(("pnpbios: dockinfo fails 0x%02x\n", res));
else {
char idstr[8];
pnpbios_id_to_string(di.di_id, idstr);
printf("%s: dock id %s serial number %d capabilities 0x%04x\n",
sc->sc_dev.dv_xname, idstr, di.di_serial, di.di_cap);
}
#endif
#ifdef PNPBIOSEVENTS #ifdef PNPBIOSEVENTS
/* if we have an event mechnism queue a thread to deal with them */ /* if we have an event mechnism queue a thread to deal with them */
/* XXX need to update with irq if we do that */ /* XXX need to update with irq if we do that */
@ -1311,7 +1320,7 @@ pnpbios_event_thread(arg)
else { else {
poll = hz; poll = hz;
rv = pnpbios_sendmessage(PNP_CM_PNP_OS_ACTIVE); rv = pnpbios_sendmessage(PNP_CM_PNP_OS_ACTIVE);
DPRINTF(("pnpbios: os active returns 0x%02x\n", rv)); EDPRINTF(("pnpbios: os active returns 0x%02x\n", rv));
} }
config_pending_decr(); config_pending_decr();
@ -1324,50 +1333,52 @@ pnpbios_event_thread(arg)
"pnpbiosevent", 0); "pnpbiosevent", 0);
else if (((evflag = *sc->sc_evaddr) & 0x01) == 0) { else if (((evflag = *sc->sc_evaddr) & 0x01) == 0) {
if (evflag) if (evflag)
DPRINTF(("pnpbios: evflags 0x%02x\n", evflag)); EDPRINTF(("pnpbios: evflags 0x%02x\n", evflag));
(void)tsleep(pnpbios_event_thread, PWAIT, (void)tsleep(pnpbios_event_thread, PWAIT,
"pnpbiosevent", poll); "pnpbiosevent", poll);
continue; continue;
} else { } else {
DPRINTF(("pnpbios: evflags 0x%02x\n", evflag)); EDPRINTF(("pnpbios: evflags 0x%02x\n", evflag));
} }
start: start:
if ((rv = pnpbios_getevent(&event))) { if ((rv = pnpbios_getevent(&event))) {
DPRINTF(("pnpbios: getevent rc: 0x%02x\n", rv)); EDPRINTF(("pnpbios: getevent rc: 0x%02x\n", rv));
#ifdef DIAGNOSTIC #ifdef DIAGNOSTIC
if (rv != PNP_RC_EVENTS_NOT_PENDING) if (rv != PNP_RC_EVENTS_NOT_PENDING)
printf("pnpbios: getevent failed: %d\n", rv); printf("%s: getevent failed: %d\n",
sc->sc_dev.dv_xname, rv);
#endif #endif
continue; continue;
} }
switch (event) { switch (event) {
case PNP_EID_ABOUT_TO_CHANGE_CONFIG: case PNP_EID_ABOUT_TO_CHANGE_CONFIG:
DPRINTF(("pnpbios: about to change event\n")); EDPRINTF(("pnpbios: about to change event\n"));
break; break;
case PNP_EID_DOCK_CHANGED: case PNP_EID_DOCK_CHANGED:
DPRINTF(("pnpbios: dock changed event\n")); EDPRINTF(("pnpbios: dock changed event\n"));
break; break;
case PNP_EID_SYSTEM_DEVICE_CHANGED: case PNP_EID_SYSTEM_DEVICE_CHANGED:
DPRINTF(("pnpbios: system device changed event\n")); EDPRINTF(("pnpbios: system device changed event\n"));
break; break;
case PNP_EID_CONFIG_CHANGE_FAILED: case PNP_EID_CONFIG_CHANGE_FAILED:
DPRINTF(("pnpbios: config changed event\n")); EDPRINTF(("pnpbios: config changed event\n"));
break; break;
case PNP_EID_UNKNOWN_SYSTEM_EVENT: case PNP_EID_UNKNOWN_SYSTEM_EVENT:
#ifdef DIAGNOSTIC #ifdef DIAGNOSTIC
printf("pnpbios: \"unknown system event\"\n"); printf("%s: \"unknown system event\"\n",
sc->sc_dev.dv_xname);
#endif #endif
break; break;
default: default:
#ifdef DIAGNOSTIC #ifdef DIAGNOSTIC
#ifdef PNPBIOSVERBOSE #ifdef PNPBIOSVERBOSE
if (event & PNP_EID_OEM_DEFINED_BIT) if (event & PNP_EID_OEM_DEFINED_BIT)
printf("pnpbios: vendor defined event 0x%04x\n", printf("%s: vendor defined event 0x%04x\n",
event); sc->sc_dev.dv_xname, event);
else else
#endif #endif
printf("pnpbios: unkown event 0x%04x\n", printf("%s: unkown event 0x%04x\n",
event); sc->sc_dev.dv_xname, event);
#endif #endif
break; break;
} }