Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/acpitools/acpidump Sync with FreeBSD's r321294:



details:   https://anonhg.NetBSD.org/src/rev/d751b25f6787
branches:  trunk
changeset: 825882:d751b25f6787
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Fri Aug 04 06:30:36 2017 +0000

description:
Sync with FreeBSD's r321294:
 - Dump TCG ACPI spec table (TCPA) more.
 - Dump DMA Remapping Reporting table (DMAR).
 - Consistently cast ACPICA 64-bit integer types when we print them.
 - Display the 'Flags' field in the HPET Description Table.
 - Do not crash when RSDT/XSDT contains an empty entry.
 - Print 64-bit addresses clearly with leading zeros to avoid confusions.
 - Create temp file safely.
 - Add missing flags into FADT.
 - Print some new ACPI 5.1 MADT entries.
 - Use __arraycount().
 - Warn and exit loop on invalid subtable length.
 - Fix the type used to hold the value returned from getopt. On arm64 char is
   unsigned so will never be -1.

diffstat:

 usr.sbin/acpitools/acpidump/acpi.c      |  741 +++++++++++++++++++++++++++----
 usr.sbin/acpitools/acpidump/acpi_user.c |   10 +-
 usr.sbin/acpitools/acpidump/acpidump.8  |    7 +-
 usr.sbin/acpitools/acpidump/acpidump.c  |    8 +-
 usr.sbin/acpitools/acpidump/acpidump.h  |   78 +++-
 5 files changed, 719 insertions(+), 125 deletions(-)

diffs (truncated from 1220 to 300 lines):

diff -r e6f904442af0 -r d751b25f6787 usr.sbin/acpitools/acpidump/acpi.c
--- a/usr.sbin/acpitools/acpidump/acpi.c        Fri Aug 04 02:43:56 2017 +0000
+++ b/usr.sbin/acpitools/acpidump/acpi.c        Fri Aug 04 06:30:36 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi.c,v 1.15 2016/02/27 16:40:22 christos Exp $ */
+/* $NetBSD: acpi.c,v 1.16 2017/08/04 06:30:36 msaitoh Exp $ */
 
 /*-
  * Copyright (c) 1998 Doug Rabson
@@ -26,11 +26,11 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- *     $FreeBSD: src/usr.sbin/acpi/acpidump/acpi.c,v 1.37 2009/08/25 20:35:57 jhb Exp $
+ *     $FreeBSD: head/usr.sbin/acpi/acpidump/acpi.c 321299 2017-07-20 17:36:17Z emaste $
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: acpi.c,v 1.15 2016/02/27 16:40:22 christos Exp $");
+__RCSID("$NetBSD: acpi.c,v 1.16 2017/08/04 06:30:36 msaitoh Exp $");
 
 #include <sys/param.h>
 #include <sys/endian.h>
@@ -116,6 +116,71 @@
 /* Size of an address. 32-bit for ACPI 1.0, 64-bit for ACPI 2.0 and up. */
 static int addr_size;
 
