|
|
9897bb |
From 5fd729c8f6c4ce295edd142fc41e03e831ba4afb Mon Sep 17 00:00:00 2001
|
|
|
9897bb |
From: Al Stone <ahs3@redhat.com>
|
|
|
9897bb |
Date: Mon, 12 Jul 2021 09:39:38 -0600
|
|
|
9897bb |
Subject: [PATCH] Support PHAT in a big-endian world
|
|
|
9897bb |
|
|
|
9897bb |
Signed-off-by: Al Stone <ahs3@redhat.com>
|
|
|
9897bb |
---
|
|
|
9897bb |
source/common/dmtbdump2.c | 36 ++++++++++++++++++++----------------
|
|
|
9897bb |
source/compiler/dttable2.c | 12 +++++++++---
|
|
|
9897bb |
2 files changed, 29 insertions(+), 19 deletions(-)
|
|
|
9897bb |
|
|
|
9897bb |
Index: acpica-unix2-20210604/source/common/dmtbdump2.c
|
|
|
9897bb |
===================================================================
|
|
|
9897bb |
--- acpica-unix2-20210604.orig/source/common/dmtbdump2.c
|
|
|
9897bb |
+++ acpica-unix2-20210604/source/common/dmtbdump2.c
|
|
|
9897bb |
@@ -1573,39 +1573,41 @@ AcpiDmDumpPhat (
|
|
|
9897bb |
ACPI_PHAT_HEADER *Subtable;
|
|
|
9897bb |
ACPI_PHAT_VERSION_DATA *VersionData;
|
|
|
9897bb |
UINT32 RecordCount;
|
|
|
9897bb |
- UINT32 Length = Table->Length;
|
|
|
9897bb |
+ UINT32 TableLength = AcpiUtReadUint32 (&Table->Length);
|
|
|
9897bb |
UINT32 Offset = sizeof (ACPI_TABLE_PHAT);
|
|
|
9897bb |
- UINT32 SubtableLength;
|
|
|
9897bb |
+ UINT16 SubtableLength;
|
|
|
9897bb |
UINT32 PathLength;
|
|
|
9897bb |
UINT32 VendorLength;
|
|
|
9897bb |
+ UINT16 SubtableType;
|
|
|
9897bb |
|
|
|
9897bb |
|
|
|
9897bb |
Subtable = ACPI_ADD_PTR (ACPI_PHAT_HEADER, Table, sizeof (ACPI_TABLE_PHAT));
|
|
|
9897bb |
|
|
|
9897bb |
- while (Offset < Table->Length)
|
|
|
9897bb |
+ while (Offset < TableLength)
|
|
|
9897bb |
{
|
|
|
9897bb |
/* Common subtable header */
|
|
|
9897bb |
|
|
|
9897bb |
+ SubtableType = AcpiUtReadUint16 (&Subtable->Type);
|
|
|
9897bb |
+ SubtableLength = AcpiUtReadUint16 (&Subtable->Length);
|
|
|
9897bb |
+
|
|
|
9897bb |
AcpiOsPrintf ("\n");
|
|
|
9897bb |
- Status = AcpiDmDumpTable (Length, 0, Subtable,
|
|
|
9897bb |
+ Status = AcpiDmDumpTable (TableLength, 0, Subtable,
|
|
|
9897bb |
sizeof (ACPI_PHAT_HEADER), AcpiDmTableInfoPhatHdr);
|
|
|
9897bb |
if (ACPI_FAILURE (Status))
|
|
|
9897bb |
{
|
|
|
9897bb |
return;
|
|
|
9897bb |
}
|
|
|
9897bb |
|
|
|
9897bb |
- switch (Subtable->Type)
|
|
|
9897bb |
+ switch (SubtableType)
|
|
|
9897bb |
{
|
|
|
9897bb |
case ACPI_PHAT_TYPE_FW_VERSION_DATA:
|
|
|
9897bb |
|
|
|
9897bb |
InfoTable = AcpiDmTableInfoPhat0;
|
|
|
9897bb |
- SubtableLength = sizeof (ACPI_PHAT_VERSION_DATA);
|
|
|
9897bb |
break;
|
|
|
9897bb |
|
|
|
9897bb |
case ACPI_PHAT_TYPE_FW_HEALTH_DATA:
|
|
|
9897bb |
|
|
|
9897bb |
InfoTable = AcpiDmTableInfoPhat1;
|
|
|
9897bb |
- SubtableLength = sizeof (ACPI_PHAT_HEALTH_DATA);
|
|
|
9897bb |
break;
|
|
|
9897bb |
|
|
|
9897bb |
default:
|
|
|
9897bb |
@@ -1616,22 +1618,22 @@ AcpiDmDumpPhat (
|
|
|
9897bb |
return;
|
|
|
9897bb |
}
|
|
|
9897bb |
|
|
|
9897bb |
- Status = AcpiDmDumpTable (Length, 0, Subtable,
|
|
|
9897bb |
+ Status = AcpiDmDumpTable (TableLength, 0, Subtable,
|
|
|
9897bb |
SubtableLength, InfoTable);
|
|
|
9897bb |
if (ACPI_FAILURE (Status))
|
|
|
9897bb |
{
|
|
|
9897bb |
return;
|
|
|
9897bb |
}
|
|
|
9897bb |
|
|
|
9897bb |
- switch (Subtable->Type)
|
|
|
9897bb |
+ switch (SubtableType)
|
|
|
9897bb |
{
|
|
|
9897bb |
case ACPI_PHAT_TYPE_FW_VERSION_DATA:
|
|
|
9897bb |
|
|
|
9897bb |
VersionData = ACPI_CAST_PTR (ACPI_PHAT_VERSION_DATA, Subtable);
|
|
|
9897bb |
- RecordCount = VersionData->ElementCount;
|
|
|
9897bb |
+ RecordCount = AcpiUtReadUint32 (&VersionData->ElementCount);
|
|
|
9897bb |
while (RecordCount)
|
|
|
9897bb |
{
|
|
|
9897bb |
- Status = AcpiDmDumpTable (Length, Offset,
|
|
|
9897bb |
+ Status = AcpiDmDumpTable (TableLength, Offset,
|
|
|
9897bb |
ACPI_ADD_PTR (ACPI_PHAT_HEADER, Subtable, sizeof (ACPI_PHAT_VERSION_DATA)),
|
|
|
9897bb |
sizeof (ACPI_PHAT_VERSION_ELEMENT), AcpiDmTableInfoPhat0a);
|
|
|
9897bb |
if (ACPI_FAILURE (Status))
|
|
|
9897bb |
@@ -1649,7 +1651,7 @@ AcpiDmDumpPhat (
|
|
|
9897bb |
/* account for the null terminator */
|
|
|
9897bb |
|
|
|
9897bb |
PathLength = strlen (ACPI_ADD_PTR (char, Subtable, sizeof (ACPI_PHAT_HEALTH_DATA))) + 1;
|
|
|
9897bb |
- Status = AcpiDmDumpTable (Length, Offset,
|
|
|
9897bb |
+ Status = AcpiDmDumpTable (TableLength, Offset,
|
|
|
9897bb |
ACPI_ADD_PTR (ACPI_PHAT_HEADER, Subtable, sizeof (ACPI_PHAT_HEALTH_DATA)),
|
|
|
9897bb |
PathLength, AcpiDmTableInfoPhat1a);
|
|
|
9897bb |
if (ACPI_FAILURE (Status))
|
|
|
9897bb |
@@ -1660,8 +1662,8 @@ AcpiDmDumpPhat (
|
|
|
9897bb |
/* Get vendor data - data length is the remaining subtable length */
|
|
|
9897bb |
|
|
|
9897bb |
VendorLength =
|
|
|
9897bb |
- Subtable->Length - sizeof (ACPI_PHAT_HEALTH_DATA) - PathLength;
|
|
|
9897bb |
- Status = AcpiDmDumpTable (Length, 0,
|
|
|
9897bb |
+ SubtableLength - sizeof (ACPI_PHAT_HEALTH_DATA) - PathLength;
|
|
|
9897bb |
+ Status = AcpiDmDumpTable (TableLength, 0,
|
|
|
9897bb |
ACPI_ADD_PTR (ACPI_PHAT_HEADER, Subtable, sizeof (ACPI_PHAT_HEALTH_DATA) + PathLength),
|
|
|
9897bb |
VendorLength, AcpiDmTableInfoPhat1b);
|
|
|
9897bb |
if (ACPI_FAILURE (Status))
|
|
|
9897bb |
@@ -1673,15 +1675,15 @@ AcpiDmDumpPhat (
|
|
|
9897bb |
default:
|
|
|
9897bb |
|
|
|
9897bb |
AcpiOsPrintf ("\n**** Unknown PHAT subtable type 0x%X\n\n",
|
|
|
9897bb |
- Subtable->Type);
|
|
|
9897bb |
+ SubtableType);
|
|
|
9897bb |
return;
|
|
|
9897bb |
}
|
|
|
9897bb |
|
|
|
9897bb |
/* Next subtable */
|
|
|
9897bb |
|
|
|
9897bb |
- Offset += Subtable->Length;
|
|
|
9897bb |
+ Offset += SubtableLength;
|
|
|
9897bb |
Subtable = ACPI_ADD_PTR (ACPI_PHAT_HEADER, Subtable,
|
|
|
9897bb |
- Subtable->Length);
|
|
|
9897bb |
+ SubtableLength);
|
|
|
9897bb |
}
|
|
|
9897bb |
}
|
|
|
9897bb |
|
|
|
9897bb |
Index: acpica-unix2-20210604/source/compiler/dttable2.c
|
|
|
9897bb |
===================================================================
|
|
|
9897bb |
--- acpica-unix2-20210604.orig/source/compiler/dttable2.c
|
|
|
9897bb |
+++ acpica-unix2-20210604/source/compiler/dttable2.c
|
|
|
9897bb |
@@ -870,6 +870,8 @@ DtCompilePhat (
|
|
|
9897bb |
ACPI_DMTABLE_INFO *Info;
|
|
|
9897bb |
ACPI_PHAT_VERSION_DATA *VersionData;
|
|
|
9897bb |
UINT32 RecordCount;
|
|
|
9897bb |
+ UINT16 SubtableType;
|
|
|
9897bb |
+ UINT16 Tmp16;
|
|
|
9897bb |
|
|
|
9897bb |
|
|
|
9897bb |
/* The table consist of subtables */
|
|
|
9897bb |
@@ -887,8 +889,9 @@ DtCompilePhat (
|
|
|
9897bb |
DtPushSubtable (Subtable);
|
|
|
9897bb |
|
|
|
9897bb |
PhatHeader = ACPI_CAST_PTR (ACPI_PHAT_HEADER, Subtable->Buffer);
|
|
|
9897bb |
+ SubtableType = AcpiUtReadUint16 (&PhatHeader->Type);
|
|
|
9897bb |
|
|
|
9897bb |
- switch (PhatHeader->Type)
|
|
|
9897bb |
+ switch (SubtableType)
|
|
|
9897bb |
{
|
|
|
9897bb |
case ACPI_PHAT_TYPE_FW_VERSION_DATA:
|
|
|
9897bb |
|
|
|
9897bb |
@@ -919,13 +922,13 @@ DtCompilePhat (
|
|
|
9897bb |
ParentTable = DtPeekSubtable ();
|
|
|
9897bb |
DtInsertSubtable (ParentTable, Subtable);
|
|
|
9897bb |
|
|
|
9897bb |
- switch (PhatHeader->Type)
|
|
|
9897bb |
+ switch (SubtableType)
|
|
|
9897bb |
{
|
|
|
9897bb |
case ACPI_PHAT_TYPE_FW_VERSION_DATA:
|
|
|
9897bb |
|
|
|
9897bb |
VersionData = ACPI_CAST_PTR (ACPI_PHAT_VERSION_DATA,
|
|
|
9897bb |
(Subtable->Buffer - sizeof (ACPI_PHAT_HEADER)));
|
|
|
9897bb |
- RecordCount = VersionData->ElementCount;
|
|
|
9897bb |
+ RecordCount = AcpiUtReadUint32 (&VersionData->ElementCount);
|
|
|
9897bb |
|
|
|
9897bb |
while (RecordCount)
|
|
|
9897bb |
{
|
|
|
9897bb |
@@ -976,6 +979,9 @@ DtCompilePhat (
|
|
|
9897bb |
DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, *PFieldList, "PHAT");
|
|
|
9897bb |
return (AE_ERROR);
|
|
|
9897bb |
}
|
|
|
9897bb |
+
|
|
|
9897bb |
+ Tmp16 = AcpiUtReadUint16 (&PhatHeader->Length);
|
|
|
9897bb |
+ PhatHeader->Length = Tmp16;
|
|
|
9897bb |
}
|
|
|
9897bb |
|
|
|
9897bb |
return (Status);
|