From 986dffaf53ffcd066ddd187b7c424941428a2921 Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Tue, 25 Aug 2009 20:35:57 +0000 Subject: [PATCH] - Use the headers from ACPI-CA to define various constants and structures for table layouts, etc. rather than homerolling our own structures and constants in acpidump.h. - Verify the extended checksum on the RSDP. - Handle new ACPI 3.0 fields in MADT including X2APIC entries and UIDs for local SAPICs. - Add handling for new ACPI 3.0 flags in the FADT. Reviewed by: jkim MFC after: 1 month --- usr.sbin/acpi/acpidump/acpi.c | 826 ++++++++++++++++------------- usr.sbin/acpi/acpidump/acpi_user.c | 48 +- usr.sbin/acpi/acpidump/acpidump.c | 6 +- usr.sbin/acpi/acpidump/acpidump.h | 375 ++----------- 4 files changed, 519 insertions(+), 736 deletions(-) diff --git a/usr.sbin/acpi/acpidump/acpi.c b/usr.sbin/acpi/acpidump/acpi.c index 800655c472c6..8a89f108ee45 100644 --- a/usr.sbin/acpi/acpidump/acpi.c +++ b/usr.sbin/acpi/acpidump/acpi.c @@ -47,31 +47,36 @@ #define END_COMMENT " */\n" static void acpi_print_string(char *s, size_t length); -static void acpi_print_gas(struct ACPIgas *gas); -static int acpi_get_fadt_revision(struct FADTbody *fadt); -static void acpi_handle_fadt(struct ACPIsdt *fadt); +static void acpi_print_gas(ACPI_GENERIC_ADDRESS *gas); +static int acpi_get_fadt_revision(ACPI_TABLE_FADT *fadt); +static void acpi_handle_fadt(ACPI_TABLE_HEADER *fadt); static void acpi_print_cpu(u_char cpu_id); -static void acpi_print_local_apic(u_char cpu_id, u_char apic_id, - u_int32_t flags); -static void acpi_print_io_apic(u_char apic_id, u_int32_t int_base, - u_int64_t apic_addr); -static void acpi_print_mps_flags(u_int16_t flags); -static void acpi_print_intr(u_int32_t intr, u_int16_t mps_flags); -static void acpi_print_apic(struct MADT_APIC *mp); -static void acpi_handle_apic(struct ACPIsdt *sdp); -static void acpi_handle_hpet(struct ACPIsdt *sdp); +static void acpi_print_cpu_uid(uint32_t uid, char *uid_string); +static void acpi_print_local_apic(uint32_t apic_id, uint32_t flags); +static void acpi_print_io_apic(uint32_t apic_id, uint32_t int_base, + uint64_t apic_addr); +static void acpi_print_mps_flags(uint16_t flags); +static void acpi_print_intr(uint32_t intr, uint16_t mps_flags); +static void acpi_print_local_nmi(u_int lint, uint16_t mps_flags); +static void acpi_print_madt(ACPI_SUBTABLE_HEADER *mp); +static void acpi_handle_madt(ACPI_TABLE_HEADER *sdp); +static void acpi_handle_ecdt(ACPI_TABLE_HEADER *sdp); +static void acpi_handle_hpet(ACPI_TABLE_HEADER *sdp); +static void acpi_handle_mcfg(ACPI_TABLE_HEADER *sdp); static void acpi_print_srat_cpu(uint32_t apic_id, uint32_t proximity_domain, uint32_t flags); -static void acpi_print_srat_memory(struct SRAT_memory *mp); -static void acpi_print_srat(struct SRATentry *srat); -static void acpi_handle_srat(struct ACPIsdt *sdp); -static void acpi_print_sdt(struct ACPIsdt *sdp); -static void acpi_print_fadt(struct ACPIsdt *sdp); -static void acpi_print_facs(struct FACSbody *facs); -static void acpi_print_dsdt(struct ACPIsdt *dsdp); -static struct ACPIsdt *acpi_map_sdt(vm_offset_t pa); -static void acpi_print_rsd_ptr(struct ACPIrsdp *rp); -static void acpi_handle_rsdt(struct ACPIsdt *rsdp); +static void acpi_print_srat_memory(ACPI_SRAT_MEM_AFFINITY *mp); +static void acpi_print_srat(ACPI_SUBTABLE_HEADER *srat); +static void acpi_handle_srat(ACPI_TABLE_HEADER *sdp); +static void acpi_print_sdt(ACPI_TABLE_HEADER *sdp); +static void acpi_print_fadt(ACPI_TABLE_HEADER *sdp); +static void acpi_print_facs(ACPI_TABLE_FACS *facs); +static void acpi_print_dsdt(ACPI_TABLE_HEADER *dsdp); +static ACPI_TABLE_HEADER *acpi_map_sdt(vm_offset_t pa); +static void acpi_print_rsd_ptr(ACPI_TABLE_RSDP *rp); +static void acpi_handle_rsdt(ACPI_TABLE_HEADER *rsdp); +static void acpi_walk_subtables(ACPI_TABLE_HEADER *table, void *first, + void (*action)(ACPI_SUBTABLE_HEADER *)); /* Size of an address. 32-bit for ACPI 1.0, 64-bit for ACPI 2.0 and up. */ static int addr_size; @@ -92,41 +97,44 @@ acpi_print_string(char *s, size_t length) } static void -acpi_print_gas(struct ACPIgas *gas) +acpi_print_gas(ACPI_GENERIC_ADDRESS *gas) { - switch(gas->address_space_id) { + switch(gas->SpaceId) { case ACPI_GAS_MEMORY: - printf("0x%08lx:%u[%u] (Memory)", (u_long)gas->address, - gas->bit_offset, gas->bit_width); + printf("0x%08lx:%u[%u] (Memory)", (u_long)gas->Address, + gas->BitOffset, gas->BitWidth); break; case ACPI_GAS_IO: - printf("0x%02lx:%u[%u] (IO)", (u_long)gas->address, - gas->bit_offset, gas->bit_width); + printf("0x%02lx:%u[%u] (IO)", (u_long)gas->Address, + gas->BitOffset, gas->BitWidth); break; case ACPI_GAS_PCI: - printf("%x:%x+0x%x (PCI)", (uint16_t)(gas->address >> 32), - (uint16_t)((gas->address >> 16) & 0xffff), - (uint16_t)gas->address); + printf("%x:%x+0x%x (PCI)", (uint16_t)(gas->Address >> 32), + (uint16_t)((gas->Address >> 16) & 0xffff), + (uint16_t)gas->Address); break; /* XXX How to handle these below? */ case ACPI_GAS_EMBEDDED: - printf("0x%x:%u[%u] (EC)", (uint16_t)gas->address, - gas->bit_offset, gas->bit_width); + printf("0x%x:%u[%u] (EC)", (uint16_t)gas->Address, + gas->BitOffset, gas->BitWidth); break; case ACPI_GAS_SMBUS: - printf("0x%x:%u[%u] (SMBus)", (uint16_t)gas->address, - gas->bit_offset, gas->bit_width); + printf("0x%x:%u[%u] (SMBus)", (uint16_t)gas->Address, + gas->BitOffset, gas->BitWidth); break; + case ACPI_GAS_CMOS: + case ACPI_GAS_PCIBAR: + case ACPI_GAS_DATATABLE: case ACPI_GAS_FIXED: default: - printf("0x%08lx (?)", (u_long)gas->address); + printf("0x%08lx (?)", (u_long)gas->Address); break; } } /* The FADT revision indicates whether we use the DSDT or X_DSDT addresses. */ static int -acpi_get_fadt_revision(struct FADTbody *fadt) +acpi_get_fadt_revision(ACPI_TABLE_FADT *fadt) { int fadt_revision; @@ -141,8 +149,8 @@ acpi_get_fadt_revision(struct FADTbody *fadt) * 32 and 64 bit versions don't match, prefer the 32 bit * version for all subsequent tables. */ - if (fadt->facs_ptr != 0 && - (fadt->x_facs_ptr & 0xffffffff) != fadt->facs_ptr) + if (fadt->Facs != 0 && + (fadt->XFacs & 0xffffffff) != fadt->Facs) fadt_revision = 1; } else fadt_revision = 1; @@ -150,34 +158,51 @@ acpi_get_fadt_revision(struct FADTbody *fadt) } static void -acpi_handle_fadt(struct ACPIsdt *sdp) +acpi_handle_fadt(ACPI_TABLE_HEADER *sdp) { - struct ACPIsdt *dsdp; - struct FACSbody *facs; - struct FADTbody *fadt; + ACPI_TABLE_HEADER *dsdp; + ACPI_TABLE_FACS *facs; + ACPI_TABLE_FADT *fadt; int fadt_revision; - fadt = (struct FADTbody *)sdp->body; + fadt = (ACPI_TABLE_FADT *)sdp; acpi_print_fadt(sdp); fadt_revision = acpi_get_fadt_revision(fadt); if (fadt_revision == 1) - facs = (struct FACSbody *)acpi_map_sdt(fadt->facs_ptr); + facs = (ACPI_TABLE_FACS *)acpi_map_sdt(fadt->Facs); else - facs = (struct FACSbody *)acpi_map_sdt(fadt->x_facs_ptr); - if (memcmp(facs->signature, "FACS", 4) != 0 || facs->len < 64) + facs = (ACPI_TABLE_FACS *)acpi_map_sdt(fadt->XFacs); + if (memcmp(facs->Signature, ACPI_SIG_FACS, 4) != 0 || facs->Length < 64) errx(1, "FACS is corrupt"); acpi_print_facs(facs); if (fadt_revision == 1) - dsdp = (struct ACPIsdt *)acpi_map_sdt(fadt->dsdt_ptr); + dsdp = (ACPI_TABLE_HEADER *)acpi_map_sdt(fadt->Dsdt); else - dsdp = (struct ACPIsdt *)acpi_map_sdt(fadt->x_dsdt_ptr); - if (acpi_checksum(dsdp, dsdp->len)) + dsdp = (ACPI_TABLE_HEADER *)acpi_map_sdt(fadt->XDsdt); + if (acpi_checksum(dsdp, dsdp->Length)) errx(1, "DSDT is corrupt"); acpi_print_dsdt(dsdp); } +static void +acpi_walk_subtables(ACPI_TABLE_HEADER *table, void *first, + void (*action)(ACPI_SUBTABLE_HEADER *)) +{ + ACPI_SUBTABLE_HEADER *subtable; + char *end; + + subtable = first; + end = (char *)table + table->Length; + while ((char *)subtable < end) { + printf("\n"); + action(subtable); + subtable = (ACPI_SUBTABLE_HEADER *)((char *)subtable + + subtable->Length); + } +} + static void acpi_print_cpu(u_char cpu_id) { @@ -190,219 +215,264 @@ acpi_print_cpu(u_char cpu_id) } static void -acpi_print_local_apic(u_char cpu_id, u_char apic_id, u_int32_t flags) +acpi_print_cpu_uid(uint32_t uid, char *uid_string) { - acpi_print_cpu(cpu_id); + + printf("\tUID=%d", uid); + if (uid_string != NULL) + printf(" (%s)", uid_string); + printf("\n"); +} + +static void +acpi_print_local_apic(uint32_t apic_id, uint32_t flags) +{ + printf("\tFlags={"); - if (flags & ACPI_MADT_APIC_LOCAL_FLAG_ENABLED) + if (flags & ACPI_MADT_ENABLED) printf("ENABLED"); else printf("DISABLED"); printf("}\n"); - printf("\tAPIC ID=%d\n", (u_int)apic_id); + printf("\tAPIC ID=%d\n", apic_id); } static void -acpi_print_io_apic(u_char apic_id, u_int32_t int_base, u_int64_t apic_addr) +acpi_print_io_apic(uint32_t apic_id, uint32_t int_base, uint64_t apic_addr) { - printf("\tAPIC ID=%d\n", (u_int)apic_id); + + printf("\tAPIC ID=%d\n", apic_id); printf("\tINT BASE=%d\n", int_base); - printf("\tADDR=0x%016jx\n", apic_addr); + printf("\tADDR=0x%016jx\n", (uintmax_t)apic_addr); } static void -acpi_print_mps_flags(u_int16_t flags) +acpi_print_mps_flags(uint16_t flags) { printf("\tFlags={Polarity="); - switch (flags & MPS_INT_FLAG_POLARITY_MASK) { - case MPS_INT_FLAG_POLARITY_CONFORM: + switch (flags & ACPI_MADT_POLARITY_MASK) { + case ACPI_MADT_POLARITY_CONFORMS: printf("conforming"); break; - case MPS_INT_FLAG_POLARITY_HIGH: + case ACPI_MADT_POLARITY_ACTIVE_HIGH: printf("active-hi"); break; - case MPS_INT_FLAG_POLARITY_LOW: + case ACPI_MADT_POLARITY_ACTIVE_LOW: printf("active-lo"); break; default: - printf("0x%x", flags & MPS_INT_FLAG_POLARITY_MASK); + printf("0x%x", flags & ACPI_MADT_POLARITY_MASK); break; } printf(", Trigger="); - switch (flags & MPS_INT_FLAG_TRIGGER_MASK) { - case MPS_INT_FLAG_TRIGGER_CONFORM: + switch (flags & ACPI_MADT_TRIGGER_MASK) { + case ACPI_MADT_TRIGGER_CONFORMS: printf("conforming"); break; - case MPS_INT_FLAG_TRIGGER_EDGE: + case ACPI_MADT_TRIGGER_EDGE: printf("edge"); break; - case MPS_INT_FLAG_TRIGGER_LEVEL: + case ACPI_MADT_TRIGGER_LEVEL: printf("level"); break; default: - printf("0x%x", (flags & MPS_INT_FLAG_TRIGGER_MASK) >> 2); + printf("0x%x", (flags & ACPI_MADT_TRIGGER_MASK) >> 2); } printf("}\n"); } static void -acpi_print_intr(u_int32_t intr, u_int16_t mps_flags) +acpi_print_intr(uint32_t intr, uint16_t mps_flags) { - printf("\tINTR=%d\n", (u_int)intr); + printf("\tINTR=%d\n", intr); + acpi_print_mps_flags(mps_flags); +} + +static void +acpi_print_local_nmi(u_int lint, uint16_t mps_flags) +{ + + printf("\tLINT Pin=%d\n", lint); acpi_print_mps_flags(mps_flags); } const char *apic_types[] = { "Local APIC", "IO APIC", "INT Override", "NMI", - "Local NMI", "Local APIC Override", "IO SAPIC", - "Local SAPIC", "Platform Interrupt" }; -const char *platform_int_types[] = { "PMI", "INIT", + "Local APIC NMI", "Local APIC Override", + "IO SAPIC", "Local SAPIC", "Platform Interrupt", + "Local X2APIC", "Local X2APIC NMI" }; +const char *platform_int_types[] = { "0 (unknown)", "PMI", "INIT", "Corrected Platform Error" }; static void -acpi_print_apic(struct MADT_APIC *mp) +acpi_print_madt(ACPI_SUBTABLE_HEADER *mp) { + ACPI_MADT_LOCAL_APIC *lapic; + ACPI_MADT_IO_APIC *ioapic; + ACPI_MADT_INTERRUPT_OVERRIDE *over; + ACPI_MADT_NMI_SOURCE *nmi; + ACPI_MADT_LOCAL_APIC_NMI *lapic_nmi; + ACPI_MADT_LOCAL_APIC_OVERRIDE *lapic_over; + ACPI_MADT_IO_SAPIC *iosapic; + ACPI_MADT_LOCAL_SAPIC *lsapic; + ACPI_MADT_INTERRUPT_SOURCE *isrc; + ACPI_MADT_LOCAL_X2APIC *x2apic; + ACPI_MADT_LOCAL_X2APIC_NMI *x2apic_nmi; - if (mp->type < sizeof(apic_types) / sizeof(apic_types[0])) - printf("\tType=%s\n", apic_types[mp->type]); + if (mp->Type < sizeof(apic_types) / sizeof(apic_types[0])) + printf("\tType=%s\n", apic_types[mp->Type]); else - printf("\tType=%d (unknown)\n", mp->type); - switch (mp->type) { - case ACPI_MADT_APIC_TYPE_LOCAL_APIC: - acpi_print_local_apic(mp->body.local_apic.cpu_id, - mp->body.local_apic.apic_id, mp->body.local_apic.flags); + printf("\tType=%d (unknown)\n", mp->Type); + switch (mp->Type) { + case ACPI_MADT_TYPE_LOCAL_APIC: + lapic = (ACPI_MADT_LOCAL_APIC *)mp; + acpi_print_cpu(lapic->ProcessorId); + acpi_print_local_apic(lapic->Id, lapic->LapicFlags); break; - case ACPI_MADT_APIC_TYPE_IO_APIC: - acpi_print_io_apic(mp->body.io_apic.apic_id, - mp->body.io_apic.int_base, - mp->body.io_apic.apic_addr); + case ACPI_MADT_TYPE_IO_APIC: + ioapic = (ACPI_MADT_IO_APIC *)mp; + acpi_print_io_apic(ioapic->Id, ioapic->GlobalIrqBase, + ioapic->Address); break; - case ACPI_MADT_APIC_TYPE_INT_OVERRIDE: - printf("\tBUS=%d\n", (u_int)mp->body.int_override.bus); - printf("\tIRQ=%d\n", (u_int)mp->body.int_override.source); - acpi_print_intr(mp->body.int_override.intr, - mp->body.int_override.mps_flags); + case ACPI_MADT_TYPE_INTERRUPT_OVERRIDE: + over = (ACPI_MADT_INTERRUPT_OVERRIDE *)mp; + printf("\tBUS=%d\n", (u_int)over->Bus); + printf("\tIRQ=%d\n", (u_int)over->SourceIrq); + acpi_print_intr(over->GlobalIrq, over->IntiFlags); break; - case ACPI_MADT_APIC_TYPE_NMI: - acpi_print_intr(mp->body.nmi.intr, mp->body.nmi.mps_flags); + case ACPI_MADT_TYPE_NMI_SOURCE: + nmi = (ACPI_MADT_NMI_SOURCE *)mp; + acpi_print_intr(nmi->GlobalIrq, nmi->IntiFlags); break; - case ACPI_MADT_APIC_TYPE_LOCAL_NMI: - acpi_print_cpu(mp->body.local_nmi.cpu_id); - printf("\tLINT Pin=%d\n", mp->body.local_nmi.lintpin); - acpi_print_mps_flags(mp->body.local_nmi.mps_flags); + case ACPI_MADT_TYPE_LOCAL_APIC_NMI: + lapic_nmi = (ACPI_MADT_LOCAL_APIC_NMI *)mp; + acpi_print_cpu(lapic_nmi->ProcessorId); + acpi_print_local_nmi(lapic_nmi->Lint, lapic_nmi->IntiFlags); break; - case ACPI_MADT_APIC_TYPE_LOCAL_OVERRIDE: + case ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE: + lapic_over = (ACPI_MADT_LOCAL_APIC_OVERRIDE *)mp; printf("\tLocal APIC ADDR=0x%016jx\n", - mp->body.local_apic_override.apic_addr); + (uintmax_t)lapic_over->Address); break; - case ACPI_MADT_APIC_TYPE_IO_SAPIC: - acpi_print_io_apic(mp->body.io_sapic.apic_id, - mp->body.io_sapic.int_base, - mp->body.io_sapic.apic_addr); + case ACPI_MADT_TYPE_IO_SAPIC: + iosapic = (ACPI_MADT_IO_SAPIC *)mp; + acpi_print_io_apic(iosapic->Id, iosapic->GlobalIrqBase, + iosapic->Address); break; - case ACPI_MADT_APIC_TYPE_LOCAL_SAPIC: - acpi_print_local_apic(mp->body.local_sapic.cpu_id, - mp->body.local_sapic.apic_id, mp->body.local_sapic.flags); - printf("\tAPIC EID=%d\n", (u_int)mp->body.local_sapic.apic_eid); + case ACPI_MADT_TYPE_LOCAL_SAPIC: + lsapic = (ACPI_MADT_LOCAL_SAPIC *)mp; + acpi_print_cpu(lsapic->ProcessorId); + acpi_print_local_apic(lsapic->Id, lsapic->LapicFlags); + printf("\tAPIC EID=%d\n", (u_int)lsapic->Eid); + if (mp->Length > __offsetof(ACPI_MADT_LOCAL_SAPIC, Uid)) + acpi_print_cpu_uid(lsapic->Uid, lsapic->UidString); break; - case ACPI_MADT_APIC_TYPE_INT_SRC: - printf("\tType=%s\n", - platform_int_types[mp->body.int_src.type]); - printf("\tCPU ID=%d\n", (u_int)mp->body.int_src.cpu_id); - printf("\tCPU EID=%d\n", (u_int)mp->body.int_src.cpu_id); - printf("\tSAPIC Vector=%d\n", - (u_int)mp->body.int_src.sapic_vector); - acpi_print_intr(mp->body.int_src.intr, - mp->body.int_src.mps_flags); + case ACPI_MADT_TYPE_INTERRUPT_SOURCE: + isrc = (ACPI_MADT_INTERRUPT_SOURCE *)mp; + if (isrc->Type < sizeof(platform_int_types) / + sizeof(platform_int_types[0])) + printf("\tType=%s\n", platform_int_types[isrc->Type]); + else + printf("\tType=%d (unknown)\n", isrc->Type); + printf("\tAPIC ID=%d\n", (u_int)isrc->Id); + printf("\tAPIC EID=%d\n", (u_int)isrc->Eid); + printf("\tSAPIC Vector=%d\n", (u_int)isrc->IoSapicVector); + acpi_print_intr(isrc->GlobalIrq, isrc->IntiFlags); + break; + case ACPI_MADT_TYPE_LOCAL_X2APIC: + x2apic = (ACPI_MADT_LOCAL_X2APIC *)mp; + acpi_print_cpu_uid(x2apic->Uid, NULL); + acpi_print_local_apic(x2apic->LocalApicId, x2apic->LapicFlags); + break; + case ACPI_MADT_TYPE_LOCAL_X2APIC_NMI: + x2apic_nmi = (ACPI_MADT_LOCAL_X2APIC_NMI *)mp; + acpi_print_cpu_uid(x2apic_nmi->Uid, NULL); + acpi_print_local_nmi(x2apic_nmi->Lint, x2apic_nmi->IntiFlags); break; } } static void -acpi_handle_apic(struct ACPIsdt *sdp) +acpi_handle_madt(ACPI_TABLE_HEADER *sdp) { - struct MADTbody *madtp; - struct MADT_APIC *madt_apicp; + ACPI_TABLE_MADT *madt; printf(BEGIN_COMMENT); acpi_print_sdt(sdp); - madtp = (struct MADTbody *) sdp->body; - printf("\tLocal APIC ADDR=0x%08x\n", madtp->lapic_addr); + madt = (ACPI_TABLE_MADT *)sdp; + printf("\tLocal APIC ADDR=0x%08x\n", madt->Address); printf("\tFlags={"); - if (madtp->flags & ACPI_APIC_FLAG_PCAT_COMPAT) + if (madt->Flags & ACPI_MADT_PCAT_COMPAT) printf("PC-AT"); printf("}\n"); - madt_apicp = (struct MADT_APIC *)madtp->body; - while (((uintptr_t)madt_apicp) - ((uintptr_t)sdp) < sdp->len) { - printf("\n"); - acpi_print_apic(madt_apicp); - madt_apicp = (struct MADT_APIC *) ((char *)madt_apicp + - madt_apicp->len); - } + acpi_walk_subtables(sdp, (madt + 1), acpi_print_madt); printf(END_COMMENT); } static void -acpi_handle_hpet(struct ACPIsdt *sdp) +acpi_handle_hpet(ACPI_TABLE_HEADER *sdp) { - struct HPETbody *hpetp; + ACPI_TABLE_HPET *hpet; printf(BEGIN_COMMENT); acpi_print_sdt(sdp); - hpetp = (struct HPETbody *) sdp->body; - printf("\tHPET Number=%d\n", hpetp->hpet_number); + hpet = (ACPI_TABLE_HPET *)sdp; + printf("\tHPET Number=%d\n", hpet->Sequence); printf("\tADDR="); - acpi_print_gas(&hpetp->genaddr); - printf("\tHW Rev=0x%x\n", hpetp->block_hwrev); - printf("\tComparitors=%d\n", hpetp->block_comparitors); - printf("\tCounter Size=%d\n", hpetp->block_counter_size); + acpi_print_gas(&hpet->Address); + printf("\tHW Rev=0x%x\n", hpet->Id & ACPI_HPET_ID_HARDWARE_REV_ID); + printf("\tComparators=%d\n", (hpet->Id & ACPI_HPET_ID_COMPARATORS) >> + 8); + printf("\tCounter Size=%d\n", hpet->Id & ACPI_HPET_ID_COUNT_SIZE_CAP ? + 1 : 0); printf("\tLegacy IRQ routing capable={"); - if (hpetp->block_legacy_capable) + if (hpet->Id & ACPI_HPET_ID_LEGACY_CAPABLE) printf("TRUE}\n"); else printf("FALSE}\n"); - printf("\tPCI Vendor ID=0x%04x\n", hpetp->block_pcivendor); - printf("\tMinimal Tick=%d\n", hpetp->clock_tick); + printf("\tPCI Vendor ID=0x%04x\n", hpet->Id >> 16); + printf("\tMinimal Tick=%d\n", hpet->MinimumTick); printf(END_COMMENT); } static void -acpi_handle_ecdt(struct ACPIsdt *sdp) +acpi_handle_ecdt(ACPI_TABLE_HEADER *sdp) { - struct ECDTbody *ecdt; + ACPI_TABLE_ECDT *ecdt; printf(BEGIN_COMMENT); acpi_print_sdt(sdp); - ecdt = (struct ECDTbody *) sdp->body; + ecdt = (ACPI_TABLE_ECDT *)sdp; printf("\tEC_CONTROL="); - acpi_print_gas(&ecdt->ec_control); + acpi_print_gas(&ecdt->Control); printf("\n\tEC_DATA="); - acpi_print_gas(&ecdt->ec_data); - printf("\n\tUID=%#x, ", ecdt->uid); - printf("GPE_BIT=%#x\n", ecdt->gpe_bit); - printf("\tEC_ID=%s\n", ecdt->ec_id); + acpi_print_gas(&ecdt->Data); + printf("\n\tUID=%#x, ", ecdt->Uid); + printf("GPE_BIT=%#x\n", ecdt->Gpe); + printf("\tEC_ID=%s\n", ecdt->Id); printf(END_COMMENT); } static void -acpi_handle_mcfg(struct ACPIsdt *sdp) +acpi_handle_mcfg(ACPI_TABLE_HEADER *sdp) { - struct MCFGbody *mcfg; - u_int i, e; + ACPI_TABLE_MCFG *mcfg; + ACPI_MCFG_ALLOCATION *alloc; + u_int i, entries; printf(BEGIN_COMMENT); acpi_print_sdt(sdp); - mcfg = (struct MCFGbody *) sdp->body; - - e = (sdp->len - ((caddr_t)&mcfg->s[0] - (caddr_t)sdp)) / - sizeof(*mcfg->s); - for (i = 0; i < e; i++, mcfg++) { + mcfg = (ACPI_TABLE_MCFG *)sdp; + entries = (sdp->Length - sizeof(ACPI_TABLE_MCFG)) / + sizeof(ACPI_MCFG_ALLOCATION); + alloc = (ACPI_MCFG_ALLOCATION *)(mcfg + 1); + for (i = 0; i < entries; i++, alloc++) { printf("\n"); - printf("\tBase Address=0x%016jx\n", mcfg->s[i].baseaddr); - printf("\tSegment Group=0x%04x\n", mcfg->s[i].seg_grp); - printf("\tStart Bus=%d\n", mcfg->s[i].start); - printf("\tEnd Bus=%d\n", mcfg->s[i].end); + printf("\tBase Address=0x%016jx\n", alloc->Address); + printf("\tSegment Group=0x%04x\n", alloc->PciSegment); + printf("\tStart Bus=%d\n", alloc->StartBusNumber); + printf("\tEnd Bus=%d\n", alloc->EndBusNumber); } printf(END_COMMENT); } @@ -423,108 +493,109 @@ acpi_print_srat_cpu(uint32_t apic_id, uint32_t proximity_domain, } static void -acpi_print_srat_memory(struct SRAT_memory *mp) +acpi_print_srat_memory(ACPI_SRAT_MEM_AFFINITY *mp) { printf("\tFlags={"); - if (mp->flags & ACPI_SRAT_MEM_ENABLED) + if (mp->Flags & ACPI_SRAT_MEM_ENABLED) printf("ENABLED"); else printf("DISABLED"); - if (mp->flags & ACPI_SRAT_MEM_HOT_PLUGGABLE) + if (mp->Flags & ACPI_SRAT_MEM_HOT_PLUGGABLE) printf(",HOT_PLUGGABLE"); - if (mp->flags & ACPI_SRAT_MEM_NON_VOLATILE) + if (mp->Flags & ACPI_SRAT_MEM_NON_VOLATILE) printf(",NON_VOLATILE"); printf("}\n"); - printf("\tBase Address=0x%016jx\n", (uintmax_t)mp->base_address); - printf("\tLength=0x%016jx\n", (uintmax_t)mp->length); - printf("\tProximity Domain=%d\n", mp->proximity_domain); + printf("\tBase Address=0x%016jx\n", (uintmax_t)mp->BaseAddress); + printf("\tLength=0x%016jx\n", (uintmax_t)mp->Length); + printf("\tProximity Domain=%d\n", mp->ProximityDomain); } const char *srat_types[] = { "CPU", "Memory", "X2APIC" }; static void -acpi_print_srat(struct SRATentry *srat) +acpi_print_srat(ACPI_SUBTABLE_HEADER *srat) { + ACPI_SRAT_CPU_AFFINITY *cpu; + ACPI_SRAT_X2APIC_CPU_AFFINITY *x2apic; - if (srat->type < sizeof(srat_types) / sizeof(srat_types[0])) - printf("\tType=%s\n", srat_types[srat->type]); + if (srat->Type < sizeof(srat_types) / sizeof(srat_types[0])) + printf("\tType=%s\n", srat_types[srat->Type]); else - printf("\tType=%d (unknown)\n", srat->type); - switch (srat->type) { + printf("\tType=%d (unknown)\n", srat->Type); + switch (srat->Type) { case ACPI_SRAT_TYPE_CPU_AFFINITY: - acpi_print_srat_cpu(srat->body.cpu.apic_id, - srat->body.cpu.proximity_domain_hi[2] << 24 | - srat->body.cpu.proximity_domain_hi[1] << 16 | - srat->body.cpu.proximity_domain_hi[0] << 0 | - srat->body.cpu.proximity_domain_lo, srat->body.cpu.flags); + cpu = (ACPI_SRAT_CPU_AFFINITY *)srat; + acpi_print_srat_cpu(cpu->ApicId, + cpu->ProximityDomainHi[2] << 24 | + cpu->ProximityDomainHi[1] << 16 | + cpu->ProximityDomainHi[0] << 0 | + cpu->ProximityDomainLo, cpu->Flags); break; case ACPI_SRAT_TYPE_MEMORY_AFFINITY: - acpi_print_srat_memory(&srat->body.mem); + acpi_print_srat_memory((ACPI_SRAT_MEM_AFFINITY *)srat); break; case ACPI_SRAT_TYPE_X2APIC_CPU_AFFINITY: - acpi_print_srat_cpu(srat->body.x2apic.apic_id, - srat->body.x2apic.proximity_domain, - srat->body.x2apic.flags); + x2apic = (ACPI_SRAT_X2APIC_CPU_AFFINITY *)srat; + acpi_print_srat_cpu(x2apic->ApicId, x2apic->ProximityDomain, + x2apic->Flags); break; } } static void -acpi_handle_srat(struct ACPIsdt *sdp) +acpi_handle_srat(ACPI_TABLE_HEADER *sdp) { - struct SRATbody *sratp; - struct SRATentry *entry; + ACPI_TABLE_SRAT *srat; printf(BEGIN_COMMENT); acpi_print_sdt(sdp); - sratp = (struct SRATbody *)sdp->body; - printf("\tTable Revision=%d\n", sratp->table_revision); - entry = sratp->body; - while (((uintptr_t)entry) - ((uintptr_t)sdp) < sdp->len) { - printf("\n"); - acpi_print_srat(entry); - entry = (struct SRATentry *)((char *)entry + entry->len); - } + srat = (ACPI_TABLE_SRAT *)sdp; + printf("\tTable Revision=%d\n", srat->TableRevision); + acpi_walk_subtables(sdp, (srat + 1), acpi_print_srat); printf(END_COMMENT); } static void -acpi_print_sdt(struct ACPIsdt *sdp) +acpi_print_sdt(ACPI_TABLE_HEADER *sdp) { printf(" "); - acpi_print_string(sdp->signature, 4); + acpi_print_string(sdp->Signature, ACPI_NAME_SIZE); printf(": Length=%d, Revision=%d, Checksum=%d,\n", - sdp->len, sdp->rev, sdp->check); + sdp->Length, sdp->Revision, sdp->Checksum); printf("\tOEMID="); - acpi_print_string(sdp->oemid, 6); + acpi_print_string(sdp->OemId, ACPI_OEM_ID_SIZE); printf(", OEM Table ID="); - acpi_print_string(sdp->oemtblid, 8); - printf(", OEM Revision=0x%x,\n", sdp->oemrev); + acpi_print_string(sdp->OemTableId, ACPI_OEM_TABLE_ID_SIZE); + printf(", OEM Revision=0x%x,\n", sdp->OemRevision); printf("\tCreator ID="); - acpi_print_string(sdp->creator, 4); - printf(", Creator Revision=0x%x\n", sdp->crerev); + acpi_print_string(sdp->AslCompilerId, ACPI_NAME_SIZE); + printf(", Creator Revision=0x%x\n", sdp->AslCompilerRevision); } static void -acpi_print_rsdt(struct ACPIsdt *rsdp) +acpi_print_rsdt(ACPI_TABLE_HEADER *rsdp) { + ACPI_TABLE_RSDT *rsdt; + ACPI_TABLE_XSDT *xsdt; int i, entries; u_long addr; + rsdt = (ACPI_TABLE_RSDT *)rsdp; + xsdt = (ACPI_TABLE_XSDT *)rsdp; printf(BEGIN_COMMENT); acpi_print_sdt(rsdp); - entries = (rsdp->len - SIZEOF_SDT_HDR) / addr_size; + entries = (rsdp->Length - sizeof(ACPI_TABLE_HEADER)) / addr_size; printf("\tEntries={ "); for (i = 0; i < entries; i++) { if (i > 0) printf(", "); switch (addr_size) { case 4: - addr = le32dec((char*)rsdp->body + i * addr_size); + addr = le32toh(rsdt->TableOffsetEntry[i]); break; case 8: - addr = le64dec((char*)rsdp->body + i * addr_size); + addr = le64toh(xsdt->TableOffsetEntry[i]); break; default: addr = 0; @@ -542,138 +613,147 @@ static const char *acpi_pm_profiles[] = { }; static void -acpi_print_fadt(struct ACPIsdt *sdp) +acpi_print_fadt(ACPI_TABLE_HEADER *sdp) { - struct FADTbody *fadt; + ACPI_TABLE_FADT *fadt; const char *pm; char sep; - fadt = (struct FADTbody *)sdp->body; + fadt = (ACPI_TABLE_FADT *)sdp; printf(BEGIN_COMMENT); acpi_print_sdt(sdp); - printf(" \tFACS=0x%x, DSDT=0x%x\n", fadt->facs_ptr, - fadt->dsdt_ptr); - printf("\tINT_MODEL=%s\n", fadt->int_model ? "APIC" : "PIC"); - if (fadt->pm_profile >= sizeof(acpi_pm_profiles) / sizeof(char *)) + printf(" \tFACS=0x%x, DSDT=0x%x\n", fadt->Facs, + fadt->Dsdt); + printf("\tINT_MODEL=%s\n", fadt->Model ? "APIC" : "PIC"); + if (fadt->PreferredProfile >= sizeof(acpi_pm_profiles) / sizeof(char *)) pm = "Reserved"; else - pm = acpi_pm_profiles[fadt->pm_profile]; - printf("\tPreferred_PM_Profile=%s (%d)\n", pm, fadt->pm_profile); - printf("\tSCI_INT=%d\n", fadt->sci_int); - printf("\tSMI_CMD=0x%x, ", fadt->smi_cmd); - printf("ACPI_ENABLE=0x%x, ", fadt->acpi_enable); - printf("ACPI_DISABLE=0x%x, ", fadt->acpi_disable); - printf("S4BIOS_REQ=0x%x\n", fadt->s4biosreq); - printf("\tPSTATE_CNT=0x%x\n", fadt->pstate_cnt); + pm = acpi_pm_profiles[fadt->PreferredProfile]; + printf("\tPreferred_PM_Profile=%s (%d)\n", pm, fadt->PreferredProfile); + printf("\tSCI_INT=%d\n", fadt->SciInterrupt); + printf("\tSMI_CMD=0x%x, ", fadt->SmiCommand); + printf("ACPI_ENABLE=0x%x, ", fadt->AcpiEnable); + printf("ACPI_DISABLE=0x%x, ", fadt->AcpiDisable); + printf("S4BIOS_REQ=0x%x\n", fadt->S4BiosRequest); + printf("\tPSTATE_CNT=0x%x\n", fadt->PstateControl); printf("\tPM1a_EVT_BLK=0x%x-0x%x\n", - fadt->pm1a_evt_blk, - fadt->pm1a_evt_blk + fadt->pm1_evt_len - 1); - if (fadt->pm1b_evt_blk != 0) + fadt->Pm1aEventBlock, + fadt->Pm1aEventBlock + fadt->Pm1EventLength - 1); + if (fadt->Pm1bEventBlock != 0) printf("\tPM1b_EVT_BLK=0x%x-0x%x\n", - fadt->pm1b_evt_blk, - fadt->pm1b_evt_blk + fadt->pm1_evt_len - 1); + fadt->Pm1bEventBlock, + fadt->Pm1bEventBlock + fadt->Pm1EventLength - 1); printf("\tPM1a_CNT_BLK=0x%x-0x%x\n", - fadt->pm1a_cnt_blk, - fadt->pm1a_cnt_blk + fadt->pm1_cnt_len - 1); - if (fadt->pm1b_cnt_blk != 0) + fadt->Pm1aControlBlock, + fadt->Pm1aControlBlock + fadt->Pm1ControlLength - 1); + if (fadt->Pm1bControlBlock != 0) printf("\tPM1b_CNT_BLK=0x%x-0x%x\n", - fadt->pm1b_cnt_blk, - fadt->pm1b_cnt_blk + fadt->pm1_cnt_len - 1); - if (fadt->pm2_cnt_blk != 0) + fadt->Pm1bControlBlock, + fadt->Pm1bControlBlock + fadt->Pm1ControlLength - 1); + if (fadt->Pm2ControlBlock != 0) printf("\tPM2_CNT_BLK=0x%x-0x%x\n", - fadt->pm2_cnt_blk, - fadt->pm2_cnt_blk + fadt->pm2_cnt_len - 1); + fadt->Pm2ControlBlock, + fadt->Pm2ControlBlock + fadt->Pm2ControlLength - 1); printf("\tPM_TMR_BLK=0x%x-0x%x\n", - fadt->pm_tmr_blk, - fadt->pm_tmr_blk + fadt->pm_tmr_len - 1); - if (fadt->gpe0_blk != 0) + fadt->PmTimerBlock, + fadt->PmTimerBlock + fadt->PmTimerLength - 1); + if (fadt->Gpe0Block != 0) printf("\tGPE0_BLK=0x%x-0x%x\n", - fadt->gpe0_blk, - fadt->gpe0_blk + fadt->gpe0_len - 1); - if (fadt->gpe1_blk != 0) + fadt->Gpe0Block, + fadt->Gpe0Block + fadt->Gpe0BlockLength - 1); + if (fadt->Gpe1Block != 0) printf("\tGPE1_BLK=0x%x-0x%x, GPE1_BASE=%d\n", - fadt->gpe1_blk, - fadt->gpe1_blk + fadt->gpe1_len - 1, - fadt->gpe1_base); - if (fadt->cst_cnt != 0) - printf("\tCST_CNT=0x%x\n", fadt->cst_cnt); + fadt->Gpe1Block, + fadt->Gpe1Block + fadt->Gpe1BlockLength - 1, + fadt->Gpe1Base); + if (fadt->CstControl != 0) + printf("\tCST_CNT=0x%x\n", fadt->CstControl); printf("\tP_LVL2_LAT=%d us, P_LVL3_LAT=%d us\n", - fadt->p_lvl2_lat, fadt->p_lvl3_lat); + fadt->C2Latency, fadt->C3Latency); printf("\tFLUSH_SIZE=%d, FLUSH_STRIDE=%d\n", - fadt->flush_size, fadt->flush_stride); + fadt->FlushSize, fadt->FlushStride); printf("\tDUTY_OFFSET=%d, DUTY_WIDTH=%d\n", - fadt->duty_off, fadt->duty_width); + fadt->DutyOffset, fadt->DutyWidth); printf("\tDAY_ALRM=%d, MON_ALRM=%d, CENTURY=%d\n", - fadt->day_alrm, fadt->mon_alrm, fadt->century); + fadt->DayAlarm, fadt->MonthAlarm, fadt->Century); #define PRINTFLAG(var, flag) do { \ - if ((var) & FADT_FLAG_## flag) { \ + if ((var) & ACPI_FADT_## flag) { \ printf("%c%s", sep, #flag); sep = ','; \ } \ } while (0) printf("\tIAPC_BOOT_ARCH="); sep = '{'; - PRINTFLAG(fadt->iapc_boot_arch, LEGACY_DEV); - PRINTFLAG(fadt->iapc_boot_arch, 8042); - if (fadt->iapc_boot_arch != 0) + PRINTFLAG(fadt->BootFlags, LEGACY_DEVICES); + PRINTFLAG(fadt->BootFlags, 8042); + PRINTFLAG(fadt->BootFlags, NO_VGA); + PRINTFLAG(fadt->BootFlags, NO_MSI); + PRINTFLAG(fadt->BootFlags, NO_ASPM); + if (fadt->BootFlags != 0) printf("}"); printf("\n"); printf("\tFlags="); sep = '{'; - PRINTFLAG(fadt->flags, WBINVD); - PRINTFLAG(fadt->flags, WBINVD_FLUSH); - PRINTFLAG(fadt->flags, PROC_C1); - PRINTFLAG(fadt->flags, P_LVL2_UP); - PRINTFLAG(fadt->flags, PWR_BUTTON); - PRINTFLAG(fadt->flags, SLP_BUTTON); - PRINTFLAG(fadt->flags, FIX_RTC); - PRINTFLAG(fadt->flags, RTC_S4); - PRINTFLAG(fadt->flags, TMR_VAL_EXT); - PRINTFLAG(fadt->flags, DCK_CAP); - PRINTFLAG(fadt->flags, RESET_REG); - PRINTFLAG(fadt->flags, SEALED_CASE); - PRINTFLAG(fadt->flags, HEADLESS); - PRINTFLAG(fadt->flags, CPU_SW_SLP); - if (fadt->flags != 0) + PRINTFLAG(fadt->Flags, WBINVD); + PRINTFLAG(fadt->Flags, WBINVD_FLUSH); + PRINTFLAG(fadt->Flags, C1_SUPPORTED); + PRINTFLAG(fadt->Flags, C2_MP_SUPPORTED); + PRINTFLAG(fadt->Flags, POWER_BUTTON); + PRINTFLAG(fadt->Flags, SLEEP_BUTTON); + PRINTFLAG(fadt->Flags, FIXED_RTC); + PRINTFLAG(fadt->Flags, S4_RTC_WAKE); + PRINTFLAG(fadt->Flags, 32BIT_TIMER); + PRINTFLAG(fadt->Flags, DOCKING_SUPPORTED); + PRINTFLAG(fadt->Flags, RESET_REGISTER); + PRINTFLAG(fadt->Flags, SEALED_CASE); + PRINTFLAG(fadt->Flags, HEADLESS); + PRINTFLAG(fadt->Flags, SLEEP_TYPE); + PRINTFLAG(fadt->Flags, PCI_EXPRESS_WAKE); + PRINTFLAG(fadt->Flags, PLATFORM_CLOCK); + PRINTFLAG(fadt->Flags, S4_RTC_VALID); + PRINTFLAG(fadt->Flags, REMOTE_POWER_ON); + PRINTFLAG(fadt->Flags, APIC_CLUSTER); + PRINTFLAG(fadt->Flags, APIC_PHYSICAL); + if (fadt->Flags != 0) printf("}\n"); #undef PRINTFLAG - if (fadt->flags & FADT_FLAG_RESET_REG) { + if (fadt->Flags & ACPI_FADT_RESET_REGISTER) { printf("\tRESET_REG="); - acpi_print_gas(&fadt->reset_reg); - printf(", RESET_VALUE=%#x\n", fadt->reset_value); + acpi_print_gas(&fadt->ResetRegister); + printf(", RESET_VALUE=%#x\n", fadt->ResetValue); } if (acpi_get_fadt_revision(fadt) > 1) { - printf("\tX_FACS=0x%08lx, ", (u_long)fadt->x_facs_ptr); - printf("X_DSDT=0x%08lx\n", (u_long)fadt->x_dsdt_ptr); + printf("\tX_FACS=0x%08lx, ", (u_long)fadt->XFacs); + printf("X_DSDT=0x%08lx\n", (u_long)fadt->XDsdt); printf("\tX_PM1a_EVT_BLK="); - acpi_print_gas(&fadt->x_pm1a_evt_blk); - if (fadt->x_pm1b_evt_blk.address != 0) { + acpi_print_gas(&fadt->XPm1aEventBlock); + if (fadt->XPm1bEventBlock.Address != 0) { printf("\n\tX_PM1b_EVT_BLK="); - acpi_print_gas(&fadt->x_pm1b_evt_blk); + acpi_print_gas(&fadt->XPm1bEventBlock); } printf("\n\tX_PM1a_CNT_BLK="); - acpi_print_gas(&fadt->x_pm1a_cnt_blk); - if (fadt->x_pm1b_cnt_blk.address != 0) { + acpi_print_gas(&fadt->XPm1aControlBlock); + if (fadt->XPm1bControlBlock.Address != 0) { printf("\n\tX_PM1b_CNT_BLK="); - acpi_print_gas(&fadt->x_pm1b_cnt_blk); + acpi_print_gas(&fadt->XPm1bControlBlock); } - if (fadt->x_pm1b_cnt_blk.address != 0) { + if (fadt->XPm2ControlBlock.Address != 0) { printf("\n\tX_PM2_CNT_BLK="); - acpi_print_gas(&fadt->x_pm2_cnt_blk); + acpi_print_gas(&fadt->XPm2ControlBlock); } printf("\n\tX_PM_TMR_BLK="); - acpi_print_gas(&fadt->x_pm_tmr_blk); - if (fadt->x_gpe0_blk.address != 0) { + acpi_print_gas(&fadt->XPmTimerBlock); + if (fadt->XGpe0Block.Address != 0) { printf("\n\tX_GPE0_BLK="); - acpi_print_gas(&fadt->x_gpe0_blk); + acpi_print_gas(&fadt->XGpe0Block); } - if (fadt->x_gpe1_blk.address != 0) { + if (fadt->XGpe1Block.Address != 0) { printf("\n\tX_GPE1_BLK="); - acpi_print_gas(&fadt->x_gpe1_blk); + acpi_print_gas(&fadt->XGpe1Block); } printf("\n"); } @@ -682,38 +762,38 @@ acpi_print_fadt(struct ACPIsdt *sdp) } static void -acpi_print_facs(struct FACSbody *facs) +acpi_print_facs(ACPI_TABLE_FACS *facs) { printf(BEGIN_COMMENT); - printf(" FACS:\tLength=%u, ", facs->len); - printf("HwSig=0x%08x, ", facs->hw_sig); - printf("Firm_Wake_Vec=0x%08x\n", facs->firm_wake_vec); + printf(" FACS:\tLength=%u, ", facs->Length); + printf("HwSig=0x%08x, ", facs->HardwareSignature); + printf("Firm_Wake_Vec=0x%08x\n", facs->FirmwareWakingVector); printf("\tGlobal_Lock="); - if (facs->global_lock != 0) { - if (facs->global_lock & FACS_FLAG_LOCK_PENDING) + if (facs->GlobalLock != 0) { + if (facs->GlobalLock & ACPI_GLOCK_PENDING) printf("PENDING,"); - if (facs->global_lock & FACS_FLAG_LOCK_OWNED) + if (facs->GlobalLock & ACPI_GLOCK_OWNED) printf("OWNED"); } printf("\n"); printf("\tFlags="); - if (facs->flags & FACS_FLAG_S4BIOS_F) + if (facs->Flags & ACPI_FACS_S4_BIOS_PRESENT) printf("S4BIOS"); printf("\n"); - if (facs->x_firm_wake_vec != 0) { + if (facs->XFirmwareWakingVector != 0) { printf("\tX_Firm_Wake_Vec=%08lx\n", - (u_long)facs->x_firm_wake_vec); + (u_long)facs->XFirmwareWakingVector); } - printf("\tVersion=%u\n", facs->version); + printf("\tVersion=%u\n", facs->Version); printf(END_COMMENT); } static void -acpi_print_dsdt(struct ACPIsdt *dsdp) +acpi_print_dsdt(ACPI_TABLE_HEADER *dsdp) { printf(BEGIN_COMMENT); acpi_print_sdt(dsdp); @@ -723,8 +803,8 @@ acpi_print_dsdt(struct ACPIsdt *dsdp) int acpi_checksum(void *p, size_t length) { - u_int8_t *bp; - u_int8_t sum; + uint8_t *bp; + uint8_t sum; bp = p; sum = 0; @@ -734,71 +814,77 @@ acpi_checksum(void *p, size_t length) return (sum); } -static struct ACPIsdt * +static ACPI_TABLE_HEADER * acpi_map_sdt(vm_offset_t pa) { - struct ACPIsdt *sp; + ACPI_TABLE_HEADER *sp; - sp = acpi_map_physical(pa, sizeof(struct ACPIsdt)); - sp = acpi_map_physical(pa, sp->len); + sp = acpi_map_physical(pa, sizeof(ACPI_TABLE_HEADER)); + sp = acpi_map_physical(pa, sp->Length); return (sp); } static void -acpi_print_rsd_ptr(struct ACPIrsdp *rp) +acpi_print_rsd_ptr(ACPI_TABLE_RSDP *rp) { printf(BEGIN_COMMENT); printf(" RSD PTR: OEM="); - acpi_print_string(rp->oem, 6); - printf(", ACPI_Rev=%s (%d)\n", rp->revision < 2 ? "1.0x" : "2.0x", - rp->revision); - if (rp->revision < 2) { - printf("\tRSDT=0x%08x, cksum=%u\n", rp->rsdt_addr, rp->sum); + acpi_print_string(rp->OemId, ACPI_OEM_ID_SIZE); + printf(", ACPI_Rev=%s (%d)\n", rp->Revision < 2 ? "1.0x" : "2.0x", + rp->Revision); + if (rp->Revision < 2) { + printf("\tRSDT=0x%08x, cksum=%u\n", rp->RsdtPhysicalAddress, + rp->Checksum); } else { printf("\tXSDT=0x%08lx, length=%u, cksum=%u\n", - (u_long)rp->xsdt_addr, rp->length, rp->xsum); + (u_long)rp->XsdtPhysicalAddress, rp->Length, + rp->ExtendedChecksum); } printf(END_COMMENT); } static void -acpi_handle_rsdt(struct ACPIsdt *rsdp) +acpi_handle_rsdt(ACPI_TABLE_HEADER *rsdp) { - struct ACPIsdt *sdp; + ACPI_TABLE_HEADER *sdp; + ACPI_TABLE_RSDT *rsdt; + ACPI_TABLE_XSDT *xsdt; vm_offset_t addr; int entries, i; acpi_print_rsdt(rsdp); - entries = (rsdp->len - SIZEOF_SDT_HDR) / addr_size; + rsdt = (ACPI_TABLE_RSDT *)rsdp; + xsdt = (ACPI_TABLE_XSDT *)rsdp; + entries = (rsdp->Length - sizeof(ACPI_TABLE_HEADER)) / addr_size; for (i = 0; i < entries; i++) { switch (addr_size) { case 4: - addr = le32dec((char*)rsdp->body + i * addr_size); + addr = le32toh(rsdt->TableOffsetEntry[i]); break; case 8: - addr = le64dec((char*)rsdp->body + i * addr_size); + addr = le64toh(xsdt->TableOffsetEntry[i]); break; default: assert((addr = 0)); } - sdp = (struct ACPIsdt *)acpi_map_sdt(addr); - if (acpi_checksum(sdp, sdp->len)) { + sdp = (ACPI_TABLE_HEADER *)acpi_map_sdt(addr); + if (acpi_checksum(sdp, sdp->Length)) { warnx("RSDT entry %d (sig %.4s) is corrupt", i, - sdp->signature); + sdp->Signature); continue; } - if (!memcmp(sdp->signature, "FACP", 4)) + if (!memcmp(sdp->Signature, ACPI_SIG_FADT, 4)) acpi_handle_fadt(sdp); - else if (!memcmp(sdp->signature, "APIC", 4)) - acpi_handle_apic(sdp); - else if (!memcmp(sdp->signature, "HPET", 4)) + else if (!memcmp(sdp->Signature, ACPI_SIG_MADT, 4)) + acpi_handle_madt(sdp); + else if (!memcmp(sdp->Signature, ACPI_SIG_HPET, 4)) acpi_handle_hpet(sdp); - else if (!memcmp(sdp->signature, "ECDT", 4)) + else if (!memcmp(sdp->Signature, ACPI_SIG_ECDT, 4)) acpi_handle_ecdt(sdp); - else if (!memcmp(sdp->signature, "MCFG", 4)) + else if (!memcmp(sdp->Signature, ACPI_SIG_MCFG, 4)) acpi_handle_mcfg(sdp); - else if (!memcmp(sdp->signature, "SRAT", 4)) + else if (!memcmp(sdp->Signature, ACPI_SIG_SRAT, 4)) acpi_handle_srat(sdp); else { printf(BEGIN_COMMENT); @@ -808,11 +894,11 @@ acpi_handle_rsdt(struct ACPIsdt *rsdp) } } -struct ACPIsdt * +ACPI_TABLE_HEADER * sdt_load_devmem(void) { - struct ACPIrsdp *rp; - struct ACPIsdt *rsdp; + ACPI_TABLE_RSDP *rp; + ACPI_TABLE_HEADER *rsdp; rp = acpi_find_rsd_ptr(); if (!rp) @@ -820,16 +906,16 @@ sdt_load_devmem(void) if (tflag) acpi_print_rsd_ptr(rp); - if (rp->revision < 2) { - rsdp = (struct ACPIsdt *)acpi_map_sdt(rp->rsdt_addr); - if (memcmp(rsdp->signature, "RSDT", 4) != 0 || - acpi_checksum(rsdp, rsdp->len) != 0) + if (rp->Revision < 2) { + rsdp = (ACPI_TABLE_HEADER *)acpi_map_sdt(rp->RsdtPhysicalAddress); + if (memcmp(rsdp->Signature, "RSDT", 4) != 0 || + acpi_checksum(rsdp, rsdp->Length) != 0) errx(1, "RSDT is corrupted"); addr_size = sizeof(uint32_t); } else { - rsdp = (struct ACPIsdt *)acpi_map_sdt(rp->xsdt_addr); - if (memcmp(rsdp->signature, "XSDT", 4) != 0 || - acpi_checksum(rsdp, rsdp->len) != 0) + rsdp = (ACPI_TABLE_HEADER *)acpi_map_sdt(rp->XsdtPhysicalAddress); + if (memcmp(rsdp->Signature, "XSDT", 4) != 0 || + acpi_checksum(rsdp, rsdp->Length) != 0) errx(1, "XSDT is corrupted"); addr_size = sizeof(uint64_t); } @@ -838,37 +924,39 @@ sdt_load_devmem(void) /* Write the DSDT to a file, concatenating any SSDTs (if present). */ static int -write_dsdt(int fd, struct ACPIsdt *rsdt, struct ACPIsdt *dsdt) +write_dsdt(int fd, ACPI_TABLE_HEADER *rsdt, ACPI_TABLE_HEADER *dsdt) { - struct ACPIsdt sdt; - struct ACPIsdt *ssdt; + ACPI_TABLE_HEADER sdt; + ACPI_TABLE_HEADER *ssdt; uint8_t sum; /* Create a new checksum to account for the DSDT and any SSDTs. */ sdt = *dsdt; if (rsdt != NULL) { - sdt.check = 0; - sum = acpi_checksum(dsdt->body, dsdt->len - SIZEOF_SDT_HDR); - ssdt = sdt_from_rsdt(rsdt, "SSDT", NULL); + sdt.Checksum = 0; + sum = acpi_checksum(dsdt + 1, dsdt->Length - + sizeof(ACPI_TABLE_HEADER)); + ssdt = sdt_from_rsdt(rsdt, ACPI_SIG_SSDT, NULL); while (ssdt != NULL) { - sdt.len += ssdt->len - SIZEOF_SDT_HDR; - sum += acpi_checksum(ssdt->body, - ssdt->len - SIZEOF_SDT_HDR); - ssdt = sdt_from_rsdt(rsdt, "SSDT", ssdt); + sdt.Length += ssdt->Length - sizeof(ACPI_TABLE_HEADER); + sum += acpi_checksum(ssdt + 1, + ssdt->Length - sizeof(ACPI_TABLE_HEADER)); + ssdt = sdt_from_rsdt(rsdt, ACPI_SIG_SSDT, ssdt); } - sum += acpi_checksum(&sdt, SIZEOF_SDT_HDR); - sdt.check -= sum; + sum += acpi_checksum(&sdt, sizeof(ACPI_TABLE_HEADER)); + sdt.Checksum -= sum; } /* Write out the DSDT header and body. */ - write(fd, &sdt, SIZEOF_SDT_HDR); - write(fd, dsdt->body, dsdt->len - SIZEOF_SDT_HDR); + write(fd, &sdt, sizeof(ACPI_TABLE_HEADER)); + write(fd, dsdt + 1, dsdt->Length - sizeof(ACPI_TABLE_HEADER)); /* Write out any SSDTs (if present.) */ if (rsdt != NULL) { ssdt = sdt_from_rsdt(rsdt, "SSDT", NULL); while (ssdt != NULL) { - write(fd, ssdt->body, ssdt->len - SIZEOF_SDT_HDR); + write(fd, ssdt + 1, ssdt->Length - + sizeof(ACPI_TABLE_HEADER)); ssdt = sdt_from_rsdt(rsdt, "SSDT", ssdt); } } @@ -876,7 +964,7 @@ write_dsdt(int fd, struct ACPIsdt *rsdt, struct ACPIsdt *dsdt) } void -dsdt_save_file(char *outfile, struct ACPIsdt *rsdt, struct ACPIsdt *dsdp) +dsdt_save_file(char *outfile, ACPI_TABLE_HEADER *rsdt, ACPI_TABLE_HEADER *dsdp) { int fd; mode_t mode; @@ -893,7 +981,7 @@ dsdt_save_file(char *outfile, struct ACPIsdt *rsdt, struct ACPIsdt *dsdp) } void -aml_disassemble(struct ACPIsdt *rsdt, struct ACPIsdt *dsdp) +aml_disassemble(ACPI_TABLE_HEADER *rsdt, ACPI_TABLE_HEADER *dsdp) { char buf[PATH_MAX], tmpstr[PATH_MAX]; const char *tmpdir; @@ -949,40 +1037,44 @@ aml_disassemble(struct ACPIsdt *rsdt, struct ACPIsdt *dsdp) } void -sdt_print_all(struct ACPIsdt *rsdp) +sdt_print_all(ACPI_TABLE_HEADER *rsdp) { acpi_handle_rsdt(rsdp); } /* Fetch a table matching the given signature via the RSDT. */ -struct ACPIsdt * -sdt_from_rsdt(struct ACPIsdt *rsdt, const char *sig, struct ACPIsdt *last) +ACPI_TABLE_HEADER * +sdt_from_rsdt(ACPI_TABLE_HEADER *rsdp, const char *sig, ACPI_TABLE_HEADER *last) { - struct ACPIsdt *sdt; + ACPI_TABLE_HEADER *sdt; + ACPI_TABLE_RSDT *rsdt; + ACPI_TABLE_XSDT *xsdt; vm_offset_t addr; int entries, i; - entries = (rsdt->len - SIZEOF_SDT_HDR) / addr_size; + rsdt = (ACPI_TABLE_RSDT *)rsdp; + xsdt = (ACPI_TABLE_XSDT *)rsdp; + entries = (rsdp->Length - sizeof(ACPI_TABLE_HEADER)) / addr_size; for (i = 0; i < entries; i++) { switch (addr_size) { case 4: - addr = le32dec((char*)rsdt->body + i * addr_size); + addr = le32toh(rsdt->TableOffsetEntry[i]); break; case 8: - addr = le64dec((char*)rsdt->body + i * addr_size); + addr = le64toh(xsdt->TableOffsetEntry[i]); break; default: assert((addr = 0)); } - sdt = (struct ACPIsdt *)acpi_map_sdt(addr); + sdt = (ACPI_TABLE_HEADER *)acpi_map_sdt(addr); if (last != NULL) { if (sdt == last) last = NULL; continue; } - if (memcmp(sdt->signature, sig, strlen(sig))) + if (memcmp(sdt->Signature, sig, strlen(sig))) continue; - if (acpi_checksum(sdt, sdt->len)) + if (acpi_checksum(sdt, sdt->Length)) errx(1, "RSDT entry %d is corrupt", i); return (sdt); } @@ -990,17 +1082,17 @@ sdt_from_rsdt(struct ACPIsdt *rsdt, const char *sig, struct ACPIsdt *last) return (NULL); } -struct ACPIsdt * -dsdt_from_fadt(struct FADTbody *fadt) +ACPI_TABLE_HEADER * +dsdt_from_fadt(ACPI_TABLE_FADT *fadt) { - struct ACPIsdt *sdt; + ACPI_TABLE_HEADER *sdt; - /* Use the DSDT address if it is version 1, otherwise use X_DSDT. */ + /* Use the DSDT address if it is version 1, otherwise use XDSDT. */ if (acpi_get_fadt_revision(fadt) == 1) - sdt = (struct ACPIsdt *)acpi_map_sdt(fadt->dsdt_ptr); + sdt = (ACPI_TABLE_HEADER *)acpi_map_sdt(fadt->Dsdt); else - sdt = (struct ACPIsdt *)acpi_map_sdt(fadt->x_dsdt_ptr); - if (acpi_checksum(sdt, sdt->len)) + sdt = (ACPI_TABLE_HEADER *)acpi_map_sdt(fadt->XDsdt); + if (acpi_checksum(sdt, sdt->Length)) errx(1, "DSDT is corrupt\n"); return (sdt); } diff --git a/usr.sbin/acpi/acpidump/acpi_user.c b/usr.sbin/acpi/acpidump/acpi_user.c index d9d9c2417dbc..f0c47b41735f 100644 --- a/usr.sbin/acpi/acpidump/acpi_user.c +++ b/usr.sbin/acpi/acpidump/acpi_user.c @@ -94,40 +94,43 @@ acpi_user_find_mapping(vm_offset_t pa, size_t size) return (map); } -static struct ACPIrsdp * +static ACPI_TABLE_RSDP * acpi_get_rsdp(u_long addr) { - struct ACPIrsdp rsdp; + ACPI_TABLE_RSDP rsdp; size_t len; /* Read in the table signature and check it. */ pread(acpi_mem_fd, &rsdp, 8, addr); - if (memcmp(rsdp.signature, "RSD PTR ", 8)) + if (memcmp(rsdp.Signature, "RSD PTR ", 8)) return (NULL); /* Read the entire table. */ pread(acpi_mem_fd, &rsdp, sizeof(rsdp), addr); - /* Run the checksum only over the version 1 header. */ - if (acpi_checksum(&rsdp, 20)) + /* Check the standard checksum. */ + if (acpi_checksum(&rsdp, ACPI_RSDP_CHECKSUM_LENGTH) != 0) + return (NULL); + + /* Check extended checksum if table version >= 2. */ + if (rsdp.Revision >= 2 && + acpi_checksum(&rsdp, ACPI_RSDP_XCHECKSUM_LENGTH) != 0) return (NULL); /* If the revision is 0, assume a version 1 length. */ - if (rsdp.revision == 0) - len = 20; + if (rsdp.Revision == 0) + len = ACPI_RSDP_REV0_SIZE; else - len = rsdp.length; - - /* XXX Should handle ACPI 2.0 RSDP extended checksum here. */ + len = rsdp.Length; return (acpi_map_physical(addr, len)); } -static struct ACPIrsdp * +static ACPI_TABLE_RSDP * acpi_scan_rsd_ptr(void) { #if defined(__amd64__) || defined(__i386__) - struct ACPIrsdp *rsdp; + ACPI_TABLE_RSDP *rsdp; u_long addr, end; /* @@ -137,15 +140,15 @@ acpi_scan_rsd_ptr(void) * 1. EBDA (1 KB area addressed by the 16 bit pointer at 0x40E * 2. High memory (0xE0000 - 0xFFFFF) */ - addr = RSDP_EBDA_PTR; + addr = ACPI_EBDA_PTR_LOCATION; pread(acpi_mem_fd, &addr, sizeof(uint16_t), addr); addr <<= 4; - end = addr + RSDP_EBDA_SIZE; + end = addr + ACPI_EBDA_WINDOW_SIZE; for (; addr < end; addr += 16) if ((rsdp = acpi_get_rsdp(addr)) != NULL) return (rsdp); - addr = RSDP_HI_START; - end = addr + RSDP_HI_SIZE; + addr = ACPI_HI_RSDP_WINDOW_BASE; + end = addr + ACPI_HI_RSDP_WINDOW_SIZE; for (; addr < end; addr += 16) if ((rsdp = acpi_get_rsdp(addr)) != NULL) return (rsdp); @@ -156,10 +159,10 @@ acpi_scan_rsd_ptr(void) /* * Public interfaces */ -struct ACPIrsdp * +ACPI_TABLE_RSDP * acpi_find_rsd_ptr(void) { - struct ACPIrsdp *rsdp; + ACPI_TABLE_RSDP *rsdp; char buf[20]; u_long addr; size_t len; @@ -191,10 +194,10 @@ acpi_map_physical(vm_offset_t pa, size_t size) return (map->va + (pa - map->pa)); } -struct ACPIsdt * +ACPI_TABLE_HEADER * dsdt_load_file(char *infile) { - struct ACPIsdt *sdt; + ACPI_TABLE_HEADER *sdt; uint8_t *dp; struct stat sb; @@ -210,8 +213,9 @@ dsdt_load_file(char *infile) if (dp == NULL) errx(1, "mmap %s", infile); - sdt = (struct ACPIsdt *)dp; - if (strncmp(dp, "DSDT", 4) != 0 || acpi_checksum(sdt, sdt->len) != 0) + sdt = (ACPI_TABLE_HEADER *)dp; + if (strncmp(dp, ACPI_SIG_DSDT, 4) != 0 || + acpi_checksum(sdt, sdt->Length) != 0) return (NULL); return (sdt); diff --git a/usr.sbin/acpi/acpidump/acpidump.c b/usr.sbin/acpi/acpidump/acpidump.c index a601ac261634..38844b63873c 100644 --- a/usr.sbin/acpi/acpidump/acpidump.c +++ b/usr.sbin/acpi/acpidump/acpidump.c @@ -54,9 +54,9 @@ usage(const char *progname) int main(int argc, char *argv[]) { + ACPI_TABLE_HEADER *rsdt, *sdt; char c, *progname; char *dsdt_input_file, *dsdt_output_file; - struct ACPIsdt *rsdt, *sdt; dsdt_input_file = dsdt_output_file = NULL; progname = argv[0]; @@ -117,8 +117,8 @@ main(int argc, char *argv[]) /* Translate RSDT to DSDT pointer */ if (dsdt_input_file == NULL) { - sdt = sdt_from_rsdt(rsdt, "FACP", NULL); - sdt = dsdt_from_fadt((struct FADTbody *)sdt->body); + sdt = sdt_from_rsdt(rsdt, ACPI_SIG_FADT, NULL); + sdt = dsdt_from_fadt((ACPI_TABLE_FADT *)sdt); } else { sdt = rsdt; rsdt = NULL; diff --git a/usr.sbin/acpi/acpidump/acpidump.h b/usr.sbin/acpi/acpidump/acpidump.h index 8eca6a8b6bb9..c75cabd34f60 100644 --- a/usr.sbin/acpi/acpidump/acpidump.h +++ b/usr.sbin/acpi/acpidump/acpidump.h @@ -28,368 +28,55 @@ */ #ifndef _ACPIDUMP_H_ -#define _ACPIDUMP_H_ +#define _ACPIDUMP_H_ -/* Generic Address structure */ -struct ACPIgas { - u_int8_t address_space_id; -#define ACPI_GAS_MEMORY 0 -#define ACPI_GAS_IO 1 -#define ACPI_GAS_PCI 2 -#define ACPI_GAS_EMBEDDED 3 -#define ACPI_GAS_SMBUS 4 -#define ACPI_GAS_FIXED 0x7f - u_int8_t bit_width; - u_int8_t bit_offset; - u_int8_t _reserved; - u_int64_t address; -} __packed; +#include +#include +#include -/* Root System Description Pointer */ -struct ACPIrsdp { - u_char signature[8]; - u_char sum; - u_char oem[6]; - u_char revision; - u_int32_t rsdt_addr; - u_int32_t length; - u_int64_t xsdt_addr; - u_char xsum; - u_char _reserved_[3]; -} __packed; +/* GAS address space ID constants. */ +#define ACPI_GAS_MEMORY 0 +#define ACPI_GAS_IO 1 +#define ACPI_GAS_PCI 2 +#define ACPI_GAS_EMBEDDED 3 +#define ACPI_GAS_SMBUS 4 +#define ACPI_GAS_CMOS 5 +#define ACPI_GAS_PCIBAR 6 +#define ACPI_GAS_DATATABLE 7 +#define ACPI_GAS_FIXED 0x7f -/* System Description Table */ -struct ACPIsdt { - u_char signature[4]; - u_int32_t len; - u_char rev; - u_char check; - u_char oemid[6]; - u_char oemtblid[8]; - u_int32_t oemrev; - u_char creator[4]; - u_int32_t crerev; -#define SIZEOF_SDT_HDR 36 /* struct size except body */ - u_int32_t body[1];/* This member should be casted */ -} __packed; - -/* Fixed ACPI Description Table (body) */ -struct FADTbody { - u_int32_t facs_ptr; - u_int32_t dsdt_ptr; - u_int8_t int_model; -#define ACPI_FADT_INTMODEL_PIC 0 /* Standard PC-AT PIC */ -#define ACPI_FADT_INTMODEL_APIC 1 /* Multiple APIC */ - u_int8_t pm_profile; - u_int16_t sci_int; - u_int32_t smi_cmd; - u_int8_t acpi_enable; - u_int8_t acpi_disable; - u_int8_t s4biosreq; - u_int8_t pstate_cnt; - u_int32_t pm1a_evt_blk; - u_int32_t pm1b_evt_blk; - u_int32_t pm1a_cnt_blk; - u_int32_t pm1b_cnt_blk; - u_int32_t pm2_cnt_blk; - u_int32_t pm_tmr_blk; - u_int32_t gpe0_blk; - u_int32_t gpe1_blk; - u_int8_t pm1_evt_len; - u_int8_t pm1_cnt_len; - u_int8_t pm2_cnt_len; - u_int8_t pm_tmr_len; - u_int8_t gpe0_len; - u_int8_t gpe1_len; - u_int8_t gpe1_base; - u_int8_t cst_cnt; - u_int16_t p_lvl2_lat; - u_int16_t p_lvl3_lat; - u_int16_t flush_size; - u_int16_t flush_stride; - u_int8_t duty_off; - u_int8_t duty_width; - u_int8_t day_alrm; - u_int8_t mon_alrm; - u_int8_t century; - u_int16_t iapc_boot_arch; -#define FADT_FLAG_LEGACY_DEV 1 /* System has legacy devices */ -#define FADT_FLAG_8042 2 /* 8042 keyboard controller */ - u_char reserved4[1]; - u_int32_t flags; -#define FADT_FLAG_WBINVD 1 /* WBINVD is correctly supported */ -#define FADT_FLAG_WBINVD_FLUSH 2 /* WBINVD flushes caches */ -#define FADT_FLAG_PROC_C1 4 /* C1 power state supported */ -#define FADT_FLAG_P_LVL2_UP 8 /* C2 power state works on SMP */ -#define FADT_FLAG_PWR_BUTTON 16 /* Power button uses control method */ -#define FADT_FLAG_SLP_BUTTON 32 /* Sleep button uses control method */ -#define FADT_FLAG_FIX_RTC 64 /* RTC wakeup not supported */ -#define FADT_FLAG_RTC_S4 128 /* RTC can wakeup from S4 state */ -#define FADT_FLAG_TMR_VAL_EXT 256 /* TMR_VAL is 32bit */ -#define FADT_FLAG_DCK_CAP 512 /* Can support docking */ -#define FADT_FLAG_RESET_REG 1024 /* Supports RESET_REG */ -#define FADT_FLAG_SEALED_CASE 2048 /* Case cannot be opened */ -#define FADT_FLAG_HEADLESS 4096 /* No monitor */ -#define FADT_FLAG_CPU_SW_SLP 8192 /* Supports CPU software sleep */ - struct ACPIgas reset_reg; - u_int8_t reset_value; - u_int8_t reserved5[3]; - u_int64_t x_facs_ptr; - u_int64_t x_dsdt_ptr; - struct ACPIgas x_pm1a_evt_blk; - struct ACPIgas x_pm1b_evt_blk; - struct ACPIgas x_pm1a_cnt_blk; - struct ACPIgas x_pm1b_cnt_blk; - struct ACPIgas x_pm2_cnt_blk; - struct ACPIgas x_pm_tmr_blk; - struct ACPIgas x_gpe0_blk; - struct ACPIgas x_gpe1_blk; -} __packed; - -/* Firmware ACPI Control Structure */ -struct FACSbody { - u_char signature[4]; - u_int32_t len; - u_int32_t hw_sig; - /* - * NOTE This should be filled with physical address below 1MB!! - * sigh.... - */ - u_int32_t firm_wake_vec; - u_int32_t global_lock; -#define FACS_FLAG_LOCK_PENDING 1 /* 5.2.6.1 Global Lock */ -#define FACS_FLAG_LOCK_OWNED 2 - u_int32_t flags; -#define FACS_FLAG_S4BIOS_F 1 /* Supports S4BIOS_SEQ */ - u_int64_t x_firm_wake_vec; - u_int8_t version; - char reserved[31]; -} __packed; - -struct MADT_local_apic { - u_char cpu_id; - u_char apic_id; - u_int32_t flags; -#define ACPI_MADT_APIC_LOCAL_FLAG_ENABLED 1 -} __packed; - -struct MADT_io_apic { - u_char apic_id; - u_char reserved; - u_int32_t apic_addr; - u_int32_t int_base; -} __packed; - -struct MADT_int_override { - u_char bus; - u_char source; - u_int32_t intr; - u_int16_t mps_flags; -#define MPS_INT_FLAG_POLARITY_MASK 0x3 -#define MPS_INT_FLAG_POLARITY_CONFORM 0x0 -#define MPS_INT_FLAG_POLARITY_HIGH 0x1 -#define MPS_INT_FLAG_POLARITY_LOW 0x3 -#define MPS_INT_FLAG_TRIGGER_MASK 0xc -#define MPS_INT_FLAG_TRIGGER_CONFORM 0x0 -#define MPS_INT_FLAG_TRIGGER_EDGE 0x4 -#define MPS_INT_FLAG_TRIGGER_LEVEL 0xc -} __packed; - -struct MADT_nmi { - u_int16_t mps_flags; - u_int32_t intr; -} __packed; - -struct MADT_local_nmi { - u_char cpu_id; - u_int16_t mps_flags; - u_char lintpin; -} __packed; - -struct MADT_local_apic_override { - u_char reserved[2]; - u_int64_t apic_addr; -} __packed; - -struct MADT_io_sapic { - u_char apic_id; - u_char reserved; - u_int32_t int_base; - u_int64_t apic_addr; -} __packed; - -struct MADT_local_sapic { - u_char cpu_id; - u_char apic_id; - u_char apic_eid; - u_char reserved[3]; - u_int32_t flags; -} __packed; - -struct MADT_int_src { - u_int16_t mps_flags; - u_char type; -#define ACPI_MADT_APIC_INT_SOURCE_PMI 1 -#define ACPI_MADT_APIC_INT_SOURCE_INIT 2 -#define ACPI_MADT_APIC_INT_SOURCE_CPEI 3 /* Corrected Platform Error */ - u_char cpu_id; - u_char cpu_eid; - u_char sapic_vector; - u_int32_t intr; - u_char reserved[4]; -} __packed; - -struct MADT_APIC { - u_char type; -#define ACPI_MADT_APIC_TYPE_LOCAL_APIC 0 -#define ACPI_MADT_APIC_TYPE_IO_APIC 1 -#define ACPI_MADT_APIC_TYPE_INT_OVERRIDE 2 -#define ACPI_MADT_APIC_TYPE_NMI 3 -#define ACPI_MADT_APIC_TYPE_LOCAL_NMI 4 -#define ACPI_MADT_APIC_TYPE_LOCAL_OVERRIDE 5 -#define ACPI_MADT_APIC_TYPE_IO_SAPIC 6 -#define ACPI_MADT_APIC_TYPE_LOCAL_SAPIC 7 -#define ACPI_MADT_APIC_TYPE_INT_SRC 8 - u_char len; - union { - struct MADT_local_apic local_apic; - struct MADT_io_apic io_apic; - struct MADT_int_override int_override; - struct MADT_nmi nmi; - struct MADT_local_nmi local_nmi; - struct MADT_local_apic_override local_apic_override; - struct MADT_io_sapic io_sapic; - struct MADT_local_sapic local_sapic; - struct MADT_int_src int_src; - } body; -} __packed; - -struct MADTbody { - u_int32_t lapic_addr; - u_int32_t flags; -#define ACPI_APIC_FLAG_PCAT_COMPAT 1 /* System has dual-8259 setup. */ - u_char body[1]; -} __packed; - -struct HPETbody { - u_int32_t block_hwrev:8, - block_comparitors:5, - block_counter_size:1, - :1, - block_legacy_capable:1, - block_pcivendor:16; - struct ACPIgas genaddr; - u_int8_t hpet_number; - u_int16_t clock_tick __packed; -} __packed; - -/* Embedded Controller Description Table */ -struct ECDTbody { - struct ACPIgas ec_control; /* Control register */ - struct ACPIgas ec_data; /* Data register */ - uint32_t uid; /* Same value as _UID in namespace */ - uint8_t gpe_bit; /* GPE bit for the EC */ - u_char ec_id[1]; /* Variable length name string */ -} __packed; - -/* Memory Mapped PCI config space base allocation structure */ -struct MCFGbody { - uint8_t rsvd[8]; - struct { - uint64_t baseaddr; /* Base Address */ - uint16_t seg_grp; /* Segment group number */ - uint8_t start; /* Starting bus number */ - uint8_t end; /* Ending bus number */ - uint8_t rsvd[4]; /* Reserved */ - } s[1] __packed; -} __packed; - -/* System Resource Affinity Table */ -struct SRAT_cpu { - uint8_t proximity_domain_lo; - uint8_t apic_id; - uint32_t flags; -#define ACPI_SRAT_CPU_ENABLED 0x00000001 - uint8_t sapic_eid; - uint8_t proximity_domain_hi[3]; - uint32_t reserved; -} __packed; - -struct SRAT_memory { - uint32_t proximity_domain; - uint16_t reserved; - uint64_t base_address; - uint64_t length; - uint32_t reserved1; - uint32_t flags; -#define ACPI_SRAT_MEM_ENABLED 0x00000001 -#define ACPI_SRAT_MEM_HOT_PLUGGABLE 0x00000002 -#define ACPI_SRAT_MEM_NON_VOLATILE 0x00000002 - uint64_t reserved2; -} __packed; - -struct SRAT_x2apic { - uint16_t reserved; - uint32_t proximity_domain; - uint32_t apic_id; - uint32_t flags; -} __packed; - -struct SRATentry { - uint8_t type; -#define ACPI_SRAT_TYPE_CPU_AFFINITY 0 -#define ACPI_SRAT_TYPE_MEMORY_AFFINITY 1 -#define ACPI_SRAT_TYPE_X2APIC_CPU_AFFINITY 2 - uint8_t len; - union { - struct SRAT_cpu cpu; - struct SRAT_memory mem; - struct SRAT_x2apic x2apic; - } body; -} __packed; - -struct SRATbody { - uint32_t table_revision; - uint64_t reserved; - struct SRATentry body[0]; -} __packed; - -/* - * Addresses to scan on ia32 for the RSD PTR. According to section 5.2.2 - * of the ACPI spec, we only consider two regions for the base address: - * 1. EBDA (1 KB area addressed to by 16 bit pointer at 0x40E) - * 2. High memory (0xE0000 - 0xFFFFF) - */ -#define RSDP_EBDA_PTR 0x40E -#define RSDP_EBDA_SIZE 0x400 -#define RSDP_HI_START 0xE0000 -#define RSDP_HI_SIZE 0x20000 +/* Subfields in the HPET Id member. */ +#define ACPI_HPET_ID_HARDWARE_REV_ID 0x000000ff +#define ACPI_HPET_ID_COMPARATORS 0x00001f00 +#define ACPI_HPET_ID_COUNT_SIZE_CAP 0x00002000 +#define ACPI_HPET_ID_LEGACY_CAPABLE 0x00008000 +#define ACPI_HPET_ID_PCI_VENDOR_ID 0xffff0000 /* Find and map the RSD PTR structure and return it for parsing */ -struct ACPIsdt *sdt_load_devmem(void); +ACPI_TABLE_HEADER *sdt_load_devmem(void); /* * Load the DSDT from a previous save file. Note that other tables are * not saved (i.e. FADT) */ -struct ACPIsdt *dsdt_load_file(char *); +ACPI_TABLE_HEADER *dsdt_load_file(char *); /* Save the DSDT to a file */ -void dsdt_save_file(char *, struct ACPIsdt *, struct ACPIsdt *); +void dsdt_save_file(char *, ACPI_TABLE_HEADER *, ACPI_TABLE_HEADER *); /* Print out as many fixed tables as possible, given the RSD PTR */ -void sdt_print_all(struct ACPIsdt *); +void sdt_print_all(ACPI_TABLE_HEADER *); /* Disassemble the AML in the DSDT */ -void aml_disassemble(struct ACPIsdt *, struct ACPIsdt *); +void aml_disassemble(ACPI_TABLE_HEADER *, ACPI_TABLE_HEADER *); /* Routines for accessing tables in physical memory */ -struct ACPIrsdp *acpi_find_rsd_ptr(void); -void *acpi_map_physical(vm_offset_t, size_t); -struct ACPIsdt *sdt_from_rsdt(struct ACPIsdt *, const char *, - struct ACPIsdt *); -struct ACPIsdt *dsdt_from_fadt(struct FADTbody *); -int acpi_checksum(void *, size_t); +ACPI_TABLE_RSDP *acpi_find_rsd_ptr(void); +void *acpi_map_physical(vm_offset_t, size_t); +ACPI_TABLE_HEADER *sdt_from_rsdt(ACPI_TABLE_HEADER *, const char *, + ACPI_TABLE_HEADER *); +ACPI_TABLE_HEADER *dsdt_from_fadt(ACPI_TABLE_FADT *); +int acpi_checksum(void *, size_t); /* Command line flags */ extern int dflag;