ACPICA: Remove duplicate table manager
[sfrench/cifs-2.6.git] / arch / i386 / kernel / acpi / boot.c
index 22e4c466e5a3632b74a740d5a9f3111e8d36b3ad..543eac5da176d06b3c43729bf0958cb5c3b15bb0 100644 (file)
@@ -82,6 +82,7 @@ EXPORT_SYMBOL(acpi_strict);
 acpi_interrupt_flags acpi_sci_flags __initdata;
 int acpi_sci_override_gsi __initdata;
 int acpi_skip_timer_override __initdata;
+int acpi_use_timer_override __initdata;
 
 #ifdef CONFIG_X86_LOCAL_APIC
 static u64 acpi_lapic_addr __initdata = APIC_DEFAULT_PHYS_BASE;
@@ -168,16 +169,16 @@ char *__acpi_map_table(unsigned long phys, unsigned long size)
 struct acpi_table_mcfg_config *pci_mmcfg_config;
 int pci_mmcfg_config_num;
 
-int __init acpi_parse_mcfg(unsigned long phys_addr, unsigned long size)
+int __init acpi_parse_mcfg(struct acpi_table_header *header)
 {
        struct acpi_table_mcfg *mcfg;
        unsigned long i;
        int config_size;
 
-       if (!phys_addr || !size)
+       if (!header)
                return -EINVAL;
 
-       mcfg = (struct acpi_table_mcfg *)__acpi_map_table(phys_addr, size);
+       mcfg = (struct acpi_table_mcfg *)header;
        if (!mcfg) {
                printk(KERN_WARNING PREFIX "Unable to map MCFG\n");
                return -ENODEV;
@@ -185,7 +186,7 @@ int __init acpi_parse_mcfg(unsigned long phys_addr, unsigned long size)
 
        /* how many config structures do we have */
        pci_mmcfg_config_num = 0;
-       i = size - sizeof(struct acpi_table_mcfg);
+       i = header->length - sizeof(struct acpi_table_mcfg);
        while (i >= sizeof(struct acpi_table_mcfg_config)) {
                ++pci_mmcfg_config_num;
                i -= sizeof(struct acpi_table_mcfg_config);
@@ -219,14 +220,14 @@ int __init acpi_parse_mcfg(unsigned long phys_addr, unsigned long size)
 #endif                         /* CONFIG_PCI_MMCONFIG */
 
 #ifdef CONFIG_X86_LOCAL_APIC
-static int __init acpi_parse_madt(unsigned long phys_addr, unsigned long size)
+static int __init acpi_parse_madt(struct acpi_table_header *header)
 {
        struct acpi_table_madt *madt = NULL;
 
-       if (!phys_addr || !size || !cpu_has_apic)
+       if (!header|| !cpu_has_apic)
                return -EINVAL;
 
-       madt = (struct acpi_table_madt *)__acpi_map_table(phys_addr, size);
+       madt = (struct acpi_table_madt *)header;
        if (!madt) {
                printk(KERN_WARNING PREFIX "Unable to map MADT\n");
                return -ENODEV;
@@ -332,7 +333,7 @@ acpi_parse_ioapic(acpi_table_entry_header * header, const unsigned long end)
 /*
  * Parse Interrupt Source Override for the ACPI SCI
  */
-static void acpi_sci_ioapic_setup(u32 bus_irq, u32 gsi, u16 polarity, u16 trigger)
+static void __init acpi_sci_ioapic_setup(u32 gsi, u16 polarity, u16 trigger)
 {
        if (trigger == 0)       /* compatible SCI trigger is level */
                trigger = 3;
@@ -352,13 +353,13 @@ static void acpi_sci_ioapic_setup(u32 bus_irq, u32 gsi, u16 polarity, u16 trigge
         * If GSI is < 16, this will update its flags,
         * else it will create a new mp_irqs[] entry.
         */
-       mp_override_legacy_irq(bus_irq, polarity, trigger, gsi);
+       mp_override_legacy_irq(gsi, polarity, trigger, gsi);
 
        /*
         * stash over-ride to indicate we've been here
         * and for later update of acpi_fadt
         */
-       acpi_sci_override_gsi = bus_irq;
+       acpi_sci_override_gsi = gsi;
        return;
 }
 
@@ -376,7 +377,7 @@ acpi_parse_int_src_ovr(acpi_table_entry_header * header,
        acpi_table_print_madt_entry(header);
 
        if (intsrc->bus_irq == acpi_fadt.sci_int) {
-               acpi_sci_ioapic_setup(intsrc->bus_irq, intsrc->global_irq,
+               acpi_sci_ioapic_setup(intsrc->global_irq,
                                      intsrc->flags.polarity,
                                      intsrc->flags.trigger);
                return 0;
@@ -618,14 +619,14 @@ acpi_scan_rsdp(unsigned long start, unsigned long length)
        return 0;
 }
 
-static int __init acpi_parse_sbf(unsigned long phys_addr, unsigned long size)
+static int __init acpi_parse_sbf(struct acpi_table_header *header)
 {
        struct acpi_table_sbf *sb;
 
-       if (!phys_addr || !size)
+       if (!header)
                return -EINVAL;
 
-       sb = (struct acpi_table_sbf *)__acpi_map_table(phys_addr, size);
+       sb = (struct acpi_table_sbf *)header;
        if (!sb) {
                printk(KERN_WARNING PREFIX "Unable to map SBF\n");
                return -ENODEV;
@@ -638,16 +639,16 @@ static int __init acpi_parse_sbf(unsigned long phys_addr, unsigned long size)
 
 #ifdef CONFIG_HPET_TIMER
 
-static int __init acpi_parse_hpet(unsigned long phys, unsigned long size)
+static int __init acpi_parse_hpet(struct acpi_table_header *header)
 {
        struct acpi_table_hpet *hpet_tbl;
        struct resource *hpet_res;
        resource_size_t res_start;
 
-       if (!phys || !size)
+       if (!header)
                return -EINVAL;
 
-       hpet_tbl = (struct acpi_table_hpet *)__acpi_map_table(phys, size);
+       hpet_tbl = (struct acpi_table_hpet *)header;
        if (!hpet_tbl) {
                printk(KERN_WARNING PREFIX "Unable to map HPET\n");
                return -ENODEV;
@@ -706,42 +707,35 @@ static int __init acpi_parse_hpet(unsigned long phys, unsigned long size)
 extern u32 pmtmr_ioport;
 #endif
 
-static int __init acpi_parse_fadt(unsigned long phys, unsigned long size)
+static int __init acpi_parse_fadt(struct acpi_table_header *header)
 {
        struct fadt_descriptor *fadt = NULL;
 
-       fadt = (struct fadt_descriptor *)__acpi_map_table(phys, size);
+       fadt = (struct fadt_descriptor *)header;
        if (!fadt) {
                printk(KERN_WARNING PREFIX "Unable to map FADT\n");
                return 0;
        }
-       /* initialize sci_int early for INT_SRC_OVR MADT parsing */
-       acpi_fadt.sci_int = fadt->sci_int;
-
-       /* initialize rev and apic_phys_dest_mode for x86_64 genapic */
-       acpi_fadt.revision = fadt->revision;
-       acpi_fadt.force_apic_physical_destination_mode =
-           fadt->force_apic_physical_destination_mode;
 
 #ifdef CONFIG_X86_PM_TIMER
        /* detect the location of the ACPI PM Timer */
-       if (fadt->revision >= FADT2_REVISION_ID) {
+       if (fadt->header.revision >= FADT2_REVISION_ID) {
                /* FADT rev. 2 */
-               if (fadt->xpm_tmr_blk.address_space_id !=
+               if (fadt->xpm_timer_block.space_id !=
                    ACPI_ADR_SPACE_SYSTEM_IO)
                        return 0;
 
-               pmtmr_ioport = fadt->xpm_tmr_blk.address;
+               pmtmr_ioport = fadt->xpm_timer_block.address;
                /*
                 * "X" fields are optional extensions to the original V1.0
                 * fields, so we must selectively expand V1.0 fields if the
                 * corresponding X field is zero.
                 */
                if (!pmtmr_ioport)
-                       pmtmr_ioport = fadt->V1_pm_tmr_blk;
+                       pmtmr_ioport = fadt->pm_timer_block;
        } else {
                /* FADT rev. 1 */
-               pmtmr_ioport = fadt->V1_pm_tmr_blk;
+               pmtmr_ioport = fadt->pm_timer_block;
        }
        if (pmtmr_ioport)
                printk(KERN_INFO PREFIX "PM-Timer IO Port: %#x\n",
@@ -879,7 +873,7 @@ static int __init acpi_parse_madt_ioapic_entries(void)
         * pretend we got one so we can set the SCI flags.
         */
        if (!acpi_sci_override_gsi)
-               acpi_sci_ioapic_setup(acpi_fadt.sci_int, acpi_fadt.sci_int, 0, 0);
+               acpi_sci_ioapic_setup(acpi_fadt.sci_int, 0, 0);
 
        /* Fill in identity legacy mapings where no override */
        mp_config_acpi_legacy_irqs();
@@ -907,7 +901,7 @@ static void __init acpi_process_madt(void)
 #ifdef CONFIG_X86_LOCAL_APIC
        int count, error;
 
-       count = acpi_table_parse(ACPI_APIC, acpi_parse_madt);
+       count = acpi_table_parse("APIC", acpi_parse_madt);
        if (count >= 1) {
 
                /*
@@ -1203,7 +1197,7 @@ int __init acpi_boot_table_init(void)
                return error;
        }
 
-       acpi_table_parse(ACPI_BOOT, acpi_parse_sbf);
+       acpi_table_parse("BOOT", acpi_parse_sbf);
 
        /*
         * blacklist may disable ACPI entirely
@@ -1231,19 +1225,19 @@ int __init acpi_boot_init(void)
        if (acpi_disabled && !acpi_ht)
                return 1;
 
-       acpi_table_parse(ACPI_BOOT, acpi_parse_sbf);
+       acpi_table_parse("BOOT", acpi_parse_sbf);
 
        /*
         * set sci_int and PM timer address
         */
-       acpi_table_parse(ACPI_FADT, acpi_parse_fadt);
+       acpi_table_parse(ACPI_SIG_FADT, acpi_parse_fadt);
 
        /*
         * Process the Multiple APIC Description Table (MADT), if present
         */
        acpi_process_madt();
 
-       acpi_table_parse(ACPI_HPET, acpi_parse_hpet);
+       acpi_table_parse("HPET", acpi_parse_hpet);
 
        return 0;
 }
@@ -1300,6 +1294,13 @@ static int __init parse_acpi_skip_timer_override(char *arg)
        return 0;
 }
 early_param("acpi_skip_timer_override", parse_acpi_skip_timer_override);
+
+static int __init parse_acpi_use_timer_override(char *arg)
+{
+       acpi_use_timer_override = 1;
+       return 0;
+}
+early_param("acpi_use_timer_override", parse_acpi_use_timer_override);
 #endif /* CONFIG_X86_IO_APIC */
 
 static int __init setup_acpi_sci(char *s)
@@ -1319,3 +1320,25 @@ static int __init setup_acpi_sci(char *s)
        return 0;
 }
 early_param("acpi_sci", setup_acpi_sci);
+
+int __acpi_acquire_global_lock(unsigned int *lock)
+{
+       unsigned int old, new, val;
+       do {
+               old = *lock;
+               new = (((old & ~0x3) + 2) + ((old >> 1) & 0x1));
+               val = cmpxchg(lock, old, new);
+       } while (unlikely (val != old));
+       return (new < 3) ? -1 : 0;
+}
+
+int __acpi_release_global_lock(unsigned int *lock)
+{
+       unsigned int old, new, val;
+       do {
+               old = *lock;
+               new = old & ~0x3;
+               val = cmpxchg(lock, old, new);
+       } while (unlikely (val != old));
+       return old & 0x1;
+}