2005-04-16 16:20:36 -06:00
|
|
|
/*
|
|
|
|
* acpi_tables.c - ACPI Boot-Time Table Parsing
|
|
|
|
*
|
|
|
|
* Copyright (C) 2001 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
|
|
|
|
*
|
|
|
|
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2015-03-24 08:02:34 -06:00
|
|
|
/* Uncomment next line to get verbose printout */
|
|
|
|
/* #define DEBUG */
|
2014-02-20 00:45:33 -07:00
|
|
|
#define pr_fmt(fmt) "ACPI: " fmt
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/smp.h>
|
|
|
|
#include <linux/string.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/irq.h>
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/acpi.h>
|
|
|
|
#include <linux/bootmem.h>
|
|
|
|
|
2005-12-30 00:44:59 -07:00
|
|
|
#define ACPI_MAX_TABLES 128
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
static char *mps_inti_flags_polarity[] = { "dfl", "high", "res", "low" };
|
|
|
|
static char *mps_inti_flags_trigger[] = { "dfl", "edge", "res", "level" };
|
|
|
|
|
2007-02-02 09:48:19 -07:00
|
|
|
static struct acpi_table_desc initial_tables[ACPI_MAX_TABLES] __initdata;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2007-03-30 12:16:10 -06:00
|
|
|
static int acpi_apic_instance __initdata;
|
2007-03-11 00:26:14 -07:00
|
|
|
|
2014-05-30 18:15:02 -06:00
|
|
|
/*
|
|
|
|
* Disable table checksum verification for the early stage due to the size
|
|
|
|
* limitation of the current x86 early mapping implementation.
|
|
|
|
*/
|
|
|
|
static bool acpi_verify_table_checksum __initdata = false;
|
|
|
|
|
2007-03-11 00:26:14 -07:00
|
|
|
void acpi_table_print_madt_entry(struct acpi_subtable_header *header)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
|
|
|
if (!header)
|
|
|
|
return;
|
|
|
|
|
|
|
|
switch (header->type) {
|
|
|
|
|
2007-02-02 09:48:22 -07:00
|
|
|
case ACPI_MADT_TYPE_LOCAL_APIC:
|
2005-08-04 22:44:28 -06:00
|
|
|
{
|
2007-02-02 09:48:22 -07:00
|
|
|
struct acpi_madt_local_apic *p =
|
|
|
|
(struct acpi_madt_local_apic *)header;
|
2015-03-24 08:02:34 -06:00
|
|
|
pr_debug("LAPIC (acpi_id[0x%02x] lapic_id[0x%02x] %s)\n",
|
|
|
|
p->processor_id, p->id,
|
|
|
|
(p->lapic_flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled");
|
2005-08-04 22:44:28 -06:00
|
|
|
}
|
2005-04-16 16:20:36 -06:00
|
|
|
break;
|
|
|
|
|
2009-03-30 15:55:30 -06:00
|
|
|
case ACPI_MADT_TYPE_LOCAL_X2APIC:
|
|
|
|
{
|
|
|
|
struct acpi_madt_local_x2apic *p =
|
|
|
|
(struct acpi_madt_local_x2apic *)header;
|
2015-03-24 08:02:34 -06:00
|
|
|
pr_debug("X2APIC (apic_id[0x%02x] uid[0x%02x] %s)\n",
|
|
|
|
p->local_apic_id, p->uid,
|
|
|
|
(p->lapic_flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled");
|
2009-03-30 15:55:30 -06:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2007-02-02 09:48:22 -07:00
|
|
|
case ACPI_MADT_TYPE_IO_APIC:
|
2005-08-04 22:44:28 -06:00
|
|
|
{
|
2007-02-02 09:48:22 -07:00
|
|
|
struct acpi_madt_io_apic *p =
|
|
|
|
(struct acpi_madt_io_apic *)header;
|
2015-03-24 08:02:34 -06:00
|
|
|
pr_debug("IOAPIC (id[0x%02x] address[0x%08x] gsi_base[%d])\n",
|
|
|
|
p->id, p->address, p->global_irq_base);
|
2005-08-04 22:44:28 -06:00
|
|
|
}
|
2005-04-16 16:20:36 -06:00
|
|
|
break;
|
|
|
|
|
2007-02-02 09:48:22 -07:00
|
|
|
case ACPI_MADT_TYPE_INTERRUPT_OVERRIDE:
|
2005-08-04 22:44:28 -06:00
|
|
|
{
|
2007-02-02 09:48:22 -07:00
|
|
|
struct acpi_madt_interrupt_override *p =
|
|
|
|
(struct acpi_madt_interrupt_override *)header;
|
2014-02-20 00:45:33 -07:00
|
|
|
pr_info("INT_SRC_OVR (bus %d bus_irq %d global_irq %d %s %s)\n",
|
|
|
|
p->bus, p->source_irq, p->global_irq,
|
|
|
|
mps_inti_flags_polarity[p->inti_flags & ACPI_MADT_POLARITY_MASK],
|
|
|
|
mps_inti_flags_trigger[(p->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2]);
|
2007-02-02 09:48:22 -07:00
|
|
|
if (p->inti_flags &
|
|
|
|
~(ACPI_MADT_POLARITY_MASK | ACPI_MADT_TRIGGER_MASK))
|
2014-02-20 00:45:33 -07:00
|
|
|
pr_info("INT_SRC_OVR unexpected reserved flags: 0x%x\n",
|
|
|
|
p->inti_flags &
|
2007-02-02 09:48:22 -07:00
|
|
|
~(ACPI_MADT_POLARITY_MASK | ACPI_MADT_TRIGGER_MASK));
|
2005-08-04 22:44:28 -06:00
|
|
|
}
|
2005-04-16 16:20:36 -06:00
|
|
|
break;
|
|
|
|
|
2007-02-02 09:48:22 -07:00
|
|
|
case ACPI_MADT_TYPE_NMI_SOURCE:
|
2005-08-04 22:44:28 -06:00
|
|
|
{
|
2007-02-02 09:48:22 -07:00
|
|
|
struct acpi_madt_nmi_source *p =
|
|
|
|
(struct acpi_madt_nmi_source *)header;
|
2014-02-20 00:45:33 -07:00
|
|
|
pr_info("NMI_SRC (%s %s global_irq %d)\n",
|
|
|
|
mps_inti_flags_polarity[p->inti_flags & ACPI_MADT_POLARITY_MASK],
|
|
|
|
mps_inti_flags_trigger[(p->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2],
|
|
|
|
p->global_irq);
|
2005-08-04 22:44:28 -06:00
|
|
|
}
|
2005-04-16 16:20:36 -06:00
|
|
|
break;
|
|
|
|
|
2007-02-02 09:48:22 -07:00
|
|
|
case ACPI_MADT_TYPE_LOCAL_APIC_NMI:
|
2005-08-04 22:44:28 -06:00
|
|
|
{
|
2007-02-02 09:48:22 -07:00
|
|
|
struct acpi_madt_local_apic_nmi *p =
|
|
|
|
(struct acpi_madt_local_apic_nmi *)header;
|
2014-02-20 00:45:33 -07:00
|
|
|
pr_info("LAPIC_NMI (acpi_id[0x%02x] %s %s lint[0x%x])\n",
|
|
|
|
p->processor_id,
|
|
|
|
mps_inti_flags_polarity[p->inti_flags & ACPI_MADT_POLARITY_MASK ],
|
|
|
|
mps_inti_flags_trigger[(p->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2],
|
|
|
|
p->lint);
|
2009-03-30 15:55:30 -06:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ACPI_MADT_TYPE_LOCAL_X2APIC_NMI:
|
|
|
|
{
|
|
|
|
u16 polarity, trigger;
|
|
|
|
struct acpi_madt_local_x2apic_nmi *p =
|
|
|
|
(struct acpi_madt_local_x2apic_nmi *)header;
|
|
|
|
|
|
|
|
polarity = p->inti_flags & ACPI_MADT_POLARITY_MASK;
|
|
|
|
trigger = (p->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2;
|
|
|
|
|
2014-02-20 00:45:33 -07:00
|
|
|
pr_info("X2APIC_NMI (uid[0x%02x] %s %s lint[0x%x])\n",
|
|
|
|
p->uid,
|
|
|
|
mps_inti_flags_polarity[polarity],
|
|
|
|
mps_inti_flags_trigger[trigger],
|
|
|
|
p->lint);
|
2005-08-04 22:44:28 -06:00
|
|
|
}
|
2005-04-16 16:20:36 -06:00
|
|
|
break;
|
|
|
|
|
2007-02-02 09:48:22 -07:00
|
|
|
case ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE:
|
2005-08-04 22:44:28 -06:00
|
|
|
{
|
2007-02-02 09:48:22 -07:00
|
|
|
struct acpi_madt_local_apic_override *p =
|
|
|
|
(struct acpi_madt_local_apic_override *)header;
|
2014-02-20 00:45:33 -07:00
|
|
|
pr_info("LAPIC_ADDR_OVR (address[%p])\n",
|
|
|
|
(void *)(unsigned long)p->address);
|
2005-08-04 22:44:28 -06:00
|
|
|
}
|
2005-04-16 16:20:36 -06:00
|
|
|
break;
|
|
|
|
|
2007-02-02 09:48:22 -07:00
|
|
|
case ACPI_MADT_TYPE_IO_SAPIC:
|
2005-08-04 22:44:28 -06:00
|
|
|
{
|
2007-02-02 09:48:22 -07:00
|
|
|
struct acpi_madt_io_sapic *p =
|
|
|
|
(struct acpi_madt_io_sapic *)header;
|
2015-03-24 08:02:34 -06:00
|
|
|
pr_debug("IOSAPIC (id[0x%x] address[%p] gsi_base[%d])\n",
|
|
|
|
p->id, (void *)(unsigned long)p->address,
|
|
|
|
p->global_irq_base);
|
2005-08-04 22:44:28 -06:00
|
|
|
}
|
2005-04-16 16:20:36 -06:00
|
|
|
break;
|
|
|
|
|
2007-02-02 09:48:22 -07:00
|
|
|
case ACPI_MADT_TYPE_LOCAL_SAPIC:
|
2005-08-04 22:44:28 -06:00
|
|
|
{
|
2007-02-02 09:48:22 -07:00
|
|
|
struct acpi_madt_local_sapic *p =
|
|
|
|
(struct acpi_madt_local_sapic *)header;
|
2015-03-24 08:02:34 -06:00
|
|
|
pr_debug("LSAPIC (acpi_id[0x%02x] lsapic_id[0x%02x] lsapic_eid[0x%02x] %s)\n",
|
|
|
|
p->processor_id, p->id, p->eid,
|
|
|
|
(p->lapic_flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled");
|
2005-08-04 22:44:28 -06:00
|
|
|
}
|
2005-04-16 16:20:36 -06:00
|
|
|
break;
|
|
|
|
|
2007-02-02 09:48:22 -07:00
|
|
|
case ACPI_MADT_TYPE_INTERRUPT_SOURCE:
|
2005-08-04 22:44:28 -06:00
|
|
|
{
|
2007-02-02 09:48:22 -07:00
|
|
|
struct acpi_madt_interrupt_source *p =
|
|
|
|
(struct acpi_madt_interrupt_source *)header;
|
2014-02-20 00:45:33 -07:00
|
|
|
pr_info("PLAT_INT_SRC (%s %s type[0x%x] id[0x%04x] eid[0x%x] iosapic_vector[0x%x] global_irq[0x%x]\n",
|
|
|
|
mps_inti_flags_polarity[p->inti_flags & ACPI_MADT_POLARITY_MASK],
|
|
|
|
mps_inti_flags_trigger[(p->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2],
|
|
|
|
p->type, p->id, p->eid, p->io_sapic_vector,
|
|
|
|
p->global_irq);
|
2005-08-04 22:44:28 -06:00
|
|
|
}
|
2005-04-16 16:20:36 -06:00
|
|
|
break;
|
|
|
|
|
2015-03-24 08:02:44 -06:00
|
|
|
case ACPI_MADT_TYPE_GENERIC_INTERRUPT:
|
|
|
|
{
|
|
|
|
struct acpi_madt_generic_interrupt *p =
|
|
|
|
(struct acpi_madt_generic_interrupt *)header;
|
|
|
|
pr_debug("GICC (acpi_id[0x%04x] address[%llx] MPIDR[0x%llx] %s)\n",
|
|
|
|
p->uid, p->base_address,
|
|
|
|
p->arm_mpidr,
|
|
|
|
(p->flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled");
|
|
|
|
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR:
|
|
|
|
{
|
|
|
|
struct acpi_madt_generic_distributor *p =
|
|
|
|
(struct acpi_madt_generic_distributor *)header;
|
|
|
|
pr_debug("GIC Distributor (gic_id[0x%04x] address[%llx] gsi_base[%d])\n",
|
|
|
|
p->gic_id, p->base_address,
|
|
|
|
p->global_irq_base);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
default:
|
2014-02-20 00:45:33 -07:00
|
|
|
pr_warn("Found unsupported MADT entry (type = 0x%x)\n",
|
|
|
|
header->type);
|
2005-04-16 16:20:36 -06:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int __init
|
2014-11-26 07:01:13 -07:00
|
|
|
acpi_parse_entries(char *id, unsigned long table_size,
|
|
|
|
acpi_tbl_entry_handler handler,
|
|
|
|
struct acpi_table_header *table_header,
|
|
|
|
int entry_id, unsigned int max_entries)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2007-02-02 09:48:22 -07:00
|
|
|
struct acpi_subtable_header *entry;
|
2014-11-26 07:01:13 -07:00
|
|
|
int count = 0;
|
2007-02-10 20:17:07 -07:00
|
|
|
unsigned long table_end;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2010-02-18 22:09:22 -07:00
|
|
|
if (acpi_disabled)
|
2009-07-07 21:22:58 -06:00
|
|
|
return -ENODEV;
|
|
|
|
|
2014-11-26 07:01:13 -07:00
|
|
|
if (!id || !handler)
|
2005-04-16 16:20:36 -06:00
|
|
|
return -EINVAL;
|
|
|
|
|
2014-11-26 07:01:13 -07:00
|
|
|
if (!table_size)
|
|
|
|
return -EINVAL;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2007-02-10 20:17:07 -07:00
|
|
|
if (!table_header) {
|
2014-02-20 00:45:33 -07:00
|
|
|
pr_warn("%4.4s not present\n", id);
|
2005-04-16 16:20:36 -06:00
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
2007-02-10 20:17:07 -07:00
|
|
|
table_end = (unsigned long)table_header + table_header->length;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/* Parse all entries looking for a match. */
|
|
|
|
|
2007-02-02 09:48:22 -07:00
|
|
|
entry = (struct acpi_subtable_header *)
|
2007-02-10 20:17:07 -07:00
|
|
|
((unsigned long)table_header + table_size);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2007-02-02 09:48:22 -07:00
|
|
|
while (((unsigned long)entry) + sizeof(struct acpi_subtable_header) <
|
2007-02-10 20:17:07 -07:00
|
|
|
table_end) {
|
2005-08-04 22:44:28 -06:00
|
|
|
if (entry->type == entry_id
|
2014-11-26 07:01:14 -07:00
|
|
|
&& (!max_entries || count < max_entries)) {
|
2012-09-25 12:11:43 -06:00
|
|
|
if (handler(entry, table_end))
|
2014-11-26 07:01:13 -07:00
|
|
|
return -EINVAL;
|
2012-09-25 12:11:43 -06:00
|
|
|
|
2014-11-26 07:01:14 -07:00
|
|
|
count++;
|
|
|
|
}
|
|
|
|
|
2012-09-25 12:11:43 -06:00
|
|
|
/*
|
|
|
|
* If entry->length is 0, break from this loop to avoid
|
|
|
|
* infinite loop.
|
|
|
|
*/
|
|
|
|
if (entry->length == 0) {
|
2014-02-20 00:45:33 -07:00
|
|
|
pr_err("[%4.4s:0x%02x] Invalid zero length\n", id, entry_id);
|
2014-11-26 07:01:13 -07:00
|
|
|
return -EINVAL;
|
2012-09-25 12:11:43 -06:00
|
|
|
}
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2007-02-02 09:48:22 -07:00
|
|
|
entry = (struct acpi_subtable_header *)
|
2005-08-04 22:44:28 -06:00
|
|
|
((unsigned long)entry + entry->length);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
2014-11-26 07:01:13 -07:00
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
if (max_entries && count > max_entries) {
|
2014-02-20 00:45:33 -07:00
|
|
|
pr_warn("[%4.4s:0x%02x] ignored %i entries of %i found\n",
|
|
|
|
id, entry_id, count - max_entries, count);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
return count;
|
2014-11-26 07:01:13 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int __init
|
|
|
|
acpi_table_parse_entries(char *id,
|
|
|
|
unsigned long table_size,
|
|
|
|
int entry_id,
|
|
|
|
acpi_tbl_entry_handler handler,
|
|
|
|
unsigned int max_entries)
|
|
|
|
{
|
|
|
|
struct acpi_table_header *table_header = NULL;
|
|
|
|
acpi_size tbl_size;
|
|
|
|
int count;
|
|
|
|
u32 instance = 0;
|
|
|
|
|
|
|
|
if (acpi_disabled)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
if (!id || !handler)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (!strncmp(id, ACPI_SIG_MADT, 4))
|
|
|
|
instance = acpi_apic_instance;
|
|
|
|
|
|
|
|
acpi_get_table_with_size(id, instance, &table_header, &tbl_size);
|
|
|
|
if (!table_header) {
|
|
|
|
pr_warn("%4.4s not present\n", id);
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
|
|
|
count = acpi_parse_entries(id, table_size, handler, table_header,
|
|
|
|
entry_id, max_entries);
|
|
|
|
|
2012-09-25 12:11:43 -06:00
|
|
|
early_acpi_os_unmap_memory((char *)table_header, tbl_size);
|
2014-11-26 07:01:13 -07:00
|
|
|
return count;
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
int __init
|
2007-02-02 09:48:22 -07:00
|
|
|
acpi_table_parse_madt(enum acpi_madt_type id,
|
2013-01-12 08:29:38 -07:00
|
|
|
acpi_tbl_entry_handler handler, unsigned int max_entries)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2007-02-10 20:17:07 -07:00
|
|
|
return acpi_table_parse_entries(ACPI_SIG_MADT,
|
2005-08-04 22:44:28 -06:00
|
|
|
sizeof(struct acpi_table_madt), id,
|
|
|
|
handler, max_entries);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
2007-02-10 19:28:03 -07:00
|
|
|
/**
|
|
|
|
* acpi_table_parse - find table with @id, run @handler on it
|
|
|
|
* @id: table id to find
|
|
|
|
* @handler: handler to run
|
|
|
|
*
|
|
|
|
* Scan the ACPI System Descriptor Table (STD) for a table matching @id,
|
2014-01-06 01:47:59 -07:00
|
|
|
* run @handler on it.
|
|
|
|
*
|
|
|
|
* Return 0 if table found, -errno if not.
|
2007-02-10 19:28:03 -07:00
|
|
|
*/
|
2013-01-12 08:29:38 -07:00
|
|
|
int __init acpi_table_parse(char *id, acpi_tbl_table_handler handler)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2007-02-02 09:48:22 -07:00
|
|
|
struct acpi_table_header *table = NULL;
|
2009-02-07 16:39:41 -07:00
|
|
|
acpi_size tbl_size;
|
2007-03-11 00:26:14 -07:00
|
|
|
|
2010-02-18 22:09:22 -07:00
|
|
|
if (acpi_disabled)
|
2009-07-07 21:22:58 -06:00
|
|
|
return -ENODEV;
|
|
|
|
|
2014-01-06 01:43:54 -07:00
|
|
|
if (!id || !handler)
|
2005-04-16 16:20:36 -06:00
|
|
|
return -EINVAL;
|
|
|
|
|
2007-03-11 00:26:14 -07:00
|
|
|
if (strncmp(id, ACPI_SIG_MADT, 4) == 0)
|
2009-02-07 16:39:41 -07:00
|
|
|
acpi_get_table_with_size(id, acpi_apic_instance, &table, &tbl_size);
|
2007-03-11 00:26:14 -07:00
|
|
|
else
|
2009-02-07 16:39:41 -07:00
|
|
|
acpi_get_table_with_size(id, 0, &table, &tbl_size);
|
2007-03-11 00:26:14 -07:00
|
|
|
|
2007-02-02 09:48:22 -07:00
|
|
|
if (table) {
|
|
|
|
handler(table);
|
2009-02-07 16:39:41 -07:00
|
|
|
early_acpi_os_unmap_memory(table, tbl_size);
|
2007-02-02 09:48:22 -07:00
|
|
|
return 0;
|
2007-02-10 19:28:03 -07:00
|
|
|
} else
|
2013-12-05 08:42:38 -07:00
|
|
|
return -ENODEV;
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
2007-03-11 00:26:14 -07:00
|
|
|
/*
|
|
|
|
* The BIOS is supposed to supply a single APIC/MADT,
|
|
|
|
* but some report two. Provide a knob to use either.
|
|
|
|
* (don't you wish instance 0 and 1 were not the same?)
|
|
|
|
*/
|
|
|
|
static void __init check_multiple_madt(void)
|
|
|
|
{
|
|
|
|
struct acpi_table_header *table = NULL;
|
2009-02-07 16:39:41 -07:00
|
|
|
acpi_size tbl_size;
|
2007-03-11 00:26:14 -07:00
|
|
|
|
2009-02-07 16:39:41 -07:00
|
|
|
acpi_get_table_with_size(ACPI_SIG_MADT, 2, &table, &tbl_size);
|
2007-03-11 00:26:14 -07:00
|
|
|
if (table) {
|
2014-02-20 00:45:33 -07:00
|
|
|
pr_warn("BIOS bug: multiple APIC/MADT found, using %d\n",
|
|
|
|
acpi_apic_instance);
|
|
|
|
pr_warn("If \"acpi_apic_instance=%d\" works better, "
|
|
|
|
"notify linux-acpi@vger.kernel.org\n",
|
|
|
|
acpi_apic_instance ? 0 : 2);
|
2009-02-07 16:39:41 -07:00
|
|
|
early_acpi_os_unmap_memory(table, tbl_size);
|
2007-03-11 00:26:14 -07:00
|
|
|
|
|
|
|
} else
|
|
|
|
acpi_apic_instance = 0;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
/*
|
|
|
|
* acpi_table_init()
|
|
|
|
*
|
|
|
|
* find RSDP, find and checksum SDT/XSDT.
|
|
|
|
* checksum all tables, print SDT/XSDT
|
2007-02-02 09:48:22 -07:00
|
|
|
*
|
2005-04-16 16:20:36 -06:00
|
|
|
* result: sdt_entry[] is initialized
|
|
|
|
*/
|
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
int __init acpi_table_init(void)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2009-02-06 12:00:56 -07:00
|
|
|
acpi_status status;
|
|
|
|
|
2014-05-30 18:15:02 -06:00
|
|
|
if (acpi_verify_table_checksum) {
|
|
|
|
pr_info("Early table checksum verification enabled\n");
|
|
|
|
acpi_gbl_verify_table_checksum = TRUE;
|
|
|
|
} else {
|
|
|
|
pr_info("Early table checksum verification disabled\n");
|
|
|
|
acpi_gbl_verify_table_checksum = FALSE;
|
|
|
|
}
|
|
|
|
|
2009-02-06 12:00:56 -07:00
|
|
|
status = acpi_initialize_tables(initial_tables, ACPI_MAX_TABLES, 0);
|
|
|
|
if (ACPI_FAILURE(status))
|
2013-12-05 08:42:38 -07:00
|
|
|
return -EINVAL;
|
2009-02-06 12:00:56 -07:00
|
|
|
|
2007-03-11 00:26:14 -07:00
|
|
|
check_multiple_madt();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int __init acpi_parse_apic_instance(char *str)
|
|
|
|
{
|
2008-08-20 17:41:45 -06:00
|
|
|
if (!str)
|
|
|
|
return -EINVAL;
|
2007-03-11 00:26:14 -07:00
|
|
|
|
2014-06-13 13:49:58 -06:00
|
|
|
if (kstrtoint(str, 0, &acpi_apic_instance))
|
|
|
|
return -EINVAL;
|
2007-03-11 00:26:14 -07:00
|
|
|
|
2014-02-20 00:45:33 -07:00
|
|
|
pr_notice("Shall use APIC/MADT table %d\n", acpi_apic_instance);
|
2007-03-11 00:26:14 -07:00
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
return 0;
|
|
|
|
}
|
2007-03-11 00:26:14 -07:00
|
|
|
|
|
|
|
early_param("acpi_apic_instance", acpi_parse_apic_instance);
|
2014-05-30 18:15:02 -06:00
|
|
|
|
|
|
|
static int __init acpi_force_table_verification_setup(char *s)
|
|
|
|
{
|
|
|
|
acpi_verify_table_checksum = true;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
early_param("acpi_force_table_verification", acpi_force_table_verification_setup);
|