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 Decode Generic Timer Description...



details:   https://anonhg.NetBSD.org/src/rev/b94256052c51
branches:  trunk
changeset: 445207:b94256052c51
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Thu Oct 18 04:29:44 2018 +0000

description:
Decode Generic Timer Description Table(GTDT) and Processor Properties Topology
Table(PPTT). Cosmetic changes and fixes might be required. Testesd by jmcneill.

diffstat:

 usr.sbin/acpitools/acpidump/acpi.c |  331 ++++++++++++++++++++++++++++++++++++-
 1 files changed, 329 insertions(+), 2 deletions(-)

diffs (truncated from 387 to 300 lines):

diff -r 2d1627350bd1 -r b94256052c51 usr.sbin/acpitools/acpidump/acpi.c
--- a/usr.sbin/acpitools/acpidump/acpi.c        Thu Oct 18 04:25:34 2018 +0000
+++ b/usr.sbin/acpitools/acpidump/acpi.c        Thu Oct 18 04:29:44 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi.c,v 1.34 2018/10/18 04:25:34 msaitoh Exp $ */
+/* $NetBSD: acpi.c,v 1.35 2018/10/18 04:29:44 msaitoh Exp $ */
 
 /*-
  * Copyright (c) 1998 Doug Rabson
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: acpi.c,v 1.34 2018/10/18 04:25:34 msaitoh Exp $");
+__RCSID("$NetBSD: acpi.c,v 1.35 2018/10/18 04:29:44 msaitoh Exp $");
 
 #include <sys/param.h>
 #include <sys/endian.h>
@@ -85,6 +85,7 @@
 static void    acpi_handle_dbg2(ACPI_TABLE_HEADER *sdp);
 static void    acpi_handle_einj(ACPI_TABLE_HEADER *sdp);
 static void    acpi_handle_erst(ACPI_TABLE_HEADER *sdp);
+static void    acpi_handle_gtdt(ACPI_TABLE_HEADER *sdp);
 static void    acpi_handle_hest(ACPI_TABLE_HEADER *sdp);
 static void    acpi_handle_lpit(ACPI_TABLE_HEADER *sdp);
 static void    acpi_handle_madt(ACPI_TABLE_HEADER *sdp);
@@ -92,6 +93,7 @@
 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_handle_pptt(ACPI_TABLE_HEADER *sdp);
 static void    acpi_handle_sbst(ACPI_TABLE_HEADER *sdp);
 static void    acpi_handle_slit(ACPI_TABLE_HEADER *sdp);
 static void    acpi_handle_spcr(ACPI_TABLE_HEADER *sdp);
@@ -1679,6 +1681,182 @@
 }
 
 static void
+acpi_print_gtd_timer(const char *name, uint32_t interrupt, uint32_t flags)
+{
+
+       printf("\t%s Timer GSIV=%d\n", name, interrupt);
+       printf("\t%s Flags={Mode=", name);
+       if (flags & ACPI_GTDT_INTERRUPT_MODE)
+               printf("edge");
+       else
+               printf("level");
+       printf(", Polarity=");
+       if (flags & ACPI_GTDT_INTERRUPT_POLARITY)
+               printf("active-lo");
+       else
+               printf("active-hi");
+       if (flags & ACPI_GTDT_ALWAYS_ON)
+               printf(", always-on");
+       printf("}\n");
+}
+
+static void
+acpi_print_gtd_block_timer_flags(const char *name, uint32_t interrupt,
+    uint32_t flags)
+{
+
+       printf("\t\t%s Timer GSIV=%d\n", name, interrupt);
+       printf("\t\t%s Timer Flags={Mode=", name);
+       if (flags & ACPI_GTDT_GT_IRQ_MODE)
+               printf("Secure");
+       else
+               printf("Non-Secure");
+       printf(", Polarity=");
+       if (flags & ACPI_GTDT_GT_IRQ_POLARITY)
+               printf("active-lo");
+       else
+               printf("active-hi");
+       printf("}\n");
+}
+
+static void
+acpi_print_gtblock(ACPI_GTDT_TIMER_BLOCK *gtblock)
+{
+       ACPI_GTDT_TIMER_ENTRY *entry;
+       unsigned int i;
+       
+       printf("\tType=GT Block\n");
+       printf("\tLength=%d\n", gtblock->Header.Length);
+       /* XXX might not 8byte aligned */
+       printf("\tBlockAddress=%016jx\n",
+           (uintmax_t)gtblock->BlockAddress);
+
+       printf("\tGT Block Timer Count=%d\n", gtblock->TimerCount);
+       entry = (ACPI_GTDT_TIMER_ENTRY *)((vaddr_t)gtblock
+           + gtblock->TimerOffset);
+       for (i = 0; i < gtblock->TimerCount; i++) {
+               printf("\n");
+               if (entry >= (ACPI_GTDT_TIMER_ENTRY *)((vaddr_t)gtblock
+                   + gtblock->Header.Length)) {
+                       printf("\\ttWrong Timer entry\n");
+                       break;
+               }
+               printf("\t\tFrame Number=%d\n", entry->FrameNumber);
+               /* XXX might not 8byte aligned */
+               printf("\t\tBaseAddress=%016jx\n",
+                   (uintmax_t)entry->BaseAddress);
+               /* XXX might not 8byte aligned */
+               printf("\t\tEl0BaseAddress=%016jx\n",
+                   (uintmax_t)entry->El0BaseAddress);
+
+               acpi_print_gtd_block_timer_flags("Physical",
+                   entry->TimerInterrupt, entry->TimerFlags);
+               acpi_print_gtd_block_timer_flags("Virtual",
+                   entry->VirtualTimerInterrupt, entry->VirtualTimerFlags);
+
+               printf("\t\tCommon Flags={Mode=");
+               if (entry->CommonFlags & ACPI_GTDT_GT_IS_SECURE_TIMER)
+                       printf("Secure");
+               else
+                       printf("Non-Secure");
+               if (entry->CommonFlags & ACPI_GTDT_GT_ALWAYS_ON)
+                       printf(", always-on");
+               printf("}\n");
+
+               entry++;
+       }
+}
+
+static void
+acpi_print_sbsa_watchdog(ACPI_GTDT_WATCHDOG *wdog)
+{
+       
+       printf("\tType=Watchdog GT\n");
+       printf("\tLength=%d\n", wdog->Header.Length);
+       /* XXX might not 8byte aligned */
+       printf("\tRefreshFrameAddress=%016jx\n",
+           (uintmax_t)wdog->RefreshFrameAddress);
+       /* XXX might not 8byte aligned */
+       printf("\tControlFrameAddress=%016jx\n",
+           (uintmax_t)wdog->ControlFrameAddress);
+       printf("\tGSIV=%d\n", wdog->TimerInterrupt);
+
+       printf("\tFlags={Mode=");
+       if (wdog->TimerFlags & ACPI_GTDT_WATCHDOG_IRQ_MODE)
+               printf("edge");
+       else
+               printf("level");
+       printf(", Polarity=");
+       if (wdog->TimerFlags & ACPI_GTDT_WATCHDOG_IRQ_POLARITY)
+               printf("active-lo");
+       else
+               printf("active-hi");
+       if (wdog->TimerFlags & ACPI_GTDT_WATCHDOG_SECURE)
+               printf(", Secure");
+       else
+               printf(", Non-Secure");
+       printf("}\n");
+}
+
+static void
+acpi_handle_gtdt(ACPI_TABLE_HEADER *sdp)
+{
+       ACPI_TABLE_GTDT *gtdt;
+       ACPI_GTDT_HEADER *hdr;
+       u_int i;
+
+       printf(BEGIN_COMMENT);
+       acpi_print_sdt(sdp);
+       gtdt = (ACPI_TABLE_GTDT *)sdp;
+
+       printf("\tCounterBlockAddresss=%016jx\n",
+           (uintmax_t)gtdt->CounterBlockAddresss); /* XXX not 8byte aligned */
+       printf("\tCounterReadBlockAddress=%016jx\n",
+           (uintmax_t)gtdt->CounterReadBlockAddress);
+
+#define PRINTTIMER(gtdt, name) acpi_print_gtd_timer(   \
+               #name, (gtdt)-> name## Interrupt,       \
+       (gtdt)-> name ## Flags)
+
+       PRINTTIMER(gtdt, SecureEl1);
+       PRINTTIMER(gtdt, NonSecureEl1);
+       PRINTTIMER(gtdt, VirtualTimer);
+       PRINTTIMER(gtdt, NonSecureEl2);
+
+#undef PRINTTIMER
+
+       printf("\tPlatform Timer Count=%d\n", gtdt->PlatformTimerCount);
+
+       hdr = (ACPI_GTDT_HEADER *)((vaddr_t)sdp + gtdt->PlatformTimerOffset);
+       for (i = 0; i < gtdt->PlatformTimerCount; i++) {
+               printf("\n");
+               if (hdr >= (ACPI_GTDT_HEADER *)((vaddr_t)sdp + sdp->Length)) {
+                       printf("\tWrong GTDT header"
+                           "(type = %hhu, length = %hu)\n",
+                           hdr->Type, hdr->Length);
+                       break;
+               }
+
+               switch (hdr->Type) {
+               case ACPI_GTDT_TYPE_TIMER_BLOCK:
+                       acpi_print_gtblock((ACPI_GTDT_TIMER_BLOCK *)hdr);
+                       break;
+               case ACPI_GTDT_TYPE_WATCHDOG:
+                       acpi_print_sbsa_watchdog((ACPI_GTDT_WATCHDOG *)hdr);
+                       break;
+               default:
+                       printf("\tUnknown Platform Timer Type"
+                           "(type = %hhu, length = %hu)\n",
+                           hdr->Type, hdr->Length);
+                       break;
+               }
+               /* Next */
+               hdr = (ACPI_GTDT_HEADER *)((vaddr_t)hdr + hdr->Length);
+       }
+       printf(END_COMMENT);
+}
+
+static void
 acpi_handle_madt(ACPI_TABLE_HEADER *sdp)
 {
        ACPI_TABLE_MADT *madt;
@@ -1872,6 +2050,151 @@
 }
 
 static void
