From 606580c05dff497d050ad7eaef67ff368b3ca004 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Wed, 3 Aug 2016 09:27:23 +0200 Subject: [PATCH] announce that a cpu is online in the apic code => move code from main.c to apic.c, because the time of announcement depends on the boot process. (The multi- and the single-kernel version of HermitCore use a different boot process.) --- hermit/arch/x86/kernel/apic.c | 8 +++++++- hermit/kernel/main.c | 4 ---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/hermit/arch/x86/kernel/apic.c b/hermit/arch/x86/kernel/apic.c index 645503fcc..ff9df9268 100644 --- a/hermit/arch/x86/kernel/apic.c +++ b/hermit/arch/x86/kernel/apic.c @@ -560,9 +560,13 @@ int apic_calibration(void) initialized = 1; irq_nested_enable(flags); + atomic_int32_inc(&cpu_online); + return 0; } + atomic_int32_inc(&cpu_online); + old = get_clock_tick(); /* wait for the next time slice */ @@ -721,7 +725,7 @@ found_mp: apic_io_entry_t* io_entry = (apic_io_entry_t*) addr; ioapic = (ioapic_t*) ((size_t) io_entry->addr); kprintf("Found IOAPIC at 0x%x\n", ioapic); - if (is_single_kernel() && ioapic) { + if (is_single_kernel() && ioapic) { page_map(IOAPIC_ADDR, (size_t)ioapic & PAGE_MASK, 1, flags); vma_add(IOAPIC_ADDR, IOAPIC_ADDR + PAGE_SIZE, VMA_READ|VMA_WRITE); ioapic = (ioapic_t*) IOAPIC_ADDR; @@ -842,6 +846,8 @@ int smp_start(void) irq_enable(); + atomic_int32_inc(&cpu_online); + return smp_main(); } diff --git a/hermit/kernel/main.c b/hermit/kernel/main.c index 24a936c02..792ac2765 100644 --- a/hermit/kernel/main.c +++ b/hermit/kernel/main.c @@ -130,7 +130,6 @@ static int hermit_init(void) #ifndef CONFIG_VGA uart_init(); #endif - atomic_int32_inc(&cpu_online); return 0; } @@ -267,8 +266,6 @@ int smp_main(void) print_status(); - atomic_int32_inc(&cpu_online); - /* wait for the other cpus */ while(atomic_int32_read(&cpu_online) < atomic_int32_read(&possible_cpus)) PAUSE; @@ -546,7 +543,6 @@ int hermit_main(void) hermit_init(); system_calibration(); // enables also interrupts - kprintf("This is Hermit %s, build date %u\n", VERSION, &__DATE__); kprintf("Isle %d of %d possible isles\n", isle, possible_isles); kprintf("Kernel starts at %p and ends at %p\n", &kernel_start, &kernel_end);