blob: f6dbb2f5e39f6da4adec8a560c4461c30b26f12d [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * boot.c - Architecture-Specific Low-Level ACPI Boot Support
3 *
4 * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
5 * Copyright (C) 2001 Jun Nakajima <jun.nakajima@intel.com>
6 *
7 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8 *
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.
13 *
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.
18 *
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
22 *
23 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
24 */
25
26#include <linux/init.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070027#include <linux/acpi.h>
Thomas Gleixnerd66bea52007-02-16 01:27:57 -080028#include <linux/acpi_pmtmr.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070029#include <linux/efi.h>
Ashok Raj73fea172006-09-26 10:52:35 +020030#include <linux/cpumask.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070031#include <linux/module.h>
Andrey Paninaea00142005-06-25 14:54:42 -070032#include <linux/dmi.h>
Nick Pigginb33fa1f2005-10-01 02:34:42 +100033#include <linux/irq.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090034#include <linux/slab.h>
adurbin@google.comf0f4c342006-09-26 10:52:39 +020035#include <linux/bootmem.h>
36#include <linux/ioport.h>
Yinghai Lua31f8202009-05-06 10:06:15 -070037#include <linux/pci.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070038
Thomas Gleixnerb72d0db2009-08-29 16:24:51 +020039#include <asm/pci_x86.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070040#include <asm/pgtable.h>
41#include <asm/io_apic.h>
42#include <asm/apic.h>
43#include <asm/io.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070044#include <asm/mpspec.h>
Alexey Starikovskiydfac2182008-04-04 23:41:50 +040045#include <asm/smp.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070046
Konrad Rzeszutek Wilkd6a77ea2013-05-14 17:09:16 +000047#include "sleep.h" /* To include x86_acpi_suspend_lowlevel */
Adrian Bunke8924ac2006-09-26 10:52:35 +020048static int __initdata acpi_force = 0;
Zhao Yakui237889b2008-12-17 16:55:18 +080049u32 acpi_rsdt_forced;
Len Brownc636f752009-05-19 23:47:38 -040050int acpi_disabled;
Andi Kleendf3bb572006-09-26 10:52:33 +020051EXPORT_SYMBOL(acpi_disabled);
52
Linus Torvalds1da177e2005-04-16 15:20:36 -070053#ifdef CONFIG_X86_64
Ingo Molnar1dcdd3d2009-01-28 17:55:37 +010054# include <asm/proto.h>
Len Brown4be44fc2005-08-05 00:44:28 -040055#endif /* X86 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070056
57#define BAD_MADT_ENTRY(entry, end) ( \
58 (!entry) || (unsigned long)entry + sizeof(*entry) > end || \
Alexey Starikovskiy5f3b1a82007-02-02 19:48:22 +030059 ((struct acpi_subtable_header *)entry)->length < sizeof(*entry))
Linus Torvalds1da177e2005-04-16 15:20:36 -070060
61#define PREFIX "ACPI: "
62
Andrew Morton90d53902006-11-02 22:07:18 -080063int acpi_noirq; /* skip ACPI IRQ initialization */
Yinghai Lu6e4be1ff2008-02-05 00:01:48 -080064int acpi_pci_disabled; /* skip ACPI PCI scan and IRQ initialization */
65EXPORT_SYMBOL(acpi_pci_disabled);
Linus Torvalds1da177e2005-04-16 15:20:36 -070066
67int acpi_lapic;
68int acpi_ioapic;
69int acpi_strict;
Naveen N. Rao9ad95872013-07-01 21:08:54 +053070int acpi_disable_cmcff;
Linus Torvalds1da177e2005-04-16 15:20:36 -070071
Alexey Starikovskiy5f3b1a82007-02-02 19:48:22 +030072u8 acpi_sci_flags __initdata;
Linus Torvalds1da177e2005-04-16 15:20:36 -070073int acpi_sci_override_gsi __initdata;
74int acpi_skip_timer_override __initdata;
Andi Kleenfa18f472006-11-14 16:57:46 +010075int acpi_use_timer_override __initdata;
Andreas Herrmann7f74f8f2011-02-24 15:53:46 +010076int acpi_fix_pin2_polarity __initdata;
Linus Torvalds1da177e2005-04-16 15:20:36 -070077
78#ifdef CONFIG_X86_LOCAL_APIC
79static u64 acpi_lapic_addr __initdata = APIC_DEFAULT_PHYS_BASE;
80#endif
81
82#ifndef __HAVE_ARCH_CMPXCHG
83#warning ACPI uses CMPXCHG, i486 and later hardware
84#endif
85
Linus Torvalds1da177e2005-04-16 15:20:36 -070086/* --------------------------------------------------------------------------
87 Boot-time Configuration
88 -------------------------------------------------------------------------- */
89
90/*
91 * The default interrupt routing model is PIC (8259). This gets
Simon Arlott27b46d72007-10-20 01:13:56 +020092 * overridden if IOAPICs are enumerated (below).
Linus Torvalds1da177e2005-04-16 15:20:36 -070093 */
Len Brown4be44fc2005-08-05 00:44:28 -040094enum acpi_irq_model_id acpi_irq_model = ACPI_IRQ_MODEL_PIC;
Linus Torvalds1da177e2005-04-16 15:20:36 -070095
Linus Torvalds1da177e2005-04-16 15:20:36 -070096
97/*
Eric W. Biederman988856e2010-03-30 01:07:15 -070098 * ISA irqs by default are the first 16 gsis but can be
99 * any gsi as specified by an interrupt source override.
100 */
101static u32 isa_irq_to_gsi[NR_IRQS_LEGACY] __read_mostly = {
102 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
103};
104
105static unsigned int gsi_to_irq(unsigned int gsi)
106{
107 unsigned int irq = gsi + NR_IRQS_LEGACY;
108 unsigned int i;
109
110 for (i = 0; i < NR_IRQS_LEGACY; i++) {
111 if (isa_irq_to_gsi[i] == gsi) {
112 return i;
113 }
114 }
115
116 /* Provide an identity mapping of gsi == irq
117 * except on truly weird platforms that have
118 * non isa irqs in the first 16 gsis.
119 */
120 if (gsi >= NR_IRQS_LEGACY)
121 irq = gsi;
122 else
Eric W. Biedermana4384df2010-06-08 11:44:32 -0700123 irq = gsi_top + gsi;
Eric W. Biederman988856e2010-03-30 01:07:15 -0700124
125 return irq;
126}
127
128static u32 irq_to_gsi(int irq)
129{
130 unsigned int gsi;
131
132 if (irq < NR_IRQS_LEGACY)
133 gsi = isa_irq_to_gsi[irq];
Eric W. Biedermana4384df2010-06-08 11:44:32 -0700134 else if (irq < gsi_top)
Eric W. Biederman988856e2010-03-30 01:07:15 -0700135 gsi = irq;
Eric W. Biedermana4384df2010-06-08 11:44:32 -0700136 else if (irq < (gsi_top + NR_IRQS_LEGACY))
137 gsi = irq - gsi_top;
Eric W. Biederman988856e2010-03-30 01:07:15 -0700138 else
139 gsi = 0xffffffff;
140
141 return gsi;
142}
143
144/*
Zhang Yanfei45f13302013-07-23 21:03:24 +0800145 * This is just a simple wrapper around early_ioremap(),
146 * with sanity checks for phys == 0 and size == 0.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147 */
Jan Beulich2fdf0742007-12-13 08:33:59 +0000148char *__init __acpi_map_table(unsigned long phys, unsigned long size)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150
Yinghai Luf34fa822008-07-09 20:16:36 -0700151 if (!phys || !size)
152 return NULL;
153
Yinghai Lu7d972772009-02-07 15:39:41 -0800154 return early_ioremap(phys, size);
155}
Zhang Yanfei45f13302013-07-23 21:03:24 +0800156
Yinghai Lu7d972772009-02-07 15:39:41 -0800157void __init __acpi_unmap_table(char *map, unsigned long size)
158{
159 if (!map || !size)
160 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161
Yinghai Lu7d972772009-02-07 15:39:41 -0800162 early_iounmap(map, size);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165#ifdef CONFIG_X86_LOCAL_APIC
Alexey Starikovskiy15a58ed2007-02-02 19:48:22 +0300166static int __init acpi_parse_madt(struct acpi_table_header *table)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700167{
Len Brown4be44fc2005-08-05 00:44:28 -0400168 struct acpi_table_madt *madt = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700169
Alexey Starikovskiy15a58ed2007-02-02 19:48:22 +0300170 if (!cpu_has_apic)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700171 return -EINVAL;
172
Alexey Starikovskiy15a58ed2007-02-02 19:48:22 +0300173 madt = (struct acpi_table_madt *)table;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174 if (!madt) {
175 printk(KERN_WARNING PREFIX "Unable to map MADT\n");
176 return -ENODEV;
177 }
178
Alexey Starikovskiyad363f82007-02-02 19:48:22 +0300179 if (madt->address) {
180 acpi_lapic_addr = (u64) madt->address;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700181
182 printk(KERN_DEBUG PREFIX "Local APIC address 0x%08x\n",
Alexey Starikovskiyad363f82007-02-02 19:48:22 +0300183 madt->address);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700184 }
185
Ingo Molnar306db032009-01-28 03:43:47 +0100186 default_acpi_madt_oem_check(madt->header.oem_id,
187 madt->header.oem_table_id);
Len Brown4be44fc2005-08-05 00:44:28 -0400188
Linus Torvalds1da177e2005-04-16 15:20:36 -0700189 return 0;
190}
191
Paul Gortmaker148f9bb2013-06-18 18:23:59 -0400192static void acpi_register_lapic(int id, u8 enabled)
Alexey Starikovskiydfac2182008-04-04 23:41:50 +0400193{
Yinghai Lufb3bbd62008-05-22 18:22:30 -0700194 unsigned int ver = 0;
195
Tang Chen82982d72013-07-23 16:00:19 +0800196 if (id >= MAX_LOCAL_APIC) {
Yinghai Lud3bd0582010-12-16 19:09:58 -0800197 printk(KERN_INFO PREFIX "skipped apicid that is too big\n");
198 return;
199 }
200
Alexey Starikovskiydfac2182008-04-04 23:41:50 +0400201 if (!enabled) {
202 ++disabled_cpus;
203 return;
204 }
205
Yinghai Lufb3bbd62008-05-22 18:22:30 -0700206 if (boot_cpu_physical_apicid != -1U)
207 ver = apic_version[boot_cpu_physical_apicid];
Yinghai Lufb3bbd62008-05-22 18:22:30 -0700208
209 generic_processor_info(id, ver);
Alexey Starikovskiydfac2182008-04-04 23:41:50 +0400210}
211
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212static int __init
Suresh Siddha7237d3d2009-03-30 13:55:30 -0800213acpi_parse_x2apic(struct acpi_subtable_header *header, const unsigned long end)
214{
215 struct acpi_madt_local_x2apic *processor = NULL;
Yinghai Lua35fd282011-12-21 17:45:16 -0800216 int apic_id;
217 u8 enabled;
Suresh Siddha7237d3d2009-03-30 13:55:30 -0800218
219 processor = (struct acpi_madt_local_x2apic *)header;
220
221 if (BAD_MADT_ENTRY(processor, end))
222 return -EINVAL;
223
224 acpi_table_print_madt_entry(header);
225
Yinghai Lua35fd282011-12-21 17:45:16 -0800226 apic_id = processor->local_apic_id;
227 enabled = processor->lapic_flags & ACPI_MADT_ENABLED;
Suresh Siddha7237d3d2009-03-30 13:55:30 -0800228#ifdef CONFIG_X86_X2APIC
229 /*
230 * We need to register disabled CPU as well to permit
231 * counting disabled CPUs. This allows us to size
232 * cpus_possible_map more accurately, to permit
233 * to not preallocating memory for all NR_CPUS
234 * when we use CPU hotplug.
235 */
Steffen Persvoldb7157ac2012-03-16 20:25:35 +0100236 if (!apic->apic_id_valid(apic_id) && enabled)
Yinghai Lua35fd282011-12-21 17:45:16 -0800237 printk(KERN_WARNING PREFIX "x2apic entry ignored\n");
238 else
239 acpi_register_lapic(apic_id, enabled);
Suresh Siddha7237d3d2009-03-30 13:55:30 -0800240#else
241 printk(KERN_WARNING PREFIX "x2apic entry ignored\n");
242#endif
243
244 return 0;
245}
246
247static int __init
Alexey Starikovskiy5f3b1a82007-02-02 19:48:22 +0300248acpi_parse_lapic(struct acpi_subtable_header * header, const unsigned long end)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249{
Alexey Starikovskiy5f3b1a82007-02-02 19:48:22 +0300250 struct acpi_madt_local_apic *processor = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251
Alexey Starikovskiy5f3b1a82007-02-02 19:48:22 +0300252 processor = (struct acpi_madt_local_apic *)header;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700253
254 if (BAD_MADT_ENTRY(processor, end))
255 return -EINVAL;
256
257 acpi_table_print_madt_entry(header);
258
Ashok Raj7f66ae42006-02-03 21:51:50 +0100259 /*
260 * We need to register disabled CPU as well to permit
261 * counting disabled CPUs. This allows us to size
262 * cpus_possible_map more accurately, to permit
263 * to not preallocating memory for all NR_CPUS
264 * when we use CPU hotplug.
265 */
Alexey Starikovskiydfac2182008-04-04 23:41:50 +0400266 acpi_register_lapic(processor->id, /* APIC ID */
267 processor->lapic_flags & ACPI_MADT_ENABLED);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700268
269 return 0;
270}
271
272static int __init
Jack Steinerac049c12008-03-28 14:12:09 -0500273acpi_parse_sapic(struct acpi_subtable_header *header, const unsigned long end)
274{
275 struct acpi_madt_local_sapic *processor = NULL;
276
277 processor = (struct acpi_madt_local_sapic *)header;
278
279 if (BAD_MADT_ENTRY(processor, end))
280 return -EINVAL;
281
282 acpi_table_print_madt_entry(header);
283
Alexey Starikovskiydfac2182008-04-04 23:41:50 +0400284 acpi_register_lapic((processor->id << 8) | processor->eid,/* APIC ID */
285 processor->lapic_flags & ACPI_MADT_ENABLED);
Jack Steinerac049c12008-03-28 14:12:09 -0500286
287 return 0;
288}
289
290static int __init
Alexey Starikovskiy5f3b1a82007-02-02 19:48:22 +0300291acpi_parse_lapic_addr_ovr(struct acpi_subtable_header * header,
Len Brown4be44fc2005-08-05 00:44:28 -0400292 const unsigned long end)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700293{
Alexey Starikovskiy5f3b1a82007-02-02 19:48:22 +0300294 struct acpi_madt_local_apic_override *lapic_addr_ovr = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700295
Alexey Starikovskiy5f3b1a82007-02-02 19:48:22 +0300296 lapic_addr_ovr = (struct acpi_madt_local_apic_override *)header;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700297
298 if (BAD_MADT_ENTRY(lapic_addr_ovr, end))
299 return -EINVAL;
300
301 acpi_lapic_addr = lapic_addr_ovr->address;
302
303 return 0;
304}
305
306static int __init
Suresh Siddha7237d3d2009-03-30 13:55:30 -0800307acpi_parse_x2apic_nmi(struct acpi_subtable_header *header,
308 const unsigned long end)
309{
310 struct acpi_madt_local_x2apic_nmi *x2apic_nmi = NULL;
311
312 x2apic_nmi = (struct acpi_madt_local_x2apic_nmi *)header;
313
314 if (BAD_MADT_ENTRY(x2apic_nmi, end))
315 return -EINVAL;
316
317 acpi_table_print_madt_entry(header);
318
319 if (x2apic_nmi->lint != 1)
320 printk(KERN_WARNING PREFIX "NMI not connected to LINT 1!\n");
321
322 return 0;
323}
324
325static int __init
Alexey Starikovskiy5f3b1a82007-02-02 19:48:22 +0300326acpi_parse_lapic_nmi(struct acpi_subtable_header * header, const unsigned long end)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700327{
Alexey Starikovskiy5f3b1a82007-02-02 19:48:22 +0300328 struct acpi_madt_local_apic_nmi *lapic_nmi = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700329
Alexey Starikovskiy5f3b1a82007-02-02 19:48:22 +0300330 lapic_nmi = (struct acpi_madt_local_apic_nmi *)header;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700331
332 if (BAD_MADT_ENTRY(lapic_nmi, end))
333 return -EINVAL;
334
335 acpi_table_print_madt_entry(header);
336
337 if (lapic_nmi->lint != 1)
338 printk(KERN_WARNING PREFIX "NMI not connected to LINT 1!\n");
339
340 return 0;
341}
342
Len Brown4be44fc2005-08-05 00:44:28 -0400343#endif /*CONFIG_X86_LOCAL_APIC */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700344
Len Brown84663612005-08-24 12:09:07 -0400345#ifdef CONFIG_X86_IO_APIC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700346
347static int __init
Alexey Starikovskiy5f3b1a82007-02-02 19:48:22 +0300348acpi_parse_ioapic(struct acpi_subtable_header * header, const unsigned long end)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700349{
Alexey Starikovskiy5f3b1a82007-02-02 19:48:22 +0300350 struct acpi_madt_io_apic *ioapic = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700351
Alexey Starikovskiy5f3b1a82007-02-02 19:48:22 +0300352 ioapic = (struct acpi_madt_io_apic *)header;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700353
354 if (BAD_MADT_ENTRY(ioapic, end))
355 return -EINVAL;
Len Brown4be44fc2005-08-05 00:44:28 -0400356
Linus Torvalds1da177e2005-04-16 15:20:36 -0700357 acpi_table_print_madt_entry(header);
358
Len Brown4be44fc2005-08-05 00:44:28 -0400359 mp_register_ioapic(ioapic->id,
360 ioapic->address, ioapic->global_irq_base);
361
Linus Torvalds1da177e2005-04-16 15:20:36 -0700362 return 0;
363}
364
365/*
366 * Parse Interrupt Source Override for the ACPI SCI
367 */
Eric W. Biederman9d2062b2010-03-30 01:07:05 -0700368static void __init acpi_sci_ioapic_setup(u8 bus_irq, u16 polarity, u16 trigger, u32 gsi)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700369{
370 if (trigger == 0) /* compatible SCI trigger is level */
371 trigger = 3;
372
373 if (polarity == 0) /* compatible SCI polarity is low */
374 polarity = 3;
375
376 /* Command-line over-ride via acpi_sci= */
Alexey Starikovskiy5f3b1a82007-02-02 19:48:22 +0300377 if (acpi_sci_flags & ACPI_MADT_TRIGGER_MASK)
378 trigger = (acpi_sci_flags & ACPI_MADT_TRIGGER_MASK) >> 2;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700379
Alexey Starikovskiy5f3b1a82007-02-02 19:48:22 +0300380 if (acpi_sci_flags & ACPI_MADT_POLARITY_MASK)
381 polarity = acpi_sci_flags & ACPI_MADT_POLARITY_MASK;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700382
383 /*
Len Brown4be44fc2005-08-05 00:44:28 -0400384 * mp_config_acpi_legacy_irqs() already setup IRQs < 16
Linus Torvalds1da177e2005-04-16 15:20:36 -0700385 * If GSI is < 16, this will update its flags,
386 * else it will create a new mp_irqs[] entry.
387 */
Eric W. Biederman9d2062b2010-03-30 01:07:05 -0700388 mp_override_legacy_irq(bus_irq, polarity, trigger, gsi);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700389
390 /*
391 * stash over-ride to indicate we've been here
Alexey Starikovskiycee324b2007-02-02 19:48:22 +0300392 * and for later update of acpi_gbl_FADT
Linus Torvalds1da177e2005-04-16 15:20:36 -0700393 */
Len Brown7bdd21c2006-12-02 02:27:46 -0500394 acpi_sci_override_gsi = gsi;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700395 return;
396}
397
398static int __init
Alexey Starikovskiy5f3b1a82007-02-02 19:48:22 +0300399acpi_parse_int_src_ovr(struct acpi_subtable_header * header,
Len Brown4be44fc2005-08-05 00:44:28 -0400400 const unsigned long end)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700401{
Alexey Starikovskiy5f3b1a82007-02-02 19:48:22 +0300402 struct acpi_madt_interrupt_override *intsrc = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700403
Alexey Starikovskiy5f3b1a82007-02-02 19:48:22 +0300404 intsrc = (struct acpi_madt_interrupt_override *)header;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700405
406 if (BAD_MADT_ENTRY(intsrc, end))
407 return -EINVAL;
408
409 acpi_table_print_madt_entry(header);
410
Alexey Starikovskiy5f3b1a82007-02-02 19:48:22 +0300411 if (intsrc->source_irq == acpi_gbl_FADT.sci_interrupt) {
Eric W. Biederman9d2062b2010-03-30 01:07:05 -0700412 acpi_sci_ioapic_setup(intsrc->source_irq,
Alexey Starikovskiy5f3b1a82007-02-02 19:48:22 +0300413 intsrc->inti_flags & ACPI_MADT_POLARITY_MASK,
Eric W. Biederman9d2062b2010-03-30 01:07:05 -0700414 (intsrc->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2,
415 intsrc->global_irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700416 return 0;
417 }
418
Feng Tangae10ccd2012-06-04 15:00:04 +0800419 if (intsrc->source_irq == 0) {
Andreas Herrmann7f74f8f2011-02-24 15:53:46 +0100420 if (acpi_skip_timer_override) {
Feng Tangae10ccd2012-06-04 15:00:04 +0800421 printk(PREFIX "BIOS IRQ0 override ignored.\n");
Andreas Herrmann7f74f8f2011-02-24 15:53:46 +0100422 return 0;
423 }
Feng Tangae10ccd2012-06-04 15:00:04 +0800424
425 if ((intsrc->global_irq == 2) && acpi_fix_pin2_polarity
426 && (intsrc->inti_flags & ACPI_MADT_POLARITY_MASK)) {
Andreas Herrmann7f74f8f2011-02-24 15:53:46 +0100427 intsrc->inti_flags &= ~ACPI_MADT_POLARITY_MASK;
428 printk(PREFIX "BIOS IRQ0 pin2 override: forcing polarity to high active.\n");
429 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700430 }
431
Alexey Starikovskiy5f3b1a82007-02-02 19:48:22 +0300432 mp_override_legacy_irq(intsrc->source_irq,
433 intsrc->inti_flags & ACPI_MADT_POLARITY_MASK,
434 (intsrc->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2,
435 intsrc->global_irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700436
437 return 0;
438}
439
Linus Torvalds1da177e2005-04-16 15:20:36 -0700440static int __init
Alexey Starikovskiy5f3b1a82007-02-02 19:48:22 +0300441acpi_parse_nmi_src(struct acpi_subtable_header * header, const unsigned long end)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700442{
Alexey Starikovskiy5f3b1a82007-02-02 19:48:22 +0300443 struct acpi_madt_nmi_source *nmi_src = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700444
Alexey Starikovskiy5f3b1a82007-02-02 19:48:22 +0300445 nmi_src = (struct acpi_madt_nmi_source *)header;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700446
447 if (BAD_MADT_ENTRY(nmi_src, end))
448 return -EINVAL;
449
450 acpi_table_print_madt_entry(header);
451
452 /* TBD: Support nimsrc entries? */
453
454 return 0;
455}
456
Len Brown4be44fc2005-08-05 00:44:28 -0400457#endif /* CONFIG_X86_IO_APIC */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700458
Linus Torvalds1da177e2005-04-16 15:20:36 -0700459/*
460 * acpi_pic_sci_set_trigger()
Alexey Starikovskiy5f3b1a82007-02-02 19:48:22 +0300461 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700462 * use ELCR to set PIC-mode trigger type for SCI
463 *
464 * If a PIC-mode SCI is not recognized or gives spurious IRQ7's
465 * it may require Edge Trigger -- use "acpi_sci=edge"
466 *
467 * Port 0x4d0-4d1 are ECLR1 and ECLR2, the Edge/Level Control Registers
468 * for the 8259 PIC. bit[n] = 1 means irq[n] is Level, otherwise Edge.
Simon Arlott27b46d72007-10-20 01:13:56 +0200469 * ECLR1 is IRQs 0-7 (IRQ 0, 1, 2 must be 0)
470 * ECLR2 is IRQs 8-15 (IRQ 8, 13 must be 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700471 */
472
Len Brown4be44fc2005-08-05 00:44:28 -0400473void __init acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700474{
475 unsigned int mask = 1 << irq;
476 unsigned int old, new;
477
478 /* Real old ELCR mask */
479 old = inb(0x4d0) | (inb(0x4d1) << 8);
480
481 /*
Simon Arlott27b46d72007-10-20 01:13:56 +0200482 * If we use ACPI to set PCI IRQs, then we should clear ELCR
Linus Torvalds1da177e2005-04-16 15:20:36 -0700483 * since we will set it correctly as we enable the PCI irq
484 * routing.
485 */
486 new = acpi_noirq ? old : 0;
487
488 /*
489 * Update SCI information in the ELCR, it isn't in the PCI
490 * routing tables..
491 */
492 switch (trigger) {
Len Brown4be44fc2005-08-05 00:44:28 -0400493 case 1: /* Edge - clear */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700494 new &= ~mask;
495 break;
Len Brown4be44fc2005-08-05 00:44:28 -0400496 case 3: /* Level - set */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700497 new |= mask;
498 break;
499 }
500
501 if (old == new)
502 return;
503
504 printk(PREFIX "setting ELCR to %04x (from %04x)\n", new, old);
505 outb(new, 0x4d0);
506 outb(new >> 8, 0x4d1);
507}
508
Linus Torvalds1da177e2005-04-16 15:20:36 -0700509int acpi_gsi_to_irq(u32 gsi, unsigned int *irq)
510{
Eric W. Biederman988856e2010-03-30 01:07:15 -0700511 *irq = gsi_to_irq(gsi);
Yinghai Lu18dce6b2010-02-10 01:20:05 -0800512
513#ifdef CONFIG_X86_IO_APIC
514 if (acpi_irq_model == ACPI_IRQ_MODEL_IOAPIC)
515 setup_IO_APIC_irq_extra(gsi);
516#endif
517
Linus Torvalds1da177e2005-04-16 15:20:36 -0700518 return 0;
519}
Huang Ying81e88fd2011-01-12 14:44:55 +0800520EXPORT_SYMBOL_GPL(acpi_gsi_to_irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700521
Eric W. Biederman2c2df842010-03-30 01:07:02 -0700522int acpi_isa_irq_to_gsi(unsigned isa_irq, u32 *gsi)
523{
524 if (isa_irq >= 16)
525 return -1;
Eric W. Biederman988856e2010-03-30 01:07:15 -0700526 *gsi = irq_to_gsi(isa_irq);
Eric W. Biederman2c2df842010-03-30 01:07:02 -0700527 return 0;
528}
529
Jeremy Fitzhardinge2f065ae2010-06-24 16:59:16 +0100530static int acpi_register_gsi_pic(struct device *dev, u32 gsi,
531 int trigger, int polarity)
532{
533#ifdef CONFIG_PCI
534 /*
535 * Make sure all (legacy) PCI IRQs are set as level-triggered.
536 */
537 if (trigger == ACPI_LEVEL_SENSITIVE)
538 eisa_set_level_irq(gsi);
539#endif
540
541 return gsi;
542}
543
544static int acpi_register_gsi_ioapic(struct device *dev, u32 gsi,
545 int trigger, int polarity)
546{
547#ifdef CONFIG_X86_IO_APIC
548 gsi = mp_register_gsi(dev, gsi, trigger, polarity);
549#endif
550
551 return gsi;
552}
553
Jeremy Fitzhardinge90f68812010-06-24 17:05:41 +0100554int (*__acpi_register_gsi)(struct device *dev, u32 gsi,
555 int trigger, int polarity) = acpi_register_gsi_pic;
Jeremy Fitzhardinge2f065ae2010-06-24 16:59:16 +0100556
Konrad Rzeszutek Wilkd6a77ea2013-05-14 17:09:16 +0000557#ifdef CONFIG_ACPI_SLEEP
558int (*acpi_suspend_lowlevel)(void) = x86_acpi_suspend_lowlevel;
559#else
560int (*acpi_suspend_lowlevel)(void);
561#endif
562
Kenji Kaneshige1f3a6a12005-07-28 14:42:00 -0400563/*
564 * success: return IRQ number (>=0)
565 * failure: return < 0
566 */
Yinghai Lue5198072009-05-15 13:05:16 -0700567int acpi_register_gsi(struct device *dev, u32 gsi, int trigger, int polarity)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700568{
569 unsigned int irq;
570 unsigned int plat_gsi = gsi;
571
Jeremy Fitzhardinge2f065ae2010-06-24 16:59:16 +0100572 plat_gsi = (*__acpi_register_gsi)(dev, gsi, trigger, polarity);
Eric W. Biederman988856e2010-03-30 01:07:15 -0700573 irq = gsi_to_irq(plat_gsi);
Yinghai Lu18dce6b2010-02-10 01:20:05 -0800574
Linus Torvalds1da177e2005-04-16 15:20:36 -0700575 return irq;
576}
Andy Shevchenko35e92b72012-10-31 22:44:48 +0100577EXPORT_SYMBOL_GPL(acpi_register_gsi);
578
579void acpi_unregister_gsi(u32 gsi)
580{
581}
582EXPORT_SYMBOL_GPL(acpi_unregister_gsi);
Len Brown4be44fc2005-08-05 00:44:28 -0400583
Jeremy Fitzhardinge2f065ae2010-06-24 16:59:16 +0100584void __init acpi_set_irq_model_pic(void)
585{
586 acpi_irq_model = ACPI_IRQ_MODEL_PIC;
587 __acpi_register_gsi = acpi_register_gsi_pic;
588 acpi_ioapic = 0;
589}
590
591void __init acpi_set_irq_model_ioapic(void)
592{
593 acpi_irq_model = ACPI_IRQ_MODEL_IOAPIC;
594 __acpi_register_gsi = acpi_register_gsi_ioapic;
595 acpi_ioapic = 1;
596}
597
Linus Torvalds1da177e2005-04-16 15:20:36 -0700598/*
599 * ACPI based hotplug support for CPU
600 */
601#ifdef CONFIG_ACPI_HOTPLUG_CPU
Alex Chiangd8191fa2010-02-22 12:11:39 -0700602#include <acpi/processor.h>
Sam Ravnborg009cbad2008-02-01 17:49:42 +0100603
Paul Gortmaker148f9bb2013-06-18 18:23:59 -0400604static void acpi_map_cpu2node(acpi_handle handle, int cpu, int physid)
Haicheng Li0271f912010-02-04 19:06:33 +0800605{
606#ifdef CONFIG_ACPI_NUMA
607 int nid;
608
609 nid = acpi_get_node(handle);
610 if (nid == -1 || !node_online(nid))
611 return;
Tejun Heobbc9e2f2011-01-23 14:37:39 +0100612 set_apicid_to_node(physid, nid);
Haicheng Li0271f912010-02-04 19:06:33 +0800613 numa_set_node(cpu, nid);
Haicheng Li0271f912010-02-04 19:06:33 +0800614#endif
615}
Sam Ravnborg009cbad2008-02-01 17:49:42 +0100616
Jiang Liud536bf32013-09-02 11:57:35 +0800617static int _acpi_map_lsapic(acpi_handle handle, int physid, int *pcpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700618{
Rusty Russellee943a82008-12-31 18:08:47 -0800619 cpumask_var_t tmp_map, new_map;
Ashok Raj73fea172006-09-26 10:52:35 +0200620 int cpu;
Rusty Russellee943a82008-12-31 18:08:47 -0800621 int retval = -ENOMEM;
Ashok Raj73fea172006-09-26 10:52:35 +0200622
Rusty Russellee943a82008-12-31 18:08:47 -0800623 if (!alloc_cpumask_var(&tmp_map, GFP_KERNEL))
624 goto out;
625
626 if (!alloc_cpumask_var(&new_map, GFP_KERNEL))
627 goto free_tmp_map;
628
629 cpumask_copy(tmp_map, cpu_present_mask);
Petr Vandrovecac909ec2012-03-08 13:33:24 -0800630 acpi_register_lapic(physid, ACPI_MADT_ENABLED);
Ashok Raj73fea172006-09-26 10:52:35 +0200631
632 /*
Yasuaki Ishimatsu57c078c2012-09-26 09:54:17 +0900633 * If acpi_register_lapic successfully generates a new logical cpu
Ashok Raj73fea172006-09-26 10:52:35 +0200634 * number, then the following will get us exactly what was mapped
635 */
Rusty Russellee943a82008-12-31 18:08:47 -0800636 cpumask_andnot(new_map, cpu_present_mask, tmp_map);
637 if (cpumask_empty(new_map)) {
Ashok Raj73fea172006-09-26 10:52:35 +0200638 printk ("Unable to map lapic to logical cpu number\n");
Rusty Russellee943a82008-12-31 18:08:47 -0800639 retval = -EINVAL;
640 goto free_new_map;
Ashok Raj73fea172006-09-26 10:52:35 +0200641 }
642
Alex Chiangd8191fa2010-02-22 12:11:39 -0700643 acpi_processor_set_pdc(handle);
644
Rusty Russellee943a82008-12-31 18:08:47 -0800645 cpu = cpumask_first(new_map);
Haicheng Li0271f912010-02-04 19:06:33 +0800646 acpi_map_cpu2node(handle, cpu, physid);
Ashok Raj73fea172006-09-26 10:52:35 +0200647
648 *pcpu = cpu;
Rusty Russellee943a82008-12-31 18:08:47 -0800649 retval = 0;
650
651free_new_map:
652 free_cpumask_var(new_map);
653free_tmp_map:
654 free_cpumask_var(tmp_map);
655out:
656 return retval;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700657}
Len Brown4be44fc2005-08-05 00:44:28 -0400658
Sam Ravnborg009cbad2008-02-01 17:49:42 +0100659/* wrapper to silence section mismatch warning */
Jiang Liud536bf32013-09-02 11:57:35 +0800660int __ref acpi_map_lsapic(acpi_handle handle, int physid, int *pcpu)
Sam Ravnborg009cbad2008-02-01 17:49:42 +0100661{
Jiang Liud536bf32013-09-02 11:57:35 +0800662 return _acpi_map_lsapic(handle, physid, pcpu);
Sam Ravnborg009cbad2008-02-01 17:49:42 +0100663}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700664EXPORT_SYMBOL(acpi_map_lsapic);
665
Len Brown4be44fc2005-08-05 00:44:28 -0400666int acpi_unmap_lsapic(int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700667{
Wen Congyangc4c60522013-02-22 16:33:24 -0800668#ifdef CONFIG_ACPI_NUMA
669 set_apicid_to_node(per_cpu(x86_cpu_to_apicid, cpu), NUMA_NO_NODE);
670#endif
671
Mike Travis71fff5e2007-10-19 20:35:03 +0200672 per_cpu(x86_cpu_to_apicid, cpu) = -1;
Mike Travis96289372008-12-31 18:08:46 -0800673 set_cpu_present(cpu, false);
Ashok Raj73fea172006-09-26 10:52:35 +0200674 num_processors--;
675
676 return (0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700677}
Len Brown4be44fc2005-08-05 00:44:28 -0400678
Linus Torvalds1da177e2005-04-16 15:20:36 -0700679EXPORT_SYMBOL(acpi_unmap_lsapic);
Len Brown4be44fc2005-08-05 00:44:28 -0400680#endif /* CONFIG_ACPI_HOTPLUG_CPU */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700681
Len Brown4be44fc2005-08-05 00:44:28 -0400682int acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base)
Kenji Kaneshigeb1bb2482005-04-28 00:25:58 -0700683{
684 /* TBD */
685 return -EINVAL;
686}
Len Brown4be44fc2005-08-05 00:44:28 -0400687
Kenji Kaneshigeb1bb2482005-04-28 00:25:58 -0700688EXPORT_SYMBOL(acpi_register_ioapic);
689
Len Brown4be44fc2005-08-05 00:44:28 -0400690int acpi_unregister_ioapic(acpi_handle handle, u32 gsi_base)
Kenji Kaneshigeb1bb2482005-04-28 00:25:58 -0700691{
692 /* TBD */
693 return -EINVAL;
694}
Len Brown4be44fc2005-08-05 00:44:28 -0400695
Kenji Kaneshigeb1bb2482005-04-28 00:25:58 -0700696EXPORT_SYMBOL(acpi_unregister_ioapic);
697
Alexey Starikovskiy5f3b1a82007-02-02 19:48:22 +0300698static int __init acpi_parse_sbf(struct acpi_table_header *table)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700699{
Alexey Starikovskiy5f3b1a82007-02-02 19:48:22 +0300700 struct acpi_table_boot *sb;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700701
Alexey Starikovskiy5f3b1a82007-02-02 19:48:22 +0300702 sb = (struct acpi_table_boot *)table;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700703 if (!sb) {
704 printk(KERN_WARNING PREFIX "Unable to map SBF\n");
705 return -ENODEV;
706 }
707
Alexey Starikovskiy5f3b1a82007-02-02 19:48:22 +0300708 sbf_port = sb->cmos_index; /* Save CMOS port */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700709
710 return 0;
711}
712
Linus Torvalds1da177e2005-04-16 15:20:36 -0700713#ifdef CONFIG_HPET_TIMER
john stultz2d0c87c2007-02-16 01:28:18 -0800714#include <asm/hpet.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -0700715
Aaron Durbina1dfd852007-07-21 17:11:39 +0200716static struct __initdata resource *hpet_res;
717
Alexey Starikovskiy5f3b1a82007-02-02 19:48:22 +0300718static int __init acpi_parse_hpet(struct acpi_table_header *table)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700719{
720 struct acpi_table_hpet *hpet_tbl;
721
Alexey Starikovskiy5f3b1a82007-02-02 19:48:22 +0300722 hpet_tbl = (struct acpi_table_hpet *)table;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700723 if (!hpet_tbl) {
724 printk(KERN_WARNING PREFIX "Unable to map HPET\n");
725 return -ENODEV;
726 }
727
Alexey Starikovskiyad363f82007-02-02 19:48:22 +0300728 if (hpet_tbl->address.space_id != ACPI_SPACE_MEM) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700729 printk(KERN_WARNING PREFIX "HPET timers must be located in "
730 "memory.\n");
731 return -1;
732 }
adurbin@google.comf0f4c342006-09-26 10:52:39 +0200733
john stultz2d0c87c2007-02-16 01:28:18 -0800734 hpet_address = hpet_tbl->address.address;
Suresh Siddhac8bc6f32009-08-04 12:07:09 -0700735 hpet_blockid = hpet_tbl->sequence;
Thomas Gleixnerf4df73c2007-11-15 21:41:50 -0500736
737 /*
738 * Some broken BIOSes advertise HPET at 0x0. We really do not
739 * want to allocate a resource there.
740 */
741 if (!hpet_address) {
742 printk(KERN_WARNING PREFIX
743 "HPET id: %#x base: %#lx is invalid\n",
744 hpet_tbl->id, hpet_address);
745 return 0;
746 }
747#ifdef CONFIG_X86_64
748 /*
749 * Some even more broken BIOSes advertise HPET at
750 * 0xfed0000000000000 instead of 0xfed00000. Fix it up and add
751 * some noise:
752 */
753 if (hpet_address == 0xfed0000000000000UL) {
754 if (!hpet_force_user) {
755 printk(KERN_WARNING PREFIX "HPET id: %#x "
756 "base: 0xfed0000000000000 is bogus\n "
757 "try hpet=force on the kernel command line to "
758 "fix it up to 0xfed00000.\n", hpet_tbl->id);
759 hpet_address = 0;
760 return 0;
761 }
762 printk(KERN_WARNING PREFIX
763 "HPET id: %#x base: 0xfed0000000000000 fixed up "
764 "to 0xfed00000.\n", hpet_tbl->id);
765 hpet_address >>= 32;
766 }
767#endif
Len Brown4be44fc2005-08-05 00:44:28 -0400768 printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n",
john stultz2d0c87c2007-02-16 01:28:18 -0800769 hpet_tbl->id, hpet_address);
adurbin@google.comf0f4c342006-09-26 10:52:39 +0200770
Aaron Durbina1dfd852007-07-21 17:11:39 +0200771 /*
772 * Allocate and initialize the HPET firmware resource for adding into
773 * the resource tree during the lateinit timeframe.
774 */
775#define HPET_RESOURCE_NAME_SIZE 9
776 hpet_res = alloc_bootmem(sizeof(*hpet_res) + HPET_RESOURCE_NAME_SIZE);
777
Aaron Durbina1dfd852007-07-21 17:11:39 +0200778 hpet_res->name = (void *)&hpet_res[1];
779 hpet_res->flags = IORESOURCE_MEM;
780 snprintf((char *)hpet_res->name, HPET_RESOURCE_NAME_SIZE, "HPET %u",
781 hpet_tbl->sequence);
782
783 hpet_res->start = hpet_address;
784 hpet_res->end = hpet_address + (1 * 1024) - 1;
785
Linus Torvalds1da177e2005-04-16 15:20:36 -0700786 return 0;
787}
Aaron Durbina1dfd852007-07-21 17:11:39 +0200788
789/*
790 * hpet_insert_resource inserts the HPET resources used into the resource
791 * tree.
792 */
793static __init int hpet_insert_resource(void)
794{
795 if (!hpet_res)
796 return 1;
797
798 return insert_resource(&iomem_resource, hpet_res);
799}
800
801late_initcall(hpet_insert_resource);
802
Linus Torvalds1da177e2005-04-16 15:20:36 -0700803#else
804#define acpi_parse_hpet NULL
805#endif
806
Alexey Starikovskiy5f3b1a82007-02-02 19:48:22 +0300807static int __init acpi_parse_fadt(struct acpi_table_header *table)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700808{
Jason Davis90660ec2005-04-16 15:24:53 -0700809
Linus Torvalds1da177e2005-04-16 15:20:36 -0700810#ifdef CONFIG_X86_PM_TIMER
811 /* detect the location of the ACPI PM Timer */
Alexey Starikovskiy5f3b1a82007-02-02 19:48:22 +0300812 if (acpi_gbl_FADT.header.revision >= FADT2_REVISION_ID) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700813 /* FADT rev. 2 */
Alexey Starikovskiy5f3b1a82007-02-02 19:48:22 +0300814 if (acpi_gbl_FADT.xpm_timer_block.space_id !=
Len Brown4be44fc2005-08-05 00:44:28 -0400815 ACPI_ADR_SPACE_SYSTEM_IO)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700816 return 0;
817
Alexey Starikovskiy5f3b1a82007-02-02 19:48:22 +0300818 pmtmr_ioport = acpi_gbl_FADT.xpm_timer_block.address;
David Shaohua Lie6e87b42005-09-21 01:35:00 -0400819 /*
820 * "X" fields are optional extensions to the original V1.0
821 * fields, so we must selectively expand V1.0 fields if the
822 * corresponding X field is zero.
823 */
824 if (!pmtmr_ioport)
Alexey Starikovskiy5f3b1a82007-02-02 19:48:22 +0300825 pmtmr_ioport = acpi_gbl_FADT.pm_timer_block;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700826 } else {
827 /* FADT rev. 1 */
Alexey Starikovskiy5f3b1a82007-02-02 19:48:22 +0300828 pmtmr_ioport = acpi_gbl_FADT.pm_timer_block;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700829 }
830 if (pmtmr_ioport)
Len Brown4be44fc2005-08-05 00:44:28 -0400831 printk(KERN_INFO PREFIX "PM-Timer IO Port: %#x\n",
832 pmtmr_ioport);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700833#endif
834 return 0;
835}
836
Linus Torvalds1da177e2005-04-16 15:20:36 -0700837#ifdef CONFIG_X86_LOCAL_APIC
838/*
839 * Parse LAPIC entries in MADT
840 * returns 0 on success, < 0 on error
841 */
Alexey Starikovskiy31d20922008-04-04 23:41:57 +0400842
Yinghai Lucbf9bd62008-02-19 03:21:06 -0800843static int __init early_acpi_parse_madt_lapic_addr_ovr(void)
844{
845 int count;
846
847 if (!cpu_has_apic)
848 return -ENODEV;
849
850 /*
851 * Note that the LAPIC address is obtained from the MADT (32-bit value)
852 * and (optionally) overriden by a LAPIC_ADDR_OVR entry (64-bit value).
853 */
854
855 count =
856 acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE,
857 acpi_parse_lapic_addr_ovr, 0);
858 if (count < 0) {
859 printk(KERN_ERR PREFIX
860 "Error parsing LAPIC address override entry\n");
861 return count;
862 }
863
Yinghai Luc0104d32010-12-07 00:55:17 -0800864 register_lapic_address(acpi_lapic_addr);
Yinghai Lucbf9bd62008-02-19 03:21:06 -0800865
866 return count;
867}
868
Len Brown4be44fc2005-08-05 00:44:28 -0400869static int __init acpi_parse_madt_lapic_entries(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700870{
871 int count;
Suresh Siddha7237d3d2009-03-30 13:55:30 -0800872 int x2count = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700873
Andi Kleen0fcd2702006-04-11 12:54:36 +0200874 if (!cpu_has_apic)
875 return -ENODEV;
876
Alexey Starikovskiy5f3b1a82007-02-02 19:48:22 +0300877 /*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700878 * Note that the LAPIC address is obtained from the MADT (32-bit value)
879 * and (optionally) overriden by a LAPIC_ADDR_OVR entry (64-bit value).
880 */
881
Len Brown4be44fc2005-08-05 00:44:28 -0400882 count =
Alexey Starikovskiy5f3b1a82007-02-02 19:48:22 +0300883 acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE,
Len Brown4be44fc2005-08-05 00:44:28 -0400884 acpi_parse_lapic_addr_ovr, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700885 if (count < 0) {
Len Brown4be44fc2005-08-05 00:44:28 -0400886 printk(KERN_ERR PREFIX
887 "Error parsing LAPIC address override entry\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700888 return count;
889 }
890
Yinghai Luc0104d32010-12-07 00:55:17 -0800891 register_lapic_address(acpi_lapic_addr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700892
Jack Steinerac049c12008-03-28 14:12:09 -0500893 count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_SAPIC,
Yinghai Lucb2ded32011-01-04 16:38:52 -0800894 acpi_parse_sapic, MAX_LOCAL_APIC);
Jack Steinerac049c12008-03-28 14:12:09 -0500895
Suresh Siddha7237d3d2009-03-30 13:55:30 -0800896 if (!count) {
897 x2count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_X2APIC,
Yinghai Lucb2ded32011-01-04 16:38:52 -0800898 acpi_parse_x2apic, MAX_LOCAL_APIC);
Jack Steinerac049c12008-03-28 14:12:09 -0500899 count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC,
Yinghai Lucb2ded32011-01-04 16:38:52 -0800900 acpi_parse_lapic, MAX_LOCAL_APIC);
Suresh Siddha7237d3d2009-03-30 13:55:30 -0800901 }
902 if (!count && !x2count) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700903 printk(KERN_ERR PREFIX "No LAPIC entries present\n");
904 /* TBD: Cleanup to allow fallback to MPS */
905 return -ENODEV;
Suresh Siddha7237d3d2009-03-30 13:55:30 -0800906 } else if (count < 0 || x2count < 0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700907 printk(KERN_ERR PREFIX "Error parsing LAPIC entry\n");
908 /* TBD: Cleanup to allow fallback to MPS */
909 return count;
910 }
911
Suresh Siddha7237d3d2009-03-30 13:55:30 -0800912 x2count =
913 acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_X2APIC_NMI,
914 acpi_parse_x2apic_nmi, 0);
Len Brown4be44fc2005-08-05 00:44:28 -0400915 count =
Alexey Starikovskiy5f3b1a82007-02-02 19:48:22 +0300916 acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC_NMI, acpi_parse_lapic_nmi, 0);
Suresh Siddha7237d3d2009-03-30 13:55:30 -0800917 if (count < 0 || x2count < 0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700918 printk(KERN_ERR PREFIX "Error parsing LAPIC NMI entry\n");
919 /* TBD: Cleanup to allow fallback to MPS */
920 return count;
921 }
922 return 0;
923}
Len Brown4be44fc2005-08-05 00:44:28 -0400924#endif /* CONFIG_X86_LOCAL_APIC */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700925
Len Brown84663612005-08-24 12:09:07 -0400926#ifdef CONFIG_X86_IO_APIC
Alexey Starikovskiy11113f82008-05-14 19:02:57 +0400927#define MP_ISA_BUS 0
928
Yinghai Lud49c4282008-06-08 18:31:54 -0700929#ifdef CONFIG_X86_ES7000
Alexey Starikovskiy11113f82008-05-14 19:02:57 +0400930extern int es7000_plat;
931#endif
932
Alexey Starikovskiy11113f82008-05-14 19:02:57 +0400933void __init mp_override_legacy_irq(u8 bus_irq, u8 polarity, u8 trigger, u32 gsi)
934{
Yinghai Lu6df88092008-06-15 18:19:46 -0700935 int ioapic;
936 int pin;
Jaswinder Singh Rajputc2c21742009-01-12 17:47:22 +0530937 struct mpc_intsrc mp_irq;
Alexey Starikovskiy11113f82008-05-14 19:02:57 +0400938
939 /*
940 * Convert 'gsi' to 'ioapic.pin'.
941 */
942 ioapic = mp_find_ioapic(gsi);
943 if (ioapic < 0)
944 return;
Jeremy Fitzhardingec3e137d2009-02-09 12:05:47 -0800945 pin = mp_find_ioapic_pin(ioapic, gsi);
Alexey Starikovskiy11113f82008-05-14 19:02:57 +0400946
947 /*
948 * TBD: This check is for faulty timer entries, where the override
949 * erroneously sets the trigger to level, resulting in a HUGE
950 * increase of timer interrupts!
951 */
952 if ((bus_irq == 0) && (trigger == 3))
953 trigger = 1;
954
Jaswinder Singh Rajputc2c21742009-01-12 17:47:22 +0530955 mp_irq.type = MP_INTSRC;
956 mp_irq.irqtype = mp_INT;
957 mp_irq.irqflag = (trigger << 2) | polarity;
958 mp_irq.srcbus = MP_ISA_BUS;
959 mp_irq.srcbusirq = bus_irq; /* IRQ */
Suresh Siddhad5371432011-05-18 16:31:37 -0700960 mp_irq.dstapic = mpc_ioapic_id(ioapic); /* APIC ID */
Jaswinder Singh Rajputc2c21742009-01-12 17:47:22 +0530961 mp_irq.dstirq = pin; /* INTIN# */
Alexey Starikovskiy11113f82008-05-14 19:02:57 +0400962
Feng Tang2d8009b2010-11-19 11:33:35 +0800963 mp_save_irq(&mp_irq);
Eric W. Biederman988856e2010-03-30 01:07:15 -0700964
965 isa_irq_to_gsi[bus_irq] = gsi;
Alexey Starikovskiy11113f82008-05-14 19:02:57 +0400966}
967
968void __init mp_config_acpi_legacy_irqs(void)
969{
Yinghai Lu6df88092008-06-15 18:19:46 -0700970 int i;
Jaswinder Singh Rajputc2c21742009-01-12 17:47:22 +0530971 struct mpc_intsrc mp_irq;
Alexey Starikovskiy11113f82008-05-14 19:02:57 +0400972
Paul Gortmakerbb8187d2012-05-17 19:06:13 -0400973#ifdef CONFIG_EISA
Alexey Starikovskiy11113f82008-05-14 19:02:57 +0400974 /*
975 * Fabricate the legacy ISA bus (bus #31).
976 */
977 mp_bus_id_to_type[MP_ISA_BUS] = MP_BUS_ISA;
978#endif
979 set_bit(MP_ISA_BUS, mp_bus_not_pci);
Thomas Gleixnercfc1b9a2008-07-21 21:35:38 +0200980 pr_debug("Bus #%d is ISA\n", MP_ISA_BUS);
Alexey Starikovskiy11113f82008-05-14 19:02:57 +0400981
Yinghai Lud49c4282008-06-08 18:31:54 -0700982#ifdef CONFIG_X86_ES7000
Alexey Starikovskiy11113f82008-05-14 19:02:57 +0400983 /*
984 * Older generations of ES7000 have no legacy identity mappings
985 */
986 if (es7000_plat == 1)
987 return;
988#endif
989
990 /*
Alexey Starikovskiy11113f82008-05-14 19:02:57 +0400991 * Use the default configuration for the IRQs 0-15. Unless
992 * overridden by (MADT) interrupt source override entries.
993 */
994 for (i = 0; i < 16; i++) {
Eric W. Biederman0fd52672010-03-30 01:07:06 -0700995 int ioapic, pin;
996 unsigned int dstapic;
Alexey Starikovskiy11113f82008-05-14 19:02:57 +0400997 int idx;
Eric W. Biederman0fd52672010-03-30 01:07:06 -0700998 u32 gsi;
999
1000 /* Locate the gsi that irq i maps to. */
1001 if (acpi_isa_irq_to_gsi(i, &gsi))
1002 continue;
1003
1004 /*
1005 * Locate the IOAPIC that manages the ISA IRQ.
1006 */
1007 ioapic = mp_find_ioapic(gsi);
1008 if (ioapic < 0)
1009 continue;
1010 pin = mp_find_ioapic_pin(ioapic, gsi);
Suresh Siddhad5371432011-05-18 16:31:37 -07001011 dstapic = mpc_ioapic_id(ioapic);
Alexey Starikovskiy11113f82008-05-14 19:02:57 +04001012
1013 for (idx = 0; idx < mp_irq_entries; idx++) {
Jaswinder Singh Rajputc2c21742009-01-12 17:47:22 +05301014 struct mpc_intsrc *irq = mp_irqs + idx;
Alexey Starikovskiy11113f82008-05-14 19:02:57 +04001015
1016 /* Do we already have a mapping for this ISA IRQ? */
Jaswinder Singh Rajputc2c21742009-01-12 17:47:22 +05301017 if (irq->srcbus == MP_ISA_BUS && irq->srcbusirq == i)
Alexey Starikovskiy11113f82008-05-14 19:02:57 +04001018 break;
1019
1020 /* Do we already have a mapping for this IOAPIC pin */
Eric W. Biederman0fd52672010-03-30 01:07:06 -07001021 if (irq->dstapic == dstapic && irq->dstirq == pin)
Alexey Starikovskiy11113f82008-05-14 19:02:57 +04001022 break;
1023 }
1024
1025 if (idx != mp_irq_entries) {
1026 printk(KERN_DEBUG "ACPI: IRQ%d used by override.\n", i);
1027 continue; /* IRQ already used */
1028 }
1029
Jaswinder Singh Rajputc2c21742009-01-12 17:47:22 +05301030 mp_irq.type = MP_INTSRC;
1031 mp_irq.irqflag = 0; /* Conforming */
1032 mp_irq.srcbus = MP_ISA_BUS;
1033 mp_irq.dstapic = dstapic;
1034 mp_irq.irqtype = mp_INT;
1035 mp_irq.srcbusirq = i; /* Identity mapped */
Eric W. Biederman0fd52672010-03-30 01:07:06 -07001036 mp_irq.dstirq = pin;
Alexey Starikovskiy11113f82008-05-14 19:02:57 +04001037
Feng Tang2d8009b2010-11-19 11:33:35 +08001038 mp_save_irq(&mp_irq);
Alexey Starikovskiy11113f82008-05-14 19:02:57 +04001039 }
1040}
1041
Yinghai Lue5198072009-05-15 13:05:16 -07001042static int mp_config_acpi_gsi(struct device *dev, u32 gsi, int trigger,
Yinghai Lua31f8202009-05-06 10:06:15 -07001043 int polarity)
1044{
1045#ifdef CONFIG_X86_MPPARSE
1046 struct mpc_intsrc mp_irq;
1047 struct pci_dev *pdev;
1048 unsigned char number;
1049 unsigned int devfn;
1050 int ioapic;
1051 u8 pin;
1052
1053 if (!acpi_ioapic)
1054 return 0;
1055 if (!dev)
1056 return 0;
1057 if (dev->bus != &pci_bus_type)
1058 return 0;
1059
1060 pdev = to_pci_dev(dev);
1061 number = pdev->bus->number;
1062 devfn = pdev->devfn;
1063 pin = pdev->pin;
1064 /* print the entry should happen on mptable identically */
1065 mp_irq.type = MP_INTSRC;
1066 mp_irq.irqtype = mp_INT;
Yinghai Lue5198072009-05-15 13:05:16 -07001067 mp_irq.irqflag = (trigger == ACPI_EDGE_SENSITIVE ? 4 : 0x0c) |
Yinghai Lua31f8202009-05-06 10:06:15 -07001068 (polarity == ACPI_ACTIVE_HIGH ? 1 : 3);
1069 mp_irq.srcbus = number;
1070 mp_irq.srcbusirq = (((devfn >> 3) & 0x1f) << 2) | ((pin - 1) & 3);
1071 ioapic = mp_find_ioapic(gsi);
Suresh Siddhad5371432011-05-18 16:31:37 -07001072 mp_irq.dstapic = mpc_ioapic_id(ioapic);
Yinghai Lua31f8202009-05-06 10:06:15 -07001073 mp_irq.dstirq = mp_find_ioapic_pin(ioapic, gsi);
1074
Feng Tang2d8009b2010-11-19 11:33:35 +08001075 mp_save_irq(&mp_irq);
Yinghai Lua31f8202009-05-06 10:06:15 -07001076#endif
1077 return 0;
1078}
1079
Yinghai Lue5198072009-05-15 13:05:16 -07001080int mp_register_gsi(struct device *dev, u32 gsi, int trigger, int polarity)
Alexey Starikovskiy11113f82008-05-14 19:02:57 +04001081{
1082 int ioapic;
1083 int ioapic_pin;
Yinghai Lue5198072009-05-15 13:05:16 -07001084 struct io_apic_irq_attr irq_attr;
Liu Ping Fan25aa2952013-08-23 16:58:47 +08001085 int ret;
Alexey Starikovskiy11113f82008-05-14 19:02:57 +04001086
1087 if (acpi_irq_model != ACPI_IRQ_MODEL_IOAPIC)
1088 return gsi;
Alexey Starikovskiy11113f82008-05-14 19:02:57 +04001089
1090 /* Don't set up the ACPI SCI because it's already set up */
1091 if (acpi_gbl_FADT.sci_interrupt == gsi)
1092 return gsi;
1093
1094 ioapic = mp_find_ioapic(gsi);
1095 if (ioapic < 0) {
1096 printk(KERN_WARNING "No IOAPIC for GSI %u\n", gsi);
1097 return gsi;
1098 }
1099
Jeremy Fitzhardingec3e137d2009-02-09 12:05:47 -08001100 ioapic_pin = mp_find_ioapic_pin(ioapic, gsi);
Alexey Starikovskiy11113f82008-05-14 19:02:57 +04001101
Alexey Starikovskiy11113f82008-05-14 19:02:57 +04001102 if (ioapic_pin > MP_MAX_IOAPIC_PIN) {
1103 printk(KERN_ERR "Invalid reference to IOAPIC pin "
Suresh Siddhad5371432011-05-18 16:31:37 -07001104 "%d-%d\n", mpc_ioapic_id(ioapic),
Alexey Starikovskiy11113f82008-05-14 19:02:57 +04001105 ioapic_pin);
1106 return gsi;
1107 }
Yinghai Luf1bdb522009-05-15 13:05:16 -07001108
1109 if (enable_update_mptable)
1110 mp_config_acpi_gsi(dev, gsi, trigger, polarity);
Yinghai Lub9e03532009-05-06 10:05:32 -07001111
Yinghai Lue5198072009-05-15 13:05:16 -07001112 set_io_apic_irq_attr(&irq_attr, ioapic, ioapic_pin,
1113 trigger == ACPI_EDGE_SENSITIVE ? 0 : 1,
1114 polarity == ACPI_ACTIVE_HIGH ? 0 : 1);
Liu Ping Fan25aa2952013-08-23 16:58:47 +08001115 ret = io_apic_set_pci_routing(dev, gsi_to_irq(gsi), &irq_attr);
1116 if (ret < 0)
1117 gsi = INT_MIN;
Yinghai Lub9e03532009-05-06 10:05:32 -07001118
Alexey Starikovskiy11113f82008-05-14 19:02:57 +04001119 return gsi;
1120}
1121
Linus Torvalds1da177e2005-04-16 15:20:36 -07001122/*
1123 * Parse IOAPIC related entries in MADT
1124 * returns 0 on success, < 0 on error
1125 */
Len Brown4be44fc2005-08-05 00:44:28 -04001126static int __init acpi_parse_madt_ioapic_entries(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001127{
1128 int count;
1129
1130 /*
1131 * ACPI interpreter is required to complete interrupt setup,
1132 * so if it is off, don't enumerate the io-apics with ACPI.
1133 * If MPS is present, it will handle them,
1134 * otherwise the system will stay in PIC mode
1135 */
Jeremy Fitzhardinge6b2b1712009-06-08 02:53:50 -07001136 if (acpi_disabled || acpi_noirq)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001137 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001138
Alexey Starikovskiy5f3b1a82007-02-02 19:48:22 +03001139 if (!cpu_has_apic)
Andi Kleend3b6a342006-04-07 19:49:39 +02001140 return -ENODEV;
1141
Linus Torvalds1da177e2005-04-16 15:20:36 -07001142 /*
Len Brown4be44fc2005-08-05 00:44:28 -04001143 * if "noapic" boot option, don't look for IO-APICs
Linus Torvalds1da177e2005-04-16 15:20:36 -07001144 */
1145 if (skip_ioapic_setup) {
1146 printk(KERN_INFO PREFIX "Skipping IOAPIC probe "
Len Brown4be44fc2005-08-05 00:44:28 -04001147 "due to 'noapic' option.\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001148 return -ENODEV;
1149 }
1150
Len Brown4be44fc2005-08-05 00:44:28 -04001151 count =
Alexey Starikovskiy5f3b1a82007-02-02 19:48:22 +03001152 acpi_table_parse_madt(ACPI_MADT_TYPE_IO_APIC, acpi_parse_ioapic,
Len Brown4be44fc2005-08-05 00:44:28 -04001153 MAX_IO_APICS);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001154 if (!count) {
1155 printk(KERN_ERR PREFIX "No IOAPIC entries present\n");
1156 return -ENODEV;
Len Brown4be44fc2005-08-05 00:44:28 -04001157 } else if (count < 0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001158 printk(KERN_ERR PREFIX "Error parsing IOAPIC entry\n");
1159 return count;
1160 }
1161
Len Brown4be44fc2005-08-05 00:44:28 -04001162 count =
Alexey Starikovskiy5f3b1a82007-02-02 19:48:22 +03001163 acpi_table_parse_madt(ACPI_MADT_TYPE_INTERRUPT_OVERRIDE, acpi_parse_int_src_ovr,
Yinghai Lu71f521b2008-08-19 20:50:03 -07001164 nr_irqs);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001165 if (count < 0) {
Len Brown4be44fc2005-08-05 00:44:28 -04001166 printk(KERN_ERR PREFIX
1167 "Error parsing interrupt source overrides entry\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001168 /* TBD: Cleanup to allow fallback to MPS */
1169 return count;
1170 }
1171
1172 /*
1173 * If BIOS did not supply an INT_SRC_OVR for the SCI
1174 * pretend we got one so we can set the SCI flags.
1175 */
1176 if (!acpi_sci_override_gsi)
Eric W. Biederman9d2062b2010-03-30 01:07:05 -07001177 acpi_sci_ioapic_setup(acpi_gbl_FADT.sci_interrupt, 0, 0,
1178 acpi_gbl_FADT.sci_interrupt);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001179
André Goddard Rosaaf901ca2009-11-14 13:09:05 -02001180 /* Fill in identity legacy mappings where no override */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001181 mp_config_acpi_legacy_irqs();
1182
Len Brown4be44fc2005-08-05 00:44:28 -04001183 count =
Alexey Starikovskiy5f3b1a82007-02-02 19:48:22 +03001184 acpi_table_parse_madt(ACPI_MADT_TYPE_NMI_SOURCE, acpi_parse_nmi_src,
Yinghai Lu71f521b2008-08-19 20:50:03 -07001185 nr_irqs);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001186 if (count < 0) {
1187 printk(KERN_ERR PREFIX "Error parsing NMI SRC entry\n");
1188 /* TBD: Cleanup to allow fallback to MPS */
1189 return count;
1190 }
1191
1192 return 0;
1193}
1194#else
1195static inline int acpi_parse_madt_ioapic_entries(void)
1196{
1197 return -1;
1198}
Len Brown84663612005-08-24 12:09:07 -04001199#endif /* !CONFIG_X86_IO_APIC */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001200
Yinghai Lucbf9bd62008-02-19 03:21:06 -08001201static void __init early_acpi_process_madt(void)
1202{
1203#ifdef CONFIG_X86_LOCAL_APIC
1204 int error;
1205
1206 if (!acpi_table_parse(ACPI_SIG_MADT, acpi_parse_madt)) {
1207
1208 /*
1209 * Parse MADT LAPIC entries
1210 */
1211 error = early_acpi_parse_madt_lapic_addr_ovr();
1212 if (!error) {
1213 acpi_lapic = 1;
1214 smp_found_config = 1;
1215 }
1216 if (error == -EINVAL) {
1217 /*
1218 * Dell Precision Workstation 410, 610 come here.
1219 */
1220 printk(KERN_ERR PREFIX
1221 "Invalid BIOS MADT, disabling ACPI\n");
1222 disable_acpi();
1223 }
1224 }
1225#endif
1226}
1227
Len Brown4be44fc2005-08-05 00:44:28 -04001228static void __init acpi_process_madt(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001229{
1230#ifdef CONFIG_X86_LOCAL_APIC
Len Brown7f8f97c2007-02-10 21:28:03 -05001231 int error;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001232
Len Brown7f8f97c2007-02-10 21:28:03 -05001233 if (!acpi_table_parse(ACPI_SIG_MADT, acpi_parse_madt)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001234
1235 /*
1236 * Parse MADT LAPIC entries
1237 */
1238 error = acpi_parse_madt_lapic_entries();
1239 if (!error) {
1240 acpi_lapic = 1;
1241
1242 /*
1243 * Parse MADT IO-APIC entries
1244 */
1245 error = acpi_parse_madt_ioapic_entries();
1246 if (!error) {
Jeremy Fitzhardinge2f065ae2010-06-24 16:59:16 +01001247 acpi_set_irq_model_ioapic();
Linus Torvalds1da177e2005-04-16 15:20:36 -07001248
1249 smp_found_config = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001250 }
1251 }
1252 if (error == -EINVAL) {
1253 /*
1254 * Dell Precision Workstation 410, 610 come here.
1255 */
Len Brown4be44fc2005-08-05 00:44:28 -04001256 printk(KERN_ERR PREFIX
1257 "Invalid BIOS MADT, disabling ACPI\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001258 disable_acpi();
1259 }
Len Brown7b37b5f2008-12-23 01:47:42 -05001260 } else {
1261 /*
1262 * ACPI found no MADT, and so ACPI wants UP PIC mode.
1263 * In the event an MPS table was found, forget it.
1264 * Boot with "acpi=off" to use MPS on such a system.
1265 */
1266 if (smp_found_config) {
1267 printk(KERN_WARNING PREFIX
1268 "No APIC-table, disabling MPS\n");
1269 smp_found_config = 0;
1270 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001271 }
Yinghai Lu69b88af2008-12-05 22:45:50 -08001272
1273 /*
1274 * ACPI supports both logical (e.g. Hyper-Threading) and physical
1275 * processors, where MPS only supports physical.
1276 */
1277 if (acpi_lapic && acpi_ioapic)
1278 printk(KERN_INFO "Using ACPI (MADT) for SMP configuration "
1279 "information\n");
1280 else if (acpi_lapic)
1281 printk(KERN_INFO "Using ACPI for processor (LAPIC) "
1282 "configuration information\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001283#endif
1284 return;
1285}
1286
Jeff Garzik18552562007-10-03 15:15:40 -04001287static int __init disable_acpi_irq(const struct dmi_system_id *d)
Andrey Paninaea00142005-06-25 14:54:42 -07001288{
1289 if (!acpi_force) {
1290 printk(KERN_NOTICE "%s detected: force use of acpi=noirq\n",
1291 d->ident);
1292 acpi_noirq_set();
1293 }
1294 return 0;
1295}
1296
Jeff Garzik18552562007-10-03 15:15:40 -04001297static int __init disable_acpi_pci(const struct dmi_system_id *d)
Andrey Paninaea00142005-06-25 14:54:42 -07001298{
1299 if (!acpi_force) {
1300 printk(KERN_NOTICE "%s detected: force use of pci=noacpi\n",
1301 d->ident);
1302 acpi_disable_pci();
1303 }
1304 return 0;
1305}
Andrey Paninaea00142005-06-25 14:54:42 -07001306
Jeff Garzik18552562007-10-03 15:15:40 -04001307static int __init dmi_disable_acpi(const struct dmi_system_id *d)
Andrey Paninaea00142005-06-25 14:54:42 -07001308{
1309 if (!acpi_force) {
Len Brown4be44fc2005-08-05 00:44:28 -04001310 printk(KERN_NOTICE "%s detected: acpi off\n", d->ident);
Andrey Paninaea00142005-06-25 14:54:42 -07001311 disable_acpi();
1312 } else {
1313 printk(KERN_NOTICE
1314 "Warning: DMI blacklist says broken, but acpi forced\n");
1315 }
1316 return 0;
1317}
1318
1319/*
Feng Tangae10ccd2012-06-04 15:00:04 +08001320 * Force ignoring BIOS IRQ0 override
Rafael J. Wysockie2079c42008-07-08 16:12:26 +02001321 */
1322static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d)
1323{
Ingo Molnar8d89adf2008-10-07 06:47:52 +02001324 if (!acpi_skip_timer_override) {
Feng Tangae10ccd2012-06-04 15:00:04 +08001325 pr_notice("%s detected: Ignoring BIOS IRQ0 override\n",
Ingo Molnar8d89adf2008-10-07 06:47:52 +02001326 d->ident);
1327 acpi_skip_timer_override = 1;
1328 }
Rafael J. Wysockie2079c42008-07-08 16:12:26 +02001329 return 0;
1330}
1331
1332/*
Andrey Paninaea00142005-06-25 14:54:42 -07001333 * If your system is blacklisted here, but you find that acpi=force
Zhang Rui5b4c0b62009-04-01 01:49:42 -04001334 * works for you, please contact linux-acpi@vger.kernel.org
Andrey Paninaea00142005-06-25 14:54:42 -07001335 */
1336static struct dmi_system_id __initdata acpi_dmi_table[] = {
1337 /*
1338 * Boxes that need ACPI disabled
1339 */
1340 {
Len Brown4be44fc2005-08-05 00:44:28 -04001341 .callback = dmi_disable_acpi,
1342 .ident = "IBM Thinkpad",
1343 .matches = {
1344 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
1345 DMI_MATCH(DMI_BOARD_NAME, "2629H1G"),
1346 },
1347 },
Andrey Paninaea00142005-06-25 14:54:42 -07001348
1349 /*
Andrey Paninaea00142005-06-25 14:54:42 -07001350 * Boxes that need ACPI PCI IRQ routing disabled
1351 */
1352 {
Len Brown4be44fc2005-08-05 00:44:28 -04001353 .callback = disable_acpi_irq,
1354 .ident = "ASUS A7V",
1355 .matches = {
1356 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC"),
1357 DMI_MATCH(DMI_BOARD_NAME, "<A7V>"),
1358 /* newer BIOS, Revision 1011, does work */
1359 DMI_MATCH(DMI_BIOS_VERSION,
1360 "ASUS A7V ACPI BIOS Revision 1007"),
1361 },
1362 },
Len Brown74586fc2007-03-08 02:48:30 -05001363 {
1364 /*
1365 * Latest BIOS for IBM 600E (1.16) has bad pcinum
1366 * for LPC bridge, which is needed for the PCI
1367 * interrupt links to work. DSDT fix is in bug 5966.
1368 * 2645, 2646 model numbers are shared with 600/600E/600X
1369 */
1370 .callback = disable_acpi_irq,
1371 .ident = "IBM Thinkpad 600 Series 2645",
1372 .matches = {
1373 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
1374 DMI_MATCH(DMI_BOARD_NAME, "2645"),
1375 },
1376 },
1377 {
1378 .callback = disable_acpi_irq,
1379 .ident = "IBM Thinkpad 600 Series 2646",
1380 .matches = {
1381 DMI_MATCH(DMI_BOARD_VENDOR, "IBM"),
1382 DMI_MATCH(DMI_BOARD_NAME, "2646"),
1383 },
1384 },
Andrey Paninaea00142005-06-25 14:54:42 -07001385 /*
1386 * Boxes that need ACPI PCI IRQ routing and PCI scan disabled
1387 */
Len Brown4be44fc2005-08-05 00:44:28 -04001388 { /* _BBN 0 bug */
1389 .callback = disable_acpi_pci,
1390 .ident = "ASUS PR-DLS",
1391 .matches = {
1392 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
1393 DMI_MATCH(DMI_BOARD_NAME, "PR-DLS"),
1394 DMI_MATCH(DMI_BIOS_VERSION,
1395 "ASUS PR-DLS ACPI BIOS Revision 1010"),
1396 DMI_MATCH(DMI_BIOS_DATE, "03/21/2003")
1397 },
1398 },
Andrey Paninaea00142005-06-25 14:54:42 -07001399 {
Len Brown4be44fc2005-08-05 00:44:28 -04001400 .callback = disable_acpi_pci,
1401 .ident = "Acer TravelMate 36x Laptop",
1402 .matches = {
1403 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
1404 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 360"),
1405 },
1406 },
Andreas Herrmann35af2822008-10-22 13:08:31 +02001407 {}
1408};
1409
1410/* second table for DMI checks that should run after early-quirks */
1411static struct dmi_system_id __initdata acpi_dmi_table_late[] = {
Matthew Garrett9340e1c2008-07-01 01:12:06 +01001412 /*
1413 * HP laptops which use a DSDT reporting as HP/SB400/10000,
1414 * which includes some code which overrides all temperature
1415 * trip points to 16C if the INTIN2 input of the I/O APIC
1416 * is enabled. This input is incorrectly designated the
1417 * ISA IRQ 0 via an interrupt source override even though
1418 * it is wired to the output of the master 8259A and INTIN0
Feng Tangae10ccd2012-06-04 15:00:04 +08001419 * is not connected at all. Force ignoring BIOS IRQ0
Rafael J. Wysockie2079c42008-07-08 16:12:26 +02001420 * override in that cases.
1421 */
1422 {
1423 .callback = dmi_ignore_irq0_timer_override,
Rafael J. Wysockie84956f2008-10-06 11:59:29 +02001424 .ident = "HP nx6115 laptop",
1425 .matches = {
1426 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
1427 DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq nx6115"),
1428 },
1429 },
1430 {
1431 .callback = dmi_ignore_irq0_timer_override,
Rafael J. Wysockie2079c42008-07-08 16:12:26 +02001432 .ident = "HP NX6125 laptop",
1433 .matches = {
1434 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
1435 DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq nx6125"),
1436 },
1437 },
1438 {
1439 .callback = dmi_ignore_irq0_timer_override,
1440 .ident = "HP NX6325 laptop",
1441 .matches = {
1442 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
1443 DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq nx6325"),
1444 },
1445 },
Rafael J. Wysockie84956f2008-10-06 11:59:29 +02001446 {
1447 .callback = dmi_ignore_irq0_timer_override,
1448 .ident = "HP 6715b laptop",
1449 .matches = {
1450 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
1451 DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq 6715b"),
1452 },
1453 },
Feng Tangf6b54f02012-06-04 15:00:06 +08001454 {
1455 .callback = dmi_ignore_irq0_timer_override,
1456 .ident = "FUJITSU SIEMENS",
1457 .matches = {
1458 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
1459 DMI_MATCH(DMI_PRODUCT_NAME, "AMILO PRO V2030"),
1460 },
1461 },
Len Brown4be44fc2005-08-05 00:44:28 -04001462 {}
Andrey Paninaea00142005-06-25 14:54:42 -07001463};
1464
Linus Torvalds1da177e2005-04-16 15:20:36 -07001465/*
1466 * acpi_boot_table_init() and acpi_boot_init()
1467 * called from setup_arch(), always.
1468 * 1. checksums all tables
1469 * 2. enumerates lapics
1470 * 3. enumerates io-apics
1471 *
1472 * acpi_table_init() is separate to allow reading SRAT without
1473 * other side effects.
1474 *
1475 * side effects of acpi_boot_init:
1476 * acpi_lapic = 1 if LAPIC found
1477 * acpi_ioapic = 1 if IOAPIC found
1478 * if (acpi_lapic && acpi_ioapic) smp_found_config = 1;
1479 * if acpi_blacklisted() acpi_disabled = 1;
1480 * acpi_irq_model=...
1481 * ...
Linus Torvalds1da177e2005-04-16 15:20:36 -07001482 */
1483
Len Brown8558e392010-01-06 16:11:06 -05001484void __init acpi_boot_table_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001485{
Andrey Paninaea00142005-06-25 14:54:42 -07001486 dmi_check_system(acpi_dmi_table);
Andrey Paninaea00142005-06-25 14:54:42 -07001487
Linus Torvalds1da177e2005-04-16 15:20:36 -07001488 /*
1489 * If acpi_disabled, bail out
Linus Torvalds1da177e2005-04-16 15:20:36 -07001490 */
Len Brown68ca4062010-02-19 00:09:22 -05001491 if (acpi_disabled)
Len Brown8558e392010-01-06 16:11:06 -05001492 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001493
Alexey Starikovskiy5f3b1a82007-02-02 19:48:22 +03001494 /*
Linus Torvalds1da177e2005-04-16 15:20:36 -07001495 * Initialize the ACPI boot-time table parser.
1496 */
Len Brown8558e392010-01-06 16:11:06 -05001497 if (acpi_table_init()) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001498 disable_acpi();
Len Brown8558e392010-01-06 16:11:06 -05001499 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001500 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001501
Alexey Starikovskiy5f3b1a82007-02-02 19:48:22 +03001502 acpi_table_parse(ACPI_SIG_BOOT, acpi_parse_sbf);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001503
1504 /*
1505 * blacklist may disable ACPI entirely
1506 */
Len Brown8558e392010-01-06 16:11:06 -05001507 if (acpi_blacklisted()) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001508 if (acpi_force) {
1509 printk(KERN_WARNING PREFIX "acpi=force override\n");
1510 } else {
1511 printk(KERN_WARNING PREFIX "Disabling ACPI support\n");
1512 disable_acpi();
Len Brown8558e392010-01-06 16:11:06 -05001513 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001514 }
1515 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001516}
1517
Yinghai Lucbf9bd62008-02-19 03:21:06 -08001518int __init early_acpi_boot_init(void)
1519{
1520 /*
1521 * If acpi_disabled, bail out
Yinghai Lucbf9bd62008-02-19 03:21:06 -08001522 */
Len Brown68ca4062010-02-19 00:09:22 -05001523 if (acpi_disabled)
Yinghai Lucbf9bd62008-02-19 03:21:06 -08001524 return 1;
1525
1526 /*
1527 * Process the Multiple APIC Description Table (MADT), if present
1528 */
1529 early_acpi_process_madt();
1530
1531 return 0;
1532}
1533
Linus Torvalds1da177e2005-04-16 15:20:36 -07001534int __init acpi_boot_init(void)
1535{
Andreas Herrmann35af2822008-10-22 13:08:31 +02001536 /* those are executed after early-quirks are executed */
1537 dmi_check_system(acpi_dmi_table_late);
1538
Linus Torvalds1da177e2005-04-16 15:20:36 -07001539 /*
1540 * If acpi_disabled, bail out
Linus Torvalds1da177e2005-04-16 15:20:36 -07001541 */
Len Brown68ca4062010-02-19 00:09:22 -05001542 if (acpi_disabled)
Len Brown4be44fc2005-08-05 00:44:28 -04001543 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001544
Alexey Starikovskiy5f3b1a82007-02-02 19:48:22 +03001545 acpi_table_parse(ACPI_SIG_BOOT, acpi_parse_sbf);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001546
1547 /*
1548 * set sci_int and PM timer address
1549 */
Alexey Starikovskiyceb6c462007-02-02 19:48:22 +03001550 acpi_table_parse(ACPI_SIG_FADT, acpi_parse_fadt);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001551
1552 /*
1553 * Process the Multiple APIC Description Table (MADT), if present
1554 */
1555 acpi_process_madt();
1556
Alexey Starikovskiy5f3b1a82007-02-02 19:48:22 +03001557 acpi_table_parse(ACPI_SIG_HPET, acpi_parse_hpet);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001558
Thomas Gleixnerb72d0db2009-08-29 16:24:51 +02001559 if (!acpi_noirq)
1560 x86_init.pci.init = pci_acpi_init;
1561
Linus Torvalds1da177e2005-04-16 15:20:36 -07001562 return 0;
1563}
Rusty Russell1a3f2392006-09-26 10:52:32 +02001564
1565static int __init parse_acpi(char *arg)
1566{
1567 if (!arg)
1568 return -EINVAL;
1569
1570 /* "acpi=off" disables both ACPI table parsing and interpreter */
1571 if (strcmp(arg, "off") == 0) {
1572 disable_acpi();
1573 }
1574 /* acpi=force to over-ride black-list */
1575 else if (strcmp(arg, "force") == 0) {
1576 acpi_force = 1;
Rusty Russell1a3f2392006-09-26 10:52:32 +02001577 acpi_disabled = 0;
1578 }
1579 /* acpi=strict disables out-of-spec workarounds */
1580 else if (strcmp(arg, "strict") == 0) {
1581 acpi_strict = 1;
1582 }
Zhao Yakui237889b2008-12-17 16:55:18 +08001583 /* acpi=rsdt use RSDT instead of XSDT */
1584 else if (strcmp(arg, "rsdt") == 0) {
1585 acpi_rsdt_forced = 1;
1586 }
Rusty Russell1a3f2392006-09-26 10:52:32 +02001587 /* "acpi=noirq" disables ACPI interrupt routing */
1588 else if (strcmp(arg, "noirq") == 0) {
1589 acpi_noirq_set();
Lin Mingaa2110c2010-04-08 14:34:27 +08001590 }
1591 /* "acpi=copy_dsdt" copys DSDT */
1592 else if (strcmp(arg, "copy_dsdt") == 0) {
1593 acpi_gbl_copy_dsdt_locally = 1;
Naveen N. Rao9ad95872013-07-01 21:08:54 +05301594 }
1595 /* "acpi=nocmcff" disables FF mode for corrected errors */
1596 else if (strcmp(arg, "nocmcff") == 0) {
1597 acpi_disable_cmcff = 1;
Rusty Russell1a3f2392006-09-26 10:52:32 +02001598 } else {
1599 /* Core will printk when we return error. */
1600 return -EINVAL;
1601 }
1602 return 0;
1603}
1604early_param("acpi", parse_acpi);
1605
1606/* FIXME: Using pci= for an ACPI parameter is a travesty. */
1607static int __init parse_pci(char *arg)
1608{
1609 if (arg && strcmp(arg, "noacpi") == 0)
1610 acpi_disable_pci();
1611 return 0;
1612}
1613early_param("pci", parse_pci);
1614
Yinghai Lu3c999f12008-06-20 16:11:20 -07001615int __init acpi_mps_check(void)
1616{
1617#if defined(CONFIG_X86_LOCAL_APIC) && !defined(CONFIG_X86_MPPARSE)
1618/* mptable code is not built-in*/
1619 if (acpi_disabled || acpi_noirq) {
1620 printk(KERN_WARNING "MPS support code is not built-in.\n"
1621 "Using acpi=off or acpi=noirq or pci=noacpi "
1622 "may have problem\n");
1623 return 1;
1624 }
1625#endif
1626 return 0;
1627}
1628
Rusty Russell1a3f2392006-09-26 10:52:32 +02001629#ifdef CONFIG_X86_IO_APIC
1630static int __init parse_acpi_skip_timer_override(char *arg)
1631{
1632 acpi_skip_timer_override = 1;
1633 return 0;
1634}
1635early_param("acpi_skip_timer_override", parse_acpi_skip_timer_override);
Andi Kleenfa18f472006-11-14 16:57:46 +01001636
1637static int __init parse_acpi_use_timer_override(char *arg)
1638{
1639 acpi_use_timer_override = 1;
1640 return 0;
1641}
1642early_param("acpi_use_timer_override", parse_acpi_use_timer_override);
Rusty Russell1a3f2392006-09-26 10:52:32 +02001643#endif /* CONFIG_X86_IO_APIC */
1644
1645static int __init setup_acpi_sci(char *s)
1646{
1647 if (!s)
1648 return -EINVAL;
1649 if (!strcmp(s, "edge"))
Alexey Starikovskiy5f3b1a82007-02-02 19:48:22 +03001650 acpi_sci_flags = ACPI_MADT_TRIGGER_EDGE |
1651 (acpi_sci_flags & ~ACPI_MADT_TRIGGER_MASK);
Rusty Russell1a3f2392006-09-26 10:52:32 +02001652 else if (!strcmp(s, "level"))
Alexey Starikovskiy5f3b1a82007-02-02 19:48:22 +03001653 acpi_sci_flags = ACPI_MADT_TRIGGER_LEVEL |
1654 (acpi_sci_flags & ~ACPI_MADT_TRIGGER_MASK);
Rusty Russell1a3f2392006-09-26 10:52:32 +02001655 else if (!strcmp(s, "high"))
Alexey Starikovskiy5f3b1a82007-02-02 19:48:22 +03001656 acpi_sci_flags = ACPI_MADT_POLARITY_ACTIVE_HIGH |
1657 (acpi_sci_flags & ~ACPI_MADT_POLARITY_MASK);
Rusty Russell1a3f2392006-09-26 10:52:32 +02001658 else if (!strcmp(s, "low"))
Alexey Starikovskiy5f3b1a82007-02-02 19:48:22 +03001659 acpi_sci_flags = ACPI_MADT_POLARITY_ACTIVE_LOW |
1660 (acpi_sci_flags & ~ACPI_MADT_POLARITY_MASK);
Rusty Russell1a3f2392006-09-26 10:52:32 +02001661 else
1662 return -EINVAL;
1663 return 0;
1664}
1665early_param("acpi_sci", setup_acpi_sci);
Andrew Mortond0a90812006-10-20 14:30:27 -07001666
1667int __acpi_acquire_global_lock(unsigned int *lock)
1668{
1669 unsigned int old, new, val;
1670 do {
1671 old = *lock;
1672 new = (((old & ~0x3) + 2) + ((old >> 1) & 0x1));
1673 val = cmpxchg(lock, old, new);
1674 } while (unlikely (val != old));
1675 return (new < 3) ? -1 : 0;
1676}
1677
1678int __acpi_release_global_lock(unsigned int *lock)
1679{
1680 unsigned int old, new, val;
1681 do {
1682 old = *lock;
1683 new = old & ~0x3;
1684 val = cmpxchg(lock, old, new);
1685 } while (unlikely (val != old));
1686 return old & 0x1;
1687}
Thomas Renninger8e305242012-10-01 00:23:53 +02001688
1689void __init arch_reserve_mem_area(acpi_physical_address addr, size_t size)
1690{
1691 e820_add_region(addr, size, E820_ACPI);
1692 update_e820();
1693}