Module Name: src Committed By: pooka Date: Thu Sep 3 15:20:08 UTC 2009
Modified Files: src/sys/kern: init_main.c subr_autoconf.c src/sys/sys: device.h Log Message: Move configure() and configure2() from subr_autoconf.c to init_main.c, since they are only peripherially related to the autoconf subsystem and more related to boot initialization. Also, apply _KERNEL_OPT to autoconf where necessary. To generate a diff of this commit: cvs rdiff -u -r1.397 -r1.398 src/sys/kern/init_main.c cvs rdiff -u -r1.179 -r1.180 src/sys/kern/subr_autoconf.c cvs rdiff -u -r1.120 -r1.121 src/sys/sys/device.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/kern/init_main.c diff -u src/sys/kern/init_main.c:1.397 src/sys/kern/init_main.c:1.398 --- src/sys/kern/init_main.c:1.397 Wed Sep 2 08:07:05 2009 +++ src/sys/kern/init_main.c Thu Sep 3 15:20:08 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: init_main.c,v 1.397 2009/09/02 08:07:05 pooka Exp $ */ +/* $NetBSD: init_main.c,v 1.398 2009/09/03 15:20:08 pooka Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -97,7 +97,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.397 2009/09/02 08:07:05 pooka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.398 2009/09/03 15:20:08 pooka Exp $"); #include "opt_ddb.h" #include "opt_ipsec.h" @@ -233,6 +233,13 @@ struct timeval50 boottime50; #endif +#ifdef _KERNEL_OPT +#include "opt_userconf.h" +#endif +#ifdef USERCONF +#include <sys/userconf.h> +#endif + extern struct proc proc0; extern struct lwp lwp0; extern struct cwdinfo cwdi0; @@ -252,6 +259,8 @@ static void check_console(struct lwp *l); static void start_init(void *); +static void configure(void); +static void configure2(void); void main(void); void __secmodel_none(void); @@ -686,6 +695,93 @@ /* NOTREACHED */ } +/* + * Configure the system's hardware. + */ +static void +configure(void) +{ + + /* Initialize autoconf data structures. */ + config_init(); + /* + * XXX + * callout_setfunc() requires mutex(9) so it can't be in config_init() + * on amiga and atari which use config_init() and autoconf(9) fucntions + * to initialize console devices. + */ + config_twiddle_init(); + + pmf_init(); +#if NDRVCTL > 0 + drvctl_init(); +#endif + +#ifdef USERCONF + if (boothowto & RB_USERCONF) + user_config(); +#endif + + if ((boothowto & (AB_SILENT|AB_VERBOSE)) == AB_SILENT) { + printf_nolog("Detecting hardware..."); + } + + /* + * Do the machine-dependent portion of autoconfiguration. This + * sets the configuration machinery here in motion by "finding" + * the root bus. When this function returns, we expect interrupts + * to be enabled. + */ + cpu_configure(); +} + +static void +configure2(void) +{ + CPU_INFO_ITERATOR cii; + struct cpu_info *ci; + int s; + + /* + * 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! */ + s = splsched(); + curcpu()->ci_schedstate.spc_flags |= SPCF_RUNNING; + splx(s); + + /* Boot the secondary processors. */ + for (CPU_INFO_FOREACH(cii, ci)) { + uvm_cpu_attach(ci); + } + mp_online = true; +#if defined(MULTIPROCESSOR) + cpu_boot_secondary_processors(); +#endif + + /* Setup the runqueues and scheduler. */ + runq_init(); + sched_init(); + + /* + * Bus scans can make it appear as if the system has paused, so + * twiddle constantly while config_interrupts() jobs are running. + */ + config_twiddle_fn(NULL); + + /* + * Create threads to call back and finish configuration for + * devices that want interrupts enabled. + */ + config_create_interruptthreads(); + + /* Get the threads going and into any sleeps before continuing. */ + yield(); +} + static void check_console(struct lwp *l) { Index: src/sys/kern/subr_autoconf.c diff -u src/sys/kern/subr_autoconf.c:1.179 src/sys/kern/subr_autoconf.c:1.180 --- src/sys/kern/subr_autoconf.c:1.179 Tue Jul 14 13:24:00 2009 +++ src/sys/kern/subr_autoconf.c Thu Sep 3 15:20:08 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_autoconf.c,v 1.179 2009/07/14 13:24:00 tsutsui Exp $ */ +/* $NetBSD: subr_autoconf.c,v 1.180 2009/09/03 15:20:08 pooka Exp $ */ /* * Copyright (c) 1996, 2000 Christopher G. Demetriou @@ -77,10 +77,12 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.179 2009/07/14 13:24:00 tsutsui Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.180 2009/09/03 15:20:08 pooka Exp $"); +#ifdef _KERNEL_OPT #include "opt_ddb.h" #include "drvctl.h" +#endif #include <sys/param.h> #include <sys/device.h> @@ -112,12 +114,7 @@ #include <machine/limits.h> -#include "opt_userconf.h" -#ifdef USERCONF -#include <sys/userconf.h> -#endif - -#ifdef __i386__ +#if defined(__i386__) && defined(_KERNEL_OPT) #include "opt_splash.h" #if defined(SPLASHSCREEN) && defined(SPLASHSCREEN_PROGRESS) #include <dev/splash/splash.h> @@ -173,7 +170,6 @@ static void config_makeroom(int, struct cfdriver *); static void config_devlink(device_t); static void config_devunlink(device_t); -static void config_twiddle_fn(void *); static void pmflock_debug(device_t, const char *, int); static void pmflock_debug_with_flags(device_t, const char *, int PMF_FN_PROTO); @@ -402,94 +398,15 @@ kthread_exit(0); } -/* - * Configure the system's hardware. - */ void -configure(void) +config_create_interruptthreads() { - /* Initialize data structures. */ - config_init(); - /* - * XXX - * callout_setfunc() requires mutex(9) so it can't be in config_init() - * on amiga and atari which use config_init() and autoconf(9) fucntions - * to initialize console devices. - */ - callout_setfunc(&config_twiddle_ch, config_twiddle_fn, NULL); - - pmf_init(); -#if NDRVCTL > 0 - drvctl_init(); -#endif - -#ifdef USERCONF - if (boothowto & RB_USERCONF) - user_config(); -#endif - - if ((boothowto & (AB_SILENT|AB_VERBOSE)) == AB_SILENT) { - config_do_twiddle = 1; - printf_nolog("Detecting hardware..."); - } - - /* - * Do the machine-dependent portion of autoconfiguration. This - * sets the configuration machinery here in motion by "finding" - * the root bus. When this function returns, we expect interrupts - * to be enabled. - */ - cpu_configure(); -} - -void -configure2(void) -{ - CPU_INFO_ITERATOR cii; - struct cpu_info *ci; - int i, s; - - /* - * 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! */ - s = splsched(); - curcpu()->ci_schedstate.spc_flags |= SPCF_RUNNING; - splx(s); - - /* Boot the secondary processors. */ - for (CPU_INFO_FOREACH(cii, ci)) { - uvm_cpu_attach(ci); - } - mp_online = true; -#if defined(MULTIPROCESSOR) - cpu_boot_secondary_processors(); -#endif - - /* Setup the runqueues and scheduler. */ - runq_init(); - sched_init(); - - /* - * Bus scans can make it appear as if the system has paused, so - * twiddle constantly while config_interrupts() jobs are running. - */ - config_twiddle_fn(NULL); + int i; - /* - * Create threads to call back and finish configuration for - * devices that want interrupts enabled. - */ for (i = 0; i < interrupt_config_threads; i++) { (void)kthread_create(PRI_NONE, 0, NULL, config_interrupts_thread, NULL, NULL, "config"); } - - /* Get the threads going and into any sleeps before continuing. */ - yield(); } /* @@ -1917,6 +1834,16 @@ } void +config_twiddle_init() +{ + + if ((boothowto & (AB_SILENT|AB_VERBOSE)) == AB_SILENT) { + config_do_twiddle = 1; + } + callout_setfunc(&config_twiddle_ch, config_twiddle_fn, NULL); +} + +void config_twiddle_fn(void *cookie) { Index: src/sys/sys/device.h diff -u src/sys/sys/device.h:1.120 src/sys/sys/device.h:1.121 --- src/sys/sys/device.h:1.120 Fri Jun 26 19:30:45 2009 +++ src/sys/sys/device.h Thu Sep 3 15:20:08 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: device.h,v 1.120 2009/06/26 19:30:45 dyoung Exp $ */ +/* $NetBSD: device.h,v 1.121 2009/09/03 15:20:08 pooka Exp $ */ /* * Copyright (c) 1996, 2000 Christopher G. Demetriou @@ -416,8 +416,6 @@ void config_init(void); void drvctl_init(void); -void configure(void); -void configure2(void); int config_cfdriver_attach(struct cfdriver *); int config_cfdriver_detach(struct cfdriver *); @@ -459,10 +457,14 @@ void config_interrupts(device_t, void (*)(device_t)); void config_pending_incr(void); void config_pending_decr(void); +void config_create_interruptthreads(void); int config_finalize_register(device_t, int (*)(device_t)); void config_finalize(void); +void config_twiddle_init(void); +void config_twiddle_fn(void *); + device_t device_lookup(cfdriver_t, int); void *device_lookup_private(cfdriver_t, int); #ifdef __HAVE_DEVICE_REGISTER