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>
8 #define pr_fmt(fmt) "ACPI: " fmt
10 #include <linux/init.h>
11 #include <linux/acpi.h>
12 #include <linux/acpi_pmtmr.h>
13 #include <linux/efi.h>
14 #include <linux/cpumask.h>
15 #include <linux/export.h>
16 #include <linux/dmi.h>
17 #include <linux/irq.h>
18 #include <linux/slab.h>
19 #include <linux/memblock.h>
20 #include <linux/ioport.h>
21 #include <linux/pci.h>
22 #include <linux/efi-bgrt.h>
23 #include <linux/serial_core.h>
24 #include <linux/pgtable.h>
26 #include <asm/e820/api.h>
27 #include <asm/irqdomain.h>
28 #include <asm/pci_x86.h>
29 #include <asm/io_apic.h>
32 #include <asm/mpspec.h>
34 #include <asm/i8259.h>
35 #include <asm/setup.h>
37 #include "sleep.h" /* To include x86_acpi_suspend_lowlevel */
38 static int __initdata acpi_force
= 0;
40 EXPORT_SYMBOL(acpi_disabled
);
43 # include <asm/proto.h>
46 int acpi_noirq
; /* skip ACPI IRQ initialization */
47 static int acpi_nobgrt
; /* skip ACPI BGRT */
48 int acpi_pci_disabled
; /* skip ACPI PCI scan and IRQ initialization */
49 EXPORT_SYMBOL(acpi_pci_disabled
);
54 int acpi_disable_cmcff
;
55 bool acpi_int_src_ovr
[NR_IRQS_LEGACY
];
57 /* ACPI SCI override configuration */
58 u8 acpi_sci_flags __initdata
;
59 u32 acpi_sci_override_gsi __initdata
= INVALID_ACPI_IRQ
;
60 int acpi_skip_timer_override __initdata
;
61 int acpi_use_timer_override __initdata
;
62 int acpi_fix_pin2_polarity __initdata
;
64 #ifdef CONFIG_X86_LOCAL_APIC
65 static u64 acpi_lapic_addr __initdata
= APIC_DEFAULT_PHYS_BASE
;
66 static bool has_lapic_cpus __initdata
;
67 static bool acpi_support_online_capable
;
70 #ifdef CONFIG_X86_IO_APIC
72 * Locks related to IOAPIC hotplug
74 * ->device_hotplug_lock
77 * Interrupt mapping side:
82 static DEFINE_MUTEX(acpi_ioapic_lock
);
85 /* --------------------------------------------------------------------------
86 Boot-time Configuration
87 -------------------------------------------------------------------------- */
90 * The default interrupt routing model is PIC (8259). This gets
91 * overridden if IOAPICs are enumerated (below).
93 enum acpi_irq_model_id acpi_irq_model
= ACPI_IRQ_MODEL_PIC
;
97 * ISA irqs by default are the first 16 gsis but can be
98 * any gsi as specified by an interrupt source override.
100 static u32 isa_irq_to_gsi
[NR_IRQS_LEGACY
] __read_mostly
= {
101 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
105 * This is just a simple wrapper around early_memremap(),
106 * with sanity checks for phys == 0 and size == 0.
108 void __init __iomem
*__acpi_map_table(unsigned long phys
, unsigned long size
)
114 return early_memremap(phys
, size
);
117 void __init
__acpi_unmap_table(void __iomem
*map
, unsigned long size
)
122 early_memunmap(map
, size
);
125 #ifdef CONFIG_X86_LOCAL_APIC
126 static int __init
acpi_parse_madt(struct acpi_table_header
*table
)
128 struct acpi_table_madt
*madt
= NULL
;
130 if (!boot_cpu_has(X86_FEATURE_APIC
))
133 madt
= (struct acpi_table_madt
*)table
;
135 pr_warn("Unable to map MADT\n");
140 acpi_lapic_addr
= (u64
) madt
->address
;
142 pr_debug("Local APIC address 0x%08x\n", madt
->address
);
145 if (madt
->flags
& ACPI_MADT_PCAT_COMPAT
)
146 legacy_pic_pcat_compat();
148 /* ACPI 6.3 and newer support the online capable bit. */
149 if (acpi_gbl_FADT
.header
.revision
> 6 ||
150 (acpi_gbl_FADT
.header
.revision
== 6 &&
151 acpi_gbl_FADT
.minor_revision
>= 3))
152 acpi_support_online_capable
= true;
154 default_acpi_madt_oem_check(madt
->header
.oem_id
,
155 madt
->header
.oem_table_id
);
160 static bool __init
acpi_is_processor_usable(u32 lapic_flags
)
162 if (lapic_flags
& ACPI_MADT_ENABLED
)
165 if (!acpi_support_online_capable
||
166 (lapic_flags
& ACPI_MADT_ONLINE_CAPABLE
))
173 acpi_parse_x2apic(union acpi_subtable_headers
*header
, const unsigned long end
)
175 struct acpi_madt_local_x2apic
*processor
= NULL
;
176 #ifdef CONFIG_X86_X2APIC
181 processor
= (struct acpi_madt_local_x2apic
*)header
;
183 if (BAD_MADT_ENTRY(processor
, end
))
186 acpi_table_print_madt_entry(&header
->common
);
188 #ifdef CONFIG_X86_X2APIC
189 apic_id
= processor
->local_apic_id
;
190 enabled
= processor
->lapic_flags
& ACPI_MADT_ENABLED
;
192 /* Ignore invalid ID */
193 if (apic_id
== 0xffffffff)
196 /* don't register processors that cannot be onlined */
197 if (!acpi_is_processor_usable(processor
->lapic_flags
))
201 * According to https://uefi.org/specs/ACPI/6.5/05_ACPI_Software_Programming_Model.html#processor-local-x2apic-structure
202 * when MADT provides both valid LAPIC and x2APIC entries, the APIC ID
203 * in x2APIC must be equal or greater than 0xff.
205 if (has_lapic_cpus
&& apic_id
< 0xff)
209 * We need to register disabled CPU as well to permit
210 * counting disabled CPUs. This allows us to size
211 * cpus_possible_map more accurately, to permit
212 * to not preallocating memory for all NR_CPUS
213 * when we use CPU hotplug.
215 if (!apic_id_valid(apic_id
)) {
217 pr_warn("x2apic entry ignored\n");
221 topology_register_apic(apic_id
, processor
->uid
, enabled
);
223 pr_warn("x2apic entry ignored\n");
230 acpi_parse_lapic(union acpi_subtable_headers
* header
, const unsigned long end
)
232 struct acpi_madt_local_apic
*processor
= NULL
;
234 processor
= (struct acpi_madt_local_apic
*)header
;
236 if (BAD_MADT_ENTRY(processor
, end
))
239 acpi_table_print_madt_entry(&header
->common
);
241 /* Ignore invalid ID */
242 if (processor
->id
== 0xff)
245 /* don't register processors that can not be onlined */
246 if (!acpi_is_processor_usable(processor
->lapic_flags
))
250 * We need to register disabled CPU as well to permit
251 * counting disabled CPUs. This allows us to size
252 * cpus_possible_map more accurately, to permit
253 * to not preallocating memory for all NR_CPUS
254 * when we use CPU hotplug.
256 topology_register_apic(processor
->id
, /* APIC ID */
257 processor
->processor_id
, /* ACPI ID */
258 processor
->lapic_flags
& ACPI_MADT_ENABLED
);
260 has_lapic_cpus
= true;
265 acpi_parse_sapic(union acpi_subtable_headers
*header
, const unsigned long end
)
267 struct acpi_madt_local_sapic
*processor
= NULL
;
269 processor
= (struct acpi_madt_local_sapic
*)header
;
271 if (BAD_MADT_ENTRY(processor
, end
))
274 acpi_table_print_madt_entry(&header
->common
);
276 topology_register_apic((processor
->id
<< 8) | processor
->eid
,/* APIC ID */
277 processor
->processor_id
, /* ACPI ID */
278 processor
->lapic_flags
& ACPI_MADT_ENABLED
);
284 acpi_parse_lapic_addr_ovr(union acpi_subtable_headers
* header
,
285 const unsigned long end
)
287 struct acpi_madt_local_apic_override
*lapic_addr_ovr
= NULL
;
289 lapic_addr_ovr
= (struct acpi_madt_local_apic_override
*)header
;
291 if (BAD_MADT_ENTRY(lapic_addr_ovr
, end
))
294 acpi_table_print_madt_entry(&header
->common
);
296 acpi_lapic_addr
= lapic_addr_ovr
->address
;
302 acpi_parse_x2apic_nmi(union acpi_subtable_headers
*header
,
303 const unsigned long end
)
305 struct acpi_madt_local_x2apic_nmi
*x2apic_nmi
= NULL
;
307 x2apic_nmi
= (struct acpi_madt_local_x2apic_nmi
*)header
;
309 if (BAD_MADT_ENTRY(x2apic_nmi
, end
))
312 acpi_table_print_madt_entry(&header
->common
);
314 if (x2apic_nmi
->lint
!= 1)
315 pr_warn("NMI not connected to LINT 1!\n");
321 acpi_parse_lapic_nmi(union acpi_subtable_headers
* header
, const unsigned long end
)
323 struct acpi_madt_local_apic_nmi
*lapic_nmi
= NULL
;
325 lapic_nmi
= (struct acpi_madt_local_apic_nmi
*)header
;
327 if (BAD_MADT_ENTRY(lapic_nmi
, end
))
330 acpi_table_print_madt_entry(&header
->common
);
332 if (lapic_nmi
->lint
!= 1)
333 pr_warn("NMI not connected to LINT 1!\n");
337 #endif /* CONFIG_X86_LOCAL_APIC */
339 #ifdef CONFIG_X86_IO_APIC
342 static int __init
mp_register_ioapic_irq(u8 bus_irq
, u8 polarity
,
343 u8 trigger
, u32 gsi
);
345 static void __init
mp_override_legacy_irq(u8 bus_irq
, u8 polarity
, u8 trigger
,
349 * Check bus_irq boundary.
351 if (bus_irq
>= NR_IRQS_LEGACY
) {
352 pr_warn("Invalid bus_irq %u for legacy override\n", bus_irq
);
357 * TBD: This check is for faulty timer entries, where the override
358 * erroneously sets the trigger to level, resulting in a HUGE
359 * increase of timer interrupts!
361 if ((bus_irq
== 0) && (trigger
== 3))
364 if (mp_register_ioapic_irq(bus_irq
, polarity
, trigger
, gsi
) < 0)
367 * Reset default identity mapping if gsi is also an legacy IRQ,
368 * otherwise there will be more than one entry with the same GSI
369 * and acpi_isa_irq_to_gsi() may give wrong result.
371 if (gsi
< nr_legacy_irqs() && isa_irq_to_gsi
[gsi
] == gsi
)
372 isa_irq_to_gsi
[gsi
] = INVALID_ACPI_IRQ
;
373 isa_irq_to_gsi
[bus_irq
] = gsi
;
376 static void mp_config_acpi_gsi(struct device
*dev
, u32 gsi
, int trigger
,
379 #ifdef CONFIG_X86_MPPARSE
380 struct mpc_intsrc mp_irq
;
381 struct pci_dev
*pdev
;
382 unsigned char number
;
389 if (!dev
|| !dev_is_pci(dev
))
392 pdev
= to_pci_dev(dev
);
393 number
= pdev
->bus
->number
;
396 /* print the entry should happen on mptable identically */
397 mp_irq
.type
= MP_INTSRC
;
398 mp_irq
.irqtype
= mp_INT
;
399 mp_irq
.irqflag
= (trigger
== ACPI_EDGE_SENSITIVE
? 4 : 0x0c) |
400 (polarity
== ACPI_ACTIVE_HIGH
? 1 : 3);
401 mp_irq
.srcbus
= number
;
402 mp_irq
.srcbusirq
= (((devfn
>> 3) & 0x1f) << 2) | ((pin
- 1) & 3);
403 ioapic
= mp_find_ioapic(gsi
);
404 mp_irq
.dstapic
= mpc_ioapic_id(ioapic
);
405 mp_irq
.dstirq
= mp_find_ioapic_pin(ioapic
, gsi
);
407 mp_save_irq(&mp_irq
);
411 static int __init
mp_register_ioapic_irq(u8 bus_irq
, u8 polarity
,
414 struct mpc_intsrc mp_irq
;
417 /* Convert 'gsi' to 'ioapic.pin'(INTIN#) */
418 ioapic
= mp_find_ioapic(gsi
);
420 pr_warn("Failed to find ioapic for gsi : %u\n", gsi
);
424 pin
= mp_find_ioapic_pin(ioapic
, gsi
);
426 mp_irq
.type
= MP_INTSRC
;
427 mp_irq
.irqtype
= mp_INT
;
428 mp_irq
.irqflag
= (trigger
<< 2) | polarity
;
429 mp_irq
.srcbus
= MP_ISA_BUS
;
430 mp_irq
.srcbusirq
= bus_irq
;
431 mp_irq
.dstapic
= mpc_ioapic_id(ioapic
);
434 mp_save_irq(&mp_irq
);
440 acpi_parse_ioapic(union acpi_subtable_headers
* header
, const unsigned long end
)
442 struct acpi_madt_io_apic
*ioapic
= NULL
;
443 struct ioapic_domain_cfg cfg
= {
444 .type
= IOAPIC_DOMAIN_DYNAMIC
,
445 .ops
= &mp_ioapic_irqdomain_ops
,
448 ioapic
= (struct acpi_madt_io_apic
*)header
;
450 if (BAD_MADT_ENTRY(ioapic
, end
))
453 acpi_table_print_madt_entry(&header
->common
);
455 /* Statically assign IRQ numbers for IOAPICs hosting legacy IRQs */
456 if (ioapic
->global_irq_base
< nr_legacy_irqs())
457 cfg
.type
= IOAPIC_DOMAIN_LEGACY
;
459 mp_register_ioapic(ioapic
->id
, ioapic
->address
, ioapic
->global_irq_base
,
466 * Parse Interrupt Source Override for the ACPI SCI
468 static void __init
acpi_sci_ioapic_setup(u8 bus_irq
, u16 polarity
, u16 trigger
, u32 gsi
)
470 if (trigger
== 0) /* compatible SCI trigger is level */
473 if (polarity
== 0) /* compatible SCI polarity is low */
476 /* Command-line over-ride via acpi_sci= */
477 if (acpi_sci_flags
& ACPI_MADT_TRIGGER_MASK
)
478 trigger
= (acpi_sci_flags
& ACPI_MADT_TRIGGER_MASK
) >> 2;
480 if (acpi_sci_flags
& ACPI_MADT_POLARITY_MASK
)
481 polarity
= acpi_sci_flags
& ACPI_MADT_POLARITY_MASK
;
483 if (bus_irq
< NR_IRQS_LEGACY
)
484 mp_override_legacy_irq(bus_irq
, polarity
, trigger
, gsi
);
486 mp_register_ioapic_irq(bus_irq
, polarity
, trigger
, gsi
);
488 acpi_penalize_sci_irq(bus_irq
, trigger
, polarity
);
491 * stash over-ride to indicate we've been here
492 * and for later update of acpi_gbl_FADT
494 acpi_sci_override_gsi
= gsi
;
499 acpi_parse_int_src_ovr(union acpi_subtable_headers
* header
,
500 const unsigned long end
)
502 struct acpi_madt_interrupt_override
*intsrc
= NULL
;
504 intsrc
= (struct acpi_madt_interrupt_override
*)header
;
506 if (BAD_MADT_ENTRY(intsrc
, end
))
509 acpi_table_print_madt_entry(&header
->common
);
511 if (intsrc
->source_irq
< NR_IRQS_LEGACY
)
512 acpi_int_src_ovr
[intsrc
->source_irq
] = true;
514 if (intsrc
->source_irq
== acpi_gbl_FADT
.sci_interrupt
) {
515 acpi_sci_ioapic_setup(intsrc
->source_irq
,
516 intsrc
->inti_flags
& ACPI_MADT_POLARITY_MASK
,
517 (intsrc
->inti_flags
& ACPI_MADT_TRIGGER_MASK
) >> 2,
522 if (intsrc
->source_irq
== 0) {
523 if (acpi_skip_timer_override
) {
524 pr_warn("BIOS IRQ0 override ignored.\n");
528 if ((intsrc
->global_irq
== 2) && acpi_fix_pin2_polarity
529 && (intsrc
->inti_flags
& ACPI_MADT_POLARITY_MASK
)) {
530 intsrc
->inti_flags
&= ~ACPI_MADT_POLARITY_MASK
;
531 pr_warn("BIOS IRQ0 pin2 override: forcing polarity to high active.\n");
535 mp_override_legacy_irq(intsrc
->source_irq
,
536 intsrc
->inti_flags
& ACPI_MADT_POLARITY_MASK
,
537 (intsrc
->inti_flags
& ACPI_MADT_TRIGGER_MASK
) >> 2,
544 acpi_parse_nmi_src(union acpi_subtable_headers
* header
, const unsigned long end
)
546 struct acpi_madt_nmi_source
*nmi_src
= NULL
;
548 nmi_src
= (struct acpi_madt_nmi_source
*)header
;
550 if (BAD_MADT_ENTRY(nmi_src
, end
))
553 acpi_table_print_madt_entry(&header
->common
);
555 /* TBD: Support nimsrc entries? */
560 #endif /* CONFIG_X86_IO_APIC */
563 * acpi_pic_sci_set_trigger()
565 * use ELCR to set PIC-mode trigger type for SCI
567 * If a PIC-mode SCI is not recognized or gives spurious IRQ7's
568 * it may require Edge Trigger -- use "acpi_sci=edge"
570 * Port 0x4d0-4d1 are ELCR1 and ELCR2, the Edge/Level Control Registers
571 * for the 8259 PIC. bit[n] = 1 means irq[n] is Level, otherwise Edge.
572 * ELCR1 is IRQs 0-7 (IRQ 0, 1, 2 must be 0)
573 * ELCR2 is IRQs 8-15 (IRQ 8, 13 must be 0)
576 void __init
acpi_pic_sci_set_trigger(unsigned int irq
, u16 trigger
)
578 unsigned int mask
= 1 << irq
;
579 unsigned int old
, new;
581 /* Real old ELCR mask */
582 old
= inb(PIC_ELCR1
) | (inb(PIC_ELCR2
) << 8);
585 * If we use ACPI to set PCI IRQs, then we should clear ELCR
586 * since we will set it correctly as we enable the PCI irq
589 new = acpi_noirq
? old
: 0;
592 * Update SCI information in the ELCR, it isn't in the PCI
596 case 1: /* Edge - clear */
599 case 3: /* Level - set */
607 pr_warn("setting ELCR to %04x (from %04x)\n", new, old
);
608 outb(new, PIC_ELCR1
);
609 outb(new >> 8, PIC_ELCR2
);
612 int acpi_gsi_to_irq(u32 gsi
, unsigned int *irqp
)
614 int rc
, irq
, trigger
, polarity
;
616 if (acpi_irq_model
== ACPI_IRQ_MODEL_PIC
) {
621 rc
= acpi_get_override_irq(gsi
, &trigger
, &polarity
);
625 trigger
= trigger
? ACPI_LEVEL_SENSITIVE
: ACPI_EDGE_SENSITIVE
;
626 polarity
= polarity
? ACPI_ACTIVE_LOW
: ACPI_ACTIVE_HIGH
;
627 irq
= acpi_register_gsi(NULL
, gsi
, trigger
, polarity
);
634 EXPORT_SYMBOL_GPL(acpi_gsi_to_irq
);
636 int acpi_isa_irq_to_gsi(unsigned isa_irq
, u32
*gsi
)
638 if (isa_irq
< nr_legacy_irqs() &&
639 isa_irq_to_gsi
[isa_irq
] != INVALID_ACPI_IRQ
) {
640 *gsi
= isa_irq_to_gsi
[isa_irq
];
647 static int acpi_register_gsi_pic(struct device
*dev
, u32 gsi
,
648 int trigger
, int polarity
)
652 * Make sure all (legacy) PCI IRQs are set as level-triggered.
654 if (trigger
== ACPI_LEVEL_SENSITIVE
)
655 elcr_set_level_irq(gsi
);
661 #ifdef CONFIG_X86_LOCAL_APIC
662 static int acpi_register_gsi_ioapic(struct device
*dev
, u32 gsi
,
663 int trigger
, int polarity
)
666 #ifdef CONFIG_X86_IO_APIC
668 struct irq_alloc_info info
;
670 node
= dev
? dev_to_node(dev
) : NUMA_NO_NODE
;
671 trigger
= trigger
== ACPI_EDGE_SENSITIVE
? 0 : 1;
672 polarity
= polarity
== ACPI_ACTIVE_HIGH
? 0 : 1;
673 ioapic_set_alloc_attr(&info
, node
, trigger
, polarity
);
675 mutex_lock(&acpi_ioapic_lock
);
676 irq
= mp_map_gsi_to_irq(gsi
, IOAPIC_MAP_ALLOC
, &info
);
677 /* Don't set up the ACPI SCI because it's already set up */
678 if (irq
>= 0 && enable_update_mptable
&& gsi
!= acpi_gbl_FADT
.sci_interrupt
)
679 mp_config_acpi_gsi(dev
, gsi
, trigger
, polarity
);
680 mutex_unlock(&acpi_ioapic_lock
);
686 static void acpi_unregister_gsi_ioapic(u32 gsi
)
688 #ifdef CONFIG_X86_IO_APIC
691 mutex_lock(&acpi_ioapic_lock
);
692 irq
= mp_map_gsi_to_irq(gsi
, 0, NULL
);
695 mutex_unlock(&acpi_ioapic_lock
);
700 int (*__acpi_register_gsi
)(struct device
*dev
, u32 gsi
,
701 int trigger
, int polarity
) = acpi_register_gsi_pic
;
702 void (*__acpi_unregister_gsi
)(u32 gsi
) = NULL
;
704 #ifdef CONFIG_ACPI_SLEEP
705 int (*acpi_suspend_lowlevel
)(void) = x86_acpi_suspend_lowlevel
;
707 int (*acpi_suspend_lowlevel
)(void);
711 * success: return IRQ number (>=0)
712 * failure: return < 0
714 int acpi_register_gsi(struct device
*dev
, u32 gsi
, int trigger
, int polarity
)
716 return __acpi_register_gsi(dev
, gsi
, trigger
, polarity
);
718 EXPORT_SYMBOL_GPL(acpi_register_gsi
);
720 void acpi_unregister_gsi(u32 gsi
)
722 if (__acpi_unregister_gsi
)
723 __acpi_unregister_gsi(gsi
);
725 EXPORT_SYMBOL_GPL(acpi_unregister_gsi
);
727 #ifdef CONFIG_X86_LOCAL_APIC
728 static void __init
acpi_set_irq_model_ioapic(void)
730 acpi_irq_model
= ACPI_IRQ_MODEL_IOAPIC
;
731 __acpi_register_gsi
= acpi_register_gsi_ioapic
;
732 __acpi_unregister_gsi
= acpi_unregister_gsi_ioapic
;
738 * ACPI based hotplug support for CPU
740 #ifdef CONFIG_ACPI_HOTPLUG_CPU
741 #include <acpi/processor.h>
743 static int acpi_map_cpu2node(acpi_handle handle
, int cpu
, int physid
)
745 #ifdef CONFIG_ACPI_NUMA
748 nid
= acpi_get_node(handle
);
749 if (nid
!= NUMA_NO_NODE
) {
750 set_apicid_to_node(physid
, nid
);
751 numa_set_node(cpu
, nid
);
757 int acpi_map_cpu(acpi_handle handle
, phys_cpuid_t physid
, u32 acpi_id
, int *pcpu
)
759 int cpu
= topology_hotplug_apic(physid
, acpi_id
);
762 pr_info("Unable to map lapic to logical cpu number\n");
766 acpi_processor_set_pdc(handle
);
767 acpi_map_cpu2node(handle
, cpu
, physid
);
772 EXPORT_SYMBOL(acpi_map_cpu
);
774 int acpi_unmap_cpu(int cpu
)
776 #ifdef CONFIG_ACPI_NUMA
777 set_apicid_to_node(per_cpu(x86_cpu_to_apicid
, cpu
), NUMA_NO_NODE
);
779 topology_hotunplug_apic(cpu
);
782 EXPORT_SYMBOL(acpi_unmap_cpu
);
783 #endif /* CONFIG_ACPI_HOTPLUG_CPU */
785 int acpi_register_ioapic(acpi_handle handle
, u64 phys_addr
, u32 gsi_base
)
788 #ifdef CONFIG_ACPI_HOTPLUG_IOAPIC
791 struct ioapic_domain_cfg cfg
= {
792 .type
= IOAPIC_DOMAIN_DYNAMIC
,
793 .ops
= &mp_ioapic_irqdomain_ops
,
796 ioapic_id
= acpi_get_ioapic_id(handle
, gsi_base
, &addr
);
798 unsigned long long uid
;
801 status
= acpi_evaluate_integer(handle
, METHOD_NAME__UID
,
803 if (ACPI_FAILURE(status
)) {
804 acpi_handle_warn(handle
, "failed to get IOAPIC ID.\n");
807 ioapic_id
= (int)uid
;
810 mutex_lock(&acpi_ioapic_lock
);
811 ret
= mp_register_ioapic(ioapic_id
, phys_addr
, gsi_base
, &cfg
);
812 mutex_unlock(&acpi_ioapic_lock
);
817 EXPORT_SYMBOL(acpi_register_ioapic
);
819 int acpi_unregister_ioapic(acpi_handle handle
, u32 gsi_base
)
823 #ifdef CONFIG_ACPI_HOTPLUG_IOAPIC
824 mutex_lock(&acpi_ioapic_lock
);
825 ret
= mp_unregister_ioapic(gsi_base
);
826 mutex_unlock(&acpi_ioapic_lock
);
831 EXPORT_SYMBOL(acpi_unregister_ioapic
);
834 * acpi_ioapic_registered - Check whether IOAPIC associated with @gsi_base
835 * has been registered
836 * @handle: ACPI handle of the IOAPIC device
837 * @gsi_base: GSI base associated with the IOAPIC
839 * Assume caller holds some type of lock to serialize acpi_ioapic_registered()
840 * with acpi_register_ioapic()/acpi_unregister_ioapic().
842 int acpi_ioapic_registered(acpi_handle handle
, u32 gsi_base
)
846 #ifdef CONFIG_ACPI_HOTPLUG_IOAPIC
847 mutex_lock(&acpi_ioapic_lock
);
848 ret
= mp_ioapic_registered(gsi_base
);
849 mutex_unlock(&acpi_ioapic_lock
);
855 static int __init
acpi_parse_sbf(struct acpi_table_header
*table
)
857 struct acpi_table_boot
*sb
= (struct acpi_table_boot
*)table
;
859 sbf_port
= sb
->cmos_index
; /* Save CMOS port */
864 #ifdef CONFIG_HPET_TIMER
865 #include <asm/hpet.h>
867 static struct resource
*hpet_res __initdata
;
869 static int __init
acpi_parse_hpet(struct acpi_table_header
*table
)
871 struct acpi_table_hpet
*hpet_tbl
= (struct acpi_table_hpet
*)table
;
873 if (hpet_tbl
->address
.space_id
!= ACPI_SPACE_MEM
) {
874 pr_warn("HPET timers must be located in memory.\n");
878 hpet_address
= hpet_tbl
->address
.address
;
879 hpet_blockid
= hpet_tbl
->sequence
;
882 * Some broken BIOSes advertise HPET at 0x0. We really do not
883 * want to allocate a resource there.
886 pr_warn("HPET id: %#x base: %#lx is invalid\n", hpet_tbl
->id
, hpet_address
);
891 * Some even more broken BIOSes advertise HPET at
892 * 0xfed0000000000000 instead of 0xfed00000. Fix it up and add
895 if (hpet_address
== 0xfed0000000000000UL
) {
896 if (!hpet_force_user
) {
897 pr_warn("HPET id: %#x base: 0xfed0000000000000 is bogus, try hpet=force on the kernel command line to fix it up to 0xfed00000.\n",
902 pr_warn("HPET id: %#x base: 0xfed0000000000000 fixed up to 0xfed00000.\n",
907 pr_info("HPET id: %#x base: %#lx\n", hpet_tbl
->id
, hpet_address
);
910 * Allocate and initialize the HPET firmware resource for adding into
911 * the resource tree during the lateinit timeframe.
913 #define HPET_RESOURCE_NAME_SIZE 9
914 hpet_res
= memblock_alloc(sizeof(*hpet_res
) + HPET_RESOURCE_NAME_SIZE
,
917 panic("%s: Failed to allocate %zu bytes\n", __func__
,
918 sizeof(*hpet_res
) + HPET_RESOURCE_NAME_SIZE
);
920 hpet_res
->name
= (void *)&hpet_res
[1];
921 hpet_res
->flags
= IORESOURCE_MEM
;
922 snprintf((char *)hpet_res
->name
, HPET_RESOURCE_NAME_SIZE
, "HPET %u",
925 hpet_res
->start
= hpet_address
;
926 hpet_res
->end
= hpet_address
+ (1 * 1024) - 1;
932 * hpet_insert_resource inserts the HPET resources used into the resource
935 static __init
int hpet_insert_resource(void)
940 return insert_resource(&iomem_resource
, hpet_res
);
943 late_initcall(hpet_insert_resource
);
946 #define acpi_parse_hpet NULL
949 static int __init
acpi_parse_fadt(struct acpi_table_header
*table
)
951 if (!(acpi_gbl_FADT
.boot_flags
& ACPI_FADT_LEGACY_DEVICES
)) {
952 pr_debug("no legacy devices present\n");
953 x86_platform
.legacy
.devices
.pnpbios
= 0;
956 if (acpi_gbl_FADT
.header
.revision
>= FADT2_REVISION_ID
&&
957 !(acpi_gbl_FADT
.boot_flags
& ACPI_FADT_8042
) &&
958 x86_platform
.legacy
.i8042
!= X86_LEGACY_I8042_PLATFORM_ABSENT
) {
959 pr_debug("i8042 controller is absent\n");
960 x86_platform
.legacy
.i8042
= X86_LEGACY_I8042_FIRMWARE_ABSENT
;
963 if (acpi_gbl_FADT
.boot_flags
& ACPI_FADT_NO_CMOS_RTC
) {
964 pr_debug("not registering RTC platform device\n");
965 x86_platform
.legacy
.rtc
= 0;
968 if (acpi_gbl_FADT
.boot_flags
& ACPI_FADT_NO_VGA
) {
969 pr_debug("probing for VGA not safe\n");
970 x86_platform
.legacy
.no_vga
= 1;
973 #ifdef CONFIG_X86_PM_TIMER
974 /* detect the location of the ACPI PM Timer */
975 if (acpi_gbl_FADT
.header
.revision
>= FADT2_REVISION_ID
) {
977 if (acpi_gbl_FADT
.xpm_timer_block
.space_id
!=
978 ACPI_ADR_SPACE_SYSTEM_IO
)
981 pmtmr_ioport
= acpi_gbl_FADT
.xpm_timer_block
.address
;
983 * "X" fields are optional extensions to the original V1.0
984 * fields, so we must selectively expand V1.0 fields if the
985 * corresponding X field is zero.
988 pmtmr_ioport
= acpi_gbl_FADT
.pm_timer_block
;
991 pmtmr_ioport
= acpi_gbl_FADT
.pm_timer_block
;
994 pr_info("PM-Timer IO Port: %#x\n", pmtmr_ioport
);
999 #ifdef CONFIG_X86_LOCAL_APIC
1001 * Parse LAPIC entries in MADT
1002 * returns 0 on success, < 0 on error
1005 static int __init
early_acpi_parse_madt_lapic_addr_ovr(void)
1009 if (!boot_cpu_has(X86_FEATURE_APIC
))
1013 * Note that the LAPIC address is obtained from the MADT (32-bit value)
1014 * and (optionally) overridden by a LAPIC_ADDR_OVR entry (64-bit value).
1017 count
= acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE
,
1018 acpi_parse_lapic_addr_ovr
, 0);
1020 pr_err("Error parsing LAPIC address override entry\n");
1024 register_lapic_address(acpi_lapic_addr
);
1029 static int __init
acpi_parse_madt_lapic_entries(void)
1031 int count
, x2count
= 0;
1033 if (!boot_cpu_has(X86_FEATURE_APIC
))
1036 count
= acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_SAPIC
,
1037 acpi_parse_sapic
, MAX_LOCAL_APIC
);
1040 count
= acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC
,
1041 acpi_parse_lapic
, MAX_LOCAL_APIC
);
1042 x2count
= acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_X2APIC
,
1043 acpi_parse_x2apic
, MAX_LOCAL_APIC
);
1045 if (!count
&& !x2count
) {
1046 pr_err("No LAPIC entries present\n");
1047 /* TBD: Cleanup to allow fallback to MPS */
1049 } else if (count
< 0 || x2count
< 0) {
1050 pr_err("Error parsing LAPIC entry\n");
1051 /* TBD: Cleanup to allow fallback to MPS */
1055 x2count
= acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_X2APIC_NMI
,
1056 acpi_parse_x2apic_nmi
, 0);
1057 count
= acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC_NMI
,
1058 acpi_parse_lapic_nmi
, 0);
1059 if (count
< 0 || x2count
< 0) {
1060 pr_err("Error parsing LAPIC NMI entry\n");
1061 /* TBD: Cleanup to allow fallback to MPS */
1066 #endif /* CONFIG_X86_LOCAL_APIC */
1068 #ifdef CONFIG_X86_IO_APIC
1069 static void __init
mp_config_acpi_legacy_irqs(void)
1072 struct mpc_intsrc mp_irq
;
1076 * Fabricate the legacy ISA bus (bus #31).
1078 mp_bus_id_to_type
[MP_ISA_BUS
] = MP_BUS_ISA
;
1080 set_bit(MP_ISA_BUS
, mp_bus_not_pci
);
1081 pr_debug("Bus #%d is ISA (nIRQs: %d)\n", MP_ISA_BUS
, nr_legacy_irqs());
1084 * Use the default configuration for the IRQs 0-15. Unless
1085 * overridden by (MADT) interrupt source override entries.
1087 for (i
= 0; i
< nr_legacy_irqs(); i
++) {
1089 unsigned int dstapic
;
1093 /* Locate the gsi that irq i maps to. */
1094 if (acpi_isa_irq_to_gsi(i
, &gsi
))
1098 * Locate the IOAPIC that manages the ISA IRQ.
1100 ioapic
= mp_find_ioapic(gsi
);
1103 pin
= mp_find_ioapic_pin(ioapic
, gsi
);
1104 dstapic
= mpc_ioapic_id(ioapic
);
1106 for (idx
= 0; idx
< mp_irq_entries
; idx
++) {
1107 struct mpc_intsrc
*irq
= mp_irqs
+ idx
;
1109 /* Do we already have a mapping for this ISA IRQ? */
1110 if (irq
->srcbus
== MP_ISA_BUS
&& irq
->srcbusirq
== i
)
1113 /* Do we already have a mapping for this IOAPIC pin */
1114 if (irq
->dstapic
== dstapic
&& irq
->dstirq
== pin
)
1118 if (idx
!= mp_irq_entries
) {
1119 pr_debug("ACPI: IRQ%d used by override.\n", i
);
1120 continue; /* IRQ already used */
1123 mp_irq
.type
= MP_INTSRC
;
1124 mp_irq
.irqflag
= 0; /* Conforming */
1125 mp_irq
.srcbus
= MP_ISA_BUS
;
1126 mp_irq
.dstapic
= dstapic
;
1127 mp_irq
.irqtype
= mp_INT
;
1128 mp_irq
.srcbusirq
= i
; /* Identity mapped */
1129 mp_irq
.dstirq
= pin
;
1131 mp_save_irq(&mp_irq
);
1136 * Parse IOAPIC related entries in MADT
1137 * returns 0 on success, < 0 on error
1139 static int __init
acpi_parse_madt_ioapic_entries(void)
1144 * ACPI interpreter is required to complete interrupt setup,
1145 * so if it is off, don't enumerate the io-apics with ACPI.
1146 * If MPS is present, it will handle them,
1147 * otherwise the system will stay in PIC mode
1149 if (acpi_disabled
|| acpi_noirq
)
1152 if (!boot_cpu_has(X86_FEATURE_APIC
))
1156 * if "noapic" boot option, don't look for IO-APICs
1158 if (ioapic_is_disabled
) {
1159 pr_info("Skipping IOAPIC probe due to 'noapic' option.\n");
1163 count
= acpi_table_parse_madt(ACPI_MADT_TYPE_IO_APIC
, acpi_parse_ioapic
,
1166 pr_err("No IOAPIC entries present\n");
1168 } else if (count
< 0) {
1169 pr_err("Error parsing IOAPIC entry\n");
1173 count
= acpi_table_parse_madt(ACPI_MADT_TYPE_INTERRUPT_OVERRIDE
,
1174 acpi_parse_int_src_ovr
, nr_irqs
);
1176 pr_err("Error parsing interrupt source overrides entry\n");
1177 /* TBD: Cleanup to allow fallback to MPS */
1182 * If BIOS did not supply an INT_SRC_OVR for the SCI
1183 * pretend we got one so we can set the SCI flags.
1184 * But ignore setting up SCI on hardware reduced platforms.
1186 if (acpi_sci_override_gsi
== INVALID_ACPI_IRQ
&& !acpi_gbl_reduced_hardware
)
1187 acpi_sci_ioapic_setup(acpi_gbl_FADT
.sci_interrupt
, 0, 0,
1188 acpi_gbl_FADT
.sci_interrupt
);
1190 /* Fill in identity legacy mappings where no override */
1191 mp_config_acpi_legacy_irqs();
1193 count
= acpi_table_parse_madt(ACPI_MADT_TYPE_NMI_SOURCE
,
1194 acpi_parse_nmi_src
, nr_irqs
);
1196 pr_err("Error parsing NMI SRC entry\n");
1197 /* TBD: Cleanup to allow fallback to MPS */
1204 static inline int acpi_parse_madt_ioapic_entries(void)
1208 #endif /* !CONFIG_X86_IO_APIC */
1210 static void __init
early_acpi_process_madt(void)
1212 #ifdef CONFIG_X86_LOCAL_APIC
1215 if (!acpi_table_parse(ACPI_SIG_MADT
, acpi_parse_madt
)) {
1218 * Parse MADT LAPIC entries
1220 error
= early_acpi_parse_madt_lapic_addr_ovr();
1223 smp_found_config
= 1;
1225 if (error
== -EINVAL
) {
1227 * Dell Precision Workstation 410, 610 come here.
1229 pr_err("Invalid BIOS MADT, disabling ACPI\n");
1236 static void __init
acpi_process_madt(void)
1238 #ifdef CONFIG_X86_LOCAL_APIC
1241 if (!acpi_table_parse(ACPI_SIG_MADT
, acpi_parse_madt
)) {
1244 * Parse MADT LAPIC entries
1246 error
= acpi_parse_madt_lapic_entries();
1251 * Parse MADT IO-APIC entries
1253 mutex_lock(&acpi_ioapic_lock
);
1254 error
= acpi_parse_madt_ioapic_entries();
1255 mutex_unlock(&acpi_ioapic_lock
);
1257 acpi_set_irq_model_ioapic();
1259 smp_found_config
= 1;
1262 #ifdef CONFIG_ACPI_MADT_WAKEUP
1264 * Parse MADT MP Wake entry.
1266 acpi_table_parse_madt(ACPI_MADT_TYPE_MULTIPROC_WAKEUP
,
1267 acpi_parse_mp_wake
, 1);
1270 if (error
== -EINVAL
) {
1272 * Dell Precision Workstation 410, 610 come here.
1274 pr_err("Invalid BIOS MADT, disabling ACPI\n");
1279 * ACPI found no MADT, and so ACPI wants UP PIC mode.
1280 * In the event an MPS table was found, forget it.
1281 * Boot with "acpi=off" to use MPS on such a system.
1283 if (smp_found_config
) {
1284 pr_warn("No APIC-table, disabling MPS\n");
1285 smp_found_config
= 0;
1290 * ACPI supports both logical (e.g. Hyper-Threading) and physical
1291 * processors, where MPS only supports physical.
1293 if (acpi_lapic
&& acpi_ioapic
)
1294 pr_info("Using ACPI (MADT) for SMP configuration information\n");
1295 else if (acpi_lapic
)
1296 pr_info("Using ACPI for processor (LAPIC) configuration information\n");
1301 static int __init
disable_acpi_irq(const struct dmi_system_id
*d
)
1304 pr_notice("%s detected: force use of acpi=noirq\n", d
->ident
);
1310 static int __init
disable_acpi_pci(const struct dmi_system_id
*d
)
1313 pr_notice("%s detected: force use of pci=noacpi\n", d
->ident
);
1319 static int __init
disable_acpi_xsdt(const struct dmi_system_id
*d
)
1322 pr_notice("%s detected: force use of acpi=rsdt\n", d
->ident
);
1323 acpi_gbl_do_not_use_xsdt
= TRUE
;
1325 pr_notice("Warning: DMI blacklist says broken, but acpi XSDT forced\n");
1330 static int __init
dmi_disable_acpi(const struct dmi_system_id
*d
)
1333 pr_notice("%s detected: acpi off\n", d
->ident
);
1336 pr_notice("Warning: DMI blacklist says broken, but acpi forced\n");
1342 * Force ignoring BIOS IRQ0 override
1344 static int __init
dmi_ignore_irq0_timer_override(const struct dmi_system_id
*d
)
1346 if (!acpi_skip_timer_override
) {
1347 pr_notice("%s detected: Ignoring BIOS IRQ0 override\n",
1349 acpi_skip_timer_override
= 1;
1355 * ACPI offers an alternative platform interface model that removes
1356 * ACPI hardware requirements for platforms that do not implement
1357 * the PC Architecture.
1359 * We initialize the Hardware-reduced ACPI model here:
1361 void __init
acpi_generic_reduced_hw_init(void)
1364 * Override x86_init functions and bypass legacy PIC in
1365 * hardware reduced ACPI mode.
1367 x86_init
.timers
.timer_init
= x86_init_noop
;
1368 x86_init
.irqs
.pre_vector_init
= x86_init_noop
;
1369 legacy_pic
= &null_legacy_pic
;
1372 static void __init
acpi_reduced_hw_init(void)
1374 if (acpi_gbl_reduced_hardware
)
1375 x86_init
.acpi
.reduced_hw_early_init();
1379 * If your system is blacklisted here, but you find that acpi=force
1380 * works for you, please contact linux-acpi@vger.kernel.org
1382 static const struct dmi_system_id acpi_dmi_table
[] __initconst
= {
1384 * Boxes that need ACPI disabled
1387 .callback
= dmi_disable_acpi
,
1388 .ident
= "IBM Thinkpad",
1390 DMI_MATCH(DMI_BOARD_VENDOR
, "IBM"),
1391 DMI_MATCH(DMI_BOARD_NAME
, "2629H1G"),
1396 * Boxes that need ACPI PCI IRQ routing disabled
1399 .callback
= disable_acpi_irq
,
1400 .ident
= "ASUS A7V",
1402 DMI_MATCH(DMI_BOARD_VENDOR
, "ASUSTeK Computer INC"),
1403 DMI_MATCH(DMI_BOARD_NAME
, "<A7V>"),
1404 /* newer BIOS, Revision 1011, does work */
1405 DMI_MATCH(DMI_BIOS_VERSION
,
1406 "ASUS A7V ACPI BIOS Revision 1007"),
1411 * Latest BIOS for IBM 600E (1.16) has bad pcinum
1412 * for LPC bridge, which is needed for the PCI
1413 * interrupt links to work. DSDT fix is in bug 5966.
1414 * 2645, 2646 model numbers are shared with 600/600E/600X
1416 .callback
= disable_acpi_irq
,
1417 .ident
= "IBM Thinkpad 600 Series 2645",
1419 DMI_MATCH(DMI_BOARD_VENDOR
, "IBM"),
1420 DMI_MATCH(DMI_BOARD_NAME
, "2645"),
1424 .callback
= disable_acpi_irq
,
1425 .ident
= "IBM Thinkpad 600 Series 2646",
1427 DMI_MATCH(DMI_BOARD_VENDOR
, "IBM"),
1428 DMI_MATCH(DMI_BOARD_NAME
, "2646"),
1432 * Boxes that need ACPI PCI IRQ routing and PCI scan disabled
1435 .callback
= disable_acpi_pci
,
1436 .ident
= "ASUS PR-DLS",
1438 DMI_MATCH(DMI_BOARD_VENDOR
, "ASUSTeK Computer INC."),
1439 DMI_MATCH(DMI_BOARD_NAME
, "PR-DLS"),
1440 DMI_MATCH(DMI_BIOS_VERSION
,
1441 "ASUS PR-DLS ACPI BIOS Revision 1010"),
1442 DMI_MATCH(DMI_BIOS_DATE
, "03/21/2003")
1446 .callback
= disable_acpi_pci
,
1447 .ident
= "Acer TravelMate 36x Laptop",
1449 DMI_MATCH(DMI_SYS_VENDOR
, "Acer"),
1450 DMI_MATCH(DMI_PRODUCT_NAME
, "TravelMate 360"),
1454 * Boxes that need ACPI XSDT use disabled due to corrupted tables
1457 .callback
= disable_acpi_xsdt
,
1458 .ident
= "Advantech DAC-BJ01",
1460 DMI_MATCH(DMI_SYS_VENDOR
, "NEC"),
1461 DMI_MATCH(DMI_PRODUCT_NAME
, "Bearlake CRB Board"),
1462 DMI_MATCH(DMI_BIOS_VERSION
, "V1.12"),
1463 DMI_MATCH(DMI_BIOS_DATE
, "02/01/2011"),
1469 /* second table for DMI checks that should run after early-quirks */
1470 static const struct dmi_system_id acpi_dmi_table_late
[] __initconst
= {
1472 * HP laptops which use a DSDT reporting as HP/SB400/10000,
1473 * which includes some code which overrides all temperature
1474 * trip points to 16C if the INTIN2 input of the I/O APIC
1475 * is enabled. This input is incorrectly designated the
1476 * ISA IRQ 0 via an interrupt source override even though
1477 * it is wired to the output of the master 8259A and INTIN0
1478 * is not connected at all. Force ignoring BIOS IRQ0
1479 * override in that cases.
1482 .callback
= dmi_ignore_irq0_timer_override
,
1483 .ident
= "HP nx6115 laptop",
1485 DMI_MATCH(DMI_SYS_VENDOR
, "Hewlett-Packard"),
1486 DMI_MATCH(DMI_PRODUCT_NAME
, "HP Compaq nx6115"),
1490 .callback
= dmi_ignore_irq0_timer_override
,
1491 .ident
= "HP NX6125 laptop",
1493 DMI_MATCH(DMI_SYS_VENDOR
, "Hewlett-Packard"),
1494 DMI_MATCH(DMI_PRODUCT_NAME
, "HP Compaq nx6125"),
1498 .callback
= dmi_ignore_irq0_timer_override
,
1499 .ident
= "HP NX6325 laptop",
1501 DMI_MATCH(DMI_SYS_VENDOR
, "Hewlett-Packard"),
1502 DMI_MATCH(DMI_PRODUCT_NAME
, "HP Compaq nx6325"),
1506 .callback
= dmi_ignore_irq0_timer_override
,
1507 .ident
= "HP 6715b laptop",
1509 DMI_MATCH(DMI_SYS_VENDOR
, "Hewlett-Packard"),
1510 DMI_MATCH(DMI_PRODUCT_NAME
, "HP Compaq 6715b"),
1514 .callback
= dmi_ignore_irq0_timer_override
,
1515 .ident
= "FUJITSU SIEMENS",
1517 DMI_MATCH(DMI_SYS_VENDOR
, "FUJITSU SIEMENS"),
1518 DMI_MATCH(DMI_PRODUCT_NAME
, "AMILO PRO V2030"),
1525 * acpi_boot_table_init() and acpi_boot_init()
1526 * called from setup_arch(), always.
1527 * 1. checksums all tables
1528 * 2. enumerates lapics
1529 * 3. enumerates io-apics
1531 * acpi_table_init() is separate to allow reading SRAT without
1532 * other side effects.
1534 * side effects of acpi_boot_init:
1535 * acpi_lapic = 1 if LAPIC found
1536 * acpi_ioapic = 1 if IOAPIC found
1537 * if (acpi_lapic && acpi_ioapic) smp_found_config = 1;
1538 * if acpi_blacklisted() acpi_disabled = 1;
1539 * acpi_irq_model=...
1543 void __init
acpi_boot_table_init(void)
1545 dmi_check_system(acpi_dmi_table
);
1548 * If acpi_disabled, bail out
1554 * Initialize the ACPI boot-time table parser.
1556 if (acpi_locate_initial_tables())
1559 acpi_reserve_initial_tables();
1562 int __init
early_acpi_boot_init(void)
1567 acpi_table_init_complete();
1569 acpi_table_parse(ACPI_SIG_BOOT
, acpi_parse_sbf
);
1572 * blacklist may disable ACPI entirely
1574 if (acpi_blacklisted()) {
1576 pr_warn("acpi=force override\n");
1578 pr_warn("Disabling ACPI support\n");
1585 * Process the Multiple APIC Description Table (MADT), if present
1587 early_acpi_process_madt();
1590 * Hardware-reduced ACPI mode initialization:
1592 acpi_reduced_hw_init();
1597 int __init
acpi_boot_init(void)
1599 /* those are executed after early-quirks are executed */
1600 dmi_check_system(acpi_dmi_table_late
);
1603 * If acpi_disabled, bail out
1608 acpi_table_parse(ACPI_SIG_BOOT
, acpi_parse_sbf
);
1611 * set sci_int and PM timer address
1613 acpi_table_parse(ACPI_SIG_FADT
, acpi_parse_fadt
);
1616 * Process the Multiple APIC Description Table (MADT), if present
1618 acpi_process_madt();
1620 acpi_table_parse(ACPI_SIG_HPET
, acpi_parse_hpet
);
1621 if (IS_ENABLED(CONFIG_ACPI_BGRT
) && !acpi_nobgrt
)
1622 acpi_table_parse(ACPI_SIG_BGRT
, acpi_parse_bgrt
);
1625 x86_init
.pci
.init
= pci_acpi_init
;
1627 /* Do not enable ACPI SPCR console by default */
1628 acpi_parse_spcr(earlycon_acpi_spcr_enable
, false);
1632 static int __init
parse_acpi(char *arg
)
1637 /* "acpi=off" disables both ACPI table parsing and interpreter */
1638 if (strcmp(arg
, "off") == 0) {
1641 /* acpi=force to over-ride black-list */
1642 else if (strcmp(arg
, "force") == 0) {
1646 /* acpi=strict disables out-of-spec workarounds */
1647 else if (strcmp(arg
, "strict") == 0) {
1650 /* acpi=rsdt use RSDT instead of XSDT */
1651 else if (strcmp(arg
, "rsdt") == 0) {
1652 acpi_gbl_do_not_use_xsdt
= TRUE
;
1654 /* "acpi=noirq" disables ACPI interrupt routing */
1655 else if (strcmp(arg
, "noirq") == 0) {
1658 /* "acpi=copy_dsdt" copies DSDT */
1659 else if (strcmp(arg
, "copy_dsdt") == 0) {
1660 acpi_gbl_copy_dsdt_locally
= 1;
1662 /* "acpi=nocmcff" disables FF mode for corrected errors */
1663 else if (strcmp(arg
, "nocmcff") == 0) {
1664 acpi_disable_cmcff
= 1;
1666 /* Core will printk when we return error. */
1671 early_param("acpi", parse_acpi
);
1673 static int __init
parse_acpi_bgrt(char *arg
)
1678 early_param("bgrt_disable", parse_acpi_bgrt
);
1680 /* FIXME: Using pci= for an ACPI parameter is a travesty. */
1681 static int __init
parse_pci(char *arg
)
1683 if (arg
&& strcmp(arg
, "noacpi") == 0)
1687 early_param("pci", parse_pci
);
1689 int __init
acpi_mps_check(void)
1691 #if defined(CONFIG_X86_LOCAL_APIC) && !defined(CONFIG_X86_MPPARSE)
1692 /* mptable code is not built-in*/
1693 if (acpi_disabled
|| acpi_noirq
) {
1694 pr_warn("MPS support code is not built-in, using acpi=off or acpi=noirq or pci=noacpi may have problem\n");
1701 #ifdef CONFIG_X86_IO_APIC
1702 static int __init
parse_acpi_skip_timer_override(char *arg
)
1704 acpi_skip_timer_override
= 1;
1707 early_param("acpi_skip_timer_override", parse_acpi_skip_timer_override
);
1709 static int __init
parse_acpi_use_timer_override(char *arg
)
1711 acpi_use_timer_override
= 1;
1714 early_param("acpi_use_timer_override", parse_acpi_use_timer_override
);
1715 #endif /* CONFIG_X86_IO_APIC */
1717 static int __init
setup_acpi_sci(char *s
)
1721 if (!strcmp(s
, "edge"))
1722 acpi_sci_flags
= ACPI_MADT_TRIGGER_EDGE
|
1723 (acpi_sci_flags
& ~ACPI_MADT_TRIGGER_MASK
);
1724 else if (!strcmp(s
, "level"))
1725 acpi_sci_flags
= ACPI_MADT_TRIGGER_LEVEL
|
1726 (acpi_sci_flags
& ~ACPI_MADT_TRIGGER_MASK
);
1727 else if (!strcmp(s
, "high"))
1728 acpi_sci_flags
= ACPI_MADT_POLARITY_ACTIVE_HIGH
|
1729 (acpi_sci_flags
& ~ACPI_MADT_POLARITY_MASK
);
1730 else if (!strcmp(s
, "low"))
1731 acpi_sci_flags
= ACPI_MADT_POLARITY_ACTIVE_LOW
|
1732 (acpi_sci_flags
& ~ACPI_MADT_POLARITY_MASK
);
1737 early_param("acpi_sci", setup_acpi_sci
);
1739 int __acpi_acquire_global_lock(unsigned int *lock
)
1741 unsigned int old
, new, val
;
1743 old
= READ_ONCE(*lock
);
1745 val
= (old
>> 1) & 0x1;
1746 new = (old
& ~0x3) + 2 + val
;
1747 } while (!try_cmpxchg(lock
, &old
, new));
1755 int __acpi_release_global_lock(unsigned int *lock
)
1757 unsigned int old
, new;
1759 old
= READ_ONCE(*lock
);
1762 } while (!try_cmpxchg(lock
, &old
, new));
1766 void __init
arch_reserve_mem_area(acpi_physical_address addr
, size_t size
)
1768 e820__range_add(addr
, size
, E820_TYPE_NVS
);
1769 e820__update_table_print();
1772 void x86_default_set_root_pointer(u64 addr
)
1774 boot_params
.acpi_rsdp_addr
= addr
;
1777 u64
x86_default_get_root_pointer(void)
1779 return boot_params
.acpi_rsdp_addr
;
1782 #ifdef CONFIG_XEN_PV
1783 void __iomem
*x86_acpi_os_ioremap(acpi_physical_address phys
, acpi_size size
)
1785 return ioremap_cache(phys
, size
);
1788 void __iomem
* (*acpi_os_ioremap
)(acpi_physical_address phys
, acpi_size size
) =
1789 x86_acpi_os_ioremap
;
1790 EXPORT_SYMBOL_GPL(acpi_os_ioremap
);