1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * boot.c - Architecture-Specific Low-Level ACPI Boot Support
5 * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
6 * Copyright (C) 2001 Jun Nakajima <jun.nakajima@intel.com>
9 #include <linux/init.h>
10 #include <linux/acpi.h>
11 #include <linux/acpi_pmtmr.h>
12 #include <linux/efi.h>
13 #include <linux/cpumask.h>
14 #include <linux/export.h>
15 #include <linux/dmi.h>
16 #include <linux/irq.h>
17 #include <linux/slab.h>
18 #include <linux/memblock.h>
19 #include <linux/ioport.h>
20 #include <linux/pci.h>
21 #include <linux/efi-bgrt.h>
22 #include <linux/serial_core.h>
24 #include <asm/e820/api.h>
25 #include <asm/irqdomain.h>
26 #include <asm/pci_x86.h>
27 #include <asm/pgtable.h>
28 #include <asm/io_apic.h>
31 #include <asm/mpspec.h>
33 #include <asm/i8259.h>
34 #include <asm/setup.h>
36 #include "sleep.h" /* To include x86_acpi_suspend_lowlevel */
37 static int __initdata acpi_force = 0;
39 EXPORT_SYMBOL(acpi_disabled);
42 # include <asm/proto.h>
45 #define PREFIX "ACPI: "
47 int acpi_noirq; /* skip ACPI IRQ initialization */
48 int acpi_pci_disabled; /* skip ACPI PCI scan and IRQ initialization */
49 EXPORT_SYMBOL(acpi_pci_disabled);
54 int acpi_disable_cmcff;
56 /* ACPI SCI override configuration */
57 u8 acpi_sci_flags __initdata;
58 u32 acpi_sci_override_gsi __initdata = INVALID_ACPI_IRQ;
59 int acpi_skip_timer_override __initdata;
60 int acpi_use_timer_override __initdata;
61 int acpi_fix_pin2_polarity __initdata;
63 #ifdef CONFIG_X86_LOCAL_APIC
64 static u64 acpi_lapic_addr __initdata = APIC_DEFAULT_PHYS_BASE;
67 #ifdef CONFIG_X86_IO_APIC
69 * Locks related to IOAPIC hotplug
71 * ->device_hotplug_lock
74 * Interrupt mapping side:
79 static DEFINE_MUTEX(acpi_ioapic_lock);
82 /* --------------------------------------------------------------------------
83 Boot-time Configuration
84 -------------------------------------------------------------------------- */
87 * The default interrupt routing model is PIC (8259). This gets
88 * overridden if IOAPICs are enumerated (below).
90 enum acpi_irq_model_id acpi_irq_model = ACPI_IRQ_MODEL_PIC;
94 * ISA irqs by default are the first 16 gsis but can be
95 * any gsi as specified by an interrupt source override.
97 static u32 isa_irq_to_gsi[NR_IRQS_LEGACY] __read_mostly = {
98 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
102 * This is just a simple wrapper around early_memremap(),
103 * with sanity checks for phys == 0 and size == 0.
105 void __init __iomem *__acpi_map_table(unsigned long phys, unsigned long size)
111 return early_memremap(phys, size);
114 void __init __acpi_unmap_table(void __iomem *map, unsigned long size)
119 early_memunmap(map, size);
122 #ifdef CONFIG_X86_LOCAL_APIC
123 static int __init acpi_parse_madt(struct acpi_table_header *table)
125 struct acpi_table_madt *madt = NULL;
127 if (!boot_cpu_has(X86_FEATURE_APIC))
130 madt = (struct acpi_table_madt *)table;
132 printk(KERN_WARNING PREFIX "Unable to map MADT\n");
137 acpi_lapic_addr = (u64) madt->address;
139 printk(KERN_DEBUG PREFIX "Local APIC address 0x%08x\n",
143 if (madt->flags & ACPI_MADT_PCAT_COMPAT)
144 legacy_pic_pcat_compat();
146 default_acpi_madt_oem_check(madt->header.oem_id,
147 madt->header.oem_table_id);
153 * acpi_register_lapic - register a local apic and generates a logic cpu number
154 * @id: local apic id to register
155 * @acpiid: ACPI id to register
156 * @enabled: this cpu is enabled or not
158 * Returns the logic cpu number which maps to the local apic
160 static int acpi_register_lapic(int id, u32 acpiid, u8 enabled)
162 unsigned int ver = 0;
165 if (id >= MAX_LOCAL_APIC) {
166 printk(KERN_INFO PREFIX "skipped apicid that is too big\n");
175 if (boot_cpu_physical_apicid != -1U)
176 ver = boot_cpu_apic_version;
178 cpu = generic_processor_info(id, ver);
180 early_per_cpu(x86_cpu_to_acpiid, cpu) = acpiid;
186 acpi_parse_x2apic(union acpi_subtable_headers *header, const unsigned long end)
188 struct acpi_madt_local_x2apic *processor = NULL;
189 #ifdef CONFIG_X86_X2APIC
194 processor = (struct acpi_madt_local_x2apic *)header;
196 if (BAD_MADT_ENTRY(processor, end))
199 acpi_table_print_madt_entry(&header->common);
201 #ifdef CONFIG_X86_X2APIC
202 apic_id = processor->local_apic_id;
203 enabled = processor->lapic_flags & ACPI_MADT_ENABLED;
205 /* Ignore invalid ID */
206 if (apic_id == 0xffffffff)
210 * We need to register disabled CPU as well to permit
211 * counting disabled CPUs. This allows us to size
212 * cpus_possible_map more accurately, to permit
213 * to not preallocating memory for all NR_CPUS
214 * when we use CPU hotplug.
216 if (!apic->apic_id_valid(apic_id)) {
218 pr_warn(PREFIX "x2apic entry ignored\n");
222 acpi_register_lapic(apic_id, processor->uid, enabled);
224 printk(KERN_WARNING PREFIX "x2apic entry ignored\n");
231 acpi_parse_lapic(union acpi_subtable_headers * header, const unsigned long end)
233 struct acpi_madt_local_apic *processor = NULL;
235 processor = (struct acpi_madt_local_apic *)header;
237 if (BAD_MADT_ENTRY(processor, end))
240 acpi_table_print_madt_entry(&header->common);
242 /* Ignore invalid ID */
243 if (processor->id == 0xff)
247 * We need to register disabled CPU as well to permit
248 * counting disabled CPUs. This allows us to size
249 * cpus_possible_map more accurately, to permit
250 * to not preallocating memory for all NR_CPUS
251 * when we use CPU hotplug.
253 acpi_register_lapic(processor->id, /* APIC ID */
254 processor->processor_id, /* ACPI ID */
255 processor->lapic_flags & ACPI_MADT_ENABLED);
261 acpi_parse_sapic(union acpi_subtable_headers *header, const unsigned long end)
263 struct acpi_madt_local_sapic *processor = NULL;
265 processor = (struct acpi_madt_local_sapic *)header;
267 if (BAD_MADT_ENTRY(processor, end))
270 acpi_table_print_madt_entry(&header->common);
272 acpi_register_lapic((processor->id << 8) | processor->eid,/* APIC ID */
273 processor->processor_id, /* ACPI ID */
274 processor->lapic_flags & ACPI_MADT_ENABLED);
280 acpi_parse_lapic_addr_ovr(union acpi_subtable_headers * header,
281 const unsigned long end)
283 struct acpi_madt_local_apic_override *lapic_addr_ovr = NULL;
285 lapic_addr_ovr = (struct acpi_madt_local_apic_override *)header;
287 if (BAD_MADT_ENTRY(lapic_addr_ovr, end))
290 acpi_table_print_madt_entry(&header->common);
292 acpi_lapic_addr = lapic_addr_ovr->address;
298 acpi_parse_x2apic_nmi(union acpi_subtable_headers *header,
299 const unsigned long end)
301 struct acpi_madt_local_x2apic_nmi *x2apic_nmi = NULL;
303 x2apic_nmi = (struct acpi_madt_local_x2apic_nmi *)header;
305 if (BAD_MADT_ENTRY(x2apic_nmi, end))
308 acpi_table_print_madt_entry(&header->common);
310 if (x2apic_nmi->lint != 1)
311 printk(KERN_WARNING PREFIX "NMI not connected to LINT 1!\n");
317 acpi_parse_lapic_nmi(union acpi_subtable_headers * header, const unsigned long end)
319 struct acpi_madt_local_apic_nmi *lapic_nmi = NULL;
321 lapic_nmi = (struct acpi_madt_local_apic_nmi *)header;
323 if (BAD_MADT_ENTRY(lapic_nmi, end))
326 acpi_table_print_madt_entry(&header->common);
328 if (lapic_nmi->lint != 1)
329 printk(KERN_WARNING PREFIX "NMI not connected to LINT 1!\n");
334 #endif /*CONFIG_X86_LOCAL_APIC */
336 #ifdef CONFIG_X86_IO_APIC
339 static int __init mp_register_ioapic_irq(u8 bus_irq, u8 polarity,
340 u8 trigger, u32 gsi);
342 static void __init mp_override_legacy_irq(u8 bus_irq, u8 polarity, u8 trigger,
346 * Check bus_irq boundary.
348 if (bus_irq >= NR_IRQS_LEGACY) {
349 pr_warn("Invalid bus_irq %u for legacy override\n", bus_irq);
354 * TBD: This check is for faulty timer entries, where the override
355 * erroneously sets the trigger to level, resulting in a HUGE
356 * increase of timer interrupts!
358 if ((bus_irq == 0) && (trigger == 3))
361 if (mp_register_ioapic_irq(bus_irq, polarity, trigger, gsi) < 0)
364 * Reset default identity mapping if gsi is also an legacy IRQ,
365 * otherwise there will be more than one entry with the same GSI
366 * and acpi_isa_irq_to_gsi() may give wrong result.
368 if (gsi < nr_legacy_irqs() && isa_irq_to_gsi[gsi] == gsi)
369 isa_irq_to_gsi[gsi] = INVALID_ACPI_IRQ;
370 isa_irq_to_gsi[bus_irq] = gsi;
373 static int mp_config_acpi_gsi(struct device *dev, u32 gsi, int trigger,
376 #ifdef CONFIG_X86_MPPARSE
377 struct mpc_intsrc mp_irq;
378 struct pci_dev *pdev;
379 unsigned char number;
386 if (!dev || !dev_is_pci(dev))
389 pdev = to_pci_dev(dev);
390 number = pdev->bus->number;
393 /* print the entry should happen on mptable identically */
394 mp_irq.type = MP_INTSRC;
395 mp_irq.irqtype = mp_INT;
396 mp_irq.irqflag = (trigger == ACPI_EDGE_SENSITIVE ? 4 : 0x0c) |
397 (polarity == ACPI_ACTIVE_HIGH ? 1 : 3);
398 mp_irq.srcbus = number;
399 mp_irq.srcbusirq = (((devfn >> 3) & 0x1f) << 2) | ((pin - 1) & 3);
400 ioapic = mp_find_ioapic(gsi);
401 mp_irq.dstapic = mpc_ioapic_id(ioapic);
402 mp_irq.dstirq = mp_find_ioapic_pin(ioapic, gsi);
404 mp_save_irq(&mp_irq);
409 static int __init mp_register_ioapic_irq(u8 bus_irq, u8 polarity,
412 struct mpc_intsrc mp_irq;
415 /* Convert 'gsi' to 'ioapic.pin'(INTIN#) */
416 ioapic = mp_find_ioapic(gsi);
418 pr_warn("Failed to find ioapic for gsi : %u\n", gsi);
422 pin = mp_find_ioapic_pin(ioapic, gsi);
424 mp_irq.type = MP_INTSRC;
425 mp_irq.irqtype = mp_INT;
426 mp_irq.irqflag = (trigger << 2) | polarity;
427 mp_irq.srcbus = MP_ISA_BUS;
428 mp_irq.srcbusirq = bus_irq;
429 mp_irq.dstapic = mpc_ioapic_id(ioapic);
432 mp_save_irq(&mp_irq);
438 acpi_parse_ioapic(union acpi_subtable_headers * header, const unsigned long end)
440 struct acpi_madt_io_apic *ioapic = NULL;
441 struct ioapic_domain_cfg cfg = {
442 .type = IOAPIC_DOMAIN_DYNAMIC,
443 .ops = &mp_ioapic_irqdomain_ops,
446 ioapic = (struct acpi_madt_io_apic *)header;
448 if (BAD_MADT_ENTRY(ioapic, end))
451 acpi_table_print_madt_entry(&header->common);
453 /* Statically assign IRQ numbers for IOAPICs hosting legacy IRQs */
454 if (ioapic->global_irq_base < nr_legacy_irqs())
455 cfg.type = IOAPIC_DOMAIN_LEGACY;
457 mp_register_ioapic(ioapic->id, ioapic->address, ioapic->global_irq_base,
464 * Parse Interrupt Source Override for the ACPI SCI
466 static void __init acpi_sci_ioapic_setup(u8 bus_irq, u16 polarity, u16 trigger, u32 gsi)
468 if (trigger == 0) /* compatible SCI trigger is level */
471 if (polarity == 0) /* compatible SCI polarity is low */
474 /* Command-line over-ride via acpi_sci= */
475 if (acpi_sci_flags & ACPI_MADT_TRIGGER_MASK)
476 trigger = (acpi_sci_flags & ACPI_MADT_TRIGGER_MASK) >> 2;
478 if (acpi_sci_flags & ACPI_MADT_POLARITY_MASK)
479 polarity = acpi_sci_flags & ACPI_MADT_POLARITY_MASK;
481 if (bus_irq < NR_IRQS_LEGACY)
482 mp_override_legacy_irq(bus_irq, polarity, trigger, gsi);
484 mp_register_ioapic_irq(bus_irq, polarity, trigger, gsi);
486 acpi_penalize_sci_irq(bus_irq, trigger, polarity);
489 * stash over-ride to indicate we've been here
490 * and for later update of acpi_gbl_FADT
492 acpi_sci_override_gsi = gsi;
497 acpi_parse_int_src_ovr(union acpi_subtable_headers * header,
498 const unsigned long end)
500 struct acpi_madt_interrupt_override *intsrc = NULL;
502 intsrc = (struct acpi_madt_interrupt_override *)header;
504 if (BAD_MADT_ENTRY(intsrc, end))
507 acpi_table_print_madt_entry(&header->common);
509 if (intsrc->source_irq == acpi_gbl_FADT.sci_interrupt) {
510 acpi_sci_ioapic_setup(intsrc->source_irq,
511 intsrc->inti_flags & ACPI_MADT_POLARITY_MASK,
512 (intsrc->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2,
517 if (intsrc->source_irq == 0) {
518 if (acpi_skip_timer_override) {
519 printk(PREFIX "BIOS IRQ0 override ignored.\n");
523 if ((intsrc->global_irq == 2) && acpi_fix_pin2_polarity
524 && (intsrc->inti_flags & ACPI_MADT_POLARITY_MASK)) {
525 intsrc->inti_flags &= ~ACPI_MADT_POLARITY_MASK;
526 printk(PREFIX "BIOS IRQ0 pin2 override: forcing polarity to high active.\n");
530 mp_override_legacy_irq(intsrc->source_irq,
531 intsrc->inti_flags & ACPI_MADT_POLARITY_MASK,
532 (intsrc->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2,
539 acpi_parse_nmi_src(union acpi_subtable_headers * header, const unsigned long end)
541 struct acpi_madt_nmi_source *nmi_src = NULL;
543 nmi_src = (struct acpi_madt_nmi_source *)header;
545 if (BAD_MADT_ENTRY(nmi_src, end))
548 acpi_table_print_madt_entry(&header->common);
550 /* TBD: Support nimsrc entries? */
555 #endif /* CONFIG_X86_IO_APIC */
558 * acpi_pic_sci_set_trigger()
560 * use ELCR to set PIC-mode trigger type for SCI
562 * If a PIC-mode SCI is not recognized or gives spurious IRQ7's
563 * it may require Edge Trigger -- use "acpi_sci=edge"
565 * Port 0x4d0-4d1 are ECLR1 and ECLR2, the Edge/Level Control Registers
566 * for the 8259 PIC. bit[n] = 1 means irq[n] is Level, otherwise Edge.
567 * ECLR1 is IRQs 0-7 (IRQ 0, 1, 2 must be 0)
568 * ECLR2 is IRQs 8-15 (IRQ 8, 13 must be 0)
571 void __init acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger)
573 unsigned int mask = 1 << irq;
574 unsigned int old, new;
576 /* Real old ELCR mask */
577 old = inb(0x4d0) | (inb(0x4d1) << 8);
580 * If we use ACPI to set PCI IRQs, then we should clear ELCR
581 * since we will set it correctly as we enable the PCI irq
584 new = acpi_noirq ? old : 0;
587 * Update SCI information in the ELCR, it isn't in the PCI
591 case 1: /* Edge - clear */
594 case 3: /* Level - set */
602 printk(PREFIX "setting ELCR to %04x (from %04x)\n", new, old);
604 outb(new >> 8, 0x4d1);
607 int acpi_gsi_to_irq(u32 gsi, unsigned int *irqp)
609 int rc, irq, trigger, polarity;
611 if (acpi_irq_model == ACPI_IRQ_MODEL_PIC) {
616 rc = acpi_get_override_irq(gsi, &trigger, &polarity);
620 trigger = trigger ? ACPI_LEVEL_SENSITIVE : ACPI_EDGE_SENSITIVE;
621 polarity = polarity ? ACPI_ACTIVE_LOW : ACPI_ACTIVE_HIGH;
622 irq = acpi_register_gsi(NULL, gsi, trigger, polarity);
629 EXPORT_SYMBOL_GPL(acpi_gsi_to_irq);
631 int acpi_isa_irq_to_gsi(unsigned isa_irq, u32 *gsi)
633 if (isa_irq < nr_legacy_irqs() &&
634 isa_irq_to_gsi[isa_irq] != INVALID_ACPI_IRQ) {
635 *gsi = isa_irq_to_gsi[isa_irq];
642 static int acpi_register_gsi_pic(struct device *dev, u32 gsi,
643 int trigger, int polarity)
647 * Make sure all (legacy) PCI IRQs are set as level-triggered.
649 if (trigger == ACPI_LEVEL_SENSITIVE)
650 elcr_set_level_irq(gsi);
656 #ifdef CONFIG_X86_LOCAL_APIC
657 static int acpi_register_gsi_ioapic(struct device *dev, u32 gsi,
658 int trigger, int polarity)
661 #ifdef CONFIG_X86_IO_APIC
663 struct irq_alloc_info info;
665 node = dev ? dev_to_node(dev) : NUMA_NO_NODE;
666 trigger = trigger == ACPI_EDGE_SENSITIVE ? 0 : 1;
667 polarity = polarity == ACPI_ACTIVE_HIGH ? 0 : 1;
668 ioapic_set_alloc_attr(&info, node, trigger, polarity);
670 mutex_lock(&acpi_ioapic_lock);
671 irq = mp_map_gsi_to_irq(gsi, IOAPIC_MAP_ALLOC, &info);
672 /* Don't set up the ACPI SCI because it's already set up */
673 if (irq >= 0 && enable_update_mptable && gsi != acpi_gbl_FADT.sci_interrupt)
674 mp_config_acpi_gsi(dev, gsi, trigger, polarity);
675 mutex_unlock(&acpi_ioapic_lock);
681 static void acpi_unregister_gsi_ioapic(u32 gsi)
683 #ifdef CONFIG_X86_IO_APIC
686 mutex_lock(&acpi_ioapic_lock);
687 irq = mp_map_gsi_to_irq(gsi, 0, NULL);
690 mutex_unlock(&acpi_ioapic_lock);
695 int (*__acpi_register_gsi)(struct device *dev, u32 gsi,
696 int trigger, int polarity) = acpi_register_gsi_pic;
697 void (*__acpi_unregister_gsi)(u32 gsi) = NULL;
699 #ifdef CONFIG_ACPI_SLEEP
700 int (*acpi_suspend_lowlevel)(void) = x86_acpi_suspend_lowlevel;
702 int (*acpi_suspend_lowlevel)(void);
706 * success: return IRQ number (>=0)
707 * failure: return < 0
709 int acpi_register_gsi(struct device *dev, u32 gsi, int trigger, int polarity)
711 return __acpi_register_gsi(dev, gsi, trigger, polarity);
713 EXPORT_SYMBOL_GPL(acpi_register_gsi);
715 void acpi_unregister_gsi(u32 gsi)
717 if (__acpi_unregister_gsi)
718 __acpi_unregister_gsi(gsi);
720 EXPORT_SYMBOL_GPL(acpi_unregister_gsi);
722 #ifdef CONFIG_X86_LOCAL_APIC
723 static void __init acpi_set_irq_model_ioapic(void)
725 acpi_irq_model = ACPI_IRQ_MODEL_IOAPIC;
726 __acpi_register_gsi = acpi_register_gsi_ioapic;
727 __acpi_unregister_gsi = acpi_unregister_gsi_ioapic;
733 * ACPI based hotplug support for CPU
735 #ifdef CONFIG_ACPI_HOTPLUG_CPU
736 #include <acpi/processor.h>
738 static int acpi_map_cpu2node(acpi_handle handle, int cpu, int physid)
740 #ifdef CONFIG_ACPI_NUMA
743 nid = acpi_get_node(handle);
744 if (nid != NUMA_NO_NODE) {
745 set_apicid_to_node(physid, nid);
746 numa_set_node(cpu, nid);
752 int acpi_map_cpu(acpi_handle handle, phys_cpuid_t physid, u32 acpi_id,
757 cpu = acpi_register_lapic(physid, acpi_id, ACPI_MADT_ENABLED);
759 pr_info(PREFIX "Unable to map lapic to logical cpu number\n");
763 acpi_processor_set_pdc(handle);
764 acpi_map_cpu2node(handle, cpu, physid);
769 EXPORT_SYMBOL(acpi_map_cpu);
771 int acpi_unmap_cpu(int cpu)
773 #ifdef CONFIG_ACPI_NUMA
774 set_apicid_to_node(per_cpu(x86_cpu_to_apicid, cpu), NUMA_NO_NODE);
777 per_cpu(x86_cpu_to_apicid, cpu) = -1;
778 set_cpu_present(cpu, false);
783 EXPORT_SYMBOL(acpi_unmap_cpu);
784 #endif /* CONFIG_ACPI_HOTPLUG_CPU */
786 int acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base)
789 #ifdef CONFIG_ACPI_HOTPLUG_IOAPIC
792 struct ioapic_domain_cfg cfg = {
793 .type = IOAPIC_DOMAIN_DYNAMIC,
794 .ops = &mp_ioapic_irqdomain_ops,
797 ioapic_id = acpi_get_ioapic_id(handle, gsi_base, &addr);
799 unsigned long long uid;
802 status = acpi_evaluate_integer(handle, METHOD_NAME__UID,
804 if (ACPI_FAILURE(status)) {
805 acpi_handle_warn(handle, "failed to get IOAPIC ID.\n");
808 ioapic_id = (int)uid;
811 mutex_lock(&acpi_ioapic_lock);
812 ret = mp_register_ioapic(ioapic_id, phys_addr, gsi_base, &cfg);
813 mutex_unlock(&acpi_ioapic_lock);
818 EXPORT_SYMBOL(acpi_register_ioapic);
820 int acpi_unregister_ioapic(acpi_handle handle, u32 gsi_base)
824 #ifdef CONFIG_ACPI_HOTPLUG_IOAPIC
825 mutex_lock(&acpi_ioapic_lock);
826 ret = mp_unregister_ioapic(gsi_base);
827 mutex_unlock(&acpi_ioapic_lock);
832 EXPORT_SYMBOL(acpi_unregister_ioapic);
835 * acpi_ioapic_registered - Check whether IOAPIC assoicatied with @gsi_base
836 * has been registered
837 * @handle: ACPI handle of the IOAPIC device
838 * @gsi_base: GSI base associated with the IOAPIC
840 * Assume caller holds some type of lock to serialize acpi_ioapic_registered()
841 * with acpi_register_ioapic()/acpi_unregister_ioapic().
843 int acpi_ioapic_registered(acpi_handle handle, u32 gsi_base)
847 #ifdef CONFIG_ACPI_HOTPLUG_IOAPIC
848 mutex_lock(&acpi_ioapic_lock);
849 ret = mp_ioapic_registered(gsi_base);
850 mutex_unlock(&acpi_ioapic_lock);
856 static int __init acpi_parse_sbf(struct acpi_table_header *table)
858 struct acpi_table_boot *sb = (struct acpi_table_boot *)table;
860 sbf_port = sb->cmos_index; /* Save CMOS port */
865 #ifdef CONFIG_HPET_TIMER
866 #include <asm/hpet.h>
868 static struct resource *hpet_res __initdata;
870 static int __init acpi_parse_hpet(struct acpi_table_header *table)
872 struct acpi_table_hpet *hpet_tbl = (struct acpi_table_hpet *)table;
874 if (hpet_tbl->address.space_id != ACPI_SPACE_MEM) {
875 printk(KERN_WARNING PREFIX "HPET timers must be located in "
880 hpet_address = hpet_tbl->address.address;
881 hpet_blockid = hpet_tbl->sequence;
884 * Some broken BIOSes advertise HPET at 0x0. We really do not
885 * want to allocate a resource there.
888 printk(KERN_WARNING PREFIX
889 "HPET id: %#x base: %#lx is invalid\n",
890 hpet_tbl->id, hpet_address);
895 * Some even more broken BIOSes advertise HPET at
896 * 0xfed0000000000000 instead of 0xfed00000. Fix it up and add
899 if (hpet_address == 0xfed0000000000000UL) {
900 if (!hpet_force_user) {
901 printk(KERN_WARNING PREFIX "HPET id: %#x "
902 "base: 0xfed0000000000000 is bogus\n "
903 "try hpet=force on the kernel command line to "
904 "fix it up to 0xfed00000.\n", hpet_tbl->id);
908 printk(KERN_WARNING PREFIX
909 "HPET id: %#x base: 0xfed0000000000000 fixed up "
910 "to 0xfed00000.\n", hpet_tbl->id);
914 printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n",
915 hpet_tbl->id, hpet_address);
918 * Allocate and initialize the HPET firmware resource for adding into
919 * the resource tree during the lateinit timeframe.
921 #define HPET_RESOURCE_NAME_SIZE 9
922 hpet_res = memblock_alloc(sizeof(*hpet_res) + HPET_RESOURCE_NAME_SIZE,
925 panic("%s: Failed to allocate %zu bytes\n", __func__,
926 sizeof(*hpet_res) + HPET_RESOURCE_NAME_SIZE);
928 hpet_res->name = (void *)&hpet_res[1];
929 hpet_res->flags = IORESOURCE_MEM;
930 snprintf((char *)hpet_res->name, HPET_RESOURCE_NAME_SIZE, "HPET %u",
933 hpet_res->start = hpet_address;
934 hpet_res->end = hpet_address + (1 * 1024) - 1;
940 * hpet_insert_resource inserts the HPET resources used into the resource
943 static __init int hpet_insert_resource(void)
948 return insert_resource(&iomem_resource, hpet_res);
951 late_initcall(hpet_insert_resource);
954 #define acpi_parse_hpet NULL
957 static int __init acpi_parse_fadt(struct acpi_table_header *table)
959 if (!(acpi_gbl_FADT.boot_flags & ACPI_FADT_LEGACY_DEVICES)) {
960 pr_debug("ACPI: no legacy devices present\n");
961 x86_platform.legacy.devices.pnpbios = 0;
964 if (acpi_gbl_FADT.header.revision >= FADT2_REVISION_ID &&
965 !(acpi_gbl_FADT.boot_flags & ACPI_FADT_8042) &&
966 x86_platform.legacy.i8042 != X86_LEGACY_I8042_PLATFORM_ABSENT) {
967 pr_debug("ACPI: i8042 controller is absent\n");
968 x86_platform.legacy.i8042 = X86_LEGACY_I8042_FIRMWARE_ABSENT;
971 if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_CMOS_RTC) {
972 pr_debug("ACPI: not registering RTC platform device\n");
973 x86_platform.legacy.rtc = 0;
976 if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_VGA) {
977 pr_debug("ACPI: probing for VGA not safe\n");
978 x86_platform.legacy.no_vga = 1;
981 #ifdef CONFIG_X86_PM_TIMER
982 /* detect the location of the ACPI PM Timer */
983 if (acpi_gbl_FADT.header.revision >= FADT2_REVISION_ID) {
985 if (acpi_gbl_FADT.xpm_timer_block.space_id !=
986 ACPI_ADR_SPACE_SYSTEM_IO)
989 pmtmr_ioport = acpi_gbl_FADT.xpm_timer_block.address;
991 * "X" fields are optional extensions to the original V1.0
992 * fields, so we must selectively expand V1.0 fields if the
993 * corresponding X field is zero.
996 pmtmr_ioport = acpi_gbl_FADT.pm_timer_block;
999 pmtmr_ioport = acpi_gbl_FADT.pm_timer_block;
1002 printk(KERN_INFO PREFIX "PM-Timer IO Port: %#x\n",
1008 #ifdef CONFIG_X86_LOCAL_APIC
1010 * Parse LAPIC entries in MADT
1011 * returns 0 on success, < 0 on error
1014 static int __init early_acpi_parse_madt_lapic_addr_ovr(void)
1018 if (!boot_cpu_has(X86_FEATURE_APIC))
1022 * Note that the LAPIC address is obtained from the MADT (32-bit value)
1023 * and (optionally) overridden by a LAPIC_ADDR_OVR entry (64-bit value).
1026 count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE,
1027 acpi_parse_lapic_addr_ovr, 0);
1029 printk(KERN_ERR PREFIX
1030 "Error parsing LAPIC address override entry\n");
1034 register_lapic_address(acpi_lapic_addr);
1039 static int __init acpi_parse_madt_lapic_entries(void)
1044 struct acpi_subtable_proc madt_proc[2];
1046 if (!boot_cpu_has(X86_FEATURE_APIC))
1049 count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_SAPIC,
1050 acpi_parse_sapic, MAX_LOCAL_APIC);
1053 memset(madt_proc, 0, sizeof(madt_proc));
1054 madt_proc[0].id = ACPI_MADT_TYPE_LOCAL_APIC;
1055 madt_proc[0].handler = acpi_parse_lapic;
1056 madt_proc[1].id = ACPI_MADT_TYPE_LOCAL_X2APIC;
1057 madt_proc[1].handler = acpi_parse_x2apic;
1058 ret = acpi_table_parse_entries_array(ACPI_SIG_MADT,
1059 sizeof(struct acpi_table_madt),
1060 madt_proc, ARRAY_SIZE(madt_proc), MAX_LOCAL_APIC);
1062 printk(KERN_ERR PREFIX
1063 "Error parsing LAPIC/X2APIC entries\n");
1067 count = madt_proc[0].count;
1068 x2count = madt_proc[1].count;
1070 if (!count && !x2count) {
1071 printk(KERN_ERR PREFIX "No LAPIC entries present\n");
1072 /* TBD: Cleanup to allow fallback to MPS */
1074 } else if (count < 0 || x2count < 0) {
1075 printk(KERN_ERR PREFIX "Error parsing LAPIC entry\n");
1076 /* TBD: Cleanup to allow fallback to MPS */
1080 x2count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_X2APIC_NMI,
1081 acpi_parse_x2apic_nmi, 0);
1082 count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC_NMI,
1083 acpi_parse_lapic_nmi, 0);
1084 if (count < 0 || x2count < 0) {
1085 printk(KERN_ERR PREFIX "Error parsing LAPIC NMI entry\n");
1086 /* TBD: Cleanup to allow fallback to MPS */
1091 #endif /* CONFIG_X86_LOCAL_APIC */
1093 #ifdef CONFIG_X86_IO_APIC
1094 static void __init mp_config_acpi_legacy_irqs(void)
1097 struct mpc_intsrc mp_irq;
1101 * Fabricate the legacy ISA bus (bus #31).
1103 mp_bus_id_to_type[MP_ISA_BUS] = MP_BUS_ISA;
1105 set_bit(MP_ISA_BUS, mp_bus_not_pci);
1106 pr_debug("Bus #%d is ISA (nIRQs: %d)\n", MP_ISA_BUS, nr_legacy_irqs());
1109 * Use the default configuration for the IRQs 0-15. Unless
1110 * overridden by (MADT) interrupt source override entries.
1112 for (i = 0; i < nr_legacy_irqs(); i++) {
1114 unsigned int dstapic;
1118 /* Locate the gsi that irq i maps to. */
1119 if (acpi_isa_irq_to_gsi(i, &gsi))
1123 * Locate the IOAPIC that manages the ISA IRQ.
1125 ioapic = mp_find_ioapic(gsi);
1128 pin = mp_find_ioapic_pin(ioapic, gsi);
1129 dstapic = mpc_ioapic_id(ioapic);
1131 for (idx = 0; idx < mp_irq_entries; idx++) {
1132 struct mpc_intsrc *irq = mp_irqs + idx;
1134 /* Do we already have a mapping for this ISA IRQ? */
1135 if (irq->srcbus == MP_ISA_BUS && irq->srcbusirq == i)
1138 /* Do we already have a mapping for this IOAPIC pin */
1139 if (irq->dstapic == dstapic && irq->dstirq == pin)
1143 if (idx != mp_irq_entries) {
1144 printk(KERN_DEBUG "ACPI: IRQ%d used by override.\n", i);
1145 continue; /* IRQ already used */
1148 mp_irq.type = MP_INTSRC;
1149 mp_irq.irqflag = 0; /* Conforming */
1150 mp_irq.srcbus = MP_ISA_BUS;
1151 mp_irq.dstapic = dstapic;
1152 mp_irq.irqtype = mp_INT;
1153 mp_irq.srcbusirq = i; /* Identity mapped */
1154 mp_irq.dstirq = pin;
1156 mp_save_irq(&mp_irq);
1161 * Parse IOAPIC related entries in MADT
1162 * returns 0 on success, < 0 on error
1164 static int __init acpi_parse_madt_ioapic_entries(void)
1169 * ACPI interpreter is required to complete interrupt setup,
1170 * so if it is off, don't enumerate the io-apics with ACPI.
1171 * If MPS is present, it will handle them,
1172 * otherwise the system will stay in PIC mode
1174 if (acpi_disabled || acpi_noirq)
1177 if (!boot_cpu_has(X86_FEATURE_APIC))
1181 * if "noapic" boot option, don't look for IO-APICs
1183 if (skip_ioapic_setup) {
1184 printk(KERN_INFO PREFIX "Skipping IOAPIC probe "
1185 "due to 'noapic' option.\n");
1189 count = acpi_table_parse_madt(ACPI_MADT_TYPE_IO_APIC, acpi_parse_ioapic,
1192 printk(KERN_ERR PREFIX "No IOAPIC entries present\n");
1194 } else if (count < 0) {
1195 printk(KERN_ERR PREFIX "Error parsing IOAPIC entry\n");
1199 count = acpi_table_parse_madt(ACPI_MADT_TYPE_INTERRUPT_OVERRIDE,
1200 acpi_parse_int_src_ovr, nr_irqs);
1202 printk(KERN_ERR PREFIX
1203 "Error parsing interrupt source overrides entry\n");
1204 /* TBD: Cleanup to allow fallback to MPS */
1209 * If BIOS did not supply an INT_SRC_OVR for the SCI
1210 * pretend we got one so we can set the SCI flags.
1211 * But ignore setting up SCI on hardware reduced platforms.
1213 if (acpi_sci_override_gsi == INVALID_ACPI_IRQ && !acpi_gbl_reduced_hardware)
1214 acpi_sci_ioapic_setup(acpi_gbl_FADT.sci_interrupt, 0, 0,
1215 acpi_gbl_FADT.sci_interrupt);
1217 /* Fill in identity legacy mappings where no override */
1218 mp_config_acpi_legacy_irqs();
1220 count = acpi_table_parse_madt(ACPI_MADT_TYPE_NMI_SOURCE,
1221 acpi_parse_nmi_src, nr_irqs);
1223 printk(KERN_ERR PREFIX "Error parsing NMI SRC entry\n");
1224 /* TBD: Cleanup to allow fallback to MPS */
1231 static inline int acpi_parse_madt_ioapic_entries(void)
1235 #endif /* !CONFIG_X86_IO_APIC */
1237 static void __init early_acpi_process_madt(void)
1239 #ifdef CONFIG_X86_LOCAL_APIC
1242 if (!acpi_table_parse(ACPI_SIG_MADT, acpi_parse_madt)) {
1245 * Parse MADT LAPIC entries
1247 error = early_acpi_parse_madt_lapic_addr_ovr();
1250 smp_found_config = 1;
1252 if (error == -EINVAL) {
1254 * Dell Precision Workstation 410, 610 come here.
1256 printk(KERN_ERR PREFIX
1257 "Invalid BIOS MADT, disabling ACPI\n");
1264 static void __init acpi_process_madt(void)
1266 #ifdef CONFIG_X86_LOCAL_APIC
1269 if (!acpi_table_parse(ACPI_SIG_MADT, acpi_parse_madt)) {
1272 * Parse MADT LAPIC entries
1274 error = acpi_parse_madt_lapic_entries();
1279 * Parse MADT IO-APIC entries
1281 mutex_lock(&acpi_ioapic_lock);
1282 error = acpi_parse_madt_ioapic_entries();
1283 mutex_unlock(&acpi_ioapic_lock);
1285 acpi_set_irq_model_ioapic();
1287 smp_found_config = 1;
1290 if (error == -EINVAL) {
1292 * Dell Precision Workstation 410, 610 come here.
1294 printk(KERN_ERR PREFIX
1295 "Invalid BIOS MADT, disabling ACPI\n");
1300 * ACPI found no MADT, and so ACPI wants UP PIC mode.
1301 * In the event an MPS table was found, forget it.
1302 * Boot with "acpi=off" to use MPS on such a system.
1304 if (smp_found_config) {
1305 printk(KERN_WARNING PREFIX
1306 "No APIC-table, disabling MPS\n");
1307 smp_found_config = 0;
1312 * ACPI supports both logical (e.g. Hyper-Threading) and physical
1313 * processors, where MPS only supports physical.
1315 if (acpi_lapic && acpi_ioapic)
1316 printk(KERN_INFO "Using ACPI (MADT) for SMP configuration "
1318 else if (acpi_lapic)
1319 printk(KERN_INFO "Using ACPI for processor (LAPIC) "
1320 "configuration information\n");
1325 static int __init disable_acpi_irq(const struct dmi_system_id *d)
1328 printk(KERN_NOTICE "%s detected: force use of acpi=noirq\n",
1335 static int __init disable_acpi_pci(const struct dmi_system_id *d)
1338 printk(KERN_NOTICE "%s detected: force use of pci=noacpi\n",
1345 static int __init disable_acpi_xsdt(const struct dmi_system_id *d)
1348 pr_notice("%s detected: force use of acpi=rsdt\n", d->ident);
1349 acpi_gbl_do_not_use_xsdt = TRUE;
1351 pr_notice("Warning: DMI blacklist says broken, but acpi XSDT forced\n");
1356 static int __init dmi_disable_acpi(const struct dmi_system_id *d)
1359 printk(KERN_NOTICE "%s detected: acpi off\n", d->ident);
1363 "Warning: DMI blacklist says broken, but acpi forced\n");
1369 * Force ignoring BIOS IRQ0 override
1371 static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d)
1373 if (!acpi_skip_timer_override) {
1374 pr_notice("%s detected: Ignoring BIOS IRQ0 override\n",
1376 acpi_skip_timer_override = 1;
1382 * ACPI offers an alternative platform interface model that removes
1383 * ACPI hardware requirements for platforms that do not implement
1384 * the PC Architecture.
1386 * We initialize the Hardware-reduced ACPI model here:
1388 void __init acpi_generic_reduced_hw_init(void)
1391 * Override x86_init functions and bypass legacy PIC in
1392 * hardware reduced ACPI mode.
1394 x86_init.timers.timer_init = x86_init_noop;
1395 x86_init.irqs.pre_vector_init = x86_init_noop;
1396 legacy_pic = &null_legacy_pic;
1399 static void __init acpi_reduced_hw_init(void)
1401 if (acpi_gbl_reduced_hardware)
1402 x86_init.acpi.reduced_hw_early_init();
1406 * If your system is blacklisted here, but you find that acpi=force
1407 * works for you, please contact linux-acpi@vger.kernel.org
1409 static const struct dmi_system_id acpi_dmi_table[] __initconst = {
1411 * Boxes that need ACPI disabled
1414 .callback = dmi_disable_acpi,
1415 .ident = "IBM Thinkpad",
1417 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
1418 DMI_MATCH(DMI_BOARD_NAME, "2629H1G"),
1423 * Boxes that need ACPI PCI IRQ routing disabled
1426 .callback = disable_acpi_irq,
1427 .ident = "ASUS A7V",
1429 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC"),
1430 DMI_MATCH(DMI_BOARD_NAME, "<A7V>"),
1431 /* newer BIOS, Revision 1011, does work */
1432 DMI_MATCH(DMI_BIOS_VERSION,
1433 "ASUS A7V ACPI BIOS Revision 1007"),
1438 * Latest BIOS for IBM 600E (1.16) has bad pcinum
1439 * for LPC bridge, which is needed for the PCI
1440 * interrupt links to work. DSDT fix is in bug 5966.
1441 * 2645, 2646 model numbers are shared with 600/600E/600X
1443 .callback = disable_acpi_irq,
1444 .ident = "IBM Thinkpad 600 Series 2645",
1446 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
1447 DMI_MATCH(DMI_BOARD_NAME, "2645"),
1451 .callback = disable_acpi_irq,
1452 .ident = "IBM Thinkpad 600 Series 2646",
1454 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
1455 DMI_MATCH(DMI_BOARD_NAME, "2646"),
1459 * Boxes that need ACPI PCI IRQ routing and PCI scan disabled
1462 .callback = disable_acpi_pci,
1463 .ident = "ASUS PR-DLS",
1465 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
1466 DMI_MATCH(DMI_BOARD_NAME, "PR-DLS"),
1467 DMI_MATCH(DMI_BIOS_VERSION,
1468 "ASUS PR-DLS ACPI BIOS Revision 1010"),
1469 DMI_MATCH(DMI_BIOS_DATE, "03/21/2003")
1473 .callback = disable_acpi_pci,
1474 .ident = "Acer TravelMate 36x Laptop",
1476 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
1477 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 360"),
1481 * Boxes that need ACPI XSDT use disabled due to corrupted tables
1484 .callback = disable_acpi_xsdt,
1485 .ident = "Advantech DAC-BJ01",
1487 DMI_MATCH(DMI_SYS_VENDOR, "NEC"),
1488 DMI_MATCH(DMI_PRODUCT_NAME, "Bearlake CRB Board"),
1489 DMI_MATCH(DMI_BIOS_VERSION, "V1.12"),
1490 DMI_MATCH(DMI_BIOS_DATE, "02/01/2011"),
1496 /* second table for DMI checks that should run after early-quirks */
1497 static const struct dmi_system_id acpi_dmi_table_late[] __initconst = {
1499 * HP laptops which use a DSDT reporting as HP/SB400/10000,
1500 * which includes some code which overrides all temperature
1501 * trip points to 16C if the INTIN2 input of the I/O APIC
1502 * is enabled. This input is incorrectly designated the
1503 * ISA IRQ 0 via an interrupt source override even though
1504 * it is wired to the output of the master 8259A and INTIN0
1505 * is not connected at all. Force ignoring BIOS IRQ0
1506 * override in that cases.
1509 .callback = dmi_ignore_irq0_timer_override,
1510 .ident = "HP nx6115 laptop",
1512 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
1513 DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq nx6115"),
1517 .callback = dmi_ignore_irq0_timer_override,
1518 .ident = "HP NX6125 laptop",
1520 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
1521 DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq nx6125"),
1525 .callback = dmi_ignore_irq0_timer_override,
1526 .ident = "HP NX6325 laptop",
1528 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
1529 DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq nx6325"),
1533 .callback = dmi_ignore_irq0_timer_override,
1534 .ident = "HP 6715b laptop",
1536 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
1537 DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq 6715b"),
1541 .callback = dmi_ignore_irq0_timer_override,
1542 .ident = "FUJITSU SIEMENS",
1544 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
1545 DMI_MATCH(DMI_PRODUCT_NAME, "AMILO PRO V2030"),
1552 * acpi_boot_table_init() and acpi_boot_init()
1553 * called from setup_arch(), always.
1554 * 1. checksums all tables
1555 * 2. enumerates lapics
1556 * 3. enumerates io-apics
1558 * acpi_table_init() is separate to allow reading SRAT without
1559 * other side effects.
1561 * side effects of acpi_boot_init:
1562 * acpi_lapic = 1 if LAPIC found
1563 * acpi_ioapic = 1 if IOAPIC found
1564 * if (acpi_lapic && acpi_ioapic) smp_found_config = 1;
1565 * if acpi_blacklisted() acpi_disabled = 1;
1566 * acpi_irq_model=...
1570 void __init acpi_boot_table_init(void)
1572 dmi_check_system(acpi_dmi_table);
1575 * If acpi_disabled, bail out
1581 * Initialize the ACPI boot-time table parser.
1583 if (acpi_locate_initial_tables())
1586 acpi_reserve_initial_tables();
1589 int __init early_acpi_boot_init(void)
1594 acpi_table_init_complete();
1596 acpi_table_parse(ACPI_SIG_BOOT, acpi_parse_sbf);
1599 * blacklist may disable ACPI entirely
1601 if (acpi_blacklisted()) {
1603 printk(KERN_WARNING PREFIX "acpi=force override\n");
1605 printk(KERN_WARNING PREFIX "Disabling ACPI support\n");
1612 * Process the Multiple APIC Description Table (MADT), if present
1614 early_acpi_process_madt();
1617 * Hardware-reduced ACPI mode initialization:
1619 acpi_reduced_hw_init();
1624 int __init acpi_boot_init(void)
1626 /* those are executed after early-quirks are executed */
1627 dmi_check_system(acpi_dmi_table_late);
1630 * If acpi_disabled, bail out
1635 acpi_table_parse(ACPI_SIG_BOOT, acpi_parse_sbf);
1638 * set sci_int and PM timer address
1640 acpi_table_parse(ACPI_SIG_FADT, acpi_parse_fadt);
1643 * Process the Multiple APIC Description Table (MADT), if present
1645 acpi_process_madt();
1647 acpi_table_parse(ACPI_SIG_HPET, acpi_parse_hpet);
1648 if (IS_ENABLED(CONFIG_ACPI_BGRT))
1649 acpi_table_parse(ACPI_SIG_BGRT, acpi_parse_bgrt);
1652 x86_init.pci.init = pci_acpi_init;
1654 /* Do not enable ACPI SPCR console by default */
1655 acpi_parse_spcr(earlycon_acpi_spcr_enable, false);
1659 static int __init parse_acpi(char *arg)
1664 /* "acpi=off" disables both ACPI table parsing and interpreter */
1665 if (strcmp(arg, "off") == 0) {
1668 /* acpi=force to over-ride black-list */
1669 else if (strcmp(arg, "force") == 0) {
1673 /* acpi=strict disables out-of-spec workarounds */
1674 else if (strcmp(arg, "strict") == 0) {
1677 /* acpi=rsdt use RSDT instead of XSDT */
1678 else if (strcmp(arg, "rsdt") == 0) {
1679 acpi_gbl_do_not_use_xsdt = TRUE;
1681 /* "acpi=noirq" disables ACPI interrupt routing */
1682 else if (strcmp(arg, "noirq") == 0) {
1685 /* "acpi=copy_dsdt" copys DSDT */
1686 else if (strcmp(arg, "copy_dsdt") == 0) {
1687 acpi_gbl_copy_dsdt_locally = 1;
1689 /* "acpi=nocmcff" disables FF mode for corrected errors */
1690 else if (strcmp(arg, "nocmcff") == 0) {
1691 acpi_disable_cmcff = 1;
1693 /* Core will printk when we return error. */
1698 early_param("acpi", parse_acpi);
1700 /* FIXME: Using pci= for an ACPI parameter is a travesty. */
1701 static int __init parse_pci(char *arg)
1703 if (arg && strcmp(arg, "noacpi") == 0)
1707 early_param("pci", parse_pci);
1709 int __init acpi_mps_check(void)
1711 #if defined(CONFIG_X86_LOCAL_APIC) && !defined(CONFIG_X86_MPPARSE)
1712 /* mptable code is not built-in*/
1713 if (acpi_disabled || acpi_noirq) {
1714 printk(KERN_WARNING "MPS support code is not built-in.\n"
1715 "Using acpi=off or acpi=noirq or pci=noacpi "
1716 "may have problem\n");
1723 #ifdef CONFIG_X86_IO_APIC
1724 static int __init parse_acpi_skip_timer_override(char *arg)
1726 acpi_skip_timer_override = 1;
1729 early_param("acpi_skip_timer_override", parse_acpi_skip_timer_override);
1731 static int __init parse_acpi_use_timer_override(char *arg)
1733 acpi_use_timer_override = 1;
1736 early_param("acpi_use_timer_override", parse_acpi_use_timer_override);
1737 #endif /* CONFIG_X86_IO_APIC */
1739 static int __init setup_acpi_sci(char *s)
1743 if (!strcmp(s, "edge"))
1744 acpi_sci_flags = ACPI_MADT_TRIGGER_EDGE |
1745 (acpi_sci_flags & ~ACPI_MADT_TRIGGER_MASK);
1746 else if (!strcmp(s, "level"))
1747 acpi_sci_flags = ACPI_MADT_TRIGGER_LEVEL |
1748 (acpi_sci_flags & ~ACPI_MADT_TRIGGER_MASK);
1749 else if (!strcmp(s, "high"))
1750 acpi_sci_flags = ACPI_MADT_POLARITY_ACTIVE_HIGH |
1751 (acpi_sci_flags & ~ACPI_MADT_POLARITY_MASK);
1752 else if (!strcmp(s, "low"))
1753 acpi_sci_flags = ACPI_MADT_POLARITY_ACTIVE_LOW |
1754 (acpi_sci_flags & ~ACPI_MADT_POLARITY_MASK);
1759 early_param("acpi_sci", setup_acpi_sci);
1761 int __acpi_acquire_global_lock(unsigned int *lock)
1763 unsigned int old, new, val;
1766 new = (((old & ~0x3) + 2) + ((old >> 1) & 0x1));
1767 val = cmpxchg(lock, old, new);
1768 } while (unlikely (val != old));
1769 return ((new & 0x3) < 3) ? -1 : 0;
1772 int __acpi_release_global_lock(unsigned int *lock)
1774 unsigned int old, new, val;
1778 val = cmpxchg(lock, old, new);
1779 } while (unlikely (val != old));
1783 void __init arch_reserve_mem_area(acpi_physical_address addr, size_t size)
1785 e820__range_add(addr, size, E820_TYPE_ACPI);
1786 e820__update_table_print();
1789 void x86_default_set_root_pointer(u64 addr)
1791 boot_params.acpi_rsdp_addr = addr;
1794 u64 x86_default_get_root_pointer(void)
1796 return boot_params.acpi_rsdp_addr;