public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Chris Jones" <christopher.jones@arm.com>
To: <devel@edk2.groups.io>
Cc: <michael.d.kinney@intel.com>, <gaoliming@byosoft.com.cn>,
	<zhiguang.liu@intel.com>, <ray.ni@intel.com>,
	<zhichao.gao@intel.com>, <Alexei.Fedorov@arm.com>,
	<Sami.Mujawar@arm.com>, <nd@arm.com>
Subject: [PATCH v1 4/7] ShellPkg: Add Cache ID to PPTT parser
Date: Mon, 18 Oct 2021 16:10:43 +0100	[thread overview]
Message-ID: <20211018151046.31232-5-christopher.jones@arm.com> (raw)
In-Reply-To: <20211018151046.31232-1-christopher.jones@arm.com>

Bugzilla: 3697 (https://bugzilla.tianocore.org/show_bug.cgi?id=3697)

Update the Acpiview PPTT parser with the Cache ID field and relevant
validations as defined in tables 5.140 and 5.141 of the ACPI 6.4
specification.

Signed-off-by: Chris Jones <christopher.jones@arm.com>
---
 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c | 118 +++++++++++++++++++-
 1 file changed, 116 insertions(+), 2 deletions(-)

diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c
index bce9edcedde50e53035059e6da57b9449209a674..a6130eae62c4387d2b6037ecec8db596e4bb6bb1 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c
@@ -20,8 +20,82 @@
 STATIC CONST UINT8*  ProcessorTopologyStructureType;
 STATIC CONST UINT8*  ProcessorTopologyStructureLength;
 STATIC CONST UINT32* NumberOfPrivateResources;
+STATIC CONST EFI_ACPI_6_4_PPTT_STRUCTURE_CACHE_FLAGS* CacheFlags;
 STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
 
+/**
+  Increment the error count and print an error that a required flag is missing.
+
+  @param [in] FlagName  Name of the missing flag.
+**/
+STATIC
+VOID
+EFIAPI
+LogCacheFlagError (
+  IN CONST CHAR16* FlagName
+  )
+{
+  IncrementErrorCount ();
+  Print (
+      L"\nERROR: On Arm based systems, all cache properties must be"
+        L"provided in the cache type structure."
+        L"Missing '%s' flag.",
+      *FlagName
+      );
+}
+
+/**
+  This function validates the Cache Type Structure (Type 1) Cache Flags field.
+
+  @param [in] Ptr     Pointer to the start of the field data.
+  @param [in] Context Pointer to context specific information e.g. this
+                      could be a pointer to the ACPI table header.
+**/
+STATIC
+VOID
+EFIAPI
+ValidateCacheFlags (
+  IN UINT8* Ptr,
+  IN VOID*  Context
+  )
+{
+#if defined(MDE_CPU_ARM) || defined(MDE_CPU_AARCH64)
+  if (CacheFlags == NULL) {
+    IncrementErrorCount ();
+    Print (L"\nERROR: Cache Structure Flags were not successfully read.");
+    return;
+  }
+
+  if (CacheFlags->SizePropertyValid == EFI_ACPI_6_4_PPTT_CACHE_SIZE_INVALID) {
+    LogCacheFlagError (L"Size Property Valid");
+  }
+  if (CacheFlags->NumberOfSetsValid == EFI_ACPI_6_4_PPTT_NUMBER_OF_SETS_INVALID) {
+    LogCacheFlagError (L"Number Of Sets Valid");
+  }
+  if (CacheFlags->AssociativityValid == EFI_ACPI_6_4_PPTT_ASSOCIATIVITY_INVALID) {
+    LogCacheFlagError (L"Associativity Valid");
+  }
+  if (CacheFlags->AllocationTypeValid == EFI_ACPI_6_4_PPTT_ALLOCATION_TYPE_INVALID) {
+    LogCacheFlagError (L"Allocation Type Valid");
+  }
+  if (CacheFlags->CacheTypeValid == EFI_ACPI_6_4_PPTT_CACHE_TYPE_INVALID) {
+    LogCacheFlagError (L"Cache Type Valid");
+  }
+  if (CacheFlags->WritePolicyValid == EFI_ACPI_6_4_PPTT_WRITE_POLICY_INVALID) {
+    LogCacheFlagError (L"Write Policy Valid");
+  }
+  if (CacheFlags->LineSizeValid == EFI_ACPI_6_4_PPTT_LINE_SIZE_INVALID) {
+    LogCacheFlagError (L"Line Size Valid");
+  }
+  // Cache ID was only introduced in revision 3
+  if (*(AcpiHdrInfo.Revision) >= 3) {
+    if (CacheFlags->CacheIdValid == EFI_ACPI_6_4_PPTT_CACHE_ID_INVALID) {
+      LogCacheFlagError (L"Cache Id Valid");
+    }
+  }
+#endif
+}
+
 /**
   This function validates the Cache Type Structure (Type 1) 'Number of sets'
   field.
@@ -141,6 +215,44 @@ ValidateCacheLineSize (
 #endif
 }
 
+/**
+  This function validates the Cache Type Structure (Type 1) Cache ID field.
+
+  @param [in] Ptr     Pointer to the start of the field data.
+  @param [in] Context Pointer to context specific information e.g. this
+                      could be a pointer to the ACPI table header.
+**/
+STATIC
+VOID
+EFIAPI
+ValidateCacheId (
+  IN UINT8* Ptr,
+  IN VOID*  Context
+  )
+{
+  UINT32 CacheId;
+  CacheId = *(UINT32*)Ptr;
+
+  // Cache ID was only introduced in revision 3
+  if (*(AcpiHdrInfo.Revision) < 3) {
+    return;
+  }
+
+  if (CacheFlags == NULL) {
+    IncrementErrorCount ();
+    Print (L"\nERROR: Cache Structure Flags were not successfully read.");
+    return;
+  }
+
+  if (CacheFlags->CacheIdValid == EFI_ACPI_6_4_PPTT_CACHE_ID_VALID) {
+    if (CacheId == 0) {
+      IncrementErrorCount ();
+      Print (L"\nERROR: 0 is not a valid Cache ID.");
+      return;
+    }
+  }
+}
+
 /**
   This function validates the Cache Type Structure (Type 1) Attributes field.
 
@@ -213,13 +325,15 @@ STATIC CONST ACPI_PARSER CacheTypeStructureParser[] = {
   {L"Length", 1, 1, L"%d", NULL, NULL, NULL, NULL},
   {L"Reserved", 2, 2, L"0x%x", NULL, NULL, NULL, NULL},
 
-  {L"Flags", 4, 4, L"0x%x", NULL, NULL, NULL, NULL},
+  {L"Flags", 4, 4, L"0x%x", NULL, (VOID**)&CacheFlags, ValidateCacheFlags,
+   NULL},
   {L"Next Level of Cache", 4, 8, L"0x%x", NULL, NULL, NULL, NULL},
   {L"Size", 4, 12, L"0x%x", NULL, NULL, NULL, NULL},
   {L"Number of sets", 4, 16, L"%d", NULL, NULL, ValidateCacheNumberOfSets, NULL},
   {L"Associativity", 1, 20, L"%d", NULL, NULL, ValidateCacheAssociativity, NULL},
   {L"Attributes", 1, 21, L"0x%x", NULL, NULL, ValidateCacheAttributes, NULL},
-  {L"Line size", 2, 22, L"%d", NULL, NULL, ValidateCacheLineSize, NULL}
+  {L"Line size", 2, 22, L"%d", NULL, NULL, ValidateCacheLineSize, NULL},
+  {L"Cache ID", 4, 24, L"%d", NULL, NULL, ValidateCacheId, NULL}
 };
 
 /**
-- 
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")


  parent reply	other threads:[~2021-10-18 15:11 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-18 15:10 [PATCH v1 0/7] Support ACPI 6.4 PPTT changes Chris Jones
2021-10-18 15:10 ` [PATCH v1 1/7] MdePkg: Add missing Cache ID (in)valid define Chris Jones
2021-10-18 15:10 ` [PATCH v1 2/7] MdePkg: Remove PPTT ID type structure Chris Jones
2021-10-29  1:34   ` 回复: " gaoliming
2021-10-29  9:18     ` Chris Jones
2021-10-18 15:10 ` [PATCH v1 3/7] ShellPkg: Update Acpiview PPTT parser to ACPI 6.4 Chris Jones
2021-10-18 16:33   ` [edk2-devel] " Jeremy Linton
2021-11-03 17:47     ` Chris Jones
2021-10-18 15:10 ` Chris Jones [this message]
2021-10-18 15:10 ` [PATCH v1 5/7] DynamicTablesPkg: Remove PPTT ID structure from ACPI 6.4 generator Chris Jones
2021-10-18 15:10 ` [PATCH v1 6/7] DynamicTablesPkg: Update PPTT generator to ACPI 6.4 Chris Jones
2021-10-18 15:10 ` [PATCH v1 7/7] DynamicTablesPkg: Add CacheId to PPTT generator Chris Jones
2021-11-02  1:23 ` 回复: [edk2-devel] [PATCH v1 0/7] Support ACPI 6.4 PPTT changes gaoliming
2021-11-03 16:20   ` Chris Jones
2021-11-04  6:06     ` 回复: " gaoliming

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211018151046.31232-5-christopher.jones@arm.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox