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>
40 #include <asm/genapic.h>
42 #include <asm/mpspec.h>
45 #ifdef CONFIG_X86_LOCAL_APIC
46 # include <mach_apic.h>
49 static int __initdata acpi_force = 0;
52 int acpi_disabled = 0;
54 int acpi_disabled = 1;
56 EXPORT_SYMBOL(acpi_disabled);
60 #include <asm/proto.h>
64 #ifdef CONFIG_X86_LOCAL_APIC
65 #include <mach_apic.h>
66 #include <mach_mpparse.h>
67 #endif /* CONFIG_X86_LOCAL_APIC */
71 #define BAD_MADT_ENTRY(entry, end) ( \
72 (!entry) || (unsigned long)entry + sizeof(*entry) > end || \
73 ((struct acpi_subtable_header *)entry)->length < sizeof(*entry))
75 #define PREFIX "ACPI: "
77 int acpi_noirq; /* skip ACPI IRQ initialization */
78 int acpi_pci_disabled; /* skip ACPI PCI scan and IRQ initialization */
79 EXPORT_SYMBOL(acpi_pci_disabled);
80 int acpi_ht __initdata = 1; /* enable HT */
86 u8 acpi_sci_flags __initdata;
87 int acpi_sci_override_gsi __initdata;
88 int acpi_skip_timer_override __initdata;
89 int acpi_use_timer_override __initdata;
91 #ifdef CONFIG_X86_LOCAL_APIC
92 static u64 acpi_lapic_addr __initdata = APIC_DEFAULT_PHYS_BASE;
95 #ifndef __HAVE_ARCH_CMPXCHG
96 #warning ACPI uses CMPXCHG, i486 and later hardware
99 /* --------------------------------------------------------------------------
100 Boot-time Configuration
101 -------------------------------------------------------------------------- */
104 * The default interrupt routing model is PIC (8259). This gets
105 * overridden if IOAPICs are enumerated (below).
107 enum acpi_irq_model_id acpi_irq_model = ACPI_IRQ_MODEL_PIC;
111 * Temporarily use the virtual area starting from FIX_IO_APIC_BASE_END,
112 * to map the target physical address. The problem is that set_fixmap()
113 * provides a single page, and it is possible that the page is not
115 * By using this area, we can map up to MAX_IO_APICS pages temporarily,
116 * i.e. until the next __va_range() call.
118 * Important Safety Note: The fixed I/O APIC page numbers are *subtracted*
119 * from the fixed base. That's why we start at FIX_IO_APIC_BASE_END and
120 * count idx down while incrementing the phys address.
122 char *__init __acpi_map_table(unsigned long phys, unsigned long size)
128 return early_ioremap(phys, size);
130 void __init __acpi_unmap_table(char *map, unsigned long size)
135 early_iounmap(map, size);
138 #ifdef CONFIG_PCI_MMCONFIG
140 static int acpi_mcfg_64bit_base_addr __initdata = FALSE;
142 /* The physical address of the MMCONFIG aperture. Set from ACPI tables. */
143 struct acpi_mcfg_allocation *pci_mmcfg_config;
144 int pci_mmcfg_config_num;
146 static int __init acpi_mcfg_oem_check(struct acpi_table_mcfg *mcfg)
148 if (!strcmp(mcfg->header.oem_id, "SGI"))
149 acpi_mcfg_64bit_base_addr = TRUE;
154 int __init acpi_parse_mcfg(struct acpi_table_header *header)
156 struct acpi_table_mcfg *mcfg;
163 mcfg = (struct acpi_table_mcfg *)header;
165 /* how many config structures do we have */
166 pci_mmcfg_config_num = 0;
167 i = header->length - sizeof(struct acpi_table_mcfg);
168 while (i >= sizeof(struct acpi_mcfg_allocation)) {
169 ++pci_mmcfg_config_num;
170 i -= sizeof(struct acpi_mcfg_allocation);
172 if (pci_mmcfg_config_num == 0) {
173 printk(KERN_ERR PREFIX "MMCONFIG has no entries\n");
177 config_size = pci_mmcfg_config_num * sizeof(*pci_mmcfg_config);
178 pci_mmcfg_config = kmalloc(config_size, GFP_KERNEL);
179 if (!pci_mmcfg_config) {
180 printk(KERN_WARNING PREFIX
181 "No memory for MCFG config tables\n");
185 memcpy(pci_mmcfg_config, &mcfg[1], config_size);
187 acpi_mcfg_oem_check(mcfg);
189 for (i = 0; i < pci_mmcfg_config_num; ++i) {
190 if ((pci_mmcfg_config[i].address > 0xFFFFFFFF) &&
191 !acpi_mcfg_64bit_base_addr) {
192 printk(KERN_ERR PREFIX
193 "MMCONFIG not in low 4GB of memory\n");
194 kfree(pci_mmcfg_config);
195 pci_mmcfg_config_num = 0;
202 #endif /* CONFIG_PCI_MMCONFIG */
204 #ifdef CONFIG_X86_LOCAL_APIC
205 static int __init acpi_parse_madt(struct acpi_table_header *table)
207 struct acpi_table_madt *madt = NULL;
212 madt = (struct acpi_table_madt *)table;
214 printk(KERN_WARNING PREFIX "Unable to map MADT\n");
219 acpi_lapic_addr = (u64) madt->address;
221 printk(KERN_DEBUG PREFIX "Local APIC address 0x%08x\n",
225 acpi_madt_oem_check(madt->header.oem_id, madt->header.oem_table_id);
230 static void __cpuinit acpi_register_lapic(int id, u8 enabled)
232 unsigned int ver = 0;
239 if (boot_cpu_physical_apicid != -1U)
240 ver = apic_version[boot_cpu_physical_apicid];
242 generic_processor_info(id, ver);
246 acpi_parse_lapic(struct acpi_subtable_header * header, const unsigned long end)
248 struct acpi_madt_local_apic *processor = NULL;
250 processor = (struct acpi_madt_local_apic *)header;
252 if (BAD_MADT_ENTRY(processor, end))
255 acpi_table_print_madt_entry(header);
258 * We need to register disabled CPU as well to permit
259 * counting disabled CPUs. This allows us to size
260 * cpus_possible_map more accurately, to permit
261 * to not preallocating memory for all NR_CPUS
262 * when we use CPU hotplug.
264 acpi_register_lapic(processor->id, /* APIC ID */
265 processor->lapic_flags & ACPI_MADT_ENABLED);
271 acpi_parse_sapic(struct acpi_subtable_header *header, const unsigned long end)
273 struct acpi_madt_local_sapic *processor = NULL;
275 processor = (struct acpi_madt_local_sapic *)header;
277 if (BAD_MADT_ENTRY(processor, end))
280 acpi_table_print_madt_entry(header);
282 acpi_register_lapic((processor->id << 8) | processor->eid,/* APIC ID */
283 processor->lapic_flags & ACPI_MADT_ENABLED);
289 acpi_parse_lapic_addr_ovr(struct acpi_subtable_header * header,
290 const unsigned long end)
292 struct acpi_madt_local_apic_override *lapic_addr_ovr = NULL;
294 lapic_addr_ovr = (struct acpi_madt_local_apic_override *)header;
296 if (BAD_MADT_ENTRY(lapic_addr_ovr, end))
299 acpi_lapic_addr = lapic_addr_ovr->address;
305 acpi_parse_lapic_nmi(struct acpi_subtable_header * header, const unsigned long end)
307 struct acpi_madt_local_apic_nmi *lapic_nmi = NULL;
309 lapic_nmi = (struct acpi_madt_local_apic_nmi *)header;
311 if (BAD_MADT_ENTRY(lapic_nmi, end))
314 acpi_table_print_madt_entry(header);
316 if (lapic_nmi->lint != 1)
317 printk(KERN_WARNING PREFIX "NMI not connected to LINT 1!\n");
322 #endif /*CONFIG_X86_LOCAL_APIC */
324 #ifdef CONFIG_X86_IO_APIC
327 acpi_parse_ioapic(struct acpi_subtable_header * header, const unsigned long end)
329 struct acpi_madt_io_apic *ioapic = NULL;
331 ioapic = (struct acpi_madt_io_apic *)header;
333 if (BAD_MADT_ENTRY(ioapic, end))
336 acpi_table_print_madt_entry(header);
338 mp_register_ioapic(ioapic->id,
339 ioapic->address, ioapic->global_irq_base);
345 * Parse Interrupt Source Override for the ACPI SCI
347 static void __init acpi_sci_ioapic_setup(u32 gsi, u16 polarity, u16 trigger)
349 if (trigger == 0) /* compatible SCI trigger is level */
352 if (polarity == 0) /* compatible SCI polarity is low */
355 /* Command-line over-ride via acpi_sci= */
356 if (acpi_sci_flags & ACPI_MADT_TRIGGER_MASK)
357 trigger = (acpi_sci_flags & ACPI_MADT_TRIGGER_MASK) >> 2;
359 if (acpi_sci_flags & ACPI_MADT_POLARITY_MASK)
360 polarity = acpi_sci_flags & ACPI_MADT_POLARITY_MASK;
363 * mp_config_acpi_legacy_irqs() already setup IRQs < 16
364 * If GSI is < 16, this will update its flags,
365 * else it will create a new mp_irqs[] entry.
367 mp_override_legacy_irq(gsi, polarity, trigger, gsi);
370 * stash over-ride to indicate we've been here
371 * and for later update of acpi_gbl_FADT
373 acpi_sci_override_gsi = gsi;
378 acpi_parse_int_src_ovr(struct acpi_subtable_header * header,
379 const unsigned long end)
381 struct acpi_madt_interrupt_override *intsrc = NULL;
383 intsrc = (struct acpi_madt_interrupt_override *)header;
385 if (BAD_MADT_ENTRY(intsrc, end))
388 acpi_table_print_madt_entry(header);
390 if (intsrc->source_irq == acpi_gbl_FADT.sci_interrupt) {
391 acpi_sci_ioapic_setup(intsrc->global_irq,
392 intsrc->inti_flags & ACPI_MADT_POLARITY_MASK,
393 (intsrc->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2);
397 if (acpi_skip_timer_override &&
398 intsrc->source_irq == 0 && intsrc->global_irq == 2) {
399 printk(PREFIX "BIOS IRQ0 pin2 override ignored.\n");
403 mp_override_legacy_irq(intsrc->source_irq,
404 intsrc->inti_flags & ACPI_MADT_POLARITY_MASK,
405 (intsrc->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2,
412 acpi_parse_nmi_src(struct acpi_subtable_header * header, const unsigned long end)
414 struct acpi_madt_nmi_source *nmi_src = NULL;
416 nmi_src = (struct acpi_madt_nmi_source *)header;
418 if (BAD_MADT_ENTRY(nmi_src, end))
421 acpi_table_print_madt_entry(header);
423 /* TBD: Support nimsrc entries? */
428 #endif /* CONFIG_X86_IO_APIC */
431 * acpi_pic_sci_set_trigger()
433 * use ELCR to set PIC-mode trigger type for SCI
435 * If a PIC-mode SCI is not recognized or gives spurious IRQ7's
436 * it may require Edge Trigger -- use "acpi_sci=edge"
438 * Port 0x4d0-4d1 are ECLR1 and ECLR2, the Edge/Level Control Registers
439 * for the 8259 PIC. bit[n] = 1 means irq[n] is Level, otherwise Edge.
440 * ECLR1 is IRQs 0-7 (IRQ 0, 1, 2 must be 0)
441 * ECLR2 is IRQs 8-15 (IRQ 8, 13 must be 0)
444 void __init acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger)
446 unsigned int mask = 1 << irq;
447 unsigned int old, new;
449 /* Real old ELCR mask */
450 old = inb(0x4d0) | (inb(0x4d1) << 8);
453 * If we use ACPI to set PCI IRQs, then we should clear ELCR
454 * since we will set it correctly as we enable the PCI irq
457 new = acpi_noirq ? old : 0;
460 * Update SCI information in the ELCR, it isn't in the PCI
464 case 1: /* Edge - clear */
467 case 3: /* Level - set */
475 printk(PREFIX "setting ELCR to %04x (from %04x)\n", new, old);
477 outb(new >> 8, 0x4d1);
480 int acpi_gsi_to_irq(u32 gsi, unsigned int *irq)
487 * success: return IRQ number (>=0)
488 * failure: return < 0
490 int acpi_register_gsi(u32 gsi, int triggering, int polarity)
493 unsigned int plat_gsi = gsi;
497 * Make sure all (legacy) PCI IRQs are set as level-triggered.
499 if (acpi_irq_model == ACPI_IRQ_MODEL_PIC) {
500 if (triggering == ACPI_LEVEL_SENSITIVE)
501 eisa_set_level_irq(gsi);
505 #ifdef CONFIG_X86_IO_APIC
506 if (acpi_irq_model == ACPI_IRQ_MODEL_IOAPIC) {
507 plat_gsi = mp_register_gsi(gsi, triggering, polarity);
510 acpi_gsi_to_irq(plat_gsi, &irq);
515 * ACPI based hotplug support for CPU
517 #ifdef CONFIG_ACPI_HOTPLUG_CPU
519 static int __cpuinit _acpi_map_lsapic(acpi_handle handle, int *pcpu)
521 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
522 union acpi_object *obj;
523 struct acpi_madt_local_apic *lapic;
524 cpumask_var_t tmp_map, new_map;
527 int retval = -ENOMEM;
529 if (ACPI_FAILURE(acpi_evaluate_object(handle, "_MAT", NULL, &buffer)))
532 if (!buffer.length || !buffer.pointer)
535 obj = buffer.pointer;
536 if (obj->type != ACPI_TYPE_BUFFER ||
537 obj->buffer.length < sizeof(*lapic)) {
538 kfree(buffer.pointer);
542 lapic = (struct acpi_madt_local_apic *)obj->buffer.pointer;
544 if (lapic->header.type != ACPI_MADT_TYPE_LOCAL_APIC ||
545 !(lapic->lapic_flags & ACPI_MADT_ENABLED)) {
546 kfree(buffer.pointer);
552 kfree(buffer.pointer);
553 buffer.length = ACPI_ALLOCATE_BUFFER;
554 buffer.pointer = NULL;
556 if (!alloc_cpumask_var(&tmp_map, GFP_KERNEL))
559 if (!alloc_cpumask_var(&new_map, GFP_KERNEL))
562 cpumask_copy(tmp_map, cpu_present_mask);
563 acpi_register_lapic(physid, lapic->lapic_flags & ACPI_MADT_ENABLED);
566 * If mp_register_lapic successfully generates a new logical cpu
567 * number, then the following will get us exactly what was mapped
569 cpumask_andnot(new_map, cpu_present_mask, tmp_map);
570 if (cpumask_empty(new_map)) {
571 printk ("Unable to map lapic to logical cpu number\n");
576 cpu = cpumask_first(new_map);
582 free_cpumask_var(new_map);
584 free_cpumask_var(tmp_map);
589 /* wrapper to silence section mismatch warning */
590 int __ref acpi_map_lsapic(acpi_handle handle, int *pcpu)
592 return _acpi_map_lsapic(handle, pcpu);
594 EXPORT_SYMBOL(acpi_map_lsapic);
596 int acpi_unmap_lsapic(int cpu)
598 per_cpu(x86_cpu_to_apicid, cpu) = -1;
599 set_cpu_present(cpu, false);
605 EXPORT_SYMBOL(acpi_unmap_lsapic);
606 #endif /* CONFIG_ACPI_HOTPLUG_CPU */
608 int acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base)
614 EXPORT_SYMBOL(acpi_register_ioapic);
616 int acpi_unregister_ioapic(acpi_handle handle, u32 gsi_base)
622 EXPORT_SYMBOL(acpi_unregister_ioapic);
624 static int __init acpi_parse_sbf(struct acpi_table_header *table)
626 struct acpi_table_boot *sb;
628 sb = (struct acpi_table_boot *)table;
630 printk(KERN_WARNING PREFIX "Unable to map SBF\n");
634 sbf_port = sb->cmos_index; /* Save CMOS port */
639 #ifdef CONFIG_HPET_TIMER
640 #include <asm/hpet.h>
642 static struct __initdata resource *hpet_res;
644 static int __init acpi_parse_hpet(struct acpi_table_header *table)
646 struct acpi_table_hpet *hpet_tbl;
648 hpet_tbl = (struct acpi_table_hpet *)table;
650 printk(KERN_WARNING PREFIX "Unable to map HPET\n");
654 if (hpet_tbl->address.space_id != ACPI_SPACE_MEM) {
655 printk(KERN_WARNING PREFIX "HPET timers must be located in "
660 hpet_address = hpet_tbl->address.address;
663 * Some broken BIOSes advertise HPET at 0x0. We really do not
664 * want to allocate a resource there.
667 printk(KERN_WARNING PREFIX
668 "HPET id: %#x base: %#lx is invalid\n",
669 hpet_tbl->id, hpet_address);
674 * Some even more broken BIOSes advertise HPET at
675 * 0xfed0000000000000 instead of 0xfed00000. Fix it up and add
678 if (hpet_address == 0xfed0000000000000UL) {
679 if (!hpet_force_user) {
680 printk(KERN_WARNING PREFIX "HPET id: %#x "
681 "base: 0xfed0000000000000 is bogus\n "
682 "try hpet=force on the kernel command line to "
683 "fix it up to 0xfed00000.\n", hpet_tbl->id);
687 printk(KERN_WARNING PREFIX
688 "HPET id: %#x base: 0xfed0000000000000 fixed up "
689 "to 0xfed00000.\n", hpet_tbl->id);
693 printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n",
694 hpet_tbl->id, hpet_address);
697 * Allocate and initialize the HPET firmware resource for adding into
698 * the resource tree during the lateinit timeframe.
700 #define HPET_RESOURCE_NAME_SIZE 9
701 hpet_res = alloc_bootmem(sizeof(*hpet_res) + HPET_RESOURCE_NAME_SIZE);
703 hpet_res->name = (void *)&hpet_res[1];
704 hpet_res->flags = IORESOURCE_MEM;
705 snprintf((char *)hpet_res->name, HPET_RESOURCE_NAME_SIZE, "HPET %u",
708 hpet_res->start = hpet_address;
709 hpet_res->end = hpet_address + (1 * 1024) - 1;
715 * hpet_insert_resource inserts the HPET resources used into the resource
718 static __init int hpet_insert_resource(void)
723 return insert_resource(&iomem_resource, hpet_res);
726 late_initcall(hpet_insert_resource);
729 #define acpi_parse_hpet NULL
732 static int __init acpi_parse_fadt(struct acpi_table_header *table)
735 #ifdef CONFIG_X86_PM_TIMER
736 /* detect the location of the ACPI PM Timer */
737 if (acpi_gbl_FADT.header.revision >= FADT2_REVISION_ID) {
739 if (acpi_gbl_FADT.xpm_timer_block.space_id !=
740 ACPI_ADR_SPACE_SYSTEM_IO)
743 pmtmr_ioport = acpi_gbl_FADT.xpm_timer_block.address;
745 * "X" fields are optional extensions to the original V1.0
746 * fields, so we must selectively expand V1.0 fields if the
747 * corresponding X field is zero.
750 pmtmr_ioport = acpi_gbl_FADT.pm_timer_block;
753 pmtmr_ioport = acpi_gbl_FADT.pm_timer_block;
756 printk(KERN_INFO PREFIX "PM-Timer IO Port: %#x\n",
762 #ifdef CONFIG_X86_LOCAL_APIC
764 * Parse LAPIC entries in MADT
765 * returns 0 on success, < 0 on error
768 static void __init acpi_register_lapic_address(unsigned long address)
770 mp_lapic_addr = address;
772 set_fixmap_nocache(FIX_APIC_BASE, address);
773 if (boot_cpu_physical_apicid == -1U) {
774 boot_cpu_physical_apicid = read_apic_id();
775 apic_version[boot_cpu_physical_apicid] =
776 GET_APIC_VERSION(apic_read(APIC_LVR));
780 static int __init early_acpi_parse_madt_lapic_addr_ovr(void)
788 * Note that the LAPIC address is obtained from the MADT (32-bit value)
789 * and (optionally) overriden by a LAPIC_ADDR_OVR entry (64-bit value).
793 acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE,
794 acpi_parse_lapic_addr_ovr, 0);
796 printk(KERN_ERR PREFIX
797 "Error parsing LAPIC address override entry\n");
801 acpi_register_lapic_address(acpi_lapic_addr);
806 static int __init acpi_parse_madt_lapic_entries(void)
814 * Note that the LAPIC address is obtained from the MADT (32-bit value)
815 * and (optionally) overriden by a LAPIC_ADDR_OVR entry (64-bit value).
819 acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE,
820 acpi_parse_lapic_addr_ovr, 0);
822 printk(KERN_ERR PREFIX
823 "Error parsing LAPIC address override entry\n");
827 acpi_register_lapic_address(acpi_lapic_addr);
829 count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_SAPIC,
830 acpi_parse_sapic, MAX_APICS);
833 count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC,
834 acpi_parse_lapic, MAX_APICS);
836 printk(KERN_ERR PREFIX "No LAPIC entries present\n");
837 /* TBD: Cleanup to allow fallback to MPS */
839 } else if (count < 0) {
840 printk(KERN_ERR PREFIX "Error parsing LAPIC entry\n");
841 /* TBD: Cleanup to allow fallback to MPS */
846 acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC_NMI, acpi_parse_lapic_nmi, 0);
848 printk(KERN_ERR PREFIX "Error parsing LAPIC NMI entry\n");
849 /* TBD: Cleanup to allow fallback to MPS */
854 #endif /* CONFIG_X86_LOCAL_APIC */
856 #ifdef CONFIG_X86_IO_APIC
859 #ifdef CONFIG_X86_ES7000
860 extern int es7000_plat;
867 DECLARE_BITMAP(pin_programmed, MP_MAX_IOAPIC_PIN + 1);
868 } mp_ioapic_routing[MAX_IO_APICS];
870 static int mp_find_ioapic(int gsi)
874 /* Find the IOAPIC that manages this GSI. */
875 for (i = 0; i < nr_ioapics; i++) {
876 if ((gsi >= mp_ioapic_routing[i].gsi_base)
877 && (gsi <= mp_ioapic_routing[i].gsi_end))
881 printk(KERN_ERR "ERROR: Unable to locate IOAPIC for GSI %d\n", gsi);
885 static u8 __init uniq_ioapic_id(u8 id)
888 if ((boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) &&
889 !APIC_XAPIC(apic_version[boot_cpu_physical_apicid]))
890 return io_apic_get_unique_id(nr_ioapics, id);
895 DECLARE_BITMAP(used, 256);
896 bitmap_zero(used, 256);
897 for (i = 0; i < nr_ioapics; i++) {
898 struct mp_config_ioapic *ia = &mp_ioapics[i];
899 __set_bit(ia->mp_apicid, used);
901 if (!test_bit(id, used))
903 return find_first_zero_bit(used, 256);
907 static int bad_ioapic(unsigned long address)
909 if (nr_ioapics >= MAX_IO_APICS) {
910 printk(KERN_ERR "ERROR: Max # of I/O APICs (%d) exceeded "
911 "(found %d)\n", MAX_IO_APICS, nr_ioapics);
912 panic("Recompile kernel with bigger MAX_IO_APICS!\n");
915 printk(KERN_ERR "WARNING: Bogus (zero) I/O APIC address"
916 " found in table, skipping!\n");
922 void __init mp_register_ioapic(int id, u32 address, u32 gsi_base)
926 if (bad_ioapic(address))
931 mp_ioapics[idx].mp_type = MP_IOAPIC;
932 mp_ioapics[idx].mp_flags = MPC_APIC_USABLE;
933 mp_ioapics[idx].mp_apicaddr = address;
935 set_fixmap_nocache(FIX_IO_APIC_BASE_0 + idx, address);
936 mp_ioapics[idx].mp_apicid = uniq_ioapic_id(id);
938 mp_ioapics[idx].mp_apicver = io_apic_get_version(idx);
940 mp_ioapics[idx].mp_apicver = 0;
943 * Build basic GSI lookup table to facilitate gsi->io_apic lookups
944 * and to prevent reprogramming of IOAPIC pins (PCI GSIs).
946 mp_ioapic_routing[idx].apic_id = mp_ioapics[idx].mp_apicid;
947 mp_ioapic_routing[idx].gsi_base = gsi_base;
948 mp_ioapic_routing[idx].gsi_end = gsi_base +
949 io_apic_get_redir_entries(idx);
951 printk(KERN_INFO "IOAPIC[%d]: apic_id %d, version %d, address 0x%lx, "
952 "GSI %d-%d\n", idx, mp_ioapics[idx].mp_apicid,
953 mp_ioapics[idx].mp_apicver, mp_ioapics[idx].mp_apicaddr,
954 mp_ioapic_routing[idx].gsi_base, mp_ioapic_routing[idx].gsi_end);
959 static void assign_to_mp_irq(struct mp_config_intsrc *m,
960 struct mp_config_intsrc *mp_irq)
962 memcpy(mp_irq, m, sizeof(struct mp_config_intsrc));
965 static int mp_irq_cmp(struct mp_config_intsrc *mp_irq,
966 struct mp_config_intsrc *m)
968 return memcmp(mp_irq, m, sizeof(struct mp_config_intsrc));
971 static void save_mp_irq(struct mp_config_intsrc *m)
975 for (i = 0; i < mp_irq_entries; i++) {
976 if (!mp_irq_cmp(&mp_irqs[i], m))
980 assign_to_mp_irq(m, &mp_irqs[mp_irq_entries]);
981 if (++mp_irq_entries == MAX_IRQ_SOURCES)
982 panic("Max # of irq sources exceeded!!\n");
985 void __init mp_override_legacy_irq(u8 bus_irq, u8 polarity, u8 trigger, u32 gsi)
989 struct mp_config_intsrc mp_irq;
992 * Convert 'gsi' to 'ioapic.pin'.
994 ioapic = mp_find_ioapic(gsi);
997 pin = gsi - mp_ioapic_routing[ioapic].gsi_base;
1000 * TBD: This check is for faulty timer entries, where the override
1001 * erroneously sets the trigger to level, resulting in a HUGE
1002 * increase of timer interrupts!
1004 if ((bus_irq == 0) && (trigger == 3))
1007 mp_irq.mp_type = MP_INTSRC;
1008 mp_irq.mp_irqtype = mp_INT;
1009 mp_irq.mp_irqflag = (trigger << 2) | polarity;
1010 mp_irq.mp_srcbus = MP_ISA_BUS;
1011 mp_irq.mp_srcbusirq = bus_irq; /* IRQ */
1012 mp_irq.mp_dstapic = mp_ioapics[ioapic].mp_apicid; /* APIC ID */
1013 mp_irq.mp_dstirq = pin; /* INTIN# */
1015 save_mp_irq(&mp_irq);
1018 void __init mp_config_acpi_legacy_irqs(void)
1022 unsigned int dstapic;
1023 struct mp_config_intsrc mp_irq;
1025 #if defined (CONFIG_MCA) || defined (CONFIG_EISA)
1027 * Fabricate the legacy ISA bus (bus #31).
1029 mp_bus_id_to_type[MP_ISA_BUS] = MP_BUS_ISA;
1031 set_bit(MP_ISA_BUS, mp_bus_not_pci);
1032 pr_debug("Bus #%d is ISA\n", MP_ISA_BUS);
1034 #ifdef CONFIG_X86_ES7000
1036 * Older generations of ES7000 have no legacy identity mappings
1038 if (es7000_plat == 1)
1043 * Locate the IOAPIC that manages the ISA IRQs (0-15).
1045 ioapic = mp_find_ioapic(0);
1048 dstapic = mp_ioapics[ioapic].mp_apicid;
1051 * Use the default configuration for the IRQs 0-15. Unless
1052 * overridden by (MADT) interrupt source override entries.
1054 for (i = 0; i < 16; i++) {
1057 for (idx = 0; idx < mp_irq_entries; idx++) {
1058 struct mp_config_intsrc *irq = mp_irqs + idx;
1060 /* Do we already have a mapping for this ISA IRQ? */
1061 if (irq->mp_srcbus == MP_ISA_BUS
1062 && irq->mp_srcbusirq == i)
1065 /* Do we already have a mapping for this IOAPIC pin */
1066 if (irq->mp_dstapic == dstapic &&
1067 irq->mp_dstirq == i)
1071 if (idx != mp_irq_entries) {
1072 printk(KERN_DEBUG "ACPI: IRQ%d used by override.\n", i);
1073 continue; /* IRQ already used */
1076 mp_irq.mp_type = MP_INTSRC;
1077 mp_irq.mp_irqflag = 0; /* Conforming */
1078 mp_irq.mp_srcbus = MP_ISA_BUS;
1079 mp_irq.mp_dstapic = dstapic;
1080 mp_irq.mp_irqtype = mp_INT;
1081 mp_irq.mp_srcbusirq = i; /* Identity mapped */
1082 mp_irq.mp_dstirq = i;
1084 save_mp_irq(&mp_irq);
1088 int mp_register_gsi(u32 gsi, int triggering, int polarity)
1092 #ifdef CONFIG_X86_32
1093 #define MAX_GSI_NUM 4096
1094 #define IRQ_COMPRESSION_START 64
1096 static int pci_irq = IRQ_COMPRESSION_START;
1098 * Mapping between Global System Interrupts, which
1099 * represent all possible interrupts, and IRQs
1100 * assigned to actual devices.
1102 static int gsi_to_irq[MAX_GSI_NUM];
1105 if (acpi_irq_model != ACPI_IRQ_MODEL_IOAPIC)
1109 /* Don't set up the ACPI SCI because it's already set up */
1110 if (acpi_gbl_FADT.sci_interrupt == gsi)
1113 ioapic = mp_find_ioapic(gsi);
1115 printk(KERN_WARNING "No IOAPIC for GSI %u\n", gsi);
1119 ioapic_pin = gsi - mp_ioapic_routing[ioapic].gsi_base;
1121 #ifdef CONFIG_X86_32
1122 if (ioapic_renumber_irq)
1123 gsi = ioapic_renumber_irq(ioapic, gsi);
1127 * Avoid pin reprogramming. PRTs typically include entries
1128 * with redundant pin->gsi mappings (but unique PCI devices);
1129 * we only program the IOAPIC on the first.
1131 if (ioapic_pin > MP_MAX_IOAPIC_PIN) {
1132 printk(KERN_ERR "Invalid reference to IOAPIC pin "
1133 "%d-%d\n", mp_ioapic_routing[ioapic].apic_id,
1137 if (test_bit(ioapic_pin, mp_ioapic_routing[ioapic].pin_programmed)) {
1138 pr_debug("Pin %d-%d already programmed\n",
1139 mp_ioapic_routing[ioapic].apic_id, ioapic_pin);
1140 #ifdef CONFIG_X86_32
1141 return (gsi < IRQ_COMPRESSION_START ? gsi : gsi_to_irq[gsi]);
1147 set_bit(ioapic_pin, mp_ioapic_routing[ioapic].pin_programmed);
1148 #ifdef CONFIG_X86_32
1150 * For GSI >= 64, use IRQ compression
1152 if ((gsi >= IRQ_COMPRESSION_START)
1153 && (triggering == ACPI_LEVEL_SENSITIVE)) {
1155 * For PCI devices assign IRQs in order, avoiding gaps
1156 * due to unused I/O APIC pins.
1159 if (gsi < MAX_GSI_NUM) {
1161 * Retain the VIA chipset work-around (gsi > 15), but
1162 * avoid a problem where the 8254 timer (IRQ0) is setup
1163 * via an override (so it's not on pin 0 of the ioapic),
1164 * and at the same time, the pin 0 interrupt is a PCI
1165 * type. The gsi > 15 test could cause these two pins
1166 * to be shared as IRQ0, and they are not shareable.
1167 * So test for this condition, and if necessary, avoid
1168 * the pin collision.
1172 * Don't assign IRQ used by ACPI SCI
1174 if (gsi == acpi_gbl_FADT.sci_interrupt)
1176 gsi_to_irq[irq] = gsi;
1178 printk(KERN_ERR "GSI %u is too high\n", gsi);
1183 io_apic_set_pci_routing(ioapic, ioapic_pin, gsi,
1184 triggering == ACPI_EDGE_SENSITIVE ? 0 : 1,
1185 polarity == ACPI_ACTIVE_HIGH ? 0 : 1);
1189 int mp_config_acpi_gsi(unsigned char number, unsigned int devfn, u8 pin,
1190 u32 gsi, int triggering, int polarity)
1192 #ifdef CONFIG_X86_MPPARSE
1193 struct mp_config_intsrc mp_irq;
1199 /* print the entry should happen on mptable identically */
1200 mp_irq.mp_type = MP_INTSRC;
1201 mp_irq.mp_irqtype = mp_INT;
1202 mp_irq.mp_irqflag = (triggering == ACPI_EDGE_SENSITIVE ? 4 : 0x0c) |
1203 (polarity == ACPI_ACTIVE_HIGH ? 1 : 3);
1204 mp_irq.mp_srcbus = number;
1205 mp_irq.mp_srcbusirq = (((devfn >> 3) & 0x1f) << 2) | ((pin - 1) & 3);
1206 ioapic = mp_find_ioapic(gsi);
1207 mp_irq.mp_dstapic = mp_ioapic_routing[ioapic].apic_id;
1208 mp_irq.mp_dstirq = gsi - mp_ioapic_routing[ioapic].gsi_base;
1210 save_mp_irq(&mp_irq);
1216 * Parse IOAPIC related entries in MADT
1217 * returns 0 on success, < 0 on error
1219 static int __init acpi_parse_madt_ioapic_entries(void)
1224 * ACPI interpreter is required to complete interrupt setup,
1225 * so if it is off, don't enumerate the io-apics with ACPI.
1226 * If MPS is present, it will handle them,
1227 * otherwise the system will stay in PIC mode
1229 if (acpi_disabled || acpi_noirq) {
1237 * if "noapic" boot option, don't look for IO-APICs
1239 if (skip_ioapic_setup) {
1240 printk(KERN_INFO PREFIX "Skipping IOAPIC probe "
1241 "due to 'noapic' option.\n");
1246 acpi_table_parse_madt(ACPI_MADT_TYPE_IO_APIC, acpi_parse_ioapic,
1249 printk(KERN_ERR PREFIX "No IOAPIC entries present\n");
1251 } else if (count < 0) {
1252 printk(KERN_ERR PREFIX "Error parsing IOAPIC entry\n");
1257 acpi_table_parse_madt(ACPI_MADT_TYPE_INTERRUPT_OVERRIDE, acpi_parse_int_src_ovr,
1260 printk(KERN_ERR PREFIX
1261 "Error parsing interrupt source overrides entry\n");
1262 /* TBD: Cleanup to allow fallback to MPS */
1267 * If BIOS did not supply an INT_SRC_OVR for the SCI
1268 * pretend we got one so we can set the SCI flags.
1270 if (!acpi_sci_override_gsi)
1271 acpi_sci_ioapic_setup(acpi_gbl_FADT.sci_interrupt, 0, 0);
1273 /* Fill in identity legacy mapings where no override */
1274 mp_config_acpi_legacy_irqs();
1277 acpi_table_parse_madt(ACPI_MADT_TYPE_NMI_SOURCE, acpi_parse_nmi_src,
1280 printk(KERN_ERR PREFIX "Error parsing NMI SRC entry\n");
1281 /* TBD: Cleanup to allow fallback to MPS */
1288 static inline int acpi_parse_madt_ioapic_entries(void)
1292 #endif /* !CONFIG_X86_IO_APIC */
1294 static void __init early_acpi_process_madt(void)
1296 #ifdef CONFIG_X86_LOCAL_APIC
1299 if (!acpi_table_parse(ACPI_SIG_MADT, acpi_parse_madt)) {
1302 * Parse MADT LAPIC entries
1304 error = early_acpi_parse_madt_lapic_addr_ovr();
1307 smp_found_config = 1;
1309 if (error == -EINVAL) {
1311 * Dell Precision Workstation 410, 610 come here.
1313 printk(KERN_ERR PREFIX
1314 "Invalid BIOS MADT, disabling ACPI\n");
1321 static void __init acpi_process_madt(void)
1323 #ifdef CONFIG_X86_LOCAL_APIC
1326 if (!acpi_table_parse(ACPI_SIG_MADT, acpi_parse_madt)) {
1329 * Parse MADT LAPIC entries
1331 error = acpi_parse_madt_lapic_entries();
1335 #ifdef CONFIG_X86_GENERICARCH
1336 generic_bigsmp_probe();
1339 * Parse MADT IO-APIC entries
1341 error = acpi_parse_madt_ioapic_entries();
1343 acpi_irq_model = ACPI_IRQ_MODEL_IOAPIC;
1346 smp_found_config = 1;
1347 #ifdef CONFIG_X86_32
1348 setup_apic_routing();
1352 if (error == -EINVAL) {
1354 * Dell Precision Workstation 410, 610 come here.
1356 printk(KERN_ERR PREFIX
1357 "Invalid BIOS MADT, disabling ACPI\n");
1362 * ACPI found no MADT, and so ACPI wants UP PIC mode.
1363 * In the event an MPS table was found, forget it.
1364 * Boot with "acpi=off" to use MPS on such a system.
1366 if (smp_found_config) {
1367 printk(KERN_WARNING PREFIX
1368 "No APIC-table, disabling MPS\n");
1369 smp_found_config = 0;
1374 * ACPI supports both logical (e.g. Hyper-Threading) and physical
1375 * processors, where MPS only supports physical.
1377 if (acpi_lapic && acpi_ioapic)
1378 printk(KERN_INFO "Using ACPI (MADT) for SMP configuration "
1380 else if (acpi_lapic)
1381 printk(KERN_INFO "Using ACPI for processor (LAPIC) "
1382 "configuration information\n");
1387 static int __init disable_acpi_irq(const struct dmi_system_id *d)
1390 printk(KERN_NOTICE "%s detected: force use of acpi=noirq\n",
1397 static int __init disable_acpi_pci(const struct dmi_system_id *d)
1400 printk(KERN_NOTICE "%s detected: force use of pci=noacpi\n",
1407 static int __init dmi_disable_acpi(const struct dmi_system_id *d)
1410 printk(KERN_NOTICE "%s detected: acpi off\n", d->ident);
1414 "Warning: DMI blacklist says broken, but acpi forced\n");
1420 * Limit ACPI to CPU enumeration for HT
1422 static int __init force_acpi_ht(const struct dmi_system_id *d)
1425 printk(KERN_NOTICE "%s detected: force use of acpi=ht\n",
1431 "Warning: acpi=force overrules DMI blacklist: acpi=ht\n");
1437 * Force ignoring BIOS IRQ0 pin2 override
1439 static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d)
1442 * The ati_ixp4x0_rev() early PCI quirk should have set
1443 * the acpi_skip_timer_override flag already:
1445 if (!acpi_skip_timer_override) {
1446 WARN(1, KERN_ERR "ati_ixp4x0 quirk not complete.\n");
1447 pr_notice("%s detected: Ignoring BIOS IRQ0 pin2 override\n",
1449 acpi_skip_timer_override = 1;
1455 * If your system is blacklisted here, but you find that acpi=force
1456 * works for you, please contact acpi-devel@sourceforge.net
1458 static struct dmi_system_id __initdata acpi_dmi_table[] = {
1460 * Boxes that need ACPI disabled
1463 .callback = dmi_disable_acpi,
1464 .ident = "IBM Thinkpad",
1466 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
1467 DMI_MATCH(DMI_BOARD_NAME, "2629H1G"),
1472 * Boxes that need acpi=ht
1475 .callback = force_acpi_ht,
1476 .ident = "FSC Primergy T850",
1478 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
1479 DMI_MATCH(DMI_PRODUCT_NAME, "PRIMERGY T850"),
1483 .callback = force_acpi_ht,
1484 .ident = "HP VISUALIZE NT Workstation",
1486 DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"),
1487 DMI_MATCH(DMI_PRODUCT_NAME, "HP VISUALIZE NT Workstation"),
1491 .callback = force_acpi_ht,
1492 .ident = "Compaq Workstation W8000",
1494 DMI_MATCH(DMI_SYS_VENDOR, "Compaq"),
1495 DMI_MATCH(DMI_PRODUCT_NAME, "Workstation W8000"),
1499 .callback = force_acpi_ht,
1500 .ident = "ASUS P4B266",
1502 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
1503 DMI_MATCH(DMI_BOARD_NAME, "P4B266"),
1507 .callback = force_acpi_ht,
1508 .ident = "ASUS P2B-DS",
1510 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
1511 DMI_MATCH(DMI_BOARD_NAME, "P2B-DS"),
1515 .callback = force_acpi_ht,
1516 .ident = "ASUS CUR-DLS",
1518 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
1519 DMI_MATCH(DMI_BOARD_NAME, "CUR-DLS"),
1523 .callback = force_acpi_ht,
1524 .ident = "ABIT i440BX-W83977",
1526 DMI_MATCH(DMI_BOARD_VENDOR, "ABIT <http://www.abit.com>"),
1527 DMI_MATCH(DMI_BOARD_NAME, "i440BX-W83977 (BP6)"),
1531 .callback = force_acpi_ht,
1532 .ident = "IBM Bladecenter",
1534 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
1535 DMI_MATCH(DMI_BOARD_NAME, "IBM eServer BladeCenter HS20"),
1539 .callback = force_acpi_ht,
1540 .ident = "IBM eServer xSeries 360",
1542 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
1543 DMI_MATCH(DMI_BOARD_NAME, "eServer xSeries 360"),
1547 .callback = force_acpi_ht,
1548 .ident = "IBM eserver xSeries 330",
1550 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
1551 DMI_MATCH(DMI_BOARD_NAME, "eserver xSeries 330"),
1555 .callback = force_acpi_ht,
1556 .ident = "IBM eserver xSeries 440",
1558 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
1559 DMI_MATCH(DMI_PRODUCT_NAME, "eserver xSeries 440"),
1564 * Boxes that need ACPI PCI IRQ routing disabled
1567 .callback = disable_acpi_irq,
1568 .ident = "ASUS A7V",
1570 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC"),
1571 DMI_MATCH(DMI_BOARD_NAME, "<A7V>"),
1572 /* newer BIOS, Revision 1011, does work */
1573 DMI_MATCH(DMI_BIOS_VERSION,
1574 "ASUS A7V ACPI BIOS Revision 1007"),
1579 * Latest BIOS for IBM 600E (1.16) has bad pcinum
1580 * for LPC bridge, which is needed for the PCI
1581 * interrupt links to work. DSDT fix is in bug 5966.
1582 * 2645, 2646 model numbers are shared with 600/600E/600X
1584 .callback = disable_acpi_irq,
1585 .ident = "IBM Thinkpad 600 Series 2645",
1587 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
1588 DMI_MATCH(DMI_BOARD_NAME, "2645"),
1592 .callback = disable_acpi_irq,
1593 .ident = "IBM Thinkpad 600 Series 2646",
1595 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
1596 DMI_MATCH(DMI_BOARD_NAME, "2646"),
1600 * Boxes that need ACPI PCI IRQ routing and PCI scan disabled
1603 .callback = disable_acpi_pci,
1604 .ident = "ASUS PR-DLS",
1606 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
1607 DMI_MATCH(DMI_BOARD_NAME, "PR-DLS"),
1608 DMI_MATCH(DMI_BIOS_VERSION,
1609 "ASUS PR-DLS ACPI BIOS Revision 1010"),
1610 DMI_MATCH(DMI_BIOS_DATE, "03/21/2003")
1614 .callback = disable_acpi_pci,
1615 .ident = "Acer TravelMate 36x Laptop",
1617 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
1618 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 360"),
1624 /* second table for DMI checks that should run after early-quirks */
1625 static struct dmi_system_id __initdata acpi_dmi_table_late[] = {
1627 * HP laptops which use a DSDT reporting as HP/SB400/10000,
1628 * which includes some code which overrides all temperature
1629 * trip points to 16C if the INTIN2 input of the I/O APIC
1630 * is enabled. This input is incorrectly designated the
1631 * ISA IRQ 0 via an interrupt source override even though
1632 * it is wired to the output of the master 8259A and INTIN0
1633 * is not connected at all. Force ignoring BIOS IRQ0 pin2
1634 * override in that cases.
1637 .callback = dmi_ignore_irq0_timer_override,
1638 .ident = "HP nx6115 laptop",
1640 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
1641 DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq nx6115"),
1645 .callback = dmi_ignore_irq0_timer_override,
1646 .ident = "HP NX6125 laptop",
1648 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
1649 DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq nx6125"),
1653 .callback = dmi_ignore_irq0_timer_override,
1654 .ident = "HP NX6325 laptop",
1656 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
1657 DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq nx6325"),
1661 .callback = dmi_ignore_irq0_timer_override,
1662 .ident = "HP 6715b laptop",
1664 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
1665 DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq 6715b"),
1672 * acpi_boot_table_init() and acpi_boot_init()
1673 * called from setup_arch(), always.
1674 * 1. checksums all tables
1675 * 2. enumerates lapics
1676 * 3. enumerates io-apics
1678 * acpi_table_init() is separate to allow reading SRAT without
1679 * other side effects.
1681 * side effects of acpi_boot_init:
1682 * acpi_lapic = 1 if LAPIC found
1683 * acpi_ioapic = 1 if IOAPIC found
1684 * if (acpi_lapic && acpi_ioapic) smp_found_config = 1;
1685 * if acpi_blacklisted() acpi_disabled = 1;
1686 * acpi_irq_model=...
1689 * return value: (currently ignored)
1694 int __init acpi_boot_table_init(void)
1698 dmi_check_system(acpi_dmi_table);
1701 * If acpi_disabled, bail out
1702 * One exception: acpi=ht continues far enough to enumerate LAPICs
1704 if (acpi_disabled && !acpi_ht)
1708 * Initialize the ACPI boot-time table parser.
1710 error = acpi_table_init();
1716 acpi_table_parse(ACPI_SIG_BOOT, acpi_parse_sbf);
1719 * blacklist may disable ACPI entirely
1721 error = acpi_blacklisted();
1724 printk(KERN_WARNING PREFIX "acpi=force override\n");
1726 printk(KERN_WARNING PREFIX "Disabling ACPI support\n");
1735 int __init early_acpi_boot_init(void)
1738 * If acpi_disabled, bail out
1739 * One exception: acpi=ht continues far enough to enumerate LAPICs
1741 if (acpi_disabled && !acpi_ht)
1745 * Process the Multiple APIC Description Table (MADT), if present
1747 early_acpi_process_madt();
1752 int __init acpi_boot_init(void)
1754 /* those are executed after early-quirks are executed */
1755 dmi_check_system(acpi_dmi_table_late);
1758 * If acpi_disabled, bail out
1759 * One exception: acpi=ht continues far enough to enumerate LAPICs
1761 if (acpi_disabled && !acpi_ht)
1764 acpi_table_parse(ACPI_SIG_BOOT, acpi_parse_sbf);
1767 * set sci_int and PM timer address
1769 acpi_table_parse(ACPI_SIG_FADT, acpi_parse_fadt);
1772 * Process the Multiple APIC Description Table (MADT), if present
1774 acpi_process_madt();
1776 acpi_table_parse(ACPI_SIG_HPET, acpi_parse_hpet);
1781 static int __init parse_acpi(char *arg)
1786 /* "acpi=off" disables both ACPI table parsing and interpreter */
1787 if (strcmp(arg, "off") == 0) {
1790 /* acpi=force to over-ride black-list */
1791 else if (strcmp(arg, "force") == 0) {
1796 /* acpi=strict disables out-of-spec workarounds */
1797 else if (strcmp(arg, "strict") == 0) {
1800 /* Limit ACPI just to boot-time to enable HT */
1801 else if (strcmp(arg, "ht") == 0) {
1806 /* acpi=rsdt use RSDT instead of XSDT */
1807 else if (strcmp(arg, "rsdt") == 0) {
1808 acpi_rsdt_forced = 1;
1810 /* "acpi=noirq" disables ACPI interrupt routing */
1811 else if (strcmp(arg, "noirq") == 0) {
1814 /* Core will printk when we return error. */
1819 early_param("acpi", parse_acpi);
1821 /* FIXME: Using pci= for an ACPI parameter is a travesty. */
1822 static int __init parse_pci(char *arg)
1824 if (arg && strcmp(arg, "noacpi") == 0)
1828 early_param("pci", parse_pci);
1830 int __init acpi_mps_check(void)
1832 #if defined(CONFIG_X86_LOCAL_APIC) && !defined(CONFIG_X86_MPPARSE)
1833 /* mptable code is not built-in*/
1834 if (acpi_disabled || acpi_noirq) {
1835 printk(KERN_WARNING "MPS support code is not built-in.\n"
1836 "Using acpi=off or acpi=noirq or pci=noacpi "
1837 "may have problem\n");
1844 #ifdef CONFIG_X86_IO_APIC
1845 static int __init parse_acpi_skip_timer_override(char *arg)
1847 acpi_skip_timer_override = 1;
1850 early_param("acpi_skip_timer_override", parse_acpi_skip_timer_override);
1852 static int __init parse_acpi_use_timer_override(char *arg)
1854 acpi_use_timer_override = 1;
1857 early_param("acpi_use_timer_override", parse_acpi_use_timer_override);
1858 #endif /* CONFIG_X86_IO_APIC */
1860 static int __init setup_acpi_sci(char *s)
1864 if (!strcmp(s, "edge"))
1865 acpi_sci_flags = ACPI_MADT_TRIGGER_EDGE |
1866 (acpi_sci_flags & ~ACPI_MADT_TRIGGER_MASK);
1867 else if (!strcmp(s, "level"))
1868 acpi_sci_flags = ACPI_MADT_TRIGGER_LEVEL |
1869 (acpi_sci_flags & ~ACPI_MADT_TRIGGER_MASK);
1870 else if (!strcmp(s, "high"))
1871 acpi_sci_flags = ACPI_MADT_POLARITY_ACTIVE_HIGH |
1872 (acpi_sci_flags & ~ACPI_MADT_POLARITY_MASK);
1873 else if (!strcmp(s, "low"))
1874 acpi_sci_flags = ACPI_MADT_POLARITY_ACTIVE_LOW |
1875 (acpi_sci_flags & ~ACPI_MADT_POLARITY_MASK);
1880 early_param("acpi_sci", setup_acpi_sci);
1882 int __acpi_acquire_global_lock(unsigned int *lock)
1884 unsigned int old, new, val;
1887 new = (((old & ~0x3) + 2) + ((old >> 1) & 0x1));
1888 val = cmpxchg(lock, old, new);
1889 } while (unlikely (val != old));
1890 return (new < 3) ? -1 : 0;
1893 int __acpi_release_global_lock(unsigned int *lock)
1895 unsigned int old, new, val;
1899 val = cmpxchg(lock, old, new);
1900 } while (unlikely (val != old));