Blame 0040-Support-DSDT-SSDT-in-a-big-endian-world.patch

6c29d68
From a11c0a997dca2b40d1bcff68368d9d5d5297b781 Mon Sep 17 00:00:00 2001
edb6c78
From: Al Stone <ahs3@redhat.com>
edb6c78
Date: Thu, 15 Oct 2020 11:35:23 -0600
6c29d68
Subject: [PATCH 2/5] Support DSDT/SSDT in a big-endian world
edb6c78
edb6c78
NB: this is a very large diff.  The problem is that ResourceTemplates
edb6c78
are treated differently during compilation and disassembly so each of
edb6c78
the resource types had code that needed to be touched directly.
edb6c78
edb6c78
In general, however, just reading or writing individual AML opcodes
edb6c78
wasn't that much of a change, and most of it was on the codegen side.
edb6c78
edb6c78
Signed-off-by: Al Stone <ahs3@redhat.com>
edb6c78
---
edb6c78
 source/common/dmrestag.c                   |   2 +-
edb6c78
 source/common/dmtables.c                   |  17 +-
edb6c78
 source/common/dmtbdump.c                   |   3 +-
6c29d68
 source/compiler/aslcodegen.c               |  61 ++++--
6c29d68
 source/compiler/aslopcodes.c               |   3 +-
edb6c78
 source/compiler/aslrestype1.c              |  44 +++--
edb6c78
 source/compiler/aslrestype1i.c             |  33 ++--
6c29d68
 source/compiler/aslrestype2.c              |  20 +-
6c29d68
 source/compiler/aslrestype2d.c             |  99 ++++++----
6c29d68
 source/compiler/aslrestype2e.c             |  90 ++++++---
6c29d68
 source/compiler/aslrestype2q.c             |  81 +++++---
6c29d68
 source/compiler/aslrestype2s.c             | 214 +++++++++++++++++----
6c29d68
 source/compiler/aslrestype2w.c             |  94 +++++----
6c29d68
 source/components/disassembler/dmbuffer.c  |  10 +-
edb6c78
 source/components/disassembler/dmopcode.c  |   8 +-
edb6c78
 source/components/disassembler/dmresrc.c   |   2 +-
edb6c78
 source/components/disassembler/dmresrcl.c  |  43 +++--
6c29d68
 source/components/disassembler/dmresrcl2.c | 128 +++++++-----
edb6c78
 source/components/disassembler/dmresrcs.c  |  18 +-
6c29d68
 source/components/disassembler/dmwalk.c    |   2 +-
edb6c78
 source/components/dispatcher/dsfield.c     |  16 +-
edb6c78
 source/components/namespace/nsaccess.c     |   2 +-
edb6c78
 source/components/namespace/nsnames.c      |   2 +-
edb6c78
 source/components/namespace/nsparse.c      |   6 +-
edb6c78
 source/components/namespace/nsutils.c      |   7 +-
6c29d68
 25 files changed, 682 insertions(+), 323 deletions(-)
edb6c78
38a008c
Index: acpica-unix2-20200925/source/common/dmrestag.c
38a008c
===================================================================
38a008c
--- acpica-unix2-20200925.orig/source/common/dmrestag.c
38a008c
+++ acpica-unix2-20200925/source/common/dmrestag.c
38a008c
@@ -1038,7 +1038,7 @@ AcpiDmAddResourcesToNamespace (
edb6c78
      * NextOp contains the Aml pointer and the Aml length
edb6c78
      */
edb6c78
     AcpiUtWalkAmlResources (NULL, (UINT8 *) NextOp->Named.Data,
edb6c78
-        (ACPI_SIZE) NextOp->Common.Value.Integer,
edb6c78
+        (ACPI_SIZE) NextOp->Common.Value.Size,
edb6c78
         AcpiDmAddResourceToNamespace, (void **) BufferNode);
edb6c78
 }
edb6c78
 
38a008c
Index: acpica-unix2-20200925/source/common/dmtables.c
38a008c
===================================================================
38a008c
--- acpica-unix2-20200925.orig/source/common/dmtables.c
38a008c
+++ acpica-unix2-20200925/source/common/dmtables.c
38a008c
@@ -142,6 +142,10 @@ AdCreateTableHeader (
edb6c78
     ACPI_TABLE_HEADER       *Table)
edb6c78
 {
edb6c78
     UINT8                   Checksum;
edb6c78
+    UINT32                  TableLength = AcpiUtReadUint32(&Table->Length);
edb6c78
+    UINT32                  OemRevision = AcpiUtReadUint32(&Table->OemRevision);
edb6c78
+    UINT32                  CompilerRevision = 
edb6c78
+	    			AcpiUtReadUint32(&Table->AslCompilerRevision);
edb6c78
 
edb6c78
 
edb6c78
     /* Reset globals for External statements */
38a008c
@@ -156,7 +160,7 @@ AdCreateTableHeader (
edb6c78
 
edb6c78
     AcpiOsPrintf (" * Original Table Header:\n");
edb6c78
     AcpiOsPrintf (" *     Signature        \"%4.4s\"\n",    Table->Signature);
edb6c78
-    AcpiOsPrintf (" *     Length           0x%8.8X (%u)\n", Table->Length, Table->Length);
edb6c78
+    AcpiOsPrintf (" *     Length           0x%8.8X (%u)\n", TableLength, TableLength);
edb6c78
 
edb6c78
     /* Print and validate the revision */
edb6c78
 
38a008c
@@ -188,7 +192,7 @@ AdCreateTableHeader (
edb6c78
 
edb6c78
     AcpiOsPrintf ("\n *     Checksum         0x%2.2X",        Table->Checksum);
edb6c78
 
edb6c78
-    Checksum = AcpiTbChecksum (ACPI_CAST_PTR (UINT8, Table), Table->Length);
edb6c78
+    Checksum = AcpiTbChecksum (ACPI_CAST_PTR (UINT8, Table), TableLength);
edb6c78
     if (Checksum)
edb6c78
     {
edb6c78
         AcpiOsPrintf (" **** Incorrect checksum, should be 0x%2.2X",
38a008c
@@ -198,9 +202,9 @@ AdCreateTableHeader (
edb6c78
     AcpiOsPrintf ("\n");
edb6c78
     AcpiOsPrintf (" *     OEM ID           \"%.6s\"\n",     Table->OemId);
edb6c78
     AcpiOsPrintf (" *     OEM Table ID     \"%.8s\"\n",     Table->OemTableId);
edb6c78
-    AcpiOsPrintf (" *     OEM Revision     0x%8.8X (%u)\n", Table->OemRevision, Table->OemRevision);
edb6c78
+    AcpiOsPrintf (" *     OEM Revision     0x%8.8X (%u)\n", OemRevision, OemRevision);
edb6c78
     AcpiOsPrintf (" *     Compiler ID      \"%.4s\"\n",     Table->AslCompilerId);
edb6c78
-    AcpiOsPrintf (" *     Compiler Version 0x%8.8X (%u)\n", Table->AslCompilerRevision, Table->AslCompilerRevision);
edb6c78
+    AcpiOsPrintf (" *     Compiler Version 0x%8.8X (%u)\n", CompilerRevision, CompilerRevision);
edb6c78
     AcpiOsPrintf (" */\n");
edb6c78
 
edb6c78
     /*
38a008c
@@ -221,7 +225,7 @@ AdCreateTableHeader (
edb6c78
     AcpiOsPrintf (
edb6c78
         "DefinitionBlock (\"\", \"%4.4s\", %u, \"%.6s\", \"%.8s\", 0x%8.8X)\n",
edb6c78
         Table->Signature, Table->Revision,
edb6c78
-        Table->OemId, Table->OemTableId, Table->OemRevision);
edb6c78
+        Table->OemId, Table->OemTableId, OemRevision);
edb6c78
 }
edb6c78
 
edb6c78
 
38a008c
@@ -396,7 +400,8 @@ AdParseTable (
edb6c78
 
edb6c78
     fprintf (stderr, "Pass 1 parse of [%4.4s]\n", (char *) Table->Signature);
edb6c78
 
edb6c78
-    AmlLength = Table->Length - sizeof (ACPI_TABLE_HEADER);
edb6c78
+    AmlLength = AcpiUtReadUint32(&Table->Length);
edb6c78
+    AmlLength -= sizeof (ACPI_TABLE_HEADER);
edb6c78
     AmlStart = ((UINT8 *) Table + sizeof (ACPI_TABLE_HEADER));
edb6c78
 
edb6c78
     AcpiUtSetIntegerWidth (Table->Revision);
38a008c
Index: acpica-unix2-20200925/source/common/dmtbdump.c
38a008c
===================================================================
38a008c
--- acpica-unix2-20200925.orig/source/common/dmtbdump.c
38a008c
+++ acpica-unix2-20200925/source/common/dmtbdump.c
38a008c
@@ -333,8 +333,7 @@ AcpiDmDumpXsdt (
edb6c78
     for (i = 0; i < Entries; i++)
edb6c78
     {
edb6c78
         AcpiDmLineHeader2 (Offset, sizeof (UINT64), "ACPI Table Address", i);
edb6c78
-        AcpiOsPrintf ("%8.8X%8.8X\n",
edb6c78
-		     	ACPI_FORMAT_UINT64 (AcpiUtReadUint64(&Array[i])));
edb6c78
+        AcpiOsPrintf ("%16.16lX\n", AcpiUtReadUint64(&Array[i]));
edb6c78
         Offset += sizeof (UINT64);
edb6c78
     }
edb6c78
 }
38a008c
Index: acpica-unix2-20200925/source/compiler/aslcodegen.c
38a008c
===================================================================
38a008c
--- acpica-unix2-20200925.orig/source/compiler/aslcodegen.c
38a008c
+++ acpica-unix2-20200925/source/compiler/aslcodegen.c
38a008c
@@ -238,6 +238,10 @@ CgWriteAmlOpcode (
edb6c78
 {
edb6c78
     UINT8                   PkgLenFirstByte;
edb6c78
     UINT32                  i;
edb6c78
+    UINT8                   Tmp8;
edb6c78
+    UINT16                  Tmp16;
edb6c78
+    UINT32                  Tmp32;
edb6c78
+    UINT64                  Tmp64;
edb6c78
     union {
edb6c78
         UINT16                  Opcode;
edb6c78
         UINT8                   OpcodeBytes[2];
38a008c
@@ -305,25 +309,26 @@ CgWriteAmlOpcode (
edb6c78
 
edb6c78
         /* Value is the length to be encoded (Used in field definitions) */
edb6c78
 
edb6c78
-        PkgLen.Len = (UINT32) Op->Asl.Value.Integer;
edb6c78
+	PkgLen.Len = (UINT32) Op->Asl.Value.Integer;
edb6c78
         break;
edb6c78
 
edb6c78
     default:
edb6c78
 
edb6c78
         /* Check for two-byte opcode */
edb6c78
 
edb6c78
+	Tmp16 = AcpiUtReadUint16(&Aml.Opcode);
edb6c78
         if (Aml.Opcode > 0x00FF)
edb6c78
         {
edb6c78
             /* Write the high byte first */
edb6c78
 
edb6c78
-            CgLocalWriteAmlData (Op, &Aml.OpcodeBytes[1], 1);
edb6c78
+            CgLocalWriteAmlData (Op, ((UINT8 *)&Tmp16)+1, 1);
edb6c78
         }
edb6c78
 
edb6c78
-        CgLocalWriteAmlData (Op, &Aml.OpcodeBytes[0], 1);
edb6c78
+        CgLocalWriteAmlData (Op, (UINT8 *)&Tmp16, 1);
edb6c78
 
edb6c78
         /* Subtreelength doesn't include length of package length bytes */
edb6c78
 
edb6c78
-        PkgLen.Len = Op->Asl.AmlSubtreeLength + Op->Asl.AmlPkgLenBytes;
edb6c78
+	PkgLen.Len = Op->Asl.AmlSubtreeLength + Op->Asl.AmlPkgLenBytes;
edb6c78
         break;
edb6c78
     }
edb6c78
 
38a008c
@@ -335,7 +340,8 @@ CgWriteAmlOpcode (
edb6c78
         {
edb6c78
             /* Simplest case -- no bytes to follow, just write the count */
edb6c78
 
edb6c78
-            CgLocalWriteAmlData (Op, &PkgLen.LenBytes[0], 1);
edb6c78
+	    Tmp8 = (UINT8) PkgLen.Len;
edb6c78
+            CgLocalWriteAmlData (Op, &Tmp8, 1);
edb6c78
         }
edb6c78
         else if (Op->Asl.AmlPkgLenBytes != 0)
edb6c78
         {
38a008c
@@ -343,9 +349,10 @@ CgWriteAmlOpcode (
edb6c78
              * Encode the "bytes to follow" in the first byte, top two bits.
edb6c78
              * The low-order nybble of the length is in the bottom 4 bits
edb6c78
              */
edb6c78
+	    Tmp8 = (UINT8) PkgLen.Len;
edb6c78
             PkgLenFirstByte = (UINT8)
edb6c78
                 (((UINT32) (Op->Asl.AmlPkgLenBytes - 1) << 6) |
edb6c78
-                (PkgLen.LenBytes[0] & 0x0F));
edb6c78
+                (Tmp8 & 0x0F));
edb6c78
 
edb6c78
             CgLocalWriteAmlData (Op, &PkgLenFirstByte, 1);
edb6c78
 
38a008c
@@ -359,6 +366,9 @@ CgWriteAmlOpcode (
edb6c78
              * Now we can write the remaining bytes -
edb6c78
              * either 1, 2, or 3 bytes
edb6c78
              */
edb6c78
+	    Tmp32 = PkgLen.Len;
edb6c78
+	    AcpiUtWriteUint(&PkgLen.Len, Op->Asl.AmlPkgLenBytes,
edb6c78
+			    &Tmp32, sizeof(UINT32));
edb6c78
             for (i = 0; i < (UINT32) (Op->Asl.AmlPkgLenBytes - 1); i++)
edb6c78
             {
edb6c78
                 CgLocalWriteAmlData (Op, &PkgLen.LenBytes[i], 1);
38a008c
@@ -370,22 +380,30 @@ CgWriteAmlOpcode (
edb6c78
     {
edb6c78
     case AML_BYTE_OP:
edb6c78
 
edb6c78
-        CgLocalWriteAmlData (Op, &Op->Asl.Value.Integer, 1);
edb6c78
+	Tmp64 = 0;
edb6c78
+	AcpiUtWriteUint(&Tmp64, 1, &Op->Asl.Value.Integer, 8);
edb6c78
+        CgLocalWriteAmlData (Op, &Tmp64, 1);
edb6c78
         break;
edb6c78
 
edb6c78
     case AML_WORD_OP:
edb6c78
 
edb6c78
-        CgLocalWriteAmlData (Op, &Op->Asl.Value.Integer, 2);
edb6c78
+	Tmp64 = 0;
edb6c78
+	AcpiUtWriteUint(&Tmp64, 2, &Op->Asl.Value.Integer, 8);
edb6c78
+        CgLocalWriteAmlData (Op, &Tmp64, 2);
edb6c78
        break;
edb6c78
 
edb6c78
     case AML_DWORD_OP:
edb6c78
 
edb6c78
-        CgLocalWriteAmlData (Op, &Op->Asl.Value.Integer, 4);
edb6c78
+	Tmp64 = 0;
edb6c78
+	AcpiUtWriteUint(&Tmp64, 4, &Op->Asl.Value.Integer, 8);
edb6c78
+        CgLocalWriteAmlData (Op, &Tmp64, 4);
edb6c78
         break;
edb6c78
 
edb6c78
     case AML_QWORD_OP:
edb6c78
 
edb6c78
-        CgLocalWriteAmlData (Op, &Op->Asl.Value.Integer, 8);
edb6c78
+	Tmp64 = 0;
edb6c78
+	AcpiUtWriteUint(&Tmp64, 8, &Op->Asl.Value.Integer, 8);
edb6c78
+        CgLocalWriteAmlData (Op, &Tmp64, 8);
edb6c78
         break;
edb6c78
 
edb6c78
     case AML_STRING_OP:
38a008c
@@ -423,6 +441,7 @@ CgWriteTableHeader (
edb6c78
     ACPI_PARSE_OBJECT       *Child;
edb6c78
     UINT32                  CommentLength;
edb6c78
     ACPI_COMMENT_NODE       *Current;
edb6c78
+    UINT32                  Tmp32;
edb6c78
 
edb6c78
 
edb6c78
     memset (&AslGbl_TableHeader, 0, sizeof (ACPI_TABLE_HEADER));
38a008c
@@ -478,7 +497,9 @@ CgWriteTableHeader (
edb6c78
     /* OEM Revision */
edb6c78
 
edb6c78
     Child = Child->Asl.Next;
edb6c78
-    AslGbl_TableHeader.OemRevision = (UINT32) Child->Asl.Value.Integer;
edb6c78
+    AcpiUtWriteUint(&Tmp32, sizeof(UINT32),
edb6c78
+		   &Child->Asl.Value.Integer, sizeof(Child->Asl.Value.Integer));
edb6c78
+    AslGbl_TableHeader.OemRevision = Tmp32;
edb6c78
 
edb6c78
     /* Compiler ID */
edb6c78
 
38a008c
@@ -486,7 +507,8 @@ CgWriteTableHeader (
edb6c78
 
edb6c78
     /* Compiler version */
edb6c78
 
edb6c78
-    AslGbl_TableHeader.AslCompilerRevision = ACPI_CA_VERSION;
edb6c78
+    Tmp32 = ACPI_CA_VERSION;
edb6c78
+    AslGbl_TableHeader.AslCompilerRevision = AcpiUtReadUint32(&Tmp32);
edb6c78
 
edb6c78
     /* Table length. Checksum zero for now, will rewrite later */
edb6c78
 
38a008c
@@ -541,6 +563,15 @@ CgWriteTableHeader (
edb6c78
     AslGbl_TableHeader.Checksum = 0;
edb6c78
     Op->Asl.FinalAmlOffset = ftell (AslGbl_Files[ASL_FILE_AML_OUTPUT].Handle);
edb6c78
 
edb6c78
+    /*
edb6c78
+     * Adjust the Table length; it will only change when big-endian
edb6c78
+     * but we have to wait until here in case there is arithmetic to
edb6c78
+     * be done on the length before this step in the function
edb6c78
+     */
edb6c78
+
edb6c78
+    Tmp32 = AslGbl_TableHeader.Length;
edb6c78
+    AslGbl_TableHeader.Length = AcpiUtReadUint32(&Tmp32);
edb6c78
+
edb6c78
     /* Write entire header and clear the table header global */
edb6c78
 
edb6c78
     CgLocalWriteAmlData (Op, &AslGbl_TableHeader, sizeof (ACPI_TABLE_HEADER));
38a008c
@@ -625,6 +656,7 @@ CgWriteNode (
edb6c78
     ACPI_PARSE_OBJECT       *Op)
edb6c78
 {
edb6c78
     ASL_RESOURCE_NODE       *Rnode;
edb6c78
+    UINT64                  Tmp64;
edb6c78
 
edb6c78
 
edb6c78
     /* Write all comments here. */
38a008c
@@ -653,7 +685,10 @@ CgWriteNode (
edb6c78
     case AML_RAW_DATA_DWORD:
edb6c78
     case AML_RAW_DATA_QWORD:
edb6c78
 
edb6c78
-        CgLocalWriteAmlData (Op, &Op->Asl.Value.Integer, Op->Asl.AmlLength);
edb6c78
+	Tmp64 = 0;
edb6c78
+	AcpiUtWriteUint(&Tmp64, Op->Asl.AmlLength,
edb6c78
+			&Op->Asl.Value.Integer, sizeof(UINT64));
edb6c78
+        CgLocalWriteAmlData (Op, &Tmp64, Op->Asl.AmlLength);
edb6c78
         return;
edb6c78
 
edb6c78
 
38a008c
Index: acpica-unix2-20200925/source/compiler/aslopcodes.c
38a008c
===================================================================
38a008c
--- acpica-unix2-20200925.orig/source/compiler/aslopcodes.c
38a008c
+++ acpica-unix2-20200925/source/compiler/aslopcodes.c
38a008c
@@ -511,7 +511,8 @@ OpcDoUnicode (
6c29d68
 
6c29d68
     for (i = 0; i < Count; i++)
6c29d68
     {
6c29d68
-        UnicodeString[i] = (UINT16) AsciiString[i];
6c29d68
+        AcpiUtWriteUint(&UnicodeString[i], sizeof(UINT16),
6c29d68
+		       	&AsciiString[i], sizeof(UINT8));
6c29d68
     }
6c29d68
 
6c29d68
     /*
38a008c
Index: acpica-unix2-20200925/source/compiler/aslrestype1.c
38a008c
===================================================================
38a008c
--- acpica-unix2-20200925.orig/source/compiler/aslrestype1.c
38a008c
+++ acpica-unix2-20200925/source/compiler/aslrestype1.c
38a008c
@@ -143,6 +143,7 @@ RsDoMemory24Descriptor (
edb6c78
     ASL_RESOURCE_NODE       *Rnode;
edb6c78
     UINT32                  CurrentByteOffset;
edb6c78
     UINT32                  i;
edb6c78
+    UINT16                  Tmp16;
edb6c78
 
edb6c78
 
edb6c78
     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
38a008c
@@ -151,7 +152,8 @@ RsDoMemory24Descriptor (
edb6c78
 
edb6c78
     Descriptor = Rnode->Buffer;
edb6c78
     Descriptor->Memory24.DescriptorType = ACPI_RESOURCE_NAME_MEMORY24;
edb6c78
-    Descriptor->Memory24.ResourceLength = 9;
edb6c78
+    Tmp16 = 9;
edb6c78
+    Descriptor->Memory24.ResourceLength = AcpiUtReadUint16(&Tmp16);
edb6c78
 
edb6c78
     /* Process all child initialization nodes */
edb6c78
 
38a008c
@@ -168,7 +170,8 @@ RsDoMemory24Descriptor (
edb6c78
 
edb6c78
         case 1: /* Min Address */
edb6c78
 
edb6c78
-            Descriptor->Memory24.Minimum = (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+            Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->Memory24.Minimum = AcpiUtReadUint16(&Tmp16);
edb6c78
             RsCreateWordField (InitializerOp, ACPI_RESTAG_MINADDR,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.Minimum));
edb6c78
             MinOp = InitializerOp;
38a008c
@@ -176,7 +179,8 @@ RsDoMemory24Descriptor (
edb6c78
 
edb6c78
         case 2: /* Max Address */
edb6c78
 
edb6c78
-            Descriptor->Memory24.Maximum = (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+            Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->Memory24.Maximum = AcpiUtReadUint16(&Tmp16);
edb6c78
             RsCreateWordField (InitializerOp, ACPI_RESTAG_MAXADDR,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.Maximum));
edb6c78
             MaxOp = InitializerOp;
38a008c
@@ -184,14 +188,16 @@ RsDoMemory24Descriptor (
edb6c78
 
edb6c78
         case 3: /* Alignment */
edb6c78
 
edb6c78
-            Descriptor->Memory24.Alignment = (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+            Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->Memory24.Alignment = AcpiUtReadUint16(&Tmp16);
edb6c78
             RsCreateWordField (InitializerOp, ACPI_RESTAG_ALIGNMENT,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.Alignment));
edb6c78
             break;
edb6c78
 
edb6c78
         case 4: /* Length */
edb6c78
 
edb6c78
-            Descriptor->Memory24.AddressLength = (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+            Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->Memory24.AddressLength = AcpiUtReadUint16(&Tmp16);
edb6c78
             RsCreateWordField (InitializerOp, ACPI_RESTAG_LENGTH,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.AddressLength));
edb6c78
             LengthOp = InitializerOp;
38a008c
@@ -249,6 +255,8 @@ RsDoMemory32Descriptor (
edb6c78
     ASL_RESOURCE_NODE       *Rnode;
edb6c78
     UINT32                  CurrentByteOffset;
edb6c78
     UINT32                  i;
edb6c78
+    UINT16                  Tmp16;
edb6c78
+    UINT32                  Tmp32;
edb6c78
 
edb6c78
 
edb6c78
     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
38a008c
@@ -257,7 +265,8 @@ RsDoMemory32Descriptor (
edb6c78
 
edb6c78
     Descriptor = Rnode->Buffer;
edb6c78
     Descriptor->Memory32.DescriptorType = ACPI_RESOURCE_NAME_MEMORY32;
edb6c78
-    Descriptor->Memory32.ResourceLength = 17;
edb6c78
+    Tmp16 = 17;
edb6c78
+    Descriptor->Memory32.ResourceLength = AcpiUtReadUint16(&Tmp16);
edb6c78
 
edb6c78
     /* Process all child initialization nodes */
edb6c78
 
38a008c
@@ -274,7 +283,8 @@ RsDoMemory32Descriptor (
edb6c78
 
edb6c78
         case 1:  /* Min Address */
edb6c78
 
edb6c78
-            Descriptor->Memory32.Minimum = (UINT32) InitializerOp->Asl.Value.Integer;
edb6c78
+            Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->Memory32.Minimum = AcpiUtReadUint32(&Tmp32);
edb6c78
             RsCreateDwordField (InitializerOp, ACPI_RESTAG_MINADDR,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.Minimum));
edb6c78
             MinOp = InitializerOp;
38a008c
@@ -282,7 +292,8 @@ RsDoMemory32Descriptor (
edb6c78
 
edb6c78
         case 2: /* Max Address */
edb6c78
 
edb6c78
-            Descriptor->Memory32.Maximum = (UINT32) InitializerOp->Asl.Value.Integer;
edb6c78
+            Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->Memory32.Maximum = AcpiUtReadUint32(&Tmp32);
edb6c78
             RsCreateDwordField (InitializerOp, ACPI_RESTAG_MAXADDR,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.Maximum));
edb6c78
             MaxOp = InitializerOp;
38a008c
@@ -290,7 +301,8 @@ RsDoMemory32Descriptor (
edb6c78
 
edb6c78
         case 3: /* Alignment */
edb6c78
 
edb6c78
-            Descriptor->Memory32.Alignment = (UINT32) InitializerOp->Asl.Value.Integer;
edb6c78
+            Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->Memory32.Alignment = AcpiUtReadUint32(&Tmp32);
edb6c78
             RsCreateDwordField (InitializerOp, ACPI_RESTAG_ALIGNMENT,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.Alignment));
edb6c78
             AlignOp = InitializerOp;
38a008c
@@ -298,7 +310,8 @@ RsDoMemory32Descriptor (
edb6c78
 
edb6c78
         case 4: /* Length */
edb6c78
 
edb6c78
-            Descriptor->Memory32.AddressLength = (UINT32) InitializerOp->Asl.Value.Integer;
edb6c78
+            Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->Memory32.AddressLength = AcpiUtReadUint32(&Tmp32);
edb6c78
             RsCreateDwordField (InitializerOp, ACPI_RESTAG_LENGTH,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.AddressLength));
edb6c78
             LengthOp = InitializerOp;
38a008c
@@ -352,6 +365,8 @@ RsDoMemory32FixedDescriptor (
edb6c78
     ASL_RESOURCE_NODE       *Rnode;
edb6c78
     UINT32                  CurrentByteOffset;
edb6c78
     UINT32                  i;
edb6c78
+    UINT16                  Tmp16;
edb6c78
+    UINT32                  Tmp32;
edb6c78
 
edb6c78
 
edb6c78
     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
38a008c
@@ -360,7 +375,8 @@ RsDoMemory32FixedDescriptor (
edb6c78
 
edb6c78
     Descriptor = Rnode->Buffer;
edb6c78
     Descriptor->FixedMemory32.DescriptorType = ACPI_RESOURCE_NAME_FIXED_MEMORY32;
edb6c78
-    Descriptor->FixedMemory32.ResourceLength = 9;
edb6c78
+    Tmp16 = 9;
edb6c78
+    Descriptor->FixedMemory32.ResourceLength = AcpiUtReadUint16(&Tmp16);
edb6c78
 
edb6c78
     /* Process all child initialization nodes */
edb6c78
 
38a008c
@@ -377,14 +393,16 @@ RsDoMemory32FixedDescriptor (
edb6c78
 
edb6c78
         case 1: /* Address */
edb6c78
 
edb6c78
-            Descriptor->FixedMemory32.Address = (UINT32) InitializerOp->Asl.Value.Integer;
edb6c78
+            Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->FixedMemory32.Address = AcpiUtReadUint32(&Tmp32);
edb6c78
             RsCreateDwordField (InitializerOp, ACPI_RESTAG_BASEADDRESS,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (FixedMemory32.Address));
edb6c78
             break;
edb6c78
 
edb6c78
         case 2: /* Length */
edb6c78
 
edb6c78
-            Descriptor->FixedMemory32.AddressLength = (UINT32) InitializerOp->Asl.Value.Integer;
edb6c78
+            Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->FixedMemory32.AddressLength = AcpiUtReadUint32(&Tmp32);
edb6c78
             RsCreateDwordField (InitializerOp, ACPI_RESTAG_LENGTH,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (FixedMemory32.AddressLength));
edb6c78
             break;
38a008c
Index: acpica-unix2-20200925/source/compiler/aslrestype1i.c
38a008c
===================================================================
38a008c
--- acpica-unix2-20200925.orig/source/compiler/aslrestype1i.c
38a008c
+++ acpica-unix2-20200925/source/compiler/aslrestype1i.c
38a008c
@@ -199,6 +199,7 @@ RsDoFixedDmaDescriptor (
edb6c78
     ASL_RESOURCE_NODE       *Rnode;
edb6c78
     UINT32                  CurrentByteOffset;
edb6c78
     UINT32                  i;
edb6c78
+    UINT16                  Tmp16;
edb6c78
 
edb6c78
 
edb6c78
     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
38a008c
@@ -217,14 +218,16 @@ RsDoFixedDmaDescriptor (
edb6c78
         {
edb6c78
         case 0: /* DMA Request Lines [WORD] (_DMA) */
edb6c78
 
edb6c78
-            Descriptor->FixedDma.RequestLines = (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+            Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->FixedDma.RequestLines = AcpiUtReadUint16(&Tmp16);
edb6c78
             RsCreateWordField (InitializerOp, ACPI_RESTAG_DMA,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (FixedDma.RequestLines));
edb6c78
             break;
edb6c78
 
edb6c78
         case 1: /* DMA Channel [WORD] (_TYP) */
edb6c78
 
edb6c78
-            Descriptor->FixedDma.Channels = (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+            Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->FixedDma.Channels = AcpiUtReadUint16(&Tmp16);
edb6c78
             RsCreateWordField (InitializerOp, ACPI_RESTAG_DMATYPE,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (FixedDma.Channels));
edb6c78
             break;
38a008c
@@ -275,6 +278,7 @@ RsDoFixedIoDescriptor (
edb6c78
     ASL_RESOURCE_NODE       *Rnode;
edb6c78
     UINT32                  CurrentByteOffset;
edb6c78
     UINT32                  i;
edb6c78
+    UINT16                  Tmp16;
edb6c78
 
edb6c78
 
edb6c78
     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
38a008c
@@ -293,8 +297,8 @@ RsDoFixedIoDescriptor (
edb6c78
         {
edb6c78
         case 0: /* Base Address */
edb6c78
 
edb6c78
-            Descriptor->FixedIo.Address =
edb6c78
-                (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+            Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->FixedIo.Address = AcpiUtReadUint16(&Tmp16);
edb6c78
             RsCreateWordField (InitializerOp, ACPI_RESTAG_BASEADDRESS,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (FixedIo.Address));
edb6c78
             AddressOp = InitializerOp;
38a008c
@@ -358,6 +362,7 @@ RsDoIoDescriptor (
edb6c78
     ASL_RESOURCE_NODE       *Rnode;
edb6c78
     UINT32                  CurrentByteOffset;
edb6c78
     UINT32                  i;
edb6c78
+    UINT16                  Tmp16;
edb6c78
 
edb6c78
 
edb6c78
     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
38a008c
@@ -383,8 +388,8 @@ RsDoIoDescriptor (
edb6c78
 
edb6c78
         case 1:  /* Min Address */
edb6c78
 
edb6c78
-            Descriptor->Io.Minimum =
edb6c78
-                (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+            Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->Io.Minimum = AcpiUtReadUint16(&Tmp16);
edb6c78
             RsCreateWordField (InitializerOp, ACPI_RESTAG_MINADDR,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Io.Minimum));
edb6c78
             MinOp = InitializerOp;
38a008c
@@ -392,8 +397,8 @@ RsDoIoDescriptor (
edb6c78
 
edb6c78
         case 2: /* Max Address */
edb6c78
 
edb6c78
-            Descriptor->Io.Maximum =
edb6c78
-                (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+            Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->Io.Maximum = AcpiUtReadUint16(&Tmp16);
edb6c78
             RsCreateWordField (InitializerOp, ACPI_RESTAG_MAXADDR,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Io.Maximum));
edb6c78
             MaxOp = InitializerOp;
38a008c
@@ -434,10 +439,10 @@ RsDoIoDescriptor (
edb6c78
     /* Validate the Min/Max/Len/Align values */
edb6c78
 
edb6c78
     RsSmallAddressCheck (ACPI_RESOURCE_NAME_IO,
edb6c78
-        Descriptor->Io.Minimum,
edb6c78
-        Descriptor->Io.Maximum,
edb6c78
-        Descriptor->Io.AddressLength,
edb6c78
-        Descriptor->Io.Alignment,
edb6c78
+        (UINT32)(AcpiUtReadUint16(&Descriptor->Io.Minimum)),
edb6c78
+        (UINT32)(AcpiUtReadUint16(&Descriptor->Io.Maximum)),
edb6c78
+        (UINT32)Descriptor->Io.AddressLength,
edb6c78
+        (UINT32)Descriptor->Io.Alignment,
edb6c78
         MinOp, MaxOp, LengthOp, AlignOp, Info->DescriptorTypeOp);
edb6c78
 
edb6c78
     return (Rnode);
38a008c
@@ -561,7 +566,7 @@ RsDoIrqDescriptor (
edb6c78
 
edb6c78
     /* Now we can set the channel mask */
edb6c78
 
edb6c78
-    Descriptor->Irq.IrqMask = IrqMask;
edb6c78
+    Descriptor->Irq.IrqMask = AcpiUtReadUint16(&IrqMask);
edb6c78
     return (Rnode);
edb6c78
 }
edb6c78
 
38a008c
@@ -660,6 +665,6 @@ RsDoIrqNoFlagsDescriptor (
edb6c78
 
edb6c78
     /* Now we can set the interrupt mask */
edb6c78
 
edb6c78
-    Descriptor->Irq.IrqMask = IrqMask;
edb6c78
+    Descriptor->Irq.IrqMask = AcpiUtReadUint16(&IrqMask);
edb6c78
     return (Rnode);
edb6c78
 }
38a008c
Index: acpica-unix2-20200925/source/compiler/aslrestype2.c
38a008c
===================================================================
38a008c
--- acpica-unix2-20200925.orig/source/compiler/aslrestype2.c
38a008c
+++ acpica-unix2-20200925/source/compiler/aslrestype2.c
38a008c
@@ -77,6 +77,8 @@ RsDoGeneralRegisterDescriptor (
edb6c78
     ASL_RESOURCE_NODE       *Rnode;
edb6c78
     UINT32                  CurrentByteOffset;
edb6c78
     UINT32                  i;
edb6c78
+    UINT16                  Tmp16;
edb6c78
+    UINT64                  Tmp64;
edb6c78
 
edb6c78
 
edb6c78
     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
38a008c
@@ -85,7 +87,8 @@ RsDoGeneralRegisterDescriptor (
edb6c78
 
edb6c78
     Descriptor = Rnode->Buffer;
edb6c78
     Descriptor->GenericReg.DescriptorType = ACPI_RESOURCE_NAME_GENERIC_REGISTER;
edb6c78
-    Descriptor->GenericReg.ResourceLength = 12;
edb6c78
+    Tmp16 = 12;
edb6c78
+    Descriptor->GenericReg.ResourceLength = AcpiUtReadUint16(&Tmp16);
edb6c78
 
edb6c78
     /* Process all child initialization nodes */
edb6c78
 
38a008c
@@ -116,7 +119,8 @@ RsDoGeneralRegisterDescriptor (
edb6c78
 
edb6c78
         case 3: /* Register Address */
edb6c78
 
edb6c78
-            Descriptor->GenericReg.Address = InitializerOp->Asl.Value.Integer;
edb6c78
+            Tmp64 = InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->GenericReg.Address = AcpiUtReadUint64(&Tmp64);
edb6c78
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_ADDRESS,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (GenericReg.Address));
edb6c78
             break;
38a008c
@@ -184,6 +188,8 @@ RsDoInterruptDescriptor (
edb6c78
     BOOLEAN                 HasResSourceIndex = FALSE;
edb6c78
     UINT8                   ResSourceIndex = 0;
edb6c78
     UINT8                   *ResSourceString = NULL;
edb6c78
+    UINT16                  Tmp16;
edb6c78
+    UINT32                  Tmp32;
edb6c78
 
edb6c78
 
edb6c78
     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
38a008c
@@ -225,7 +231,7 @@ RsDoInterruptDescriptor (
edb6c78
      * Initial descriptor length -- may be enlarged if there are
edb6c78
      * optional fields present
edb6c78
      */
edb6c78
-    Descriptor->ExtendedIrq.ResourceLength  = 2;  /* Flags and table length byte */
edb6c78
+    Descriptor->ExtendedIrq.ResourceLength  = 2; /* Flags and table length byte */
edb6c78
     Descriptor->ExtendedIrq.InterruptCount  = 0;
edb6c78
 
edb6c78
     Rover = ACPI_CAST_PTR (AML_RESOURCE,
38a008c
@@ -333,7 +339,8 @@ RsDoInterruptDescriptor (
edb6c78
 
edb6c78
             /* Save the integer and move pointer to the next one */
edb6c78
 
edb6c78
-            Rover->DwordItem = (UINT32) InitializerOp->Asl.Value.Integer;
edb6c78
+            Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
edb6c78
+            Rover->DwordItem = AcpiUtReadUint32(&Tmp32);
edb6c78
             Rover = ACPI_ADD_PTR (AML_RESOURCE, &(Rover->DwordItem), 4);
edb6c78
             Descriptor->ExtendedIrq.InterruptCount++;
edb6c78
             Descriptor->ExtendedIrq.ResourceLength += 4;
38a008c
@@ -384,6 +391,8 @@ RsDoInterruptDescriptor (
edb6c78
         Descriptor->ExtendedIrq.ResourceLength = (UINT16)
edb6c78
             (Descriptor->ExtendedIrq.ResourceLength + StringLength);
edb6c78
     }
edb6c78
+    Tmp16 = Descriptor->ExtendedIrq.ResourceLength;
edb6c78
+    Descriptor->ExtendedIrq.ResourceLength  = AcpiUtReadUint16(&Tmp16);
edb6c78
 
edb6c78
     Rnode->BufferLength =
edb6c78
         (ASL_RESDESC_OFFSET (ExtendedIrq.Interrupts[0]) -
38a008c
@@ -436,7 +445,8 @@ RsDoVendorLargeDescriptor (
edb6c78
 
edb6c78
     Descriptor = Rnode->Buffer;
edb6c78
     Descriptor->VendorLarge.DescriptorType = ACPI_RESOURCE_NAME_VENDOR_LARGE;
edb6c78
-    Descriptor->VendorLarge.ResourceLength = (UINT16) i;
edb6c78
+    AcpiUtWriteUint(&Descriptor->VendorLarge.ResourceLength, sizeof(UINT16),
edb6c78
+		    &i, sizeof(UINT32));
edb6c78
 
edb6c78
     /* Point to end-of-descriptor for vendor data */
edb6c78
 
38a008c
Index: acpica-unix2-20200925/source/compiler/aslrestype2d.c
38a008c
===================================================================
38a008c
--- acpica-unix2-20200925.orig/source/compiler/aslrestype2d.c
38a008c
+++ acpica-unix2-20200925/source/compiler/aslrestype2d.c
38a008c
@@ -84,6 +84,8 @@ RsDoDwordIoDescriptor (
edb6c78
     UINT32                  CurrentByteOffset;
edb6c78
     UINT32                  i;
edb6c78
     BOOLEAN                 ResSourceIndex = FALSE;
edb6c78
+    UINT16		    Tmp16;
edb6c78
+    UINT32		    Tmp32;
edb6c78
 
edb6c78
 
edb6c78
     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
38a008c
@@ -147,8 +149,8 @@ RsDoDwordIoDescriptor (
edb6c78
 
edb6c78
         case 5: /* Address Granularity */
edb6c78
 
edb6c78
-            Descriptor->Address32.Granularity =
edb6c78
-                (UINT32) InitializerOp->Asl.Value.Integer;
edb6c78
+	    Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->Address32.Granularity = AcpiUtReadUint32(&Tmp32);
edb6c78
             RsCreateDwordField (InitializerOp, ACPI_RESTAG_GRANULARITY,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Granularity));
edb6c78
             GranOp = InitializerOp;
38a008c
@@ -156,8 +158,8 @@ RsDoDwordIoDescriptor (
edb6c78
 
edb6c78
         case 6: /* Address Min */
edb6c78
 
edb6c78
-            Descriptor->Address32.Minimum =
edb6c78
-                (UINT32) InitializerOp->Asl.Value.Integer;
edb6c78
+	    Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->Address32.Minimum = AcpiUtReadUint32(&Tmp32);
edb6c78
             RsCreateDwordField (InitializerOp, ACPI_RESTAG_MINADDR,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Minimum));
edb6c78
             MinOp = InitializerOp;
38a008c
@@ -165,8 +167,8 @@ RsDoDwordIoDescriptor (
edb6c78
 
edb6c78
         case 7: /* Address Max */
edb6c78
 
edb6c78
-            Descriptor->Address32.Maximum =
edb6c78
-                (UINT32) InitializerOp->Asl.Value.Integer;
edb6c78
+	    Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->Address32.Maximum = AcpiUtReadUint32(&Tmp32);
edb6c78
             RsCreateDwordField (InitializerOp, ACPI_RESTAG_MAXADDR,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Maximum));
edb6c78
             MaxOp = InitializerOp;
38a008c
@@ -174,16 +176,16 @@ RsDoDwordIoDescriptor (
edb6c78
 
edb6c78
         case 8: /* Translation Offset */
edb6c78
 
edb6c78
-            Descriptor->Address32.TranslationOffset =
edb6c78
-                (UINT32) InitializerOp->Asl.Value.Integer;
edb6c78
+	    Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->Address32.TranslationOffset = AcpiUtReadUint32(&Tmp32);
edb6c78
             RsCreateDwordField (InitializerOp, ACPI_RESTAG_TRANSLATION,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.TranslationOffset));
edb6c78
             break;
edb6c78
 
edb6c78
         case 9: /* Address Length */
edb6c78
 
edb6c78
-            Descriptor->Address32.AddressLength =
edb6c78
-                (UINT32) InitializerOp->Asl.Value.Integer;
edb6c78
+	    Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->Address32.AddressLength = AcpiUtReadUint32(&Tmp32);
edb6c78
             RsCreateDwordField (InitializerOp, ACPI_RESTAG_LENGTH,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.AddressLength));
edb6c78
             LengthOp = InitializerOp;
38a008c
@@ -271,11 +273,14 @@ RsDoDwordIoDescriptor (
edb6c78
 
edb6c78
     /* Validate the Min/Max/Len/Gran values */
edb6c78
 
edb6c78
+    Tmp16 = Descriptor->Address32.ResourceLength;
edb6c78
+    Descriptor->Address32.ResourceLength = AcpiUtReadUint16(&Tmp16);
edb6c78
+
edb6c78
     RsLargeAddressCheck (
edb6c78
-        (UINT64) Descriptor->Address32.Minimum,
edb6c78
-        (UINT64) Descriptor->Address32.Maximum,
edb6c78
-        (UINT64) Descriptor->Address32.AddressLength,
edb6c78
-        (UINT64) Descriptor->Address32.Granularity,
edb6c78
+        (UINT64) AcpiUtReadUint32(&Descriptor->Address32.Minimum),
edb6c78
+        (UINT64) AcpiUtReadUint32(&Descriptor->Address32.Maximum),
edb6c78
+        (UINT64) AcpiUtReadUint32(&Descriptor->Address32.AddressLength),
edb6c78
+        (UINT64) AcpiUtReadUint32(&Descriptor->Address32.Granularity),
edb6c78
         Descriptor->Address32.Flags,
edb6c78
         MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp);
edb6c78
 
38a008c
@@ -314,6 +319,8 @@ RsDoDwordMemoryDescriptor (
edb6c78
     UINT32                  CurrentByteOffset;
edb6c78
     UINT32                  i;
edb6c78
     BOOLEAN                 ResSourceIndex = FALSE;
edb6c78
+    UINT16                  Tmp16;
edb6c78
+    UINT32                  Tmp32;
edb6c78
 
edb6c78
 
edb6c78
     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
38a008c
@@ -385,8 +392,8 @@ RsDoDwordMemoryDescriptor (
edb6c78
 
edb6c78
         case 6: /* Address Granularity */
edb6c78
 
edb6c78
-            Descriptor->Address32.Granularity =
edb6c78
-                (UINT32) InitializerOp->Asl.Value.Integer;
edb6c78
+            Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->Address32.Granularity = AcpiUtReadUint32(&Tmp32);
edb6c78
             RsCreateDwordField (InitializerOp, ACPI_RESTAG_GRANULARITY,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Granularity));
edb6c78
             GranOp = InitializerOp;
38a008c
@@ -394,8 +401,8 @@ RsDoDwordMemoryDescriptor (
edb6c78
 
edb6c78
         case 7: /* Min Address */
edb6c78
 
edb6c78
-            Descriptor->Address32.Minimum =
edb6c78
-                (UINT32) InitializerOp->Asl.Value.Integer;
edb6c78
+            Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->Address32.Minimum = AcpiUtReadUint32(&Tmp32);
edb6c78
             RsCreateDwordField (InitializerOp, ACPI_RESTAG_MINADDR,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Minimum));
edb6c78
             MinOp = InitializerOp;
38a008c
@@ -403,8 +410,8 @@ RsDoDwordMemoryDescriptor (
edb6c78
 
edb6c78
         case 8: /* Max Address */
edb6c78
 
edb6c78
-            Descriptor->Address32.Maximum =
edb6c78
-                (UINT32) InitializerOp->Asl.Value.Integer;
edb6c78
+            Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->Address32.Maximum = AcpiUtReadUint32(&Tmp32);
edb6c78
             RsCreateDwordField (InitializerOp, ACPI_RESTAG_MAXADDR,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Maximum));
edb6c78
             MaxOp = InitializerOp;
38a008c
@@ -412,16 +419,16 @@ RsDoDwordMemoryDescriptor (
edb6c78
 
edb6c78
         case 9: /* Translation Offset */
edb6c78
 
edb6c78
-            Descriptor->Address32.TranslationOffset =
edb6c78
-                (UINT32) InitializerOp->Asl.Value.Integer;
edb6c78
+            Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->Address32.TranslationOffset = AcpiUtReadUint32(&Tmp32);
edb6c78
             RsCreateDwordField (InitializerOp, ACPI_RESTAG_TRANSLATION,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.TranslationOffset));
edb6c78
             break;
edb6c78
 
edb6c78
         case 10: /* Address Length */
edb6c78
 
edb6c78
-            Descriptor->Address32.AddressLength =
edb6c78
-                (UINT32) InitializerOp->Asl.Value.Integer;
edb6c78
+            Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->Address32.AddressLength = AcpiUtReadUint32(&Tmp32);
edb6c78
             RsCreateDwordField (InitializerOp, ACPI_RESTAG_LENGTH,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.AddressLength));
edb6c78
             LengthOp = InitializerOp;
38a008c
@@ -506,11 +513,14 @@ RsDoDwordMemoryDescriptor (
edb6c78
 
edb6c78
     /* Validate the Min/Max/Len/Gran values */
edb6c78
 
edb6c78
+    Tmp16 = Descriptor->Address32.ResourceLength;
edb6c78
+    Descriptor->Address32.ResourceLength = AcpiUtReadUint16(&Tmp16);
edb6c78
+
edb6c78
     RsLargeAddressCheck (
edb6c78
-        (UINT64) Descriptor->Address32.Minimum,
edb6c78
-        (UINT64) Descriptor->Address32.Maximum,
edb6c78
-        (UINT64) Descriptor->Address32.AddressLength,
edb6c78
-        (UINT64) Descriptor->Address32.Granularity,
edb6c78
+        (UINT64) AcpiUtReadUint32(&Descriptor->Address32.Minimum),
edb6c78
+        (UINT64) AcpiUtReadUint32(&Descriptor->Address32.Maximum),
edb6c78
+        (UINT64) AcpiUtReadUint32(&Descriptor->Address32.AddressLength),
edb6c78
+        (UINT64) AcpiUtReadUint32(&Descriptor->Address32.Granularity),
edb6c78
         Descriptor->Address32.Flags,
edb6c78
         MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp);
edb6c78
 
38a008c
@@ -549,6 +559,8 @@ RsDoDwordSpaceDescriptor (
edb6c78
     UINT32                  CurrentByteOffset;
edb6c78
     UINT32                  i;
edb6c78
     BOOLEAN                 ResSourceIndex = FALSE;
edb6c78
+    UINT16                  Tmp16;
edb6c78
+    UINT32                  Tmp32;
edb6c78
 
edb6c78
 
edb6c78
     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
38a008c
@@ -616,8 +628,8 @@ RsDoDwordSpaceDescriptor (
edb6c78
 
edb6c78
         case 6: /* Address Granularity */
edb6c78
 
edb6c78
-            Descriptor->Address32.Granularity =
edb6c78
-                (UINT32) InitializerOp->Asl.Value.Integer;
edb6c78
+	    Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->Address32.Granularity = AcpiUtReadUint32(&Tmp32);
edb6c78
             RsCreateDwordField (InitializerOp, ACPI_RESTAG_GRANULARITY,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Granularity));
edb6c78
             GranOp = InitializerOp;
38a008c
@@ -625,8 +637,8 @@ RsDoDwordSpaceDescriptor (
edb6c78
 
edb6c78
         case 7: /* Min Address */
edb6c78
 
edb6c78
-            Descriptor->Address32.Minimum =
edb6c78
-                (UINT32) InitializerOp->Asl.Value.Integer;
edb6c78
+	    Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->Address32.Minimum = AcpiUtReadUint32(&Tmp32);
edb6c78
             RsCreateDwordField (InitializerOp, ACPI_RESTAG_MINADDR,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Minimum));
edb6c78
             MinOp = InitializerOp;
38a008c
@@ -634,8 +646,8 @@ RsDoDwordSpaceDescriptor (
edb6c78
 
edb6c78
         case 8: /* Max Address */
edb6c78
 
edb6c78
-            Descriptor->Address32.Maximum =
edb6c78
-                (UINT32) InitializerOp->Asl.Value.Integer;
edb6c78
+	    Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->Address32.Maximum = AcpiUtReadUint32(&Tmp32);
edb6c78
             RsCreateDwordField (InitializerOp, ACPI_RESTAG_MAXADDR,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Maximum));
edb6c78
             MaxOp = InitializerOp;
38a008c
@@ -643,16 +655,16 @@ RsDoDwordSpaceDescriptor (
edb6c78
 
edb6c78
         case 9: /* Translation Offset */
edb6c78
 
edb6c78
-            Descriptor->Address32.TranslationOffset =
edb6c78
-                (UINT32) InitializerOp->Asl.Value.Integer;
edb6c78
+	    Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->Address32.TranslationOffset = AcpiUtReadUint32(&Tmp32);
edb6c78
             RsCreateDwordField (InitializerOp, ACPI_RESTAG_TRANSLATION,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.TranslationOffset));
edb6c78
             break;
edb6c78
 
edb6c78
         case 10: /* Address Length */
edb6c78
 
edb6c78
-            Descriptor->Address32.AddressLength =
edb6c78
-                (UINT32) InitializerOp->Asl.Value.Integer;
edb6c78
+	    Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->Address32.AddressLength = AcpiUtReadUint32(&Tmp32);
edb6c78
             RsCreateDwordField (InitializerOp, ACPI_RESTAG_LENGTH,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.AddressLength));
edb6c78
             LengthOp = InitializerOp;
38a008c
@@ -723,11 +735,14 @@ RsDoDwordSpaceDescriptor (
edb6c78
 
edb6c78
     /* Validate the Min/Max/Len/Gran values */
edb6c78
 
edb6c78
+    Tmp16 = Descriptor->Address32.ResourceLength;
edb6c78
+    Descriptor->Address32.ResourceLength = AcpiUtReadUint16(&Tmp16);
edb6c78
+
edb6c78
     RsLargeAddressCheck (
edb6c78
-        (UINT64) Descriptor->Address32.Minimum,
edb6c78
-        (UINT64) Descriptor->Address32.Maximum,
edb6c78
-        (UINT64) Descriptor->Address32.AddressLength,
edb6c78
-        (UINT64) Descriptor->Address32.Granularity,
edb6c78
+        (UINT64) AcpiUtReadUint32(&Descriptor->Address32.Minimum),
edb6c78
+        (UINT64) AcpiUtReadUint32(&Descriptor->Address32.Maximum),
edb6c78
+        (UINT64) AcpiUtReadUint32(&Descriptor->Address32.AddressLength),
edb6c78
+        (UINT64) AcpiUtReadUint32(&Descriptor->Address32.Granularity),
edb6c78
         Descriptor->Address32.Flags,
edb6c78
         MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp);
edb6c78
 
38a008c
Index: acpica-unix2-20200925/source/compiler/aslrestype2e.c
38a008c
===================================================================
38a008c
--- acpica-unix2-20200925.orig/source/compiler/aslrestype2e.c
38a008c
+++ acpica-unix2-20200925/source/compiler/aslrestype2e.c
38a008c
@@ -80,6 +80,7 @@ RsDoExtendedIoDescriptor (
edb6c78
     UINT16                  StringLength = 0;
edb6c78
     UINT32                  CurrentByteOffset;
edb6c78
     UINT32                  i;
edb6c78
+    UINT16                  Tmp16;
edb6c78
 
edb6c78
 
edb6c78
     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
38a008c
@@ -139,7 +140,8 @@ RsDoExtendedIoDescriptor (
edb6c78
 
edb6c78
         case 5: /* Address Granularity */
edb6c78
 
edb6c78
-            Descriptor->ExtAddress64.Granularity = InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->ExtAddress64.Granularity =
edb6c78
+		    AcpiUtReadUint64(&InitializerOp->Asl.Value.Integer);
edb6c78
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_GRANULARITY,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Granularity));
edb6c78
             GranOp = InitializerOp;
38a008c
@@ -147,7 +149,8 @@ RsDoExtendedIoDescriptor (
edb6c78
 
edb6c78
         case 6: /* Address Min */
edb6c78
 
edb6c78
-            Descriptor->ExtAddress64.Minimum = InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->ExtAddress64.Minimum = 
edb6c78
+	            AcpiUtReadUint64(&InitializerOp->Asl.Value.Integer);
edb6c78
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_MINADDR,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Minimum));
edb6c78
             MinOp = InitializerOp;
38a008c
@@ -155,7 +158,8 @@ RsDoExtendedIoDescriptor (
edb6c78
 
edb6c78
         case 7: /* Address Max */
edb6c78
 
edb6c78
-            Descriptor->ExtAddress64.Maximum = InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->ExtAddress64.Maximum = 
edb6c78
+	            AcpiUtReadUint64(&InitializerOp->Asl.Value.Integer);
edb6c78
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_MAXADDR,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Maximum));
edb6c78
             MaxOp = InitializerOp;
38a008c
@@ -163,14 +167,16 @@ RsDoExtendedIoDescriptor (
edb6c78
 
edb6c78
         case 8: /* Translation Offset */
edb6c78
 
edb6c78
-            Descriptor->ExtAddress64.TranslationOffset = InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->ExtAddress64.TranslationOffset = 
edb6c78
+	            AcpiUtReadUint64(&InitializerOp->Asl.Value.Integer);
edb6c78
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_TRANSLATION,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.TranslationOffset));
edb6c78
             break;
edb6c78
 
edb6c78
         case 9: /* Address Length */
edb6c78
 
edb6c78
-            Descriptor->ExtAddress64.AddressLength = InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->ExtAddress64.AddressLength = 
edb6c78
+	            AcpiUtReadUint64(&InitializerOp->Asl.Value.Integer);
edb6c78
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_LENGTH,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.AddressLength));
edb6c78
             LengthOp = InitializerOp;
38a008c
@@ -178,7 +184,8 @@ RsDoExtendedIoDescriptor (
edb6c78
 
edb6c78
         case 10: /* Type-Specific Attributes */
edb6c78
 
edb6c78
-            Descriptor->ExtAddress64.TypeSpecific = InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->ExtAddress64.TypeSpecific = 
edb6c78
+	            AcpiUtReadUint64(&InitializerOp->Asl.Value.Integer);
edb6c78
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_TYPESPECIFICATTRIBUTES,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.TypeSpecific));
edb6c78
             break;
38a008c
@@ -213,11 +220,14 @@ RsDoExtendedIoDescriptor (
edb6c78
 
edb6c78
     /* Validate the Min/Max/Len/Gran values */
edb6c78
 
edb6c78
+    Tmp16 = Descriptor->ExtAddress64.ResourceLength;
edb6c78
+    Descriptor->ExtAddress64.ResourceLength = AcpiUtReadUint16(&Tmp16);
edb6c78
+
edb6c78
     RsLargeAddressCheck (
edb6c78
-        Descriptor->ExtAddress64.Minimum,
edb6c78
-        Descriptor->ExtAddress64.Maximum,
edb6c78
-        Descriptor->ExtAddress64.AddressLength,
edb6c78
-        Descriptor->ExtAddress64.Granularity,
edb6c78
+        AcpiUtReadUint64(&Descriptor->ExtAddress64.Minimum),
edb6c78
+        AcpiUtReadUint64(&Descriptor->ExtAddress64.Maximum),
edb6c78
+        AcpiUtReadUint64(&Descriptor->ExtAddress64.AddressLength),
edb6c78
+        AcpiUtReadUint64(&Descriptor->ExtAddress64.Granularity),
edb6c78
         Descriptor->ExtAddress64.Flags,
edb6c78
         MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp);
edb6c78
 
38a008c
@@ -253,6 +263,7 @@ RsDoExtendedMemoryDescriptor (
edb6c78
     UINT16                  StringLength = 0;
edb6c78
     UINT32                  CurrentByteOffset;
edb6c78
     UINT32                  i;
edb6c78
+    UINT16                  Tmp16;
edb6c78
 
edb6c78
 
edb6c78
     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
38a008c
@@ -319,7 +330,8 @@ RsDoExtendedMemoryDescriptor (
edb6c78
 
edb6c78
         case 6: /* Address Granularity */
edb6c78
 
edb6c78
-            Descriptor->ExtAddress64.Granularity = InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->ExtAddress64.Granularity = 
edb6c78
+		    AcpiUtReadUint64(&InitializerOp->Asl.Value.Integer);
edb6c78
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_GRANULARITY,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Granularity));
edb6c78
             GranOp = InitializerOp;
38a008c
@@ -327,7 +339,8 @@ RsDoExtendedMemoryDescriptor (
edb6c78
 
edb6c78
         case 7: /* Min Address */
edb6c78
 
edb6c78
-            Descriptor->ExtAddress64.Minimum = InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->ExtAddress64.Minimum = 
edb6c78
+	            AcpiUtReadUint64(&InitializerOp->Asl.Value.Integer);
edb6c78
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_MINADDR,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Minimum));
edb6c78
             MinOp = InitializerOp;
38a008c
@@ -335,7 +348,8 @@ RsDoExtendedMemoryDescriptor (
edb6c78
 
edb6c78
         case 8: /* Max Address */
edb6c78
 
edb6c78
-            Descriptor->ExtAddress64.Maximum = InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->ExtAddress64.Maximum = 
edb6c78
+	            AcpiUtReadUint64(&InitializerOp->Asl.Value.Integer);
edb6c78
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_MAXADDR,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Maximum));
edb6c78
             MaxOp = InitializerOp;
38a008c
@@ -343,14 +357,16 @@ RsDoExtendedMemoryDescriptor (
edb6c78
 
edb6c78
         case 9: /* Translation Offset */
edb6c78
 
edb6c78
-            Descriptor->ExtAddress64.TranslationOffset = InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->ExtAddress64.TranslationOffset = 
edb6c78
+	            AcpiUtReadUint64(&InitializerOp->Asl.Value.Integer);
edb6c78
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_TRANSLATION,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.TranslationOffset));
edb6c78
             break;
edb6c78
 
edb6c78
         case 10: /* Address Length */
edb6c78
 
edb6c78
-            Descriptor->ExtAddress64.AddressLength = InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->ExtAddress64.AddressLength = 
edb6c78
+	            AcpiUtReadUint64(&InitializerOp->Asl.Value.Integer);
edb6c78
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_LENGTH,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.AddressLength));
edb6c78
             LengthOp = InitializerOp;
38a008c
@@ -358,7 +374,8 @@ RsDoExtendedMemoryDescriptor (
edb6c78
 
edb6c78
         case 11: /* Type-Specific Attributes */
edb6c78
 
edb6c78
-            Descriptor->ExtAddress64.TypeSpecific = InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->ExtAddress64.TypeSpecific = 
edb6c78
+	            AcpiUtReadUint64(&InitializerOp->Asl.Value.Integer);
edb6c78
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_TYPESPECIFICATTRIBUTES,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.TypeSpecific));
edb6c78
             break;
38a008c
@@ -394,11 +411,14 @@ RsDoExtendedMemoryDescriptor (
edb6c78
 
edb6c78
     /* Validate the Min/Max/Len/Gran values */
edb6c78
 
edb6c78
+    Tmp16 = Descriptor->ExtAddress64.ResourceLength;
edb6c78
+    Descriptor->ExtAddress64.ResourceLength = AcpiUtReadUint16(&Tmp16);
edb6c78
+
edb6c78
     RsLargeAddressCheck (
edb6c78
-        Descriptor->ExtAddress64.Minimum,
edb6c78
-        Descriptor->ExtAddress64.Maximum,
edb6c78
-        Descriptor->ExtAddress64.AddressLength,
edb6c78
-        Descriptor->ExtAddress64.Granularity,
edb6c78
+        AcpiUtReadUint64(&Descriptor->ExtAddress64.Minimum),
edb6c78
+        AcpiUtReadUint64(&Descriptor->ExtAddress64.Maximum),
edb6c78
+        AcpiUtReadUint64(&Descriptor->ExtAddress64.AddressLength),
edb6c78
+        AcpiUtReadUint64(&Descriptor->ExtAddress64.Granularity),
edb6c78
         Descriptor->ExtAddress64.Flags,
edb6c78
         MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp);
edb6c78
 
38a008c
@@ -434,6 +454,7 @@ RsDoExtendedSpaceDescriptor (
edb6c78
     UINT16                  StringLength = 0;
edb6c78
     UINT32                  CurrentByteOffset;
edb6c78
     UINT32                  i;
edb6c78
+    UINT16                  Tmp16;
edb6c78
 
edb6c78
 
edb6c78
     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
38a008c
@@ -497,7 +518,8 @@ RsDoExtendedSpaceDescriptor (
edb6c78
 
edb6c78
         case 6: /* Address Granularity */
edb6c78
 
edb6c78
-            Descriptor->ExtAddress64.Granularity = InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->ExtAddress64.Granularity = 
edb6c78
+		    AcpiUtReadUint64(&InitializerOp->Asl.Value.Integer);
edb6c78
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_GRANULARITY,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Granularity));
edb6c78
             GranOp = InitializerOp;
38a008c
@@ -505,7 +527,8 @@ RsDoExtendedSpaceDescriptor (
edb6c78
 
edb6c78
         case 7: /* Min Address */
edb6c78
 
edb6c78
-            Descriptor->ExtAddress64.Minimum = InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->ExtAddress64.Minimum = 
edb6c78
+	            AcpiUtReadUint64(&InitializerOp->Asl.Value.Integer);
edb6c78
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_MINADDR,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Minimum));
edb6c78
             MinOp = InitializerOp;
38a008c
@@ -513,7 +536,8 @@ RsDoExtendedSpaceDescriptor (
edb6c78
 
edb6c78
         case 8: /* Max Address */
edb6c78
 
edb6c78
-            Descriptor->ExtAddress64.Maximum = InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->ExtAddress64.Maximum = 
edb6c78
+	            AcpiUtReadUint64(&InitializerOp->Asl.Value.Integer);
edb6c78
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_MAXADDR,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Maximum));
edb6c78
             MaxOp = InitializerOp;
38a008c
@@ -521,14 +545,16 @@ RsDoExtendedSpaceDescriptor (
edb6c78
 
edb6c78
         case 9: /* Translation Offset */
edb6c78
 
edb6c78
-            Descriptor->ExtAddress64.TranslationOffset = InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->ExtAddress64.TranslationOffset = 
edb6c78
+	            AcpiUtReadUint64(&InitializerOp->Asl.Value.Integer);
edb6c78
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_TRANSLATION,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.TranslationOffset));
edb6c78
             break;
edb6c78
 
edb6c78
         case 10: /* Address Length */
edb6c78
 
edb6c78
-            Descriptor->ExtAddress64.AddressLength = InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->ExtAddress64.AddressLength = 
edb6c78
+	            AcpiUtReadUint64(&InitializerOp->Asl.Value.Integer);
edb6c78
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_LENGTH,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.AddressLength));
edb6c78
             LengthOp = InitializerOp;
38a008c
@@ -536,7 +562,8 @@ RsDoExtendedSpaceDescriptor (
edb6c78
 
edb6c78
         case 11: /* Type-Specific Attributes */
edb6c78
 
edb6c78
-            Descriptor->ExtAddress64.TypeSpecific = InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->ExtAddress64.TypeSpecific = 
edb6c78
+	            AcpiUtReadUint64(&InitializerOp->Asl.Value.Integer);
edb6c78
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_TYPESPECIFICATTRIBUTES,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.TypeSpecific));
edb6c78
             break;
38a008c
@@ -557,11 +584,14 @@ RsDoExtendedSpaceDescriptor (
edb6c78
 
edb6c78
     /* Validate the Min/Max/Len/Gran values */
edb6c78
 
edb6c78
+    Tmp16 = Descriptor->ExtAddress64.ResourceLength;
edb6c78
+    Descriptor->ExtAddress64.ResourceLength = AcpiUtReadUint16(&Tmp16);
edb6c78
+
edb6c78
     RsLargeAddressCheck (
edb6c78
-        Descriptor->ExtAddress64.Minimum,
edb6c78
-        Descriptor->ExtAddress64.Maximum,
edb6c78
-        Descriptor->ExtAddress64.AddressLength,
edb6c78
-        Descriptor->ExtAddress64.Granularity,
edb6c78
+        AcpiUtReadUint64(&Descriptor->ExtAddress64.Minimum),
edb6c78
+        AcpiUtReadUint64(&Descriptor->ExtAddress64.Maximum),
edb6c78
+        AcpiUtReadUint64(&Descriptor->ExtAddress64.AddressLength),
edb6c78
+        AcpiUtReadUint64(&Descriptor->ExtAddress64.Granularity),
edb6c78
         Descriptor->ExtAddress64.Flags,
edb6c78
         MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp);
edb6c78
 
38a008c
Index: acpica-unix2-20200925/source/compiler/aslrestype2q.c
38a008c
===================================================================
38a008c
--- acpica-unix2-20200925.orig/source/compiler/aslrestype2q.c
38a008c
+++ acpica-unix2-20200925/source/compiler/aslrestype2q.c
38a008c
@@ -84,6 +84,7 @@ RsDoQwordIoDescriptor (
edb6c78
     UINT32                  CurrentByteOffset;
edb6c78
     UINT32                  i;
edb6c78
     BOOLEAN                 ResSourceIndex = FALSE;
edb6c78
+    UINT16                  Tmp16;
edb6c78
 
edb6c78
 
edb6c78
     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
38a008c
@@ -147,7 +148,8 @@ RsDoQwordIoDescriptor (
edb6c78
 
edb6c78
         case 5: /* Address Granularity */
edb6c78
 
edb6c78
-            Descriptor->Address64.Granularity = InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->Address64.Granularity = 
edb6c78
+		    AcpiUtReadUint64(&InitializerOp->Asl.Value.Integer);
edb6c78
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_GRANULARITY,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Granularity));
edb6c78
             GranOp = InitializerOp;
38a008c
@@ -155,7 +157,8 @@ RsDoQwordIoDescriptor (
edb6c78
 
edb6c78
         case 6: /* Address Min */
edb6c78
 
edb6c78
-            Descriptor->Address64.Minimum = InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->Address64.Minimum = 
edb6c78
+	            AcpiUtReadUint64(&InitializerOp->Asl.Value.Integer);
edb6c78
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_MINADDR,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Minimum));
edb6c78
             MinOp = InitializerOp;
38a008c
@@ -163,7 +166,8 @@ RsDoQwordIoDescriptor (
edb6c78
 
edb6c78
         case 7: /* Address Max */
edb6c78
 
edb6c78
-            Descriptor->Address64.Maximum = InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->Address64.Maximum = 
edb6c78
+	            AcpiUtReadUint64(&InitializerOp->Asl.Value.Integer);
edb6c78
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_MAXADDR,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Maximum));
edb6c78
             MaxOp = InitializerOp;
38a008c
@@ -171,14 +175,16 @@ RsDoQwordIoDescriptor (
edb6c78
 
edb6c78
         case 8: /* Translation Offset */
edb6c78
 
edb6c78
-            Descriptor->Address64.TranslationOffset = InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->Address64.TranslationOffset = 
edb6c78
+	            AcpiUtReadUint64(&InitializerOp->Asl.Value.Integer);
edb6c78
             RsCreateByteField (InitializerOp, ACPI_RESTAG_TRANSLATION,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.TranslationOffset));
edb6c78
             break;
edb6c78
 
edb6c78
         case 9: /* Address Length */
edb6c78
 
edb6c78
-            Descriptor->Address64.AddressLength = InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->Address64.AddressLength = 
edb6c78
+	            AcpiUtReadUint64(&InitializerOp->Asl.Value.Integer);
edb6c78
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_LENGTH,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.AddressLength));
edb6c78
             LengthOp = InitializerOp;
38a008c
@@ -262,11 +268,14 @@ RsDoQwordIoDescriptor (
edb6c78
 
edb6c78
     /* Validate the Min/Max/Len/Gran values */
edb6c78
 
edb6c78
+    Tmp16 = Descriptor->Address64.ResourceLength;
edb6c78
+    Descriptor->Address64.ResourceLength = AcpiUtReadUint16(&Tmp16);
edb6c78
+
edb6c78
     RsLargeAddressCheck (
edb6c78
-        Descriptor->Address64.Minimum,
edb6c78
-        Descriptor->Address64.Maximum,
edb6c78
-        Descriptor->Address64.AddressLength,
edb6c78
-        Descriptor->Address64.Granularity,
edb6c78
+        AcpiUtReadUint64(&Descriptor->Address64.Minimum),
edb6c78
+        AcpiUtReadUint64(&Descriptor->Address64.Maximum),
edb6c78
+        AcpiUtReadUint64(&Descriptor->Address64.AddressLength),
edb6c78
+        AcpiUtReadUint64(&Descriptor->Address64.Granularity),
edb6c78
         Descriptor->Address64.Flags,
edb6c78
         MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp);
edb6c78
 
38a008c
@@ -305,6 +314,7 @@ RsDoQwordMemoryDescriptor (
edb6c78
     UINT32                  CurrentByteOffset;
edb6c78
     UINT32                  i;
edb6c78
     BOOLEAN                 ResSourceIndex = FALSE;
edb6c78
+    UINT16                  Tmp16;
edb6c78
 
edb6c78
 
edb6c78
     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
38a008c
@@ -375,7 +385,8 @@ RsDoQwordMemoryDescriptor (
edb6c78
 
edb6c78
         case 6: /* Address Granularity */
edb6c78
 
edb6c78
-            Descriptor->Address64.Granularity = InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->Address64.Granularity = 
edb6c78
+		    AcpiUtReadUint64(&InitializerOp->Asl.Value.Integer);
edb6c78
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_GRANULARITY,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Granularity));
edb6c78
             GranOp = InitializerOp;
38a008c
@@ -383,7 +394,8 @@ RsDoQwordMemoryDescriptor (
edb6c78
 
edb6c78
         case 7: /* Min Address */
edb6c78
 
edb6c78
-            Descriptor->Address64.Minimum = InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->Address64.Minimum = 
edb6c78
+	            AcpiUtReadUint64(&InitializerOp->Asl.Value.Integer);
edb6c78
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_MINADDR,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Minimum));
edb6c78
             MinOp = InitializerOp;
38a008c
@@ -391,7 +403,8 @@ RsDoQwordMemoryDescriptor (
edb6c78
 
edb6c78
         case 8: /* Max Address */
edb6c78
 
edb6c78
-            Descriptor->Address64.Maximum = InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->Address64.Maximum = 
edb6c78
+	            AcpiUtReadUint64(&InitializerOp->Asl.Value.Integer);
edb6c78
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_MAXADDR,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Maximum));
edb6c78
             MaxOp = InitializerOp;
38a008c
@@ -399,14 +412,16 @@ RsDoQwordMemoryDescriptor (
edb6c78
 
edb6c78
         case 9: /* Translation Offset */
edb6c78
 
edb6c78
-            Descriptor->Address64.TranslationOffset = InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->Address64.TranslationOffset = 
edb6c78
+	            AcpiUtReadUint64(&InitializerOp->Asl.Value.Integer);
edb6c78
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_TRANSLATION,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.TranslationOffset));
edb6c78
             break;
edb6c78
 
edb6c78
         case 10: /* Address Length */
edb6c78
 
edb6c78
-            Descriptor->Address64.AddressLength = InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->Address64.AddressLength = 
edb6c78
+	            AcpiUtReadUint64(&InitializerOp->Asl.Value.Integer);
edb6c78
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_LENGTH,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.AddressLength));
edb6c78
             LengthOp = InitializerOp;
38a008c
@@ -491,11 +506,14 @@ RsDoQwordMemoryDescriptor (
edb6c78
 
edb6c78
     /* Validate the Min/Max/Len/Gran values */
edb6c78
 
edb6c78
+    Tmp16 = Descriptor->Address64.ResourceLength;
edb6c78
+    Descriptor->Address64.ResourceLength = AcpiUtReadUint16(&Tmp16);
edb6c78
+
edb6c78
     RsLargeAddressCheck (
edb6c78
-        Descriptor->Address64.Minimum,
edb6c78
-        Descriptor->Address64.Maximum,
edb6c78
-        Descriptor->Address64.AddressLength,
edb6c78
-        Descriptor->Address64.Granularity,
edb6c78
+        AcpiUtReadUint64(&Descriptor->Address64.Minimum),
edb6c78
+        AcpiUtReadUint64(&Descriptor->Address64.Maximum),
edb6c78
+        AcpiUtReadUint64(&Descriptor->Address64.AddressLength),
edb6c78
+        AcpiUtReadUint64(&Descriptor->Address64.Granularity),
edb6c78
         Descriptor->Address64.Flags,
edb6c78
         MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp);
edb6c78
 
38a008c
@@ -534,6 +552,7 @@ RsDoQwordSpaceDescriptor (
edb6c78
     UINT32                  CurrentByteOffset;
edb6c78
     UINT32                  i;
edb6c78
     BOOLEAN                 ResSourceIndex = FALSE;
edb6c78
+    UINT16                  Tmp16;
edb6c78
 
edb6c78
 
edb6c78
     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
38a008c
@@ -601,7 +620,8 @@ RsDoQwordSpaceDescriptor (
edb6c78
 
edb6c78
         case 6: /* Address Granularity */
edb6c78
 
edb6c78
-            Descriptor->Address64.Granularity = InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->Address64.Granularity = 
edb6c78
+		    AcpiUtReadUint64(&InitializerOp->Asl.Value.Integer);
edb6c78
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_GRANULARITY,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Granularity));
edb6c78
             GranOp = InitializerOp;
38a008c
@@ -609,7 +629,8 @@ RsDoQwordSpaceDescriptor (
edb6c78
 
edb6c78
         case 7: /* Min Address */
edb6c78
 
edb6c78
-            Descriptor->Address64.Minimum = InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->Address64.Minimum = 
edb6c78
+		    AcpiUtReadUint64(&InitializerOp->Asl.Value.Integer);
edb6c78
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_MINADDR,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Minimum));
edb6c78
             MinOp = InitializerOp;
38a008c
@@ -617,7 +638,8 @@ RsDoQwordSpaceDescriptor (
edb6c78
 
edb6c78
         case 8: /* Max Address */
edb6c78
 
edb6c78
-            Descriptor->Address64.Maximum = InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->Address64.Maximum = 
edb6c78
+		    AcpiUtReadUint64(&InitializerOp->Asl.Value.Integer);
edb6c78
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_MAXADDR,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Maximum));
edb6c78
             MaxOp = InitializerOp;
38a008c
@@ -625,14 +647,16 @@ RsDoQwordSpaceDescriptor (
edb6c78
 
edb6c78
         case 9: /* Translation Offset */
edb6c78
 
edb6c78
-            Descriptor->Address64.TranslationOffset = InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->Address64.TranslationOffset = 
edb6c78
+		    AcpiUtReadUint64(&InitializerOp->Asl.Value.Integer);
edb6c78
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_TRANSLATION,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.TranslationOffset));
edb6c78
             break;
edb6c78
 
edb6c78
         case 10: /* Address Length */
edb6c78
 
edb6c78
-            Descriptor->Address64.AddressLength = InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->Address64.AddressLength = 
edb6c78
+		    AcpiUtReadUint64(&InitializerOp->Asl.Value.Integer);
edb6c78
             RsCreateQwordField (InitializerOp, ACPI_RESTAG_LENGTH,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.AddressLength));
edb6c78
             LengthOp = InitializerOp;
38a008c
@@ -702,11 +726,14 @@ RsDoQwordSpaceDescriptor (
edb6c78
 
edb6c78
     /* Validate the Min/Max/Len/Gran values */
edb6c78
 
edb6c78
+    Tmp16 = Descriptor->Address64.ResourceLength;
edb6c78
+    Descriptor->Address64.ResourceLength = AcpiUtReadUint16(&Tmp16);
edb6c78
+
edb6c78
     RsLargeAddressCheck (
edb6c78
-        Descriptor->Address64.Minimum,
edb6c78
-        Descriptor->Address64.Maximum,
edb6c78
-        Descriptor->Address64.AddressLength,
edb6c78
-        Descriptor->Address64.Granularity,
edb6c78
+        AcpiUtReadUint64(&Descriptor->Address64.Minimum),
edb6c78
+        AcpiUtReadUint64(&Descriptor->Address64.Maximum),
edb6c78
+        AcpiUtReadUint64(&Descriptor->Address64.AddressLength),
edb6c78
+        AcpiUtReadUint64(&Descriptor->Address64.Granularity),
edb6c78
         Descriptor->Address64.Flags,
edb6c78
         MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp);
edb6c78
 
38a008c
Index: acpica-unix2-20200925/source/compiler/aslrestype2s.c
38a008c
===================================================================
38a008c
--- acpica-unix2-20200925.orig/source/compiler/aslrestype2s.c
38a008c
+++ acpica-unix2-20200925/source/compiler/aslrestype2s.c
38a008c
@@ -343,6 +343,7 @@ RsDoGpioIntDescriptor (
edb6c78
     UINT32                  CurrentByteOffset;
edb6c78
     UINT32                  PinCount = 0;
edb6c78
     UINT32                  i;
edb6c78
+    UINT16                  Tmp16;
edb6c78
 
edb6c78
 
edb6c78
     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
38a008c
@@ -485,7 +486,8 @@ RsDoGpioIntDescriptor (
edb6c78
              *  (implies resource source must immediately follow the pin list.)
edb6c78
              *  Name: _PIN
edb6c78
              */
edb6c78
-            *InterruptList = (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+            Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+            *InterruptList = AcpiUtReadUint16(&Tmp16);
edb6c78
             InterruptList++;
edb6c78
             PinCount++;
edb6c78
 
38a008c
@@ -518,6 +520,27 @@ RsDoGpioIntDescriptor (
edb6c78
 
edb6c78
     MpSaveGpioInfo (Info->MappingOp, Descriptor,
edb6c78
         PinCount, PinList, ResourceSource);
edb6c78
+
edb6c78
+    /* correct endian-ness issues */
edb6c78
+    Tmp16 = Descriptor->Gpio.ResourceLength;
edb6c78
+    Descriptor->Gpio.ResourceLength = AcpiUtReadUint16(&Tmp16);
edb6c78
+    Tmp16 = Descriptor->Gpio.Flags;
edb6c78
+    Descriptor->Gpio.Flags = AcpiUtReadUint16(&Tmp16);
edb6c78
+    Tmp16 = Descriptor->Gpio.IntFlags;
edb6c78
+    Descriptor->Gpio.IntFlags = AcpiUtReadUint16(&Tmp16);
edb6c78
+    Tmp16 = Descriptor->Gpio.DriveStrength;
edb6c78
+    Descriptor->Gpio.DriveStrength = AcpiUtReadUint16(&Tmp16);
edb6c78
+    Tmp16 = Descriptor->Gpio.DebounceTimeout;
edb6c78
+    Descriptor->Gpio.DebounceTimeout = AcpiUtReadUint16(&Tmp16);
edb6c78
+    Tmp16 = Descriptor->Gpio.PinTableOffset;
edb6c78
+    Descriptor->Gpio.PinTableOffset = AcpiUtReadUint16(&Tmp16);
edb6c78
+    Tmp16 = Descriptor->Gpio.ResSourceOffset;
edb6c78
+    Descriptor->Gpio.ResSourceOffset = AcpiUtReadUint16(&Tmp16);
edb6c78
+    Tmp16 = Descriptor->Gpio.VendorOffset;
edb6c78
+    Descriptor->Gpio.VendorOffset = AcpiUtReadUint16(&Tmp16);
edb6c78
+    Tmp16 = Descriptor->Gpio.VendorLength;
edb6c78
+    Descriptor->Gpio.VendorLength = AcpiUtReadUint16(&Tmp16);
edb6c78
+
edb6c78
     return (Rnode);
edb6c78
 }
edb6c78
 
38a008c
@@ -552,6 +575,7 @@ RsDoGpioIoDescriptor (
edb6c78
     UINT32                  CurrentByteOffset;
edb6c78
     UINT32                  PinCount = 0;
edb6c78
     UINT32                  i;
edb6c78
+    UINT16                  Tmp16;
edb6c78
 
edb6c78
 
edb6c78
     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
38a008c
@@ -691,7 +715,8 @@ RsDoGpioIoDescriptor (
edb6c78
              *  (implies resource source must immediately follow the pin list.)
edb6c78
              *  Name: _PIN
edb6c78
              */
edb6c78
-            *InterruptList = (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+            Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+            *InterruptList = AcpiUtReadUint16(&Tmp16);
edb6c78
             InterruptList++;
edb6c78
             PinCount++;
edb6c78
 
38a008c
@@ -724,6 +749,27 @@ RsDoGpioIoDescriptor (
edb6c78
 
edb6c78
     MpSaveGpioInfo (Info->MappingOp, Descriptor,
edb6c78
         PinCount, PinList, ResourceSource);
edb6c78
+
edb6c78
+    /* correct endian-ness issues */
edb6c78
+    Tmp16 = Descriptor->Gpio.ResourceLength;
edb6c78
+    Descriptor->Gpio.ResourceLength = AcpiUtReadUint16(&Tmp16);
edb6c78
+    Tmp16 = Descriptor->Gpio.Flags;
edb6c78
+    Descriptor->Gpio.Flags = AcpiUtReadUint16(&Tmp16);
edb6c78
+    Tmp16 = Descriptor->Gpio.IntFlags;
edb6c78
+    Descriptor->Gpio.IntFlags = AcpiUtReadUint16(&Tmp16);
edb6c78
+    Tmp16 = Descriptor->Gpio.DriveStrength;
edb6c78
+    Descriptor->Gpio.DriveStrength = AcpiUtReadUint16(&Tmp16);
edb6c78
+    Tmp16 = Descriptor->Gpio.DebounceTimeout;
edb6c78
+    Descriptor->Gpio.DebounceTimeout = AcpiUtReadUint16(&Tmp16);
edb6c78
+    Tmp16 = Descriptor->Gpio.PinTableOffset;
edb6c78
+    Descriptor->Gpio.PinTableOffset = AcpiUtReadUint16(&Tmp16);
edb6c78
+    Tmp16 = Descriptor->Gpio.ResSourceOffset;
edb6c78
+    Descriptor->Gpio.ResSourceOffset = AcpiUtReadUint16(&Tmp16);
edb6c78
+    Tmp16 = Descriptor->Gpio.VendorOffset;
edb6c78
+    Descriptor->Gpio.VendorOffset = AcpiUtReadUint16(&Tmp16);
edb6c78
+    Tmp16 = Descriptor->Gpio.VendorLength;
edb6c78
+    Descriptor->Gpio.VendorLength = AcpiUtReadUint16(&Tmp16);
edb6c78
+
edb6c78
     return (Rnode);
edb6c78
 }
edb6c78
 
38a008c
@@ -754,6 +800,8 @@ RsDoI2cSerialBusDescriptor (
edb6c78
     UINT16                  DescriptorSize;
edb6c78
     UINT32                  CurrentByteOffset;
edb6c78
     UINT32                  i;
edb6c78
+    UINT16                  Tmp16;
edb6c78
+    UINT32                  Tmp32;
edb6c78
 
edb6c78
 
edb6c78
     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
38a008c
@@ -781,7 +829,8 @@ RsDoI2cSerialBusDescriptor (
edb6c78
     Descriptor->I2cSerialBus.RevisionId = AML_RESOURCE_I2C_REVISION;
edb6c78
     Descriptor->I2cSerialBus.TypeRevisionId = AML_RESOURCE_I2C_TYPE_REVISION;
edb6c78
     Descriptor->I2cSerialBus.Type = AML_RESOURCE_I2C_SERIALBUSTYPE;
edb6c78
-    Descriptor->I2cSerialBus.TypeDataLength = AML_RESOURCE_I2C_MIN_DATA_LEN + VendorLength;
edb6c78
+    Tmp16 = AML_RESOURCE_I2C_MIN_DATA_LEN + VendorLength;
edb6c78
+    Descriptor->I2cSerialBus.TypeDataLength = AcpiUtReadUint16(&Tmp16);
edb6c78
 
edb6c78
     if (Info->DescriptorTypeOp->Asl.ParseOpcode == PARSEOP_I2C_SERIALBUS_V2)
edb6c78
     {
38a008c
@@ -795,13 +844,15 @@ RsDoI2cSerialBusDescriptor (
6c29d68
 
6c29d68
     /* Process all child initialization nodes */
6c29d68
 
6c29d68
+    Descriptor->I2cSerialBus.TypeSpecificFlags = 0;
6c29d68
     for (i = 0; InitializerOp; i++)
6c29d68
     {
6c29d68
         switch (i)
edb6c78
         {
edb6c78
         case 0: /* Slave Address [WORD] (_ADR) */
edb6c78
 
edb6c78
-            Descriptor->I2cSerialBus.SlaveAddress = (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+            Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->I2cSerialBus.SlaveAddress = AcpiUtReadUint16(&Tmp16);
edb6c78
             RsCreateWordField (InitializerOp, ACPI_RESTAG_ADDRESS,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (I2cSerialBus.SlaveAddress));
edb6c78
             break;
38a008c
@@ -815,16 +866,19 @@ RsDoI2cSerialBusDescriptor (
edb6c78
 
edb6c78
         case 2: /* Connection Speed [DWORD] (_SPE) */
edb6c78
 
edb6c78
-            Descriptor->I2cSerialBus.ConnectionSpeed = (UINT32) InitializerOp->Asl.Value.Integer;
edb6c78
+	    Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->I2cSerialBus.ConnectionSpeed = AcpiUtReadUint32(&Tmp32);
edb6c78
             RsCreateDwordField (InitializerOp, ACPI_RESTAG_SPEED,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (I2cSerialBus.ConnectionSpeed));
edb6c78
             break;
6c29d68
 
6c29d68
         case 3: /* Addressing Mode [Flag] (_MOD) */
6c29d68
 
6c29d68
-            RsSetFlagBits16 (&Descriptor->I2cSerialBus.TypeSpecificFlags, InitializerOp, 0, 0);
6c29d68
+	    Tmp16 = AcpiUtReadUint16(&Descriptor->I2cSerialBus.TypeSpecificFlags);
6c29d68
+            RsSetFlagBits16 (&Tmp16, InitializerOp, 0, 0);
6c29d68
             RsCreateBitField (InitializerOp, ACPI_RESTAG_MODE,
6c29d68
                 CurrentByteOffset + ASL_RESDESC_OFFSET (I2cSerialBus.TypeSpecificFlags), 0);
6c29d68
+	    Descriptor->I2cSerialBus.TypeSpecificFlags = AcpiUtReadUint16(&Tmp16);
6c29d68
             break;
6c29d68
 
6c29d68
         case 4: /* ResSource [Optional Field - STRING] */
38a008c
@@ -882,6 +936,8 @@ RsDoI2cSerialBusDescriptor (
6c29d68
         InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
6c29d68
     }
6c29d68
 
6c29d68
+    Tmp16 = Descriptor->I2cSerialBus.ResourceLength;
6c29d68
+    Descriptor->I2cSerialBus.ResourceLength = AcpiUtReadUint16(&Tmp16);
6c29d68
     MpSaveSerialInfo (Info->MappingOp, Descriptor, ResourceSource);
6c29d68
     return (Rnode);
6c29d68
 }
38a008c
@@ -913,6 +969,8 @@ RsDoSpiSerialBusDescriptor (
edb6c78
     UINT16                  DescriptorSize;
edb6c78
     UINT32                  CurrentByteOffset;
edb6c78
     UINT32                  i;
edb6c78
+    UINT16                  Tmp16;
edb6c78
+    UINT32                  Tmp32;
edb6c78
 
edb6c78
 
edb6c78
     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
38a008c
@@ -935,12 +993,13 @@ RsDoSpiSerialBusDescriptor (
edb6c78
         sizeof (AML_RESOURCE_LARGE_HEADER));
edb6c78
 
edb6c78
     Descriptor = Rnode->Buffer;
edb6c78
-    Descriptor->SpiSerialBus.ResourceLength = DescriptorSize;
edb6c78
+    Descriptor->SpiSerialBus.ResourceLength = AcpiUtReadUint16(&DescriptorSize);
edb6c78
     Descriptor->SpiSerialBus.DescriptorType = ACPI_RESOURCE_NAME_SERIAL_BUS;
edb6c78
     Descriptor->SpiSerialBus.RevisionId = AML_RESOURCE_SPI_REVISION;
edb6c78
     Descriptor->SpiSerialBus.TypeRevisionId = AML_RESOURCE_SPI_TYPE_REVISION;
edb6c78
     Descriptor->SpiSerialBus.Type = AML_RESOURCE_SPI_SERIALBUSTYPE;
edb6c78
-    Descriptor->SpiSerialBus.TypeDataLength = AML_RESOURCE_SPI_MIN_DATA_LEN + VendorLength;
edb6c78
+    Tmp16 = AML_RESOURCE_SPI_MIN_DATA_LEN + VendorLength;
edb6c78
+    Descriptor->SpiSerialBus.TypeDataLength = AcpiUtReadUint16(&Tmp16);
edb6c78
 
edb6c78
     if (Info->DescriptorTypeOp->Asl.ParseOpcode == PARSEOP_SPI_SERIALBUS_V2)
edb6c78
     {
38a008c
@@ -955,29 +1014,35 @@ RsDoSpiSerialBusDescriptor (
6c29d68
 
6c29d68
     /* Process all child initialization nodes */
6c29d68
 
6c29d68
+    Descriptor->SpiSerialBus.TypeSpecificFlags = 0;
6c29d68
     for (i = 0; InitializerOp; i++)
6c29d68
     {
6c29d68
         switch (i)
edb6c78
         {
edb6c78
         case 0: /* Device Selection [WORD] (_ADR) */
edb6c78
 
edb6c78
-            Descriptor->SpiSerialBus.DeviceSelection = (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+            Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->SpiSerialBus.DeviceSelection = AcpiUtReadUint16(&Tmp16);
edb6c78
             RsCreateWordField (InitializerOp, ACPI_RESTAG_ADDRESS,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (SpiSerialBus.DeviceSelection));
edb6c78
             break;
6c29d68
 
6c29d68
         case 1: /* Device Polarity [Flag] (_DPL) */
6c29d68
 
6c29d68
-            RsSetFlagBits16 (&Descriptor->SpiSerialBus.TypeSpecificFlags, InitializerOp, 1, 0);
6c29d68
+	    Tmp16 = AcpiUtReadUint16(&Descriptor->SpiSerialBus.TypeSpecificFlags);
6c29d68
+            RsSetFlagBits16 (&Tmp16, InitializerOp, 1, 0);
6c29d68
             RsCreateBitField (InitializerOp, ACPI_RESTAG_DEVICEPOLARITY,
6c29d68
                 CurrentByteOffset + ASL_RESDESC_OFFSET (SpiSerialBus.TypeSpecificFlags), 1);
6c29d68
+	    Descriptor->SpiSerialBus.TypeSpecificFlags = AcpiUtReadUint16(&Tmp16);
6c29d68
             break;
6c29d68
 
6c29d68
         case 2: /* Wire Mode [Flag] (_MOD) */
6c29d68
 
6c29d68
-            RsSetFlagBits16 (&Descriptor->SpiSerialBus.TypeSpecificFlags, InitializerOp, 0, 0);
6c29d68
+	    Tmp16 = AcpiUtReadUint16(&Descriptor->SpiSerialBus.TypeSpecificFlags);
6c29d68
+            RsSetFlagBits16 (&Tmp16, InitializerOp, 0, 0);
6c29d68
             RsCreateBitField (InitializerOp, ACPI_RESTAG_MODE,
6c29d68
                 CurrentByteOffset + ASL_RESDESC_OFFSET (SpiSerialBus.TypeSpecificFlags), 0);
6c29d68
+	    Descriptor->SpiSerialBus.TypeSpecificFlags = AcpiUtReadUint16(&Tmp16);
6c29d68
             break;
6c29d68
 
6c29d68
         case 3: /* Device Bit Length [BYTE] (_LEN) */
38a008c
@@ -996,7 +1061,8 @@ RsDoSpiSerialBusDescriptor (
edb6c78
 
edb6c78
         case 5: /* Connection Speed [DWORD] (_SPE) */
edb6c78
 
edb6c78
-            Descriptor->SpiSerialBus.ConnectionSpeed = (UINT32) InitializerOp->Asl.Value.Integer;
edb6c78
+	    Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->SpiSerialBus.ConnectionSpeed = AcpiUtReadUint32(&Tmp32);
edb6c78
             RsCreateDwordField (InitializerOp, ACPI_RESTAG_SPEED,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (SpiSerialBus.ConnectionSpeed));
edb6c78
             break;
38a008c
@@ -1101,6 +1167,8 @@ RsDoUartSerialBusDescriptor (
edb6c78
     UINT16                  DescriptorSize;
edb6c78
     UINT32                  CurrentByteOffset;
edb6c78
     UINT32                  i;
edb6c78
+    UINT16                  Tmp16;
edb6c78
+    UINT32                  Tmp32;
edb6c78
 
edb6c78
 
edb6c78
     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
38a008c
@@ -1123,12 +1191,13 @@ RsDoUartSerialBusDescriptor (
edb6c78
         sizeof (AML_RESOURCE_LARGE_HEADER));
edb6c78
 
edb6c78
     Descriptor = Rnode->Buffer;
edb6c78
-    Descriptor->UartSerialBus.ResourceLength = DescriptorSize;
edb6c78
+    Descriptor->UartSerialBus.ResourceLength = AcpiUtReadUint16(&DescriptorSize);
edb6c78
     Descriptor->UartSerialBus.DescriptorType = ACPI_RESOURCE_NAME_SERIAL_BUS;
edb6c78
     Descriptor->UartSerialBus.RevisionId = AML_RESOURCE_UART_REVISION;
edb6c78
     Descriptor->UartSerialBus.TypeRevisionId = AML_RESOURCE_UART_TYPE_REVISION;
edb6c78
     Descriptor->UartSerialBus.Type = AML_RESOURCE_UART_SERIALBUSTYPE;
edb6c78
-    Descriptor->UartSerialBus.TypeDataLength = AML_RESOURCE_UART_MIN_DATA_LEN + VendorLength;
edb6c78
+    Tmp16 = AML_RESOURCE_UART_MIN_DATA_LEN + VendorLength;
edb6c78
+    Descriptor->UartSerialBus.TypeDataLength = AcpiUtReadUint16(&Tmp16);
edb6c78
 
edb6c78
     if (Info->DescriptorTypeOp->Asl.ParseOpcode == PARSEOP_UART_SERIALBUS_V2)
edb6c78
     {
38a008c
@@ -1142,29 +1211,35 @@ RsDoUartSerialBusDescriptor (
6c29d68
 
6c29d68
     /* Process all child initialization nodes */
6c29d68
 
6c29d68
+    Descriptor->UartSerialBus.TypeSpecificFlags = 0;
6c29d68
     for (i = 0; InitializerOp; i++)
6c29d68
     {
6c29d68
         switch (i)
edb6c78
         {
edb6c78
         case 0: /* Connection Speed (Baud Rate) [DWORD] (_SPE) */
edb6c78
 
edb6c78
-            Descriptor->UartSerialBus.DefaultBaudRate = (UINT32) InitializerOp->Asl.Value.Integer;
edb6c78
+	    Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->UartSerialBus.DefaultBaudRate = AcpiUtReadUint32(&Tmp32);
edb6c78
             RsCreateDwordField (InitializerOp, ACPI_RESTAG_SPEED,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.DefaultBaudRate));
edb6c78
             break;
6c29d68
 
6c29d68
         case 1: /* Bits Per Byte [Flags] (_LEN) */
6c29d68
 
6c29d68
-            RsSetFlagBits16 (&Descriptor->UartSerialBus.TypeSpecificFlags, InitializerOp, 4, 3);
6c29d68
+	    Tmp16 = AcpiUtReadUint16(&Descriptor->UartSerialBus.TypeSpecificFlags);
6c29d68
+            RsSetFlagBits16 (&Tmp16, InitializerOp, 4, 3);
6c29d68
             RsCreateMultiBitField (InitializerOp, ACPI_RESTAG_LENGTH,
6c29d68
                 CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.TypeSpecificFlags), 4, 3);
6c29d68
+	    Descriptor->UartSerialBus.TypeSpecificFlags = AcpiUtReadUint16(&Tmp16);;
6c29d68
             break;
6c29d68
 
6c29d68
         case 2: /* Stop Bits [Flags] (_STB) */
6c29d68
 
6c29d68
-            RsSetFlagBits16 (&Descriptor->UartSerialBus.TypeSpecificFlags, InitializerOp, 2, 1);
6c29d68
+	    Tmp16 = AcpiUtReadUint16(&Descriptor->UartSerialBus.TypeSpecificFlags);
6c29d68
+            RsSetFlagBits16 (&Tmp16, InitializerOp, 2, 1);
6c29d68
             RsCreateMultiBitField (InitializerOp, ACPI_RESTAG_STOPBITS,
6c29d68
                 CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.TypeSpecificFlags), 2, 2);
6c29d68
+	    Descriptor->UartSerialBus.TypeSpecificFlags = AcpiUtReadUint16(&Tmp16);;
6c29d68
             break;
6c29d68
 
6c29d68
         case 3: /* Lines In Use [BYTE] (_LIN) */
38a008c
@@ -1176,9 +1251,11 @@ RsDoUartSerialBusDescriptor (
6c29d68
 
6c29d68
         case 4: /* Endianness [Flag] (_END) */
6c29d68
 
6c29d68
-            RsSetFlagBits16 (&Descriptor->UartSerialBus.TypeSpecificFlags, InitializerOp, 7, 0);
6c29d68
+	    Tmp16 = AcpiUtReadUint16(&Descriptor->UartSerialBus.TypeSpecificFlags);
6c29d68
+            RsSetFlagBits16 (&Tmp16, InitializerOp, 7, 0);
6c29d68
             RsCreateBitField (InitializerOp, ACPI_RESTAG_ENDIANNESS,
6c29d68
                 CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.TypeSpecificFlags), 7);
6c29d68
+	    Descriptor->UartSerialBus.TypeSpecificFlags = AcpiUtReadUint16(&Tmp16);;
6c29d68
             break;
6c29d68
 
6c29d68
         case 5: /* Parity [BYTE] (_PAR) */
38a008c
@@ -1190,21 +1267,25 @@ RsDoUartSerialBusDescriptor (
6c29d68
 
6c29d68
         case 6: /* Flow Control [Flags] (_FLC) */
6c29d68
 
6c29d68
-            RsSetFlagBits16 (&Descriptor->UartSerialBus.TypeSpecificFlags, InitializerOp, 0, 0);
6c29d68
+	    Tmp16 = AcpiUtReadUint16(&Descriptor->UartSerialBus.TypeSpecificFlags);
6c29d68
+            RsSetFlagBits16 (&Tmp16, InitializerOp, 0, 0);
6c29d68
             RsCreateMultiBitField (InitializerOp, ACPI_RESTAG_FLOWCONTROL,
6c29d68
                 CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.TypeSpecificFlags), 0, 2);
6c29d68
+	    Descriptor->UartSerialBus.TypeSpecificFlags = AcpiUtReadUint16(&Tmp16);;
6c29d68
             break;
edb6c78
 
edb6c78
         case 7: /* Rx Buffer Size [WORD] (_RXL) */
edb6c78
 
edb6c78
-            Descriptor->UartSerialBus.RxFifoSize = (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+	    Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->UartSerialBus.RxFifoSize = AcpiUtReadUint16(&Tmp16);
edb6c78
             RsCreateWordField (InitializerOp, ACPI_RESTAG_LENGTH_RX,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.RxFifoSize));
edb6c78
             break;
edb6c78
 
edb6c78
         case 8: /* Tx Buffer Size [WORD] (_TXL) */
edb6c78
 
edb6c78
-            Descriptor->UartSerialBus.TxFifoSize = (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+	    Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->UartSerialBus.TxFifoSize = AcpiUtReadUint16(&Tmp16);
edb6c78
             RsCreateWordField (InitializerOp, ACPI_RESTAG_LENGTH_TX,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.TxFifoSize));
edb6c78
             break;
38a008c
@@ -1308,6 +1389,7 @@ RsDoPinFunctionDescriptor (
edb6c78
     UINT32                  CurrentByteOffset;
edb6c78
     UINT32                  PinCount = 0;
edb6c78
     UINT32                  i;
edb6c78
+    UINT16                  Tmp16;
edb6c78
 
edb6c78
     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
edb6c78
     CurrentByteOffset = Info->CurrentByteOffset;
38a008c
@@ -1331,7 +1413,7 @@ RsDoPinFunctionDescriptor (
edb6c78
         sizeof (AML_RESOURCE_LARGE_HEADER));
edb6c78
 
edb6c78
     Descriptor = Rnode->Buffer;
edb6c78
-    Descriptor->PinFunction.ResourceLength = DescriptorSize;
edb6c78
+    Descriptor->PinFunction.ResourceLength = AcpiUtReadUint16(&DescriptorSize);
edb6c78
     Descriptor->PinFunction.DescriptorType = ACPI_RESOURCE_NAME_PIN_FUNCTION;
edb6c78
     Descriptor->PinFunction.RevisionId = AML_RESOURCE_PIN_FUNCTION_REVISION;
edb6c78
 
38a008c
@@ -1371,7 +1453,8 @@ RsDoPinFunctionDescriptor (
edb6c78
 
edb6c78
         case 2: /* Function Number [WORD] (_FUN) */
edb6c78
 
edb6c78
-            Descriptor->PinFunction.FunctionNumber = (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+            Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->PinFunction.FunctionNumber = AcpiUtReadUint16(&Tmp16);
edb6c78
             RsCreateDwordField (InitializerOp, ACPI_RESTAG_FUNCTION,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (PinFunction.FunctionNumber));
edb6c78
             break;
38a008c
@@ -1419,6 +1502,12 @@ RsDoPinFunctionDescriptor (
edb6c78
             {
edb6c78
                 Descriptor->PinFunction.VendorLength = VendorLength;
edb6c78
             }
edb6c78
+            Tmp16 = (UINT16) ACPI_PTR_DIFF (VendorData, Descriptor);
edb6c78
+            Descriptor->PinFunction.VendorOffset = AcpiUtReadUint16(&Tmp16);
edb6c78
+            
edb6c78
+            Tmp16 = Descriptor->PinFunction.VendorLength;
edb6c78
+            Descriptor->PinFunction.VendorLength = AcpiUtReadUint16(&Tmp16);
edb6c78
+
edb6c78
             break;
edb6c78
 
edb6c78
         default:
38a008c
@@ -1430,7 +1519,8 @@ RsDoPinFunctionDescriptor (
edb6c78
              *  (implies resource source must immediately follow the pin list.)
edb6c78
              *  Name: _PIN
edb6c78
              */
edb6c78
-            *PinList = (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+            Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+            *PinList = AcpiUtReadUint16(&Tmp16);
edb6c78
             PinList++;
edb6c78
             PinCount++;
edb6c78
 
38a008c
@@ -1461,6 +1551,13 @@ RsDoPinFunctionDescriptor (
edb6c78
         InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
edb6c78
     }
edb6c78
 
edb6c78
+    /* correct the endian-ness of the values */
edb6c78
+    Tmp16 = Descriptor->PinFunction.PinTableOffset;
edb6c78
+    Descriptor->PinFunction.PinTableOffset = AcpiUtReadUint16(&Tmp16);
edb6c78
+
edb6c78
+    Tmp16 = Descriptor->PinFunction.ResSourceOffset;
edb6c78
+    Descriptor->PinFunction.ResSourceOffset = AcpiUtReadUint16(&Tmp16);
edb6c78
+
edb6c78
     return (Rnode);
edb6c78
 }
edb6c78
 
38a008c
@@ -1494,6 +1591,8 @@ RsDoPinConfigDescriptor (
edb6c78
     UINT32                  CurrentByteOffset;
edb6c78
     UINT32                  PinCount = 0;
edb6c78
     UINT32                  i;
edb6c78
+    UINT16                  Tmp16;
edb6c78
+    UINT32                  Tmp32;
edb6c78
 
edb6c78
     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
edb6c78
     CurrentByteOffset = Info->CurrentByteOffset;
38a008c
@@ -1517,7 +1616,7 @@ RsDoPinConfigDescriptor (
edb6c78
         sizeof (AML_RESOURCE_LARGE_HEADER));
edb6c78
 
edb6c78
     Descriptor = Rnode->Buffer;
edb6c78
-    Descriptor->PinConfig.ResourceLength = DescriptorSize;
edb6c78
+    Descriptor->PinConfig.ResourceLength = AcpiUtReadUint16(&DescriptorSize);
edb6c78
     Descriptor->PinConfig.DescriptorType = ACPI_RESOURCE_NAME_PIN_CONFIG;
edb6c78
     Descriptor->PinConfig.RevisionId = AML_RESOURCE_PIN_CONFIG_REVISION;
edb6c78
 
38a008c
@@ -1571,7 +1670,8 @@ RsDoPinConfigDescriptor (
edb6c78
 
edb6c78
         case 2: /* Pin Config Value [DWORD] (_VAL) */
edb6c78
 
edb6c78
-            Descriptor->PinConfig.PinConfigValue = (UINT32) InitializerOp->Asl.Value.Integer;
edb6c78
+            Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->PinConfig.PinConfigValue = AcpiUtReadUint32(&Tmp32);
edb6c78
             RsCreateDwordField (InitializerOp, ACPI_RESTAG_PINCONFIG_VALUE,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (PinConfig.PinConfigValue));
edb6c78
             break;
38a008c
@@ -1630,7 +1730,8 @@ RsDoPinConfigDescriptor (
edb6c78
              *  (implies resource source must immediately follow the pin list.)
edb6c78
              *  Name: _PIN
edb6c78
              */
edb6c78
-            *PinList = (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+            Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+            *PinList = AcpiUtReadUint16(&Tmp16);
edb6c78
             PinList++;
edb6c78
             PinCount++;
edb6c78
 
38a008c
@@ -1661,6 +1762,16 @@ RsDoPinConfigDescriptor (
edb6c78
         InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
edb6c78
     }
edb6c78
 
edb6c78
+    /* correct the endianness if needed */
edb6c78
+    Tmp16 = Descriptor->PinConfig.PinTableOffset;
edb6c78
+    Descriptor->PinConfig.PinTableOffset = AcpiUtReadUint16(&Tmp16);
edb6c78
+    Tmp16 = Descriptor->PinConfig.ResSourceOffset;
edb6c78
+    Descriptor->PinConfig.ResSourceOffset = AcpiUtReadUint16(&Tmp16);
edb6c78
+    Tmp16 = Descriptor->PinConfig.VendorOffset;
edb6c78
+    Descriptor->PinConfig.VendorOffset = AcpiUtReadUint16(&Tmp16);
edb6c78
+    Tmp16 = Descriptor->PinConfig.VendorLength;
edb6c78
+    Descriptor->PinConfig.VendorLength = AcpiUtReadUint16(&Tmp16);
edb6c78
+
edb6c78
     return (Rnode);
edb6c78
 }
edb6c78
 
38a008c
@@ -1694,6 +1805,7 @@ RsDoPinGroupDescriptor (
edb6c78
     UINT32                  CurrentByteOffset;
edb6c78
     UINT32                  PinCount = 0;
edb6c78
     UINT32                  i;
edb6c78
+    UINT16                  Tmp16;
edb6c78
 
edb6c78
     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
edb6c78
     CurrentByteOffset = Info->CurrentByteOffset;
38a008c
@@ -1717,7 +1829,7 @@ RsDoPinGroupDescriptor (
edb6c78
         sizeof (AML_RESOURCE_LARGE_HEADER));
edb6c78
 
edb6c78
     Descriptor = Rnode->Buffer;
edb6c78
-    Descriptor->PinGroup.ResourceLength = DescriptorSize;
edb6c78
+    Descriptor->PinGroup.ResourceLength = AcpiUtReadUint16(&DescriptorSize);
edb6c78
     Descriptor->PinGroup.DescriptorType = ACPI_RESOURCE_NAME_PIN_GROUP;
edb6c78
     Descriptor->PinGroup.RevisionId = AML_RESOURCE_PIN_GROUP_REVISION;
edb6c78
 
38a008c
@@ -1784,7 +1896,8 @@ RsDoPinGroupDescriptor (
edb6c78
              *  (implies resource source must immediately follow the pin list.)
edb6c78
              *  Name: _PIN
edb6c78
              */
edb6c78
-            *PinList = (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+	    Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+            *PinList = AcpiUtReadUint16(&Tmp16);
edb6c78
             PinList++;
edb6c78
             PinCount++;
edb6c78
 
38a008c
@@ -1815,6 +1928,16 @@ RsDoPinGroupDescriptor (
edb6c78
         InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
edb6c78
     }
edb6c78
 
edb6c78
+    /* correct enddianness as needed */
edb6c78
+    Tmp16 = Descriptor->PinGroup.PinTableOffset;
edb6c78
+    Descriptor->PinGroup.PinTableOffset = AcpiUtReadUint16(&Tmp16);
edb6c78
+    Tmp16 = Descriptor->PinGroup.LabelOffset;
edb6c78
+    Descriptor->PinGroup.LabelOffset = AcpiUtReadUint16(&Tmp16);
edb6c78
+    Tmp16 = Descriptor->PinGroup.VendorOffset;
edb6c78
+    Descriptor->PinGroup.VendorOffset = AcpiUtReadUint16(&Tmp16);
edb6c78
+    Tmp16 = Descriptor->PinGroup.VendorLength;
edb6c78
+    Descriptor->PinGroup.VendorLength = AcpiUtReadUint16(&Tmp16);
edb6c78
+
edb6c78
     return (Rnode);
edb6c78
 }
edb6c78
 
38a008c
@@ -1847,6 +1970,7 @@ RsDoPinGroupFunctionDescriptor (
edb6c78
     UINT16                  DescriptorSize;
edb6c78
     UINT32                  CurrentByteOffset;
edb6c78
     UINT32                  i;
edb6c78
+    UINT16                  Tmp16;
edb6c78
 
edb6c78
     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
edb6c78
     CurrentByteOffset = Info->CurrentByteOffset;
38a008c
@@ -1870,7 +1994,7 @@ RsDoPinGroupFunctionDescriptor (
edb6c78
         sizeof (AML_RESOURCE_LARGE_HEADER));
edb6c78
 
edb6c78
     Descriptor = Rnode->Buffer;
edb6c78
-    Descriptor->PinGroupFunction.ResourceLength = DescriptorSize;
edb6c78
+    Descriptor->PinGroupFunction.ResourceLength = AcpiUtReadUint16(&DescriptorSize);
edb6c78
     Descriptor->PinGroupFunction.DescriptorType = ACPI_RESOURCE_NAME_PIN_GROUP_FUNCTION;
edb6c78
     Descriptor->PinGroupFunction.RevisionId = AML_RESOURCE_PIN_GROUP_FUNCTION_REVISION;
edb6c78
 
38a008c
@@ -1902,7 +2026,8 @@ RsDoPinGroupFunctionDescriptor (
edb6c78
 
edb6c78
         case 1: /* Function Number [WORD] */
edb6c78
 
edb6c78
-            Descriptor->PinGroupFunction.FunctionNumber = (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+            Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->PinGroupFunction.FunctionNumber = AcpiUtReadUint16(&Tmp16);
edb6c78
             RsCreateDwordField (InitializerOp, ACPI_RESTAG_FUNCTION,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (PinGroupFunction.FunctionNumber));
edb6c78
             break;
38a008c
@@ -1961,6 +2086,16 @@ RsDoPinGroupFunctionDescriptor (
edb6c78
         InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
edb6c78
     }
edb6c78
 
edb6c78
+    /* correct enddianness as needed */
edb6c78
+    Tmp16 = Descriptor->PinGroupFunction.ResSourceOffset;
edb6c78
+    Descriptor->PinGroupFunction.ResSourceOffset = AcpiUtReadUint16(&Tmp16);
edb6c78
+    Tmp16 = Descriptor->PinGroupFunction.ResSourceLabelOffset;
edb6c78
+    Descriptor->PinGroupFunction.ResSourceLabelOffset = AcpiUtReadUint16(&Tmp16);
edb6c78
+    Tmp16 = Descriptor->PinGroupFunction.VendorOffset;
edb6c78
+    Descriptor->PinGroupFunction.VendorOffset = AcpiUtReadUint16(&Tmp16);
edb6c78
+    Tmp16 = Descriptor->PinGroupFunction.VendorLength;
edb6c78
+    Descriptor->PinGroupFunction.VendorLength = AcpiUtReadUint16(&Tmp16);
edb6c78
+
edb6c78
     return (Rnode);
edb6c78
 }
edb6c78
 
38a008c
@@ -1993,6 +2128,8 @@ RsDoPinGroupConfigDescriptor (
edb6c78
     UINT16                  DescriptorSize;
edb6c78
     UINT32                  CurrentByteOffset;
edb6c78
     UINT32                  i;
edb6c78
+    UINT16                  Tmp16;
edb6c78
+    UINT32                  Tmp32;
edb6c78
 
edb6c78
     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
edb6c78
     CurrentByteOffset = Info->CurrentByteOffset;
38a008c
@@ -2016,7 +2153,7 @@ RsDoPinGroupConfigDescriptor (
edb6c78
         sizeof (AML_RESOURCE_LARGE_HEADER));
edb6c78
 
edb6c78
     Descriptor = Rnode->Buffer;
edb6c78
-    Descriptor->PinGroupConfig.ResourceLength = DescriptorSize;
edb6c78
+    Descriptor->PinGroupConfig.ResourceLength = AcpiUtReadUint16(&DescriptorSize);
edb6c78
     Descriptor->PinGroupConfig.DescriptorType = ACPI_RESOURCE_NAME_PIN_GROUP_CONFIG;
edb6c78
     Descriptor->PinGroupConfig.RevisionId = AML_RESOURCE_PIN_GROUP_CONFIG_REVISION;
edb6c78
 
38a008c
@@ -2069,7 +2206,8 @@ RsDoPinGroupConfigDescriptor (
edb6c78
 
edb6c78
         case 2: /* Pin Config Value [DWORD] (_VAL) */
edb6c78
 
edb6c78
-            Descriptor->PinGroupConfig.PinConfigValue = (UINT32) InitializerOp->Asl.Value.Integer;
edb6c78
+            Tmp32 = (UINT32) InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->PinGroupConfig.PinConfigValue = AcpiUtReadUint32(&Tmp32);
edb6c78
             RsCreateDwordField (InitializerOp, ACPI_RESTAG_PINCONFIG_VALUE,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (PinGroupConfig.PinConfigValue));
edb6c78
             break;
38a008c
@@ -2130,5 +2268,15 @@ RsDoPinGroupConfigDescriptor (
edb6c78
         InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
edb6c78
     }
edb6c78
 
edb6c78
+    /* correct enddianness as needed */
edb6c78
+    Tmp16 = Descriptor->PinGroupConfig.ResSourceOffset;
edb6c78
+    Descriptor->PinGroupConfig.ResSourceOffset = AcpiUtReadUint16(&Tmp16);
edb6c78
+    Tmp16 = Descriptor->PinGroupConfig.ResSourceLabelOffset;
edb6c78
+    Descriptor->PinGroupConfig.ResSourceLabelOffset = AcpiUtReadUint16(&Tmp16);
edb6c78
+    Tmp16 = Descriptor->PinGroupConfig.VendorOffset;
edb6c78
+    Descriptor->PinGroupConfig.VendorOffset = AcpiUtReadUint16(&Tmp16);
edb6c78
+    Tmp16 = Descriptor->PinGroupConfig.VendorLength;
edb6c78
+    Descriptor->PinGroupConfig.VendorLength = AcpiUtReadUint16(&Tmp16);
edb6c78
+
edb6c78
     return (Rnode);
edb6c78
 }
38a008c
Index: acpica-unix2-20200925/source/compiler/aslrestype2w.c
38a008c
===================================================================
38a008c
--- acpica-unix2-20200925.orig/source/compiler/aslrestype2w.c
38a008c
+++ acpica-unix2-20200925/source/compiler/aslrestype2w.c
38a008c
@@ -84,6 +84,7 @@ RsDoWordIoDescriptor (
edb6c78
     UINT32                  CurrentByteOffset;
edb6c78
     UINT32                  i;
edb6c78
     BOOLEAN                 ResSourceIndex = FALSE;
edb6c78
+    UINT16                  Tmp16;
edb6c78
 
edb6c78
 
edb6c78
     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
38a008c
@@ -147,7 +148,8 @@ RsDoWordIoDescriptor (
edb6c78
 
edb6c78
         case 5: /* Address Granularity */
edb6c78
 
edb6c78
-            Descriptor->Address16.Granularity = (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+	    Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->Address16.Granularity = AcpiUtReadUint16(&Tmp16);
edb6c78
             RsCreateWordField (InitializerOp, ACPI_RESTAG_GRANULARITY,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Granularity));
edb6c78
             GranOp = InitializerOp;
38a008c
@@ -155,7 +157,8 @@ RsDoWordIoDescriptor (
edb6c78
 
edb6c78
         case 6: /* Address Min */
edb6c78
 
edb6c78
-            Descriptor->Address16.Minimum = (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+	    Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->Address16.Minimum = AcpiUtReadUint16(&Tmp16);
edb6c78
             RsCreateWordField (InitializerOp, ACPI_RESTAG_MINADDR,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Minimum));
edb6c78
             MinOp = InitializerOp;
38a008c
@@ -163,7 +166,8 @@ RsDoWordIoDescriptor (
edb6c78
 
edb6c78
         case 7: /* Address Max */
edb6c78
 
edb6c78
-            Descriptor->Address16.Maximum = (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+	    Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->Address16.Maximum = AcpiUtReadUint16(&Tmp16);
edb6c78
             RsCreateWordField (InitializerOp, ACPI_RESTAG_MAXADDR,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Maximum));
edb6c78
             MaxOp = InitializerOp;
38a008c
@@ -171,14 +175,16 @@ RsDoWordIoDescriptor (
edb6c78
 
edb6c78
         case 8: /* Translation Offset */
edb6c78
 
edb6c78
-            Descriptor->Address16.TranslationOffset = (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+	    Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->Address16.TranslationOffset = AcpiUtReadUint16(&Tmp16);
edb6c78
             RsCreateWordField (InitializerOp, ACPI_RESTAG_TRANSLATION,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.TranslationOffset));
edb6c78
             break;
edb6c78
 
edb6c78
         case 9: /* Address Length */
edb6c78
 
edb6c78
-            Descriptor->Address16.AddressLength = (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+	    Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->Address16.AddressLength = AcpiUtReadUint16(&Tmp16);
edb6c78
             RsCreateWordField (InitializerOp, ACPI_RESTAG_LENGTH,
edb6c78
                  CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.AddressLength));
edb6c78
             LengthOp = InitializerOp;
38a008c
@@ -263,13 +269,17 @@ RsDoWordIoDescriptor (
edb6c78
     /* Validate the Min/Max/Len/Gran values */
edb6c78
 
edb6c78
     RsLargeAddressCheck (
edb6c78
-        (UINT64) Descriptor->Address16.Minimum,
edb6c78
-        (UINT64) Descriptor->Address16.Maximum,
edb6c78
-        (UINT64) Descriptor->Address16.AddressLength,
edb6c78
-        (UINT64) Descriptor->Address16.Granularity,
edb6c78
+        (UINT64) AcpiUtReadUint16(&Descriptor->Address16.Minimum),
edb6c78
+        (UINT64) AcpiUtReadUint16(&Descriptor->Address16.Maximum),
edb6c78
+        (UINT64) AcpiUtReadUint16(&Descriptor->Address16.AddressLength),
edb6c78
+        (UINT64) AcpiUtReadUint16(&Descriptor->Address16.Granularity),
edb6c78
         Descriptor->Address16.Flags,
edb6c78
         MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp);
edb6c78
 
edb6c78
+    /* correct enddianness */
edb6c78
+    Tmp16 = Descriptor->Address16.ResourceLength;
edb6c78
+    Descriptor->Address16.ResourceLength = AcpiUtReadUint16(&Tmp16);
edb6c78
+
edb6c78
     Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS16) +
edb6c78
         OptionIndex + StringLength;
edb6c78
     return (Rnode);
38a008c
@@ -305,6 +315,7 @@ RsDoWordBusNumberDescriptor (
edb6c78
     UINT32                  CurrentByteOffset;
edb6c78
     UINT32                  i;
edb6c78
     BOOLEAN                 ResSourceIndex = FALSE;
edb6c78
+    UINT16                  Tmp16;
edb6c78
 
edb6c78
 
edb6c78
     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
38a008c
@@ -361,8 +372,8 @@ RsDoWordBusNumberDescriptor (
edb6c78
 
edb6c78
         case 4: /* Address Granularity */
edb6c78
 
edb6c78
-            Descriptor->Address16.Granularity =
edb6c78
-                (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+            Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->Address16.Granularity = AcpiUtReadUint16(&Tmp16);
edb6c78
             RsCreateWordField (InitializerOp, ACPI_RESTAG_GRANULARITY,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Granularity));
edb6c78
             GranOp = InitializerOp;
38a008c
@@ -370,8 +381,8 @@ RsDoWordBusNumberDescriptor (
edb6c78
 
edb6c78
         case 5: /* Min Address */
edb6c78
 
edb6c78
-            Descriptor->Address16.Minimum =
edb6c78
-                (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+            Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->Address16.Minimum = AcpiUtReadUint16(&Tmp16);
edb6c78
             RsCreateWordField (InitializerOp, ACPI_RESTAG_MINADDR,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Minimum));
edb6c78
             MinOp = InitializerOp;
38a008c
@@ -379,8 +390,8 @@ RsDoWordBusNumberDescriptor (
edb6c78
 
edb6c78
         case 6: /* Max Address */
edb6c78
 
edb6c78
-            Descriptor->Address16.Maximum =
edb6c78
-                (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+            Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->Address16.Maximum = AcpiUtReadUint16(&Tmp16);
edb6c78
             RsCreateWordField (InitializerOp, ACPI_RESTAG_MAXADDR,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Maximum));
edb6c78
             MaxOp = InitializerOp;
38a008c
@@ -388,16 +399,16 @@ RsDoWordBusNumberDescriptor (
edb6c78
 
edb6c78
         case 7: /* Translation Offset */
edb6c78
 
edb6c78
-            Descriptor->Address16.TranslationOffset =
edb6c78
-                (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+            Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->Address16.TranslationOffset = AcpiUtReadUint16(&Tmp16);
edb6c78
             RsCreateWordField (InitializerOp, ACPI_RESTAG_TRANSLATION,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.TranslationOffset));
edb6c78
             break;
edb6c78
 
edb6c78
         case 8: /* Address Length */
edb6c78
 
edb6c78
-            Descriptor->Address16.AddressLength =
edb6c78
-                (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+            Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->Address16.AddressLength = AcpiUtReadUint16(&Tmp16);
edb6c78
             RsCreateWordField (InitializerOp, ACPI_RESTAG_LENGTH,
edb6c78
                  CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.AddressLength));
edb6c78
             LengthOp = InitializerOp;
38a008c
@@ -468,13 +479,17 @@ RsDoWordBusNumberDescriptor (
edb6c78
     /* Validate the Min/Max/Len/Gran values */
edb6c78
 
edb6c78
     RsLargeAddressCheck (
edb6c78
-        (UINT64) Descriptor->Address16.Minimum,
edb6c78
-        (UINT64) Descriptor->Address16.Maximum,
edb6c78
-        (UINT64) Descriptor->Address16.AddressLength,
edb6c78
-        (UINT64) Descriptor->Address16.Granularity,
edb6c78
+        (UINT64) AcpiUtReadUint16(&Descriptor->Address16.Minimum),
edb6c78
+        (UINT64) AcpiUtReadUint16(&Descriptor->Address16.Maximum),
edb6c78
+        (UINT64) AcpiUtReadUint16(&Descriptor->Address16.AddressLength),
edb6c78
+        (UINT64) AcpiUtReadUint16(&Descriptor->Address16.Granularity),
edb6c78
         Descriptor->Address16.Flags,
edb6c78
         MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp);
edb6c78
 
edb6c78
+    /* correct enddianness */
edb6c78
+    Tmp16 = Descriptor->Address16.ResourceLength;
edb6c78
+    Descriptor->Address16.ResourceLength = AcpiUtReadUint16(&Tmp16);
edb6c78
+
edb6c78
     Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS16) +
edb6c78
         OptionIndex + StringLength;
edb6c78
     return (Rnode);
38a008c
@@ -510,6 +525,7 @@ RsDoWordSpaceDescriptor (
edb6c78
     UINT32                  CurrentByteOffset;
edb6c78
     UINT32                  i;
edb6c78
     BOOLEAN                 ResSourceIndex = FALSE;
edb6c78
+    UINT16                  Tmp16;
edb6c78
 
edb6c78
 
edb6c78
     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
38a008c
@@ -577,8 +593,8 @@ RsDoWordSpaceDescriptor (
edb6c78
 
edb6c78
         case 6: /* Address Granularity */
edb6c78
 
edb6c78
-            Descriptor->Address16.Granularity =
edb6c78
-                (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+	    Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->Address16.Granularity = AcpiUtReadUint16(&Tmp16);
edb6c78
             RsCreateWordField (InitializerOp, ACPI_RESTAG_GRANULARITY,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Granularity));
edb6c78
             GranOp = InitializerOp;
38a008c
@@ -586,8 +602,8 @@ RsDoWordSpaceDescriptor (
edb6c78
 
edb6c78
         case 7: /* Min Address */
edb6c78
 
edb6c78
-            Descriptor->Address16.Minimum =
edb6c78
-                (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+	    Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->Address16.Minimum = AcpiUtReadUint16(&Tmp16);
edb6c78
             RsCreateWordField (InitializerOp, ACPI_RESTAG_MINADDR,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Minimum));
edb6c78
             MinOp = InitializerOp;
38a008c
@@ -595,8 +611,8 @@ RsDoWordSpaceDescriptor (
edb6c78
 
edb6c78
         case 8: /* Max Address */
edb6c78
 
edb6c78
-            Descriptor->Address16.Maximum =
edb6c78
-                (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+	    Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->Address16.Maximum = AcpiUtReadUint16(&Tmp16);
edb6c78
             RsCreateWordField (InitializerOp, ACPI_RESTAG_MAXADDR,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Maximum));
edb6c78
             MaxOp = InitializerOp;
38a008c
@@ -604,16 +620,16 @@ RsDoWordSpaceDescriptor (
edb6c78
 
edb6c78
         case 9: /* Translation Offset */
edb6c78
 
edb6c78
-            Descriptor->Address16.TranslationOffset =
edb6c78
-                (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+	    Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->Address16.TranslationOffset = AcpiUtReadUint16(&Tmp16);
edb6c78
             RsCreateWordField (InitializerOp, ACPI_RESTAG_TRANSLATION,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.TranslationOffset));
edb6c78
             break;
edb6c78
 
edb6c78
         case 10: /* Address Length */
edb6c78
 
edb6c78
-            Descriptor->Address16.AddressLength =
edb6c78
-                (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+	    Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
edb6c78
+            Descriptor->Address16.AddressLength = AcpiUtReadUint16(&Tmp16);
edb6c78
             RsCreateWordField (InitializerOp, ACPI_RESTAG_LENGTH,
edb6c78
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.AddressLength));
edb6c78
             LengthOp = InitializerOp;
38a008c
@@ -684,13 +700,17 @@ RsDoWordSpaceDescriptor (
edb6c78
     /* Validate the Min/Max/Len/Gran values */
edb6c78
 
edb6c78
     RsLargeAddressCheck (
edb6c78
-        (UINT64) Descriptor->Address16.Minimum,
edb6c78
-        (UINT64) Descriptor->Address16.Maximum,
edb6c78
-        (UINT64) Descriptor->Address16.AddressLength,
edb6c78
-        (UINT64) Descriptor->Address16.Granularity,
edb6c78
+        (UINT64) AcpiUtReadUint16(&Descriptor->Address16.Minimum),
edb6c78
+        (UINT64) AcpiUtReadUint16(&Descriptor->Address16.Maximum),
edb6c78
+        (UINT64) AcpiUtReadUint16(&Descriptor->Address16.AddressLength),
edb6c78
+        (UINT64) AcpiUtReadUint16(&Descriptor->Address16.Granularity),
edb6c78
         Descriptor->Address16.Flags,
edb6c78
         MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp);
edb6c78
 
edb6c78
+    /* correct enddianness */
edb6c78
+    Tmp16 = Descriptor->Address16.ResourceLength;
edb6c78
+    Descriptor->Address16.ResourceLength = AcpiUtReadUint16(&Tmp16);
edb6c78
+
edb6c78
     Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS16) +
edb6c78
         OptionIndex + StringLength;
edb6c78
     return (Rnode);
38a008c
Index: acpica-unix2-20200925/source/components/disassembler/dmbuffer.c
38a008c
===================================================================
38a008c
--- acpica-unix2-20200925.orig/source/components/disassembler/dmbuffer.c
38a008c
+++ acpica-unix2-20200925/source/components/disassembler/dmbuffer.c
38a008c
@@ -204,7 +204,7 @@ AcpiDmByteList (
edb6c78
 
edb6c78
 
edb6c78
     ByteData = Op->Named.Data;
edb6c78
-    ByteCount = (UINT32) Op->Common.Value.Integer;
edb6c78
+    ByteCount = (UINT32) Op->Common.Value.Size;
edb6c78
 
edb6c78
     /*
edb6c78
      * The byte list belongs to a buffer, and can be produced by either
38a008c
@@ -308,7 +308,7 @@ AcpiDmIsUuidBuffer (
6c29d68
     /* Extract the byte list info */
6c29d68
 
6c29d68
     ByteData = NextOp->Named.Data;
6c29d68
-    ByteCount = (UINT32) NextOp->Common.Value.Integer;
6c29d68
+    ByteCount = (UINT32) NextOp->Common.Value.Size;
6c29d68
 
6c29d68
     /* Byte count must be exactly 16 */
6c29d68
 
38a008c
@@ -436,7 +436,7 @@ AcpiDmIsUnicodeBuffer (
6c29d68
     /* Extract the byte list info */
6c29d68
 
6c29d68
     ByteData = NextOp->Named.Data;
6c29d68
-    ByteCount = (UINT32) NextOp->Common.Value.Integer;
6c29d68
+    ByteCount = (UINT32) NextOp->Common.Value.Size;
6c29d68
     WordCount = ACPI_DIV_2 (ByteCount);
6c29d68
 
6c29d68
     /*
38a008c
@@ -878,14 +878,14 @@ AcpiDmUnicode (
6c29d68
     /* Extract the buffer info as a WORD buffer */
6c29d68
 
6c29d68
     WordData = ACPI_CAST_PTR (UINT16, Op->Named.Data);
6c29d68
-    WordCount = ACPI_DIV_2 (((UINT32) Op->Common.Value.Integer));
6c29d68
+    WordCount = ACPI_DIV_2 (((UINT32) Op->Common.Value.Size));
6c29d68
 
6c29d68
     /* Write every other byte as an ASCII character */
6c29d68
 
6c29d68
     AcpiOsPrintf ("\"");
6c29d68
     for (i = 0; i < (WordCount - 1); i++)
6c29d68
     {
6c29d68
-        OutputValue = (int) WordData[i];
6c29d68
+        OutputValue = (int) AcpiUtReadUint16(&WordData[i]);
6c29d68
 
6c29d68
         /* Handle values that must be escaped */
6c29d68
 
38a008c
Index: acpica-unix2-20200925/source/components/disassembler/dmopcode.c
38a008c
===================================================================
38a008c
--- acpica-unix2-20200925.orig/source/components/disassembler/dmopcode.c
38a008c
+++ acpica-unix2-20200925/source/components/disassembler/dmopcode.c
38a008c
@@ -882,23 +882,23 @@ AcpiDmDisassembleOneOp (
edb6c78
 
edb6c78
     case AML_INT_NAMEDFIELD_OP:
edb6c78
 
edb6c78
-        Length = AcpiDmDumpName (Op->Named.Name);
edb6c78
+        Length = AcpiDmDumpName (AcpiUtReadUint32(&Op->Named.Name));
edb6c78
 
edb6c78
         AcpiOsPrintf (",");
edb6c78
         ASL_CV_PRINT_ONE_COMMENT (Op, AML_NAMECOMMENT, NULL, 0);
edb6c78
         AcpiOsPrintf ("%*.s  %u", (unsigned) (5 - Length), " ",
edb6c78
-            (UINT32) Op->Common.Value.Integer);
edb6c78
+            (UINT32) Op->Common.Value.Size);
edb6c78
 
edb6c78
         AcpiDmCommaIfFieldMember (Op);
edb6c78
 
edb6c78
-        Info->BitOffset += (UINT32) Op->Common.Value.Integer;
edb6c78
+        Info->BitOffset += (UINT32) Op->Common.Value.Size;
edb6c78
         break;
edb6c78
 
edb6c78
     case AML_INT_RESERVEDFIELD_OP:
edb6c78
 
edb6c78
         /* Offset() -- Must account for previous offsets */
edb6c78
 
edb6c78
-        Offset = (UINT32) Op->Common.Value.Integer;
edb6c78
+        Offset = (UINT32) Op->Common.Value.Size;
edb6c78
         Info->BitOffset += Offset;
edb6c78
 
edb6c78
         if (Info->BitOffset % 8 == 0)
38a008c
Index: acpica-unix2-20200925/source/components/disassembler/dmresrc.c
38a008c
===================================================================
38a008c
--- acpica-unix2-20200925.orig/source/components/disassembler/dmresrc.c
38a008c
+++ acpica-unix2-20200925/source/components/disassembler/dmresrc.c
38a008c
@@ -417,7 +417,7 @@ AcpiDmIsResourceTemplate (
edb6c78
         return (AE_TYPE);
edb6c78
     }
edb6c78
 
edb6c78
-    DeclaredBufferLength = NextOp->Common.Value.Size;
edb6c78
+    DeclaredBufferLength = NextOp->Common.Value.Integer;
edb6c78
 
edb6c78
     /* Get the length of the raw initialization byte list */
edb6c78
 
38a008c
Index: acpica-unix2-20200925/source/components/disassembler/dmresrcl.c
38a008c
===================================================================
38a008c
--- acpica-unix2-20200925.orig/source/components/disassembler/dmresrcl.c
38a008c
+++ acpica-unix2-20200925/source/components/disassembler/dmresrcl.c
38a008c
@@ -141,6 +141,8 @@ AcpiDmMemoryFields (
edb6c78
     UINT32                  Level)
edb6c78
 {
edb6c78
     UINT32                  i;
edb6c78
+    UINT16                  Tmp16;
edb6c78
+    UINT32                  Tmp32;
edb6c78
 
edb6c78
 
edb6c78
     for (i = 0; i < 4; i++)
38a008c
@@ -151,14 +153,16 @@ AcpiDmMemoryFields (
edb6c78
         {
edb6c78
         case 16:
edb6c78
 
edb6c78
-            AcpiDmDumpInteger16 (ACPI_CAST_PTR (UINT16, Source)[i],
edb6c78
-                AcpiDmMemoryNames[i]);
edb6c78
+	    Tmp16 = ACPI_CAST_PTR (UINT16, Source)[i];
edb6c78
+            AcpiDmDumpInteger16 (AcpiUtReadUint16(&Tmp16),
edb6c78
+			         AcpiDmMemoryNames[i]);
edb6c78
             break;
edb6c78
 
edb6c78
         case 32:
edb6c78
 
edb6c78
-            AcpiDmDumpInteger32 (ACPI_CAST_PTR (UINT32, Source)[i],
edb6c78
-                AcpiDmMemoryNames[i]);
edb6c78
+	    Tmp32 = ACPI_CAST_PTR (UINT32, Source)[i];
edb6c78
+            AcpiDmDumpInteger32 (AcpiUtReadUint32(&Tmp32),
edb6c78
+			         AcpiDmMemoryNames[i]);
edb6c78
             break;
edb6c78
 
edb6c78
         default:
38a008c
@@ -190,6 +194,9 @@ AcpiDmAddressFields (
edb6c78
     UINT32                  Level)
edb6c78
 {
edb6c78
     UINT32                  i;
edb6c78
+    UINT16                  Tmp16;
edb6c78
+    UINT32                  Tmp32;
edb6c78
+    UINT64                  Tmp64;
edb6c78
 
edb6c78
 
edb6c78
     AcpiOsPrintf ("\n");
38a008c
@@ -202,20 +209,23 @@ AcpiDmAddressFields (
edb6c78
         {
edb6c78
         case 16:
edb6c78
 
edb6c78
-            AcpiDmDumpInteger16 (ACPI_CAST_PTR (UINT16, Source)[i],
edb6c78
-                AcpiDmAddressNames[i]);
edb6c78
+	    Tmp16 = ACPI_CAST_PTR (UINT16, Source)[i];
edb6c78
+            AcpiDmDumpInteger16 (AcpiUtReadUint16(&Tmp16),
edb6c78
+                		 AcpiDmAddressNames[i]);
edb6c78
             break;
edb6c78
 
edb6c78
         case 32:
edb6c78
 
edb6c78
-            AcpiDmDumpInteger32 (ACPI_CAST_PTR (UINT32, Source)[i],
edb6c78
-                AcpiDmAddressNames[i]);
edb6c78
+	    Tmp32 = ACPI_CAST_PTR (UINT32, Source)[i];
edb6c78
+            AcpiDmDumpInteger32 (AcpiUtReadUint32(&Tmp32),
edb6c78
+                		 AcpiDmAddressNames[i]);
edb6c78
             break;
edb6c78
 
edb6c78
         case 64:
edb6c78
 
edb6c78
-            AcpiDmDumpInteger64 (ACPI_CAST_PTR (UINT64, Source)[i],
edb6c78
-                AcpiDmAddressNames[i]);
edb6c78
+	    Tmp64 = ACPI_CAST_PTR (UINT64, Source)[i];
edb6c78
+            AcpiDmDumpInteger64 (AcpiUtReadUint64(&Tmp64),
edb6c78
+                		 AcpiDmAddressNames[i]);
edb6c78
             break;
edb6c78
 
edb6c78
         default:
38a008c
@@ -749,7 +759,7 @@ AcpiDmExtendedDescriptor (
edb6c78
     /* Extra field for this descriptor only */
edb6c78
 
edb6c78
     AcpiDmIndent (Level + 1);
edb6c78
-    AcpiDmDumpInteger64 (Resource->ExtAddress64.TypeSpecific,
edb6c78
+    AcpiDmDumpInteger64 (AcpiUtReadUint64(&Resource->ExtAddress64.TypeSpecific),
edb6c78
         "Type-Specific Attributes");
edb6c78
 
edb6c78
     /* Insert a descriptor name */
38a008c
@@ -876,11 +886,11 @@ AcpiDmFixedMemory32Descriptor (
edb6c78
         AcpiGbl_RwDecode [ACPI_GET_1BIT_FLAG (Resource->FixedMemory32.Flags)]);
edb6c78
 
edb6c78
     AcpiDmIndent (Level + 1);
edb6c78
-    AcpiDmDumpInteger32 (Resource->FixedMemory32.Address,
edb6c78
+    AcpiDmDumpInteger32 (AcpiUtReadUint32(&Resource->FixedMemory32.Address),
edb6c78
         "Address Base");
edb6c78
 
edb6c78
     AcpiDmIndent (Level + 1);
edb6c78
-    AcpiDmDumpInteger32 (Resource->FixedMemory32.AddressLength,
edb6c78
+    AcpiDmDumpInteger32 (AcpiUtReadUint32(&Resource->FixedMemory32.AddressLength),
edb6c78
         "Address Length");
edb6c78
 
edb6c78
     /* Insert a descriptor name */
38a008c
@@ -926,7 +936,8 @@ AcpiDmGenericRegisterDescriptor (
edb6c78
     AcpiDmDumpInteger8 (Resource->GenericReg.BitOffset, "Bit Offset");
edb6c78
 
edb6c78
     AcpiDmIndent (Level + 1);
edb6c78
-    AcpiDmDumpInteger64 (Resource->GenericReg.Address, "Address");
edb6c78
+    AcpiDmDumpInteger64 (AcpiUtReadUint64(&Resource->GenericReg.Address),
edb6c78
+		         "Address");
edb6c78
 
edb6c78
     /* Optional field for ACPI 3.0 */
edb6c78
 
38a008c
@@ -989,7 +1000,7 @@ AcpiDmInterruptDescriptor (
edb6c78
     AcpiDmResourceSource (Resource,
edb6c78
         sizeof (AML_RESOURCE_EXTENDED_IRQ) +
edb6c78
             ((UINT32) Resource->ExtendedIrq.InterruptCount - 1) * sizeof (UINT32),
edb6c78
-        Resource->ExtendedIrq.ResourceLength);
edb6c78
+        AcpiUtReadUint16(&Resource->ExtendedIrq.ResourceLength));
edb6c78
 
edb6c78
     /* Insert a descriptor name */
edb6c78
 
38a008c
@@ -1004,7 +1015,7 @@ AcpiDmInterruptDescriptor (
edb6c78
     {
edb6c78
         AcpiDmIndent (Level + 1);
edb6c78
         AcpiOsPrintf ("0x%8.8X,\n",
edb6c78
-            (UINT32) Resource->ExtendedIrq.Interrupts[i]);
edb6c78
+            AcpiUtReadUint32(&Resource->ExtendedIrq.Interrupts[i]));
edb6c78
     }
edb6c78
 
edb6c78
     AcpiDmIndent (Level);
38a008c
Index: acpica-unix2-20200925/source/components/disassembler/dmresrcl2.c
38a008c
===================================================================
38a008c
--- acpica-unix2-20200925.orig/source/components/disassembler/dmresrcl2.c
38a008c
+++ acpica-unix2-20200925/source/components/disassembler/dmresrcl2.c
38a008c
@@ -191,22 +191,27 @@ AcpiDmGpioCommon (
edb6c78
     char                    *DeviceName = NULL;
edb6c78
     UINT32                  PinCount;
edb6c78
     UINT32                  i;
edb6c78
+    UINT16                  ResSourceOffset;
edb6c78
+    UINT16                  VendorOffset;
edb6c78
+    UINT16                  VendorLength;
6c29d68
+    UINT16                  Tmp16;
edb6c78
 
edb6c78
 
edb6c78
     /* ResourceSource, ResourceSourceIndex, ResourceType */
edb6c78
 
edb6c78
     AcpiDmIndent (Level + 1);
edb6c78
-    if (Resource->Gpio.ResSourceOffset)
edb6c78
+    ResSourceOffset = AcpiUtReadUint16(&Resource->Gpio.ResSourceOffset);
edb6c78
+    if (ResSourceOffset)
edb6c78
     {
edb6c78
         DeviceName = ACPI_ADD_PTR (char,
edb6c78
-            Resource, Resource->Gpio.ResSourceOffset),
edb6c78
+            Resource, ResSourceOffset),
edb6c78
         AcpiUtPrintString (DeviceName, ACPI_UINT16_MAX);
edb6c78
     }
edb6c78
 
6c29d68
     AcpiOsPrintf (", ");
6c29d68
     AcpiOsPrintf ("0x%2.2X, ", Resource->Gpio.ResSourceIndex);
6c29d68
-    AcpiOsPrintf ("%s, ",
6c29d68
-        AcpiGbl_ConsumeDecode [ACPI_GET_1BIT_FLAG (Resource->Gpio.Flags)]);
6c29d68
+    Tmp16 = AcpiUtReadUint16(&Resource->Gpio.Flags);
6c29d68
+    AcpiOsPrintf ("%s, ", AcpiGbl_ConsumeDecode [ACPI_GET_1BIT_FLAG (Tmp16)]);
6c29d68
 
6c29d68
     /* Insert a descriptor name */
6c29d68
 
38a008c
@@ -215,15 +220,15 @@ AcpiDmGpioCommon (
edb6c78
 
edb6c78
     /* Dump the vendor data */
edb6c78
 
edb6c78
-    if (Resource->Gpio.VendorOffset)
edb6c78
+    VendorOffset = AcpiUtReadUint16(&Resource->Gpio.VendorOffset);
edb6c78
+    VendorLength = AcpiUtReadUint16(&Resource->Gpio.VendorLength);
edb6c78
+    if (VendorOffset)
edb6c78
     {
edb6c78
         AcpiOsPrintf ("\n");
edb6c78
         AcpiDmIndent (Level + 1);
edb6c78
-        VendorData = ACPI_ADD_PTR (UINT8, Resource,
edb6c78
-            Resource->Gpio.VendorOffset);
edb6c78
+        VendorData = ACPI_ADD_PTR (UINT8, Resource, VendorOffset);
edb6c78
 
edb6c78
-        AcpiDmDumpRawDataBuffer (VendorData,
edb6c78
-            Resource->Gpio.VendorLength, Level);
edb6c78
+        AcpiDmDumpRawDataBuffer (VendorData, VendorLength, Level);
edb6c78
     }
edb6c78
 
edb6c78
     AcpiOsPrintf (")\n");
38a008c
@@ -233,17 +238,17 @@ AcpiDmGpioCommon (
edb6c78
     AcpiDmIndent (Level + 1);
edb6c78
     AcpiOsPrintf ("{   // Pin list\n");
edb6c78
 
6c29d68
-    PinCount = ((UINT32) (Resource->Gpio.ResSourceOffset -
6c29d68
-        Resource->Gpio.PinTableOffset)) /
6c29d68
-        sizeof (UINT16);
edb6c78
+    PinCount = (UINT32) AcpiUtReadUint16(&Resource->Gpio.ResSourceOffset);
edb6c78
+    PinCount -= (UINT32) AcpiUtReadUint16(&Resource->Gpio.PinTableOffset);
edb6c78
+    PinCount /= sizeof (UINT16);
edb6c78
 
edb6c78
     PinList = (UINT16 *) ACPI_ADD_PTR (char, Resource,
edb6c78
-        Resource->Gpio.PinTableOffset);
edb6c78
+        AcpiUtReadUint16(&Resource->Gpio.PinTableOffset));
edb6c78
 
edb6c78
     for (i = 0; i < PinCount; i++)
edb6c78
     {
edb6c78
         AcpiDmIndent (Level + 2);
edb6c78
-        AcpiOsPrintf ("0x%4.4X%s\n", PinList[i],
edb6c78
+        AcpiOsPrintf ("0x%4.4X%s\n", AcpiUtReadUint16(&(PinList[i])),
edb6c78
             ((i + 1) < PinCount) ? "," : "");
edb6c78
     }
edb6c78
 
38a008c
@@ -277,16 +282,18 @@ AcpiDmGpioIntDescriptor (
6c29d68
     UINT32                  Length,
6c29d68
     UINT32                  Level)
6c29d68
 {
6c29d68
+    UINT16                  Tmp16;
6c29d68
 
6c29d68
     /* Dump the GpioInt-specific portion of the descriptor */
6c29d68
 
6c29d68
     /* EdgeLevel, ActiveLevel, Shared */
6c29d68
 
6c29d68
     AcpiDmIndent (Level);
6c29d68
+    Tmp16 = AcpiUtReadUint16(&Resource->Gpio.IntFlags);
6c29d68
     AcpiOsPrintf ("GpioInt (%s, %s, %s, ",
6c29d68
-        AcpiGbl_HeDecode [ACPI_GET_1BIT_FLAG (Resource->Gpio.IntFlags)],
6c29d68
-        AcpiGbl_LlDecode [ACPI_EXTRACT_2BIT_FLAG (Resource->Gpio.IntFlags, 1)],
6c29d68
-        AcpiGbl_ShrDecode [ACPI_EXTRACT_2BIT_FLAG (Resource->Gpio.IntFlags, 3)]);
6c29d68
+        AcpiGbl_HeDecode [ACPI_GET_1BIT_FLAG (Tmp16)],
6c29d68
+        AcpiGbl_LlDecode [ACPI_EXTRACT_2BIT_FLAG (Tmp16, 1)],
6c29d68
+        AcpiGbl_ShrDecode [ACPI_EXTRACT_2BIT_FLAG (Tmp16, 3)]);
6c29d68
 
6c29d68
     /* PinConfig, DebounceTimeout */
6c29d68
 
38a008c
@@ -299,7 +306,8 @@ AcpiDmGpioIntDescriptor (
edb6c78
     {
edb6c78
         AcpiOsPrintf ("0x%2.2X, ", Resource->Gpio.PinConfig);
edb6c78
     }
edb6c78
-    AcpiOsPrintf ("0x%4.4X,\n", Resource->Gpio.DebounceTimeout);
edb6c78
+    AcpiOsPrintf ("0x%4.4X,\n",
edb6c78
+		  AcpiUtReadUint16(&Resource->Gpio.DebounceTimeout));
edb6c78
 
edb6c78
     /* Dump the GpioInt/GpioIo common portion of the descriptor */
edb6c78
 
38a008c
@@ -329,14 +337,16 @@ AcpiDmGpioIoDescriptor (
6c29d68
     UINT32                  Length,
6c29d68
     UINT32                  Level)
6c29d68
 {
6c29d68
+    UINT16                  Tmp16;
6c29d68
 
6c29d68
     /* Dump the GpioIo-specific portion of the descriptor */
6c29d68
 
6c29d68
     /* Shared, PinConfig */
6c29d68
 
6c29d68
     AcpiDmIndent (Level);
6c29d68
+    Tmp16 = AcpiUtReadUint16(&Resource->Gpio.IntFlags);
6c29d68
     AcpiOsPrintf ("GpioIo (%s, ",
6c29d68
-        AcpiGbl_ShrDecode [ACPI_EXTRACT_2BIT_FLAG (Resource->Gpio.IntFlags, 3)]);
6c29d68
+        AcpiGbl_ShrDecode [ACPI_EXTRACT_2BIT_FLAG (Tmp16, 3)]);
6c29d68
 
6c29d68
     if (Resource->Gpio.PinConfig <= 3)
6c29d68
     {
38a008c
@@ -350,10 +360,10 @@ AcpiDmGpioIoDescriptor (
edb6c78
 
edb6c78
     /* DebounceTimeout, DriveStrength, IoRestriction */
edb6c78
 
edb6c78
-    AcpiOsPrintf ("0x%4.4X, ", Resource->Gpio.DebounceTimeout);
edb6c78
-    AcpiOsPrintf ("0x%4.4X, ", Resource->Gpio.DriveStrength);
6c29d68
-    AcpiOsPrintf ("%s,\n",
6c29d68
-        AcpiGbl_IorDecode [ACPI_GET_2BIT_FLAG (Resource->Gpio.IntFlags)]);
edb6c78
+    AcpiOsPrintf ("0x%4.4X, ", AcpiUtReadUint16(&Resource->Gpio.DebounceTimeout));
edb6c78
+    AcpiOsPrintf ("0x%4.4X, ", AcpiUtReadUint16(&Resource->Gpio.DriveStrength));
6c29d68
+    Tmp16 = AcpiUtReadUint16(&Resource->Gpio.IntFlags);
6c29d68
+    AcpiOsPrintf ("%s,\n", AcpiGbl_IorDecode [ACPI_GET_2BIT_FLAG (Tmp16)]);
6c29d68
 
6c29d68
     /* Dump the GpioInt/GpioIo common portion of the descriptor */
edb6c78
 
38a008c
@@ -434,6 +444,9 @@ AcpiDmPinFunctionDescriptor (
edb6c78
     char                    *DeviceName = NULL;
edb6c78
     UINT32                  PinCount;
edb6c78
     UINT32                  i;
edb6c78
+    UINT16                  ResSourceOffset;
edb6c78
+    UINT16                  VendorOffset;
edb6c78
+    UINT16                  VendorLength;
edb6c78
 
edb6c78
     AcpiDmIndent (Level);
edb6c78
     AcpiOsPrintf ("PinFunction (%s, ",
38a008c
@@ -451,12 +464,14 @@ AcpiDmPinFunctionDescriptor (
edb6c78
 
edb6c78
     /* FunctionNumber */
edb6c78
 
edb6c78
-    AcpiOsPrintf ("0x%4.4X, ", Resource->PinFunction.FunctionNumber);
edb6c78
+    AcpiOsPrintf ("0x%4.4X, ", 
edb6c78
+		  AcpiUtReadUint16(&Resource->PinFunction.FunctionNumber));
edb6c78
 
edb6c78
-    if (Resource->PinFunction.ResSourceOffset)
edb6c78
+    ResSourceOffset = AcpiUtReadUint16(&Resource->PinFunction.ResSourceOffset);
edb6c78
+    if (ResSourceOffset)
edb6c78
     {
edb6c78
         DeviceName = ACPI_ADD_PTR (char,
edb6c78
-            Resource, Resource->PinFunction.ResSourceOffset),
edb6c78
+            Resource, ResSourceOffset),
edb6c78
         AcpiUtPrintString (DeviceName, ACPI_UINT16_MAX);
edb6c78
     }
edb6c78
 
38a008c
@@ -476,15 +491,15 @@ AcpiDmPinFunctionDescriptor (
edb6c78
 
edb6c78
     /* Dump the vendor data */
edb6c78
 
edb6c78
-    if (Resource->PinFunction.VendorLength)
edb6c78
+    VendorOffset = AcpiUtReadUint16(&Resource->PinFunction.VendorOffset);
edb6c78
+    VendorLength = AcpiUtReadUint16(&Resource->PinFunction.VendorLength);
edb6c78
+    if (VendorLength)
edb6c78
     {
edb6c78
         AcpiOsPrintf ("\n");
edb6c78
         AcpiDmIndent (Level + 1);
edb6c78
-        VendorData = ACPI_ADD_PTR (UINT8, Resource,
edb6c78
-            Resource->PinFunction.VendorOffset);
edb6c78
+        VendorData = ACPI_ADD_PTR (UINT8, Resource, VendorOffset);
edb6c78
 
edb6c78
-        AcpiDmDumpRawDataBuffer (VendorData,
edb6c78
-            Resource->PinFunction.VendorLength, Level);
edb6c78
+        AcpiDmDumpRawDataBuffer (VendorData, VendorLength, Level);
edb6c78
     }
edb6c78
 
edb6c78
     AcpiOsPrintf (")\n");
38a008c
@@ -495,17 +510,17 @@ AcpiDmPinFunctionDescriptor (
edb6c78
 
edb6c78
     AcpiOsPrintf ("{   // Pin list\n");
edb6c78
 
edb6c78
-    PinCount = ((UINT32) (Resource->PinFunction.ResSourceOffset -
edb6c78
-        Resource->PinFunction.PinTableOffset)) /
edb6c78
-        sizeof (UINT16);
edb6c78
+    PinCount = AcpiUtReadUint16(&Resource->PinFunction.ResSourceOffset);
edb6c78
+    PinCount -= AcpiUtReadUint16(&Resource->PinFunction.PinTableOffset);
edb6c78
+    PinCount /= sizeof (UINT16);
edb6c78
 
edb6c78
     PinList = (UINT16 *) ACPI_ADD_PTR (char, Resource,
edb6c78
-        Resource->PinFunction.PinTableOffset);
edb6c78
+        AcpiUtReadUint16(&Resource->PinFunction.PinTableOffset));
edb6c78
 
edb6c78
     for (i = 0; i < PinCount; i++)
edb6c78
     {
edb6c78
         AcpiDmIndent (Level + 2);
edb6c78
-        AcpiOsPrintf ("0x%4.4X%s\n", PinList[i],
edb6c78
+        AcpiOsPrintf ("0x%4.4X%s\n", AcpiUtReadUint16(&(PinList[i])),
edb6c78
             ((i + 1) < PinCount) ? "," : "");
edb6c78
     }
edb6c78
 
38a008c
@@ -541,7 +556,8 @@ AcpiDmDumpSerialBusVendorData (
6c29d68
     {
6c29d68
     case AML_RESOURCE_I2C_SERIALBUSTYPE:
6c29d68
 
6c29d68
-        VendorLength = Resource->CommonSerialBus.TypeDataLength -
6c29d68
+        VendorLength = 
6c29d68
+	    AcpiUtReadUint16(&Resource->CommonSerialBus.TypeDataLength) -
6c29d68
             AML_RESOURCE_I2C_MIN_DATA_LEN;
6c29d68
 
6c29d68
         VendorData = ACPI_ADD_PTR (UINT8, Resource,
38a008c
@@ -550,7 +566,8 @@ AcpiDmDumpSerialBusVendorData (
6c29d68
 
6c29d68
     case AML_RESOURCE_SPI_SERIALBUSTYPE:
6c29d68
 
6c29d68
-        VendorLength = Resource->CommonSerialBus.TypeDataLength -
6c29d68
+        VendorLength = 
6c29d68
+	    AcpiUtReadUint16(&Resource->CommonSerialBus.TypeDataLength) -
6c29d68
             AML_RESOURCE_SPI_MIN_DATA_LEN;
6c29d68
 
6c29d68
         VendorData = ACPI_ADD_PTR (UINT8, Resource,
38a008c
@@ -559,7 +576,8 @@ AcpiDmDumpSerialBusVendorData (
6c29d68
 
6c29d68
     case AML_RESOURCE_UART_SERIALBUSTYPE:
6c29d68
 
6c29d68
-        VendorLength = Resource->CommonSerialBus.TypeDataLength -
6c29d68
+        VendorLength = 
6c29d68
+	    AcpiUtReadUint16(&Resource->CommonSerialBus.TypeDataLength) -
6c29d68
             AML_RESOURCE_UART_MIN_DATA_LEN;
6c29d68
 
6c29d68
         VendorData = ACPI_ADD_PTR (UINT8, Resource,
38a008c
@@ -607,9 +625,9 @@ AcpiDmI2cSerialBusDescriptor (
6c29d68
 
6c29d68
     AcpiDmIndent (Level);
6c29d68
     AcpiOsPrintf ("I2cSerialBusV2 (0x%4.4X, %s, 0x%8.8X,\n",
6c29d68
-        Resource->I2cSerialBus.SlaveAddress,
6c29d68
+        AcpiUtReadUint16(&Resource->I2cSerialBus.SlaveAddress),
6c29d68
         AcpiGbl_SmDecode [ACPI_GET_1BIT_FLAG (Resource->I2cSerialBus.Flags)],
6c29d68
-        Resource->I2cSerialBus.ConnectionSpeed);
6c29d68
+        AcpiUtReadUint32(&Resource->I2cSerialBus.ConnectionSpeed));
6c29d68
 
6c29d68
     AcpiDmIndent (Level + 1);
6c29d68
     AcpiOsPrintf ("%s, ",
38a008c
@@ -618,7 +636,7 @@ AcpiDmI2cSerialBusDescriptor (
6c29d68
     /* ResourceSource is a required field */
6c29d68
 
6c29d68
     ResourceSourceOffset = sizeof (AML_RESOURCE_COMMON_SERIALBUS) +
6c29d68
-        Resource->CommonSerialBus.TypeDataLength;
6c29d68
+        AcpiUtReadUint16(&Resource->CommonSerialBus.TypeDataLength);
6c29d68
 
6c29d68
     DeviceName = ACPI_ADD_PTR (char, Resource, ResourceSourceOffset);
6c29d68
     AcpiUtPrintString (DeviceName, ACPI_UINT16_MAX);
38a008c
@@ -675,15 +693,17 @@ AcpiDmSpiSerialBusDescriptor (
6c29d68
 {
6c29d68
     UINT32                  ResourceSourceOffset;
6c29d68
     char                    *DeviceName;
6c29d68
+    UINT16                  Tmp16;
6c29d68
 
6c29d68
 
6c29d68
     /* DeviceSelection, DeviceSelectionPolarity, WireMode, DataBitLength */
6c29d68
 
6c29d68
     AcpiDmIndent (Level);
6c29d68
+    Tmp16 = AcpiUtReadUint16(&Resource->SpiSerialBus.TypeSpecificFlags);
6c29d68
     AcpiOsPrintf ("SpiSerialBusV2 (0x%4.4X, %s, %s, 0x%2.2X,\n",
6c29d68
-        Resource->SpiSerialBus.DeviceSelection,
6c29d68
-        AcpiGbl_DpDecode [ACPI_EXTRACT_1BIT_FLAG (Resource->SpiSerialBus.TypeSpecificFlags, 1)],
6c29d68
-        AcpiGbl_WmDecode [ACPI_GET_1BIT_FLAG (Resource->SpiSerialBus.TypeSpecificFlags)],
6c29d68
+        AcpiUtReadUint16(&Resource->SpiSerialBus.DeviceSelection),
6c29d68
+        AcpiGbl_DpDecode [ACPI_EXTRACT_1BIT_FLAG (Tmp16, 1)],
6c29d68
+        AcpiGbl_WmDecode [ACPI_GET_1BIT_FLAG (Tmp16)],
6c29d68
         Resource->SpiSerialBus.DataBitLength);
6c29d68
 
6c29d68
     /* SlaveMode, ConnectionSpeed, ClockPolarity, ClockPhase */
38a008c
@@ -691,7 +711,7 @@ AcpiDmSpiSerialBusDescriptor (
6c29d68
     AcpiDmIndent (Level + 1);
6c29d68
     AcpiOsPrintf ("%s, 0x%8.8X, %s,\n",
6c29d68
         AcpiGbl_SmDecode [ACPI_GET_1BIT_FLAG (Resource->SpiSerialBus.Flags)],
6c29d68
-        Resource->SpiSerialBus.ConnectionSpeed,
6c29d68
+        AcpiUtReadUint32(&Resource->SpiSerialBus.ConnectionSpeed),
6c29d68
         AcpiGbl_CpoDecode [ACPI_GET_1BIT_FLAG (Resource->SpiSerialBus.ClockPolarity)]);
6c29d68
 
6c29d68
     AcpiDmIndent (Level + 1);
38a008c
@@ -701,7 +721,7 @@ AcpiDmSpiSerialBusDescriptor (
6c29d68
     /* ResourceSource is a required field */
6c29d68
 
6c29d68
     ResourceSourceOffset = sizeof (AML_RESOURCE_COMMON_SERIALBUS) +
6c29d68
-        Resource->CommonSerialBus.TypeDataLength;
6c29d68
+        AcpiUtReadUint16(&Resource->CommonSerialBus.TypeDataLength);
6c29d68
 
6c29d68
     DeviceName = ACPI_ADD_PTR (char, Resource, ResourceSourceOffset);
6c29d68
     AcpiUtPrintString (DeviceName, ACPI_UINT16_MAX);
38a008c
@@ -758,15 +778,17 @@ AcpiDmUartSerialBusDescriptor (
6c29d68
 {
6c29d68
     UINT32                  ResourceSourceOffset;
6c29d68
     char                    *DeviceName;
6c29d68
+    UINT16                  Tmp16;
6c29d68
 
6c29d68
 
6c29d68
     /* ConnectionSpeed, BitsPerByte, StopBits */
6c29d68
 
6c29d68
     AcpiDmIndent (Level);
6c29d68
+    Tmp16 = AcpiUtReadUint16(&Resource->UartSerialBus.TypeSpecificFlags);
6c29d68
     AcpiOsPrintf ("UartSerialBusV2 (0x%8.8X, %s, %s,\n",
6c29d68
-        Resource->UartSerialBus.DefaultBaudRate,
6c29d68
-        AcpiGbl_BpbDecode [ACPI_EXTRACT_3BIT_FLAG (Resource->UartSerialBus.TypeSpecificFlags, 4)],
6c29d68
-        AcpiGbl_SbDecode [ACPI_EXTRACT_2BIT_FLAG (Resource->UartSerialBus.TypeSpecificFlags, 2)]);
6c29d68
+        AcpiUtReadUint32(&Resource->UartSerialBus.DefaultBaudRate),
6c29d68
+        AcpiGbl_BpbDecode [ACPI_EXTRACT_3BIT_FLAG (Tmp16, 4)],
6c29d68
+        AcpiGbl_SbDecode [ACPI_EXTRACT_2BIT_FLAG (Tmp16, 2)]);
6c29d68
 
6c29d68
     /* LinesInUse, IsBigEndian, Parity, FlowControl */
6c29d68
 
38a008c
@@ -781,13 +803,13 @@ AcpiDmUartSerialBusDescriptor (
6c29d68
 
6c29d68
     AcpiDmIndent (Level + 1);
6c29d68
     AcpiOsPrintf ("0x%4.4X, 0x%4.4X, ",
6c29d68
-        Resource->UartSerialBus.RxFifoSize,
6c29d68
-        Resource->UartSerialBus.TxFifoSize);
6c29d68
+        AcpiUtReadUint16(&Resource->UartSerialBus.RxFifoSize),
6c29d68
+        AcpiUtReadUint16(&Resource->UartSerialBus.TxFifoSize));
6c29d68
 
6c29d68
     /* ResourceSource is a required field */
6c29d68
 
6c29d68
     ResourceSourceOffset = sizeof (AML_RESOURCE_COMMON_SERIALBUS) +
6c29d68
-        Resource->CommonSerialBus.TypeDataLength;
6c29d68
+        AcpiUtReadUint16(&Resource->CommonSerialBus.TypeDataLength);
6c29d68
 
6c29d68
     DeviceName = ACPI_ADD_PTR (char, Resource, ResourceSourceOffset);
6c29d68
     AcpiUtPrintString (DeviceName, ACPI_UINT16_MAX);
38a008c
Index: acpica-unix2-20200925/source/components/disassembler/dmresrcs.c
38a008c
===================================================================
38a008c
--- acpica-unix2-20200925.orig/source/components/disassembler/dmresrcs.c
38a008c
+++ acpica-unix2-20200925/source/components/disassembler/dmresrcs.c
38a008c
@@ -93,7 +93,7 @@ AcpiDmIrqDescriptor (
edb6c78
     AcpiOsPrintf (")\n");
edb6c78
 
edb6c78
     AcpiDmIndent (Level + 1);
edb6c78
-    AcpiDmBitList (Resource->Irq.IrqMask);
edb6c78
+    AcpiDmBitList (AcpiUtReadUint16(&Resource->Irq.IrqMask));
edb6c78
 }
edb6c78
 
edb6c78
 
38a008c
@@ -161,8 +161,8 @@ AcpiDmFixedDmaDescriptor (
edb6c78
 
edb6c78
     AcpiDmIndent (Level);
edb6c78
     AcpiOsPrintf ("FixedDMA (0x%4.4X, 0x%4.4X, ",
edb6c78
-        Resource->FixedDma.RequestLines,
edb6c78
-        Resource->FixedDma.Channels);
edb6c78
+        AcpiUtReadUint16(&Resource->FixedDma.RequestLines),
edb6c78
+        AcpiUtReadUint16(&Resource->FixedDma.Channels));
edb6c78
 
edb6c78
     if (Resource->FixedDma.Width <= 5)
edb6c78
     {
38a008c
@@ -210,10 +210,12 @@ AcpiDmIoDescriptor (
edb6c78
         AcpiGbl_IoDecode [ACPI_GET_1BIT_FLAG (Resource->Io.Flags)]);
edb6c78
 
edb6c78
     AcpiDmIndent (Level + 1);
edb6c78
-    AcpiDmDumpInteger16 (Resource->Io.Minimum, "Range Minimum");
edb6c78
+    AcpiDmDumpInteger16 (AcpiUtReadUint16(&Resource->Io.Minimum),
edb6c78
+		         "Range Minimum");
edb6c78
 
edb6c78
     AcpiDmIndent (Level + 1);
edb6c78
-    AcpiDmDumpInteger16 (Resource->Io.Maximum, "Range Maximum");
edb6c78
+    AcpiDmDumpInteger16 (AcpiUtReadUint16(&Resource->Io.Maximum),
edb6c78
+		         "Range Maximum");
edb6c78
 
edb6c78
     AcpiDmIndent (Level + 1);
edb6c78
     AcpiDmDumpInteger8 (Resource->Io.Alignment, "Alignment");
38a008c
@@ -256,10 +258,12 @@ AcpiDmFixedIoDescriptor (
edb6c78
     AcpiOsPrintf ("FixedIO (\n");
edb6c78
 
edb6c78
     AcpiDmIndent (Level + 1);
edb6c78
-    AcpiDmDumpInteger16 (Resource->FixedIo.Address, "Address");
edb6c78
+    AcpiDmDumpInteger16 (AcpiUtReadUint16(&Resource->FixedIo.Address),
edb6c78
+		         "Address");
edb6c78
 
edb6c78
     AcpiDmIndent (Level + 1);
edb6c78
-    AcpiDmDumpInteger8 (Resource->FixedIo.AddressLength, "Length");
edb6c78
+    AcpiDmDumpInteger8 (AcpiUtReadUint16(&Resource->FixedIo.AddressLength),
edb6c78
+			"Length");
edb6c78
 
edb6c78
     /* Insert a descriptor name */
edb6c78
 
38a008c
Index: acpica-unix2-20200925/source/components/disassembler/dmwalk.c
38a008c
===================================================================
38a008c
--- acpica-unix2-20200925.orig/source/components/disassembler/dmwalk.c
38a008c
+++ acpica-unix2-20200925/source/components/disassembler/dmwalk.c
38a008c
@@ -1155,7 +1155,7 @@ AcpiDmAscendingOp (
6c29d68
         {
6c29d68
             ParentOp->Common.DisasmFlags |= ACPI_PARSEOP_EMPTY_TERMLIST;
6c29d68
             ASL_CV_CLOSE_PAREN (Op, Level);
6c29d68
-            AcpiOsPrintf ("{");
6c29d68
+            AcpiOsPrintf (" {");
6c29d68
         }
6c29d68
     }
6c29d68
 
38a008c
Index: acpica-unix2-20200925/source/components/dispatcher/dsfield.c
38a008c
===================================================================
38a008c
--- acpica-unix2-20200925.orig/source/components/dispatcher/dsfield.c
38a008c
+++ acpica-unix2-20200925/source/components/dispatcher/dsfield.c
38a008c
@@ -336,6 +336,8 @@ AcpiDsGetFieldNames (
edb6c78
     char                    *NamePath;
edb6c78
 #endif
edb6c78
 
edb6c78
+    char                    TmpName[ACPI_NAMESEG_SIZE+1];
edb6c78
+
edb6c78
 
edb6c78
     ACPI_FUNCTION_TRACE_PTR (DsGetFieldNames, Info);
edb6c78
 
38a008c
@@ -442,14 +444,17 @@ AcpiDsGetFieldNames (
edb6c78
 
edb6c78
             /* Lookup the name, it should already exist */
edb6c78
 
edb6c78
+	    memset(TmpName, 0, ACPI_NAMESEG_SIZE+1);
edb6c78
+	    AcpiUtWriteUint(TmpName, ACPI_NAMESEG_SIZE,
edb6c78
+			    &Arg->Named.Name, ACPI_NAMESEG_SIZE);
edb6c78
             Status = AcpiNsLookup (WalkState->ScopeInfo,
edb6c78
-                (char *) &Arg->Named.Name, Info->FieldType,
edb6c78
+                TmpName, Info->FieldType,
edb6c78
                 ACPI_IMODE_EXECUTE, ACPI_NS_DONT_OPEN_SCOPE,
edb6c78
                 WalkState, &Info->FieldNode);
edb6c78
             if (ACPI_FAILURE (Status))
edb6c78
             {
edb6c78
                 ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo,
edb6c78
-                    (char *) &Arg->Named.Name, Status);
edb6c78
+                    TmpName, Status);
edb6c78
                 return_ACPI_STATUS (Status);
edb6c78
             }
edb6c78
             else
38a008c
@@ -703,8 +708,13 @@ AcpiDsInitFieldObjects (
edb6c78
          */
edb6c78
         if (Arg->Common.AmlOpcode == AML_INT_NAMEDFIELD_OP)
edb6c78
         {
edb6c78
+	    char Tmp[ACPI_NAMESEG_SIZE+1];
edb6c78
+
edb6c78
+	    memset(&Tmp, 0, ACPI_NAMESEG_SIZE+1);
edb6c78
+	    AcpiUtWriteUint(&Tmp, ACPI_NAMESEG_SIZE,
edb6c78
+			    &Arg->Named.Name, ACPI_NAMESEG_SIZE);
edb6c78
             Status = AcpiNsLookup (WalkState->ScopeInfo,
edb6c78
-                (char *) &Arg->Named.Name, Type, ACPI_IMODE_LOAD_PASS1,
edb6c78
+                Tmp, Type, ACPI_IMODE_LOAD_PASS1,
edb6c78
                 Flags, WalkState, &Node);
edb6c78
             if (ACPI_FAILURE (Status))
edb6c78
             {
38a008c
Index: acpica-unix2-20200925/source/components/namespace/nsaccess.c
38a008c
===================================================================
38a008c
--- acpica-unix2-20200925.orig/source/components/namespace/nsaccess.c
38a008c
+++ acpica-unix2-20200925/source/components/namespace/nsaccess.c
38a008c
@@ -645,7 +645,7 @@ AcpiNsLookup (
edb6c78
 
edb6c78
         /* Extract one ACPI name from the front of the pathname */
edb6c78
 
edb6c78
-        ACPI_MOVE_32_TO_32 (&SimpleName, Path);
edb6c78
+        ACPI_COPY_NAMESEG (&SimpleName, Path);
edb6c78
 
edb6c78
         /* Try to find the single (4 character) ACPI name */
edb6c78
 
38a008c
Index: acpica-unix2-20200925/source/components/namespace/nsnames.c
38a008c
===================================================================
38a008c
--- acpica-unix2-20200925.orig/source/components/namespace/nsnames.c
38a008c
+++ acpica-unix2-20200925/source/components/namespace/nsnames.c
38a008c
@@ -300,7 +300,7 @@ AcpiNsBuildNormalizedPath (
edb6c78
             ACPI_PATH_PUT8(FullPath, PathSize, AML_DUAL_NAME_PREFIX, Length);
edb6c78
         }
edb6c78
 
edb6c78
-        ACPI_MOVE_32_TO_32 (Name, &NextNode->Name);
edb6c78
+        ACPI_COPY_NAMESEG (Name, &NextNode->Name);
edb6c78
         DoNoTrailing = NoTrailing;
edb6c78
         for (i = 0; i < 4; i++)
edb6c78
         {
38a008c
Index: acpica-unix2-20200925/source/components/namespace/nsparse.c
38a008c
===================================================================
38a008c
--- acpica-unix2-20200925.orig/source/components/namespace/nsparse.c
38a008c
+++ acpica-unix2-20200925/source/components/namespace/nsparse.c
38a008c
@@ -203,6 +203,7 @@ AcpiNsOneCompleteParse (
edb6c78
     ACPI_WALK_STATE         *WalkState;
edb6c78
     ACPI_TABLE_HEADER       *Table;
edb6c78
     ACPI_OWNER_ID           OwnerId;
edb6c78
+    UINT32                  TableLength;
edb6c78
 
edb6c78
 
edb6c78
     ACPI_FUNCTION_TRACE (NsOneCompleteParse);
38a008c
@@ -216,13 +217,14 @@ AcpiNsOneCompleteParse (
edb6c78
 
edb6c78
     /* Table must consist of at least a complete header */
edb6c78
 
edb6c78
-    if (Table->Length < sizeof (ACPI_TABLE_HEADER))
edb6c78
+    TableLength = AcpiUtReadUint32(&Table->Length);
edb6c78
+    if (TableLength < sizeof (ACPI_TABLE_HEADER))
edb6c78
     {
edb6c78
         return_ACPI_STATUS (AE_BAD_HEADER);
edb6c78
     }
edb6c78
 
edb6c78
     AmlStart = (UINT8 *) Table + sizeof (ACPI_TABLE_HEADER);
edb6c78
-    AmlLength = Table->Length - sizeof (ACPI_TABLE_HEADER);
edb6c78
+    AmlLength = TableLength - sizeof (ACPI_TABLE_HEADER);
edb6c78
 
edb6c78
     Status = AcpiTbGetOwnerId (TableIndex, &OwnerId);
edb6c78
     if (ACPI_FAILURE (Status))
38a008c
Index: acpica-unix2-20200925/source/components/namespace/nsutils.c
38a008c
===================================================================
38a008c
--- acpica-unix2-20200925.orig/source/components/namespace/nsutils.c
38a008c
+++ acpica-unix2-20200925/source/components/namespace/nsutils.c
38a008c
@@ -272,7 +272,6 @@ AcpiNsBuildInternalName (
edb6c78
     const char              *ExternalName = Info->NextExternalChar;
edb6c78
     char                    *Result = NULL;
edb6c78
     UINT32                  i;
edb6c78
-    char		    TmpSeg[ACPI_NAMESEG_SIZE+1];
edb6c78
 
edb6c78
 
edb6c78
     ACPI_FUNCTION_TRACE (NsBuildInternalName);
38a008c
@@ -336,7 +335,6 @@ AcpiNsBuildInternalName (
edb6c78
 
edb6c78
     for (; NumSegments; NumSegments--)
edb6c78
     {
edb6c78
-        memset(TmpSeg, 0, ACPI_NAMESEG_SIZE+1);
edb6c78
         for (i = 0; i < ACPI_NAMESEG_SIZE; i++)
edb6c78
         {
edb6c78
             if (ACPI_IS_PATH_SEPARATOR (*ExternalName) ||
38a008c
@@ -344,17 +342,16 @@ AcpiNsBuildInternalName (
edb6c78
             {
edb6c78
                 /* Pad the segment with underscore(s) if segment is short */
edb6c78
 
edb6c78
-                TmpSeg[i] = '_';
edb6c78
+                Result[i] = '_';
edb6c78
             }
edb6c78
             else
edb6c78
             {
edb6c78
                 /* Convert the character to uppercase and save it */
edb6c78
 
edb6c78
-                TmpSeg[i] = (char) toupper ((int) *ExternalName);
edb6c78
+                Result[i] = (char) toupper ((int) *ExternalName);
edb6c78
                 ExternalName++;
edb6c78
             }
edb6c78
         }
edb6c78
-	AcpiUtWriteUint(Result, ACPI_NAMESEG_SIZE, TmpSeg, ACPI_NAMESEG_SIZE);
edb6c78
 
edb6c78
         /* Now we must have a path separator, or the pathname is bad */
edb6c78