Blame SOURCES/0013-Support-DRTM-in-a-big-endian-world.patch

214d7a
From bcdec27f562b0df37546b5e8ad2eab76348062eb Mon Sep 17 00:00:00 2001
214d7a
From: Al Stone <ahs3@redhat.com>
214d7a
Date: Sat, 19 Sep 2020 15:44:06 -0600
214d7a
Subject: [PATCH 13/45] Support DRTM in a big-endian world
214d7a
214d7a
Signed-off-by: Al Stone <ahs3@redhat.com>
214d7a
---
214d7a
 source/common/dmtbdump1.c  | 25 +++++++++++++++----------
214d7a
 source/compiler/dttable1.c |  6 ++++--
214d7a
 2 files changed, 19 insertions(+), 12 deletions(-)
214d7a
214d7a
Index: acpica-unix2-20210604/source/common/dmtbdump1.c
214d7a
===================================================================
214d7a
--- acpica-unix2-20210604.orig/source/common/dmtbdump1.c
214d7a
+++ acpica-unix2-20210604/source/common/dmtbdump1.c
214d7a
@@ -770,11 +770,14 @@ AcpiDmDumpDrtm (
214d7a
     ACPI_DRTM_RESOURCE_LIST *DrtmRl;
214d7a
     ACPI_DRTM_DPS_ID        *DrtmDps;
214d7a
     UINT32                  Count;
214d7a
+    UINT32                  ResourceCount;
214d7a
+    UINT32                  ValidatedTableCount;
214d7a
+    UINT32                  TableLength = AcpiUtReadUint32 (&Table->Length);
214d7a
 
214d7a
 
214d7a
     /* Main table */
214d7a
 
214d7a
-    Status = AcpiDmDumpTable (Table->Length, 0, Table, 0,
214d7a
+    Status = AcpiDmDumpTable (TableLength, 0, Table, 0,
214d7a
         AcpiDmTableInfoDrtm);
214d7a
     if (ACPI_FAILURE (Status))
214d7a
     {
214d7a
@@ -789,7 +792,7 @@ AcpiDmDumpDrtm (
214d7a
 
214d7a
     DrtmVtl = ACPI_ADD_PTR (ACPI_DRTM_VTABLE_LIST, Table, Offset);
214d7a
     AcpiOsPrintf ("\n");
214d7a
-    Status = AcpiDmDumpTable (Table->Length, Offset,
214d7a
+    Status = AcpiDmDumpTable (TableLength, Offset,
214d7a
         DrtmVtl, ACPI_OFFSET (ACPI_DRTM_VTABLE_LIST, ValidatedTables),
214d7a
         AcpiDmTableInfoDrtm0);
214d7a
     if (ACPI_FAILURE (Status))
214d7a
@@ -802,10 +805,11 @@ AcpiDmDumpDrtm (
214d7a
     /* Dump Validated table addresses */
214d7a
 
214d7a
     Count = 0;
214d7a
-    while ((Offset < Table->Length) &&
214d7a
-            (DrtmVtl->ValidatedTableCount > Count))
214d7a
+    ValidatedTableCount = AcpiUtReadUint32 (&DrtmVtl->ValidatedTableCount);
214d7a
+    while ((Offset < TableLength) &&
214d7a
+            (ValidatedTableCount > Count))
214d7a
     {
214d7a
-        Status = AcpiDmDumpTable (Table->Length, Offset,
214d7a
+        Status = AcpiDmDumpTable (TableLength, Offset,
214d7a
             ACPI_ADD_PTR (void, Table, Offset), sizeof (UINT64),
214d7a
             AcpiDmTableInfoDrtm0a);
214d7a
         if (ACPI_FAILURE (Status))
214d7a
@@ -821,7 +825,7 @@ AcpiDmDumpDrtm (
214d7a
 
214d7a
     DrtmRl = ACPI_ADD_PTR (ACPI_DRTM_RESOURCE_LIST, Table, Offset);
214d7a
     AcpiOsPrintf ("\n");
214d7a
-    Status = AcpiDmDumpTable (Table->Length, Offset,
214d7a
+    Status = AcpiDmDumpTable (TableLength, Offset,
214d7a
         DrtmRl, ACPI_OFFSET (ACPI_DRTM_RESOURCE_LIST, Resources),
214d7a
         AcpiDmTableInfoDrtm1);
214d7a
     if (ACPI_FAILURE (Status))
214d7a
@@ -834,10 +838,11 @@ AcpiDmDumpDrtm (
214d7a
     /* Dump the Resource List */
214d7a
 
214d7a
     Count = 0;
214d7a
-    while ((Offset < Table->Length) &&
214d7a
-           (DrtmRl->ResourceCount > Count))
214d7a
+    ResourceCount = AcpiUtReadUint32 (&DrtmRl->ResourceCount);
214d7a
+    while ((Offset < TableLength) &&
214d7a
+           (ResourceCount > Count))
214d7a
     {
214d7a
-        Status = AcpiDmDumpTable (Table->Length, Offset,
214d7a
+        Status = AcpiDmDumpTable (TableLength, Offset,
214d7a
             ACPI_ADD_PTR (void, Table, Offset),
214d7a
             sizeof (ACPI_DRTM_RESOURCE), AcpiDmTableInfoDrtm1a);
214d7a
         if (ACPI_FAILURE (Status))
214d7a
@@ -853,7 +858,7 @@ AcpiDmDumpDrtm (
214d7a
 
214d7a
     DrtmDps = ACPI_ADD_PTR (ACPI_DRTM_DPS_ID, Table, Offset);
214d7a
     AcpiOsPrintf ("\n");
214d7a
-    (void) AcpiDmDumpTable (Table->Length, Offset,
214d7a
+    (void) AcpiDmDumpTable (TableLength, Offset,
214d7a
         DrtmDps, sizeof (ACPI_DRTM_DPS_ID), AcpiDmTableInfoDrtm2);
214d7a
 }
214d7a
 
214d7a
Index: acpica-unix2-20210604/source/compiler/dttable1.c
214d7a
===================================================================
214d7a
--- acpica-unix2-20210604.orig/source/compiler/dttable1.c
214d7a
+++ acpica-unix2-20210604/source/compiler/dttable1.c
214d7a
@@ -849,7 +849,8 @@ DtCompileDrtm (
214d7a
         Count++;
214d7a
     }
214d7a
 
214d7a
-    DrtmVtl->ValidatedTableCount = Count;
214d7a
+    AcpiUtWriteUint (&DrtmVtl->ValidatedTableCount, sizeof (UINT32),
214d7a
+            &Count, sizeof (UINT32));
214d7a
     DtPopSubtable ();
214d7a
     ParentTable = DtPeekSubtable ();
214d7a
 
214d7a
@@ -887,7 +888,8 @@ DtCompileDrtm (
214d7a
         Count++;
214d7a
     }
214d7a
 
214d7a
-    DrtmRl->ResourceCount = Count;
214d7a
+    AcpiUtWriteUint(&DrtmRl->ResourceCount, sizeof(UINT32),
214d7a
+            &Count, sizeof(UINT32));
214d7a
     DtPopSubtable ();
214d7a
     ParentTable = DtPeekSubtable ();
214d7a