Loader protocol must be globally accessible
All checks were successful
Builds / ExectOS (amd64) (push) Successful in 29s
Builds / ExectOS (i686) (push) Successful in 27s

This commit is contained in:
Rafal Kupiec 2024-01-01 14:05:48 +01:00
parent 835d2f3551
commit e728b9d299
Signed by: belliash
GPG Key ID: 4E829243E0CFE6B4
5 changed files with 47 additions and 43 deletions

View File

@ -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;

View File

@ -153,7 +153,7 @@ BlOpenVolume(IN PEFI_DEVICE_PATH_PROTOCOL DevicePath,
XTCDECL
EFI_STATUS
BlOpenXtProtocol(OUT PVOID *ProtocolHandler,
BlOpenProtocol(OUT PVOID *ProtocolHandler,
IN PEFI_GUID ProtocolGuid);
XTCDECL

View File

@ -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;

View File

@ -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,7 +336,7 @@ BlLoadModules(IN PWCHAR ModulesList)
*/
XTCDECL
EFI_STATUS
BlOpenXtProtocol(OUT PVOID *ProtocolHandler,
BlOpenProtocol(OUT PVOID *ProtocolHandler,
IN PEFI_GUID ProtocolGuid)
{
PEFI_HANDLE Handles = NULL;
@ -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);
}

View File

@ -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 */