From e45542fbd6cbc0a815b0808f16cf4a8e87410f64 Mon Sep 17 00:00:00 2001 From: Etienne Brateau Date: Sat, 24 Sep 2022 18:31:45 +0200 Subject: Fix when enabling APIC without SMP When we want to enable APIC, we must initialize the structure or otherwise, it will try to access to a not initialized memory addresses. Message-Id: <20220924163145.39894-1-etienne.brateau@gmail.com> --- i386/i386/smp.c | 10 ++-------- i386/i386at/model_dep.c | 10 ++++++++-- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'i386') diff --git a/i386/i386/smp.c b/i386/i386/smp.c index f64fb7f7..d7523a73 100644 --- a/i386/i386/smp.c +++ b/i386/i386/smp.c @@ -20,7 +20,6 @@ #include #include -#include #include @@ -42,12 +41,7 @@ static void smp_data_init(void) */ int smp_init(void) { - int apic_success; + smp_data_init(); - apic_success = acpi_apic_init(); - if (apic_success == ACPI_SUCCESS) { - smp_data_init(); - } - - return apic_success; + return 0; } diff --git a/i386/i386at/model_dep.c b/i386/i386at/model_dep.c index 105aedb2..1819526b 100644 --- a/i386/i386at/model_dep.c +++ b/i386/i386at/model_dep.c @@ -66,6 +66,7 @@ #include #include #include +#include #include #include #include @@ -170,10 +171,14 @@ void machine_init(void) hyp_init(); #else /* MACH_HYP */ -#if (NCPUS > 1) && defined(APIC) - smp_init(); +#if defined(APIC) + if (acpi_apic_init() != ACPI_SUCCESS) { + panic("APIC not found, unable to boot"); + } ioapic_configure(); lapic_enable_timer(); +#if (NCPUS > 1) + smp_init(); #warning FIXME: Rather unmask them from their respective drivers /* kd */ @@ -183,6 +188,7 @@ void machine_init(void) /* com1 */ unmask_irq(3); #endif /* NCPUS > 1 */ +#endif /* APIC */ #ifdef LINUX_DEV /* -- cgit v1.2.3