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