Introduce support for max_cpus and use it to generate MADT and SSDT tables. If nothing provided, default to 15, to make sure not to break certain legacy OSes. This is similar in functionality to what was pushed into QEMU/BOCHS. Signed-off-by: Jes Sorense
--- src/acpi.c | 21 ++++++++++++++------- src/qemu-cfg.c | 8 ++++++++ src/qemu-cfg.h | 3 +++ 3 files changed, 25 insertions(+), 7 deletions(-) Index: seabios/src/acpi.c =================================================================== --- seabios.orig/src/acpi.c +++ seabios/src/acpi.c @@ -12,7 +12,7 @@ #include "biosvar.h" // GET_EBDA #include "pci_ids.h" // PCI_VENDOR_ID_INTEL #include "pci_regs.h" // PCI_INTERRUPT_LINE - +#include "qemu-cfg.h" /****************************************************/ /* ACPI tables init */ @@ -213,6 +213,11 @@ struct madt_intsrcovr { } PACKED; #include "acpi-dsdt.hex" +/* + * Maximum number of supported CPUs, including hot-plug. + */ +#define MAX_CPUS_DEFAULT 15 +u16 max_cpus; static inline u16 cpu_to_le16(u16 x) { @@ -245,8 +250,7 @@ acpi_build_processor_ssdt(u8 *ssdt) { u8 *ssdt_ptr = ssdt; int i, length; - int smp_cpus = CountCPUs; - int acpi_cpus = smp_cpus > 0xff ? 0xff : smp_cpus; + int acpi_cpus = max_cpus > 0xff ? 0xff : max_cpus; ssdt_ptr[9] = 0; // checksum; ssdt_ptr += sizeof(struct acpi_table_header); @@ -301,6 +305,10 @@ void acpi_bios_init(void) if (! CONFIG_ACPI) return; + max_cpus = qemu_cfg_get_max_cpus(); + if (!max_cpus) + max_cpus = MAX_CPUS_DEFAULT; + dprintf(3, "init ACPI tables\n"); // This code is hardcoded for PIIX4 Power Management device. @@ -348,11 +356,10 @@ void acpi_bios_init(void) ssdt = (void *)(addr); addr += acpi_build_processor_ssdt(ssdt); - int smp_cpus = CountCPUs; addr = ALIGN(addr, 8); madt_addr = addr; madt_size = sizeof(*madt) + - sizeof(struct madt_processor_apic) * smp_cpus + + sizeof(struct madt_processor_apic) * max_cpus + sizeof(struct madt_io_apic); madt = (void *)(addr); addr += madt_size; @@ -417,7 +424,7 @@ void acpi_bios_init(void) madt->local_apic_address = cpu_to_le32(BUILD_APIC_ADDR); madt->flags = cpu_to_le32(1); struct madt_processor_apic *apic = (void *)&madt[1]; - for(i=0;i