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.
This commit is contained in:
pooka 2009-09-03 15:20:08 +00:00
parent d0cad2b04e
commit 5e46a7c29a
3 changed files with 120 additions and 95 deletions

View File

@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.397 2009/09/02 08:07:05 pooka Exp $"
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 @@ int start_init_exec; /* semaphore for start_init() */
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 @@ main(void)
/* 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)
{

View File

@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.179 2009/07/14 13:24:00 tsutsui
#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_devdealloc(device_t);
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 @@ config_interrupts_thread(void *cookie)
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);
int i;
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.
*/
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();
}
/*
@ -1916,6 +1833,16 @@ config_finalize(void)
}
}
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)
{

View File

@ -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 @@ int config_handle_wedges(struct device *, int);
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_deferred(device_t);
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