Refactor part 1
This commit is contained in:
@@ -2,16 +2,23 @@
|
||||
* PROJECT: ExectOS
|
||||
* COPYRIGHT: See COPYING.md in the top level directory
|
||||
* FILE: xtldr/config.c
|
||||
* DESCRIPTION: XT Boot Manager Configuration
|
||||
* DESCRIPTION: XT Boot Loader Configuration
|
||||
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
||||
*/
|
||||
|
||||
#include <xtbm.h>
|
||||
|
||||
|
||||
/**
|
||||
* Parses command line arguments and updates global configuration.
|
||||
*
|
||||
* @return This routine does not return any value.
|
||||
*
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTCDECL
|
||||
VOID
|
||||
BmpParseCommandLineOptions(VOID)
|
||||
BlpConfigParseCommandLine(VOID)
|
||||
{
|
||||
EFI_GUID LIPGuid = EFI_LOADED_IMAGE_PROTOCOL_GUID;
|
||||
PEFI_LOADED_IMAGE_PROTOCOL LoadedImage;
|
||||
@@ -25,14 +32,24 @@ BmpParseCommandLineOptions(VOID)
|
||||
if(LoadedImage && LoadedImage->LoadOptions)
|
||||
{
|
||||
/* Update global boot loader configuration */
|
||||
BmpUpdateGlobalConfiguration(LoadedImage->LoadOptions);
|
||||
BlpConfigUpdateGlobalConfiguration(LoadedImage->LoadOptions);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates XTLDR configuration based on provided options.
|
||||
*
|
||||
* @param Options
|
||||
* Supplies a formatted list of options to be processed and stored in global configuration.
|
||||
*
|
||||
* @return This routine does not return any value.
|
||||
*
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTCDECL
|
||||
VOID
|
||||
BmpUpdateGlobalConfiguration(IN PWCHAR Options)
|
||||
BlpConfigUpdateGlobalConfiguration(IN PWCHAR Options)
|
||||
{
|
||||
PWCHAR Argument, LastArg;
|
||||
SIZE_T Length;
|
||||
@@ -51,9 +68,9 @@ BmpUpdateGlobalConfiguration(IN PWCHAR Options)
|
||||
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';
|
||||
BlMemoryAllocatePool(Length, (PVOID *)&BlpConfiguration.Default);
|
||||
RtlCopyMemory(BlpConfiguration.Default, Argument, (Length * sizeof(WCHAR)) - 1);
|
||||
BlpConfiguration.Default[Length] = '\0';
|
||||
}
|
||||
else if(RtlWideStringCompare(Argument, L"DEBUG=", 6) == 0)
|
||||
{
|
||||
@@ -62,14 +79,14 @@ BmpUpdateGlobalConfiguration(IN PWCHAR Options)
|
||||
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';
|
||||
BlMemoryAllocatePool(Length, (PVOID *)&BlpConfiguration.Debug);
|
||||
RtlCopyMemory(BlpConfiguration.Debug, Argument, (Length * sizeof(WCHAR)) - 1);
|
||||
BlpConfiguration.Debug[Length] = '\0';
|
||||
}
|
||||
else if(RtlWideStringCompare(Argument, L"SHELL", 5) == 0)
|
||||
{
|
||||
/* Force shell mode */
|
||||
BmpConfiguration.Shell = TRUE;
|
||||
BlpConfiguration.Shell = TRUE;
|
||||
}
|
||||
else if(RtlWideStringCompare(Argument, L"THEME=", 6) == 0)
|
||||
{
|
||||
@@ -78,9 +95,9 @@ BmpUpdateGlobalConfiguration(IN PWCHAR Options)
|
||||
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';
|
||||
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)
|
||||
{
|
||||
@@ -88,13 +105,13 @@ BmpUpdateGlobalConfiguration(IN PWCHAR Options)
|
||||
Argument += 8;
|
||||
|
||||
/* Zero the timeout */
|
||||
BmpConfiguration.Timeout = 0;
|
||||
BlpConfiguration.Timeout = 0;
|
||||
|
||||
/* Read the timeout value and store it in global configuration */
|
||||
while(*Argument >= '0' && *Argument <= '9')
|
||||
{
|
||||
BmpConfiguration.Timeout *= 10;
|
||||
BmpConfiguration.Timeout += *Argument - '0';
|
||||
BlpConfiguration.Timeout *= 10;
|
||||
BlpConfiguration.Timeout += *Argument - '0';
|
||||
Argument++;
|
||||
}
|
||||
}
|
||||
@@ -105,9 +122,9 @@ BmpUpdateGlobalConfiguration(IN PWCHAR Options)
|
||||
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';
|
||||
BlMemoryAllocatePool(Length, (PVOID *)&BlpConfiguration.Tune);
|
||||
RtlCopyMemory(BlpConfiguration.Tune, Argument, (Length * sizeof(WCHAR)) - 1);
|
||||
BlpConfiguration.Tune[Length] = '\0';
|
||||
}
|
||||
|
||||
/* Take next argument */
|
||||
|
||||
Reference in New Issue
Block a user