debuggers.hg

view xen/arch/x86/acpi/boot.c @ 16964:e23144190f93

x86: Fix 16889:60bb765b25b5 in a couple of respects:
1. Leave bottom-most 1MB permanently mapped.
2. ACPI-table mapping code shoudl be aware that mappings above 1MB of
non-RAM are not permanent.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Jan 29 09:36:37 2008 +0000 (2008-01-29)
parents 4034317507de
children 21532468020b
line source
1 /*
2 * boot.c - Architecture-Specific Low-Level ACPI Boot Support
3 *
4 * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
5 * Copyright (C) 2001 Jun Nakajima <jun.nakajima@intel.com>
6 *
7 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 *
23 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
24 */
26 #include <xen/config.h>
27 #include <xen/errno.h>
28 #include <xen/init.h>
29 #include <xen/acpi.h>
30 #include <xen/irq.h>
31 #include <xen/dmi.h>
32 #include <asm/fixmap.h>
33 #include <asm/page.h>
34 #include <asm/apic.h>
35 #include <asm/io_apic.h>
36 #include <asm/apic.h>
37 #include <asm/io.h>
38 #include <asm/mpspec.h>
39 #include <asm/processor.h>
40 #include <mach_apic.h>
41 #include <mach_mpparse.h>
43 int sbf_port;
44 #define CONFIG_ACPI_PCI
46 #define BAD_MADT_ENTRY(entry, end) ( \
47 (!entry) || (unsigned long)entry + sizeof(*entry) > end || \
48 ((acpi_table_entry_header *)entry)->length != sizeof(*entry))
50 #define PREFIX "ACPI: "
52 #ifdef CONFIG_ACPI_PCI
53 int acpi_noirq __initdata; /* skip ACPI IRQ initialization */
54 int acpi_pci_disabled __initdata; /* skip ACPI PCI scan and IRQ initialization */
55 #else
56 int acpi_noirq __initdata = 1;
57 int acpi_pci_disabled __initdata = 1;
58 #endif
59 int acpi_ht __initdata = 1; /* enable HT */
61 int acpi_lapic;
62 int acpi_ioapic;
63 int acpi_strict;
64 EXPORT_SYMBOL(acpi_strict);
66 acpi_interrupt_flags acpi_sci_flags __initdata;
67 int acpi_sci_override_gsi __initdata;
68 int acpi_skip_timer_override __initdata;
70 #ifdef CONFIG_X86_LOCAL_APIC
71 static u64 acpi_lapic_addr __initdata = APIC_DEFAULT_PHYS_BASE;
72 #endif
74 u32 acpi_smi_cmd;
75 u8 acpi_enable_value, acpi_disable_value;
77 #ifndef __HAVE_ARCH_CMPXCHG
78 #warning ACPI uses CMPXCHG, i486 and later hardware
79 #endif
81 #define MAX_MADT_ENTRIES 256
82 u8 x86_acpiid_to_apicid[MAX_MADT_ENTRIES] =
83 {[0 ... MAX_MADT_ENTRIES - 1] = 0xff };
84 EXPORT_SYMBOL(x86_acpiid_to_apicid);
86 /* --------------------------------------------------------------------------
87 Boot-time Configuration
88 -------------------------------------------------------------------------- */
90 /*
91 * The default interrupt routing model is PIC (8259). This gets
92 * overriden if IOAPICs are enumerated (below).
93 */
94 enum acpi_irq_model_id acpi_irq_model = ACPI_IRQ_MODEL_PIC;
96 /*
97 * Temporarily use the virtual area starting from FIX_IO_APIC_BASE_END,
98 * to map the target physical address. The problem is that set_fixmap()
99 * provides a single page, and it is possible that the page is not
100 * sufficient.
101 * By using this area, we can map up to MAX_IO_APICS pages temporarily,
102 * i.e. until the next __va_range() call.
103 *
104 * Important Safety Note: The fixed I/O APIC page numbers are *subtracted*
105 * from the fixed base. That's why we start at FIX_IO_APIC_BASE_END and
106 * count idx down while incrementing the phys address.
107 */
108 char *__acpi_map_table(unsigned long phys, unsigned long size)
109 {
110 unsigned long base, offset, mapped_size;
111 int idx;
113 /* XEN: RAM holes above 1MB are not permanently mapped. */
114 if (phys + size < 1 * 1024 * 1024)
115 return __va(phys);
117 offset = phys & (PAGE_SIZE - 1);
118 mapped_size = PAGE_SIZE - offset;
119 set_fixmap(FIX_ACPI_END, phys);
120 base = fix_to_virt(FIX_ACPI_END);
122 /*
123 * Most cases can be covered by the below.
124 */
125 idx = FIX_ACPI_END;
126 while (mapped_size < size) {
127 if (--idx < FIX_ACPI_BEGIN)
128 return NULL; /* cannot handle this */
129 phys += PAGE_SIZE;
130 set_fixmap(idx, phys);
131 mapped_size += PAGE_SIZE;
132 }
134 return ((char *) base + offset);
135 }
137 #ifdef CONFIG_X86_LOCAL_APIC
138 static int __init acpi_parse_madt(unsigned long phys_addr, unsigned long size)
139 {
140 struct acpi_table_madt *madt = NULL;
142 if (!phys_addr || !size)
143 return -EINVAL;
145 madt = (struct acpi_table_madt *)__acpi_map_table(phys_addr, size);
146 if (!madt) {
147 printk(KERN_WARNING PREFIX "Unable to map MADT\n");
148 return -ENODEV;
149 }
151 if (madt->lapic_address) {
152 acpi_lapic_addr = (u64) madt->lapic_address;
154 printk(KERN_DEBUG PREFIX "Local APIC address 0x%08x\n",
155 madt->lapic_address);
156 }
158 acpi_madt_oem_check(madt->header.oem_id, madt->header.oem_table_id);
160 return 0;
161 }
163 static int __init
164 acpi_parse_lapic(acpi_table_entry_header * header, const unsigned long end)
165 {
166 struct acpi_table_lapic *processor = NULL;
168 processor = (struct acpi_table_lapic *)header;
170 if (BAD_MADT_ENTRY(processor, end))
171 return -EINVAL;
173 acpi_table_print_madt_entry(header);
175 /* Record local apic id only when enabled */
176 if (processor->flags.enabled)
177 x86_acpiid_to_apicid[processor->acpi_id] = processor->id;
179 /*
180 * We need to register disabled CPU as well to permit
181 * counting disabled CPUs. This allows us to size
182 * cpus_possible_map more accurately, to permit
183 * to not preallocating memory for all NR_CPUS
184 * when we use CPU hotplug.
185 */
186 mp_register_lapic(processor->id, /* APIC ID */
187 processor->flags.enabled); /* Enabled? */
189 return 0;
190 }
192 static int __init
193 acpi_parse_lapic_addr_ovr(acpi_table_entry_header * header,
194 const unsigned long end)
195 {
196 struct acpi_table_lapic_addr_ovr *lapic_addr_ovr = NULL;
198 lapic_addr_ovr = (struct acpi_table_lapic_addr_ovr *)header;
200 if (BAD_MADT_ENTRY(lapic_addr_ovr, end))
201 return -EINVAL;
203 acpi_lapic_addr = lapic_addr_ovr->address;
205 return 0;
206 }
208 static int __init
209 acpi_parse_lapic_nmi(acpi_table_entry_header * header, const unsigned long end)
210 {
211 struct acpi_table_lapic_nmi *lapic_nmi = NULL;
213 lapic_nmi = (struct acpi_table_lapic_nmi *)header;
215 if (BAD_MADT_ENTRY(lapic_nmi, end))
216 return -EINVAL;
218 acpi_table_print_madt_entry(header);
220 if (lapic_nmi->lint != 1)
221 printk(KERN_WARNING PREFIX "NMI not connected to LINT 1!\n");
223 return 0;
224 }
226 #endif /*CONFIG_X86_LOCAL_APIC */
228 #if defined(CONFIG_X86_IO_APIC) /*&& defined(CONFIG_ACPI_INTERPRETER)*/
230 static int __init
231 acpi_parse_ioapic(acpi_table_entry_header * header, const unsigned long end)
232 {
233 struct acpi_table_ioapic *ioapic = NULL;
235 ioapic = (struct acpi_table_ioapic *)header;
237 if (BAD_MADT_ENTRY(ioapic, end))
238 return -EINVAL;
240 acpi_table_print_madt_entry(header);
242 mp_register_ioapic(ioapic->id,
243 ioapic->address, ioapic->global_irq_base);
245 return 0;
246 }
248 static int __init
249 acpi_parse_int_src_ovr(acpi_table_entry_header * header,
250 const unsigned long end)
251 {
252 struct acpi_table_int_src_ovr *intsrc = NULL;
254 intsrc = (struct acpi_table_int_src_ovr *)header;
256 if (BAD_MADT_ENTRY(intsrc, end))
257 return -EINVAL;
259 acpi_table_print_madt_entry(header);
261 if (acpi_skip_timer_override &&
262 intsrc->bus_irq == 0 && intsrc->global_irq == 2) {
263 printk(PREFIX "BIOS IRQ0 pin2 override ignored.\n");
264 return 0;
265 }
267 mp_override_legacy_irq(intsrc->bus_irq,
268 intsrc->flags.polarity,
269 intsrc->flags.trigger, intsrc->global_irq);
271 return 0;
272 }
274 static int __init
275 acpi_parse_nmi_src(acpi_table_entry_header * header, const unsigned long end)
276 {
277 struct acpi_table_nmi_src *nmi_src = NULL;
279 nmi_src = (struct acpi_table_nmi_src *)header;
281 if (BAD_MADT_ENTRY(nmi_src, end))
282 return -EINVAL;
284 acpi_table_print_madt_entry(header);
286 /* TBD: Support nimsrc entries? */
288 return 0;
289 }
291 #endif /* CONFIG_X86_IO_APIC */
293 static unsigned long __init
294 acpi_scan_rsdp(unsigned long start, unsigned long length)
295 {
296 unsigned long offset = 0;
297 unsigned long sig_len = sizeof("RSD PTR ") - 1;
299 /*
300 * Scan all 16-byte boundaries of the physical memory region for the
301 * RSDP signature.
302 */
303 for (offset = 0; offset < length; offset += 16) {
304 if (strncmp((char *)(start + offset), "RSD PTR ", sig_len))
305 continue;
306 return (start + offset);
307 }
309 return 0;
310 }
312 static int __init acpi_parse_sbf(unsigned long phys_addr, unsigned long size)
313 {
314 struct acpi_table_sbf *sb;
316 if (!phys_addr || !size)
317 return -EINVAL;
319 sb = (struct acpi_table_sbf *)__acpi_map_table(phys_addr, size);
320 if (!sb) {
321 printk(KERN_WARNING PREFIX "Unable to map SBF\n");
322 return -ENODEV;
323 }
325 sbf_port = sb->sbf_cmos; /* Save CMOS port */
327 return 0;
328 }
330 #ifdef CONFIG_HPET_TIMER
332 static int __init acpi_parse_hpet(unsigned long phys, unsigned long size)
333 {
334 struct acpi_table_hpet *hpet_tbl;
336 if (!phys || !size)
337 return -EINVAL;
339 hpet_tbl = (struct acpi_table_hpet *)__acpi_map_table(phys, size);
340 if (!hpet_tbl) {
341 printk(KERN_WARNING PREFIX "Unable to map HPET\n");
342 return -ENODEV;
343 }
345 if (hpet_tbl->addr.space_id != ACPI_SPACE_MEM) {
346 printk(KERN_WARNING PREFIX "HPET timers must be located in "
347 "memory.\n");
348 return -1;
349 }
351 #if 0/*def CONFIG_X86_64*/
352 vxtime.hpet_address = hpet_tbl->addr.addrl |
353 ((long) hpet_tbl->addr.addrh << 32);
355 printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n",
356 hpet_tbl->id, vxtime.hpet_address);
357 #else /* X86 */
358 {
359 extern unsigned long hpet_address;
361 hpet_address = hpet_tbl->addr.addrl;
362 printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n",
363 hpet_tbl->id, hpet_address);
364 }
365 #endif /* X86 */
367 return 0;
368 }
369 #else
370 #define acpi_parse_hpet NULL
371 #endif
373 #ifdef CONFIG_X86_PM_TIMER
374 extern u32 pmtmr_ioport;
375 #endif
377 #ifdef CONFIG_ACPI_SLEEP
378 /* Get pm1x_cnt and pm1x_evt information for ACPI sleep */
379 static void __init
380 acpi_fadt_parse_sleep_info(struct fadt_descriptor_rev2 *fadt)
381 {
382 struct acpi_table_rsdp *rsdp;
383 unsigned long rsdp_phys;
384 struct facs_descriptor_rev2 *facs = NULL;
385 uint64_t facs_pa;
387 rsdp_phys = acpi_find_rsdp();
388 if (!rsdp_phys || acpi_disabled)
389 goto bad;
390 rsdp = __va(rsdp_phys);
392 if (fadt->revision >= FADT2_REVISION_ID) {
393 /* Sanity check on FADT Rev. 2 */
394 if ((fadt->xpm1a_cnt_blk.address_space_id !=
395 ACPI_ADR_SPACE_SYSTEM_IO) ||
396 (fadt->xpm1b_cnt_blk.address_space_id !=
397 ACPI_ADR_SPACE_SYSTEM_IO) ||
398 (fadt->xpm1a_evt_blk.address_space_id !=
399 ACPI_ADR_SPACE_SYSTEM_IO) ||
400 (fadt->xpm1b_evt_blk.address_space_id !=
401 ACPI_ADR_SPACE_SYSTEM_IO))
402 goto bad;
404 acpi_sinfo.pm1a_cnt = (uint16_t)fadt->xpm1a_cnt_blk.address;
405 acpi_sinfo.pm1b_cnt = (uint16_t)fadt->xpm1b_cnt_blk.address;
406 acpi_sinfo.pm1a_evt = (uint16_t)fadt->xpm1a_evt_blk.address;
407 acpi_sinfo.pm1b_evt = (uint16_t)fadt->xpm1b_evt_blk.address;
408 }
410 if (!acpi_sinfo.pm1a_cnt)
411 acpi_sinfo.pm1a_cnt = (uint16_t)fadt->V1_pm1a_cnt_blk;
412 if (!acpi_sinfo.pm1b_cnt)
413 acpi_sinfo.pm1b_cnt = (uint16_t)fadt->V1_pm1b_cnt_blk;
414 if (!acpi_sinfo.pm1a_evt)
415 acpi_sinfo.pm1a_evt = (uint16_t)fadt->V1_pm1a_evt_blk;
416 if (!acpi_sinfo.pm1b_evt)
417 acpi_sinfo.pm1b_evt = (uint16_t)fadt->V1_pm1b_evt_blk;
419 /* Now FACS... */
420 if (fadt->revision >= FADT2_REVISION_ID)
421 facs_pa = fadt->xfirmware_ctrl;
422 else
423 facs_pa = (uint64_t)fadt->V1_firmware_ctrl;
425 facs = (struct facs_descriptor_rev2 *)
426 __acpi_map_table(facs_pa, sizeof(struct facs_descriptor_rev2));
427 if (!facs)
428 goto bad;
430 if (strncmp(facs->signature, "FACS", 4)) {
431 printk(KERN_ERR PREFIX "Invalid FACS signature %.4s\n",
432 facs->signature);
433 goto bad;
434 }
436 if (facs->length < 24) {
437 printk(KERN_ERR PREFIX "Invalid FACS table length: 0x%x",
438 facs->length);
439 goto bad;
440 }
442 if (facs->length < 64)
443 printk(KERN_WARNING PREFIX
444 "FACS is shorter than ACPI spec allow: 0x%x",
445 facs->length);
447 if ((rsdp->revision < 2) || (facs->length < 32)) {
448 acpi_sinfo.wakeup_vector = facs_pa +
449 offsetof(struct facs_descriptor_rev2,
450 firmware_waking_vector);
451 acpi_sinfo.vector_width = 32;
452 } else {
453 acpi_sinfo.wakeup_vector = facs_pa +
454 offsetof(struct facs_descriptor_rev2,
455 xfirmware_waking_vector);
456 acpi_sinfo.vector_width = 64;
457 }
459 printk(KERN_INFO PREFIX
460 "ACPI SLEEP INFO: pm1x_cnt[%x,%x], pm1x_evt[%x,%x]\n",
461 acpi_sinfo.pm1a_cnt, acpi_sinfo.pm1b_cnt,
462 acpi_sinfo.pm1a_evt, acpi_sinfo.pm1b_cnt);
463 printk(KERN_INFO PREFIX
464 " wakeup_vec[%"PRIx64"], vec_size[%x]\n",
465 acpi_sinfo.wakeup_vector, acpi_sinfo.vector_width);
466 return;
467 bad:
468 memset(&acpi_sinfo, 0, sizeof(acpi_sinfo));
469 }
470 #endif
472 static int __init acpi_parse_fadt(unsigned long phys, unsigned long size)
473 {
474 struct fadt_descriptor_rev2 *fadt = NULL;
476 fadt = (struct fadt_descriptor_rev2 *)__acpi_map_table(phys, size);
477 if (!fadt) {
478 printk(KERN_WARNING PREFIX "Unable to map FADT\n");
479 return 0;
480 }
482 #ifdef CONFIG_ACPI_INTERPRETER
483 /* initialize sci_int early for INT_SRC_OVR MADT parsing */
484 acpi_fadt.sci_int = fadt->sci_int;
486 /* initialize rev and apic_phys_dest_mode for x86_64 genapic */
487 acpi_fadt.revision = fadt->revision;
488 acpi_fadt.force_apic_physical_destination_mode =
489 fadt->force_apic_physical_destination_mode;
490 #endif
492 #ifdef CONFIG_X86_PM_TIMER
493 /* detect the location of the ACPI PM Timer */
494 if (fadt->revision >= FADT2_REVISION_ID) {
495 /* FADT rev. 2 */
496 if (fadt->xpm_tmr_blk.address_space_id ==
497 ACPI_ADR_SPACE_SYSTEM_IO)
498 pmtmr_ioport = fadt->xpm_tmr_blk.address;
499 /*
500 * "X" fields are optional extensions to the original V1.0
501 * fields, so we must selectively expand V1.0 fields if the
502 * corresponding X field is zero.
503 */
504 if (!pmtmr_ioport)
505 pmtmr_ioport = fadt->V1_pm_tmr_blk;
506 } else {
507 /* FADT rev. 1 */
508 pmtmr_ioport = fadt->V1_pm_tmr_blk;
509 }
510 if (pmtmr_ioport)
511 printk(KERN_INFO PREFIX "PM-Timer IO Port: %#x\n",
512 pmtmr_ioport);
513 #endif
515 acpi_smi_cmd = fadt->smi_cmd;
516 acpi_enable_value = fadt->acpi_enable;
517 acpi_disable_value = fadt->acpi_disable;
519 #ifdef CONFIG_ACPI_SLEEP
520 acpi_fadt_parse_sleep_info(fadt);
521 #endif
523 return 0;
524 }
526 unsigned long __init acpi_find_rsdp(void)
527 {
528 unsigned long rsdp_phys = 0;
530 #if 0
531 if (efi_enabled) {
532 if (efi.acpi20 != EFI_INVALID_TABLE_ADDR)
533 return efi.acpi20;
534 else if (efi.acpi != EFI_INVALID_TABLE_ADDR)
535 return efi.acpi;
536 }
537 #endif
538 /*
539 * Scan memory looking for the RSDP signature. First search EBDA (low
540 * memory) paragraphs and then search upper memory (E0000-FFFFF).
541 */
542 rsdp_phys = acpi_scan_rsdp(0, 0x400);
543 if (!rsdp_phys)
544 rsdp_phys = acpi_scan_rsdp(0xE0000, 0x20000);
546 return rsdp_phys;
547 }
549 #ifdef CONFIG_X86_LOCAL_APIC
550 /*
551 * Parse LAPIC entries in MADT
552 * returns 0 on success, < 0 on error
553 */
554 static int __init acpi_parse_madt_lapic_entries(void)
555 {
556 int count;
558 if (!cpu_has_apic)
559 return -ENODEV;
561 /*
562 * Note that the LAPIC address is obtained from the MADT (32-bit value)
563 * and (optionally) overriden by a LAPIC_ADDR_OVR entry (64-bit value).
564 */
566 count =
567 acpi_table_parse_madt(ACPI_MADT_LAPIC_ADDR_OVR,
568 acpi_parse_lapic_addr_ovr, 0);
569 if (count < 0) {
570 printk(KERN_ERR PREFIX
571 "Error parsing LAPIC address override entry\n");
572 return count;
573 }
575 mp_register_lapic_address(acpi_lapic_addr);
577 count = acpi_table_parse_madt(ACPI_MADT_LAPIC, acpi_parse_lapic,
578 MAX_APICS);
579 if (!count) {
580 printk(KERN_ERR PREFIX "No LAPIC entries present\n");
581 /* TBD: Cleanup to allow fallback to MPS */
582 return -ENODEV;
583 } else if (count < 0) {
584 printk(KERN_ERR PREFIX "Error parsing LAPIC entry\n");
585 /* TBD: Cleanup to allow fallback to MPS */
586 return count;
587 }
589 count =
590 acpi_table_parse_madt(ACPI_MADT_LAPIC_NMI, acpi_parse_lapic_nmi, 0);
591 if (count < 0) {
592 printk(KERN_ERR PREFIX "Error parsing LAPIC NMI entry\n");
593 /* TBD: Cleanup to allow fallback to MPS */
594 return count;
595 }
596 return 0;
597 }
598 #endif /* CONFIG_X86_LOCAL_APIC */
600 #if defined(CONFIG_X86_IO_APIC) /*&& defined(CONFIG_ACPI_INTERPRETER)*/
601 /*
602 * Parse IOAPIC related entries in MADT
603 * returns 0 on success, < 0 on error
604 */
605 static int __init acpi_parse_madt_ioapic_entries(void)
606 {
607 int count;
609 /*
610 * ACPI interpreter is required to complete interrupt setup,
611 * so if it is off, don't enumerate the io-apics with ACPI.
612 * If MPS is present, it will handle them,
613 * otherwise the system will stay in PIC mode
614 */
615 if (acpi_disabled || acpi_noirq) {
616 return -ENODEV;
617 }
619 if (!cpu_has_apic)
620 return -ENODEV;
622 /*
623 * if "noapic" boot option, don't look for IO-APICs
624 */
625 if (skip_ioapic_setup) {
626 printk(KERN_INFO PREFIX "Skipping IOAPIC probe "
627 "due to 'noapic' option.\n");
628 return -ENODEV;
629 }
631 count =
632 acpi_table_parse_madt(ACPI_MADT_IOAPIC, acpi_parse_ioapic,
633 MAX_IO_APICS);
634 if (!count) {
635 printk(KERN_ERR PREFIX "No IOAPIC entries present\n");
636 return -ENODEV;
637 } else if (count < 0) {
638 printk(KERN_ERR PREFIX "Error parsing IOAPIC entry\n");
639 return count;
640 }
642 count =
643 acpi_table_parse_madt(ACPI_MADT_INT_SRC_OVR, acpi_parse_int_src_ovr,
644 NR_IRQ_VECTORS);
645 if (count < 0) {
646 printk(KERN_ERR PREFIX
647 "Error parsing interrupt source overrides entry\n");
648 /* TBD: Cleanup to allow fallback to MPS */
649 return count;
650 }
652 #ifdef CONFIG_ACPI_INTERPRETER
653 /*
654 * If BIOS did not supply an INT_SRC_OVR for the SCI
655 * pretend we got one so we can set the SCI flags.
656 */
657 if (!acpi_sci_override_gsi)
658 acpi_sci_ioapic_setup(acpi_fadt.sci_int, 0, 0);
659 #endif
661 /* Fill in identity legacy mapings where no override */
662 mp_config_acpi_legacy_irqs();
664 count =
665 acpi_table_parse_madt(ACPI_MADT_NMI_SRC, acpi_parse_nmi_src,
666 NR_IRQ_VECTORS);
667 if (count < 0) {
668 printk(KERN_ERR PREFIX "Error parsing NMI SRC entry\n");
669 /* TBD: Cleanup to allow fallback to MPS */
670 return count;
671 }
673 return 0;
674 }
675 #else
676 static inline int acpi_parse_madt_ioapic_entries(void)
677 {
678 return -1;
679 }
680 #endif /* !(CONFIG_X86_IO_APIC && CONFIG_ACPI_INTERPRETER) */
683 static void __init acpi_process_madt(void)
684 {
685 #ifdef CONFIG_X86_LOCAL_APIC
686 int count, error;
688 count = acpi_table_parse(ACPI_APIC, acpi_parse_madt);
689 if (count >= 1) {
691 /*
692 * Parse MADT LAPIC entries
693 */
694 error = acpi_parse_madt_lapic_entries();
695 if (!error) {
696 acpi_lapic = 1;
697 generic_bigsmp_probe();
699 /*
700 * Parse MADT IO-APIC entries
701 */
702 error = acpi_parse_madt_ioapic_entries();
703 if (!error) {
704 acpi_irq_model = ACPI_IRQ_MODEL_IOAPIC;
705 acpi_irq_balance_set(NULL);
706 acpi_ioapic = 1;
708 smp_found_config = 1;
709 clustered_apic_check();
710 }
711 }
712 if (error == -EINVAL) {
713 /*
714 * Dell Precision Workstation 410, 610 come here.
715 */
716 printk(KERN_ERR PREFIX
717 "Invalid BIOS MADT, disabling ACPI\n");
718 disable_acpi();
719 }
720 }
721 #endif
722 return;
723 }
725 extern int acpi_force;
727 #ifdef __i386__
729 static int __init disable_acpi_irq(struct dmi_system_id *d)
730 {
731 if (!acpi_force) {
732 printk(KERN_NOTICE "%s detected: force use of acpi=noirq\n",
733 d->ident);
734 acpi_noirq_set();
735 }
736 return 0;
737 }
739 static int __init disable_acpi_pci(struct dmi_system_id *d)
740 {
741 if (!acpi_force) {
742 printk(KERN_NOTICE "%s detected: force use of pci=noacpi\n",
743 d->ident);
744 /*acpi_disable_pci();*/
745 }
746 return 0;
747 }
749 static int __init dmi_disable_acpi(struct dmi_system_id *d)
750 {
751 if (!acpi_force) {
752 printk(KERN_NOTICE "%s detected: acpi off\n", d->ident);
753 disable_acpi();
754 } else {
755 printk(KERN_NOTICE
756 "Warning: DMI blacklist says broken, but acpi forced\n");
757 }
758 return 0;
759 }
761 /*
762 * Limit ACPI to CPU enumeration for HT
763 */
764 static int __init force_acpi_ht(struct dmi_system_id *d)
765 {
766 if (!acpi_force) {
767 printk(KERN_NOTICE "%s detected: force use of acpi=ht\n",
768 d->ident);
769 disable_acpi();
770 acpi_ht = 1;
771 } else {
772 printk(KERN_NOTICE
773 "Warning: acpi=force overrules DMI blacklist: acpi=ht\n");
774 }
775 return 0;
776 }
778 /*
779 * If your system is blacklisted here, but you find that acpi=force
780 * works for you, please contact acpi-devel@sourceforge.net
781 */
782 static struct dmi_system_id __initdata acpi_dmi_table[] = {
783 /*
784 * Boxes that need ACPI disabled
785 */
786 {
787 .callback = dmi_disable_acpi,
788 .ident = "IBM Thinkpad",
789 .matches = {
790 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
791 DMI_MATCH(DMI_BOARD_NAME, "2629H1G"),
792 },
793 },
795 /*
796 * Boxes that need acpi=ht
797 */
798 {
799 .callback = force_acpi_ht,
800 .ident = "FSC Primergy T850",
801 .matches = {
802 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
803 DMI_MATCH(DMI_PRODUCT_NAME, "PRIMERGY T850"),
804 },
805 },
806 {
807 .callback = force_acpi_ht,
808 .ident = "DELL GX240",
809 .matches = {
810 DMI_MATCH(DMI_BOARD_VENDOR, "Dell Computer Corporation"),
811 DMI_MATCH(DMI_BOARD_NAME, "OptiPlex GX240"),
812 },
813 },
814 {
815 .callback = force_acpi_ht,
816 .ident = "HP VISUALIZE NT Workstation",
817 .matches = {
818 DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"),
819 DMI_MATCH(DMI_PRODUCT_NAME, "HP VISUALIZE NT Workstation"),
820 },
821 },
822 {
823 .callback = force_acpi_ht,
824 .ident = "Compaq Workstation W8000",
825 .matches = {
826 DMI_MATCH(DMI_SYS_VENDOR, "Compaq"),
827 DMI_MATCH(DMI_PRODUCT_NAME, "Workstation W8000"),
828 },
829 },
830 {
831 .callback = force_acpi_ht,
832 .ident = "ASUS P4B266",
833 .matches = {
834 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
835 DMI_MATCH(DMI_BOARD_NAME, "P4B266"),
836 },
837 },
838 {
839 .callback = force_acpi_ht,
840 .ident = "ASUS P2B-DS",
841 .matches = {
842 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
843 DMI_MATCH(DMI_BOARD_NAME, "P2B-DS"),
844 },
845 },
846 {
847 .callback = force_acpi_ht,
848 .ident = "ASUS CUR-DLS",
849 .matches = {
850 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
851 DMI_MATCH(DMI_BOARD_NAME, "CUR-DLS"),
852 },
853 },
854 {
855 .callback = force_acpi_ht,
856 .ident = "ABIT i440BX-W83977",
857 .matches = {
858 DMI_MATCH(DMI_BOARD_VENDOR, "ABIT <http://www.abit.com>"),
859 DMI_MATCH(DMI_BOARD_NAME, "i440BX-W83977 (BP6)"),
860 },
861 },
862 {
863 .callback = force_acpi_ht,
864 .ident = "IBM Bladecenter",
865 .matches = {
866 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
867 DMI_MATCH(DMI_BOARD_NAME, "IBM eServer BladeCenter HS20"),
868 },
869 },
870 {
871 .callback = force_acpi_ht,
872 .ident = "IBM eServer xSeries 360",
873 .matches = {
874 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
875 DMI_MATCH(DMI_BOARD_NAME, "eServer xSeries 360"),
876 },
877 },
878 {
879 .callback = force_acpi_ht,
880 .ident = "IBM eserver xSeries 330",
881 .matches = {
882 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
883 DMI_MATCH(DMI_BOARD_NAME, "eserver xSeries 330"),
884 },
885 },
886 {
887 .callback = force_acpi_ht,
888 .ident = "IBM eserver xSeries 440",
889 .matches = {
890 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
891 DMI_MATCH(DMI_PRODUCT_NAME, "eserver xSeries 440"),
892 },
893 },
895 /*
896 * Boxes that need ACPI PCI IRQ routing disabled
897 */
898 {
899 .callback = disable_acpi_irq,
900 .ident = "ASUS A7V",
901 .matches = {
902 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC"),
903 DMI_MATCH(DMI_BOARD_NAME, "<A7V>"),
904 /* newer BIOS, Revision 1011, does work */
905 DMI_MATCH(DMI_BIOS_VERSION,
906 "ASUS A7V ACPI BIOS Revision 1007"),
907 },
908 },
910 /*
911 * Boxes that need ACPI PCI IRQ routing and PCI scan disabled
912 */
913 { /* _BBN 0 bug */
914 .callback = disable_acpi_pci,
915 .ident = "ASUS PR-DLS",
916 .matches = {
917 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
918 DMI_MATCH(DMI_BOARD_NAME, "PR-DLS"),
919 DMI_MATCH(DMI_BIOS_VERSION,
920 "ASUS PR-DLS ACPI BIOS Revision 1010"),
921 DMI_MATCH(DMI_BIOS_DATE, "03/21/2003")
922 },
923 },
924 {
925 .callback = disable_acpi_pci,
926 .ident = "Acer TravelMate 36x Laptop",
927 .matches = {
928 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
929 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 360"),
930 },
931 },
932 {}
933 };
935 #endif /* __i386__ */
937 /*
938 * acpi_boot_table_init() and acpi_boot_init()
939 * called from setup_arch(), always.
940 * 1. checksums all tables
941 * 2. enumerates lapics
942 * 3. enumerates io-apics
943 *
944 * acpi_table_init() is separate to allow reading SRAT without
945 * other side effects.
946 *
947 * side effects of acpi_boot_init:
948 * acpi_lapic = 1 if LAPIC found
949 * acpi_ioapic = 1 if IOAPIC found
950 * if (acpi_lapic && acpi_ioapic) smp_found_config = 1;
951 * if acpi_blacklisted() acpi_disabled = 1;
952 * acpi_irq_model=...
953 * ...
954 *
955 * return value: (currently ignored)
956 * 0: success
957 * !0: failure
958 */
960 int __init acpi_boot_table_init(void)
961 {
962 int error;
964 #ifdef __i386__
965 dmi_check_system(acpi_dmi_table);
966 #endif
968 /*
969 * If acpi_disabled, bail out
970 * One exception: acpi=ht continues far enough to enumerate LAPICs
971 */
972 if (acpi_disabled && !acpi_ht)
973 return 1;
975 /*
976 * Initialize the ACPI boot-time table parser.
977 */
978 error = acpi_table_init();
979 if (error) {
980 disable_acpi();
981 return error;
982 }
984 acpi_table_parse(ACPI_BOOT, acpi_parse_sbf);
986 /*
987 * blacklist may disable ACPI entirely
988 */
989 error = acpi_blacklisted();
990 if (error) {
991 extern int acpi_force;
993 if (acpi_force) {
994 printk(KERN_WARNING PREFIX "acpi=force override\n");
995 } else {
996 printk(KERN_WARNING PREFIX "Disabling ACPI support\n");
997 disable_acpi();
998 return error;
999 }
1002 return 0;
1005 int __init acpi_boot_init(void)
1007 /*
1008 * If acpi_disabled, bail out
1009 * One exception: acpi=ht continues far enough to enumerate LAPICs
1010 */
1011 if (acpi_disabled && !acpi_ht)
1012 return 1;
1014 acpi_table_parse(ACPI_BOOT, acpi_parse_sbf);
1016 /*
1017 * set sci_int and PM timer address
1018 */
1019 acpi_table_parse(ACPI_FADT, acpi_parse_fadt);
1021 /*
1022 * Process the Multiple APIC Description Table (MADT), if present
1023 */
1024 acpi_process_madt();
1026 acpi_table_parse(ACPI_HPET, acpi_parse_hpet);
1028 acpi_dmar_init();
1030 return 0;