aboutsummaryrefslogtreecommitdiff
path: root/i386/i386at
diff options
context:
space:
mode:
authorDamien Zammit <damien@zamaudio.com>2023-02-13 01:27:00 +0100
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2023-02-13 01:27:00 +0100
commit64799765e2af5f52a74de10c9575cc30009bdfd0 (patch)
tree72a20eb964f2ae182d0b7c47e72a84931f4936ca /i386/i386at
parentea2646b6d6f2dc02a59a2693d08957596c84e9d3 (diff)
downloadgnumach-64799765e2af5f52a74de10c9575cc30009bdfd0.tar.gz
gnumach-64799765e2af5f52a74de10c9575cc30009bdfd0.tar.bz2
gnumach-64799765e2af5f52a74de10c9575cc30009bdfd0.zip
i386: Refactor int stacks to be per cpu for SMP
This also serialises the AP bringup, so paging can be enabled per cpu one by one. Also-by: Almudena Garcia <liberamenso10000@gmail.com>
Diffstat (limited to 'i386/i386at')
-rw-r--r--i386/i386at/boothdr.S18
-rw-r--r--i386/i386at/ioapic.c5
-rw-r--r--i386/i386at/model_dep.c33
3 files changed, 31 insertions, 25 deletions
diff --git a/i386/i386at/boothdr.S b/i386/i386at/boothdr.S
index 82d4b34a..d1d1fa51 100644
--- a/i386/i386at/boothdr.S
+++ b/i386/i386at/boothdr.S
@@ -1,6 +1,6 @@
#include <mach/machine/asm.h>
-
+#include <i386/apic.h>
#include <i386/i386asm.h>
/*
@@ -54,7 +54,18 @@ boot_entry:
movw %ax,%ss
/* Switch to our own interrupt stack. */
- movl $_intstack+INTSTACK_SIZE,%esp
+ movl $solid_intstack+INTSTACK_SIZE-4, %esp
+ andl $0xfffffff0,%esp
+
+ /* Enable local apic */
+ xorl %eax, %eax
+ xorl %edx, %edx
+ movl $APIC_MSR, %ecx
+ rdmsr
+ orl $APIC_MSR_ENABLE, %eax
+ orl $APIC_MSR_BSP, %eax
+ movl $APIC_MSR, %ecx
+ wrmsr
/* Reset EFLAGS to a known state. */
pushl $0
@@ -91,9 +102,6 @@ iplt_done:
/* Jump into C code. */
call EXT(c_boot_entry)
- .comm _intstack,INTSTACK_SIZE
- .comm _eintstack,0
-
.align 16
.word 0
boot_gdt_descr:
diff --git a/i386/i386at/ioapic.c b/i386/i386at/ioapic.c
index 003690ed..f7b0d1d3 100644
--- a/i386/i386at/ioapic.c
+++ b/i386/i386at/ioapic.c
@@ -186,9 +186,8 @@ lapic_enable_timer(void)
/* Some buggy hardware requires this set again */
lapic->divider_config.r = LAPIC_TIMER_DIVIDE_16;
- /* Enable interrupts for the first time on BSP */
- asm("sti");
- printf("LAPIC timer configured\n");
+ /* Enable interrupts for the first time */
+ printf("LAPIC timer configured on cpu%d\n", cpu_number());
}
void
diff --git a/i386/i386at/model_dep.c b/i386/i386at/model_dep.c
index 3a4b41a1..5bde5d17 100644
--- a/i386/i386at/model_dep.c
+++ b/i386/i386at/model_dep.c
@@ -128,11 +128,9 @@ extern char version[];
/* If set, reboot the system on ctrl-alt-delete. */
boolean_t rebootflag = FALSE; /* exported to kdintr */
-/* Interrupt stack. */
-static char int_stack[INTSTACK_SIZE] __aligned(INTSTACK_SIZE);
-#if NCPUS <= 1
-vm_offset_t int_stack_top[1], int_stack_base[1];
-#endif
+/* Interrupt stacks */
+extern vm_offset_t int_stack_top[], int_stack_base[];
+extern uint8_t solid_intstack[]; /* bottom */
#ifdef LINUX_DEV
extern void linux_init(void);
@@ -165,15 +163,16 @@ void machine_init(void)
hyp_init();
#else /* MACH_HYP */
-#if defined(APIC)
- if (acpi_apic_init() != ACPI_SUCCESS) {
- panic("APIC not found, unable to boot");
- }
- ioapic_configure();
- lapic_enable_timer();
#if (NCPUS > 1)
+ acpi_apic_init();
smp_init();
+#endif
+#if defined(APIC)
+ ioapic_configure();
+#endif
+ startrtclock();
+#if defined(APIC)
#warning FIXME: Rather unmask them from their respective drivers
/* kd */
unmask_irq(1);
@@ -181,8 +180,7 @@ void machine_init(void)
unmask_irq(4);
/* com1 */
unmask_irq(3);
-#endif /* NCPUS > 1 */
-#endif /* APIC */
+#endif
#ifdef LINUX_DEV
/*
@@ -477,8 +475,7 @@ i386at_init(void)
hyp_p2m_init();
#endif /* MACH_XEN */
- int_stack_base[0] = (vm_offset_t)&int_stack;
- int_stack_top[0] = int_stack_base[0] + INTSTACK_SIZE - 4;
+ interrupt_stack_alloc();
}
/*
@@ -549,7 +546,6 @@ void c_boot_entry(vm_offset_t bi)
#endif /* MACH_KDB */
machine_slot[0].is_cpu = TRUE;
- machine_slot[0].running = TRUE;
machine_slot[0].cpu_subtype = CPU_SUBTYPE_AT386;
switch (cpu_type)
@@ -595,8 +591,11 @@ timemmap(dev_t dev, vm_offset_t off, vm_prot_t prot)
void
startrtclock(void)
{
-#ifndef APIC
+#ifdef APIC
+ lapic_enable_timer();
+#else
clkstart();
+ unmask_irq(0);
#endif
}