From 21056065db4e84997761b2801da2ed2f19cfeb3a Mon Sep 17 00:00:00 2001 From: thorpej Date: Thu, 27 Sep 2001 17:13:39 +0000 Subject: [PATCH] Move the code that enumerates the pnpbios device nodes into a separate function. --- sys/arch/i386/pnpbios/pnpbios.c | 58 +++++++++++++++++++++++---------- 1 file changed, 41 insertions(+), 17 deletions(-) diff --git a/sys/arch/i386/pnpbios/pnpbios.c b/sys/arch/i386/pnpbios/pnpbios.c index d8547bff024a..25acaa2536a5 100644 --- a/sys/arch/i386/pnpbios/pnpbios.c +++ b/sys/arch/i386/pnpbios/pnpbios.c @@ -1,4 +1,4 @@ -/* $NetBSD: pnpbios.c,v 1.24 2001/09/10 21:19:15 chris Exp $ */ +/* $NetBSD: pnpbios.c,v 1.25 2001/09/27 17:13:39 thorpej Exp $ */ /* * Copyright (c) 2000 Jason R. Thorpe. All rights reserved. @@ -140,6 +140,7 @@ static int pnpbios_submatch __P((struct device *parent, struct cfdata *match, void *aux)); extern int pnpbioscall __P((int)); +static void pnpbios_enumerate(struct pnpbios_softc *sc); static int pnpbios_update_dock_status __P((struct pnpbios_softc *sc)); /* scanning functions */ @@ -287,16 +288,14 @@ pnpbios_attach(parent, self, aux) { struct pnpbios_softc *sc = (struct pnpbios_softc *)self; struct pnpbios_attach_args *paa = aux; - struct pnpdevnode *dn; caddr_t p; unsigned int codepbase, datapbase, evaddrp; caddr_t codeva, datava; extern char pnpbiostramp[], epnpbiostramp[]; - int res, num, i, size, idx; + int res, num, size; #ifdef PNPBIOSEVENTS int evtype; #endif - u_int8_t *buf; pnpbios_softc = sc; sc->sc_ic = paa->paa_ic; @@ -362,7 +361,6 @@ pnpbios_attach(parent, self, aux) } printf(": nodes %d, max len %d\n", num, size); - buf = malloc(size, M_DEVBUF, M_NOWAIT); #ifdef PNPBIOSEVENTS EDPRINTF(("%s: event flag vaddr 0x%08x\n", sc->sc_dev.dv_xname, @@ -373,6 +371,44 @@ pnpbios_attach(parent, self, aux) sc->sc_docked = -1; (void) pnpbios_update_dock_status(sc); + /* Enumerate the device nodes. */ + pnpbios_enumerate(sc); + +#ifdef PNPBIOSEVENTS + /* if we have an event mechnism queue a thread to deal with them */ + /* XXX need to update with irq if we do that */ + if (evtype != PNP_IC_CONTROL_EVENT_NONE) { + if (evtype != PNP_IC_CONTROL_EVENT_POLL || sc->sc_evaddr) { + sc->sc_threadrun = 1; + config_pending_incr(); + kthread_create(pnpbios_create_event_thread, sc); + } + } +#endif +} + +static void +pnpbios_enumerate(sc) + struct pnpbios_softc *sc; +{ + int res, num, i, size, idx; + struct pnpdevnode *dn; + u_int8_t *buf; + + res = pnpbios_getnumnodes(&num, &size); + if (res) { + printf("%s: pnpbios_getnumnodes: error %d\n", + sc->sc_dev.dv_xname, res); + return; + } + + buf = malloc(size, M_DEVBUF, M_NOWAIT); + if (buf == NULL) { + printf("%s: unable to allocate node buffer\n", + sc->sc_dev.dv_xname); + return; + } + /* * Loop through the list of indices getting data and match/attaching * each as appropriate. @@ -437,18 +473,6 @@ pnpbios_attach(parent, self, aux) printf("%s: last index %d\n", sc->sc_dev.dv_xname, idx); free(buf, M_DEVBUF); - -#ifdef PNPBIOSEVENTS - /* if we have an event mechnism queue a thread to deal with them */ - /* XXX need to update with irq if we do that */ - if (evtype != PNP_IC_CONTROL_EVENT_NONE) { - if (evtype != PNP_IC_CONTROL_EVENT_POLL || sc->sc_evaddr) { - sc->sc_threadrun = 1; - config_pending_incr(); - kthread_create(pnpbios_create_event_thread, sc); - } - } -#endif } static int