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 */ /* XT Boot Loader hex table */
STATIC PUINT16 BlpHexTable = L"0123456789ABCDEF"; STATIC PUINT16 BlpHexTable = L"0123456789ABCDEF";
/* XT Boot Loader protocol */
XTBL_LOADER_PROTOCOL BlpLdrProtocol;
/* XT Boot Loader loaded modules list */ /* XT Boot Loader loaded modules list */
LIST_ENTRY BlpLoadedModules; LIST_ENTRY BlpLoadedModules;

View File

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

View File

@ -24,6 +24,8 @@ EXTERN LIST_ENTRY BlpConfigSections;
/* XT Boot Loader hex table */ /* XT Boot Loader hex table */
EXTERN PUINT16 BlpHexTable; EXTERN PUINT16 BlpHexTable;
EXTERN XTBL_LOADER_PROTOCOL BlpLdrProtocol;
/* XT Boot Loader loaded modules list */ /* XT Boot Loader loaded modules list */
EXTERN LIST_ENTRY BlpLoadedModules; EXTERN LIST_ENTRY BlpLoadedModules;

View File

@ -308,7 +308,7 @@ BlLoadModules(IN PWCHAR ModulesList)
if(Status != STATUS_EFI_SUCCESS) if(Status != STATUS_EFI_SUCCESS)
{ {
/* Failed to load module, print error message and set new return value */ /* 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; 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 * @param ProtocolHandler
* Supplies the address where a pointer to the opened protocol is returned. * Supplies the address where a pointer to the opened protocol is returned.
@ -336,8 +336,8 @@ BlLoadModules(IN PWCHAR ModulesList)
*/ */
XTCDECL XTCDECL
EFI_STATUS EFI_STATUS
BlOpenXtProtocol(OUT PVOID *ProtocolHandler, BlOpenProtocol(OUT PVOID *ProtocolHandler,
IN PEFI_GUID ProtocolGuid) IN PEFI_GUID ProtocolGuid)
{ {
PEFI_HANDLE Handles = NULL; PEFI_HANDLE Handles = NULL;
EFI_STATUS Status; EFI_STATUS Status;
@ -472,45 +472,44 @@ EFI_STATUS
BlpRegisterXtLoaderProtocol() BlpRegisterXtLoaderProtocol()
{ {
EFI_GUID Guid = XT_BOOT_LOADER_PROTOCOL_GUID; EFI_GUID Guid = XT_BOOT_LOADER_PROTOCOL_GUID;
XTBL_LOADER_PROTOCOL LdrProtocol;
EFI_HANDLE Handle = NULL; EFI_HANDLE Handle = NULL;
/* Set all routines available via loader protocol */ /* Set all routines available via loader protocol */
LdrProtocol.Boot.FindProtocol = BlFindBootProtocol; BlpLdrProtocol.Boot.FindProtocol = BlFindBootProtocol;
LdrProtocol.Boot.InitializeMenuList = BlInitializeBootMenuList; BlpLdrProtocol.Boot.InitializeMenuList = BlInitializeBootMenuList;
LdrProtocol.Boot.InvokeProtocol = BlInvokeBootProtocol; BlpLdrProtocol.Boot.InvokeProtocol = BlInvokeBootProtocol;
LdrProtocol.Boot.RegisterMenu = BlRegisterBootMenu; BlpLdrProtocol.Boot.RegisterMenu = BlRegisterBootMenu;
LdrProtocol.Boot.RegisterProtocol = BlRegisterBootProtocol; BlpLdrProtocol.Boot.RegisterProtocol = BlRegisterBootProtocol;
LdrProtocol.Console.ClearLine = BlClearConsoleLine; BlpLdrProtocol.Console.ClearLine = BlClearConsoleLine;
LdrProtocol.Console.ClearScreen = BlClearConsoleScreen; BlpLdrProtocol.Console.ClearScreen = BlClearConsoleScreen;
LdrProtocol.Console.DisableCursor = BlDisableConsoleCursor; BlpLdrProtocol.Console.DisableCursor = BlDisableConsoleCursor;
LdrProtocol.Console.EnableCursor = BlEnableConsoleCursor; BlpLdrProtocol.Console.EnableCursor = BlEnableConsoleCursor;
LdrProtocol.Console.Print = BlConsolePrint; BlpLdrProtocol.Console.Print = BlConsolePrint;
LdrProtocol.Console.QueryMode = BlQueryConsoleMode; BlpLdrProtocol.Console.QueryMode = BlQueryConsoleMode;
LdrProtocol.Console.ReadKeyStroke = BlReadKeyStroke; BlpLdrProtocol.Console.ReadKeyStroke = BlReadKeyStroke;
LdrProtocol.Console.ResetInputBuffer = BlResetConsoleInputBuffer; BlpLdrProtocol.Console.ResetInputBuffer = BlResetConsoleInputBuffer;
LdrProtocol.Console.SetAttributes = BlSetConsoleAttributes; BlpLdrProtocol.Console.SetAttributes = BlSetConsoleAttributes;
LdrProtocol.Console.SetCursorPosition = BlSetCursorPosition; BlpLdrProtocol.Console.SetCursorPosition = BlSetCursorPosition;
LdrProtocol.Console.Write = BlConsoleWrite; BlpLdrProtocol.Console.Write = BlConsoleWrite;
LdrProtocol.Debug.Print = BlDebugPrint; BlpLdrProtocol.Debug.Print = BlDebugPrint;
LdrProtocol.Disk.CloseVolume = BlCloseVolume; BlpLdrProtocol.Disk.CloseVolume = BlCloseVolume;
LdrProtocol.Disk.OpenVolume = BlOpenVolume; BlpLdrProtocol.Disk.OpenVolume = BlOpenVolume;
LdrProtocol.Disk.ReadFile = BlReadFile; BlpLdrProtocol.Disk.ReadFile = BlReadFile;
LdrProtocol.Memory.AllocatePages = BlMemoryAllocatePages; BlpLdrProtocol.Memory.AllocatePages = BlMemoryAllocatePages;
LdrProtocol.Memory.AllocatePool = BlMemoryAllocatePool; BlpLdrProtocol.Memory.AllocatePool = BlMemoryAllocatePool;
LdrProtocol.Memory.FreePages = BlMemoryFreePages; BlpLdrProtocol.Memory.FreePages = BlMemoryFreePages;
LdrProtocol.Memory.FreePool = BlMemoryFreePool; BlpLdrProtocol.Memory.FreePool = BlMemoryFreePool;
LdrProtocol.Protocol.Open = BlOpenXtProtocol; BlpLdrProtocol.Protocol.Open = BlOpenProtocol;
LdrProtocol.Tui.DisplayErrorDialog = BlDisplayErrorDialog; BlpLdrProtocol.Tui.DisplayErrorDialog = BlDisplayErrorDialog;
LdrProtocol.Tui.DisplayInfoDialog = BlDisplayInfoDialog; BlpLdrProtocol.Tui.DisplayInfoDialog = BlDisplayInfoDialog;
LdrProtocol.Tui.DisplayProgressDialog = BlDisplayProgressDialog; BlpLdrProtocol.Tui.DisplayProgressDialog = BlDisplayProgressDialog;
LdrProtocol.Tui.UpdateProgressBar = BlUpdateProgressBar; BlpLdrProtocol.Tui.UpdateProgressBar = BlUpdateProgressBar;
LdrProtocol.Util.ExitBootServices = BlExitBootServices; BlpLdrProtocol.Util.ExitBootServices = BlExitBootServices;
LdrProtocol.Util.GetSecureBootStatus = BlGetSecureBootStatus; BlpLdrProtocol.Util.GetSecureBootStatus = BlGetSecureBootStatus;
LdrProtocol.Util.SleepExecution = BlSleepExecution; BlpLdrProtocol.Util.SleepExecution = BlSleepExecution;
LdrProtocol.Util.WaitForEfiEvent = BlWaitForEfiEvent; BlpLdrProtocol.Util.WaitForEfiEvent = BlWaitForEfiEvent;
/* Register XTLDR loader protocol */ /* Register XTLDR loader protocol */
BlDebugPrint(L"Registering XT loader protocol\n"); 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) if(DEBUG)
{ {
/* Attempt to open EFI LoadedImage protocol */ /* Attempt to open EFI LoadedImage protocol */
Status = BlOpenXtProtocol((PVOID *)&LoadedImage, &LipGuid); Status = BlOpenProtocol((PVOID *)&LoadedImage, &LipGuid);
if(Status == STATUS_EFI_SUCCESS) if(Status == STATUS_EFI_SUCCESS)
{ {
/* Protocol opened successfully, print useful debug information */ /* Protocol opened successfully, print useful debug information */
@ -261,7 +261,7 @@ BlInvokeBootProtocol(IN PLIST_ENTRY OptionsList)
} }
/* Open boot protocol */ /* Open boot protocol */
Status = BlOpenXtProtocol((PVOID *)&BootProtocol, &BootProtocolGuid); Status = BlOpenProtocol((PVOID *)&BootProtocol, &BootProtocolGuid);
if(Status != STATUS_EFI_SUCCESS) if(Status != STATUS_EFI_SUCCESS)
{ {
/* Failed to open boot protocol */ /* Failed to open boot protocol */