\r
#include <Pi/PiStatusCode.h>\r
\r
-\r
//\r
// Convenience variables for the status codes that are relevant for LoadImage()\r
// and StartImage() preparations and return codes.\r
//\r
-STATIC EFI_STATUS_CODE_VALUE mLoadPrep;\r
-STATIC EFI_STATUS_CODE_VALUE mLoadFail;\r
-STATIC EFI_STATUS_CODE_VALUE mStartPrep;\r
-STATIC EFI_STATUS_CODE_VALUE mStartFail;\r
-\r
+STATIC EFI_STATUS_CODE_VALUE mLoadPrep;\r
+STATIC EFI_STATUS_CODE_VALUE mLoadFail;\r
+STATIC EFI_STATUS_CODE_VALUE mStartPrep;\r
+STATIC EFI_STATUS_CODE_VALUE mStartFail;\r
\r
/**\r
Handle status codes reported through ReportStatusCodeLib /\r
EFI_STATUS\r
EFIAPI\r
HandleStatusCode (\r
- IN EFI_STATUS_CODE_TYPE CodeType,\r
- IN EFI_STATUS_CODE_VALUE Value,\r
- IN UINT32 Instance,\r
- IN EFI_GUID *CallerId,\r
- IN EFI_STATUS_CODE_DATA *Data\r
+ IN EFI_STATUS_CODE_TYPE CodeType,\r
+ IN EFI_STATUS_CODE_VALUE Value,\r
+ IN UINT32 Instance,\r
+ IN EFI_GUID *CallerId,\r
+ IN EFI_STATUS_CODE_DATA *Data\r
)\r
{\r
- UINTN VariableSize;\r
- UINT16 BootCurrent;\r
- EFI_STATUS Status;\r
- CHAR16 BootOptionName[ARRAY_SIZE (L"Boot####")];\r
- EFI_BOOT_MANAGER_LOAD_OPTION BmBootOption;\r
- BOOLEAN DevPathStringIsDynamic;\r
- CHAR16 *DevPathString;\r
+ UINTN VariableSize;\r
+ UINT16 BootCurrent;\r
+ EFI_STATUS Status;\r
+ CHAR16 BootOptionName[ARRAY_SIZE (L"Boot####")];\r
+ EFI_BOOT_MANAGER_LOAD_OPTION BmBootOption;\r
+ BOOLEAN DevPathStringIsDynamic;\r
+ CHAR16 *DevPathString;\r
\r
//\r
// Ignore all status codes that are irrelevant for LoadImage() and\r
// StartImage() preparations and return codes.\r
//\r
- if (Value != mLoadPrep && Value != mLoadFail &&\r
- Value != mStartPrep && Value != mStartFail) {\r
+ if ((Value != mLoadPrep) && (Value != mLoadFail) &&\r
+ (Value != mStartPrep) && (Value != mStartFail))\r
+ {\r
return EFI_SUCCESS;\r
}\r
+\r
//\r
// Ignore status codes that are not reported by the same containing module.\r
//\r
//\r
// Sanity-check Data in case of failure reports.\r
//\r
- if ((Value == mLoadFail || Value == mStartFail) &&\r
- (Data == NULL ||\r
- Data->HeaderSize != sizeof *Data ||\r
- Data->Size != sizeof (EFI_RETURN_STATUS_EXTENDED_DATA) - sizeof *Data ||\r
- !CompareGuid (&Data->Type, &gEfiStatusCodeSpecificDataGuid))) {\r
- DEBUG ((DEBUG_ERROR, "%a:%a: malformed Data\n", gEfiCallerBaseName,\r
- __FUNCTION__));\r
+ if (((Value == mLoadFail) || (Value == mStartFail)) &&\r
+ ((Data == NULL) ||\r
+ (Data->HeaderSize != sizeof *Data) ||\r
+ (Data->Size != sizeof (EFI_RETURN_STATUS_EXTENDED_DATA) - sizeof *Data) ||\r
+ !CompareGuid (&Data->Type, &gEfiStatusCodeSpecificDataGuid)))\r
+ {\r
+ DEBUG ((\r
+ DEBUG_ERROR,\r
+ "%a:%a: malformed Data\n",\r
+ gEfiCallerBaseName,\r
+ __FUNCTION__\r
+ ));\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
// Get the number of the Boot#### option that the status code applies to.\r
//\r
VariableSize = sizeof BootCurrent;\r
- Status = gRT->GetVariable (EFI_BOOT_CURRENT_VARIABLE_NAME,\r
- &gEfiGlobalVariableGuid, NULL /* Attributes */,\r
- &VariableSize, &BootCurrent);\r
+ Status = gRT->GetVariable (\r
+ EFI_BOOT_CURRENT_VARIABLE_NAME,\r
+ &gEfiGlobalVariableGuid,\r
+ NULL /* Attributes */,\r
+ &VariableSize,\r
+ &BootCurrent\r
+ );\r
if (EFI_ERROR (Status)) {\r
- DEBUG ((DEBUG_ERROR, "%a:%a: failed to get %g:\"%s\": %r\n",\r
- gEfiCallerBaseName, __FUNCTION__, &gEfiGlobalVariableGuid,\r
- EFI_BOOT_CURRENT_VARIABLE_NAME, Status));\r
+ DEBUG ((\r
+ DEBUG_ERROR,\r
+ "%a:%a: failed to get %g:\"%s\": %r\n",\r
+ gEfiCallerBaseName,\r
+ __FUNCTION__,\r
+ &gEfiGlobalVariableGuid,\r
+ EFI_BOOT_CURRENT_VARIABLE_NAME,\r
+ Status\r
+ ));\r
return Status;\r
}\r
+\r
if (VariableSize != sizeof BootCurrent) {\r
- DEBUG ((DEBUG_ERROR, "%a:%a: got %Lu bytes for %g:\"%s\", expected %Lu\n",\r
- gEfiCallerBaseName, __FUNCTION__, (UINT64)VariableSize,\r
- &gEfiGlobalVariableGuid, EFI_BOOT_CURRENT_VARIABLE_NAME,\r
- (UINT64)sizeof BootCurrent));\r
+ DEBUG ((\r
+ DEBUG_ERROR,\r
+ "%a:%a: got %Lu bytes for %g:\"%s\", expected %Lu\n",\r
+ gEfiCallerBaseName,\r
+ __FUNCTION__,\r
+ (UINT64)VariableSize,\r
+ &gEfiGlobalVariableGuid,\r
+ EFI_BOOT_CURRENT_VARIABLE_NAME,\r
+ (UINT64)sizeof BootCurrent\r
+ ));\r
return EFI_INCOMPATIBLE_VERSION;\r
}\r
\r
//\r
// Get the Boot#### option that the status code applies to.\r
//\r
- UnicodeSPrint (BootOptionName, sizeof BootOptionName, L"Boot%04x",\r
- BootCurrent);\r
+ UnicodeSPrint (\r
+ BootOptionName,\r
+ sizeof BootOptionName,\r
+ L"Boot%04x",\r
+ BootCurrent\r
+ );\r
Status = EfiBootManagerVariableToLoadOption (BootOptionName, &BmBootOption);\r
if (EFI_ERROR (Status)) {\r
- DEBUG ((DEBUG_ERROR,\r
+ DEBUG ((\r
+ DEBUG_ERROR,\r
"%a:%a: EfiBootManagerVariableToLoadOption(\"%s\"): %r\n",\r
- gEfiCallerBaseName, __FUNCTION__, BootOptionName, Status));\r
+ gEfiCallerBaseName,\r
+ __FUNCTION__,\r
+ BootOptionName,\r
+ Status\r
+ ));\r
return Status;\r
}\r
\r
// Format the device path.\r
//\r
DevPathStringIsDynamic = TRUE;\r
- DevPathString = ConvertDevicePathToText (\r
- BmBootOption.FilePath,\r
- FALSE, // DisplayOnly\r
- FALSE // AllowShortcuts\r
- );\r
+ DevPathString = ConvertDevicePathToText (\r
+ BmBootOption.FilePath,\r
+ FALSE, // DisplayOnly\r
+ FALSE // AllowShortcuts\r
+ );\r
if (DevPathString == NULL) {\r
DevPathStringIsDynamic = FALSE;\r
- DevPathString = L"<out of memory while formatting device path>";\r
+ DevPathString = L"<out of memory while formatting device path>";\r
}\r
\r
//\r
// Print the message to the console.\r
//\r
- if (Value == mLoadPrep || Value == mStartPrep) {\r
+ if ((Value == mLoadPrep) || (Value == mStartPrep)) {\r
Print (\r
L"%a: %a %s \"%s\" from %s\n",\r
gEfiCallerBaseName,\r
if (DevPathStringIsDynamic) {\r
FreePool (DevPathString);\r
}\r
+\r
EfiBootManagerFreeLoadOption (&BmBootOption);\r
return EFI_SUCCESS;\r
}\r
\r
-\r
/**\r
Unregister HandleStatusCode() at ExitBootServices().\r
\r
VOID\r
EFIAPI\r
UnregisterAtExitBootServices (\r
- IN EFI_EVENT Event,\r
- IN VOID *Context\r
+ IN EFI_EVENT Event,\r
+ IN VOID *Context\r
)\r
{\r
- EFI_RSC_HANDLER_PROTOCOL *StatusCodeRouter;\r
+ EFI_RSC_HANDLER_PROTOCOL *StatusCodeRouter;\r
\r
StatusCodeRouter = Context;\r
StatusCodeRouter->Unregister (HandleStatusCode);\r
}\r
\r
-\r
/**\r
Register a status code handler for printing the Boot Manager's LoadImage()\r
and StartImage() preparations, and return codes, to the UEFI console.\r
VOID\r
)\r
{\r
- EFI_STATUS Status;\r
- EFI_RSC_HANDLER_PROTOCOL *StatusCodeRouter;\r
- EFI_EVENT ExitBootEvent;\r
-\r
- Status = gBS->LocateProtocol (&gEfiRscHandlerProtocolGuid,\r
- NULL /* Registration */, (VOID **)&StatusCodeRouter);\r
+ EFI_STATUS Status;\r
+ EFI_RSC_HANDLER_PROTOCOL *StatusCodeRouter;\r
+ EFI_EVENT ExitBootEvent;\r
+\r
+ Status = gBS->LocateProtocol (\r
+ &gEfiRscHandlerProtocolGuid,\r
+ NULL /* Registration */,\r
+ (VOID **)&StatusCodeRouter\r
+ );\r
ASSERT_EFI_ERROR (Status);\r
if (EFI_ERROR (Status)) {\r
return Status;\r
//\r
// Set the EFI_STATUS_CODE_VALUE convenience variables.\r
//\r
- mLoadPrep = PcdGet32 (PcdProgressCodeOsLoaderLoad);\r
- mLoadFail = (EFI_SOFTWARE_DXE_BS_DRIVER |\r
- EFI_SW_DXE_BS_EC_BOOT_OPTION_LOAD_ERROR);\r
+ mLoadPrep = PcdGet32 (PcdProgressCodeOsLoaderLoad);\r
+ mLoadFail = (EFI_SOFTWARE_DXE_BS_DRIVER |\r
+ EFI_SW_DXE_BS_EC_BOOT_OPTION_LOAD_ERROR);\r
mStartPrep = PcdGet32 (PcdProgressCodeOsLoaderStart);\r
mStartFail = (EFI_SOFTWARE_DXE_BS_DRIVER |\r
EFI_SW_DXE_BS_EC_BOOT_OPTION_FAILED);\r
//\r
Status = StatusCodeRouter->Register (HandleStatusCode, TPL_CALLBACK);\r
if (EFI_ERROR (Status)) {\r
- DEBUG ((DEBUG_ERROR, "%a:%a: failed to register status code handler: %r\n",\r
- gEfiCallerBaseName, __FUNCTION__, Status));\r
+ DEBUG ((\r
+ DEBUG_ERROR,\r
+ "%a:%a: failed to register status code handler: %r\n",\r
+ gEfiCallerBaseName,\r
+ __FUNCTION__,\r
+ Status\r
+ ));\r
return Status;\r
}\r
\r
//\r
// We have to unregister the callback right now, and fail the function.\r
//\r
- DEBUG ((DEBUG_ERROR, "%a:%a: failed to create ExitBootServices() event: "\r
- "%r\n", gEfiCallerBaseName, __FUNCTION__, Status));\r
+ DEBUG ((\r
+ DEBUG_ERROR,\r
+ "%a:%a: failed to create ExitBootServices() event: "\r
+ "%r\n",\r
+ gEfiCallerBaseName,\r
+ __FUNCTION__,\r
+ Status\r
+ ));\r
StatusCodeRouter->Unregister (HandleStatusCode);\r
return Status;\r
}\r