1 From 14d220a34462e61fe69141c86f4c3cd2ae68c279 Mon Sep 17 00:00:00 2001
2 From: Al Stone <ahs3@redhat.com>
3 Date: Wed, 30 Sep 2020 18:59:57 -0600
4 Subject: [PATCH 43/45] Support DSDT/SSDT in a big-endian world.
6 NB: this is a very large diff. The problem is that ResourceTemplates
7 are treated differently during compilation and disassembly so each of
8 the resource types had code that needed to be touched directly.
10 In general, however, just reading or writing individual AML opcodes
11 wasn't that much of a change, and most of it was on the codegen side.
13 Signed-off-by: Al Stone <ahs3@redhat.com>
15 source/common/adwalk.c | 3 +-
16 source/common/dmrestag.c | 2 +-
17 source/common/dmtables.c | 17 +-
18 source/common/dmtbdump.c | 3 +-
19 source/common/dmtbdump3.c | 8 +-
20 source/compiler/aslcodegen.c | 59 ++++--
21 source/compiler/aslopcodes.c | 3 +-
22 source/compiler/aslrestype1.c | 60 ++++--
23 source/compiler/aslrestype1i.c | 35 ++--
24 source/compiler/aslrestype2.c | 20 +-
25 source/compiler/aslrestype2d.c | 99 ++++++----
26 source/compiler/aslrestype2e.c | 90 ++++++---
27 source/compiler/aslrestype2q.c | 81 +++++---
28 source/compiler/aslrestype2s.c | 214 +++++++++++++++++----
29 source/compiler/aslrestype2w.c | 94 +++++----
30 source/compiler/dttable2.c | 3 +-
31 source/components/disassembler/dmbuffer.c | 37 +++-
32 source/components/disassembler/dmopcode.c | 21 +-
33 source/components/disassembler/dmresrc.c | 2 +-
34 source/components/disassembler/dmresrcl.c | 43 +++--
35 source/components/disassembler/dmresrcl2.c | 128 +++++++-----
36 source/components/disassembler/dmresrcs.c | 18 +-
37 source/components/disassembler/dmwalk.c | 2 +-
38 source/components/namespace/nsaccess.c | 2 +-
39 source/components/namespace/nsnames.c | 4 +-
40 source/components/namespace/nsparse.c | 6 +-
41 source/components/namespace/nsutils.c | 7 +-
42 source/components/utilities/utresrc.c | 2 +-
43 28 files changed, 721 insertions(+), 341 deletions(-)
45 Index: acpica-unix2-20220331/source/common/adwalk.c
46 ===================================================================
47 --- acpica-unix2-20220331.orig/source/common/adwalk.c
48 +++ acpica-unix2-20220331/source/common/adwalk.c
49 @@ -679,7 +679,8 @@ AcpiDmLoadDescendingOp (
51 if (!Path && Op->Common.AmlOpcode == AML_INT_NAMEDFIELD_OP)
53 - *ACPI_CAST_PTR (UINT32, &FieldPath[0]) = Op->Named.Name;
54 + AcpiUtWriteUint (FieldPath, ACPI_NAMESEG_SIZE,
55 + &Op->Named.Name, ACPI_NAMESEG_SIZE);
59 Index: acpica-unix2-20220331/source/common/dmrestag.c
60 ===================================================================
61 --- acpica-unix2-20220331.orig/source/common/dmrestag.c
62 +++ acpica-unix2-20220331/source/common/dmrestag.c
63 @@ -1048,7 +1048,7 @@ AcpiDmAddResourcesToNamespace (
64 * NextOp contains the Aml pointer and the Aml length
66 AcpiUtWalkAmlResources (NULL, (UINT8 *) NextOp->Named.Data,
67 - (ACPI_SIZE) NextOp->Common.Value.Integer,
68 + (ACPI_SIZE) NextOp->Common.Value.Size,
69 AcpiDmAddResourceToNamespace, (void **) BufferNode);
72 Index: acpica-unix2-20220331/source/common/dmtables.c
73 ===================================================================
74 --- acpica-unix2-20220331.orig/source/common/dmtables.c
75 +++ acpica-unix2-20220331/source/common/dmtables.c
76 @@ -142,6 +142,10 @@ AdCreateTableHeader (
77 ACPI_TABLE_HEADER *Table)
80 + UINT32 TableLength = AcpiUtReadUint32 (&Table->Length);
81 + UINT32 OemRevision = AcpiUtReadUint32 (&Table->OemRevision);
82 + UINT32 CompilerRevision =
83 + AcpiUtReadUint32 (&Table->AslCompilerRevision);
86 /* Reset globals for External statements */
87 @@ -156,7 +160,7 @@ AdCreateTableHeader (
89 AcpiOsPrintf (" * Original Table Header:\n");
90 AcpiOsPrintf (" * Signature \"%4.4s\"\n", Table->Signature);
91 - AcpiOsPrintf (" * Length 0x%8.8X (%u)\n", Table->Length, Table->Length);
92 + AcpiOsPrintf (" * Length 0x%8.8X (%u)\n", TableLength, TableLength);
94 /* Print and validate the revision */
96 @@ -188,7 +192,7 @@ AdCreateTableHeader (
98 AcpiOsPrintf ("\n * Checksum 0x%2.2X", Table->Checksum);
100 - Checksum = AcpiTbChecksum (ACPI_CAST_PTR (UINT8, Table), Table->Length);
101 + Checksum = AcpiTbChecksum (ACPI_CAST_PTR (UINT8, Table), TableLength);
104 AcpiOsPrintf (" **** Incorrect checksum, should be 0x%2.2X",
105 @@ -198,9 +202,9 @@ AdCreateTableHeader (
107 AcpiOsPrintf (" * OEM ID \"%.6s\"\n", Table->OemId);
108 AcpiOsPrintf (" * OEM Table ID \"%.8s\"\n", Table->OemTableId);
109 - AcpiOsPrintf (" * OEM Revision 0x%8.8X (%u)\n", Table->OemRevision, Table->OemRevision);
110 + AcpiOsPrintf (" * OEM Revision 0x%8.8X (%u)\n", OemRevision, OemRevision);
111 AcpiOsPrintf (" * Compiler ID \"%.4s\"\n", Table->AslCompilerId);
112 - AcpiOsPrintf (" * Compiler Version 0x%8.8X (%u)\n", Table->AslCompilerRevision, Table->AslCompilerRevision);
113 + AcpiOsPrintf (" * Compiler Version 0x%8.8X (%u)\n", CompilerRevision, CompilerRevision);
114 AcpiOsPrintf (" */\n");
117 @@ -221,7 +225,7 @@ AdCreateTableHeader (
119 "DefinitionBlock (\"\", \"%4.4s\", %u, \"%.6s\", \"%.8s\", 0x%8.8X)\n",
120 Table->Signature, Table->Revision,
121 - Table->OemId, Table->OemTableId, Table->OemRevision);
122 + Table->OemId, Table->OemTableId, OemRevision);
126 @@ -396,7 +400,8 @@ AdParseTable (
128 fprintf (stderr, "Pass 1 parse of [%4.4s]\n", (char *) Table->Signature);
130 - AmlLength = Table->Length - sizeof (ACPI_TABLE_HEADER);
131 + AmlLength = AcpiUtReadUint32 (&Table->Length);
132 + AmlLength -= sizeof (ACPI_TABLE_HEADER);
133 AmlStart = ((UINT8 *) Table + sizeof (ACPI_TABLE_HEADER));
135 AcpiUtSetIntegerWidth (Table->Revision);
136 Index: acpica-unix2-20220331/source/common/dmtbdump.c
137 ===================================================================
138 --- acpica-unix2-20220331.orig/source/common/dmtbdump.c
139 +++ acpica-unix2-20220331/source/common/dmtbdump.c
140 @@ -392,8 +392,7 @@ AcpiDmDumpXsdt (
141 for (i = 0; i < Entries; i++)
143 AcpiDmLineHeader2 (Offset, sizeof (UINT64), "ACPI Table Address", i);
144 - AcpiOsPrintf ("%8.8X%8.8X\n",
145 - ACPI_FORMAT_UINT64 (AcpiUtReadUint64 (&Array[i])));
146 + AcpiOsPrintf ("%16.16lX\n", AcpiUtReadUint64 (&Array[i]));
147 Offset += sizeof (UINT64);
150 Index: acpica-unix2-20220331/source/common/dmtbdump3.c
151 ===================================================================
152 --- acpica-unix2-20220331.orig/source/common/dmtbdump3.c
153 +++ acpica-unix2-20220331/source/common/dmtbdump3.c
154 @@ -741,12 +741,13 @@ AcpiDmDumpWpbt (
157 ACPI_TABLE_WPBT *Subtable;
158 + UINT32 TableLength = AcpiUtReadUint32 (&Table->Length);
159 UINT16 ArgumentsLength;
162 /* Dump the main table */
164 - Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoWpbt);
165 + Status = AcpiDmDumpTable (TableLength, 0, Table, 0, AcpiDmTableInfoWpbt);
166 if (ACPI_FAILURE (Status))
169 @@ -755,13 +756,13 @@ AcpiDmDumpWpbt (
170 /* Extract the arguments buffer length from the main table */
172 Subtable = ACPI_CAST_PTR (ACPI_TABLE_WPBT, Table);
173 - ArgumentsLength = Subtable->ArgumentsLength;
174 + ArgumentsLength = AcpiUtReadUint16 (&Subtable->ArgumentsLength);
176 /* Dump the arguments buffer if present */
180 - (void) AcpiDmDumpTable (Table->Length, 0, Table, ArgumentsLength,
181 + (void) AcpiDmDumpTable (TableLength, 0, Table, ArgumentsLength,
182 AcpiDmTableInfoWpbt0);
185 Index: acpica-unix2-20220331/source/compiler/aslcodegen.c
186 ===================================================================
187 --- acpica-unix2-20220331.orig/source/compiler/aslcodegen.c
188 +++ acpica-unix2-20220331/source/compiler/aslcodegen.c
189 @@ -238,6 +238,10 @@ CgWriteAmlOpcode (
191 UINT8 PkgLenFirstByte;
199 UINT8 OpcodeBytes[2];
200 @@ -312,14 +316,15 @@ CgWriteAmlOpcode (
202 /* Check for two-byte opcode */
204 + Tmp16 = AcpiUtReadUint16 (&Aml.Opcode);
205 if (Aml.Opcode > 0x00FF)
207 /* Write the high byte first */
209 - CgLocalWriteAmlData (Op, &Aml.OpcodeBytes[1], 1);
210 + CgLocalWriteAmlData (Op, ((UINT8 *) &Tmp16)+1, 1);
213 - CgLocalWriteAmlData (Op, &Aml.OpcodeBytes[0], 1);
214 + CgLocalWriteAmlData (Op, (UINT8 *) &Tmp16, 1);
216 /* Subtreelength doesn't include length of package length bytes */
218 @@ -335,7 +340,8 @@ CgWriteAmlOpcode (
220 /* Simplest case -- no bytes to follow, just write the count */
222 - CgLocalWriteAmlData (Op, &PkgLen.LenBytes[0], 1);
223 + Tmp8 = (UINT8) PkgLen.Len;
224 + CgLocalWriteAmlData (Op, &Tmp8, 1);
226 else if (Op->Asl.AmlPkgLenBytes != 0)
228 @@ -343,9 +349,10 @@ CgWriteAmlOpcode (
229 * Encode the "bytes to follow" in the first byte, top two bits.
230 * The low-order nybble of the length is in the bottom 4 bits
232 + Tmp8 = (UINT8) PkgLen.Len;
233 PkgLenFirstByte = (UINT8)
234 (((UINT32) (Op->Asl.AmlPkgLenBytes - 1) << 6) |
235 - (PkgLen.LenBytes[0] & 0x0F));
238 CgLocalWriteAmlData (Op, &PkgLenFirstByte, 1);
240 @@ -359,6 +366,9 @@ CgWriteAmlOpcode (
241 * Now we can write the remaining bytes -
242 * either 1, 2, or 3 bytes
244 + Tmp32 = PkgLen.Len;
245 + AcpiUtWriteUint (&PkgLen.Len, Op->Asl.AmlPkgLenBytes,
246 + &Tmp32, sizeof (UINT32));
247 for (i = 0; i < (UINT32) (Op->Asl.AmlPkgLenBytes - 1); i++)
249 CgLocalWriteAmlData (Op, &PkgLen.LenBytes[i], 1);
250 @@ -370,22 +380,30 @@ CgWriteAmlOpcode (
254 - CgLocalWriteAmlData (Op, &Op->Asl.Value.Integer, 1);
256 + AcpiUtWriteUint (&Tmp64, 1, &Op->Asl.Value.Integer, 8);
257 + CgLocalWriteAmlData (Op, &Tmp64, 1);
262 - CgLocalWriteAmlData (Op, &Op->Asl.Value.Integer, 2);
265 + AcpiUtWriteUint (&Tmp64, 2, &Op->Asl.Value.Integer, 8);
266 + CgLocalWriteAmlData (Op, &Tmp64, 2);
271 - CgLocalWriteAmlData (Op, &Op->Asl.Value.Integer, 4);
273 + AcpiUtWriteUint (&Tmp64, 4, &Op->Asl.Value.Integer, 8);
274 + CgLocalWriteAmlData (Op, &Tmp64, 4);
279 - CgLocalWriteAmlData (Op, &Op->Asl.Value.Integer, 8);
281 + AcpiUtWriteUint (&Tmp64, 8, &Op->Asl.Value.Integer, 8);
282 + CgLocalWriteAmlData (Op, &Tmp64, 8);
286 @@ -423,6 +441,7 @@ CgWriteTableHeader (
287 ACPI_PARSE_OBJECT *Child;
288 UINT32 CommentLength;
289 ACPI_COMMENT_NODE *Current;
293 memset (&AslGbl_TableHeader, 0, sizeof (ACPI_TABLE_HEADER));
294 @@ -478,7 +497,9 @@ CgWriteTableHeader (
297 Child = Child->Asl.Next;
298 - AslGbl_TableHeader.OemRevision = (UINT32) Child->Asl.Value.Integer;
299 + AcpiUtWriteUint (&Tmp32, sizeof (UINT32),
300 + &Child->Asl.Value.Integer, sizeof (Child->Asl.Value.Integer));
301 + AslGbl_TableHeader.OemRevision = Tmp32;
305 @@ -486,7 +507,8 @@ CgWriteTableHeader (
307 /* Compiler version */
309 - AslGbl_TableHeader.AslCompilerRevision = ACPI_CA_VERSION;
310 + Tmp32 = ACPI_CA_VERSION;
311 + AslGbl_TableHeader.AslCompilerRevision = AcpiUtReadUint32 (&Tmp32);
313 /* Table length. Checksum zero for now, will rewrite later */
315 @@ -541,6 +563,15 @@ CgWriteTableHeader (
316 AslGbl_TableHeader.Checksum = 0;
317 Op->Asl.FinalAmlOffset = ftell (AslGbl_Files[ASL_FILE_AML_OUTPUT].Handle);
320 + * Adjust the Table length; it will only change when big-endian
321 + * but we have to wait until here in case there is arithmetic to
322 + * be done on the length before this step in the function
325 + Tmp32 = AslGbl_TableHeader.Length;
326 + AslGbl_TableHeader.Length = AcpiUtReadUint32 (&Tmp32);
328 /* Write entire header and clear the table header global */
330 CgLocalWriteAmlData (Op, &AslGbl_TableHeader, sizeof (ACPI_TABLE_HEADER));
331 @@ -625,6 +656,7 @@ CgWriteNode (
332 ACPI_PARSE_OBJECT *Op)
334 ASL_RESOURCE_NODE *Rnode;
338 /* Write all comments here. */
339 @@ -653,7 +685,10 @@ CgWriteNode (
340 case AML_RAW_DATA_DWORD:
341 case AML_RAW_DATA_QWORD:
343 - CgLocalWriteAmlData (Op, &Op->Asl.Value.Integer, Op->Asl.AmlLength);
345 + AcpiUtWriteUint (&Tmp64, Op->Asl.AmlLength,
346 + &Op->Asl.Value.Integer, sizeof (UINT64));
347 + CgLocalWriteAmlData (Op, &Tmp64, Op->Asl.AmlLength);
351 Index: acpica-unix2-20220331/source/compiler/aslopcodes.c
352 ===================================================================
353 --- acpica-unix2-20220331.orig/source/compiler/aslopcodes.c
354 +++ acpica-unix2-20220331/source/compiler/aslopcodes.c
355 @@ -511,7 +511,8 @@ OpcDoUnicode (
357 for (i = 0; i < Count; i++)
359 - UnicodeString[i] = (UINT16) AsciiString[i];
360 + AcpiUtWriteUint (&UnicodeString[i], sizeof (UINT16),
361 + &AsciiString[i], sizeof (UINT8));
365 Index: acpica-unix2-20220331/source/compiler/aslrestype1.c
366 ===================================================================
367 --- acpica-unix2-20220331.orig/source/compiler/aslrestype1.c
368 +++ acpica-unix2-20220331/source/compiler/aslrestype1.c
369 @@ -143,6 +143,7 @@ RsDoMemory24Descriptor (
370 ASL_RESOURCE_NODE *Rnode;
371 UINT32 CurrentByteOffset;
376 InitializerOp = Info->DescriptorTypeOp->Asl.Child;
377 @@ -151,7 +152,8 @@ RsDoMemory24Descriptor (
379 Descriptor = Rnode->Buffer;
380 Descriptor->Memory24.DescriptorType = ACPI_RESOURCE_NAME_MEMORY24;
381 - Descriptor->Memory24.ResourceLength = 9;
383 + Descriptor->Memory24.ResourceLength = AcpiUtReadUint16 (&Tmp16);
385 /* Process all child initialization nodes */
387 @@ -168,7 +170,8 @@ RsDoMemory24Descriptor (
389 case 1: /* Min Address */
391 - Descriptor->Memory24.Minimum = (UINT16) InitializerOp->Asl.Value.Integer;
392 + Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
393 + Descriptor->Memory24.Minimum = AcpiUtReadUint16 (&Tmp16);
394 RsCreateWordField (InitializerOp, ACPI_RESTAG_MINADDR,
395 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.Minimum));
396 MinOp = InitializerOp;
397 @@ -176,7 +179,8 @@ RsDoMemory24Descriptor (
399 case 2: /* Max Address */
401 - Descriptor->Memory24.Maximum = (UINT16) InitializerOp->Asl.Value.Integer;
402 + Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
403 + Descriptor->Memory24.Maximum = AcpiUtReadUint16 (&Tmp16);
404 RsCreateWordField (InitializerOp, ACPI_RESTAG_MAXADDR,
405 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.Maximum));
406 MaxOp = InitializerOp;
407 @@ -184,14 +188,16 @@ RsDoMemory24Descriptor (
409 case 3: /* Alignment */
411 - Descriptor->Memory24.Alignment = (UINT16) InitializerOp->Asl.Value.Integer;
412 + Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
413 + Descriptor->Memory24.Alignment = AcpiUtReadUint16 (&Tmp16);
414 RsCreateWordField (InitializerOp, ACPI_RESTAG_ALIGNMENT,
415 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.Alignment));
420 - Descriptor->Memory24.AddressLength = (UINT16) InitializerOp->Asl.Value.Integer;
421 + Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
422 + Descriptor->Memory24.AddressLength = AcpiUtReadUint16 (&Tmp16);
423 RsCreateWordField (InitializerOp, ACPI_RESTAG_LENGTH,
424 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.AddressLength));
425 LengthOp = InitializerOp;
426 @@ -214,10 +220,10 @@ RsDoMemory24Descriptor (
427 /* Validate the Min/Max/Len/Align values (Alignment==0 means 64K) */
429 RsSmallAddressCheck (ACPI_RESOURCE_NAME_MEMORY24,
430 - Descriptor->Memory24.Minimum,
431 - Descriptor->Memory24.Maximum,
432 - Descriptor->Memory24.AddressLength,
433 - Descriptor->Memory24.Alignment,
434 + (UINT32) AcpiUtReadUint16 (&Descriptor->Memory24.Minimum),
435 + (UINT32) AcpiUtReadUint16 (&Descriptor->Memory24.Maximum),
436 + (UINT32) AcpiUtReadUint16 (&Descriptor->Memory24.AddressLength),
437 + (UINT32) AcpiUtReadUint16 (&Descriptor->Memory24.Alignment),
438 MinOp, MaxOp, LengthOp, NULL, Info->DescriptorTypeOp);
441 @@ -249,6 +255,8 @@ RsDoMemory32Descriptor (
442 ASL_RESOURCE_NODE *Rnode;
443 UINT32 CurrentByteOffset;
449 InitializerOp = Info->DescriptorTypeOp->Asl.Child;
450 @@ -257,7 +265,8 @@ RsDoMemory32Descriptor (
452 Descriptor = Rnode->Buffer;
453 Descriptor->Memory32.DescriptorType = ACPI_RESOURCE_NAME_MEMORY32;
454 - Descriptor->Memory32.ResourceLength = 17;
456 + Descriptor->Memory32.ResourceLength = AcpiUtReadUint16 (&Tmp16);
458 /* Process all child initialization nodes */
460 @@ -274,7 +283,8 @@ RsDoMemory32Descriptor (
462 case 1: /* Min Address */
464 - Descriptor->Memory32.Minimum = (UINT32) InitializerOp->Asl.Value.Integer;
465 + Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
466 + Descriptor->Memory32.Minimum = AcpiUtReadUint32 (&Tmp32);
467 RsCreateDwordField (InitializerOp, ACPI_RESTAG_MINADDR,
468 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.Minimum));
469 MinOp = InitializerOp;
470 @@ -282,7 +292,8 @@ RsDoMemory32Descriptor (
472 case 2: /* Max Address */
474 - Descriptor->Memory32.Maximum = (UINT32) InitializerOp->Asl.Value.Integer;
475 + Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
476 + Descriptor->Memory32.Maximum = AcpiUtReadUint32 (&Tmp32);
477 RsCreateDwordField (InitializerOp, ACPI_RESTAG_MAXADDR,
478 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.Maximum));
479 MaxOp = InitializerOp;
480 @@ -290,7 +301,8 @@ RsDoMemory32Descriptor (
482 case 3: /* Alignment */
484 - Descriptor->Memory32.Alignment = (UINT32) InitializerOp->Asl.Value.Integer;
485 + Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
486 + Descriptor->Memory32.Alignment = AcpiUtReadUint32 (&Tmp32);
487 RsCreateDwordField (InitializerOp, ACPI_RESTAG_ALIGNMENT,
488 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.Alignment));
489 AlignOp = InitializerOp;
490 @@ -298,7 +310,8 @@ RsDoMemory32Descriptor (
494 - Descriptor->Memory32.AddressLength = (UINT32) InitializerOp->Asl.Value.Integer;
495 + Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
496 + Descriptor->Memory32.AddressLength = AcpiUtReadUint32 (&Tmp32);
497 RsCreateDwordField (InitializerOp, ACPI_RESTAG_LENGTH,
498 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.AddressLength));
499 LengthOp = InitializerOp;
500 @@ -321,10 +334,10 @@ RsDoMemory32Descriptor (
501 /* Validate the Min/Max/Len/Align values */
503 RsSmallAddressCheck (ACPI_RESOURCE_NAME_MEMORY32,
504 - Descriptor->Memory32.Minimum,
505 - Descriptor->Memory32.Maximum,
506 - Descriptor->Memory32.AddressLength,
507 - Descriptor->Memory32.Alignment,
508 + AcpiUtReadUint32 (&Descriptor->Memory32.Minimum),
509 + AcpiUtReadUint32 (&Descriptor->Memory32.Maximum),
510 + AcpiUtReadUint32 (&Descriptor->Memory32.AddressLength),
511 + AcpiUtReadUint32 (&Descriptor->Memory32.Alignment),
512 MinOp, MaxOp, LengthOp, AlignOp, Info->DescriptorTypeOp);
515 @@ -352,6 +365,8 @@ RsDoMemory32FixedDescriptor (
516 ASL_RESOURCE_NODE *Rnode;
517 UINT32 CurrentByteOffset;
523 InitializerOp = Info->DescriptorTypeOp->Asl.Child;
524 @@ -360,7 +375,8 @@ RsDoMemory32FixedDescriptor (
526 Descriptor = Rnode->Buffer;
527 Descriptor->FixedMemory32.DescriptorType = ACPI_RESOURCE_NAME_FIXED_MEMORY32;
528 - Descriptor->FixedMemory32.ResourceLength = 9;
530 + Descriptor->FixedMemory32.ResourceLength = AcpiUtReadUint16 (&Tmp16);
532 /* Process all child initialization nodes */
534 @@ -377,14 +393,16 @@ RsDoMemory32FixedDescriptor (
536 case 1: /* Address */
538 - Descriptor->FixedMemory32.Address = (UINT32) InitializerOp->Asl.Value.Integer;
539 + Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
540 + Descriptor->FixedMemory32.Address = AcpiUtReadUint32 (&Tmp32);
541 RsCreateDwordField (InitializerOp, ACPI_RESTAG_BASEADDRESS,
542 CurrentByteOffset + ASL_RESDESC_OFFSET (FixedMemory32.Address));
547 - Descriptor->FixedMemory32.AddressLength = (UINT32) InitializerOp->Asl.Value.Integer;
548 + Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
549 + Descriptor->FixedMemory32.AddressLength = AcpiUtReadUint32 (&Tmp32);
550 RsCreateDwordField (InitializerOp, ACPI_RESTAG_LENGTH,
551 CurrentByteOffset + ASL_RESDESC_OFFSET (FixedMemory32.AddressLength));
553 Index: acpica-unix2-20220331/source/compiler/aslrestype1i.c
554 ===================================================================
555 --- acpica-unix2-20220331.orig/source/compiler/aslrestype1i.c
556 +++ acpica-unix2-20220331/source/compiler/aslrestype1i.c
557 @@ -199,6 +199,7 @@ RsDoFixedDmaDescriptor (
558 ASL_RESOURCE_NODE *Rnode;
559 UINT32 CurrentByteOffset;
564 InitializerOp = Info->DescriptorTypeOp->Asl.Child;
565 @@ -217,14 +218,16 @@ RsDoFixedDmaDescriptor (
567 case 0: /* DMA Request Lines [WORD] (_DMA) */
569 - Descriptor->FixedDma.RequestLines = (UINT16) InitializerOp->Asl.Value.Integer;
570 + Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
571 + Descriptor->FixedDma.RequestLines = AcpiUtReadUint16 (&Tmp16);
572 RsCreateWordField (InitializerOp, ACPI_RESTAG_DMA,
573 CurrentByteOffset + ASL_RESDESC_OFFSET (FixedDma.RequestLines));
576 case 1: /* DMA Channel [WORD] (_TYP) */
578 - Descriptor->FixedDma.Channels = (UINT16) InitializerOp->Asl.Value.Integer;
579 + Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
580 + Descriptor->FixedDma.Channels = AcpiUtReadUint16 (&Tmp16);
581 RsCreateWordField (InitializerOp, ACPI_RESTAG_DMATYPE,
582 CurrentByteOffset + ASL_RESDESC_OFFSET (FixedDma.Channels));
584 @@ -275,6 +278,7 @@ RsDoFixedIoDescriptor (
585 ASL_RESOURCE_NODE *Rnode;
586 UINT32 CurrentByteOffset;
591 InitializerOp = Info->DescriptorTypeOp->Asl.Child;
592 @@ -293,8 +297,8 @@ RsDoFixedIoDescriptor (
594 case 0: /* Base Address */
596 - Descriptor->FixedIo.Address =
597 - (UINT16) InitializerOp->Asl.Value.Integer;
598 + Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
599 + Descriptor->FixedIo.Address = AcpiUtReadUint16 (&Tmp16);
600 RsCreateWordField (InitializerOp, ACPI_RESTAG_BASEADDRESS,
601 CurrentByteOffset + ASL_RESDESC_OFFSET (FixedIo.Address));
602 AddressOp = InitializerOp;
603 @@ -324,7 +328,7 @@ RsDoFixedIoDescriptor (
607 - if (Descriptor->FixedIo.Address > 0x03FF)
608 + if (AcpiUtReadUint16 (&Descriptor->FixedIo.Address) > 0x03FF)
610 AslError (ASL_WARNING, ASL_MSG_ISA_ADDRESS, AddressOp, NULL);
612 @@ -358,6 +362,7 @@ RsDoIoDescriptor (
613 ASL_RESOURCE_NODE *Rnode;
614 UINT32 CurrentByteOffset;
619 InitializerOp = Info->DescriptorTypeOp->Asl.Child;
620 @@ -383,8 +388,8 @@ RsDoIoDescriptor (
622 case 1: /* Min Address */
624 - Descriptor->Io.Minimum =
625 - (UINT16) InitializerOp->Asl.Value.Integer;
626 + Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
627 + Descriptor->Io.Minimum = AcpiUtReadUint16 (&Tmp16);
628 RsCreateWordField (InitializerOp, ACPI_RESTAG_MINADDR,
629 CurrentByteOffset + ASL_RESDESC_OFFSET (Io.Minimum));
630 MinOp = InitializerOp;
631 @@ -392,8 +397,8 @@ RsDoIoDescriptor (
633 case 2: /* Max Address */
635 - Descriptor->Io.Maximum =
636 - (UINT16) InitializerOp->Asl.Value.Integer;
637 + Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
638 + Descriptor->Io.Maximum = AcpiUtReadUint16 (&Tmp16);
639 RsCreateWordField (InitializerOp, ACPI_RESTAG_MAXADDR,
640 CurrentByteOffset + ASL_RESDESC_OFFSET (Io.Maximum));
641 MaxOp = InitializerOp;
642 @@ -434,10 +439,10 @@ RsDoIoDescriptor (
643 /* Validate the Min/Max/Len/Align values */
645 RsSmallAddressCheck (ACPI_RESOURCE_NAME_IO,
646 - Descriptor->Io.Minimum,
647 - Descriptor->Io.Maximum,
648 - Descriptor->Io.AddressLength,
649 - Descriptor->Io.Alignment,
650 + (UINT32) (AcpiUtReadUint16 (&Descriptor->Io.Minimum)),
651 + (UINT32) (AcpiUtReadUint16 (&Descriptor->Io.Maximum)),
652 + (UINT32) Descriptor->Io.AddressLength,
653 + (UINT32) Descriptor->Io.Alignment,
654 MinOp, MaxOp, LengthOp, AlignOp, Info->DescriptorTypeOp);
657 @@ -561,7 +566,7 @@ RsDoIrqDescriptor (
659 /* Now we can set the channel mask */
661 - Descriptor->Irq.IrqMask = IrqMask;
662 + Descriptor->Irq.IrqMask = AcpiUtReadUint16 (&IrqMask);
666 @@ -660,6 +665,6 @@ RsDoIrqNoFlagsDescriptor (
668 /* Now we can set the interrupt mask */
670 - Descriptor->Irq.IrqMask = IrqMask;
671 + Descriptor->Irq.IrqMask = AcpiUtReadUint16(&IrqMask);
674 Index: acpica-unix2-20220331/source/compiler/aslrestype2.c
675 ===================================================================
676 --- acpica-unix2-20220331.orig/source/compiler/aslrestype2.c
677 +++ acpica-unix2-20220331/source/compiler/aslrestype2.c
678 @@ -77,6 +77,8 @@ RsDoGeneralRegisterDescriptor (
679 ASL_RESOURCE_NODE *Rnode;
680 UINT32 CurrentByteOffset;
686 InitializerOp = Info->DescriptorTypeOp->Asl.Child;
687 @@ -85,7 +87,8 @@ RsDoGeneralRegisterDescriptor (
689 Descriptor = Rnode->Buffer;
690 Descriptor->GenericReg.DescriptorType = ACPI_RESOURCE_NAME_GENERIC_REGISTER;
691 - Descriptor->GenericReg.ResourceLength = 12;
693 + Descriptor->GenericReg.ResourceLength = AcpiUtReadUint16 (&Tmp16);
695 /* Process all child initialization nodes */
697 @@ -116,7 +119,8 @@ RsDoGeneralRegisterDescriptor (
699 case 3: /* Register Address */
701 - Descriptor->GenericReg.Address = InitializerOp->Asl.Value.Integer;
702 + Tmp64 = InitializerOp->Asl.Value.Integer;
703 + Descriptor->GenericReg.Address = AcpiUtReadUint64 (&Tmp64);
704 RsCreateQwordField (InitializerOp, ACPI_RESTAG_ADDRESS,
705 CurrentByteOffset + ASL_RESDESC_OFFSET (GenericReg.Address));
707 @@ -184,6 +188,8 @@ RsDoInterruptDescriptor (
708 BOOLEAN HasResSourceIndex = FALSE;
709 UINT8 ResSourceIndex = 0;
710 UINT8 *ResSourceString = NULL;
715 InitializerOp = Info->DescriptorTypeOp->Asl.Child;
716 @@ -225,7 +231,7 @@ RsDoInterruptDescriptor (
717 * Initial descriptor length -- may be enlarged if there are
718 * optional fields present
720 - Descriptor->ExtendedIrq.ResourceLength = 2; /* Flags and table length byte */
721 + Descriptor->ExtendedIrq.ResourceLength = 2; /* Flags and table length byte */
722 Descriptor->ExtendedIrq.InterruptCount = 0;
724 Rover = ACPI_CAST_PTR (AML_RESOURCE,
725 @@ -333,7 +339,8 @@ RsDoInterruptDescriptor (
727 /* Save the integer and move pointer to the next one */
729 - Rover->DwordItem = (UINT32) InitializerOp->Asl.Value.Integer;
730 + Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
731 + Rover->DwordItem = AcpiUtReadUint32 (&Tmp32);
732 Rover = ACPI_ADD_PTR (AML_RESOURCE, &(Rover->DwordItem), 4);
733 Descriptor->ExtendedIrq.InterruptCount++;
734 Descriptor->ExtendedIrq.ResourceLength += 4;
735 @@ -384,6 +391,8 @@ RsDoInterruptDescriptor (
736 Descriptor->ExtendedIrq.ResourceLength = (UINT16)
737 (Descriptor->ExtendedIrq.ResourceLength + StringLength);
739 + Tmp16 = Descriptor->ExtendedIrq.ResourceLength;
740 + Descriptor->ExtendedIrq.ResourceLength = AcpiUtReadUint16 (&Tmp16);
742 Rnode->BufferLength =
743 (ASL_RESDESC_OFFSET (ExtendedIrq.Interrupts[0]) -
744 @@ -436,7 +445,8 @@ RsDoVendorLargeDescriptor (
746 Descriptor = Rnode->Buffer;
747 Descriptor->VendorLarge.DescriptorType = ACPI_RESOURCE_NAME_VENDOR_LARGE;
748 - Descriptor->VendorLarge.ResourceLength = (UINT16) i;
749 + AcpiUtWriteUint (&Descriptor->VendorLarge.ResourceLength, sizeof (UINT16),
750 + &i, sizeof (UINT32));
752 /* Point to end-of-descriptor for vendor data */
754 Index: acpica-unix2-20220331/source/compiler/aslrestype2d.c
755 ===================================================================
756 --- acpica-unix2-20220331.orig/source/compiler/aslrestype2d.c
757 +++ acpica-unix2-20220331/source/compiler/aslrestype2d.c
758 @@ -84,6 +84,8 @@ RsDoDwordIoDescriptor (
759 UINT32 CurrentByteOffset;
761 BOOLEAN ResSourceIndex = FALSE;
766 InitializerOp = Info->DescriptorTypeOp->Asl.Child;
767 @@ -147,8 +149,8 @@ RsDoDwordIoDescriptor (
769 case 5: /* Address Granularity */
771 - Descriptor->Address32.Granularity =
772 - (UINT32) InitializerOp->Asl.Value.Integer;
773 + Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
774 + Descriptor->Address32.Granularity = AcpiUtReadUint32 (&Tmp32);
775 RsCreateDwordField (InitializerOp, ACPI_RESTAG_GRANULARITY,
776 CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Granularity));
777 GranOp = InitializerOp;
778 @@ -156,8 +158,8 @@ RsDoDwordIoDescriptor (
780 case 6: /* Address Min */
782 - Descriptor->Address32.Minimum =
783 - (UINT32) InitializerOp->Asl.Value.Integer;
784 + Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
785 + Descriptor->Address32.Minimum = AcpiUtReadUint32 (&Tmp32);
786 RsCreateDwordField (InitializerOp, ACPI_RESTAG_MINADDR,
787 CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Minimum));
788 MinOp = InitializerOp;
789 @@ -165,8 +167,8 @@ RsDoDwordIoDescriptor (
791 case 7: /* Address Max */
793 - Descriptor->Address32.Maximum =
794 - (UINT32) InitializerOp->Asl.Value.Integer;
795 + Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
796 + Descriptor->Address32.Maximum = AcpiUtReadUint32 (&Tmp32);
797 RsCreateDwordField (InitializerOp, ACPI_RESTAG_MAXADDR,
798 CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Maximum));
799 MaxOp = InitializerOp;
800 @@ -174,16 +176,16 @@ RsDoDwordIoDescriptor (
802 case 8: /* Translation Offset */
804 - Descriptor->Address32.TranslationOffset =
805 - (UINT32) InitializerOp->Asl.Value.Integer;
806 + Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
807 + Descriptor->Address32.TranslationOffset = AcpiUtReadUint32 (&Tmp32);
808 RsCreateDwordField (InitializerOp, ACPI_RESTAG_TRANSLATION,
809 CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.TranslationOffset));
812 case 9: /* Address Length */
814 - Descriptor->Address32.AddressLength =
815 - (UINT32) InitializerOp->Asl.Value.Integer;
816 + Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
817 + Descriptor->Address32.AddressLength = AcpiUtReadUint32 (&Tmp32);
818 RsCreateDwordField (InitializerOp, ACPI_RESTAG_LENGTH,
819 CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.AddressLength));
820 LengthOp = InitializerOp;
821 @@ -271,11 +273,14 @@ RsDoDwordIoDescriptor (
823 /* Validate the Min/Max/Len/Gran values */
825 + Tmp16 = Descriptor->Address32.ResourceLength;
826 + Descriptor->Address32.ResourceLength = AcpiUtReadUint16 (&Tmp16);
828 RsLargeAddressCheck (
829 - (UINT64) Descriptor->Address32.Minimum,
830 - (UINT64) Descriptor->Address32.Maximum,
831 - (UINT64) Descriptor->Address32.AddressLength,
832 - (UINT64) Descriptor->Address32.Granularity,
833 + (UINT64) AcpiUtReadUint32 (&Descriptor->Address32.Minimum),
834 + (UINT64) AcpiUtReadUint32 (&Descriptor->Address32.Maximum),
835 + (UINT64) AcpiUtReadUint32 (&Descriptor->Address32.AddressLength),
836 + (UINT64) AcpiUtReadUint32 (&Descriptor->Address32.Granularity),
837 Descriptor->Address32.Flags,
838 MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp);
840 @@ -314,6 +319,8 @@ RsDoDwordMemoryDescriptor (
841 UINT32 CurrentByteOffset;
843 BOOLEAN ResSourceIndex = FALSE;
848 InitializerOp = Info->DescriptorTypeOp->Asl.Child;
849 @@ -385,8 +392,8 @@ RsDoDwordMemoryDescriptor (
851 case 6: /* Address Granularity */
853 - Descriptor->Address32.Granularity =
854 - (UINT32) InitializerOp->Asl.Value.Integer;
855 + Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
856 + Descriptor->Address32.Granularity = AcpiUtReadUint32 (&Tmp32);
857 RsCreateDwordField (InitializerOp, ACPI_RESTAG_GRANULARITY,
858 CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Granularity));
859 GranOp = InitializerOp;
860 @@ -394,8 +401,8 @@ RsDoDwordMemoryDescriptor (
862 case 7: /* Min Address */
864 - Descriptor->Address32.Minimum =
865 - (UINT32) InitializerOp->Asl.Value.Integer;
866 + Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
867 + Descriptor->Address32.Minimum = AcpiUtReadUint32 (&Tmp32);
868 RsCreateDwordField (InitializerOp, ACPI_RESTAG_MINADDR,
869 CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Minimum));
870 MinOp = InitializerOp;
871 @@ -403,8 +410,8 @@ RsDoDwordMemoryDescriptor (
873 case 8: /* Max Address */
875 - Descriptor->Address32.Maximum =
876 - (UINT32) InitializerOp->Asl.Value.Integer;
877 + Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
878 + Descriptor->Address32.Maximum = AcpiUtReadUint32 (&Tmp32);
879 RsCreateDwordField (InitializerOp, ACPI_RESTAG_MAXADDR,
880 CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Maximum));
881 MaxOp = InitializerOp;
882 @@ -412,16 +419,16 @@ RsDoDwordMemoryDescriptor (
884 case 9: /* Translation Offset */
886 - Descriptor->Address32.TranslationOffset =
887 - (UINT32) InitializerOp->Asl.Value.Integer;
888 + Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
889 + Descriptor->Address32.TranslationOffset = AcpiUtReadUint32 (&Tmp32);
890 RsCreateDwordField (InitializerOp, ACPI_RESTAG_TRANSLATION,
891 CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.TranslationOffset));
894 case 10: /* Address Length */
896 - Descriptor->Address32.AddressLength =
897 - (UINT32) InitializerOp->Asl.Value.Integer;
898 + Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
899 + Descriptor->Address32.AddressLength = AcpiUtReadUint32 (&Tmp32);
900 RsCreateDwordField (InitializerOp, ACPI_RESTAG_LENGTH,
901 CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.AddressLength));
902 LengthOp = InitializerOp;
903 @@ -506,11 +513,14 @@ RsDoDwordMemoryDescriptor (
905 /* Validate the Min/Max/Len/Gran values */
907 + Tmp16 = Descriptor->Address32.ResourceLength;
908 + Descriptor->Address32.ResourceLength = AcpiUtReadUint16 (&Tmp16);
910 RsLargeAddressCheck (
911 - (UINT64) Descriptor->Address32.Minimum,
912 - (UINT64) Descriptor->Address32.Maximum,
913 - (UINT64) Descriptor->Address32.AddressLength,
914 - (UINT64) Descriptor->Address32.Granularity,
915 + (UINT64) AcpiUtReadUint32 (&Descriptor->Address32.Minimum),
916 + (UINT64) AcpiUtReadUint32 (&Descriptor->Address32.Maximum),
917 + (UINT64) AcpiUtReadUint32 (&Descriptor->Address32.AddressLength),
918 + (UINT64) AcpiUtReadUint32 (&Descriptor->Address32.Granularity),
919 Descriptor->Address32.Flags,
920 MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp);
922 @@ -549,6 +559,8 @@ RsDoDwordSpaceDescriptor (
923 UINT32 CurrentByteOffset;
925 BOOLEAN ResSourceIndex = FALSE;
930 InitializerOp = Info->DescriptorTypeOp->Asl.Child;
931 @@ -616,8 +628,8 @@ RsDoDwordSpaceDescriptor (
933 case 6: /* Address Granularity */
935 - Descriptor->Address32.Granularity =
936 - (UINT32) InitializerOp->Asl.Value.Integer;
937 + Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
938 + Descriptor->Address32.Granularity = AcpiUtReadUint32 (&Tmp32);
939 RsCreateDwordField (InitializerOp, ACPI_RESTAG_GRANULARITY,
940 CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Granularity));
941 GranOp = InitializerOp;
942 @@ -625,8 +637,8 @@ RsDoDwordSpaceDescriptor (
944 case 7: /* Min Address */
946 - Descriptor->Address32.Minimum =
947 - (UINT32) InitializerOp->Asl.Value.Integer;
948 + Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
949 + Descriptor->Address32.Minimum = AcpiUtReadUint32 (&Tmp32);
950 RsCreateDwordField (InitializerOp, ACPI_RESTAG_MINADDR,
951 CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Minimum));
952 MinOp = InitializerOp;
953 @@ -634,8 +646,8 @@ RsDoDwordSpaceDescriptor (
955 case 8: /* Max Address */
957 - Descriptor->Address32.Maximum =
958 - (UINT32) InitializerOp->Asl.Value.Integer;
959 + Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
960 + Descriptor->Address32.Maximum = AcpiUtReadUint32 (&Tmp32);
961 RsCreateDwordField (InitializerOp, ACPI_RESTAG_MAXADDR,
962 CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Maximum));
963 MaxOp = InitializerOp;
964 @@ -643,16 +655,16 @@ RsDoDwordSpaceDescriptor (
966 case 9: /* Translation Offset */
968 - Descriptor->Address32.TranslationOffset =
969 - (UINT32) InitializerOp->Asl.Value.Integer;
970 + Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
971 + Descriptor->Address32.TranslationOffset = AcpiUtReadUint32 (&Tmp32);
972 RsCreateDwordField (InitializerOp, ACPI_RESTAG_TRANSLATION,
973 CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.TranslationOffset));
976 case 10: /* Address Length */
978 - Descriptor->Address32.AddressLength =
979 - (UINT32) InitializerOp->Asl.Value.Integer;
980 + Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
981 + Descriptor->Address32.AddressLength = AcpiUtReadUint32 (&Tmp32);
982 RsCreateDwordField (InitializerOp, ACPI_RESTAG_LENGTH,
983 CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.AddressLength));
984 LengthOp = InitializerOp;
985 @@ -723,11 +735,14 @@ RsDoDwordSpaceDescriptor (
987 /* Validate the Min/Max/Len/Gran values */
989 + Tmp16 = Descriptor->Address32.ResourceLength;
990 + Descriptor->Address32.ResourceLength = AcpiUtReadUint16 (&Tmp16);
992 RsLargeAddressCheck (
993 - (UINT64) Descriptor->Address32.Minimum,
994 - (UINT64) Descriptor->Address32.Maximum,
995 - (UINT64) Descriptor->Address32.AddressLength,
996 - (UINT64) Descriptor->Address32.Granularity,
997 + (UINT64) AcpiUtReadUint32 (&Descriptor->Address32.Minimum),
998 + (UINT64) AcpiUtReadUint32 (&Descriptor->Address32.Maximum),
999 + (UINT64) AcpiUtReadUint32 (&Descriptor->Address32.AddressLength),
1000 + (UINT64) AcpiUtReadUint32 (&Descriptor->Address32.Granularity),
1001 Descriptor->Address32.Flags,
1002 MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp);
1004 Index: acpica-unix2-20220331/source/compiler/aslrestype2q.c
1005 ===================================================================
1006 --- acpica-unix2-20220331.orig/source/compiler/aslrestype2q.c
1007 +++ acpica-unix2-20220331/source/compiler/aslrestype2q.c
1008 @@ -84,6 +84,7 @@ RsDoQwordIoDescriptor (
1009 UINT32 CurrentByteOffset;
1011 BOOLEAN ResSourceIndex = FALSE;
1015 InitializerOp = Info->DescriptorTypeOp->Asl.Child;
1016 @@ -147,7 +148,8 @@ RsDoQwordIoDescriptor (
1018 case 5: /* Address Granularity */
1020 - Descriptor->Address64.Granularity = InitializerOp->Asl.Value.Integer;
1021 + Descriptor->Address64.Granularity =
1022 + AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
1023 RsCreateQwordField (InitializerOp, ACPI_RESTAG_GRANULARITY,
1024 CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Granularity));
1025 GranOp = InitializerOp;
1026 @@ -155,7 +157,8 @@ RsDoQwordIoDescriptor (
1028 case 6: /* Address Min */
1030 - Descriptor->Address64.Minimum = InitializerOp->Asl.Value.Integer;
1031 + Descriptor->Address64.Minimum =
1032 + AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
1033 RsCreateQwordField (InitializerOp, ACPI_RESTAG_MINADDR,
1034 CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Minimum));
1035 MinOp = InitializerOp;
1036 @@ -163,7 +166,8 @@ RsDoQwordIoDescriptor (
1038 case 7: /* Address Max */
1040 - Descriptor->Address64.Maximum = InitializerOp->Asl.Value.Integer;
1041 + Descriptor->Address64.Maximum =
1042 + AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
1043 RsCreateQwordField (InitializerOp, ACPI_RESTAG_MAXADDR,
1044 CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Maximum));
1045 MaxOp = InitializerOp;
1046 @@ -171,14 +175,16 @@ RsDoQwordIoDescriptor (
1048 case 8: /* Translation Offset */
1050 - Descriptor->Address64.TranslationOffset = InitializerOp->Asl.Value.Integer;
1051 + Descriptor->Address64.TranslationOffset =
1052 + AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
1053 RsCreateByteField (InitializerOp, ACPI_RESTAG_TRANSLATION,
1054 CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.TranslationOffset));
1057 case 9: /* Address Length */
1059 - Descriptor->Address64.AddressLength = InitializerOp->Asl.Value.Integer;
1060 + Descriptor->Address64.AddressLength =
1061 + AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
1062 RsCreateQwordField (InitializerOp, ACPI_RESTAG_LENGTH,
1063 CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.AddressLength));
1064 LengthOp = InitializerOp;
1065 @@ -262,11 +268,14 @@ RsDoQwordIoDescriptor (
1067 /* Validate the Min/Max/Len/Gran values */
1069 + Tmp16 = Descriptor->Address64.ResourceLength;
1070 + Descriptor->Address64.ResourceLength = AcpiUtReadUint16 (&Tmp16);
1072 RsLargeAddressCheck (
1073 - Descriptor->Address64.Minimum,
1074 - Descriptor->Address64.Maximum,
1075 - Descriptor->Address64.AddressLength,
1076 - Descriptor->Address64.Granularity,
1077 + AcpiUtReadUint64 (&Descriptor->Address64.Minimum),
1078 + AcpiUtReadUint64 (&Descriptor->Address64.Maximum),
1079 + AcpiUtReadUint64 (&Descriptor->Address64.AddressLength),
1080 + AcpiUtReadUint64 (&Descriptor->Address64.Granularity),
1081 Descriptor->Address64.Flags,
1082 MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp);
1084 @@ -305,6 +314,7 @@ RsDoQwordMemoryDescriptor (
1085 UINT32 CurrentByteOffset;
1087 BOOLEAN ResSourceIndex = FALSE;
1091 InitializerOp = Info->DescriptorTypeOp->Asl.Child;
1092 @@ -375,7 +385,8 @@ RsDoQwordMemoryDescriptor (
1094 case 6: /* Address Granularity */
1096 - Descriptor->Address64.Granularity = InitializerOp->Asl.Value.Integer;
1097 + Descriptor->Address64.Granularity =
1098 + AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
1099 RsCreateQwordField (InitializerOp, ACPI_RESTAG_GRANULARITY,
1100 CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Granularity));
1101 GranOp = InitializerOp;
1102 @@ -383,7 +394,8 @@ RsDoQwordMemoryDescriptor (
1104 case 7: /* Min Address */
1106 - Descriptor->Address64.Minimum = InitializerOp->Asl.Value.Integer;
1107 + Descriptor->Address64.Minimum =
1108 + AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
1109 RsCreateQwordField (InitializerOp, ACPI_RESTAG_MINADDR,
1110 CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Minimum));
1111 MinOp = InitializerOp;
1112 @@ -391,7 +403,8 @@ RsDoQwordMemoryDescriptor (
1114 case 8: /* Max Address */
1116 - Descriptor->Address64.Maximum = InitializerOp->Asl.Value.Integer;
1117 + Descriptor->Address64.Maximum =
1118 + AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
1119 RsCreateQwordField (InitializerOp, ACPI_RESTAG_MAXADDR,
1120 CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Maximum));
1121 MaxOp = InitializerOp;
1122 @@ -399,14 +412,16 @@ RsDoQwordMemoryDescriptor (
1124 case 9: /* Translation Offset */
1126 - Descriptor->Address64.TranslationOffset = InitializerOp->Asl.Value.Integer;
1127 + Descriptor->Address64.TranslationOffset =
1128 + AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
1129 RsCreateQwordField (InitializerOp, ACPI_RESTAG_TRANSLATION,
1130 CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.TranslationOffset));
1133 case 10: /* Address Length */
1135 - Descriptor->Address64.AddressLength = InitializerOp->Asl.Value.Integer;
1136 + Descriptor->Address64.AddressLength =
1137 + AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
1138 RsCreateQwordField (InitializerOp, ACPI_RESTAG_LENGTH,
1139 CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.AddressLength));
1140 LengthOp = InitializerOp;
1141 @@ -491,11 +506,14 @@ RsDoQwordMemoryDescriptor (
1143 /* Validate the Min/Max/Len/Gran values */
1145 + Tmp16 = Descriptor->Address64.ResourceLength;
1146 + Descriptor->Address64.ResourceLength = AcpiUtReadUint16 (&Tmp16);
1148 RsLargeAddressCheck (
1149 - Descriptor->Address64.Minimum,
1150 - Descriptor->Address64.Maximum,
1151 - Descriptor->Address64.AddressLength,
1152 - Descriptor->Address64.Granularity,
1153 + AcpiUtReadUint64 (&Descriptor->Address64.Minimum),
1154 + AcpiUtReadUint64 (&Descriptor->Address64.Maximum),
1155 + AcpiUtReadUint64 (&Descriptor->Address64.AddressLength),
1156 + AcpiUtReadUint64 (&Descriptor->Address64.Granularity),
1157 Descriptor->Address64.Flags,
1158 MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp);
1160 @@ -534,6 +552,7 @@ RsDoQwordSpaceDescriptor (
1161 UINT32 CurrentByteOffset;
1163 BOOLEAN ResSourceIndex = FALSE;
1167 InitializerOp = Info->DescriptorTypeOp->Asl.Child;
1168 @@ -601,7 +620,8 @@ RsDoQwordSpaceDescriptor (
1170 case 6: /* Address Granularity */
1172 - Descriptor->Address64.Granularity = InitializerOp->Asl.Value.Integer;
1173 + Descriptor->Address64.Granularity =
1174 + AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
1175 RsCreateQwordField (InitializerOp, ACPI_RESTAG_GRANULARITY,
1176 CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Granularity));
1177 GranOp = InitializerOp;
1178 @@ -609,7 +629,8 @@ RsDoQwordSpaceDescriptor (
1180 case 7: /* Min Address */
1182 - Descriptor->Address64.Minimum = InitializerOp->Asl.Value.Integer;
1183 + Descriptor->Address64.Minimum =
1184 + AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
1185 RsCreateQwordField (InitializerOp, ACPI_RESTAG_MINADDR,
1186 CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Minimum));
1187 MinOp = InitializerOp;
1188 @@ -617,7 +638,8 @@ RsDoQwordSpaceDescriptor (
1190 case 8: /* Max Address */
1192 - Descriptor->Address64.Maximum = InitializerOp->Asl.Value.Integer;
1193 + Descriptor->Address64.Maximum =
1194 + AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
1195 RsCreateQwordField (InitializerOp, ACPI_RESTAG_MAXADDR,
1196 CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Maximum));
1197 MaxOp = InitializerOp;
1198 @@ -625,14 +647,16 @@ RsDoQwordSpaceDescriptor (
1200 case 9: /* Translation Offset */
1202 - Descriptor->Address64.TranslationOffset = InitializerOp->Asl.Value.Integer;
1203 + Descriptor->Address64.TranslationOffset =
1204 + AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
1205 RsCreateQwordField (InitializerOp, ACPI_RESTAG_TRANSLATION,
1206 CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.TranslationOffset));
1209 case 10: /* Address Length */
1211 - Descriptor->Address64.AddressLength = InitializerOp->Asl.Value.Integer;
1212 + Descriptor->Address64.AddressLength =
1213 + AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
1214 RsCreateQwordField (InitializerOp, ACPI_RESTAG_LENGTH,
1215 CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.AddressLength));
1216 LengthOp = InitializerOp;
1217 @@ -702,11 +726,14 @@ RsDoQwordSpaceDescriptor (
1219 /* Validate the Min/Max/Len/Gran values */
1221 + Tmp16 = Descriptor->Address64.ResourceLength;
1222 + Descriptor->Address64.ResourceLength = AcpiUtReadUint16 (&Tmp16);
1224 RsLargeAddressCheck (
1225 - Descriptor->Address64.Minimum,
1226 - Descriptor->Address64.Maximum,
1227 - Descriptor->Address64.AddressLength,
1228 - Descriptor->Address64.Granularity,
1229 + AcpiUtReadUint64 (&Descriptor->Address64.Minimum),
1230 + AcpiUtReadUint64 (&Descriptor->Address64.Maximum),
1231 + AcpiUtReadUint64 (&Descriptor->Address64.AddressLength),
1232 + AcpiUtReadUint64 (&Descriptor->Address64.Granularity),
1233 Descriptor->Address64.Flags,
1234 MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp);
1236 Index: acpica-unix2-20220331/source/compiler/aslrestype2w.c
1237 ===================================================================
1238 --- acpica-unix2-20220331.orig/source/compiler/aslrestype2w.c
1239 +++ acpica-unix2-20220331/source/compiler/aslrestype2w.c
1240 @@ -84,6 +84,7 @@ RsDoWordIoDescriptor (
1241 UINT32 CurrentByteOffset;
1243 BOOLEAN ResSourceIndex = FALSE;
1247 InitializerOp = Info->DescriptorTypeOp->Asl.Child;
1248 @@ -147,7 +148,8 @@ RsDoWordIoDescriptor (
1250 case 5: /* Address Granularity */
1252 - Descriptor->Address16.Granularity = (UINT16) InitializerOp->Asl.Value.Integer;
1253 + Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
1254 + Descriptor->Address16.Granularity = AcpiUtReadUint16 (&Tmp16);
1255 RsCreateWordField (InitializerOp, ACPI_RESTAG_GRANULARITY,
1256 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Granularity));
1257 GranOp = InitializerOp;
1258 @@ -155,7 +157,8 @@ RsDoWordIoDescriptor (
1260 case 6: /* Address Min */
1262 - Descriptor->Address16.Minimum = (UINT16) InitializerOp->Asl.Value.Integer;
1263 + Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
1264 + Descriptor->Address16.Minimum = AcpiUtReadUint16 (&Tmp16);
1265 RsCreateWordField (InitializerOp, ACPI_RESTAG_MINADDR,
1266 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Minimum));
1267 MinOp = InitializerOp;
1268 @@ -163,7 +166,8 @@ RsDoWordIoDescriptor (
1270 case 7: /* Address Max */
1272 - Descriptor->Address16.Maximum = (UINT16) InitializerOp->Asl.Value.Integer;
1273 + Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
1274 + Descriptor->Address16.Maximum = AcpiUtReadUint16 (&Tmp16);
1275 RsCreateWordField (InitializerOp, ACPI_RESTAG_MAXADDR,
1276 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Maximum));
1277 MaxOp = InitializerOp;
1278 @@ -171,14 +175,16 @@ RsDoWordIoDescriptor (
1280 case 8: /* Translation Offset */
1282 - Descriptor->Address16.TranslationOffset = (UINT16) InitializerOp->Asl.Value.Integer;
1283 + Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
1284 + Descriptor->Address16.TranslationOffset = AcpiUtReadUint16 (&Tmp16);
1285 RsCreateWordField (InitializerOp, ACPI_RESTAG_TRANSLATION,
1286 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.TranslationOffset));
1289 case 9: /* Address Length */
1291 - Descriptor->Address16.AddressLength = (UINT16) InitializerOp->Asl.Value.Integer;
1292 + Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
1293 + Descriptor->Address16.AddressLength = AcpiUtReadUint16 (&Tmp16);
1294 RsCreateWordField (InitializerOp, ACPI_RESTAG_LENGTH,
1295 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.AddressLength));
1296 LengthOp = InitializerOp;
1297 @@ -263,13 +269,17 @@ RsDoWordIoDescriptor (
1298 /* Validate the Min/Max/Len/Gran values */
1300 RsLargeAddressCheck (
1301 - (UINT64) Descriptor->Address16.Minimum,
1302 - (UINT64) Descriptor->Address16.Maximum,
1303 - (UINT64) Descriptor->Address16.AddressLength,
1304 - (UINT64) Descriptor->Address16.Granularity,
1305 + (UINT64) AcpiUtReadUint16 (&Descriptor->Address16.Minimum),
1306 + (UINT64) AcpiUtReadUint16 (&Descriptor->Address16.Maximum),
1307 + (UINT64) AcpiUtReadUint16 (&Descriptor->Address16.AddressLength),
1308 + (UINT64) AcpiUtReadUint16 (&Descriptor->Address16.Granularity),
1309 Descriptor->Address16.Flags,
1310 MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp);
1312 + /* correct enddianness */
1313 + Tmp16 = Descriptor->Address16.ResourceLength;
1314 + Descriptor->Address16.ResourceLength = AcpiUtReadUint16 (&Tmp16);
1316 Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS16) +
1317 OptionIndex + StringLength;
1319 @@ -305,6 +315,7 @@ RsDoWordBusNumberDescriptor (
1320 UINT32 CurrentByteOffset;
1322 BOOLEAN ResSourceIndex = FALSE;
1326 InitializerOp = Info->DescriptorTypeOp->Asl.Child;
1327 @@ -361,8 +372,8 @@ RsDoWordBusNumberDescriptor (
1329 case 4: /* Address Granularity */
1331 - Descriptor->Address16.Granularity =
1332 - (UINT16) InitializerOp->Asl.Value.Integer;
1333 + Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
1334 + Descriptor->Address16.Granularity = AcpiUtReadUint16 (&Tmp16);
1335 RsCreateWordField (InitializerOp, ACPI_RESTAG_GRANULARITY,
1336 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Granularity));
1337 GranOp = InitializerOp;
1338 @@ -370,8 +381,8 @@ RsDoWordBusNumberDescriptor (
1340 case 5: /* Min Address */
1342 - Descriptor->Address16.Minimum =
1343 - (UINT16) InitializerOp->Asl.Value.Integer;
1344 + Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
1345 + Descriptor->Address16.Minimum = AcpiUtReadUint16 (&Tmp16);
1346 RsCreateWordField (InitializerOp, ACPI_RESTAG_MINADDR,
1347 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Minimum));
1348 MinOp = InitializerOp;
1349 @@ -379,8 +390,8 @@ RsDoWordBusNumberDescriptor (
1351 case 6: /* Max Address */
1353 - Descriptor->Address16.Maximum =
1354 - (UINT16) InitializerOp->Asl.Value.Integer;
1355 + Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
1356 + Descriptor->Address16.Maximum = AcpiUtReadUint16 (&Tmp16);
1357 RsCreateWordField (InitializerOp, ACPI_RESTAG_MAXADDR,
1358 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Maximum));
1359 MaxOp = InitializerOp;
1360 @@ -388,16 +399,16 @@ RsDoWordBusNumberDescriptor (
1362 case 7: /* Translation Offset */
1364 - Descriptor->Address16.TranslationOffset =
1365 - (UINT16) InitializerOp->Asl.Value.Integer;
1366 + Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
1367 + Descriptor->Address16.TranslationOffset = AcpiUtReadUint16 (&Tmp16);
1368 RsCreateWordField (InitializerOp, ACPI_RESTAG_TRANSLATION,
1369 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.TranslationOffset));
1372 case 8: /* Address Length */
1374 - Descriptor->Address16.AddressLength =
1375 - (UINT16) InitializerOp->Asl.Value.Integer;
1376 + Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
1377 + Descriptor->Address16.AddressLength = AcpiUtReadUint16 (&Tmp16);
1378 RsCreateWordField (InitializerOp, ACPI_RESTAG_LENGTH,
1379 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.AddressLength));
1380 LengthOp = InitializerOp;
1381 @@ -468,13 +479,17 @@ RsDoWordBusNumberDescriptor (
1382 /* Validate the Min/Max/Len/Gran values */
1384 RsLargeAddressCheck (
1385 - (UINT64) Descriptor->Address16.Minimum,
1386 - (UINT64) Descriptor->Address16.Maximum,
1387 - (UINT64) Descriptor->Address16.AddressLength,
1388 - (UINT64) Descriptor->Address16.Granularity,
1389 + (UINT64) AcpiUtReadUint16 (&Descriptor->Address16.Minimum),
1390 + (UINT64) AcpiUtReadUint16 (&Descriptor->Address16.Maximum),
1391 + (UINT64) AcpiUtReadUint16 (&Descriptor->Address16.AddressLength),
1392 + (UINT64) AcpiUtReadUint16 (&Descriptor->Address16.Granularity),
1393 Descriptor->Address16.Flags,
1394 MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp);
1396 + /* correct enddianness */
1397 + Tmp16 = Descriptor->Address16.ResourceLength;
1398 + Descriptor->Address16.ResourceLength = AcpiUtReadUint16 (&Tmp16);
1400 Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS16) +
1401 OptionIndex + StringLength;
1403 @@ -510,6 +525,7 @@ RsDoWordSpaceDescriptor (
1404 UINT32 CurrentByteOffset;
1406 BOOLEAN ResSourceIndex = FALSE;
1410 InitializerOp = Info->DescriptorTypeOp->Asl.Child;
1411 @@ -577,8 +593,8 @@ RsDoWordSpaceDescriptor (
1413 case 6: /* Address Granularity */
1415 - Descriptor->Address16.Granularity =
1416 - (UINT16) InitializerOp->Asl.Value.Integer;
1417 + Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
1418 + Descriptor->Address16.Granularity = AcpiUtReadUint16 (&Tmp16);
1419 RsCreateWordField (InitializerOp, ACPI_RESTAG_GRANULARITY,
1420 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Granularity));
1421 GranOp = InitializerOp;
1422 @@ -586,8 +602,8 @@ RsDoWordSpaceDescriptor (
1424 case 7: /* Min Address */
1426 - Descriptor->Address16.Minimum =
1427 - (UINT16) InitializerOp->Asl.Value.Integer;
1428 + Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
1429 + Descriptor->Address16.Minimum = AcpiUtReadUint16 (&Tmp16);
1430 RsCreateWordField (InitializerOp, ACPI_RESTAG_MINADDR,
1431 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Minimum));
1432 MinOp = InitializerOp;
1433 @@ -595,8 +611,8 @@ RsDoWordSpaceDescriptor (
1435 case 8: /* Max Address */
1437 - Descriptor->Address16.Maximum =
1438 - (UINT16) InitializerOp->Asl.Value.Integer;
1439 + Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
1440 + Descriptor->Address16.Maximum = AcpiUtReadUint16 (&Tmp16);
1441 RsCreateWordField (InitializerOp, ACPI_RESTAG_MAXADDR,
1442 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Maximum));
1443 MaxOp = InitializerOp;
1444 @@ -604,16 +620,16 @@ RsDoWordSpaceDescriptor (
1446 case 9: /* Translation Offset */
1448 - Descriptor->Address16.TranslationOffset =
1449 - (UINT16) InitializerOp->Asl.Value.Integer;
1450 + Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
1451 + Descriptor->Address16.TranslationOffset = AcpiUtReadUint16 (&Tmp16);
1452 RsCreateWordField (InitializerOp, ACPI_RESTAG_TRANSLATION,
1453 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.TranslationOffset));
1456 case 10: /* Address Length */
1458 - Descriptor->Address16.AddressLength =
1459 - (UINT16) InitializerOp->Asl.Value.Integer;
1460 + Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
1461 + Descriptor->Address16.AddressLength = AcpiUtReadUint16 (&Tmp16);
1462 RsCreateWordField (InitializerOp, ACPI_RESTAG_LENGTH,
1463 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.AddressLength));
1464 LengthOp = InitializerOp;
1465 @@ -684,13 +700,17 @@ RsDoWordSpaceDescriptor (
1466 /* Validate the Min/Max/Len/Gran values */
1468 RsLargeAddressCheck (
1469 - (UINT64) Descriptor->Address16.Minimum,
1470 - (UINT64) Descriptor->Address16.Maximum,
1471 - (UINT64) Descriptor->Address16.AddressLength,
1472 - (UINT64) Descriptor->Address16.Granularity,
1473 + (UINT64) AcpiUtReadUint16 (&Descriptor->Address16.Minimum),
1474 + (UINT64) AcpiUtReadUint16 (&Descriptor->Address16.Maximum),
1475 + (UINT64) AcpiUtReadUint16 (&Descriptor->Address16.AddressLength),
1476 + (UINT64) AcpiUtReadUint16 (&Descriptor->Address16.Granularity),
1477 Descriptor->Address16.Flags,
1478 MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp);
1480 + /* correct enddianness */
1481 + Tmp16 = Descriptor->Address16.ResourceLength;
1482 + Descriptor->Address16.ResourceLength = AcpiUtReadUint16 (&Tmp16);
1484 Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS16) +
1485 OptionIndex + StringLength;
1487 Index: acpica-unix2-20220331/source/compiler/dttable2.c
1488 ===================================================================
1489 --- acpica-unix2-20220331.orig/source/compiler/dttable2.c
1490 +++ acpica-unix2-20220331/source/compiler/dttable2.c
1491 @@ -3046,7 +3046,8 @@ DtCompileWpbt (
1493 /* Extract the length of the Arguments buffer, insert into main table */
1495 - Table->ArgumentsLength = (UINT16) Subtable->TotalLength;
1496 + AcpiUtWriteUint (&Table->ArgumentsLength, sizeof (UINT16),
1497 + &Subtable->TotalLength, sizeof (UINT32));
1498 DtInsertSubtable (ParentTable, Subtable);
1501 Index: acpica-unix2-20220331/source/components/disassembler/dmbuffer.c
1502 ===================================================================
1503 --- acpica-unix2-20220331.orig/source/components/disassembler/dmbuffer.c
1504 +++ acpica-unix2-20220331/source/components/disassembler/dmbuffer.c
1505 @@ -204,7 +204,7 @@ AcpiDmByteList (
1508 ByteData = Op->Named.Data;
1509 - ByteCount = (UINT32) Op->Common.Value.Integer;
1510 + ByteCount = (UINT32) Op->Common.Value.Size;
1513 * The byte list belongs to a buffer, and can be produced by either
1514 @@ -308,7 +308,7 @@ AcpiDmIsUuidBuffer (
1515 /* Extract the byte list info */
1517 ByteData = NextOp->Named.Data;
1518 - ByteCount = (UINT32) NextOp->Common.Value.Integer;
1519 + ByteCount = (UINT32) NextOp->Common.Value.Size;
1521 /* Byte count must be exactly 16 */
1523 @@ -436,7 +436,7 @@ AcpiDmIsUnicodeBuffer (
1524 /* Extract the byte list info */
1526 ByteData = NextOp->Named.Data;
1527 - ByteCount = (UINT32) NextOp->Common.Value.Integer;
1528 + ByteCount = (UINT32) NextOp->Common.Value.Size;
1529 WordCount = ACPI_DIV_2 (ByteCount);
1532 @@ -878,14 +878,14 @@ AcpiDmUnicode (
1533 /* Extract the buffer info as a WORD buffer */
1535 WordData = ACPI_CAST_PTR (UINT16, Op->Named.Data);
1536 - WordCount = ACPI_DIV_2 (((UINT32) Op->Common.Value.Integer));
1537 + WordCount = ACPI_DIV_2 (((UINT32) Op->Common.Value.Size));
1539 /* Write every other byte as an ASCII character */
1541 AcpiOsPrintf ("\"");
1542 for (i = 0; i < (WordCount - 1); i++)
1544 - OutputValue = (int) WordData[i];
1545 + OutputValue = (int) AcpiUtReadUint16 (&WordData[i]);
1547 /* Handle values that must be escaped */
1549 @@ -947,7 +947,29 @@ AcpiDmGetHardwareIdType (
1551 /* Swap from little-endian to big-endian to simplify conversion */
1553 - BigEndianId = AcpiUtDwordByteSwap ((UINT32) Op->Common.Value.Integer);
1554 + BigEndianId = (UINT32) Op->Common.Value.Integer;
1555 + if (UtIsBigEndianMachine())
1558 + * We'll need to store the bytes in little-endian order
1559 + * so they can be re-used properly later since everything is
1560 + * assumed to be in little-endian form.
1563 + UINT32 *Ptr = (UINT32 *)(&Op->Common.Value.Integer);
1564 + *Ptr = AcpiUtDwordByteSwap (BigEndianId);
1569 + * We'll need to just use the bytes in big-endian order;
1570 + * they're already in little-endian order.
1573 + UINT32 Tmp32 = BigEndianId;
1575 + BigEndianId = AcpiUtDwordByteSwap ((UINT32) Tmp32);
1578 /* Create the 3 leading ASCII letters */
1580 @@ -1073,11 +1095,12 @@ AcpiDmDecompressEisaId (
1582 char IdBuffer[ACPI_EISAID_STRING_SIZE];
1583 const AH_DEVICE_ID *Info;
1584 + UINT32 Tmp32 = EncodedId;
1587 /* Convert EISAID to a string an emit the statement */
1589 - AcpiExEisaIdToString (IdBuffer, EncodedId);
1590 + AcpiExEisaIdToString (IdBuffer, AcpiUtReadUint32 (&Tmp32));
1591 AcpiOsPrintf ("EisaId (\"%s\")", IdBuffer);
1593 /* If we know about the ID, emit the description */
1594 Index: acpica-unix2-20220331/source/components/disassembler/dmopcode.c
1595 ===================================================================
1596 --- acpica-unix2-20220331.orig/source/components/disassembler/dmopcode.c
1597 +++ acpica-unix2-20220331/source/components/disassembler/dmopcode.c
1598 @@ -778,7 +778,9 @@ AcpiDmDisassembleOneOp (
1602 - AcpiOsPrintf ("0x%4.4X", (UINT32) Op->Common.Value.Integer);
1603 + UINT16 Tmp16 = (UINT16) Op->Common.Value.Integer;
1605 + AcpiOsPrintf ("0x%4.4X", (UINT32) AcpiUtReadUint16 (&Tmp16));
1609 @@ -790,14 +792,19 @@ AcpiDmDisassembleOneOp (
1613 - AcpiOsPrintf ("0x%8.8X", (UINT32) Op->Common.Value.Integer);
1614 + UINT32 Tmp32 = (UINT32) Op->Common.Value.Integer;
1616 + AcpiOsPrintf ("0x%8.8X", (UINT32) AcpiUtReadUint32 (&Tmp32));
1622 - AcpiOsPrintf ("0x%8.8X%8.8X",
1623 - ACPI_FORMAT_UINT64 (Op->Common.Value.Integer));
1625 + UINT64 Tmp64 = AcpiUtReadUint64 (&Op->Common.Value.Integer);
1627 + AcpiOsPrintf ("0x%8.8X%8.8X", ACPI_FORMAT_UINT64 (Tmp64));
1632 @@ -887,18 +894,18 @@ AcpiDmDisassembleOneOp (
1634 ASL_CV_PRINT_ONE_COMMENT (Op, AML_NAMECOMMENT, NULL, 0);
1635 AcpiOsPrintf ("%*.s %u", (unsigned) (5 - Length), " ",
1636 - (UINT32) Op->Common.Value.Integer);
1637 + (UINT32) Op->Common.Value.Size);
1639 AcpiDmCommaIfFieldMember (Op);
1641 - Info->BitOffset += (UINT32) Op->Common.Value.Integer;
1642 + Info->BitOffset += (UINT32) Op->Common.Value.Size;
1645 case AML_INT_RESERVEDFIELD_OP:
1647 /* Offset() -- Must account for previous offsets */
1649 - Offset = (UINT32) Op->Common.Value.Integer;
1650 + Offset = (UINT32) Op->Common.Value.Size;
1651 Info->BitOffset += Offset;
1653 if (Info->BitOffset % 8 == 0)
1654 Index: acpica-unix2-20220331/source/components/disassembler/dmresrc.c
1655 ===================================================================
1656 --- acpica-unix2-20220331.orig/source/components/disassembler/dmresrc.c
1657 +++ acpica-unix2-20220331/source/components/disassembler/dmresrc.c
1658 @@ -417,7 +417,7 @@ AcpiDmIsResourceTemplate (
1662 - DeclaredBufferLength = NextOp->Common.Value.Size;
1663 + DeclaredBufferLength = NextOp->Common.Value.Integer;
1665 /* Get the length of the raw initialization byte list */
1667 Index: acpica-unix2-20220331/source/components/disassembler/dmresrcl.c
1668 ===================================================================
1669 --- acpica-unix2-20220331.orig/source/components/disassembler/dmresrcl.c
1670 +++ acpica-unix2-20220331/source/components/disassembler/dmresrcl.c
1671 @@ -141,6 +141,8 @@ AcpiDmMemoryFields (
1679 for (i = 0; i < 4; i++)
1680 @@ -151,14 +153,16 @@ AcpiDmMemoryFields (
1684 - AcpiDmDumpInteger16 (ACPI_CAST_PTR (UINT16, Source)[i],
1685 - AcpiDmMemoryNames[i]);
1686 + Tmp16 = ACPI_CAST_PTR (UINT16, Source)[i];
1687 + AcpiDmDumpInteger16 (AcpiUtReadUint16 (&Tmp16),
1688 + AcpiDmMemoryNames[i]);
1693 - AcpiDmDumpInteger32 (ACPI_CAST_PTR (UINT32, Source)[i],
1694 - AcpiDmMemoryNames[i]);
1695 + Tmp32 = ACPI_CAST_PTR (UINT32, Source)[i];
1696 + AcpiDmDumpInteger32 (AcpiUtReadUint32 (&Tmp32),
1697 + AcpiDmMemoryNames[i]);
1701 @@ -190,6 +194,9 @@ AcpiDmAddressFields (
1710 AcpiOsPrintf ("\n");
1711 @@ -202,20 +209,23 @@ AcpiDmAddressFields (
1715 - AcpiDmDumpInteger16 (ACPI_CAST_PTR (UINT16, Source)[i],
1716 - AcpiDmAddressNames[i]);
1717 + Tmp16 = ACPI_CAST_PTR (UINT16, Source)[i];
1718 + AcpiDmDumpInteger16 (AcpiUtReadUint16 (&Tmp16),
1719 + AcpiDmAddressNames[i]);
1724 - AcpiDmDumpInteger32 (ACPI_CAST_PTR (UINT32, Source)[i],
1725 - AcpiDmAddressNames[i]);
1726 + Tmp32 = ACPI_CAST_PTR (UINT32, Source)[i];
1727 + AcpiDmDumpInteger32 (AcpiUtReadUint32 (&Tmp32),
1728 + AcpiDmAddressNames[i]);
1733 - AcpiDmDumpInteger64 (ACPI_CAST_PTR (UINT64, Source)[i],
1734 - AcpiDmAddressNames[i]);
1735 + Tmp64 = ACPI_CAST_PTR (UINT64, Source)[i];
1736 + AcpiDmDumpInteger64 (AcpiUtReadUint64 (&Tmp64),
1737 + AcpiDmAddressNames[i]);
1741 @@ -749,7 +759,7 @@ AcpiDmExtendedDescriptor (
1742 /* Extra field for this descriptor only */
1744 AcpiDmIndent (Level + 1);
1745 - AcpiDmDumpInteger64 (Resource->ExtAddress64.TypeSpecific,
1746 + AcpiDmDumpInteger64 (AcpiUtReadUint64 (&Resource->ExtAddress64.TypeSpecific),
1747 "Type-Specific Attributes");
1749 /* Insert a descriptor name */
1750 @@ -876,11 +886,11 @@ AcpiDmFixedMemory32Descriptor (
1751 AcpiGbl_RwDecode [ACPI_GET_1BIT_FLAG (Resource->FixedMemory32.Flags)]);
1753 AcpiDmIndent (Level + 1);
1754 - AcpiDmDumpInteger32 (Resource->FixedMemory32.Address,
1755 + AcpiDmDumpInteger32 (AcpiUtReadUint32 (&Resource->FixedMemory32.Address),
1758 AcpiDmIndent (Level + 1);
1759 - AcpiDmDumpInteger32 (Resource->FixedMemory32.AddressLength,
1760 + AcpiDmDumpInteger32 (AcpiUtReadUint32 (&Resource->FixedMemory32.AddressLength),
1763 /* Insert a descriptor name */
1764 @@ -926,7 +936,8 @@ AcpiDmGenericRegisterDescriptor (
1765 AcpiDmDumpInteger8 (Resource->GenericReg.BitOffset, "Bit Offset");
1767 AcpiDmIndent (Level + 1);
1768 - AcpiDmDumpInteger64 (Resource->GenericReg.Address, "Address");
1769 + AcpiDmDumpInteger64 (AcpiUtReadUint64 (&Resource->GenericReg.Address),
1772 /* Optional field for ACPI 3.0 */
1774 @@ -989,7 +1000,7 @@ AcpiDmInterruptDescriptor (
1775 AcpiDmResourceSource (Resource,
1776 sizeof (AML_RESOURCE_EXTENDED_IRQ) +
1777 ((UINT32) Resource->ExtendedIrq.InterruptCount - 1) * sizeof (UINT32),
1778 - Resource->ExtendedIrq.ResourceLength);
1779 + AcpiUtReadUint16 (&Resource->ExtendedIrq.ResourceLength));
1781 /* Insert a descriptor name */
1783 @@ -1004,7 +1015,7 @@ AcpiDmInterruptDescriptor (
1785 AcpiDmIndent (Level + 1);
1786 AcpiOsPrintf ("0x%8.8X,\n",
1787 - (UINT32) Resource->ExtendedIrq.Interrupts[i]);
1788 + AcpiUtReadUint32 (&Resource->ExtendedIrq.Interrupts[i]));
1791 AcpiDmIndent (Level);
1792 Index: acpica-unix2-20220331/source/components/disassembler/dmresrcl2.c
1793 ===================================================================
1794 --- acpica-unix2-20220331.orig/source/components/disassembler/dmresrcl2.c
1795 +++ acpica-unix2-20220331/source/components/disassembler/dmresrcl2.c
1796 @@ -199,22 +199,27 @@ AcpiDmGpioCommon (
1797 char *DeviceName = NULL;
1800 + UINT16 ResSourceOffset;
1801 + UINT16 VendorOffset;
1802 + UINT16 VendorLength;
1806 /* ResourceSource, ResourceSourceIndex, ResourceType */
1808 AcpiDmIndent (Level + 1);
1809 - if (Resource->Gpio.ResSourceOffset)
1810 + ResSourceOffset = AcpiUtReadUint16 (&Resource->Gpio.ResSourceOffset);
1811 + if (ResSourceOffset)
1813 DeviceName = ACPI_ADD_PTR (char,
1814 - Resource, Resource->Gpio.ResSourceOffset),
1815 + Resource, ResSourceOffset),
1816 AcpiUtPrintString (DeviceName, ACPI_UINT16_MAX);
1819 AcpiOsPrintf (", ");
1820 AcpiOsPrintf ("0x%2.2X, ", Resource->Gpio.ResSourceIndex);
1821 - AcpiOsPrintf ("%s, ",
1822 - AcpiGbl_ConsumeDecode [ACPI_GET_1BIT_FLAG (Resource->Gpio.Flags)]);
1823 + Tmp16 = AcpiUtReadUint16 (&Resource->Gpio.Flags);
1824 + AcpiOsPrintf ("%s, ", AcpiGbl_ConsumeDecode [ACPI_GET_1BIT_FLAG (Tmp16)]);
1826 /* Insert a descriptor name */
1828 @@ -223,15 +228,15 @@ AcpiDmGpioCommon (
1830 /* Dump the vendor data */
1832 - if (Resource->Gpio.VendorOffset)
1833 + VendorOffset = AcpiUtReadUint16 (&Resource->Gpio.VendorOffset);
1834 + VendorLength = AcpiUtReadUint16 (&Resource->Gpio.VendorLength);
1837 AcpiOsPrintf ("\n");
1838 AcpiDmIndent (Level + 1);
1839 - VendorData = ACPI_ADD_PTR (UINT8, Resource,
1840 - Resource->Gpio.VendorOffset);
1841 + VendorData = ACPI_ADD_PTR (UINT8, Resource, VendorOffset);
1843 - AcpiDmDumpRawDataBuffer (VendorData,
1844 - Resource->Gpio.VendorLength, Level);
1845 + AcpiDmDumpRawDataBuffer (VendorData, VendorLength, Level);
1848 AcpiOsPrintf (")\n");
1849 @@ -241,17 +246,17 @@ AcpiDmGpioCommon (
1850 AcpiDmIndent (Level + 1);
1851 AcpiOsPrintf ("{ // Pin list\n");
1853 - PinCount = ((UINT32) (Resource->Gpio.ResSourceOffset -
1854 - Resource->Gpio.PinTableOffset)) /
1856 + PinCount = (UINT32) AcpiUtReadUint16 (&Resource->Gpio.ResSourceOffset);
1857 + PinCount -= (UINT32) AcpiUtReadUint16 (&Resource->Gpio.PinTableOffset);
1858 + PinCount /= sizeof (UINT16);
1860 PinList = (UINT16 *) ACPI_ADD_PTR (char, Resource,
1861 - Resource->Gpio.PinTableOffset);
1862 + AcpiUtReadUint16 (&Resource->Gpio.PinTableOffset));
1864 for (i = 0; i < PinCount; i++)
1866 AcpiDmIndent (Level + 2);
1867 - AcpiOsPrintf ("0x%4.4X%s\n", PinList[i],
1868 + AcpiOsPrintf ("0x%4.4X%s\n", AcpiUtReadUint16 (&(PinList[i])),
1869 ((i + 1) < PinCount) ? "," : "");
1872 @@ -285,16 +290,18 @@ AcpiDmGpioIntDescriptor (
1878 /* Dump the GpioInt-specific portion of the descriptor */
1880 /* EdgeLevel, ActiveLevel, Shared */
1882 AcpiDmIndent (Level);
1883 + Tmp16 = AcpiUtReadUint16 (&Resource->Gpio.IntFlags);
1884 AcpiOsPrintf ("GpioInt (%s, %s, %s, ",
1885 - AcpiGbl_HeDecode [ACPI_GET_1BIT_FLAG (Resource->Gpio.IntFlags)],
1886 - AcpiGbl_LlDecode [ACPI_EXTRACT_2BIT_FLAG (Resource->Gpio.IntFlags, 1)],
1887 - AcpiGbl_ShrDecode [ACPI_EXTRACT_2BIT_FLAG (Resource->Gpio.IntFlags, 3)]);
1888 + AcpiGbl_HeDecode [ACPI_GET_1BIT_FLAG (Tmp16)],
1889 + AcpiGbl_LlDecode [ACPI_EXTRACT_2BIT_FLAG (Tmp16, 1)],
1890 + AcpiGbl_ShrDecode [ACPI_EXTRACT_2BIT_FLAG (Tmp16, 3)]);
1892 /* PinConfig, DebounceTimeout */
1894 @@ -307,7 +314,8 @@ AcpiDmGpioIntDescriptor (
1896 AcpiOsPrintf ("0x%2.2X, ", Resource->Gpio.PinConfig);
1898 - AcpiOsPrintf ("0x%4.4X,\n", Resource->Gpio.DebounceTimeout);
1899 + AcpiOsPrintf ("0x%4.4X,\n",
1900 + AcpiUtReadUint16 (&Resource->Gpio.DebounceTimeout));
1902 /* Dump the GpioInt/GpioIo common portion of the descriptor */
1904 @@ -337,14 +345,16 @@ AcpiDmGpioIoDescriptor (
1910 /* Dump the GpioIo-specific portion of the descriptor */
1912 /* Shared, PinConfig */
1914 AcpiDmIndent (Level);
1915 + Tmp16 = AcpiUtReadUint16 (&Resource->Gpio.IntFlags);
1916 AcpiOsPrintf ("GpioIo (%s, ",
1917 - AcpiGbl_ShrDecode [ACPI_EXTRACT_2BIT_FLAG (Resource->Gpio.IntFlags, 3)]);
1918 + AcpiGbl_ShrDecode [ACPI_EXTRACT_2BIT_FLAG (Tmp16, 3)]);
1920 if (Resource->Gpio.PinConfig <= 3)
1922 @@ -358,10 +368,10 @@ AcpiDmGpioIoDescriptor (
1924 /* DebounceTimeout, DriveStrength, IoRestriction */
1926 - AcpiOsPrintf ("0x%4.4X, ", Resource->Gpio.DebounceTimeout);
1927 - AcpiOsPrintf ("0x%4.4X, ", Resource->Gpio.DriveStrength);
1928 - AcpiOsPrintf ("%s,\n",
1929 - AcpiGbl_IorDecode [ACPI_GET_2BIT_FLAG (Resource->Gpio.IntFlags)]);
1930 + AcpiOsPrintf ("0x%4.4X, ", AcpiUtReadUint16 (&Resource->Gpio.DebounceTimeout));
1931 + AcpiOsPrintf ("0x%4.4X, ", AcpiUtReadUint16 (&Resource->Gpio.DriveStrength));
1932 + Tmp16 = AcpiUtReadUint16 (&Resource->Gpio.IntFlags);
1933 + AcpiOsPrintf ("%s,\n", AcpiGbl_IorDecode [ACPI_GET_2BIT_FLAG (Tmp16)]);
1935 /* Dump the GpioInt/GpioIo common portion of the descriptor */
1937 @@ -442,6 +452,9 @@ AcpiDmPinFunctionDescriptor (
1938 char *DeviceName = NULL;
1941 + UINT16 ResSourceOffset;
1942 + UINT16 VendorOffset;
1943 + UINT16 VendorLength;
1945 AcpiDmIndent (Level);
1946 AcpiOsPrintf ("PinFunction (%s, ",
1947 @@ -459,12 +472,14 @@ AcpiDmPinFunctionDescriptor (
1949 /* FunctionNumber */
1951 - AcpiOsPrintf ("0x%4.4X, ", Resource->PinFunction.FunctionNumber);
1952 + AcpiOsPrintf ("0x%4.4X, ",
1953 + AcpiUtReadUint16 (&Resource->PinFunction.FunctionNumber));
1955 - if (Resource->PinFunction.ResSourceOffset)
1956 + ResSourceOffset = AcpiUtReadUint16 (&Resource->PinFunction.ResSourceOffset);
1957 + if (ResSourceOffset)
1959 DeviceName = ACPI_ADD_PTR (char,
1960 - Resource, Resource->PinFunction.ResSourceOffset),
1961 + Resource, ResSourceOffset),
1962 AcpiUtPrintString (DeviceName, ACPI_UINT16_MAX);
1965 @@ -484,15 +499,15 @@ AcpiDmPinFunctionDescriptor (
1967 /* Dump the vendor data */
1969 - if (Resource->PinFunction.VendorLength)
1970 + VendorOffset = AcpiUtReadUint16 (&Resource->PinFunction.VendorOffset);
1971 + VendorLength = AcpiUtReadUint16 (&Resource->PinFunction.VendorLength);
1974 AcpiOsPrintf ("\n");
1975 AcpiDmIndent (Level + 1);
1976 - VendorData = ACPI_ADD_PTR (UINT8, Resource,
1977 - Resource->PinFunction.VendorOffset);
1978 + VendorData = ACPI_ADD_PTR (UINT8, Resource, VendorOffset);
1980 - AcpiDmDumpRawDataBuffer (VendorData,
1981 - Resource->PinFunction.VendorLength, Level);
1982 + AcpiDmDumpRawDataBuffer (VendorData, VendorLength, Level);
1985 AcpiOsPrintf (")\n");
1986 @@ -503,17 +518,17 @@ AcpiDmPinFunctionDescriptor (
1988 AcpiOsPrintf ("{ // Pin list\n");
1990 - PinCount = ((UINT32) (Resource->PinFunction.ResSourceOffset -
1991 - Resource->PinFunction.PinTableOffset)) /
1993 + PinCount = AcpiUtReadUint16 (&Resource->PinFunction.ResSourceOffset);
1994 + PinCount -= AcpiUtReadUint16 (&Resource->PinFunction.PinTableOffset);
1995 + PinCount /= sizeof (UINT16);
1997 PinList = (UINT16 *) ACPI_ADD_PTR (char, Resource,
1998 - Resource->PinFunction.PinTableOffset);
1999 + AcpiUtReadUint16 (&Resource->PinFunction.PinTableOffset));
2001 for (i = 0; i < PinCount; i++)
2003 AcpiDmIndent (Level + 2);
2004 - AcpiOsPrintf ("0x%4.4X%s\n", PinList[i],
2005 + AcpiOsPrintf ("0x%4.4X%s\n", AcpiUtReadUint16 (&(PinList[i])),
2006 ((i + 1) < PinCount) ? "," : "");
2009 @@ -549,7 +564,8 @@ AcpiDmDumpSerialBusVendorData (
2011 case AML_RESOURCE_I2C_SERIALBUSTYPE:
2013 - VendorLength = Resource->CommonSerialBus.TypeDataLength -
2015 + AcpiUtReadUint16 (&Resource->CommonSerialBus.TypeDataLength) -
2016 AML_RESOURCE_I2C_MIN_DATA_LEN;
2018 VendorData = ACPI_ADD_PTR (UINT8, Resource,
2019 @@ -558,7 +574,8 @@ AcpiDmDumpSerialBusVendorData (
2021 case AML_RESOURCE_SPI_SERIALBUSTYPE:
2023 - VendorLength = Resource->CommonSerialBus.TypeDataLength -
2025 + AcpiUtReadUint16 (&Resource->CommonSerialBus.TypeDataLength) -
2026 AML_RESOURCE_SPI_MIN_DATA_LEN;
2028 VendorData = ACPI_ADD_PTR (UINT8, Resource,
2029 @@ -567,7 +584,8 @@ AcpiDmDumpSerialBusVendorData (
2031 case AML_RESOURCE_UART_SERIALBUSTYPE:
2033 - VendorLength = Resource->CommonSerialBus.TypeDataLength -
2035 + AcpiUtReadUint16 (&Resource->CommonSerialBus.TypeDataLength) -
2036 AML_RESOURCE_UART_MIN_DATA_LEN;
2038 VendorData = ACPI_ADD_PTR (UINT8, Resource,
2039 @@ -693,9 +711,9 @@ AcpiDmI2cSerialBusDescriptor (
2041 AcpiDmIndent (Level);
2042 AcpiOsPrintf ("I2cSerialBusV2 (0x%4.4X, %s, 0x%8.8X,\n",
2043 - Resource->I2cSerialBus.SlaveAddress,
2044 + AcpiUtReadUint16 (&Resource->I2cSerialBus.SlaveAddress),
2045 AcpiGbl_SmDecode [ACPI_GET_1BIT_FLAG (Resource->I2cSerialBus.Flags)],
2046 - Resource->I2cSerialBus.ConnectionSpeed);
2047 + AcpiUtReadUint32 (&Resource->I2cSerialBus.ConnectionSpeed));
2049 AcpiDmIndent (Level + 1);
2050 AcpiOsPrintf ("%s, ",
2051 @@ -704,7 +722,7 @@ AcpiDmI2cSerialBusDescriptor (
2052 /* ResourceSource is a required field */
2054 ResourceSourceOffset = sizeof (AML_RESOURCE_COMMON_SERIALBUS) +
2055 - Resource->CommonSerialBus.TypeDataLength;
2056 + AcpiUtReadUint16 (&Resource->CommonSerialBus.TypeDataLength);
2058 DeviceName = ACPI_ADD_PTR (char, Resource, ResourceSourceOffset);
2059 AcpiUtPrintString (DeviceName, ACPI_UINT16_MAX);
2060 @@ -761,15 +779,17 @@ AcpiDmSpiSerialBusDescriptor (
2062 UINT32 ResourceSourceOffset;
2067 /* DeviceSelection, DeviceSelectionPolarity, WireMode, DataBitLength */
2069 AcpiDmIndent (Level);
2070 + Tmp16 = AcpiUtReadUint16 (&Resource->SpiSerialBus.TypeSpecificFlags);
2071 AcpiOsPrintf ("SpiSerialBusV2 (0x%4.4X, %s, %s, 0x%2.2X,\n",
2072 - Resource->SpiSerialBus.DeviceSelection,
2073 - AcpiGbl_DpDecode [ACPI_EXTRACT_1BIT_FLAG (Resource->SpiSerialBus.TypeSpecificFlags, 1)],
2074 - AcpiGbl_WmDecode [ACPI_GET_1BIT_FLAG (Resource->SpiSerialBus.TypeSpecificFlags)],
2075 + AcpiUtReadUint16 (&Resource->SpiSerialBus.DeviceSelection),
2076 + AcpiGbl_DpDecode [ACPI_EXTRACT_1BIT_FLAG (Tmp16, 1)],
2077 + AcpiGbl_WmDecode [ACPI_GET_1BIT_FLAG (Tmp16)],
2078 Resource->SpiSerialBus.DataBitLength);
2080 /* SlaveMode, ConnectionSpeed, ClockPolarity, ClockPhase */
2081 @@ -777,7 +797,7 @@ AcpiDmSpiSerialBusDescriptor (
2082 AcpiDmIndent (Level + 1);
2083 AcpiOsPrintf ("%s, 0x%8.8X, %s,\n",
2084 AcpiGbl_SmDecode [ACPI_GET_1BIT_FLAG (Resource->SpiSerialBus.Flags)],
2085 - Resource->SpiSerialBus.ConnectionSpeed,
2086 + AcpiUtReadUint32 (&Resource->SpiSerialBus.ConnectionSpeed),
2087 AcpiGbl_CpoDecode [ACPI_GET_1BIT_FLAG (Resource->SpiSerialBus.ClockPolarity)]);
2089 AcpiDmIndent (Level + 1);
2090 @@ -787,7 +807,7 @@ AcpiDmSpiSerialBusDescriptor (
2091 /* ResourceSource is a required field */
2093 ResourceSourceOffset = sizeof (AML_RESOURCE_COMMON_SERIALBUS) +
2094 - Resource->CommonSerialBus.TypeDataLength;
2095 + AcpiUtReadUint16 (&Resource->CommonSerialBus.TypeDataLength);
2097 DeviceName = ACPI_ADD_PTR (char, Resource, ResourceSourceOffset);
2098 AcpiUtPrintString (DeviceName, ACPI_UINT16_MAX);
2099 @@ -844,15 +864,17 @@ AcpiDmUartSerialBusDescriptor (
2101 UINT32 ResourceSourceOffset;
2106 /* ConnectionSpeed, BitsPerByte, StopBits */
2108 AcpiDmIndent (Level);
2109 + Tmp16 = AcpiUtReadUint16 (&Resource->UartSerialBus.TypeSpecificFlags);
2110 AcpiOsPrintf ("UartSerialBusV2 (0x%8.8X, %s, %s,\n",
2111 - Resource->UartSerialBus.DefaultBaudRate,
2112 - AcpiGbl_BpbDecode [ACPI_EXTRACT_3BIT_FLAG (Resource->UartSerialBus.TypeSpecificFlags, 4)],
2113 - AcpiGbl_SbDecode [ACPI_EXTRACT_2BIT_FLAG (Resource->UartSerialBus.TypeSpecificFlags, 2)]);
2114 + AcpiUtReadUint32 (&Resource->UartSerialBus.DefaultBaudRate),
2115 + AcpiGbl_BpbDecode [ACPI_EXTRACT_3BIT_FLAG (Tmp16, 4)],
2116 + AcpiGbl_SbDecode [ACPI_EXTRACT_2BIT_FLAG (Tmp16, 2)]);
2118 /* LinesInUse, IsBigEndian, Parity, FlowControl */
2120 @@ -867,13 +889,13 @@ AcpiDmUartSerialBusDescriptor (
2122 AcpiDmIndent (Level + 1);
2123 AcpiOsPrintf ("0x%4.4X, 0x%4.4X, ",
2124 - Resource->UartSerialBus.RxFifoSize,
2125 - Resource->UartSerialBus.TxFifoSize);
2126 + AcpiUtReadUint16 (&Resource->UartSerialBus.RxFifoSize),
2127 + AcpiUtReadUint16 (&Resource->UartSerialBus.TxFifoSize));
2129 /* ResourceSource is a required field */
2131 ResourceSourceOffset = sizeof (AML_RESOURCE_COMMON_SERIALBUS) +
2132 - Resource->CommonSerialBus.TypeDataLength;
2133 + AcpiUtReadUint16 (&Resource->CommonSerialBus.TypeDataLength);
2135 DeviceName = ACPI_ADD_PTR (char, Resource, ResourceSourceOffset);
2136 AcpiUtPrintString (DeviceName, ACPI_UINT16_MAX);
2137 Index: acpica-unix2-20220331/source/components/disassembler/dmresrcs.c
2138 ===================================================================
2139 --- acpica-unix2-20220331.orig/source/components/disassembler/dmresrcs.c
2140 +++ acpica-unix2-20220331/source/components/disassembler/dmresrcs.c
2141 @@ -93,7 +93,7 @@ AcpiDmIrqDescriptor (
2142 AcpiOsPrintf (")\n");
2144 AcpiDmIndent (Level + 1);
2145 - AcpiDmBitList (Resource->Irq.IrqMask);
2146 + AcpiDmBitList (AcpiUtReadUint16 (&Resource->Irq.IrqMask));
2150 @@ -161,8 +161,8 @@ AcpiDmFixedDmaDescriptor (
2152 AcpiDmIndent (Level);
2153 AcpiOsPrintf ("FixedDMA (0x%4.4X, 0x%4.4X, ",
2154 - Resource->FixedDma.RequestLines,
2155 - Resource->FixedDma.Channels);
2156 + AcpiUtReadUint16 (&Resource->FixedDma.RequestLines),
2157 + AcpiUtReadUint16 (&Resource->FixedDma.Channels));
2159 if (Resource->FixedDma.Width <= 5)
2161 @@ -210,10 +210,12 @@ AcpiDmIoDescriptor (
2162 AcpiGbl_IoDecode [ACPI_GET_1BIT_FLAG (Resource->Io.Flags)]);
2164 AcpiDmIndent (Level + 1);
2165 - AcpiDmDumpInteger16 (Resource->Io.Minimum, "Range Minimum");
2166 + AcpiDmDumpInteger16 (AcpiUtReadUint16 (&Resource->Io.Minimum),
2169 AcpiDmIndent (Level + 1);
2170 - AcpiDmDumpInteger16 (Resource->Io.Maximum, "Range Maximum");
2171 + AcpiDmDumpInteger16 (AcpiUtReadUint16 (&Resource->Io.Maximum),
2174 AcpiDmIndent (Level + 1);
2175 AcpiDmDumpInteger8 (Resource->Io.Alignment, "Alignment");
2176 @@ -256,10 +258,12 @@ AcpiDmFixedIoDescriptor (
2177 AcpiOsPrintf ("FixedIO (\n");
2179 AcpiDmIndent (Level + 1);
2180 - AcpiDmDumpInteger16 (Resource->FixedIo.Address, "Address");
2181 + AcpiDmDumpInteger16 (AcpiUtReadUint16 (&Resource->FixedIo.Address),
2184 AcpiDmIndent (Level + 1);
2185 - AcpiDmDumpInteger8 (Resource->FixedIo.AddressLength, "Length");
2186 + AcpiDmDumpInteger8 (AcpiUtReadUint16 (&Resource->FixedIo.AddressLength),
2189 /* Insert a descriptor name */
2191 Index: acpica-unix2-20220331/source/components/disassembler/dmwalk.c
2192 ===================================================================
2193 --- acpica-unix2-20220331.orig/source/components/disassembler/dmwalk.c
2194 +++ acpica-unix2-20220331/source/components/disassembler/dmwalk.c
2195 @@ -1163,7 +1163,7 @@ AcpiDmAscendingOp (
2197 ParentOp->Common.DisasmFlags |= ACPI_PARSEOP_EMPTY_TERMLIST;
2198 ASL_CV_CLOSE_PAREN (Op, Level);
2199 - AcpiOsPrintf ("{");
2200 + AcpiOsPrintf (" {");
2204 Index: acpica-unix2-20220331/source/components/namespace/nsaccess.c
2205 ===================================================================
2206 --- acpica-unix2-20220331.orig/source/components/namespace/nsaccess.c
2207 +++ acpica-unix2-20220331/source/components/namespace/nsaccess.c
2208 @@ -644,7 +644,7 @@ AcpiNsLookup (
2210 /* Extract one ACPI name from the front of the pathname */
2212 - ACPI_MOVE_32_TO_32 (&SimpleName, Path);
2213 + ACPI_COPY_NAMESEG (&SimpleName, Path);
2215 /* Try to find the single (4 character) ACPI name */
2217 Index: acpica-unix2-20220331/source/components/namespace/nsnames.c
2218 ===================================================================
2219 --- acpica-unix2-20220331.orig/source/components/namespace/nsnames.c
2220 +++ acpica-unix2-20220331/source/components/namespace/nsnames.c
2221 @@ -297,10 +297,10 @@ AcpiNsBuildNormalizedPath (
2223 if (NextNode != Node)
2225 - ACPI_PATH_PUT8(FullPath, PathSize, AML_DUAL_NAME_PREFIX, Length);
2226 + ACPI_PATH_PUT8 (FullPath, PathSize, AML_DUAL_NAME_PREFIX, Length);
2229 - ACPI_MOVE_32_TO_32 (Name, &NextNode->Name);
2230 + ACPI_COPY_NAMESEG (Name, &NextNode->Name);
2231 DoNoTrailing = NoTrailing;
2232 for (i = 0; i < 4; i++)
2234 Index: acpica-unix2-20220331/source/components/namespace/nsparse.c
2235 ===================================================================
2236 --- acpica-unix2-20220331.orig/source/components/namespace/nsparse.c
2237 +++ acpica-unix2-20220331/source/components/namespace/nsparse.c
2238 @@ -203,6 +203,7 @@ AcpiNsOneCompleteParse (
2239 ACPI_WALK_STATE *WalkState;
2240 ACPI_TABLE_HEADER *Table;
2241 ACPI_OWNER_ID OwnerId;
2242 + UINT32 TableLength;
2245 ACPI_FUNCTION_TRACE (NsOneCompleteParse);
2246 @@ -216,13 +217,14 @@ AcpiNsOneCompleteParse (
2248 /* Table must consist of at least a complete header */
2250 - if (Table->Length < sizeof (ACPI_TABLE_HEADER))
2251 + TableLength = AcpiUtReadUint32 (&Table->Length);
2252 + if (TableLength < sizeof (ACPI_TABLE_HEADER))
2254 return_ACPI_STATUS (AE_BAD_HEADER);
2257 AmlStart = (UINT8 *) Table + sizeof (ACPI_TABLE_HEADER);
2258 - AmlLength = Table->Length - sizeof (ACPI_TABLE_HEADER);
2259 + AmlLength = TableLength - sizeof (ACPI_TABLE_HEADER);
2261 Status = AcpiTbGetOwnerId (TableIndex, &OwnerId);
2262 if (ACPI_FAILURE (Status))
2263 Index: acpica-unix2-20220331/source/components/namespace/nsutils.c
2264 ===================================================================
2265 --- acpica-unix2-20220331.orig/source/components/namespace/nsutils.c
2266 +++ acpica-unix2-20220331/source/components/namespace/nsutils.c
2267 @@ -272,7 +272,6 @@ AcpiNsBuildInternalName (
2268 const char *ExternalName = Info->NextExternalChar;
2269 char *Result = NULL;
2271 - char TmpSeg[ACPI_NAMESEG_SIZE+1];
2274 ACPI_FUNCTION_TRACE (NsBuildInternalName);
2275 @@ -336,7 +335,6 @@ AcpiNsBuildInternalName (
2277 for (; NumSegments; NumSegments--)
2279 - memset (TmpSeg, 0, ACPI_NAMESEG_SIZE+1);
2280 for (i = 0; i < ACPI_NAMESEG_SIZE; i++)
2282 if (ACPI_IS_PATH_SEPARATOR (*ExternalName) ||
2283 @@ -344,17 +342,16 @@ AcpiNsBuildInternalName (
2285 /* Pad the segment with underscore(s) if segment is short */
2292 /* Convert the character to uppercase and save it */
2294 - TmpSeg[i] = (char) toupper ((int) *ExternalName);
2295 + Result[i] = (char) toupper ((int) *ExternalName);
2299 - AcpiUtWriteUint (Result, ACPI_NAMESEG_SIZE, TmpSeg, ACPI_NAMESEG_SIZE);
2301 /* Now we must have a path separator, or the pathname is bad */
2303 Index: acpica-unix2-20220331/source/components/utilities/utresrc.c
2304 ===================================================================
2305 --- acpica-unix2-20220331.orig/source/components/utilities/utresrc.c
2306 +++ acpica-unix2-20220331/source/components/utilities/utresrc.c
2307 @@ -541,7 +541,7 @@ AcpiUtGetResourceLength (
2309 /* Large Resource type -- bytes 1-2 contain the 16-bit length */
2311 - ACPI_MOVE_16_TO_16 (&ResourceLength, ACPI_ADD_PTR (UINT8, Aml, 1));
2312 + ResourceLength = AcpiUtReadUint16 (ACPI_ADD_PTR (UINT8, Aml, 1));
2316 Index: acpica-unix2-20220331/source/compiler/aslrestype2e.c
2317 ===================================================================
2318 --- acpica-unix2-20220331.orig/source/compiler/aslrestype2e.c
2319 +++ acpica-unix2-20220331/source/compiler/aslrestype2e.c
2320 @@ -80,6 +80,7 @@ RsDoExtendedIoDescriptor (
2321 UINT16 StringLength = 0;
2322 UINT32 CurrentByteOffset;
2327 InitializerOp = Info->DescriptorTypeOp->Asl.Child;
2328 @@ -139,7 +140,8 @@ RsDoExtendedIoDescriptor (
2330 case 5: /* Address Granularity */
2332 - Descriptor->ExtAddress64.Granularity = InitializerOp->Asl.Value.Integer;
2333 + Descriptor->ExtAddress64.Granularity =
2334 + AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
2335 RsCreateQwordField (InitializerOp, ACPI_RESTAG_GRANULARITY,
2336 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Granularity));
2337 GranOp = InitializerOp;
2338 @@ -147,7 +149,8 @@ RsDoExtendedIoDescriptor (
2340 case 6: /* Address Min */
2342 - Descriptor->ExtAddress64.Minimum = InitializerOp->Asl.Value.Integer;
2343 + Descriptor->ExtAddress64.Minimum =
2344 + AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
2345 RsCreateQwordField (InitializerOp, ACPI_RESTAG_MINADDR,
2346 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Minimum));
2347 MinOp = InitializerOp;
2348 @@ -155,7 +158,8 @@ RsDoExtendedIoDescriptor (
2350 case 7: /* Address Max */
2352 - Descriptor->ExtAddress64.Maximum = InitializerOp->Asl.Value.Integer;
2353 + Descriptor->ExtAddress64.Maximum =
2354 + AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
2355 RsCreateQwordField (InitializerOp, ACPI_RESTAG_MAXADDR,
2356 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Maximum));
2357 MaxOp = InitializerOp;
2358 @@ -163,14 +167,16 @@ RsDoExtendedIoDescriptor (
2360 case 8: /* Translation Offset */
2362 - Descriptor->ExtAddress64.TranslationOffset = InitializerOp->Asl.Value.Integer;
2363 + Descriptor->ExtAddress64.TranslationOffset =
2364 + AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
2365 RsCreateQwordField (InitializerOp, ACPI_RESTAG_TRANSLATION,
2366 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.TranslationOffset));
2369 case 9: /* Address Length */
2371 - Descriptor->ExtAddress64.AddressLength = InitializerOp->Asl.Value.Integer;
2372 + Descriptor->ExtAddress64.AddressLength =
2373 + AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
2374 RsCreateQwordField (InitializerOp, ACPI_RESTAG_LENGTH,
2375 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.AddressLength));
2376 LengthOp = InitializerOp;
2377 @@ -178,7 +184,8 @@ RsDoExtendedIoDescriptor (
2379 case 10: /* Type-Specific Attributes */
2381 - Descriptor->ExtAddress64.TypeSpecific = InitializerOp->Asl.Value.Integer;
2382 + Descriptor->ExtAddress64.TypeSpecific =
2383 + AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
2384 RsCreateQwordField (InitializerOp, ACPI_RESTAG_TYPESPECIFICATTRIBUTES,
2385 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.TypeSpecific));
2387 @@ -213,11 +220,14 @@ RsDoExtendedIoDescriptor (
2389 /* Validate the Min/Max/Len/Gran values */
2391 + Tmp16 = Descriptor->ExtAddress64.ResourceLength;
2392 + Descriptor->ExtAddress64.ResourceLength = AcpiUtReadUint16 (&Tmp16);
2394 RsLargeAddressCheck (
2395 - Descriptor->ExtAddress64.Minimum,
2396 - Descriptor->ExtAddress64.Maximum,
2397 - Descriptor->ExtAddress64.AddressLength,
2398 - Descriptor->ExtAddress64.Granularity,
2399 + AcpiUtReadUint64 (&Descriptor->ExtAddress64.Minimum),
2400 + AcpiUtReadUint64 (&Descriptor->ExtAddress64.Maximum),
2401 + AcpiUtReadUint64 (&Descriptor->ExtAddress64.AddressLength),
2402 + AcpiUtReadUint64 (&Descriptor->ExtAddress64.Granularity),
2403 Descriptor->ExtAddress64.Flags,
2404 MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp);
2406 @@ -253,6 +263,7 @@ RsDoExtendedMemoryDescriptor (
2407 UINT16 StringLength = 0;
2408 UINT32 CurrentByteOffset;
2413 InitializerOp = Info->DescriptorTypeOp->Asl.Child;
2414 @@ -319,7 +330,8 @@ RsDoExtendedMemoryDescriptor (
2416 case 6: /* Address Granularity */
2418 - Descriptor->ExtAddress64.Granularity = InitializerOp->Asl.Value.Integer;
2419 + Descriptor->ExtAddress64.Granularity =
2420 + AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
2421 RsCreateQwordField (InitializerOp, ACPI_RESTAG_GRANULARITY,
2422 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Granularity));
2423 GranOp = InitializerOp;
2424 @@ -327,7 +339,8 @@ RsDoExtendedMemoryDescriptor (
2426 case 7: /* Min Address */
2428 - Descriptor->ExtAddress64.Minimum = InitializerOp->Asl.Value.Integer;
2429 + Descriptor->ExtAddress64.Minimum =
2430 + AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
2431 RsCreateQwordField (InitializerOp, ACPI_RESTAG_MINADDR,
2432 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Minimum));
2433 MinOp = InitializerOp;
2434 @@ -335,7 +348,8 @@ RsDoExtendedMemoryDescriptor (
2436 case 8: /* Max Address */
2438 - Descriptor->ExtAddress64.Maximum = InitializerOp->Asl.Value.Integer;
2439 + Descriptor->ExtAddress64.Maximum =
2440 + AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
2441 RsCreateQwordField (InitializerOp, ACPI_RESTAG_MAXADDR,
2442 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Maximum));
2443 MaxOp = InitializerOp;
2444 @@ -343,14 +357,16 @@ RsDoExtendedMemoryDescriptor (
2446 case 9: /* Translation Offset */
2448 - Descriptor->ExtAddress64.TranslationOffset = InitializerOp->Asl.Value.Integer;
2449 + Descriptor->ExtAddress64.TranslationOffset =
2450 + AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
2451 RsCreateQwordField (InitializerOp, ACPI_RESTAG_TRANSLATION,
2452 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.TranslationOffset));
2455 case 10: /* Address Length */
2457 - Descriptor->ExtAddress64.AddressLength = InitializerOp->Asl.Value.Integer;
2458 + Descriptor->ExtAddress64.AddressLength =
2459 + AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
2460 RsCreateQwordField (InitializerOp, ACPI_RESTAG_LENGTH,
2461 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.AddressLength));
2462 LengthOp = InitializerOp;
2463 @@ -358,7 +374,8 @@ RsDoExtendedMemoryDescriptor (
2465 case 11: /* Type-Specific Attributes */
2467 - Descriptor->ExtAddress64.TypeSpecific = InitializerOp->Asl.Value.Integer;
2468 + Descriptor->ExtAddress64.TypeSpecific =
2469 + AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
2470 RsCreateQwordField (InitializerOp, ACPI_RESTAG_TYPESPECIFICATTRIBUTES,
2471 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.TypeSpecific));
2473 @@ -394,11 +411,14 @@ RsDoExtendedMemoryDescriptor (
2475 /* Validate the Min/Max/Len/Gran values */
2477 + Tmp16 = Descriptor->ExtAddress64.ResourceLength;
2478 + Descriptor->ExtAddress64.ResourceLength = AcpiUtReadUint16 (&Tmp16);
2480 RsLargeAddressCheck (
2481 - Descriptor->ExtAddress64.Minimum,
2482 - Descriptor->ExtAddress64.Maximum,
2483 - Descriptor->ExtAddress64.AddressLength,
2484 - Descriptor->ExtAddress64.Granularity,
2485 + AcpiUtReadUint64 (&Descriptor->ExtAddress64.Minimum),
2486 + AcpiUtReadUint64 (&Descriptor->ExtAddress64.Maximum),
2487 + AcpiUtReadUint64 (&Descriptor->ExtAddress64.AddressLength),
2488 + AcpiUtReadUint64 (&Descriptor->ExtAddress64.Granularity),
2489 Descriptor->ExtAddress64.Flags,
2490 MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp);
2492 @@ -434,6 +454,7 @@ RsDoExtendedSpaceDescriptor (
2493 UINT16 StringLength = 0;
2494 UINT32 CurrentByteOffset;
2499 InitializerOp = Info->DescriptorTypeOp->Asl.Child;
2500 @@ -497,7 +518,8 @@ RsDoExtendedSpaceDescriptor (
2502 case 6: /* Address Granularity */
2504 - Descriptor->ExtAddress64.Granularity = InitializerOp->Asl.Value.Integer;
2505 + Descriptor->ExtAddress64.Granularity =
2506 + AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
2507 RsCreateQwordField (InitializerOp, ACPI_RESTAG_GRANULARITY,
2508 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Granularity));
2509 GranOp = InitializerOp;
2510 @@ -505,7 +527,8 @@ RsDoExtendedSpaceDescriptor (
2512 case 7: /* Min Address */
2514 - Descriptor->ExtAddress64.Minimum = InitializerOp->Asl.Value.Integer;
2515 + Descriptor->ExtAddress64.Minimum =
2516 + AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
2517 RsCreateQwordField (InitializerOp, ACPI_RESTAG_MINADDR,
2518 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Minimum));
2519 MinOp = InitializerOp;
2520 @@ -513,7 +536,8 @@ RsDoExtendedSpaceDescriptor (
2522 case 8: /* Max Address */
2524 - Descriptor->ExtAddress64.Maximum = InitializerOp->Asl.Value.Integer;
2525 + Descriptor->ExtAddress64.Maximum =
2526 + AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
2527 RsCreateQwordField (InitializerOp, ACPI_RESTAG_MAXADDR,
2528 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Maximum));
2529 MaxOp = InitializerOp;
2530 @@ -521,14 +545,16 @@ RsDoExtendedSpaceDescriptor (
2532 case 9: /* Translation Offset */
2534 - Descriptor->ExtAddress64.TranslationOffset = InitializerOp->Asl.Value.Integer;
2535 + Descriptor->ExtAddress64.TranslationOffset =
2536 + AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
2537 RsCreateQwordField (InitializerOp, ACPI_RESTAG_TRANSLATION,
2538 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.TranslationOffset));
2541 case 10: /* Address Length */
2543 - Descriptor->ExtAddress64.AddressLength = InitializerOp->Asl.Value.Integer;
2544 + Descriptor->ExtAddress64.AddressLength =
2545 + AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
2546 RsCreateQwordField (InitializerOp, ACPI_RESTAG_LENGTH,
2547 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.AddressLength));
2548 LengthOp = InitializerOp;
2549 @@ -536,7 +562,8 @@ RsDoExtendedSpaceDescriptor (
2551 case 11: /* Type-Specific Attributes */
2553 - Descriptor->ExtAddress64.TypeSpecific = InitializerOp->Asl.Value.Integer;
2554 + Descriptor->ExtAddress64.TypeSpecific =
2555 + AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
2556 RsCreateQwordField (InitializerOp, ACPI_RESTAG_TYPESPECIFICATTRIBUTES,
2557 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.TypeSpecific));
2559 @@ -557,11 +584,14 @@ RsDoExtendedSpaceDescriptor (
2561 /* Validate the Min/Max/Len/Gran values */
2563 + Tmp16 = Descriptor->ExtAddress64.ResourceLength;
2564 + Descriptor->ExtAddress64.ResourceLength = AcpiUtReadUint16 (&Tmp16);
2566 RsLargeAddressCheck (
2567 - Descriptor->ExtAddress64.Minimum,
2568 - Descriptor->ExtAddress64.Maximum,
2569 - Descriptor->ExtAddress64.AddressLength,
2570 - Descriptor->ExtAddress64.Granularity,
2571 + AcpiUtReadUint64 (&Descriptor->ExtAddress64.Minimum),
2572 + AcpiUtReadUint64 (&Descriptor->ExtAddress64.Maximum),
2573 + AcpiUtReadUint64 (&Descriptor->ExtAddress64.AddressLength),
2574 + AcpiUtReadUint64 (&Descriptor->ExtAddress64.Granularity),
2575 Descriptor->ExtAddress64.Flags,
2576 MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp);
2578 Index: acpica-unix2-20220331/source/compiler/aslrestype2s.c
2579 ===================================================================
2580 --- acpica-unix2-20220331.orig/source/compiler/aslrestype2s.c
2581 +++ acpica-unix2-20220331/source/compiler/aslrestype2s.c
2582 @@ -343,6 +343,7 @@ RsDoGpioIntDescriptor (
2583 UINT32 CurrentByteOffset;
2584 UINT32 PinCount = 0;
2589 InitializerOp = Info->DescriptorTypeOp->Asl.Child;
2590 @@ -485,7 +486,8 @@ RsDoGpioIntDescriptor (
2591 * (implies resource source must immediately follow the pin list.)
2594 - *InterruptList = (UINT16) InitializerOp->Asl.Value.Integer;
2595 + Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
2596 + *InterruptList = AcpiUtReadUint16 (&Tmp16);
2600 @@ -518,6 +520,27 @@ RsDoGpioIntDescriptor (
2602 MpSaveGpioInfo (Info->MappingOp, Descriptor,
2603 PinCount, PinList, ResourceSource);
2605 + /* correct endian-ness issues */
2606 + Tmp16 = Descriptor->Gpio.ResourceLength;
2607 + Descriptor->Gpio.ResourceLength = AcpiUtReadUint16 (&Tmp16);
2608 + Tmp16 = Descriptor->Gpio.Flags;
2609 + Descriptor->Gpio.Flags = AcpiUtReadUint16 (&Tmp16);
2610 + Tmp16 = Descriptor->Gpio.IntFlags;
2611 + Descriptor->Gpio.IntFlags = AcpiUtReadUint16 (&Tmp16);
2612 + Tmp16 = Descriptor->Gpio.DriveStrength;
2613 + Descriptor->Gpio.DriveStrength = AcpiUtReadUint16 (&Tmp16);
2614 + Tmp16 = Descriptor->Gpio.DebounceTimeout;
2615 + Descriptor->Gpio.DebounceTimeout = AcpiUtReadUint16 (&Tmp16);
2616 + Tmp16 = Descriptor->Gpio.PinTableOffset;
2617 + Descriptor->Gpio.PinTableOffset = AcpiUtReadUint16 (&Tmp16);
2618 + Tmp16 = Descriptor->Gpio.ResSourceOffset;
2619 + Descriptor->Gpio.ResSourceOffset = AcpiUtReadUint16 (&Tmp16);
2620 + Tmp16 = Descriptor->Gpio.VendorOffset;
2621 + Descriptor->Gpio.VendorOffset = AcpiUtReadUint16 (&Tmp16);
2622 + Tmp16 = Descriptor->Gpio.VendorLength;
2623 + Descriptor->Gpio.VendorLength = AcpiUtReadUint16 (&Tmp16);
2628 @@ -552,6 +575,7 @@ RsDoGpioIoDescriptor (
2629 UINT32 CurrentByteOffset;
2630 UINT32 PinCount = 0;
2635 InitializerOp = Info->DescriptorTypeOp->Asl.Child;
2636 @@ -691,7 +715,8 @@ RsDoGpioIoDescriptor (
2637 * (implies resource source must immediately follow the pin list.)
2640 - *InterruptList = (UINT16) InitializerOp->Asl.Value.Integer;
2641 + Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
2642 + *InterruptList = AcpiUtReadUint16 (&Tmp16);
2646 @@ -724,6 +749,27 @@ RsDoGpioIoDescriptor (
2648 MpSaveGpioInfo (Info->MappingOp, Descriptor,
2649 PinCount, PinList, ResourceSource);
2651 + /* correct endian-ness issues */
2652 + Tmp16 = Descriptor->Gpio.ResourceLength;
2653 + Descriptor->Gpio.ResourceLength = AcpiUtReadUint16 (&Tmp16);
2654 + Tmp16 = Descriptor->Gpio.Flags;
2655 + Descriptor->Gpio.Flags = AcpiUtReadUint16 (&Tmp16);
2656 + Tmp16 = Descriptor->Gpio.IntFlags;
2657 + Descriptor->Gpio.IntFlags = AcpiUtReadUint16 (&Tmp16);
2658 + Tmp16 = Descriptor->Gpio.DriveStrength;
2659 + Descriptor->Gpio.DriveStrength = AcpiUtReadUint16 (&Tmp16);
2660 + Tmp16 = Descriptor->Gpio.DebounceTimeout;
2661 + Descriptor->Gpio.DebounceTimeout = AcpiUtReadUint16 (&Tmp16);
2662 + Tmp16 = Descriptor->Gpio.PinTableOffset;
2663 + Descriptor->Gpio.PinTableOffset = AcpiUtReadUint16 (&Tmp16);
2664 + Tmp16 = Descriptor->Gpio.ResSourceOffset;
2665 + Descriptor->Gpio.ResSourceOffset = AcpiUtReadUint16 (&Tmp16);
2666 + Tmp16 = Descriptor->Gpio.VendorOffset;
2667 + Descriptor->Gpio.VendorOffset = AcpiUtReadUint16 (&Tmp16);
2668 + Tmp16 = Descriptor->Gpio.VendorLength;
2669 + Descriptor->Gpio.VendorLength = AcpiUtReadUint16 (&Tmp16);
2674 @@ -754,6 +800,8 @@ RsDoI2cSerialBusDescriptor (
2675 UINT16 DescriptorSize;
2676 UINT32 CurrentByteOffset;
2682 InitializerOp = Info->DescriptorTypeOp->Asl.Child;
2683 @@ -781,7 +829,8 @@ RsDoI2cSerialBusDescriptor (
2684 Descriptor->I2cSerialBus.RevisionId = AML_RESOURCE_I2C_REVISION;
2685 Descriptor->I2cSerialBus.TypeRevisionId = AML_RESOURCE_I2C_TYPE_REVISION;
2686 Descriptor->I2cSerialBus.Type = AML_RESOURCE_I2C_SERIALBUSTYPE;
2687 - Descriptor->I2cSerialBus.TypeDataLength = AML_RESOURCE_I2C_MIN_DATA_LEN + VendorLength;
2688 + Tmp16 = AML_RESOURCE_I2C_MIN_DATA_LEN + VendorLength;
2689 + Descriptor->I2cSerialBus.TypeDataLength = AcpiUtReadUint16 (&Tmp16);
2691 if (Info->DescriptorTypeOp->Asl.ParseOpcode == PARSEOP_I2C_SERIALBUS_V2)
2693 @@ -795,13 +844,15 @@ RsDoI2cSerialBusDescriptor (
2695 /* Process all child initialization nodes */
2697 + Descriptor->I2cSerialBus.TypeSpecificFlags = 0;
2698 for (i = 0; InitializerOp; i++)
2702 case 0: /* Slave Address [WORD] (_ADR) */
2704 - Descriptor->I2cSerialBus.SlaveAddress = (UINT16) InitializerOp->Asl.Value.Integer;
2705 + Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
2706 + Descriptor->I2cSerialBus.SlaveAddress = AcpiUtReadUint16 (&Tmp16);
2707 RsCreateWordField (InitializerOp, ACPI_RESTAG_ADDRESS,
2708 CurrentByteOffset + ASL_RESDESC_OFFSET (I2cSerialBus.SlaveAddress));
2710 @@ -815,16 +866,19 @@ RsDoI2cSerialBusDescriptor (
2712 case 2: /* Connection Speed [DWORD] (_SPE) */
2714 - Descriptor->I2cSerialBus.ConnectionSpeed = (UINT32) InitializerOp->Asl.Value.Integer;
2715 + Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
2716 + Descriptor->I2cSerialBus.ConnectionSpeed = AcpiUtReadUint32 (&Tmp32);
2717 RsCreateDwordField (InitializerOp, ACPI_RESTAG_SPEED,
2718 CurrentByteOffset + ASL_RESDESC_OFFSET (I2cSerialBus.ConnectionSpeed));
2721 case 3: /* Addressing Mode [Flag] (_MOD) */
2723 - RsSetFlagBits16 (&Descriptor->I2cSerialBus.TypeSpecificFlags, InitializerOp, 0, 0);
2724 + Tmp16 = AcpiUtReadUint16 (&Descriptor->I2cSerialBus.TypeSpecificFlags);
2725 + RsSetFlagBits16 (&Tmp16, InitializerOp, 0, 0);
2726 RsCreateBitField (InitializerOp, ACPI_RESTAG_MODE,
2727 CurrentByteOffset + ASL_RESDESC_OFFSET (I2cSerialBus.TypeSpecificFlags), 0);
2728 + Descriptor->I2cSerialBus.TypeSpecificFlags = AcpiUtReadUint16 (&Tmp16);
2731 case 4: /* ResSource [Optional Field - STRING] */
2732 @@ -882,6 +936,8 @@ RsDoI2cSerialBusDescriptor (
2733 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
2736 + Tmp16 = Descriptor->I2cSerialBus.ResourceLength;
2737 + Descriptor->I2cSerialBus.ResourceLength = AcpiUtReadUint16 (&Tmp16);
2738 MpSaveSerialInfo (Info->MappingOp, Descriptor, ResourceSource);
2741 @@ -913,6 +969,8 @@ RsDoSpiSerialBusDescriptor (
2742 UINT16 DescriptorSize;
2743 UINT32 CurrentByteOffset;
2749 InitializerOp = Info->DescriptorTypeOp->Asl.Child;
2750 @@ -935,12 +993,13 @@ RsDoSpiSerialBusDescriptor (
2751 sizeof (AML_RESOURCE_LARGE_HEADER));
2753 Descriptor = Rnode->Buffer;
2754 - Descriptor->SpiSerialBus.ResourceLength = DescriptorSize;
2755 + Descriptor->SpiSerialBus.ResourceLength = AcpiUtReadUint16 (&DescriptorSize);
2756 Descriptor->SpiSerialBus.DescriptorType = ACPI_RESOURCE_NAME_SERIAL_BUS;
2757 Descriptor->SpiSerialBus.RevisionId = AML_RESOURCE_SPI_REVISION;
2758 Descriptor->SpiSerialBus.TypeRevisionId = AML_RESOURCE_SPI_TYPE_REVISION;
2759 Descriptor->SpiSerialBus.Type = AML_RESOURCE_SPI_SERIALBUSTYPE;
2760 - Descriptor->SpiSerialBus.TypeDataLength = AML_RESOURCE_SPI_MIN_DATA_LEN + VendorLength;
2761 + Tmp16 = AML_RESOURCE_SPI_MIN_DATA_LEN + VendorLength;
2762 + Descriptor->SpiSerialBus.TypeDataLength = AcpiUtReadUint16 (&Tmp16);
2764 if (Info->DescriptorTypeOp->Asl.ParseOpcode == PARSEOP_SPI_SERIALBUS_V2)
2766 @@ -955,29 +1014,35 @@ RsDoSpiSerialBusDescriptor (
2768 /* Process all child initialization nodes */
2770 + Descriptor->SpiSerialBus.TypeSpecificFlags = 0;
2771 for (i = 0; InitializerOp; i++)
2775 case 0: /* Device Selection [WORD] (_ADR) */
2777 - Descriptor->SpiSerialBus.DeviceSelection = (UINT16) InitializerOp->Asl.Value.Integer;
2778 + Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
2779 + Descriptor->SpiSerialBus.DeviceSelection = AcpiUtReadUint16 (&Tmp16);
2780 RsCreateWordField (InitializerOp, ACPI_RESTAG_ADDRESS,
2781 CurrentByteOffset + ASL_RESDESC_OFFSET (SpiSerialBus.DeviceSelection));
2784 case 1: /* Device Polarity [Flag] (_DPL) */
2786 - RsSetFlagBits16 (&Descriptor->SpiSerialBus.TypeSpecificFlags, InitializerOp, 1, 0);
2787 + Tmp16 = AcpiUtReadUint16 (&Descriptor->SpiSerialBus.TypeSpecificFlags);
2788 + RsSetFlagBits16 (&Tmp16, InitializerOp, 1, 0);
2789 RsCreateBitField (InitializerOp, ACPI_RESTAG_DEVICEPOLARITY,
2790 CurrentByteOffset + ASL_RESDESC_OFFSET (SpiSerialBus.TypeSpecificFlags), 1);
2791 + Descriptor->SpiSerialBus.TypeSpecificFlags = AcpiUtReadUint16 (&Tmp16);
2794 case 2: /* Wire Mode [Flag] (_MOD) */
2796 - RsSetFlagBits16 (&Descriptor->SpiSerialBus.TypeSpecificFlags, InitializerOp, 0, 0);
2797 + Tmp16 = AcpiUtReadUint16 (&Descriptor->SpiSerialBus.TypeSpecificFlags);
2798 + RsSetFlagBits16 (&Tmp16, InitializerOp, 0, 0);
2799 RsCreateBitField (InitializerOp, ACPI_RESTAG_MODE,
2800 CurrentByteOffset + ASL_RESDESC_OFFSET (SpiSerialBus.TypeSpecificFlags), 0);
2801 + Descriptor->SpiSerialBus.TypeSpecificFlags = AcpiUtReadUint16 (&Tmp16);
2804 case 3: /* Device Bit Length [BYTE] (_LEN) */
2805 @@ -996,7 +1061,8 @@ RsDoSpiSerialBusDescriptor (
2807 case 5: /* Connection Speed [DWORD] (_SPE) */
2809 - Descriptor->SpiSerialBus.ConnectionSpeed = (UINT32) InitializerOp->Asl.Value.Integer;
2810 + Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
2811 + Descriptor->SpiSerialBus.ConnectionSpeed = AcpiUtReadUint32 (&Tmp32);
2812 RsCreateDwordField (InitializerOp, ACPI_RESTAG_SPEED,
2813 CurrentByteOffset + ASL_RESDESC_OFFSET (SpiSerialBus.ConnectionSpeed));
2815 @@ -1101,6 +1167,8 @@ RsDoUartSerialBusDescriptor (
2816 UINT16 DescriptorSize;
2817 UINT32 CurrentByteOffset;
2823 InitializerOp = Info->DescriptorTypeOp->Asl.Child;
2824 @@ -1123,12 +1191,13 @@ RsDoUartSerialBusDescriptor (
2825 sizeof (AML_RESOURCE_LARGE_HEADER));
2827 Descriptor = Rnode->Buffer;
2828 - Descriptor->UartSerialBus.ResourceLength = DescriptorSize;
2829 + Descriptor->UartSerialBus.ResourceLength = AcpiUtReadUint16 (&DescriptorSize);
2830 Descriptor->UartSerialBus.DescriptorType = ACPI_RESOURCE_NAME_SERIAL_BUS;
2831 Descriptor->UartSerialBus.RevisionId = AML_RESOURCE_UART_REVISION;
2832 Descriptor->UartSerialBus.TypeRevisionId = AML_RESOURCE_UART_TYPE_REVISION;
2833 Descriptor->UartSerialBus.Type = AML_RESOURCE_UART_SERIALBUSTYPE;
2834 - Descriptor->UartSerialBus.TypeDataLength = AML_RESOURCE_UART_MIN_DATA_LEN + VendorLength;
2835 + Tmp16 = AML_RESOURCE_UART_MIN_DATA_LEN + VendorLength;
2836 + Descriptor->UartSerialBus.TypeDataLength = AcpiUtReadUint16 (&Tmp16);
2838 if (Info->DescriptorTypeOp->Asl.ParseOpcode == PARSEOP_UART_SERIALBUS_V2)
2840 @@ -1142,29 +1211,35 @@ RsDoUartSerialBusDescriptor (
2842 /* Process all child initialization nodes */
2844 + Descriptor->UartSerialBus.TypeSpecificFlags = 0;
2845 for (i = 0; InitializerOp; i++)
2849 case 0: /* Connection Speed (Baud Rate) [DWORD] (_SPE) */
2851 - Descriptor->UartSerialBus.DefaultBaudRate = (UINT32) InitializerOp->Asl.Value.Integer;
2852 + Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
2853 + Descriptor->UartSerialBus.DefaultBaudRate = AcpiUtReadUint32 (&Tmp32);
2854 RsCreateDwordField (InitializerOp, ACPI_RESTAG_SPEED,
2855 CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.DefaultBaudRate));
2858 case 1: /* Bits Per Byte [Flags] (_LEN) */
2860 - RsSetFlagBits16 (&Descriptor->UartSerialBus.TypeSpecificFlags, InitializerOp, 4, 3);
2861 + Tmp16 = AcpiUtReadUint16 (&Descriptor->UartSerialBus.TypeSpecificFlags);
2862 + RsSetFlagBits16 (&Tmp16, InitializerOp, 4, 3);
2863 RsCreateMultiBitField (InitializerOp, ACPI_RESTAG_LENGTH,
2864 CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.TypeSpecificFlags), 4, 3);
2865 + Descriptor->UartSerialBus.TypeSpecificFlags = AcpiUtReadUint16 (&Tmp16);;
2868 case 2: /* Stop Bits [Flags] (_STB) */
2870 - RsSetFlagBits16 (&Descriptor->UartSerialBus.TypeSpecificFlags, InitializerOp, 2, 1);
2871 + Tmp16 = AcpiUtReadUint16 (&Descriptor->UartSerialBus.TypeSpecificFlags);
2872 + RsSetFlagBits16 (&Tmp16, InitializerOp, 2, 1);
2873 RsCreateMultiBitField (InitializerOp, ACPI_RESTAG_STOPBITS,
2874 CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.TypeSpecificFlags), 2, 2);
2875 + Descriptor->UartSerialBus.TypeSpecificFlags = AcpiUtReadUint16 (&Tmp16);;
2878 case 3: /* Lines In Use [BYTE] (_LIN) */
2879 @@ -1176,9 +1251,11 @@ RsDoUartSerialBusDescriptor (
2881 case 4: /* Endianness [Flag] (_END) */
2883 - RsSetFlagBits16 (&Descriptor->UartSerialBus.TypeSpecificFlags, InitializerOp, 7, 0);
2884 + Tmp16 = AcpiUtReadUint16 (&Descriptor->UartSerialBus.TypeSpecificFlags);
2885 + RsSetFlagBits16 (&Tmp16, InitializerOp, 7, 0);
2886 RsCreateBitField (InitializerOp, ACPI_RESTAG_ENDIANNESS,
2887 CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.TypeSpecificFlags), 7);
2888 + Descriptor->UartSerialBus.TypeSpecificFlags = AcpiUtReadUint16 (&Tmp16);;
2891 case 5: /* Parity [BYTE] (_PAR) */
2892 @@ -1190,21 +1267,25 @@ RsDoUartSerialBusDescriptor (
2894 case 6: /* Flow Control [Flags] (_FLC) */
2896 - RsSetFlagBits16 (&Descriptor->UartSerialBus.TypeSpecificFlags, InitializerOp, 0, 0);
2897 + Tmp16 = AcpiUtReadUint16 (&Descriptor->UartSerialBus.TypeSpecificFlags);
2898 + RsSetFlagBits16 (&Tmp16, InitializerOp, 0, 0);
2899 RsCreateMultiBitField (InitializerOp, ACPI_RESTAG_FLOWCONTROL,
2900 CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.TypeSpecificFlags), 0, 2);
2901 + Descriptor->UartSerialBus.TypeSpecificFlags = AcpiUtReadUint16 (&Tmp16);;
2904 case 7: /* Rx Buffer Size [WORD] (_RXL) */
2906 - Descriptor->UartSerialBus.RxFifoSize = (UINT16) InitializerOp->Asl.Value.Integer;
2907 + Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
2908 + Descriptor->UartSerialBus.RxFifoSize = AcpiUtReadUint16 (&Tmp16);
2909 RsCreateWordField (InitializerOp, ACPI_RESTAG_LENGTH_RX,
2910 CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.RxFifoSize));
2913 case 8: /* Tx Buffer Size [WORD] (_TXL) */
2915 - Descriptor->UartSerialBus.TxFifoSize = (UINT16) InitializerOp->Asl.Value.Integer;
2916 + Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
2917 + Descriptor->UartSerialBus.TxFifoSize = AcpiUtReadUint16 (&Tmp16);
2918 RsCreateWordField (InitializerOp, ACPI_RESTAG_LENGTH_TX,
2919 CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.TxFifoSize));
2921 @@ -1444,6 +1525,7 @@ RsDoPinFunctionDescriptor (
2922 UINT32 CurrentByteOffset;
2923 UINT32 PinCount = 0;
2927 InitializerOp = Info->DescriptorTypeOp->Asl.Child;
2928 CurrentByteOffset = Info->CurrentByteOffset;
2929 @@ -1467,7 +1549,7 @@ RsDoPinFunctionDescriptor (
2930 sizeof (AML_RESOURCE_LARGE_HEADER));
2932 Descriptor = Rnode->Buffer;
2933 - Descriptor->PinFunction.ResourceLength = DescriptorSize;
2934 + Descriptor->PinFunction.ResourceLength = AcpiUtReadUint16 (&DescriptorSize);
2935 Descriptor->PinFunction.DescriptorType = ACPI_RESOURCE_NAME_PIN_FUNCTION;
2936 Descriptor->PinFunction.RevisionId = AML_RESOURCE_PIN_FUNCTION_REVISION;
2938 @@ -1507,7 +1589,8 @@ RsDoPinFunctionDescriptor (
2940 case 2: /* Function Number [WORD] (_FUN) */
2942 - Descriptor->PinFunction.FunctionNumber = (UINT16) InitializerOp->Asl.Value.Integer;
2943 + Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
2944 + Descriptor->PinFunction.FunctionNumber = AcpiUtReadUint16 (&Tmp16);
2945 RsCreateDwordField (InitializerOp, ACPI_RESTAG_FUNCTION,
2946 CurrentByteOffset + ASL_RESDESC_OFFSET (PinFunction.FunctionNumber));
2948 @@ -1555,6 +1638,12 @@ RsDoPinFunctionDescriptor (
2950 Descriptor->PinFunction.VendorLength = VendorLength;
2952 + Tmp16 = (UINT16) ACPI_PTR_DIFF (VendorData, Descriptor);
2953 + Descriptor->PinFunction.VendorOffset = AcpiUtReadUint16 (&Tmp16);
2955 + Tmp16 = Descriptor->PinFunction.VendorLength;
2956 + Descriptor->PinFunction.VendorLength = AcpiUtReadUint16 (&Tmp16);
2961 @@ -1566,7 +1655,8 @@ RsDoPinFunctionDescriptor (
2962 * (implies resource source must immediately follow the pin list.)
2965 - *PinList = (UINT16) InitializerOp->Asl.Value.Integer;
2966 + Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
2967 + *PinList = AcpiUtReadUint16 (&Tmp16);
2971 @@ -1597,6 +1687,13 @@ RsDoPinFunctionDescriptor (
2972 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
2975 + /* correct the endian-ness of the values */
2976 + Tmp16 = Descriptor->PinFunction.PinTableOffset;
2977 + Descriptor->PinFunction.PinTableOffset = AcpiUtReadUint16 (&Tmp16);
2979 + Tmp16 = Descriptor->PinFunction.ResSourceOffset;
2980 + Descriptor->PinFunction.ResSourceOffset = AcpiUtReadUint16 (&Tmp16);
2985 @@ -1630,6 +1727,8 @@ RsDoPinConfigDescriptor (
2986 UINT32 CurrentByteOffset;
2987 UINT32 PinCount = 0;
2992 InitializerOp = Info->DescriptorTypeOp->Asl.Child;
2993 CurrentByteOffset = Info->CurrentByteOffset;
2994 @@ -1653,7 +1752,7 @@ RsDoPinConfigDescriptor (
2995 sizeof (AML_RESOURCE_LARGE_HEADER));
2997 Descriptor = Rnode->Buffer;
2998 - Descriptor->PinConfig.ResourceLength = DescriptorSize;
2999 + Descriptor->PinConfig.ResourceLength = AcpiUtReadUint16 (&DescriptorSize);
3000 Descriptor->PinConfig.DescriptorType = ACPI_RESOURCE_NAME_PIN_CONFIG;
3001 Descriptor->PinConfig.RevisionId = AML_RESOURCE_PIN_CONFIG_REVISION;
3003 @@ -1707,7 +1806,8 @@ RsDoPinConfigDescriptor (
3005 case 2: /* Pin Config Value [DWORD] (_VAL) */
3007 - Descriptor->PinConfig.PinConfigValue = (UINT32) InitializerOp->Asl.Value.Integer;
3008 + Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
3009 + Descriptor->PinConfig.PinConfigValue = AcpiUtReadUint32 (&Tmp32);
3010 RsCreateDwordField (InitializerOp, ACPI_RESTAG_PINCONFIG_VALUE,
3011 CurrentByteOffset + ASL_RESDESC_OFFSET (PinConfig.PinConfigValue));
3013 @@ -1766,7 +1866,8 @@ RsDoPinConfigDescriptor (
3014 * (implies resource source must immediately follow the pin list.)
3017 - *PinList = (UINT16) InitializerOp->Asl.Value.Integer;
3018 + Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
3019 + *PinList = AcpiUtReadUint16 (&Tmp16);
3023 @@ -1797,6 +1898,16 @@ RsDoPinConfigDescriptor (
3024 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
3027 + /* correct the endianness if needed */
3028 + Tmp16 = Descriptor->PinConfig.PinTableOffset;
3029 + Descriptor->PinConfig.PinTableOffset = AcpiUtReadUint16 (&Tmp16);
3030 + Tmp16 = Descriptor->PinConfig.ResSourceOffset;
3031 + Descriptor->PinConfig.ResSourceOffset = AcpiUtReadUint16 (&Tmp16);
3032 + Tmp16 = Descriptor->PinConfig.VendorOffset;
3033 + Descriptor->PinConfig.VendorOffset = AcpiUtReadUint16 (&Tmp16);
3034 + Tmp16 = Descriptor->PinConfig.VendorLength;
3035 + Descriptor->PinConfig.VendorLength = AcpiUtReadUint16 (&Tmp16);
3040 @@ -1830,6 +1941,7 @@ RsDoPinGroupDescriptor (
3041 UINT32 CurrentByteOffset;
3042 UINT32 PinCount = 0;
3046 InitializerOp = Info->DescriptorTypeOp->Asl.Child;
3047 CurrentByteOffset = Info->CurrentByteOffset;
3048 @@ -1853,7 +1965,7 @@ RsDoPinGroupDescriptor (
3049 sizeof (AML_RESOURCE_LARGE_HEADER));
3051 Descriptor = Rnode->Buffer;
3052 - Descriptor->PinGroup.ResourceLength = DescriptorSize;
3053 + Descriptor->PinGroup.ResourceLength = AcpiUtReadUint16 (&DescriptorSize);
3054 Descriptor->PinGroup.DescriptorType = ACPI_RESOURCE_NAME_PIN_GROUP;
3055 Descriptor->PinGroup.RevisionId = AML_RESOURCE_PIN_GROUP_REVISION;
3057 @@ -1920,7 +2032,8 @@ RsDoPinGroupDescriptor (
3058 * (implies resource source must immediately follow the pin list.)
3061 - *PinList = (UINT16) InitializerOp->Asl.Value.Integer;
3062 + Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
3063 + *PinList = AcpiUtReadUint16 (&Tmp16);
3067 @@ -1951,6 +2064,16 @@ RsDoPinGroupDescriptor (
3068 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
3071 + /* correct enddianness as needed */
3072 + Tmp16 = Descriptor->PinGroup.PinTableOffset;
3073 + Descriptor->PinGroup.PinTableOffset = AcpiUtReadUint16 (&Tmp16);
3074 + Tmp16 = Descriptor->PinGroup.LabelOffset;
3075 + Descriptor->PinGroup.LabelOffset = AcpiUtReadUint16 (&Tmp16);
3076 + Tmp16 = Descriptor->PinGroup.VendorOffset;
3077 + Descriptor->PinGroup.VendorOffset = AcpiUtReadUint16 (&Tmp16);
3078 + Tmp16 = Descriptor->PinGroup.VendorLength;
3079 + Descriptor->PinGroup.VendorLength = AcpiUtReadUint16 (&Tmp16);
3084 @@ -1983,6 +2106,7 @@ RsDoPinGroupFunctionDescriptor (
3085 UINT16 DescriptorSize;
3086 UINT32 CurrentByteOffset;
3090 InitializerOp = Info->DescriptorTypeOp->Asl.Child;
3091 CurrentByteOffset = Info->CurrentByteOffset;
3092 @@ -2006,7 +2130,7 @@ RsDoPinGroupFunctionDescriptor (
3093 sizeof (AML_RESOURCE_LARGE_HEADER));
3095 Descriptor = Rnode->Buffer;
3096 - Descriptor->PinGroupFunction.ResourceLength = DescriptorSize;
3097 + Descriptor->PinGroupFunction.ResourceLength = AcpiUtReadUint16 (&DescriptorSize);
3098 Descriptor->PinGroupFunction.DescriptorType = ACPI_RESOURCE_NAME_PIN_GROUP_FUNCTION;
3099 Descriptor->PinGroupFunction.RevisionId = AML_RESOURCE_PIN_GROUP_FUNCTION_REVISION;
3101 @@ -2038,7 +2162,8 @@ RsDoPinGroupFunctionDescriptor (
3103 case 1: /* Function Number [WORD] */
3105 - Descriptor->PinGroupFunction.FunctionNumber = (UINT16) InitializerOp->Asl.Value.Integer;
3106 + Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
3107 + Descriptor->PinGroupFunction.FunctionNumber = AcpiUtReadUint16 (&Tmp16);
3108 RsCreateDwordField (InitializerOp, ACPI_RESTAG_FUNCTION,
3109 CurrentByteOffset + ASL_RESDESC_OFFSET (PinGroupFunction.FunctionNumber));
3111 @@ -2097,6 +2222,16 @@ RsDoPinGroupFunctionDescriptor (
3112 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
3115 + /* correct enddianness as needed */
3116 + Tmp16 = Descriptor->PinGroupFunction.ResSourceOffset;
3117 + Descriptor->PinGroupFunction.ResSourceOffset = AcpiUtReadUint16 (&Tmp16);
3118 + Tmp16 = Descriptor->PinGroupFunction.ResSourceLabelOffset;
3119 + Descriptor->PinGroupFunction.ResSourceLabelOffset = AcpiUtReadUint16 (&Tmp16);
3120 + Tmp16 = Descriptor->PinGroupFunction.VendorOffset;
3121 + Descriptor->PinGroupFunction.VendorOffset = AcpiUtReadUint16 (&Tmp16);
3122 + Tmp16 = Descriptor->PinGroupFunction.VendorLength;
3123 + Descriptor->PinGroupFunction.VendorLength = AcpiUtReadUint16 (&Tmp16);
3128 @@ -2129,6 +2264,8 @@ RsDoPinGroupConfigDescriptor (
3129 UINT16 DescriptorSize;
3130 UINT32 CurrentByteOffset;
3135 InitializerOp = Info->DescriptorTypeOp->Asl.Child;
3136 CurrentByteOffset = Info->CurrentByteOffset;
3137 @@ -2152,7 +2289,7 @@ RsDoPinGroupConfigDescriptor (
3138 sizeof (AML_RESOURCE_LARGE_HEADER));
3140 Descriptor = Rnode->Buffer;
3141 - Descriptor->PinGroupConfig.ResourceLength = DescriptorSize;
3142 + Descriptor->PinGroupConfig.ResourceLength = AcpiUtReadUint16 (&DescriptorSize);
3143 Descriptor->PinGroupConfig.DescriptorType = ACPI_RESOURCE_NAME_PIN_GROUP_CONFIG;
3144 Descriptor->PinGroupConfig.RevisionId = AML_RESOURCE_PIN_GROUP_CONFIG_REVISION;
3146 @@ -2205,7 +2342,8 @@ RsDoPinGroupConfigDescriptor (
3148 case 2: /* Pin Config Value [DWORD] (_VAL) */
3150 - Descriptor->PinGroupConfig.PinConfigValue = (UINT32) InitializerOp->Asl.Value.Integer;
3151 + Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
3152 + Descriptor->PinGroupConfig.PinConfigValue = AcpiUtReadUint32 (&Tmp32);
3153 RsCreateDwordField (InitializerOp, ACPI_RESTAG_PINCONFIG_VALUE,
3154 CurrentByteOffset + ASL_RESDESC_OFFSET (PinGroupConfig.PinConfigValue));
3156 @@ -2266,5 +2404,15 @@ RsDoPinGroupConfigDescriptor (
3157 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
3160 + /* correct enddianness as needed */
3161 + Tmp16 = Descriptor->PinGroupConfig.ResSourceOffset;
3162 + Descriptor->PinGroupConfig.ResSourceOffset = AcpiUtReadUint16 (&Tmp16);
3163 + Tmp16 = Descriptor->PinGroupConfig.ResSourceLabelOffset;
3164 + Descriptor->PinGroupConfig.ResSourceLabelOffset = AcpiUtReadUint16 (&Tmp16);
3165 + Tmp16 = Descriptor->PinGroupConfig.VendorOffset;
3166 + Descriptor->PinGroupConfig.VendorOffset = AcpiUtReadUint16 (&Tmp16);
3167 + Tmp16 = Descriptor->PinGroupConfig.VendorLength;
3168 + Descriptor->PinGroupConfig.VendorLength = AcpiUtReadUint16 (&Tmp16);