diff --git a/STIVALE2.md b/STIVALE2.md index 52d08827..745abb46 100644 --- a/STIVALE2.md +++ b/STIVALE2.md @@ -378,8 +378,10 @@ This tag reports to the kernel info about the firmware. struct stivale2_struct_tag_smp { uint64_t identifier; // Identifier: 0x34d1d96339647025 uint64_t next; - uint64_t cpu_count; // Total number of logical CPUs (including BSP) - struct stivale2_smp_info smp_info[]; + uint64_t cpu_count; // Total number of logical CPUs (excluding BSP) + struct stivale2_smp_info smp_info[]; // Array of smp_info structs, one per + // additional logical processor, note + // that the BSP does not have one. } __attribute__((packed)); ``` @@ -405,5 +407,10 @@ struct stivale2_smp_info { // is handed off. // All general purpose registers are cleared // except ESP/RSP, and RDI in 64-bit mode. + uint64_t extra_argument; // This field is here for the kernel to use + // for whatever it wants. Writes here should + // be performed before writing to goto_address + // so that the receiving processor can safely + // retrieve the data. } __attribute__((packed)); ``` diff --git a/limine.bin b/limine.bin index c843a6d7..5e7ae201 100644 Binary files a/limine.bin and b/limine.bin differ diff --git a/stage2/sys/smp.c b/stage2/sys/smp.c index d5811771..36cd15ba 100644 --- a/stage2/sys/smp.c +++ b/stage2/sys/smp.c @@ -89,7 +89,7 @@ struct smp_information *init_smp(size_t *cpu_count, asm volatile ("sgdt %0" :: "m"(gdtr)); struct smp_information *ret = balloc_aligned(0, 1); - *cpu_count = 1; + *cpu_count = 0; // Parse the MADT entries for (uint8_t *madt_ptr = (uint8_t *)madt->madt_entries_begin; diff --git a/stage2/sys/smp.h b/stage2/sys/smp.h index fa207f72..30f26800 100644 --- a/stage2/sys/smp.h +++ b/stage2/sys/smp.h @@ -11,6 +11,7 @@ struct smp_information { uint32_t lapic_id; uint64_t stack_addr; uint64_t goto_address; + uint64_t extra_argument; } __attribute__((packed)); struct smp_information *init_smp(size_t *cpu_count, diff --git a/stage2/sys/smp_trampoline.asm b/stage2/sys/smp_trampoline.asm index a78c3b32..769ecd97 100644 --- a/stage2/sys/smp_trampoline.asm +++ b/stage2/sys/smp_trampoline.asm @@ -100,8 +100,8 @@ parking32: .out: mov esp, dword [edi + 8] push 0 - push eax push edi + push eax xor eax, eax xor ebx, ebx xor ecx, ecx diff --git a/stivale/stivale2.h b/stivale/stivale2.h index 4a59781e..54cbde6f 100644 --- a/stivale/stivale2.h +++ b/stivale/stivale2.h @@ -136,6 +136,7 @@ struct stivale2_smp_info { uint32_t lapic_id; uint64_t target_stack; uint64_t goto_address; + uint64_t extra_argument; } __attribute__((packed)); struct stivale2_struct_tag_smp {