+/* Strings used in the TCPA table */
+static const char *tcpa_event_type_strings[] = {
+       "PREBOOT Certificate",
+       "POST Code",
+       "Unused",
+       "No Action",
+       "Separator",
+       "Action",
+       "Event Tag",
+       "S-CRTM Contents",
+       "S-CRTM Version",
+       "CPU Microcode",
+       "Platform Config Flags",
+       "Table of Devices",
+       "Compact Hash",
+       "IPL",
+       "IPL Partition Data",
+       "Non-Host Code",
+       "Non-Host Config",
+       "Non-Host Info"
+};
+
+static const char *TCPA_pcclient_strings[] = {
+       "<undefined>",
+       "SMBIOS",
+       "BIS Certificate",
+       "POST BIOS ROM Strings",
+       "ESCD",
+       "CMOS",
+       "NVRAM",
+       "Option ROM Execute",
+       "Option ROM Configurateion",
+       "<undefined>",
+       "Option ROM Microcode Update ",
+       "S-CRTM Version String",
+       "S-CRTM Contents",
+       "POST Contents",
+       "Table of Devices",
+};
+
+#define        PRINTFLAG_END()         printflag_end()
+
+static char pf_sep = '{';
+
+static void
+printflag_end(void)
+{
+
+       if (pf_sep != '{') {
+               printf("}");
+               pf_sep = '{';
+       }
+       printf("\n");
+}
+
+static void
+printflag(uint64_t var, uint64_t mask, const char *name)
+{
+
+       if (var & mask) {
+               printf("%c%s", pf_sep, name);
+               pf_sep = ',';
+       }
+}
+
 static void
 acpi_print_string(char *s, size_t length)
 {
@@ -136,12 +201,18 @@
 {
        switch(gas->SpaceId) {
        case ACPI_GAS_MEMORY:
-               printf("0x%08lx:%u[%u] (Memory)", (u_long)gas->Address,
-                      gas->BitOffset, gas->BitWidth);
+               if (gas->BitWidth <= 32)
+                       printf("0x%08x:%u[%u] (Memory)",
+                           (u_int)gas->Address, gas->BitOffset,
+                           gas->BitWidth);
+               else
+                       printf("0x%016jx:%u[%u] (Memory)",
+                           (uintmax_t)gas->Address, gas->BitOffset,
+                           gas->BitWidth);
                break;
        case ACPI_GAS_IO:
-               printf("0x%02lx:%u[%u] (IO)", (u_long)gas->Address,
-                      gas->BitOffset, gas->BitWidth);
+               printf("0x%02x:%u[%u] (IO)", (u_int)gas->Address,
+                   gas->BitOffset, gas->BitWidth);
                break;
        case ACPI_GAS_PCI:
                printf("%x:%x+0x%x (PCI)", (uint16_t)(gas->Address >> 32),
@@ -162,7 +233,7 @@
        case ACPI_GAS_DATATABLE:
        case ACPI_GAS_FIXED:
        default:
-               printf("0x%08lx (?)", (u_long)gas->Address);
+               printf("0x%016jx (?)", (uintmax_t)gas->Address);
                break;
        }
 }
@@ -720,6 +791,10 @@
        end = (char *)table + table->Length;
        while ((char *)subtable < end) {
                printf("\n");
+               if (subtable->Length < sizeof(ACPI_SUBTABLE_HEADER)) {
+                       warnx("invalid subtable length %u", subtable->Length);
+                       return;
+               }
                action(subtable);
                subtable = (ACPI_SUBTABLE_HEADER *)((char *)subtable +
                    subtable->Length);
@@ -806,6 +881,23 @@
 }
 
 static void
+acpi_print_gicc_flags(uint32_t flags)
+{
+
+       printf("\tFlags={Performance intr=");
+       if (flags & ACPI_MADT_PERFORMANCE_IRQ_MODE)
+               printf("edge");
+       else
+               printf("level");
+       printf(", VGIC intr=");
+       if (flags & ACPI_MADT_VGIC_IRQ_MODE)
+               printf("edge");
+       else
+               printf("level");
+       printf("}\n");
+}
+
+static void
 acpi_print_intr(uint32_t intr, uint16_t mps_flags)
 {
 
@@ -821,12 +913,27 @@
        acpi_print_mps_flags(mps_flags);
 }
 
-const char *apic_types[] = { "Local APIC", "IO APIC", "INT Override", "NMI",
-                            "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 const char *apic_types[] = {
+    [ACPI_MADT_TYPE_LOCAL_APIC] = "Local APIC",
+    [ACPI_MADT_TYPE_IO_APIC] = "IO APIC",
+    [ACPI_MADT_TYPE_INTERRUPT_OVERRIDE] = "INT Override",
+    [ACPI_MADT_TYPE_NMI_SOURCE] = "NMI",
+    [ACPI_MADT_TYPE_LOCAL_APIC_NMI] = "Local APIC NMI",
+    [ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE] = "Local APIC Override",
+    [ACPI_MADT_TYPE_IO_SAPIC] = "IO SAPIC",
+    [ACPI_MADT_TYPE_LOCAL_SAPIC] = "Local SAPIC",
+    [ACPI_MADT_TYPE_INTERRUPT_SOURCE] = "Platform Interrupt",
+    [ACPI_MADT_TYPE_LOCAL_X2APIC] = "Local X2APIC",
+    [ACPI_MADT_TYPE_LOCAL_X2APIC_NMI] = "Local X2APIC NMI",
+    [ACPI_MADT_TYPE_GENERIC_INTERRUPT] = "GIC CPU Interface Structure",
+    [ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR] = "GIC Distributor Structure",
+    [ACPI_MADT_TYPE_GENERIC_MSI_FRAME] = "GICv2m MSI Frame",
+    [ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR] = "GIC Redistributor Structure",
+    [ACPI_MADT_TYPE_GENERIC_TRANSLATOR] = "GIC ITS Structure"
+};
+
+static const char *platform_int_types[] = { "0 (unknown)", "PMI", "INIT",
+                                           "Corrected Platform Error" };
 
 static void
 acpi_print_madt(ACPI_SUBTABLE_HEADER *mp)
@@ -842,8 +949,12 @@
        ACPI_MADT_INTERRUPT_SOURCE *isrc;
        ACPI_MADT_LOCAL_X2APIC *x2apic;
        ACPI_MADT_LOCAL_X2APIC_NMI *x2apic_nmi;
+       ACPI_MADT_GENERIC_INTERRUPT *gicc;
+       ACPI_MADT_GENERIC_DISTRIBUTOR *gicd;
+       ACPI_MADT_GENERIC_REDISTRIBUTOR *gicr;
+       ACPI_MADT_GENERIC_TRANSLATOR *gict;
 
-       if (mp->Type < sizeof(apic_types) / sizeof(apic_types[0]))
+       if (mp->Type < __arraycount(apic_types))
                printf("\tType=%s\n", apic_types[mp->Type]);
        else
                printf("\tType=%d (unknown)\n", mp->Type);
@@ -893,8 +1004,7 @@
                break;
        case ACPI_MADT_TYPE_INTERRUPT_SOURCE:
                isrc = (ACPI_MADT_INTERRUPT_SOURCE *)mp;
-               if (isrc->Type < sizeof(platform_int_types) /
-                   sizeof(platform_int_types[0]))
+               if (isrc->Type < __arraycount(platform_int_types))
                        printf("\tType=%s\n", platform_int_types[isrc->Type]);
                else
                        printf("\tType=%d (unknown)\n", isrc->Type);
@@ -913,6 +1023,41 @@
                acpi_print_cpu_uid(x2apic_nmi->Uid, NULL);
                acpi_print_local_nmi(x2apic_nmi->Lint, x2apic_nmi->IntiFlags);
                break;
+       case ACPI_MADT_TYPE_GENERIC_INTERRUPT:
+               gicc = (ACPI_MADT_GENERIC_INTERRUPT *)mp;
+               acpi_print_cpu_uid(gicc->Uid, NULL);
+               printf("\tCPU INTERFACE=%x\n", gicc->CpuInterfaceNumber);
+               acpi_print_gicc_flags(gicc->Flags);
+               printf("\tParking Protocol Version=%x\n", gicc->ParkingVersion);
+               printf("\tPERF INTR=%d\n", gicc->PerformanceInterrupt);
+               printf("\tParked ADDR=%016jx\n",
+                   (uintmax_t)gicc->ParkedAddress);
+               printf("\tBase ADDR=%016jx\n", (uintmax_t)gicc->BaseAddress);
+               printf("\tGICV=%016jx\n", (uintmax_t)gicc->GicvBaseAddress);
+               printf("\tGICH=%016jx\n", (uintmax_t)gicc->GichBaseAddress);
+               printf("\tVGIC INTR=%d\n", gicc->VgicInterrupt);
+               printf("\tGICR ADDR=%016jx\n",
+                   (uintmax_t)gicc->GicrBaseAddress);
+               printf("\tMPIDR=%jx\n", (uintmax_t)gicc->ArmMpidr);
+               printf("\tEfficency Class=%d\n", (u_int)gicc->EfficiencyClass);
+               break;
+       case ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR:
+               gicd = (ACPI_MADT_GENERIC_DISTRIBUTOR *)mp;
+               printf("\tGIC ID=%d\n", (u_int)gicd->GicId);
+               printf("\tBase ADDR=%016jx\n", (uintmax_t)gicd->BaseAddress);
+               printf("\tVector Base=%d\n", gicd->GlobalIrqBase);
+               printf("\tGIC VERSION=%d\n", (u_int)gicd->Version);
+               break;
+       case ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR:
+               gicr = (ACPI_MADT_GENERIC_REDISTRIBUTOR *)mp;
+               printf("\tBase ADDR=%016jx\n", (uintmax_t)gicr->BaseAddress);
+               printf("\tLength=%08x\n", gicr->Length);
+               break;
+       case ACPI_MADT_TYPE_GENERIC_TRANSLATOR:
+               gict = (ACPI_MADT_GENERIC_TRANSLATOR *)mp;
+               printf("\tGIC ITS ID=%d\n", gict->TranslationId);
+               printf("\tBase ADDR=%016jx\n", (uintmax_t)gict->BaseAddress);
+               break;
        }
 }
 
