@@ -17,6 +17,9 @@
#define APIC_ENABLED 0x0100
+#define ACPI_CPU_STATUS_MAP 0xaf00
+#define ACPI_CPU_STATUS_MAP_SZ 32
+
struct { u32 ecx, eax, edx; } smp_mtrr[32] VAR16VISIBLE;
u32 smp_mtrr_count VAR16VISIBLE;
@@ -115,6 +118,21 @@ smp_probe(void)
msleep(10);
} else {
u8 cmos_smp_count = inb_cmos(CMOS_BIOS_SMP_COUNT);
+ u8 i = 0, acpi_cpu_online_count = 0;
+
+ /* count plugged in cpus in acpi PRST bitmap */
+ while (i < ACPI_CPU_STATUS_MAP_SZ) {
+ u8 j = 0, status = inb(ACPI_CPU_STATUS_MAP + (i++));
+ while (j < 8)
+ if ((status >> j++) & 1)
+ ++acpi_cpu_online_count;
+ }
+ /* if one or several cpus were hotplugged then on reboot we should
+ * take them into account and wait for them too*/
+ if (cmos_smp_count < --acpi_cpu_online_count)
+ cmos_smp_count = acpi_cpu_online_count;
+
+ dprintf(1, "acpi_cpu_online_count: %d\n", acpi_cpu_online_count);
while (cmos_smp_count + 1 != readl(&CountCPUs))
yield();
}