Refactor, part 7; register XTLDR protocol
All checks were successful
Builds / ExectOS (amd64) (push) Successful in 32s
Builds / ExectOS (i686) (push) Successful in 28s

This commit is contained in:
Rafal Kupiec 2023-12-05 22:18:25 +01:00
parent c4f1429a3b
commit 6733146b71
Signed by: belliash
GPG Key ID: 4E829243E0CFE6B4
5 changed files with 31 additions and 24 deletions

View File

@ -6,7 +6,6 @@
# Debug - enables the debugging port and consists of two comma-separated parameters: com port and baud rate; # Debug - enables the debugging port and consists of two comma-separated parameters: com port and baud rate;
# it is also possible to specify custom port address with: COM0:[address],[baud_rate] # it is also possible to specify custom port address with: COM0:[address],[baud_rate]
# Default - specifies which operating system listen in config file will be started if no choice is made # Default - specifies which operating system listen in config file will be started if no choice is made
# Theme - allows to set a custom theme to personalize XTLDR's look'n'feel
# Timeout - sets the countdown timer (in seconds) before the default OS get started automatically # Timeout - sets the countdown timer (in seconds) before the default OS get started automatically
# Tune - plays a tune on the pcspeaker right before the XTLDR loads # Tune - plays a tune on the pcspeaker right before the XTLDR loads
# #
@ -25,7 +24,6 @@
Tune=400 880 2 988 2 783 2 392 2 587 3 Tune=400 880 2 988 2 783 2 392 2 587 3
Debug=COM1,115200 Debug=COM1,115200
Timeout=30 Timeout=30
Theme=Fancy
Default=ExectOS Default=ExectOS
[ExectOS] [ExectOS]

View File

@ -13,6 +13,10 @@
#include <xtuefi.h> #include <xtuefi.h>
/* XTLDR directories */
#define XTBL_LOADER_DIRECTORY L"\\EFI\\BOOT\\XTLDR\\"
#define XTBL_THEMES_DIRECTORY L"\\EFI\\BOOT\\XTLDR\\THEMES\\"
/* XTLDR Debug Port type definitions */ /* XTLDR Debug Port type definitions */
#define XTBL_DEBUGPORT_SCREEN 1 #define XTBL_DEBUGPORT_SCREEN 1
#define XTBL_DEBUGPORT_SERIAL 2 #define XTBL_DEBUGPORT_SERIAL 2
@ -38,7 +42,6 @@ typedef struct _XTBL_CONFIGURATION
PWCHAR Debug; PWCHAR Debug;
ULONG DebugPort; ULONG DebugPort;
BOOLEAN Shell; BOOLEAN Shell;
PWCHAR Theme;
ULONG Timeout; ULONG Timeout;
PWCHAR Tune; PWCHAR Tune;
} XTBL_CONFIGURATION, *PXTBL_CONFIGURATION; } XTBL_CONFIGURATION, *PXTBL_CONFIGURATION;

View File

