From 093ef010c84f465efd36ae0b410c6ba1d5ff1c83 Mon Sep 17 00:00:00 2001 From: Rafal Kupiec Date: Wed, 20 Dec 2023 15:54:11 +0100 Subject: [PATCH] Add more debugging --- xtldr2/efiutils.c | 26 ++++++++++++++++++++++++++ xtldr2/xtldr.c | 3 +-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/xtldr2/efiutils.c b/xtldr2/efiutils.c index 28bdf7f..d6124f3 100644 --- a/xtldr2/efiutils.c +++ b/xtldr2/efiutils.c @@ -130,9 +130,35 @@ XTCDECL VOID BlpInitializeEfiBootLoader() { + EFI_GUID LipGuid = EFI_LOADED_IMAGE_PROTOCOL_GUID; + PEFI_LOADED_IMAGE_PROTOCOL LoadedImage; + EFI_STATUS Status; + /* Set current XTLDR status */ BlpStatus.BootServices = TRUE; /* Initialize console */ BlpInitializeConsole(); + + /* Print XTLDR version */ + BlConsolePrint(L"XTLDR boot loader v%s\n", XTOS_VERSION); + + /* Check if debug is enabled */ + if(DEBUG) + { + Status = BlOpenXtProtocol((PVOID *)&LoadedImage, &LipGuid); + + /* Print useful debug information */ + BlConsolePrint(L"\n---------- BOOTLOADER DEBUG ----------\n" + L"Pointer Size : %d\n" + L"Image Base Address: 0x%lx\n" + L"Image Base Size : 0x%lx\n" + L"Image Revision : 0x%lx\n" + L"--------------------------------------\n", + sizeof(PVOID), + LoadedImage->ImageBase, + LoadedImage->ImageSize, + LoadedImage->Revision); + BlSleepExecution(5000); + } } diff --git a/xtldr2/xtldr.c b/xtldr2/xtldr.c index 0be8f71..956b4eb 100644 --- a/xtldr2/xtldr.c +++ b/xtldr2/xtldr.c @@ -124,9 +124,8 @@ BlStartXtLoader(IN EFI_HANDLE ImageHandle, EfiImageHandle = ImageHandle; EfiSystemTable = SystemTable; - /* Initialize XTLDR and early print XTLDR version */ + /* Initialize XTLDR and */ BlpInitializeEfiBootLoader(); - BlConsolePrint(L"XTLDR boot loader v%s\n", XTOS_VERSION); /* Parse configuration options passed from UEFI shell */ Status = BlpParseCommandLine();