Source-Changes-HG archive

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

[src/trunk]: src/sys/kern - Centralize the declaration and clearing of `cold'.



details:   https://anonhg.NetBSD.org/src/rev/ddfcff003d35
branches:  trunk
changeset: 476489:ddfcff003d35
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Fri Sep 17 20:11:56 1999 +0000

description:
- Centralize the declaration and clearing of `cold'.
- Call configure() after setting up proc0.
- Call initclocks() from configure(), after cpu_configure().  Once the
  clocks are running, clear `cold'.  Then run interrupt-driven
  autoconfiguration.

diffstat:

 sys/kern/init_main.c     |  17 ++++++++++-------
 sys/kern/subr_autoconf.c |  35 +++++++++++++++++++++--------------
 2 files changed, 31 insertions(+), 21 deletions(-)

diffs (145 lines):

diff -r cbb3c7231e08 -r ddfcff003d35 sys/kern/init_main.c
--- a/sys/kern/init_main.c      Fri Sep 17 19:59:35 1999 +0000
+++ b/sys/kern/init_main.c      Fri Sep 17 20:11:56 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: init_main.c,v 1.155 1999/09/15 18:10:34 thorpej Exp $  */
+/*     $NetBSD: init_main.c,v 1.156 1999/09/17 20:11:56 thorpej Exp $  */
 
 /*
  * Copyright (c) 1995 Christopher G. Demetriou.  All rights reserved.
@@ -129,6 +129,7 @@
 
 struct vnode *rootvp, *swapdev_vp;
 int    boothowto;
+int    cold = 1;                       /* still working on startup */
 struct timeval boottime;
 struct timeval runtime;
 
@@ -209,12 +210,14 @@
        /* Initialize sockets. */
        soinit();
 
-       disk_init();            /* must come before autoconfiguration */
-       tty_init();             /* initialise tty list */
+       /*
+        * The following 3 things must be done before autoconfiguration.
+        */
+       disk_init();            /* initialize disk list */
+       tty_init();             /* initialize tty list */
 #if NRND > 0
-       rnd_init();
+       rnd_init();             /* initialize RNG */
 #endif
-       configure();            /* configure the hardware */
 
        /*
         * Initialize process and pgrp structures.
@@ -318,8 +321,8 @@
 #endif
        vfsinit();
 
-       /* Start real time and statistics clocks. */
-       initclocks();
+       /* Configure the system hardware.  This will enable interrupts. */
+       configure();
 
 #ifdef SYSVSHM
        /* Initialize System V style shared memory. */
diff -r cbb3c7231e08 -r ddfcff003d35 sys/kern/subr_autoconf.c
--- a/sys/kern/subr_autoconf.c  Fri Sep 17 19:59:35 1999 +0000
+++ b/sys/kern/subr_autoconf.c  Fri Sep 17 20:11:56 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: subr_autoconf.c,v 1.42 1999/09/15 19:37:08 thorpej Exp $       */
+/*     $NetBSD: subr_autoconf.c,v 1.43 1999/09/17 20:11:56 thorpej Exp $       */
 
 /*
  * Copyright (c) 1992, 1993
@@ -50,6 +50,7 @@
 #include <sys/device.h>
 #include <sys/malloc.h>
 #include <sys/systm.h>
+#include <sys/kernel.h>
 #include <sys/errno.h>
 #include <machine/limits.h>
 
@@ -95,13 +96,6 @@
 struct evcntlist allevents;            /* list of all event counters */
 
 /*
- * This variable indicates, from the configuration machinery's point of
- * view, if interrupts are enabled.  They start disabled, and are
- * considered enabled once cpu_configure() returns.
- */
-int    config_interrupts_enabled;
-
-/*
  * Configure the system's hardware.
  */
 void
@@ -120,7 +114,14 @@
         * to be enabled.
         */
        cpu_configure();
-       config_interrupts_enabled = 1;
+
+       /*
+        * Now that we've found all the hardware, start the real time
+        * and statistics clocks.
+        */
+       initclocks();
+
+       cold = 0;       /* clocks are running, we're warm now! */
 
        /*
         * Now callback to finish configuration for devices which want
@@ -323,7 +324,8 @@
                panic("config_attach: device name too long");
 
        /* get memory for all device vars */
-       dev = (struct device *)malloc(ca->ca_devsize, M_DEVBUF, M_NOWAIT);
+       dev = (struct device *)malloc(ca->ca_devsize, M_DEVBUF,
+           cold ? M_NOWAIT : M_WAITOK);
        if (!dev)
            panic("config_attach: memory allocation for device softc failed");
        memset(dev, 0, ca->ca_devsize);
@@ -359,7 +361,8 @@
                while (new <= dev->dv_unit)
                        new *= 2;
                cd->cd_ndevs = new;
-               nsp = malloc(new * sizeof(void *), M_DEVBUF, M_NOWAIT); 
+               nsp = malloc(new * sizeof(void *), M_DEVBUF,
+                   cold ? M_NOWAIT : M_WAITOK);        
                if (nsp == 0)
                        panic("config_attach: %sing dev array",
                            old != 0 ? "expand" : "creat");
@@ -578,7 +581,9 @@
        }
 #endif
 
-       dc = malloc(sizeof(*dc), M_DEVBUF, M_WAITOK);
+       dc = malloc(sizeof(*dc), M_DEVBUF, cold ? M_NOWAIT : M_WAITOK);
+       if (dc == NULL)
+               panic("config_defer: unable to allocate callback");
 
        dc->dc_dev = dev;
        dc->dc_func = func;
@@ -599,7 +604,7 @@
        /*
         * If interrupts are enabled, callback now.
         */
-       if (config_interrupts_enabled) {
+       if (cold == 0) {
                (*func)(dev);
                return;
        }
@@ -612,7 +617,9 @@
        }
 #endif
 
-       dc = malloc(sizeof(*dc), M_DEVBUF, M_WAITOK);
+       dc = malloc(sizeof(*dc), M_DEVBUF, cold ? M_NOWAIT : M_WAITOK);
+       if (dc == NULL)
+               panic("config_interrupts: unable to allocate callback");
 
        dc->dc_dev = dev;
        dc->dc_func = func;



Home | Main Index | Thread Index | Old Index