summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRegia König2021-06-15 12:54:19 +0200
committerRegia König2021-06-15 12:54:19 +0200
commit74fef130183f1d99db81426c9a9682917d737f7c (patch)
tree685c63d345bb0fbc00c1c7b2348ac6ef3975401e
parentRetrieve position (address) where the efi image is loaded (diff)
downloadmemtest86-74fef130183f1d99db81426c9a9682917d737f7c.tar.gz
memtest86-74fef130183f1d99db81426c9a9682917d737f7c.tar.xz
memtest86-74fef130183f1d99db81426c9a9682917d737f7c.zip
Get current return address in UefiMain
-rw-r--r--efi_memtest/MemtestEfi.c28
-rw-r--r--efi_memtest/memtest86+/efi/test.c14
2 files changed, 30 insertions, 12 deletions
diff --git a/efi_memtest/MemtestEfi.c b/efi_memtest/MemtestEfi.c
index 87ea80b..876d825 100644
--- a/efi_memtest/MemtestEfi.c
+++ b/efi_memtest/MemtestEfi.c
@@ -34,14 +34,14 @@ UefiMain (
}
- {
- char log[43] = "Address of UefiMain: ";
- int length = 23;
+ if (logflag) {
+ char log[41] = "Address of UefiMain: ";
+ int length = 21;
int_to_charr((unsigned long)UefiMain, log, &length);
print_log(log, length);
}
- {
+ if (logflag) {
char log[43] = "Address of test_start: ";
int length = 23;
int_to_charr((unsigned long)test_start, log, &length);
@@ -57,24 +57,38 @@ UefiMain (
NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL);
if (status != EFI_SUCCESS) {
- print_log("Failed to open LoadedImage.", 27);
+ if (logflag) print_log("Failed to open LoadedImage.", 27);
} else {
VOID *base = ((EFI_LOADED_IMAGE_PROTOCOL *) LoadedImage)->ImageBase;
UINT64 size = ((EFI_LOADED_IMAGE_PROTOCOL *) LoadedImage)->ImageSize;
- {
+ if (logflag) {
char log[31] = "ImageBase: ";
int length = 11;
int_to_charr((unsigned long) base, log, &length);
print_log(log, length);
}
- {
+ if (logflag) {
char log[31] = "ImageSize: ";
int length = 11;
int_to_charr(size, log, &length);
print_log(log, length);
}
}
+
+ if (logflag) {
+ char log[45] = "Address of SystemTable = ";
+ int length = 25;
+ int_to_charr((unsigned long) SystemTable, log, &length);
+ print_log(log, length);
+ }
+
+ if (logflag) {
+ char log[45] = "Current return address = ";
+ int length = 25;
+ int_to_charr((unsigned long) ((unsigned long *) __builtin_return_address(0)), log, &length);
+ print_log(log, length);
+ }
test_start();
diff --git a/efi_memtest/memtest86+/efi/test.c b/efi_memtest/memtest86+/efi/test.c
index 7b7d3ec..900e082 100644
--- a/efi_memtest/memtest86+/efi/test.c
+++ b/efi_memtest/memtest86+/efi/test.c
@@ -318,11 +318,15 @@ STATIC void addr_tst2_init_segment(ulong* p,
*p = (ulong)p;
if ((ulong)p == bad_addr) {
addr_written = 1;
- char log[35] = "content of p = ";
- int length = 15;
- int_to_charr(*p, log, &length);
- print_log(log, length);
- }
+ }
+
+ if (addr_written) {
+ ulong *px = (ulong *)bad_addr;
+ char log[35] = "content of p = ";
+ int length = 15;
+ int_to_charr(*px, log, &length);
+ print_log(log, length);
+ }
}
/*asm __volatile__ (