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