]> git.pld-linux.org Git - packages/acpica.git/blob - 0016-Support-FADT-aka-FACP-in-a-big-endian-world.patch
- updated to 20220331 + current Fedora patch set; acpinames is gone
[packages/acpica.git] / 0016-Support-FADT-aka-FACP-in-a-big-endian-world.patch
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
5
6 Signed-off-by: Al Stone <ahs3@redhat.com>
7 ---
8  source/common/dmtbdump.c          | 25 ++++++++++++-----------
9  source/components/tables/tbfadt.c | 34 +++++++++++++++++++++++--------
10  2 files changed, 38 insertions(+), 21 deletions(-)
11
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)
18  {
19      ACPI_STATUS             Status;
20 +    UINT32                  TableLength = AcpiUtReadUint32 (&Table->Length);
21  
22  
23      /* Always dump the minimum FADT revision 1 fields (ACPI 1.0) */
24  
25 -    Status = AcpiDmDumpTable (Table->Length, 0, Table, 0,
26 +    Status = AcpiDmDumpTable (TableLength, 0, Table, 0,
27          AcpiDmTableInfoFadt1);
28      if (ACPI_FAILURE (Status))
29      {
30 @@ -430,10 +431,10 @@ AcpiDmDumpFadt (
31  
32      /* Check for FADT revision 2 fields (ACPI 1.0B MS extensions) */
33  
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))
38      {
39 -        Status = AcpiDmDumpTable (Table->Length, 0, Table, 0,
40 +        Status = AcpiDmDumpTable (TableLength, 0, Table, 0,
41              AcpiDmTableInfoFadt2);
42          if (ACPI_FAILURE (Status))
43          {
44 @@ -443,9 +444,9 @@ AcpiDmDumpFadt (
45  
46      /* Check for FADT revision 3/4 fields and up (ACPI 2.0+ extended data) */
47  
48 -    else if (Table->Length > ACPI_FADT_V2_SIZE)
49 +    else if (TableLength > ACPI_FADT_V2_SIZE)
50      {
51 -        Status = AcpiDmDumpTable (Table->Length, 0, Table, 0,
52 +        Status = AcpiDmDumpTable (TableLength, 0, Table, 0,
53              AcpiDmTableInfoFadt3);
54          if (ACPI_FAILURE (Status))
55          {
56 @@ -454,9 +455,9 @@ AcpiDmDumpFadt (
57  
58          /* Check for FADT revision 5 fields and up (ACPI 5.0+) */
59  
60 -        if (Table->Length > ACPI_FADT_V3_SIZE)
61 +        if (TableLength > ACPI_FADT_V3_SIZE)
62          {
63 -            Status = AcpiDmDumpTable (Table->Length, 0, Table, 0,
64 +            Status = AcpiDmDumpTable (TableLength, 0, Table, 0,
65                  AcpiDmTableInfoFadt5);
66              if (ACPI_FAILURE (Status))
67              {
68 @@ -466,9 +467,9 @@ AcpiDmDumpFadt (
69  
70          /* Check for FADT revision 6 fields and up (ACPI 6.0+) */
71  
72 -        if (Table->Length > ACPI_FADT_V3_SIZE)
73 +        if (TableLength > ACPI_FADT_V3_SIZE)
74          {
75 -            Status = AcpiDmDumpTable (Table->Length, 0, Table, 0,
76 +            Status = AcpiDmDumpTable (TableLength, 0, Table, 0,
77                  AcpiDmTableInfoFadt6);
78              if (ACPI_FAILURE (Status))
79              {
80 @@ -479,11 +480,11 @@ AcpiDmDumpFadt (
81  
82      /* Validate various fields in the FADT, including length */
83  
84 -    AcpiTbCreateLocalFadt (Table, Table->Length);
85 +    AcpiTbCreateLocalFadt (Table, TableLength);
86  
87      /* Validate FADT length against the revision */
88  
89 -    AcpiDmValidateFadtLength (Table->Revision, Table->Length);
90 +    AcpiDmValidateFadtLength (Table->Revision, TableLength);
91  }
92  
93  
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 (
99      UINT32                  Address32,
100      UINT64                  Address64)
101  {
102 -
103      if (!Address64)
104      {
105          /* 64-bit address is zero, use 32-bit address */
106 @@ -520,6 +519,9 @@ AcpiTbConvertFadt (
107      UINT8                   Length;
108      UINT8                   Flags;
109      UINT32                  i;
110 +    UINT32                  Tmp;
111 +    UINT32                  Value32;
112 +    UINT64                  Value64;
113  
114  
115      /*
116 @@ -533,7 +535,7 @@ AcpiTbConvertFadt (
117       * Note: The FADT revision value is unreliable. Only the length can be
118       * trusted.
119       */
120 -    if (AcpiGbl_FADT.Header.Length <= ACPI_FADT_V2_SIZE)
121 +    if (AcpiUtReadUint32 (&AcpiGbl_FADT.Header.Length) <= ACPI_FADT_V2_SIZE)
122      {
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.
128       */
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));
133  
134      /*
135       * Expand the 32-bit DSDT addresses to 64-bit as necessary.
136       * Later ACPICA code will always use the X 64-bit field.
137       */
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));
145  
146      /* If Hardware Reduced flag is set, we are all done */
147  
148 @@ -614,7 +621,11 @@ AcpiTbConvertFadt (
149          {
150              if (Address64->Address)
151              {
152 -                if (Address64->Address != (UINT64) Address32)
153 +                Value32 = AcpiUtReadUint32 (&Address32);
154 +                Value64 = AcpiUtReadUint64 (&Address64->Address);
155 +
156 +                /* if (Address64->Address != (UINT64) Address32) */
157 +                if (Value64 != (UINT64) Value32)
158                  {
159                      /* Address mismatch */
160  
161 @@ -655,9 +666,10 @@ AcpiTbConvertFadt (
162               */
163              if (!Address64->Address || AcpiGbl_Use32BitFadtAddresses)
164              {
165 +                Value32 = AcpiUtReadUint32 (&Address32);
166                  AcpiTbInitGenericAddress (Address64,
167                      ACPI_ADR_SPACE_SYSTEM_IO, Length,
168 -                    (UINT64) Address32, Name, Flags);
169 +                    (UINT64) Value32, Name, Flags);
170              }
171          }
172  
173 @@ -780,10 +792,14 @@ AcpiTbSetupFadtRegisters (
174  
175          if (Source64->Address)
176          {
177 +            UINT64 Address64;
178 +
179 +            Address64 = AcpiUtReadUint64 (&Source64->Address);
180 +            Address64 +=
181 +                (FadtPmInfoTable[i].RegisterNum * Pm1RegisterByteWidth);
182              AcpiTbInitGenericAddress (FadtPmInfoTable[i].Target,
183                  Source64->SpaceId, Pm1RegisterByteWidth,
184 -                Source64->Address +
185 -                    (FadtPmInfoTable[i].RegisterNum * Pm1RegisterByteWidth),
186 +                Address64,
187                  "PmRegisters", 0);
188          }
189      }
This page took 0.058647 seconds and 3 git commands to generate.