2021-07-12 03:22:10 +00:00
|
|
|
From 2cb0b87a15682da4f19f707fa3ffece504f94b5a Mon Sep 17 00:00:00 2001
|
2020-10-19 18:24:09 +00:00
|
|
|
From: Al Stone <ahs3@redhat.com>
|
|
|
|
Date: Sat, 19 Sep 2020 13:37:38 -0600
|
2021-07-12 03:22:10 +00:00
|
|
|
Subject: [PATCH 11/45] Support DBG2 table in a big-endian world
|
2020-10-19 18:24:09 +00:00
|
|
|
|
|
|
|
Signed-off-by: Al Stone <ahs3@redhat.com>
|
|
|
|
---
|
2021-07-12 03:22:10 +00:00
|
|
|
source/common/dmtbdump1.c | 37 ++++++++++++++++++--------------
|
2020-10-19 18:24:09 +00:00
|
|
|
source/compiler/dttable1.c | 43 ++++++++++++++++++++++++--------------
|
2021-07-12 03:22:10 +00:00
|
|
|
2 files changed, 48 insertions(+), 32 deletions(-)
|
2020-10-19 18:24:09 +00:00
|
|
|
|
2021-07-12 03:22:10 +00:00
|
|
|
Index: acpica-unix2-20210604/source/common/dmtbdump1.c
|
2020-10-19 18:24:09 +00:00
|
|
|
===================================================================
|
2021-07-12 03:22:10 +00:00
|
|
|
--- acpica-unix2-20210604.orig/source/common/dmtbdump1.c
|
|
|
|
+++ acpica-unix2-20210604/source/common/dmtbdump1.c
|
|
|
|
@@ -374,7 +374,7 @@ AcpiDmDumpCsrt (
|
2020-10-19 18:24:09 +00:00
|
|
|
ACPI_CSRT_GROUP *Subtable;
|
|
|
|
ACPI_CSRT_SHARED_INFO *SharedInfoTable;
|
|
|
|
ACPI_CSRT_DESCRIPTOR *SubSubtable;
|
|
|
|
- UINT32 Length = Table->Length;
|
2021-07-12 03:22:10 +00:00
|
|
|
+ UINT32 Length = AcpiUtReadUint32 (&Table->Length);
|
2020-10-19 18:24:09 +00:00
|
|
|
UINT32 Offset = sizeof (ACPI_TABLE_CSRT);
|
|
|
|
UINT32 SubOffset;
|
|
|
|
UINT32 SubSubOffset;
|
2021-07-12 03:22:10 +00:00
|
|
|
@@ -386,7 +386,7 @@ AcpiDmDumpCsrt (
|
2020-10-19 18:24:09 +00:00
|
|
|
/* Subtables (Resource Groups) */
|
|
|
|
|
|
|
|
Subtable = ACPI_ADD_PTR (ACPI_CSRT_GROUP, Table, Offset);
|
|
|
|
- while (Offset < Table->Length)
|
|
|
|
+ while (Offset < Length)
|
|
|
|
{
|
|
|
|
/* Resource group subtable */
|
|
|
|
|
2021-07-12 03:22:10 +00:00
|
|
|
@@ -420,7 +420,7 @@ AcpiDmDumpCsrt (
|
2020-10-19 18:24:09 +00:00
|
|
|
Offset + SubOffset);
|
|
|
|
|
|
|
|
while ((SubOffset < Subtable->Length) &&
|
|
|
|
- ((Offset + SubOffset) < Table->Length))
|
|
|
|
+ ((Offset + SubOffset) < Length))
|
|
|
|
{
|
|
|
|
AcpiOsPrintf ("\n");
|
|
|
|
Status = AcpiDmDumpTable (Length, Offset + SubOffset, SubSubtable,
|
2021-07-12 03:22:10 +00:00
|
|
|
@@ -481,12 +481,13 @@ AcpiDmDumpDbg2 (
|
2020-10-19 18:24:09 +00:00
|
|
|
{
|
|
|
|
ACPI_STATUS Status;
|
|
|
|
ACPI_DBG2_DEVICE *Subtable;
|
|
|
|
- UINT32 Length = Table->Length;
|
2021-07-12 03:22:10 +00:00
|
|
|
+ UINT32 Length = AcpiUtReadUint32 (&Table->Length);
|
2020-10-19 18:24:09 +00:00
|
|
|
UINT32 Offset = sizeof (ACPI_TABLE_DBG2);
|
|
|
|
UINT32 i;
|
|
|
|
UINT32 ArrayOffset;
|
|
|
|
UINT32 AbsoluteOffset;
|
|
|
|
UINT8 *Array;
|
|
|
|
+ UINT16 SubtableLength;
|
|
|
|
|
|
|
|
|
|
|
|
/* Main table */
|
2021-07-12 03:22:10 +00:00
|
|
|
@@ -500,11 +501,12 @@ AcpiDmDumpDbg2 (
|
2020-10-19 18:24:09 +00:00
|
|
|
/* Subtables */
|
|
|
|
|
|
|
|
Subtable = ACPI_ADD_PTR (ACPI_DBG2_DEVICE, Table, Offset);
|
|
|
|
- while (Offset < Table->Length)
|
|
|
|
+ while (Offset < Length)
|
|
|
|
{
|
|
|
|
AcpiOsPrintf ("\n");
|
2021-07-12 03:22:10 +00:00
|
|
|
+ SubtableLength = AcpiUtReadUint16 (&Subtable->Length);
|
2020-10-19 18:24:09 +00:00
|
|
|
Status = AcpiDmDumpTable (Length, Offset, Subtable,
|
|
|
|
- Subtable->Length, AcpiDmTableInfoDbg2Device);
|
|
|
|
+ SubtableLength, AcpiDmTableInfoDbg2Device);
|
|
|
|
if (ACPI_FAILURE (Status))
|
|
|
|
{
|
|
|
|
return;
|
2021-07-12 03:22:10 +00:00
|
|
|
@@ -514,13 +516,13 @@ AcpiDmDumpDbg2 (
|
2020-10-19 18:24:09 +00:00
|
|
|
|
|
|
|
for (i = 0; i < Subtable->RegisterCount; i++)
|
|
|
|
{
|
|
|
|
- ArrayOffset = Subtable->BaseAddressOffset +
|
2021-07-12 03:22:10 +00:00
|
|
|
+ ArrayOffset = AcpiUtReadUint16 (&Subtable->BaseAddressOffset) +
|
2020-10-19 18:24:09 +00:00
|
|
|
(sizeof (ACPI_GENERIC_ADDRESS) * i);
|
|
|
|
AbsoluteOffset = Offset + ArrayOffset;
|
|
|
|
Array = (UINT8 *) Subtable + ArrayOffset;
|
|
|
|
|
|
|
|
Status = AcpiDmDumpTable (Length, AbsoluteOffset, Array,
|
|
|
|
- Subtable->Length, AcpiDmTableInfoDbg2Addr);
|
|
|
|
+ SubtableLength, AcpiDmTableInfoDbg2Addr);
|
|
|
|
if (ACPI_FAILURE (Status))
|
|
|
|
{
|
|
|
|
return;
|
2021-07-12 03:22:10 +00:00
|
|
|
@@ -531,13 +533,13 @@ AcpiDmDumpDbg2 (
|
2020-10-19 18:24:09 +00:00
|
|
|
|
|
|
|
for (i = 0; i < Subtable->RegisterCount; i++)
|
|
|
|
{
|
|
|
|
- ArrayOffset = Subtable->AddressSizeOffset +
|
2021-07-12 03:22:10 +00:00
|
|
|
+ ArrayOffset = AcpiUtReadUint16 (&Subtable->AddressSizeOffset) +
|
2020-10-19 18:24:09 +00:00
|
|
|
(sizeof (UINT32) * i);
|
|
|
|
AbsoluteOffset = Offset + ArrayOffset;
|
|
|
|
Array = (UINT8 *) Subtable + ArrayOffset;
|
|
|
|
|
|
|
|
Status = AcpiDmDumpTable (Length, AbsoluteOffset, Array,
|
|
|
|
- Subtable->Length, AcpiDmTableInfoDbg2Size);
|
|
|
|
+ SubtableLength, AcpiDmTableInfoDbg2Size);
|
|
|
|
if (ACPI_FAILURE (Status))
|
|
|
|
{
|
|
|
|
return;
|
2021-07-12 03:22:10 +00:00
|
|
|
@@ -547,12 +549,12 @@ AcpiDmDumpDbg2 (
|
2020-10-19 18:24:09 +00:00
|
|
|
/* Dump the Namestring (required) */
|
|
|
|
|
|
|
|
AcpiOsPrintf ("\n");
|
|
|
|
- ArrayOffset = Subtable->NamepathOffset;
|
2021-07-12 03:22:10 +00:00
|
|
|
+ ArrayOffset = AcpiUtReadUint16 (&Subtable->NamepathOffset);
|
2020-10-19 18:24:09 +00:00
|
|
|
AbsoluteOffset = Offset + ArrayOffset;
|
|
|
|
Array = (UINT8 *) Subtable + ArrayOffset;
|
|
|
|
|
|
|
|
Status = AcpiDmDumpTable (Length, AbsoluteOffset, Array,
|
|
|
|
- Subtable->Length, AcpiDmTableInfoDbg2Name);
|
|
|
|
+ SubtableLength, AcpiDmTableInfoDbg2Name);
|
|
|
|
if (ACPI_FAILURE (Status))
|
|
|
|
{
|
|
|
|
return;
|
2021-07-12 03:22:10 +00:00
|
|
|
@@ -562,8 +564,11 @@ AcpiDmDumpDbg2 (
|
2020-10-19 18:24:09 +00:00
|
|
|
|
|
|
|
if (Subtable->OemDataOffset)
|
|
|
|
{
|
|
|
|
- Status = AcpiDmDumpTable (Length, Offset + Subtable->OemDataOffset,
|
|
|
|
- Table, Subtable->OemDataLength,
|
2021-07-12 03:22:10 +00:00
|
|
|
+ Array = (UINT8 *) Subtable + AcpiUtReadUint16 (&Subtable->OemDataOffset);
|
|
|
|
+
|
2020-10-19 18:24:09 +00:00
|
|
|
+ Status = AcpiDmDumpTable (Length,
|
2021-07-12 03:22:10 +00:00
|
|
|
+ Offset + AcpiUtReadUint16 (&Subtable->OemDataOffset),
|
|
|
|
+ Array, AcpiUtReadUint16 (&Subtable->OemDataLength),
|
2020-10-19 18:24:09 +00:00
|
|
|
AcpiDmTableInfoDbg2OemData);
|
|
|
|
if (ACPI_FAILURE (Status))
|
|
|
|
{
|
2021-07-12 03:22:10 +00:00
|
|
|
@@ -573,9 +578,9 @@ AcpiDmDumpDbg2 (
|
2020-10-19 18:24:09 +00:00
|
|
|
|
|
|
|
/* Point to next subtable */
|
|
|
|
|
|
|
|
- Offset += Subtable->Length;
|
|
|
|
+ Offset += SubtableLength;
|
|
|
|
Subtable = ACPI_ADD_PTR (ACPI_DBG2_DEVICE, Subtable,
|
|
|
|
- Subtable->Length);
|
|
|
|
+ SubtableLength);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-12 03:22:10 +00:00
|
|
|
Index: acpica-unix2-20210604/source/compiler/dttable1.c
|
2020-10-19 18:24:09 +00:00
|
|
|
===================================================================
|
2021-07-12 03:22:10 +00:00
|
|
|
--- acpica-unix2-20210604.orig/source/compiler/dttable1.c
|
|
|
|
+++ acpica-unix2-20210604/source/compiler/dttable1.c
|
|
|
|
@@ -355,6 +355,7 @@ DtCompileCsrt (
|
2020-10-19 18:24:09 +00:00
|
|
|
DT_FIELD **PFieldList = (DT_FIELD **) List;
|
|
|
|
UINT32 DescriptorCount;
|
|
|
|
UINT32 GroupLength;
|
|
|
|
+ UINT32 Tmp;
|
|
|
|
|
|
|
|
|
|
|
|
/* Subtables (Resource Groups) */
|
2021-07-12 03:22:10 +00:00
|
|
|
@@ -373,12 +374,13 @@ DtCompileCsrt (
|
2020-10-19 18:24:09 +00:00
|
|
|
|
|
|
|
/* Compute the number of resource descriptors */
|
|
|
|
|
|
|
|
- GroupLength =
|
|
|
|
- (ACPI_CAST_PTR (ACPI_CSRT_GROUP,
|
|
|
|
- Subtable->Buffer))->Length -
|
|
|
|
- (ACPI_CAST_PTR (ACPI_CSRT_GROUP,
|
|
|
|
- Subtable->Buffer))->SharedInfoLength -
|
|
|
|
- sizeof (ACPI_CSRT_GROUP);
|
2021-07-12 03:22:10 +00:00
|
|
|
+ Tmp = AcpiUtReadUint32 (&(ACPI_CAST_PTR (ACPI_CSRT_GROUP,
|
|
|
|
+ Subtable->Buffer))->Length);
|
|
|
|
+ GroupLength = Tmp;
|
|
|
|
+ Tmp = AcpiUtReadUint32 (&(ACPI_CAST_PTR (ACPI_CSRT_GROUP,
|
|
|
|
+ Subtable->Buffer))->SharedInfoLength);
|
2020-10-19 18:24:09 +00:00
|
|
|
+ GroupLength -= Tmp;
|
|
|
|
+ GroupLength -= sizeof (ACPI_CSRT_GROUP);
|
|
|
|
|
|
|
|
DescriptorCount = (GroupLength /
|
|
|
|
sizeof (ACPI_CSRT_DESCRIPTOR));
|
2021-07-12 03:22:10 +00:00
|
|
|
@@ -466,6 +468,7 @@ DtCompileDbg2 (
|
2020-10-19 18:24:09 +00:00
|
|
|
ACPI_DBG2_DEVICE *DeviceInfo;
|
|
|
|
UINT16 CurrentOffset;
|
|
|
|
UINT32 i;
|
|
|
|
+ UINT32 Tmp;
|
|
|
|
|
|
|
|
|
|
|
|
/* Main table */
|
2021-07-12 03:22:10 +00:00
|
|
|
@@ -482,10 +485,12 @@ DtCompileDbg2 (
|
2020-10-19 18:24:09 +00:00
|
|
|
/* Main table fields */
|
|
|
|
|
|
|
|
Dbg2Header = ACPI_CAST_PTR (ACPI_DBG2_HEADER, Subtable->Buffer);
|
|
|
|
- Dbg2Header->InfoOffset = sizeof (ACPI_TABLE_HEADER) + ACPI_PTR_DIFF (
|
|
|
|
- ACPI_ADD_PTR (UINT8, Dbg2Header, sizeof (ACPI_DBG2_HEADER)), Dbg2Header);
|
|
|
|
+ Tmp = sizeof (ACPI_TABLE_HEADER) + ACPI_PTR_DIFF (
|
|
|
|
+ ACPI_ADD_PTR (UINT8, Dbg2Header, sizeof (ACPI_DBG2_HEADER)), Dbg2Header);
|
2021-07-12 03:22:10 +00:00
|
|
|
+ AcpiUtWriteUint (&Dbg2Header->InfoOffset, sizeof (UINT32),
|
|
|
|
+ &Tmp, sizeof (UINT32));
|
2020-10-19 18:24:09 +00:00
|
|
|
|
|
|
|
- SubtableCount = Dbg2Header->InfoCount;
|
|
|
|
+ SubtableCount = Tmp;
|
|
|
|
DtPushSubtable (Subtable);
|
|
|
|
|
|
|
|
/* Process all Device Information subtables (Count = InfoCount) */
|
2021-07-12 03:22:10 +00:00
|
|
|
@@ -512,7 +517,8 @@ DtCompileDbg2 (
|
2020-10-19 18:24:09 +00:00
|
|
|
|
|
|
|
/* BaseAddressRegister GAS array (Required, size is RegisterCount) */
|
|
|
|
|
|
|
|
- DeviceInfo->BaseAddressOffset = CurrentOffset;
|
2021-07-12 03:22:10 +00:00
|
|
|
+ AcpiUtWriteUint (&DeviceInfo->BaseAddressOffset, sizeof (UINT16),
|
|
|
|
+ &CurrentOffset, sizeof (UINT16));
|
2020-10-19 18:24:09 +00:00
|
|
|
for (i = 0; *PFieldList && (i < DeviceInfo->RegisterCount); i++)
|
|
|
|
{
|
|
|
|
Status = DtCompileTable (PFieldList, AcpiDmTableInfoDbg2Addr,
|
2021-07-12 03:22:10 +00:00
|
|
|
@@ -528,7 +534,8 @@ DtCompileDbg2 (
|
2020-10-19 18:24:09 +00:00
|
|
|
|
|
|
|
/* AddressSize array (Required, size = RegisterCount) */
|
|
|
|
|
|
|
|
- DeviceInfo->AddressSizeOffset = CurrentOffset;
|
2021-07-12 03:22:10 +00:00
|
|
|
+ AcpiUtWriteUint (&DeviceInfo->AddressSizeOffset, sizeof (UINT16),
|
|
|
|
+ &CurrentOffset, sizeof (UINT16));
|
2020-10-19 18:24:09 +00:00
|
|
|
for (i = 0; *PFieldList && (i < DeviceInfo->RegisterCount); i++)
|
|
|
|
{
|
|
|
|
Status = DtCompileTable (PFieldList, AcpiDmTableInfoDbg2Size,
|
2021-07-12 03:22:10 +00:00
|
|
|
@@ -544,7 +551,8 @@ DtCompileDbg2 (
|
2020-10-19 18:24:09 +00:00
|
|
|
|
|
|
|
/* NamespaceString device identifier (Required, size = NamePathLength) */
|
|
|
|
|
|
|
|
- DeviceInfo->NamepathOffset = CurrentOffset;
|
2021-07-12 03:22:10 +00:00
|
|
|
+ AcpiUtWriteUint (&DeviceInfo->NamepathOffset, sizeof (UINT16),
|
|
|
|
+ &CurrentOffset, sizeof (UINT16));
|
2020-10-19 18:24:09 +00:00
|
|
|
Status = DtCompileTable (PFieldList, AcpiDmTableInfoDbg2Name,
|
|
|
|
&Subtable);
|
|
|
|
if (ACPI_FAILURE (Status))
|
2021-07-12 03:22:10 +00:00
|
|
|
@@ -554,8 +562,9 @@ DtCompileDbg2 (
|
2020-10-19 18:24:09 +00:00
|
|
|
|
|
|
|
/* Update the device info header */
|
|
|
|
|
|
|
|
- DeviceInfo->NamepathLength = (UINT16) Subtable->Length;
|
|
|
|
- CurrentOffset += (UINT16) DeviceInfo->NamepathLength;
|
2021-07-12 03:22:10 +00:00
|
|
|
+ AcpiUtWriteUint (&DeviceInfo->NamepathLength, sizeof (UINT16),
|
|
|
|
+ &Subtable->Length, sizeof (UINT32));
|
|
|
|
+ CurrentOffset += AcpiUtReadUint16 (&DeviceInfo->NamepathLength);
|
2020-10-19 18:24:09 +00:00
|
|
|
DtInsertSubtable (ParentTable, Subtable);
|
|
|
|
|
|
|
|
/* OemData - Variable-length data (Optional, size = OemDataLength) */
|
2021-07-12 03:22:10 +00:00
|
|
|
@@ -582,8 +591,10 @@ DtCompileDbg2 (
|
2020-10-19 18:24:09 +00:00
|
|
|
|
|
|
|
if (Subtable && Subtable->Length)
|
|
|
|
{
|
|
|
|
- DeviceInfo->OemDataOffset = CurrentOffset;
|
|
|
|
- DeviceInfo->OemDataLength = (UINT16) Subtable->Length;
|
2021-07-12 03:22:10 +00:00
|
|
|
+ AcpiUtWriteUint (&DeviceInfo->OemDataOffset, sizeof (UINT16),
|
|
|
|
+ &CurrentOffset, sizeof (UINT16));
|
|
|
|
+ AcpiUtWriteUint (&DeviceInfo->OemDataLength, sizeof (UINT16),
|
|
|
|
+ &Subtable->Length, sizeof (UINT32));
|
2020-10-19 18:24:09 +00:00
|
|
|
|
|
|
|
DtInsertSubtable (ParentTable, Subtable);
|
|
|
|
}
|