vgabios: Unify code to generate the vbe mode list.
[seabios.git] / src / smp.c
index f989ec129d023f85d651e255e61662454e25c524..8c077a1bab49e2a80b810ab1eb673a5291df5e23 100644 (file)
--- a/src/smp.c
+++ b/src/smp.c
 
 #define APIC_ENABLED 0x0100
 
-struct { u32 ecx, eax, edx; } smp_mtrr[16] VAR16VISIBLE;
+struct { u32 ecx, eax, edx; } smp_mtrr[32] VAR16VISIBLE;
 u32 smp_mtrr_count VAR16VISIBLE;
 
 void
 wrmsr_smp(u32 index, u64 val)
 {
     wrmsr(index, val);
-    if (smp_mtrr_count >= ARRAY_SIZE(smp_mtrr))
+    if (smp_mtrr_count >= ARRAY_SIZE(smp_mtrr)) {
+        warn_noalloc();
         return;
+    }
     smp_mtrr[smp_mtrr_count].ecx = index;
     smp_mtrr[smp_mtrr_count].eax = val;
     smp_mtrr[smp_mtrr_count].edx = val >> 32;
@@ -72,7 +74,7 @@ smp_probe(void)
     ASSERT32FLAT();
     u32 eax, ebx, ecx, cpuid_features;
     cpuid(1, &eax, &ebx, &ecx, &cpuid_features);
-    if ((cpuid_features & CPUID_APIC)) {
+    if (eax < 1 || !(cpuid_features & CPUID_APIC)) {
         // No apic - only the main cpu is present.
         dprintf(1, "No apic - only the main cpu is present.\n");
         CountCPUs= 1;
@@ -127,11 +129,3 @@ smp_probe(void)
     dprintf(1, "Found %d cpu(s) max supported %d cpu(s)\n", readl(&CountCPUs),
         MaxCountCPUs);
 }
-
-// Reset variables to zero
-void
-smp_probe_setup(void)
-{
-    CountCPUs = 0;
-    smp_mtrr_count = 0;
-}