From d631ab59a79389f22fffd1a4937eec05405efd1b Mon Sep 17 00:00:00 2001 From: Sepherosa Ziehau Date: Sat, 4 Jun 2011 21:29:32 +0800 Subject: [PATCH] i386: Split mp_enable() into multiple SYSINITs --- sys/platform/pc32/apic/ioapic.c | 19 ++++++++++ sys/platform/pc32/apic/lapic.c | 22 ++++++++++++ sys/platform/pc32/i386/machdep.c | 8 ----- sys/platform/pc32/i386/mp_machdep.c | 55 ++++------------------------- 4 files changed, 48 insertions(+), 56 deletions(-) diff --git a/sys/platform/pc32/apic/ioapic.c b/sys/platform/pc32/apic/ioapic.c index c212c83d40..31b4f31e50 100644 --- a/sys/platform/pc32/apic/ioapic.c +++ b/sys/platform/pc32/apic/ioapic.c @@ -39,6 +39,7 @@ #include #include #include +#include #include #include @@ -586,3 +587,21 @@ ioapic_map(vm_paddr_t pa) KKASSERT(pa < 0x100000000LL); return pmap_mapdev_uncacheable(pa, PAGE_SIZE); } + +static void +ioapic_sysinit(void *dummy __unused) +{ + int error; + + if (!ioapic_enable) + return; + + KASSERT(lapic_enable, ("I/O APIC is enabled, but LAPIC is disabled\n")); + error = ioapic_config(); + if (error) { + ioapic_enable = 0; + icu_reinit_noioapic(); + lapic_fixup_noioapic(); + } +} +SYSINIT(ioapic, SI_BOOT2_IOAPIC, SI_ORDER_FIRST, ioapic_sysinit, NULL) diff --git a/sys/platform/pc32/apic/lapic.c b/sys/platform/pc32/apic/lapic.c index a0f3343bad..2af9ca8c21 100644 --- a/sys/platform/pc32/apic/lapic.c +++ b/sys/platform/pc32/apic/lapic.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include @@ -713,3 +714,24 @@ lapic_fixup_noioapic(void) temp |= APIC_LVT_MASKED; lapic->lvt_lint1 = temp; } + +static void +lapic_sysinit(void *dummy __unused) +{ + if (lapic_enable) { + int error; + + error = lapic_config(); + if (error) + lapic_enable = 0; + } + + if (lapic_enable) { + /* Initialize BSP's local APIC */ + lapic_init(TRUE); + } else if (ioapic_enable) { + ioapic_enable = 0; + icu_reinit_noioapic(); + } +} +SYSINIT(lapic, SI_BOOT2_LAPIC, SI_ORDER_FIRST, lapic_sysinit, NULL) diff --git a/sys/platform/pc32/i386/machdep.c b/sys/platform/pc32/i386/machdep.c index d0b18f77f7..8d3046b22a 100644 --- a/sys/platform/pc32/i386/machdep.c +++ b/sys/platform/pc32/i386/machdep.c @@ -367,14 +367,6 @@ again: */ bufinit(); vm_pager_bufferinit(); - -#ifdef SMP - /* - * OK, enough kmem_alloc/malloc state should be up, lets get on with it! - */ - mp_start(); /* fire up the APs and APICs */ - mp_announce(); -#endif /* SMP */ } static void diff --git a/sys/platform/pc32/i386/mp_machdep.c b/sys/platform/pc32/i386/mp_machdep.c index 780205fc69..e3503f3a22 100644 --- a/sys/platform/pc32/i386/mp_machdep.c +++ b/sys/platform/pc32/i386/mp_machdep.c @@ -168,13 +168,11 @@ static u_int boot_address; static int mp_finish; static int mp_finish_lapic; -static void mp_enable(u_int boot_addr); - static int start_all_aps(u_int boot_addr); static void install_ap_tramp(u_int boot_addr); static int start_ap(struct mdglobaldata *gd, u_int boot_addr, int smibest); static int smitest(void); -static void cpu_simple_setup(void); +static void mp_bsp_simple_setup(void); static cpumask_t smp_startup_mask = 1; /* which cpus have been started */ static cpumask_t smp_lapic_mask = 1; /* which cpus have lapic been inited */ @@ -196,17 +194,6 @@ mp_bootaddress(u_int basemem) return boot_address; } -/* - * Startup the SMP processors. - */ -void -mp_start(void) -{ - POSTCODE(MP_START_POST); - mp_enable(boot_address); -} - - /* * Print various information about the SMP system hardware and setup. */ @@ -301,47 +288,19 @@ init_secondary(void) */ /* - * start the SMP system + * Start the SMP system */ static void -mp_enable(u_int boot_addr) +mp_start_aps(void *dummy __unused) { - int error; - - POSTCODE(MP_ENABLE_POST); - - if (lapic_enable) { - error = lapic_config(); - if (error) - lapic_enable = 0; - } - - if (lapic_enable) { - /* Initialize BSP's local APIC */ - lapic_init(TRUE); - } else if (ioapic_enable) { - ioapic_enable = 0; - icu_reinit_noioapic(); - } - if (lapic_enable) { /* start each Application Processor */ - start_all_aps(boot_addr); + start_all_aps(boot_address); } else { - cpu_simple_setup(); - } - - if (ioapic_enable) { - KASSERT(lapic_enable, - ("I/O APIC is enabled, but LAPIC is disabled\n")); - error = ioapic_config(); - if (error) { - ioapic_enable = 0; - icu_reinit_noioapic(); - lapic_fixup_noioapic(); - } + mp_bsp_simple_setup(); } } +SYSINIT(startaps, SI_BOOT2_START_APS, SI_ORDER_FIRST, mp_start_aps, NULL) /* * start each AP in our list @@ -1128,7 +1087,7 @@ cpu_send_ipiq_passive(int dcpu) #endif static void -cpu_simple_setup(void) +mp_bsp_simple_setup(void) { /* build our map of 'other' CPUs */ mycpu->gd_other_cpus = smp_startup_mask & ~CPUMASK(mycpu->gd_cpuid); -- 2.41.0