Initial XTLDR configuration
This commit is contained in:
parent
e302f662bb
commit
ab7fa5ffa4
@ -8,6 +8,7 @@ include_directories(
|
|||||||
|
|
||||||
# Specify list of source code files
|
# Specify list of source code files
|
||||||
list(APPEND XTLDR_SOURCE
|
list(APPEND XTLDR_SOURCE
|
||||||
|
${XTLDR_SOURCE_DIR}/config.c
|
||||||
${XTLDR_SOURCE_DIR}/console.c
|
${XTLDR_SOURCE_DIR}/console.c
|
||||||
${XTLDR_SOURCE_DIR}/globals.c
|
${XTLDR_SOURCE_DIR}/globals.c
|
||||||
${XTLDR_SOURCE_DIR}/hardware.c
|
${XTLDR_SOURCE_DIR}/hardware.c
|
||||||
|
116
xtldr2/config.c
Normal file
116
xtldr2/config.c
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
/**
|
||||||
|
* PROJECT: ExectOS
|
||||||
|
* COPYRIGHT: See COPYING.md in the top level directory
|
||||||
|
* FILE: xtldr/config.c
|
||||||
|
* DESCRIPTION: XT Boot Manager Configuration
|
||||||
|
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <xtbm.h>
|
||||||
|
|
||||||
|
|
||||||
|
XTCDECL
|
||||||
|
VOID
|
||||||
|
BmpParseCommandLineOptions(VOID)
|
||||||
|
{
|
||||||
|
EFI_GUID LIPGuid = EFI_LOADED_IMAGE_PROTOCOL_GUID;
|
||||||
|
PEFI_LOADED_IMAGE_PROTOCOL LoadedImage;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
/* Handle loaded image protocol */
|
||||||
|
Status = EfiSystemTable->BootServices->HandleProtocol(EfiImageHandle, &LIPGuid, (PVOID *)&LoadedImage);
|
||||||
|
if(Status == STATUS_EFI_SUCCESS)
|
||||||
|
{
|
||||||
|
/* Check if launched from UEFI shell */
|
||||||
|
if(LoadedImage && LoadedImage->LoadOptions)
|
||||||
|
{
|
||||||
|
/* Update global boot loader configuration */
|
||||||
|
BmpUpdateGlobalConfiguration(LoadedImage->LoadOptions);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
XTCDECL
|
||||||
|
VOID
|
||||||
|
BmpUpdateGlobalConfiguration(IN PWCHAR Options)
|
||||||
|
{
|
||||||
|
PWCHAR Argument, LastArg;
|
||||||
|
SIZE_T Length;
|
||||||
|
|
||||||
|
/* Tokenize provided options */
|
||||||
|
Argument = RtlWideStringTokenize(Options, L" ", &LastArg);
|
||||||
|
|
||||||
|
/* Iterate over all arguments passed to boot loader */
|
||||||
|
while(Argument != NULL)
|
||||||
|
{
|
||||||
|
/* Check all provided parameters */
|
||||||
|
if(RtlWideStringCompare(Argument, L"DEFAULT=", 8) == 0)
|
||||||
|
{
|
||||||
|
/* Skip to the argument value and calculate argument length */
|
||||||
|
Argument += 8;
|
||||||
|
Length = RtlWideStringLength(Argument, 0);
|
||||||
|
|
||||||
|
/* Save default OS parameter in global configuration */
|
||||||
|
BmAllocateEfiPool(Length, (PVOID *)&BmpConfiguration.Default);
|
||||||
|
RtlCopyMemory(BmpConfiguration.Default, Argument, (Length * sizeof(WCHAR)) - 1);
|
||||||
|
BmpConfiguration.Default[Length] = '\0';
|
||||||
|
}
|
||||||
|
else if(RtlWideStringCompare(Argument, L"DEBUG=", 6) == 0)
|
||||||
|
{
|
||||||
|
/* Skip to the argument value */
|
||||||
|
Argument += 6;
|
||||||
|
Length = RtlWideStringLength(Argument, 0);
|
||||||
|
|
||||||
|
/* Save debug port in global configuration */
|
||||||
|
BmAllocateEfiPool(Length, (PVOID *)&BmpConfiguration.Debug);
|
||||||
|
RtlCopyMemory(BmpConfiguration.Debug, Argument, (Length * sizeof(WCHAR)) - 1);
|
||||||
|
BmpConfiguration.Debug[Length] = '\0';
|
||||||
|
}
|
||||||
|
else if(RtlWideStringCompare(Argument, L"SHELL", 5) == 0)
|
||||||
|
{
|
||||||
|
/* Force shell mode */
|
||||||
|
BmpConfiguration.Shell = TRUE;
|
||||||
|
}
|
||||||
|
else if(RtlWideStringCompare(Argument, L"THEME=", 6) == 0)
|
||||||
|
{
|
||||||
|
/* Skip to the argument value */
|
||||||
|
Argument += 6;
|
||||||
|
Length = RtlWideStringLength(Argument, 0);
|
||||||
|
|
||||||
|
/* Save theme in global configuration */
|
||||||
|
BmAllocateEfiPool(Length, (PVOID *)&BmpConfiguration.Theme);
|
||||||
|
RtlCopyMemory(BmpConfiguration.Theme, Argument, (Length * sizeof(WCHAR)) - 1);
|
||||||
|
BmpConfiguration.Theme[Length] = '\0';
|
||||||
|
}
|
||||||
|
else if(RtlWideStringCompare(Argument, L"TIMEOUT=", 8) == 0)
|
||||||
|
{
|
||||||
|
/* Skip to the argument value */
|
||||||
|
Argument += 8;
|
||||||
|
|
||||||
|
/* Zero the timeout */
|
||||||
|
BmpConfiguration.Timeout = 0;
|
||||||
|
|
||||||
|
/* Read the timeout value and store it in global configuration */
|
||||||
|
while(*Argument >= '0' && *Argument <= '9')
|
||||||
|
{
|
||||||
|
BmpConfiguration.Timeout *= 10;
|
||||||
|
BmpConfiguration.Timeout += *Argument - '0';
|
||||||
|
Argument++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(RtlWideStringCompare(Argument, L"TUNE=", 5) == 0)
|
||||||
|
{
|
||||||
|
/* Skip to the argument value */
|
||||||
|
Argument += 5;
|
||||||
|
Length = RtlWideStringLength(Argument, 0);
|
||||||
|
|
||||||
|
/* Save theme in global configuration */
|
||||||
|
BmAllocateEfiPool(Length, (PVOID *)&BmpConfiguration.Tune);
|
||||||
|
RtlCopyMemory(BmpConfiguration.Tune, Argument, (Length * sizeof(WCHAR)) - 1);
|
||||||
|
BmpConfiguration.Tune[Length] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Take next argument */
|
||||||
|
Argument = RtlWideStringTokenize(NULL, L" ", &LastArg);
|
||||||
|
}
|
||||||
|
}
|
@ -9,6 +9,9 @@
|
|||||||
#include <xtbm.h>
|
#include <xtbm.h>
|
||||||
|
|
||||||
|
|
||||||
|
/* XT Boot Loader configuration data */
|
||||||
|
XTBM_CONFIGURATION BmpConfiguration = {0};
|
||||||
|
|
||||||
/* XT Boot Loader hex table */
|
/* XT Boot Loader hex table */
|
||||||
STATIC PUINT16 BmpHexTable = L"0123456789ABCDEF";
|
STATIC PUINT16 BmpHexTable = L"0123456789ABCDEF";
|
||||||
|
|
||||||
|
@ -72,12 +72,17 @@ EFI_STATUS
|
|||||||
BmStartXtLoader(IN EFI_HANDLE ImageHandle,
|
BmStartXtLoader(IN EFI_HANDLE ImageHandle,
|
||||||
IN PEFI_SYSTEM_TABLE SystemTable);
|
IN PEFI_SYSTEM_TABLE SystemTable);
|
||||||
|
|
||||||
|
|
||||||
XTCDECL
|
XTCDECL
|
||||||
VOID
|
VOID
|
||||||
BmpFormatString(IN BMPRINTCHAR PrintCharRoutine,
|
BmpFormatString(IN BMPRINTCHAR PrintCharRoutine,
|
||||||
IN PUINT16 Format,
|
IN PUINT16 Format,
|
||||||
IN ...);
|
IN ...);
|
||||||
|
|
||||||
|
XTCDECL
|
||||||
|
VOID
|
||||||
|
BmpParseCommandLineOptions(VOID);
|
||||||
|
|
||||||
XTCDECL
|
XTCDECL
|
||||||
VOID
|
VOID
|
||||||
BmpPrintSigned32String(IN BMPRINTCHAR PrintCharRoutine,
|
BmpPrintSigned32String(IN BMPRINTCHAR PrintCharRoutine,
|
||||||
@ -108,4 +113,8 @@ XTCDECL
|
|||||||
UINT64
|
UINT64
|
||||||
BmpReadStringPadding(IN PUINT16 *Format);
|
BmpReadStringPadding(IN PUINT16 *Format);
|
||||||
|
|
||||||
|
XTCDECL
|
||||||
|
VOID
|
||||||
|
BmpUpdateGlobalConfiguration(IN PWCHAR Options);
|
||||||
|
|
||||||
#endif /* __XTLDR_BOOTMAN_H */
|
#endif /* __XTLDR_BOOTMAN_H */
|
||||||
|
@ -12,6 +12,9 @@
|
|||||||
#include <xtbmapi.h>
|
#include <xtbmapi.h>
|
||||||
|
|
||||||
|
|
||||||
|
/* XT Boot Loader configuration data */
|
||||||
|
EXTERN XTBM_CONFIGURATION BmpConfiguration;
|
||||||
|
|
||||||
/* XT Boot Loader hex table */
|
/* XT Boot Loader hex table */
|
||||||
EXTERN PUINT16 BmpHexTable;
|
EXTERN PUINT16 BmpHexTable;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user