]>
Commit | Line | Data |
---|---|---|
b643ab7e JB |
1 | From 06623392351dfea54bd69507b6672c933a5e3fd2 Mon Sep 17 00:00:00 2001 |
2 | From: Al Stone <ahs3@redhat.com> | |
3 | Date: Sat, 19 Sep 2020 15:22:00 -0600 | |
4 | Subject: [PATCH 12/45] Support DMAR in a big-endian world | |
5 | ||
6 | Signed-off-by: Al Stone <ahs3@redhat.com> | |
7 | --- | |
8 | source/common/dmtable.c | 4 ++-- | |
9 | source/common/dmtbdump1.c | 26 +++++++++++++++----------- | |
10 | source/compiler/dttable1.c | 12 +++++++----- | |
11 | 3 files changed, 24 insertions(+), 18 deletions(-) | |
12 | ||
13 | Index: acpica-unix2-20220331/source/common/dmtable.c | |
14 | =================================================================== | |
15 | --- acpica-unix2-20220331.orig/source/common/dmtable.c | |
16 | +++ acpica-unix2-20220331/source/common/dmtable.c | |
17 | @@ -1578,13 +1578,13 @@ AcpiDmDumpTable ( | |
18 | ||
19 | /* DMAR subtable types */ | |
20 | ||
21 | - Temp16 = ACPI_GET16 (Target); | |
22 | + Temp16 = AcpiUtReadUint16 (Target); | |
23 | if (Temp16 > ACPI_DMAR_TYPE_RESERVED) | |
24 | { | |
25 | Temp16 = ACPI_DMAR_TYPE_RESERVED; | |
26 | } | |
27 | ||
28 | - AcpiOsPrintf (UINT16_FORMAT, ACPI_GET16 (Target), | |
29 | + AcpiOsPrintf (UINT16_FORMAT, Temp16, | |
30 | AcpiDmDmarSubnames[Temp16]); | |
31 | break; | |
32 | ||
33 | Index: acpica-unix2-20220331/source/common/dmtbdump1.c | |
34 | =================================================================== | |
35 | --- acpica-unix2-20220331.orig/source/common/dmtbdump1.c | |
36 | +++ acpica-unix2-20220331/source/common/dmtbdump1.c | |
37 | @@ -899,13 +899,15 @@ AcpiDmDumpDmar ( | |
38 | { | |
39 | ACPI_STATUS Status; | |
40 | ACPI_DMAR_HEADER *Subtable; | |
41 | - UINT32 Length = Table->Length; | |
42 | + UINT32 Length = AcpiUtReadUint32 (&Table->Length); | |
43 | UINT32 Offset = sizeof (ACPI_TABLE_DMAR); | |
44 | ACPI_DMTABLE_INFO *InfoTable; | |
45 | ACPI_DMAR_DEVICE_SCOPE *ScopeTable; | |
46 | UINT32 ScopeOffset; | |
47 | UINT8 *PciPath; | |
48 | UINT32 PathOffset; | |
49 | + UINT16 SubtableType; | |
50 | + UINT16 SubtableLength; | |
51 | ||
52 | ||
53 | /* Main table */ | |
54 | @@ -919,13 +921,14 @@ AcpiDmDumpDmar ( | |
55 | /* Subtables */ | |
56 | ||
57 | Subtable = ACPI_ADD_PTR (ACPI_DMAR_HEADER, Table, Offset); | |
58 | - while (Offset < Table->Length) | |
59 | + while (Offset < Length) | |
60 | { | |
61 | /* Common subtable header */ | |
62 | ||
63 | AcpiOsPrintf ("\n"); | |
64 | + SubtableLength = AcpiUtReadUint16 (&Subtable->Length); | |
65 | Status = AcpiDmDumpTable (Length, Offset, Subtable, | |
66 | - Subtable->Length, AcpiDmTableInfoDmarHdr); | |
67 | + SubtableLength, AcpiDmTableInfoDmarHdr); | |
68 | if (ACPI_FAILURE (Status)) | |
69 | { | |
70 | return; | |
71 | @@ -933,7 +936,8 @@ AcpiDmDumpDmar ( | |
72 | ||
73 | AcpiOsPrintf ("\n"); | |
74 | ||
75 | - switch (Subtable->Type) | |
76 | + SubtableType = AcpiUtReadUint16 (&Subtable->Type); | |
77 | + switch (SubtableType) | |
78 | { | |
79 | case ACPI_DMAR_TYPE_HARDWARE_UNIT: | |
80 | ||
81 | @@ -974,12 +978,12 @@ AcpiDmDumpDmar ( | |
82 | default: | |
83 | ||
84 | AcpiOsPrintf ("\n**** Unknown DMAR subtable type 0x%X\n\n", | |
85 | - Subtable->Type); | |
86 | + SubtableType); | |
87 | return; | |
88 | } | |
89 | ||
90 | Status = AcpiDmDumpTable (Length, Offset, Subtable, | |
91 | - Subtable->Length, InfoTable); | |
92 | + SubtableLength, InfoTable); | |
93 | if (ACPI_FAILURE (Status)) | |
94 | { | |
95 | return; | |
96 | @@ -988,8 +992,8 @@ AcpiDmDumpDmar ( | |
97 | /* | |
98 | * Dump the optional device scope entries | |
99 | */ | |
100 | - if ((Subtable->Type == ACPI_DMAR_TYPE_HARDWARE_AFFINITY) || | |
101 | - (Subtable->Type == ACPI_DMAR_TYPE_NAMESPACE)) | |
102 | + if ((SubtableType == ACPI_DMAR_TYPE_HARDWARE_AFFINITY) || | |
103 | + (SubtableType == ACPI_DMAR_TYPE_NAMESPACE)) | |
104 | { | |
105 | /* These types do not support device scopes */ | |
106 | ||
107 | @@ -997,7 +1001,7 @@ AcpiDmDumpDmar ( | |
108 | } | |
109 | ||
110 | ScopeTable = ACPI_ADD_PTR (ACPI_DMAR_DEVICE_SCOPE, Subtable, ScopeOffset); | |
111 | - while (ScopeOffset < Subtable->Length) | |
112 | + while (ScopeOffset < SubtableLength) | |
113 | { | |
114 | AcpiOsPrintf ("\n"); | |
115 | Status = AcpiDmDumpTable (Length, Offset + ScopeOffset, ScopeTable, | |
116 | @@ -1038,9 +1042,9 @@ AcpiDmDumpDmar ( | |
117 | NextSubtable: | |
118 | /* Point to next subtable */ | |
119 | ||
120 | - Offset += Subtable->Length; | |
121 | + Offset += SubtableLength; | |
122 | Subtable = ACPI_ADD_PTR (ACPI_DMAR_HEADER, Subtable, | |
123 | - Subtable->Length); | |
124 | + SubtableLength); | |
125 | } | |
126 | } | |
127 | ||
128 | Index: acpica-unix2-20220331/source/compiler/dttable1.c | |
129 | =================================================================== | |
130 | --- acpica-unix2-20220331.orig/source/compiler/dttable1.c | |
131 | +++ acpica-unix2-20220331/source/compiler/dttable1.c | |
132 | @@ -997,6 +997,7 @@ DtCompileDmar ( | |
133 | ACPI_DMAR_DEVICE_SCOPE *DmarDeviceScope; | |
134 | UINT32 DeviceScopeLength; | |
135 | UINT32 PciPathLength; | |
136 | + UINT16 DmarHeaderType; | |
137 | ||
138 | ||
139 | Status = DtCompileTable (PFieldList, AcpiDmTableInfoDmar, &Subtable); | |
140 | @@ -1027,7 +1028,8 @@ DtCompileDmar ( | |
141 | ||
142 | DmarHeader = ACPI_CAST_PTR (ACPI_DMAR_HEADER, Subtable->Buffer); | |
143 | ||
144 | - switch (DmarHeader->Type) | |
145 | + DmarHeaderType = AcpiUtReadUint16 (&DmarHeader->Type); | |
146 | + switch (DmarHeaderType) | |
147 | { | |
148 | case ACPI_DMAR_TYPE_HARDWARE_UNIT: | |
149 | ||
150 | @@ -1079,8 +1081,8 @@ DtCompileDmar ( | |
151 | /* | |
152 | * Optional Device Scope subtables | |
153 | */ | |
154 | - if ((DmarHeader->Type == ACPI_DMAR_TYPE_HARDWARE_AFFINITY) || | |
155 | - (DmarHeader->Type == ACPI_DMAR_TYPE_NAMESPACE)) | |
156 | + if ((DmarHeaderType == ACPI_DMAR_TYPE_HARDWARE_AFFINITY) || | |
157 | + (DmarHeaderType == ACPI_DMAR_TYPE_NAMESPACE)) | |
158 | { | |
159 | /* These types do not support device scopes */ | |
160 | ||
161 | @@ -1089,8 +1091,8 @@ DtCompileDmar ( | |
162 | } | |
163 | ||
164 | DtPushSubtable (Subtable); | |
165 | - DeviceScopeLength = DmarHeader->Length - Subtable->Length - | |
166 | - ParentTable->Length; | |
167 | + DeviceScopeLength = AcpiUtReadUint16 (&DmarHeader->Length) - | |
168 | + Subtable->Length - ParentTable->Length; | |
169 | while (DeviceScopeLength) | |
170 | { | |
171 | Status = DtCompileTable (PFieldList, AcpiDmTableInfoDmarScope, |