]> xenbits.xensource.com Git - seabios.git/commitdiff
smp: consolidate CPU APIC ID detection and accounting
authorKevin O'Connor <kevin@koconnor.net>
Thu, 13 Oct 2016 12:38:26 +0000 (14:38 +0200)
committerKevin O'Connor <kevin@koconnor.net>
Tue, 25 Oct 2016 13:58:17 +0000 (09:58 -0400)
Signed-off-by: "Kevin O'Connor" <kevin@koconnor.net>
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
src/fw/smp.c

index 719d51d6fc343e63b462576e114fffb02d8bccf3..31bcc6a07792e2b88e7943040c262937f62501fb 100644 (file)
@@ -55,23 +55,29 @@ int apic_id_is_present(u8 apic_id)
     return !!(FoundAPICIDs[apic_id/32] & (1ul << (apic_id % 32)));
 }
 
+static int
+apic_id_init(void)
+{
+    // Track found apic id for use in legacy internal bios tables
+    u32 eax, ebx, ecx, cpuid_features;
+    cpuid(1, &eax, &ebx, &ecx, &cpuid_features);
+    u8 apic_id = ebx>>24;
+    FoundAPICIDs[apic_id/32] |= 1 << (apic_id % 32);
+    return apic_id;
+}
+
 void VISIBLE32FLAT
 handle_smp(void)
 {
     if (!CONFIG_QEMU)
         return;
 
-    // Detect apic_id
-    u32 eax, ebx, ecx, cpuid_features;
-    cpuid(1, &eax, &ebx, &ecx, &cpuid_features);
-    u8 apic_id = ebx>>24;
-    dprintf(DEBUG_HDL_smp, "handle_smp: apic_id=%d\n", apic_id);
+    // Track this CPU and detect the apic_id
+    int apic_id = apic_id_init();
+    dprintf(DEBUG_HDL_smp, "handle_smp: apic_id=0x%x\n", apic_id);
 
     smp_write_msrs();
 
-    // Set bit on FoundAPICIDs
-    FoundAPICIDs[apic_id/32] |= (1 << (apic_id % 32));
-
     CountCPUs++;
 }
 
@@ -94,8 +100,7 @@ smp_scan(void)
     }
 
     // mark the BSP initial APIC ID as found, too:
-    u8 apic_id = ebx>>24;
-    FoundAPICIDs[apic_id/32] |= (1 << (apic_id % 32));
+    apic_id_init();
     CountCPUs = 1;
 
     // Setup jump trampoline to counter code.