Index: sys/amd64/acpica/madt.c =================================================================== RCS file: /home/ncvs/src/sys/amd64/acpica/madt.c,v retrieving revision 1.21 diff -u -r1.21 madt.c --- sys/amd64/acpica/madt.c 11 Aug 2006 19:22:55 -0000 1.21 +++ sys/amd64/acpica/madt.c 22 Feb 2007 23:57:56 -0000 @@ -56,7 +56,7 @@ #define NIOAPICS 32 /* Max number of I/O APICs */ #define NLAPICS 32 /* Max number of local APICs */ -typedef void madt_entry_handler(APIC_HEADER *entry, void *arg); +typedef void madt_entry_handler(ACPI_SUBTABLE_HEADER *entry, void *arg); /* These two arrays are indexed by APIC IDs. */ struct ioapic_info { @@ -70,7 +70,7 @@ } lapics[NLAPICS]; static int madt_found_sci_override; -static MULTIPLE_APIC_TABLE *madt; +static ACPI_TABLE_MADT *madt; static vm_paddr_t madt_physaddr; static vm_offset_t madt_length; @@ -82,14 +82,17 @@ static int madt_find_interrupt(int intr, void **apic, u_int *pin); static void *madt_map(vm_paddr_t pa, int offset, vm_offset_t length); static void *madt_map_table(vm_paddr_t pa, int offset, const char *sig); -static void madt_parse_apics(APIC_HEADER *entry, void *arg); -static void madt_parse_interrupt_override(MADT_INTERRUPT_OVERRIDE *intr); -static void madt_parse_ints(APIC_HEADER *entry, void *arg __unused); -static void madt_parse_local_nmi(MADT_LOCAL_APIC_NMI *nmi); -static void madt_parse_nmi(MADT_NMI_SOURCE *nmi); +static void madt_parse_apics(ACPI_SUBTABLE_HEADER *entry, void *arg); +static void madt_parse_interrupt_override( + ACPI_MADT_INTERRUPT_OVERRIDE *intr); +static void madt_parse_ints(ACPI_SUBTABLE_HEADER *entry, + void *arg __unused); +static void madt_parse_local_nmi(ACPI_MADT_LOCAL_APIC_NMI *nmi); +static void madt_parse_nmi(ACPI_MADT_NMI_SOURCE *nmi); static int madt_probe(void); static int madt_probe_cpus(void); -static void madt_probe_cpus_handler(APIC_HEADER *entry, void *arg __unused); +static void madt_probe_cpus_handler(ACPI_SUBTABLE_HEADER *entry, + void *arg __unused); static int madt_probe_table(vm_paddr_t address); static void madt_register(void *dummy); static int madt_setup_local(void); @@ -161,14 +164,14 @@ void *table; header = madt_map(pa, offset, sizeof(ACPI_TABLE_HEADER)); - if (strncmp(header->Signature, sig, 4) != 0) { + if (strncmp(header->Signature, sig, ACPI_NAME_SIZE) != 0) { madt_unmap(header, sizeof(ACPI_TABLE_HEADER)); return (NULL); } length = header->Length; madt_unmap(header, sizeof(ACPI_TABLE_HEADER)); table = madt_map(pa, offset, length); - if (ACPI_FAILURE(AcpiTbVerifyTableChecksum(table))) { + if (ACPI_FAILURE(AcpiTbChecksum(table, length))) { if (bootverbose) printf("MADT: Failed checksum for table %s\n", sig); madt_unmap(table, length); @@ -192,10 +195,10 @@ static int madt_probe(void) { - ACPI_POINTER rsdp_ptr; - RSDP_DESCRIPTOR *rsdp; - RSDT_DESCRIPTOR *rsdt; - XSDT_DESCRIPTOR *xsdt; + ACPI_PHYSICAL_ADDRESS rsdp_ptr; + ACPI_TABLE_RSDP *rsdp; + ACPI_TABLE_RSDT *rsdt; + ACPI_TABLE_XSDT *xsdt; int i, count; if (resource_disabled("acpi", 0)) @@ -206,12 +209,12 @@ * calls pmap_mapbios() to find the RSDP, we assume that we can use * pmap_mapbios() to map the RSDP. */ - if (AcpiOsGetRootPointer(ACPI_LOGICAL_ADDRESSING, &rsdp_ptr) != AE_OK) + if ((rsdp_ptr = AcpiOsGetRootPointer()) == 0) return (ENXIO); #ifdef __i386__ - KASSERT(rsdp_ptr.Pointer.Physical < KERNLOAD, ("RSDP too high")); + KASSERT(rsdp_ptr < KERNLOAD, ("RSDP too high")); #endif - rsdp = pmap_mapbios(rsdp_ptr.Pointer.Physical, sizeof(RSDP_DESCRIPTOR)); + rsdp = pmap_mapbios(rsdp_ptr, sizeof(ACPI_TABLE_RSDP)); if (rsdp == NULL) { if (bootverbose) printf("MADT: Failed to map RSDP\n"); @@ -230,38 +233,40 @@ * the version 1.0 portion of the RSDP. Version 2.0 has * an additional checksum that we verify first. */ - if (AcpiTbGenerateChecksum(rsdp, ACPI_RSDP_XCHECKSUM_LENGTH)) { + if (AcpiTbChecksum((UINT8 *)rsdp, ACPI_RSDP_XCHECKSUM_LENGTH)) { if (bootverbose) printf("MADT: RSDP failed extended checksum\n"); return (ENXIO); } - xsdt = madt_map_table(rsdp->XsdtPhysicalAddress, 1, XSDT_SIG); + xsdt = madt_map_table(rsdp->XsdtPhysicalAddress, 1, + ACPI_SIG_XSDT); if (xsdt == NULL) { if (bootverbose) printf("MADT: Failed to map XSDT\n"); return (ENXIO); } - count = (xsdt->Length - sizeof(ACPI_TABLE_HEADER)) / + count = (xsdt->Header.Length - sizeof(ACPI_TABLE_HEADER)) / sizeof(UINT64); for (i = 0; i < count; i++) if (madt_probe_table(xsdt->TableOffsetEntry[i])) break; madt_unmap_table(xsdt); } else { - rsdt = madt_map_table(rsdp->RsdtPhysicalAddress, 1, RSDT_SIG); + rsdt = madt_map_table(rsdp->RsdtPhysicalAddress, 1, + ACPI_SIG_RSDT); if (rsdt == NULL) { if (bootverbose) printf("MADT: Failed to map RSDT\n"); return (ENXIO); } - count = (rsdt->Length - sizeof(ACPI_TABLE_HEADER)) / + count = (rsdt->Header.Length - sizeof(ACPI_TABLE_HEADER)) / sizeof(UINT32); for (i = 0; i < count; i++) if (madt_probe_table(rsdt->TableOffsetEntry[i])) break; madt_unmap_table(rsdt); } - pmap_unmapbios((vm_offset_t)rsdp, sizeof(RSDP_DESCRIPTOR)); + pmap_unmapbios((vm_offset_t)rsdp, sizeof(ACPI_TABLE_RSDP)); if (madt_physaddr == 0) { if (bootverbose) printf("MADT: No MADT table found\n"); @@ -275,7 +280,7 @@ * Verify that we can map the full table and that its checksum is * correct, etc. */ - madt = madt_map_table(madt_physaddr, 0, APIC_SIG); + madt = madt_map_table(madt_physaddr, 0, ACPI_SIG_MADT); if (madt == NULL) return (ENXIO); madt_unmap_table(madt); @@ -303,7 +308,7 @@ printf("Table '%.4s' at 0x%jx\n", table->Signature, (uintmax_t)address); - if (strncmp(table->Signature, APIC_SIG, 4) != 0) { + if (strncmp(table->Signature, ACPI_SIG_MADT, ACPI_NAME_SIZE) != 0) { madt_unmap(table, sizeof(ACPI_TABLE_HEADER)); return (0); } @@ -320,7 +325,7 @@ madt_probe_cpus(void) { - madt = madt_map_table(madt_physaddr, 0, APIC_SIG); + madt = madt_map_table(madt_physaddr, 0, ACPI_SIG_MADT); KASSERT(madt != NULL, ("Unable to re-map MADT")); madt_walk_table(madt_probe_cpus_handler, NULL); madt_unmap_table(madt); @@ -336,10 +341,10 @@ { madt = pmap_mapbios(madt_physaddr, madt_length); - lapic_init((uintptr_t)madt->LocalApicAddress); + lapic_init((uintptr_t)madt->Address); printf("ACPI APIC Table: <%.*s %.*s>\n", - (int)sizeof(madt->OemId), madt->OemId, - (int)sizeof(madt->OemTableId), madt->OemTableId); + (int)sizeof(madt->Header.OemId), madt->Header.OemId, + (int)sizeof(madt->Header.OemTableId), madt->Header.OemTableId); /* * We ignore 64-bit local APIC override entries. Should we @@ -378,10 +383,10 @@ * force it to use level trigger and active-low polarity. */ if (!madt_found_sci_override) { - if (madt_find_interrupt(AcpiGbl_FADT->SciInt, &ioapic, &pin) - != 0) - printf("MADT: Could not find APIC for SCI IRQ %d\n", - AcpiGbl_FADT->SciInt); + if (madt_find_interrupt(AcpiGbl_FADT.SciInterrupt, &ioapic, + &pin) != 0) + printf("MADT: Could not find APIC for SCI IRQ %u\n", + AcpiGbl_FADT.SciInterrupt); else { printf( "MADT: Forcing active-low polarity and level trigger for SCI\n"); @@ -416,46 +421,46 @@ static void madt_walk_table(madt_entry_handler *handler, void *arg) { - APIC_HEADER *entry; + ACPI_SUBTABLE_HEADER *entry; u_char *p, *end; - end = (u_char *)(madt) + madt->Length; + end = (u_char *)(madt) + madt->Header.Length; for (p = (u_char *)(madt + 1); p < end; ) { - entry = (APIC_HEADER *)p; + entry = (ACPI_SUBTABLE_HEADER *)p; handler(entry, arg); p += entry->Length; } } static void -madt_probe_cpus_handler(APIC_HEADER *entry, void *arg) +madt_probe_cpus_handler(ACPI_SUBTABLE_HEADER *entry, void *arg) { - MADT_PROCESSOR_APIC *proc; + ACPI_MADT_LOCAL_APIC *proc; struct lapic_info *la; switch (entry->Type) { - case APIC_PROCESSOR: + case ACPI_MADT_TYPE_LOCAL_APIC: /* * The MADT does not include a BSP flag, so we have to * let the MP code figure out which CPU is the BSP on * its own. */ - proc = (MADT_PROCESSOR_APIC *)entry; + proc = (ACPI_MADT_LOCAL_APIC *)entry; if (bootverbose) - printf("MADT: Found CPU APIC ID %d ACPI ID %d: %s\n", - proc->LocalApicId, proc->ProcessorId, - proc->ProcessorEnabled ? "enabled" : "disabled"); - if (!proc->ProcessorEnabled) + printf("MADT: Found CPU APIC ID %u ACPI ID %u: %s\n", + proc->Id, proc->ProcessorId, + (proc->LapicFlags & ACPI_MADT_ENABLED) ? + "enabled" : "disabled"); + if (!(proc->LapicFlags & ACPI_MADT_ENABLED)) break; - if (proc->LocalApicId >= NLAPICS) - panic("%s: CPU ID %d too high", __func__, - proc->LocalApicId); - la = &lapics[proc->LocalApicId]; + if (proc->Id >= NLAPICS) + panic("%s: CPU ID %u too high", __func__, proc->Id); + la = &lapics[proc->Id]; KASSERT(la->la_enabled == 0, - ("Duplicate local APIC ID %d", proc->LocalApicId)); + ("Duplicate local APIC ID %u", proc->Id)); la->la_enabled = 1; la->la_acpi_id = proc->ProcessorId; - lapic_create(proc->LocalApicId, 0); + lapic_create(proc->Id, 0); break; } } @@ -465,27 +470,26 @@ * Add an I/O APIC from an entry in the table. */ static void -madt_parse_apics(APIC_HEADER *entry, void *arg __unused) +madt_parse_apics(ACPI_SUBTABLE_HEADER *entry, void *arg __unused) { - MADT_IO_APIC *apic; + ACPI_MADT_IO_APIC *apic; switch (entry->Type) { - case APIC_IO: - apic = (MADT_IO_APIC *)entry; + case ACPI_MADT_TYPE_IO_APIC: + apic = (ACPI_MADT_IO_APIC *)entry; if (bootverbose) - printf("MADT: Found IO APIC ID %d, Interrupt %d at %p\n", - apic->IoApicId, apic->Interrupt, + printf( + "MADT: Found IO APIC ID %u, Interrupt %u at %p\n", + apic->Id, apic->GlobalIrqBase, (void *)(uintptr_t)apic->Address); - if (apic->IoApicId >= NIOAPICS) - panic("%s: I/O APIC ID %d too high", __func__, - apic->IoApicId); - if (ioapics[apic->IoApicId].io_apic != NULL) - panic("%s: Double APIC ID %d", __func__, - apic->IoApicId); - ioapics[apic->IoApicId].io_apic = ioapic_create( - (uintptr_t)apic->Address, apic->IoApicId, - apic->Interrupt); - ioapics[apic->IoApicId].io_vector = apic->Interrupt; + if (apic->Id >= NIOAPICS) + panic("%s: I/O APIC ID %u too high", __func__, + apic->Id); + if (ioapics[apic->Id].io_apic != NULL) + panic("%s: Double APIC ID %u", __func__, apic->Id); + ioapics[apic->Id].io_apic = ioapic_create( + (uintptr_t)apic->Address, apic->Id, apic->GlobalIrqBase); + ioapics[apic->Id].io_vector = apic->GlobalIrqBase; break; default: break; @@ -502,15 +506,15 @@ interrupt_polarity(UINT16 Polarity, UINT8 Source) { - switch (Polarity) { - case POLARITY_CONFORMS: - if (Source == AcpiGbl_FADT->SciInt) + switch (Polarity & ACPI_MADT_POLARITY_MASK) { + case ACPI_MADT_POLARITY_CONFORMS: + if (Source == AcpiGbl_FADT.SciInterrupt) return (INTR_POLARITY_LOW); else return (INTR_POLARITY_HIGH); - case POLARITY_ACTIVE_HIGH: + case ACPI_MADT_POLARITY_ACTIVE_HIGH: return (INTR_POLARITY_HIGH); - case POLARITY_ACTIVE_LOW: + case ACPI_MADT_POLARITY_ACTIVE_LOW: return (INTR_POLARITY_LOW); default: panic("Bogus Interrupt Polarity"); @@ -521,15 +525,15 @@ interrupt_trigger(UINT16 TriggerMode, UINT8 Source) { - switch (TriggerMode) { - case TRIGGER_CONFORMS: - if (Source == AcpiGbl_FADT->SciInt) + switch (TriggerMode & ACPI_MADT_TRIGGER_MASK) { + case ACPI_MADT_TRIGGER_CONFORMS: + if (Source == AcpiGbl_FADT.SciInterrupt) return (INTR_TRIGGER_LEVEL); else return (INTR_TRIGGER_EDGE); - case TRIGGER_EDGE: + case ACPI_MADT_TRIGGER_EDGE: return (INTR_TRIGGER_EDGE); - case TRIGGER_LEVEL: + case ACPI_MADT_TRIGGER_LEVEL: return (INTR_TRIGGER_LEVEL); default: panic("Bogus Interrupt Trigger Mode"); @@ -587,7 +591,7 @@ * Parse an interrupt source override for an ISA interrupt. */ static void -madt_parse_interrupt_override(MADT_INTERRUPT_OVERRIDE *intr) +madt_parse_interrupt_override(ACPI_MADT_INTERRUPT_OVERRIDE *intr) { void *new_ioapic, *old_ioapic; u_int new_pin, old_pin; @@ -595,20 +599,19 @@ enum intr_polarity pol; char buf[64]; - if (acpi_quirks & ACPI_Q_MADT_IRQ0 && intr->Source == 0 && - intr->Interrupt == 2) { + if (acpi_quirks & ACPI_Q_MADT_IRQ0 && intr->SourceIrq == 0 && + intr->GlobalIrq == 2) { if (bootverbose) printf("MADT: Skipping timer override\n"); return; } if (bootverbose) printf("MADT: Interrupt override: source %u, irq %u\n", - intr->Source, intr->Interrupt); + intr->SourceIrq, intr->GlobalIrq); KASSERT(intr->Bus == 0, ("bus for interrupt overrides must be zero")); - if (madt_find_interrupt(intr->Interrupt, &new_ioapic, - &new_pin) != 0) { - printf("MADT: Could not find APIC for vector %d (IRQ %d)\n", - intr->Interrupt, intr->Source); + if (madt_find_interrupt(intr->GlobalIrq, &new_ioapic, &new_pin) != 0) { + printf("MADT: Could not find APIC for vector %u (IRQ %u)\n", + intr->GlobalIrq, intr->SourceIrq); return; } @@ -616,15 +619,15 @@ * Lookup the appropriate trigger and polarity modes for this * entry. */ - trig = interrupt_trigger(intr->TriggerMode, intr->Source); - pol = interrupt_polarity(intr->Polarity, intr->Source); + trig = interrupt_trigger(intr->IntiFlags, intr->SourceIrq); + pol = interrupt_polarity(intr->IntiFlags, intr->SourceIrq); /* * If the SCI is identity mapped but has edge trigger and * active-hi polarity or the force_sci_lo tunable is set, * force it to use level/lo. */ - if (intr->Source == AcpiGbl_FADT->SciInt) { + if (intr->SourceIrq == AcpiGbl_FADT.SciInterrupt) { madt_found_sci_override = 1; if (getenv_string("hw.acpi.sci.trigger", buf, sizeof(buf))) { if (tolower(buf[0]) == 'e') @@ -653,23 +656,24 @@ } /* Remap the IRQ if it is mapped to a different interrupt vector. */ - if (intr->Source != intr->Interrupt) { + if (intr->SourceIrq != intr->GlobalIrq) { /* * If the SCI is remapped to a non-ISA global interrupt, * then override the vector we use to setup and allocate * the interrupt. */ - if (intr->Interrupt > 15 && - intr->Source == AcpiGbl_FADT->SciInt) - acpi_OverrideInterruptLevel(intr->Interrupt); + if (intr->GlobalIrq > 15 && + intr->SourceIrq == AcpiGbl_FADT.SciInterrupt) + acpi_OverrideInterruptLevel(intr->GlobalIrq); else - ioapic_remap_vector(new_ioapic, new_pin, intr->Source); - if (madt_find_interrupt(intr->Source, &old_ioapic, + ioapic_remap_vector(new_ioapic, new_pin, + intr->SourceIrq); + if (madt_find_interrupt(intr->SourceIrq, &old_ioapic, &old_pin) != 0) - printf("MADT: Could not find APIC for source IRQ %d\n", - intr->Source); + printf("MADT: Could not find APIC for source IRQ %u\n", + intr->SourceIrq); else if (ioapic_get_vector(old_ioapic, old_pin) == - intr->Source) + intr->SourceIrq) ioapic_disable_pin(old_ioapic, old_pin); } @@ -682,31 +686,31 @@ * Parse an entry for an NMI routed to an IO APIC. */ static void -madt_parse_nmi(MADT_NMI_SOURCE *nmi) +madt_parse_nmi(ACPI_MADT_NMI_SOURCE *nmi) { void *ioapic; u_int pin; - if (madt_find_interrupt(nmi->Interrupt, &ioapic, &pin) != 0) { - printf("MADT: Could not find APIC for vector %d\n", - nmi->Interrupt); + if (madt_find_interrupt(nmi->GlobalIrq, &ioapic, &pin) != 0) { + printf("MADT: Could not find APIC for vector %u\n", + nmi->GlobalIrq); return; } ioapic_set_nmi(ioapic, pin); - if (nmi->TriggerMode != TRIGGER_CONFORMS) + if (!(nmi->IntiFlags & ACPI_MADT_TRIGGER_CONFORMS)) ioapic_set_triggermode(ioapic, pin, - interrupt_trigger(nmi->TriggerMode, 0)); - if (nmi->Polarity != TRIGGER_CONFORMS) + interrupt_trigger(nmi->IntiFlags, 0)); + if (!(nmi->IntiFlags & ACPI_MADT_TRIGGER_CONFORMS)) ioapic_set_polarity(ioapic, pin, - interrupt_polarity(nmi->Polarity, 0)); + interrupt_polarity(nmi->IntiFlags, 0)); } /* * Parse an entry for an NMI routed to a local APIC LVT pin. */ static void -madt_parse_local_nmi(MADT_LOCAL_APIC_NMI *nmi) +madt_parse_local_nmi(ACPI_MADT_LOCAL_APIC_NMI *nmi) { u_int apic_id, pin; @@ -714,8 +718,8 @@ apic_id = APIC_ID_ALL; else if (madt_find_cpu(nmi->ProcessorId, &apic_id) != 0) { if (bootverbose) - printf("MADT: Ignoring local NMI routed to ACPI CPU %u\n", - nmi->ProcessorId); + printf("MADT: Ignoring local NMI routed to " + "ACPI CPU %u\n", nmi->ProcessorId); return; } if (nmi->Lint == 0) @@ -723,31 +727,31 @@ else pin = LVT_LINT1; lapic_set_lvt_mode(apic_id, pin, APIC_LVT_DM_NMI); - if (nmi->TriggerMode != TRIGGER_CONFORMS) + if (!(nmi->IntiFlags & ACPI_MADT_TRIGGER_CONFORMS)) lapic_set_lvt_triggermode(apic_id, pin, - interrupt_trigger(nmi->TriggerMode, 0)); - if (nmi->Polarity != POLARITY_CONFORMS) + interrupt_trigger(nmi->IntiFlags, 0)); + if (!(nmi->IntiFlags & ACPI_MADT_POLARITY_CONFORMS)) lapic_set_lvt_polarity(apic_id, pin, - interrupt_polarity(nmi->Polarity, 0)); + interrupt_polarity(nmi->IntiFlags, 0)); } /* * Parse interrupt entries. */ static void -madt_parse_ints(APIC_HEADER *entry, void *arg __unused) +madt_parse_ints(ACPI_SUBTABLE_HEADER *entry, void *arg __unused) { switch (entry->Type) { - case APIC_XRUPT_OVERRIDE: + case ACPI_MADT_TYPE_INTERRUPT_OVERRIDE: madt_parse_interrupt_override( - (MADT_INTERRUPT_OVERRIDE *)entry); + (ACPI_MADT_INTERRUPT_OVERRIDE *)entry); break; - case APIC_NMI: - madt_parse_nmi((MADT_NMI_SOURCE *)entry); + case ACPI_MADT_TYPE_NMI_SOURCE: + madt_parse_nmi((ACPI_MADT_NMI_SOURCE *)entry); break; - case APIC_LOCAL_NMI: - madt_parse_local_nmi((MADT_LOCAL_APIC_NMI *)entry); + case ACPI_MADT_TYPE_LOCAL_APIC_NMI: + madt_parse_local_nmi((ACPI_MADT_LOCAL_APIC_NMI *)entry); break; } } @@ -768,7 +772,7 @@ if (CPU_ABSENT(i)) continue; pc = pcpu_find(i); - KASSERT(pc != NULL, ("no pcpu data for CPU %d", i)); + KASSERT(pc != NULL, ("no pcpu data for CPU %u", i)); la = &lapics[pc->pc_apic_id]; if (!la->la_enabled) panic("APIC: CPU with APIC ID %u is not enabled", Index: sys/i386/acpica/madt.c =================================================================== RCS file: /home/ncvs/src/sys/i386/acpica/madt.c,v retrieving revision 1.24 diff -u -r1.24 madt.c --- sys/i386/acpica/madt.c 11 Aug 2006 19:22:56 -0000 1.24 +++ sys/i386/acpica/madt.c 22 Feb 2007 23:57:57 -0000 @@ -56,7 +56,7 @@ #define NIOAPICS 32 /* Max number of I/O APICs */ #define NLAPICS 32 /* Max number of local APICs */ -typedef void madt_entry_handler(APIC_HEADER *entry, void *arg); +typedef void madt_entry_handler(ACPI_SUBTABLE_HEADER *entry, void *arg); /* These two arrays are indexed by APIC IDs. */ struct ioapic_info { @@ -70,7 +70,7 @@ } lapics[NLAPICS]; static int madt_found_sci_override; -static MULTIPLE_APIC_TABLE *madt; +static ACPI_TABLE_MADT *madt; static vm_paddr_t madt_physaddr; static vm_offset_t madt_length; @@ -82,14 +82,17 @@ static int madt_find_interrupt(int intr, void **apic, u_int *pin); static void *madt_map(vm_paddr_t pa, int offset, vm_offset_t length); static void *madt_map_table(vm_paddr_t pa, int offset, const char *sig); -static void madt_parse_apics(APIC_HEADER *entry, void *arg); -static void madt_parse_interrupt_override(MADT_INTERRUPT_OVERRIDE *intr); -static void madt_parse_ints(APIC_HEADER *entry, void *arg __unused); -static void madt_parse_local_nmi(MADT_LOCAL_APIC_NMI *nmi); -static void madt_parse_nmi(MADT_NMI_SOURCE *nmi); +static void madt_parse_apics(ACPI_SUBTABLE_HEADER *entry, void *arg); +static void madt_parse_interrupt_override( + ACPI_MADT_INTERRUPT_OVERRIDE *intr); +static void madt_parse_ints(ACPI_SUBTABLE_HEADER *entry, + void *arg __unused); +static void madt_parse_local_nmi(ACPI_MADT_LOCAL_APIC_NMI *nmi); +static void madt_parse_nmi(ACPI_MADT_NMI_SOURCE *nmi); static int madt_probe(void); static int madt_probe_cpus(void); -static void madt_probe_cpus_handler(APIC_HEADER *entry, void *arg __unused); +static void madt_probe_cpus_handler(ACPI_SUBTABLE_HEADER *entry, + void *arg __unused); static int madt_probe_table(vm_paddr_t address); static void madt_register(void *dummy); static int madt_setup_local(void); @@ -161,14 +164,14 @@ void *table; header = madt_map(pa, offset, sizeof(ACPI_TABLE_HEADER)); - if (strncmp(header->Signature, sig, 4) != 0) { + if (strncmp(header->Signature, sig, ACPI_NAME_SIZE) != 0) { madt_unmap(header, sizeof(ACPI_TABLE_HEADER)); return (NULL); } length = header->Length; madt_unmap(header, sizeof(ACPI_TABLE_HEADER)); table = madt_map(pa, offset, length); - if (ACPI_FAILURE(AcpiTbVerifyTableChecksum(table))) { + if (ACPI_FAILURE(AcpiTbChecksum(table, length))) { if (bootverbose) printf("MADT: Failed checksum for table %s\n", sig); madt_unmap(table, length); @@ -192,10 +195,10 @@ static int madt_probe(void) { - ACPI_POINTER rsdp_ptr; - RSDP_DESCRIPTOR *rsdp; - RSDT_DESCRIPTOR *rsdt; - XSDT_DESCRIPTOR *xsdt; + ACPI_PHYSICAL_ADDRESS rsdp_ptr; + ACPI_TABLE_RSDP *rsdp; + ACPI_TABLE_RSDT *rsdt; + ACPI_TABLE_XSDT *xsdt; int i, count; if (resource_disabled("acpi", 0)) @@ -206,12 +209,12 @@ * calls pmap_mapbios() to find the RSDP, we assume that we can use * pmap_mapbios() to map the RSDP. */ - if (AcpiOsGetRootPointer(ACPI_LOGICAL_ADDRESSING, &rsdp_ptr) != AE_OK) + if ((rsdp_ptr = AcpiOsGetRootPointer()) == 0) return (ENXIO); #ifdef __i386__ - KASSERT(rsdp_ptr.Pointer.Physical < KERNLOAD, ("RSDP too high")); + KASSERT(rsdp_ptr < KERNLOAD, ("RSDP too high")); #endif - rsdp = pmap_mapbios(rsdp_ptr.Pointer.Physical, sizeof(RSDP_DESCRIPTOR)); + rsdp = pmap_mapbios(rsdp_ptr, sizeof(ACPI_TABLE_RSDP)); if (rsdp == NULL) { if (bootverbose) printf("MADT: Failed to map RSDP\n"); @@ -230,38 +233,40 @@ * the version 1.0 portion of the RSDP. Version 2.0 has * an additional checksum that we verify first. */ - if (AcpiTbGenerateChecksum(rsdp, ACPI_RSDP_XCHECKSUM_LENGTH)) { + if (AcpiTbChecksum((UINT8 *)rsdp, ACPI_RSDP_XCHECKSUM_LENGTH)) { if (bootverbose) printf("MADT: RSDP failed extended checksum\n"); return (ENXIO); } - xsdt = madt_map_table(rsdp->XsdtPhysicalAddress, 1, XSDT_SIG); + xsdt = madt_map_table(rsdp->XsdtPhysicalAddress, 1, + ACPI_SIG_XSDT); if (xsdt == NULL) { if (bootverbose) printf("MADT: Failed to map XSDT\n"); return (ENXIO); } - count = (xsdt->Length - sizeof(ACPI_TABLE_HEADER)) / + count = (xsdt->Header.Length - sizeof(ACPI_TABLE_HEADER)) / sizeof(UINT64); for (i = 0; i < count; i++) if (madt_probe_table(xsdt->TableOffsetEntry[i])) break; madt_unmap_table(xsdt); } else { - rsdt = madt_map_table(rsdp->RsdtPhysicalAddress, 1, RSDT_SIG); + rsdt = madt_map_table(rsdp->RsdtPhysicalAddress, 1, + ACPI_SIG_RSDT); if (rsdt == NULL) { if (bootverbose) printf("MADT: Failed to map RSDT\n"); return (ENXIO); } - count = (rsdt->Length - sizeof(ACPI_TABLE_HEADER)) / + count = (rsdt->Header.Length - sizeof(ACPI_TABLE_HEADER)) / sizeof(UINT32); for (i = 0; i < count; i++) if (madt_probe_table(rsdt->TableOffsetEntry[i])) break; madt_unmap_table(rsdt); } - pmap_unmapbios((vm_offset_t)rsdp, sizeof(RSDP_DESCRIPTOR)); + pmap_unmapbios((vm_offset_t)rsdp, sizeof(ACPI_TABLE_RSDP)); if (madt_physaddr == 0) { if (bootverbose) printf("MADT: No MADT table found\n"); @@ -275,7 +280,7 @@ * Verify that we can map the full table and that its checksum is * correct, etc. */ - madt = madt_map_table(madt_physaddr, 0, APIC_SIG); + madt = madt_map_table(madt_physaddr, 0, ACPI_SIG_MADT); if (madt == NULL) return (ENXIO); madt_unmap_table(madt); @@ -303,7 +308,7 @@ printf("Table '%.4s' at 0x%jx\n", table->Signature, (uintmax_t)address); - if (strncmp(table->Signature, APIC_SIG, 4) != 0) { + if (strncmp(table->Signature, ACPI_SIG_MADT, ACPI_NAME_SIZE) != 0) { madt_unmap(table, sizeof(ACPI_TABLE_HEADER)); return (0); } @@ -320,7 +325,7 @@ madt_probe_cpus(void) { - madt = madt_map_table(madt_physaddr, 0, APIC_SIG); + madt = madt_map_table(madt_physaddr, 0, ACPI_SIG_MADT); KASSERT(madt != NULL, ("Unable to re-map MADT")); madt_walk_table(madt_probe_cpus_handler, NULL); madt_unmap_table(madt); @@ -336,10 +341,10 @@ { madt = pmap_mapbios(madt_physaddr, madt_length); - lapic_init((uintptr_t)madt->LocalApicAddress); + lapic_init((uintptr_t)madt->Address); printf("ACPI APIC Table: <%.*s %.*s>\n", - (int)sizeof(madt->OemId), madt->OemId, - (int)sizeof(madt->OemTableId), madt->OemTableId); + (int)sizeof(madt->Header.OemId), madt->Header.OemId, + (int)sizeof(madt->Header.OemTableId), madt->Header.OemTableId); /* * We ignore 64-bit local APIC override entries. Should we @@ -378,10 +383,10 @@ * force it to use level trigger and active-low polarity. */ if (!madt_found_sci_override) { - if (madt_find_interrupt(AcpiGbl_FADT->SciInt, &ioapic, &pin) - != 0) - printf("MADT: Could not find APIC for SCI IRQ %d\n", - AcpiGbl_FADT->SciInt); + if (madt_find_interrupt(AcpiGbl_FADT.SciInterrupt, &ioapic, + &pin) != 0) + printf("MADT: Could not find APIC for SCI IRQ %u\n", + AcpiGbl_FADT.SciInterrupt); else { printf( "MADT: Forcing active-low polarity and level trigger for SCI\n"); @@ -415,46 +420,46 @@ static void madt_walk_table(madt_entry_handler *handler, void *arg) { - APIC_HEADER *entry; + ACPI_SUBTABLE_HEADER *entry; u_char *p, *end; - end = (u_char *)(madt) + madt->Length; + end = (u_char *)(madt) + madt->Header.Length; for (p = (u_char *)(madt + 1); p < end; ) { - entry = (APIC_HEADER *)p; + entry = (ACPI_SUBTABLE_HEADER *)p; handler(entry, arg); p += entry->Length; } } static void -madt_probe_cpus_handler(APIC_HEADER *entry, void *arg) +madt_probe_cpus_handler(ACPI_SUBTABLE_HEADER *entry, void *arg) { - MADT_PROCESSOR_APIC *proc; + ACPI_MADT_LOCAL_APIC *proc; struct lapic_info *la; switch (entry->Type) { - case APIC_PROCESSOR: + case ACPI_MADT_TYPE_LOCAL_APIC: /* * The MADT does not include a BSP flag, so we have to * let the MP code figure out which CPU is the BSP on * its own. */ - proc = (MADT_PROCESSOR_APIC *)entry; + proc = (ACPI_MADT_LOCAL_APIC *)entry; if (bootverbose) - printf("MADT: Found CPU APIC ID %d ACPI ID %d: %s\n", - proc->LocalApicId, proc->ProcessorId, - proc->ProcessorEnabled ? "enabled" : "disabled"); - if (!proc->ProcessorEnabled) + printf("MADT: Found CPU APIC ID %u ACPI ID %u: %s\n", + proc->Id, proc->ProcessorId, + (proc->LapicFlags & ACPI_MADT_ENABLED) ? + "enabled" : "disabled"); + if (!(proc->LapicFlags & ACPI_MADT_ENABLED)) break; - if (proc->LocalApicId >= NLAPICS) - panic("%s: CPU ID %d too high", __func__, - proc->LocalApicId); - la = &lapics[proc->LocalApicId]; + if (proc->Id >= NLAPICS) + panic("%s: CPU ID %u too high", __func__, proc->Id); + la = &lapics[proc->Id]; KASSERT(la->la_enabled == 0, - ("Duplicate local APIC ID %d", proc->LocalApicId)); + ("Duplicate local APIC ID %u", proc->Id)); la->la_enabled = 1; la->la_acpi_id = proc->ProcessorId; - lapic_create(proc->LocalApicId, 0); + lapic_create(proc->Id, 0); break; } } @@ -464,27 +469,26 @@ * Add an I/O APIC from an entry in the table. */ static void -madt_parse_apics(APIC_HEADER *entry, void *arg __unused) +madt_parse_apics(ACPI_SUBTABLE_HEADER *entry, void *arg __unused) { - MADT_IO_APIC *apic; + ACPI_MADT_IO_APIC *apic; switch (entry->Type) { - case APIC_IO: - apic = (MADT_IO_APIC *)entry; + case ACPI_MADT_TYPE_IO_APIC: + apic = (ACPI_MADT_IO_APIC *)entry; if (bootverbose) - printf("MADT: Found IO APIC ID %d, Interrupt %d at %p\n", - apic->IoApicId, apic->Interrupt, + printf( + "MADT: Found IO APIC ID %u, Interrupt %u at %p\n", + apic->Id, apic->GlobalIrqBase, (void *)(uintptr_t)apic->Address); - if (apic->IoApicId >= NIOAPICS) - panic("%s: I/O APIC ID %d too high", __func__, - apic->IoApicId); - if (ioapics[apic->IoApicId].io_apic != NULL) - panic("%s: Double APIC ID %d", __func__, - apic->IoApicId); - ioapics[apic->IoApicId].io_apic = ioapic_create( - (uintptr_t)apic->Address, apic->IoApicId, - apic->Interrupt); - ioapics[apic->IoApicId].io_vector = apic->Interrupt; + if (apic->Id >= NIOAPICS) + panic("%s: I/O APIC ID %u too high", __func__, + apic->Id); + if (ioapics[apic->Id].io_apic != NULL) + panic("%s: Double APIC ID %u", __func__, apic->Id); + ioapics[apic->Id].io_apic = ioapic_create( + (uintptr_t)apic->Address, apic->Id, apic->GlobalIrqBase); + ioapics[apic->Id].io_vector = apic->GlobalIrqBase; break; default: break; @@ -501,15 +505,15 @@ interrupt_polarity(UINT16 Polarity, UINT8 Source) { - switch (Polarity) { - case POLARITY_CONFORMS: - if (Source == AcpiGbl_FADT->SciInt) + switch (Polarity & ACPI_MADT_POLARITY_MASK) { + case ACPI_MADT_POLARITY_CONFORMS: + if (Source == AcpiGbl_FADT.SciInterrupt) return (INTR_POLARITY_LOW); else return (INTR_POLARITY_HIGH); - case POLARITY_ACTIVE_HIGH: + case ACPI_MADT_POLARITY_ACTIVE_HIGH: return (INTR_POLARITY_HIGH); - case POLARITY_ACTIVE_LOW: + case ACPI_MADT_POLARITY_ACTIVE_LOW: return (INTR_POLARITY_LOW); default: panic("Bogus Interrupt Polarity"); @@ -520,15 +524,15 @@ interrupt_trigger(UINT16 TriggerMode, UINT8 Source) { - switch (TriggerMode) { - case TRIGGER_CONFORMS: - if (Source == AcpiGbl_FADT->SciInt) + switch (TriggerMode & ACPI_MADT_TRIGGER_MASK) { + case ACPI_MADT_TRIGGER_CONFORMS: + if (Source == AcpiGbl_FADT.SciInterrupt) return (INTR_TRIGGER_LEVEL); else return (INTR_TRIGGER_EDGE); - case TRIGGER_EDGE: + case ACPI_MADT_TRIGGER_EDGE: return (INTR_TRIGGER_EDGE); - case TRIGGER_LEVEL: + case ACPI_MADT_TRIGGER_LEVEL: return (INTR_TRIGGER_LEVEL); default: panic("Bogus Interrupt Trigger Mode"); @@ -586,7 +590,7 @@ * Parse an interrupt source override for an ISA interrupt. */ static void -madt_parse_interrupt_override(MADT_INTERRUPT_OVERRIDE *intr) +madt_parse_interrupt_override(ACPI_MADT_INTERRUPT_OVERRIDE *intr) { void *new_ioapic, *old_ioapic; u_int new_pin, old_pin; @@ -594,20 +598,19 @@ enum intr_polarity pol; char buf[64]; - if (acpi_quirks & ACPI_Q_MADT_IRQ0 && intr->Source == 0 && - intr->Interrupt == 2) { + if (acpi_quirks & ACPI_Q_MADT_IRQ0 && intr->SourceIrq == 0 && + intr->GlobalIrq == 2) { if (bootverbose) printf("MADT: Skipping timer override\n"); return; } if (bootverbose) printf("MADT: Interrupt override: source %u, irq %u\n", - intr->Source, intr->Interrupt); + intr->SourceIrq, intr->GlobalIrq); KASSERT(intr->Bus == 0, ("bus for interrupt overrides must be zero")); - if (madt_find_interrupt(intr->Interrupt, &new_ioapic, - &new_pin) != 0) { - printf("MADT: Could not find APIC for vector %d (IRQ %d)\n", - intr->Interrupt, intr->Source); + if (madt_find_interrupt(intr->GlobalIrq, &new_ioapic, &new_pin) != 0) { + printf("MADT: Could not find APIC for vector %u (IRQ %u)\n", + intr->GlobalIrq, intr->SourceIrq); return; } @@ -615,15 +618,15 @@ * Lookup the appropriate trigger and polarity modes for this * entry. */ - trig = interrupt_trigger(intr->TriggerMode, intr->Source); - pol = interrupt_polarity(intr->Polarity, intr->Source); + trig = interrupt_trigger(intr->IntiFlags, intr->SourceIrq); + pol = interrupt_polarity(intr->IntiFlags, intr->SourceIrq); /* * If the SCI is identity mapped but has edge trigger and * active-hi polarity or the force_sci_lo tunable is set, * force it to use level/lo. */ - if (intr->Source == AcpiGbl_FADT->SciInt) { + if (intr->SourceIrq == AcpiGbl_FADT.SciInterrupt) { madt_found_sci_override = 1; if (getenv_string("hw.acpi.sci.trigger", buf, sizeof(buf))) { if (tolower(buf[0]) == 'e') @@ -652,23 +655,24 @@ } /* Remap the IRQ if it is mapped to a different interrupt vector. */ - if (intr->Source != intr->Interrupt) { + if (intr->SourceIrq != intr->GlobalIrq) { /* * If the SCI is remapped to a non-ISA global interrupt, * then override the vector we use to setup and allocate * the interrupt. */ - if (intr->Interrupt > 15 && - intr->Source == AcpiGbl_FADT->SciInt) - acpi_OverrideInterruptLevel(intr->Interrupt); + if (intr->GlobalIrq > 15 && + intr->SourceIrq == AcpiGbl_FADT.SciInterrupt) + acpi_OverrideInterruptLevel(intr->GlobalIrq); else - ioapic_remap_vector(new_ioapic, new_pin, intr->Source); - if (madt_find_interrupt(intr->Source, &old_ioapic, + ioapic_remap_vector(new_ioapic, new_pin, + intr->SourceIrq); + if (madt_find_interrupt(intr->SourceIrq, &old_ioapic, &old_pin) != 0) - printf("MADT: Could not find APIC for source IRQ %d\n", - intr->Source); + printf("MADT: Could not find APIC for source IRQ %u\n", + intr->SourceIrq); else if (ioapic_get_vector(old_ioapic, old_pin) == - intr->Source) + intr->SourceIrq) ioapic_disable_pin(old_ioapic, old_pin); } @@ -681,31 +685,31 @@ * Parse an entry for an NMI routed to an IO APIC. */ static void -madt_parse_nmi(MADT_NMI_SOURCE *nmi) +madt_parse_nmi(ACPI_MADT_NMI_SOURCE *nmi) { void *ioapic; u_int pin; - if (madt_find_interrupt(nmi->Interrupt, &ioapic, &pin) != 0) { - printf("MADT: Could not find APIC for vector %d\n", - nmi->Interrupt); + if (madt_find_interrupt(nmi->GlobalIrq, &ioapic, &pin) != 0) { + printf("MADT: Could not find APIC for vector %u\n", + nmi->GlobalIrq); return; } ioapic_set_nmi(ioapic, pin); - if (nmi->TriggerMode != TRIGGER_CONFORMS) + if (!(nmi->IntiFlags & ACPI_MADT_TRIGGER_CONFORMS)) ioapic_set_triggermode(ioapic, pin, - interrupt_trigger(nmi->TriggerMode, 0)); - if (nmi->Polarity != TRIGGER_CONFORMS) + interrupt_trigger(nmi->IntiFlags, 0)); + if (!(nmi->IntiFlags & ACPI_MADT_TRIGGER_CONFORMS)) ioapic_set_polarity(ioapic, pin, - interrupt_polarity(nmi->Polarity, 0)); + interrupt_polarity(nmi->IntiFlags, 0)); } /* * Parse an entry for an NMI routed to a local APIC LVT pin. */ static void -madt_parse_local_nmi(MADT_LOCAL_APIC_NMI *nmi) +madt_parse_local_nmi(ACPI_MADT_LOCAL_APIC_NMI *nmi) { u_int apic_id, pin; @@ -713,8 +717,8 @@ apic_id = APIC_ID_ALL; else if (madt_find_cpu(nmi->ProcessorId, &apic_id) != 0) { if (bootverbose) - printf("MADT: Ignoring local NMI routed to ACPI CPU %u\n", - nmi->ProcessorId); + printf("MADT: Ignoring local NMI routed to " + "ACPI CPU %u\n", nmi->ProcessorId); return; } if (nmi->Lint == 0) @@ -722,31 +726,31 @@ else pin = LVT_LINT1; lapic_set_lvt_mode(apic_id, pin, APIC_LVT_DM_NMI); - if (nmi->TriggerMode != TRIGGER_CONFORMS) + if (!(nmi->IntiFlags & ACPI_MADT_TRIGGER_CONFORMS)) lapic_set_lvt_triggermode(apic_id, pin, - interrupt_trigger(nmi->TriggerMode, 0)); - if (nmi->Polarity != POLARITY_CONFORMS) + interrupt_trigger(nmi->IntiFlags, 0)); + if (!(nmi->IntiFlags & ACPI_MADT_POLARITY_CONFORMS)) lapic_set_lvt_polarity(apic_id, pin, - interrupt_polarity(nmi->Polarity, 0)); + interrupt_polarity(nmi->IntiFlags, 0)); } /* * Parse interrupt entries. */ static void -madt_parse_ints(APIC_HEADER *entry, void *arg __unused) +madt_parse_ints(ACPI_SUBTABLE_HEADER *entry, void *arg __unused) { switch (entry->Type) { - case APIC_XRUPT_OVERRIDE: + case ACPI_MADT_TYPE_INTERRUPT_OVERRIDE: madt_parse_interrupt_override( - (MADT_INTERRUPT_OVERRIDE *)entry); + (ACPI_MADT_INTERRUPT_OVERRIDE *)entry); break; - case APIC_NMI: - madt_parse_nmi((MADT_NMI_SOURCE *)entry); + case ACPI_MADT_TYPE_NMI_SOURCE: + madt_parse_nmi((ACPI_MADT_NMI_SOURCE *)entry); break; - case APIC_LOCAL_NMI: - madt_parse_local_nmi((MADT_LOCAL_APIC_NMI *)entry); + case ACPI_MADT_TYPE_LOCAL_APIC_NMI: + madt_parse_local_nmi((ACPI_MADT_LOCAL_APIC_NMI *)entry); break; } } @@ -767,7 +771,7 @@ if (CPU_ABSENT(i)) continue; pc = pcpu_find(i); - KASSERT(pc != NULL, ("no pcpu data for CPU %d", i)); + KASSERT(pc != NULL, ("no pcpu data for CPU %u", i)); la = &lapics[pc->pc_apic_id]; if (!la->la_enabled) panic("APIC: CPU with APIC ID %u is not enabled", Index: sys/ia64/acpica/madt.c =================================================================== RCS file: /home/ncvs/src/sys/ia64/acpica/madt.c,v retrieving revision 1.19 diff -u -r1.19 madt.c --- sys/ia64/acpica/madt.c 11 Sep 2005 18:39:03 -0000 1.19 +++ sys/ia64/acpica/madt.c 22 Feb 2007 23:57:57 -0000 @@ -36,69 +36,71 @@ struct sapic *sapic_create(int, int, u_int64_t); static void -print_entry(APIC_HEADER *entry) +print_entry(ACPI_SUBTABLE_HEADER *entry) { switch (entry->Type) { - case APIC_XRUPT_OVERRIDE: { - MADT_INTERRUPT_OVERRIDE *iso = - (MADT_INTERRUPT_OVERRIDE *)entry; + case ACPI_MADT_TYPE_INTERRUPT_OVERRIDE: { + ACPI_MADT_INTERRUPT_OVERRIDE *iso = + (ACPI_MADT_INTERRUPT_OVERRIDE *)entry; printf("\tInterrupt source override entry\n"); - printf("\t\tBus=%d, Source=%d, Irq=0x%x\n", iso->Bus, - iso->Source, iso->Interrupt); + printf("\t\tBus=%u, Source=%u, Irq=0x%x\n", iso->Bus, + iso->SourceIrq, iso->GlobalIrq); break; } - case APIC_IO: + case ACPI_MADT_TYPE_IO_APIC: printf("\tI/O APIC entry\n"); break; - case APIC_IO_SAPIC: { - MADT_IO_SAPIC *sapic = (MADT_IO_SAPIC *)entry; + case ACPI_MADT_TYPE_IO_SAPIC: { + ACPI_MADT_IO_SAPIC *sapic = (ACPI_MADT_IO_SAPIC *)entry; printf("\tI/O SAPIC entry\n"); printf("\t\tId=0x%x, InterruptBase=0x%x, Address=0x%lx\n", - sapic->IoSapicId, sapic->InterruptBase, sapic->Address); + sapic->Id, sapic->GlobalIrqBase, sapic->Address); break; } - case APIC_LOCAL_NMI: + case ACPI_MADT_TYPE_LOCAL_APIC_NMI: printf("\tLocal APIC NMI entry\n"); break; - case APIC_ADDRESS_OVERRIDE: { - MADT_ADDRESS_OVERRIDE *lapic = (MADT_ADDRESS_OVERRIDE *)entry; + case ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE: { + ACPI_MADT_LOCAL_APIC_OVERRIDE *lapic = + (ACPI_MADT_LOCAL_APIC_OVERRIDE *)entry; printf("\tLocal APIC override entry\n"); printf("\t\tLocal APIC address=0x%jx\n", lapic->Address); break; } - case APIC_LOCAL_SAPIC: { - MADT_LOCAL_SAPIC *sapic = (MADT_LOCAL_SAPIC *)entry; + case ACPI_MADT_TYPE_LOCAL_SAPIC: { + ACPI_MADT_LOCAL_SAPIC *sapic = (ACPI_MADT_LOCAL_SAPIC *)entry; printf("\tLocal SAPIC entry\n"); printf("\t\tProcessorId=0x%x, Id=0x%x, Eid=0x%x", - sapic->ProcessorId, sapic->LocalSapicId, - sapic->LocalSapicEid); - if (!sapic->ProcessorEnabled) + sapic->ProcessorId, sapic->Id, sapic->Eid); + if (!(sapic->LapicFlags & ACPI_MADT_ENABLED)) printf(" (disabled)"); printf("\n"); break; } - case APIC_NMI: + case ACPI_MADT_TYPE_NMI_SOURCE: printf("\tNMI entry\n"); break; - case APIC_XRUPT_SOURCE: { - MADT_INTERRUPT_SOURCE *pis = (MADT_INTERRUPT_SOURCE *)entry; + case ACPI_MADT_TYPE_INTERRUPT_SOURCE: { + ACPI_MADT_INTERRUPT_SOURCE *pis = + (ACPI_MADT_INTERRUPT_SOURCE *)entry; printf("\tPlatform interrupt entry\n"); - printf("\t\tPolarity=%d, TriggerMode=%d, Id=0x%x, " + printf("\t\tPolarity=%u, TriggerMode=%u, Id=0x%x, " "Eid=0x%x, Vector=0x%x, Irq=%d\n", - pis->Polarity, pis->TriggerMode, pis->ProcessorId, - pis->ProcessorEid, pis->IoSapicVector, pis->Interrupt); + pis->IntiFlags & ACPI_MADT_POLARITY_MASK, + (pis->IntiFlags & ACPI_MADT_TRIGGER_MASK) >> 2, + pis->Id, pis->Eid, pis->IoSapicVector, pis->GlobalIrq); break; } - case APIC_PROCESSOR: + case ACPI_MADT_TYPE_LOCAL_APIC: printf("\tLocal APIC entry\n"); break; @@ -111,25 +113,25 @@ void ia64_probe_sapics(void) { - ACPI_POINTER rsdp_ptr; - APIC_HEADER *entry; - MULTIPLE_APIC_TABLE *table; - RSDP_DESCRIPTOR *rsdp; - XSDT_DESCRIPTOR *xsdt; + ACPI_PHYSICAL_ADDRESS rsdp_ptr; + ACPI_SUBTABLE_HEADER *entry; + ACPI_TABLE_MADT *table; + ACPI_TABLE_RSDP *rsdp; + ACPI_TABLE_XSDT *xsdt; char *end, *p; int t, tables; - if (AcpiOsGetRootPointer(ACPI_LOGICAL_ADDRESSING, &rsdp_ptr) != AE_OK) + if ((rsdp_ptr = AcpiOsGetRootPointer()) == 0) return; - rsdp = (RSDP_DESCRIPTOR *)IA64_PHYS_TO_RR7(rsdp_ptr.Pointer.Physical); - xsdt = (XSDT_DESCRIPTOR *)IA64_PHYS_TO_RR7(rsdp->XsdtPhysicalAddress); + rsdp = (ACPI_TABLE_RSDP *)IA64_PHYS_TO_RR7(rsdp_ptr); + xsdt = (ACPI_TABLE_XSDT *)IA64_PHYS_TO_RR7(rsdp->XsdtPhysicalAddress); - tables = (UINT64 *)((char *)xsdt + xsdt->Length) - + tables = (UINT64 *)((char *)xsdt + xsdt->Header.Length) - xsdt->TableOffsetEntry; for (t = 0; t < tables; t++) { - table = (MULTIPLE_APIC_TABLE *) + table = (ACPI_TABLE_MADT *) IA64_PHYS_TO_RR7(xsdt->TableOffsetEntry[t]); if (bootverbose) @@ -137,47 +139,48 @@ table->Signature[0], table->Signature[1], table->Signature[2], table->Signature[3], table); - if (strncmp(table->Signature, APIC_SIG, 4) != 0 || - ACPI_FAILURE(AcpiTbVerifyTableChecksum((void *)table))) + if (strncmp(table->Signature, ACPI_SIG_MADT, + ACPI_NAME_SIZE) != 0 || + ACPI_FAILURE(AcpiTbChecksum((void *)table, + table->Header.Length))) continue; /* Save the address of the processor interrupt block. */ if (bootverbose) - printf("\tLocal APIC address=0x%x\n", - table->LocalApicAddress); - ia64_lapic_address = table->LocalApicAddress; + printf("\tLocal APIC address=0x%x\n", table->Address); + ia64_lapic_address = table->Address; - end = (char *)table + table->Length; + end = (char *)table + table->Header.Length; p = (char *)(table + 1); while (p < end) { - entry = (APIC_HEADER *)p; + entry = (ACPI_SUBTABLE_HEADER *)p; if (bootverbose) print_entry(entry); switch (entry->Type) { - case APIC_IO_SAPIC: { - MADT_IO_SAPIC *sapic = (MADT_IO_SAPIC *)entry; - sapic_create(sapic->IoSapicId, - sapic->InterruptBase, sapic->Address); + case ACPI_MADT_TYPE_LOCAL_SAPIC: { + ACPI_MADT_IO_SAPIC *sapic = + (ACPI_MADT_IO_SAPIC *)entry; + sapic_create(sapic->Id, sapic->GlobalIrqBase, + sapic->Address); break; } - case APIC_ADDRESS_OVERRIDE: { - MADT_ADDRESS_OVERRIDE *lapic = - (MADT_ADDRESS_OVERRIDE*)entry; + case ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE: { + ACPI_MADT_LOCAL_APIC_OVERRIDE *lapic = + (ACPI_MADT_LOCAL_APIC_OVERRIDE *)entry; ia64_lapic_address = lapic->Address; break; } #ifdef SMP - case APIC_LOCAL_SAPIC: { - MADT_LOCAL_SAPIC *sapic = - (MADT_LOCAL_SAPIC *)entry; + case ACPI_MADT_TYPE_LOCAL_SAPIC: { + ACPI_MADT_LOCAL_SAPIC *sapic = + (ACPI_MADT_LOCAL_SAPIC *)entry; if (sapic->ProcessorEnabled) cpu_mp_add(sapic->ProcessorId, - sapic->LocalSapicId, - sapic->LocalSapicEid); + sapic->Id, sapic->Eid); break; } #endif @@ -198,43 +201,45 @@ int ia64_count_cpus(void) { - ACPI_POINTER rsdp_ptr; - MULTIPLE_APIC_TABLE *table; - MADT_LOCAL_SAPIC *entry; - RSDP_DESCRIPTOR *rsdp; - XSDT_DESCRIPTOR *xsdt; + ACPI_PHYSICAL_ADDRESS rsdp_ptr; + ACPI_SUBTABLE_HEADER *entry; + ACPI_TABLE_MADT *table; + ACPI_TABLE_RSDP *rsdp; + ACPI_TABLE_XSDT *xsdt; char *end, *p; int cpus, t, tables; - if (AcpiOsGetRootPointer(ACPI_LOGICAL_ADDRESSING, &rsdp_ptr) != AE_OK) + if ((rsdp_ptr = AcpiOsGetRootPointer()) == 0) return (0); - rsdp = (RSDP_DESCRIPTOR *)IA64_PHYS_TO_RR7(rsdp_ptr.Pointer.Physical); - xsdt = (XSDT_DESCRIPTOR *)IA64_PHYS_TO_RR7(rsdp->XsdtPhysicalAddress); + rsdp = (ACPI_TABLE_RSDP *)IA64_PHYS_TO_RR7(rsdp_ptr); + xsdt = (ACPI_TABLE_XSDT *)IA64_PHYS_TO_RR7(rsdp->XsdtPhysicalAddress); - tables = (UINT64 *)((char *)xsdt + xsdt->Length) - + tables = (UINT64 *)((char *)xsdt + xsdt->Header.Length) - xsdt->TableOffsetEntry; cpus = 0; for (t = 0; t < tables; t++) { - table = (MULTIPLE_APIC_TABLE *) + table = (ACPI_TABLE_MADT *) IA64_PHYS_TO_RR7(xsdt->TableOffsetEntry[t]); - if (strncmp(table->Signature, APIC_SIG, 4) != 0 || - ACPI_FAILURE(AcpiTbVerifyTableChecksum((void *)table))) + if (strncmp(table->Signature, ACPI_SIG_MADT, + ACPI_NAME_SIZE) != 0 || + ACPI_FAILURE(AcpiTbChecksum((void *)table, + table->Header.Length))) continue; - end = (char *)table + table->Length; + end = (char *)table + table->Header.Length; p = (char *)(table + 1); while (p < end) { - entry = (MADT_LOCAL_SAPIC *)p; + entry = (ACPI_MADT_LOCAL_SAPIC *)p; - if (entry->Type == APIC_LOCAL_SAPIC && - entry->ProcessorEnabled) + if (entry->Type == ACPI_MADT_TYPE_LOCAL_SAPIC && + (entry->LapicFlags & ACPI_MADT_ENABLED)) cpus++; - p += entry->Length; + p += entry->Header.Length; } }