ia64/xen-unstable

view linux-2.6.11-xen-sparse/arch/xen/i386/kernel/acpi/boot.c @ 4769:d37452f3e8f0

bitkeeper revision 1.1389.7.4 (42792d1dpWcMoYEkCeHotKk4mVnZfg)

boot.c:
Fix assignment warning.
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
author cl349@firebug.cl.cam.ac.uk[cl349]
date Wed May 04 20:14:21 2005 +0000 (2005-05-04)
parents 3fd85cfa1932
children 86c325c8937a
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 #ifdef CONFIG_XEN
110 char *__acpi_map_table(unsigned long phys_addr, unsigned long size)
111 {
112 unsigned int i,j;
114 j = PAGE_ALIGN(size) >> PAGE_SHIFT;
115 for (i = 0; (i < FIX_ACPI_PAGES) && j ; i++, j--) {
116 __set_fixmap_ma(FIX_ACPI_END - i,
117 (phys_addr & PAGE_MASK) + (i << PAGE_SHIFT),
118 PAGE_KERNEL);
119 }
121 return (char *) __fix_to_virt(FIX_ACPI_END) + (phys_addr & ~PAGE_MASK);
122 }
124 #else
125 #ifdef CONFIG_X86_64
127 /* rely on all ACPI tables being in the direct mapping */
128 char *__acpi_map_table(unsigned long phys_addr, unsigned long size)
129 {
130 if (!phys_addr || !size)
131 return NULL;
133 if (phys_addr < (end_pfn_map << PAGE_SHIFT))
134 return __va(phys_addr);
136 return NULL;
137 }
139 #else
141 /*
142 * Temporarily use the virtual area starting from FIX_IO_APIC_BASE_END,
143 * to map the target physical address. The problem is that set_fixmap()
144 * provides a single page, and it is possible that the page is not
145 * sufficient.
146 * By using this area, we can map up to MAX_IO_APICS pages temporarily,
147 * i.e. until the next __va_range() call.
148 *
149 * Important Safety Note: The fixed I/O APIC page numbers are *subtracted*
150 * from the fixed base. That's why we start at FIX_IO_APIC_BASE_END and
151 * count idx down while incrementing the phys address.
152 */
153 char *__acpi_map_table(unsigned long phys, unsigned long size)
154 {
155 unsigned long base, offset, mapped_size;
156 int idx;
158 if (phys + size < 8*1024*1024)
159 return __va(phys);
161 offset = phys & (PAGE_SIZE - 1);
162 mapped_size = PAGE_SIZE - offset;
163 set_fixmap(FIX_ACPI_END, phys);
164 base = fix_to_virt(FIX_ACPI_END);
166 /*
167 * Most cases can be covered by the below.
168 */
169 idx = FIX_ACPI_END;
170 while (mapped_size < size) {
171 if (--idx < FIX_ACPI_BEGIN)
172 return NULL; /* cannot handle this */
173 phys += PAGE_SIZE;
174 set_fixmap(idx, phys);
175 mapped_size += PAGE_SIZE;
176 }
178 return ((unsigned char *) base + offset);
179 }
180 #endif
181 #endif /* CONFIG_XEN */
183 #ifdef CONFIG_PCI_MMCONFIG
184 static int __init acpi_parse_mcfg(unsigned long phys_addr, unsigned long size)
185 {
186 struct acpi_table_mcfg *mcfg;
188 if (!phys_addr || !size)
189 return -EINVAL;
191 mcfg = (struct acpi_table_mcfg *) __acpi_map_table(phys_addr, size);
192 if (!mcfg) {
193 printk(KERN_WARNING PREFIX "Unable to map MCFG\n");
194 return -ENODEV;
195 }
197 if (mcfg->base_reserved) {
198 printk(KERN_ERR PREFIX "MMCONFIG not in low 4GB of memory\n");
199 return -ENODEV;
200 }
202 pci_mmcfg_base_addr = mcfg->base_address;
204 return 0;
205 }
206 #else
207 #define acpi_parse_mcfg NULL
208 #endif /* !CONFIG_PCI_MMCONFIG */
210 #ifdef CONFIG_X86_LOCAL_APIC
211 static int __init
212 acpi_parse_madt (
213 unsigned long phys_addr,
214 unsigned long size)
215 {
216 struct acpi_table_madt *madt = NULL;
218 if (!phys_addr || !size)
219 return -EINVAL;
221 madt = (struct acpi_table_madt *) __acpi_map_table(phys_addr, size);
222 if (!madt) {
223 printk(KERN_WARNING PREFIX "Unable to map MADT\n");
224 return -ENODEV;
225 }
227 if (madt->lapic_address) {
228 acpi_lapic_addr = (u64) madt->lapic_address;
230 printk(KERN_DEBUG PREFIX "Local APIC address 0x%08x\n",
231 madt->lapic_address);
232 }
234 acpi_madt_oem_check(madt->header.oem_id, madt->header.oem_table_id);
236 return 0;
237 }
240 static int __init
241 acpi_parse_lapic (
242 acpi_table_entry_header *header, const unsigned long end)
243 {
244 struct acpi_table_lapic *processor = NULL;
246 processor = (struct acpi_table_lapic*) header;
248 if (BAD_MADT_ENTRY(processor, end))
249 return -EINVAL;
251 acpi_table_print_madt_entry(header);
253 /* no utility in registering a disabled processor */
254 if (processor->flags.enabled == 0)
255 return 0;
257 x86_acpiid_to_apicid[processor->acpi_id] = processor->id;
259 mp_register_lapic (
260 processor->id, /* APIC ID */
261 processor->flags.enabled); /* Enabled? */
263 return 0;
264 }
266 static int __init
267 acpi_parse_lapic_addr_ovr (
268 acpi_table_entry_header *header, const unsigned long end)
269 {
270 struct acpi_table_lapic_addr_ovr *lapic_addr_ovr = NULL;
272 lapic_addr_ovr = (struct acpi_table_lapic_addr_ovr*) header;
274 if (BAD_MADT_ENTRY(lapic_addr_ovr, end))
275 return -EINVAL;
277 acpi_lapic_addr = lapic_addr_ovr->address;
279 return 0;
280 }
282 static int __init
283 acpi_parse_lapic_nmi (
284 acpi_table_entry_header *header, const unsigned long end)
285 {
286 struct acpi_table_lapic_nmi *lapic_nmi = NULL;
288 lapic_nmi = (struct acpi_table_lapic_nmi*) header;
290 if (BAD_MADT_ENTRY(lapic_nmi, end))
291 return -EINVAL;
293 acpi_table_print_madt_entry(header);
295 if (lapic_nmi->lint != 1)
296 printk(KERN_WARNING PREFIX "NMI not connected to LINT 1!\n");
298 return 0;
299 }
302 #endif /*CONFIG_X86_LOCAL_APIC*/
304 #if defined(CONFIG_X86_IO_APIC) && defined(CONFIG_ACPI_INTERPRETER)
306 static int __init
307 acpi_parse_ioapic (
308 acpi_table_entry_header *header, const unsigned long end)
309 {
310 struct acpi_table_ioapic *ioapic = NULL;
312 ioapic = (struct acpi_table_ioapic*) header;
314 if (BAD_MADT_ENTRY(ioapic, end))
315 return -EINVAL;
317 acpi_table_print_madt_entry(header);
319 mp_register_ioapic (
320 ioapic->id,
321 ioapic->address,
322 ioapic->global_irq_base);
324 return 0;
325 }
327 /*
328 * Parse Interrupt Source Override for the ACPI SCI
329 */
330 static void
331 acpi_sci_ioapic_setup(u32 gsi, u16 polarity, u16 trigger)
332 {
333 if (trigger == 0) /* compatible SCI trigger is level */
334 trigger = 3;
336 if (polarity == 0) /* compatible SCI polarity is low */
337 polarity = 3;
339 /* Command-line over-ride via acpi_sci= */
340 if (acpi_sci_flags.trigger)
341 trigger = acpi_sci_flags.trigger;
343 if (acpi_sci_flags.polarity)
344 polarity = acpi_sci_flags.polarity;
346 /*
347 * mp_config_acpi_legacy_irqs() already setup IRQs < 16
348 * If GSI is < 16, this will update its flags,
349 * else it will create a new mp_irqs[] entry.
350 */
351 mp_override_legacy_irq(gsi, polarity, trigger, gsi);
353 /*
354 * stash over-ride to indicate we've been here
355 * and for later update of acpi_fadt
356 */
357 acpi_sci_override_gsi = gsi;
358 return;
359 }
361 static int __init
362 acpi_parse_int_src_ovr (
363 acpi_table_entry_header *header, const unsigned long end)
364 {
365 struct acpi_table_int_src_ovr *intsrc = NULL;
367 intsrc = (struct acpi_table_int_src_ovr*) header;
369 if (BAD_MADT_ENTRY(intsrc, end))
370 return -EINVAL;
372 acpi_table_print_madt_entry(header);
374 if (intsrc->bus_irq == acpi_fadt.sci_int) {
375 acpi_sci_ioapic_setup(intsrc->global_irq,
376 intsrc->flags.polarity, intsrc->flags.trigger);
377 return 0;
378 }
380 if (acpi_skip_timer_override &&
381 intsrc->bus_irq == 0 && intsrc->global_irq == 2) {
382 printk(PREFIX "BIOS IRQ0 pin2 override ignored.\n");
383 return 0;
384 }
386 mp_override_legacy_irq (
387 intsrc->bus_irq,
388 intsrc->flags.polarity,
389 intsrc->flags.trigger,
390 intsrc->global_irq);
392 return 0;
393 }
396 static int __init
397 acpi_parse_nmi_src (
398 acpi_table_entry_header *header, const unsigned long end)
399 {
400 struct acpi_table_nmi_src *nmi_src = NULL;
402 nmi_src = (struct acpi_table_nmi_src*) header;
404 if (BAD_MADT_ENTRY(nmi_src, end))
405 return -EINVAL;
407 acpi_table_print_madt_entry(header);
409 /* TBD: Support nimsrc entries? */
411 return 0;
412 }
414 #endif /* CONFIG_X86_IO_APIC */
416 #ifdef CONFIG_ACPI_BUS
418 /*
419 * acpi_pic_sci_set_trigger()
420 *
421 * use ELCR to set PIC-mode trigger type for SCI
422 *
423 * If a PIC-mode SCI is not recognized or gives spurious IRQ7's
424 * it may require Edge Trigger -- use "acpi_sci=edge"
425 *
426 * Port 0x4d0-4d1 are ECLR1 and ECLR2, the Edge/Level Control Registers
427 * for the 8259 PIC. bit[n] = 1 means irq[n] is Level, otherwise Edge.
428 * ECLR1 is IRQ's 0-7 (IRQ 0, 1, 2 must be 0)
429 * ECLR2 is IRQ's 8-15 (IRQ 8, 13 must be 0)
430 */
432 void __init
433 acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger)
434 {
435 unsigned int mask = 1 << irq;
436 unsigned int old, new;
438 /* Real old ELCR mask */
439 old = inb(0x4d0) | (inb(0x4d1) << 8);
441 /*
442 * If we use ACPI to set PCI irq's, then we should clear ELCR
443 * since we will set it correctly as we enable the PCI irq
444 * routing.
445 */
446 new = acpi_noirq ? old : 0;
448 /*
449 * Update SCI information in the ELCR, it isn't in the PCI
450 * routing tables..
451 */
452 switch (trigger) {
453 case 1: /* Edge - clear */
454 new &= ~mask;
455 break;
456 case 3: /* Level - set */
457 new |= mask;
458 break;
459 }
461 if (old == new)
462 return;
464 printk(PREFIX "setting ELCR to %04x (from %04x)\n", new, old);
465 outb(new, 0x4d0);
466 outb(new >> 8, 0x4d1);
467 }
470 #endif /* CONFIG_ACPI_BUS */
472 int acpi_gsi_to_irq(u32 gsi, unsigned int *irq)
473 {
474 #ifdef CONFIG_X86_IO_APIC
475 if (use_pci_vector() && !platform_legacy_irq(gsi))
476 *irq = IO_APIC_VECTOR(gsi);
477 else
478 #endif
479 *irq = gsi;
480 return 0;
481 }
483 unsigned int acpi_register_gsi(u32 gsi, int edge_level, int active_high_low)
484 {
485 unsigned int irq;
486 unsigned int plat_gsi = gsi;
488 #ifdef CONFIG_X86_IO_APIC
489 if (acpi_irq_model == ACPI_IRQ_MODEL_IOAPIC) {
490 plat_gsi = mp_register_gsi(gsi, edge_level, active_high_low);
491 }
492 #endif
493 acpi_gsi_to_irq(plat_gsi, &irq);
494 return irq;
495 }
496 EXPORT_SYMBOL(acpi_register_gsi);
498 /*
499 * ACPI based hotplug support for CPU
500 */
501 #ifdef CONFIG_ACPI_HOTPLUG_CPU
502 int
503 acpi_map_lsapic(acpi_handle handle, int *pcpu)
504 {
505 /* TBD */
506 return -EINVAL;
507 }
508 EXPORT_SYMBOL(acpi_map_lsapic);
511 int
512 acpi_unmap_lsapic(int cpu)
513 {
514 /* TBD */
515 return -EINVAL;
516 }
517 EXPORT_SYMBOL(acpi_unmap_lsapic);
518 #endif /* CONFIG_ACPI_HOTPLUG_CPU */
520 static unsigned long __init
521 acpi_scan_rsdp (
522 unsigned long start,
523 unsigned long length)
524 {
525 unsigned long offset = 0;
526 unsigned long sig_len = sizeof("RSD PTR ") - 1;
527 unsigned long vstart = (unsigned long)isa_bus_to_virt(start);
529 /*
530 * Scan all 16-byte boundaries of the physical memory region for the
531 * RSDP signature.
532 */
533 for (offset = 0; offset < length; offset += 16) {
534 if (strncmp((char *) (vstart + offset), "RSD PTR ", sig_len))
535 continue;
536 return (start + offset);
537 }
539 return 0;
540 }
542 static int __init acpi_parse_sbf(unsigned long phys_addr, unsigned long size)
543 {
544 struct acpi_table_sbf *sb;
546 if (!phys_addr || !size)
547 return -EINVAL;
549 sb = (struct acpi_table_sbf *) __acpi_map_table(phys_addr, size);
550 if (!sb) {
551 printk(KERN_WARNING PREFIX "Unable to map SBF\n");
552 return -ENODEV;
553 }
555 sbf_port = sb->sbf_cmos; /* Save CMOS port */
557 return 0;
558 }
561 #ifdef CONFIG_HPET_TIMER
563 static int __init acpi_parse_hpet(unsigned long phys, unsigned long size)
564 {
565 struct acpi_table_hpet *hpet_tbl;
567 if (!phys || !size)
568 return -EINVAL;
570 hpet_tbl = (struct acpi_table_hpet *) __acpi_map_table(phys, size);
571 if (!hpet_tbl) {
572 printk(KERN_WARNING PREFIX "Unable to map HPET\n");
573 return -ENODEV;
574 }
576 if (hpet_tbl->addr.space_id != ACPI_SPACE_MEM) {
577 printk(KERN_WARNING PREFIX "HPET timers must be located in "
578 "memory.\n");
579 return -1;
580 }
582 #ifdef CONFIG_X86_64
583 vxtime.hpet_address = hpet_tbl->addr.addrl |
584 ((long) hpet_tbl->addr.addrh << 32);
586 printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n",
587 hpet_tbl->id, vxtime.hpet_address);
588 #else /* X86 */
589 {
590 extern unsigned long hpet_address;
592 hpet_address = hpet_tbl->addr.addrl;
593 printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n",
594 hpet_tbl->id, hpet_address);
595 }
596 #endif /* X86 */
598 return 0;
599 }
600 #else
601 #define acpi_parse_hpet NULL
602 #endif
604 #ifdef CONFIG_X86_PM_TIMER
605 extern u32 pmtmr_ioport;
606 #endif
608 static int __init acpi_parse_fadt(unsigned long phys, unsigned long size)
609 {
610 struct fadt_descriptor_rev2 *fadt = NULL;
612 fadt = (struct fadt_descriptor_rev2*) __acpi_map_table(phys,size);
613 if(!fadt) {
614 printk(KERN_WARNING PREFIX "Unable to map FADT\n");
615 return 0;
616 }
618 #ifdef CONFIG_ACPI_INTERPRETER
619 /* initialize sci_int early for INT_SRC_OVR MADT parsing */
620 acpi_fadt.sci_int = fadt->sci_int;
621 #endif
623 #ifdef CONFIG_X86_PM_TIMER
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 __set_fixmap_ma(FIX_ACPI_RSDP_PAGE, rsdp_phys, PAGE_KERNEL);
663 return rsdp_phys;
664 }
666 #ifdef CONFIG_X86_LOCAL_APIC
667 /*
668 * Parse LAPIC entries in MADT
669 * returns 0 on success, < 0 on error
670 */
671 static int __init
672 acpi_parse_madt_lapic_entries(void)
673 {
674 int count;
676 #ifdef CONFIG_XEN
677 return 0;
678 #endif
680 /*
681 * Note that the LAPIC address is obtained from the MADT (32-bit value)
682 * and (optionally) overriden by a LAPIC_ADDR_OVR entry (64-bit value).
683 */
685 count = acpi_table_parse_madt(ACPI_MADT_LAPIC_ADDR_OVR, acpi_parse_lapic_addr_ovr, 0);
686 if (count < 0) {
687 printk(KERN_ERR PREFIX "Error parsing LAPIC address override entry\n");
688 return count;
689 }
691 mp_register_lapic_address(acpi_lapic_addr);
693 count = acpi_table_parse_madt(ACPI_MADT_LAPIC, acpi_parse_lapic,
694 MAX_APICS);
695 if (!count) {
696 printk(KERN_ERR PREFIX "No LAPIC entries present\n");
697 /* TBD: Cleanup to allow fallback to MPS */
698 return -ENODEV;
699 }
700 else if (count < 0) {
701 printk(KERN_ERR PREFIX "Error parsing LAPIC entry\n");
702 /* TBD: Cleanup to allow fallback to MPS */
703 return count;
704 }
706 count = acpi_table_parse_madt(ACPI_MADT_LAPIC_NMI, acpi_parse_lapic_nmi, 0);
707 if (count < 0) {
708 printk(KERN_ERR PREFIX "Error parsing LAPIC NMI entry\n");
709 /* TBD: Cleanup to allow fallback to MPS */
710 return count;
711 }
712 return 0;
713 }
714 #endif /* CONFIG_X86_LOCAL_APIC */
716 #if defined(CONFIG_X86_IO_APIC) && defined(CONFIG_ACPI_INTERPRETER)
717 /*
718 * Parse IOAPIC related entries in MADT
719 * returns 0 on success, < 0 on error
720 */
721 static int __init
722 acpi_parse_madt_ioapic_entries(void)
723 {
724 int count;
726 /*
727 * ACPI interpreter is required to complete interrupt setup,
728 * so if it is off, don't enumerate the io-apics with ACPI.
729 * If MPS is present, it will handle them,
730 * otherwise the system will stay in PIC mode
731 */
732 if (acpi_disabled || acpi_noirq) {
733 return -ENODEV;
734 }
736 /*
737 * if "noapic" boot option, don't look for IO-APICs
738 */
739 if (skip_ioapic_setup) {
740 printk(KERN_INFO PREFIX "Skipping IOAPIC probe "
741 "due to 'noapic' option.\n");
742 return -ENODEV;
743 }
745 count = acpi_table_parse_madt(ACPI_MADT_IOAPIC, acpi_parse_ioapic, MAX_IO_APICS);
746 if (!count) {
747 printk(KERN_ERR PREFIX "No IOAPIC entries present\n");
748 return -ENODEV;
749 }
750 else if (count < 0) {
751 printk(KERN_ERR PREFIX "Error parsing IOAPIC entry\n");
752 return count;
753 }
755 count = acpi_table_parse_madt(ACPI_MADT_INT_SRC_OVR, acpi_parse_int_src_ovr, NR_IRQ_VECTORS);
756 if (count < 0) {
757 printk(KERN_ERR PREFIX "Error parsing interrupt source overrides entry\n");
758 /* TBD: Cleanup to allow fallback to MPS */
759 return count;
760 }
762 /*
763 * If BIOS did not supply an INT_SRC_OVR for the SCI
764 * pretend we got one so we can set the SCI flags.
765 */
766 if (!acpi_sci_override_gsi)
767 acpi_sci_ioapic_setup(acpi_fadt.sci_int, 0, 0);
769 /* Fill in identity legacy mapings where no override */
770 mp_config_acpi_legacy_irqs();
772 count = acpi_table_parse_madt(ACPI_MADT_NMI_SRC, acpi_parse_nmi_src, NR_IRQ_VECTORS);
773 if (count < 0) {
774 printk(KERN_ERR PREFIX "Error parsing NMI SRC entry\n");
775 /* TBD: Cleanup to allow fallback to MPS */
776 return count;
777 }
779 return 0;
780 }
781 #else
782 static inline int acpi_parse_madt_ioapic_entries(void)
783 {
784 return -1;
785 }
786 #endif /* !(CONFIG_X86_IO_APIC && CONFIG_ACPI_INTERPRETER) */
789 static void __init
790 acpi_process_madt(void)
791 {
792 #ifdef CONFIG_X86_LOCAL_APIC
793 int count, error;
795 count = acpi_table_parse(ACPI_APIC, acpi_parse_madt);
796 if (count >= 1) {
798 /*
799 * Parse MADT LAPIC entries
800 */
801 error = acpi_parse_madt_lapic_entries();
802 if (!error) {
803 acpi_lapic = 1;
805 /*
806 * Parse MADT IO-APIC entries
807 */
808 error = acpi_parse_madt_ioapic_entries();
809 if (!error) {
810 acpi_irq_model = ACPI_IRQ_MODEL_IOAPIC;
811 acpi_irq_balance_set(NULL);
812 acpi_ioapic = 1;
814 smp_found_config = 1;
815 clustered_apic_check();
816 }
817 }
818 if (error == -EINVAL) {
819 /*
820 * Dell Precision Workstation 410, 610 come here.
821 */
822 printk(KERN_ERR PREFIX "Invalid BIOS MADT, disabling ACPI\n");
823 disable_acpi();
824 }
825 }
826 #endif
827 return;
828 }
830 /*
831 * acpi_boot_table_init() and acpi_boot_init()
832 * called from setup_arch(), always.
833 * 1. checksums all tables
834 * 2. enumerates lapics
835 * 3. enumerates io-apics
836 *
837 * acpi_table_init() is separate to allow reading SRAT without
838 * other side effects.
839 *
840 * side effects of acpi_boot_init:
841 * acpi_lapic = 1 if LAPIC found
842 * acpi_ioapic = 1 if IOAPIC found
843 * if (acpi_lapic && acpi_ioapic) smp_found_config = 1;
844 * if acpi_blacklisted() acpi_disabled = 1;
845 * acpi_irq_model=...
846 * ...
847 *
848 * return value: (currently ignored)
849 * 0: success
850 * !0: failure
851 */
853 int __init
854 acpi_boot_table_init(void)
855 {
856 int error;
858 /*
859 * If acpi_disabled, bail out
860 * One exception: acpi=ht continues far enough to enumerate LAPICs
861 */
862 if (acpi_disabled && !acpi_ht)
863 return 1;
865 /*
866 * Initialize the ACPI boot-time table parser.
867 */
868 error = acpi_table_init();
869 if (error) {
870 disable_acpi();
871 return error;
872 }
874 #ifdef __i386__
875 #ifndef CONFIG_XEN
876 check_acpi_pci();
877 #endif
878 #endif
880 acpi_table_parse(ACPI_BOOT, acpi_parse_sbf);
882 /*
883 * blacklist may disable ACPI entirely
884 */
885 error = acpi_blacklisted();
886 if (error) {
887 extern int acpi_force;
889 if (acpi_force) {
890 printk(KERN_WARNING PREFIX "acpi=force override\n");
891 } else {
892 printk(KERN_WARNING PREFIX "Disabling ACPI support\n");
893 disable_acpi();
894 return error;
895 }
896 }
898 return 0;
899 }
902 int __init acpi_boot_init(void)
903 {
904 /*
905 * If acpi_disabled, bail out
906 * One exception: acpi=ht continues far enough to enumerate LAPICs
907 */
908 if (acpi_disabled && !acpi_ht)
909 return 1;
911 acpi_table_parse(ACPI_BOOT, acpi_parse_sbf);
913 /*
914 * set sci_int and PM timer address
915 */
916 acpi_table_parse(ACPI_FADT, acpi_parse_fadt);
918 /*
919 * Process the Multiple APIC Description Table (MADT), if present
920 */
921 acpi_process_madt();
923 acpi_table_parse(ACPI_HPET, acpi_parse_hpet);
924 acpi_table_parse(ACPI_MCFG, acpi_parse_mcfg);
926 return 0;
927 }