aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2016-10-13 14:38:26 +0200
committerKevin O'Connor <kevin@koconnor.net>2016-10-25 09:58:17 -0400
commiteb516e4204ffa25ef94796e1e58f8dc649761fd5 (patch)
tree5dbc6e6e9fd941b089f659393f198b5a00c1a5e3
parentf769589877b606d2c1b9b218b54b6ccef9440230 (diff)
downloadseabios-eb516e4204ffa25ef94796e1e58f8dc649761fd5.tar.gz
seabios-eb516e4204ffa25ef94796e1e58f8dc649761fd5.tar.xz
seabios-eb516e4204ffa25ef94796e1e58f8dc649761fd5.zip
smp: consolidate CPU APIC ID detection and accounting
Signed-off-by: "Kevin O'Connor" <kevin@koconnor.net> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
-rw-r--r--src/fw/smp.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/fw/smp.c b/src/fw/smp.c
index 719d51d..31bcc6a 100644
--- a/src/fw/smp.c
+++ b/src/fw/smp.c
@@ -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.