diff --git a/xtldr2/globals.c b/xtldr2/globals.c index cbfc400..4a6a286 100644 --- a/xtldr2/globals.c +++ b/xtldr2/globals.c @@ -21,6 +21,9 @@ LIST_ENTRY BlpConfigSections; /* XT Boot Loader hex table */ STATIC PUINT16 BlpHexTable = L"0123456789ABCDEF"; +/* XT Boot Loader protocol */ +XTBL_LOADER_PROTOCOL BlpLdrProtocol; + /* XT Boot Loader loaded modules list */ LIST_ENTRY BlpLoadedModules; diff --git a/xtldr2/includes/bootman.h b/xtldr2/includes/bootman.h index 3f8bfc0..59a34c2 100644 --- a/xtldr2/includes/bootman.h +++ b/xtldr2/includes/bootman.h @@ -153,8 +153,8 @@ BlOpenVolume(IN PEFI_DEVICE_PATH_PROTOCOL DevicePath, XTCDECL EFI_STATUS -BlOpenXtProtocol(OUT PVOID *ProtocolHandler, - IN PEFI_GUID ProtocolGuid); +BlOpenProtocol(OUT PVOID *ProtocolHandler, + IN PEFI_GUID ProtocolGuid); XTCDECL VOID diff --git a/xtldr2/includes/globals.h b/xtldr2/includes/globals.h index b5eed43..0e6402a 100644 --- a/xtldr2/includes/globals.h +++ b/xtldr2/includes/globals.h @@ -24,6 +24,8 @@ EXTERN LIST_ENTRY BlpConfigSections; /* XT Boot Loader hex table */ EXTERN PUINT16 BlpHexTable; +EXTERN XTBL_LOADER_PROTOCOL BlpLdrProtocol; + /* XT Boot Loader loaded modules list */ EXTERN LIST_ENTRY BlpLoadedModules; diff --git a/xtldr2/protocol.c b/xtldr2/protocol.c index 3ba341e..503eaa7 100644 --- a/xtldr2/protocol.c +++ b/xtldr2/protocol.c @@ -308,7 +308,7 @@ BlLoadModules(IN PWCHAR ModulesList) if(Status != STATUS_EFI_SUCCESS) { /* Failed to load module, print error message and set new return value */ - BlDebugPrint(L"Failed to load module '%S', (Status Code: 0x%lx)\n", Module, Status); + BlDebugPrint(L"ERROR: Failed to load module '%S', (Status Code: 0x%lx)\n", Module, Status); ReturnStatus = STATUS_EFI_LOAD_ERROR; } @@ -322,7 +322,7 @@ BlLoadModules(IN PWCHAR ModulesList) } /** - * This routine locates and opens the requested XT boot loader protocol. + * This routine locates and opens the requested XT Boot Loader or EFI protocol. * * @param ProtocolHandler * Supplies the address where a pointer to the opened protocol is returned. @@ -336,8 +336,8 @@ BlLoadModules(IN PWCHAR ModulesList) */ XTCDECL EFI_STATUS -BlOpenXtProtocol(OUT PVOID *ProtocolHandler, - IN PEFI_GUID ProtocolGuid) +BlOpenProtocol(OUT PVOID *ProtocolHandler, + IN PEFI_GUID ProtocolGuid) { PEFI_HANDLE Handles = NULL; EFI_STATUS Status; @@ -472,45 +472,44 @@ EFI_STATUS BlpRegisterXtLoaderProtocol() { EFI_GUID Guid = XT_BOOT_LOADER_PROTOCOL_GUID; - XTBL_LOADER_PROTOCOL LdrProtocol; EFI_HANDLE Handle = NULL; /* Set all routines available via loader protocol */ - LdrProtocol.Boot.FindProtocol = BlFindBootProtocol; - LdrProtocol.Boot.InitializeMenuList = BlInitializeBootMenuList; - LdrProtocol.Boot.InvokeProtocol = BlInvokeBootProtocol; - LdrProtocol.Boot.RegisterMenu = BlRegisterBootMenu; - LdrProtocol.Boot.RegisterProtocol = BlRegisterBootProtocol; - LdrProtocol.Console.ClearLine = BlClearConsoleLine; - LdrProtocol.Console.ClearScreen = BlClearConsoleScreen; - LdrProtocol.Console.DisableCursor = BlDisableConsoleCursor; - LdrProtocol.Console.EnableCursor = BlEnableConsoleCursor; - LdrProtocol.Console.Print = BlConsolePrint; - LdrProtocol.Console.QueryMode = BlQueryConsoleMode; - LdrProtocol.Console.ReadKeyStroke = BlReadKeyStroke; - LdrProtocol.Console.ResetInputBuffer = BlResetConsoleInputBuffer; - LdrProtocol.Console.SetAttributes = BlSetConsoleAttributes; - LdrProtocol.Console.SetCursorPosition = BlSetCursorPosition; - LdrProtocol.Console.Write = BlConsoleWrite; - LdrProtocol.Debug.Print = BlDebugPrint; - LdrProtocol.Disk.CloseVolume = BlCloseVolume; - LdrProtocol.Disk.OpenVolume = BlOpenVolume; - LdrProtocol.Disk.ReadFile = BlReadFile; - LdrProtocol.Memory.AllocatePages = BlMemoryAllocatePages; - LdrProtocol.Memory.AllocatePool = BlMemoryAllocatePool; - LdrProtocol.Memory.FreePages = BlMemoryFreePages; - LdrProtocol.Memory.FreePool = BlMemoryFreePool; - LdrProtocol.Protocol.Open = BlOpenXtProtocol; - LdrProtocol.Tui.DisplayErrorDialog = BlDisplayErrorDialog; - LdrProtocol.Tui.DisplayInfoDialog = BlDisplayInfoDialog; - LdrProtocol.Tui.DisplayProgressDialog = BlDisplayProgressDialog; - LdrProtocol.Tui.UpdateProgressBar = BlUpdateProgressBar; - LdrProtocol.Util.ExitBootServices = BlExitBootServices; - LdrProtocol.Util.GetSecureBootStatus = BlGetSecureBootStatus; - LdrProtocol.Util.SleepExecution = BlSleepExecution; - LdrProtocol.Util.WaitForEfiEvent = BlWaitForEfiEvent; + BlpLdrProtocol.Boot.FindProtocol = BlFindBootProtocol; + BlpLdrProtocol.Boot.InitializeMenuList = BlInitializeBootMenuList; + BlpLdrProtocol.Boot.InvokeProtocol = BlInvokeBootProtocol; + BlpLdrProtocol.Boot.RegisterMenu = BlRegisterBootMenu; + BlpLdrProtocol.Boot.RegisterProtocol = BlRegisterBootProtocol; + BlpLdrProtocol.Console.ClearLine = BlClearConsoleLine; + BlpLdrProtocol.Console.ClearScreen = BlClearConsoleScreen; + BlpLdrProtocol.Console.DisableCursor = BlDisableConsoleCursor; + BlpLdrProtocol.Console.EnableCursor = BlEnableConsoleCursor; + BlpLdrProtocol.Console.Print = BlConsolePrint; + BlpLdrProtocol.Console.QueryMode = BlQueryConsoleMode; + BlpLdrProtocol.Console.ReadKeyStroke = BlReadKeyStroke; + BlpLdrProtocol.Console.ResetInputBuffer = BlResetConsoleInputBuffer; + BlpLdrProtocol.Console.SetAttributes = BlSetConsoleAttributes; + BlpLdrProtocol.Console.SetCursorPosition = BlSetCursorPosition; + BlpLdrProtocol.Console.Write = BlConsoleWrite; + BlpLdrProtocol.Debug.Print = BlDebugPrint; + BlpLdrProtocol.Disk.CloseVolume = BlCloseVolume; + BlpLdrProtocol.Disk.OpenVolume = BlOpenVolume; + BlpLdrProtocol.Disk.ReadFile = BlReadFile; + BlpLdrProtocol.Memory.AllocatePages = BlMemoryAllocatePages; + BlpLdrProtocol.Memory.AllocatePool = BlMemoryAllocatePool; + BlpLdrProtocol.Memory.FreePages = BlMemoryFreePages; + BlpLdrProtocol.Memory.FreePool = BlMemoryFreePool; + BlpLdrProtocol.Protocol.Open = BlOpenProtocol; + BlpLdrProtocol.Tui.DisplayErrorDialog = BlDisplayErrorDialog; + BlpLdrProtocol.Tui.DisplayInfoDialog = BlDisplayInfoDialog; + BlpLdrProtocol.Tui.DisplayProgressDialog = BlDisplayProgressDialog; + BlpLdrProtocol.Tui.UpdateProgressBar = BlUpdateProgressBar; + BlpLdrProtocol.Util.ExitBootServices = BlExitBootServices; + BlpLdrProtocol.Util.GetSecureBootStatus = BlGetSecureBootStatus; + BlpLdrProtocol.Util.SleepExecution = BlSleepExecution; + BlpLdrProtocol.Util.WaitForEfiEvent = BlWaitForEfiEvent; /* Register XTLDR loader protocol */ BlDebugPrint(L"Registering XT loader protocol\n"); - return EfiSystemTable->BootServices->InstallProtocolInterface(&Handle, &Guid, EFI_NATIVE_INTERFACE, &LdrProtocol); + return EfiSystemTable->BootServices->InstallProtocolInterface(&Handle, &Guid, EFI_NATIVE_INTERFACE, &BlpLdrProtocol); } diff --git a/xtldr2/xtldr.c b/xtldr2/xtldr.c index 1efd698..e1c5230 100644 --- a/xtldr2/xtldr.c +++ b/xtldr2/xtldr.c @@ -45,7 +45,7 @@ BlInitializeBootLoader() if(DEBUG) { /* Attempt to open EFI LoadedImage protocol */ - Status = BlOpenXtProtocol((PVOID *)&LoadedImage, &LipGuid); + Status = BlOpenProtocol((PVOID *)&LoadedImage, &LipGuid); if(Status == STATUS_EFI_SUCCESS) { /* Protocol opened successfully, print useful debug information */ @@ -261,7 +261,7 @@ BlInvokeBootProtocol(IN PLIST_ENTRY OptionsList) } /* Open boot protocol */ - Status = BlOpenXtProtocol((PVOID *)&BootProtocol, &BootProtocolGuid); + Status = BlOpenProtocol((PVOID *)&BootProtocol, &BootProtocolGuid); if(Status != STATUS_EFI_SUCCESS) { /* Failed to open boot protocol */