|
|
214d7a |
From b3051bc2bad8988f3ad81a8307de6f1d0eef4ace Mon Sep 17 00:00:00 2001
|
|
|
214d7a |
From: Al Stone <ahs3@redhat.com>
|
|
|
214d7a |
Date: Sun, 20 Sep 2020 11:42:21 -0600
|
|
|
214d7a |
Subject: [PATCH 16/45] Support FADT (aka, FACP) in a big-endian world
|
|
|
214d7a |
|
|
|
214d7a |
Signed-off-by: Al Stone <ahs3@redhat.com>
|
|
|
214d7a |
---
|
|
|
214d7a |
source/common/dmtbdump.c | 25 ++++++++++++-----------
|
|
|
214d7a |
source/components/tables/tbfadt.c | 34 +++++++++++++++++++++++--------
|
|
|
214d7a |
2 files changed, 38 insertions(+), 21 deletions(-)
|
|
|
214d7a |
|
|
|
214d7a |
Index: acpica-unix2-20210604/source/common/dmtbdump.c
|
|
|
214d7a |
===================================================================
|
|
|
214d7a |
--- acpica-unix2-20210604.orig/source/common/dmtbdump.c
|
|
|
214d7a |
+++ acpica-unix2-20210604/source/common/dmtbdump.c
|
|
|
214d7a |
@@ -363,11 +363,12 @@ AcpiDmDumpFadt (
|
|
|
214d7a |
ACPI_TABLE_HEADER *Table)
|
|
|
214d7a |
{
|
|
|
214d7a |
ACPI_STATUS Status;
|
|
|
214d7a |
+ UINT32 TableLength = AcpiUtReadUint32 (&Table->Length);
|
|
|
214d7a |
|
|
|
214d7a |
|
|
|
214d7a |
/* Always dump the minimum FADT revision 1 fields (ACPI 1.0) */
|
|
|
214d7a |
|
|
|
214d7a |
- Status = AcpiDmDumpTable (Table->Length, 0, Table, 0,
|
|
|
214d7a |
+ Status = AcpiDmDumpTable (TableLength, 0, Table, 0,
|
|
|
214d7a |
AcpiDmTableInfoFadt1);
|
|
|
214d7a |
if (ACPI_FAILURE (Status))
|
|
|
214d7a |
{
|
|
|
214d7a |
@@ -376,10 +377,10 @@ AcpiDmDumpFadt (
|
|
|
214d7a |
|
|
|
214d7a |
/* Check for FADT revision 2 fields (ACPI 1.0B MS extensions) */
|
|
|
214d7a |
|
|
|
214d7a |
- if ((Table->Length > ACPI_FADT_V1_SIZE) &&
|
|
|
214d7a |
- (Table->Length <= ACPI_FADT_V2_SIZE))
|
|
|
214d7a |
+ if ((TableLength > ACPI_FADT_V1_SIZE) &&
|
|
|
214d7a |
+ (TableLength <= ACPI_FADT_V2_SIZE))
|
|
|
214d7a |
{
|
|
|
214d7a |
- Status = AcpiDmDumpTable (Table->Length, 0, Table, 0,
|
|
|
214d7a |
+ Status = AcpiDmDumpTable (TableLength, 0, Table, 0,
|
|
|
214d7a |
AcpiDmTableInfoFadt2);
|
|
|
214d7a |
if (ACPI_FAILURE (Status))
|
|
|
214d7a |
{
|
|
|
214d7a |
@@ -389,9 +390,9 @@ AcpiDmDumpFadt (
|
|
|
214d7a |
|
|
|
214d7a |
/* Check for FADT revision 3/4 fields and up (ACPI 2.0+ extended data) */
|
|
|
214d7a |
|
|
|
214d7a |
- else if (Table->Length > ACPI_FADT_V2_SIZE)
|
|
|
214d7a |
+ else if (TableLength > ACPI_FADT_V2_SIZE)
|
|
|
214d7a |
{
|
|
|
214d7a |
- Status = AcpiDmDumpTable (Table->Length, 0, Table, 0,
|
|
|
214d7a |
+ Status = AcpiDmDumpTable (TableLength, 0, Table, 0,
|
|
|
214d7a |
AcpiDmTableInfoFadt3);
|
|
|
214d7a |
if (ACPI_FAILURE (Status))
|
|
|
214d7a |
{
|
|
|
214d7a |
@@ -400,9 +401,9 @@ AcpiDmDumpFadt (
|
|
|
214d7a |
|
|
|
214d7a |
/* Check for FADT revision 5 fields and up (ACPI 5.0+) */
|
|
|
214d7a |
|
|
|
214d7a |
- if (Table->Length > ACPI_FADT_V3_SIZE)
|
|
|
214d7a |
+ if (TableLength > ACPI_FADT_V3_SIZE)
|
|
|
214d7a |
{
|
|
|
214d7a |
- Status = AcpiDmDumpTable (Table->Length, 0, Table, 0,
|
|
|
214d7a |
+ Status = AcpiDmDumpTable (TableLength, 0, Table, 0,
|
|
|
214d7a |
AcpiDmTableInfoFadt5);
|
|
|
214d7a |
if (ACPI_FAILURE (Status))
|
|
|
214d7a |
{
|
|
|
214d7a |
@@ -412,9 +413,9 @@ AcpiDmDumpFadt (
|
|
|
214d7a |
|
|
|
214d7a |
/* Check for FADT revision 6 fields and up (ACPI 6.0+) */
|
|
|
214d7a |
|
|
|
214d7a |
- if (Table->Length > ACPI_FADT_V3_SIZE)
|
|
|
214d7a |
+ if (TableLength > ACPI_FADT_V3_SIZE)
|
|
|
214d7a |
{
|
|
|
214d7a |
- Status = AcpiDmDumpTable (Table->Length, 0, Table, 0,
|
|
|
214d7a |
+ Status = AcpiDmDumpTable (TableLength, 0, Table, 0,
|
|
|
214d7a |
AcpiDmTableInfoFadt6);
|
|
|
214d7a |
if (ACPI_FAILURE (Status))
|
|
|
214d7a |
{
|
|
|
214d7a |
@@ -425,11 +426,11 @@ AcpiDmDumpFadt (
|
|
|
214d7a |
|
|
|
214d7a |
/* Validate various fields in the FADT, including length */
|
|
|
214d7a |
|
|
|
214d7a |
- AcpiTbCreateLocalFadt (Table, Table->Length);
|
|
|
214d7a |
+ AcpiTbCreateLocalFadt (Table, TableLength);
|
|
|
214d7a |
|
|
|
214d7a |
/* Validate FADT length against the revision */
|
|
|
214d7a |
|
|
|
214d7a |
- AcpiDmValidateFadtLength (Table->Revision, Table->Length);
|
|
|
214d7a |
+ AcpiDmValidateFadtLength (Table->Revision, TableLength);
|
|
|
214d7a |
}
|
|
|
214d7a |
|
|
|
214d7a |
|
|
|
214d7a |
Index: acpica-unix2-20210604/source/components/tables/tbfadt.c
|
|
|
214d7a |
===================================================================
|
|
|
214d7a |
--- acpica-unix2-20210604.orig/source/components/tables/tbfadt.c
|
|
|
214d7a |
+++ acpica-unix2-20210604/source/components/tables/tbfadt.c
|
|
|
214d7a |
@@ -289,7 +289,6 @@ AcpiTbSelectAddress (
|
|
|
214d7a |
UINT32 Address32,
|
|
|
214d7a |
UINT64 Address64)
|
|
|
214d7a |
{
|
|
|
214d7a |
-
|
|
|
214d7a |
if (!Address64)
|
|
|
214d7a |
{
|
|
|
214d7a |
/* 64-bit address is zero, use 32-bit address */
|
|
|
214d7a |
@@ -520,6 +519,9 @@ AcpiTbConvertFadt (
|
|
|
214d7a |
UINT8 Length;
|
|
|
214d7a |
UINT8 Flags;
|
|
|
214d7a |
UINT32 i;
|
|
|
214d7a |
+ UINT32 Tmp;
|
|
|
214d7a |
+ UINT32 Value32;
|
|
|
214d7a |
+ UINT64 Value64;
|
|
|
214d7a |
|
|
|
214d7a |
|
|
|
214d7a |
/*
|
|
|
214d7a |
@@ -533,7 +535,7 @@ AcpiTbConvertFadt (
|
|
|
214d7a |
* Note: The FADT revision value is unreliable. Only the length can be
|
|
|
214d7a |
* trusted.
|
|
|
214d7a |
*/
|
|
|
214d7a |
- if (AcpiGbl_FADT.Header.Length <= ACPI_FADT_V2_SIZE)
|
|
|
214d7a |
+ if (AcpiUtReadUint32 (&AcpiGbl_FADT.Header.Length) <= ACPI_FADT_V2_SIZE)
|
|
|
214d7a |
{
|
|
|
214d7a |
AcpiGbl_FADT.PreferredProfile = 0;
|
|
|
214d7a |
AcpiGbl_FADT.PstateControl = 0;
|
|
|
214d7a |
@@ -546,14 +548,19 @@ AcpiTbConvertFadt (
|
|
|
214d7a |
* current FADT version as defined by the ACPI specification.
|
|
|
214d7a |
* Thus, we will have a common FADT internally.
|
|
|
214d7a |
*/
|
|
|
214d7a |
- AcpiGbl_FADT.Header.Length = sizeof (ACPI_TABLE_FADT);
|
|
|
214d7a |
+ Tmp = sizeof (ACPI_TABLE_FADT);
|
|
|
214d7a |
+ AcpiUtWriteUint (&AcpiGbl_FADT.Header.Length, sizeof (UINT32),
|
|
|
214d7a |
+ &Tmp, sizeof (UINT32));
|
|
|
214d7a |
|
|
|
214d7a |
/*
|
|
|
214d7a |
* Expand the 32-bit DSDT addresses to 64-bit as necessary.
|
|
|
214d7a |
* Later ACPICA code will always use the X 64-bit field.
|
|
|
214d7a |
*/
|
|
|
214d7a |
- AcpiGbl_FADT.XDsdt = AcpiTbSelectAddress ("DSDT",
|
|
|
214d7a |
- AcpiGbl_FADT.Dsdt, AcpiGbl_FADT.XDsdt);
|
|
|
214d7a |
+ Value32 = AcpiUtReadUint32 (&AcpiGbl_FADT.Dsdt);
|
|
|
214d7a |
+ Value64 = AcpiUtReadUint64 (&AcpiGbl_FADT.XDsdt);
|
|
|
214d7a |
+ Value64 = AcpiTbSelectAddress ("DSDT", Value32, Value64);
|
|
|
214d7a |
+ AcpiUtWriteUint (&AcpiGbl_FADT.XDsdt, sizeof (UINT64),
|
|
|
214d7a |
+ &Value64, sizeof (UINT64));
|
|
|
214d7a |
|
|
|
214d7a |
/* If Hardware Reduced flag is set, we are all done */
|
|
|
214d7a |
|
|
|
214d7a |
@@ -614,7 +621,11 @@ AcpiTbConvertFadt (
|
|
|
214d7a |
{
|
|
|
214d7a |
if (Address64->Address)
|
|
|
214d7a |
{
|
|
|
214d7a |
- if (Address64->Address != (UINT64) Address32)
|
|
|
214d7a |
+ Value32 = AcpiUtReadUint32 (&Address32);
|
|
|
214d7a |
+ Value64 = AcpiUtReadUint64 (&Address64->Address);
|
|
|
214d7a |
+
|
|
|
214d7a |
+ /* if (Address64->Address != (UINT64) Address32) */
|
|
|
214d7a |
+ if (Value64 != (UINT64) Value32)
|
|
|
214d7a |
{
|
|
|
214d7a |
/* Address mismatch */
|
|
|
214d7a |
|
|
|
214d7a |
@@ -655,9 +666,10 @@ AcpiTbConvertFadt (
|
|
|
214d7a |
*/
|
|
|
214d7a |
if (!Address64->Address || AcpiGbl_Use32BitFadtAddresses)
|
|
|
214d7a |
{
|
|
|
214d7a |
+ Value32 = AcpiUtReadUint32 (&Address32);
|
|
|
214d7a |
AcpiTbInitGenericAddress (Address64,
|
|
|
214d7a |
ACPI_ADR_SPACE_SYSTEM_IO, Length,
|
|
|
214d7a |
- (UINT64) Address32, Name, Flags);
|
|
|
214d7a |
+ (UINT64) Value32, Name, Flags);
|
|
|
214d7a |
}
|
|
|
214d7a |
}
|
|
|
214d7a |
|
|
|
214d7a |
@@ -780,10 +792,14 @@ AcpiTbSetupFadtRegisters (
|
|
|
214d7a |
|
|
|
214d7a |
if (Source64->Address)
|
|
|
214d7a |
{
|
|
|
214d7a |
+ UINT64 Address64;
|
|
|
214d7a |
+
|
|
|
214d7a |
+ Address64 = AcpiUtReadUint64 (&Source64->Address);
|
|
|
214d7a |
+ Address64 +=
|
|
|
214d7a |
+ (FadtPmInfoTable[i].RegisterNum * Pm1RegisterByteWidth);
|
|
|
214d7a |
AcpiTbInitGenericAddress (FadtPmInfoTable[i].Target,
|
|
|
214d7a |
Source64->SpaceId, Pm1RegisterByteWidth,
|
|
|
214d7a |
- Source64->Address +
|
|
|
214d7a |
- (FadtPmInfoTable[i].RegisterNum * Pm1RegisterByteWidth),
|
|
|
214d7a |
+ Address64,
|
|
|
214d7a |
"PmRegisters", 0);
|
|
|
214d7a |
}
|
|
|
214d7a |
}
|