Source-Changes-HG archive

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

[src/trunk]: src/sys Move configure() and configure2() from subr_autoconf.c t...



details:   https://anonhg.NetBSD.org/src/rev/18a399959ed2
branches:  trunk
changeset: 747131:18a399959ed2
user:      pooka <pooka%NetBSD.org@localhost>
date:      Thu Sep 03 15:20:08 2009 +0000

description:
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.

diffstat:

 sys/kern/init_main.c     |  100 +++++++++++++++++++++++++++++++++++++++++-
 sys/kern/subr_autoconf.c |  111 ++++++++--------------------------------------
 sys/sys/device.h         |    8 ++-
 3 files changed, 122 insertions(+), 97 deletions(-)

diffs (truncated from 329 to 300 lines):

diff -r 08c8c41ebe28 -r 18a399959ed2 sys/kern/init_main.c
--- a/sys/kern/init_main.c      Thu Sep 03 14:55:29 2009 +0000
+++ b/sys/kern/init_main.c      Thu Sep 03 15:20:08 2009 +0000
@@ -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)
 {
diff -r 08c8c41ebe28 -r 18a399959ed2 sys/kern/subr_autoconf.c
--- a/sys/kern/subr_autoconf.c  Thu Sep 03 14:55:29 2009 +0000
+++ b/sys/kern/subr_autoconf.c  Thu Sep 03 15:20:08 2009 +0000
@@ -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);
-
-       /*
-        * Create threads to call back and finish configuration for
-        * devices that want interrupts enabled.
-        */
+       int i;
+
        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)
 {
 
diff -r 08c8c41ebe28 -r 18a399959ed2 sys/sys/device.h
--- a/sys/sys/device.h  Thu Sep 03 14:55:29 2009 +0000
+++ b/sys/sys/device.h  Thu Sep 03 15:20:08 2009 +0000
@@ -1,4 +1,4 @@



Home | Main Index | Thread Index | Old Index