ia64/xen-unstable

view linux-2.6-xen-sparse/arch/xen/i386/kernel/acpi/boot.c @ 8509:ba4d42f18661

Move definition of pm_power_off to a more sensible location.

Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
author cl349@firebug.cl.cam.ac.uk
date Fri Jan 06 12:59:55 2006 +0100 (2006-01-06)
parents 6e24488a89f7
children
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 #ifdef CONFIG_X86_64
45 static inline void acpi_madt_oem_check(char *oem_id, char *oem_table_id) { }
46 extern void __init clustered_apic_check(void);
47 static inline int ioapic_setup_disabled(void) { return 0; }
48 #include <asm/proto.h>
50 #else /* X86 */
52 #ifdef CONFIG_X86_LOCAL_APIC
53 #include <mach_apic.h>
54 #include <mach_mpparse.h>
55 #endif /* CONFIG_X86_LOCAL_APIC */
57 #endif /* X86 */
59 #define BAD_MADT_ENTRY(entry, end) ( \
60 (!entry) || (unsigned long)entry + sizeof(*entry) > end || \
61 ((acpi_table_entry_header *)entry)->length != sizeof(*entry))
63 #define PREFIX "ACPI: "
65 #ifdef CONFIG_ACPI_PCI
66 int acpi_noirq __initdata; /* skip ACPI IRQ initialization */
67 int acpi_pci_disabled __initdata; /* skip ACPI PCI scan and IRQ initialization */
68 #else
69 int acpi_noirq __initdata = 1;
70 int acpi_pci_disabled __initdata = 1;
71 #endif
72 int acpi_ht __initdata = 1; /* enable HT */
74 int acpi_lapic;
75 int acpi_ioapic;
76 int acpi_strict;
77 EXPORT_SYMBOL(acpi_strict);
79 acpi_interrupt_flags acpi_sci_flags __initdata;
80 int acpi_sci_override_gsi __initdata;
81 int acpi_skip_timer_override __initdata;
83 #ifdef CONFIG_X86_LOCAL_APIC
84 static u64 acpi_lapic_addr __initdata = APIC_DEFAULT_PHYS_BASE;
85 #endif
87 #ifndef __HAVE_ARCH_CMPXCHG
88 #warning ACPI uses CMPXCHG, i486 and later hardware
89 #endif
91 #define MAX_MADT_ENTRIES 256
92 u8 x86_acpiid_to_apicid[MAX_MADT_ENTRIES] =
93 { [0 ... MAX_MADT_ENTRIES-1] = 0xff };
94 EXPORT_SYMBOL(x86_acpiid_to_apicid);
96 /* --------------------------------------------------------------------------
97 Boot-time Configuration
98 -------------------------------------------------------------------------- */
100 /*
101 * The default interrupt routing model is PIC (8259). This gets
102 * overriden if IOAPICs are enumerated (below).
103 */
104 enum acpi_irq_model_id acpi_irq_model = ACPI_IRQ_MODEL_PIC;
106 #if defined(CONFIG_X86_64) && !defined(CONFIG_XEN)
108 /* rely on all ACPI tables being in the direct mapping */
109 char *__acpi_map_table(unsigned long phys_addr, unsigned long size)
110 {
111 if (!phys_addr || !size)
112 return NULL;
114 if (phys_addr < (end_pfn_map << PAGE_SHIFT))
115 return __va(phys_addr);
117 return NULL;
118 }
120 #else
122 /*
123 * Temporarily use the virtual area starting from FIX_IO_APIC_BASE_END,
124 * to map the target physical address. The problem is that set_fixmap()
125 * provides a single page, and it is possible that the page is not
126 * sufficient.
127 * By using this area, we can map up to MAX_IO_APICS pages temporarily,
128 * i.e. until the next __va_range() call.
129 *
130 * Important Safety Note: The fixed I/O APIC page numbers are *subtracted*
131 * from the fixed base. That's why we start at FIX_IO_APIC_BASE_END and
132 * count idx down while incrementing the phys address.
133 */
134 char *__acpi_map_table(unsigned long phys, unsigned long size)
135 {
136 unsigned long base, offset, mapped_size;
137 int idx;
139 #ifndef CONFIG_XEN
140 if (phys + size < 8*1024*1024)
141 return __va(phys);
142 #endif
144 offset = phys & (PAGE_SIZE - 1);
145 mapped_size = PAGE_SIZE - offset;
146 set_fixmap(FIX_ACPI_END, phys);
147 base = fix_to_virt(FIX_ACPI_END);
149 /*
150 * Most cases can be covered by the below.
151 */
152 idx = FIX_ACPI_END;
153 while (mapped_size < size) {
154 if (--idx < FIX_ACPI_BEGIN)
155 return NULL; /* cannot handle this */
156 phys += PAGE_SIZE;
157 set_fixmap(idx, phys);
158 mapped_size += PAGE_SIZE;
159 }
161 return ((unsigned char *) base + offset);
162 }
163 #endif
165 #ifdef CONFIG_PCI_MMCONFIG
166 static int __init acpi_parse_mcfg(unsigned long phys_addr, unsigned long size)
167 {
168 struct acpi_table_mcfg *mcfg;
170 if (!phys_addr || !size)
171 return -EINVAL;
173 mcfg = (struct acpi_table_mcfg *) __acpi_map_table(phys_addr, size);
174 if (!mcfg) {
175 printk(KERN_WARNING PREFIX "Unable to map MCFG\n");
176 return -ENODEV;
177 }
179 if (mcfg->base_reserved) {
180 printk(KERN_ERR PREFIX "MMCONFIG not in low 4GB of memory\n");
181 return -ENODEV;
182 }
184 pci_mmcfg_base_addr = mcfg->base_address;
186 return 0;
187 }
188 #else
189 #define acpi_parse_mcfg NULL
190 #endif /* !CONFIG_PCI_MMCONFIG */
192 #ifdef CONFIG_X86_LOCAL_APIC
193 static int __init
194 acpi_parse_madt (
195 unsigned long phys_addr,
196 unsigned long size)
197 {
198 struct acpi_table_madt *madt = NULL;
200 if (!phys_addr || !size)
201 return -EINVAL;
203 madt = (struct acpi_table_madt *) __acpi_map_table(phys_addr, size);
204 if (!madt) {
205 printk(KERN_WARNING PREFIX "Unable to map MADT\n");
206 return -ENODEV;
207 }
209 if (madt->lapic_address) {
210 acpi_lapic_addr = (u64) madt->lapic_address;
212 printk(KERN_DEBUG PREFIX "Local APIC address 0x%08x\n",
213 madt->lapic_address);
214 }
216 acpi_madt_oem_check(madt->header.oem_id, madt->header.oem_table_id);
218 return 0;
219 }
222 static int __init
223 acpi_parse_lapic (
224 acpi_table_entry_header *header, const unsigned long end)
225 {
226 struct acpi_table_lapic *processor = NULL;
228 processor = (struct acpi_table_lapic*) header;
230 if (BAD_MADT_ENTRY(processor, end))
231 return -EINVAL;
233 acpi_table_print_madt_entry(header);
235 /* no utility in registering a disabled processor */
236 if (processor->flags.enabled == 0)
237 return 0;
239 x86_acpiid_to_apicid[processor->acpi_id] = processor->id;
241 mp_register_lapic (
242 processor->id, /* APIC ID */
243 processor->flags.enabled); /* Enabled? */
245 return 0;
246 }
248 static int __init
249 acpi_parse_lapic_addr_ovr (
250 acpi_table_entry_header *header, const unsigned long end)
251 {
252 struct acpi_table_lapic_addr_ovr *lapic_addr_ovr = NULL;
254 lapic_addr_ovr = (struct acpi_table_lapic_addr_ovr*) header;
256 if (BAD_MADT_ENTRY(lapic_addr_ovr, end))
257 return -EINVAL;
259 acpi_lapic_addr = lapic_addr_ovr->address;
261 return 0;
262 }
264 static int __init
265 acpi_parse_lapic_nmi (
266 acpi_table_entry_header *header, const unsigned long end)
267 {
268 struct acpi_table_lapic_nmi *lapic_nmi = NULL;
270 lapic_nmi = (struct acpi_table_lapic_nmi*) header;
272 if (BAD_MADT_ENTRY(lapic_nmi, end))
273 return -EINVAL;
275 acpi_table_print_madt_entry(header);
277 if (lapic_nmi->lint != 1)
278 printk(KERN_WARNING PREFIX "NMI not connected to LINT 1!\n");
280 return 0;
281 }
284 #endif /*CONFIG_X86_LOCAL_APIC*/
286 #if defined(CONFIG_X86_IO_APIC) && defined(CONFIG_ACPI_INTERPRETER)
288 static int __init
289 acpi_parse_ioapic (
290 acpi_table_entry_header *header, const unsigned long end)
291 {
292 struct acpi_table_ioapic *ioapic = NULL;
294 ioapic = (struct acpi_table_ioapic*) header;
296 if (BAD_MADT_ENTRY(ioapic, end))
297 return -EINVAL;
299 acpi_table_print_madt_entry(header);
301 mp_register_ioapic (
302 ioapic->id,
303 ioapic->address,
304 ioapic->global_irq_base);
306 return 0;
307 }
309 /*
310 * Parse Interrupt Source Override for the ACPI SCI
311 */
312 static void
313 acpi_sci_ioapic_setup(u32 gsi, u16 polarity, u16 trigger)
314 {
315 if (trigger == 0) /* compatible SCI trigger is level */
316 trigger = 3;
318 if (polarity == 0) /* compatible SCI polarity is low */
319 polarity = 3;
321 /* Command-line over-ride via acpi_sci= */
322 if (acpi_sci_flags.trigger)
323 trigger = acpi_sci_flags.trigger;
325 if (acpi_sci_flags.polarity)
326 polarity = acpi_sci_flags.polarity;
328 /*
329 * mp_config_acpi_legacy_irqs() already setup IRQs < 16
330 * If GSI is < 16, this will update its flags,
331 * else it will create a new mp_irqs[] entry.
332 */
333 mp_override_legacy_irq(gsi, polarity, trigger, gsi);
335 /*
336 * stash over-ride to indicate we've been here
337 * and for later update of acpi_fadt
338 */
339 acpi_sci_override_gsi = gsi;
340 return;
341 }
343 static int __init
344 acpi_parse_int_src_ovr (
345 acpi_table_entry_header *header, const unsigned long end)
346 {
347 struct acpi_table_int_src_ovr *intsrc = NULL;
349 intsrc = (struct acpi_table_int_src_ovr*) header;
351 if (BAD_MADT_ENTRY(intsrc, end))
352 return -EINVAL;
354 acpi_table_print_madt_entry(header);
356 if (intsrc->bus_irq == acpi_fadt.sci_int) {
357 acpi_sci_ioapic_setup(intsrc->global_irq,
358 intsrc->flags.polarity, intsrc->flags.trigger);
359 return 0;
360 }
362 if (acpi_skip_timer_override &&
363 intsrc->bus_irq == 0 && intsrc->global_irq == 2) {
364 printk(PREFIX "BIOS IRQ0 pin2 override ignored.\n");
365 return 0;
366 }
368 mp_override_legacy_irq (
369 intsrc->bus_irq,
370 intsrc->flags.polarity,
371 intsrc->flags.trigger,
372 intsrc->global_irq);
374 return 0;
375 }
378 static int __init
379 acpi_parse_nmi_src (
380 acpi_table_entry_header *header, const unsigned long end)
381 {
382 struct acpi_table_nmi_src *nmi_src = NULL;
384 nmi_src = (struct acpi_table_nmi_src*) header;
386 if (BAD_MADT_ENTRY(nmi_src, end))
387 return -EINVAL;
389 acpi_table_print_madt_entry(header);
391 /* TBD: Support nimsrc entries? */
393 return 0;
394 }
396 #endif /* CONFIG_X86_IO_APIC */
398 #ifdef CONFIG_ACPI_BUS
400 /*
401 * acpi_pic_sci_set_trigger()
402 *
403 * use ELCR to set PIC-mode trigger type for SCI
404 *
405 * If a PIC-mode SCI is not recognized or gives spurious IRQ7's
406 * it may require Edge Trigger -- use "acpi_sci=edge"
407 *
408 * Port 0x4d0-4d1 are ECLR1 and ECLR2, the Edge/Level Control Registers
409 * for the 8259 PIC. bit[n] = 1 means irq[n] is Level, otherwise Edge.
410 * ECLR1 is IRQ's 0-7 (IRQ 0, 1, 2 must be 0)
411 * ECLR2 is IRQ's 8-15 (IRQ 8, 13 must be 0)
412 */
414 void __init
415 acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger)
416 {
417 unsigned int mask = 1 << irq;
418 unsigned int old, new;
420 /* Real old ELCR mask */
421 old = inb(0x4d0) | (inb(0x4d1) << 8);
423 /*
424 * If we use ACPI to set PCI irq's, then we should clear ELCR
425 * since we will set it correctly as we enable the PCI irq
426 * routing.
427 */
428 new = acpi_noirq ? old : 0;
430 /*
431 * Update SCI information in the ELCR, it isn't in the PCI
432 * routing tables..
433 */
434 switch (trigger) {
435 case 1: /* Edge - clear */
436 new &= ~mask;
437 break;
438 case 3: /* Level - set */
439 new |= mask;
440 break;
441 }
443 if (old == new)
444 return;
446 printk(PREFIX "setting ELCR to %04x (from %04x)\n", new, old);
447 outb(new, 0x4d0);
448 outb(new >> 8, 0x4d1);
449 }
452 #endif /* CONFIG_ACPI_BUS */
454 int acpi_gsi_to_irq(u32 gsi, unsigned int *irq)
455 {
456 #ifdef CONFIG_X86_IO_APIC
457 if (use_pci_vector() && !platform_legacy_irq(gsi))
458 *irq = IO_APIC_VECTOR(gsi);
459 else
460 #endif
461 *irq = gsi;
462 return 0;
463 }
465 unsigned int acpi_register_gsi(u32 gsi, int edge_level, int active_high_low)
466 {
467 unsigned int irq;
468 unsigned int plat_gsi = gsi;
470 #ifdef CONFIG_PCI
471 /*
472 * Make sure all (legacy) PCI IRQs are set as level-triggered.
473 */
474 if (acpi_irq_model == ACPI_IRQ_MODEL_PIC) {
475 extern void eisa_set_level_irq(unsigned int irq);
477 if (edge_level == ACPI_LEVEL_SENSITIVE)
478 eisa_set_level_irq(gsi);
479 }
480 #endif
482 #ifdef CONFIG_X86_IO_APIC
483 if (acpi_irq_model == ACPI_IRQ_MODEL_IOAPIC) {
484 plat_gsi = mp_register_gsi(gsi, edge_level, active_high_low);
485 }
486 #endif
487 acpi_gsi_to_irq(plat_gsi, &irq);
488 return irq;
489 }
490 EXPORT_SYMBOL(acpi_register_gsi);
492 /*
493 * ACPI based hotplug support for CPU
494 */
495 #ifdef CONFIG_ACPI_HOTPLUG_CPU
496 int
497 acpi_map_lsapic(acpi_handle handle, int *pcpu)
498 {
499 /* TBD */
500 return -EINVAL;
501 }
502 EXPORT_SYMBOL(acpi_map_lsapic);
505 int
506 acpi_unmap_lsapic(int cpu)
507 {
508 /* TBD */
509 return -EINVAL;
510 }
511 EXPORT_SYMBOL(acpi_unmap_lsapic);
512 #endif /* CONFIG_ACPI_HOTPLUG_CPU */
514 static unsigned long __init
515 acpi_scan_rsdp (
516 unsigned long start,
517 unsigned long length)
518 {
519 unsigned long offset = 0;
520 unsigned long sig_len = sizeof("RSD PTR ") - 1;
521 unsigned long vstart = (unsigned long)isa_bus_to_virt(start);
523 /*
524 * Scan all 16-byte boundaries of the physical memory region for the
525 * RSDP signature.
526 */
527 for (offset = 0; offset < length; offset += 16) {
528 if (strncmp((char *) (vstart + offset), "RSD PTR ", sig_len))
529 continue;
530 return (start + offset);
531 }
533 return 0;
534 }
536 static int __init acpi_parse_sbf(unsigned long phys_addr, unsigned long size)
537 {
538 struct acpi_table_sbf *sb;
540 if (!phys_addr || !size)
541 return -EINVAL;
543 sb = (struct acpi_table_sbf *) __acpi_map_table(phys_addr, size);
544 if (!sb) {
545 printk(KERN_WARNING PREFIX "Unable to map SBF\n");
546 return -ENODEV;
547 }
549 sbf_port = sb->sbf_cmos; /* Save CMOS port */
551 return 0;
552 }
555 #ifdef CONFIG_HPET_TIMER
557 static int __init acpi_parse_hpet(unsigned long phys, unsigned long size)
558 {
559 struct acpi_table_hpet *hpet_tbl;
561 if (!phys || !size)
562 return -EINVAL;
564 hpet_tbl = (struct acpi_table_hpet *) __acpi_map_table(phys, size);
565 if (!hpet_tbl) {
566 printk(KERN_WARNING PREFIX "Unable to map HPET\n");
567 return -ENODEV;
568 }
570 if (hpet_tbl->addr.space_id != ACPI_SPACE_MEM) {
571 printk(KERN_WARNING PREFIX "HPET timers must be located in "
572 "memory.\n");
573 return -1;
574 }
576 #ifdef CONFIG_X86_64
577 vxtime.hpet_address = hpet_tbl->addr.addrl |
578 ((long) hpet_tbl->addr.addrh << 32);
580 printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n",
581 hpet_tbl->id, vxtime.hpet_address);
582 #else /* X86 */
583 {
584 extern unsigned long hpet_address;
586 hpet_address = hpet_tbl->addr.addrl;
587 printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n",
588 hpet_tbl->id, hpet_address);
589 }
590 #endif /* X86 */
592 return 0;
593 }
594 #else
595 #define acpi_parse_hpet NULL
596 #endif
598 #ifdef CONFIG_X86_PM_TIMER
599 extern u32 pmtmr_ioport;
600 #endif
602 static int __init acpi_parse_fadt(unsigned long phys, unsigned long size)
603 {
604 struct fadt_descriptor_rev2 *fadt = NULL;
606 fadt = (struct fadt_descriptor_rev2*) __acpi_map_table(phys,size);
607 if(!fadt) {
608 printk(KERN_WARNING PREFIX "Unable to map FADT\n");
609 return 0;
610 }
612 #ifdef CONFIG_ACPI_INTERPRETER
613 /* initialize sci_int early for INT_SRC_OVR MADT parsing */
614 acpi_fadt.sci_int = fadt->sci_int;
615 #endif
617 #ifdef CONFIG_ACPI_BUS
618 /* initialize rev and apic_phys_dest_mode for x86_64 genapic */
619 acpi_fadt.revision = fadt->revision;
620 acpi_fadt.force_apic_physical_destination_mode = fadt->force_apic_physical_destination_mode;
621 #endif
623 #if defined(CONFIG_X86_PM_TIMER) && !defined(CONFIG_XEN)
624 /* detect the location of the ACPI PM Timer */
625 if (fadt->revision >= FADT2_REVISION_ID) {
626 /* FADT rev. 2 */
627 if (fadt->xpm_tmr_blk.address_space_id != ACPI_ADR_SPACE_SYSTEM_IO)
628 return 0;
630 pmtmr_ioport = fadt->xpm_tmr_blk.address;
631 } else {
632 /* FADT rev. 1 */
633 pmtmr_ioport = fadt->V1_pm_tmr_blk;
634 }
635 if (pmtmr_ioport)
636 printk(KERN_INFO PREFIX "PM-Timer IO Port: %#x\n", pmtmr_ioport);
637 #endif
638 return 0;
639 }
642 unsigned long __init
643 acpi_find_rsdp (void)
644 {
645 unsigned long rsdp_phys = 0;
647 if (efi_enabled) {
648 if (efi.acpi20)
649 return __pa(efi.acpi20);
650 else if (efi.acpi)
651 return __pa(efi.acpi);
652 }
653 /*
654 * Scan memory looking for the RSDP signature. First search EBDA (low
655 * memory) paragraphs and then search upper memory (E0000-FFFFF).
656 */
657 rsdp_phys = acpi_scan_rsdp (0, 0x400);
658 if (!rsdp_phys)
659 rsdp_phys = acpi_scan_rsdp (0xE0000, 0x20000);
661 return rsdp_phys;
662 }
664 #ifdef CONFIG_X86_LOCAL_APIC
665 /*
666 * Parse LAPIC entries in MADT
667 * returns 0 on success, < 0 on error
668 */
669 static int __init
670 acpi_parse_madt_lapic_entries(void)
671 {
672 int count;
674 /*
675 * Note that the LAPIC address is obtained from the MADT (32-bit value)
676 * and (optionally) overriden by a LAPIC_ADDR_OVR entry (64-bit value).
677 */
679 count = acpi_table_parse_madt(ACPI_MADT_LAPIC_ADDR_OVR, acpi_parse_lapic_addr_ovr, 0);
680 if (count < 0) {
681 printk(KERN_ERR PREFIX "Error parsing LAPIC address override entry\n");
682 return count;
683 }
685 mp_register_lapic_address(acpi_lapic_addr);
687 count = acpi_table_parse_madt(ACPI_MADT_LAPIC, acpi_parse_lapic,
688 MAX_APICS);
689 if (!count) {
690 printk(KERN_ERR PREFIX "No LAPIC entries present\n");
691 /* TBD: Cleanup to allow fallback to MPS */
692 return -ENODEV;
693 }
694 else if (count < 0) {
695 printk(KERN_ERR PREFIX "Error parsing LAPIC entry\n");
696 /* TBD: Cleanup to allow fallback to MPS */
697 return count;
698 }
700 count = acpi_table_parse_madt(ACPI_MADT_LAPIC_NMI, acpi_parse_lapic_nmi, 0);
701 if (count < 0) {
702 printk(KERN_ERR PREFIX "Error parsing LAPIC NMI entry\n");
703 /* TBD: Cleanup to allow fallback to MPS */
704 return count;
705 }
706 return 0;
707 }
708 #endif /* CONFIG_X86_LOCAL_APIC */
710 #if defined(CONFIG_X86_IO_APIC) && defined(CONFIG_ACPI_INTERPRETER)
711 /*
712 * Parse IOAPIC related entries in MADT
713 * returns 0 on success, < 0 on error
714 */
715 static int __init
716 acpi_parse_madt_ioapic_entries(void)
717 {
718 int count;
720 /*
721 * ACPI interpreter is required to complete interrupt setup,
722 * so if it is off, don't enumerate the io-apics with ACPI.
723 * If MPS is present, it will handle them,
724 * otherwise the system will stay in PIC mode
725 */
726 if (acpi_disabled || acpi_noirq) {
727 return -ENODEV;
728 }
730 /*
731 * if "noapic" boot option, don't look for IO-APICs
732 */
733 if (skip_ioapic_setup) {
734 printk(KERN_INFO PREFIX "Skipping IOAPIC probe "
735 "due to 'noapic' option.\n");
736 return -ENODEV;
737 }
739 count = acpi_table_parse_madt(ACPI_MADT_IOAPIC, acpi_parse_ioapic, MAX_IO_APICS);
740 if (!count) {
741 printk(KERN_ERR PREFIX "No IOAPIC entries present\n");
742 return -ENODEV;
743 }
744 else if (count < 0) {
745 printk(KERN_ERR PREFIX "Error parsing IOAPIC entry\n");
746 return count;
747 }
749 count = acpi_table_parse_madt(ACPI_MADT_INT_SRC_OVR, acpi_parse_int_src_ovr, NR_IRQ_VECTORS);
750 if (count < 0) {
751 printk(KERN_ERR PREFIX "Error parsing interrupt source overrides entry\n");
752 /* TBD: Cleanup to allow fallback to MPS */
753 return count;
754 }
756 /*
757 * If BIOS did not supply an INT_SRC_OVR for the SCI
758 * pretend we got one so we can set the SCI flags.
759 */
760 if (!acpi_sci_override_gsi)
761 acpi_sci_ioapic_setup(acpi_fadt.sci_int, 0, 0);
763 /* Fill in identity legacy mapings where no override */
764 mp_config_acpi_legacy_irqs();
766 count = acpi_table_parse_madt(ACPI_MADT_NMI_SRC, acpi_parse_nmi_src, NR_IRQ_VECTORS);
767 if (count < 0) {
768 printk(KERN_ERR PREFIX "Error parsing NMI SRC entry\n");
769 /* TBD: Cleanup to allow fallback to MPS */
770 return count;
771 }
773 return 0;
774 }
775 #else
776 static inline int acpi_parse_madt_ioapic_entries(void)
777 {
778 return -1;
779 }
780 #endif /* !(CONFIG_X86_IO_APIC && CONFIG_ACPI_INTERPRETER) */
783 static void __init
784 acpi_process_madt(void)
785 {
786 #ifdef CONFIG_X86_LOCAL_APIC
787 int count, error;
789 count = acpi_table_parse(ACPI_APIC, acpi_parse_madt);
790 if (count >= 1) {
792 /*
793 * Parse MADT LAPIC entries
794 */
795 error = acpi_parse_madt_lapic_entries();
796 if (!error) {
797 acpi_lapic = 1;
799 /*
800 * Parse MADT IO-APIC entries
801 */
802 error = acpi_parse_madt_ioapic_entries();
803 if (!error) {
804 acpi_irq_model = ACPI_IRQ_MODEL_IOAPIC;
805 acpi_irq_balance_set(NULL);
806 acpi_ioapic = 1;
808 smp_found_config = 1;
809 clustered_apic_check();
810 }
811 }
812 if (error == -EINVAL) {
813 /*
814 * Dell Precision Workstation 410, 610 come here.
815 */
816 printk(KERN_ERR PREFIX "Invalid BIOS MADT, disabling ACPI\n");
817 disable_acpi();
818 }
819 }
820 #endif
821 return;
822 }
824 /*
825 * acpi_boot_table_init() and acpi_boot_init()
826 * called from setup_arch(), always.
827 * 1. checksums all tables
828 * 2. enumerates lapics
829 * 3. enumerates io-apics
830 *
831 * acpi_table_init() is separate to allow reading SRAT without
832 * other side effects.
833 *
834 * side effects of acpi_boot_init:
835 * acpi_lapic = 1 if LAPIC found
836 * acpi_ioapic = 1 if IOAPIC found
837 * if (acpi_lapic && acpi_ioapic) smp_found_config = 1;
838 * if acpi_blacklisted() acpi_disabled = 1;
839 * acpi_irq_model=...
840 * ...
841 *
842 * return value: (currently ignored)
843 * 0: success
844 * !0: failure
845 */
847 int __init
848 acpi_boot_table_init(void)
849 {
850 int error;
852 /*
853 * If acpi_disabled, bail out
854 * One exception: acpi=ht continues far enough to enumerate LAPICs
855 */
856 if (acpi_disabled && !acpi_ht)
857 return 1;
859 /*
860 * Initialize the ACPI boot-time table parser.
861 */
862 error = acpi_table_init();
863 if (error) {
864 disable_acpi();
865 return error;
866 }
868 #ifdef __i386__
869 check_acpi_pci();
870 #endif
872 acpi_table_parse(ACPI_BOOT, acpi_parse_sbf);
874 /*
875 * blacklist may disable ACPI entirely
876 */
877 error = acpi_blacklisted();
878 if (error) {
879 extern int acpi_force;
881 if (acpi_force) {
882 printk(KERN_WARNING PREFIX "acpi=force override\n");
883 } else {
884 printk(KERN_WARNING PREFIX "Disabling ACPI support\n");
885 disable_acpi();
886 return error;
887 }
888 }
890 return 0;
891 }
894 int __init acpi_boot_init(void)
895 {
896 /*
897 * If acpi_disabled, bail out
898 * One exception: acpi=ht continues far enough to enumerate LAPICs
899 */
900 if (acpi_disabled && !acpi_ht)
901 return 1;
903 acpi_table_parse(ACPI_BOOT, acpi_parse_sbf);
905 /*
906 * set sci_int and PM timer address
907 */
908 acpi_table_parse(ACPI_FADT, acpi_parse_fadt);
910 /*
911 * Process the Multiple APIC Description Table (MADT), if present
912 */
913 acpi_process_madt();
915 acpi_table_parse(ACPI_HPET, acpi_parse_hpet);
916 acpi_table_parse(ACPI_MCFG, acpi_parse_mcfg);
918 return 0;
919 }