Al Stone 99adb1
Subject: [RFC PATCH] Avoid all Linux /dev/mem accesses when -c is specified
Al Stone 99adb1
From: Roy Franz <roy.franz@linaro.org>
Al Stone 99adb1
Date: 05/15/2015 12:50 PM
Al Stone 99adb1
To: linaro-uefi@lists.linaro.org, linaro-acpi@lists.linaro.org, graeme.gregory@linaro.org, al.stone@linaro.org
Al Stone 99adb1
CC: Roy Franz <roy.franz@linaro.org>
Al Stone 99adb1
Al Stone 99adb1
Don't try to read the RSDP structure or RSDT/XSDT tables
Al Stone 99adb1
from memory with the -c option.  These are now provided
Al Stone 99adb1
as files in /sysfs, and this allows acpidump to function
Al Stone 99adb1
when /dev/mem is not available, which will be the case
Al Stone 99adb1
for Aarch64 servers.
Al Stone 99adb1
Al Stone 99adb1
Signed-off-by: Roy Franz <roy.franz@linaro.org>
Al Stone 99adb1
---
Al Stone 99adb1
 source/os_specific/service_layers/oslinuxtbl.c | 87 +++++++++++++-------------
Al Stone 99adb1
 1 file changed, 43 insertions(+), 44 deletions(-)
Al Stone 99adb1
Al Stone 99adb1
Index: acpica-unix/source/os_specific/service_layers/oslinuxtbl.c
Al Stone 99adb1
===================================================================
Al Stone 99adb1
--- acpica-unix.orig/source/os_specific/service_layers/oslinuxtbl.c
Al Stone 99adb1
+++ acpica-unix/source/os_specific/service_layers/oslinuxtbl.c
Al Stone 99adb1
@@ -686,70 +686,69 @@ OslTableInitialize (
Al Stone 99adb1
         return (AE_OK);
Al Stone 99adb1
     }
Al Stone 99adb1
 
