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