summaryrefslogtreecommitdiff
path: root/ArmPlatformPkg/Scripts
diff options
context:
space:
mode:
authorRonald Cron <ronald.cron@arm.com>2014-08-19 13:29:52 +0000
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>2014-08-19 13:29:52 +0000
commit3402aac7d985bf8a9f9d3c639f3fe93609380513 (patch)
tree67b11334dc45181581aaaac236243fe72c7f614c /ArmPlatformPkg/Scripts
parent62d441fb17d59958bf00c4a1f3b52bf6a0b40b24 (diff)
ARM Packages: Removed trailing spaces
Trailing spaces create issue/warning when generating/applying patches. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ronald Cron <ronald.cron@arm.com> Reviewed-By: Olivier Martin <olivier.martin@arm.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15833 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ArmPlatformPkg/Scripts')
-rw-r--r--ArmPlatformPkg/Scripts/Ds5/build_report.py28
-rw-r--r--ArmPlatformPkg/Scripts/Ds5/cmd_load_symbols.py22
-rw-r--r--ArmPlatformPkg/Scripts/Ds5/edk2_debugger.py78
-rw-r--r--ArmPlatformPkg/Scripts/Ds5/firmware_volume.py134
-rw-r--r--ArmPlatformPkg/Scripts/Ds5/system_table.py54
5 files changed, 158 insertions, 158 deletions
diff --git a/ArmPlatformPkg/Scripts/Ds5/build_report.py b/ArmPlatformPkg/Scripts/Ds5/build_report.py
index e59230090f..effaf1db48 100644
--- a/ArmPlatformPkg/Scripts/Ds5/build_report.py
+++ b/ArmPlatformPkg/Scripts/Ds5/build_report.py
@@ -1,26 +1,26 @@
#
# Copyright (c) 2011-2012, ARM Limited. All rights reserved.
-#
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+# This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
import re
class BuildReport:
PCDs = {}
-
+
def parse_platform_summary(self, file):
pass
-
+
def parse_pcd_report(self, report_file):
pcd_reg = re.compile(" (\*P|\*F|\*M| ) (\w+)(\ +)\: (.*) \((\w+)\) = (.*)\n")
-
+
for line in report_file.xreadlines():
stripped_line = line.strip()
if re.match("\<=+\>", stripped_line):
@@ -32,19 +32,19 @@ class BuildReport:
m = pcd_reg.match(line)
if m:
self.PCDs[guid][m.group(2)] = (m.group(6).strip(),m.group(5))
-
+
def parse_firmware_device(self, file):
pass
-
+
def parse_module_summary(self, file):
#print "Module Summary"
pass
-
+
CONST_SECTION_HEADERS = [('Platform Summary', parse_platform_summary),
('Platform Configuration Database Report',parse_pcd_report),
('Firmware Device (FD)',parse_firmware_device),
('Module Summary',parse_module_summary)]
-
+
def __init__(self, filename = 'report.log'):
report_file = open(filename, 'r')
for line in report_file.xreadlines():
diff --git a/ArmPlatformPkg/Scripts/Ds5/cmd_load_symbols.py b/ArmPlatformPkg/Scripts/Ds5/cmd_load_symbols.py
index 994a475cb9..280b6b4de0 100644
--- a/ArmPlatformPkg/Scripts/Ds5/cmd_load_symbols.py
+++ b/ArmPlatformPkg/Scripts/Ds5/cmd_load_symbols.py
@@ -1,13 +1,13 @@
#
# Copyright (c) 2011-2013, ARM Limited. All rights reserved.
-#
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+# This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
from arm_ds.debugger_v1 import Debugger
@@ -38,7 +38,7 @@ if (opts is None) or (not opts):
else:
region_reg = re.compile("\((.*),(.*)\)")
base_reg = re.compile("(.*)")
-
+
for o,a in opts:
region_type = None
regex = None
@@ -63,7 +63,7 @@ else:
regex = region_reg
else:
assert False, "Unhandled option (%s)" % o
-
+
if region_type:
m = regex.match(a)
if m:
@@ -76,7 +76,7 @@ else:
raise Exception('cmd_load_symbols', "Expect a base address")
else:
raise Exception('cmd_load_symbols', "Expect a region format as (base,size)")
-
+
# Debugger object for accessing the debugger
debugger = Debugger()
@@ -89,7 +89,7 @@ ec = debugger.getExecutionContext(0)
try:
armplatform_debugger = edk2_debugger.ArmPlatformDebugger(ec, report_file, regions, verbose)
-
+
if load_all:
armplatform_debugger.load_all_symbols()
else:
diff --git a/ArmPlatformPkg/Scripts/Ds5/edk2_debugger.py b/ArmPlatformPkg/Scripts/Ds5/edk2_debugger.py
index b6108d6a19..cb420af898 100644
--- a/ArmPlatformPkg/Scripts/Ds5/edk2_debugger.py
+++ b/ArmPlatformPkg/Scripts/Ds5/edk2_debugger.py
@@ -1,13 +1,13 @@
#
# Copyright (c) 2011-2013, ARM Limited. All rights reserved.
-#
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+# This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
import os
@@ -29,11 +29,11 @@ def dump_fv(ec, fv_base, fv_size):
fv = firmware_volume.FirmwareVolume(ec,
int(build.PCDs['gArmTokenSpaceGuid']['PcdFvBaseAddress'][0],16),
int(build.PCDs['gArmTokenSpaceGuid']['PcdFvSize'][0],16))
-
+
ffs = fv.get_next_ffs()
- while ffs != None:
+ while ffs != None:
print "# %s" % ffs
-
+
section = ffs.get_next_section()
while section != None:
print "\t%s" % section
@@ -42,21 +42,21 @@ def dump_fv(ec, fv_base, fv_size):
except Exception:
pass
section = ffs.get_next_section(section)
-
+
ffs = fv.get_next_ffs(ffs)
def dump_system_table(ec, mem_base, mem_size):
st = system_table.SystemTable(ec, mem_base, mem_size)
-
+
debug_info_table_base = st.get_configuration_table(system_table.DebugInfoTable.CONST_DEBUG_INFO_TABLE_GUID)
-
+
debug_info_table = system_table.DebugInfoTable(ec, debug_info_table_base)
debug_info_table.dump()
def load_symbol_from_file(ec, filename, address, verbose = False):
if verbose:
print "Add symbols of %s at 0x%x" % (filename, address)
-
+
try:
ec.getImageService().addSymbols(filename, address)
except:
@@ -81,28 +81,28 @@ class ArmPlatform:
self.sysmembase = sysmembase
self.sysmemsize = sysmemsize
self.fvs = fvs
-
+
class ArmPlatformDebugger:
system_table = None
firmware_volumes = {}
-
+
REGION_TYPE_SYSMEM = 1
REGION_TYPE_ROM = 2
REGION_TYPE_FV = 3
-
+
def __init__(self, ec, report_log, regions, verbose = False):
self.ec = ec
self.verbose = verbose
fvs = []
sysmem_base = None
sysmem_size = None
-
+
if report_log and os.path.isfile(report_log):
try:
self.build = build_report.BuildReport(report_log)
except IOError:
raise IOError(2, 'Report \'%s\' is not valid' % report_log)
-
+
# Generate list of supported Firmware Volumes
if self.build.PCDs['gArmTokenSpaceGuid'].has_key('PcdFvSize') and int(self.build.PCDs['gArmTokenSpaceGuid']['PcdFvSize'][0],16) != 0:
fvs.append((int(self.build.PCDs['gArmTokenSpaceGuid']['PcdFvBaseAddress'][0],16),int(self.build.PCDs['gArmTokenSpaceGuid']['PcdFvSize'][0],16)))
@@ -110,7 +110,7 @@ class ArmPlatformDebugger:
fvs.append((int(self.build.PCDs['gArmTokenSpaceGuid']['PcdSecureFvBaseAddress'][0],16),int(self.build.PCDs['gArmTokenSpaceGuid']['PcdSecureFvSize'][0],16)))
if self.build.PCDs['gArmTokenSpaceGuid'].has_key('PcdHypFvSize') and int(self.build.PCDs['gArmTokenSpaceGuid']['PcdHypFvSize'][0],16) != 0:
fvs.append((int(self.build.PCDs['gArmTokenSpaceGuid']['PcdHypFvBaseAddress'][0],16),int(self.build.PCDs['gArmTokenSpaceGuid']['PcdHypFvSize'][0],16)))
-
+
sysmem_base = int(self.build.PCDs['gArmTokenSpaceGuid']['PcdSystemMemoryBase'][0],16)
sysmem_size = int(self.build.PCDs['gArmTokenSpaceGuid']['PcdSystemMemorySize'][0],16)
else:
@@ -127,9 +127,9 @@ class ArmPlatformDebugger:
fvs.append((base,0))
else:
print "Region type '%d' Not Supported" % region[0]
-
+
self.platform = ArmPlatform(sysmem_base, sysmem_size, fvs)
-
+
def in_sysmem(self, addr):
return (self.platform.sysmembase is not None) and (self.platform.sysmembase <= addr) and (addr < self.platform.sysmembase + self.platform.sysmemsize)
@@ -146,21 +146,21 @@ class ArmPlatformDebugger:
pc = int(self.ec.getRegisterService().getValue('PC')) & 0xFFFFFFFF
if self.in_fv(pc):
debug_infos = []
-
+
(fv_base, fv_size) = self.get_fv_at(pc)
-
+
if self.firmware_volumes.has_key(fv_base) == False:
self.firmware_volumes[fv_base] = firmware_volume.FirmwareVolume(self.ec, fv_base, fv_size)
-
+
stack_frame = self.ec.getTopLevelStackFrame()
info = self.firmware_volumes[fv_base].load_symbols_at(int(stack_frame.getRegisterService().getValue('PC')) & 0xFFFFFFFF, self.verbose)
debug_infos.append(info)
while stack_frame.next() is not None:
stack_frame = stack_frame.next()
-
+
# Stack frame attached to 'PC'
pc = int(stack_frame.getRegisterService().getValue('PC')) & 0xFFFFFFFF
-
+
# Check if the symbols for this stack frame have already been loaded
found = False
for debug_info in debug_infos:
@@ -169,28 +169,28 @@ class ArmPlatformDebugger:
if found == False:
info = self.firmware_volumes[fv_base].load_symbols_at(pc)
debug_infos.append(info)
-
+
#self.firmware_volumes[fv_base].load_symbols_at(pc)
elif self.in_sysmem(pc):
debug_infos = []
-
+
if self.system_table is None:
# Find the System Table
self.system_table = system_table.SystemTable(self.ec, self.platform.sysmembase, self.platform.sysmemsize)
-
+
# Find the Debug Info Table
debug_info_table_base = self.system_table.get_configuration_table(system_table.DebugInfoTable.CONST_DEBUG_INFO_TABLE_GUID)
self.debug_info_table = system_table.DebugInfoTable(self.ec, debug_info_table_base)
-
+
stack_frame = self.ec.getTopLevelStackFrame()
info = self.debug_info_table.load_symbols_at(int(stack_frame.getRegisterService().getValue('PC')) & 0xFFFFFFFF, self.verbose)
debug_infos.append(info)
while stack_frame.next() is not None:
stack_frame = stack_frame.next()
-
+
# Stack frame attached to 'PC'
pc = int(stack_frame.getRegisterService().getValue('PC')) & 0xFFFFFFFF
-
+
# Check if the symbols for this stack frame have already been loaded
found = False
for debug_info in debug_infos:
@@ -202,16 +202,16 @@ class ArmPlatformDebugger:
debug_infos.append(info)
except:
pass
-
+
#self.debug_info_table.load_symbols_at(pc)
else:
raise Exception('ArmPlatformDebugger', "Not supported region")
-
+
def load_all_symbols(self):
# Load all the XIP symbols attached to the Firmware Volume
for (fv_base, fv_size) in self.platform.fvs:
if self.firmware_volumes.has_key(fv_base) == False:
- self.firmware_volumes[fv_base] = firmware_volume.FirmwareVolume(self.ec, fv_base, fv_size)
+ self.firmware_volumes[fv_base] = firmware_volume.FirmwareVolume(self.ec, fv_base, fv_size)
self.firmware_volumes[fv_base].load_all_symbols(self.verbose)
try:
@@ -219,12 +219,12 @@ class ArmPlatformDebugger:
if self.system_table is None:
# Find the System Table
self.system_table = system_table.SystemTable(self.ec, self.platform.sysmembase, self.platform.sysmemsize)
-
-
+
+
# Find the Debug Info Table
debug_info_table_base = self.system_table.get_configuration_table(system_table.DebugInfoTable.CONST_DEBUG_INFO_TABLE_GUID)
self.debug_info_table = system_table.DebugInfoTable(self.ec, debug_info_table_base)
-
+
self.debug_info_table.load_all_symbols(self.verbose)
except:
# Debugger exception could be excepted if DRAM has not been initialized or if we have not started to run from DRAM yet
diff --git a/ArmPlatformPkg/Scripts/Ds5/firmware_volume.py b/ArmPlatformPkg/Scripts/Ds5/firmware_volume.py
index cd6f34acaf..8e3a8adc9b 100644
--- a/ArmPlatformPkg/Scripts/Ds5/firmware_volume.py
+++ b/ArmPlatformPkg/Scripts/Ds5/firmware_volume.py
@@ -1,13 +1,13 @@
#
# Copyright (c) 2011-2013, ARM Limited. All rights reserved.
-#
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+# This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
from arm_ds.debugger_v1 import DebugException
@@ -16,29 +16,29 @@ import struct
import string
import edk2_debugger
-
+
class EfiFileSection(object):
EFI_SECTION_PE32 = 0x10
EFI_SECTION_PIC = 0x11
EFI_SECTION_TE = 0x12
-
+
EFI_IMAGE_DEBUG_TYPE_CODEVIEW = 0x2
-
+
SIZEOF_EFI_FFS_FILE_HEADER = 0x28
def __init__(self, ec, base):
self.base = base
self.ec = ec
-
+
def __str__(self):
return "FileSection(type:0x%X, size:0x%x)" % (self.get_type(), self.get_size())
-
+
def get_base(self):
return self.base
-
+
def get_type(self):
return struct.unpack("B", self.ec.getMemoryService().read(self.base + 0x3, 1, 8))[0]
-
+
def get_size(self):
return (struct.unpack("<I", self.ec.getMemoryService().read(self.base, 4, 32))[0] & 0x00ffffff)
@@ -55,23 +55,23 @@ class EfiFileSection(object):
class EfiSectionTE:
SIZEOF_EFI_TE_IMAGE_HEADER = 0x28
EFI_TE_IMAGE_SIGNATURE = ('V','Z')
-
+
def __init__(self, ec, base_te):
self.ec = ec
self.base_te = int(base_te)
te_sig = struct.unpack("cc", self.ec.getMemoryService().read(self.base_te, 2, 32))
if te_sig != EfiSectionTE.EFI_TE_IMAGE_SIGNATURE:
raise Exception("EfiFileSectionTE","TE Signature incorrect")
-
+
def get_debug_filepath(self):
stripped_size = struct.unpack("<H", self.ec.getMemoryService().read(self.base_te + 0x6, 2, 32))[0]
stripped_size -= EfiSectionTE.SIZEOF_EFI_TE_IMAGE_HEADER
-
+
debug_dir_entry_rva = self.ec.getMemoryService().readMemory32(self.base_te + 0x20)
if debug_dir_entry_rva == 0:
raise Exception("EfiFileSectionTE","No debug directory for image")
debug_dir_entry_rva -= stripped_size
-
+
debug_type = self.ec.getMemoryService().readMemory32(self.base_te + debug_dir_entry_rva + 0xC)
if (debug_type != 0xdf) and (debug_type != EfiFileSection.EFI_IMAGE_DEBUG_TYPE_CODEVIEW):
raise Exception("EfiFileSectionTE","Debug type is not dwarf")
@@ -82,20 +82,20 @@ class EfiSectionTE:
dwarf_sig = struct.unpack("cccc", self.ec.getMemoryService().read(self.base_te + debug_rva, 4, 32))
if (dwarf_sig != 0x66727764) and (dwarf_sig != FirmwareFile.CONST_NB10_SIGNATURE):
raise Exception("EfiFileSectionTE","Dwarf debug signature not found")
-
+
if dwarf_sig == 0x66727764:
filename = self.base_te + debug_rva + 0xc
else:
filename = self.base_te + debug_rva + 0x10
filename = struct.unpack("200s", self.ec.getMemoryService().read(filename, 200, 32))[0]
return filename[0:string.find(filename,'\0')]
-
+
def get_debug_elfbase(self):
stripped_size = struct.unpack("<H", self.ec.getMemoryService().read(self.base_te + 0x6, 2, 32))[0]
stripped_size -= EfiSectionTE.SIZEOF_EFI_TE_IMAGE_HEADER
-
+
base_of_code = self.ec.getMemoryService().readMemory32(self.base_te + 0xC)
-
+
return self.base_te + base_of_code - stripped_size
class EfiSectionPE32:
@@ -115,28 +115,28 @@ class EfiSectionPE32:
debug_type = self.ec.getMemoryService().readMemory32(self.base_pe32 + debug_dir_entry_rva + 0xC)
if (debug_type != 0xdf) and (debug_type != EfiFileSection.EFI_IMAGE_DEBUG_TYPE_CODEVIEW):
raise Exception("EfiFileSectionPE32","Debug type is not dwarf")
-
-
+
+
debug_rva = self.ec.getMemoryService().readMemory32(self.base_pe32 + debug_dir_entry_rva + 0x14)
-
+
dwarf_sig = struct.unpack("cccc", self.ec.getMemoryService().read(str(self.base_pe32 + debug_rva), 4, 32))
if (dwarf_sig != 0x66727764) and (dwarf_sig != FirmwareFile.CONST_NB10_SIGNATURE):
raise Exception("EfiFileSectionPE32","Dwarf debug signature not found")
-
+
if dwarf_sig == 0x66727764:
filename = self.base_pe32 + debug_rva + 0xc
else:
filename = self.base_pe32 + 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_pe32 + self.ec.getMemoryService().readMemory32(self.base_pe32 + 0x3C)
-
+
base_of_code = self.base_pe32 + self.ec.getMemoryService().readMemory32(pe_file_header + 0x28)
base_of_data = self.base_pe32 + 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:
@@ -160,33 +160,33 @@ class EfiSectionPE64:
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
@@ -199,42 +199,42 @@ class FirmwareFile:
EFI_FV_FILETYPE_APPLICATION = 0x09
EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE = 0x0B
EFI_FV_FILETYPE_FFS_MIN = 0xF0
-
+
CONST_NB10_SIGNATURE = ('N','B','1','0')
-
+
def __init__(self, fv, base, ec):
self.fv = fv
self.base = base
self.ec = ec
-
+
def __str__(self):
return "FFS(state:0x%x, type:0x%X, size:0x%x)" % (self.get_state(), self.get_type(), self.get_size())
-
+
def get_base(self):
return self.base
-
+
def get_size(self):
size = (self.ec.getMemoryService().readMemory32(self.base + 0x14) & 0x00ffffff)
# Occupied size is the size considering the alignment
return size + ((0x8 - (size & 0x7)) & 0x7)
-
+
def get_type(self):
return self.ec.getMemoryService().readMemory8(self.base + 0x12)
-
+
def get_state(self):
state = self.ec.getMemoryService().readMemory8(self.base + 0x17)
-
+
polarity = self.fv.get_polarity()
if polarity:
state = ~state
-
+
highest_bit = 0x80;
while (highest_bit != 0) and ((highest_bit & state) == 0):
highest_bit >>= 1
-
+
return highest_bit
-
+
def get_next_section(self, section=None):
if section == None:
if self.get_type() != FirmwareFile.EFI_FV_FILETYPE_FFS_MIN:
@@ -243,7 +243,7 @@ class FirmwareFile:
return None
else:
section_base = int(section.get_base() + section.get_size())
-
+
# Align to next 4 byte boundary
if (section_base & 0x3) != 0:
section_base = section_base + 0x4 - (section_base & 0x3)
@@ -252,38 +252,38 @@ class FirmwareFile:
return EfiFileSection(self.ec, section_base)
else:
return None
-
+
class FirmwareVolume:
CONST_FV_SIGNATURE = ('_','F','V','H')
EFI_FVB2_ERASE_POLARITY = 0x800
-
+
DebugInfos = []
-
+
def __init__(self, ec, fv_base, fv_size):
self.ec = ec
self.fv_base = fv_base
self.fv_size = fv_size
-
+
try:
signature = struct.unpack("cccc", self.ec.getMemoryService().read(fv_base + 0x28, 4, 32))
except DebugException:
raise Exception("FirmwareVolume", "Not possible to access the defined firmware volume at [0x%X,0x%X]. Could be the used build report does not correspond to your current debugging context." % (int(fv_base),int(fv_base+fv_size)))
if signature != FirmwareVolume.CONST_FV_SIGNATURE:
raise Exception("FirmwareVolume", "This is not a valid firmware volume")
-
+
def get_size(self):
return self.ec.getMemoryService().readMemory32(self.fv_base + 0x20)
-
+
def get_attributes(self):
return self.ec.getMemoryService().readMemory32(self.fv_base + 0x2C)
-
+
def get_polarity(self):
attributes = self.get_attributes()
if attributes & FirmwareVolume.EFI_FVB2_ERASE_POLARITY:
return 1
else:
return 0
-
+
def get_next_ffs(self, ffs=None):
if ffs == None:
# Get the offset of the first FFS file from the FV header
@@ -291,21 +291,21 @@ class FirmwareVolume:
else:
# Goto the next FFS file
ffs_base = int(ffs.get_base() + ffs.get_size())
-
+
# Align to next 8 byte boundary
if (ffs_base & 0x7) != 0:
ffs_base = ffs_base + 0x8 - (ffs_base & 0x7)
-
+
if ffs_base < self.fv_base + self.get_size():
return FirmwareFile(self, ffs_base, self.ec)
else:
return None
-
- def get_debug_info(self):
+
+ def get_debug_info(self):
self.DebugInfos = []
-
+
ffs = self.get_next_ffs()
- while ffs != None:
+ while ffs != None:
section = ffs.get_next_section()
while section != None:
type = section.get_type()
@@ -317,7 +317,7 @@ class FirmwareVolume:
def load_symbols_at(self, addr, verbose = False):
if self.DebugInfos == []:
self.get_debug_info()
-
+
for debug_info in self.DebugInfos:
if (addr >= debug_info[0]) and (addr < debug_info[0] + debug_info[1]):
if debug_info[2] == EfiFileSection.EFI_SECTION_TE:
@@ -326,7 +326,7 @@ class FirmwareVolume:
section = EfiSectionPE32(self.ec, debug_info[0] + 0x4)
else:
raise Exception('FirmwareVolume','Section Type not supported')
-
+
try:
edk2_debugger.load_symbol_from_file(self.ec, section.get_debug_filepath(), section.get_debug_elfbase(), verbose)
except Exception, (ErrorClass, ErrorMessage):
@@ -338,7 +338,7 @@ class FirmwareVolume:
def load_all_symbols(self, verbose = False):
if self.DebugInfos == []:
self.get_debug_info()
-
+
for debug_info in self.DebugInfos:
if debug_info[2] == EfiFileSection.EFI_SECTION_TE:
section = EfiSectionTE(self.ec, debug_info[0] + 0x4)
@@ -346,7 +346,7 @@ class FirmwareVolume:
section = EfiSectionPE32(self.ec, debug_info[0] + 0x4)
else:
continue
-
+
try:
edk2_debugger.load_symbol_from_file(self.ec, section.get_debug_filepath(), section.get_debug_elfbase(), verbose)
except Exception, (ErrorClass, ErrorMessage):
diff --git a/ArmPlatformPkg/Scripts/Ds5/system_table.py b/ArmPlatformPkg/Scripts/Ds5/system_table.py
index dbb827e96d..0a14f80830 100644
--- a/ArmPlatformPkg/Scripts/Ds5/system_table.py
+++ b/ArmPlatformPkg/Scripts/Ds5/system_table.py
@@ -1,13 +1,13 @@
#
# Copyright (c) 2011-2013, ARM Limited. All rights reserved.
-#
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+# This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
from arm_ds.debugger_v1 import DebugException
@@ -19,13 +19,13 @@ import firmware_volume
class DebugInfoTable:
CONST_DEBUG_INFO_TABLE_GUID = ( 0x49152E77L, 0x47641ADAL, 0xFE7AA2B7L, 0x8B5ED9FEL)
-
+
DebugInfos = []
-
+
def __init__(self, ec, debug_info_table_header_offset):
self.ec = ec
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)
@@ -33,9 +33,9 @@ class DebugInfoTable:
debug_info_table_base = self.ec.getMemoryService().readMemory64(self.base + 0x8)
else:
debug_info_table_base = self.ec.getMemoryService().readMemory32(self.base + 0x8)
-
+
self.DebugInfos = []
-
+
for i in range(0, count):
# Get the address of the structure EFI_DEBUG_IMAGE_INFO
if edk2_debugger.is_aarch64(self.ec):
@@ -59,14 +59,14 @@ class DebugInfoTable:
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)
def load_symbols_at(self, addr, verbose = False):
if self.DebugInfos == []:
self.get_debug_info()
-
+
found = False
for debug_info in self.DebugInfos:
if (addr >= debug_info[0]) and (addr < debug_info[0] + debug_info[1]):
@@ -74,7 +74,7 @@ class DebugInfoTable:
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):
@@ -90,13 +90,13 @@ class DebugInfoTable:
def load_all_symbols(self, verbose = False):
if self.DebugInfos == []:
self.get_debug_info()
-
+
for debug_info in self.DebugInfos:
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):
@@ -112,24 +112,24 @@ class DebugInfoTable:
else:
section = firmware_volume.EfiSectionPE32(self.ec, base_pe32)
print section.get_debug_filepath()
-
+
class SystemTable:
CONST_ST_SIGNATURE = ('I','B','I',' ','S','Y','S','T')
-
+
def __init__(self, ec, membase, memsize):
self.membase = membase
self.memsize = memsize
self.ec = ec
-
+
found = False
-
+
# Start from the top of the memory
offset = self.membase + self.memsize
# Align to highest 4MB boundary
offset = offset & ~0x3FFFFF
# We should not have a System Table at the top of the System Memory
offset = offset - 0x400000
-
+
# Start at top and look on 4MB boundaries for system table ptr structure
while offset > self.membase:
try:
@@ -144,10 +144,10 @@ class SystemTable:
self.system_table_base = self.ec.getMemoryService().readMemory32(offset + 0x8)
break
offset = offset - 0x400000
-
+
if not found:
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):
if edk2_debugger.is_aarch64(self.ec):
# Number of configuration Table entry
@@ -161,7 +161,7 @@ class SystemTable:
# 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):
if edk2_debugger.is_aarch64(self.ec):
offset = conf_table_offset + (i * 0x18)
@@ -173,5 +173,5 @@ class SystemTable:
return self.ec.getMemoryService().readMemory64(offset + 0x10)
else:
return self.ec.getMemoryService().readMemory32(offset + 0x10)
-
+
raise Exception('SystemTable','Configuration Table not found')