Blame SOURCES/0043-Support-DSDT-SSDT-in-a-big-endian-world.patch

9897bb
From 14d220a34462e61fe69141c86f4c3cd2ae68c279 Mon Sep 17 00:00:00 2001
9897bb
From: Al Stone <ahs3@redhat.com>
9897bb
Date: Wed, 30 Sep 2020 18:59:57 -0600
9897bb
Subject: [PATCH 43/45] Support DSDT/SSDT in a big-endian world.
9897bb
9897bb
NB: this is a very large diff.  The problem is that ResourceTemplates
9897bb
are treated differently during compilation and disassembly so each of
9897bb
the resource types had code that needed to be touched directly.
9897bb
9897bb
In general, however, just reading or writing individual AML opcodes
9897bb
wasn't that much of a change, and most of it was on the codegen side.
9897bb
9897bb
Signed-off-by: Al Stone <ahs3@redhat.com>
9897bb
---
9897bb
 source/common/adwalk.c                     |   3 +-
9897bb
 source/common/dmrestag.c                   |   2 +-
9897bb
 source/common/dmtables.c                   |  17 +-
9897bb
 source/common/dmtbdump.c                   |   3 +-
9897bb
 source/common/dmtbdump3.c                  |   8 +-
9897bb
 source/compiler/aslcodegen.c               |  59 ++++--
9897bb
 source/compiler/aslopcodes.c               |   3 +-
9897bb
 source/compiler/aslrestype1.c              |  60 ++++--
9897bb
 source/compiler/aslrestype1i.c             |  35 ++--
9897bb
 source/compiler/aslrestype2.c              |  20 +-
9897bb
 source/compiler/aslrestype2d.c             |  99 ++++++----
9897bb
 source/compiler/aslrestype2e.c             |  90 ++++++---
9897bb
 source/compiler/aslrestype2q.c             |  81 +++++---
9897bb
 source/compiler/aslrestype2s.c             | 214 +++++++++++++++++----
9897bb
 source/compiler/aslrestype2w.c             |  94 +++++----
9897bb
 source/compiler/dttable2.c                 |   3 +-
9897bb
 source/components/disassembler/dmbuffer.c  |  37 +++-
9897bb
 source/components/disassembler/dmopcode.c  |  21 +-
9897bb
 source/components/disassembler/dmresrc.c   |   2 +-
9897bb
 source/components/disassembler/dmresrcl.c  |  43 +++--
9897bb
 source/components/disassembler/dmresrcl2.c | 128 +++++++-----
9897bb
 source/components/disassembler/dmresrcs.c  |  18 +-
9897bb
 source/components/disassembler/dmwalk.c    |   2 +-
9897bb
 source/components/namespace/nsaccess.c     |   2 +-
9897bb
 source/components/namespace/nsnames.c      |   4 +-
9897bb
 source/components/namespace/nsparse.c      |   6 +-
9897bb
 source/components/namespace/nsutils.c      |   7 +-
9897bb
 source/components/utilities/utresrc.c      |   2 +-
9897bb
 28 files changed, 721 insertions(+), 341 deletions(-)
