1 From b3051bc2bad8988f3ad81a8307de6f1d0eef4ace Mon Sep 17 00:00:00 2001
2 From: Al Stone <ahs3@redhat.com>
3 Date: Sun, 20 Sep 2020 11:42:21 -0600
4 Subject: [PATCH 16/45] Support FADT (aka, FACP) in a big-endian world
6 Signed-off-by: Al Stone <ahs3@redhat.com>
8 source/common/dmtbdump.c | 25 ++++++++++++-----------
9 source/components/tables/tbfadt.c | 34 +++++++++++++++++++++++--------
10 2 files changed, 38 insertions(+), 21 deletions(-)
12 Index: acpica-unix2-20220331/source/common/dmtbdump.c
13 ===================================================================
14 --- acpica-unix2-20220331.orig/source/common/dmtbdump.c
15 +++ acpica-unix2-20220331/source/common/dmtbdump.c
16 @@ -417,11 +417,12 @@ AcpiDmDumpFadt (
17 ACPI_TABLE_HEADER *Table)
20 + UINT32 TableLength = AcpiUtReadUint32 (&Table->Length);
23 /* Always dump the minimum FADT revision 1 fields (ACPI 1.0) */
25 - Status = AcpiDmDumpTable (Table->Length, 0, Table, 0,
26 + Status = AcpiDmDumpTable (TableLength, 0, Table, 0,
27 AcpiDmTableInfoFadt1);
28 if (ACPI_FAILURE (Status))
30 @@ -430,10 +431,10 @@ AcpiDmDumpFadt (
32 /* Check for FADT revision 2 fields (ACPI 1.0B MS extensions) */
34 - if ((Table->Length > ACPI_FADT_V1_SIZE) &&
35 - (Table->Length <= ACPI_FADT_V2_SIZE))
36 + if ((TableLength > ACPI_FADT_V1_SIZE) &&
37 + (TableLength <= ACPI_FADT_V2_SIZE))
39 - Status = AcpiDmDumpTable (Table->Length, 0, Table, 0,
40 + Status = AcpiDmDumpTable (TableLength, 0, Table, 0,
41 AcpiDmTableInfoFadt2);
42 if (ACPI_FAILURE (Status))
44 @@ -443,9 +444,9 @@ AcpiDmDumpFadt (
46 /* Check for FADT revision 3/4 fields and up (ACPI 2.0+ extended data) */
48 - else if (Table->Length > ACPI_FADT_V2_SIZE)
49 + else if (TableLength > ACPI_FADT_V2_SIZE)
51 - Status = AcpiDmDumpTable (Table->Length, 0, Table, 0,
52 + Status = AcpiDmDumpTable (TableLength, 0, Table, 0,
53 AcpiDmTableInfoFadt3);
54 if (ACPI_FAILURE (Status))
56 @@ -454,9 +455,9 @@ AcpiDmDumpFadt (
58 /* Check for FADT revision 5 fields and up (ACPI 5.0+) */
60 - if (Table->Length > ACPI_FADT_V3_SIZE)
61 + if (TableLength > ACPI_FADT_V3_SIZE)
63 - Status = AcpiDmDumpTable (Table->Length, 0, Table, 0,
64 + Status = AcpiDmDumpTable (TableLength, 0, Table, 0,
65 AcpiDmTableInfoFadt5);
66 if (ACPI_FAILURE (Status))
68 @@ -466,9 +467,9 @@ AcpiDmDumpFadt (
70 /* Check for FADT revision 6 fields and up (ACPI 6.0+) */
72 - if (Table->Length > ACPI_FADT_V3_SIZE)
73 + if (TableLength > ACPI_FADT_V3_SIZE)
75 - Status = AcpiDmDumpTable (Table->Length, 0, Table, 0,
76 + Status = AcpiDmDumpTable (TableLength, 0, Table, 0,
77 AcpiDmTableInfoFadt6);
78 if (ACPI_FAILURE (Status))
80 @@ -479,11 +480,11 @@ AcpiDmDumpFadt (
82 /* Validate various fields in the FADT, including length */
84 - AcpiTbCreateLocalFadt (Table, Table->Length);
85 + AcpiTbCreateLocalFadt (Table, TableLength);
87 /* Validate FADT length against the revision */
89 - AcpiDmValidateFadtLength (Table->Revision, Table->Length);
90 + AcpiDmValidateFadtLength (Table->Revision, TableLength);
94 Index: acpica-unix2-20220331/source/components/tables/tbfadt.c
95 ===================================================================
96 --- acpica-unix2-20220331.orig/source/components/tables/tbfadt.c
97 +++ acpica-unix2-20220331/source/components/tables/tbfadt.c
98 @@ -289,7 +289,6 @@ AcpiTbSelectAddress (
105 /* 64-bit address is zero, use 32-bit address */
106 @@ -520,6 +519,9 @@ AcpiTbConvertFadt (
116 @@ -533,7 +535,7 @@ AcpiTbConvertFadt (
117 * Note: The FADT revision value is unreliable. Only the length can be
120 - if (AcpiGbl_FADT.Header.Length <= ACPI_FADT_V2_SIZE)
121 + if (AcpiUtReadUint32 (&AcpiGbl_FADT.Header.Length) <= ACPI_FADT_V2_SIZE)
123 AcpiGbl_FADT.PreferredProfile = 0;
124 AcpiGbl_FADT.PstateControl = 0;
125 @@ -546,14 +548,19 @@ AcpiTbConvertFadt (
126 * current FADT version as defined by the ACPI specification.
127 * Thus, we will have a common FADT internally.
129 - AcpiGbl_FADT.Header.Length = sizeof (ACPI_TABLE_FADT);
130 + Tmp = sizeof (ACPI_TABLE_FADT);
131 + AcpiUtWriteUint (&AcpiGbl_FADT.Header.Length, sizeof (UINT32),
132 + &Tmp, sizeof (UINT32));
135 * Expand the 32-bit DSDT addresses to 64-bit as necessary.
136 * Later ACPICA code will always use the X 64-bit field.
138 - AcpiGbl_FADT.XDsdt = AcpiTbSelectAddress ("DSDT",
139 - AcpiGbl_FADT.Dsdt, AcpiGbl_FADT.XDsdt);
140 + Value32 = AcpiUtReadUint32 (&AcpiGbl_FADT.Dsdt);
141 + Value64 = AcpiUtReadUint64 (&AcpiGbl_FADT.XDsdt);
142 + Value64 = AcpiTbSelectAddress ("DSDT", Value32, Value64);
143 + AcpiUtWriteUint (&AcpiGbl_FADT.XDsdt, sizeof (UINT64),
144 + &Value64, sizeof (UINT64));
146 /* If Hardware Reduced flag is set, we are all done */
148 @@ -614,7 +621,11 @@ AcpiTbConvertFadt (
150 if (Address64->Address)
152 - if (Address64->Address != (UINT64) Address32)
153 + Value32 = AcpiUtReadUint32 (&Address32);
154 + Value64 = AcpiUtReadUint64 (&Address64->Address);
156 + /* if (Address64->Address != (UINT64) Address32) */
157 + if (Value64 != (UINT64) Value32)
159 /* Address mismatch */
161 @@ -655,9 +666,10 @@ AcpiTbConvertFadt (
163 if (!Address64->Address || AcpiGbl_Use32BitFadtAddresses)
165 + Value32 = AcpiUtReadUint32 (&Address32);
166 AcpiTbInitGenericAddress (Address64,
167 ACPI_ADR_SPACE_SYSTEM_IO, Length,
168 - (UINT64) Address32, Name, Flags);
169 + (UINT64) Value32, Name, Flags);
173 @@ -780,10 +792,14 @@ AcpiTbSetupFadtRegisters (
175 if (Source64->Address)
179 + Address64 = AcpiUtReadUint64 (&Source64->Address);
181 + (FadtPmInfoTable[i].RegisterNum * Pm1RegisterByteWidth);
182 AcpiTbInitGenericAddress (FadtPmInfoTable[i].Target,
183 Source64->SpaceId, Pm1RegisterByteWidth,
184 - Source64->Address +
185 - (FadtPmInfoTable[i].RegisterNum * Pm1RegisterByteWidth),