:: commit b733ef25ef1af34df68e1421ad9013f4d57b3d80

mintsuki <mintsuki@protonmail.com> — 2020-09-26 15:12

parents: a58fd6bd3c

Fix stivale2 SMP tag issue

diff --git a/limine.bin b/limine.bin
index 3f423bc2..e4b8a94a 100644
Binary files a/limine.bin and b/limine.bin differ
diff --git a/stage2/sys/smp.c b/stage2/sys/smp.c
index 8c5e4e1f..222720bb 100644
--- a/stage2/sys/smp.c
+++ b/stage2/sys/smp.c
@@ -90,7 +90,7 @@ struct smp_information *init_smp(size_t   *cpu_count,
     asm volatile ("sgdt %0" :: "m"(gdtr) : "memory");
 
     struct smp_information *ret = conv_mem_alloc_aligned(0, 1);
-    *cpu_count = 1;
+    *cpu_count = 0;
 
     // Parse the MADT entries
     for (uint8_t *madt_ptr = (uint8_t *)madt->madt_entries_begin;
@@ -104,6 +104,10 @@ struct smp_information *init_smp(size_t   *cpu_count,
 
                 struct madt_lapic *lapic = (void *)madt_ptr;
 
+                // Check if we can actually try to start the AP
+                if (!((lapic->flags & 1) ^ ((lapic->flags >> 1) & 1)))
+                    continue;
+
                 struct smp_information *info_struct =
                         conv_mem_alloc_aligned(sizeof(struct smp_information), 1);
 
@@ -116,10 +120,6 @@ struct smp_information *init_smp(size_t   *cpu_count,
                     continue;
                 }
 
-                // Check if we can actually try to start the AP
-                if (!((lapic->flags & 1) ^ ((lapic->flags >> 1) & 1)))
-                    continue;
-
                 print("smp: Found candidate AP for bring-up. LAPIC ID: %u\n", lapic->lapic_id);
 
                 // Try to start the AP
tab: 248 wrap: offon