提交 a8fa883a 编写于 作者: K Keith Busch 提交者: Joseph Qi

ICX: acpi: Create subtable parsing infrastructure

commit 60574d1e05b094d222162260dd9cac49f4d0996a upstream.

Parsing entries in an ACPI table had assumed a generic header
structure. There is no standard ACPI header, though, so less common
layouts with different field sizes required custom parsers to go through
their subtable entry list.

Create the infrastructure for adding different table types so parsing
the entries array may be more reused for all ACPI system tables and
the common code doesn't need to be duplicated.
Reviewed-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: NJonathan Cameron <Jonathan.Cameron@huawei.com>
Tested-by: NJonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: NKeith Busch <keith.busch@intel.com>
Tested-by: NBrice Goglin <Brice.Goglin@inria.fr>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NFan Du <fan.du@intel.com>
Signed-off-by: NJeffle Xu <jefflexu@linux.alibaba.com>
Acked-by: NJoseph Qi <joseph.qi@linux.alibaba.com>
Acked-by: NCaspar Zhang <caspar@linux.alibaba.com>
上级 d144582b
...@@ -46,7 +46,7 @@ static inline int get_cpu_for_acpi_id(u32 uid) ...@@ -46,7 +46,7 @@ static inline int get_cpu_for_acpi_id(u32 uid)
return -EINVAL; return -EINVAL;
} }
static int __init acpi_parse_gicc_pxm(struct acpi_subtable_header *header, static int __init acpi_parse_gicc_pxm(union acpi_subtable_headers *header,
const unsigned long end) const unsigned long end)
{ {
struct acpi_srat_gicc_affinity *pa; struct acpi_srat_gicc_affinity *pa;
......
...@@ -548,7 +548,7 @@ acpi_map_gic_cpu_interface(struct acpi_madt_generic_interrupt *processor) ...@@ -548,7 +548,7 @@ acpi_map_gic_cpu_interface(struct acpi_madt_generic_interrupt *processor)
} }
static int __init static int __init
acpi_parse_gic_cpu_interface(struct acpi_subtable_header *header, acpi_parse_gic_cpu_interface(union acpi_subtable_headers *header,
const unsigned long end) const unsigned long end)
{ {
struct acpi_madt_generic_interrupt *processor; struct acpi_madt_generic_interrupt *processor;
...@@ -557,7 +557,7 @@ acpi_parse_gic_cpu_interface(struct acpi_subtable_header *header, ...@@ -557,7 +557,7 @@ acpi_parse_gic_cpu_interface(struct acpi_subtable_header *header,
if (BAD_MADT_GICC_ENTRY(processor, end)) if (BAD_MADT_GICC_ENTRY(processor, end))
return -EINVAL; return -EINVAL;
acpi_table_print_madt_entry(header); acpi_table_print_madt_entry(&header->common);
acpi_map_gic_cpu_interface(processor); acpi_map_gic_cpu_interface(processor);
......
...@@ -177,7 +177,7 @@ struct acpi_table_madt *acpi_madt __initdata; ...@@ -177,7 +177,7 @@ struct acpi_table_madt *acpi_madt __initdata;
static u8 has_8259; static u8 has_8259;
static int __init static int __init
acpi_parse_lapic_addr_ovr(struct acpi_subtable_header * header, acpi_parse_lapic_addr_ovr(union acpi_subtable_headers * header,
const unsigned long end) const unsigned long end)
{ {
struct acpi_madt_local_apic_override *lapic; struct acpi_madt_local_apic_override *lapic;
...@@ -195,7 +195,7 @@ acpi_parse_lapic_addr_ovr(struct acpi_subtable_header * header, ...@@ -195,7 +195,7 @@ acpi_parse_lapic_addr_ovr(struct acpi_subtable_header * header,
} }
static int __init static int __init
acpi_parse_lsapic(struct acpi_subtable_header * header, const unsigned long end) acpi_parse_lsapic(union acpi_subtable_headers *header, const unsigned long end)
{ {
struct acpi_madt_local_sapic *lsapic; struct acpi_madt_local_sapic *lsapic;
...@@ -216,7 +216,7 @@ acpi_parse_lsapic(struct acpi_subtable_header * header, const unsigned long end) ...@@ -216,7 +216,7 @@ acpi_parse_lsapic(struct acpi_subtable_header * header, const unsigned long end)
} }
static int __init static int __init
acpi_parse_lapic_nmi(struct acpi_subtable_header * header, const unsigned long end) acpi_parse_lapic_nmi(union acpi_subtable_headers * header, const unsigned long end)
{ {
struct acpi_madt_local_apic_nmi *lacpi_nmi; struct acpi_madt_local_apic_nmi *lacpi_nmi;
...@@ -230,7 +230,7 @@ acpi_parse_lapic_nmi(struct acpi_subtable_header * header, const unsigned long e ...@@ -230,7 +230,7 @@ acpi_parse_lapic_nmi(struct acpi_subtable_header * header, const unsigned long e
} }
static int __init static int __init
acpi_parse_iosapic(struct acpi_subtable_header * header, const unsigned long end) acpi_parse_iosapic(union acpi_subtable_headers * header, const unsigned long end)
{ {
struct acpi_madt_io_sapic *iosapic; struct acpi_madt_io_sapic *iosapic;
...@@ -245,7 +245,7 @@ acpi_parse_iosapic(struct acpi_subtable_header * header, const unsigned long end ...@@ -245,7 +245,7 @@ acpi_parse_iosapic(struct acpi_subtable_header * header, const unsigned long end
static unsigned int __initdata acpi_madt_rev; static unsigned int __initdata acpi_madt_rev;
static int __init static int __init
acpi_parse_plat_int_src(struct acpi_subtable_header * header, acpi_parse_plat_int_src(union acpi_subtable_headers * header,
const unsigned long end) const unsigned long end)
{ {
struct acpi_madt_interrupt_source *plintsrc; struct acpi_madt_interrupt_source *plintsrc;
...@@ -329,7 +329,7 @@ unsigned int get_cpei_target_cpu(void) ...@@ -329,7 +329,7 @@ unsigned int get_cpei_target_cpu(void)
} }
static int __init static int __init
acpi_parse_int_src_ovr(struct acpi_subtable_header * header, acpi_parse_int_src_ovr(union acpi_subtable_headers * header,
const unsigned long end) const unsigned long end)
{ {
struct acpi_madt_interrupt_override *p; struct acpi_madt_interrupt_override *p;
...@@ -350,7 +350,7 @@ acpi_parse_int_src_ovr(struct acpi_subtable_header * header, ...@@ -350,7 +350,7 @@ acpi_parse_int_src_ovr(struct acpi_subtable_header * header,
} }
static int __init static int __init
acpi_parse_nmi_src(struct acpi_subtable_header * header, const unsigned long end) acpi_parse_nmi_src(union acpi_subtable_headers * header, const unsigned long end)
{ {
struct acpi_madt_nmi_source *nmi_src; struct acpi_madt_nmi_source *nmi_src;
......
...@@ -196,7 +196,7 @@ static int acpi_register_lapic(int id, u32 acpiid, u8 enabled) ...@@ -196,7 +196,7 @@ static int acpi_register_lapic(int id, u32 acpiid, u8 enabled)
} }
static int __init static int __init
acpi_parse_x2apic(struct acpi_subtable_header *header, const unsigned long end) acpi_parse_x2apic(union acpi_subtable_headers *header, const unsigned long end)
{ {
struct acpi_madt_local_x2apic *processor = NULL; struct acpi_madt_local_x2apic *processor = NULL;
#ifdef CONFIG_X86_X2APIC #ifdef CONFIG_X86_X2APIC
...@@ -209,7 +209,7 @@ acpi_parse_x2apic(struct acpi_subtable_header *header, const unsigned long end) ...@@ -209,7 +209,7 @@ acpi_parse_x2apic(struct acpi_subtable_header *header, const unsigned long end)
if (BAD_MADT_ENTRY(processor, end)) if (BAD_MADT_ENTRY(processor, end))
return -EINVAL; return -EINVAL;
acpi_table_print_madt_entry(header); acpi_table_print_madt_entry(&header->common);
#ifdef CONFIG_X86_X2APIC #ifdef CONFIG_X86_X2APIC
apic_id = processor->local_apic_id; apic_id = processor->local_apic_id;
...@@ -241,7 +241,7 @@ acpi_parse_x2apic(struct acpi_subtable_header *header, const unsigned long end) ...@@ -241,7 +241,7 @@ acpi_parse_x2apic(struct acpi_subtable_header *header, const unsigned long end)
} }
static int __init static int __init
acpi_parse_lapic(struct acpi_subtable_header * header, const unsigned long end) acpi_parse_lapic(union acpi_subtable_headers * header, const unsigned long end)
{ {
struct acpi_madt_local_apic *processor = NULL; struct acpi_madt_local_apic *processor = NULL;
...@@ -250,7 +250,7 @@ acpi_parse_lapic(struct acpi_subtable_header * header, const unsigned long end) ...@@ -250,7 +250,7 @@ acpi_parse_lapic(struct acpi_subtable_header * header, const unsigned long end)
if (BAD_MADT_ENTRY(processor, end)) if (BAD_MADT_ENTRY(processor, end))
return -EINVAL; return -EINVAL;
acpi_table_print_madt_entry(header); acpi_table_print_madt_entry(&header->common);
/* Ignore invalid ID */ /* Ignore invalid ID */
if (processor->id == 0xff) if (processor->id == 0xff)
...@@ -271,7 +271,7 @@ acpi_parse_lapic(struct acpi_subtable_header * header, const unsigned long end) ...@@ -271,7 +271,7 @@ acpi_parse_lapic(struct acpi_subtable_header * header, const unsigned long end)
} }
static int __init static int __init
acpi_parse_sapic(struct acpi_subtable_header *header, const unsigned long end) acpi_parse_sapic(union acpi_subtable_headers *header, const unsigned long end)
{ {
struct acpi_madt_local_sapic *processor = NULL; struct acpi_madt_local_sapic *processor = NULL;
...@@ -280,7 +280,7 @@ acpi_parse_sapic(struct acpi_subtable_header *header, const unsigned long end) ...@@ -280,7 +280,7 @@ acpi_parse_sapic(struct acpi_subtable_header *header, const unsigned long end)
if (BAD_MADT_ENTRY(processor, end)) if (BAD_MADT_ENTRY(processor, end))
return -EINVAL; return -EINVAL;
acpi_table_print_madt_entry(header); acpi_table_print_madt_entry(&header->common);
acpi_register_lapic((processor->id << 8) | processor->eid,/* APIC ID */ acpi_register_lapic((processor->id << 8) | processor->eid,/* APIC ID */
processor->processor_id, /* ACPI ID */ processor->processor_id, /* ACPI ID */
...@@ -290,7 +290,7 @@ acpi_parse_sapic(struct acpi_subtable_header *header, const unsigned long end) ...@@ -290,7 +290,7 @@ acpi_parse_sapic(struct acpi_subtable_header *header, const unsigned long end)
} }
static int __init static int __init
acpi_parse_lapic_addr_ovr(struct acpi_subtable_header * header, acpi_parse_lapic_addr_ovr(union acpi_subtable_headers * header,
const unsigned long end) const unsigned long end)
{ {
struct acpi_madt_local_apic_override *lapic_addr_ovr = NULL; struct acpi_madt_local_apic_override *lapic_addr_ovr = NULL;
...@@ -300,7 +300,7 @@ acpi_parse_lapic_addr_ovr(struct acpi_subtable_header * header, ...@@ -300,7 +300,7 @@ acpi_parse_lapic_addr_ovr(struct acpi_subtable_header * header,
if (BAD_MADT_ENTRY(lapic_addr_ovr, end)) if (BAD_MADT_ENTRY(lapic_addr_ovr, end))
return -EINVAL; return -EINVAL;
acpi_table_print_madt_entry(header); acpi_table_print_madt_entry(&header->common);
acpi_lapic_addr = lapic_addr_ovr->address; acpi_lapic_addr = lapic_addr_ovr->address;
...@@ -308,7 +308,7 @@ acpi_parse_lapic_addr_ovr(struct acpi_subtable_header * header, ...@@ -308,7 +308,7 @@ acpi_parse_lapic_addr_ovr(struct acpi_subtable_header * header,
} }
static int __init static int __init
acpi_parse_x2apic_nmi(struct acpi_subtable_header *header, acpi_parse_x2apic_nmi(union acpi_subtable_headers *header,
const unsigned long end) const unsigned long end)
{ {
struct acpi_madt_local_x2apic_nmi *x2apic_nmi = NULL; struct acpi_madt_local_x2apic_nmi *x2apic_nmi = NULL;
...@@ -318,7 +318,7 @@ acpi_parse_x2apic_nmi(struct acpi_subtable_header *header, ...@@ -318,7 +318,7 @@ acpi_parse_x2apic_nmi(struct acpi_subtable_header *header,
if (BAD_MADT_ENTRY(x2apic_nmi, end)) if (BAD_MADT_ENTRY(x2apic_nmi, end))
return -EINVAL; return -EINVAL;
acpi_table_print_madt_entry(header); acpi_table_print_madt_entry(&header->common);
if (x2apic_nmi->lint != 1) if (x2apic_nmi->lint != 1)
printk(KERN_WARNING PREFIX "NMI not connected to LINT 1!\n"); printk(KERN_WARNING PREFIX "NMI not connected to LINT 1!\n");
...@@ -327,7 +327,7 @@ acpi_parse_x2apic_nmi(struct acpi_subtable_header *header, ...@@ -327,7 +327,7 @@ acpi_parse_x2apic_nmi(struct acpi_subtable_header *header,
} }
static int __init static int __init
acpi_parse_lapic_nmi(struct acpi_subtable_header * header, const unsigned long end) acpi_parse_lapic_nmi(union acpi_subtable_headers * header, const unsigned long end)
{ {
struct acpi_madt_local_apic_nmi *lapic_nmi = NULL; struct acpi_madt_local_apic_nmi *lapic_nmi = NULL;
...@@ -336,7 +336,7 @@ acpi_parse_lapic_nmi(struct acpi_subtable_header * header, const unsigned long e ...@@ -336,7 +336,7 @@ acpi_parse_lapic_nmi(struct acpi_subtable_header * header, const unsigned long e
if (BAD_MADT_ENTRY(lapic_nmi, end)) if (BAD_MADT_ENTRY(lapic_nmi, end))
return -EINVAL; return -EINVAL;
acpi_table_print_madt_entry(header); acpi_table_print_madt_entry(&header->common);
if (lapic_nmi->lint != 1) if (lapic_nmi->lint != 1)
printk(KERN_WARNING PREFIX "NMI not connected to LINT 1!\n"); printk(KERN_WARNING PREFIX "NMI not connected to LINT 1!\n");
...@@ -448,7 +448,7 @@ static int __init mp_register_ioapic_irq(u8 bus_irq, u8 polarity, ...@@ -448,7 +448,7 @@ static int __init mp_register_ioapic_irq(u8 bus_irq, u8 polarity,
} }
static int __init static int __init
acpi_parse_ioapic(struct acpi_subtable_header * header, const unsigned long end) acpi_parse_ioapic(union acpi_subtable_headers * header, const unsigned long end)
{ {
struct acpi_madt_io_apic *ioapic = NULL; struct acpi_madt_io_apic *ioapic = NULL;
struct ioapic_domain_cfg cfg = { struct ioapic_domain_cfg cfg = {
...@@ -461,7 +461,7 @@ acpi_parse_ioapic(struct acpi_subtable_header * header, const unsigned long end) ...@@ -461,7 +461,7 @@ acpi_parse_ioapic(struct acpi_subtable_header * header, const unsigned long end)
if (BAD_MADT_ENTRY(ioapic, end)) if (BAD_MADT_ENTRY(ioapic, end))
return -EINVAL; return -EINVAL;
acpi_table_print_madt_entry(header); acpi_table_print_madt_entry(&header->common);
/* Statically assign IRQ numbers for IOAPICs hosting legacy IRQs */ /* Statically assign IRQ numbers for IOAPICs hosting legacy IRQs */
if (ioapic->global_irq_base < nr_legacy_irqs()) if (ioapic->global_irq_base < nr_legacy_irqs())
...@@ -507,7 +507,7 @@ static void __init acpi_sci_ioapic_setup(u8 bus_irq, u16 polarity, u16 trigger, ...@@ -507,7 +507,7 @@ static void __init acpi_sci_ioapic_setup(u8 bus_irq, u16 polarity, u16 trigger,
} }
static int __init static int __init
acpi_parse_int_src_ovr(struct acpi_subtable_header * header, acpi_parse_int_src_ovr(union acpi_subtable_headers * header,
const unsigned long end) const unsigned long end)
{ {
struct acpi_madt_interrupt_override *intsrc = NULL; struct acpi_madt_interrupt_override *intsrc = NULL;
...@@ -517,7 +517,7 @@ acpi_parse_int_src_ovr(struct acpi_subtable_header * header, ...@@ -517,7 +517,7 @@ acpi_parse_int_src_ovr(struct acpi_subtable_header * header,
if (BAD_MADT_ENTRY(intsrc, end)) if (BAD_MADT_ENTRY(intsrc, end))
return -EINVAL; return -EINVAL;
acpi_table_print_madt_entry(header); acpi_table_print_madt_entry(&header->common);
if (intsrc->source_irq == acpi_gbl_FADT.sci_interrupt) { if (intsrc->source_irq == acpi_gbl_FADT.sci_interrupt) {
acpi_sci_ioapic_setup(intsrc->source_irq, acpi_sci_ioapic_setup(intsrc->source_irq,
...@@ -549,7 +549,7 @@ acpi_parse_int_src_ovr(struct acpi_subtable_header * header, ...@@ -549,7 +549,7 @@ acpi_parse_int_src_ovr(struct acpi_subtable_header * header,
} }
static int __init static int __init
acpi_parse_nmi_src(struct acpi_subtable_header * header, const unsigned long end) acpi_parse_nmi_src(union acpi_subtable_headers * header, const unsigned long end)
{ {
struct acpi_madt_nmi_source *nmi_src = NULL; struct acpi_madt_nmi_source *nmi_src = NULL;
...@@ -558,7 +558,7 @@ acpi_parse_nmi_src(struct acpi_subtable_header * header, const unsigned long end ...@@ -558,7 +558,7 @@ acpi_parse_nmi_src(struct acpi_subtable_header * header, const unsigned long end
if (BAD_MADT_ENTRY(nmi_src, end)) if (BAD_MADT_ENTRY(nmi_src, end))
return -EINVAL; return -EINVAL;
acpi_table_print_madt_entry(header); acpi_table_print_madt_entry(&header->common);
/* TBD: Support nimsrc entries? */ /* TBD: Support nimsrc entries? */
......
...@@ -339,7 +339,7 @@ acpi_numa_x2apic_affinity_init(struct acpi_srat_x2apic_cpu_affinity *pa) ...@@ -339,7 +339,7 @@ acpi_numa_x2apic_affinity_init(struct acpi_srat_x2apic_cpu_affinity *pa)
} }
static int __init static int __init
acpi_parse_x2apic_affinity(struct acpi_subtable_header *header, acpi_parse_x2apic_affinity(union acpi_subtable_headers *header,
const unsigned long end) const unsigned long end)
{ {
struct acpi_srat_x2apic_cpu_affinity *processor_affinity; struct acpi_srat_x2apic_cpu_affinity *processor_affinity;
...@@ -348,7 +348,7 @@ acpi_parse_x2apic_affinity(struct acpi_subtable_header *header, ...@@ -348,7 +348,7 @@ acpi_parse_x2apic_affinity(struct acpi_subtable_header *header,
if (!processor_affinity) if (!processor_affinity)
return -EINVAL; return -EINVAL;
acpi_table_print_srat_entry(header); acpi_table_print_srat_entry(&header->common);
/* let architecture-dependent part to do it */ /* let architecture-dependent part to do it */
acpi_numa_x2apic_affinity_init(processor_affinity); acpi_numa_x2apic_affinity_init(processor_affinity);
...@@ -357,7 +357,7 @@ acpi_parse_x2apic_affinity(struct acpi_subtable_header *header, ...@@ -357,7 +357,7 @@ acpi_parse_x2apic_affinity(struct acpi_subtable_header *header,
} }
static int __init static int __init
acpi_parse_processor_affinity(struct acpi_subtable_header *header, acpi_parse_processor_affinity(union acpi_subtable_headers *header,
const unsigned long end) const unsigned long end)
{ {
struct acpi_srat_cpu_affinity *processor_affinity; struct acpi_srat_cpu_affinity *processor_affinity;
...@@ -366,7 +366,7 @@ acpi_parse_processor_affinity(struct acpi_subtable_header *header, ...@@ -366,7 +366,7 @@ acpi_parse_processor_affinity(struct acpi_subtable_header *header,
if (!processor_affinity) if (!processor_affinity)
return -EINVAL; return -EINVAL;
acpi_table_print_srat_entry(header); acpi_table_print_srat_entry(&header->common);
/* let architecture-dependent part to do it */ /* let architecture-dependent part to do it */
acpi_numa_processor_affinity_init(processor_affinity); acpi_numa_processor_affinity_init(processor_affinity);
...@@ -375,7 +375,7 @@ acpi_parse_processor_affinity(struct acpi_subtable_header *header, ...@@ -375,7 +375,7 @@ acpi_parse_processor_affinity(struct acpi_subtable_header *header,
} }
static int __init static int __init
acpi_parse_gicc_affinity(struct acpi_subtable_header *header, acpi_parse_gicc_affinity(union acpi_subtable_headers *header,
const unsigned long end) const unsigned long end)
{ {
struct acpi_srat_gicc_affinity *processor_affinity; struct acpi_srat_gicc_affinity *processor_affinity;
...@@ -384,7 +384,7 @@ acpi_parse_gicc_affinity(struct acpi_subtable_header *header, ...@@ -384,7 +384,7 @@ acpi_parse_gicc_affinity(struct acpi_subtable_header *header,
if (!processor_affinity) if (!processor_affinity)
return -EINVAL; return -EINVAL;
acpi_table_print_srat_entry(header); acpi_table_print_srat_entry(&header->common);
/* let architecture-dependent part to do it */ /* let architecture-dependent part to do it */
acpi_numa_gicc_affinity_init(processor_affinity); acpi_numa_gicc_affinity_init(processor_affinity);
...@@ -395,7 +395,7 @@ acpi_parse_gicc_affinity(struct acpi_subtable_header *header, ...@@ -395,7 +395,7 @@ acpi_parse_gicc_affinity(struct acpi_subtable_header *header,
static int __initdata parsed_numa_memblks; static int __initdata parsed_numa_memblks;
static int __init static int __init
acpi_parse_memory_affinity(struct acpi_subtable_header * header, acpi_parse_memory_affinity(union acpi_subtable_headers * header,
const unsigned long end) const unsigned long end)
{ {
struct acpi_srat_mem_affinity *memory_affinity; struct acpi_srat_mem_affinity *memory_affinity;
...@@ -404,7 +404,7 @@ acpi_parse_memory_affinity(struct acpi_subtable_header * header, ...@@ -404,7 +404,7 @@ acpi_parse_memory_affinity(struct acpi_subtable_header * header,
if (!memory_affinity) if (!memory_affinity)
return -EINVAL; return -EINVAL;
acpi_table_print_srat_entry(header); acpi_table_print_srat_entry(&header->common);
/* let architecture-dependent part to do it */ /* let architecture-dependent part to do it */
if (!acpi_numa_memory_affinity_init(memory_affinity)) if (!acpi_numa_memory_affinity_init(memory_affinity))
......
...@@ -2243,10 +2243,10 @@ static struct acpi_probe_entry *ape; ...@@ -2243,10 +2243,10 @@ static struct acpi_probe_entry *ape;
static int acpi_probe_count; static int acpi_probe_count;
static DEFINE_MUTEX(acpi_probe_mutex); static DEFINE_MUTEX(acpi_probe_mutex);
static int __init acpi_match_madt(struct acpi_subtable_header *header, static int __init acpi_match_madt(union acpi_subtable_headers *header,
const unsigned long end) const unsigned long end)
{ {
if (!ape->subtable_valid || ape->subtable_valid(header, ape)) if (!ape->subtable_valid || ape->subtable_valid(&header->common, ape))
if (!ape->probe_subtbl(header, end)) if (!ape->probe_subtbl(header, end))
acpi_probe_count++; acpi_probe_count++;
......
...@@ -50,6 +50,15 @@ static struct acpi_table_desc initial_tables[ACPI_MAX_TABLES] __initdata; ...@@ -50,6 +50,15 @@ static struct acpi_table_desc initial_tables[ACPI_MAX_TABLES] __initdata;
static int acpi_apic_instance __initdata; static int acpi_apic_instance __initdata;
enum acpi_subtable_type {
ACPI_SUBTABLE_COMMON,
};
struct acpi_subtable_entry {
union acpi_subtable_headers *hdr;
enum acpi_subtable_type type;
};
/* /*
* Disable table checksum verification for the early stage due to the size * Disable table checksum verification for the early stage due to the size
* limitation of the current x86 early mapping implementation. * limitation of the current x86 early mapping implementation.
...@@ -218,6 +227,42 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header) ...@@ -218,6 +227,42 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header)
} }
} }
static unsigned long __init
acpi_get_entry_type(struct acpi_subtable_entry *entry)
{
switch (entry->type) {
case ACPI_SUBTABLE_COMMON:
return entry->hdr->common.type;
}
return 0;
}
static unsigned long __init
acpi_get_entry_length(struct acpi_subtable_entry *entry)
{
switch (entry->type) {
case ACPI_SUBTABLE_COMMON:
return entry->hdr->common.length;
}
return 0;
}
static unsigned long __init
acpi_get_subtable_header_length(struct acpi_subtable_entry *entry)
{
switch (entry->type) {
case ACPI_SUBTABLE_COMMON:
return sizeof(entry->hdr->common);
}
return 0;
}
static enum acpi_subtable_type __init
acpi_get_subtable_type(char *id)
{
return ACPI_SUBTABLE_COMMON;
}
/** /**
* acpi_parse_entries_array - for each proc_num find a suitable subtable * acpi_parse_entries_array - for each proc_num find a suitable subtable
* *
...@@ -247,8 +292,8 @@ acpi_parse_entries_array(char *id, unsigned long table_size, ...@@ -247,8 +292,8 @@ acpi_parse_entries_array(char *id, unsigned long table_size,
struct acpi_subtable_proc *proc, int proc_num, struct acpi_subtable_proc *proc, int proc_num,
unsigned int max_entries) unsigned int max_entries)
{ {
struct acpi_subtable_header *entry; struct acpi_subtable_entry entry;
unsigned long table_end; unsigned long table_end, subtable_len, entry_len;
int count = 0; int count = 0;
int errs = 0; int errs = 0;
int i; int i;
...@@ -271,19 +316,20 @@ acpi_parse_entries_array(char *id, unsigned long table_size, ...@@ -271,19 +316,20 @@ acpi_parse_entries_array(char *id, unsigned long table_size,
/* Parse all entries looking for a match. */ /* Parse all entries looking for a match. */
entry = (struct acpi_subtable_header *) entry.type = acpi_get_subtable_type(id);
entry.hdr = (union acpi_subtable_headers *)
((unsigned long)table_header + table_size); ((unsigned long)table_header + table_size);
subtable_len = acpi_get_subtable_header_length(&entry);
while (((unsigned long)entry) + sizeof(struct acpi_subtable_header) < while (((unsigned long)entry.hdr) + subtable_len < table_end) {
table_end) {
if (max_entries && count >= max_entries) if (max_entries && count >= max_entries)
break; break;
for (i = 0; i < proc_num; i++) { for (i = 0; i < proc_num; i++) {
if (entry->type != proc[i].id) if (acpi_get_entry_type(&entry) != proc[i].id)
continue; continue;
if (!proc[i].handler || if (!proc[i].handler ||
(!errs && proc[i].handler(entry, table_end))) { (!errs && proc[i].handler(entry.hdr, table_end))) {
errs++; errs++;
continue; continue;
} }
...@@ -298,13 +344,14 @@ acpi_parse_entries_array(char *id, unsigned long table_size, ...@@ -298,13 +344,14 @@ acpi_parse_entries_array(char *id, unsigned long table_size,
* If entry->length is 0, break from this loop to avoid * If entry->length is 0, break from this loop to avoid
* infinite loop. * infinite loop.
*/ */
if (entry->length == 0) { entry_len = acpi_get_entry_length(&entry);
if (entry_len == 0) {
pr_err("[%4.4s:0x%02x] Invalid zero length\n", id, proc->id); pr_err("[%4.4s:0x%02x] Invalid zero length\n", id, proc->id);
return -EINVAL; return -EINVAL;
} }
entry = (struct acpi_subtable_header *) entry.hdr = (union acpi_subtable_headers *)
((unsigned long)entry + entry->length); ((unsigned long)entry.hdr + entry_len);
} }
if (max_entries && count > max_entries) { if (max_entries && count > max_entries) {
......
...@@ -446,7 +446,7 @@ static struct fwnode_handle *gicv2m_get_fwnode(struct device *dev) ...@@ -446,7 +446,7 @@ static struct fwnode_handle *gicv2m_get_fwnode(struct device *dev)
} }
static int __init static int __init
acpi_parse_madt_msi(struct acpi_subtable_header *header, acpi_parse_madt_msi(union acpi_subtable_headers *header,
const unsigned long end) const unsigned long end)
{ {
int ret; int ret;
......
...@@ -159,7 +159,7 @@ static int __init its_pci_of_msi_init(void) ...@@ -159,7 +159,7 @@ static int __init its_pci_of_msi_init(void)
#ifdef CONFIG_ACPI #ifdef CONFIG_ACPI
static int __init static int __init
its_pci_msi_parse_madt(struct acpi_subtable_header *header, its_pci_msi_parse_madt(union acpi_subtable_headers *header,
const unsigned long end) const unsigned long end)
{ {
struct acpi_madt_generic_translator *its_entry; struct acpi_madt_generic_translator *its_entry;
......
...@@ -117,7 +117,7 @@ static int __init its_pmsi_init_one(struct fwnode_handle *fwnode, ...@@ -117,7 +117,7 @@ static int __init its_pmsi_init_one(struct fwnode_handle *fwnode,
#ifdef CONFIG_ACPI #ifdef CONFIG_ACPI
static int __init static int __init
its_pmsi_parse_madt(struct acpi_subtable_header *header, its_pmsi_parse_madt(union acpi_subtable_headers *header,
const unsigned long end) const unsigned long end)
{ {
struct acpi_madt_generic_translator *its_entry; struct acpi_madt_generic_translator *its_entry;
......
...@@ -3840,13 +3840,13 @@ static int __init acpi_get_its_numa_node(u32 its_id) ...@@ -3840,13 +3840,13 @@ static int __init acpi_get_its_numa_node(u32 its_id)
return NUMA_NO_NODE; return NUMA_NO_NODE;
} }
static int __init gic_acpi_match_srat_its(struct acpi_subtable_header *header, static int __init gic_acpi_match_srat_its(union acpi_subtable_headers *header,
const unsigned long end) const unsigned long end)
{ {
return 0; return 0;
} }
static int __init gic_acpi_parse_srat_its(struct acpi_subtable_header *header, static int __init gic_acpi_parse_srat_its(union acpi_subtable_headers *header,
const unsigned long end) const unsigned long end)
{ {
int node; int node;
...@@ -3913,7 +3913,7 @@ static int __init acpi_get_its_numa_node(u32 its_id) { return NUMA_NO_NODE; } ...@@ -3913,7 +3913,7 @@ static int __init acpi_get_its_numa_node(u32 its_id) { return NUMA_NO_NODE; }
static void __init acpi_its_srat_maps_free(void) { } static void __init acpi_its_srat_maps_free(void) { }
#endif #endif
static int __init gic_acpi_parse_madt_its(struct acpi_subtable_header *header, static int __init gic_acpi_parse_madt_its(union acpi_subtable_headers *header,
const unsigned long end) const unsigned long end)
{ {
struct acpi_madt_generic_translator *its_entry; struct acpi_madt_generic_translator *its_entry;
......
...@@ -1368,7 +1368,7 @@ gic_acpi_register_redist(phys_addr_t phys_base, void __iomem *redist_base) ...@@ -1368,7 +1368,7 @@ gic_acpi_register_redist(phys_addr_t phys_base, void __iomem *redist_base)
} }
static int __init static int __init
gic_acpi_parse_madt_redist(struct acpi_subtable_header *header, gic_acpi_parse_madt_redist(union acpi_subtable_headers *header,
const unsigned long end) const unsigned long end)
{ {
struct acpi_madt_generic_redistributor *redist = struct acpi_madt_generic_redistributor *redist =
...@@ -1386,7 +1386,7 @@ gic_acpi_parse_madt_redist(struct acpi_subtable_header *header, ...@@ -1386,7 +1386,7 @@ gic_acpi_parse_madt_redist(struct acpi_subtable_header *header,
} }
static int __init static int __init
gic_acpi_parse_madt_gicc(struct acpi_subtable_header *header, gic_acpi_parse_madt_gicc(union acpi_subtable_headers *header,
const unsigned long end) const unsigned long end)
{ {
struct acpi_madt_generic_interrupt *gicc = struct acpi_madt_generic_interrupt *gicc =
...@@ -1428,14 +1428,14 @@ static int __init gic_acpi_collect_gicr_base(void) ...@@ -1428,14 +1428,14 @@ static int __init gic_acpi_collect_gicr_base(void)
return -ENODEV; return -ENODEV;
} }
static int __init gic_acpi_match_gicr(struct acpi_subtable_header *header, static int __init gic_acpi_match_gicr(union acpi_subtable_headers *header,
const unsigned long end) const unsigned long end)
{ {
/* Subtable presence means that redist exists, that's it */ /* Subtable presence means that redist exists, that's it */
return 0; return 0;
} }
static int __init gic_acpi_match_gicc(struct acpi_subtable_header *header, static int __init gic_acpi_match_gicc(union acpi_subtable_headers *header,
const unsigned long end) const unsigned long end)
{ {
struct acpi_madt_generic_interrupt *gicc = struct acpi_madt_generic_interrupt *gicc =
...@@ -1501,7 +1501,7 @@ static bool __init acpi_validate_gic_table(struct acpi_subtable_header *header, ...@@ -1501,7 +1501,7 @@ static bool __init acpi_validate_gic_table(struct acpi_subtable_header *header,
return true; return true;
} }
static int __init gic_acpi_parse_virt_madt_gicc(struct acpi_subtable_header *header, static int __init gic_acpi_parse_virt_madt_gicc(union acpi_subtable_headers *header,
const unsigned long end) const unsigned long end)
{ {
struct acpi_madt_generic_interrupt *gicc = struct acpi_madt_generic_interrupt *gicc =
......
...@@ -1508,7 +1508,7 @@ static struct ...@@ -1508,7 +1508,7 @@ static struct
} acpi_data __initdata; } acpi_data __initdata;
static int __init static int __init
gic_acpi_parse_madt_cpu(struct acpi_subtable_header *header, gic_acpi_parse_madt_cpu(union acpi_subtable_headers *header,
const unsigned long end) const unsigned long end)
{ {
struct acpi_madt_generic_interrupt *processor; struct acpi_madt_generic_interrupt *processor;
...@@ -1540,7 +1540,7 @@ gic_acpi_parse_madt_cpu(struct acpi_subtable_header *header, ...@@ -1540,7 +1540,7 @@ gic_acpi_parse_madt_cpu(struct acpi_subtable_header *header,
} }
/* The things you have to do to just *count* something... */ /* The things you have to do to just *count* something... */
static int __init acpi_dummy_func(struct acpi_subtable_header *header, static int __init acpi_dummy_func(union acpi_subtable_headers *header,
const unsigned long end) const unsigned long end)
{ {
return 0; return 0;
......
...@@ -382,7 +382,7 @@ static const struct mbox_chan_ops pcc_chan_ops = { ...@@ -382,7 +382,7 @@ static const struct mbox_chan_ops pcc_chan_ops = {
* *
* This gets called for each entry in the PCC table. * This gets called for each entry in the PCC table.
*/ */
static int parse_pcc_subspace(struct acpi_subtable_header *header, static int parse_pcc_subspace(union acpi_subtable_headers *header,
const unsigned long end) const unsigned long end)
{ {
struct acpi_pcct_subspace *ss = (struct acpi_pcct_subspace *) header; struct acpi_pcct_subspace *ss = (struct acpi_pcct_subspace *) header;
......
...@@ -141,10 +141,13 @@ enum acpi_address_range_id { ...@@ -141,10 +141,13 @@ enum acpi_address_range_id {
/* Table Handlers */ /* Table Handlers */
union acpi_subtable_headers {
struct acpi_subtable_header common;
};
typedef int (*acpi_tbl_table_handler)(struct acpi_table_header *table); typedef int (*acpi_tbl_table_handler)(struct acpi_table_header *table);
typedef int (*acpi_tbl_entry_handler)(struct acpi_subtable_header *header, typedef int (*acpi_tbl_entry_handler)(union acpi_subtable_headers *header,
const unsigned long end); const unsigned long end);
/* Debugger support */ /* Debugger support */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册