]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmPlatformPkg/Scripts/Ds5/system_table.py
ARM Packages: Removed trailing spaces
[mirror_edk2.git] / ArmPlatformPkg / Scripts / Ds5 / system_table.py
index 8dec591e63cc7cd1ddf6a7bf1ad5389ebc30c5d1..0a14f8083098c3eafbf41272bc1bf6f0b3546567 100644 (file)
@@ -1,13 +1,13 @@
 #\r
-#  Copyright (c) 2011-2012, ARM Limited. All rights reserved.\r
-#  \r
-#  This program and the accompanying materials                          \r
-#  are licensed and made available under the terms and conditions of the BSD License         \r
-#  which accompanies this distribution.  The full text of the license may be found at        \r
-#  http://opensource.org/licenses/bsd-license.php                                            \r
+#  Copyright (c) 2011-2013, ARM Limited. All rights reserved.\r
 #\r
-#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+#  This program and the accompanying materials\r
+#  are licensed and made available under the terms and conditions of the BSD License\r
+#  which accompanies this distribution.  The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php\r
+#\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 #\r
 \r
 from arm_ds.debugger_v1 import DebugException\r
@@ -19,45 +19,67 @@ import firmware_volume
 \r
 class DebugInfoTable:\r
     CONST_DEBUG_INFO_TABLE_GUID = ( 0x49152E77L, 0x47641ADAL, 0xFE7AA2B7L, 0x8B5ED9FEL)\r
-    \r
+\r
     DebugInfos = []\r
-    \r
+\r
     def __init__(self, ec, debug_info_table_header_offset):\r
         self.ec = ec\r
         self.base = debug_info_table_header_offset\r
-        \r
+\r
     def get_debug_info(self):\r
+        # Get the information from EFI_DEBUG_IMAGE_INFO_TABLE_HEADER\r
         count = self.ec.getMemoryService().readMemory32(self.base + 0x4)\r
-        debug_info_table_base = self.ec.getMemoryService().readMemory32(self.base + 0x8)\r
-        \r
+        if edk2_debugger.is_aarch64(self.ec):\r
+            debug_info_table_base = self.ec.getMemoryService().readMemory64(self.base + 0x8)\r
+        else:\r
+            debug_info_table_base = self.ec.getMemoryService().readMemory32(self.base + 0x8)\r
+\r
         self.DebugInfos = []\r
-        \r
+\r
         for i in range(0, count):\r
             # Get the address of the structure EFI_DEBUG_IMAGE_INFO\r
-            debug_info = self.ec.getMemoryService().readMemory32(debug_info_table_base + (i * 4))\r
+            if edk2_debugger.is_aarch64(self.ec):\r
+                debug_info = self.ec.getMemoryService().readMemory64(debug_info_table_base + (i * 8))\r
+            else:\r
+                debug_info = self.ec.getMemoryService().readMemory32(debug_info_table_base + (i * 4))\r
+\r
             if debug_info:\r
                 debug_info_type = self.ec.getMemoryService().readMemory32(debug_info)\r
                 # Normal Debug Info Type\r
                 if debug_info_type == 1:\r
-                    # Get the base address of the structure EFI_LOADED_IMAGE_PROTOCOL\r
-                    loaded_image_protocol = self.ec.getMemoryService().readMemory32(debug_info + 0x4)\r
-                    \r
-                    image_base = self.ec.getMemoryService().readMemory32(loaded_image_protocol + 0x20)\r
-                    image_size = self.ec.getMemoryService().readMemory32(loaded_image_protocol + 0x28)\r
-                    \r
+                    if edk2_debugger.is_aarch64(self.ec):\r
+                        # Get the base address of the structure EFI_LOADED_IMAGE_PROTOCOL\r
+                        loaded_image_protocol = self.ec.getMemoryService().readMemory64(debug_info + 0x8)\r
+\r
+                        image_base = self.ec.getMemoryService().readMemory64(loaded_image_protocol + 0x40)\r
+                        image_size = self.ec.getMemoryService().readMemory32(loaded_image_protocol + 0x48)\r
+                    else:\r
+                        # Get the base address of the structure EFI_LOADED_IMAGE_PROTOCOL\r
+                        loaded_image_protocol = self.ec.getMemoryService().readMemory32(debug_info + 0x4)\r
+\r
+                        image_base = self.ec.getMemoryService().readMemory32(loaded_image_protocol + 0x20)\r
+                        image_size = self.ec.getMemoryService().readMemory32(loaded_image_protocol + 0x28)\r
+\r
                     self.DebugInfos.append((image_base,image_size))\r
-    \r
+\r
     # Return (base, size)\r
-    def load_symbols_at(self, addr):\r
+    def load_symbols_at(self, addr, verbose = False):\r
         if self.DebugInfos == []:\r
             self.get_debug_info()\r
-        \r
+\r
         found = False\r
         for debug_info in self.DebugInfos:\r
             if (addr >= debug_info[0]) and (addr < debug_info[0] + debug_info[1]):\r
-                section = firmware_volume.EfiSectionPE32(self.ec, debug_info[0])\r
-                \r
-                edk2_debugger.load_symbol_from_file(self.ec, section.get_debug_filepath(), section.get_debug_elfbase())\r
+                if edk2_debugger.is_aarch64(self.ec):\r
+                    section = firmware_volume.EfiSectionPE64(self.ec, debug_info[0])\r
+                else:\r
+                    section = firmware_volume.EfiSectionPE32(self.ec, debug_info[0])\r
+\r
+                try:\r
+                    edk2_debugger.load_symbol_from_file(self.ec, section.get_debug_filepath(), section.get_debug_elfbase(), verbose)\r
+                except Exception, (ErrorClass, ErrorMessage):\r
+                    if verbose:\r
+                        print "Error while loading a symbol file (%s: %s)" % (ErrorClass, ErrorMessage)\r
 \r
                 found = True\r
                 return debug_info\r