@ -18,7 +18,7 @@
*/ */
XTCDECL XTCDECL
VOID VOID
BlpConfigParseCommandLine(VOID) BlpParseCommandLineOptions(VOID)
{ {
EFI_GUID LIPGuid = EFI_LOADED_IMAGE_PROTOCOL_GUID; EFI_GUID LIPGuid = EFI_LOADED_IMAGE_PROTOCOL_GUID;
PEFI_LOADED_IMAGE_PROTOCOL LoadedImage; PEFI_LOADED_IMAGE_PROTOCOL LoadedImage;
@ -32,7 +32,7 @@ BlpConfigParseCommandLine(VOID)
if(LoadedImage && LoadedImage->LoadOptions) if(LoadedImage && LoadedImage->LoadOptions)
{ {
/* Update global boot loader configuration */ /* Update global boot loader configuration */
BlpConfigUpdateGlobalConfiguration(LoadedImage->LoadOptions); BlpUpdateGlobalConfiguration(LoadedImage->LoadOptions);
} }
} }
} }
@ -49,7 +49,7 @@ BlpConfigParseCommandLine(VOID)
*/ */
XTCDECL XTCDECL
VOID VOID
BlpConfigUpdateGlobalConfiguration(IN PWCHAR Options) BlpUpdateGlobalConfiguration(IN PWCHAR Options)
{ {
PWCHAR Argument, LastArg; PWCHAR Argument, LastArg;
SIZE_T Length; SIZE_T Length;
@ -92,21 +92,6 @@ BlpConfigUpdateGlobalConfiguration(IN PWCHAR Options)
/* Force shell mode */ /* Force shell mode */
BlpConfiguration.Shell = TRUE; BlpConfiguration.Shell = TRUE;
} }
else if(RtlWideStringCompare(Argument, L"THEME=", 6) == 0)
{
/* Skip to the argument value */
Argument += 6;
Length = RtlWideStringLength(Argument, 0);
/* Store theme configuration if not set already */
if(BlpConfiguration.Theme == NULL)
{
/* Save theme in global configuration */
BlMemoryAllocatePool(Length, (PVOID *)&BlpConfiguration.Theme);
RtlCopyMemory(BlpConfiguration.Theme, Argument, (Length * sizeof(WCHAR)) - 1);
BlpConfiguration.Theme[Length] = '\0';
}
}
else if(RtlWideStringCompare(Argument, L"TIMEOUT=", 8) == 0) else if(RtlWideStringCompare(Argument, L"TIMEOUT=", 8) == 0)
{ {
/* Skip to the argument value */ /* Skip to the argument value */

View File

@ -61,6 +61,11 @@ XTCDECL
EFI_STATUS EFI_STATUS
BlMemoryFreePool(IN PVOID Memory); BlMemoryFreePool(IN PVOID Memory);
XTCDECL
EFI_STATUS
BlOpenXtProtocol(OUT PVOID *ProtocolHandler,
IN PEFI_GUID ProtocolGuid);
XTCDECL XTCDECL
VOID VOID
BlSleepExecution(IN ULONG_PTR Milliseconds); BlSleepExecution(IN ULONG_PTR Milliseconds);
@ -76,11 +81,11 @@ BlpActivateSerialIOController();
XTCDECL XTCDECL
VOID VOID
BlpConfigParseCommandLine(VOID); BlpParseCommandLineOptions(VOID);
XTCDECL XTCDECL
VOID VOID
BlpConfigUpdateGlobalConfiguration(IN PWCHAR Options); BlpUpdateGlobalConfiguration(IN PWCHAR Options);
XTCDECL XTCDECL
VOID VOID
@ -108,6 +113,10 @@ BlpInitializeSerialPort(IN ULONG PortNumber,
IN ULONG PortAddress, IN ULONG PortAddress,
IN ULONG BaudRate); IN ULONG BaudRate);
XTCDECL
EFI_STATUS
BlpRegisterXtLoaderProtocol();
XTCDECL XTCDECL
VOID VOID
BlpStringFormat(IN BMPRINTCHAR PrintCharRoutine, BlpStringFormat(IN BMPRINTCHAR PrintCharRoutine,

View File

@ -29,12 +29,16 @@ BlStartXtLoader(IN EFI_HANDLE ImageHandle,
{ {
EFI_STATUS Status; EFI_STATUS Status;
/* Set the system table and image handle */
EfiImageHandle = ImageHandle;
EfiSystemTable = SystemTable;
/* Initialize XTLDR and early print XTLDR version */ /* Initialize XTLDR and early print XTLDR version */
BlpInitializeEfiBootLoader(); BlpInitializeEfiBootLoader();
BlConsolePrint(L"XTLDR boot loader v%s\n", XTOS_VERSION); BlConsolePrint(L"XTLDR boot loader v%s\n", XTOS_VERSION);
/* Parse configuration options passed from UEFI shell */ /* Parse configuration options passed from UEFI shell */
BlpConfigParseCommandLine(); BlpParseCommandLineOptions();
/* Attempt to early initialize debug console */ /* Attempt to early initialize debug console */
if(DEBUG) if(DEBUG)
@ -56,6 +60,14 @@ BlStartXtLoader(IN EFI_HANDLE ImageHandle,
BlDebugPrint(L"WARNING: Failed to disable watchdog timer\n"); BlDebugPrint(L"WARNING: Failed to disable watchdog timer\n");
} }
/* Register loader protocol */
Status = BlpRegisterXtLoaderProtocol();
if(Status != STATUS_EFI_SUCCESS)
{
/* Failed to register loader protocol */
BlDebugPrint(L"ERROR: Failed to register XTLDR loader protocol\n");
}
/* Temporary infinite loop */ /* Temporary infinite loop */
for(;;); for(;;);