1
0
Fork 0

fix/kernel: Fixed MADT tables to use

acpi_madt_entry_t header;
This commit is contained in:
Kevin Alavik 2025-05-16 19:23:25 +02:00
parent 09de945b15
commit 1f70ada525
Signed by: cmpsb
GPG key ID: 10D1CC0526FDC6D7
3 changed files with 20 additions and 16 deletions

View file

@ -2,7 +2,7 @@
MAKEFLAGS += -rR MAKEFLAGS += -rR
.SUFFIXES: .SUFFIXES:
QEMUFLAGS := -m 2G -serial stdio QEMUFLAGS := -m 2G -serial stdio -smp 4
USER_QEMUFLAGS ?= USER_QEMUFLAGS ?=
IMAGE_NAME := release/emk IMAGE_NAME := release/emk

View file

@ -18,6 +18,7 @@
#include <flanterm/backends/fb.h> #include <flanterm/backends/fb.h>
#endif // FLANTERM_SUPPORT #endif // FLANTERM_SUPPORT
#include <sys/acpi.h> #include <sys/acpi.h>
#include <sys/acpi/madt.h>
__attribute__((used, section(".limine_requests"))) static volatile LIMINE_BASE_REVISION(3); __attribute__((used, section(".limine_requests"))) static volatile LIMINE_BASE_REVISION(3);
__attribute__((used, section(".limine_requests"))) static volatile struct limine_memmap_request memmap_request = { __attribute__((used, section(".limine_requests"))) static volatile struct limine_memmap_request memmap_request = {
@ -37,6 +38,9 @@ __attribute__((used, section(".limine_requests"))) volatile struct limine_frameb
__attribute__((used, section(".limine_requests"))) static volatile struct limine_rsdp_request rsdp_request = { __attribute__((used, section(".limine_requests"))) static volatile struct limine_rsdp_request rsdp_request = {
.revision = 0, .revision = 0,
.id = LIMINE_RSDP_REQUEST}; .id = LIMINE_RSDP_REQUEST};
__attribute__((used, section(".limine_requests"))) static volatile struct limine_mp_request mp_request = {
.revision = 0,
.id = LIMINE_MP_REQUEST};
__attribute__((used, section(".limine_requests_start"))) static volatile LIMINE_REQUESTS_START_MARKER; __attribute__((used, section(".limine_requests_start"))) static volatile LIMINE_REQUESTS_START_MARKER;
__attribute__((used, section(".limine_requests_end"))) static volatile LIMINE_REQUESTS_END_MARKER; __attribute__((used, section(".limine_requests_end"))) static volatile LIMINE_REQUESTS_END_MARKER;
@ -171,7 +175,7 @@ void emk_entry(void)
acpi_init(); acpi_init();
log_early("Initialized ACPI"); log_early("Initialized ACPI");
void *madt = acpi_find_table("APIC"); acpi_madt_t *madt = (acpi_madt_t *)acpi_find_table("APIC");
if (!madt) if (!madt)
{ {
kpanic(NULL, "Failed to find MADT table"); kpanic(NULL, "Failed to find MADT table");
@ -179,5 +183,12 @@ void emk_entry(void)
log_early("Found MADT at %p", madt); log_early("Found MADT at %p", madt);
if (!mp_request.response)
{
kpanic(NULL, "Failed to get MP request");
}
log_early("%d available cores", mp_request.response->cpu_count);
hlt(); hlt();
} }

View file

@ -30,8 +30,7 @@ typedef struct acpi_madt_entry
/* Entry Type 0: Processor Local APIC */ /* Entry Type 0: Processor Local APIC */
typedef struct acpi_madt_lapic typedef struct acpi_madt_lapic
{ {
uint8_t type; acpi_madt_entry_t header;
uint8_t length;
uint8_t acpi_proc_id; /* ACPI Processor ID */ uint8_t acpi_proc_id; /* ACPI Processor ID */
uint8_t apic_id; /* APIC ID */ uint8_t apic_id; /* APIC ID */
uint32_t flags; /* Bit 0: Processor Enabled, Bit 1: Online Capable */ uint32_t flags; /* Bit 0: Processor Enabled, Bit 1: Online Capable */
@ -40,8 +39,7 @@ typedef struct acpi_madt_lapic
/* Entry Type 1: I/O APIC */ /* Entry Type 1: I/O APIC */
typedef struct acpi_madt_ioapic typedef struct acpi_madt_ioapic
{ {
uint8_t type; acpi_madt_entry_t header;
uint8_t length;
uint8_t ioapic_id; /* I/O APIC's ID */ uint8_t ioapic_id; /* I/O APIC's ID */
uint8_t reserved; /* Reserved (0) */ uint8_t reserved; /* Reserved (0) */
uint32_t ioapic_addr; /* I/O APIC Address */ uint32_t ioapic_addr; /* I/O APIC Address */
@ -51,8 +49,7 @@ typedef struct acpi_madt_ioapic
/* Entry Type 2: I/O APIC Interrupt Source Override */ /* Entry Type 2: I/O APIC Interrupt Source Override */
typedef struct acpi_madt_ioapic_src_ovr typedef struct acpi_madt_ioapic_src_ovr
{ {
uint8_t type; acpi_madt_entry_t header;
uint8_t length;
uint8_t bus_source; /* Bus Source */ uint8_t bus_source; /* Bus Source */
uint8_t irq_source; /* IRQ Source */ uint8_t irq_source; /* IRQ Source */
uint32_t gsi; /* Global System Interrupt */ uint32_t gsi; /* Global System Interrupt */
@ -62,8 +59,7 @@ typedef struct acpi_madt_ioapic_src_ovr
/* Entry Type 3: I/O APIC Non-Maskable Interrupt Source */ /* Entry Type 3: I/O APIC Non-Maskable Interrupt Source */
typedef struct acpi_madt_ioapic_nmi_src typedef struct acpi_madt_ioapic_nmi_src
{ {
uint8_t type; acpi_madt_entry_t header;
uint8_t length;
uint8_t nmi_source; /* NMI Source */ uint8_t nmi_source; /* NMI Source */
uint8_t reserved; /* Reserved */ uint8_t reserved; /* Reserved */
uint16_t flags; /* Flags */ uint16_t flags; /* Flags */
@ -73,8 +69,7 @@ typedef struct acpi_madt_ioapic_nmi_src
/* Entry Type 4: Local APIC Non-Maskable Interrupt */ /* Entry Type 4: Local APIC Non-Maskable Interrupt */
typedef struct acpi_madt_lapic_nmi typedef struct acpi_madt_lapic_nmi
{ {
uint8_t type; acpi_madt_entry_t header;
uint8_t length;
uint8_t acpi_proc_id; /* ACPI Processor ID (0xFF for all processors) */ uint8_t acpi_proc_id; /* ACPI Processor ID (0xFF for all processors) */
uint16_t flags; /* Flags */ uint16_t flags; /* Flags */
uint8_t lint; /* LINT# (0 or 1) */ uint8_t lint; /* LINT# (0 or 1) */
@ -83,8 +78,7 @@ typedef struct acpi_madt_lapic_nmi
/* Entry Type 5: Local APIC Address Override */ /* Entry Type 5: Local APIC Address Override */
typedef struct acpi_madt_lapic_addr_ovr typedef struct acpi_madt_lapic_addr_ovr
{ {
uint8_t type; acpi_madt_entry_t header;
uint8_t length;
uint16_t reserved; /* Reserved */ uint16_t reserved; /* Reserved */
uint64_t lapic_addr; /* 64-bit Physical Address of Local APIC */ uint64_t lapic_addr; /* 64-bit Physical Address of Local APIC */
} __attribute__((packed)) acpi_madt_lapic_addr_ovr_t; } __attribute__((packed)) acpi_madt_lapic_addr_ovr_t;
@ -92,8 +86,7 @@ typedef struct acpi_madt_lapic_addr_ovr
/* Entry Type 9: Processor Local x2APIC */ /* Entry Type 9: Processor Local x2APIC */
typedef struct acpi_madt_lx2apic typedef struct acpi_madt_lx2apic
{ {
uint8_t type; acpi_madt_entry_t header;
uint8_t length;
uint16_t reserved; uint16_t reserved;
uint32_t x2apic_id; /* Processor's Local x2APIC ID */ uint32_t x2apic_id; /* Processor's Local x2APIC ID */
uint32_t flags; /* Flags (same as Local APIC) */ uint32_t flags; /* Flags (same as Local APIC) */