]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
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> | |
27 | #include <linux/config.h> | |
28 | #include <linux/acpi.h> | |
29 | #include <linux/efi.h> | |
30 | #include <linux/irq.h> | |
31 | #include <linux/module.h> | |
32 | ||
33 | #include <asm/pgtable.h> | |
34 | #include <asm/io_apic.h> | |
35 | #include <asm/apic.h> | |
36 | #include <asm/io.h> | |
37 | #include <asm/irq.h> | |
38 | #include <asm/mpspec.h> | |
39 | ||
40 | #ifdef CONFIG_X86_64 | |
41 | ||
42 | static inline void acpi_madt_oem_check(char *oem_id, char *oem_table_id) { } | |
43 | extern void __init clustered_apic_check(void); | |
44 | static inline int ioapic_setup_disabled(void) { return 0; } | |
45 | #include <asm/proto.h> | |
46 | ||
47 | #else /* X86 */ | |
48 | ||
49 | #ifdef CONFIG_X86_LOCAL_APIC | |
50 | #include <mach_apic.h> | |
51 | #include <mach_mpparse.h> | |
52 | #endif /* CONFIG_X86_LOCAL_APIC */ | |
53 | ||
54 | #endif /* X86 */ | |
55 | ||
56 | #define BAD_MADT_ENTRY(entry, end) ( \ | |
57 | (!entry) || (unsigned long)entry + sizeof(*entry) > end || \ | |
58 | ((acpi_table_entry_header *)entry)->length != sizeof(*entry)) | |
59 | ||
60 | #define PREFIX "ACPI: " | |
61 | ||
62 | #ifdef CONFIG_ACPI_PCI | |
63 | int acpi_noirq __initdata; /* skip ACPI IRQ initialization */ | |
64 | int acpi_pci_disabled __initdata; /* skip ACPI PCI scan and IRQ initialization */ | |
65 | #else | |
66 | int acpi_noirq __initdata = 1; | |
67 | int acpi_pci_disabled __initdata = 1; | |
68 | #endif | |
69 | int acpi_ht __initdata = 1; /* enable HT */ | |
70 | ||
71 | int acpi_lapic; | |
72 | int acpi_ioapic; | |
73 | int acpi_strict; | |
74 | EXPORT_SYMBOL(acpi_strict); | |
75 | ||
76 | acpi_interrupt_flags acpi_sci_flags __initdata; | |
77 | int acpi_sci_override_gsi __initdata; | |
78 | int acpi_skip_timer_override __initdata; | |
79 | ||
80 | #ifdef CONFIG_X86_LOCAL_APIC | |
81 | static u64 acpi_lapic_addr __initdata = APIC_DEFAULT_PHYS_BASE; | |
82 | #endif | |
83 | ||
84 | #ifndef __HAVE_ARCH_CMPXCHG | |
85 | #warning ACPI uses CMPXCHG, i486 and later hardware | |
86 | #endif | |
87 | ||
88 | #define MAX_MADT_ENTRIES 256 | |
89 | u8 x86_acpiid_to_apicid[MAX_MADT_ENTRIES] = | |
90 | { [0 ... MAX_MADT_ENTRIES-1] = 0xff }; | |
91 | EXPORT_SYMBOL(x86_acpiid_to_apicid); | |
92 | ||
93 | /* -------------------------------------------------------------------------- | |
94 | Boot-time Configuration | |
95 | -------------------------------------------------------------------------- */ | |
96 | ||
97 | /* | |
98 | * The default interrupt routing model is PIC (8259). This gets | |
99 | * overriden if IOAPICs are enumerated (below). | |
100 | */ | |
101 | enum acpi_irq_model_id acpi_irq_model = ACPI_IRQ_MODEL_PIC; | |
102 | ||
103 | #ifdef CONFIG_X86_64 | |
104 | ||
105 | /* rely on all ACPI tables being in the direct mapping */ | |
106 | char *__acpi_map_table(unsigned long phys_addr, unsigned long size) | |
107 | { | |
108 | if (!phys_addr || !size) | |
109 | return NULL; | |
110 | ||
111 | if (phys_addr < (end_pfn_map << PAGE_SHIFT)) | |
112 | return __va(phys_addr); | |
113 | ||
114 | return NULL; | |
115 | } | |
116 | ||
117 | #else | |
118 | ||
119 | /* | |
120 | * Temporarily use the virtual area starting from FIX_IO_APIC_BASE_END, | |
121 | * to map the target physical address. The problem is that set_fixmap() | |
122 | * provides a single page, and it is possible that the page is not | |
123 | * sufficient. | |
124 | * By using this area, we can map up to MAX_IO_APICS pages temporarily, | |
125 | * i.e. until the next __va_range() call. | |
126 | * | |
127 | * Important Safety Note: The fixed I/O APIC page numbers are *subtracted* | |
128 | * from the fixed base. That's why we start at FIX_IO_APIC_BASE_END and | |
129 | * count idx down while incrementing the phys address. | |
130 | */ | |
131 | char *__acpi_map_table(unsigned long phys, unsigned long size) | |
132 | { | |
133 | unsigned long base, offset, mapped_size; | |
134 | int idx; | |
135 | ||
136 | if (phys + size < 8*1024*1024) | |
137 | return __va(phys); | |
138 | ||
139 | offset = phys & (PAGE_SIZE - 1); | |
140 | mapped_size = PAGE_SIZE - offset; | |
141 | set_fixmap(FIX_ACPI_END, phys); | |
142 | base = fix_to_virt(FIX_ACPI_END); | |
143 | ||
144 | /* | |
145 | * Most cases can be covered by the below. | |
146 | */ | |
147 | idx = FIX_ACPI_END; | |
148 | while (mapped_size < size) { | |
149 | if (--idx < FIX_ACPI_BEGIN) | |
150 | return NULL; /* cannot handle this */ | |
151 | phys += PAGE_SIZE; | |
152 | set_fixmap(idx, phys); | |
153 | mapped_size += PAGE_SIZE; | |
154 | } | |
155 | ||
156 | return ((unsigned char *) base + offset); | |
157 | } | |
158 | #endif | |
159 | ||
160 | #ifdef CONFIG_PCI_MMCONFIG | |
161 | static int __init acpi_parse_mcfg(unsigned long phys_addr, unsigned long size) | |
162 | { | |
163 | struct acpi_table_mcfg *mcfg; | |
164 | ||
165 | if (!phys_addr || !size) | |
166 | return -EINVAL; | |
167 | ||
168 | mcfg = (struct acpi_table_mcfg *) __acpi_map_table(phys_addr, size); | |
169 | if (!mcfg) { | |
170 | printk(KERN_WARNING PREFIX "Unable to map MCFG\n"); | |
171 | return -ENODEV; | |
172 | } | |
173 | ||
174 | if (mcfg->base_reserved) { | |
175 | printk(KERN_ERR PREFIX "MMCONFIG not in low 4GB of memory\n"); | |
176 | return -ENODEV; | |
177 | } | |
178 | ||
179 | pci_mmcfg_base_addr = mcfg->base_address; | |
180 | ||
181 | return 0; | |
182 | } | |
183 | #else | |
184 | #define acpi_parse_mcfg NULL | |
185 | #endif /* !CONFIG_PCI_MMCONFIG */ | |
186 | ||
187 | #ifdef CONFIG_X86_LOCAL_APIC | |
188 | static int __init | |
189 | acpi_parse_madt ( | |
190 | unsigned long phys_addr, | |
191 | unsigned long size) | |
192 | { | |
193 | struct acpi_table_madt *madt = NULL; | |
194 | ||
195 | if (!phys_addr || !size) | |
196 | return -EINVAL; | |
197 | ||
198 | madt = (struct acpi_table_madt *) __acpi_map_table(phys_addr, size); | |
199 | if (!madt) { | |
200 | printk(KERN_WARNING PREFIX "Unable to map MADT\n"); | |
201 | return -ENODEV; | |
202 | } | |
203 | ||
204 | if (madt->lapic_address) { | |
205 | acpi_lapic_addr = (u64) madt->lapic_address; | |
206 | ||
207 | printk(KERN_DEBUG PREFIX "Local APIC address 0x%08x\n", | |
208 | madt->lapic_address); | |
209 | } | |
210 | ||
211 | acpi_madt_oem_check(madt->header.oem_id, madt->header.oem_table_id); | |
212 | ||
213 | return 0; | |
214 | } | |
215 | ||
216 | ||
217 | static int __init | |
218 | acpi_parse_lapic ( | |
219 | acpi_table_entry_header *header, const unsigned long end) | |
220 | { | |
221 | struct acpi_table_lapic *processor = NULL; | |
222 | ||
223 | processor = (struct acpi_table_lapic*) header; | |
224 | ||
225 | if (BAD_MADT_ENTRY(processor, end)) | |
226 | return -EINVAL; | |
227 | ||
228 | acpi_table_print_madt_entry(header); | |
229 | ||
230 | /* no utility in registering a disabled processor */ | |
231 | if (processor->flags.enabled == 0) | |
232 | return 0; | |
233 | ||
234 | x86_acpiid_to_apicid[processor->acpi_id] = processor->id; | |
235 | ||
236 | mp_register_lapic ( | |
237 | processor->id, /* APIC ID */ | |
238 | processor->flags.enabled); /* Enabled? */ | |
239 | ||
240 | return 0; | |
241 | } | |
242 | ||
243 | static int __init | |
244 | acpi_parse_lapic_addr_ovr ( | |
245 | acpi_table_entry_header *header, const unsigned long end) | |
246 | { | |
247 | struct acpi_table_lapic_addr_ovr *lapic_addr_ovr = NULL; | |
248 | ||
249 | lapic_addr_ovr = (struct acpi_table_lapic_addr_ovr*) header; | |
250 | ||
251 | if (BAD_MADT_ENTRY(lapic_addr_ovr, end)) | |
252 | return -EINVAL; | |
253 | ||
254 | acpi_lapic_addr = lapic_addr_ovr->address; | |
255 | ||
256 | return 0; | |
257 | } | |
258 | ||
259 | static int __init | |
260 | acpi_parse_lapic_nmi ( | |
261 | acpi_table_entry_header *header, const unsigned long end) | |
262 | { | |
263 | struct acpi_table_lapic_nmi *lapic_nmi = NULL; | |
264 | ||
265 | lapic_nmi = (struct acpi_table_lapic_nmi*) header; | |
266 | ||
267 | if (BAD_MADT_ENTRY(lapic_nmi, end)) | |
268 | return -EINVAL; | |
269 | ||
270 | acpi_table_print_madt_entry(header); | |
271 | ||
272 | if (lapic_nmi->lint != 1) | |
273 | printk(KERN_WARNING PREFIX "NMI not connected to LINT 1!\n"); | |
274 | ||
275 | return 0; | |
276 | } | |
277 | ||
278 | ||
279 | #endif /*CONFIG_X86_LOCAL_APIC*/ | |
280 | ||
281 | #if defined(CONFIG_X86_IO_APIC) && defined(CONFIG_ACPI_INTERPRETER) | |
282 | ||
283 | static int __init | |
284 | acpi_parse_ioapic ( | |
285 | acpi_table_entry_header *header, const unsigned long end) | |
286 | { | |
287 | struct acpi_table_ioapic *ioapic = NULL; | |
288 | ||
289 | ioapic = (struct acpi_table_ioapic*) header; | |
290 | ||
291 | if (BAD_MADT_ENTRY(ioapic, end)) | |
292 | return -EINVAL; | |
293 | ||
294 | acpi_table_print_madt_entry(header); | |
295 | ||
296 | mp_register_ioapic ( | |
297 | ioapic->id, | |
298 | ioapic->address, | |
299 | ioapic->global_irq_base); | |
300 | ||
301 | return 0; | |
302 | } | |
303 | ||
304 | /* | |
305 | * Parse Interrupt Source Override for the ACPI SCI | |
306 | */ | |
307 | static void | |
308 | acpi_sci_ioapic_setup(u32 gsi, u16 polarity, u16 trigger) | |
309 | { | |
310 | if (trigger == 0) /* compatible SCI trigger is level */ | |
311 | trigger = 3; | |
312 | ||
313 | if (polarity == 0) /* compatible SCI polarity is low */ | |
314 | polarity = 3; | |
315 | ||
316 | /* Command-line over-ride via acpi_sci= */ | |
317 | if (acpi_sci_flags.trigger) | |
318 | trigger = acpi_sci_flags.trigger; | |
319 | ||
320 | if (acpi_sci_flags.polarity) | |
321 | polarity = acpi_sci_flags.polarity; | |
322 | ||
323 | /* | |
324 | * mp_config_acpi_legacy_irqs() already setup IRQs < 16 | |
325 | * If GSI is < 16, this will update its flags, | |
326 | * else it will create a new mp_irqs[] entry. | |
327 | */ | |
328 | mp_override_legacy_irq(gsi, polarity, trigger, gsi); | |
329 | ||
330 | /* | |
331 | * stash over-ride to indicate we've been here | |
332 | * and for later update of acpi_fadt | |
333 | */ | |
334 | acpi_sci_override_gsi = gsi; | |
335 | return; | |
336 | } | |
337 | ||
338 | static int __init | |
339 | acpi_parse_int_src_ovr ( | |
340 | acpi_table_entry_header *header, const unsigned long end) | |
341 | { | |
342 | struct acpi_table_int_src_ovr *intsrc = NULL; | |
343 | ||
344 | intsrc = (struct acpi_table_int_src_ovr*) header; | |
345 | ||
346 | if (BAD_MADT_ENTRY(intsrc, end)) | |
347 | return -EINVAL; | |
348 | ||
349 | acpi_table_print_madt_entry(header); | |
350 | ||
351 | if (intsrc->bus_irq == acpi_fadt.sci_int) { | |
352 | acpi_sci_ioapic_setup(intsrc->global_irq, | |
353 | intsrc->flags.polarity, intsrc->flags.trigger); | |
354 | return 0; | |
355 | } | |
356 | ||
357 | if (acpi_skip_timer_override && | |
358 | intsrc->bus_irq == 0 && intsrc->global_irq == 2) { | |
359 | printk(PREFIX "BIOS IRQ0 pin2 override ignored.\n"); | |
360 | return 0; | |
361 | } | |
362 | ||
363 | mp_override_legacy_irq ( | |
364 | intsrc->bus_irq, | |
365 | intsrc->flags.polarity, | |
366 | intsrc->flags.trigger, | |
367 | intsrc->global_irq); | |
368 | ||
369 | return 0; | |
370 | } | |
371 | ||
372 | ||
373 | static int __init | |
374 | acpi_parse_nmi_src ( | |
375 | acpi_table_entry_header *header, const unsigned long end) | |
376 | { | |
377 | struct acpi_table_nmi_src *nmi_src = NULL; | |
378 | ||
379 | nmi_src = (struct acpi_table_nmi_src*) header; | |
380 | ||
381 | if (BAD_MADT_ENTRY(nmi_src, end)) | |
382 | return -EINVAL; | |
383 | ||
384 | acpi_table_print_madt_entry(header); | |
385 | ||
386 | /* TBD: Support nimsrc entries? */ | |
387 | ||
388 | return 0; | |
389 | } | |
390 | ||
391 | #endif /* CONFIG_X86_IO_APIC */ | |
392 | ||
393 | #ifdef CONFIG_ACPI_BUS | |
394 | ||
395 | /* | |
396 | * acpi_pic_sci_set_trigger() | |
397 | * | |
398 | * use ELCR to set PIC-mode trigger type for SCI | |
399 | * | |
400 | * If a PIC-mode SCI is not recognized or gives spurious IRQ7's | |
401 | * it may require Edge Trigger -- use "acpi_sci=edge" | |
402 | * | |
403 | * Port 0x4d0-4d1 are ECLR1 and ECLR2, the Edge/Level Control Registers | |
404 | * for the 8259 PIC. bit[n] = 1 means irq[n] is Level, otherwise Edge. | |
405 | * ECLR1 is IRQ's 0-7 (IRQ 0, 1, 2 must be 0) | |
406 | * ECLR2 is IRQ's 8-15 (IRQ 8, 13 must be 0) | |
407 | */ | |
408 | ||
409 | void __init | |
410 | acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger) | |
411 | { | |
412 | unsigned int mask = 1 << irq; | |
413 | unsigned int old, new; | |
414 | ||
415 | /* Real old ELCR mask */ | |
416 | old = inb(0x4d0) | (inb(0x4d1) << 8); | |
417 | ||
418 | /* | |
419 | * If we use ACPI to set PCI irq's, then we should clear ELCR | |
420 | * since we will set it correctly as we enable the PCI irq | |
421 | * routing. | |
422 | */ | |
423 | new = acpi_noirq ? old : 0; | |
424 | ||
425 | /* | |
426 | * Update SCI information in the ELCR, it isn't in the PCI | |
427 | * routing tables.. | |
428 | */ | |
429 | switch (trigger) { | |
430 | case 1: /* Edge - clear */ | |
431 | new &= ~mask; | |
432 | break; | |
433 | case 3: /* Level - set */ | |
434 | new |= mask; | |
435 | break; | |
436 | } | |
437 | ||
438 | if (old == new) | |
439 | return; | |
440 | ||
441 | printk(PREFIX "setting ELCR to %04x (from %04x)\n", new, old); | |
442 | outb(new, 0x4d0); | |
443 | outb(new >> 8, 0x4d1); | |
444 | } | |
445 | ||
446 | ||
447 | #endif /* CONFIG_ACPI_BUS */ | |
448 | ||
449 | int acpi_gsi_to_irq(u32 gsi, unsigned int *irq) | |
450 | { | |
451 | #ifdef CONFIG_X86_IO_APIC | |
452 | if (use_pci_vector() && !platform_legacy_irq(gsi)) | |
453 | *irq = IO_APIC_VECTOR(gsi); | |
454 | else | |
455 | #endif | |
456 | *irq = gsi; | |
457 | return 0; | |
458 | } | |
459 | ||
1f3a6a15 KK |
460 | /* |
461 | * success: return IRQ number (>=0) | |
462 | * failure: return < 0 | |
463 | */ | |
464 | int acpi_register_gsi(u32 gsi, int edge_level, int active_high_low) | |
1da177e4 LT |
465 | { |
466 | unsigned int irq; | |
467 | unsigned int plat_gsi = gsi; | |
468 | ||
469 | #ifdef CONFIG_PCI | |
470 | /* | |
471 | * Make sure all (legacy) PCI IRQs are set as level-triggered. | |
472 | */ | |
473 | if (acpi_irq_model == ACPI_IRQ_MODEL_PIC) { | |
474 | extern void eisa_set_level_irq(unsigned int irq); | |
475 | ||
476 | if (edge_level == ACPI_LEVEL_SENSITIVE) | |
477 | eisa_set_level_irq(gsi); | |
478 | } | |
479 | #endif | |
480 | ||
481 | #ifdef CONFIG_X86_IO_APIC | |
482 | if (acpi_irq_model == ACPI_IRQ_MODEL_IOAPIC) { | |
483 | plat_gsi = mp_register_gsi(gsi, edge_level, active_high_low); | |
484 | } | |
485 | #endif | |
486 | acpi_gsi_to_irq(plat_gsi, &irq); | |
487 | return irq; | |
488 | } | |
489 | EXPORT_SYMBOL(acpi_register_gsi); | |
490 | ||
491 | /* | |
492 | * ACPI based hotplug support for CPU | |
493 | */ | |
494 | #ifdef CONFIG_ACPI_HOTPLUG_CPU | |
495 | int | |
496 | acpi_map_lsapic(acpi_handle handle, int *pcpu) | |
497 | { | |
498 | /* TBD */ | |
499 | return -EINVAL; | |
500 | } | |
501 | EXPORT_SYMBOL(acpi_map_lsapic); | |
502 | ||
503 | ||
504 | int | |
505 | acpi_unmap_lsapic(int cpu) | |
506 | { | |
507 | /* TBD */ | |
508 | return -EINVAL; | |
509 | } | |
510 | EXPORT_SYMBOL(acpi_unmap_lsapic); | |
511 | #endif /* CONFIG_ACPI_HOTPLUG_CPU */ | |
512 | ||
513 | static unsigned long __init | |
514 | acpi_scan_rsdp ( | |
515 | unsigned long start, | |
516 | unsigned long length) | |
517 | { | |
518 | unsigned long offset = 0; | |
519 | unsigned long sig_len = sizeof("RSD PTR ") - 1; | |
520 | ||
521 | /* | |
522 | * Scan all 16-byte boundaries of the physical memory region for the | |
523 | * RSDP signature. | |
524 | */ | |
525 | for (offset = 0; offset < length; offset += 16) { | |
526 | if (strncmp((char *) (start + offset), "RSD PTR ", sig_len)) | |
527 | continue; | |
528 | return (start + offset); | |
529 | } | |
530 | ||
531 | return 0; | |
532 | } | |
533 | ||
534 | static int __init acpi_parse_sbf(unsigned long phys_addr, unsigned long size) | |
535 | { | |
536 | struct acpi_table_sbf *sb; | |
537 | ||
538 | if (!phys_addr || !size) | |
539 | return -EINVAL; | |
540 | ||
541 | sb = (struct acpi_table_sbf *) __acpi_map_table(phys_addr, size); | |
542 | if (!sb) { | |
543 | printk(KERN_WARNING PREFIX "Unable to map SBF\n"); | |
544 | return -ENODEV; | |
545 | } | |
546 | ||
547 | sbf_port = sb->sbf_cmos; /* Save CMOS port */ | |
548 | ||
549 | return 0; | |
550 | } | |
551 | ||
552 | ||
553 | #ifdef CONFIG_HPET_TIMER | |
554 | ||
555 | static int __init acpi_parse_hpet(unsigned long phys, unsigned long size) | |
556 | { | |
557 | struct acpi_table_hpet *hpet_tbl; | |
558 | ||
559 | if (!phys || !size) | |
560 | return -EINVAL; | |
561 | ||
562 | hpet_tbl = (struct acpi_table_hpet *) __acpi_map_table(phys, size); | |
563 | if (!hpet_tbl) { | |
564 | printk(KERN_WARNING PREFIX "Unable to map HPET\n"); | |
565 | return -ENODEV; | |
566 | } | |
567 | ||
568 | if (hpet_tbl->addr.space_id != ACPI_SPACE_MEM) { | |
569 | printk(KERN_WARNING PREFIX "HPET timers must be located in " | |
570 | "memory.\n"); | |
571 | return -1; | |
572 | } | |
573 | ||
574 | #ifdef CONFIG_X86_64 | |
575 | vxtime.hpet_address = hpet_tbl->addr.addrl | | |
576 | ((long) hpet_tbl->addr.addrh << 32); | |
577 | ||
578 | printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n", | |
579 | hpet_tbl->id, vxtime.hpet_address); | |
580 | #else /* X86 */ | |
581 | { | |
582 | extern unsigned long hpet_address; | |
583 | ||
584 | hpet_address = hpet_tbl->addr.addrl; | |
585 | printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n", | |
586 | hpet_tbl->id, hpet_address); | |
587 | } | |
588 | #endif /* X86 */ | |
589 | ||
590 | return 0; | |
591 | } | |
592 | #else | |
593 | #define acpi_parse_hpet NULL | |
594 | #endif | |
595 | ||
596 | #ifdef CONFIG_X86_PM_TIMER | |
597 | extern u32 pmtmr_ioport; | |
598 | #endif | |
599 | ||
600 | static int __init acpi_parse_fadt(unsigned long phys, unsigned long size) | |
601 | { | |
602 | struct fadt_descriptor_rev2 *fadt = NULL; | |
603 | ||
604 | fadt = (struct fadt_descriptor_rev2*) __acpi_map_table(phys,size); | |
605 | if(!fadt) { | |
606 | printk(KERN_WARNING PREFIX "Unable to map FADT\n"); | |
607 | return 0; | |
608 | } | |
609 | ||
610 | #ifdef CONFIG_ACPI_INTERPRETER | |
611 | /* initialize sci_int early for INT_SRC_OVR MADT parsing */ | |
612 | acpi_fadt.sci_int = fadt->sci_int; | |
613 | #endif | |
614 | ||
15e88699 | 615 | #ifdef CONFIG_ACPI_BUS |
90660ec3 JD |
616 | /* initialize rev and apic_phys_dest_mode for x86_64 genapic */ |
617 | acpi_fadt.revision = fadt->revision; | |
618 | acpi_fadt.force_apic_physical_destination_mode = fadt->force_apic_physical_destination_mode; | |
15e88699 | 619 | #endif |
90660ec3 | 620 | |
1da177e4 LT |
621 | #ifdef CONFIG_X86_PM_TIMER |
622 | /* detect the location of the ACPI PM Timer */ | |
623 | if (fadt->revision >= FADT2_REVISION_ID) { | |
624 | /* FADT rev. 2 */ | |
625 | if (fadt->xpm_tmr_blk.address_space_id != ACPI_ADR_SPACE_SYSTEM_IO) | |
626 | return 0; | |
627 | ||
628 | pmtmr_ioport = fadt->xpm_tmr_blk.address; | |
629 | } else { | |
630 | /* FADT rev. 1 */ | |
631 | pmtmr_ioport = fadt->V1_pm_tmr_blk; | |
632 | } | |
633 | if (pmtmr_ioport) | |
634 | printk(KERN_INFO PREFIX "PM-Timer IO Port: %#x\n", pmtmr_ioport); | |
635 | #endif | |
636 | return 0; | |
637 | } | |
638 | ||
639 | ||
640 | unsigned long __init | |
641 | acpi_find_rsdp (void) | |
642 | { | |
643 | unsigned long rsdp_phys = 0; | |
644 | ||
645 | if (efi_enabled) { | |
646 | if (efi.acpi20) | |
647 | return __pa(efi.acpi20); | |
648 | else if (efi.acpi) | |
649 | return __pa(efi.acpi); | |
650 | } | |
651 | /* | |
652 | * Scan memory looking for the RSDP signature. First search EBDA (low | |
653 | * memory) paragraphs and then search upper memory (E0000-FFFFF). | |
654 | */ | |
655 | rsdp_phys = acpi_scan_rsdp (0, 0x400); | |
656 | if (!rsdp_phys) | |
22490eb8 | 657 | rsdp_phys = acpi_scan_rsdp (0xE0000, 0x20000); |
1da177e4 LT |
658 | |
659 | return rsdp_phys; | |
660 | } | |
661 | ||
662 | #ifdef CONFIG_X86_LOCAL_APIC | |
663 | /* | |
664 | * Parse LAPIC entries in MADT | |
665 | * returns 0 on success, < 0 on error | |
666 | */ | |
667 | static int __init | |
668 | acpi_parse_madt_lapic_entries(void) | |
669 | { | |
670 | int count; | |
671 | ||
672 | /* | |
673 | * Note that the LAPIC address is obtained from the MADT (32-bit value) | |
674 | * and (optionally) overriden by a LAPIC_ADDR_OVR entry (64-bit value). | |
675 | */ | |
676 | ||
677 | count = acpi_table_parse_madt(ACPI_MADT_LAPIC_ADDR_OVR, acpi_parse_lapic_addr_ovr, 0); | |
678 | if (count < 0) { | |
679 | printk(KERN_ERR PREFIX "Error parsing LAPIC address override entry\n"); | |
680 | return count; | |
681 | } | |
682 | ||
683 | mp_register_lapic_address(acpi_lapic_addr); | |
684 | ||
685 | count = acpi_table_parse_madt(ACPI_MADT_LAPIC, acpi_parse_lapic, | |
686 | MAX_APICS); | |
687 | if (!count) { | |
688 | printk(KERN_ERR PREFIX "No LAPIC entries present\n"); | |
689 | /* TBD: Cleanup to allow fallback to MPS */ | |
690 | return -ENODEV; | |
691 | } | |
692 | else if (count < 0) { | |
693 | printk(KERN_ERR PREFIX "Error parsing LAPIC entry\n"); | |
694 | /* TBD: Cleanup to allow fallback to MPS */ | |
695 | return count; | |
696 | } | |
697 | ||
698 | count = acpi_table_parse_madt(ACPI_MADT_LAPIC_NMI, acpi_parse_lapic_nmi, 0); | |
699 | if (count < 0) { | |
700 | printk(KERN_ERR PREFIX "Error parsing LAPIC NMI entry\n"); | |
701 | /* TBD: Cleanup to allow fallback to MPS */ | |
702 | return count; | |
703 | } | |
704 | return 0; | |
705 | } | |
706 | #endif /* CONFIG_X86_LOCAL_APIC */ | |
707 | ||
708 | #if defined(CONFIG_X86_IO_APIC) && defined(CONFIG_ACPI_INTERPRETER) | |
709 | /* | |
710 | * Parse IOAPIC related entries in MADT | |
711 | * returns 0 on success, < 0 on error | |
712 | */ | |
713 | static int __init | |
714 | acpi_parse_madt_ioapic_entries(void) | |
715 | { | |
716 | int count; | |
717 | ||
718 | /* | |
719 | * ACPI interpreter is required to complete interrupt setup, | |
720 | * so if it is off, don't enumerate the io-apics with ACPI. | |
721 | * If MPS is present, it will handle them, | |
722 | * otherwise the system will stay in PIC mode | |
723 | */ | |
724 | if (acpi_disabled || acpi_noirq) { | |
725 | return -ENODEV; | |
726 | } | |
727 | ||
728 | /* | |
729 | * if "noapic" boot option, don't look for IO-APICs | |
730 | */ | |
731 | if (skip_ioapic_setup) { | |
732 | printk(KERN_INFO PREFIX "Skipping IOAPIC probe " | |
733 | "due to 'noapic' option.\n"); | |
734 | return -ENODEV; | |
735 | } | |
736 | ||
737 | count = acpi_table_parse_madt(ACPI_MADT_IOAPIC, acpi_parse_ioapic, MAX_IO_APICS); | |
738 | if (!count) { | |
739 | printk(KERN_ERR PREFIX "No IOAPIC entries present\n"); | |
740 | return -ENODEV; | |
741 | } | |
742 | else if (count < 0) { | |
743 | printk(KERN_ERR PREFIX "Error parsing IOAPIC entry\n"); | |
744 | return count; | |
745 | } | |
746 | ||
747 | count = acpi_table_parse_madt(ACPI_MADT_INT_SRC_OVR, acpi_parse_int_src_ovr, NR_IRQ_VECTORS); | |
748 | if (count < 0) { | |
749 | printk(KERN_ERR PREFIX "Error parsing interrupt source overrides entry\n"); | |
750 | /* TBD: Cleanup to allow fallback to MPS */ | |
751 | return count; | |
752 | } | |
753 | ||
754 | /* | |
755 | * If BIOS did not supply an INT_SRC_OVR for the SCI | |
756 | * pretend we got one so we can set the SCI flags. | |
757 | */ | |
758 | if (!acpi_sci_override_gsi) | |
759 | acpi_sci_ioapic_setup(acpi_fadt.sci_int, 0, 0); | |
760 | ||
761 | /* Fill in identity legacy mapings where no override */ | |
762 | mp_config_acpi_legacy_irqs(); | |
763 | ||
764 | count = acpi_table_parse_madt(ACPI_MADT_NMI_SRC, acpi_parse_nmi_src, NR_IRQ_VECTORS); | |
765 | if (count < 0) { | |
766 | printk(KERN_ERR PREFIX "Error parsing NMI SRC entry\n"); | |
767 | /* TBD: Cleanup to allow fallback to MPS */ | |
768 | return count; | |
769 | } | |
770 | ||
771 | return 0; | |
772 | } | |
773 | #else | |
774 | static inline int acpi_parse_madt_ioapic_entries(void) | |
775 | { | |
776 | return -1; | |
777 | } | |
778 | #endif /* !(CONFIG_X86_IO_APIC && CONFIG_ACPI_INTERPRETER) */ | |
779 | ||
780 | ||
781 | static void __init | |
782 | acpi_process_madt(void) | |
783 | { | |
784 | #ifdef CONFIG_X86_LOCAL_APIC | |
785 | int count, error; | |
786 | ||
787 | count = acpi_table_parse(ACPI_APIC, acpi_parse_madt); | |
788 | if (count >= 1) { | |
789 | ||
790 | /* | |
791 | * Parse MADT LAPIC entries | |
792 | */ | |
793 | error = acpi_parse_madt_lapic_entries(); | |
794 | if (!error) { | |
795 | acpi_lapic = 1; | |
796 | ||
797 | /* | |
798 | * Parse MADT IO-APIC entries | |
799 | */ | |
800 | error = acpi_parse_madt_ioapic_entries(); | |
801 | if (!error) { | |
802 | acpi_irq_model = ACPI_IRQ_MODEL_IOAPIC; | |
803 | acpi_irq_balance_set(NULL); | |
804 | acpi_ioapic = 1; | |
805 | ||
806 | smp_found_config = 1; | |
807 | clustered_apic_check(); | |
808 | } | |
809 | } | |
810 | if (error == -EINVAL) { | |
811 | /* | |
812 | * Dell Precision Workstation 410, 610 come here. | |
813 | */ | |
814 | printk(KERN_ERR PREFIX "Invalid BIOS MADT, disabling ACPI\n"); | |
815 | disable_acpi(); | |
816 | } | |
817 | } | |
818 | #endif | |
819 | return; | |
820 | } | |
821 | ||
822 | /* | |
823 | * acpi_boot_table_init() and acpi_boot_init() | |
824 | * called from setup_arch(), always. | |
825 | * 1. checksums all tables | |
826 | * 2. enumerates lapics | |
827 | * 3. enumerates io-apics | |
828 | * | |
829 | * acpi_table_init() is separate to allow reading SRAT without | |
830 | * other side effects. | |
831 | * | |
832 | * side effects of acpi_boot_init: | |
833 | * acpi_lapic = 1 if LAPIC found | |
834 | * acpi_ioapic = 1 if IOAPIC found | |
835 | * if (acpi_lapic && acpi_ioapic) smp_found_config = 1; | |
836 | * if acpi_blacklisted() acpi_disabled = 1; | |
837 | * acpi_irq_model=... | |
838 | * ... | |
839 | * | |
840 | * return value: (currently ignored) | |
841 | * 0: success | |
842 | * !0: failure | |
843 | */ | |
844 | ||
845 | int __init | |
846 | acpi_boot_table_init(void) | |
847 | { | |
848 | int error; | |
849 | ||
850 | /* | |
851 | * If acpi_disabled, bail out | |
852 | * One exception: acpi=ht continues far enough to enumerate LAPICs | |
853 | */ | |
854 | if (acpi_disabled && !acpi_ht) | |
855 | return 1; | |
856 | ||
857 | /* | |
858 | * Initialize the ACPI boot-time table parser. | |
859 | */ | |
860 | error = acpi_table_init(); | |
861 | if (error) { | |
862 | disable_acpi(); | |
863 | return error; | |
864 | } | |
865 | ||
866 | #ifdef __i386__ | |
867 | check_acpi_pci(); | |
868 | #endif | |
869 | ||
870 | acpi_table_parse(ACPI_BOOT, acpi_parse_sbf); | |
871 | ||
872 | /* | |
873 | * blacklist may disable ACPI entirely | |
874 | */ | |
875 | error = acpi_blacklisted(); | |
876 | if (error) { | |
877 | extern int acpi_force; | |
878 | ||
879 | if (acpi_force) { | |
880 | printk(KERN_WARNING PREFIX "acpi=force override\n"); | |
881 | } else { | |
882 | printk(KERN_WARNING PREFIX "Disabling ACPI support\n"); | |
883 | disable_acpi(); | |
884 | return error; | |
885 | } | |
886 | } | |
887 | ||
888 | return 0; | |
889 | } | |
890 | ||
891 | ||
892 | int __init acpi_boot_init(void) | |
893 | { | |
894 | /* | |
895 | * If acpi_disabled, bail out | |
896 | * One exception: acpi=ht continues far enough to enumerate LAPICs | |
897 | */ | |
898 | if (acpi_disabled && !acpi_ht) | |
899 | return 1; | |
900 | ||
901 | acpi_table_parse(ACPI_BOOT, acpi_parse_sbf); | |
902 | ||
903 | /* | |
904 | * set sci_int and PM timer address | |
905 | */ | |
906 | acpi_table_parse(ACPI_FADT, acpi_parse_fadt); | |
907 | ||
908 | /* | |
909 | * Process the Multiple APIC Description Table (MADT), if present | |
910 | */ | |
911 | acpi_process_madt(); | |
912 | ||
913 | acpi_table_parse(ACPI_HPET, acpi_parse_hpet); | |
914 | acpi_table_parse(ACPI_MCFG, acpi_parse_mcfg); | |
915 | ||
916 | return 0; | |
917 | } | |
918 |