+++ /dev/null
-/** @file\r
- Report Status Code Library that depends on a GUIDed HOB for report status\r
- code functionality.\r
-\r
- Copyright (c) 2009, Intel Corporation. All rights reserved.<BR>\r
- This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include "ReportStatusCodeLibInternal.h"\r
-\r
-//\r
-// Handle to install report status code protocol interface\r
-//\r
-EFI_HANDLE mHandle = NULL;\r
-\r
-//\r
-// Report status protocol interface.\r
-//\r
-EFI_STATUS_CODE_PROTOCOL mStatusProtocol = {\r
- NULL\r
-};\r
-\r
-/**\r
- Initializes report status code infrastructure for DXE phase.\r
-\r
- The constructor function assumes the PEI phase has published the GUIDed HOB\r
- tagged by gEfiStatusCodeRuntimeProtocolGuid and publish status code runtime\r
- protocol based on the GUID data. It will ASSERT() if one of these operations\r
- fails and it will always return EFI_SUCCESS.\r
-\r
- @param ImageHandle The firmware allocated handle for the EFI image.\r
- @param SystemTable A pointer to the EFI System Table.\r
-\r
- @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-DxeCoreReportStatusCodeFromHobLibConstructor (\r
- IN EFI_HANDLE ImageHandle,\r
- IN EFI_SYSTEM_TABLE *SystemTable\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_HOB_GUID_TYPE *GuidHob;\r
-\r
- GuidHob = GetFirstGuidHob(&gEfiStatusCodeRuntimeProtocolGuid);\r
- ASSERT (GuidHob != NULL);\r
- \r
- mStatusProtocol.ReportStatusCode = (EFI_REPORT_STATUS_CODE) (*(UINTN *) GET_GUID_HOB_DATA (GuidHob));\r
- ASSERT (mStatusProtocol.ReportStatusCode != NULL);\r
-\r
- //\r
- // Install report status protocol interface so that later DXE phase drivers can retrieve the protocol\r
- // interface to report status code.\r
- //\r
- Status = gBS->InstallProtocolInterface (\r
- &mHandle,\r
- &gEfiStatusCodeRuntimeProtocolGuid,\r
- EFI_NATIVE_INTERFACE,\r
- &mStatusProtocol\r
- );\r
- ASSERT_EFI_ERROR (Status);\r
-\r
- return Status;\r
-}\r
-\r
-/**\r
- Reports a status code with full parameters.\r
-\r
- The function reports a status code. If ExtendedData is NULL and ExtendedDataSize\r
- is 0, then an extended data buffer is not reported. If ExtendedData is not\r
- NULL and ExtendedDataSize is not 0, then an extended data buffer is allocated.\r
- ExtendedData is assumed not have the standard status code header, so this function\r
- is responsible for allocating a buffer large enough for the standard header and\r
- the extended data passed into this function. The standard header is filled in\r
- with a GUID specified by ExtendedDataGuid. If ExtendedDataGuid is NULL, then a\r
- GUID of gEfiStatusCodeSpecificDatauid is used. The status code is reported with\r
- an instance specified by Instance and a caller ID specified by CallerId. If\r
- CallerId is NULL, then a caller ID of gEfiCallerIdGuid is used.\r
-\r
- ReportStatusCodeEx()must actively prevent recursion. If ReportStatusCodeEx()\r
- is called while processing another any other Report Status Code Library function,\r
- then ReportStatusCodeEx() must return EFI_DEVICE_ERROR immediately.\r
-\r
- If ExtendedData is NULL and ExtendedDataSize is not zero, then ASSERT().\r
- If ExtendedData is not NULL and ExtendedDataSize is zero, then ASSERT().\r
-\r
- @param Type Status code type.\r
- @param Value Status code value.\r
- @param Instance Status code instance number.\r
- @param CallerId Pointer to a GUID that identifies the caller of this\r
- function. If this parameter is NULL, then a caller\r
- ID of gEfiCallerIdGuid is used.\r
- @param ExtendedDataGuid Pointer to the GUID for the extended data buffer.\r
- If this parameter is NULL, then a the status code\r
- standard header is filled in with\r
- gEfiStatusCodeSpecificDataGuid.\r
- @param ExtendedData Pointer to the extended data buffer. This is an\r
- optional parameter that may be NULL.\r
- @param ExtendedDataSize The size, in bytes, of the extended data buffer.\r
-\r
- @retval EFI_SUCCESS The status code was reported.\r
- @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate\r
- the extended data section if it was specified.\r
- @retval EFI_UNSUPPORTED Report status code is not supported\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-InternalReportStatusCodeEx (\r
- IN EFI_STATUS_CODE_TYPE Type,\r
- IN EFI_STATUS_CODE_VALUE Value,\r
- IN UINT32 Instance,\r
- IN CONST EFI_GUID *CallerId OPTIONAL,\r
- IN CONST EFI_GUID *ExtendedDataGuid OPTIONAL,\r
- IN CONST VOID *ExtendedData OPTIONAL,\r
- IN UINTN ExtendedDataSize\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_STATUS_CODE_DATA *StatusCodeData;\r
-\r
- ASSERT (!((ExtendedData == NULL) && (ExtendedDataSize != 0)));\r
- ASSERT (!((ExtendedData != NULL) && (ExtendedDataSize == 0)));\r
-\r
- if (gBS == NULL) {\r
- return EFI_UNSUPPORTED;\r
- }\r
-\r
- //\r
- // Allocate space for the Status Code Header and its buffer\r
- //\r
- StatusCodeData = NULL;\r
- gBS->AllocatePool (EfiBootServicesData, sizeof (EFI_STATUS_CODE_DATA) + ExtendedDataSize, (VOID **)&StatusCodeData);\r
- if (StatusCodeData == NULL) {\r
- return EFI_OUT_OF_RESOURCES;\r
- }\r
-\r
- //\r
- // Fill in the extended data header\r
- //\r
- StatusCodeData->HeaderSize = sizeof (EFI_STATUS_CODE_DATA);\r
- StatusCodeData->Size = (UINT16)ExtendedDataSize;\r
- if (ExtendedDataGuid == NULL) {\r
- ExtendedDataGuid = &gEfiStatusCodeSpecificDataGuid;\r
- }\r
- CopyGuid (&StatusCodeData->Type, ExtendedDataGuid);\r
-\r
- //\r
- // Fill in the extended data buffer\r
- //\r
- CopyMem (StatusCodeData + 1, ExtendedData, ExtendedDataSize);\r
-\r
- //\r
- // Report the status code\r
- //\r
- if (CallerId == NULL) {\r
- CallerId = &gEfiCallerIdGuid;\r
- }\r
- Status = InternalReportStatusCode (Type, Value, Instance, CallerId, StatusCodeData);\r
-\r
- //\r
- // Free the allocated buffer\r
- //\r
- gBS->FreePool (StatusCodeData);\r
-\r
- return Status;\r
-}\r
-\r