2 * boot.c - Architecture-Specific Low-Level ACPI Boot Support
4 * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
5 * Copyright (C) 2001 Jun Nakajima <jun.nakajima@intel.com>
7 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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.
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.
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
23 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
26 #include <linux/init.h>
27 #include <linux/acpi.h>
28 #include <linux/acpi_pmtmr.h>
29 #include <linux/efi.h>
30 #include <linux/cpumask.h>
31 #include <linux/module.h>
32 #include <linux/dmi.h>
33 #include <linux/irq.h>
34 #include <linux/bootmem.h>
35 #include <linux/ioport.h>
37 #include <asm/pgtable.h>
38 #include <asm/io_apic.h>
41 #include <asm/mpspec.h>
43 static int __initdata acpi_force = 0;
46 int acpi_disabled = 0;
48 int acpi_disabled = 1;
50 EXPORT_SYMBOL(acpi_disabled);
54 #include <asm/proto.h>
56 static inline int acpi_madt_oem_check(char *oem_id, char *oem_table_id) { return 0; }
61 #ifdef CONFIG_X86_LOCAL_APIC
62 #include <mach_apic.h>
63 #include <mach_mpparse.h>
64 #endif /* CONFIG_X86_LOCAL_APIC */
68 #define BAD_MADT_ENTRY(entry, end) ( \
69 (!entry) || (unsigned long)entry + sizeof(*entry) > end || \
70 ((struct acpi_subtable_header *)entry)->length < sizeof(*entry))
72 #define PREFIX "ACPI: "
74 int acpi_noirq; /* skip ACPI IRQ initialization */
75 int acpi_pci_disabled __initdata; /* skip ACPI PCI scan and IRQ initialization */
76 int acpi_ht __initdata = 1; /* enable HT */
81 EXPORT_SYMBOL(acpi_strict);
83 u8 acpi_sci_flags __initdata;
84 int acpi_sci_override_gsi __initdata;
85 int acpi_skip_timer_override __initdata;
86 int acpi_use_timer_override __initdata;
88 #if defined(CONFIG_X86_LOCAL_APIC) && !defined(CONFIG_XEN)
89 static u64 acpi_lapic_addr __initdata = APIC_DEFAULT_PHYS_BASE;
92 #ifndef __HAVE_ARCH_CMPXCHG
93 #warning ACPI uses CMPXCHG, i486 and later hardware
96 /* --------------------------------------------------------------------------
97 Boot-time Configuration
98 -------------------------------------------------------------------------- */
101 * The default interrupt routing model is PIC (8259). This gets
102 * overriden if IOAPICs are enumerated (below).
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)
111 if (!phys_addr || !size)
114 if (phys_addr+size <= (end_pfn_map << PAGE_SHIFT) + PAGE_SIZE)
115 return __va(phys_addr);
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
127 * By using this area, we can map up to MAX_IO_APICS pages temporarily,
128 * i.e. until the next __va_range() call.
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.
134 char *__acpi_map_table(unsigned long phys, unsigned long size)
136 unsigned long base, offset, mapped_size;
140 if (phys + size < 8 * 1024 * 1024)
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);
150 * Most cases can be covered by the below.
153 while (mapped_size < size) {
154 if (--idx < FIX_ACPI_BEGIN)
155 return NULL; /* cannot handle this */
157 set_fixmap(idx, phys);
158 mapped_size += PAGE_SIZE;
161 return ((unsigned char *)base + offset);
165 #ifdef CONFIG_PCI_MMCONFIG
166 /* The physical address of the MMCONFIG aperture. Set from ACPI tables. */
167 struct acpi_mcfg_allocation *pci_mmcfg_config;
168 int pci_mmcfg_config_num;
170 int __init acpi_parse_mcfg(struct acpi_table_header *header)
172 struct acpi_table_mcfg *mcfg;
179 mcfg = (struct acpi_table_mcfg *)header;
181 /* how many config structures do we have */
182 pci_mmcfg_config_num = 0;
183 i = header->length - sizeof(struct acpi_table_mcfg);
184 while (i >= sizeof(struct acpi_mcfg_allocation)) {
185 ++pci_mmcfg_config_num;
186 i -= sizeof(struct acpi_mcfg_allocation);
188 if (pci_mmcfg_config_num == 0) {
189 printk(KERN_ERR PREFIX "MMCONFIG has no entries\n");
193 config_size = pci_mmcfg_config_num * sizeof(*pci_mmcfg_config);
194 pci_mmcfg_config = kmalloc(config_size, GFP_KERNEL);
195 if (!pci_mmcfg_config) {
196 printk(KERN_WARNING PREFIX
197 "No memory for MCFG config tables\n");
201 memcpy(pci_mmcfg_config, &mcfg[1], config_size);
202 for (i = 0; i < pci_mmcfg_config_num; ++i) {
203 if (pci_mmcfg_config[i].address > 0xFFFFFFFF) {
204 printk(KERN_ERR PREFIX
205 "MMCONFIG not in low 4GB of memory\n");
206 kfree(pci_mmcfg_config);
207 pci_mmcfg_config_num = 0;
214 #endif /* CONFIG_PCI_MMCONFIG */
216 #ifdef CONFIG_X86_LOCAL_APIC
217 static int __init acpi_parse_madt(struct acpi_table_header *table)
219 struct acpi_table_madt *madt = NULL;
224 madt = (struct acpi_table_madt *)table;
226 printk(KERN_WARNING PREFIX "Unable to map MADT\n");
232 acpi_lapic_addr = (u64) madt->address;
234 printk(KERN_DEBUG PREFIX "Local APIC address 0x%08x\n",
239 acpi_madt_oem_check(madt->header.oem_id, madt->header.oem_table_id);
245 acpi_parse_lapic(struct acpi_subtable_header * header, const unsigned long end)
247 struct acpi_madt_local_apic *processor = NULL;
249 processor = (struct acpi_madt_local_apic *)header;
251 if (BAD_MADT_ENTRY(processor, end))
254 acpi_table_print_madt_entry(header);
257 * We need to register disabled CPU as well to permit
258 * counting disabled CPUs. This allows us to size
259 * cpus_possible_map more accurately, to permit
260 * to not preallocating memory for all NR_CPUS
261 * when we use CPU hotplug.
263 mp_register_lapic(processor->id, /* APIC ID */
264 processor->lapic_flags & ACPI_MADT_ENABLED); /* Enabled? */
270 acpi_parse_lapic_addr_ovr(struct acpi_subtable_header * header,
271 const unsigned long end)
274 struct acpi_madt_local_apic_override *lapic_addr_ovr = NULL;
276 lapic_addr_ovr = (struct acpi_madt_local_apic_override *)header;
278 if (BAD_MADT_ENTRY(lapic_addr_ovr, end))
281 acpi_lapic_addr = lapic_addr_ovr->address;
288 acpi_parse_lapic_nmi(struct acpi_subtable_header * header, const unsigned long end)
290 struct acpi_madt_local_apic_nmi *lapic_nmi = NULL;
292 lapic_nmi = (struct acpi_madt_local_apic_nmi *)header;
294 if (BAD_MADT_ENTRY(lapic_nmi, end))
297 acpi_table_print_madt_entry(header);
299 if (lapic_nmi->lint != 1)
300 printk(KERN_WARNING PREFIX "NMI not connected to LINT 1!\n");
305 #endif /*CONFIG_X86_LOCAL_APIC */
307 #ifdef CONFIG_X86_IO_APIC
310 acpi_parse_ioapic(struct acpi_subtable_header * header, const unsigned long end)
312 struct acpi_madt_io_apic *ioapic = NULL;
314 ioapic = (struct acpi_madt_io_apic *)header;
316 if (BAD_MADT_ENTRY(ioapic, end))
319 acpi_table_print_madt_entry(header);
321 mp_register_ioapic(ioapic->id,
322 ioapic->address, ioapic->global_irq_base);
328 * Parse Interrupt Source Override for the ACPI SCI
330 static void __init acpi_sci_ioapic_setup(u32 gsi, u16 polarity, u16 trigger)
332 if (trigger == 0) /* compatible SCI trigger is level */
335 if (polarity == 0) /* compatible SCI polarity is low */
338 /* Command-line over-ride via acpi_sci= */
339 if (acpi_sci_flags & ACPI_MADT_TRIGGER_MASK)
340 trigger = (acpi_sci_flags & ACPI_MADT_TRIGGER_MASK) >> 2;
342 if (acpi_sci_flags & ACPI_MADT_POLARITY_MASK)
343 polarity = acpi_sci_flags & ACPI_MADT_POLARITY_MASK;
346 * mp_config_acpi_legacy_irqs() already setup IRQs < 16
347 * If GSI is < 16, this will update its flags,
348 * else it will create a new mp_irqs[] entry.
350 mp_override_legacy_irq(gsi, polarity, trigger, gsi);
353 * stash over-ride to indicate we've been here
354 * and for later update of acpi_gbl_FADT
356 acpi_sci_override_gsi = gsi;
361 acpi_parse_int_src_ovr(struct acpi_subtable_header * header,
362 const unsigned long end)
364 struct acpi_madt_interrupt_override *intsrc = NULL;
366 intsrc = (struct acpi_madt_interrupt_override *)header;
368 if (BAD_MADT_ENTRY(intsrc, end))
371 acpi_table_print_madt_entry(header);
373 if (intsrc->source_irq == acpi_gbl_FADT.sci_interrupt) {
374 acpi_sci_ioapic_setup(intsrc->global_irq,
375 intsrc->inti_flags & ACPI_MADT_POLARITY_MASK,
376 (intsrc->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2);
380 if (acpi_skip_timer_override &&
381 intsrc->source_irq == 0 && intsrc->global_irq == 2) {
382 printk(PREFIX "BIOS IRQ0 pin2 override ignored.\n");
386 mp_override_legacy_irq(intsrc->source_irq,
387 intsrc->inti_flags & ACPI_MADT_POLARITY_MASK,
388 (intsrc->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2,
395 acpi_parse_nmi_src(struct acpi_subtable_header * header, const unsigned long end)
397 struct acpi_madt_nmi_source *nmi_src = NULL;
399 nmi_src = (struct acpi_madt_nmi_source *)header;
401 if (BAD_MADT_ENTRY(nmi_src, end))
404 acpi_table_print_madt_entry(header);
406 /* TBD: Support nimsrc entries? */
411 #endif /* CONFIG_X86_IO_APIC */
414 * acpi_pic_sci_set_trigger()
416 * use ELCR to set PIC-mode trigger type for SCI
418 * If a PIC-mode SCI is not recognized or gives spurious IRQ7's
419 * it may require Edge Trigger -- use "acpi_sci=edge"
421 * Port 0x4d0-4d1 are ECLR1 and ECLR2, the Edge/Level Control Registers
422 * for the 8259 PIC. bit[n] = 1 means irq[n] is Level, otherwise Edge.
423 * ECLR1 is IRQ's 0-7 (IRQ 0, 1, 2 must be 0)
424 * ECLR2 is IRQ's 8-15 (IRQ 8, 13 must be 0)
427 void __init acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger)
429 unsigned int mask = 1 << irq;
430 unsigned int old, new;
432 /* Real old ELCR mask */
433 old = inb(0x4d0) | (inb(0x4d1) << 8);
436 * If we use ACPI to set PCI irq's, then we should clear ELCR
437 * since we will set it correctly as we enable the PCI irq
440 new = acpi_noirq ? old : 0;
443 * Update SCI information in the ELCR, it isn't in the PCI
447 case 1: /* Edge - clear */
450 case 3: /* Level - set */
458 printk(PREFIX "setting ELCR to %04x (from %04x)\n", new, old);
460 outb(new >> 8, 0x4d1);
463 int acpi_gsi_to_irq(u32 gsi, unsigned int *irq)
470 * success: return IRQ number (>=0)
471 * failure: return < 0
473 int acpi_register_gsi(u32 gsi, int triggering, int polarity)
476 unsigned int plat_gsi = gsi;
480 * Make sure all (legacy) PCI IRQs are set as level-triggered.
482 if (acpi_irq_model == ACPI_IRQ_MODEL_PIC) {
483 extern void eisa_set_level_irq(unsigned int irq);
485 if (triggering == ACPI_LEVEL_SENSITIVE)
486 eisa_set_level_irq(gsi);
490 #ifdef CONFIG_X86_IO_APIC
491 if (acpi_irq_model == ACPI_IRQ_MODEL_IOAPIC) {
492 plat_gsi = mp_register_gsi(gsi, triggering, polarity);
495 acpi_gsi_to_irq(plat_gsi, &irq);
499 EXPORT_SYMBOL(acpi_register_gsi);
502 * ACPI based hotplug support for CPU
504 #ifdef CONFIG_ACPI_HOTPLUG_CPU
505 int acpi_map_lsapic(acpi_handle handle, int *pcpu)
507 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
508 union acpi_object *obj;
509 struct acpi_madt_local_apic *lapic;
510 cpumask_t tmp_map, new_map;
514 if (ACPI_FAILURE(acpi_evaluate_object(handle, "_MAT", NULL, &buffer)))
517 if (!buffer.length || !buffer.pointer)
520 obj = buffer.pointer;
521 if (obj->type != ACPI_TYPE_BUFFER ||
522 obj->buffer.length < sizeof(*lapic)) {
523 kfree(buffer.pointer);
527 lapic = (struct acpi_madt_local_apic *)obj->buffer.pointer;
529 if (lapic->header.type != ACPI_MADT_TYPE_LOCAL_APIC ||
530 !(lapic->lapic_flags & ACPI_MADT_ENABLED)) {
531 kfree(buffer.pointer);
537 kfree(buffer.pointer);
538 buffer.length = ACPI_ALLOCATE_BUFFER;
539 buffer.pointer = NULL;
541 tmp_map = cpu_present_map;
542 mp_register_lapic(physid, lapic->lapic_flags & ACPI_MADT_ENABLED);
545 * If mp_register_lapic successfully generates a new logical cpu
546 * number, then the following will get us exactly what was mapped
548 cpus_andnot(new_map, cpu_present_map, tmp_map);
549 if (cpus_empty(new_map)) {
550 printk ("Unable to map lapic to logical cpu number\n");
554 cpu = first_cpu(new_map);
560 EXPORT_SYMBOL(acpi_map_lsapic);
562 int acpi_unmap_lsapic(int cpu)
564 x86_cpu_to_apicid[cpu] = -1;
565 cpu_clear(cpu, cpu_present_map);
571 EXPORT_SYMBOL(acpi_unmap_lsapic);
572 #endif /* CONFIG_ACPI_HOTPLUG_CPU */
574 int acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base)
580 EXPORT_SYMBOL(acpi_register_ioapic);
582 int acpi_unregister_ioapic(acpi_handle handle, u32 gsi_base)
588 EXPORT_SYMBOL(acpi_unregister_ioapic);
590 static unsigned long __init
591 acpi_scan_rsdp(unsigned long start, unsigned long length)
593 unsigned long offset = 0;
594 unsigned long sig_len = sizeof("RSD PTR ") - 1;
595 unsigned long vstart = (unsigned long)isa_bus_to_virt(start);
598 * Scan all 16-byte boundaries of the physical memory region for the
601 for (offset = 0; offset < length; offset += 16) {
602 if (strncmp((char *)(vstart + offset), "RSD PTR ", sig_len))
604 return (start + offset);
610 static int __init acpi_parse_sbf(struct acpi_table_header *table)
612 struct acpi_table_boot *sb;
614 sb = (struct acpi_table_boot *)table;
616 printk(KERN_WARNING PREFIX "Unable to map SBF\n");
620 sbf_port = sb->cmos_index; /* Save CMOS port */
625 #ifdef CONFIG_HPET_TIMER
626 #include <asm/hpet.h>
628 static int __init acpi_parse_hpet(struct acpi_table_header *table)
630 struct acpi_table_hpet *hpet_tbl;
631 struct resource *hpet_res;
632 resource_size_t res_start;
634 hpet_tbl = (struct acpi_table_hpet *)table;
636 printk(KERN_WARNING PREFIX "Unable to map HPET\n");
640 if (hpet_tbl->address.space_id != ACPI_SPACE_MEM) {
641 printk(KERN_WARNING PREFIX "HPET timers must be located in "
646 #define HPET_RESOURCE_NAME_SIZE 9
647 hpet_res = alloc_bootmem(sizeof(*hpet_res) + HPET_RESOURCE_NAME_SIZE);
649 memset(hpet_res, 0, sizeof(*hpet_res));
650 hpet_res->name = (void *)&hpet_res[1];
651 hpet_res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
652 snprintf((char *)hpet_res->name, HPET_RESOURCE_NAME_SIZE,
653 "HPET %u", hpet_tbl->sequence);
654 hpet_res->end = (1 * 1024) - 1;
657 hpet_address = hpet_tbl->address.address;
658 printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n",
659 hpet_tbl->id, hpet_address);
661 res_start = hpet_address;
664 hpet_res->start = res_start;
665 hpet_res->end += res_start;
666 insert_resource(&iomem_resource, hpet_res);
672 #define acpi_parse_hpet NULL
675 static int __init acpi_parse_fadt(struct acpi_table_header *table)
678 #ifdef CONFIG_X86_PM_TIMER
679 /* detect the location of the ACPI PM Timer */
680 if (acpi_gbl_FADT.header.revision >= FADT2_REVISION_ID) {
682 if (acpi_gbl_FADT.xpm_timer_block.space_id !=
683 ACPI_ADR_SPACE_SYSTEM_IO)
686 pmtmr_ioport = acpi_gbl_FADT.xpm_timer_block.address;
688 * "X" fields are optional extensions to the original V1.0
689 * fields, so we must selectively expand V1.0 fields if the
690 * corresponding X field is zero.
693 pmtmr_ioport = acpi_gbl_FADT.pm_timer_block;
696 pmtmr_ioport = acpi_gbl_FADT.pm_timer_block;
699 printk(KERN_INFO PREFIX "PM-Timer IO Port: %#x\n",
705 unsigned long __init acpi_find_rsdp(void)
707 unsigned long rsdp_phys = 0;
710 if (efi.acpi20 != EFI_INVALID_TABLE_ADDR)
712 else if (efi.acpi != EFI_INVALID_TABLE_ADDR)
716 * Scan memory looking for the RSDP signature. First search EBDA (low
717 * memory) paragraphs and then search upper memory (E0000-FFFFF).
719 rsdp_phys = acpi_scan_rsdp(0, 0x400);
721 rsdp_phys = acpi_scan_rsdp(0xE0000, 0x20000);
726 #ifdef CONFIG_X86_LOCAL_APIC
728 * Parse LAPIC entries in MADT
729 * returns 0 on success, < 0 on error
731 static int __init acpi_parse_madt_lapic_entries(void)
739 * Note that the LAPIC address is obtained from the MADT (32-bit value)
740 * and (optionally) overriden by a LAPIC_ADDR_OVR entry (64-bit value).
744 acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE,
745 acpi_parse_lapic_addr_ovr, 0);
747 printk(KERN_ERR PREFIX
748 "Error parsing LAPIC address override entry\n");
753 mp_register_lapic_address(acpi_lapic_addr);
756 count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC, acpi_parse_lapic,
759 printk(KERN_ERR PREFIX "No LAPIC entries present\n");
760 /* TBD: Cleanup to allow fallback to MPS */
762 } else if (count < 0) {
763 printk(KERN_ERR PREFIX "Error parsing LAPIC entry\n");
764 /* TBD: Cleanup to allow fallback to MPS */
769 acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC_NMI, acpi_parse_lapic_nmi, 0);
771 printk(KERN_ERR PREFIX "Error parsing LAPIC NMI entry\n");
772 /* TBD: Cleanup to allow fallback to MPS */
777 #endif /* CONFIG_X86_LOCAL_APIC */
779 #ifdef CONFIG_X86_IO_APIC
781 * Parse IOAPIC related entries in MADT
782 * returns 0 on success, < 0 on error
784 static int __init acpi_parse_madt_ioapic_entries(void)
789 * ACPI interpreter is required to complete interrupt setup,
790 * so if it is off, don't enumerate the io-apics with ACPI.
791 * If MPS is present, it will handle them,
792 * otherwise the system will stay in PIC mode
794 if (acpi_disabled || acpi_noirq) {
802 * if "noapic" boot option, don't look for IO-APICs
804 if (skip_ioapic_setup) {
805 printk(KERN_INFO PREFIX "Skipping IOAPIC probe "
806 "due to 'noapic' option.\n");
811 acpi_table_parse_madt(ACPI_MADT_TYPE_IO_APIC, acpi_parse_ioapic,
814 printk(KERN_ERR PREFIX "No IOAPIC entries present\n");
816 } else if (count < 0) {
817 printk(KERN_ERR PREFIX "Error parsing IOAPIC entry\n");
822 acpi_table_parse_madt(ACPI_MADT_TYPE_INTERRUPT_OVERRIDE, acpi_parse_int_src_ovr,
825 printk(KERN_ERR PREFIX
826 "Error parsing interrupt source overrides entry\n");
827 /* TBD: Cleanup to allow fallback to MPS */
832 * If BIOS did not supply an INT_SRC_OVR for the SCI
833 * pretend we got one so we can set the SCI flags.
835 if (!acpi_sci_override_gsi)
836 acpi_sci_ioapic_setup(acpi_gbl_FADT.sci_interrupt, 0, 0);
838 /* Fill in identity legacy mapings where no override */
839 mp_config_acpi_legacy_irqs();
842 acpi_table_parse_madt(ACPI_MADT_TYPE_NMI_SOURCE, acpi_parse_nmi_src,
845 printk(KERN_ERR PREFIX "Error parsing NMI SRC entry\n");
846 /* TBD: Cleanup to allow fallback to MPS */
853 static inline int acpi_parse_madt_ioapic_entries(void)
857 #endif /* !CONFIG_X86_IO_APIC */
859 static void __init acpi_process_madt(void)
861 #ifdef CONFIG_X86_LOCAL_APIC
864 if (!acpi_table_parse(ACPI_SIG_MADT, acpi_parse_madt)) {
867 * Parse MADT LAPIC entries
869 error = acpi_parse_madt_lapic_entries();
873 #ifdef CONFIG_X86_GENERICARCH
874 generic_bigsmp_probe();
877 * Parse MADT IO-APIC entries
879 error = acpi_parse_madt_ioapic_entries();
881 acpi_irq_model = ACPI_IRQ_MODEL_IOAPIC;
882 acpi_irq_balance_set(NULL);
885 smp_found_config = 1;
886 clustered_apic_check();
889 if (error == -EINVAL) {
891 * Dell Precision Workstation 410, 610 come here.
893 printk(KERN_ERR PREFIX
894 "Invalid BIOS MADT, disabling ACPI\n");
904 static int __init disable_acpi_irq(struct dmi_system_id *d)
907 printk(KERN_NOTICE "%s detected: force use of acpi=noirq\n",
914 static int __init disable_acpi_pci(struct dmi_system_id *d)
917 printk(KERN_NOTICE "%s detected: force use of pci=noacpi\n",
924 static int __init dmi_disable_acpi(struct dmi_system_id *d)
927 printk(KERN_NOTICE "%s detected: acpi off\n", d->ident);
931 "Warning: DMI blacklist says broken, but acpi forced\n");
937 * Limit ACPI to CPU enumeration for HT
939 static int __init force_acpi_ht(struct dmi_system_id *d)
942 printk(KERN_NOTICE "%s detected: force use of acpi=ht\n",
948 "Warning: acpi=force overrules DMI blacklist: acpi=ht\n");
954 * If your system is blacklisted here, but you find that acpi=force
955 * works for you, please contact acpi-devel@sourceforge.net
957 static struct dmi_system_id __initdata acpi_dmi_table[] = {
959 * Boxes that need ACPI disabled
962 .callback = dmi_disable_acpi,
963 .ident = "IBM Thinkpad",
965 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
966 DMI_MATCH(DMI_BOARD_NAME, "2629H1G"),
971 * Boxes that need acpi=ht
974 .callback = force_acpi_ht,
975 .ident = "FSC Primergy T850",
977 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
978 DMI_MATCH(DMI_PRODUCT_NAME, "PRIMERGY T850"),
982 .callback = force_acpi_ht,
983 .ident = "DELL GX240",
985 DMI_MATCH(DMI_BOARD_VENDOR, "Dell Computer Corporation"),
986 DMI_MATCH(DMI_BOARD_NAME, "OptiPlex GX240"),
990 .callback = force_acpi_ht,
991 .ident = "HP VISUALIZE NT Workstation",
993 DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"),
994 DMI_MATCH(DMI_PRODUCT_NAME, "HP VISUALIZE NT Workstation"),
998 .callback = force_acpi_ht,
999 .ident = "Compaq Workstation W8000",
1001 DMI_MATCH(DMI_SYS_VENDOR, "Compaq"),
1002 DMI_MATCH(DMI_PRODUCT_NAME, "Workstation W8000"),
1006 .callback = force_acpi_ht,
1007 .ident = "ASUS P4B266",
1009 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
1010 DMI_MATCH(DMI_BOARD_NAME, "P4B266"),
1014 .callback = force_acpi_ht,
1015 .ident = "ASUS P2B-DS",
1017 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
1018 DMI_MATCH(DMI_BOARD_NAME, "P2B-DS"),
1022 .callback = force_acpi_ht,
1023 .ident = "ASUS CUR-DLS",
1025 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
1026 DMI_MATCH(DMI_BOARD_NAME, "CUR-DLS"),
1030 .callback = force_acpi_ht,
1031 .ident = "ABIT i440BX-W83977",
1033 DMI_MATCH(DMI_BOARD_VENDOR, "ABIT <http://www.abit.com>"),
1034 DMI_MATCH(DMI_BOARD_NAME, "i440BX-W83977 (BP6)"),
1038 .callback = force_acpi_ht,
1039 .ident = "IBM Bladecenter",
1041 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
1042 DMI_MATCH(DMI_BOARD_NAME, "IBM eServer BladeCenter HS20"),
1046 .callback = force_acpi_ht,
1047 .ident = "IBM eServer xSeries 360",
1049 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
1050 DMI_MATCH(DMI_BOARD_NAME, "eServer xSeries 360"),
1054 .callback = force_acpi_ht,
1055 .ident = "IBM eserver xSeries 330",
1057 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
1058 DMI_MATCH(DMI_BOARD_NAME, "eserver xSeries 330"),
1062 .callback = force_acpi_ht,
1063 .ident = "IBM eserver xSeries 440",
1065 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
1066 DMI_MATCH(DMI_PRODUCT_NAME, "eserver xSeries 440"),
1071 * Boxes that need ACPI PCI IRQ routing disabled
1074 .callback = disable_acpi_irq,
1075 .ident = "ASUS A7V",
1077 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC"),
1078 DMI_MATCH(DMI_BOARD_NAME, "<A7V>"),
1079 /* newer BIOS, Revision 1011, does work */
1080 DMI_MATCH(DMI_BIOS_VERSION,
1081 "ASUS A7V ACPI BIOS Revision 1007"),
1086 * Latest BIOS for IBM 600E (1.16) has bad pcinum
1087 * for LPC bridge, which is needed for the PCI
1088 * interrupt links to work. DSDT fix is in bug 5966.
1089 * 2645, 2646 model numbers are shared with 600/600E/600X
1091 .callback = disable_acpi_irq,
1092 .ident = "IBM Thinkpad 600 Series 2645",
1094 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
1095 DMI_MATCH(DMI_BOARD_NAME, "2645"),
1099 .callback = disable_acpi_irq,
1100 .ident = "IBM Thinkpad 600 Series 2646",
1102 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
1103 DMI_MATCH(DMI_BOARD_NAME, "2646"),
1107 * Boxes that need ACPI PCI IRQ routing and PCI scan disabled
1110 .callback = disable_acpi_pci,
1111 .ident = "ASUS PR-DLS",
1113 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
1114 DMI_MATCH(DMI_BOARD_NAME, "PR-DLS"),
1115 DMI_MATCH(DMI_BIOS_VERSION,
1116 "ASUS PR-DLS ACPI BIOS Revision 1010"),
1117 DMI_MATCH(DMI_BIOS_DATE, "03/21/2003")
1121 .callback = disable_acpi_pci,
1122 .ident = "Acer TravelMate 36x Laptop",
1124 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
1125 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 360"),
1131 #endif /* __i386__ */
1134 * acpi_boot_table_init() and acpi_boot_init()
1135 * called from setup_arch(), always.
1136 * 1. checksums all tables
1137 * 2. enumerates lapics
1138 * 3. enumerates io-apics
1140 * acpi_table_init() is separate to allow reading SRAT without
1141 * other side effects.
1143 * side effects of acpi_boot_init:
1144 * acpi_lapic = 1 if LAPIC found
1145 * acpi_ioapic = 1 if IOAPIC found
1146 * if (acpi_lapic && acpi_ioapic) smp_found_config = 1;
1147 * if acpi_blacklisted() acpi_disabled = 1;
1148 * acpi_irq_model=...
1151 * return value: (currently ignored)
1156 int __init acpi_boot_table_init(void)
1161 dmi_check_system(acpi_dmi_table);
1165 * If acpi_disabled, bail out
1166 * One exception: acpi=ht continues far enough to enumerate LAPICs
1168 if (acpi_disabled && !acpi_ht)
1172 * Initialize the ACPI boot-time table parser.
1174 error = acpi_table_init();
1180 acpi_table_parse(ACPI_SIG_BOOT, acpi_parse_sbf);
1183 * blacklist may disable ACPI entirely
1185 error = acpi_blacklisted();
1188 printk(KERN_WARNING PREFIX "acpi=force override\n");
1190 printk(KERN_WARNING PREFIX "Disabling ACPI support\n");
1199 int __init acpi_boot_init(void)
1202 * If acpi_disabled, bail out
1203 * One exception: acpi=ht continues far enough to enumerate LAPICs
1205 if (acpi_disabled && !acpi_ht)
1208 acpi_table_parse(ACPI_SIG_BOOT, acpi_parse_sbf);
1211 * set sci_int and PM timer address
1213 acpi_table_parse(ACPI_SIG_FADT, acpi_parse_fadt);
1216 * Process the Multiple APIC Description Table (MADT), if present
1218 acpi_process_madt();
1220 acpi_table_parse(ACPI_SIG_HPET, acpi_parse_hpet);
1225 static int __init parse_acpi(char *arg)
1230 /* "acpi=off" disables both ACPI table parsing and interpreter */
1231 if (strcmp(arg, "off") == 0) {
1234 /* acpi=force to over-ride black-list */
1235 else if (strcmp(arg, "force") == 0) {
1240 /* acpi=strict disables out-of-spec workarounds */
1241 else if (strcmp(arg, "strict") == 0) {
1244 /* Limit ACPI just to boot-time to enable HT */
1245 else if (strcmp(arg, "ht") == 0) {
1250 /* "acpi=noirq" disables ACPI interrupt routing */
1251 else if (strcmp(arg, "noirq") == 0) {
1254 /* Core will printk when we return error. */
1259 early_param("acpi", parse_acpi);
1261 /* FIXME: Using pci= for an ACPI parameter is a travesty. */
1262 static int __init parse_pci(char *arg)
1264 if (arg && strcmp(arg, "noacpi") == 0)
1268 early_param("pci", parse_pci);
1270 #ifdef CONFIG_X86_IO_APIC
1271 static int __init parse_acpi_skip_timer_override(char *arg)
1273 acpi_skip_timer_override = 1;
1276 early_param("acpi_skip_timer_override", parse_acpi_skip_timer_override);
1278 static int __init parse_acpi_use_timer_override(char *arg)
1280 acpi_use_timer_override = 1;
1283 early_param("acpi_use_timer_override", parse_acpi_use_timer_override);
1284 #endif /* CONFIG_X86_IO_APIC */
1286 static int __init setup_acpi_sci(char *s)
1290 if (!strcmp(s, "edge"))
1291 acpi_sci_flags = ACPI_MADT_TRIGGER_EDGE |
1292 (acpi_sci_flags & ~ACPI_MADT_TRIGGER_MASK);
1293 else if (!strcmp(s, "level"))
1294 acpi_sci_flags = ACPI_MADT_TRIGGER_LEVEL |
1295 (acpi_sci_flags & ~ACPI_MADT_TRIGGER_MASK);
1296 else if (!strcmp(s, "high"))
1297 acpi_sci_flags = ACPI_MADT_POLARITY_ACTIVE_HIGH |
1298 (acpi_sci_flags & ~ACPI_MADT_POLARITY_MASK);
1299 else if (!strcmp(s, "low"))
1300 acpi_sci_flags = ACPI_MADT_POLARITY_ACTIVE_LOW |
1301 (acpi_sci_flags & ~ACPI_MADT_POLARITY_MASK);
1306 early_param("acpi_sci", setup_acpi_sci);
1308 int __acpi_acquire_global_lock(unsigned int *lock)
1310 unsigned int old, new, val;
1313 new = (((old & ~0x3) + 2) + ((old >> 1) & 0x1));
1314 val = cmpxchg(lock, old, new);
1315 } while (unlikely (val != old));
1316 return (new < 3) ? -1 : 0;
1319 int __acpi_release_global_lock(unsigned int *lock)
1321 unsigned int old, new, val;
1325 val = cmpxchg(lock, old, new);
1326 } while (unlikely (val != old));