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