Refactor BlGetConfigValue to return EFI_STATUS and output value via parameter
This commit is contained in:
parent
1eea654a36
commit
2ee33ab229
@ -54,7 +54,7 @@ typedef EFI_STATUS (*PBL_CLOSE_XT_PROTOCOL)(IN PEFI_HANDLE Handle, IN PEFI_GUID
|
||||
typedef BOOLEAN (*PBL_CONFIG_GET_BOOLEAN_VALUE)(IN CONST PWCHAR ConfigName);
|
||||
typedef EFI_STATUS (*PBL_CONFIG_GET_BOOT_OPTION_VALUE)(IN PLIST_ENTRY Options, IN CONST PWCHAR OptionName, OUT PWCHAR *OptionValue);
|
||||
typedef VOID (*PBL_CONFIG_GET_EDITABLE_OPTIONS)(OUT CONST PWCHAR **OptionsArray, OUT PSIZE_T OptionsCount);
|
||||
typedef PWCHAR (*PBL_CONFIG_GET_VALUE)(IN CONST PWCHAR ConfigName);
|
||||
typedef EFI_STATUS (*PBL_CONFIG_GET_VALUE)(IN CONST PWCHAR ConfigName, OUT PWCHAR *ConfigValue);
|
||||
typedef EFI_STATUS (*PBL_CONFIG_SET_BOOT_OPTION_VALUE)(IN PLIST_ENTRY Options, IN CONST PWCHAR OptionName, IN CONST PWCHAR OptionValue);
|
||||
typedef VOID (*PBL_CONSOLE_CLEAR_SCREEN)();
|
||||
typedef VOID (*PBL_CONSOLE_DISABLE_CURSOR)();
|
||||
|
@ -99,7 +99,7 @@ BlGetConfigBooleanValue(IN CONST PWCHAR ConfigName)
|
||||
PWCHAR Value;
|
||||
|
||||
/* Get config value */
|
||||
Value = BlGetConfigValue(ConfigName);
|
||||
BlGetConfigValue(ConfigName, &Value);
|
||||
|
||||
/* Check if option is enabled */
|
||||
if(RtlCompareWideStringInsensitive(Value, L"ENABLED", 0) == 0 ||
|
||||
@ -126,8 +126,9 @@ BlGetConfigBooleanValue(IN CONST PWCHAR ConfigName)
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTCDECL
|
||||
PWCHAR
|
||||
BlGetConfigValue(IN CONST PWCHAR ConfigName)
|
||||
EFI_STATUS
|
||||
BlGetConfigValue(IN CONST PWCHAR ConfigName,
|
||||
OUT PWCHAR *ConfigValue)
|
||||
{
|
||||
PXTBL_CONFIG_ENTRY ConfigEntry;
|
||||
PLIST_ENTRY ConfigListEntry;
|
||||
@ -135,6 +136,9 @@ BlGetConfigValue(IN CONST PWCHAR ConfigName)
|
||||
EFI_STATUS Status;
|
||||
PWCHAR Value;
|
||||
|
||||
/* Assume the option will not be found */
|
||||
*ConfigValue = NULL;
|
||||
|
||||
/* Get config entry name length */
|
||||
KeyLength = RtlWideStringLength(ConfigName, 0);
|
||||
|
||||
@ -157,13 +161,14 @@ BlGetConfigValue(IN CONST PWCHAR ConfigName)
|
||||
{
|
||||
/* Memory allocation failure, return NULL */
|
||||
BlDebugPrint(L"ERROR: Memory allocation failure (Status Code: 0x%zX)\n", Status);
|
||||
return NULL;
|
||||
return Status;
|
||||
}
|
||||
|
||||
/* Copy value and return it */
|
||||
RtlCopyMemory(Value, ConfigEntry->Value, ValueLength * sizeof(WCHAR));
|
||||
Value[ValueLength] = L'\0';
|
||||
return Value;
|
||||
*ConfigValue = Value;
|
||||
return STATUS_EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/* Move to the next config entry */
|
||||
@ -171,7 +176,7 @@ BlGetConfigValue(IN CONST PWCHAR ConfigName)
|
||||
}
|
||||
|
||||
/* Config entry not found, return NULL */
|
||||
return NULL;
|
||||
return STATUS_EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -852,6 +857,7 @@ VOID
|
||||
BlpUpdateConfiguration(IN PLIST_ENTRY NewConfig)
|
||||
{
|
||||
PXTBL_CONFIG_ENTRY ConfigEntry;
|
||||
PWCHAR ConfigValue;
|
||||
PLIST_ENTRY ConfigListEntry, NextListEntry;
|
||||
|
||||
/* Iterate through new config entries */
|
||||
@ -865,7 +871,8 @@ BlpUpdateConfiguration(IN PLIST_ENTRY NewConfig)
|
||||
NextListEntry = ConfigListEntry->Flink;
|
||||
|
||||
/* Make sure config entry does not exist yet */
|
||||
if(BlGetConfigValue(ConfigEntry->Name) == NULL)
|
||||
BlGetConfigValue(ConfigEntry->Name, &ConfigValue);
|
||||
if(ConfigValue == NULL)
|
||||
{
|
||||
/* Remove new config entry from input list and put it into global config list */
|
||||
RtlRemoveEntryList(&ConfigEntry->Flink);
|
||||
|
@ -105,7 +105,7 @@ BlpInitializeDebugConsole()
|
||||
BaudRate = 0;
|
||||
|
||||
/* Get debug configuration */
|
||||
DebugConfiguration = BlGetConfigValue(L"DEBUG");
|
||||
BlGetConfigValue(L"DEBUG", &DebugConfiguration);
|
||||
|
||||
/* Make sure any debug options are provided and debug console is not initialized yet */
|
||||
if(DebugConfiguration && BlpStatus.DebugPort == 0)
|
||||
|
@ -149,8 +149,9 @@ BOOLEAN
|
||||
BlGetConfigBooleanValue(IN CONST PWCHAR ConfigName);
|
||||
|
||||
XTCDECL
|
||||
PWCHAR
|
||||
BlGetConfigValue(IN CONST PWCHAR ConfigName);
|
||||
EFI_STATUS
|
||||
BlGetConfigValue(IN CONST PWCHAR ConfigName,
|
||||
OUT PWCHAR *ConfigValue);
|
||||
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
|
@ -196,6 +196,7 @@ XtLdrModuleMain(IN EFI_HANDLE ImageHandle,
|
||||
IN PEFI_SYSTEM_TABLE SystemTable)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
PWCHAR Tune;
|
||||
|
||||
/* Open the XTLDR protocol */
|
||||
Status = BlGetXtLdrProtocol(SystemTable, ImageHandle, &XtLdrProtocol);
|
||||
@ -206,7 +207,8 @@ XtLdrModuleMain(IN EFI_HANDLE ImageHandle,
|
||||
}
|
||||
|
||||
/* Play the tune set in the configuration */
|
||||
BpPlayTune(XtLdrProtocol->Config.GetValue(L"TUNE"));
|
||||
XtLdrProtocol->Config.GetValue(L"TUNE", &Tune);
|
||||
BpPlayTune(Tune);
|
||||
|
||||
/* Return success */
|
||||
return STATUS_EFI_SUCCESS;
|
||||
|
@ -57,7 +57,7 @@ BlDisplayBootMenu()
|
||||
}
|
||||
|
||||
/* Get timeout from the configuration */
|
||||
TimeOutString = BlGetConfigValue(L"TIMEOUT");
|
||||
BlGetConfigValue(L"TIMEOUT", &TimeOutString);
|
||||
TimeOut = -1;
|
||||
|
||||
/* Check if timeout is specified */
|
||||
|
@ -109,7 +109,7 @@ BlInitializeBootMenuList(IN ULONG MaxNameLength,
|
||||
NumberOfEntries = 0;
|
||||
|
||||
/* Get default menu entry from configuration */
|
||||
DefaultMenuEntry = BlGetConfigValue(L"DEFAULT");
|
||||
BlGetConfigValue(L"DEFAULT", &DefaultMenuEntry);
|
||||
|
||||
/* Check if configuration allows to use last booted OS */
|
||||
if(BlGetConfigBooleanValue(L"KEEPLASTBOOT"))
|
||||
@ -391,6 +391,7 @@ EFI_STATUS
|
||||
BlStartXtLoader(IN EFI_HANDLE ImageHandle,
|
||||
IN PEFI_SYSTEM_TABLE SystemTable)
|
||||
{
|
||||
PWCHAR Modules;
|
||||
EFI_STATUS Status;
|
||||
|
||||
/* Set the system table and image handle */
|
||||
@ -455,8 +456,9 @@ BlStartXtLoader(IN EFI_HANDLE ImageHandle,
|
||||
return Status;
|
||||
}
|
||||
|
||||
/* Load boot loader modules */
|
||||
Status = BlLoadModules(BlGetConfigValue(L"MODULES"));
|
||||
/* Load all necessary modules */
|
||||
BlGetConfigValue(L"MODULES", &Modules);
|
||||
Status = BlLoadModules(Modules);
|
||||
if(Status != STATUS_EFI_SUCCESS)
|
||||
{
|
||||
/* Failed to load modules */
|
||||
|
Loading…
x
Reference in New Issue
Block a user