2005-04-16 22:20:36 +00: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
|
|
|
|
*
|
|
|
|
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#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>
|
|
|
|
|
|
|
|
#define PREFIX "ACPI: "
|
|
|
|
|
2005-12-30 07:44:59 +00:00
|
|
|
#define ACPI_MAX_TABLES 128
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
static char *mps_inti_flags_polarity[] = { "dfl", "high", "res", "low" };
|
|
|
|
static char *mps_inti_flags_trigger[] = { "dfl", "edge", "res", "level" };
|
|
|
|
|
2007-02-02 16:48:19 +00:00
|
|
|
static struct acpi_table_desc initial_tables[ACPI_MAX_TABLES] __initdata;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2007-02-02 16:48:22 +00:00
|
|
|
void acpi_table_print_madt_entry(struct acpi_subtable_header * header)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
if (!header)
|
|
|
|
return;
|
|
|
|
|
|
|
|
switch (header->type) {
|
|
|
|
|
2007-02-02 16:48:22 +00:00
|
|
|
case ACPI_MADT_TYPE_LOCAL_APIC:
|
2005-08-05 04:44:28 +00:00
|
|
|
{
|
2007-02-02 16:48:22 +00:00
|
|
|
struct acpi_madt_local_apic *p =
|
|
|
|
(struct acpi_madt_local_apic *)header;
|
2005-08-05 04:44:28 +00:00
|
|
|
printk(KERN_INFO PREFIX
|
|
|
|
"LAPIC (acpi_id[0x%02x] lapic_id[0x%02x] %s)\n",
|
2007-02-02 16:48:22 +00:00
|
|
|
p->processor_id, p->id,
|
|
|
|
(p->lapic_flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled");
|
2005-08-05 04:44:28 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
break;
|
|
|
|
|
2007-02-02 16:48:22 +00:00
|
|
|
case ACPI_MADT_TYPE_IO_APIC:
|
2005-08-05 04:44:28 +00:00
|
|
|
{
|
2007-02-02 16:48:22 +00:00
|
|
|
struct acpi_madt_io_apic *p =
|
|
|
|
(struct acpi_madt_io_apic *)header;
|
2005-08-05 04:44:28 +00:00
|
|
|
printk(KERN_INFO PREFIX
|
|
|
|
"IOAPIC (id[0x%02x] address[0x%08x] gsi_base[%d])\n",
|
|
|
|
p->id, p->address, p->global_irq_base);
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
break;
|
|
|
|
|
2007-02-02 16:48:22 +00:00
|
|
|
case ACPI_MADT_TYPE_INTERRUPT_OVERRIDE:
|
2005-08-05 04:44:28 +00:00
|
|
|
{
|
2007-02-02 16:48:22 +00:00
|
|
|
struct acpi_madt_interrupt_override *p =
|
|
|
|
(struct acpi_madt_interrupt_override *)header;
|
2005-08-05 04:44:28 +00:00
|
|
|
printk(KERN_INFO PREFIX
|
|
|
|
"INT_SRC_OVR (bus %d bus_irq %d global_irq %d %s %s)\n",
|
2007-02-02 16:48:22 +00:00
|
|
|
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]);
|
|
|
|
if (p->inti_flags &
|
|
|
|
~(ACPI_MADT_POLARITY_MASK | ACPI_MADT_TRIGGER_MASK))
|
2005-08-05 04:44:28 +00:00
|
|
|
printk(KERN_INFO PREFIX
|
|
|
|
"INT_SRC_OVR unexpected reserved flags: 0x%x\n",
|
2007-02-02 16:48:22 +00:00
|
|
|
p->inti_flags &
|
|
|
|
~(ACPI_MADT_POLARITY_MASK | ACPI_MADT_TRIGGER_MASK));
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-08-05 04:44:28 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
break;
|
|
|
|
|
2007-02-02 16:48:22 +00:00
|
|
|
case ACPI_MADT_TYPE_NMI_SOURCE:
|
2005-08-05 04:44:28 +00:00
|
|
|
{
|
2007-02-02 16:48:22 +00:00
|
|
|
struct acpi_madt_nmi_source *p =
|
|
|
|
(struct acpi_madt_nmi_source *)header;
|
2005-08-05 04:44:28 +00:00
|
|
|
printk(KERN_INFO PREFIX
|
|
|
|
"NMI_SRC (%s %s global_irq %d)\n",
|
2007-02-02 16:48:22 +00:00
|
|
|
mps_inti_flags_polarity[p->inti_flags & ACPI_MADT_POLARITY_MASK],
|
|
|
|
mps_inti_flags_trigger[(p->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2],
|
2005-08-05 04:44:28 +00:00
|
|
|
p->global_irq);
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
break;
|
|
|
|
|
2007-02-02 16:48:22 +00:00
|
|
|
case ACPI_MADT_TYPE_LOCAL_APIC_NMI:
|
2005-08-05 04:44:28 +00:00
|
|
|
{
|
2007-02-02 16:48:22 +00:00
|
|
|
struct acpi_madt_local_apic_nmi *p =
|
|
|
|
(struct acpi_madt_local_apic_nmi *)header;
|
2005-08-05 04:44:28 +00:00
|
|
|
printk(KERN_INFO PREFIX
|
|
|
|
"LAPIC_NMI (acpi_id[0x%02x] %s %s lint[0x%x])\n",
|
2007-02-02 16:48:22 +00:00
|
|
|
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],
|
2005-08-05 04:44:28 +00:00
|
|
|
p->lint);
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
break;
|
|
|
|
|
2007-02-02 16:48:22 +00:00
|
|
|
case ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE:
|
2005-08-05 04:44:28 +00:00
|
|
|
{
|
2007-02-02 16:48:22 +00:00
|
|
|
struct acpi_madt_local_apic_override *p =
|
|
|
|
(struct acpi_madt_local_apic_override *)header;
|
2005-08-05 04:44:28 +00:00
|
|
|
printk(KERN_INFO PREFIX
|
|
|
|
"LAPIC_ADDR_OVR (address[%p])\n",
|
|
|
|
(void *)(unsigned long)p->address);
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
break;
|
|
|
|
|
2007-02-02 16:48:22 +00:00
|
|
|
case ACPI_MADT_TYPE_IO_SAPIC:
|
2005-08-05 04:44:28 +00:00
|
|
|
{
|
2007-02-02 16:48:22 +00:00
|
|
|
struct acpi_madt_io_sapic *p =
|
|
|
|
(struct acpi_madt_io_sapic *)header;
|
2005-08-05 04:44:28 +00:00
|
|
|
printk(KERN_INFO PREFIX
|
|
|
|
"IOSAPIC (id[0x%x] address[%p] gsi_base[%d])\n",
|
|
|
|
p->id, (void *)(unsigned long)p->address,
|
|
|
|
p->global_irq_base);
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
break;
|
|
|
|
|
2007-02-02 16:48:22 +00:00
|
|
|
case ACPI_MADT_TYPE_LOCAL_SAPIC:
|
2005-08-05 04:44:28 +00:00
|
|
|
{
|
2007-02-02 16:48:22 +00:00
|
|
|
struct acpi_madt_local_sapic *p =
|
|
|
|
(struct acpi_madt_local_sapic *)header;
|
2005-08-05 04:44:28 +00:00
|
|
|
printk(KERN_INFO PREFIX
|
|
|
|
"LSAPIC (acpi_id[0x%02x] lsapic_id[0x%02x] lsapic_eid[0x%02x] %s)\n",
|
2007-02-02 16:48:22 +00:00
|
|
|
p->processor_id, p->id, p->eid,
|
|
|
|
(p->lapic_flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled");
|
2005-08-05 04:44:28 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
break;
|
|
|
|
|
2007-02-02 16:48:22 +00:00
|
|
|
case ACPI_MADT_TYPE_INTERRUPT_SOURCE:
|
2005-08-05 04:44:28 +00:00
|
|
|
{
|
2007-02-02 16:48:22 +00:00
|
|
|
struct acpi_madt_interrupt_source *p =
|
|
|
|
(struct acpi_madt_interrupt_source *)header;
|
2005-08-05 04:44:28 +00:00
|
|
|
printk(KERN_INFO PREFIX
|
|
|
|
"PLAT_INT_SRC (%s %s type[0x%x] id[0x%04x] eid[0x%x] iosapic_vector[0x%x] global_irq[0x%x]\n",
|
2007-02-02 16:48:22 +00:00
|
|
|
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,
|
2005-08-05 04:44:28 +00:00
|
|
|
p->global_irq);
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2005-08-05 04:44:28 +00:00
|
|
|
printk(KERN_WARNING PREFIX
|
|
|
|
"Found unsupported MADT entry (type = 0x%x)\n",
|
|
|
|
header->type);
|
2005-04-16 22:20:36 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int __init
|
2007-02-02 16:48:22 +00:00
|
|
|
acpi_table_parse_madt_family(char *id,
|
2005-08-05 04:44:28 +00:00
|
|
|
unsigned long madt_size,
|
|
|
|
int entry_id,
|
|
|
|
acpi_madt_entry_handler handler,
|
|
|
|
unsigned int max_entries)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2007-02-02 16:48:22 +00:00
|
|
|
struct acpi_table_header *madt = NULL;
|
2007-02-02 16:48:22 +00:00
|
|
|
struct acpi_subtable_header *entry;
|
2005-08-05 04:44:28 +00:00
|
|
|
unsigned int count = 0;
|
|
|
|
unsigned long madt_end;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
if (!handler)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
/* Locate the MADT (if exists). There should only be one. */
|
2007-02-02 16:48:22 +00:00
|
|
|
acpi_get_table(id, 0, &madt);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
if (!madt) {
|
2007-02-02 16:48:22 +00:00
|
|
|
printk(KERN_WARNING PREFIX "%4.4s not present\n", id);
|
2005-04-16 22:20:36 +00:00
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
2007-02-02 16:48:22 +00:00
|
|
|
madt_end = (unsigned long)madt + madt->length;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* Parse all entries looking for a match. */
|
|
|
|
|
2007-02-02 16:48:22 +00:00
|
|
|
entry = (struct acpi_subtable_header *)
|
2005-08-05 04:44:28 +00:00
|
|
|
((unsigned long)madt + madt_size);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2007-02-02 16:48:22 +00:00
|
|
|
while (((unsigned long)entry) + sizeof(struct acpi_subtable_header) <
|
2005-08-05 04:44:28 +00:00
|
|
|
madt_end) {
|
|
|
|
if (entry->type == entry_id
|
|
|
|
&& (!max_entries || count++ < max_entries))
|
2005-04-16 22:20:36 +00:00
|
|
|
if (handler(entry, madt_end))
|
|
|
|
return -EINVAL;
|
|
|
|
|
2007-02-02 16:48:22 +00:00
|
|
|
entry = (struct acpi_subtable_header *)
|
2005-08-05 04:44:28 +00:00
|
|
|
((unsigned long)entry + entry->length);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
if (max_entries && count > max_entries) {
|
2007-02-02 16:48:22 +00:00
|
|
|
printk(KERN_WARNING PREFIX "[%4.4s:0x%02x] ignored %i entries of "
|
|
|
|
"%i found\n", id, entry_id, count - max_entries, count);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
int __init
|
2007-02-02 16:48:22 +00:00
|
|
|
acpi_table_parse_madt(enum acpi_madt_type id,
|
2005-08-05 04:44:28 +00:00
|
|
|
acpi_madt_entry_handler handler, unsigned int max_entries)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2007-02-02 16:48:22 +00:00
|
|
|
return acpi_table_parse_madt_family(ACPI_SIG_MADT,
|
2005-08-05 04:44:28 +00:00
|
|
|
sizeof(struct acpi_table_madt), id,
|
|
|
|
handler, max_entries);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2007-02-02 16:48:22 +00:00
|
|
|
int __init acpi_table_parse(char *id, acpi_table_handler handler)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2007-02-02 16:48:22 +00:00
|
|
|
struct acpi_table_header *table = NULL;
|
2005-04-16 22:20:36 +00:00
|
|
|
if (!handler)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2007-02-02 16:48:22 +00:00
|
|
|
acpi_get_table(id, 0, &table);
|
|
|
|
if (table) {
|
|
|
|
handler(table);
|
|
|
|
return 1;
|
|
|
|
} else
|
|
|
|
return 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* acpi_table_init()
|
|
|
|
*
|
|
|
|
* find RSDP, find and checksum SDT/XSDT.
|
|
|
|
* checksum all tables, print SDT/XSDT
|
2007-02-02 16:48:22 +00:00
|
|
|
*
|
2005-04-16 22:20:36 +00:00
|
|
|
* result: sdt_entry[] is initialized
|
|
|
|
*/
|
|
|
|
|
2007-02-02 16:48:22 +00:00
|
|
|
|
2005-08-05 04:44:28 +00:00
|
|
|
int __init acpi_table_init(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2007-02-02 16:48:19 +00:00
|
|
|
acpi_initialize_tables(initial_tables, ACPI_MAX_TABLES, 0);
|
2005-04-16 22:20:36 +00:00
|
|
|
return 0;
|
|
|
|
}
|