+acpi_print_pptt_processor(ACPI_PPTT_PROCESSOR *processor)
+{
+       uint32_t *private;
+       unsigned int i;
+
+       printf("\tType=processor\n");
+       printf("\tLength=%d\n", processor->Header.Length);
+#define PRINTFLAG(var, flag)   printflag((var), ACPI_PPTT_## flag, #flag)
+
+       printf("\tFlags=");
+       PRINTFLAG(processor->Flags, PHYSICAL_PACKAGE);
+       PRINTFLAG(processor->Flags, ACPI_PROCESSOR_ID_VALID);
+       PRINTFLAG_END();
+
+#undef PRINTFLAG
+       printf("\tParent=%08x\n", processor->Parent);
+       printf("\tACPI Processor ID=0x%08x\n", processor->AcpiProcessorId);
+       printf("\tprivate resources=%d\n", processor->NumberOfPrivResources);
+
+       private = (uint32_t *)(processor + 1);
+       for (i = 0; i < processor->NumberOfPrivResources; i++)
+               printf("\tprivate resources%d=%08x\n", i, private[i]);
+}
+
+static void
+acpi_print_pptt_cache(ACPI_PPTT_CACHE *cache)
+{
+
+       printf("\tType=cache\n");
+       printf("\tLength=%d\n", cache->Header.Length);
+
+#define        PRINTFLAG(var, flag)    printflag((var), ACPI_PPTT_## flag, #flag)
+       printf("\tFlags=");
+       PRINTFLAG(cache->Flags, SIZE_PROPERTY_VALID);
+       PRINTFLAG(cache->Flags, NUMBER_OF_SETS_VALID);
+       PRINTFLAG(cache->Flags, ASSOCIATIVITY_VALID);
+       PRINTFLAG(cache->Flags, ALLOCATION_TYPE_VALID);
+       PRINTFLAG(cache->Flags, CACHE_TYPE_VALID);
+       PRINTFLAG(cache->Flags, WRITE_POLICY_VALID);
+       PRINTFLAG(cache->Flags, LINE_SIZE_VALID);
+       PRINTFLAG_END();
+#undef PRINTFLAG
+
+       printf("\tNextLevel=0x%08x\n", cache->NextLevelOfCache);
+       if (cache->Flags & ACPI_PPTT_SIZE_PROPERTY_VALID)
+               printf("\tSize=%d\n", cache->Size);
+       if (cache->Flags & ACPI_PPTT_NUMBER_OF_SETS_VALID)
+               printf("\tSets=%d\n", cache->NumberOfSets);
+       if (cache->Flags & ACPI_PPTT_ASSOCIATIVITY_VALID)
+               printf("\tAssociativity=%d\n", cache->Associativity);
+       if (cache->Flags & ACPI_PPTT_ALLOCATION_TYPE_VALID) {
+               printf("\tAllocation type=");
+               switch (__SHIFTOUT(cache->Attributes,
+                       ACPI_PPTT_MASK_ALLOCATION_TYPE)) {
+               case ACPI_PPTT_CACHE_READ_ALLOCATE:
+                       printf("Read allocate\n");
+                       break;
+               case ACPI_PPTT_CACHE_WRITE_ALLOCATE:
+                       printf("Write allocate\n");
+                       break;
+               case ACPI_PPTT_CACHE_RW_ALLOCATE:
+               case ACPI_PPTT_CACHE_RW_ALLOCATE_ALT:
+                       printf("Read and Write allocate\n");
+                       break;
+               }
+       }
+       if (cache->Flags & ACPI_PPTT_CACHE_TYPE_VALID) {
+               printf("\tCache type=");
+               switch (__SHIFTOUT(cache->Attributes,
+                       ACPI_PPTT_MASK_CACHE_TYPE)) {
+               case ACPI_PPTT_CACHE_TYPE_DATA:
+                       printf("Data\n");
+                       break;
+               case ACPI_PPTT_CACHE_TYPE_INSTR:
+                       printf("Instruction\n");
+                       break;
+               case ACPI_PPTT_CACHE_TYPE_UNIFIED:
+               case ACPI_PPTT_CACHE_TYPE_UNIFIED_ALT:
+                       printf("Unified\n");



Home | Main Index | Thread Index | Old Index