Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/i386/pnpbios Move the code that enumerates the pnpb...



details:   https://anonhg.NetBSD.org/src/rev/ed9ca982c0a1
branches:  trunk
changeset: 515510:ed9ca982c0a1
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Thu Sep 27 17:13:39 2001 +0000

description:
Move the code that enumerates the pnpbios device nodes into a
separate function.

diffstat:

 sys/arch/i386/pnpbios/pnpbios.c |  58 ++++++++++++++++++++++++++++------------
 1 files changed, 41 insertions(+), 17 deletions(-)

diffs (107 lines):

diff -r ccdde2590714 -r ed9ca982c0a1 sys/arch/i386/pnpbios/pnpbios.c
--- a/sys/arch/i386/pnpbios/pnpbios.c   Thu Sep 27 16:31:23 2001 +0000
+++ b/sys/arch/i386/pnpbios/pnpbios.c   Thu Sep 27 17:13:39 2001 +0000
@@ -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 @@
     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 @@
 {
        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 @@
        }
 
        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 @@
        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 @@
                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



Home | Main Index | Thread Index | Old Index