9897bb
9897bb
Index: acpica-unix2-20210604/source/common/adwalk.c
9897bb
===================================================================
9897bb
--- acpica-unix2-20210604.orig/source/common/adwalk.c
9897bb
+++ acpica-unix2-20210604/source/common/adwalk.c
9897bb
@@ -679,7 +679,8 @@ AcpiDmLoadDescendingOp (
9897bb
 
9897bb
         if (!Path && Op->Common.AmlOpcode == AML_INT_NAMEDFIELD_OP)
9897bb
         {
9897bb
-            *ACPI_CAST_PTR (UINT32, &FieldPath[0]) = Op->Named.Name;
9897bb
+            AcpiUtWriteUint (FieldPath, ACPI_NAMESEG_SIZE,
9897bb
+		             &Op->Named.Name, ACPI_NAMESEG_SIZE);
9897bb
             FieldPath[4] = 0;
9897bb
             Path = FieldPath;
9897bb
         }
9897bb
Index: acpica-unix2-20210604/source/common/dmrestag.c
9897bb
===================================================================
9897bb
--- acpica-unix2-20210604.orig/source/common/dmrestag.c
9897bb
+++ acpica-unix2-20210604/source/common/dmrestag.c
9897bb
@@ -1048,7 +1048,7 @@ AcpiDmAddResourcesToNamespace (
9897bb
      * NextOp contains the Aml pointer and the Aml length
9897bb
      */
9897bb
     AcpiUtWalkAmlResources (NULL, (UINT8 *) NextOp->Named.Data,
9897bb
-        (ACPI_SIZE) NextOp->Common.Value.Integer,
9897bb
+        (ACPI_SIZE) NextOp->Common.Value.Size,
9897bb
         AcpiDmAddResourceToNamespace, (void **) BufferNode);
9897bb
 }
9897bb
 
9897bb
Index: acpica-unix2-20210604/source/common/dmtables.c
9897bb
===================================================================
9897bb
--- acpica-unix2-20210604.orig/source/common/dmtables.c
9897bb
+++ acpica-unix2-20210604/source/common/dmtables.c
9897bb
@@ -142,6 +142,10 @@ AdCreateTableHeader (
9897bb
     ACPI_TABLE_HEADER       *Table)
9897bb
 {
9897bb
     UINT8                   Checksum;
9897bb
+    UINT32                  TableLength = AcpiUtReadUint32 (&Table->Length);
9897bb
+    UINT32                  OemRevision = AcpiUtReadUint32 (&Table->OemRevision);
9897bb
+    UINT32                  CompilerRevision =
9897bb
+                                AcpiUtReadUint32 (&Table->AslCompilerRevision);
9897bb
 
9897bb
 
9897bb
     /* Reset globals for External statements */
9897bb
@@ -156,7 +160,7 @@ AdCreateTableHeader (
9897bb
 
9897bb
     AcpiOsPrintf (" * Original Table Header:\n");
9897bb
     AcpiOsPrintf (" *     Signature        \"%4.4s\"\n",    Table->Signature);
9897bb
-    AcpiOsPrintf (" *     Length           0x%8.8X (%u)\n", Table->Length, Table->Length);
9897bb
+    AcpiOsPrintf (" *     Length           0x%8.8X (%u)\n", TableLength, TableLength);
9897bb
 
9897bb
     /* Print and validate the revision */
9897bb
 
9897bb
@@ -188,7 +192,7 @@ AdCreateTableHeader (
9897bb
 
9897bb
     AcpiOsPrintf ("\n *     Checksum         0x%2.2X",        Table->Checksum);
9897bb
 
9897bb
-    Checksum = AcpiTbChecksum (ACPI_CAST_PTR (UINT8, Table), Table->Length);
9897bb
+    Checksum = AcpiTbChecksum (ACPI_CAST_PTR (UINT8, Table), TableLength);
9897bb
     if (Checksum)
9897bb
     {
9897bb
         AcpiOsPrintf (" **** Incorrect checksum, should be 0x%2.2X",
9897bb
@@ -198,9 +202,9 @@ AdCreateTableHeader (
9897bb
     AcpiOsPrintf ("\n");
9897bb
     AcpiOsPrintf (" *     OEM ID           \"%.6s\"\n",     Table->OemId);
9897bb
     AcpiOsPrintf (" *     OEM Table ID     \"%.8s\"\n",     Table->OemTableId);
9897bb
-    AcpiOsPrintf (" *     OEM Revision     0x%8.8X (%u)\n", Table->OemRevision, Table->OemRevision);
9897bb
+    AcpiOsPrintf (" *     OEM Revision     0x%8.8X (%u)\n", OemRevision, OemRevision);
9897bb
     AcpiOsPrintf (" *     Compiler ID      \"%.4s\"\n",     Table->AslCompilerId);
9897bb
-    AcpiOsPrintf (" *     Compiler Version 0x%8.8X (%u)\n", Table->AslCompilerRevision, Table->AslCompilerRevision);
9897bb
+    AcpiOsPrintf (" *     Compiler Version 0x%8.8X (%u)\n", CompilerRevision, CompilerRevision);
9897bb
     AcpiOsPrintf (" */\n");
9897bb
 
9897bb
     /*
9897bb
@@ -221,7 +225,7 @@ AdCreateTableHeader (
9897bb
     AcpiOsPrintf (
9897bb
         "DefinitionBlock (\"\", \"%4.4s\", %u, \"%.6s\", \"%.8s\", 0x%8.8X)\n",
9897bb
         Table->Signature, Table->Revision,
9897bb
-        Table->OemId, Table->OemTableId, Table->OemRevision);
9897bb
+        Table->OemId, Table->OemTableId, OemRevision);
9897bb
 }
9897bb
 
9897bb
 
9897bb
@@ -396,7 +400,8 @@ AdParseTable (
9897bb
 
9897bb
     fprintf (stderr, "Pass 1 parse of [%4.4s]\n", (char *) Table->Signature);
9897bb
 
9897bb
-    AmlLength = Table->Length - sizeof (ACPI_TABLE_HEADER);
9897bb
+    AmlLength = AcpiUtReadUint32 (&Table->Length);
9897bb
+    AmlLength -= sizeof (ACPI_TABLE_HEADER);
9897bb
     AmlStart = ((UINT8 *) Table + sizeof (ACPI_TABLE_HEADER));
9897bb
 
9897bb
     AcpiUtSetIntegerWidth (Table->Revision);
9897bb
Index: acpica-unix2-20210604/source/common/dmtbdump.c
9897bb
===================================================================
9897bb
--- acpica-unix2-20210604.orig/source/common/dmtbdump.c
9897bb
+++ acpica-unix2-20210604/source/common/dmtbdump.c
9897bb
@@ -338,8 +338,7 @@ AcpiDmDumpXsdt (
9897bb
     for (i = 0; i < Entries; i++)
9897bb
     {
9897bb
         AcpiDmLineHeader2 (Offset, sizeof (UINT64), "ACPI Table Address", i);
9897bb
-        AcpiOsPrintf ("%8.8X%8.8X\n",
9897bb
-                ACPI_FORMAT_UINT64 (AcpiUtReadUint64 (&Array[i])));
9897bb
+        AcpiOsPrintf ("%16.16lX\n", AcpiUtReadUint64 (&Array[i]));
9897bb
         Offset += sizeof (UINT64);
9897bb
     }
9897bb
 }
9897bb
Index: acpica-unix2-20210604/source/common/dmtbdump3.c
9897bb
===================================================================
9897bb
--- acpica-unix2-20210604.orig/source/common/dmtbdump3.c
9897bb
+++ acpica-unix2-20210604/source/common/dmtbdump3.c
9897bb
@@ -736,13 +736,13 @@ AcpiDmDumpWpbt (
9897bb
 {
9897bb
     ACPI_STATUS             Status;
9897bb
     ACPI_TABLE_WPBT         *Subtable;
9897bb
-    UINT32                  Length = Table->Length;
9897bb
+    UINT32                  TableLength = AcpiUtReadUint32 (&Table->Length);
9897bb
     UINT16                  ArgumentsLength;
9897bb
 
9897bb
 
9897bb
     /* Dump the main table */
9897bb
 
9897bb
-    Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoWpbt);
9897bb
+    Status = AcpiDmDumpTable (TableLength, 0, Table, 0, AcpiDmTableInfoWpbt);
9897bb
     if (ACPI_FAILURE (Status))
9897bb
     {
9897bb
         return;
9897bb
@@ -751,10 +751,10 @@ AcpiDmDumpWpbt (
9897bb
     /* Extract the arguments buffer length from the main table */
9897bb
 
9897bb
     Subtable = ACPI_CAST_PTR (ACPI_TABLE_WPBT, Table);
9897bb
-    ArgumentsLength = Subtable->ArgumentsLength;
9897bb
+    ArgumentsLength = AcpiUtReadUint16 (&Subtable->ArgumentsLength);
9897bb
 
9897bb
     /* Dump the arguments buffer */
9897bb
 
9897bb
-    (void) AcpiDmDumpTable (Table->Length, 0, Table, ArgumentsLength,
9897bb
+    (void) AcpiDmDumpTable (TableLength, 0, Table, ArgumentsLength,
9897bb
         AcpiDmTableInfoWpbt0);
9897bb
 }
9897bb
Index: acpica-unix2-20210604/source/compiler/aslcodegen.c
9897bb
===================================================================
9897bb
--- acpica-unix2-20210604.orig/source/compiler/aslcodegen.c
9897bb
+++ acpica-unix2-20210604/source/compiler/aslcodegen.c
9897bb
@@ -238,6 +238,10 @@ CgWriteAmlOpcode (
9897bb
 {
9897bb
     UINT8                   PkgLenFirstByte;
9897bb
     UINT32                  i;
9897bb
+    UINT8                   Tmp8;
9897bb
+    UINT16                  Tmp16;
9897bb
+    UINT32                  Tmp32;
9897bb
+    UINT64                  Tmp64;
9897bb
     union {
9897bb
         UINT16                  Opcode;
9897bb
         UINT8                   OpcodeBytes[2];
9897bb
@@ -312,14 +316,15 @@ CgWriteAmlOpcode (
9897bb
 
9897bb
         /* Check for two-byte opcode */
9897bb
 
9897bb
+        Tmp16 = AcpiUtReadUint16 (&Aml.Opcode);
9897bb
         if (Aml.Opcode > 0x00FF)
9897bb
         {
9897bb
             /* Write the high byte first */
9897bb
 
9897bb
-            CgLocalWriteAmlData (Op, &Aml.OpcodeBytes[1], 1);
9897bb
+            CgLocalWriteAmlData (Op, ((UINT8 *) &Tmp16)+1, 1);
9897bb
         }
9897bb
 
9897bb
-        CgLocalWriteAmlData (Op, &Aml.OpcodeBytes[0], 1);
9897bb
+        CgLocalWriteAmlData (Op, (UINT8 *) &Tmp16, 1);
9897bb
 
9897bb
         /* Subtreelength doesn't include length of package length bytes */
9897bb
 
9897bb
@@ -335,7 +340,8 @@ CgWriteAmlOpcode (
9897bb
         {
9897bb
             /* Simplest case -- no bytes to follow, just write the count */
9897bb
 
9897bb
-            CgLocalWriteAmlData (Op, &PkgLen.LenBytes[0], 1);
9897bb
+            Tmp8 = (UINT8) PkgLen.Len;
9897bb
+            CgLocalWriteAmlData (Op, &Tmp8, 1);
9897bb
         }
9897bb
         else if (Op->Asl.AmlPkgLenBytes != 0)
9897bb
         {
9897bb
@@ -343,9 +349,10 @@ CgWriteAmlOpcode (
9897bb
              * Encode the "bytes to follow" in the first byte, top two bits.
9897bb
              * The low-order nybble of the length is in the bottom 4 bits
9897bb
              */
9897bb
+            Tmp8 = (UINT8) PkgLen.Len;
9897bb
             PkgLenFirstByte = (UINT8)
9897bb
                 (((UINT32) (Op->Asl.AmlPkgLenBytes - 1) << 6) |
9897bb
-                (PkgLen.LenBytes[0] & 0x0F));
9897bb
+                (Tmp8 & 0x0F));
9897bb
 
9897bb
             CgLocalWriteAmlData (Op, &PkgLenFirstByte, 1);
9897bb
 
9897bb
@@ -359,6 +366,9 @@ CgWriteAmlOpcode (
9897bb
              * Now we can write the remaining bytes -
9897bb
              * either 1, 2, or 3 bytes
9897bb
              */
9897bb
+            Tmp32 = PkgLen.Len;
9897bb
+            AcpiUtWriteUint (&PkgLen.Len, Op->Asl.AmlPkgLenBytes,
9897bb
+                &Tmp32, sizeof (UINT32));
9897bb
             for (i = 0; i < (UINT32) (Op->Asl.AmlPkgLenBytes - 1); i++)
9897bb
             {
9897bb
                 CgLocalWriteAmlData (Op, &PkgLen.LenBytes[i], 1);
9897bb
@@ -370,22 +380,30 @@ CgWriteAmlOpcode (
9897bb
     {
9897bb
     case AML_BYTE_OP:
9897bb
 
9897bb
-        CgLocalWriteAmlData (Op, &Op->Asl.Value.Integer, 1);
9897bb
+        Tmp64 = 0;
9897bb
+        AcpiUtWriteUint (&Tmp64, 1, &Op->Asl.Value.Integer, 8);
9897bb
+        CgLocalWriteAmlData (Op, &Tmp64, 1);
9897bb
         break;
9897bb
 
9897bb
     case AML_WORD_OP:
9897bb
 
9897bb
-        CgLocalWriteAmlData (Op, &Op->Asl.Value.Integer, 2);
9897bb
-       break;
9897bb
+        Tmp64 = 0;
9897bb
+        AcpiUtWriteUint (&Tmp64, 2, &Op->Asl.Value.Integer, 8);
9897bb
+        CgLocalWriteAmlData (Op, &Tmp64, 2);
9897bb
+        break;
9897bb
 
9897bb
     case AML_DWORD_OP:
9897bb
 
9897bb
-        CgLocalWriteAmlData (Op, &Op->Asl.Value.Integer, 4);
9897bb
+        Tmp64 = 0;
9897bb
+        AcpiUtWriteUint (&Tmp64, 4, &Op->Asl.Value.Integer, 8);
9897bb
+        CgLocalWriteAmlData (Op, &Tmp64, 4);
9897bb
         break;
9897bb
 
9897bb
     case AML_QWORD_OP:
9897bb
 
9897bb
-        CgLocalWriteAmlData (Op, &Op->Asl.Value.Integer, 8);
9897bb
+        Tmp64 = 0;
9897bb
+        AcpiUtWriteUint (&Tmp64, 8, &Op->Asl.Value.Integer, 8);
9897bb
+        CgLocalWriteAmlData (Op, &Tmp64, 8);
9897bb
         break;
9897bb
 
9897bb
     case AML_STRING_OP:
9897bb
@@ -423,6 +441,7 @@ CgWriteTableHeader (
9897bb
     ACPI_PARSE_OBJECT       *Child;
9897bb
     UINT32                  CommentLength;
9897bb
     ACPI_COMMENT_NODE       *Current;
9897bb
+    UINT32                  Tmp32;
9897bb
 
9897bb
 
9897bb
     memset (&AslGbl_TableHeader, 0, sizeof (ACPI_TABLE_HEADER));
9897bb
@@ -478,7 +497,9 @@ CgWriteTableHeader (
9897bb
     /* OEM Revision */
9897bb
 
9897bb
     Child = Child->Asl.Next;
9897bb
-    AslGbl_TableHeader.OemRevision = (UINT32) Child->Asl.Value.Integer;
9897bb
+    AcpiUtWriteUint (&Tmp32, sizeof (UINT32),
9897bb
+           &Child->Asl.Value.Integer, sizeof (Child->Asl.Value.Integer));
9897bb
+    AslGbl_TableHeader.OemRevision = Tmp32;
9897bb
 
9897bb
     /* Compiler ID */
9897bb
 
9897bb
@@ -486,7 +507,8 @@ CgWriteTableHeader (
9897bb
 
9897bb
     /* Compiler version */
9897bb
 
9897bb
-    AslGbl_TableHeader.AslCompilerRevision = ACPI_CA_VERSION;
9897bb
+    Tmp32 = ACPI_CA_VERSION;
9897bb
+    AslGbl_TableHeader.AslCompilerRevision = AcpiUtReadUint32 (&Tmp32);
9897bb
 
9897bb
     /* Table length. Checksum zero for now, will rewrite later */
9897bb
 
9897bb
@@ -541,6 +563,15 @@ CgWriteTableHeader (
9897bb
     AslGbl_TableHeader.Checksum = 0;
9897bb
     Op->Asl.FinalAmlOffset = ftell (AslGbl_Files[ASL_FILE_AML_OUTPUT].Handle);
9897bb
 
9897bb
+    /*
9897bb
+     * Adjust the Table length; it will only change when big-endian
9897bb
+     * but we have to wait until here in case there is arithmetic to
9897bb
+     * be done on the length before this step in the function
9897bb
+     */
9897bb
+
9897bb
+    Tmp32 = AslGbl_TableHeader.Length;
9897bb
+    AslGbl_TableHeader.Length = AcpiUtReadUint32 (&Tmp32);
9897bb
+
9897bb
     /* Write entire header and clear the table header global */
9897bb
 
9897bb
     CgLocalWriteAmlData (Op, &AslGbl_TableHeader, sizeof (ACPI_TABLE_HEADER));
9897bb
@@ -625,6 +656,7 @@ CgWriteNode (
9897bb
     ACPI_PARSE_OBJECT       *Op)
9897bb
 {
9897bb
     ASL_RESOURCE_NODE       *Rnode;
9897bb
+    UINT64                  Tmp64;
9897bb
 
9897bb
 
9897bb
     /* Write all comments here. */
9897bb
@@ -653,7 +685,10 @@ CgWriteNode (
9897bb
     case AML_RAW_DATA_DWORD:
9897bb
     case AML_RAW_DATA_QWORD:
9897bb
 
9897bb
-        CgLocalWriteAmlData (Op, &Op->Asl.Value.Integer, Op->Asl.AmlLength);
9897bb
+        Tmp64 = 0;
9897bb
+        AcpiUtWriteUint (&Tmp64, Op->Asl.AmlLength,
9897bb
+            &Op->Asl.Value.Integer, sizeof (UINT64));
9897bb
+        CgLocalWriteAmlData (Op, &Tmp64, Op->Asl.AmlLength);
9897bb
         return;
9897bb
 
9897bb
 
9897bb
Index: acpica-unix2-20210604/source/compiler/aslopcodes.c
9897bb
===================================================================
9897bb
--- acpica-unix2-20210604.orig/source/compiler/aslopcodes.c
9897bb
+++ acpica-unix2-20210604/source/compiler/aslopcodes.c
9897bb
@@ -511,7 +511,8 @@ OpcDoUnicode (
9897bb
 
9897bb
     for (i = 0; i < Count; i++)
9897bb
     {
9897bb
-        UnicodeString[i] = (UINT16) AsciiString[i];
9897bb
+        AcpiUtWriteUint (&UnicodeString[i], sizeof (UINT16),
9897bb
+                &AsciiString[i], sizeof (UINT8));
9897bb
     }
9897bb
 
9897bb
     /*
9897bb
Index: acpica-unix2-20210604/source/compiler/aslrestype1.c
9897bb
===================================================================
9897bb
--- acpica-unix2-20210604.orig/source/compiler/aslrestype1.c
9897bb
+++ acpica-unix2-20210604/source/compiler/aslrestype1.c
9897bb
@@ -143,6 +143,7 @@ RsDoMemory24Descriptor (
9897bb
     ASL_RESOURCE_NODE       *Rnode;
9897bb
     UINT32                  CurrentByteOffset;
9897bb
     UINT32                  i;
9897bb
+    UINT16                  Tmp16;
9897bb
 
9897bb
 
9897bb
     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
9897bb
@@ -151,7 +152,8 @@ RsDoMemory24Descriptor (
9897bb
 
9897bb
     Descriptor = Rnode->Buffer;
9897bb
     Descriptor->Memory24.DescriptorType = ACPI_RESOURCE_NAME_MEMORY24;
9897bb
-    Descriptor->Memory24.ResourceLength = 9;
9897bb
+    Tmp16 = 9;
9897bb
+    Descriptor->Memory24.ResourceLength = AcpiUtReadUint16 (&Tmp16);
9897bb
 
9897bb
     /* Process all child initialization nodes */
9897bb
 
9897bb
@@ -168,7 +170,8 @@ RsDoMemory24Descriptor (
9897bb
 
9897bb
         case 1: /* Min Address */
9897bb
 
9897bb
-            Descriptor->Memory24.Minimum = (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->Memory24.Minimum = AcpiUtReadUint16 (&Tmp16);
9897bb
             RsCreateWordField (InitializerOp, ACPI_RESTAG_MINADDR,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.Minimum));
9897bb
             MinOp = InitializerOp;
9897bb
@@ -176,7 +179,8 @@ RsDoMemory24Descriptor (
9897bb
 
9897bb
         case 2: /* Max Address */
9897bb
 
9897bb
-            Descriptor->Memory24.Maximum = (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->Memory24.Maximum = AcpiUtReadUint16 (&Tmp16);
9897bb
             RsCreateWordField (InitializerOp, ACPI_RESTAG_MAXADDR,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.Maximum));
9897bb
             MaxOp = InitializerOp;
9897bb
@@ -184,14 +188,16 @@ RsDoMemory24Descriptor (
9897bb
 
9897bb
         case 3: /* Alignment */
9897bb
 
9897bb
-            Descriptor->Memory24.Alignment = (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->Memory24.Alignment = AcpiUtReadUint16 (&Tmp16);
9897bb
             RsCreateWordField (InitializerOp, ACPI_RESTAG_ALIGNMENT,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.Alignment));
9897bb
             break;
9897bb
 
9897bb
         case 4: /* Length */
9897bb
 
9897bb
-            Descriptor->Memory24.AddressLength = (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->Memory24.AddressLength = AcpiUtReadUint16 (&Tmp16);
9897bb
             RsCreateWordField (InitializerOp, ACPI_RESTAG_LENGTH,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.AddressLength));
9897bb
             LengthOp = InitializerOp;
9897bb
@@ -214,10 +220,10 @@ RsDoMemory24Descriptor (
9897bb
     /* Validate the Min/Max/Len/Align values (Alignment==0 means 64K) */
9897bb
 
9897bb
     RsSmallAddressCheck (ACPI_RESOURCE_NAME_MEMORY24,
9897bb
-        Descriptor->Memory24.Minimum,
9897bb
-        Descriptor->Memory24.Maximum,
9897bb
-        Descriptor->Memory24.AddressLength,
9897bb
-        Descriptor->Memory24.Alignment,
9897bb
+        (UINT32) AcpiUtReadUint16 (&Descriptor->Memory24.Minimum),
9897bb
+        (UINT32) AcpiUtReadUint16 (&Descriptor->Memory24.Maximum),
9897bb
+        (UINT32) AcpiUtReadUint16 (&Descriptor->Memory24.AddressLength),
9897bb
+        (UINT32) AcpiUtReadUint16 (&Descriptor->Memory24.Alignment),
9897bb
         MinOp, MaxOp, LengthOp, NULL, Info->DescriptorTypeOp);
9897bb
 
9897bb
     return (Rnode);
9897bb
@@ -249,6 +255,8 @@ RsDoMemory32Descriptor (
9897bb
     ASL_RESOURCE_NODE       *Rnode;
9897bb
     UINT32                  CurrentByteOffset;
9897bb
     UINT32                  i;
9897bb
+    UINT16                  Tmp16;
9897bb
+    UINT32                  Tmp32;
9897bb
 
9897bb
 
9897bb
     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
9897bb
@@ -257,7 +265,8 @@ RsDoMemory32Descriptor (
9897bb
 
9897bb
     Descriptor = Rnode->Buffer;
9897bb
     Descriptor->Memory32.DescriptorType = ACPI_RESOURCE_NAME_MEMORY32;
9897bb
-    Descriptor->Memory32.ResourceLength = 17;
9897bb
+    Tmp16 = 17;
9897bb
+    Descriptor->Memory32.ResourceLength = AcpiUtReadUint16 (&Tmp16);
9897bb
 
9897bb
     /* Process all child initialization nodes */
9897bb
 
9897bb
@@ -274,7 +283,8 @@ RsDoMemory32Descriptor (
9897bb
 
9897bb
         case 1:  /* Min Address */
9897bb
 
9897bb
-            Descriptor->Memory32.Minimum = (UINT32) InitializerOp->Asl.Value.Integer;
9897bb
+            Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->Memory32.Minimum = AcpiUtReadUint32 (&Tmp32);
9897bb
             RsCreateDwordField (InitializerOp, ACPI_RESTAG_MINADDR,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.Minimum));
9897bb
             MinOp = InitializerOp;
9897bb
@@ -282,7 +292,8 @@ RsDoMemory32Descriptor (
9897bb
 
9897bb
         case 2: /* Max Address */
9897bb
 
9897bb
-            Descriptor->Memory32.Maximum = (UINT32) InitializerOp->Asl.Value.Integer;
9897bb
+            Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->Memory32.Maximum = AcpiUtReadUint32 (&Tmp32);
9897bb
             RsCreateDwordField (InitializerOp, ACPI_RESTAG_MAXADDR,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.Maximum));
9897bb
             MaxOp = InitializerOp;
9897bb
@@ -290,7 +301,8 @@ RsDoMemory32Descriptor (
9897bb
 
9897bb
         case 3: /* Alignment */
9897bb
 
9897bb
-            Descriptor->Memory32.Alignment = (UINT32) InitializerOp->Asl.Value.Integer;
9897bb
+            Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->Memory32.Alignment = AcpiUtReadUint32 (&Tmp32);
9897bb
             RsCreateDwordField (InitializerOp, ACPI_RESTAG_ALIGNMENT,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.Alignment));
9897bb
             AlignOp = InitializerOp;
9897bb
@@ -298,7 +310,8 @@ RsDoMemory32Descriptor (
9897bb
 
9897bb
         case 4: /* Length */
9897bb
 
9897bb
-            Descriptor->Memory32.AddressLength = (UINT32) InitializerOp->Asl.Value.Integer;
9897bb
+            Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->Memory32.AddressLength = AcpiUtReadUint32 (&Tmp32);
9897bb
             RsCreateDwordField (InitializerOp, ACPI_RESTAG_LENGTH,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.AddressLength));
9897bb
             LengthOp = InitializerOp;
9897bb
@@ -321,10 +334,10 @@ RsDoMemory32Descriptor (
9897bb
     /* Validate the Min/Max/Len/Align values */
9897bb
 
9897bb
     RsSmallAddressCheck (ACPI_RESOURCE_NAME_MEMORY32,
9897bb
-        Descriptor->Memory32.Minimum,
9897bb
-        Descriptor->Memory32.Maximum,
9897bb
-        Descriptor->Memory32.AddressLength,
9897bb
-        Descriptor->Memory32.Alignment,
9897bb
+        AcpiUtReadUint32 (&Descriptor->Memory32.Minimum),
9897bb
+        AcpiUtReadUint32 (&Descriptor->Memory32.Maximum),
9897bb
+        AcpiUtReadUint32 (&Descriptor->Memory32.AddressLength),
9897bb
+        AcpiUtReadUint32 (&Descriptor->Memory32.Alignment),
9897bb
         MinOp, MaxOp, LengthOp, AlignOp, Info->DescriptorTypeOp);
9897bb
 
9897bb
     return (Rnode);
9897bb
@@ -352,6 +365,8 @@ RsDoMemory32FixedDescriptor (
9897bb
     ASL_RESOURCE_NODE       *Rnode;
9897bb
     UINT32                  CurrentByteOffset;
9897bb
     UINT32                  i;
9897bb
+    UINT16                  Tmp16;
9897bb
+    UINT32                  Tmp32;
9897bb
 
9897bb
 
9897bb
     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
9897bb
@@ -360,7 +375,8 @@ RsDoMemory32FixedDescriptor (
9897bb
 
9897bb
     Descriptor = Rnode->Buffer;
9897bb
     Descriptor->FixedMemory32.DescriptorType = ACPI_RESOURCE_NAME_FIXED_MEMORY32;
9897bb
-    Descriptor->FixedMemory32.ResourceLength = 9;
9897bb
+    Tmp16 = 9;
9897bb
+    Descriptor->FixedMemory32.ResourceLength = AcpiUtReadUint16 (&Tmp16);
9897bb
 
9897bb
     /* Process all child initialization nodes */
9897bb
 
9897bb
@@ -377,14 +393,16 @@ RsDoMemory32FixedDescriptor (
9897bb
 
9897bb
         case 1: /* Address */
9897bb
 
9897bb
-            Descriptor->FixedMemory32.Address = (UINT32) InitializerOp->Asl.Value.Integer;
9897bb
+            Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->FixedMemory32.Address = AcpiUtReadUint32 (&Tmp32);
9897bb
             RsCreateDwordField (InitializerOp, ACPI_RESTAG_BASEADDRESS,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (FixedMemory32.Address));
9897bb
             break;
9897bb
 
9897bb
         case 2: /* Length */
9897bb
 
9897bb
-            Descriptor->FixedMemory32.AddressLength = (UINT32) InitializerOp->Asl.Value.Integer;
9897bb
+            Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->FixedMemory32.AddressLength = AcpiUtReadUint32 (&Tmp32);
9897bb
             RsCreateDwordField (InitializerOp, ACPI_RESTAG_LENGTH,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (FixedMemory32.AddressLength));
9897bb
             break;
9897bb
Index: acpica-unix2-20210604/source/compiler/aslrestype1i.c
9897bb
===================================================================
9897bb
--- acpica-unix2-20210604.orig/source/compiler/aslrestype1i.c
9897bb
+++ acpica-unix2-20210604/source/compiler/aslrestype1i.c
9897bb
@@ -199,6 +199,7 @@ RsDoFixedDmaDescriptor (
9897bb
     ASL_RESOURCE_NODE       *Rnode;
9897bb
     UINT32                  CurrentByteOffset;
9897bb
     UINT32                  i;
9897bb
+    UINT16                  Tmp16;
9897bb
 
9897bb
 
9897bb
     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
9897bb
@@ -217,14 +218,16 @@ RsDoFixedDmaDescriptor (
9897bb
         {
9897bb
         case 0: /* DMA Request Lines [WORD] (_DMA) */
9897bb
 
9897bb
-            Descriptor->FixedDma.RequestLines = (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->FixedDma.RequestLines = AcpiUtReadUint16 (&Tmp16);
9897bb
             RsCreateWordField (InitializerOp, ACPI_RESTAG_DMA,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (FixedDma.RequestLines));
9897bb
             break;
9897bb
 
9897bb
         case 1: /* DMA Channel [WORD] (_TYP) */
9897bb
 
9897bb
-            Descriptor->FixedDma.Channels = (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->FixedDma.Channels = AcpiUtReadUint16 (&Tmp16);
9897bb
             RsCreateWordField (InitializerOp, ACPI_RESTAG_DMATYPE,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (FixedDma.Channels));
9897bb
             break;
9897bb
@@ -275,6 +278,7 @@ RsDoFixedIoDescriptor (
9897bb
     ASL_RESOURCE_NODE       *Rnode;
9897bb
     UINT32                  CurrentByteOffset;
9897bb
     UINT32                  i;
9897bb
+    UINT16                  Tmp16;
9897bb
 
9897bb
 
9897bb
     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
9897bb
@@ -293,8 +297,8 @@ RsDoFixedIoDescriptor (
9897bb
         {
9897bb
         case 0: /* Base Address */
9897bb
 
9897bb
-            Descriptor->FixedIo.Address =
9897bb
-                (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->FixedIo.Address = AcpiUtReadUint16 (&Tmp16);
9897bb
             RsCreateWordField (InitializerOp, ACPI_RESTAG_BASEADDRESS,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (FixedIo.Address));
9897bb
             AddressOp = InitializerOp;
9897bb
@@ -324,7 +328,7 @@ RsDoFixedIoDescriptor (
9897bb
 
9897bb
     /* Error checks */
9897bb
 
9897bb
-    if (Descriptor->FixedIo.Address > 0x03FF)
9897bb
+    if (AcpiUtReadUint16 (&Descriptor->FixedIo.Address) > 0x03FF)
9897bb
     {
9897bb
         AslError (ASL_WARNING, ASL_MSG_ISA_ADDRESS, AddressOp, NULL);
9897bb
     }
9897bb
@@ -358,6 +362,7 @@ RsDoIoDescriptor (
9897bb
     ASL_RESOURCE_NODE       *Rnode;
9897bb
     UINT32                  CurrentByteOffset;
9897bb
     UINT32                  i;
9897bb
+    UINT16                  Tmp16;
9897bb
 
9897bb
 
9897bb
     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
9897bb
@@ -383,8 +388,8 @@ RsDoIoDescriptor (
9897bb
 
9897bb
         case 1:  /* Min Address */
9897bb
 
9897bb
-            Descriptor->Io.Minimum =
9897bb
-                (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->Io.Minimum = AcpiUtReadUint16 (&Tmp16);
9897bb
             RsCreateWordField (InitializerOp, ACPI_RESTAG_MINADDR,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Io.Minimum));
9897bb
             MinOp = InitializerOp;
9897bb
@@ -392,8 +397,8 @@ RsDoIoDescriptor (
9897bb
 
9897bb
         case 2: /* Max Address */
9897bb
 
9897bb
-            Descriptor->Io.Maximum =
9897bb
-                (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->Io.Maximum = AcpiUtReadUint16 (&Tmp16);
9897bb
             RsCreateWordField (InitializerOp, ACPI_RESTAG_MAXADDR,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Io.Maximum));
9897bb
             MaxOp = InitializerOp;
9897bb
@@ -434,10 +439,10 @@ RsDoIoDescriptor (
9897bb
     /* Validate the Min/Max/Len/Align values */
9897bb
 
9897bb
     RsSmallAddressCheck (ACPI_RESOURCE_NAME_IO,
9897bb
-        Descriptor->Io.Minimum,
9897bb
-        Descriptor->Io.Maximum,
9897bb
-        Descriptor->Io.AddressLength,
9897bb
-        Descriptor->Io.Alignment,
9897bb
+        (UINT32) (AcpiUtReadUint16 (&Descriptor->Io.Minimum)),
9897bb
+        (UINT32) (AcpiUtReadUint16 (&Descriptor->Io.Maximum)),
9897bb
+        (UINT32) Descriptor->Io.AddressLength,
9897bb
+        (UINT32) Descriptor->Io.Alignment,
9897bb
         MinOp, MaxOp, LengthOp, AlignOp, Info->DescriptorTypeOp);
9897bb
 
9897bb
     return (Rnode);
9897bb
@@ -561,7 +566,7 @@ RsDoIrqDescriptor (
9897bb
 
9897bb
     /* Now we can set the channel mask */
9897bb
 
9897bb
-    Descriptor->Irq.IrqMask = IrqMask;
9897bb
+    Descriptor->Irq.IrqMask = AcpiUtReadUint16 (&IrqMask);
9897bb
     return (Rnode);
9897bb
 }
9897bb
 
9897bb
@@ -660,6 +665,6 @@ RsDoIrqNoFlagsDescriptor (
9897bb
 
9897bb
     /* Now we can set the interrupt mask */
9897bb
 
9897bb
-    Descriptor->Irq.IrqMask = IrqMask;
9897bb
+    Descriptor->Irq.IrqMask = AcpiUtReadUint16(&IrqMask);
9897bb
     return (Rnode);
9897bb
 }
9897bb
Index: acpica-unix2-20210604/source/compiler/aslrestype2.c
9897bb
===================================================================
9897bb
--- acpica-unix2-20210604.orig/source/compiler/aslrestype2.c
9897bb
+++ acpica-unix2-20210604/source/compiler/aslrestype2.c
9897bb
@@ -77,6 +77,8 @@ RsDoGeneralRegisterDescriptor (
9897bb
     ASL_RESOURCE_NODE       *Rnode;
9897bb
     UINT32                  CurrentByteOffset;
9897bb
     UINT32                  i;
9897bb
+    UINT16                  Tmp16;
9897bb
+    UINT64                  Tmp64;
9897bb
 
9897bb
 
9897bb
     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
9897bb
@@ -85,7 +87,8 @@ RsDoGeneralRegisterDescriptor (
9897bb
 
9897bb
     Descriptor = Rnode->Buffer;
9897bb
     Descriptor->GenericReg.DescriptorType = ACPI_RESOURCE_NAME_GENERIC_REGISTER;
9897bb
-    Descriptor->GenericReg.ResourceLength = 12;
9897bb
+    Tmp16 = 12;
9897bb
+    Descriptor->GenericReg.ResourceLength = AcpiUtReadUint16 (&Tmp16);
9897bb
 
9897bb
     /* Process all child initialization nodes */
9897bb
 
9897bb
@@ -116,7 +119,8 @@ RsDoGeneralRegisterDescriptor (
9897bb
 
9897bb
         case 3: /* Register Address */
9897bb
 
9897bb
-            Descriptor->GenericReg.Address = InitializerOp->Asl.Value.Integer;
9897bb
+            Tmp64 = InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->GenericReg.Address = AcpiUtReadUint64 (&Tmp64);
9897bb
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_ADDRESS,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (GenericReg.Address));
9897bb
             break;
9897bb
@@ -184,6 +188,8 @@ RsDoInterruptDescriptor (
9897bb
     BOOLEAN                 HasResSourceIndex = FALSE;
9897bb
     UINT8                   ResSourceIndex = 0;
9897bb
     UINT8                   *ResSourceString = NULL;
9897bb
+    UINT16                  Tmp16;
9897bb
+    UINT32                  Tmp32;
9897bb
 
9897bb
 
9897bb
     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
9897bb
@@ -225,7 +231,7 @@ RsDoInterruptDescriptor (
9897bb
      * Initial descriptor length -- may be enlarged if there are
9897bb
      * optional fields present
9897bb
      */
9897bb
-    Descriptor->ExtendedIrq.ResourceLength  = 2;  /* Flags and table length byte */
9897bb
+    Descriptor->ExtendedIrq.ResourceLength  = 2; /* Flags and table length byte */
9897bb
     Descriptor->ExtendedIrq.InterruptCount  = 0;
9897bb
 
9897bb
     Rover = ACPI_CAST_PTR (AML_RESOURCE,
9897bb
@@ -333,7 +339,8 @@ RsDoInterruptDescriptor (
9897bb
 
9897bb
             /* Save the integer and move pointer to the next one */
9897bb
 
9897bb
-            Rover->DwordItem = (UINT32) InitializerOp->Asl.Value.Integer;
9897bb
+            Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
9897bb
+            Rover->DwordItem = AcpiUtReadUint32 (&Tmp32);
9897bb
             Rover = ACPI_ADD_PTR (AML_RESOURCE, &(Rover->DwordItem), 4);
9897bb
             Descriptor->ExtendedIrq.InterruptCount++;
9897bb
             Descriptor->ExtendedIrq.ResourceLength += 4;
9897bb
@@ -384,6 +391,8 @@ RsDoInterruptDescriptor (
9897bb
         Descriptor->ExtendedIrq.ResourceLength = (UINT16)
9897bb
             (Descriptor->ExtendedIrq.ResourceLength + StringLength);
9897bb
     }
9897bb
+    Tmp16 = Descriptor->ExtendedIrq.ResourceLength;
9897bb
+    Descriptor->ExtendedIrq.ResourceLength  = AcpiUtReadUint16 (&Tmp16);
9897bb
 
9897bb
     Rnode->BufferLength =
9897bb
         (ASL_RESDESC_OFFSET (ExtendedIrq.Interrupts[0]) -
9897bb
@@ -436,7 +445,8 @@ RsDoVendorLargeDescriptor (
9897bb
 
9897bb
     Descriptor = Rnode->Buffer;
9897bb
     Descriptor->VendorLarge.DescriptorType = ACPI_RESOURCE_NAME_VENDOR_LARGE;
9897bb
-    Descriptor->VendorLarge.ResourceLength = (UINT16) i;
9897bb
+    AcpiUtWriteUint (&Descriptor->VendorLarge.ResourceLength, sizeof (UINT16),
9897bb
+            &i, sizeof (UINT32));
9897bb
 
9897bb
     /* Point to end-of-descriptor for vendor data */
9897bb
 
9897bb
Index: acpica-unix2-20210604/source/compiler/aslrestype2d.c
9897bb
===================================================================
9897bb
--- acpica-unix2-20210604.orig/source/compiler/aslrestype2d.c
9897bb
+++ acpica-unix2-20210604/source/compiler/aslrestype2d.c
9897bb
@@ -84,6 +84,8 @@ RsDoDwordIoDescriptor (
9897bb
     UINT32                  CurrentByteOffset;
9897bb
     UINT32                  i;
9897bb
     BOOLEAN                 ResSourceIndex = FALSE;
9897bb
+    UINT16                  Tmp16;
9897bb
+    UINT32                  Tmp32;
9897bb
 
9897bb
 
9897bb
     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
9897bb
@@ -147,8 +149,8 @@ RsDoDwordIoDescriptor (
9897bb
 
9897bb
         case 5: /* Address Granularity */
9897bb
 
9897bb
-            Descriptor->Address32.Granularity =
9897bb
-                (UINT32) InitializerOp->Asl.Value.Integer;
9897bb
+            Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->Address32.Granularity = AcpiUtReadUint32 (&Tmp32);
9897bb
             RsCreateDwordField (InitializerOp, ACPI_RESTAG_GRANULARITY,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Granularity));
9897bb
             GranOp = InitializerOp;
9897bb
@@ -156,8 +158,8 @@ RsDoDwordIoDescriptor (
9897bb
 
9897bb
         case 6: /* Address Min */
9897bb
 
9897bb
-            Descriptor->Address32.Minimum =
9897bb
-                (UINT32) InitializerOp->Asl.Value.Integer;
9897bb
+            Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->Address32.Minimum = AcpiUtReadUint32 (&Tmp32);
9897bb
             RsCreateDwordField (InitializerOp, ACPI_RESTAG_MINADDR,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Minimum));
9897bb
             MinOp = InitializerOp;
9897bb
@@ -165,8 +167,8 @@ RsDoDwordIoDescriptor (
9897bb
 
9897bb
         case 7: /* Address Max */
9897bb
 
9897bb
-            Descriptor->Address32.Maximum =
9897bb
-                (UINT32) InitializerOp->Asl.Value.Integer;
9897bb
+            Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->Address32.Maximum = AcpiUtReadUint32 (&Tmp32);
9897bb
             RsCreateDwordField (InitializerOp, ACPI_RESTAG_MAXADDR,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Maximum));
9897bb
             MaxOp = InitializerOp;
9897bb
@@ -174,16 +176,16 @@ RsDoDwordIoDescriptor (
9897bb
 
9897bb
         case 8: /* Translation Offset */
9897bb
 
9897bb
-            Descriptor->Address32.TranslationOffset =
9897bb
-                (UINT32) InitializerOp->Asl.Value.Integer;
9897bb
+            Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->Address32.TranslationOffset = AcpiUtReadUint32 (&Tmp32);
9897bb
             RsCreateDwordField (InitializerOp, ACPI_RESTAG_TRANSLATION,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.TranslationOffset));
9897bb
             break;
9897bb
 
9897bb
         case 9: /* Address Length */
9897bb
 
9897bb
-            Descriptor->Address32.AddressLength =
9897bb
-                (UINT32) InitializerOp->Asl.Value.Integer;
9897bb
+            Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->Address32.AddressLength = AcpiUtReadUint32 (&Tmp32);
9897bb
             RsCreateDwordField (InitializerOp, ACPI_RESTAG_LENGTH,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.AddressLength));
9897bb
             LengthOp = InitializerOp;
9897bb
@@ -271,11 +273,14 @@ RsDoDwordIoDescriptor (
9897bb
 
9897bb
     /* Validate the Min/Max/Len/Gran values */
9897bb
 
9897bb
+    Tmp16 = Descriptor->Address32.ResourceLength;
9897bb
+    Descriptor->Address32.ResourceLength = AcpiUtReadUint16 (&Tmp16);
9897bb
+
9897bb
     RsLargeAddressCheck (
9897bb
-        (UINT64) Descriptor->Address32.Minimum,
9897bb
-        (UINT64) Descriptor->Address32.Maximum,
9897bb
-        (UINT64) Descriptor->Address32.AddressLength,
9897bb
-        (UINT64) Descriptor->Address32.Granularity,
9897bb
+        (UINT64) AcpiUtReadUint32 (&Descriptor->Address32.Minimum),
9897bb
+        (UINT64) AcpiUtReadUint32 (&Descriptor->Address32.Maximum),
9897bb
+        (UINT64) AcpiUtReadUint32 (&Descriptor->Address32.AddressLength),
9897bb
+        (UINT64) AcpiUtReadUint32 (&Descriptor->Address32.Granularity),
9897bb
         Descriptor->Address32.Flags,
9897bb
         MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp);
9897bb
 
9897bb
@@ -314,6 +319,8 @@ RsDoDwordMemoryDescriptor (
9897bb
     UINT32                  CurrentByteOffset;
9897bb
     UINT32                  i;
9897bb
     BOOLEAN                 ResSourceIndex = FALSE;
9897bb
+    UINT16                  Tmp16;
9897bb
+    UINT32                  Tmp32;
9897bb
 
9897bb
 
9897bb
     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
9897bb
@@ -385,8 +392,8 @@ RsDoDwordMemoryDescriptor (
9897bb
 
9897bb
         case 6: /* Address Granularity */
9897bb
 
9897bb
-            Descriptor->Address32.Granularity =
9897bb
-                (UINT32) InitializerOp->Asl.Value.Integer;
9897bb
+            Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->Address32.Granularity = AcpiUtReadUint32 (&Tmp32);
9897bb
             RsCreateDwordField (InitializerOp, ACPI_RESTAG_GRANULARITY,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Granularity));
9897bb
             GranOp = InitializerOp;
9897bb
@@ -394,8 +401,8 @@ RsDoDwordMemoryDescriptor (
9897bb
 
9897bb
         case 7: /* Min Address */
9897bb
 
9897bb
-            Descriptor->Address32.Minimum =
9897bb
-                (UINT32) InitializerOp->Asl.Value.Integer;
9897bb
+            Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->Address32.Minimum = AcpiUtReadUint32 (&Tmp32);
9897bb
             RsCreateDwordField (InitializerOp, ACPI_RESTAG_MINADDR,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Minimum));
9897bb
             MinOp = InitializerOp;
9897bb
@@ -403,8 +410,8 @@ RsDoDwordMemoryDescriptor (
9897bb
 
9897bb
         case 8: /* Max Address */
9897bb
 
9897bb
-            Descriptor->Address32.Maximum =
9897bb
-                (UINT32) InitializerOp->Asl.Value.Integer;
9897bb
+            Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->Address32.Maximum = AcpiUtReadUint32 (&Tmp32);
9897bb
             RsCreateDwordField (InitializerOp, ACPI_RESTAG_MAXADDR,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Maximum));
9897bb
             MaxOp = InitializerOp;
9897bb
@@ -412,16 +419,16 @@ RsDoDwordMemoryDescriptor (
9897bb
 
9897bb
         case 9: /* Translation Offset */
9897bb
 
9897bb
-            Descriptor->Address32.TranslationOffset =
9897bb
-                (UINT32) InitializerOp->Asl.Value.Integer;
9897bb
+            Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->Address32.TranslationOffset = AcpiUtReadUint32 (&Tmp32);
9897bb
             RsCreateDwordField (InitializerOp, ACPI_RESTAG_TRANSLATION,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.TranslationOffset));
9897bb
             break;
9897bb
 
9897bb
         case 10: /* Address Length */
9897bb
 
9897bb
-            Descriptor->Address32.AddressLength =
9897bb
-                (UINT32) InitializerOp->Asl.Value.Integer;
9897bb
+            Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->Address32.AddressLength = AcpiUtReadUint32 (&Tmp32);
9897bb
             RsCreateDwordField (InitializerOp, ACPI_RESTAG_LENGTH,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.AddressLength));
9897bb
             LengthOp = InitializerOp;
9897bb
@@ -506,11 +513,14 @@ RsDoDwordMemoryDescriptor (
9897bb
 
9897bb
     /* Validate the Min/Max/Len/Gran values */
9897bb
 
9897bb
+    Tmp16 = Descriptor->Address32.ResourceLength;
9897bb
+    Descriptor->Address32.ResourceLength = AcpiUtReadUint16 (&Tmp16);
9897bb
+
9897bb
     RsLargeAddressCheck (
9897bb
-        (UINT64) Descriptor->Address32.Minimum,
9897bb
-        (UINT64) Descriptor->Address32.Maximum,
9897bb
-        (UINT64) Descriptor->Address32.AddressLength,
9897bb
-        (UINT64) Descriptor->Address32.Granularity,
9897bb
+        (UINT64) AcpiUtReadUint32 (&Descriptor->Address32.Minimum),
9897bb
+        (UINT64) AcpiUtReadUint32 (&Descriptor->Address32.Maximum),
9897bb
+        (UINT64) AcpiUtReadUint32 (&Descriptor->Address32.AddressLength),
9897bb
+        (UINT64) AcpiUtReadUint32 (&Descriptor->Address32.Granularity),
9897bb
         Descriptor->Address32.Flags,
9897bb
         MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp);
9897bb
 
9897bb
@@ -549,6 +559,8 @@ RsDoDwordSpaceDescriptor (
9897bb
     UINT32                  CurrentByteOffset;
9897bb
     UINT32                  i;
9897bb
     BOOLEAN                 ResSourceIndex = FALSE;
9897bb
+    UINT16                  Tmp16;
9897bb
+    UINT32                  Tmp32;
9897bb
 
9897bb
 
9897bb
     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
9897bb
@@ -616,8 +628,8 @@ RsDoDwordSpaceDescriptor (
9897bb
 
9897bb
         case 6: /* Address Granularity */
9897bb
 
9897bb
-            Descriptor->Address32.Granularity =
9897bb
-                (UINT32) InitializerOp->Asl.Value.Integer;
9897bb
+            Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->Address32.Granularity = AcpiUtReadUint32 (&Tmp32);
9897bb
             RsCreateDwordField (InitializerOp, ACPI_RESTAG_GRANULARITY,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Granularity));
9897bb
             GranOp = InitializerOp;
9897bb
@@ -625,8 +637,8 @@ RsDoDwordSpaceDescriptor (
9897bb
 
9897bb
         case 7: /* Min Address */
9897bb
 
9897bb
-            Descriptor->Address32.Minimum =
9897bb
-                (UINT32) InitializerOp->Asl.Value.Integer;
9897bb
+            Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->Address32.Minimum = AcpiUtReadUint32 (&Tmp32);
9897bb
             RsCreateDwordField (InitializerOp, ACPI_RESTAG_MINADDR,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Minimum));
9897bb
             MinOp = InitializerOp;
9897bb
@@ -634,8 +646,8 @@ RsDoDwordSpaceDescriptor (
9897bb
 
9897bb
         case 8: /* Max Address */
9897bb
 
9897bb
-            Descriptor->Address32.Maximum =
9897bb
-                (UINT32) InitializerOp->Asl.Value.Integer;
9897bb
+            Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->Address32.Maximum = AcpiUtReadUint32 (&Tmp32);
9897bb
             RsCreateDwordField (InitializerOp, ACPI_RESTAG_MAXADDR,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Maximum));
9897bb
             MaxOp = InitializerOp;
9897bb
@@ -643,16 +655,16 @@ RsDoDwordSpaceDescriptor (
9897bb
 
9897bb
         case 9: /* Translation Offset */
9897bb
 
9897bb
-            Descriptor->Address32.TranslationOffset =
9897bb
-                (UINT32) InitializerOp->Asl.Value.Integer;
9897bb
+            Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->Address32.TranslationOffset = AcpiUtReadUint32 (&Tmp32);
9897bb
             RsCreateDwordField (InitializerOp, ACPI_RESTAG_TRANSLATION,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.TranslationOffset));
9897bb
             break;
9897bb
 
9897bb
         case 10: /* Address Length */
9897bb
 
9897bb
-            Descriptor->Address32.AddressLength =
9897bb
-                (UINT32) InitializerOp->Asl.Value.Integer;
9897bb
+            Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->Address32.AddressLength = AcpiUtReadUint32 (&Tmp32);
9897bb
             RsCreateDwordField (InitializerOp, ACPI_RESTAG_LENGTH,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.AddressLength));
9897bb
             LengthOp = InitializerOp;
9897bb
@@ -723,11 +735,14 @@ RsDoDwordSpaceDescriptor (
9897bb
 
9897bb
     /* Validate the Min/Max/Len/Gran values */
9897bb
 
9897bb
+    Tmp16 = Descriptor->Address32.ResourceLength;
9897bb
+    Descriptor->Address32.ResourceLength = AcpiUtReadUint16 (&Tmp16);
9897bb
+
9897bb
     RsLargeAddressCheck (
9897bb
-        (UINT64) Descriptor->Address32.Minimum,
9897bb
-        (UINT64) Descriptor->Address32.Maximum,
9897bb
-        (UINT64) Descriptor->Address32.AddressLength,
9897bb
-        (UINT64) Descriptor->Address32.Granularity,
9897bb
+        (UINT64) AcpiUtReadUint32 (&Descriptor->Address32.Minimum),
9897bb
+        (UINT64) AcpiUtReadUint32 (&Descriptor->Address32.Maximum),
9897bb
+        (UINT64) AcpiUtReadUint32 (&Descriptor->Address32.AddressLength),
9897bb
+        (UINT64) AcpiUtReadUint32 (&Descriptor->Address32.Granularity),
9897bb
         Descriptor->Address32.Flags,
9897bb
         MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp);
9897bb
 
9897bb
Index: acpica-unix2-20210604/source/compiler/aslrestype2q.c
9897bb
===================================================================
9897bb
--- acpica-unix2-20210604.orig/source/compiler/aslrestype2q.c
9897bb
+++ acpica-unix2-20210604/source/compiler/aslrestype2q.c
9897bb
@@ -84,6 +84,7 @@ RsDoQwordIoDescriptor (
9897bb
     UINT32                  CurrentByteOffset;
9897bb
     UINT32                  i;
9897bb
     BOOLEAN                 ResSourceIndex = FALSE;
9897bb
+    UINT16                  Tmp16;
9897bb
 
9897bb
 
9897bb
     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
9897bb
@@ -147,7 +148,8 @@ RsDoQwordIoDescriptor (
9897bb
 
9897bb
         case 5: /* Address Granularity */
9897bb
 
9897bb
-            Descriptor->Address64.Granularity = InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->Address64.Granularity =
9897bb
+                AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
9897bb
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_GRANULARITY,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Granularity));
9897bb
             GranOp = InitializerOp;
9897bb
@@ -155,7 +157,8 @@ RsDoQwordIoDescriptor (
9897bb
 
9897bb
         case 6: /* Address Min */
9897bb
 
9897bb
-            Descriptor->Address64.Minimum = InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->Address64.Minimum =
9897bb
+                AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
9897bb
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_MINADDR,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Minimum));
9897bb
             MinOp = InitializerOp;
9897bb
@@ -163,7 +166,8 @@ RsDoQwordIoDescriptor (
9897bb
 
9897bb
         case 7: /* Address Max */
9897bb
 
9897bb
-            Descriptor->Address64.Maximum = InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->Address64.Maximum =
9897bb
+                AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
9897bb
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_MAXADDR,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Maximum));
9897bb
             MaxOp = InitializerOp;
9897bb
@@ -171,14 +175,16 @@ RsDoQwordIoDescriptor (
9897bb
 
9897bb
         case 8: /* Translation Offset */
9897bb
 
9897bb
-            Descriptor->Address64.TranslationOffset = InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->Address64.TranslationOffset =
9897bb
+                AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
9897bb
             RsCreateByteField (InitializerOp, ACPI_RESTAG_TRANSLATION,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.TranslationOffset));
9897bb
             break;
9897bb
 
9897bb
         case 9: /* Address Length */
9897bb
 
9897bb
-            Descriptor->Address64.AddressLength = InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->Address64.AddressLength =
9897bb
+                AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
9897bb
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_LENGTH,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.AddressLength));
9897bb
             LengthOp = InitializerOp;
9897bb
@@ -262,11 +268,14 @@ RsDoQwordIoDescriptor (
9897bb
 
9897bb
     /* Validate the Min/Max/Len/Gran values */
9897bb
 
9897bb
+    Tmp16 = Descriptor->Address64.ResourceLength;
9897bb
+    Descriptor->Address64.ResourceLength = AcpiUtReadUint16 (&Tmp16);
9897bb
+
9897bb
     RsLargeAddressCheck (
9897bb
-        Descriptor->Address64.Minimum,
9897bb
-        Descriptor->Address64.Maximum,
9897bb
-        Descriptor->Address64.AddressLength,
9897bb
-        Descriptor->Address64.Granularity,
9897bb
+        AcpiUtReadUint64 (&Descriptor->Address64.Minimum),
9897bb
+        AcpiUtReadUint64 (&Descriptor->Address64.Maximum),
9897bb
+        AcpiUtReadUint64 (&Descriptor->Address64.AddressLength),
9897bb
+        AcpiUtReadUint64 (&Descriptor->Address64.Granularity),
9897bb
         Descriptor->Address64.Flags,
9897bb
         MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp);
9897bb
 
9897bb
@@ -305,6 +314,7 @@ RsDoQwordMemoryDescriptor (
9897bb
     UINT32                  CurrentByteOffset;
9897bb
     UINT32                  i;
9897bb
     BOOLEAN                 ResSourceIndex = FALSE;
9897bb
+    UINT16                  Tmp16;
9897bb
 
9897bb
 
9897bb
     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
9897bb
@@ -375,7 +385,8 @@ RsDoQwordMemoryDescriptor (
9897bb
 
9897bb
         case 6: /* Address Granularity */
9897bb
 
9897bb
-            Descriptor->Address64.Granularity = InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->Address64.Granularity =
9897bb
+                AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
9897bb
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_GRANULARITY,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Granularity));
9897bb
             GranOp = InitializerOp;
9897bb
@@ -383,7 +394,8 @@ RsDoQwordMemoryDescriptor (
9897bb
 
9897bb
         case 7: /* Min Address */
9897bb
 
9897bb
-            Descriptor->Address64.Minimum = InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->Address64.Minimum =
9897bb
+                AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
9897bb
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_MINADDR,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Minimum));
9897bb
             MinOp = InitializerOp;
9897bb
@@ -391,7 +403,8 @@ RsDoQwordMemoryDescriptor (
9897bb
 
9897bb
         case 8: /* Max Address */
9897bb
 
9897bb
-            Descriptor->Address64.Maximum = InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->Address64.Maximum =
9897bb
+                AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
9897bb
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_MAXADDR,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Maximum));
9897bb
             MaxOp = InitializerOp;
9897bb
@@ -399,14 +412,16 @@ RsDoQwordMemoryDescriptor (
9897bb
 
9897bb
         case 9: /* Translation Offset */
9897bb
 
9897bb
-            Descriptor->Address64.TranslationOffset = InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->Address64.TranslationOffset =
9897bb
+                AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
9897bb
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_TRANSLATION,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.TranslationOffset));
9897bb
             break;
9897bb
 
9897bb
         case 10: /* Address Length */
9897bb
 
9897bb
-            Descriptor->Address64.AddressLength = InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->Address64.AddressLength =
9897bb
+                AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
9897bb
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_LENGTH,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.AddressLength));
9897bb
             LengthOp = InitializerOp;
9897bb
@@ -491,11 +506,14 @@ RsDoQwordMemoryDescriptor (
9897bb
 
9897bb
     /* Validate the Min/Max/Len/Gran values */
9897bb
 
9897bb
+    Tmp16 = Descriptor->Address64.ResourceLength;
9897bb
+    Descriptor->Address64.ResourceLength = AcpiUtReadUint16 (&Tmp16);
9897bb
+
9897bb
     RsLargeAddressCheck (
9897bb
-        Descriptor->Address64.Minimum,
9897bb
-        Descriptor->Address64.Maximum,
9897bb
-        Descriptor->Address64.AddressLength,
9897bb
-        Descriptor->Address64.Granularity,
9897bb
+        AcpiUtReadUint64 (&Descriptor->Address64.Minimum),
9897bb
+        AcpiUtReadUint64 (&Descriptor->Address64.Maximum),
9897bb
+        AcpiUtReadUint64 (&Descriptor->Address64.AddressLength),
9897bb
+        AcpiUtReadUint64 (&Descriptor->Address64.Granularity),
9897bb
         Descriptor->Address64.Flags,
9897bb
         MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp);
9897bb
 
9897bb
@@ -534,6 +552,7 @@ RsDoQwordSpaceDescriptor (
9897bb
     UINT32                  CurrentByteOffset;
9897bb
     UINT32                  i;
9897bb
     BOOLEAN                 ResSourceIndex = FALSE;
9897bb
+    UINT16                  Tmp16;
9897bb
 
9897bb
 
9897bb
     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
9897bb
@@ -601,7 +620,8 @@ RsDoQwordSpaceDescriptor (
9897bb
 
9897bb
         case 6: /* Address Granularity */
9897bb
 
9897bb
-            Descriptor->Address64.Granularity = InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->Address64.Granularity =
9897bb
+                AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
9897bb
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_GRANULARITY,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Granularity));
9897bb
             GranOp = InitializerOp;
9897bb
@@ -609,7 +629,8 @@ RsDoQwordSpaceDescriptor (
9897bb
 
9897bb
         case 7: /* Min Address */
9897bb
 
9897bb
-            Descriptor->Address64.Minimum = InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->Address64.Minimum =
9897bb
+                AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
9897bb
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_MINADDR,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Minimum));
9897bb
             MinOp = InitializerOp;
9897bb
@@ -617,7 +638,8 @@ RsDoQwordSpaceDescriptor (
9897bb
 
9897bb
         case 8: /* Max Address */
9897bb
 
9897bb
-            Descriptor->Address64.Maximum = InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->Address64.Maximum =
9897bb
+                AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
9897bb
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_MAXADDR,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Maximum));
9897bb
             MaxOp = InitializerOp;
9897bb
@@ -625,14 +647,16 @@ RsDoQwordSpaceDescriptor (
9897bb
 
9897bb
         case 9: /* Translation Offset */
9897bb
 
9897bb
-            Descriptor->Address64.TranslationOffset = InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->Address64.TranslationOffset =
9897bb
+                AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
9897bb
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_TRANSLATION,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.TranslationOffset));
9897bb
             break;
9897bb
 
9897bb
         case 10: /* Address Length */
9897bb
 
9897bb
-            Descriptor->Address64.AddressLength = InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->Address64.AddressLength =
9897bb
+                AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
9897bb
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_LENGTH,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.AddressLength));
9897bb
             LengthOp = InitializerOp;
9897bb
@@ -702,11 +726,14 @@ RsDoQwordSpaceDescriptor (
9897bb
 
9897bb
     /* Validate the Min/Max/Len/Gran values */
9897bb
 
9897bb
+    Tmp16 = Descriptor->Address64.ResourceLength;
9897bb
+    Descriptor->Address64.ResourceLength = AcpiUtReadUint16 (&Tmp16);
9897bb
+
9897bb
     RsLargeAddressCheck (
9897bb
-        Descriptor->Address64.Minimum,
9897bb
-        Descriptor->Address64.Maximum,
9897bb
-        Descriptor->Address64.AddressLength,
9897bb
-        Descriptor->Address64.Granularity,
9897bb
+        AcpiUtReadUint64 (&Descriptor->Address64.Minimum),
9897bb
+        AcpiUtReadUint64 (&Descriptor->Address64.Maximum),
9897bb
+        AcpiUtReadUint64 (&Descriptor->Address64.AddressLength),
9897bb
+        AcpiUtReadUint64 (&Descriptor->Address64.Granularity),
9897bb
         Descriptor->Address64.Flags,
9897bb
         MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp);
9897bb
 
9897bb
Index: acpica-unix2-20210604/source/compiler/aslrestype2w.c
9897bb
===================================================================
9897bb
--- acpica-unix2-20210604.orig/source/compiler/aslrestype2w.c
9897bb
+++ acpica-unix2-20210604/source/compiler/aslrestype2w.c
9897bb
@@ -84,6 +84,7 @@ RsDoWordIoDescriptor (
9897bb
     UINT32                  CurrentByteOffset;
9897bb
     UINT32                  i;
9897bb
     BOOLEAN                 ResSourceIndex = FALSE;
9897bb
+    UINT16                  Tmp16;
9897bb
 
9897bb
 
9897bb
     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
9897bb
@@ -147,7 +148,8 @@ RsDoWordIoDescriptor (
9897bb
 
9897bb
         case 5: /* Address Granularity */
9897bb
 
9897bb
-            Descriptor->Address16.Granularity = (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->Address16.Granularity = AcpiUtReadUint16 (&Tmp16);
9897bb
             RsCreateWordField (InitializerOp, ACPI_RESTAG_GRANULARITY,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Granularity));
9897bb
             GranOp = InitializerOp;
9897bb
@@ -155,7 +157,8 @@ RsDoWordIoDescriptor (
9897bb
 
9897bb
         case 6: /* Address Min */
9897bb
 
9897bb
-            Descriptor->Address16.Minimum = (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->Address16.Minimum = AcpiUtReadUint16 (&Tmp16);
9897bb
             RsCreateWordField (InitializerOp, ACPI_RESTAG_MINADDR,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Minimum));
9897bb
             MinOp = InitializerOp;
9897bb
@@ -163,7 +166,8 @@ RsDoWordIoDescriptor (
9897bb
 
9897bb
         case 7: /* Address Max */
9897bb
 
9897bb
-            Descriptor->Address16.Maximum = (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->Address16.Maximum = AcpiUtReadUint16 (&Tmp16);
9897bb
             RsCreateWordField (InitializerOp, ACPI_RESTAG_MAXADDR,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Maximum));
9897bb
             MaxOp = InitializerOp;
9897bb
@@ -171,14 +175,16 @@ RsDoWordIoDescriptor (
9897bb
 
9897bb
         case 8: /* Translation Offset */
9897bb
 
9897bb
-            Descriptor->Address16.TranslationOffset = (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->Address16.TranslationOffset = AcpiUtReadUint16 (&Tmp16);
9897bb
             RsCreateWordField (InitializerOp, ACPI_RESTAG_TRANSLATION,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.TranslationOffset));
9897bb
             break;
9897bb
 
9897bb
         case 9: /* Address Length */
9897bb
 
9897bb
-            Descriptor->Address16.AddressLength = (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->Address16.AddressLength = AcpiUtReadUint16 (&Tmp16);
9897bb
             RsCreateWordField (InitializerOp, ACPI_RESTAG_LENGTH,
9897bb
                  CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.AddressLength));
9897bb
             LengthOp = InitializerOp;
9897bb
@@ -263,13 +269,17 @@ RsDoWordIoDescriptor (
9897bb
     /* Validate the Min/Max/Len/Gran values */
9897bb
 
9897bb
     RsLargeAddressCheck (
9897bb
-        (UINT64) Descriptor->Address16.Minimum,
9897bb
-        (UINT64) Descriptor->Address16.Maximum,
9897bb
-        (UINT64) Descriptor->Address16.AddressLength,
9897bb
-        (UINT64) Descriptor->Address16.Granularity,
9897bb
+        (UINT64) AcpiUtReadUint16 (&Descriptor->Address16.Minimum),
9897bb
+        (UINT64) AcpiUtReadUint16 (&Descriptor->Address16.Maximum),
9897bb
+        (UINT64) AcpiUtReadUint16 (&Descriptor->Address16.AddressLength),
9897bb
+        (UINT64) AcpiUtReadUint16 (&Descriptor->Address16.Granularity),
9897bb
         Descriptor->Address16.Flags,
9897bb
         MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp);
9897bb
 
9897bb
+    /* correct enddianness */
9897bb
+    Tmp16 = Descriptor->Address16.ResourceLength;
9897bb
+    Descriptor->Address16.ResourceLength = AcpiUtReadUint16 (&Tmp16);
9897bb
+
9897bb
     Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS16) +
9897bb
         OptionIndex + StringLength;
9897bb
     return (Rnode);
9897bb
@@ -305,6 +315,7 @@ RsDoWordBusNumberDescriptor (
9897bb
     UINT32                  CurrentByteOffset;
9897bb
     UINT32                  i;
9897bb
     BOOLEAN                 ResSourceIndex = FALSE;
9897bb
+    UINT16                  Tmp16;
9897bb
 
9897bb
 
9897bb
     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
9897bb
@@ -361,8 +372,8 @@ RsDoWordBusNumberDescriptor (
9897bb
 
9897bb
         case 4: /* Address Granularity */
9897bb
 
9897bb
-            Descriptor->Address16.Granularity =
9897bb
-                (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->Address16.Granularity = AcpiUtReadUint16 (&Tmp16);
9897bb
             RsCreateWordField (InitializerOp, ACPI_RESTAG_GRANULARITY,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Granularity));
9897bb
             GranOp = InitializerOp;
9897bb
@@ -370,8 +381,8 @@ RsDoWordBusNumberDescriptor (
9897bb
 
9897bb
         case 5: /* Min Address */
9897bb
 
9897bb
-            Descriptor->Address16.Minimum =
9897bb
-                (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->Address16.Minimum = AcpiUtReadUint16 (&Tmp16);
9897bb
             RsCreateWordField (InitializerOp, ACPI_RESTAG_MINADDR,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Minimum));
9897bb
             MinOp = InitializerOp;
9897bb
@@ -379,8 +390,8 @@ RsDoWordBusNumberDescriptor (
9897bb
 
9897bb
         case 6: /* Max Address */
9897bb
 
9897bb
-            Descriptor->Address16.Maximum =
9897bb
-                (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->Address16.Maximum = AcpiUtReadUint16 (&Tmp16);
9897bb
             RsCreateWordField (InitializerOp, ACPI_RESTAG_MAXADDR,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Maximum));
9897bb
             MaxOp = InitializerOp;
9897bb
@@ -388,16 +399,16 @@ RsDoWordBusNumberDescriptor (
9897bb
 
9897bb
         case 7: /* Translation Offset */
9897bb
 
9897bb
-            Descriptor->Address16.TranslationOffset =
9897bb
-                (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->Address16.TranslationOffset = AcpiUtReadUint16 (&Tmp16);
9897bb
             RsCreateWordField (InitializerOp, ACPI_RESTAG_TRANSLATION,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.TranslationOffset));
9897bb
             break;
9897bb
 
9897bb
         case 8: /* Address Length */
9897bb
 
9897bb
-            Descriptor->Address16.AddressLength =
9897bb
-                (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->Address16.AddressLength = AcpiUtReadUint16 (&Tmp16);
9897bb
             RsCreateWordField (InitializerOp, ACPI_RESTAG_LENGTH,
9897bb
                  CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.AddressLength));
9897bb
             LengthOp = InitializerOp;
9897bb
@@ -468,13 +479,17 @@ RsDoWordBusNumberDescriptor (
9897bb
     /* Validate the Min/Max/Len/Gran values */
9897bb
 
9897bb
     RsLargeAddressCheck (
9897bb
-        (UINT64) Descriptor->Address16.Minimum,
9897bb
-        (UINT64) Descriptor->Address16.Maximum,
9897bb
-        (UINT64) Descriptor->Address16.AddressLength,
9897bb
-        (UINT64) Descriptor->Address16.Granularity,
9897bb
+        (UINT64) AcpiUtReadUint16 (&Descriptor->Address16.Minimum),
9897bb
+        (UINT64) AcpiUtReadUint16 (&Descriptor->Address16.Maximum),
9897bb
+        (UINT64) AcpiUtReadUint16 (&Descriptor->Address16.AddressLength),
9897bb
+        (UINT64) AcpiUtReadUint16 (&Descriptor->Address16.Granularity),
9897bb
         Descriptor->Address16.Flags,
9897bb
         MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp);
9897bb
 
9897bb
+    /* correct enddianness */
9897bb
+    Tmp16 = Descriptor->Address16.ResourceLength;
9897bb
+    Descriptor->Address16.ResourceLength = AcpiUtReadUint16 (&Tmp16);
9897bb
+
9897bb
     Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS16) +
9897bb
         OptionIndex + StringLength;
9897bb
     return (Rnode);
9897bb
@@ -510,6 +525,7 @@ RsDoWordSpaceDescriptor (
9897bb
     UINT32                  CurrentByteOffset;
9897bb
     UINT32                  i;
9897bb
     BOOLEAN                 ResSourceIndex = FALSE;
9897bb
+    UINT16                  Tmp16;
9897bb
 
9897bb
 
9897bb
     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
9897bb
@@ -577,8 +593,8 @@ RsDoWordSpaceDescriptor (
9897bb
 
9897bb
         case 6: /* Address Granularity */
9897bb
 
9897bb
-            Descriptor->Address16.Granularity =
9897bb
-                (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->Address16.Granularity = AcpiUtReadUint16 (&Tmp16);
9897bb
             RsCreateWordField (InitializerOp, ACPI_RESTAG_GRANULARITY,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Granularity));
9897bb
             GranOp = InitializerOp;
9897bb
@@ -586,8 +602,8 @@ RsDoWordSpaceDescriptor (
9897bb
 
9897bb
         case 7: /* Min Address */
9897bb
 
9897bb
-            Descriptor->Address16.Minimum =
9897bb
-                (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->Address16.Minimum = AcpiUtReadUint16 (&Tmp16);
9897bb
             RsCreateWordField (InitializerOp, ACPI_RESTAG_MINADDR,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Minimum));
9897bb
             MinOp = InitializerOp;
9897bb
@@ -595,8 +611,8 @@ RsDoWordSpaceDescriptor (
9897bb
 
9897bb
         case 8: /* Max Address */
9897bb
 
9897bb
-            Descriptor->Address16.Maximum =
9897bb
-                (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->Address16.Maximum = AcpiUtReadUint16 (&Tmp16);
9897bb
             RsCreateWordField (InitializerOp, ACPI_RESTAG_MAXADDR,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Maximum));
9897bb
             MaxOp = InitializerOp;
9897bb
@@ -604,16 +620,16 @@ RsDoWordSpaceDescriptor (
9897bb
 
9897bb
         case 9: /* Translation Offset */
9897bb
 
9897bb
-            Descriptor->Address16.TranslationOffset =
9897bb
-                (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->Address16.TranslationOffset = AcpiUtReadUint16 (&Tmp16);
9897bb
             RsCreateWordField (InitializerOp, ACPI_RESTAG_TRANSLATION,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.TranslationOffset));
9897bb
             break;
9897bb
 
9897bb
         case 10: /* Address Length */
9897bb
 
9897bb
-            Descriptor->Address16.AddressLength =
9897bb
-                (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->Address16.AddressLength = AcpiUtReadUint16 (&Tmp16);
9897bb
             RsCreateWordField (InitializerOp, ACPI_RESTAG_LENGTH,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.AddressLength));
9897bb
             LengthOp = InitializerOp;
9897bb
@@ -684,13 +700,17 @@ RsDoWordSpaceDescriptor (
9897bb
     /* Validate the Min/Max/Len/Gran values */
9897bb
 
9897bb
     RsLargeAddressCheck (
9897bb
-        (UINT64) Descriptor->Address16.Minimum,
9897bb
-        (UINT64) Descriptor->Address16.Maximum,
9897bb
-        (UINT64) Descriptor->Address16.AddressLength,
9897bb
-        (UINT64) Descriptor->Address16.Granularity,
9897bb
+        (UINT64) AcpiUtReadUint16 (&Descriptor->Address16.Minimum),
9897bb
+        (UINT64) AcpiUtReadUint16 (&Descriptor->Address16.Maximum),
9897bb
+        (UINT64) AcpiUtReadUint16 (&Descriptor->Address16.AddressLength),
9897bb
+        (UINT64) AcpiUtReadUint16 (&Descriptor->Address16.Granularity),
9897bb
         Descriptor->Address16.Flags,
9897bb
         MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp);
9897bb
 
9897bb
+    /* correct enddianness */
9897bb
+    Tmp16 = Descriptor->Address16.ResourceLength;
9897bb
+    Descriptor->Address16.ResourceLength = AcpiUtReadUint16 (&Tmp16);
9897bb
+
9897bb
     Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS16) +
9897bb
         OptionIndex + StringLength;
9897bb
     return (Rnode);
9897bb
Index: acpica-unix2-20210604/source/compiler/dttable2.c
9897bb
===================================================================
9897bb
--- acpica-unix2-20210604.orig/source/compiler/dttable2.c
9897bb
+++ acpica-unix2-20210604/source/compiler/dttable2.c
9897bb
@@ -2635,7 +2635,8 @@ DtCompileWpbt (
9897bb
 
9897bb
     /* Extract the length of the Arguments buffer, insert into main table */
9897bb
 
9897bb
-    Length = (UINT16) Subtable->TotalLength;
9897bb
+    AcpiUtWriteUint (&Length, sizeof (UINT16),
9897bb
+           &Subtable->TotalLength, sizeof (UINT32));
9897bb
     Table = ACPI_CAST_PTR (ACPI_TABLE_WPBT, ParentTable->Buffer);
9897bb
     Table->ArgumentsLength = Length;
9897bb
 
9897bb
Index: acpica-unix2-20210604/source/components/disassembler/dmbuffer.c
9897bb
===================================================================
9897bb
--- acpica-unix2-20210604.orig/source/components/disassembler/dmbuffer.c
9897bb
+++ acpica-unix2-20210604/source/components/disassembler/dmbuffer.c
9897bb
@@ -204,7 +204,7 @@ AcpiDmByteList (
9897bb
 
9897bb
 
9897bb
     ByteData = Op->Named.Data;
9897bb
-    ByteCount = (UINT32) Op->Common.Value.Integer;
9897bb
+    ByteCount = (UINT32) Op->Common.Value.Size;
9897bb
 
9897bb
     /*
9897bb
      * The byte list belongs to a buffer, and can be produced by either
9897bb
@@ -308,7 +308,7 @@ AcpiDmIsUuidBuffer (
9897bb
     /* Extract the byte list info */
9897bb
 
9897bb
     ByteData = NextOp->Named.Data;
9897bb
-    ByteCount = (UINT32) NextOp->Common.Value.Integer;
9897bb
+    ByteCount = (UINT32) NextOp->Common.Value.Size;
9897bb
 
9897bb
     /* Byte count must be exactly 16 */
9897bb
 
9897bb
@@ -436,7 +436,7 @@ AcpiDmIsUnicodeBuffer (
9897bb
     /* Extract the byte list info */
9897bb
 
9897bb
     ByteData = NextOp->Named.Data;
9897bb
-    ByteCount = (UINT32) NextOp->Common.Value.Integer;
9897bb
+    ByteCount = (UINT32) NextOp->Common.Value.Size;
9897bb
     WordCount = ACPI_DIV_2 (ByteCount);
9897bb
 
9897bb
     /*
9897bb
@@ -878,14 +878,14 @@ AcpiDmUnicode (
9897bb
     /* Extract the buffer info as a WORD buffer */
9897bb
 
9897bb
     WordData = ACPI_CAST_PTR (UINT16, Op->Named.Data);
9897bb
-    WordCount = ACPI_DIV_2 (((UINT32) Op->Common.Value.Integer));
9897bb
+    WordCount = ACPI_DIV_2 (((UINT32) Op->Common.Value.Size));
9897bb
 
9897bb
     /* Write every other byte as an ASCII character */
9897bb
 
9897bb
     AcpiOsPrintf ("\"");
9897bb
     for (i = 0; i < (WordCount - 1); i++)
9897bb
     {
9897bb
-        OutputValue = (int) WordData[i];
9897bb
+        OutputValue = (int) AcpiUtReadUint16 (&WordData[i]);
9897bb
 
9897bb
         /* Handle values that must be escaped */
9897bb
 
9897bb
@@ -947,7 +947,29 @@ AcpiDmGetHardwareIdType (
9897bb
 
9897bb
         /* Swap from little-endian to big-endian to simplify conversion */
9897bb
 
9897bb
-        BigEndianId = AcpiUtDwordByteSwap ((UINT32) Op->Common.Value.Integer);
9897bb
+        BigEndianId = (UINT32) Op->Common.Value.Integer;
9897bb
+        if (UtIsBigEndianMachine())
9897bb
+        {
9897bb
+            /*
9897bb
+             * We'll need to store the bytes in little-endian order
9897bb
+             * so they can be re-used properly later since everything is
9897bb
+             * assumed to be in little-endian form.
9897bb
+             */
9897bb
+
9897bb
+	     UINT32 *Ptr = (UINT32 *)(&Op->Common.Value.Integer);
9897bb
+	     *Ptr = AcpiUtDwordByteSwap (BigEndianId);
9897bb
+        }
9897bb
+        else
9897bb
+        {
9897bb
+            /*
9897bb
+             * We'll need to just use the bytes in big-endian order;
9897bb
+             * they're already in little-endian order.
9897bb
+             */
9897bb
+
9897bb
+            UINT32 Tmp32 = BigEndianId;
9897bb
+
9897bb
+            BigEndianId = AcpiUtDwordByteSwap ((UINT32) Tmp32);
9897bb
+        }
9897bb
 
9897bb
         /* Create the 3 leading ASCII letters */
9897bb
 
9897bb
@@ -1073,11 +1095,12 @@ AcpiDmDecompressEisaId (
9897bb
 {
9897bb
     char                    IdBuffer[ACPI_EISAID_STRING_SIZE];
9897bb
     const AH_DEVICE_ID      *Info;
9897bb
+    UINT32                  Tmp32 = EncodedId;
9897bb
 
9897bb
 
9897bb
     /* Convert EISAID to a string an emit the statement */
9897bb
 
9897bb
-    AcpiExEisaIdToString (IdBuffer, EncodedId);
9897bb
+    AcpiExEisaIdToString (IdBuffer, AcpiUtReadUint32 (&Tmp32));
9897bb
     AcpiOsPrintf ("EisaId (\"%s\")", IdBuffer);
9897bb
 
9897bb
     /* If we know about the ID, emit the description */
9897bb
Index: acpica-unix2-20210604/source/components/disassembler/dmopcode.c
9897bb
===================================================================
9897bb
--- acpica-unix2-20210604.orig/source/components/disassembler/dmopcode.c
9897bb
+++ acpica-unix2-20210604/source/components/disassembler/dmopcode.c
9897bb
@@ -778,7 +778,9 @@ AcpiDmDisassembleOneOp (
9897bb
         }
9897bb
         else
9897bb
         {
9897bb
-            AcpiOsPrintf ("0x%4.4X", (UINT32) Op->Common.Value.Integer);
9897bb
+            UINT16 Tmp16 = (UINT16) Op->Common.Value.Integer;
9897bb
+
9897bb
+            AcpiOsPrintf ("0x%4.4X", (UINT32) AcpiUtReadUint16 (&Tmp16));
9897bb
         }
9897bb
         break;
9897bb
 
9897bb
@@ -790,14 +792,19 @@ AcpiDmDisassembleOneOp (
9897bb
         }
9897bb
         else
9897bb
         {
9897bb
-            AcpiOsPrintf ("0x%8.8X", (UINT32) Op->Common.Value.Integer);
9897bb
+            UINT32 Tmp32 = (UINT32) Op->Common.Value.Integer;
9897bb
+
9897bb
+            AcpiOsPrintf ("0x%8.8X", (UINT32) AcpiUtReadUint32 (&Tmp32));
9897bb
         }
9897bb
         break;
9897bb
 
9897bb
     case AML_QWORD_OP:
9897bb
 
9897bb
-        AcpiOsPrintf ("0x%8.8X%8.8X",
9897bb
-            ACPI_FORMAT_UINT64 (Op->Common.Value.Integer));
9897bb
+        {
9897bb
+	    UINT64 Tmp64 = AcpiUtReadUint64 (&Op->Common.Value.Integer);
9897bb
+
9897bb
+            AcpiOsPrintf ("0x%8.8X%8.8X", ACPI_FORMAT_UINT64 (Tmp64));
9897bb
+        }
9897bb
         break;
9897bb
 
9897bb
     case AML_STRING_OP:
9897bb
@@ -887,18 +894,18 @@ AcpiDmDisassembleOneOp (
9897bb
         AcpiOsPrintf (",");
9897bb
         ASL_CV_PRINT_ONE_COMMENT (Op, AML_NAMECOMMENT, NULL, 0);
9897bb
         AcpiOsPrintf ("%*.s  %u", (unsigned) (5 - Length), " ",
9897bb
-            (UINT32) Op->Common.Value.Integer);
9897bb
+            (UINT32) Op->Common.Value.Size);
9897bb
 
9897bb
         AcpiDmCommaIfFieldMember (Op);
9897bb
 
9897bb
-        Info->BitOffset += (UINT32) Op->Common.Value.Integer;
9897bb
+        Info->BitOffset += (UINT32) Op->Common.Value.Size;
9897bb
         break;
9897bb
 
9897bb
     case AML_INT_RESERVEDFIELD_OP:
9897bb
 
9897bb
         /* Offset() -- Must account for previous offsets */
9897bb
 
9897bb
-        Offset = (UINT32) Op->Common.Value.Integer;
9897bb
+        Offset = (UINT32) Op->Common.Value.Size;
9897bb
         Info->BitOffset += Offset;
9897bb
 
9897bb
         if (Info->BitOffset % 8 == 0)
9897bb
Index: acpica-unix2-20210604/source/components/disassembler/dmresrc.c
9897bb
===================================================================
9897bb
--- acpica-unix2-20210604.orig/source/components/disassembler/dmresrc.c
9897bb
+++ acpica-unix2-20210604/source/components/disassembler/dmresrc.c
9897bb
@@ -417,7 +417,7 @@ AcpiDmIsResourceTemplate (
9897bb
         return (AE_TYPE);
9897bb
     }
9897bb
 
9897bb
-    DeclaredBufferLength = NextOp->Common.Value.Size;
9897bb
+    DeclaredBufferLength = NextOp->Common.Value.Integer;
9897bb
 
9897bb
     /* Get the length of the raw initialization byte list */
9897bb
 
9897bb
Index: acpica-unix2-20210604/source/components/disassembler/dmresrcl.c
9897bb
===================================================================
9897bb
--- acpica-unix2-20210604.orig/source/components/disassembler/dmresrcl.c
9897bb
+++ acpica-unix2-20210604/source/components/disassembler/dmresrcl.c
9897bb
@@ -141,6 +141,8 @@ AcpiDmMemoryFields (
9897bb
     UINT32                  Level)
9897bb
 {
9897bb
     UINT32                  i;
9897bb
+    UINT16                  Tmp16;
9897bb
+    UINT32                  Tmp32;
9897bb
 
9897bb
 
9897bb
     for (i = 0; i < 4; i++)
9897bb
@@ -151,14 +153,16 @@ AcpiDmMemoryFields (
9897bb
         {
9897bb
         case 16:
9897bb
 
9897bb
-            AcpiDmDumpInteger16 (ACPI_CAST_PTR (UINT16, Source)[i],
9897bb
-                AcpiDmMemoryNames[i]);
9897bb
+            Tmp16 = ACPI_CAST_PTR (UINT16, Source)[i];
9897bb
+            AcpiDmDumpInteger16 (AcpiUtReadUint16 (&Tmp16),
9897bb
+                     AcpiDmMemoryNames[i]);
9897bb
             break;
9897bb
 
9897bb
         case 32:
9897bb
 
9897bb
-            AcpiDmDumpInteger32 (ACPI_CAST_PTR (UINT32, Source)[i],
9897bb
-                AcpiDmMemoryNames[i]);
9897bb
+            Tmp32 = ACPI_CAST_PTR (UINT32, Source)[i];
9897bb
+            AcpiDmDumpInteger32 (AcpiUtReadUint32 (&Tmp32),
9897bb
+                     AcpiDmMemoryNames[i]);
9897bb
             break;
9897bb
 
9897bb
         default:
9897bb
@@ -190,6 +194,9 @@ AcpiDmAddressFields (
9897bb
     UINT32                  Level)
9897bb
 {
9897bb
     UINT32                  i;
9897bb
+    UINT16                  Tmp16;
9897bb
+    UINT32                  Tmp32;
9897bb
+    UINT64                  Tmp64;
9897bb
 
9897bb
 
9897bb
     AcpiOsPrintf ("\n");
9897bb
@@ -202,20 +209,23 @@ AcpiDmAddressFields (
9897bb
         {
9897bb
         case 16:
9897bb
 
9897bb
-            AcpiDmDumpInteger16 (ACPI_CAST_PTR (UINT16, Source)[i],
9897bb
-                AcpiDmAddressNames[i]);
9897bb
+            Tmp16 = ACPI_CAST_PTR (UINT16, Source)[i];
9897bb
+            AcpiDmDumpInteger16 (AcpiUtReadUint16 (&Tmp16),
9897bb
+                         AcpiDmAddressNames[i]);
9897bb
             break;
9897bb
 
9897bb
         case 32:
9897bb
 
9897bb
-            AcpiDmDumpInteger32 (ACPI_CAST_PTR (UINT32, Source)[i],
9897bb
-                AcpiDmAddressNames[i]);
9897bb
+            Tmp32 = ACPI_CAST_PTR (UINT32, Source)[i];
9897bb
+            AcpiDmDumpInteger32 (AcpiUtReadUint32 (&Tmp32),
9897bb
+                         AcpiDmAddressNames[i]);
9897bb
             break;
9897bb
 
9897bb
         case 64:
9897bb
 
9897bb
-            AcpiDmDumpInteger64 (ACPI_CAST_PTR (UINT64, Source)[i],
9897bb
-                AcpiDmAddressNames[i]);
9897bb
+            Tmp64 = ACPI_CAST_PTR (UINT64, Source)[i];
9897bb
+            AcpiDmDumpInteger64 (AcpiUtReadUint64 (&Tmp64),
9897bb
+                         AcpiDmAddressNames[i]);
9897bb
             break;
9897bb
 
9897bb
         default:
9897bb
@@ -749,7 +759,7 @@ AcpiDmExtendedDescriptor (
9897bb
     /* Extra field for this descriptor only */
9897bb
 
9897bb
     AcpiDmIndent (Level + 1);
9897bb
-    AcpiDmDumpInteger64 (Resource->ExtAddress64.TypeSpecific,
9897bb
+    AcpiDmDumpInteger64 (AcpiUtReadUint64 (&Resource->ExtAddress64.TypeSpecific),
9897bb
         "Type-Specific Attributes");
9897bb
 
9897bb
     /* Insert a descriptor name */
9897bb
@@ -876,11 +886,11 @@ AcpiDmFixedMemory32Descriptor (
9897bb
         AcpiGbl_RwDecode [ACPI_GET_1BIT_FLAG (Resource->FixedMemory32.Flags)]);
9897bb
 
9897bb
     AcpiDmIndent (Level + 1);
9897bb
-    AcpiDmDumpInteger32 (Resource->FixedMemory32.Address,
9897bb
+    AcpiDmDumpInteger32 (AcpiUtReadUint32 (&Resource->FixedMemory32.Address),
9897bb
         "Address Base");
9897bb
 
9897bb
     AcpiDmIndent (Level + 1);
9897bb
-    AcpiDmDumpInteger32 (Resource->FixedMemory32.AddressLength,
9897bb
+    AcpiDmDumpInteger32 (AcpiUtReadUint32 (&Resource->FixedMemory32.AddressLength),
9897bb
         "Address Length");
9897bb
 
9897bb
     /* Insert a descriptor name */
9897bb
@@ -926,7 +936,8 @@ AcpiDmGenericRegisterDescriptor (
9897bb
     AcpiDmDumpInteger8 (Resource->GenericReg.BitOffset, "Bit Offset");
9897bb
 
9897bb
     AcpiDmIndent (Level + 1);
9897bb
-    AcpiDmDumpInteger64 (Resource->GenericReg.Address, "Address");
9897bb
+    AcpiDmDumpInteger64 (AcpiUtReadUint64 (&Resource->GenericReg.Address),
9897bb
+                 "Address");
9897bb
 
9897bb
     /* Optional field for ACPI 3.0 */
9897bb
 
9897bb
@@ -989,7 +1000,7 @@ AcpiDmInterruptDescriptor (
9897bb
     AcpiDmResourceSource (Resource,
9897bb
         sizeof (AML_RESOURCE_EXTENDED_IRQ) +
9897bb
             ((UINT32) Resource->ExtendedIrq.InterruptCount - 1) * sizeof (UINT32),
9897bb
-        Resource->ExtendedIrq.ResourceLength);
9897bb
+            AcpiUtReadUint16 (&Resource->ExtendedIrq.ResourceLength));
9897bb
 
9897bb
     /* Insert a descriptor name */
9897bb
 
9897bb
@@ -1004,7 +1015,7 @@ AcpiDmInterruptDescriptor (
9897bb
     {
9897bb
         AcpiDmIndent (Level + 1);
9897bb
         AcpiOsPrintf ("0x%8.8X,\n",
9897bb
-            (UINT32) Resource->ExtendedIrq.Interrupts[i]);
9897bb
+            AcpiUtReadUint32 (&Resource->ExtendedIrq.Interrupts[i]));
9897bb
     }
9897bb
 
9897bb
     AcpiDmIndent (Level);
9897bb
Index: acpica-unix2-20210604/source/components/disassembler/dmresrcl2.c
9897bb
===================================================================
9897bb
--- acpica-unix2-20210604.orig/source/components/disassembler/dmresrcl2.c
9897bb
+++ acpica-unix2-20210604/source/components/disassembler/dmresrcl2.c
9897bb
@@ -199,22 +199,27 @@ AcpiDmGpioCommon (
9897bb
     char                    *DeviceName = NULL;
9897bb
     UINT32                  PinCount;
9897bb
     UINT32                  i;
9897bb
+    UINT16                  ResSourceOffset;
9897bb
+    UINT16                  VendorOffset;
9897bb
+    UINT16                  VendorLength;
9897bb
+    UINT16                  Tmp16;
9897bb
 
9897bb
 
9897bb
     /* ResourceSource, ResourceSourceIndex, ResourceType */
9897bb
 
9897bb
     AcpiDmIndent (Level + 1);
9897bb
-    if (Resource->Gpio.ResSourceOffset)
9897bb
+    ResSourceOffset = AcpiUtReadUint16 (&Resource->Gpio.ResSourceOffset);
9897bb
+    if (ResSourceOffset)
9897bb
     {
9897bb
         DeviceName = ACPI_ADD_PTR (char,
9897bb
-            Resource, Resource->Gpio.ResSourceOffset),
9897bb
+            Resource, ResSourceOffset),
9897bb
         AcpiUtPrintString (DeviceName, ACPI_UINT16_MAX);
9897bb
     }
9897bb
 
9897bb
     AcpiOsPrintf (", ");
9897bb
     AcpiOsPrintf ("0x%2.2X, ", Resource->Gpio.ResSourceIndex);
9897bb
-    AcpiOsPrintf ("%s, ",
9897bb
-        AcpiGbl_ConsumeDecode [ACPI_GET_1BIT_FLAG (Resource->Gpio.Flags)]);
9897bb
+    Tmp16 = AcpiUtReadUint16 (&Resource->Gpio.Flags);
9897bb
+    AcpiOsPrintf ("%s, ", AcpiGbl_ConsumeDecode [ACPI_GET_1BIT_FLAG (Tmp16)]);
9897bb
 
9897bb
     /* Insert a descriptor name */
9897bb
 
9897bb
@@ -223,15 +228,15 @@ AcpiDmGpioCommon (
9897bb
 
9897bb
     /* Dump the vendor data */
9897bb
 
9897bb
-    if (Resource->Gpio.VendorOffset)
9897bb
+    VendorOffset = AcpiUtReadUint16 (&Resource->Gpio.VendorOffset);
9897bb
+    VendorLength = AcpiUtReadUint16 (&Resource->Gpio.VendorLength);
9897bb
+    if (VendorOffset)
9897bb
     {
9897bb
         AcpiOsPrintf ("\n");
9897bb
         AcpiDmIndent (Level + 1);
9897bb
-        VendorData = ACPI_ADD_PTR (UINT8, Resource,
9897bb
-            Resource->Gpio.VendorOffset);
9897bb
+        VendorData = ACPI_ADD_PTR (UINT8, Resource, VendorOffset);
9897bb
 
9897bb
-        AcpiDmDumpRawDataBuffer (VendorData,
9897bb
-            Resource->Gpio.VendorLength, Level);
9897bb
+        AcpiDmDumpRawDataBuffer (VendorData, VendorLength, Level);
9897bb
     }
9897bb
 
9897bb
     AcpiOsPrintf (")\n");
9897bb
@@ -241,17 +246,17 @@ AcpiDmGpioCommon (
9897bb
     AcpiDmIndent (Level + 1);
9897bb
     AcpiOsPrintf ("{   // Pin list\n");
9897bb
 
9897bb
-    PinCount = ((UINT32) (Resource->Gpio.ResSourceOffset -
9897bb
-        Resource->Gpio.PinTableOffset)) /
9897bb
-        sizeof (UINT16);
9897bb
+    PinCount = (UINT32) AcpiUtReadUint16 (&Resource->Gpio.ResSourceOffset);
9897bb
+    PinCount -= (UINT32) AcpiUtReadUint16 (&Resource->Gpio.PinTableOffset);
9897bb
+    PinCount /= sizeof (UINT16);
9897bb
 
9897bb
     PinList = (UINT16 *) ACPI_ADD_PTR (char, Resource,
9897bb
-        Resource->Gpio.PinTableOffset);
9897bb
+        AcpiUtReadUint16 (&Resource->Gpio.PinTableOffset));
9897bb
 
9897bb
     for (i = 0; i < PinCount; i++)
9897bb
     {
9897bb
         AcpiDmIndent (Level + 2);
9897bb
-        AcpiOsPrintf ("0x%4.4X%s\n", PinList[i],
9897bb
+        AcpiOsPrintf ("0x%4.4X%s\n", AcpiUtReadUint16 (&(PinList[i])),
9897bb
             ((i + 1) < PinCount) ? "," : "");
9897bb
     }
9897bb
 
9897bb
@@ -285,16 +290,18 @@ AcpiDmGpioIntDescriptor (
9897bb
     UINT32                  Length,
9897bb
     UINT32                  Level)
9897bb
 {
9897bb
+    UINT16                  Tmp16;
9897bb
 
9897bb
     /* Dump the GpioInt-specific portion of the descriptor */
9897bb
 
9897bb
     /* EdgeLevel, ActiveLevel, Shared */
9897bb
 
9897bb
     AcpiDmIndent (Level);
9897bb
+    Tmp16 = AcpiUtReadUint16 (&Resource->Gpio.IntFlags);
9897bb
     AcpiOsPrintf ("GpioInt (%s, %s, %s, ",
9897bb
-        AcpiGbl_HeDecode [ACPI_GET_1BIT_FLAG (Resource->Gpio.IntFlags)],
9897bb
-        AcpiGbl_LlDecode [ACPI_EXTRACT_2BIT_FLAG (Resource->Gpio.IntFlags, 1)],
9897bb
-        AcpiGbl_ShrDecode [ACPI_EXTRACT_2BIT_FLAG (Resource->Gpio.IntFlags, 3)]);
9897bb
+        AcpiGbl_HeDecode [ACPI_GET_1BIT_FLAG (Tmp16)],
9897bb
+        AcpiGbl_LlDecode [ACPI_EXTRACT_2BIT_FLAG (Tmp16, 1)],
9897bb
+        AcpiGbl_ShrDecode [ACPI_EXTRACT_2BIT_FLAG (Tmp16, 3)]);
9897bb
 
9897bb
     /* PinConfig, DebounceTimeout */
9897bb
 
9897bb
@@ -307,7 +314,8 @@ AcpiDmGpioIntDescriptor (
9897bb
     {
9897bb
         AcpiOsPrintf ("0x%2.2X, ", Resource->Gpio.PinConfig);
9897bb
     }
9897bb
-    AcpiOsPrintf ("0x%4.4X,\n", Resource->Gpio.DebounceTimeout);
9897bb
+    AcpiOsPrintf ("0x%4.4X,\n",
9897bb
+          AcpiUtReadUint16 (&Resource->Gpio.DebounceTimeout));
9897bb
 
9897bb
     /* Dump the GpioInt/GpioIo common portion of the descriptor */
9897bb
 
9897bb
@@ -337,14 +345,16 @@ AcpiDmGpioIoDescriptor (
9897bb
     UINT32                  Length,
9897bb
     UINT32                  Level)
9897bb
 {
9897bb
+    UINT16                  Tmp16;
9897bb
 
9897bb
     /* Dump the GpioIo-specific portion of the descriptor */
9897bb
 
9897bb
     /* Shared, PinConfig */
9897bb
 
9897bb
     AcpiDmIndent (Level);
9897bb
+    Tmp16 = AcpiUtReadUint16 (&Resource->Gpio.IntFlags);
9897bb
     AcpiOsPrintf ("GpioIo (%s, ",
9897bb
-        AcpiGbl_ShrDecode [ACPI_EXTRACT_2BIT_FLAG (Resource->Gpio.IntFlags, 3)]);
9897bb
+        AcpiGbl_ShrDecode [ACPI_EXTRACT_2BIT_FLAG (Tmp16, 3)]);
9897bb
 
9897bb
     if (Resource->Gpio.PinConfig <= 3)
9897bb
     {
9897bb
@@ -358,10 +368,10 @@ AcpiDmGpioIoDescriptor (
9897bb
 
9897bb
     /* DebounceTimeout, DriveStrength, IoRestriction */
9897bb
 
9897bb
-    AcpiOsPrintf ("0x%4.4X, ", Resource->Gpio.DebounceTimeout);
9897bb
-    AcpiOsPrintf ("0x%4.4X, ", Resource->Gpio.DriveStrength);
9897bb
-    AcpiOsPrintf ("%s,\n",
9897bb
-        AcpiGbl_IorDecode [ACPI_GET_2BIT_FLAG (Resource->Gpio.IntFlags)]);
9897bb
+    AcpiOsPrintf ("0x%4.4X, ", AcpiUtReadUint16 (&Resource->Gpio.DebounceTimeout));
9897bb
+    AcpiOsPrintf ("0x%4.4X, ", AcpiUtReadUint16 (&Resource->Gpio.DriveStrength));
9897bb
+    Tmp16 = AcpiUtReadUint16 (&Resource->Gpio.IntFlags);
9897bb
+    AcpiOsPrintf ("%s,\n", AcpiGbl_IorDecode [ACPI_GET_2BIT_FLAG (Tmp16)]);
9897bb
 
9897bb
     /* Dump the GpioInt/GpioIo common portion of the descriptor */
9897bb
 
9897bb
@@ -442,6 +452,9 @@ AcpiDmPinFunctionDescriptor (
9897bb
     char                    *DeviceName = NULL;
9897bb
     UINT32                  PinCount;
9897bb
     UINT32                  i;
9897bb
+    UINT16                  ResSourceOffset;
9897bb
+    UINT16                  VendorOffset;
9897bb
+    UINT16                  VendorLength;
9897bb
 
9897bb
     AcpiDmIndent (Level);
9897bb
     AcpiOsPrintf ("PinFunction (%s, ",
9897bb
@@ -459,12 +472,14 @@ AcpiDmPinFunctionDescriptor (
9897bb
 
9897bb
     /* FunctionNumber */
9897bb
 
9897bb
-    AcpiOsPrintf ("0x%4.4X, ", Resource->PinFunction.FunctionNumber);
9897bb
+    AcpiOsPrintf ("0x%4.4X, ",
9897bb
+          AcpiUtReadUint16 (&Resource->PinFunction.FunctionNumber));
9897bb
 
9897bb
-    if (Resource->PinFunction.ResSourceOffset)
9897bb
+    ResSourceOffset = AcpiUtReadUint16 (&Resource->PinFunction.ResSourceOffset);
9897bb
+    if (ResSourceOffset)
9897bb
     {
9897bb
         DeviceName = ACPI_ADD_PTR (char,
9897bb
-            Resource, Resource->PinFunction.ResSourceOffset),
9897bb
+            Resource, ResSourceOffset),
9897bb
         AcpiUtPrintString (DeviceName, ACPI_UINT16_MAX);
9897bb
     }
9897bb
 
9897bb
@@ -484,15 +499,15 @@ AcpiDmPinFunctionDescriptor (
9897bb
 
9897bb
     /* Dump the vendor data */
9897bb
 
9897bb
-    if (Resource->PinFunction.VendorLength)
9897bb
+    VendorOffset = AcpiUtReadUint16 (&Resource->PinFunction.VendorOffset);
9897bb
+    VendorLength = AcpiUtReadUint16 (&Resource->PinFunction.VendorLength);
9897bb
+    if (VendorLength)
9897bb
     {
9897bb
         AcpiOsPrintf ("\n");
9897bb
         AcpiDmIndent (Level + 1);
9897bb
-        VendorData = ACPI_ADD_PTR (UINT8, Resource,
9897bb
-            Resource->PinFunction.VendorOffset);
9897bb
+        VendorData = ACPI_ADD_PTR (UINT8, Resource, VendorOffset);
9897bb
 
9897bb
-        AcpiDmDumpRawDataBuffer (VendorData,
9897bb
-            Resource->PinFunction.VendorLength, Level);
9897bb
+        AcpiDmDumpRawDataBuffer (VendorData, VendorLength, Level);
9897bb
     }
9897bb
 
9897bb
     AcpiOsPrintf (")\n");
9897bb
@@ -503,17 +518,17 @@ AcpiDmPinFunctionDescriptor (
9897bb
 
9897bb
     AcpiOsPrintf ("{   // Pin list\n");
9897bb
 
9897bb
-    PinCount = ((UINT32) (Resource->PinFunction.ResSourceOffset -
9897bb
-        Resource->PinFunction.PinTableOffset)) /
9897bb
-        sizeof (UINT16);
9897bb
+    PinCount = AcpiUtReadUint16 (&Resource->PinFunction.ResSourceOffset);
9897bb
+    PinCount -= AcpiUtReadUint16 (&Resource->PinFunction.PinTableOffset);
9897bb
+    PinCount /= sizeof (UINT16);
9897bb
 
9897bb
     PinList = (UINT16 *) ACPI_ADD_PTR (char, Resource,
9897bb
-        Resource->PinFunction.PinTableOffset);
9897bb
+        AcpiUtReadUint16 (&Resource->PinFunction.PinTableOffset));
9897bb
 
9897bb
     for (i = 0; i < PinCount; i++)
9897bb
     {
9897bb
         AcpiDmIndent (Level + 2);
9897bb
-        AcpiOsPrintf ("0x%4.4X%s\n", PinList[i],
9897bb
+        AcpiOsPrintf ("0x%4.4X%s\n", AcpiUtReadUint16 (&(PinList[i])),
9897bb
             ((i + 1) < PinCount) ? "," : "");
9897bb
     }
9897bb
 
9897bb
@@ -549,7 +564,8 @@ AcpiDmDumpSerialBusVendorData (
9897bb
     {
9897bb
     case AML_RESOURCE_I2C_SERIALBUSTYPE:
9897bb
 
9897bb
-        VendorLength = Resource->CommonSerialBus.TypeDataLength -
9897bb
+        VendorLength =
9897bb
+            AcpiUtReadUint16 (&Resource->CommonSerialBus.TypeDataLength) -
9897bb
             AML_RESOURCE_I2C_MIN_DATA_LEN;
9897bb
 
9897bb
         VendorData = ACPI_ADD_PTR (UINT8, Resource,
9897bb
@@ -558,7 +574,8 @@ AcpiDmDumpSerialBusVendorData (
9897bb
 
9897bb
     case AML_RESOURCE_SPI_SERIALBUSTYPE:
9897bb
 
9897bb
-        VendorLength = Resource->CommonSerialBus.TypeDataLength -
9897bb
+        VendorLength =
9897bb
+            AcpiUtReadUint16 (&Resource->CommonSerialBus.TypeDataLength) -
9897bb
             AML_RESOURCE_SPI_MIN_DATA_LEN;
9897bb
 
9897bb
         VendorData = ACPI_ADD_PTR (UINT8, Resource,
9897bb
@@ -567,7 +584,8 @@ AcpiDmDumpSerialBusVendorData (
9897bb
 
9897bb
     case AML_RESOURCE_UART_SERIALBUSTYPE:
9897bb
 
9897bb
-        VendorLength = Resource->CommonSerialBus.TypeDataLength -
9897bb
+        VendorLength =
9897bb
+            AcpiUtReadUint16 (&Resource->CommonSerialBus.TypeDataLength) -
9897bb
             AML_RESOURCE_UART_MIN_DATA_LEN;
9897bb
 
9897bb
         VendorData = ACPI_ADD_PTR (UINT8, Resource,
9897bb
@@ -693,9 +711,9 @@ AcpiDmI2cSerialBusDescriptor (
9897bb
 
9897bb
     AcpiDmIndent (Level);
9897bb
     AcpiOsPrintf ("I2cSerialBusV2 (0x%4.4X, %s, 0x%8.8X,\n",
9897bb
-        Resource->I2cSerialBus.SlaveAddress,
9897bb
+        AcpiUtReadUint16 (&Resource->I2cSerialBus.SlaveAddress),
9897bb
         AcpiGbl_SmDecode [ACPI_GET_1BIT_FLAG (Resource->I2cSerialBus.Flags)],
9897bb
-        Resource->I2cSerialBus.ConnectionSpeed);
9897bb
+        AcpiUtReadUint32 (&Resource->I2cSerialBus.ConnectionSpeed));
9897bb
 
9897bb
     AcpiDmIndent (Level + 1);
9897bb
     AcpiOsPrintf ("%s, ",
9897bb
@@ -704,7 +722,7 @@ AcpiDmI2cSerialBusDescriptor (
9897bb
     /* ResourceSource is a required field */
9897bb
 
9897bb
     ResourceSourceOffset = sizeof (AML_RESOURCE_COMMON_SERIALBUS) +
9897bb
-        Resource->CommonSerialBus.TypeDataLength;
9897bb
+        AcpiUtReadUint16 (&Resource->CommonSerialBus.TypeDataLength);
9897bb
 
9897bb
     DeviceName = ACPI_ADD_PTR (char, Resource, ResourceSourceOffset);
9897bb
     AcpiUtPrintString (DeviceName, ACPI_UINT16_MAX);
9897bb
@@ -761,15 +779,17 @@ AcpiDmSpiSerialBusDescriptor (
9897bb
 {
9897bb
     UINT32                  ResourceSourceOffset;
9897bb
     char                    *DeviceName;
9897bb
+    UINT16                  Tmp16;
9897bb
 
9897bb
 
9897bb
     /* DeviceSelection, DeviceSelectionPolarity, WireMode, DataBitLength */
9897bb
 
9897bb
     AcpiDmIndent (Level);
9897bb
+    Tmp16 = AcpiUtReadUint16 (&Resource->SpiSerialBus.TypeSpecificFlags);
9897bb
     AcpiOsPrintf ("SpiSerialBusV2 (0x%4.4X, %s, %s, 0x%2.2X,\n",
9897bb
-        Resource->SpiSerialBus.DeviceSelection,
9897bb
-        AcpiGbl_DpDecode [ACPI_EXTRACT_1BIT_FLAG (Resource->SpiSerialBus.TypeSpecificFlags, 1)],
9897bb
-        AcpiGbl_WmDecode [ACPI_GET_1BIT_FLAG (Resource->SpiSerialBus.TypeSpecificFlags)],
9897bb
+        AcpiUtReadUint16 (&Resource->SpiSerialBus.DeviceSelection),
9897bb
+        AcpiGbl_DpDecode [ACPI_EXTRACT_1BIT_FLAG (Tmp16, 1)],
9897bb
+        AcpiGbl_WmDecode [ACPI_GET_1BIT_FLAG (Tmp16)],
9897bb
         Resource->SpiSerialBus.DataBitLength);
9897bb
 
9897bb
     /* SlaveMode, ConnectionSpeed, ClockPolarity, ClockPhase */
9897bb
@@ -777,7 +797,7 @@ AcpiDmSpiSerialBusDescriptor (
9897bb
     AcpiDmIndent (Level + 1);
9897bb
     AcpiOsPrintf ("%s, 0x%8.8X, %s,\n",
9897bb
         AcpiGbl_SmDecode [ACPI_GET_1BIT_FLAG (Resource->SpiSerialBus.Flags)],
9897bb
-        Resource->SpiSerialBus.ConnectionSpeed,
9897bb
+        AcpiUtReadUint32 (&Resource->SpiSerialBus.ConnectionSpeed),
9897bb
         AcpiGbl_CpoDecode [ACPI_GET_1BIT_FLAG (Resource->SpiSerialBus.ClockPolarity)]);
9897bb
 
9897bb
     AcpiDmIndent (Level + 1);
9897bb
@@ -787,7 +807,7 @@ AcpiDmSpiSerialBusDescriptor (
9897bb
     /* ResourceSource is a required field */
9897bb
 
9897bb
     ResourceSourceOffset = sizeof (AML_RESOURCE_COMMON_SERIALBUS) +
9897bb
-        Resource->CommonSerialBus.TypeDataLength;
9897bb
+        AcpiUtReadUint16 (&Resource->CommonSerialBus.TypeDataLength);
9897bb
 
9897bb
     DeviceName = ACPI_ADD_PTR (char, Resource, ResourceSourceOffset);
9897bb
     AcpiUtPrintString (DeviceName, ACPI_UINT16_MAX);
9897bb
@@ -844,15 +864,17 @@ AcpiDmUartSerialBusDescriptor (
9897bb
 {
9897bb
     UINT32                  ResourceSourceOffset;
9897bb
     char                    *DeviceName;
9897bb
+    UINT16                  Tmp16;
9897bb
 
9897bb
 
9897bb
     /* ConnectionSpeed, BitsPerByte, StopBits */
9897bb
 
9897bb
     AcpiDmIndent (Level);
9897bb
+    Tmp16 = AcpiUtReadUint16 (&Resource->UartSerialBus.TypeSpecificFlags);
9897bb
     AcpiOsPrintf ("UartSerialBusV2 (0x%8.8X, %s, %s,\n",
9897bb
-        Resource->UartSerialBus.DefaultBaudRate,
9897bb
-        AcpiGbl_BpbDecode [ACPI_EXTRACT_3BIT_FLAG (Resource->UartSerialBus.TypeSpecificFlags, 4)],
9897bb
-        AcpiGbl_SbDecode [ACPI_EXTRACT_2BIT_FLAG (Resource->UartSerialBus.TypeSpecificFlags, 2)]);
9897bb
+        AcpiUtReadUint32 (&Resource->UartSerialBus.DefaultBaudRate),
9897bb
+        AcpiGbl_BpbDecode [ACPI_EXTRACT_3BIT_FLAG (Tmp16, 4)],
9897bb
+        AcpiGbl_SbDecode [ACPI_EXTRACT_2BIT_FLAG (Tmp16, 2)]);
9897bb
 
9897bb
     /* LinesInUse, IsBigEndian, Parity, FlowControl */
9897bb
 
9897bb
@@ -867,13 +889,13 @@ AcpiDmUartSerialBusDescriptor (
9897bb
 
9897bb
     AcpiDmIndent (Level + 1);
9897bb
     AcpiOsPrintf ("0x%4.4X, 0x%4.4X, ",
9897bb
-        Resource->UartSerialBus.RxFifoSize,
9897bb
-        Resource->UartSerialBus.TxFifoSize);
9897bb
+        AcpiUtReadUint16 (&Resource->UartSerialBus.RxFifoSize),
9897bb
+        AcpiUtReadUint16 (&Resource->UartSerialBus.TxFifoSize));
9897bb
 
9897bb
     /* ResourceSource is a required field */
9897bb
 
9897bb
     ResourceSourceOffset = sizeof (AML_RESOURCE_COMMON_SERIALBUS) +
9897bb
-        Resource->CommonSerialBus.TypeDataLength;
9897bb
+        AcpiUtReadUint16 (&Resource->CommonSerialBus.TypeDataLength);
9897bb
 
9897bb
     DeviceName = ACPI_ADD_PTR (char, Resource, ResourceSourceOffset);
9897bb
     AcpiUtPrintString (DeviceName, ACPI_UINT16_MAX);
9897bb
Index: acpica-unix2-20210604/source/components/disassembler/dmresrcs.c
9897bb
===================================================================
9897bb
--- acpica-unix2-20210604.orig/source/components/disassembler/dmresrcs.c
9897bb
+++ acpica-unix2-20210604/source/components/disassembler/dmresrcs.c
9897bb
@@ -93,7 +93,7 @@ AcpiDmIrqDescriptor (
9897bb
     AcpiOsPrintf (")\n");
9897bb
 
9897bb
     AcpiDmIndent (Level + 1);
9897bb
-    AcpiDmBitList (Resource->Irq.IrqMask);
9897bb
+    AcpiDmBitList (AcpiUtReadUint16 (&Resource->Irq.IrqMask));
9897bb
 }
9897bb
 
9897bb
 
9897bb
@@ -161,8 +161,8 @@ AcpiDmFixedDmaDescriptor (
9897bb
 
9897bb
     AcpiDmIndent (Level);
9897bb
     AcpiOsPrintf ("FixedDMA (0x%4.4X, 0x%4.4X, ",
9897bb
-        Resource->FixedDma.RequestLines,
9897bb
-        Resource->FixedDma.Channels);
9897bb
+        AcpiUtReadUint16 (&Resource->FixedDma.RequestLines),
9897bb
+        AcpiUtReadUint16 (&Resource->FixedDma.Channels));
9897bb
 
9897bb
     if (Resource->FixedDma.Width <= 5)
9897bb
     {
9897bb
@@ -210,10 +210,12 @@ AcpiDmIoDescriptor (
9897bb
         AcpiGbl_IoDecode [ACPI_GET_1BIT_FLAG (Resource->Io.Flags)]);
9897bb
 
9897bb
     AcpiDmIndent (Level + 1);
9897bb
-    AcpiDmDumpInteger16 (Resource->Io.Minimum, "Range Minimum");
9897bb
+    AcpiDmDumpInteger16 (AcpiUtReadUint16 (&Resource->Io.Minimum),
9897bb
+                 "Range Minimum");
9897bb
 
9897bb
     AcpiDmIndent (Level + 1);
9897bb
-    AcpiDmDumpInteger16 (Resource->Io.Maximum, "Range Maximum");
9897bb
+    AcpiDmDumpInteger16 (AcpiUtReadUint16 (&Resource->Io.Maximum),
9897bb
+                 "Range Maximum");
9897bb
 
9897bb
     AcpiDmIndent (Level + 1);
9897bb
     AcpiDmDumpInteger8 (Resource->Io.Alignment, "Alignment");
9897bb
@@ -256,10 +258,12 @@ AcpiDmFixedIoDescriptor (
9897bb
     AcpiOsPrintf ("FixedIO (\n");
9897bb
 
9897bb
     AcpiDmIndent (Level + 1);
9897bb
-    AcpiDmDumpInteger16 (Resource->FixedIo.Address, "Address");
9897bb
+    AcpiDmDumpInteger16 (AcpiUtReadUint16 (&Resource->FixedIo.Address),
9897bb
+                 "Address");
9897bb
 
9897bb
     AcpiDmIndent (Level + 1);
9897bb
-    AcpiDmDumpInteger8 (Resource->FixedIo.AddressLength, "Length");
9897bb
+    AcpiDmDumpInteger8 (AcpiUtReadUint16 (&Resource->FixedIo.AddressLength),
9897bb
+            "Length");
9897bb
 
9897bb
     /* Insert a descriptor name */
9897bb
 
9897bb
Index: acpica-unix2-20210604/source/components/disassembler/dmwalk.c
9897bb
===================================================================
9897bb
--- acpica-unix2-20210604.orig/source/components/disassembler/dmwalk.c
9897bb
+++ acpica-unix2-20210604/source/components/disassembler/dmwalk.c
9897bb
@@ -1155,7 +1155,7 @@ AcpiDmAscendingOp (
9897bb
         {
9897bb
             ParentOp->Common.DisasmFlags |= ACPI_PARSEOP_EMPTY_TERMLIST;
9897bb
             ASL_CV_CLOSE_PAREN (Op, Level);
9897bb
-            AcpiOsPrintf ("{");
9897bb
+            AcpiOsPrintf (" {");
9897bb
         }
9897bb
     }
9897bb
 
9897bb
Index: acpica-unix2-20210604/source/components/namespace/nsaccess.c
9897bb
===================================================================
9897bb
--- acpica-unix2-20210604.orig/source/components/namespace/nsaccess.c
9897bb
+++ acpica-unix2-20210604/source/components/namespace/nsaccess.c
9897bb
@@ -644,7 +644,7 @@ AcpiNsLookup (
9897bb
 
9897bb
         /* Extract one ACPI name from the front of the pathname */
9897bb
 
9897bb
-        ACPI_MOVE_32_TO_32 (&SimpleName, Path);
9897bb
+        ACPI_COPY_NAMESEG (&SimpleName, Path);
9897bb
 
9897bb
         /* Try to find the single (4 character) ACPI name */
9897bb
 
9897bb
Index: acpica-unix2-20210604/source/components/namespace/nsnames.c
9897bb
===================================================================
9897bb
--- acpica-unix2-20210604.orig/source/components/namespace/nsnames.c
9897bb
+++ acpica-unix2-20210604/source/components/namespace/nsnames.c
9897bb
@@ -297,10 +297,10 @@ AcpiNsBuildNormalizedPath (
9897bb
     {
9897bb
         if (NextNode != Node)
9897bb
         {
9897bb
-            ACPI_PATH_PUT8(FullPath, PathSize, AML_DUAL_NAME_PREFIX, Length);
9897bb
+            ACPI_PATH_PUT8 (FullPath, PathSize, AML_DUAL_NAME_PREFIX, Length);
9897bb
         }
9897bb
 
9897bb
-        ACPI_MOVE_32_TO_32 (Name, &NextNode->Name);
9897bb
+        ACPI_COPY_NAMESEG (Name, &NextNode->Name);
9897bb
         DoNoTrailing = NoTrailing;
9897bb
         for (i = 0; i < 4; i++)
9897bb
         {
9897bb
Index: acpica-unix2-20210604/source/components/namespace/nsparse.c
9897bb
===================================================================
9897bb
--- acpica-unix2-20210604.orig/source/components/namespace/nsparse.c
9897bb
+++ acpica-unix2-20210604/source/components/namespace/nsparse.c
9897bb
@@ -203,6 +203,7 @@ AcpiNsOneCompleteParse (
9897bb
     ACPI_WALK_STATE         *WalkState;
9897bb
     ACPI_TABLE_HEADER       *Table;
9897bb
     ACPI_OWNER_ID           OwnerId;
9897bb
+    UINT32                  TableLength;
9897bb
 
9897bb
 
9897bb
     ACPI_FUNCTION_TRACE (NsOneCompleteParse);
9897bb
@@ -216,13 +217,14 @@ AcpiNsOneCompleteParse (
9897bb
 
9897bb
     /* Table must consist of at least a complete header */
9897bb
 
9897bb
-    if (Table->Length < sizeof (ACPI_TABLE_HEADER))
9897bb
+    TableLength = AcpiUtReadUint32 (&Table->Length);
9897bb
+    if (TableLength < sizeof (ACPI_TABLE_HEADER))
9897bb
     {
9897bb
         return_ACPI_STATUS (AE_BAD_HEADER);
9897bb
     }
9897bb
 
9897bb
     AmlStart = (UINT8 *) Table + sizeof (ACPI_TABLE_HEADER);
9897bb
-    AmlLength = Table->Length - sizeof (ACPI_TABLE_HEADER);
9897bb
+    AmlLength = TableLength - sizeof (ACPI_TABLE_HEADER);
9897bb
 
9897bb
     Status = AcpiTbGetOwnerId (TableIndex, &OwnerId);
9897bb
     if (ACPI_FAILURE (Status))
9897bb
Index: acpica-unix2-20210604/source/components/namespace/nsutils.c
9897bb
===================================================================
9897bb
--- acpica-unix2-20210604.orig/source/components/namespace/nsutils.c
9897bb
+++ acpica-unix2-20210604/source/components/namespace/nsutils.c
9897bb
@@ -272,7 +272,6 @@ AcpiNsBuildInternalName (
9897bb
     const char              *ExternalName = Info->NextExternalChar;
9897bb
     char                    *Result = NULL;
9897bb
     UINT32                  i;
9897bb
-    char                    TmpSeg[ACPI_NAMESEG_SIZE+1];
9897bb
 
9897bb
 
9897bb
     ACPI_FUNCTION_TRACE (NsBuildInternalName);
9897bb
@@ -336,7 +335,6 @@ AcpiNsBuildInternalName (
9897bb
 
9897bb
     for (; NumSegments; NumSegments--)
9897bb
     {
9897bb
-        memset (TmpSeg, 0, ACPI_NAMESEG_SIZE+1);
9897bb
         for (i = 0; i < ACPI_NAMESEG_SIZE; i++)
9897bb
         {
9897bb
             if (ACPI_IS_PATH_SEPARATOR (*ExternalName) ||
9897bb
@@ -344,17 +342,16 @@ AcpiNsBuildInternalName (
9897bb
             {
9897bb
                 /* Pad the segment with underscore(s) if segment is short */
9897bb
 
9897bb
-                TmpSeg[i] = '_';
9897bb
+                Result[i] = '_';
9897bb
             }
9897bb
             else
9897bb
             {
9897bb
                 /* Convert the character to uppercase and save it */
9897bb
 
9897bb
-                TmpSeg[i] = (char) toupper ((int) *ExternalName);
9897bb
+                Result[i] = (char) toupper ((int) *ExternalName);
9897bb
                 ExternalName++;
9897bb
             }
9897bb
         }
9897bb
-    AcpiUtWriteUint (Result, ACPI_NAMESEG_SIZE, TmpSeg, ACPI_NAMESEG_SIZE);
9897bb
 
9897bb
         /* Now we must have a path separator, or the pathname is bad */
9897bb
 
9897bb
Index: acpica-unix2-20210604/source/components/utilities/utresrc.c
9897bb
===================================================================
9897bb
--- acpica-unix2-20210604.orig/source/components/utilities/utresrc.c
9897bb
+++ acpica-unix2-20210604/source/components/utilities/utresrc.c
9897bb
@@ -541,7 +541,7 @@ AcpiUtGetResourceLength (
9897bb
     {
9897bb
         /* Large Resource type -- bytes 1-2 contain the 16-bit length */
9897bb
 
9897bb
-        ACPI_MOVE_16_TO_16 (&ResourceLength, ACPI_ADD_PTR (UINT8, Aml, 1));
9897bb
+        ResourceLength = AcpiUtReadUint16 (ACPI_ADD_PTR (UINT8, Aml, 1));
9897bb
 
9897bb
     }
9897bb
     else
9897bb
Index: acpica-unix2-20210604/source/compiler/aslrestype2e.c
9897bb
===================================================================
9897bb
--- acpica-unix2-20210604.orig/source/compiler/aslrestype2e.c
9897bb
+++ acpica-unix2-20210604/source/compiler/aslrestype2e.c
9897bb
@@ -80,6 +80,7 @@ RsDoExtendedIoDescriptor (
9897bb
     UINT16                  StringLength = 0;
9897bb
     UINT32                  CurrentByteOffset;
9897bb
     UINT32                  i;
9897bb
+    UINT16                  Tmp16;
9897bb
 
9897bb
 
9897bb
     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
9897bb
@@ -139,7 +140,8 @@ RsDoExtendedIoDescriptor (
9897bb
 
9897bb
         case 5: /* Address Granularity */
9897bb
 
9897bb
-            Descriptor->ExtAddress64.Granularity = InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->ExtAddress64.Granularity =
9897bb
+                AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
9897bb
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_GRANULARITY,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Granularity));
9897bb
             GranOp = InitializerOp;
9897bb
@@ -147,7 +149,8 @@ RsDoExtendedIoDescriptor (
9897bb
 
9897bb
         case 6: /* Address Min */
9897bb
 
9897bb
-            Descriptor->ExtAddress64.Minimum = InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->ExtAddress64.Minimum =
9897bb
+                AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
9897bb
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_MINADDR,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Minimum));
9897bb
             MinOp = InitializerOp;
9897bb
@@ -155,7 +158,8 @@ RsDoExtendedIoDescriptor (
9897bb
 
9897bb
         case 7: /* Address Max */
9897bb
 
9897bb
-            Descriptor->ExtAddress64.Maximum = InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->ExtAddress64.Maximum =
9897bb
+                AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
9897bb
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_MAXADDR,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Maximum));
9897bb
             MaxOp = InitializerOp;
9897bb
@@ -163,14 +167,16 @@ RsDoExtendedIoDescriptor (
9897bb
 
9897bb
         case 8: /* Translation Offset */
9897bb
 
9897bb
-            Descriptor->ExtAddress64.TranslationOffset = InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->ExtAddress64.TranslationOffset =
9897bb
+                AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
9897bb
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_TRANSLATION,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.TranslationOffset));
9897bb
             break;
9897bb
 
9897bb
         case 9: /* Address Length */
9897bb
 
9897bb
-            Descriptor->ExtAddress64.AddressLength = InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->ExtAddress64.AddressLength =
9897bb
+                AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
9897bb
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_LENGTH,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.AddressLength));
9897bb
             LengthOp = InitializerOp;
9897bb
@@ -178,7 +184,8 @@ RsDoExtendedIoDescriptor (
9897bb
 
9897bb
         case 10: /* Type-Specific Attributes */
9897bb
 
9897bb
-            Descriptor->ExtAddress64.TypeSpecific = InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->ExtAddress64.TypeSpecific =
9897bb
+                AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
9897bb
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_TYPESPECIFICATTRIBUTES,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.TypeSpecific));
9897bb
             break;
9897bb
@@ -213,11 +220,14 @@ RsDoExtendedIoDescriptor (
9897bb
 
9897bb
     /* Validate the Min/Max/Len/Gran values */
9897bb
 
9897bb
+    Tmp16 = Descriptor->ExtAddress64.ResourceLength;
9897bb
+    Descriptor->ExtAddress64.ResourceLength = AcpiUtReadUint16 (&Tmp16);
9897bb
+
9897bb
     RsLargeAddressCheck (
9897bb
-        Descriptor->ExtAddress64.Minimum,
9897bb
-        Descriptor->ExtAddress64.Maximum,
9897bb
-        Descriptor->ExtAddress64.AddressLength,
9897bb
-        Descriptor->ExtAddress64.Granularity,
9897bb
+        AcpiUtReadUint64 (&Descriptor->ExtAddress64.Minimum),
9897bb
+        AcpiUtReadUint64 (&Descriptor->ExtAddress64.Maximum),
9897bb
+        AcpiUtReadUint64 (&Descriptor->ExtAddress64.AddressLength),
9897bb
+        AcpiUtReadUint64 (&Descriptor->ExtAddress64.Granularity),
9897bb
         Descriptor->ExtAddress64.Flags,
9897bb
         MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp);
9897bb
 
9897bb
@@ -253,6 +263,7 @@ RsDoExtendedMemoryDescriptor (
9897bb
     UINT16                  StringLength = 0;
9897bb
     UINT32                  CurrentByteOffset;
9897bb
     UINT32                  i;
9897bb
+    UINT16                  Tmp16;
9897bb
 
9897bb
 
9897bb
     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
9897bb
@@ -319,7 +330,8 @@ RsDoExtendedMemoryDescriptor (
9897bb
 
9897bb
         case 6: /* Address Granularity */
9897bb
 
9897bb
-            Descriptor->ExtAddress64.Granularity = InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->ExtAddress64.Granularity =
9897bb
+                AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
9897bb
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_GRANULARITY,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Granularity));
9897bb
             GranOp = InitializerOp;
9897bb
@@ -327,7 +339,8 @@ RsDoExtendedMemoryDescriptor (
9897bb
 
9897bb
         case 7: /* Min Address */
9897bb
 
9897bb
-            Descriptor->ExtAddress64.Minimum = InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->ExtAddress64.Minimum =
9897bb
+                AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
9897bb
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_MINADDR,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Minimum));
9897bb
             MinOp = InitializerOp;
9897bb
@@ -335,7 +348,8 @@ RsDoExtendedMemoryDescriptor (
9897bb
 
9897bb
         case 8: /* Max Address */
9897bb
 
9897bb
-            Descriptor->ExtAddress64.Maximum = InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->ExtAddress64.Maximum =
9897bb
+                AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
9897bb
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_MAXADDR,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Maximum));
9897bb
             MaxOp = InitializerOp;
9897bb
@@ -343,14 +357,16 @@ RsDoExtendedMemoryDescriptor (
9897bb
 
9897bb
         case 9: /* Translation Offset */
9897bb
 
9897bb
-            Descriptor->ExtAddress64.TranslationOffset = InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->ExtAddress64.TranslationOffset =
9897bb
+                AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
9897bb
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_TRANSLATION,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.TranslationOffset));
9897bb
             break;
9897bb
 
9897bb
         case 10: /* Address Length */
9897bb
 
9897bb
-            Descriptor->ExtAddress64.AddressLength = InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->ExtAddress64.AddressLength =
9897bb
+                AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
9897bb
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_LENGTH,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.AddressLength));
9897bb
             LengthOp = InitializerOp;
9897bb
@@ -358,7 +374,8 @@ RsDoExtendedMemoryDescriptor (
9897bb
 
9897bb
         case 11: /* Type-Specific Attributes */
9897bb
 
9897bb
-            Descriptor->ExtAddress64.TypeSpecific = InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->ExtAddress64.TypeSpecific =
9897bb
+                AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
9897bb
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_TYPESPECIFICATTRIBUTES,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.TypeSpecific));
9897bb
             break;
9897bb
@@ -394,11 +411,14 @@ RsDoExtendedMemoryDescriptor (
9897bb
 
9897bb
     /* Validate the Min/Max/Len/Gran values */
9897bb
 
9897bb
+    Tmp16 = Descriptor->ExtAddress64.ResourceLength;
9897bb
+    Descriptor->ExtAddress64.ResourceLength = AcpiUtReadUint16 (&Tmp16);
9897bb
+
9897bb
     RsLargeAddressCheck (
9897bb
-        Descriptor->ExtAddress64.Minimum,
9897bb
-        Descriptor->ExtAddress64.Maximum,
9897bb
-        Descriptor->ExtAddress64.AddressLength,
9897bb
-        Descriptor->ExtAddress64.Granularity,
9897bb
+        AcpiUtReadUint64 (&Descriptor->ExtAddress64.Minimum),
9897bb
+        AcpiUtReadUint64 (&Descriptor->ExtAddress64.Maximum),
9897bb
+        AcpiUtReadUint64 (&Descriptor->ExtAddress64.AddressLength),
9897bb
+        AcpiUtReadUint64 (&Descriptor->ExtAddress64.Granularity),
9897bb
         Descriptor->ExtAddress64.Flags,
9897bb
         MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp);
9897bb
 
9897bb
@@ -434,6 +454,7 @@ RsDoExtendedSpaceDescriptor (
9897bb
     UINT16                  StringLength = 0;
9897bb
     UINT32                  CurrentByteOffset;
9897bb
     UINT32                  i;
9897bb
+    UINT16                  Tmp16;
9897bb
 
9897bb
 
9897bb
     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
9897bb
@@ -497,7 +518,8 @@ RsDoExtendedSpaceDescriptor (
9897bb
 
9897bb
         case 6: /* Address Granularity */
9897bb
 
9897bb
-            Descriptor->ExtAddress64.Granularity = InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->ExtAddress64.Granularity =
9897bb
+                AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
9897bb
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_GRANULARITY,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Granularity));
9897bb
             GranOp = InitializerOp;
9897bb
@@ -505,7 +527,8 @@ RsDoExtendedSpaceDescriptor (
9897bb
 
9897bb
         case 7: /* Min Address */
9897bb
 
9897bb
-            Descriptor->ExtAddress64.Minimum = InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->ExtAddress64.Minimum =
9897bb
+                AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
9897bb
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_MINADDR,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Minimum));
9897bb
             MinOp = InitializerOp;
9897bb
@@ -513,7 +536,8 @@ RsDoExtendedSpaceDescriptor (
9897bb
 
9897bb
         case 8: /* Max Address */
9897bb
 
9897bb
-            Descriptor->ExtAddress64.Maximum = InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->ExtAddress64.Maximum =
9897bb
+                AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
9897bb
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_MAXADDR,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Maximum));
9897bb
             MaxOp = InitializerOp;
9897bb
@@ -521,14 +545,16 @@ RsDoExtendedSpaceDescriptor (
9897bb
 
9897bb
         case 9: /* Translation Offset */
9897bb
 
9897bb
-            Descriptor->ExtAddress64.TranslationOffset = InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->ExtAddress64.TranslationOffset =
9897bb
+                AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
9897bb
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_TRANSLATION,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.TranslationOffset));
9897bb
             break;
9897bb
 
9897bb
         case 10: /* Address Length */
9897bb
 
9897bb
-            Descriptor->ExtAddress64.AddressLength = InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->ExtAddress64.AddressLength =
9897bb
+                AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
9897bb
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_LENGTH,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.AddressLength));
9897bb
             LengthOp = InitializerOp;
9897bb
@@ -536,7 +562,8 @@ RsDoExtendedSpaceDescriptor (
9897bb
 
9897bb
         case 11: /* Type-Specific Attributes */
9897bb
 
9897bb
-            Descriptor->ExtAddress64.TypeSpecific = InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->ExtAddress64.TypeSpecific =
9897bb
+                AcpiUtReadUint64 (&InitializerOp->Asl.Value.Integer);
9897bb
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_TYPESPECIFICATTRIBUTES,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.TypeSpecific));
9897bb
             break;
9897bb
@@ -557,11 +584,14 @@ RsDoExtendedSpaceDescriptor (
9897bb
 
9897bb
     /* Validate the Min/Max/Len/Gran values */
9897bb
 
9897bb
+    Tmp16 = Descriptor->ExtAddress64.ResourceLength;
9897bb
+    Descriptor->ExtAddress64.ResourceLength = AcpiUtReadUint16 (&Tmp16);
9897bb
+
9897bb
     RsLargeAddressCheck (
9897bb
-        Descriptor->ExtAddress64.Minimum,
9897bb
-        Descriptor->ExtAddress64.Maximum,
9897bb
-        Descriptor->ExtAddress64.AddressLength,
9897bb
-        Descriptor->ExtAddress64.Granularity,
9897bb
+        AcpiUtReadUint64 (&Descriptor->ExtAddress64.Minimum),
9897bb
+        AcpiUtReadUint64 (&Descriptor->ExtAddress64.Maximum),
9897bb
+        AcpiUtReadUint64 (&Descriptor->ExtAddress64.AddressLength),
9897bb
+        AcpiUtReadUint64 (&Descriptor->ExtAddress64.Granularity),
9897bb
         Descriptor->ExtAddress64.Flags,
9897bb
         MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp);
9897bb
 
9897bb
Index: acpica-unix2-20210604/source/compiler/aslrestype2s.c
9897bb
===================================================================
9897bb
--- acpica-unix2-20210604.orig/source/compiler/aslrestype2s.c
9897bb
+++ acpica-unix2-20210604/source/compiler/aslrestype2s.c
9897bb
@@ -343,6 +343,7 @@ RsDoGpioIntDescriptor (
9897bb
     UINT32                  CurrentByteOffset;
9897bb
     UINT32                  PinCount = 0;
9897bb
     UINT32                  i;
9897bb
+    UINT16                  Tmp16;
9897bb
 
9897bb
 
9897bb
     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
9897bb
@@ -485,7 +486,8 @@ RsDoGpioIntDescriptor (
9897bb
              *  (implies resource source must immediately follow the pin list.)
9897bb
              *  Name: _PIN
9897bb
              */
9897bb
-            *InterruptList = (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            *InterruptList = AcpiUtReadUint16 (&Tmp16);
9897bb
             InterruptList++;
9897bb
             PinCount++;
9897bb
 
9897bb
@@ -518,6 +520,27 @@ RsDoGpioIntDescriptor (
9897bb
 
9897bb
     MpSaveGpioInfo (Info->MappingOp, Descriptor,
9897bb
         PinCount, PinList, ResourceSource);
9897bb
+
9897bb
+    /* correct endian-ness issues */
9897bb
+    Tmp16 = Descriptor->Gpio.ResourceLength;
9897bb
+    Descriptor->Gpio.ResourceLength = AcpiUtReadUint16 (&Tmp16);
9897bb
+    Tmp16 = Descriptor->Gpio.Flags;
9897bb
+    Descriptor->Gpio.Flags = AcpiUtReadUint16 (&Tmp16);
9897bb
+    Tmp16 = Descriptor->Gpio.IntFlags;
9897bb
+    Descriptor->Gpio.IntFlags = AcpiUtReadUint16 (&Tmp16);
9897bb
+    Tmp16 = Descriptor->Gpio.DriveStrength;
9897bb
+    Descriptor->Gpio.DriveStrength = AcpiUtReadUint16 (&Tmp16);
9897bb
+    Tmp16 = Descriptor->Gpio.DebounceTimeout;
9897bb
+    Descriptor->Gpio.DebounceTimeout = AcpiUtReadUint16 (&Tmp16);
9897bb
+    Tmp16 = Descriptor->Gpio.PinTableOffset;
9897bb
+    Descriptor->Gpio.PinTableOffset = AcpiUtReadUint16 (&Tmp16);
9897bb
+    Tmp16 = Descriptor->Gpio.ResSourceOffset;
9897bb
+    Descriptor->Gpio.ResSourceOffset = AcpiUtReadUint16 (&Tmp16);
9897bb
+    Tmp16 = Descriptor->Gpio.VendorOffset;
9897bb
+    Descriptor->Gpio.VendorOffset = AcpiUtReadUint16 (&Tmp16);
9897bb
+    Tmp16 = Descriptor->Gpio.VendorLength;
9897bb
+    Descriptor->Gpio.VendorLength = AcpiUtReadUint16 (&Tmp16);
9897bb
+
9897bb
     return (Rnode);
9897bb
 }
9897bb
 
9897bb
@@ -552,6 +575,7 @@ RsDoGpioIoDescriptor (
9897bb
     UINT32                  CurrentByteOffset;
9897bb
     UINT32                  PinCount = 0;
9897bb
     UINT32                  i;
9897bb
+    UINT16                  Tmp16;
9897bb
 
9897bb
 
9897bb
     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
9897bb
@@ -691,7 +715,8 @@ RsDoGpioIoDescriptor (
9897bb
              *  (implies resource source must immediately follow the pin list.)
9897bb
              *  Name: _PIN
9897bb
              */
9897bb
-            *InterruptList = (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            *InterruptList = AcpiUtReadUint16 (&Tmp16);
9897bb
             InterruptList++;
9897bb
             PinCount++;
9897bb
 
9897bb
@@ -724,6 +749,27 @@ RsDoGpioIoDescriptor (
9897bb
 
9897bb
     MpSaveGpioInfo (Info->MappingOp, Descriptor,
9897bb
         PinCount, PinList, ResourceSource);
9897bb
+
9897bb
+    /* correct endian-ness issues */
9897bb
+    Tmp16 = Descriptor->Gpio.ResourceLength;
9897bb
+    Descriptor->Gpio.ResourceLength = AcpiUtReadUint16 (&Tmp16);
9897bb
+    Tmp16 = Descriptor->Gpio.Flags;
9897bb
+    Descriptor->Gpio.Flags = AcpiUtReadUint16 (&Tmp16);
9897bb
+    Tmp16 = Descriptor->Gpio.IntFlags;
9897bb
+    Descriptor->Gpio.IntFlags = AcpiUtReadUint16 (&Tmp16);
9897bb
+    Tmp16 = Descriptor->Gpio.DriveStrength;
9897bb
+    Descriptor->Gpio.DriveStrength = AcpiUtReadUint16 (&Tmp16);
9897bb
+    Tmp16 = Descriptor->Gpio.DebounceTimeout;
9897bb
+    Descriptor->Gpio.DebounceTimeout = AcpiUtReadUint16 (&Tmp16);
9897bb
+    Tmp16 = Descriptor->Gpio.PinTableOffset;
9897bb
+    Descriptor->Gpio.PinTableOffset = AcpiUtReadUint16 (&Tmp16);
9897bb
+    Tmp16 = Descriptor->Gpio.ResSourceOffset;
9897bb
+    Descriptor->Gpio.ResSourceOffset = AcpiUtReadUint16 (&Tmp16);
9897bb
+    Tmp16 = Descriptor->Gpio.VendorOffset;
9897bb
+    Descriptor->Gpio.VendorOffset = AcpiUtReadUint16 (&Tmp16);
9897bb
+    Tmp16 = Descriptor->Gpio.VendorLength;
9897bb
+    Descriptor->Gpio.VendorLength = AcpiUtReadUint16 (&Tmp16);
9897bb
+
9897bb
     return (Rnode);
9897bb
 }
9897bb
 
9897bb
@@ -754,6 +800,8 @@ RsDoI2cSerialBusDescriptor (
9897bb
     UINT16                  DescriptorSize;
9897bb
     UINT32                  CurrentByteOffset;
9897bb
     UINT32                  i;
9897bb
+    UINT16                  Tmp16;
9897bb
+    UINT32                  Tmp32;
9897bb
 
9897bb
 
9897bb
     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
9897bb
@@ -781,7 +829,8 @@ RsDoI2cSerialBusDescriptor (
9897bb
     Descriptor->I2cSerialBus.RevisionId = AML_RESOURCE_I2C_REVISION;
9897bb
     Descriptor->I2cSerialBus.TypeRevisionId = AML_RESOURCE_I2C_TYPE_REVISION;
9897bb
     Descriptor->I2cSerialBus.Type = AML_RESOURCE_I2C_SERIALBUSTYPE;
9897bb
-    Descriptor->I2cSerialBus.TypeDataLength = AML_RESOURCE_I2C_MIN_DATA_LEN + VendorLength;
9897bb
+    Tmp16 = AML_RESOURCE_I2C_MIN_DATA_LEN + VendorLength;
9897bb
+    Descriptor->I2cSerialBus.TypeDataLength = AcpiUtReadUint16 (&Tmp16);
9897bb
 
9897bb
     if (Info->DescriptorTypeOp->Asl.ParseOpcode == PARSEOP_I2C_SERIALBUS_V2)
9897bb
     {
9897bb
@@ -795,13 +844,15 @@ RsDoI2cSerialBusDescriptor (
9897bb
 
9897bb
     /* Process all child initialization nodes */
9897bb
 
9897bb
+    Descriptor->I2cSerialBus.TypeSpecificFlags = 0;
9897bb
     for (i = 0; InitializerOp; i++)
9897bb
     {
9897bb
         switch (i)
9897bb
         {
9897bb
         case 0: /* Slave Address [WORD] (_ADR) */
9897bb
 
9897bb
-            Descriptor->I2cSerialBus.SlaveAddress = (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->I2cSerialBus.SlaveAddress = AcpiUtReadUint16 (&Tmp16);
9897bb
             RsCreateWordField (InitializerOp, ACPI_RESTAG_ADDRESS,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (I2cSerialBus.SlaveAddress));
9897bb
             break;
9897bb
@@ -815,16 +866,19 @@ RsDoI2cSerialBusDescriptor (
9897bb
 
9897bb
         case 2: /* Connection Speed [DWORD] (_SPE) */
9897bb
 
9897bb
-            Descriptor->I2cSerialBus.ConnectionSpeed = (UINT32) InitializerOp->Asl.Value.Integer;
9897bb
+            Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->I2cSerialBus.ConnectionSpeed = AcpiUtReadUint32 (&Tmp32);
9897bb
             RsCreateDwordField (InitializerOp, ACPI_RESTAG_SPEED,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (I2cSerialBus.ConnectionSpeed));
9897bb
             break;
9897bb
 
9897bb
         case 3: /* Addressing Mode [Flag] (_MOD) */
9897bb
 
9897bb
-            RsSetFlagBits16 (&Descriptor->I2cSerialBus.TypeSpecificFlags, InitializerOp, 0, 0);
9897bb
+            Tmp16 = AcpiUtReadUint16 (&Descriptor->I2cSerialBus.TypeSpecificFlags);
9897bb
+            RsSetFlagBits16 (&Tmp16, InitializerOp, 0, 0);
9897bb
             RsCreateBitField (InitializerOp, ACPI_RESTAG_MODE,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (I2cSerialBus.TypeSpecificFlags), 0);
9897bb
+            Descriptor->I2cSerialBus.TypeSpecificFlags = AcpiUtReadUint16 (&Tmp16);
9897bb
             break;
9897bb
 
9897bb
         case 4: /* ResSource [Optional Field - STRING] */
9897bb
@@ -882,6 +936,8 @@ RsDoI2cSerialBusDescriptor (
9897bb
         InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
9897bb
     }
9897bb
 
9897bb
+    Tmp16 = Descriptor->I2cSerialBus.ResourceLength;
9897bb
+    Descriptor->I2cSerialBus.ResourceLength = AcpiUtReadUint16 (&Tmp16);
9897bb
     MpSaveSerialInfo (Info->MappingOp, Descriptor, ResourceSource);
9897bb
     return (Rnode);
9897bb
 }
9897bb
@@ -913,6 +969,8 @@ RsDoSpiSerialBusDescriptor (
9897bb
     UINT16                  DescriptorSize;
9897bb
     UINT32                  CurrentByteOffset;
9897bb
     UINT32                  i;
9897bb
+    UINT16                  Tmp16;
9897bb
+    UINT32                  Tmp32;
9897bb
 
9897bb
 
9897bb
     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
9897bb
@@ -935,12 +993,13 @@ RsDoSpiSerialBusDescriptor (
9897bb
         sizeof (AML_RESOURCE_LARGE_HEADER));
9897bb
 
9897bb
     Descriptor = Rnode->Buffer;
9897bb
-    Descriptor->SpiSerialBus.ResourceLength = DescriptorSize;
9897bb
+    Descriptor->SpiSerialBus.ResourceLength = AcpiUtReadUint16 (&DescriptorSize);
9897bb
     Descriptor->SpiSerialBus.DescriptorType = ACPI_RESOURCE_NAME_SERIAL_BUS;
9897bb
     Descriptor->SpiSerialBus.RevisionId = AML_RESOURCE_SPI_REVISION;
9897bb
     Descriptor->SpiSerialBus.TypeRevisionId = AML_RESOURCE_SPI_TYPE_REVISION;
9897bb
     Descriptor->SpiSerialBus.Type = AML_RESOURCE_SPI_SERIALBUSTYPE;
9897bb
-    Descriptor->SpiSerialBus.TypeDataLength = AML_RESOURCE_SPI_MIN_DATA_LEN + VendorLength;
9897bb
+    Tmp16 = AML_RESOURCE_SPI_MIN_DATA_LEN + VendorLength;
9897bb
+    Descriptor->SpiSerialBus.TypeDataLength = AcpiUtReadUint16 (&Tmp16);
9897bb
 
9897bb
     if (Info->DescriptorTypeOp->Asl.ParseOpcode == PARSEOP_SPI_SERIALBUS_V2)
9897bb
     {
9897bb
@@ -955,29 +1014,35 @@ RsDoSpiSerialBusDescriptor (
9897bb
 
9897bb
     /* Process all child initialization nodes */
9897bb
 
9897bb
+    Descriptor->SpiSerialBus.TypeSpecificFlags = 0;
9897bb
     for (i = 0; InitializerOp; i++)
9897bb
     {
9897bb
         switch (i)
9897bb
         {
9897bb
         case 0: /* Device Selection [WORD] (_ADR) */
9897bb
 
9897bb
-            Descriptor->SpiSerialBus.DeviceSelection = (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->SpiSerialBus.DeviceSelection = AcpiUtReadUint16 (&Tmp16);
9897bb
             RsCreateWordField (InitializerOp, ACPI_RESTAG_ADDRESS,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (SpiSerialBus.DeviceSelection));
9897bb
             break;
9897bb
 
9897bb
         case 1: /* Device Polarity [Flag] (_DPL) */
9897bb
 
9897bb
-            RsSetFlagBits16 (&Descriptor->SpiSerialBus.TypeSpecificFlags, InitializerOp, 1, 0);
9897bb
+            Tmp16 = AcpiUtReadUint16 (&Descriptor->SpiSerialBus.TypeSpecificFlags);
9897bb
+            RsSetFlagBits16 (&Tmp16, InitializerOp, 1, 0);
9897bb
             RsCreateBitField (InitializerOp, ACPI_RESTAG_DEVICEPOLARITY,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (SpiSerialBus.TypeSpecificFlags), 1);
9897bb
+            Descriptor->SpiSerialBus.TypeSpecificFlags = AcpiUtReadUint16 (&Tmp16);
9897bb
             break;
9897bb
 
9897bb
         case 2: /* Wire Mode [Flag] (_MOD) */
9897bb
 
9897bb
-            RsSetFlagBits16 (&Descriptor->SpiSerialBus.TypeSpecificFlags, InitializerOp, 0, 0);
9897bb
+            Tmp16 = AcpiUtReadUint16 (&Descriptor->SpiSerialBus.TypeSpecificFlags);
9897bb
+            RsSetFlagBits16 (&Tmp16, InitializerOp, 0, 0);
9897bb
             RsCreateBitField (InitializerOp, ACPI_RESTAG_MODE,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (SpiSerialBus.TypeSpecificFlags), 0);
9897bb
+            Descriptor->SpiSerialBus.TypeSpecificFlags = AcpiUtReadUint16 (&Tmp16);
9897bb
             break;
9897bb
 
9897bb
         case 3: /* Device Bit Length [BYTE] (_LEN) */
9897bb
@@ -996,7 +1061,8 @@ RsDoSpiSerialBusDescriptor (
9897bb
 
9897bb
         case 5: /* Connection Speed [DWORD] (_SPE) */
9897bb
 
9897bb
-            Descriptor->SpiSerialBus.ConnectionSpeed = (UINT32) InitializerOp->Asl.Value.Integer;
9897bb
+            Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->SpiSerialBus.ConnectionSpeed = AcpiUtReadUint32 (&Tmp32);
9897bb
             RsCreateDwordField (InitializerOp, ACPI_RESTAG_SPEED,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (SpiSerialBus.ConnectionSpeed));
9897bb
             break;
9897bb
@@ -1101,6 +1167,8 @@ RsDoUartSerialBusDescriptor (
9897bb
     UINT16                  DescriptorSize;
9897bb
     UINT32                  CurrentByteOffset;
9897bb
     UINT32                  i;
9897bb
+    UINT16                  Tmp16;
9897bb
+    UINT32                  Tmp32;
9897bb
 
9897bb
 
9897bb
     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
9897bb
@@ -1123,12 +1191,13 @@ RsDoUartSerialBusDescriptor (
9897bb
         sizeof (AML_RESOURCE_LARGE_HEADER));
9897bb
 
9897bb
     Descriptor = Rnode->Buffer;
9897bb
-    Descriptor->UartSerialBus.ResourceLength = DescriptorSize;
9897bb
+    Descriptor->UartSerialBus.ResourceLength = AcpiUtReadUint16 (&DescriptorSize);
9897bb
     Descriptor->UartSerialBus.DescriptorType = ACPI_RESOURCE_NAME_SERIAL_BUS;
9897bb
     Descriptor->UartSerialBus.RevisionId = AML_RESOURCE_UART_REVISION;
9897bb
     Descriptor->UartSerialBus.TypeRevisionId = AML_RESOURCE_UART_TYPE_REVISION;
9897bb
     Descriptor->UartSerialBus.Type = AML_RESOURCE_UART_SERIALBUSTYPE;
9897bb
-    Descriptor->UartSerialBus.TypeDataLength = AML_RESOURCE_UART_MIN_DATA_LEN + VendorLength;
9897bb
+    Tmp16 = AML_RESOURCE_UART_MIN_DATA_LEN + VendorLength;
9897bb
+    Descriptor->UartSerialBus.TypeDataLength = AcpiUtReadUint16 (&Tmp16);
9897bb
 
9897bb
     if (Info->DescriptorTypeOp->Asl.ParseOpcode == PARSEOP_UART_SERIALBUS_V2)
9897bb
     {
9897bb
@@ -1142,29 +1211,35 @@ RsDoUartSerialBusDescriptor (
9897bb
 
9897bb
     /* Process all child initialization nodes */
9897bb
 
9897bb
+    Descriptor->UartSerialBus.TypeSpecificFlags = 0;
9897bb
     for (i = 0; InitializerOp; i++)
9897bb
     {
9897bb
         switch (i)
9897bb
         {
9897bb
         case 0: /* Connection Speed (Baud Rate) [DWORD] (_SPE) */
9897bb
 
9897bb
-            Descriptor->UartSerialBus.DefaultBaudRate = (UINT32) InitializerOp->Asl.Value.Integer;
9897bb
+            Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->UartSerialBus.DefaultBaudRate = AcpiUtReadUint32 (&Tmp32);
9897bb
             RsCreateDwordField (InitializerOp, ACPI_RESTAG_SPEED,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.DefaultBaudRate));
9897bb
             break;
9897bb
 
9897bb
         case 1: /* Bits Per Byte [Flags] (_LEN) */
9897bb
 
9897bb
-            RsSetFlagBits16 (&Descriptor->UartSerialBus.TypeSpecificFlags, InitializerOp, 4, 3);
9897bb
+            Tmp16 = AcpiUtReadUint16 (&Descriptor->UartSerialBus.TypeSpecificFlags);
9897bb
+            RsSetFlagBits16 (&Tmp16, InitializerOp, 4, 3);
9897bb
             RsCreateMultiBitField (InitializerOp, ACPI_RESTAG_LENGTH,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.TypeSpecificFlags), 4, 3);
9897bb
+            Descriptor->UartSerialBus.TypeSpecificFlags = AcpiUtReadUint16 (&Tmp16);;
9897bb
             break;
9897bb
 
9897bb
         case 2: /* Stop Bits [Flags] (_STB) */
9897bb
 
9897bb
-            RsSetFlagBits16 (&Descriptor->UartSerialBus.TypeSpecificFlags, InitializerOp, 2, 1);
9897bb
+            Tmp16 = AcpiUtReadUint16 (&Descriptor->UartSerialBus.TypeSpecificFlags);
9897bb
+            RsSetFlagBits16 (&Tmp16, InitializerOp, 2, 1);
9897bb
             RsCreateMultiBitField (InitializerOp, ACPI_RESTAG_STOPBITS,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.TypeSpecificFlags), 2, 2);
9897bb
+            Descriptor->UartSerialBus.TypeSpecificFlags = AcpiUtReadUint16 (&Tmp16);;
9897bb
             break;
9897bb
 
9897bb
         case 3: /* Lines In Use [BYTE] (_LIN) */
9897bb
@@ -1176,9 +1251,11 @@ RsDoUartSerialBusDescriptor (
9897bb
 
9897bb
         case 4: /* Endianness [Flag] (_END) */
9897bb
 
9897bb
-            RsSetFlagBits16 (&Descriptor->UartSerialBus.TypeSpecificFlags, InitializerOp, 7, 0);
9897bb
+            Tmp16 = AcpiUtReadUint16 (&Descriptor->UartSerialBus.TypeSpecificFlags);
9897bb
+            RsSetFlagBits16 (&Tmp16, InitializerOp, 7, 0);
9897bb
             RsCreateBitField (InitializerOp, ACPI_RESTAG_ENDIANNESS,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.TypeSpecificFlags), 7);
9897bb
+            Descriptor->UartSerialBus.TypeSpecificFlags = AcpiUtReadUint16 (&Tmp16);;
9897bb
             break;
9897bb
 
9897bb
         case 5: /* Parity [BYTE] (_PAR) */
9897bb
@@ -1190,21 +1267,25 @@ RsDoUartSerialBusDescriptor (
9897bb
 
9897bb
         case 6: /* Flow Control [Flags] (_FLC) */
9897bb
 
9897bb
-            RsSetFlagBits16 (&Descriptor->UartSerialBus.TypeSpecificFlags, InitializerOp, 0, 0);
9897bb
+            Tmp16 = AcpiUtReadUint16 (&Descriptor->UartSerialBus.TypeSpecificFlags);
9897bb
+            RsSetFlagBits16 (&Tmp16, InitializerOp, 0, 0);
9897bb
             RsCreateMultiBitField (InitializerOp, ACPI_RESTAG_FLOWCONTROL,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.TypeSpecificFlags), 0, 2);
9897bb
+            Descriptor->UartSerialBus.TypeSpecificFlags = AcpiUtReadUint16 (&Tmp16);;
9897bb
             break;
9897bb
 
9897bb
         case 7: /* Rx Buffer Size [WORD] (_RXL) */
9897bb
 
9897bb
-            Descriptor->UartSerialBus.RxFifoSize = (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->UartSerialBus.RxFifoSize = AcpiUtReadUint16 (&Tmp16);
9897bb
             RsCreateWordField (InitializerOp, ACPI_RESTAG_LENGTH_RX,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.RxFifoSize));
9897bb
             break;
9897bb
 
9897bb
         case 8: /* Tx Buffer Size [WORD] (_TXL) */
9897bb
 
9897bb
-            Descriptor->UartSerialBus.TxFifoSize = (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->UartSerialBus.TxFifoSize = AcpiUtReadUint16 (&Tmp16);
9897bb
             RsCreateWordField (InitializerOp, ACPI_RESTAG_LENGTH_TX,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.TxFifoSize));
9897bb
             break;
9897bb
@@ -1444,6 +1525,7 @@ RsDoPinFunctionDescriptor (
9897bb
     UINT32                  CurrentByteOffset;
9897bb
     UINT32                  PinCount = 0;
9897bb
     UINT32                  i;
9897bb
+    UINT16                  Tmp16;
9897bb
 
9897bb
     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
9897bb
     CurrentByteOffset = Info->CurrentByteOffset;
9897bb
@@ -1467,7 +1549,7 @@ RsDoPinFunctionDescriptor (
9897bb
         sizeof (AML_RESOURCE_LARGE_HEADER));
9897bb
 
9897bb
     Descriptor = Rnode->Buffer;
9897bb
-    Descriptor->PinFunction.ResourceLength = DescriptorSize;
9897bb
+    Descriptor->PinFunction.ResourceLength = AcpiUtReadUint16 (&DescriptorSize);
9897bb
     Descriptor->PinFunction.DescriptorType = ACPI_RESOURCE_NAME_PIN_FUNCTION;
9897bb
     Descriptor->PinFunction.RevisionId = AML_RESOURCE_PIN_FUNCTION_REVISION;
9897bb
 
9897bb
@@ -1507,7 +1589,8 @@ RsDoPinFunctionDescriptor (
9897bb
 
9897bb
         case 2: /* Function Number [WORD] (_FUN) */
9897bb
 
9897bb
-            Descriptor->PinFunction.FunctionNumber = (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->PinFunction.FunctionNumber = AcpiUtReadUint16 (&Tmp16);
9897bb
             RsCreateDwordField (InitializerOp, ACPI_RESTAG_FUNCTION,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (PinFunction.FunctionNumber));
9897bb
             break;
9897bb
@@ -1555,6 +1638,12 @@ RsDoPinFunctionDescriptor (
9897bb
             {
9897bb
                 Descriptor->PinFunction.VendorLength = VendorLength;
9897bb
             }
9897bb
+            Tmp16 = (UINT16) ACPI_PTR_DIFF (VendorData, Descriptor);
9897bb
+            Descriptor->PinFunction.VendorOffset = AcpiUtReadUint16 (&Tmp16);
9897bb
+
9897bb
+            Tmp16 = Descriptor->PinFunction.VendorLength;
9897bb
+            Descriptor->PinFunction.VendorLength = AcpiUtReadUint16 (&Tmp16);
9897bb
+
9897bb
             break;
9897bb
 
9897bb
         default:
9897bb
@@ -1566,7 +1655,8 @@ RsDoPinFunctionDescriptor (
9897bb
              *  (implies resource source must immediately follow the pin list.)
9897bb
              *  Name: _PIN
9897bb
              */
9897bb
-            *PinList = (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            *PinList = AcpiUtReadUint16 (&Tmp16);
9897bb
             PinList++;
9897bb
             PinCount++;
9897bb
 
9897bb
@@ -1597,6 +1687,13 @@ RsDoPinFunctionDescriptor (
9897bb
         InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
9897bb
     }
9897bb
 
9897bb
+    /* correct the endian-ness of the values */
9897bb
+    Tmp16 = Descriptor->PinFunction.PinTableOffset;
9897bb
+    Descriptor->PinFunction.PinTableOffset = AcpiUtReadUint16 (&Tmp16);
9897bb
+
9897bb
+    Tmp16 = Descriptor->PinFunction.ResSourceOffset;
9897bb
+    Descriptor->PinFunction.ResSourceOffset = AcpiUtReadUint16 (&Tmp16);
9897bb
+
9897bb
     return (Rnode);
9897bb
 }
9897bb
 
9897bb
@@ -1630,6 +1727,8 @@ RsDoPinConfigDescriptor (
9897bb
     UINT32                  CurrentByteOffset;
9897bb
     UINT32                  PinCount = 0;
9897bb
     UINT32                  i;
9897bb
+    UINT16                  Tmp16;
9897bb
+    UINT32                  Tmp32;
9897bb
 
9897bb
     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
9897bb
     CurrentByteOffset = Info->CurrentByteOffset;
9897bb
@@ -1653,7 +1752,7 @@ RsDoPinConfigDescriptor (
9897bb
         sizeof (AML_RESOURCE_LARGE_HEADER));
9897bb
 
9897bb
     Descriptor = Rnode->Buffer;
9897bb
-    Descriptor->PinConfig.ResourceLength = DescriptorSize;
9897bb
+    Descriptor->PinConfig.ResourceLength = AcpiUtReadUint16 (&DescriptorSize);
9897bb
     Descriptor->PinConfig.DescriptorType = ACPI_RESOURCE_NAME_PIN_CONFIG;
9897bb
     Descriptor->PinConfig.RevisionId = AML_RESOURCE_PIN_CONFIG_REVISION;
9897bb
 
9897bb
@@ -1707,7 +1806,8 @@ RsDoPinConfigDescriptor (
9897bb
 
9897bb
         case 2: /* Pin Config Value [DWORD] (_VAL) */
9897bb
 
9897bb
-            Descriptor->PinConfig.PinConfigValue = (UINT32) InitializerOp->Asl.Value.Integer;
9897bb
+            Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->PinConfig.PinConfigValue = AcpiUtReadUint32 (&Tmp32);
9897bb
             RsCreateDwordField (InitializerOp, ACPI_RESTAG_PINCONFIG_VALUE,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (PinConfig.PinConfigValue));
9897bb
             break;
9897bb
@@ -1766,7 +1866,8 @@ RsDoPinConfigDescriptor (
9897bb
              *  (implies resource source must immediately follow the pin list.)
9897bb
              *  Name: _PIN
9897bb
              */
9897bb
-            *PinList = (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            *PinList = AcpiUtReadUint16 (&Tmp16);
9897bb
             PinList++;
9897bb
             PinCount++;
9897bb
 
9897bb
@@ -1797,6 +1898,16 @@ RsDoPinConfigDescriptor (
9897bb
         InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
9897bb
     }
9897bb
 
9897bb
+    /* correct the endianness if needed */
9897bb
+    Tmp16 = Descriptor->PinConfig.PinTableOffset;
9897bb
+    Descriptor->PinConfig.PinTableOffset = AcpiUtReadUint16 (&Tmp16);
9897bb
+    Tmp16 = Descriptor->PinConfig.ResSourceOffset;
9897bb
+    Descriptor->PinConfig.ResSourceOffset = AcpiUtReadUint16 (&Tmp16);
9897bb
+    Tmp16 = Descriptor->PinConfig.VendorOffset;
9897bb
+    Descriptor->PinConfig.VendorOffset = AcpiUtReadUint16 (&Tmp16);
9897bb
+    Tmp16 = Descriptor->PinConfig.VendorLength;
9897bb
+    Descriptor->PinConfig.VendorLength = AcpiUtReadUint16 (&Tmp16);
9897bb
+
9897bb
     return (Rnode);
9897bb
 }
9897bb
 
9897bb
@@ -1830,6 +1941,7 @@ RsDoPinGroupDescriptor (
9897bb
     UINT32                  CurrentByteOffset;
9897bb
     UINT32                  PinCount = 0;
9897bb
     UINT32                  i;
9897bb
+    UINT16                  Tmp16;
9897bb
 
9897bb
     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
9897bb
     CurrentByteOffset = Info->CurrentByteOffset;
9897bb
@@ -1853,7 +1965,7 @@ RsDoPinGroupDescriptor (
9897bb
         sizeof (AML_RESOURCE_LARGE_HEADER));
9897bb
 
9897bb
     Descriptor = Rnode->Buffer;
9897bb
-    Descriptor->PinGroup.ResourceLength = DescriptorSize;
9897bb
+    Descriptor->PinGroup.ResourceLength = AcpiUtReadUint16 (&DescriptorSize);
9897bb
     Descriptor->PinGroup.DescriptorType = ACPI_RESOURCE_NAME_PIN_GROUP;
9897bb
     Descriptor->PinGroup.RevisionId = AML_RESOURCE_PIN_GROUP_REVISION;
9897bb
 
9897bb
@@ -1920,7 +2032,8 @@ RsDoPinGroupDescriptor (
9897bb
              *  (implies resource source must immediately follow the pin list.)
9897bb
              *  Name: _PIN
9897bb
              */
9897bb
-            *PinList = (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+        Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            *PinList = AcpiUtReadUint16 (&Tmp16);
9897bb
             PinList++;
9897bb
             PinCount++;
9897bb
 
9897bb
@@ -1951,6 +2064,16 @@ RsDoPinGroupDescriptor (
9897bb
         InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
9897bb
     }
9897bb
 
9897bb
+    /* correct enddianness as needed */
9897bb
+    Tmp16 = Descriptor->PinGroup.PinTableOffset;
9897bb
+    Descriptor->PinGroup.PinTableOffset = AcpiUtReadUint16 (&Tmp16);
9897bb
+    Tmp16 = Descriptor->PinGroup.LabelOffset;
9897bb
+    Descriptor->PinGroup.LabelOffset = AcpiUtReadUint16 (&Tmp16);
9897bb
+    Tmp16 = Descriptor->PinGroup.VendorOffset;
9897bb
+    Descriptor->PinGroup.VendorOffset = AcpiUtReadUint16 (&Tmp16);
9897bb
+    Tmp16 = Descriptor->PinGroup.VendorLength;
9897bb
+    Descriptor->PinGroup.VendorLength = AcpiUtReadUint16 (&Tmp16);
9897bb
+
9897bb
     return (Rnode);
9897bb
 }
9897bb
 
9897bb
@@ -1983,6 +2106,7 @@ RsDoPinGroupFunctionDescriptor (
9897bb
     UINT16                  DescriptorSize;
9897bb
     UINT32                  CurrentByteOffset;
9897bb
     UINT32                  i;
9897bb
+    UINT16                  Tmp16;
9897bb
 
9897bb
     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
9897bb
     CurrentByteOffset = Info->CurrentByteOffset;
9897bb
@@ -2006,7 +2130,7 @@ RsDoPinGroupFunctionDescriptor (
9897bb
         sizeof (AML_RESOURCE_LARGE_HEADER));
9897bb
 
9897bb
     Descriptor = Rnode->Buffer;
9897bb
-    Descriptor->PinGroupFunction.ResourceLength = DescriptorSize;
9897bb
+    Descriptor->PinGroupFunction.ResourceLength = AcpiUtReadUint16 (&DescriptorSize);
9897bb
     Descriptor->PinGroupFunction.DescriptorType = ACPI_RESOURCE_NAME_PIN_GROUP_FUNCTION;
9897bb
     Descriptor->PinGroupFunction.RevisionId = AML_RESOURCE_PIN_GROUP_FUNCTION_REVISION;
9897bb
 
9897bb
@@ -2038,7 +2162,8 @@ RsDoPinGroupFunctionDescriptor (
9897bb
 
9897bb
         case 1: /* Function Number [WORD] */
9897bb
 
9897bb
-            Descriptor->PinGroupFunction.FunctionNumber = (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->PinGroupFunction.FunctionNumber = AcpiUtReadUint16 (&Tmp16);
9897bb
             RsCreateDwordField (InitializerOp, ACPI_RESTAG_FUNCTION,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (PinGroupFunction.FunctionNumber));
9897bb
             break;
9897bb
@@ -2097,6 +2222,16 @@ RsDoPinGroupFunctionDescriptor (
9897bb
         InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
9897bb
     }
9897bb
 
9897bb
+    /* correct enddianness as needed */
9897bb
+    Tmp16 = Descriptor->PinGroupFunction.ResSourceOffset;
9897bb
+    Descriptor->PinGroupFunction.ResSourceOffset = AcpiUtReadUint16 (&Tmp16);
9897bb
+    Tmp16 = Descriptor->PinGroupFunction.ResSourceLabelOffset;
9897bb
+    Descriptor->PinGroupFunction.ResSourceLabelOffset = AcpiUtReadUint16 (&Tmp16);
9897bb
+    Tmp16 = Descriptor->PinGroupFunction.VendorOffset;
9897bb
+    Descriptor->PinGroupFunction.VendorOffset = AcpiUtReadUint16 (&Tmp16);
9897bb
+    Tmp16 = Descriptor->PinGroupFunction.VendorLength;
9897bb
+    Descriptor->PinGroupFunction.VendorLength = AcpiUtReadUint16 (&Tmp16);
9897bb
+
9897bb
     return (Rnode);
9897bb
 }
9897bb
 
9897bb
@@ -2129,6 +2264,8 @@ RsDoPinGroupConfigDescriptor (
9897bb
     UINT16                  DescriptorSize;
9897bb
     UINT32                  CurrentByteOffset;
9897bb
     UINT32                  i;
9897bb
+    UINT16                  Tmp16;
9897bb
+    UINT32                  Tmp32;
9897bb
 
9897bb
     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
9897bb
     CurrentByteOffset = Info->CurrentByteOffset;
9897bb
@@ -2152,7 +2289,7 @@ RsDoPinGroupConfigDescriptor (
9897bb
         sizeof (AML_RESOURCE_LARGE_HEADER));
9897bb
 
9897bb
     Descriptor = Rnode->Buffer;
9897bb
-    Descriptor->PinGroupConfig.ResourceLength = DescriptorSize;
9897bb
+    Descriptor->PinGroupConfig.ResourceLength = AcpiUtReadUint16 (&DescriptorSize);
9897bb
     Descriptor->PinGroupConfig.DescriptorType = ACPI_RESOURCE_NAME_PIN_GROUP_CONFIG;
9897bb
     Descriptor->PinGroupConfig.RevisionId = AML_RESOURCE_PIN_GROUP_CONFIG_REVISION;
9897bb
 
9897bb
@@ -2205,7 +2342,8 @@ RsDoPinGroupConfigDescriptor (
9897bb
 
9897bb
         case 2: /* Pin Config Value [DWORD] (_VAL) */
9897bb
 
9897bb
-            Descriptor->PinGroupConfig.PinConfigValue = (UINT32) InitializerOp->Asl.Value.Integer;
9897bb
+            Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
9897bb
+            Descriptor->PinGroupConfig.PinConfigValue = AcpiUtReadUint32 (&Tmp32);
9897bb
             RsCreateDwordField (InitializerOp, ACPI_RESTAG_PINCONFIG_VALUE,
9897bb
                 CurrentByteOffset + ASL_RESDESC_OFFSET (PinGroupConfig.PinConfigValue));
9897bb
             break;
9897bb
@@ -2266,5 +2404,15 @@ RsDoPinGroupConfigDescriptor (
9897bb
         InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
9897bb
     }
9897bb
 
9897bb
+    /* correct enddianness as needed */
9897bb
+    Tmp16 = Descriptor->PinGroupConfig.ResSourceOffset;
9897bb
+    Descriptor->PinGroupConfig.ResSourceOffset = AcpiUtReadUint16 (&Tmp16);
9897bb
+    Tmp16 = Descriptor->PinGroupConfig.ResSourceLabelOffset;
9897bb
+    Descriptor->PinGroupConfig.ResSourceLabelOffset = AcpiUtReadUint16 (&Tmp16);
9897bb
+    Tmp16 = Descriptor->PinGroupConfig.VendorOffset;
9897bb
+    Descriptor->PinGroupConfig.VendorOffset = AcpiUtReadUint16 (&Tmp16);
9897bb
+    Tmp16 = Descriptor->PinGroupConfig.VendorLength;
9897bb
+    Descriptor->PinGroupConfig.VendorLength = AcpiUtReadUint16 (&Tmp16);
9897bb
+
9897bb
     return (Rnode);
9897bb
 }