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> Reviewed-on: https://review.coreboot.org/c/coreboot/+/74312 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Tim Wawrzynczak <inforichland@gmail.com>
This commit is contained in:
parent
9ac1fb729f
commit
2e9f0d3b6a
|
@ -122,7 +122,7 @@ int acpi_create_mcfg_mmconfig(acpi_mcfg_mmconfig_t *mmconfig, u32 base,
|
|||
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 @@ int acpi_create_madt_lapic(acpi_madt_lapic_t *lapic, u8 cpu, u8 apic)
|
|||
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,18 @@ int acpi_create_madt_lx2apic(acpi_madt_lx2apic_t *lapic, u32 cpu, u32 apic)
|
|||
return lapic->length;
|
||||
}
|
||||
|
||||
unsigned long acpi_create_madt_one_lapic(unsigned long current, u32 index, u32 lapic_id)
|
||||
{
|
||||
if (lapic_id <= ACPI_MADT_MAX_LAPIC_ID)
|
||||
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 +171,8 @@ static unsigned long acpi_create_madt_lapics(unsigned long current)
|
|||
}
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -682,6 +682,8 @@ typedef struct acpi_madt_lapic {
|
|||
u32 flags; /* Local APIC flags */
|
||||
} __packed acpi_madt_lapic_t;
|
||||
|
||||
#define ACPI_MADT_MAX_LAPIC_ID 0xfe
|
||||
|
||||
/* MADT: Local APIC NMI Structure */
|
||||
typedef struct acpi_madt_lapic_nmi {
|
||||
u8 type; /* Type (4) */
|
||||
|
@ -1334,7 +1336,6 @@ int acpi_create_cedt_chbs(acpi_cedt_chbs_t *chbs, u32 uid, u32 cxl_ver, u64 base
|
|||
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 +1344,11 @@ int acpi_create_madt_irqoverride(acpi_madt_irqoverride_t *irqoverride,
|
|||
|
||||
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,
|
||||
|
|
|
@ -81,14 +81,9 @@ static unsigned long acpi_create_madt_lapics_hybrid(unsigned long current)
|
|||
{
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -540,8 +540,7 @@ unsigned long xeonsp_acpi_create_madt_lapics(unsigned long current)
|
|||
}
|
||||
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++;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue