summaryrefslogtreecommitdiffstats
path: root/BaseTools
diff options
context:
space:
mode:
Diffstat (limited to 'BaseTools')
-rwxr-xr-xBaseTools/Conf/tools_def.template4
-rwxr-xr-xBaseTools/Scripts/efi_debugging.py36
2 files changed, 36 insertions, 4 deletions
diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.template
index 11be436e73..04a39e268d 100755
--- a/BaseTools/Conf/tools_def.template
+++ b/BaseTools/Conf/tools_def.template
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2006 - 2025, Intel Corporation. All rights reserved.<BR>
# Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
# Portions copyright (c) 2011 - 2019, ARM Ltd. All rights reserved.<BR>
# Copyright (c) 2015, Hewlett-Packard Development Company, L.P.<BR>
@@ -943,7 +943,7 @@ DEFINE GCC_LOONGARCH64_ASLDLINK_FLAGS = DEF(GCC_LOONGARCH64_DLINK_FLAGS) -Wl,--e
DEFINE GCC_IA32_X64_DLINK_FLAGS = DEF(GCC_IA32_X64_DLINK_COMMON) --entry _$(IMAGE_ENTRY_POINT) --file-alignment 0x20 --section-alignment 0x20 -Map $(DEST_DIR_DEBUG)/$(BASE_NAME).map
DEFINE GCC_ASM_FLAGS = -c -x assembler -imacros AutoGen.h
DEFINE GCC_PP_FLAGS = -E -x assembler-with-cpp -include AutoGen.h
-DEFINE GCC_VFRPP_FLAGS = -x c -E -P -DVFRCOMPILE --include $(MODULE_NAME)StrDefs.h
+DEFINE GCC_VFRPP_FLAGS = -x c -E -DVFRCOMPILE --include $(MODULE_NAME)StrDefs.h
DEFINE GCC_ASLPP_FLAGS = -x c -E -include AutoGen.h
DEFINE GCC_ASLCC_FLAGS = -x c
DEFINE GCC_WINDRES_FLAGS = -J rc -O coff
diff --git a/BaseTools/Scripts/efi_debugging.py b/BaseTools/Scripts/efi_debugging.py
index 9848cd5968..1c1446a878 100755
--- a/BaseTools/Scripts/efi_debugging.py
+++ b/BaseTools/Scripts/efi_debugging.py
@@ -33,6 +33,7 @@ import os
import uuid
import struct
import re
+import zlib
from ctypes import c_char, c_uint8, c_uint16, c_uint32, c_uint64, c_void_p
from ctypes import ARRAY, sizeof
from ctypes import Structure, LittleEndianStructure
@@ -1770,8 +1771,10 @@ class EfiConfigurationTable:
def __init__(self, file, gST_addr=None):
self._file = file
if gST_addr is None:
- # ToDo add code to search for gST via EFI_SYSTEM_TABLE_POINTER
- return
+ # search for gST via EFI_SYSTEM_TABLE_POINTER
+ system_table_pointer = self._get_system_table_pointer()
+ if not system_table_pointer is None:
+ gST_addr = system_table_pointer.EfiSystemTableBase
gST = self._ctype_read(EFI_SYSTEM_TABLE, gST_addr)
self.read_efi_config_table(gST.NumberOfTableEntries,
@@ -1796,6 +1799,35 @@ class EfiConfigurationTable:
data = self._file.read(sizeof(ctype_struct))
return ctype_struct.from_buffer(bytearray(data))
+ def _get_system_table_pointer(self):
+ start_addr = 0x0
+ end_addr = 0xf0000000
+ alignment = 0x00400000
+ # The translation of "IBI SYST" for the signature of EFI_SYSTEM_TABLE
+ efi_system_table_signature = 0x5453595320494249
+
+ system_table_pointer = None
+
+ current_addr = start_addr
+ while current_addr < end_addr:
+ try:
+ self._file.seek(current_addr)
+ data = self._file.read(sizeof(EFI_SYSTEM_TABLE_POINTER))
+ except:
+ current_addr = current_addr + alignment
+ continue
+
+ system_table_pointer = EFI_SYSTEM_TABLE_POINTER.from_buffer(bytearray(data))
+ if system_table_pointer.Signature == efi_system_table_signature:
+ buf1 = bytearray(system_table_pointer)[:16]
+ crc32_value = zlib.crc32(buf1)
+ crc32_value = zlib.crc32(b'\0' * (sizeof(EFI_SYSTEM_TABLE_POINTER) - len(buf1)), crc32_value)
+ if crc32_value == system_table_pointer.Crc32:
+ break
+ system_table_pointer = None
+ current_addr = current_addr + alignment
+ return system_table_pointer
+
@ classmethod
def read_efi_config_table(cls, table_cnt, table_ptr, ctype_read):
'''Create a dictionary of EFI Configuration table entries'''