direct-io.hg

view linux-2.6-xen-sparse/arch/xen/i386/kernel/acpi/boot.c @ 6455:15d378281a0b

CONFIG_X86_PM_TIMER is a no-op option when building Linux
for Xen, but make sure it doesn't break the build.

Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Sat Aug 27 11:49:35 2005 +0000 (2005-08-27)
parents 9312a3e8a6f8
children a698bd49931b 287d36b46fa3 38312fe7ec38 f0dc15fd3c1b
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 <linux/init.h>
27 #include <linux/config.h>
28 #include <linux/acpi.h>
29 #include <linux/efi.h>
30 #include <linux/irq.h>
31 #include <linux/module.h>
33 #include <asm/pgtable.h>
34 #include <asm/io_apic.h>
35 #include <asm/apic.h>
36 #include <asm/io.h>
37 #include <asm/irq.h>
38 #include <asm/mpspec.h>
39 #ifdef CONFIG_XEN
40 #include <asm/fixmap.h>
41 #endif
43 void (*pm_power_off)(void) = NULL;
45 #ifdef CONFIG_X86_64
47 static inline void acpi_madt_oem_check(char *oem_id, char *oem_table_id) { }
48 extern void __init clustered_apic_check(void);
49 static inline int ioapic_setup_disabled(void) { return 0; }
50 #include <asm/proto.h>
52 #else /* X86 */
54 #ifdef CONFIG_X86_LOCAL_APIC
55 #include <mach_apic.h>
56 #include <mach_mpparse.h>
57 #endif /* CONFIG_X86_LOCAL_APIC */
59 #endif /* X86 */
61 #define BAD_MADT_ENTRY(entry, end) ( \
62 (!entry) || (unsigned long)entry + sizeof(*entry) > end || \
63 ((acpi_table_entry_header *)entry)->length != sizeof(*entry))
65 #define PREFIX "ACPI: "
67 #ifdef CONFIG_ACPI_PCI
68 int acpi_noirq __initdata; /* skip ACPI IRQ initialization */
69 int acpi_pci_disabled __initdata; /* skip ACPI PCI scan and IRQ initialization */
70 #else
71 int acpi_noirq __initdata = 1;
72 int acpi_pci_disabled __initdata = 1;
73 #endif
74 int acpi_ht __initdata = 1; /* enable HT */
76 int acpi_lapic;
77 int acpi_ioapic;
78 int acpi_strict;
79 EXPORT_SYMBOL(acpi_strict);
81 acpi_interrupt_flags acpi_sci_flags __initdata;
82 int acpi_sci_override_gsi __initdata;
83 int acpi_skip_timer_override __initdata;
85 #ifdef CONFIG_X86_LOCAL_APIC
86 static u64 acpi_lapic_addr __initdata = APIC_DEFAULT_PHYS_BASE;
87 #endif
89 #ifndef __HAVE_ARCH_CMPXCHG
90 #warning ACPI uses CMPXCHG, i486 and later hardware
91 #endif
93 #define MAX_MADT_ENTRIES 256
94 u8 x86_acpiid_to_apicid[MAX_MADT_ENTRIES] =
95 { [0 ... MAX_MADT_ENTRIES-1] = 0xff };
96 EXPORT_SYMBOL(x86_acpiid_to_apicid);
98 /* --------------------------------------------------------------------------
99 Boot-time Configuration
100 -------------------------------------------------------------------------- */
102 /*
103 * The default interrupt routing model is PIC (8259). This gets
104 * overriden if IOAPICs are enumerated (below).
105 */
106 enum acpi_irq_model_id acpi_irq_model = ACPI_IRQ_MODEL_PIC;
108 #if defined(CONFIG_X86_64) && !defined(CONFIG_XEN)
110 /* rely on all ACPI tables being in the direct mapping */
111 char *__acpi_map_table(unsigned long phys_addr, unsigned long size)
112 {
113 if (!phys_addr || !size)
114 return NULL;
116 if (phys_addr < (end_pfn_map << PAGE_SHIFT))
117 return __va(phys_addr);
119 return NULL;
120 }
122 #else
124 /*
125 * Temporarily use the virtual area starting from FIX_IO_APIC_BASE_END,
126 * to map the target physical address. The problem is that set_fixmap()
127 * provides a single page, and it is possible that the page is not
128 * sufficient.
129 * By using this area, we can map up to MAX_IO_APICS pages temporarily,
130 * i.e. until the next __va_range() call.
131 *
132 * Important Safety Note: The fixed I/O APIC page numbers are *subtracted*
133 * from the fixed base. That's why we start at FIX_IO_APIC_BASE_END and
134 * count idx down while incrementing the phys address.
135 */
136 char *__acpi_map_table(unsigned long phys, unsigned long size)
137 {
138 unsigned long base, offset, mapped_size;
139 int idx;
141 #ifndef CONFIG_XEN
142 if (phys + size < 8*1024*1024)
143 return __va(phys);
144 #endif
146 offset = phys & (PAGE_SIZE - 1);
147 mapped_size = PAGE_SIZE - offset;
148 set_fixmap(FIX_ACPI_END, phys);
149 base = fix_to_virt(FIX_ACPI_END);
151 /*
152 * Most cases can be covered by the below.
153 */
154 idx = FIX_ACPI_END;
155 while (mapped_size < size) {
156 if (--idx < FIX_ACPI_BEGIN)
157 return NULL; /* cannot handle this */
158 phys += PAGE_SIZE;
159 set_fixmap(idx, phys);
160 mapped_size += PAGE_SIZE;
161 }
163 return ((unsigned char *) base + offset);
164 }
165 #endif
167 #ifdef CONFIG_PCI_MMCONFIG
168 static int __init acpi_parse_mcfg(unsigned long phys_addr, unsigned long size)
169 {
170 struct acpi_table_mcfg *mcfg;
172 if (!phys_addr || !size)
173 return -EINVAL;
175 mcfg = (struct acpi_table_mcfg *) __acpi_map_table(phys_addr, size);
176 if (!mcfg) {
177 printk(KERN_WARNING PREFIX "Unable to map MCFG\n");
178 return -ENODEV;
179 }
181 if (mcfg->base_reserved) {
182 printk(KERN_ERR PREFIX "MMCONFIG not in low 4GB of memory\n");
183 return -ENODEV;
184 }
186 pci_mmcfg_base_addr = mcfg->base_address;
188 return 0;
189 }
190 #else
191 #define acpi_parse_mcfg NULL
192 #endif /* !CONFIG_PCI_MMCONFIG */
194 #ifdef CONFIG_X86_LOCAL_APIC
195 static int __init
196 acpi_parse_madt (
197 unsigned long phys_addr,
198 unsigned long size)
199 {
200 struct acpi_table_madt *madt = NULL;
202 if (!phys_addr || !size)
203 return -EINVAL;
205 madt = (struct acpi_table_madt *) __acpi_map_table(phys_addr, size);
206 if (!madt) {
207 printk(KERN_WARNING PREFIX "Unable to map MADT\n");
208 return -ENODEV;
209 }
211 if (madt->lapic_address) {
212 acpi_lapic_addr = (u64) madt->lapic_address;
214 printk(KERN_DEBUG PREFIX "Local APIC address 0x%08x\n",
215 madt->lapic_address);
216 }
218 acpi_madt_oem_check(madt->header.oem_id, madt->header.oem_table_id);
220 return 0;
221 }
224 static int __init
225 acpi_parse_lapic (
226 acpi_table_entry_header *header, const unsigned long end)
227 {
228 struct acpi_table_lapic *processor = NULL;
230 processor = (struct acpi_table_lapic*) header;
232 if (BAD_MADT_ENTRY(processor, end))
233 return -EINVAL;
235 acpi_table_print_madt_entry(header);
237 /* no utility in registering a disabled processor */
238 if (processor->flags.enabled == 0)
239 return 0;
241 x86_acpiid_to_apicid[processor->acpi_id] = processor->id;
243 mp_register_lapic (
244 processor->id, /* APIC ID */
245 processor->flags.enabled); /* Enabled? */
247 return 0;
248 }
250 static int __init
251 acpi_parse_lapic_addr_ovr (
252 acpi_table_entry_header *header, const unsigned long end)
253 {
254 struct acpi_table_lapic_addr_ovr *lapic_addr_ovr = NULL;
256 lapic_addr_ovr = (struct acpi_table_lapic_addr_ovr*) header;
258 if (BAD_MADT_ENTRY(lapic_addr_ovr, end))
259 return -EINVAL;
261 acpi_lapic_addr = lapic_addr_ovr->address;
263 return 0;
264 }
266 static int __init
267 acpi_parse_lapic_nmi (
268 acpi_table_entry_header *header, const unsigned long end)
269 {
270 struct acpi_table_lapic_nmi *lapic_nmi = NULL;
272 lapic_nmi = (struct acpi_table_lapic_nmi*) header;
274 if (BAD_MADT_ENTRY(lapic_nmi, end))
275 return -EINVAL;
277 acpi_table_print_madt_entry(header);
279 if (lapic_nmi->lint != 1)
280 printk(KERN_WARNING PREFIX "NMI not connected to LINT 1!\n");
282 return 0;
283 }
286 #endif /*CONFIG_X86_LOCAL_APIC*/
288 #if defined(CONFIG_X86_IO_APIC) && defined(CONFIG_ACPI_INTERPRETER)
290 static int __init
291 acpi_parse_ioapic (
292 acpi_table_entry_header *header, const unsigned long end)
293 {
294 struct acpi_table_ioapic *ioapic = NULL;
296 ioapic = (struct acpi_table_ioapic*) header;
298 if (BAD_MADT_ENTRY(ioapic, end))
299 return -EINVAL;
301 acpi_table_print_madt_entry(header);
303 mp_register_ioapic (
304 ioapic->id,
305 ioapic->address,
306 ioapic->global_irq_base);
308 return 0;
309 }
311 /*
312 * Parse Interrupt Source Override for the ACPI SCI
313 */
314 static void
315 acpi_sci_ioapic_setup(u32 gsi, u16 polarity, u16 trigger)
316 {
317 if (trigger == 0) /* compatible SCI trigger is level */
318 trigger = 3;
320 if (polarity == 0) /* compatible SCI polarity is low */
321 polarity = 3;
323 /* Command-line over-ride via acpi_sci= */
324 if (acpi_sci_flags.trigger)
325 trigger = acpi_sci_flags.trigger;
327 if (acpi_sci_flags.polarity)
328 polarity = acpi_sci_flags.polarity;
330 /*
331 * mp_config_acpi_legacy_irqs() already setup IRQs < 16
332 * If GSI is < 16, this will update its flags,
333 * else it will create a new mp_irqs[] entry.
334 */
335 mp_override_legacy_irq(gsi, polarity, trigger, gsi);
337 /*
338 * stash over-ride to indicate we've been here
339 * and for later update of acpi_fadt
340 */
341 acpi_sci_override_gsi = gsi;
342 return;
343 }
345 static int __init
346 acpi_parse_int_src_ovr (
347 acpi_table_entry_header *header, const unsigned long end)
348 {
349 struct acpi_table_int_src_ovr *intsrc = NULL;
351 intsrc = (struct acpi_table_int_src_ovr*) header;
353 if (BAD_MADT_ENTRY(intsrc, end))
354 return -EINVAL;
356 acpi_table_print_madt_entry(header);
358 if (intsrc->bus_irq == acpi_fadt.sci_int) {
359 acpi_sci_ioapic_setup(intsrc->global_irq,
360 intsrc->flags.polarity, intsrc->flags.trigger);
361 return 0;
362 }
364 if (acpi_skip_timer_override &&
365 intsrc->bus_irq == 0 && intsrc->global_irq == 2) {
366 printk(PREFIX "BIOS IRQ0 pin2 override ignored.\n");
367 return 0;
368 }
370 mp_override_legacy_irq (
371 intsrc->bus_irq,
372 intsrc->flags.polarity,
373 intsrc->flags.trigger,
374 intsrc->global_irq);
376 return 0;
377 }
380 static int __init
381 acpi_parse_nmi_src (
382 acpi_table_entry_header *header, const unsigned long end)
383 {
384 struct acpi_table_nmi_src *nmi_src = NULL;
386 nmi_src = (struct acpi_table_nmi_src*) header;
388 if (BAD_MADT_ENTRY(nmi_src, end))
389 return -EINVAL;
391 acpi_table_print_madt_entry(header);
393 /* TBD: Support nimsrc entries? */
395 return 0;
396 }
398 #endif /* CONFIG_X86_IO_APIC */
400 #ifdef CONFIG_ACPI_BUS
402 /*
403 * acpi_pic_sci_set_trigger()
404 *
405 * use ELCR to set PIC-mode trigger type for SCI
406 *
407 * If a PIC-mode SCI is not recognized or gives spurious IRQ7's
408 * it may require Edge Trigger -- use "acpi_sci=edge"
409 *
410 * Port 0x4d0-4d1 are ECLR1 and ECLR2, the Edge/Level Control Registers
411 * for the 8259 PIC. bit[n] = 1 means irq[n] is Level, otherwise Edge.
412 * ECLR1 is IRQ's 0-7 (IRQ 0, 1, 2 must be 0)
413 * ECLR2 is IRQ's 8-15 (IRQ 8, 13 must be 0)
414 */
416 void __init
417 acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger)
418 {
419 unsigned int mask = 1 << irq;
420 unsigned int old, new;
422 /* Real old ELCR mask */
423 old = inb(0x4d0) | (inb(0x4d1) << 8);
425 /*
426 * If we use ACPI to set PCI irq's, then we should clear ELCR
427 * since we will set it correctly as we enable the PCI irq
428 * routing.
429 */
430 new = acpi_noirq ? old : 0;
432 /*
433 * Update SCI information in the ELCR, it isn't in the PCI
434 * routing tables..
435 */
436 switch (trigger) {
437 case 1: /* Edge - clear */
438 new &= ~mask;
439 break;
440 case 3: /* Level - set */
441 new |= mask;
442 break;
443 }
445 if (old == new)
446 return;
448 printk(PREFIX "setting ELCR to %04x (from %04x)\n", new, old);
449 outb(new, 0x4d0);
450 outb(new >> 8, 0x4d1);
451 }
454 #endif /* CONFIG_ACPI_BUS */
456 int acpi_gsi_to_irq(u32 gsi, unsigned int *irq)
457 {
458 #ifdef CONFIG_X86_IO_APIC
459 if (use_pci_vector() && !platform_legacy_irq(gsi))
460 *irq = IO_APIC_VECTOR(gsi);
461 else
462 #endif
463 *irq = gsi;
464 return 0;
465 }
467 unsigned int acpi_register_gsi(u32 gsi, int edge_level, int active_high_low)
468 {
469 unsigned int irq;
470 unsigned int plat_gsi = gsi;
472 #ifdef CONFIG_X86_IO_APIC
473 if (acpi_irq_model == ACPI_IRQ_MODEL_IOAPIC) {
474 plat_gsi = mp_register_gsi(gsi, edge_level, active_high_low);
475 }
476 #endif
477 acpi_gsi_to_irq(plat_gsi, &irq);
478 return irq;
479 }
480 EXPORT_SYMBOL(acpi_register_gsi);
482 /*
483 * ACPI based hotplug support for CPU
484 */
485 #ifdef CONFIG_ACPI_HOTPLUG_CPU
486 int
487 acpi_map_lsapic(acpi_handle handle, int *pcpu)
488 {
489 /* TBD */
490 return -EINVAL;
491 }
492 EXPORT_SYMBOL(acpi_map_lsapic);
495 int
496 acpi_unmap_lsapic(int cpu)
497 {
498 /* TBD */
499 return -EINVAL;
500 }
501 EXPORT_SYMBOL(acpi_unmap_lsapic);
502 #endif /* CONFIG_ACPI_HOTPLUG_CPU */
504 static unsigned long __init
505 acpi_scan_rsdp (
506 unsigned long start,
507 unsigned long length)
508 {
509 unsigned long offset = 0;
510 unsigned long sig_len = sizeof("RSD PTR ") - 1;
511 unsigned long vstart = (unsigned long)isa_bus_to_virt(start);
513 /*
514 * Scan all 16-byte boundaries of the physical memory region for the
515 * RSDP signature.
516 */
517 for (offset = 0; offset < length; offset += 16) {
518 if (strncmp((char *) (vstart + offset), "RSD PTR ", sig_len))
519 continue;
520 return (start + offset);
521 }
523 return 0;
524 }
526 static int __init acpi_parse_sbf(unsigned long phys_addr, unsigned long size)
527 {
528 struct acpi_table_sbf *sb;
530 if (!phys_addr || !size)
531 return -EINVAL;
533 sb = (struct acpi_table_sbf *) __acpi_map_table(phys_addr, size);
534 if (!sb) {
535 printk(KERN_WARNING PREFIX "Unable to map SBF\n");
536 return -ENODEV;
537 }
539 sbf_port = sb->sbf_cmos; /* Save CMOS port */
541 return 0;
542 }
545 #ifdef CONFIG_HPET_TIMER
547 static int __init acpi_parse_hpet(unsigned long phys, unsigned long size)
548 {
549 struct acpi_table_hpet *hpet_tbl;
551 if (!phys || !size)
552 return -EINVAL;
554 hpet_tbl = (struct acpi_table_hpet *) __acpi_map_table(phys, size);
555 if (!hpet_tbl) {
556 printk(KERN_WARNING PREFIX "Unable to map HPET\n");
557 return -ENODEV;
558 }
560 if (hpet_tbl->addr.space_id != ACPI_SPACE_MEM) {
561 printk(KERN_WARNING PREFIX "HPET timers must be located in "
562 "memory.\n");
563 return -1;
564 }
566 #ifdef CONFIG_X86_64
567 vxtime.hpet_address = hpet_tbl->addr.addrl |
568 ((long) hpet_tbl->addr.addrh << 32);
570 printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n",
571 hpet_tbl->id, vxtime.hpet_address);
572 #else /* X86 */
573 {
574 extern unsigned long hpet_address;
576 hpet_address = hpet_tbl->addr.addrl;
577 printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n",
578 hpet_tbl->id, hpet_address);
579 }
580 #endif /* X86 */
582 return 0;
583 }
584 #else
585 #define acpi_parse_hpet NULL
586 #endif
588 #ifdef CONFIG_X86_PM_TIMER
589 extern u32 pmtmr_ioport;
590 #endif
592 static int __init acpi_parse_fadt(unsigned long phys, unsigned long size)
593 {
594 struct fadt_descriptor_rev2 *fadt = NULL;
596 fadt = (struct fadt_descriptor_rev2*) __acpi_map_table(phys,size);
597 if(!fadt) {
598 printk(KERN_WARNING PREFIX "Unable to map FADT\n");
599 return 0;
600 }
602 #ifdef CONFIG_ACPI_INTERPRETER
603 /* initialize sci_int early for INT_SRC_OVR MADT parsing */
604 acpi_fadt.sci_int = fadt->sci_int;
605 #endif
607 #ifdef CONFIG_ACPI_BUS
608 /* initialize rev and apic_phys_dest_mode for x86_64 genapic */
609 acpi_fadt.revision = fadt->revision;
610 acpi_fadt.force_apic_physical_destination_mode = fadt->force_apic_physical_destination_mode;
611 #endif
613 #if defined(CONFIG_X86_PM_TIMER) && !defined(CONFIG_XEN)
614 /* detect the location of the ACPI PM Timer */
615 if (fadt->revision >= FADT2_REVISION_ID) {
616 /* FADT rev. 2 */
617 if (fadt->xpm_tmr_blk.address_space_id != ACPI_ADR_SPACE_SYSTEM_IO)
618 return 0;
620 pmtmr_ioport = fadt->xpm_tmr_blk.address;
621 } else {
622 /* FADT rev. 1 */
623 pmtmr_ioport = fadt->V1_pm_tmr_blk;
624 }
625 if (pmtmr_ioport)
626 printk(KERN_INFO PREFIX "PM-Timer IO Port: %#x\n", pmtmr_ioport);
627 #endif
628 return 0;
629 }
632 unsigned long __init
633 acpi_find_rsdp (void)
634 {
635 unsigned long rsdp_phys = 0;
637 if (efi_enabled) {
638 if (efi.acpi20)
639 return __pa(efi.acpi20);
640 else if (efi.acpi)
641 return __pa(efi.acpi);
642 }
643 /*
644 * Scan memory looking for the RSDP signature. First search EBDA (low
645 * memory) paragraphs and then search upper memory (E0000-FFFFF).
646 */
647 rsdp_phys = acpi_scan_rsdp (0, 0x400);
648 if (!rsdp_phys)
649 rsdp_phys = acpi_scan_rsdp (0xE0000, 0x20000);
651 set_fixmap(FIX_ACPI_RSDP_PAGE, rsdp_phys);
653 return rsdp_phys;
654 }
656 #ifdef CONFIG_X86_LOCAL_APIC
657 /*
658 * Parse LAPIC entries in MADT
659 * returns 0 on success, < 0 on error
660 */
661 static int __init
662 acpi_parse_madt_lapic_entries(void)
663 {
664 int count;
666 /*
667 * Note that the LAPIC address is obtained from the MADT (32-bit value)
668 * and (optionally) overriden by a LAPIC_ADDR_OVR entry (64-bit value).
669 */
671 count = acpi_table_parse_madt(ACPI_MADT_LAPIC_ADDR_OVR, acpi_parse_lapic_addr_ovr, 0);
672 if (count < 0) {
673 printk(KERN_ERR PREFIX "Error parsing LAPIC address override entry\n");
674 return count;
675 }
677 mp_register_lapic_address(acpi_lapic_addr);
679 count = acpi_table_parse_madt(ACPI_MADT_LAPIC, acpi_parse_lapic,
680 MAX_APICS);
681 if (!count) {
682 printk(KERN_ERR PREFIX "No LAPIC entries present\n");
683 /* TBD: Cleanup to allow fallback to MPS */
684 return -ENODEV;
685 }
686 else if (count < 0) {
687 printk(KERN_ERR PREFIX "Error parsing LAPIC entry\n");
688 /* TBD: Cleanup to allow fallback to MPS */
689 return count;
690 }
692 count = acpi_table_parse_madt(ACPI_MADT_LAPIC_NMI, acpi_parse_lapic_nmi, 0);
693 if (count < 0) {
694 printk(KERN_ERR PREFIX "Error parsing LAPIC NMI entry\n");
695 /* TBD: Cleanup to allow fallback to MPS */
696 return count;
697 }
698 return 0;
699 }
700 #endif /* CONFIG_X86_LOCAL_APIC */
702 #if defined(CONFIG_X86_IO_APIC) && defined(CONFIG_ACPI_INTERPRETER)
703 /*
704 * Parse IOAPIC related entries in MADT
705 * returns 0 on success, < 0 on error
706 */
707 static int __init
708 acpi_parse_madt_ioapic_entries(void)
709 {
710 int count;
712 /*
713 * ACPI interpreter is required to complete interrupt setup,
714 * so if it is off, don't enumerate the io-apics with ACPI.
715 * If MPS is present, it will handle them,
716 * otherwise the system will stay in PIC mode
717 */
718 if (acpi_disabled || acpi_noirq) {
719 return -ENODEV;
720 }
722 /*
723 * if "noapic" boot option, don't look for IO-APICs
724 */
725 if (skip_ioapic_setup) {
726 printk(KERN_INFO PREFIX "Skipping IOAPIC probe "
727 "due to 'noapic' option.\n");
728 return -ENODEV;
729 }
731 count = acpi_table_parse_madt(ACPI_MADT_IOAPIC, acpi_parse_ioapic, MAX_IO_APICS);
732 if (!count) {
733 printk(KERN_ERR PREFIX "No IOAPIC entries present\n");
734 return -ENODEV;
735 }
736 else if (count < 0) {
737 printk(KERN_ERR PREFIX "Error parsing IOAPIC entry\n");
738 return count;
739 }
741 count = acpi_table_parse_madt(ACPI_MADT_INT_SRC_OVR, acpi_parse_int_src_ovr, NR_IRQ_VECTORS);
742 if (count < 0) {
743 printk(KERN_ERR PREFIX "Error parsing interrupt source overrides entry\n");
744 /* TBD: Cleanup to allow fallback to MPS */
745 return count;
746 }
748 /*
749 * If BIOS did not supply an INT_SRC_OVR for the SCI
750 * pretend we got one so we can set the SCI flags.
751 */
752 if (!acpi_sci_override_gsi)
753 acpi_sci_ioapic_setup(acpi_fadt.sci_int, 0, 0);
755 /* Fill in identity legacy mapings where no override */
756 mp_config_acpi_legacy_irqs();
758 count = acpi_table_parse_madt(ACPI_MADT_NMI_SRC, acpi_parse_nmi_src, NR_IRQ_VECTORS);
759 if (count < 0) {
760 printk(KERN_ERR PREFIX "Error parsing NMI SRC entry\n");
761 /* TBD: Cleanup to allow fallback to MPS */
762 return count;
763 }
765 return 0;
766 }
767 #else
768 static inline int acpi_parse_madt_ioapic_entries(void)
769 {
770 return -1;
771 }
772 #endif /* !(CONFIG_X86_IO_APIC && CONFIG_ACPI_INTERPRETER) */
775 static void __init
776 acpi_process_madt(void)
777 {
778 #ifdef CONFIG_X86_LOCAL_APIC
779 int count, error;
781 count = acpi_table_parse(ACPI_APIC, acpi_parse_madt);
782 if (count >= 1) {
784 /*
785 * Parse MADT LAPIC entries
786 */
787 error = acpi_parse_madt_lapic_entries();
788 if (!error) {
789 acpi_lapic = 1;
791 /*
792 * Parse MADT IO-APIC entries
793 */
794 error = acpi_parse_madt_ioapic_entries();
795 if (!error) {
796 acpi_irq_model = ACPI_IRQ_MODEL_IOAPIC;
797 acpi_irq_balance_set(NULL);
798 acpi_ioapic = 1;
800 smp_found_config = 1;
801 clustered_apic_check();
802 }
803 }
804 if (error == -EINVAL) {
805 /*
806 * Dell Precision Workstation 410, 610 come here.
807 */
808 printk(KERN_ERR PREFIX "Invalid BIOS MADT, disabling ACPI\n");
809 disable_acpi();
810 }
811 }
812 #endif
813 return;
814 }
816 /*
817 * acpi_boot_table_init() and acpi_boot_init()
818 * called from setup_arch(), always.
819 * 1. checksums all tables
820 * 2. enumerates lapics
821 * 3. enumerates io-apics
822 *
823 * acpi_table_init() is separate to allow reading SRAT without
824 * other side effects.
825 *
826 * side effects of acpi_boot_init:
827 * acpi_lapic = 1 if LAPIC found
828 * acpi_ioapic = 1 if IOAPIC found
829 * if (acpi_lapic && acpi_ioapic) smp_found_config = 1;
830 * if acpi_blacklisted() acpi_disabled = 1;
831 * acpi_irq_model=...
832 * ...
833 *
834 * return value: (currently ignored)
835 * 0: success
836 * !0: failure
837 */
839 int __init
840 acpi_boot_table_init(void)
841 {
842 int error;
844 /*
845 * If acpi_disabled, bail out
846 * One exception: acpi=ht continues far enough to enumerate LAPICs
847 */
848 if (acpi_disabled && !acpi_ht)
849 return 1;
851 /*
852 * Initialize the ACPI boot-time table parser.
853 */
854 error = acpi_table_init();
855 if (error) {
856 disable_acpi();
857 return error;
858 }
860 #ifdef __i386__
861 check_acpi_pci();
862 #endif
864 acpi_table_parse(ACPI_BOOT, acpi_parse_sbf);
866 /*
867 * blacklist may disable ACPI entirely
868 */
869 error = acpi_blacklisted();
870 if (error) {
871 extern int acpi_force;
873 if (acpi_force) {
874 printk(KERN_WARNING PREFIX "acpi=force override\n");
875 } else {
876 printk(KERN_WARNING PREFIX "Disabling ACPI support\n");
877 disable_acpi();
878 return error;
879 }
880 }
882 return 0;
883 }
886 int __init acpi_boot_init(void)
887 {
888 /*
889 * If acpi_disabled, bail out
890 * One exception: acpi=ht continues far enough to enumerate LAPICs
891 */
892 if (acpi_disabled && !acpi_ht)
893 return 1;
895 acpi_table_parse(ACPI_BOOT, acpi_parse_sbf);
897 /*
898 * set sci_int and PM timer address
899 */
900 acpi_table_parse(ACPI_FADT, acpi_parse_fadt);
902 /*
903 * Process the Multiple APIC Description Table (MADT), if present
904 */
905 acpi_process_madt();
907 acpi_table_parse(ACPI_HPET, acpi_parse_hpet);
908 acpi_table_parse(ACPI_MCFG, acpi_parse_mcfg);
910 return 0;
911 }