Blame view
drivers/acpi/tables.c
10 KB
1da177e4c Linux-2.6.12-rc2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
/* * 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 * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * */ |
1da177e4c Linux-2.6.12-rc2 |
25 26 |
#include <linux/init.h> #include <linux/kernel.h> |
1da177e4c Linux-2.6.12-rc2 |
27 28 29 30 31 32 33 34 35 |
#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: " |
04348e69e [ACPI] reduce ker... |
36 |
#define ACPI_MAX_TABLES 128 |
1da177e4c Linux-2.6.12-rc2 |
37 |
|
1da177e4c Linux-2.6.12-rc2 |
38 39 |
static char *mps_inti_flags_polarity[] = { "dfl", "high", "res", "low" }; static char *mps_inti_flags_trigger[] = { "dfl", "edge", "res", "level" }; |
ad71860a1 ACPICA: minimal p... |
40 |
static struct acpi_table_desc initial_tables[ACPI_MAX_TABLES] __initdata; |
1da177e4c Linux-2.6.12-rc2 |
41 |
|
4e381a4f0 Revert "ACPI: par... |
42 |
static int acpi_apic_instance __initdata; |
a1fdcc0d2 ACPI: Add support... |
43 44 |
void acpi_table_print_madt_entry(struct acpi_subtable_header *header) |
1da177e4c Linux-2.6.12-rc2 |
45 46 47 48 49 |
{ if (!header) return; switch (header->type) { |
5f3b1a8b6 ACPICA: Remove du... |
50 |
case ACPI_MADT_TYPE_LOCAL_APIC: |
4be44fcd3 [ACPI] Lindent al... |
51 |
{ |
5f3b1a8b6 ACPICA: Remove du... |
52 53 |
struct acpi_madt_local_apic *p = (struct acpi_madt_local_apic *)header; |
4be44fcd3 [ACPI] Lindent al... |
54 55 56 |
printk(KERN_INFO PREFIX "LAPIC (acpi_id[0x%02x] lapic_id[0x%02x] %s) ", |
5f3b1a8b6 ACPICA: Remove du... |
57 58 |
p->processor_id, p->id, (p->lapic_flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled"); |
4be44fcd3 [ACPI] Lindent al... |
59 |
} |
1da177e4c Linux-2.6.12-rc2 |
60 |
break; |
7237d3de7 x86, ACPI: add su... |
61 62 63 64 65 66 67 68 69 70 71 72 |
case ACPI_MADT_TYPE_LOCAL_X2APIC: { struct acpi_madt_local_x2apic *p = (struct acpi_madt_local_x2apic *)header; printk(KERN_INFO PREFIX "X2APIC (apic_id[0x%02x] uid[0x%02x] %s) ", p->local_apic_id, p->uid, (p->lapic_flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled"); } break; |
5f3b1a8b6 ACPICA: Remove du... |
73 |
case ACPI_MADT_TYPE_IO_APIC: |
4be44fcd3 [ACPI] Lindent al... |
74 |
{ |
5f3b1a8b6 ACPICA: Remove du... |
75 76 |
struct acpi_madt_io_apic *p = (struct acpi_madt_io_apic *)header; |
4be44fcd3 [ACPI] Lindent al... |
77 78 79 80 81 |
printk(KERN_INFO PREFIX "IOAPIC (id[0x%02x] address[0x%08x] gsi_base[%d]) ", p->id, p->address, p->global_irq_base); } |
1da177e4c Linux-2.6.12-rc2 |
82 |
break; |
5f3b1a8b6 ACPICA: Remove du... |
83 |
case ACPI_MADT_TYPE_INTERRUPT_OVERRIDE: |
4be44fcd3 [ACPI] Lindent al... |
84 |
{ |
5f3b1a8b6 ACPICA: Remove du... |
85 86 |
struct acpi_madt_interrupt_override *p = (struct acpi_madt_interrupt_override *)header; |
4be44fcd3 [ACPI] Lindent al... |
87 88 89 |
printk(KERN_INFO PREFIX "INT_SRC_OVR (bus %d bus_irq %d global_irq %d %s %s) ", |
5f3b1a8b6 ACPICA: Remove du... |
90 91 92 93 94 |
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)) |
4be44fcd3 [ACPI] Lindent al... |
95 96 97 |
printk(KERN_INFO PREFIX "INT_SRC_OVR unexpected reserved flags: 0x%x ", |
5f3b1a8b6 ACPICA: Remove du... |
98 99 |
p->inti_flags & ~(ACPI_MADT_POLARITY_MASK | ACPI_MADT_TRIGGER_MASK)); |
1da177e4c Linux-2.6.12-rc2 |
100 |
|
4be44fcd3 [ACPI] Lindent al... |
101 |
} |
1da177e4c Linux-2.6.12-rc2 |
102 |
break; |
5f3b1a8b6 ACPICA: Remove du... |
103 |
case ACPI_MADT_TYPE_NMI_SOURCE: |
4be44fcd3 [ACPI] Lindent al... |
104 |
{ |
5f3b1a8b6 ACPICA: Remove du... |
105 106 |
struct acpi_madt_nmi_source *p = (struct acpi_madt_nmi_source *)header; |
4be44fcd3 [ACPI] Lindent al... |
107 108 109 |
printk(KERN_INFO PREFIX "NMI_SRC (%s %s global_irq %d) ", |
5f3b1a8b6 ACPICA: Remove du... |
110 111 |
mps_inti_flags_polarity[p->inti_flags & ACPI_MADT_POLARITY_MASK], mps_inti_flags_trigger[(p->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2], |
4be44fcd3 [ACPI] Lindent al... |
112 113 |
p->global_irq); } |
1da177e4c Linux-2.6.12-rc2 |
114 |
break; |
5f3b1a8b6 ACPICA: Remove du... |
115 |
case ACPI_MADT_TYPE_LOCAL_APIC_NMI: |
4be44fcd3 [ACPI] Lindent al... |
116 |
{ |
5f3b1a8b6 ACPICA: Remove du... |
117 118 |
struct acpi_madt_local_apic_nmi *p = (struct acpi_madt_local_apic_nmi *)header; |
4be44fcd3 [ACPI] Lindent al... |
119 120 121 |
printk(KERN_INFO PREFIX "LAPIC_NMI (acpi_id[0x%02x] %s %s lint[0x%x]) ", |
5f3b1a8b6 ACPICA: Remove du... |
122 123 124 |
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], |
4be44fcd3 [ACPI] Lindent al... |
125 |
p->lint); |
7237d3de7 x86, ACPI: add su... |
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
} 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; printk(KERN_INFO PREFIX "X2APIC_NMI (uid[0x%02x] %s %s lint[0x%x]) ", p->uid, mps_inti_flags_polarity[polarity], mps_inti_flags_trigger[trigger], p->lint); |
4be44fcd3 [ACPI] Lindent al... |
145 |
} |
1da177e4c Linux-2.6.12-rc2 |
146 |
break; |
5f3b1a8b6 ACPICA: Remove du... |
147 |
case ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE: |
4be44fcd3 [ACPI] Lindent al... |
148 |
{ |
5f3b1a8b6 ACPICA: Remove du... |
149 150 |
struct acpi_madt_local_apic_override *p = (struct acpi_madt_local_apic_override *)header; |
4be44fcd3 [ACPI] Lindent al... |
151 152 153 154 155 |
printk(KERN_INFO PREFIX "LAPIC_ADDR_OVR (address[%p]) ", (void *)(unsigned long)p->address); } |
1da177e4c Linux-2.6.12-rc2 |
156 |
break; |
5f3b1a8b6 ACPICA: Remove du... |
157 |
case ACPI_MADT_TYPE_IO_SAPIC: |
4be44fcd3 [ACPI] Lindent al... |
158 |
{ |
5f3b1a8b6 ACPICA: Remove du... |
159 160 |
struct acpi_madt_io_sapic *p = (struct acpi_madt_io_sapic *)header; |
4be44fcd3 [ACPI] Lindent al... |
161 162 163 164 165 166 |
printk(KERN_INFO PREFIX "IOSAPIC (id[0x%x] address[%p] gsi_base[%d]) ", p->id, (void *)(unsigned long)p->address, p->global_irq_base); } |
1da177e4c Linux-2.6.12-rc2 |
167 |
break; |
5f3b1a8b6 ACPICA: Remove du... |
168 |
case ACPI_MADT_TYPE_LOCAL_SAPIC: |
4be44fcd3 [ACPI] Lindent al... |
169 |
{ |
5f3b1a8b6 ACPICA: Remove du... |
170 171 |
struct acpi_madt_local_sapic *p = (struct acpi_madt_local_sapic *)header; |
4be44fcd3 [ACPI] Lindent al... |
172 173 174 |
printk(KERN_INFO PREFIX "LSAPIC (acpi_id[0x%02x] lsapic_id[0x%02x] lsapic_eid[0x%02x] %s) ", |
5f3b1a8b6 ACPICA: Remove du... |
175 176 |
p->processor_id, p->id, p->eid, (p->lapic_flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled"); |
4be44fcd3 [ACPI] Lindent al... |
177 |
} |
1da177e4c Linux-2.6.12-rc2 |
178 |
break; |
5f3b1a8b6 ACPICA: Remove du... |
179 |
case ACPI_MADT_TYPE_INTERRUPT_SOURCE: |
4be44fcd3 [ACPI] Lindent al... |
180 |
{ |
5f3b1a8b6 ACPICA: Remove du... |
181 182 |
struct acpi_madt_interrupt_source *p = (struct acpi_madt_interrupt_source *)header; |
4be44fcd3 [ACPI] Lindent al... |
183 184 185 |
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] ", |
5f3b1a8b6 ACPICA: Remove du... |
186 187 188 |
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, |
4be44fcd3 [ACPI] Lindent al... |
189 190 |
p->global_irq); } |
1da177e4c Linux-2.6.12-rc2 |
191 192 193 |
break; default: |
4be44fcd3 [ACPI] Lindent al... |
194 195 196 197 |
printk(KERN_WARNING PREFIX "Found unsupported MADT entry (type = 0x%x) ", header->type); |
1da177e4c Linux-2.6.12-rc2 |
198 199 200 |
break; } } |
1da177e4c Linux-2.6.12-rc2 |
201 202 |
int __init |
6eb87fed5 ACPI: acpi_table_... |
203 204 |
acpi_table_parse_entries(char *id, unsigned long table_size, |
4be44fcd3 [ACPI] Lindent al... |
205 |
int entry_id, |
5a8765a84 ACPI: acpi_madt_e... |
206 |
acpi_table_entry_handler handler, |
4be44fcd3 [ACPI] Lindent al... |
207 |
unsigned int max_entries) |
1da177e4c Linux-2.6.12-rc2 |
208 |
{ |
6eb87fed5 ACPI: acpi_table_... |
209 |
struct acpi_table_header *table_header = NULL; |
5f3b1a8b6 ACPICA: Remove du... |
210 |
struct acpi_subtable_header *entry; |
4be44fcd3 [ACPI] Lindent al... |
211 |
unsigned int count = 0; |
6eb87fed5 ACPI: acpi_table_... |
212 |
unsigned long table_end; |
7d97277b7 acpi/x86: introdu... |
213 |
acpi_size tbl_size; |
1da177e4c Linux-2.6.12-rc2 |
214 |
|
68ca40693 ACPI: delete the ... |
215 |
if (acpi_disabled) |
e5b8fc6ac ACPI: check acpi_... |
216 |
return -ENODEV; |
1da177e4c Linux-2.6.12-rc2 |
217 218 |
if (!handler) return -EINVAL; |
a1fdcc0d2 ACPI: Add support... |
219 |
if (strncmp(id, ACPI_SIG_MADT, 4) == 0) |
7d97277b7 acpi/x86: introdu... |
220 |
acpi_get_table_with_size(id, acpi_apic_instance, &table_header, &tbl_size); |
a1fdcc0d2 ACPI: Add support... |
221 |
else |
7d97277b7 acpi/x86: introdu... |
222 |
acpi_get_table_with_size(id, 0, &table_header, &tbl_size); |
1da177e4c Linux-2.6.12-rc2 |
223 |
|
6eb87fed5 ACPI: acpi_table_... |
224 |
if (!table_header) { |
ceb6c4683 ACPICA: Remove du... |
225 226 |
printk(KERN_WARNING PREFIX "%4.4s not present ", id); |
1da177e4c Linux-2.6.12-rc2 |
227 228 |
return -ENODEV; } |
6eb87fed5 ACPI: acpi_table_... |
229 |
table_end = (unsigned long)table_header + table_header->length; |
1da177e4c Linux-2.6.12-rc2 |
230 231 |
/* Parse all entries looking for a match. */ |
5f3b1a8b6 ACPICA: Remove du... |
232 |
entry = (struct acpi_subtable_header *) |
6eb87fed5 ACPI: acpi_table_... |
233 |
((unsigned long)table_header + table_size); |
1da177e4c Linux-2.6.12-rc2 |
234 |
|
5f3b1a8b6 ACPICA: Remove du... |
235 |
while (((unsigned long)entry) + sizeof(struct acpi_subtable_header) < |
6eb87fed5 ACPI: acpi_table_... |
236 |
table_end) { |
4be44fcd3 [ACPI] Lindent al... |
237 238 |
if (entry->type == entry_id && (!max_entries || count++ < max_entries)) |
7d97277b7 acpi/x86: introdu... |
239 240 |
if (handler(entry, table_end)) { early_acpi_os_unmap_memory((char *)table_header, tbl_size); |
1da177e4c Linux-2.6.12-rc2 |
241 |
return -EINVAL; |
7d97277b7 acpi/x86: introdu... |
242 |
} |
1da177e4c Linux-2.6.12-rc2 |
243 |
|
5f3b1a8b6 ACPICA: Remove du... |
244 |
entry = (struct acpi_subtable_header *) |
4be44fcd3 [ACPI] Lindent al... |
245 |
((unsigned long)entry + entry->length); |
1da177e4c Linux-2.6.12-rc2 |
246 247 |
} if (max_entries && count > max_entries) { |
ceb6c4683 ACPICA: Remove du... |
248 249 250 |
printk(KERN_WARNING PREFIX "[%4.4s:0x%02x] ignored %i entries of " "%i found ", id, entry_id, count - max_entries, count); |
1da177e4c Linux-2.6.12-rc2 |
251 |
} |
7d97277b7 acpi/x86: introdu... |
252 |
early_acpi_os_unmap_memory((char *)table_header, tbl_size); |
1da177e4c Linux-2.6.12-rc2 |
253 254 |
return count; } |
1da177e4c Linux-2.6.12-rc2 |
255 |
int __init |
5f3b1a8b6 ACPICA: Remove du... |
256 |
acpi_table_parse_madt(enum acpi_madt_type id, |
5a8765a84 ACPI: acpi_madt_e... |
257 |
acpi_table_entry_handler handler, unsigned int max_entries) |
1da177e4c Linux-2.6.12-rc2 |
258 |
{ |
6eb87fed5 ACPI: acpi_table_... |
259 |
return acpi_table_parse_entries(ACPI_SIG_MADT, |
4be44fcd3 [ACPI] Lindent al... |
260 261 |
sizeof(struct acpi_table_madt), id, handler, max_entries); |
1da177e4c Linux-2.6.12-rc2 |
262 |
} |
7f8f97c3c ACPI: acpi_table_... |
263 264 265 266 267 268 269 270 271 |
/** * 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, * run @handler on it. Return 0 if table found, return on if not. */ |
ceb6c4683 ACPICA: Remove du... |
272 |
int __init acpi_table_parse(char *id, acpi_table_handler handler) |
1da177e4c Linux-2.6.12-rc2 |
273 |
{ |
ceb6c4683 ACPICA: Remove du... |
274 |
struct acpi_table_header *table = NULL; |
7d97277b7 acpi/x86: introdu... |
275 |
acpi_size tbl_size; |
a1fdcc0d2 ACPI: Add support... |
276 |
|
68ca40693 ACPI: delete the ... |
277 |
if (acpi_disabled) |
e5b8fc6ac ACPI: check acpi_... |
278 |
return -ENODEV; |
1da177e4c Linux-2.6.12-rc2 |
279 280 |
if (!handler) return -EINVAL; |
a1fdcc0d2 ACPI: Add support... |
281 |
if (strncmp(id, ACPI_SIG_MADT, 4) == 0) |
7d97277b7 acpi/x86: introdu... |
282 |
acpi_get_table_with_size(id, acpi_apic_instance, &table, &tbl_size); |
a1fdcc0d2 ACPI: Add support... |
283 |
else |
7d97277b7 acpi/x86: introdu... |
284 |
acpi_get_table_with_size(id, 0, &table, &tbl_size); |
a1fdcc0d2 ACPI: Add support... |
285 |
|
ceb6c4683 ACPICA: Remove du... |
286 287 |
if (table) { handler(table); |
7d97277b7 acpi/x86: introdu... |
288 |
early_acpi_os_unmap_memory(table, tbl_size); |
ceb6c4683 ACPICA: Remove du... |
289 |
return 0; |
7f8f97c3c ACPI: acpi_table_... |
290 291 |
} else return 1; |
1da177e4c Linux-2.6.12-rc2 |
292 |
} |
a1fdcc0d2 ACPI: Add support... |
293 294 295 296 297 298 299 300 |
/* * 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; |
7d97277b7 acpi/x86: introdu... |
301 |
acpi_size tbl_size; |
a1fdcc0d2 ACPI: Add support... |
302 |
|
7d97277b7 acpi/x86: introdu... |
303 |
acpi_get_table_with_size(ACPI_SIG_MADT, 2, &table, &tbl_size); |
a1fdcc0d2 ACPI: Add support... |
304 305 306 307 308 309 310 311 312 313 |
if (table) { printk(KERN_WARNING PREFIX "BIOS bug: multiple APIC/MADT found," " using %d ", acpi_apic_instance); printk(KERN_WARNING PREFIX "If \"acpi_apic_instance=%d\" works better, " "notify linux-acpi@vger.kernel.org ", acpi_apic_instance ? 0 : 2); |
7d97277b7 acpi/x86: introdu... |
314 |
early_acpi_os_unmap_memory(table, tbl_size); |
a1fdcc0d2 ACPI: Add support... |
315 316 317 318 319 320 |
} else acpi_apic_instance = 0; return; } |
1da177e4c Linux-2.6.12-rc2 |
321 322 323 324 325 |
/* * acpi_table_init() * * find RSDP, find and checksum SDT/XSDT. * checksum all tables, print SDT/XSDT |
5f3b1a8b6 ACPICA: Remove du... |
326 |
* |
1da177e4c Linux-2.6.12-rc2 |
327 328 |
* result: sdt_entry[] is initialized */ |
4be44fcd3 [ACPI] Lindent al... |
329 |
int __init acpi_table_init(void) |
1da177e4c Linux-2.6.12-rc2 |
330 |
{ |
9e3a9d1ed ACPI: disable ACP... |
331 332 333 334 335 |
acpi_status status; status = acpi_initialize_tables(initial_tables, ACPI_MAX_TABLES, 0); if (ACPI_FAILURE(status)) return 1; |
a1fdcc0d2 ACPI: Add support... |
336 337 338 339 340 341 |
check_multiple_madt(); return 0; } static int __init acpi_parse_apic_instance(char *str) { |
f0df2d6b5 acpi: add checkin... |
342 343 |
if (!str) return -EINVAL; |
a1fdcc0d2 ACPI: Add support... |
344 345 346 347 348 349 |
acpi_apic_instance = simple_strtoul(str, NULL, 0); printk(KERN_NOTICE PREFIX "Shall use APIC/MADT table %d ", acpi_apic_instance); |
1da177e4c Linux-2.6.12-rc2 |
350 351 |
return 0; } |
a1fdcc0d2 ACPI: Add support... |
352 353 |
early_param("acpi_apic_instance", acpi_parse_apic_instance); |