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