From 0d7a86c3564dac6726e0d8b6dae849c1ccab533c Mon Sep 17 00:00:00 2001 From: thorpej Date: Fri, 17 Sep 1999 20:11:56 +0000 Subject: [PATCH] - 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. --- sys/kern/init_main.c | 17 ++++++++++------- sys/kern/subr_autoconf.c | 35 +++++++++++++++++++++-------------- 2 files changed, 31 insertions(+), 21 deletions(-) diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index eadab3abae60..59ebd9af0535 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -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 @@ extern struct user *proc0paddr; struct vnode *rootvp, *swapdev_vp; int boothowto; +int cold = 1; /* still working on startup */ struct timeval boottime; struct timeval runtime; @@ -209,12 +210,14 @@ main() /* 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 @@ main() #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 --git a/sys/kern/subr_autoconf.c b/sys/kern/subr_autoconf.c index 2856b0ce02ba..2d8be9838770 100644 --- a/sys/kern/subr_autoconf.c +++ b/sys/kern/subr_autoconf.c @@ -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 #include #include +#include #include #include @@ -94,13 +95,6 @@ static void config_process_deferred __P((struct deferred_config_head *, struct devicelist alldevs; /* list of all devices */ 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. */ @@ -120,7 +114,14 @@ configure() * 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 @@ config_attach(parent, cf, aux, print) 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 @@ config_attach(parent, cf, aux, print) 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 @@ config_defer(dev, func) } #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 @@ config_interrupts(dev, func) /* * If interrupts are enabled, callback now. */ - if (config_interrupts_enabled) { + if (cold == 0) { (*func)(dev); return; } @@ -612,7 +617,9 @@ config_interrupts(dev, func) } #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;