Al Stone 99adb1
+    if (!Gbl_DumpCustomizedTables)
Al Stone 99adb1
+    {
Al Stone 99adb1
     /* Get RSDP from memory */
Al Stone 99adb1
 
Al Stone 99adb1
-    Status = OslLoadRsdp ();
Al Stone 99adb1
-    if (ACPI_FAILURE (Status))
Al Stone 99adb1
-    {
Al Stone 99adb1
-        return (Status);
Al Stone 99adb1
-    }
Al Stone 99adb1
+        Status = OslLoadRsdp ();
Al Stone 99adb1
+        if (ACPI_FAILURE (Status))
Al Stone 99adb1
+        {
Al Stone 99adb1
+            return (Status);
Al Stone 99adb1
+        }
Al Stone 99adb1
 
Al Stone 99adb1
-    /* Get XSDT from memory */
Al Stone 99adb1
+        /* Get XSDT from memory */
Al Stone 99adb1
 
Al Stone 99adb1
-    if (Gbl_Rsdp.Revision && !Gbl_DoNotDumpXsdt)
Al Stone 99adb1
-    {
Al Stone 99adb1
-        if (Gbl_Xsdt)
Al Stone 99adb1
+        if (Gbl_Rsdp.Revision && !Gbl_DoNotDumpXsdt)
Al Stone 99adb1
         {
Al Stone 99adb1
-            free (Gbl_Xsdt);
Al Stone 99adb1
-            Gbl_Xsdt = NULL;
Al Stone 99adb1
+            if (Gbl_Xsdt)
Al Stone 99adb1
+            {
Al Stone 99adb1
+                free (Gbl_Xsdt);
Al Stone 99adb1
+                Gbl_Xsdt = NULL;
Al Stone 99adb1
+            }
Al Stone 99adb1
+
Al Stone 99adb1
+            Gbl_Revision = 2;
Al Stone 99adb1
+            Status = OslGetBiosTable (ACPI_SIG_XSDT, 0,
Al Stone 99adb1
+                ACPI_CAST_PTR (ACPI_TABLE_HEADER *, &Gbl_Xsdt), &Address);
Al Stone 99adb1
+            if (ACPI_FAILURE (Status))
Al Stone 99adb1
+            {
Al Stone 99adb1
+                return (Status);
Al Stone 99adb1
+            }
Al Stone 99adb1
         }
Al Stone 99adb1
 
Al Stone 99adb1
-        Gbl_Revision = 2;
Al Stone 99adb1
-        Status = OslGetBiosTable (ACPI_SIG_XSDT, 0,
Al Stone 99adb1
-            ACPI_CAST_PTR (ACPI_TABLE_HEADER *, &Gbl_Xsdt), &Address);
Al Stone 99adb1
-        if (ACPI_FAILURE (Status))
Al Stone 99adb1
+        /* Get RSDT from memory */
Al Stone 99adb1
+
Al Stone 99adb1
+        if (Gbl_Rsdp.RsdtPhysicalAddress)
Al Stone 99adb1
         {
Al Stone 99adb1
-            return (Status);
Al Stone 99adb1
+            if (Gbl_Rsdt)
Al Stone 99adb1
+            {
Al Stone 99adb1
+                free (Gbl_Rsdt);
Al Stone 99adb1
+                Gbl_Rsdt = NULL;
Al Stone 99adb1
+            }
Al Stone 99adb1
+
Al Stone 99adb1
+            Status = OslGetBiosTable (ACPI_SIG_RSDT, 0,
Al Stone 99adb1
+                ACPI_CAST_PTR (ACPI_TABLE_HEADER *, &Gbl_Rsdt), &Address);
Al Stone 99adb1
+            if (ACPI_FAILURE (Status))
Al Stone 99adb1
+            {
Al Stone 99adb1
+                return (Status);
Al Stone 99adb1
+            }
Al Stone 99adb1
         }
Al Stone 99adb1
-    }
Al Stone 99adb1
 
Al Stone 99adb1
-    /* Get RSDT from memory */
Al Stone 99adb1
+        /* Get FADT from memory */
Al Stone 99adb1
 
Al Stone 99adb1
-    if (Gbl_Rsdp.RsdtPhysicalAddress)
Al Stone 99adb1
-    {
Al Stone 99adb1
-        if (Gbl_Rsdt)
Al Stone 99adb1
+        if (Gbl_Fadt)
Al Stone 99adb1
         {
Al Stone 99adb1
-            free (Gbl_Rsdt);
Al Stone 99adb1
-            Gbl_Rsdt = NULL;
Al Stone 99adb1
+            free (Gbl_Fadt);
Al Stone 99adb1
+            Gbl_Fadt = NULL;
Al Stone 99adb1
         }
Al Stone 99adb1
 
Al Stone 99adb1
-        Status = OslGetBiosTable (ACPI_SIG_RSDT, 0,
Al Stone 99adb1
-            ACPI_CAST_PTR (ACPI_TABLE_HEADER *, &Gbl_Rsdt), &Address);
Al Stone 99adb1
+        Status = OslGetBiosTable (ACPI_SIG_FADT, 0,
Al Stone 99adb1
+            ACPI_CAST_PTR (ACPI_TABLE_HEADER *, &Gbl_Fadt), &Gbl_FadtAddress);
Al Stone 99adb1
         if (ACPI_FAILURE (Status))
Al Stone 99adb1
         {
Al Stone 99adb1
             return (Status);
Al Stone 99adb1
         }
Al Stone 99adb1
-    }
Al Stone 99adb1
-
Al Stone 99adb1
-    /* Get FADT from memory */
Al Stone 99adb1
-
Al Stone 99adb1
-    if (Gbl_Fadt)
Al Stone 99adb1
-    {
Al Stone 99adb1
-        free (Gbl_Fadt);
Al Stone 99adb1
-        Gbl_Fadt = NULL;
Al Stone 99adb1
-    }
Al Stone 99adb1
 
Al Stone 99adb1
-    Status = OslGetBiosTable (ACPI_SIG_FADT, 0,
Al Stone 99adb1
-        ACPI_CAST_PTR (ACPI_TABLE_HEADER *, &Gbl_Fadt), &Gbl_FadtAddress);
Al Stone 99adb1
-    if (ACPI_FAILURE (Status))
Al Stone 99adb1
-    {
Al Stone 99adb1
-        return (Status);
Al Stone 99adb1
-    }
Al Stone 99adb1
-
Al Stone 99adb1
-    if (!Gbl_DumpCustomizedTables)
Al Stone 99adb1
-    {
Al Stone 99adb1
         /* Add mandatory tables to global table list first */
Al Stone 99adb1
-
Al Stone 99adb1
         Status = OslAddTableToList (ACPI_RSDP_NAME, 0);
Al Stone 99adb1
         if (ACPI_FAILURE (Status))
Al Stone 99adb1
         {