diff --git a/GNUmakefile b/GNUmakefile index 8154114..fbf16f2 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -2,7 +2,7 @@ MAKEFLAGS += -rR .SUFFIXES: -QEMUFLAGS := -m 2G -serial stdio +QEMUFLAGS := -m 2G -serial stdio -smp 4 USER_QEMUFLAGS ?= IMAGE_NAME := release/emk diff --git a/kernel/src/emk.c b/kernel/src/emk.c index 8ee7961..9589e9a 100644 --- a/kernel/src/emk.c +++ b/kernel/src/emk.c @@ -18,6 +18,7 @@ #include #endif // FLANTERM_SUPPORT #include +#include __attribute__((used, section(".limine_requests"))) static volatile LIMINE_BASE_REVISION(3); __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 = { .revision = 0, .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_end"))) static volatile LIMINE_REQUESTS_END_MARKER; @@ -171,7 +175,7 @@ void emk_entry(void) acpi_init(); log_early("Initialized ACPI"); - void *madt = acpi_find_table("APIC"); + acpi_madt_t *madt = (acpi_madt_t *)acpi_find_table("APIC"); if (!madt) { kpanic(NULL, "Failed to find MADT table"); @@ -179,5 +183,12 @@ void emk_entry(void) 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(); } \ No newline at end of file diff --git a/kernel/src/sys/acpi/madt.h b/kernel/src/sys/acpi/madt.h index a8f1d23..fb36505 100644 --- a/kernel/src/sys/acpi/madt.h +++ b/kernel/src/sys/acpi/madt.h @@ -30,8 +30,7 @@ typedef struct acpi_madt_entry /* Entry Type 0: Processor Local APIC */ typedef struct acpi_madt_lapic { - uint8_t type; - uint8_t length; + acpi_madt_entry_t header; uint8_t acpi_proc_id; /* ACPI Processor ID */ uint8_t apic_id; /* APIC ID */ 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 */ typedef struct acpi_madt_ioapic { - uint8_t type; - uint8_t length; + acpi_madt_entry_t header; uint8_t ioapic_id; /* I/O APIC's ID */ uint8_t reserved; /* Reserved (0) */ 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 */ typedef struct acpi_madt_ioapic_src_ovr { - uint8_t type; - uint8_t length; + acpi_madt_entry_t header; uint8_t bus_source; /* Bus Source */ uint8_t irq_source; /* IRQ Source */ 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 */ typedef struct acpi_madt_ioapic_nmi_src { - uint8_t type; - uint8_t length; + acpi_madt_entry_t header; uint8_t nmi_source; /* NMI Source */ uint8_t reserved; /* Reserved */ uint16_t flags; /* Flags */ @@ -73,8 +69,7 @@ typedef struct acpi_madt_ioapic_nmi_src /* Entry Type 4: Local APIC Non-Maskable Interrupt */ typedef struct acpi_madt_lapic_nmi { - uint8_t type; - uint8_t length; + acpi_madt_entry_t header; uint8_t acpi_proc_id; /* ACPI Processor ID (0xFF for all processors) */ uint16_t flags; /* Flags */ uint8_t lint; /* LINT# (0 or 1) */ @@ -83,8 +78,7 @@ typedef struct acpi_madt_lapic_nmi /* Entry Type 5: Local APIC Address Override */ typedef struct acpi_madt_lapic_addr_ovr { - uint8_t type; - uint8_t length; + acpi_madt_entry_t header; uint16_t reserved; /* Reserved */ uint64_t lapic_addr; /* 64-bit Physical Address of Local APIC */ } __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 */ typedef struct acpi_madt_lx2apic { - uint8_t type; - uint8_t length; + acpi_madt_entry_t header; uint16_t reserved; uint32_t x2apic_id; /* Processor's Local x2APIC ID */ uint32_t flags; /* Flags (same as Local APIC) */