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

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