Revision: 14491
http://sourceforge.net/p/edk2/code/14491
Author: oliviermartin
Date: 2013-07-18 21:32:43 +0000 (Thu, 18 Jul 2013)
Log Message:
-----------
ArmPlatformPkg/Ds5: Added Aarch64 support
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Harry Liebel <[email protected]>
Signed-off-by: Olivier Martin <[email protected]>
Modified Paths:
--------------
trunk/edk2/ArmPlatformPkg/Scripts/Ds5/edk2_debugger.py
trunk/edk2/ArmPlatformPkg/Scripts/Ds5/firmware_volume.py
trunk/edk2/ArmPlatformPkg/Scripts/Ds5/system_table.py
Modified: trunk/edk2/ArmPlatformPkg/Scripts/Ds5/edk2_debugger.py
===================================================================
--- trunk/edk2/ArmPlatformPkg/Scripts/Ds5/edk2_debugger.py 2013-07-18
19:53:43 UTC (rev 14490)
+++ trunk/edk2/ArmPlatformPkg/Scripts/Ds5/edk2_debugger.py 2013-07-18
21:32:43 UTC (rev 14491)
@@ -66,8 +66,16 @@
ec.getImageService().addSymbols(filename, address)
except:
print "Warning: not possible to load symbols from %s at 0x%x" %
(filename, address)
- pass
+def is_aarch64(ec):
+ success = True
+ try:
+ # Try to access a Aarch64 specific register
+ ec.getRegisterService().getValue('X0')
+ except:
+ success = False
+ return success
+
class ArmPlatform:
def __init__(self, sysmembase=None, sysmemsize=None, fvs={}):
self.sysmembase = sysmembase
@@ -189,8 +197,11 @@
if (pc >= debug_info[0]) and (pc < debug_info[0] +
debug_info[1]):
found = True
if found == False:
- info = self.debug_info_table.load_symbols_at(pc)
- debug_infos.append(info)
+ try:
+ info = self.debug_info_table.load_symbols_at(pc)
+ debug_infos.append(info)
+ except:
+ pass
#self.debug_info_table.load_symbols_at(pc)
else:
@@ -218,4 +229,3 @@
except:
# Debugger exception could be excepted if DRAM has not been
initialized or if we have not started to run from DRAM yet
print "Note: no symbols have been found in System Memory (possible
cause: the UEFI permanent memory has been installed yet)"
- pass
Modified: trunk/edk2/ArmPlatformPkg/Scripts/Ds5/firmware_volume.py
===================================================================
--- trunk/edk2/ArmPlatformPkg/Scripts/Ds5/firmware_volume.py 2013-07-18
19:53:43 UTC (rev 14490)
+++ trunk/edk2/ArmPlatformPkg/Scripts/Ds5/firmware_volume.py 2013-07-18
21:32:43 UTC (rev 14491)
@@ -140,8 +140,53 @@
if (base_of_code < base_of_data) and (base_of_code != 0):
return base_of_code
else:
- return base_of_data
+ return base_of_data
+
+class EfiSectionPE64:
+ def __init__(self, ec, base_pe64):
+ self.ec = ec
+ self.base_pe64 = base_pe64
+
+ def get_debug_filepath(self):
+ # Offset from dos hdr to PE file hdr (EFI_IMAGE_NT_HEADERS64)
+ #file_header_offset =
self.ec.getMemoryService().readMemory32(self.base_pe64 + 0x3C)
+ file_header_offset = 0x0
+
+ # Offset to debug dir in PE hdrs
+ debug_dir_entry_rva =
self.ec.getMemoryService().readMemory32(self.base_pe64 + file_header_offset +
0x138)
+ if debug_dir_entry_rva == 0:
+ raise Exception("EfiFileSectionPE64","No Debug Directory")
+
+ debug_type = self.ec.getMemoryService().readMemory32(self.base_pe64 +
debug_dir_entry_rva + 0xC)
+ if (debug_type != 0xdf) and (debug_type !=
EfiFileSection.EFI_IMAGE_DEBUG_TYPE_CODEVIEW):
+ raise Exception("EfiFileSectionPE64","Debug type is not dwarf")
+
+
+ debug_rva = self.ec.getMemoryService().readMemory32(self.base_pe64 +
debug_dir_entry_rva + 0x14)
+
+ dwarf_sig = struct.unpack("cccc",
self.ec.getMemoryService().read(str(self.base_pe64 + debug_rva), 4, 32))
+ if (dwarf_sig != 0x66727764) and (dwarf_sig !=
FirmwareFile.CONST_NB10_SIGNATURE):
+ raise Exception("EfiFileSectionPE64","Dwarf debug signature not
found")
+ if dwarf_sig == 0x66727764:
+ filename = self.base_pe64 + debug_rva + 0xc
+ else:
+ filename = self.base_pe64 + debug_rva + 0x10
+ filename = struct.unpack("200s",
self.ec.getMemoryService().read(str(filename), 200, 32))[0]
+ return filename[0:string.find(filename,'\0')]
+
+ def get_debug_elfbase(self):
+ # Offset from dos hdr to PE file hdr
+ pe_file_header = self.base_pe64 +
self.ec.getMemoryService().readMemory32(self.base_pe64 + 0x3C)
+
+ base_of_code = self.base_pe64 +
self.ec.getMemoryService().readMemory32(pe_file_header + 0x28)
+ base_of_data = self.base_pe64 +
self.ec.getMemoryService().readMemory32(pe_file_header + 0x2C)
+
+ if (base_of_code < base_of_data) and (base_of_code != 0):
+ return base_of_code
+ else:
+ return base_of_data
+
class FirmwareFile:
EFI_FV_FILETYPE_RAW = 0x01
EFI_FV_FILETYPE_FREEFORM = 0x02
@@ -287,7 +332,6 @@
except Exception, (ErrorClass, ErrorMessage):
if verbose:
print "Error while loading a symbol file (%s: %s)" %
(ErrorClass, ErrorMessage)
- pass
return debug_info
@@ -308,5 +352,4 @@
except Exception, (ErrorClass, ErrorMessage):
if verbose:
print "Error while loading a symbol file (%s: %s)" %
(ErrorClass, ErrorMessage)
- pass
Modified: trunk/edk2/ArmPlatformPkg/Scripts/Ds5/system_table.py
===================================================================
--- trunk/edk2/ArmPlatformPkg/Scripts/Ds5/system_table.py 2013-07-18
19:53:43 UTC (rev 14490)
+++ trunk/edk2/ArmPlatformPkg/Scripts/Ds5/system_table.py 2013-07-18
21:32:43 UTC (rev 14491)
@@ -27,6 +27,7 @@
self.base = debug_info_table_header_offset
def get_debug_info(self):
+ # Get the information from EFI_DEBUG_IMAGE_INFO_TABLE_HEADER
count = self.ec.getMemoryService().readMemory32(self.base + 0x4)
debug_info_table_base =
self.ec.getMemoryService().readMemory32(self.base + 0x8)
@@ -34,17 +35,28 @@
for i in range(0, count):
# Get the address of the structure EFI_DEBUG_IMAGE_INFO
- debug_info =
self.ec.getMemoryService().readMemory32(debug_info_table_base + (i * 4))
+ if edk2_debugger.is_aarch64(self.ec):
+ debug_info =
self.ec.getMemoryService().readMemory32(debug_info_table_base + (i * 8))
+ else:
+ debug_info =
self.ec.getMemoryService().readMemory32(debug_info_table_base + (i * 4))
+
if debug_info:
debug_info_type =
self.ec.getMemoryService().readMemory32(debug_info)
# Normal Debug Info Type
if debug_info_type == 1:
- # Get the base address of the structure
EFI_LOADED_IMAGE_PROTOCOL
- loaded_image_protocol =
self.ec.getMemoryService().readMemory32(debug_info + 0x4)
+ if edk2_debugger.is_aarch64(self.ec):
+ # Get the base address of the structure
EFI_LOADED_IMAGE_PROTOCOL
+ loaded_image_protocol =
self.ec.getMemoryService().readMemory32(debug_info + 0x8)
+
+ image_base =
self.ec.getMemoryService().readMemory32(loaded_image_protocol + 0x40)
+ image_size =
self.ec.getMemoryService().readMemory32(loaded_image_protocol + 0x48)
+ else:
+ # Get the base address of the structure
EFI_LOADED_IMAGE_PROTOCOL
+ loaded_image_protocol =
self.ec.getMemoryService().readMemory32(debug_info + 0x4)
+
+ image_base =
self.ec.getMemoryService().readMemory32(loaded_image_protocol + 0x20)
+ image_size =
self.ec.getMemoryService().readMemory32(loaded_image_protocol + 0x28)
- image_base =
self.ec.getMemoryService().readMemory32(loaded_image_protocol + 0x20)
- image_size =
self.ec.getMemoryService().readMemory32(loaded_image_protocol + 0x28)
-
self.DebugInfos.append((image_base,image_size))
# Return (base, size)
@@ -55,14 +67,16 @@
found = False
for debug_info in self.DebugInfos:
if (addr >= debug_info[0]) and (addr < debug_info[0] +
debug_info[1]):
- section = firmware_volume.EfiSectionPE32(self.ec,
debug_info[0])
+ if edk2_debugger.is_aarch64(self.ec):
+ section = firmware_volume.EfiSectionPE64(self.ec,
debug_info[0])
+ else:
+ section = firmware_volume.EfiSectionPE32(self.ec,
debug_info[0])
try:
edk2_debugger.load_symbol_from_file(self.ec,
section.get_debug_filepath(), section.get_debug_elfbase(), verbose)
except Exception, (ErrorClass, ErrorMessage):
if verbose:
print "Error while loading a symbol file (%s: %s)" %
(ErrorClass, ErrorMessage)
- pass
found = True
return debug_info
@@ -75,20 +89,25 @@
self.get_debug_info()
for debug_info in self.DebugInfos:
- section = firmware_volume.EfiSectionPE32(self.ec, debug_info[0])
-
+ if edk2_debugger.is_aarch64(self.ec):
+ section = firmware_volume.EfiSectionPE64(self.ec,
debug_info[0])
+ else:
+ section = firmware_volume.EfiSectionPE32(self.ec,
debug_info[0])
+
try:
edk2_debugger.load_symbol_from_file(self.ec,
section.get_debug_filepath(), section.get_debug_elfbase(), verbose)
except Exception, (ErrorClass, ErrorMessage):
if verbose:
print "Error while loading a symbol file (%s: %s)" %
(ErrorClass, ErrorMessage)
- pass
def dump(self):
self.get_debug_info()
for debug_info in self.DebugInfos:
base_pe32 = debug_info[0]
- section = firmware_volume.EfiSectionPE32(self.ec, base_pe32)
+ if edk2_debugger.is_aarch64(self.ec):
+ section = firmware_volume.EfiSectionPE64(self.ec, base_pe32)
+ else:
+ section = firmware_volume.EfiSectionPE32(self.ec, base_pe32)
print section.get_debug_filepath()
class SystemTable:
@@ -124,14 +143,24 @@
raise Exception('SystemTable','System Table not found in System
Memory [0x%x;0x%X]' % (membase,membase+memsize))
def get_configuration_table(self, conf_table_guid):
- # Number of configuration Table entry
- conf_table_entry_count =
self.ec.getMemoryService().readMemory32(self.system_table_base + 0x40)
+ if edk2_debugger.is_aarch64(self.ec):
+ # Number of configuration Table entry
+ conf_table_entry_count =
self.ec.getMemoryService().readMemory32(self.system_table_base + 0x68)
+
+ # Get location of the Configuration Table entries
+ conf_table_offset =
self.ec.getMemoryService().readMemory32(self.system_table_base + 0x70)
+ else:
+ # Number of configuration Table entry
+ conf_table_entry_count =
self.ec.getMemoryService().readMemory32(self.system_table_base + 0x40)
+
+ # Get location of the Configuration Table entries
+ conf_table_offset =
self.ec.getMemoryService().readMemory32(self.system_table_base + 0x44)
- # Get location of the Configuration Table entries
- conf_table_offset =
self.ec.getMemoryService().readMemory32(self.system_table_base + 0x44)
-
for i in range(0, conf_table_entry_count):
- offset = conf_table_offset + (i * 0x14)
+ if edk2_debugger.is_aarch64(self.ec):
+ offset = conf_table_offset + (i * 0x18)
+ else:
+ offset = conf_table_offset + (i * 0x14)
guid = struct.unpack("<IIII",
self.ec.getMemoryService().read(str(offset), 16, 32))
if guid == conf_table_guid:
return self.ec.getMemoryService().readMemory32(offset + 0x10)
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits