[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 2/6 gnumach] separate lapic_enable from lapic_setup
From: |
Damien Zammit |
Subject: |
[PATCH 2/6 gnumach] separate lapic_enable from lapic_setup |
Date: |
Mon, 05 Feb 2024 11:33:44 +0000 |
This allows us to init the lapic without
necessarily turning on the IOAPIC interrupts.
---
i386/i386/apic.c | 15 +++++++++++++--
i386/i386/apic.h | 2 ++
i386/i386/mp_desc.c | 6 +++---
i386/i386at/ioapic.c | 1 +
4 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/i386/i386/apic.c b/i386/i386/apic.c
index 700fafd3..feb49c85 100644
--- a/i386/i386/apic.c
+++ b/i386/i386/apic.c
@@ -308,6 +308,18 @@ void apic_send_ipi(unsigned dest_shorthand, unsigned
deliv_mode, unsigned dest_m
void
lapic_enable(void)
+{
+ lapic->spurious_vector.r |= LAPIC_ENABLE;
+}
+
+void
+lapic_disable(void)
+{
+ lapic->spurious_vector.r &= ~LAPIC_ENABLE;
+}
+
+void
+lapic_setup(void)
{
unsigned long flags;
int apic_id;
@@ -338,8 +350,7 @@ lapic_enable(void)
/* Enable LAPIC to send or recieve IPI/SIPIs */
dummy = lapic->spurious_vector.r;
lapic->spurious_vector.r = IOAPIC_SPURIOUS_BASE
- | LAPIC_ENABLE_DIRECTED_EOI
- | LAPIC_ENABLE;
+ | LAPIC_ENABLE_DIRECTED_EOI;
lapic->error_status.r = 0;
diff --git a/i386/i386/apic.h b/i386/i386/apic.h
index e1d49895..29387d9d 100644
--- a/i386/i386/apic.h
+++ b/i386/i386/apic.h
@@ -244,6 +244,8 @@ int apic_get_total_gsis(void);
void picdisable(void);
void lapic_eoi(void);
void ioapic_irq_eoi(int pin);
+void lapic_setup(void);
+void lapic_disable(void);
void lapic_enable(void);
void lapic_enable_timer(void);
void calibrate_lapic_timer(void);
diff --git a/i386/i386/mp_desc.c b/i386/i386/mp_desc.c
index 467f2728..860bbd9e 100644
--- a/i386/i386/mp_desc.c
+++ b/i386/i386/mp_desc.c
@@ -269,6 +269,7 @@ cpu_setup(int cpu)
machine_slot[cpu].cpu_type = machine_slot[0].cpu_type;
init_fpu();
+ lapic_setup();
lapic_enable();
cpu_launch_first_thread(THREAD_NULL);
}
@@ -312,12 +313,10 @@ start_other_cpus(void)
memcpy((void*)phystokv(AP_BOOT_ADDR), (void*) &apboot,
(uint32_t)&apbootend - (uint32_t)&apboot);
-#ifndef APIC
- lapic_enable(); /* Enable lapic only once */
-#endif
unsigned cpu;
splhigh();
+ lapic_disable();
bspdone = 0;
for (cpu = 1; cpu < ncpus; cpu++) {
@@ -335,5 +334,6 @@ start_other_cpus(void)
__sync_synchronize();
}
printf("BSP: Completed SMP init\n");
+ lapic_enable();
}
#endif /* NCPUS > 1 */
diff --git a/i386/i386at/ioapic.c b/i386/i386at/ioapic.c
index 270362c3..2553a2c9 100644
--- a/i386/i386at/ioapic.c
+++ b/i386/i386at/ioapic.c
@@ -458,5 +458,6 @@ ioapic_configure(void)
}
/* Start the IO APIC receiving interrupts */
+ lapic_setup();
lapic_enable();
}
--
2.43.0
- [PATCH 0/6 gnumach] SMP on AMD hardware, Damien Zammit, 2024/02/05
- [PATCH 1/6 gnumach] Fix apic_send_ipi function clobbering read only fields, Damien Zammit, 2024/02/05
- [PATCH 2/6 gnumach] separate lapic_enable from lapic_setup,
Damien Zammit <=
- [PATCH 3/6 gnumach] smp: Remove hardcoded AP_BOOT_ADDR, Damien Zammit, 2024/02/05
- [PATCH 4/6 gnumach] Add HPET timer for small accurate delays, Damien Zammit, 2024/02/05
- [PATCH 5/6 gnumach] smp: Use HPET instead of pit one-shot that is unreliable, Damien Zammit, 2024/02/05
- [PATCH 6/6 gnumach] smp: Fix INIT/STARTUP IPI sequence, Damien Zammit, 2024/02/05