Attention is currently required from: Lance Zhao, Jonathan Zhang, Johnny Lin, Tim Wawrzynczak, Christian Walter, Arthur Heymans, Tim Chu.
Kyösti Mälkki has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/74312 )
Change subject: ACPI: Add helper for MADT LAPICs ......................................................................
ACPI: Add helper for MADT LAPICs
This avoids some code duplication related to X2APIC mode.
Change-Id: I592c69e0f52687924fe41189b082c86913999136 Signed-off-by: Kyösti Mälkki kyosti.malkki@gmail.com --- M src/acpi/acpi.c M src/include/acpi/acpi.h M src/soc/intel/common/block/acpi/cpu_hybrid.c M src/soc/intel/xeon_sp/spr/soc_acpi.c 4 files changed, 31 insertions(+), 23 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/12/74312/1
diff --git a/src/acpi/acpi.c b/src/acpi/acpi.c index 2439d7b..0549c0b 100644 --- a/src/acpi/acpi.c +++ b/src/acpi/acpi.c @@ -122,7 +122,7 @@ return sizeof(acpi_mcfg_mmconfig_t); }
-int acpi_create_madt_lapic(acpi_madt_lapic_t *lapic, u8 cpu, u8 apic) +static int acpi_create_madt_lapic(acpi_madt_lapic_t *lapic, u8 cpu, u8 apic) { lapic->type = LOCAL_APIC; /* Local APIC structure */ lapic->length = sizeof(acpi_madt_lapic_t); @@ -133,7 +133,7 @@ return lapic->length; }
-int acpi_create_madt_lx2apic(acpi_madt_lx2apic_t *lapic, u32 cpu, u32 apic) +static int acpi_create_madt_lx2apic(acpi_madt_lx2apic_t *lapic, u32 cpu, u32 apic) { lapic->type = LOCAL_X2APIC; /* Local APIC structure */ lapic->reserved = 0; @@ -145,6 +145,16 @@ return lapic->length; }
+unsigned long acpi_create_madt_one_lapic(unsigned long current, u32 index, u32 lapic_id) +{ + if (lapic_id < 0xff) + current += acpi_create_madt_lapic((acpi_madt_lapic_t *)current, index, lapic_id); + else + current += acpi_create_madt_lx2apic((acpi_madt_lx2apic_t *)current, index, lapic_id); + + return current; +} + static unsigned long acpi_create_madt_lapics(unsigned long current) { struct device *cpu; @@ -159,14 +169,8 @@ } if (num_cpus > 1) bubblesort(apic_ids, num_cpus, NUM_ASCENDING); - for (index = 0; index < num_cpus; index++) { - if (apic_ids[index] < 0xff) - current += acpi_create_madt_lapic((acpi_madt_lapic_t *)current, - index, apic_ids[index]); - else - current += acpi_create_madt_lx2apic((acpi_madt_lx2apic_t *)current, - index, apic_ids[index]); - } + for (index = 0; index < num_cpus; index++) + current = acpi_create_madt_one_lapic(current, index, apic_ids[index]);
return current; } diff --git a/src/include/acpi/acpi.h b/src/include/acpi/acpi.h index 36201ae..bfa111b 100644 --- a/src/include/acpi/acpi.h +++ b/src/include/acpi/acpi.h @@ -1334,7 +1334,6 @@ int acpi_create_cedt_cfmws(acpi_cedt_cfmws_t *cfmws, u64 base_hpa, u64 window_size, u8 eniw, u32 hbig, u16 restriction, u16 qtg_id, const u32 *interleave_target);
-int acpi_create_madt_lapic(acpi_madt_lapic_t *lapic, u8 cpu, u8 apic); int acpi_create_madt_ioapic(acpi_madt_ioapic_t *ioapic, u8 id, u32 addr, u32 gsi_base); int acpi_create_madt_ioapic_from_hw(acpi_madt_ioapic_t *ioapic, u32 addr); @@ -1343,12 +1342,11 @@
void acpi_create_madt(acpi_madt_t *madt);
+unsigned long acpi_create_madt_one_lapic(unsigned long current, u32 cpu, u32 apic); unsigned long acpi_create_madt_lapics_with_nmis(unsigned long current);
unsigned long acpi_create_madt_lapic_nmis(unsigned long current);
-int acpi_create_madt_lx2apic(acpi_madt_lx2apic_t *lapic, u32 cpu, u32 apic); - int acpi_create_srat_lapic(acpi_srat_lapic_t *lapic, u8 node, u8 apic); int acpi_create_srat_x2apic(acpi_srat_x2apic_t *x2apic, u32 node, u32 apic); int acpi_create_srat_mem(acpi_srat_mem_t *mem, u8 node, u32 basek, u32 sizek, diff --git a/src/soc/intel/common/block/acpi/cpu_hybrid.c b/src/soc/intel/common/block/acpi/cpu_hybrid.c index 2e39f72..e18c288 100644 --- a/src/soc/intel/common/block/acpi/cpu_hybrid.c +++ b/src/soc/intel/common/block/acpi/cpu_hybrid.c @@ -81,14 +81,9 @@ { size_t index;
- for (index = 0; index < cpu_apic_info.total_cpu_cnt; index++) { - if (cpu_apic_info.apic_ids[index] < 0xff) - current += acpi_create_madt_lapic((acpi_madt_lapic_t *)current, - index, cpu_apic_info.apic_ids[index]); - else - current += acpi_create_madt_lx2apic((acpi_madt_lx2apic_t *)current, - index, cpu_apic_info.apic_ids[index]); - } + for (index = 0; index < cpu_apic_info.total_cpu_cnt; index++) + current = acpi_create_madt_one_lapic(current, index, + cpu_apic_info.apic_ids[index]);
return current; } diff --git a/src/soc/intel/xeon_sp/spr/soc_acpi.c b/src/soc/intel/xeon_sp/spr/soc_acpi.c index 619e5bb..c609f4f 100644 --- a/src/soc/intel/xeon_sp/spr/soc_acpi.c +++ b/src/soc/intel/xeon_sp/spr/soc_acpi.c @@ -540,8 +540,7 @@ } if (!cpu->enabled) continue; - current += acpi_create_madt_lapic((acpi_madt_lapic_t *)current, num_cpus, - cpu->path.apic.apic_id); + current = acpi_create_madt_one_lapic(current, num_cpus, cpu->path.apic.apic_id); num_cpus++; }