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>
61 #include <asm/genapic.h>
65 #ifdef CONFIG_X86_LOCAL_APIC
66 #include <mach_apic.h>
67 #include <mach_mpparse.h>
68 #endif /* CONFIG_X86_LOCAL_APIC */
72 #define BAD_MADT_ENTRY(entry, end) ( \
73 (!entry) || (unsigned long)entry + sizeof(*entry) > end || \
74 ((struct acpi_subtable_header *)entry)->length < sizeof(*entry))
76 #define PREFIX "ACPI: "
78 int acpi_noirq; /* skip ACPI IRQ initialization */
79 int acpi_pci_disabled; /* skip ACPI PCI scan and IRQ initialization */
80 EXPORT_SYMBOL(acpi_pci_disabled);
81 int acpi_ht __initdata = 1; /* enable HT */
87 u8 acpi_sci_flags __initdata;
88 int acpi_sci_override_gsi __initdata;
89 int acpi_skip_timer_override __initdata;
90 int acpi_use_timer_override __initdata;
92 #ifdef CONFIG_X86_LOCAL_APIC
93 static u64 acpi_lapic_addr __initdata = APIC_DEFAULT_PHYS_BASE;
96 #ifndef __HAVE_ARCH_CMPXCHG
97 #warning ACPI uses CMPXCHG, i486 and later hardware
101 /* --------------------------------------------------------------------------
102 Boot-time Configuration
103 -------------------------------------------------------------------------- */
106 * The default interrupt routing model is PIC (8259). This gets
107 * overridden if IOAPICs are enumerated (below).
109 enum acpi_irq_model_id acpi_irq_model = ACPI_IRQ_MODEL_PIC;
113 * Temporarily use the virtual area starting from FIX_IO_APIC_BASE_END,
114 * to map the target physical address. The problem is that set_fixmap()
115 * provides a single page, and it is possible that the page is not
117 * By using this area, we can map up to MAX_IO_APICS pages temporarily,
118 * i.e. until the next __va_range() call.
120 * Important Safety Note: The fixed I/O APIC page numbers are *subtracted*
121 * from the fixed base. That's why we start at FIX_IO_APIC_BASE_END and
122 * count idx down while incrementing the phys address.
124 char *__init __acpi_map_table(unsigned long phys, unsigned long size)
126 unsigned long base, offset, mapped_size;
132 if (phys+size <= (max_low_pfn_mapped << PAGE_SHIFT))
135 offset = phys & (PAGE_SIZE - 1);
136 mapped_size = PAGE_SIZE - offset;
137 clear_fixmap(FIX_ACPI_END);
138 set_fixmap(FIX_ACPI_END, phys);
139 base = fix_to_virt(FIX_ACPI_END);
142 * Most cases can be covered by the below.
145 while (mapped_size < size) {
146 if (--idx < FIX_ACPI_BEGIN)
147 return NULL; /* cannot handle this */
150 set_fixmap(idx, phys);
151 mapped_size += PAGE_SIZE;
154 return ((unsigned char *)base + offset);
157 #ifdef CONFIG_PCI_MMCONFIG
159 static int acpi_mcfg_64bit_base_addr __initdata = FALSE;
161 /* The physical address of the MMCONFIG aperture. Set from ACPI tables. */
162 struct acpi_mcfg_allocation *pci_mmcfg_config;
163 int pci_mmcfg_config_num;
165 static int __init acpi_mcfg_oem_check(struct acpi_table_mcfg *mcfg)
167 if (!strcmp(mcfg->header.oem_id, "SGI"))
168 acpi_mcfg_64bit_base_addr = TRUE;
173 int __init acpi_parse_mcfg(struct acpi_table_header *header)
175 struct acpi_table_mcfg *mcfg;
182 mcfg = (struct acpi_table_mcfg *)header;
184 /* how many config structures do we have */
185 pci_mmcfg_config_num = 0;
186 i = header->length - sizeof(struct acpi_table_mcfg);
187 while (i >= sizeof(struct acpi_mcfg_allocation)) {
188 ++pci_mmcfg_config_num;
189 i -= sizeof(struct acpi_mcfg_allocation);
191 if (pci_mmcfg_config_num == 0) {
192 printk(KERN_ERR PREFIX "MMCONFIG has no entries\n");
196 config_size = pci_mmcfg_config_num * sizeof(*pci_mmcfg_config);
197 pci_mmcfg_config = kmalloc(config_size, GFP_KERNEL);
198 if (!pci_mmcfg_config) {
199 printk(KERN_WARNING PREFIX
200 "No memory for MCFG config tables\n");
204 memcpy(pci_mmcfg_config, &mcfg[1], config_size);
206 acpi_mcfg_oem_check(mcfg);
208 for (i = 0; i < pci_mmcfg_config_num; ++i) {
209 if ((pci_mmcfg_config[i].address > 0xFFFFFFFF) &&
210 !acpi_mcfg_64bit_base_addr) {
211 printk(KERN_ERR PREFIX
212 "MMCONFIG not in low 4GB of memory\n");
213 kfree(pci_mmcfg_config);
214 pci_mmcfg_config_num = 0;
221 #endif /* CONFIG_PCI_MMCONFIG */
223 #ifdef CONFIG_X86_LOCAL_APIC
224 static int __init acpi_parse_madt(struct acpi_table_header *table)
226 struct acpi_table_madt *madt = NULL;
231 madt = (struct acpi_table_madt *)table;
233 printk(KERN_WARNING PREFIX "Unable to map MADT\n");
238 acpi_lapic_addr = (u64) madt->address;
240 printk(KERN_DEBUG PREFIX "Local APIC address 0x%08x\n",
244 acpi_madt_oem_check(madt->header.oem_id, madt->header.oem_table_id);
249 static void __cpuinit acpi_register_lapic(int id, u8 enabled)
251 unsigned int ver = 0;
259 if (boot_cpu_physical_apicid != -1U)
260 ver = apic_version[boot_cpu_physical_apicid];
263 generic_processor_info(id, ver);
267 acpi_parse_lapic(struct acpi_subtable_header * header, const unsigned long end)
269 struct acpi_madt_local_apic *processor = NULL;
271 processor = (struct acpi_madt_local_apic *)header;
273 if (BAD_MADT_ENTRY(processor, end))
276 acpi_table_print_madt_entry(header);
279 * We need to register disabled CPU as well to permit
280 * counting disabled CPUs. This allows us to size
281 * cpus_possible_map more accurately, to permit
282 * to not preallocating memory for all NR_CPUS
283 * when we use CPU hotplug.
285 acpi_register_lapic(processor->id, /* APIC ID */
286 processor->lapic_flags & ACPI_MADT_ENABLED);
292 acpi_parse_sapic(struct acpi_subtable_header *header, const unsigned long end)
294 struct acpi_madt_local_sapic *processor = NULL;
296 processor = (struct acpi_madt_local_sapic *)header;
298 if (BAD_MADT_ENTRY(processor, end))
301 acpi_table_print_madt_entry(header);
303 acpi_register_lapic((processor->id << 8) | processor->eid,/* APIC ID */
304 processor->lapic_flags & ACPI_MADT_ENABLED);
310 acpi_parse_lapic_addr_ovr(struct acpi_subtable_header * header,
311 const unsigned long end)
313 struct acpi_madt_local_apic_override *lapic_addr_ovr = NULL;
315 lapic_addr_ovr = (struct acpi_madt_local_apic_override *)header;
317 if (BAD_MADT_ENTRY(lapic_addr_ovr, end))
320 acpi_lapic_addr = lapic_addr_ovr->address;
326 acpi_parse_lapic_nmi(struct acpi_subtable_header * header, const unsigned long end)
328 struct acpi_madt_local_apic_nmi *lapic_nmi = NULL;
330 lapic_nmi = (struct acpi_madt_local_apic_nmi *)header;
332 if (BAD_MADT_ENTRY(lapic_nmi, end))
335 acpi_table_print_madt_entry(header);
337 if (lapic_nmi->lint != 1)
338 printk(KERN_WARNING PREFIX "NMI not connected to LINT 1!\n");
343 #endif /*CONFIG_X86_LOCAL_APIC */
345 #ifdef CONFIG_X86_IO_APIC
348 acpi_parse_ioapic(struct acpi_subtable_header * header, const unsigned long end)
350 struct acpi_madt_io_apic *ioapic = NULL;
352 ioapic = (struct acpi_madt_io_apic *)header;
354 if (BAD_MADT_ENTRY(ioapic, end))
357 acpi_table_print_madt_entry(header);
359 mp_register_ioapic(ioapic->id,
360 ioapic->address, ioapic->global_irq_base);
366 * Parse Interrupt Source Override for the ACPI SCI
368 static void __init acpi_sci_ioapic_setup(u32 gsi, u16 polarity, u16 trigger)
370 if (trigger == 0) /* compatible SCI trigger is level */
373 if (polarity == 0) /* compatible SCI polarity is low */
376 /* Command-line over-ride via acpi_sci= */
377 if (acpi_sci_flags & ACPI_MADT_TRIGGER_MASK)
378 trigger = (acpi_sci_flags & ACPI_MADT_TRIGGER_MASK) >> 2;
380 if (acpi_sci_flags & ACPI_MADT_POLARITY_MASK)
381 polarity = acpi_sci_flags & ACPI_MADT_POLARITY_MASK;
384 * mp_config_acpi_legacy_irqs() already setup IRQs < 16
385 * If GSI is < 16, this will update its flags,
386 * else it will create a new mp_irqs[] entry.
388 mp_override_legacy_irq(gsi, polarity, trigger, gsi);
391 * stash over-ride to indicate we've been here
392 * and for later update of acpi_gbl_FADT
394 acpi_sci_override_gsi = gsi;
399 acpi_parse_int_src_ovr(struct acpi_subtable_header * header,
400 const unsigned long end)
402 struct acpi_madt_interrupt_override *intsrc = NULL;
404 intsrc = (struct acpi_madt_interrupt_override *)header;
406 if (BAD_MADT_ENTRY(intsrc, end))
409 acpi_table_print_madt_entry(header);
411 if (intsrc->source_irq == acpi_gbl_FADT.sci_interrupt) {
412 acpi_sci_ioapic_setup(intsrc->global_irq,
413 intsrc->inti_flags & ACPI_MADT_POLARITY_MASK,
414 (intsrc->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2);
418 if (acpi_skip_timer_override &&
419 intsrc->source_irq == 0 && intsrc->global_irq == 2) {
420 printk(PREFIX "BIOS IRQ0 pin2 override ignored.\n");
424 mp_override_legacy_irq(intsrc->source_irq,
425 intsrc->inti_flags & ACPI_MADT_POLARITY_MASK,
426 (intsrc->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2,
433 acpi_parse_nmi_src(struct acpi_subtable_header * header, const unsigned long end)
435 struct acpi_madt_nmi_source *nmi_src = NULL;
437 nmi_src = (struct acpi_madt_nmi_source *)header;
439 if (BAD_MADT_ENTRY(nmi_src, end))
442 acpi_table_print_madt_entry(header);
444 /* TBD: Support nimsrc entries? */
449 #endif /* CONFIG_X86_IO_APIC */
452 * acpi_pic_sci_set_trigger()
454 * use ELCR to set PIC-mode trigger type for SCI
456 * If a PIC-mode SCI is not recognized or gives spurious IRQ7's
457 * it may require Edge Trigger -- use "acpi_sci=edge"
459 * Port 0x4d0-4d1 are ECLR1 and ECLR2, the Edge/Level Control Registers
460 * for the 8259 PIC. bit[n] = 1 means irq[n] is Level, otherwise Edge.
461 * ECLR1 is IRQs 0-7 (IRQ 0, 1, 2 must be 0)
462 * ECLR2 is IRQs 8-15 (IRQ 8, 13 must be 0)
465 void __init acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger)
467 unsigned int mask = 1 << irq;
468 unsigned int old, new;
470 /* Real old ELCR mask */
471 old = inb(0x4d0) | (inb(0x4d1) << 8);
474 * If we use ACPI to set PCI IRQs, then we should clear ELCR
475 * since we will set it correctly as we enable the PCI irq
478 new = acpi_noirq ? old : 0;
481 * Update SCI information in the ELCR, it isn't in the PCI
485 case 1: /* Edge - clear */
488 case 3: /* Level - set */
496 printk(PREFIX "setting ELCR to %04x (from %04x)\n", new, old);
498 outb(new >> 8, 0x4d1);
501 int acpi_gsi_to_irq(u32 gsi, unsigned int *irq)
508 * success: return IRQ number (>=0)
509 * failure: return < 0
511 int acpi_register_gsi(u32 gsi, int triggering, int polarity)
514 unsigned int plat_gsi = gsi;
518 * Make sure all (legacy) PCI IRQs are set as level-triggered.
520 if (acpi_irq_model == ACPI_IRQ_MODEL_PIC) {
521 if (triggering == ACPI_LEVEL_SENSITIVE)
522 eisa_set_level_irq(gsi);
526 #ifdef CONFIG_X86_IO_APIC
527 if (acpi_irq_model == ACPI_IRQ_MODEL_IOAPIC) {
528 plat_gsi = mp_register_gsi(gsi, triggering, polarity);
531 acpi_gsi_to_irq(plat_gsi, &irq);
536 * ACPI based hotplug support for CPU
538 #ifdef CONFIG_ACPI_HOTPLUG_CPU
540 static int __cpuinit _acpi_map_lsapic(acpi_handle handle, int *pcpu)
542 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
543 union acpi_object *obj;
544 struct acpi_madt_local_apic *lapic;
545 cpumask_t tmp_map, new_map;
549 if (ACPI_FAILURE(acpi_evaluate_object(handle, "_MAT", NULL, &buffer)))
552 if (!buffer.length || !buffer.pointer)
555 obj = buffer.pointer;
556 if (obj->type != ACPI_TYPE_BUFFER ||
557 obj->buffer.length < sizeof(*lapic)) {
558 kfree(buffer.pointer);
562 lapic = (struct acpi_madt_local_apic *)obj->buffer.pointer;
564 if (lapic->header.type != ACPI_MADT_TYPE_LOCAL_APIC ||
565 !(lapic->lapic_flags & ACPI_MADT_ENABLED)) {
566 kfree(buffer.pointer);
572 kfree(buffer.pointer);
573 buffer.length = ACPI_ALLOCATE_BUFFER;
574 buffer.pointer = NULL;
576 tmp_map = cpu_present_map;
577 acpi_register_lapic(physid, lapic->lapic_flags & ACPI_MADT_ENABLED);
580 * If mp_register_lapic successfully generates a new logical cpu
581 * number, then the following will get us exactly what was mapped
583 cpus_andnot(new_map, cpu_present_map, tmp_map);
584 if (cpus_empty(new_map)) {
585 printk ("Unable to map lapic to logical cpu number\n");
589 cpu = first_cpu(new_map);
595 /* wrapper to silence section mismatch warning */
596 int __ref acpi_map_lsapic(acpi_handle handle, int *pcpu)
598 return _acpi_map_lsapic(handle, pcpu);
600 EXPORT_SYMBOL(acpi_map_lsapic);
602 int acpi_unmap_lsapic(int cpu)
604 per_cpu(x86_cpu_to_apicid, cpu) = -1;
605 cpu_clear(cpu, cpu_present_map);
611 EXPORT_SYMBOL(acpi_unmap_lsapic);
612 #endif /* CONFIG_ACPI_HOTPLUG_CPU */
614 int acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base)
620 EXPORT_SYMBOL(acpi_register_ioapic);
622 int acpi_unregister_ioapic(acpi_handle handle, u32 gsi_base)
628 EXPORT_SYMBOL(acpi_unregister_ioapic);
630 static int __init acpi_parse_sbf(struct acpi_table_header *table)
632 struct acpi_table_boot *sb;
634 sb = (struct acpi_table_boot *)table;
636 printk(KERN_WARNING PREFIX "Unable to map SBF\n");
640 sbf_port = sb->cmos_index; /* Save CMOS port */
645 #ifdef CONFIG_HPET_TIMER
646 #include <asm/hpet.h>
648 static struct __initdata resource *hpet_res;
650 static int __init acpi_parse_hpet(struct acpi_table_header *table)
652 struct acpi_table_hpet *hpet_tbl;
654 hpet_tbl = (struct acpi_table_hpet *)table;
656 printk(KERN_WARNING PREFIX "Unable to map HPET\n");
660 if (hpet_tbl->address.space_id != ACPI_SPACE_MEM) {
661 printk(KERN_WARNING PREFIX "HPET timers must be located in "
666 hpet_address = hpet_tbl->address.address;
669 * Some broken BIOSes advertise HPET at 0x0. We really do not
670 * want to allocate a resource there.
673 printk(KERN_WARNING PREFIX
674 "HPET id: %#x base: %#lx is invalid\n",
675 hpet_tbl->id, hpet_address);
680 * Some even more broken BIOSes advertise HPET at
681 * 0xfed0000000000000 instead of 0xfed00000. Fix it up and add
684 if (hpet_address == 0xfed0000000000000UL) {
685 if (!hpet_force_user) {
686 printk(KERN_WARNING PREFIX "HPET id: %#x "
687 "base: 0xfed0000000000000 is bogus\n "
688 "try hpet=force on the kernel command line to "
689 "fix it up to 0xfed00000.\n", hpet_tbl->id);
693 printk(KERN_WARNING PREFIX
694 "HPET id: %#x base: 0xfed0000000000000 fixed up "
695 "to 0xfed00000.\n", hpet_tbl->id);
699 printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n",
700 hpet_tbl->id, hpet_address);
703 * Allocate and initialize the HPET firmware resource for adding into
704 * the resource tree during the lateinit timeframe.
706 #define HPET_RESOURCE_NAME_SIZE 9
707 hpet_res = alloc_bootmem(sizeof(*hpet_res) + HPET_RESOURCE_NAME_SIZE);
709 hpet_res->name = (void *)&hpet_res[1];
710 hpet_res->flags = IORESOURCE_MEM;
711 snprintf((char *)hpet_res->name, HPET_RESOURCE_NAME_SIZE, "HPET %u",
714 hpet_res->start = hpet_address;
715 hpet_res->end = hpet_address + (1 * 1024) - 1;
721 * hpet_insert_resource inserts the HPET resources used into the resource
724 static __init int hpet_insert_resource(void)
729 return insert_resource(&iomem_resource, hpet_res);
732 late_initcall(hpet_insert_resource);
735 #define acpi_parse_hpet NULL
738 static int __init acpi_parse_fadt(struct acpi_table_header *table)
741 #ifdef CONFIG_X86_PM_TIMER
742 /* detect the location of the ACPI PM Timer */
743 if (acpi_gbl_FADT.header.revision >= FADT2_REVISION_ID) {
745 if (acpi_gbl_FADT.xpm_timer_block.space_id !=
746 ACPI_ADR_SPACE_SYSTEM_IO)
749 pmtmr_ioport = acpi_gbl_FADT.xpm_timer_block.address;
751 * "X" fields are optional extensions to the original V1.0
752 * fields, so we must selectively expand V1.0 fields if the
753 * corresponding X field is zero.
756 pmtmr_ioport = acpi_gbl_FADT.pm_timer_block;
759 pmtmr_ioport = acpi_gbl_FADT.pm_timer_block;
762 printk(KERN_INFO PREFIX "PM-Timer IO Port: %#x\n",
768 #ifdef CONFIG_X86_LOCAL_APIC
770 * Parse LAPIC entries in MADT
771 * returns 0 on success, < 0 on error
774 static void __init acpi_register_lapic_address(unsigned long address)
776 mp_lapic_addr = address;
778 set_fixmap_nocache(FIX_APIC_BASE, address);
779 if (boot_cpu_physical_apicid == -1U) {
780 boot_cpu_physical_apicid = GET_APIC_ID(read_apic_id());
782 apic_version[boot_cpu_physical_apicid] =
783 GET_APIC_VERSION(apic_read(APIC_LVR));
788 static int __init early_acpi_parse_madt_lapic_addr_ovr(void)
796 * Note that the LAPIC address is obtained from the MADT (32-bit value)
797 * and (optionally) overriden by a LAPIC_ADDR_OVR entry (64-bit value).
801 acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE,
802 acpi_parse_lapic_addr_ovr, 0);
804 printk(KERN_ERR PREFIX
805 "Error parsing LAPIC address override entry\n");
809 acpi_register_lapic_address(acpi_lapic_addr);
814 static int __init acpi_parse_madt_lapic_entries(void)
822 * Note that the LAPIC address is obtained from the MADT (32-bit value)
823 * and (optionally) overriden by a LAPIC_ADDR_OVR entry (64-bit value).
827 acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE,
828 acpi_parse_lapic_addr_ovr, 0);
830 printk(KERN_ERR PREFIX
831 "Error parsing LAPIC address override entry\n");
835 acpi_register_lapic_address(acpi_lapic_addr);
837 count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_SAPIC,
838 acpi_parse_sapic, MAX_APICS);
841 count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC,
842 acpi_parse_lapic, MAX_APICS);
844 printk(KERN_ERR PREFIX "No LAPIC entries present\n");
845 /* TBD: Cleanup to allow fallback to MPS */
847 } else if (count < 0) {
848 printk(KERN_ERR PREFIX "Error parsing LAPIC entry\n");
849 /* TBD: Cleanup to allow fallback to MPS */
854 acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC_NMI, acpi_parse_lapic_nmi, 0);
856 printk(KERN_ERR PREFIX "Error parsing LAPIC NMI entry\n");
857 /* TBD: Cleanup to allow fallback to MPS */
862 #endif /* CONFIG_X86_LOCAL_APIC */
864 #ifdef CONFIG_X86_IO_APIC
867 #ifdef CONFIG_X86_ES7000
868 extern int es7000_plat;
875 DECLARE_BITMAP(pin_programmed, MP_MAX_IOAPIC_PIN + 1);
876 } mp_ioapic_routing[MAX_IO_APICS];
878 static int mp_find_ioapic(int gsi)
882 /* Find the IOAPIC that manages this GSI. */
883 for (i = 0; i < nr_ioapics; i++) {
884 if ((gsi >= mp_ioapic_routing[i].gsi_base)
885 && (gsi <= mp_ioapic_routing[i].gsi_end))
889 printk(KERN_ERR "ERROR: Unable to locate IOAPIC for GSI %d\n", gsi);
893 static u8 __init uniq_ioapic_id(u8 id)
896 if ((boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) &&
897 !APIC_XAPIC(apic_version[boot_cpu_physical_apicid]))
898 return io_apic_get_unique_id(nr_ioapics, id);
903 DECLARE_BITMAP(used, 256);
904 bitmap_zero(used, 256);
905 for (i = 0; i < nr_ioapics; i++) {
906 struct mp_config_ioapic *ia = &mp_ioapics[i];
907 __set_bit(ia->mp_apicid, used);
909 if (!test_bit(id, used))
911 return find_first_zero_bit(used, 256);
915 static int bad_ioapic(unsigned long address)
917 if (nr_ioapics >= MAX_IO_APICS) {
918 printk(KERN_ERR "ERROR: Max # of I/O APICs (%d) exceeded "
919 "(found %d)\n", MAX_IO_APICS, nr_ioapics);
920 panic("Recompile kernel with bigger MAX_IO_APICS!\n");
923 printk(KERN_ERR "WARNING: Bogus (zero) I/O APIC address"
924 " found in table, skipping!\n");
930 void __init mp_register_ioapic(int id, u32 address, u32 gsi_base)
934 if (bad_ioapic(address))
939 mp_ioapics[idx].mp_type = MP_IOAPIC;
940 mp_ioapics[idx].mp_flags = MPC_APIC_USABLE;
941 mp_ioapics[idx].mp_apicaddr = address;
943 set_fixmap_nocache(FIX_IO_APIC_BASE_0 + idx, address);
944 mp_ioapics[idx].mp_apicid = uniq_ioapic_id(id);
946 mp_ioapics[idx].mp_apicver = io_apic_get_version(idx);
948 mp_ioapics[idx].mp_apicver = 0;
951 * Build basic GSI lookup table to facilitate gsi->io_apic lookups
952 * and to prevent reprogramming of IOAPIC pins (PCI GSIs).
954 mp_ioapic_routing[idx].apic_id = mp_ioapics[idx].mp_apicid;
955 mp_ioapic_routing[idx].gsi_base = gsi_base;
956 mp_ioapic_routing[idx].gsi_end = gsi_base +
957 io_apic_get_redir_entries(idx);
959 printk(KERN_INFO "IOAPIC[%d]: apic_id %d, version %d, address 0x%lx, "
960 "GSI %d-%d\n", idx, mp_ioapics[idx].mp_apicid,
961 mp_ioapics[idx].mp_apicver, mp_ioapics[idx].mp_apicaddr,
962 mp_ioapic_routing[idx].gsi_base, mp_ioapic_routing[idx].gsi_end);
967 static void assign_to_mp_irq(struct mp_config_intsrc *m,
968 struct mp_config_intsrc *mp_irq)
970 memcpy(mp_irq, m, sizeof(struct mp_config_intsrc));
973 static int mp_irq_cmp(struct mp_config_intsrc *mp_irq,
974 struct mp_config_intsrc *m)
976 return memcmp(mp_irq, m, sizeof(struct mp_config_intsrc));
979 static void save_mp_irq(struct mp_config_intsrc *m)
983 for (i = 0; i < mp_irq_entries; i++) {
984 if (!mp_irq_cmp(&mp_irqs[i], m))
988 assign_to_mp_irq(m, &mp_irqs[mp_irq_entries]);
989 if (++mp_irq_entries == MAX_IRQ_SOURCES)
990 panic("Max # of irq sources exceeded!!\n");
993 void __init mp_override_legacy_irq(u8 bus_irq, u8 polarity, u8 trigger, u32 gsi)
997 struct mp_config_intsrc mp_irq;
1000 * Convert 'gsi' to 'ioapic.pin'.
1002 ioapic = mp_find_ioapic(gsi);
1005 pin = gsi - mp_ioapic_routing[ioapic].gsi_base;
1008 * TBD: This check is for faulty timer entries, where the override
1009 * erroneously sets the trigger to level, resulting in a HUGE
1010 * increase of timer interrupts!
1012 if ((bus_irq == 0) && (trigger == 3))
1015 mp_irq.mp_type = MP_INTSRC;
1016 mp_irq.mp_irqtype = mp_INT;
1017 mp_irq.mp_irqflag = (trigger << 2) | polarity;
1018 mp_irq.mp_srcbus = MP_ISA_BUS;
1019 mp_irq.mp_srcbusirq = bus_irq; /* IRQ */
1020 mp_irq.mp_dstapic = mp_ioapics[ioapic].mp_apicid; /* APIC ID */
1021 mp_irq.mp_dstirq = pin; /* INTIN# */
1023 save_mp_irq(&mp_irq);
1026 void __init mp_config_acpi_legacy_irqs(void)
1030 unsigned int dstapic;
1031 struct mp_config_intsrc mp_irq;
1033 #if defined (CONFIG_MCA) || defined (CONFIG_EISA)
1035 * Fabricate the legacy ISA bus (bus #31).
1037 mp_bus_id_to_type[MP_ISA_BUS] = MP_BUS_ISA;
1039 set_bit(MP_ISA_BUS, mp_bus_not_pci);
1040 pr_debug("Bus #%d is ISA\n", MP_ISA_BUS);
1042 #ifdef CONFIG_X86_ES7000
1044 * Older generations of ES7000 have no legacy identity mappings
1046 if (es7000_plat == 1)
1051 * Locate the IOAPIC that manages the ISA IRQs (0-15).
1053 ioapic = mp_find_ioapic(0);
1056 dstapic = mp_ioapics[ioapic].mp_apicid;
1059 * Use the default configuration for the IRQs 0-15. Unless
1060 * overridden by (MADT) interrupt source override entries.
1062 for (i = 0; i < 16; i++) {
1065 for (idx = 0; idx < mp_irq_entries; idx++) {
1066 struct mp_config_intsrc *irq = mp_irqs + idx;
1068 /* Do we already have a mapping for this ISA IRQ? */
1069 if (irq->mp_srcbus == MP_ISA_BUS
1070 && irq->mp_srcbusirq == i)
1073 /* Do we already have a mapping for this IOAPIC pin */
1074 if (irq->mp_dstapic == dstapic &&
1075 irq->mp_dstirq == i)
1079 if (idx != mp_irq_entries) {
1080 printk(KERN_DEBUG "ACPI: IRQ%d used by override.\n", i);
1081 continue; /* IRQ already used */
1084 mp_irq.mp_type = MP_INTSRC;
1085 mp_irq.mp_irqflag = 0; /* Conforming */
1086 mp_irq.mp_srcbus = MP_ISA_BUS;
1087 mp_irq.mp_dstapic = dstapic;
1088 mp_irq.mp_irqtype = mp_INT;
1089 mp_irq.mp_srcbusirq = i; /* Identity mapped */
1090 mp_irq.mp_dstirq = i;
1092 save_mp_irq(&mp_irq);
1096 int mp_register_gsi(u32 gsi, int triggering, int polarity)
1100 #ifdef CONFIG_X86_32
1101 #define MAX_GSI_NUM 4096
1102 #define IRQ_COMPRESSION_START 64
1104 static int pci_irq = IRQ_COMPRESSION_START;
1106 * Mapping between Global System Interrupts, which
1107 * represent all possible interrupts, and IRQs
1108 * assigned to actual devices.
1110 static int gsi_to_irq[MAX_GSI_NUM];
1113 if (acpi_irq_model != ACPI_IRQ_MODEL_IOAPIC)
1117 /* Don't set up the ACPI SCI because it's already set up */
1118 if (acpi_gbl_FADT.sci_interrupt == gsi)
1121 ioapic = mp_find_ioapic(gsi);
1123 printk(KERN_WARNING "No IOAPIC for GSI %u\n", gsi);
1127 ioapic_pin = gsi - mp_ioapic_routing[ioapic].gsi_base;
1129 #ifdef CONFIG_X86_32
1130 if (ioapic_renumber_irq)
1131 gsi = ioapic_renumber_irq(ioapic, gsi);
1135 * Avoid pin reprogramming. PRTs typically include entries
1136 * with redundant pin->gsi mappings (but unique PCI devices);
1137 * we only program the IOAPIC on the first.
1139 if (ioapic_pin > MP_MAX_IOAPIC_PIN) {
1140 printk(KERN_ERR "Invalid reference to IOAPIC pin "
1141 "%d-%d\n", mp_ioapic_routing[ioapic].apic_id,
1145 if (test_bit(ioapic_pin, mp_ioapic_routing[ioapic].pin_programmed)) {
1146 pr_debug(KERN_DEBUG "Pin %d-%d already programmed\n",
1147 mp_ioapic_routing[ioapic].apic_id, ioapic_pin);
1148 #ifdef CONFIG_X86_32
1149 return (gsi < IRQ_COMPRESSION_START ? gsi : gsi_to_irq[gsi]);
1155 set_bit(ioapic_pin, mp_ioapic_routing[ioapic].pin_programmed);
1156 #ifdef CONFIG_X86_32
1158 * For GSI >= 64, use IRQ compression
1160 if ((gsi >= IRQ_COMPRESSION_START)
1161 && (triggering == ACPI_LEVEL_SENSITIVE)) {
1163 * For PCI devices assign IRQs in order, avoiding gaps
1164 * due to unused I/O APIC pins.
1167 if (gsi < MAX_GSI_NUM) {
1169 * Retain the VIA chipset work-around (gsi > 15), but
1170 * avoid a problem where the 8254 timer (IRQ0) is setup
1171 * via an override (so it's not on pin 0 of the ioapic),
1172 * and at the same time, the pin 0 interrupt is a PCI
1173 * type. The gsi > 15 test could cause these two pins
1174 * to be shared as IRQ0, and they are not shareable.
1175 * So test for this condition, and if necessary, avoid
1176 * the pin collision.
1180 * Don't assign IRQ used by ACPI SCI
1182 if (gsi == acpi_gbl_FADT.sci_interrupt)
1184 gsi_to_irq[irq] = gsi;
1186 printk(KERN_ERR "GSI %u is too high\n", gsi);
1191 io_apic_set_pci_routing(ioapic, ioapic_pin, gsi,
1192 triggering == ACPI_EDGE_SENSITIVE ? 0 : 1,
1193 polarity == ACPI_ACTIVE_HIGH ? 0 : 1);
1197 int mp_config_acpi_gsi(unsigned char number, unsigned int devfn, u8 pin,
1198 u32 gsi, int triggering, int polarity)
1200 #ifdef CONFIG_X86_MPPARSE
1201 struct mp_config_intsrc mp_irq;
1207 /* print the entry should happen on mptable identically */
1208 mp_irq.mp_type = MP_INTSRC;
1209 mp_irq.mp_irqtype = mp_INT;
1210 mp_irq.mp_irqflag = (triggering == ACPI_EDGE_SENSITIVE ? 4 : 0x0c) |
1211 (polarity == ACPI_ACTIVE_HIGH ? 1 : 3);
1212 mp_irq.mp_srcbus = number;
1213 mp_irq.mp_srcbusirq = (((devfn >> 3) & 0x1f) << 2) | ((pin - 1) & 3);
1214 ioapic = mp_find_ioapic(gsi);
1215 mp_irq.mp_dstapic = mp_ioapic_routing[ioapic].apic_id;
1216 mp_irq.mp_dstirq = gsi - mp_ioapic_routing[ioapic].gsi_base;
1218 save_mp_irq(&mp_irq);
1224 * Parse IOAPIC related entries in MADT
1225 * returns 0 on success, < 0 on error
1227 static int __init acpi_parse_madt_ioapic_entries(void)
1232 * ACPI interpreter is required to complete interrupt setup,
1233 * so if it is off, don't enumerate the io-apics with ACPI.
1234 * If MPS is present, it will handle them,
1235 * otherwise the system will stay in PIC mode
1237 if (acpi_disabled || acpi_noirq) {
1245 * if "noapic" boot option, don't look for IO-APICs
1247 if (skip_ioapic_setup) {
1248 printk(KERN_INFO PREFIX "Skipping IOAPIC probe "
1249 "due to 'noapic' option.\n");
1254 acpi_table_parse_madt(ACPI_MADT_TYPE_IO_APIC, acpi_parse_ioapic,
1257 printk(KERN_ERR PREFIX "No IOAPIC entries present\n");
1259 } else if (count < 0) {
1260 printk(KERN_ERR PREFIX "Error parsing IOAPIC entry\n");
1265 acpi_table_parse_madt(ACPI_MADT_TYPE_INTERRUPT_OVERRIDE, acpi_parse_int_src_ovr,
1268 printk(KERN_ERR PREFIX
1269 "Error parsing interrupt source overrides entry\n");
1270 /* TBD: Cleanup to allow fallback to MPS */
1275 * If BIOS did not supply an INT_SRC_OVR for the SCI
1276 * pretend we got one so we can set the SCI flags.
1278 if (!acpi_sci_override_gsi)
1279 acpi_sci_ioapic_setup(acpi_gbl_FADT.sci_interrupt, 0, 0);
1281 /* Fill in identity legacy mapings where no override */
1282 mp_config_acpi_legacy_irqs();
1285 acpi_table_parse_madt(ACPI_MADT_TYPE_NMI_SOURCE, acpi_parse_nmi_src,
1288 printk(KERN_ERR PREFIX "Error parsing NMI SRC entry\n");
1289 /* TBD: Cleanup to allow fallback to MPS */
1296 static inline int acpi_parse_madt_ioapic_entries(void)
1300 #endif /* !CONFIG_X86_IO_APIC */
1302 static void __init early_acpi_process_madt(void)
1304 #ifdef CONFIG_X86_LOCAL_APIC
1307 if (!acpi_table_parse(ACPI_SIG_MADT, acpi_parse_madt)) {
1310 * Parse MADT LAPIC entries
1312 error = early_acpi_parse_madt_lapic_addr_ovr();
1315 smp_found_config = 1;
1317 if (error == -EINVAL) {
1319 * Dell Precision Workstation 410, 610 come here.
1321 printk(KERN_ERR PREFIX
1322 "Invalid BIOS MADT, disabling ACPI\n");
1329 static void __init acpi_process_madt(void)
1331 #ifdef CONFIG_X86_LOCAL_APIC
1334 if (!acpi_table_parse(ACPI_SIG_MADT, acpi_parse_madt)) {
1337 * Parse MADT LAPIC entries
1339 error = acpi_parse_madt_lapic_entries();
1343 #ifdef CONFIG_X86_GENERICARCH
1344 generic_bigsmp_probe();
1347 * Parse MADT IO-APIC entries
1349 error = acpi_parse_madt_ioapic_entries();
1351 acpi_irq_model = ACPI_IRQ_MODEL_IOAPIC;
1352 acpi_irq_balance_set(NULL);
1355 smp_found_config = 1;
1356 setup_apic_routing();
1359 if (error == -EINVAL) {
1361 * Dell Precision Workstation 410, 610 come here.
1363 printk(KERN_ERR PREFIX
1364 "Invalid BIOS MADT, disabling ACPI\n");
1372 static int __init disable_acpi_irq(const struct dmi_system_id *d)
1375 printk(KERN_NOTICE "%s detected: force use of acpi=noirq\n",
1382 static int __init disable_acpi_pci(const struct dmi_system_id *d)
1385 printk(KERN_NOTICE "%s detected: force use of pci=noacpi\n",
1392 static int __init dmi_disable_acpi(const struct dmi_system_id *d)
1395 printk(KERN_NOTICE "%s detected: acpi off\n", d->ident);
1399 "Warning: DMI blacklist says broken, but acpi forced\n");
1405 * Limit ACPI to CPU enumeration for HT
1407 static int __init force_acpi_ht(const struct dmi_system_id *d)
1410 printk(KERN_NOTICE "%s detected: force use of acpi=ht\n",
1416 "Warning: acpi=force overrules DMI blacklist: acpi=ht\n");
1422 * Force ignoring BIOS IRQ0 pin2 override
1424 static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d)
1426 pr_notice("%s detected: Ignoring BIOS IRQ0 pin2 override\n", d->ident);
1427 acpi_skip_timer_override = 1;
1432 * If your system is blacklisted here, but you find that acpi=force
1433 * works for you, please contact acpi-devel@sourceforge.net
1435 static struct dmi_system_id __initdata acpi_dmi_table[] = {
1437 * Boxes that need ACPI disabled
1440 .callback = dmi_disable_acpi,
1441 .ident = "IBM Thinkpad",
1443 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
1444 DMI_MATCH(DMI_BOARD_NAME, "2629H1G"),
1449 * Boxes that need acpi=ht
1452 .callback = force_acpi_ht,
1453 .ident = "FSC Primergy T850",
1455 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
1456 DMI_MATCH(DMI_PRODUCT_NAME, "PRIMERGY T850"),
1460 .callback = force_acpi_ht,
1461 .ident = "HP VISUALIZE NT Workstation",
1463 DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"),
1464 DMI_MATCH(DMI_PRODUCT_NAME, "HP VISUALIZE NT Workstation"),
1468 .callback = force_acpi_ht,
1469 .ident = "Compaq Workstation W8000",
1471 DMI_MATCH(DMI_SYS_VENDOR, "Compaq"),
1472 DMI_MATCH(DMI_PRODUCT_NAME, "Workstation W8000"),
1476 .callback = force_acpi_ht,
1477 .ident = "ASUS P4B266",
1479 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
1480 DMI_MATCH(DMI_BOARD_NAME, "P4B266"),
1484 .callback = force_acpi_ht,
1485 .ident = "ASUS P2B-DS",
1487 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
1488 DMI_MATCH(DMI_BOARD_NAME, "P2B-DS"),
1492 .callback = force_acpi_ht,
1493 .ident = "ASUS CUR-DLS",
1495 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
1496 DMI_MATCH(DMI_BOARD_NAME, "CUR-DLS"),
1500 .callback = force_acpi_ht,
1501 .ident = "ABIT i440BX-W83977",
1503 DMI_MATCH(DMI_BOARD_VENDOR, "ABIT <http://www.abit.com>"),
1504 DMI_MATCH(DMI_BOARD_NAME, "i440BX-W83977 (BP6)"),
1508 .callback = force_acpi_ht,
1509 .ident = "IBM Bladecenter",
1511 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
1512 DMI_MATCH(DMI_BOARD_NAME, "IBM eServer BladeCenter HS20"),
1516 .callback = force_acpi_ht,
1517 .ident = "IBM eServer xSeries 360",
1519 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
1520 DMI_MATCH(DMI_BOARD_NAME, "eServer xSeries 360"),
1524 .callback = force_acpi_ht,
1525 .ident = "IBM eserver xSeries 330",
1527 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
1528 DMI_MATCH(DMI_BOARD_NAME, "eserver xSeries 330"),
1532 .callback = force_acpi_ht,
1533 .ident = "IBM eserver xSeries 440",
1535 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
1536 DMI_MATCH(DMI_PRODUCT_NAME, "eserver xSeries 440"),
1541 * Boxes that need ACPI PCI IRQ routing disabled
1544 .callback = disable_acpi_irq,
1545 .ident = "ASUS A7V",
1547 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC"),
1548 DMI_MATCH(DMI_BOARD_NAME, "<A7V>"),
1549 /* newer BIOS, Revision 1011, does work */
1550 DMI_MATCH(DMI_BIOS_VERSION,
1551 "ASUS A7V ACPI BIOS Revision 1007"),
1556 * Latest BIOS for IBM 600E (1.16) has bad pcinum
1557 * for LPC bridge, which is needed for the PCI
1558 * interrupt links to work. DSDT fix is in bug 5966.
1559 * 2645, 2646 model numbers are shared with 600/600E/600X
1561 .callback = disable_acpi_irq,
1562 .ident = "IBM Thinkpad 600 Series 2645",
1564 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
1565 DMI_MATCH(DMI_BOARD_NAME, "2645"),
1569 .callback = disable_acpi_irq,
1570 .ident = "IBM Thinkpad 600 Series 2646",
1572 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
1573 DMI_MATCH(DMI_BOARD_NAME, "2646"),
1577 * Boxes that need ACPI PCI IRQ routing and PCI scan disabled
1580 .callback = disable_acpi_pci,
1581 .ident = "ASUS PR-DLS",
1583 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
1584 DMI_MATCH(DMI_BOARD_NAME, "PR-DLS"),
1585 DMI_MATCH(DMI_BIOS_VERSION,
1586 "ASUS PR-DLS ACPI BIOS Revision 1010"),
1587 DMI_MATCH(DMI_BIOS_DATE, "03/21/2003")
1591 .callback = disable_acpi_pci,
1592 .ident = "Acer TravelMate 36x Laptop",
1594 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
1595 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 360"),
1599 * HP laptops which use a DSDT reporting as HP/SB400/10000,
1600 * which includes some code which overrides all temperature
1601 * trip points to 16C if the INTIN2 input of the I/O APIC
1602 * is enabled. This input is incorrectly designated the
1603 * ISA IRQ 0 via an interrupt source override even though
1604 * it is wired to the output of the master 8259A and INTIN0
1605 * is not connected at all. Force ignoring BIOS IRQ0 pin2
1606 * override in that cases.
1609 .callback = dmi_ignore_irq0_timer_override,
1610 .ident = "HP nx6115 laptop",
1612 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
1613 DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq nx6115"),
1617 .callback = dmi_ignore_irq0_timer_override,
1618 .ident = "HP NX6125 laptop",
1620 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
1621 DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq nx6125"),
1625 .callback = dmi_ignore_irq0_timer_override,
1626 .ident = "HP NX6325 laptop",
1628 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
1629 DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq nx6325"),
1633 .callback = dmi_ignore_irq0_timer_override,
1634 .ident = "HP 6715b laptop",
1636 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
1637 DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq 6715b"),
1644 * acpi_boot_table_init() and acpi_boot_init()
1645 * called from setup_arch(), always.
1646 * 1. checksums all tables
1647 * 2. enumerates lapics
1648 * 3. enumerates io-apics
1650 * acpi_table_init() is separate to allow reading SRAT without
1651 * other side effects.
1653 * side effects of acpi_boot_init:
1654 * acpi_lapic = 1 if LAPIC found
1655 * acpi_ioapic = 1 if IOAPIC found
1656 * if (acpi_lapic && acpi_ioapic) smp_found_config = 1;
1657 * if acpi_blacklisted() acpi_disabled = 1;
1658 * acpi_irq_model=...
1661 * return value: (currently ignored)
1666 int __init acpi_boot_table_init(void)
1670 dmi_check_system(acpi_dmi_table);
1673 * If acpi_disabled, bail out
1674 * One exception: acpi=ht continues far enough to enumerate LAPICs
1676 if (acpi_disabled && !acpi_ht)
1680 * Initialize the ACPI boot-time table parser.
1682 error = acpi_table_init();
1688 acpi_table_parse(ACPI_SIG_BOOT, acpi_parse_sbf);
1691 * blacklist may disable ACPI entirely
1693 error = acpi_blacklisted();
1696 printk(KERN_WARNING PREFIX "acpi=force override\n");
1698 printk(KERN_WARNING PREFIX "Disabling ACPI support\n");
1707 int __init early_acpi_boot_init(void)
1710 * If acpi_disabled, bail out
1711 * One exception: acpi=ht continues far enough to enumerate LAPICs
1713 if (acpi_disabled && !acpi_ht)
1717 * Process the Multiple APIC Description Table (MADT), if present
1719 early_acpi_process_madt();
1724 int __init acpi_boot_init(void)
1727 * If acpi_disabled, bail out
1728 * One exception: acpi=ht continues far enough to enumerate LAPICs
1730 if (acpi_disabled && !acpi_ht)
1733 acpi_table_parse(ACPI_SIG_BOOT, acpi_parse_sbf);
1736 * set sci_int and PM timer address
1738 acpi_table_parse(ACPI_SIG_FADT, acpi_parse_fadt);
1741 * Process the Multiple APIC Description Table (MADT), if present
1743 acpi_process_madt();
1745 acpi_table_parse(ACPI_SIG_HPET, acpi_parse_hpet);
1750 static int __init parse_acpi(char *arg)
1755 /* "acpi=off" disables both ACPI table parsing and interpreter */
1756 if (strcmp(arg, "off") == 0) {
1759 /* acpi=force to over-ride black-list */
1760 else if (strcmp(arg, "force") == 0) {
1765 /* acpi=strict disables out-of-spec workarounds */
1766 else if (strcmp(arg, "strict") == 0) {
1769 /* Limit ACPI just to boot-time to enable HT */
1770 else if (strcmp(arg, "ht") == 0) {
1775 /* "acpi=noirq" disables ACPI interrupt routing */
1776 else if (strcmp(arg, "noirq") == 0) {
1779 /* Core will printk when we return error. */
1784 early_param("acpi", parse_acpi);
1786 /* FIXME: Using pci= for an ACPI parameter is a travesty. */
1787 static int __init parse_pci(char *arg)
1789 if (arg && strcmp(arg, "noacpi") == 0)
1793 early_param("pci", parse_pci);
1795 int __init acpi_mps_check(void)
1797 #if defined(CONFIG_X86_LOCAL_APIC) && !defined(CONFIG_X86_MPPARSE)
1798 /* mptable code is not built-in*/
1799 if (acpi_disabled || acpi_noirq) {
1800 printk(KERN_WARNING "MPS support code is not built-in.\n"
1801 "Using acpi=off or acpi=noirq or pci=noacpi "
1802 "may have problem\n");
1809 #ifdef CONFIG_X86_IO_APIC
1810 static int __init parse_acpi_skip_timer_override(char *arg)
1812 acpi_skip_timer_override = 1;
1815 early_param("acpi_skip_timer_override", parse_acpi_skip_timer_override);
1817 static int __init parse_acpi_use_timer_override(char *arg)
1819 acpi_use_timer_override = 1;
1822 early_param("acpi_use_timer_override", parse_acpi_use_timer_override);
1823 #endif /* CONFIG_X86_IO_APIC */
1825 static int __init setup_acpi_sci(char *s)
1829 if (!strcmp(s, "edge"))
1830 acpi_sci_flags = ACPI_MADT_TRIGGER_EDGE |
1831 (acpi_sci_flags & ~ACPI_MADT_TRIGGER_MASK);
1832 else if (!strcmp(s, "level"))
1833 acpi_sci_flags = ACPI_MADT_TRIGGER_LEVEL |
1834 (acpi_sci_flags & ~ACPI_MADT_TRIGGER_MASK);
1835 else if (!strcmp(s, "high"))
1836 acpi_sci_flags = ACPI_MADT_POLARITY_ACTIVE_HIGH |
1837 (acpi_sci_flags & ~ACPI_MADT_POLARITY_MASK);
1838 else if (!strcmp(s, "low"))
1839 acpi_sci_flags = ACPI_MADT_POLARITY_ACTIVE_LOW |
1840 (acpi_sci_flags & ~ACPI_MADT_POLARITY_MASK);
1845 early_param("acpi_sci", setup_acpi_sci);
1847 int __acpi_acquire_global_lock(unsigned int *lock)
1849 unsigned int old, new, val;
1852 new = (((old & ~0x3) + 2) + ((old >> 1) & 0x1));
1853 val = cmpxchg(lock, old, new);
1854 } while (unlikely (val != old));
1855 return (new < 3) ? -1 : 0;
1858 int __acpi_release_global_lock(unsigned int *lock)
1860 unsigned int old, new, val;
1864 val = cmpxchg(lock, old, new);
1865 } while (unlikely (val != old));