]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/x86/kernel/acpi/boot.c
x86: remove unnecessary memset and NULL check after alloc_bootmem()
[linux-2.6-omap-h63xx.git] / arch / x86 / kernel / acpi / boot.c
index fc8825d4b996f43fbd5f2b2fffc041982cbfd941..977ed5cdeaa3b1b6a8d5f78b3446df7be7e21b53 100644 (file)
 #include <asm/apic.h>
 #include <asm/io.h>
 #include <asm/mpspec.h>
+#include <asm/smp.h>
+
+#ifdef CONFIG_X86_LOCAL_APIC
+# include <mach_apic.h>
+#endif
 
 static int __initdata acpi_force = 0;
 
@@ -52,9 +57,7 @@ EXPORT_SYMBOL(acpi_disabled);
 #ifdef CONFIG_X86_64
 
 #include <asm/proto.h>
-
-static inline int acpi_madt_oem_check(char *oem_id, char *oem_table_id) { return 0; }
-
+#include <asm/genapic.h>
 
 #else                          /* X86 */
 
@@ -72,13 +75,13 @@ static inline int acpi_madt_oem_check(char *oem_id, char *oem_table_id) { return
 #define PREFIX                 "ACPI: "
 
 int acpi_noirq;                                /* skip ACPI IRQ initialization */
-int acpi_pci_disabled __initdata;      /* skip ACPI PCI scan and IRQ initialization */
+int acpi_pci_disabled;         /* skip ACPI PCI scan and IRQ initialization */
+EXPORT_SYMBOL(acpi_pci_disabled);
 int acpi_ht __initdata = 1;    /* enable HT */
 
 int acpi_lapic;
 int acpi_ioapic;
 int acpi_strict;
-EXPORT_SYMBOL(acpi_strict);
 
 u8 acpi_sci_flags __initdata;
 int acpi_sci_override_gsi __initdata;
@@ -106,12 +109,12 @@ enum acpi_irq_model_id acpi_irq_model = ACPI_IRQ_MODEL_PIC;
 #ifdef CONFIG_X86_64
 
 /* rely on all ACPI tables being in the direct mapping */
-char *__acpi_map_table(unsigned long phys_addr, unsigned long size)
+char *__init __acpi_map_table(unsigned long phys_addr, unsigned long size)
 {
        if (!phys_addr || !size)
                return NULL;
 
-       if (phys_addr+size <= (end_pfn_map << PAGE_SHIFT) + PAGE_SIZE)
+       if (phys_addr+size <= (max_pfn_mapped << PAGE_SHIFT) + PAGE_SIZE)
                return __va(phys_addr);
 
        return NULL;
@@ -131,7 +134,7 @@ char *__acpi_map_table(unsigned long phys_addr, unsigned long size)
  * from the fixed base.  That's why we start at FIX_IO_APIC_BASE_END and
  * count idx down while incrementing the phys address.
  */
-char *__acpi_map_table(unsigned long phys, unsigned long size)
+char *__init __acpi_map_table(unsigned long phys, unsigned long size)
 {
        unsigned long base, offset, mapped_size;
        int idx;
@@ -237,6 +240,16 @@ static int __init acpi_parse_madt(struct acpi_table_header *table)
        return 0;
 }
 
+static void __cpuinit acpi_register_lapic(int id, u8 enabled)
+{
+       if (!enabled) {
+               ++disabled_cpus;
+               return;
+       }
+
+       generic_processor_info(id, 0);
+}
+
 static int __init
 acpi_parse_lapic(struct acpi_subtable_header * header, const unsigned long end)
 {
@@ -256,8 +269,26 @@ acpi_parse_lapic(struct acpi_subtable_header * header, const unsigned long end)
         * to not preallocating memory for all NR_CPUS
         * when we use CPU hotplug.
         */
-       mp_register_lapic(processor->id,        /* APIC ID */
-                         processor->lapic_flags & ACPI_MADT_ENABLED);  /* Enabled? */
+       acpi_register_lapic(processor->id,      /* APIC ID */
+                           processor->lapic_flags & ACPI_MADT_ENABLED);
+
+       return 0;
+}
+
+static int __init
+acpi_parse_sapic(struct acpi_subtable_header *header, const unsigned long end)
+{
+       struct acpi_madt_local_sapic *processor = NULL;
+
+       processor = (struct acpi_madt_local_sapic *)header;
+
+       if (BAD_MADT_ENTRY(processor, end))
+               return -EINVAL;
+
+       acpi_table_print_madt_entry(header);
+
+       acpi_register_lapic((processor->id << 8) | processor->eid,/* APIC ID */
+                           processor->lapic_flags & ACPI_MADT_ENABLED);
 
        return 0;
 }
@@ -300,6 +331,8 @@ acpi_parse_lapic_nmi(struct acpi_subtable_header * header, const unsigned long e
 
 #ifdef CONFIG_X86_IO_APIC
 
+struct mp_ioapic_routing mp_ioapic_routing[MAX_IO_APICS];
+
 static int __init
 acpi_parse_ioapic(struct acpi_subtable_header * header, const unsigned long end)
 {
@@ -490,8 +523,6 @@ int acpi_register_gsi(u32 gsi, int triggering, int polarity)
        return irq;
 }
 
-EXPORT_SYMBOL(acpi_register_gsi);
-
 /*
  *  ACPI based hotplug support for CPU
  */
@@ -534,7 +565,7 @@ static int __cpuinit _acpi_map_lsapic(acpi_handle handle, int *pcpu)
        buffer.pointer = NULL;
 
        tmp_map = cpu_present_map;
-       mp_register_lapic(physid, lapic->lapic_flags & ACPI_MADT_ENABLED);
+       acpi_register_lapic(physid, lapic->lapic_flags & ACPI_MADT_ENABLED);
 
        /*
         * If mp_register_lapic successfully generates a new logical cpu
@@ -666,10 +697,6 @@ static int __init acpi_parse_hpet(struct acpi_table_header *table)
 #define HPET_RESOURCE_NAME_SIZE 9
        hpet_res = alloc_bootmem(sizeof(*hpet_res) + HPET_RESOURCE_NAME_SIZE);
 
-       if (!hpet_res)
-               return 0;
-
-       memset(hpet_res, 0, sizeof(*hpet_res));
        hpet_res->name = (void *)&hpet_res[1];
        hpet_res->flags = IORESOURCE_MEM;
        snprintf((char *)hpet_res->name, HPET_RESOURCE_NAME_SIZE, "HPET %u",
@@ -734,6 +761,16 @@ static int __init acpi_parse_fadt(struct acpi_table_header *table)
  * Parse LAPIC entries in MADT
  * returns 0 on success, < 0 on error
  */
+
+static void __init acpi_register_lapic_address(unsigned long address)
+{
+       mp_lapic_addr = address;
+
+       set_fixmap_nocache(FIX_APIC_BASE, address);
+       if (boot_cpu_physical_apicid == -1U)
+               boot_cpu_physical_apicid  = GET_APIC_ID(read_apic_id());
+}
+
 static int __init acpi_parse_madt_lapic_entries(void)
 {
        int count;
@@ -755,10 +792,14 @@ static int __init acpi_parse_madt_lapic_entries(void)
                return count;
        }
 
-       mp_register_lapic_address(acpi_lapic_addr);
+       acpi_register_lapic_address(acpi_lapic_addr);
+
+       count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_SAPIC,
+                                     acpi_parse_sapic, MAX_APICS);
 
-       count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC, acpi_parse_lapic,
-                                     MAX_APICS);
+       if (!count)
+               count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC,
+                                             acpi_parse_lapic, MAX_APICS);
        if (!count) {
                printk(KERN_ERR PREFIX "No LAPIC entries present\n");
                /* TBD: Cleanup to allow fallback to MPS */