From 8ee6f7a06ce2d569805edd35a1ac79c2511b2a27 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Sun, 11 Feb 2024 23:40:21 -0500 Subject: kernel/amd64: acpi: Fetch LAPIC base separate This commit creates a acpi_get_lapic_base() so we don't have to parse the MADT each time we want the Local APIC base. Signed-off-by: Ian Moffett --- sys/firmware/acpi/acpi_madt.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'sys/firmware') diff --git a/sys/firmware/acpi/acpi_madt.c b/sys/firmware/acpi/acpi_madt.c index 5f5d8d4..055ebd2 100644 --- a/sys/firmware/acpi/acpi_madt.c +++ b/sys/firmware/acpi/acpi_madt.c @@ -46,6 +46,14 @@ __KERNEL_META("$Hyra$: acpi_madt.c, Ian Marco Moffett, " static struct acpi_madt *madt = NULL; +void * +acpi_get_lapic_base(void) +{ + if (madt == NULL) + return NULL; + return (void *)(uint64_t)madt->lapic_addr; +} + static void do_parse(struct cpu_info *ci) { @@ -53,7 +61,6 @@ do_parse(struct cpu_info *ci) uint8_t *end = NULL; void *ioapic_mmio_base = NULL; - void *lapic_mmio_base = NULL; struct apic_header *hdr = NULL; struct ioapic *ioapic = NULL; @@ -61,10 +68,6 @@ do_parse(struct cpu_info *ci) cur = (uint8_t *)(madt + 1); end = (uint8_t *)madt + madt->hdr.length; - /* Init the Local APIC */ - lapic_mmio_base = (void *)(uintptr_t)madt->lapic_addr; - ci->lapic_base = lapic_mmio_base; - /* Parse the rest of the MADT */ while (cur < end) { hdr = (void *)cur; -- cgit v1.2.3