@@ -1349,6 +1494,7 @@
                printf("FALSE}\n");
        printf("\tPCI Vendor ID=0x%04x\n", hpet->Id >> 16);
        printf("\tMinimal Tick=%d\n", hpet->MinimumTick);
+       printf("\tFlags=0x%02x\n", hpet->Flags);
        printf(END_COMMENT);
 }
 
@@ -1420,7 +1566,7 @@
        alloc = (ACPI_MCFG_ALLOCATION *)(mcfg + 1);
        for (i = 0; i < entries; i++, alloc++) {
                printf("\n");
-               printf("\tBase Address=0x%016jx\n", alloc->Address);
+               printf("\tBase Address=0x%016jx\n", (uintmax_t)alloc->Address);
                printf("\tSegment Group=0x%04x\n", alloc->PciSegment);
                printf("\tStart Bus=%d\n", alloc->StartBusNumber);
                printf("\tEnd Bus=%d\n", alloc->EndBusNumber);
@@ -1456,7 +1602,7 @@
        slit = (ACPI_TABLE_SLIT *)sdp;
 
        cnt = slit->LocalityCount * slit->LocalityCount;
-       printf("\tLocalityCount=%"PRIu64"\n", slit->LocalityCount);
+       printf("\tLocalityCount=%ju\n", (uintmax_t)slit->LocalityCount);
        printf("\tEntry=\n\t");
        for (idx = 0; idx < cnt; idx++) {
                printf("%u ", slit->Entry[idx]);
@@ -1618,15 +1764,21 @@
        printf("\tProximity Domain=%d\n", mp->ProximityDomain);
 }
 
-const char *srat_types[] = { "CPU", "Memory", "X2APIC" };
+static const char *srat_types[] = {
+    [ACPI_SRAT_TYPE_CPU_AFFINITY] = "CPU",
+    [ACPI_SRAT_TYPE_MEMORY_AFFINITY] = "Memory",
+    [ACPI_SRAT_TYPE_X2APIC_CPU_AFFINITY] = "X2APIC",
+    [ACPI_SRAT_TYPE_GICC_AFFINITY] = "GICC",
+};
 



Home | Main Index | Thread Index | Old Index