@@ -65,39 +87,49 @@ class DebugInfoTable:
         if found == False:\r
             raise Exception('DebugInfoTable','No symbol found at 0x%x' % addr)\r
 \r
-    def load_all_symbols(self):\r
+    def load_all_symbols(self, verbose = False):\r
         if self.DebugInfos == []:\r
             self.get_debug_info()\r
-        \r
+\r
         for debug_info in self.DebugInfos:\r
-            section = firmware_volume.EfiSectionPE32(self.ec, debug_info[0])\r
-           \r
-            edk2_debugger.load_symbol_from_file(self.ec, section.get_debug_filepath(), section.get_debug_elfbase())\r
+            if edk2_debugger.is_aarch64(self.ec):\r
+                section = firmware_volume.EfiSectionPE64(self.ec, debug_info[0])\r
+            else:\r
+                section = firmware_volume.EfiSectionPE32(self.ec, debug_info[0])\r
+\r
+            try:\r
+                edk2_debugger.load_symbol_from_file(self.ec, section.get_debug_filepath(), section.get_debug_elfbase(), verbose)\r
+            except Exception, (ErrorClass, ErrorMessage):\r
+                if verbose:\r
+                    print "Error while loading a symbol file (%s: %s)" % (ErrorClass, ErrorMessage)\r
 \r
     def dump(self):\r
         self.get_debug_info()\r
         for debug_info in self.DebugInfos:\r
             base_pe32 = debug_info[0]\r
-            section = firmware_volume.EfiSectionPE32(self.ec, base_pe32)\r
+            if edk2_debugger.is_aarch64(self.ec):\r
+                section = firmware_volume.EfiSectionPE64(self.ec, base_pe32)\r
+            else:\r
+                section = firmware_volume.EfiSectionPE32(self.ec, base_pe32)\r
             print section.get_debug_filepath()\r
-        \r
+\r
 class SystemTable:\r
     CONST_ST_SIGNATURE = ('I','B','I',' ','S','Y','S','T')\r
-    \r
+\r
     def __init__(self, ec, membase, memsize):\r
         self.membase = membase\r
         self.memsize = memsize\r
         self.ec = ec\r
-        \r
+\r
         found = False\r
-        \r
+\r
         # Start from the top of the memory\r
         offset = self.membase + self.memsize\r
         # Align to highest 4MB boundary\r
         offset = offset & ~0x3FFFFF\r
         # We should not have a System Table at the top of the System Memory\r
         offset = offset - 0x400000\r
-        \r
+\r
         # Start at top and look on 4MB boundaries for system table ptr structure\r
         while offset > self.membase:\r
             try:\r
@@ -106,24 +138,40 @@ class SystemTable:
                 raise Exception('SystemTable','Fail to access System Memory. Ensure all the memory in the region [0x%x;0x%X] is accessible.' % (membase,membase+memsize))\r
             if signature == SystemTable.CONST_ST_SIGNATURE:\r
                 found = True\r
-                self.system_table_base = self.ec.getMemoryService().readMemory32(offset + 0x8)\r
+                if edk2_debugger.is_aarch64(self.ec):\r
+                    self.system_table_base = self.ec.getMemoryService().readMemory64(offset + 0x8)\r
+                else:\r
+                    self.system_table_base = self.ec.getMemoryService().readMemory32(offset + 0x8)\r
                 break\r
             offset = offset - 0x400000\r
-            \r
+\r
         if not found:\r
             raise Exception('SystemTable','System Table not found in System Memory [0x%x;0x%X]' % (membase,membase+memsize))\r
-        \r
+\r
     def get_configuration_table(self, conf_table_guid):\r
-        # Number of configuration Table entry\r
-        conf_table_entry_count = self.ec.getMemoryService().readMemory32(self.system_table_base + 0x40)\r
-        \r
-        # Get location of the Configuration Table entries\r
-        conf_table_offset = self.ec.getMemoryService().readMemory32(self.system_table_base + 0x44)\r
-        \r
+        if edk2_debugger.is_aarch64(self.ec):\r
+            # Number of configuration Table entry\r
+            conf_table_entry_count = self.ec.getMemoryService().readMemory32(self.system_table_base + 0x68)\r
+\r
+            # Get location of the Configuration Table entries\r
+            conf_table_offset = self.ec.getMemoryService().readMemory64(self.system_table_base + 0x70)\r
+        else:\r
+            # Number of configuration Table entry\r
+            conf_table_entry_count = self.ec.getMemoryService().readMemory32(self.system_table_base + 0x40)\r
+\r
+            # Get location of the Configuration Table entries\r
+            conf_table_offset = self.ec.getMemoryService().readMemory32(self.system_table_base + 0x44)\r
+\r
         for i in range(0, conf_table_entry_count):\r
-            offset = conf_table_offset + (i * 0x14)\r
+            if edk2_debugger.is_aarch64(self.ec):\r
+                offset = conf_table_offset + (i * 0x18)\r
+            else:\r
+                offset = conf_table_offset + (i * 0x14)\r
             guid = struct.unpack("<IIII", self.ec.getMemoryService().read(str(offset), 16, 32))\r
             if guid == conf_table_guid:\r
-                return self.ec.getMemoryService().readMemory32(offset + 0x10)\r
-            \r
+                if edk2_debugger.is_aarch64(self.ec):\r
+                    return self.ec.getMemoryService().readMemory64(offset + 0x10)\r
+                else:\r
+                    return self.ec.getMemoryService().readMemory32(offset + 0x10)\r
+\r
         raise Exception('SystemTable','Configuration Table not found')\r