[LibraryClasses]\r
PcdLib\r
BaseMemoryLib\r
- MemoryAllocationLib\r
UefiBootServicesTableLib\r
DebugLib\r
UefiRuntimeServicesTableLib\r
gEfiStatusCodeDataTypeDebugGuid ## CONSUMES\r
\r
[Protocols]\r
- gEfiStatusCodeRuntimeProtocolGuid ## SOMETIMES_CONSUMES (Used if revision of the EFI Specification is not less than 0x20000)\r
+ gEfiStatusCodeRuntimeProtocolGuid ## CONSUMES\r
\r
[Pcd.common]\r
gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask\r
**/\r
\r
#include <Library/ReportStatusCodeLib.h>\r
+#include <Library/BaseLib.h>\r
#include <Library/DebugLib.h>\r
#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/BaseLib.h>\r
#include <Library/BaseMemoryLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
#include <Library/PcdLib.h>\r
-#include <Library/UefiRuntimeServicesTableLib.h>\r
#include <Library/DevicePathLib.h>\r
\r
+#include <Protocol/StatusCode.h>\r
+\r
#include <Guid/StatusCodeDataTypeId.h>\r
#include <Guid/StatusCodeDataTypeDebug.h>\r
-#include <Protocol/StatusCode.h>\r
\r
-EFI_REPORT_STATUS_CODE mReportStatusCode = NULL;\r
+EFI_STATUS_CODE_PROTOCOL *mReportStatusCodeLibStatusCodeProtocol = NULL;\r
\r
/**\r
Locate the report status code service.\r
\r
- @return Function pointer to the report status code service.\r
- NULL is returned if no status code service is available.\r
+ Retrieve ReportStatusCode() API of Report Status Code Protocol.\r
\r
**/\r
-EFI_REPORT_STATUS_CODE\r
+VOID\r
InternalGetReportStatusCode (\r
VOID\r
)\r
{\r
- EFI_STATUS_CODE_PROTOCOL *StatusCodeProtocol;\r
- EFI_STATUS Status;\r
+ EFI_STATUS Status;\r
+\r
+ if (mReportStatusCodeLibStatusCodeProtocol != NULL) {\r
+ return;\r
+ }\r
\r
+ //\r
+ // Check gBS just in case ReportStatusCode is called before gBS is initialized.\r
+ //\r
if (gBS != NULL && gBS->LocateProtocol != NULL) {\r
- Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID**)&StatusCodeProtocol);\r
- if (!EFI_ERROR (Status) && StatusCodeProtocol != NULL) {\r
- return StatusCodeProtocol->ReportStatusCode;\r
+ Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID**) &mReportStatusCodeLibStatusCodeProtocol);\r
+ if (EFI_ERROR (Status)) {\r
+ mReportStatusCodeLibStatusCodeProtocol = NULL;\r
}\r
}\r
-\r
- return NULL;\r
}\r
\r
/**\r
- Internal worker function that reports a status code through the status code service.\r
+ Internal worker function that reports a status code through the Report Status Code Protocol.\r
\r
- If status code service is not cached, then this function checks if status code service is\r
- available in system. If status code service is not available, then EFI_UNSUPPORTED is\r
- returned. If status code service is present, then it is cached in mReportStatusCode.\r
- Finally this function reports status code through the status code service.\r
+ If status code service is not cached, then this function checks if Report Status Code\r
+ Protocol is available in system. If Report Status Code Protocol is not available, then\r
+ EFI_UNSUPPORTED is returned. If Report Status Code Protocol is present, then it is\r
+ cached in mReportStatusCodeLibStatusCodeProtocol. Finally this function reports status\r
+ code through the Report Status Code Protocol.\r
\r
@param Type Status code type.\r
@param Value Status code value.\r
optional parameter that may be NULL.\r
\r
@retval EFI_SUCCESS The status code was reported.\r
- @retval EFI_UNSUPPORTED Status code service is not available.\r
+ @retval EFI_UNSUPPORTED Report Status Code Protocol is not available.\r
@retval EFI_UNSUPPORTED Status code type is not supported.\r
\r
**/\r
(ReportErrorCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ||\r
(ReportDebugCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE)) {\r
//\r
- // If mReportStatusCode is NULL, then check if status code service is available in system.\r
+ // If mReportStatusCodeLibStatusCodeProtocol is NULL, then check if Report Status Code Protocol is available in system.\r
//\r
- if (mReportStatusCode == NULL) {\r
- mReportStatusCode = InternalGetReportStatusCode ();\r
- if (mReportStatusCode == NULL) {\r
- return EFI_UNSUPPORTED;\r
- }\r
+ InternalGetReportStatusCode ();\r
+ if (mReportStatusCodeLibStatusCodeProtocol == NULL) {\r
+ return EFI_UNSUPPORTED;\r
}\r
- \r
+\r
//\r
- // A status code service is present in system, so pass in all the parameters to the service.\r
+ // A Report Status Code Protocol is present in system, so pass in all the parameters to the service.\r
//\r
- return (*mReportStatusCode) (Type, Value, Instance, (EFI_GUID *)CallerId, Data);\r
+ return mReportStatusCodeLibStatusCodeProtocol->ReportStatusCode (Type, Value, Instance, (EFI_GUID *)CallerId, Data);\r
}\r
\r
return EFI_UNSUPPORTED;\r
\r
**/\r
\r
-#include "ReportStatusCodeLibInternal.h"\r
+#include <Library/ReportStatusCodeLib.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/PcdLib.h>\r
+#include <Library/DevicePathLib.h>\r
+#include <Library/UefiRuntimeLib.h>\r
+\r
+#include <Protocol/StatusCode.h>\r
+\r
+#include <Guid/StatusCodeDataTypeId.h>\r
+#include <Guid/StatusCodeDataTypeDebug.h>\r
+#include <Guid/EventGroup.h>\r
+\r
+EFI_STATUS_CODE_PROTOCOL *mReportStatusCodeLibStatusCodeProtocol = NULL;\r
+EFI_EVENT mReportStatusCodeLibVirtualAddressChangeEvent;\r
+\r
+/**\r
+ Locate the report status code service.\r
+\r
+ Retrieve ReportStatusCode() API of Report Status Code Protocol.\r
+\r
+**/\r
+VOID\r
+InternalGetReportStatusCode (\r
+ VOID\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ if (mReportStatusCodeLibStatusCodeProtocol != NULL) {\r
+ return;\r
+ }\r
+ \r
+ if (EfiAtRuntime ()) {\r
+ return;\r
+ }\r
+ \r
+ //\r
+ // Check gBS just in case ReportStatusCode is called before gBS is initialized.\r
+ //\r
+ if (gBS != NULL && gBS->LocateProtocol != NULL) {\r
+ Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID**) &mReportStatusCodeLibStatusCodeProtocol);\r
+ if (EFI_ERROR (Status)) {\r
+ mReportStatusCodeLibStatusCodeProtocol = NULL;\r
+ }\r
+ }\r
+}\r
+\r
+/**\r
+ Notification function of EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE.\r
+\r
+ @param Event Event whose notification function is being invoked.\r
+ @param Context Pointer to the notification function's context\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+ReportStatusCodeLibVirtualAddressChange (\r
+ IN EFI_EVENT Event,\r
+ IN VOID *Context\r
+ )\r
+{\r
+ if (mReportStatusCodeLibStatusCodeProtocol == NULL) {\r
+ return;\r
+ }\r
+ EfiConvertPointer (0, (VOID **) &mReportStatusCodeLibStatusCodeProtocol);\r
+}\r
+\r
+/**\r
+ The constructor function of Runtime DXE Report Status Code Lib.\r
+\r
+ This function allocates memory for extended status code data, caches\r
+ the report status code service, and registers events.\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
+ReportStatusCodeLibConstructor (\r
+ IN EFI_HANDLE ImageHandle,\r
+ IN EFI_SYSTEM_TABLE *SystemTable\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ //\r
+ // Cache the report status code service\r
+ // \r
+ InternalGetReportStatusCode ();\r
+\r
+ //\r
+ // Register notify function for EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE\r
+ // \r
+ Status = gBS->CreateEventEx (\r
+ EVT_NOTIFY_SIGNAL,\r
+ TPL_NOTIFY,\r
+ ReportStatusCodeLibVirtualAddressChange,\r
+ NULL,\r
+ &gEfiEventVirtualAddressChangeGuid,\r
+ &mReportStatusCodeLibVirtualAddressChangeEvent\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+ The destructor function of Runtime DXE Report Status Code Lib.\r
+ \r
+ The destructor function frees memory allocated by constructor, and closes related events.\r
+ It will ASSERT() if that related operation 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
+ReportStatusCodeLibDestructor (\r
+ IN EFI_HANDLE ImageHandle,\r
+ IN EFI_SYSTEM_TABLE *SystemTable\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ ASSERT (gBS != NULL);\r
+ Status = gBS->CloseEvent (mReportStatusCodeLibVirtualAddressChangeEvent);\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+ Internal worker function that reports a status code through the Report Status Code Protocol.\r
+\r
+ If status code service is not cached, then this function checks if Report Status Code\r
+ Protocol is available in system. If Report Status Code Protocol is not available, then\r
+ EFI_UNSUPPORTED is returned. If Report Status Code Protocol is present, then it is\r
+ cached in mReportStatusCodeLibStatusCodeProtocol. Finally this function reports status\r
+ code through the Report Status Code Protocol.\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. This is an optional parameter that may be\r
+ NULL.\r
+ @param Data Pointer to the extended data buffer. This is an\r
+ optional parameter that may be NULL.\r
+\r
+ @retval EFI_SUCCESS The status code was reported.\r
+ @retval EFI_UNSUPPORTED Report Status Code Protocol is not available.\r
+ @retval EFI_UNSUPPORTED Status code type is not supported.\r
+\r
+**/\r
+EFI_STATUS\r
+InternalReportStatusCode (\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 EFI_STATUS_CODE_DATA *Data OPTIONAL\r
+ )\r
+{\r
+ if ((ReportProgressCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ||\r
+ (ReportErrorCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ||\r
+ (ReportDebugCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE)) {\r
+ //\r
+ // If mReportStatusCodeLibStatusCodeProtocol is NULL, then check if Report Status Code Protocol is available in system.\r
+ //\r
+ InternalGetReportStatusCode ();\r
+ if (mReportStatusCodeLibStatusCodeProtocol == NULL) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ //\r
+ // A Report Status Code Protocol is present in system, so pass in all the parameters to the service.\r
+ //\r
+ return mReportStatusCodeLibStatusCodeProtocol->ReportStatusCode (Type, Value, Instance, (EFI_GUID *)CallerId, Data);\r
+ }\r
+ \r
+ return EFI_UNSUPPORTED;\r
+}\r
+\r
\r
/**\r
Converts a status code to an 8-bit POST code value.\r
)\r
{\r
EFI_STATUS Status;\r
+ EFI_STATUS_CODE_DATA *StatusCodeData;\r
+ UINT8 StatusCodeBuffer[EFI_STATUS_CODE_DATA_MAX_SIZE];\r
\r
ASSERT (!((ExtendedData == NULL) && (ExtendedDataSize != 0)));\r
ASSERT (!((ExtendedData != NULL) && (ExtendedDataSize == 0)));\r
\r
- if (ExtendedDataSize > EFI_STATUS_CODE_DATA_MAX_SIZE) {\r
- return EFI_OUT_OF_RESOURCES;\r
+ if (EfiAtRuntime ()) {\r
+ if (sizeof (EFI_STATUS_CODE_DATA) + ExtendedDataSize > EFI_STATUS_CODE_DATA_MAX_SIZE) {\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+ StatusCodeData = (EFI_STATUS_CODE_DATA *)StatusCodeBuffer;\r
+ } else {\r
+ if (gBS == NULL || gBS->AllocatePool == NULL || gBS->FreePool == 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
//\r
// Fill in the extended data header\r
//\r
- mStatusCodeData->HeaderSize = sizeof (EFI_STATUS_CODE_DATA);\r
- mStatusCodeData->Size = (UINT16)ExtendedDataSize;\r
+ StatusCodeData->HeaderSize = sizeof (EFI_STATUS_CODE_DATA);\r
+ StatusCodeData->Size = (UINT16)ExtendedDataSize;\r
if (ExtendedDataGuid == NULL) {\r
ExtendedDataGuid = &gEfiStatusCodeSpecificDataGuid;\r
}\r
- CopyGuid (&mStatusCodeData->Type, ExtendedDataGuid);\r
+ CopyGuid (&StatusCodeData->Type, ExtendedDataGuid);\r
\r
//\r
// Fill in the extended data buffer\r
//\r
if (ExtendedData != NULL) {\r
- CopyMem (mStatusCodeData + 1, ExtendedData, ExtendedDataSize);\r
+ CopyMem (StatusCodeData + 1, ExtendedData, ExtendedDataSize);\r
}\r
\r
//\r
if (CallerId == NULL) {\r
CallerId = &gEfiCallerIdGuid;\r
}\r
- Status = InternalReportStatusCode (Type, Value, Instance, CallerId, mStatusCodeData);\r
+ Status = InternalReportStatusCode (Type, Value, Instance, CallerId, StatusCodeData);\r
+\r
+ //\r
+ // Free the allocated buffer\r
+ //\r
+ if (!EfiAtRuntime()) {\r
+ gBS->FreePool (StatusCodeData);\r
+ }\r
\r
return Status;\r
}\r
+++ /dev/null
-/** @file\r
- Internal Header file of Report Status Code Library for RUNTIME\r
- DXE Phase.\r
-\r
- Copyright (c) 2006 - 2009, Intel Corporation<BR>\r
- All rights reserved. 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
-#ifndef __REPORT_STATUS_CODE_LIB_INTERNAL__H__\r
-#define __REPORT_STATUS_CODE_LIB_INTERNAL__H__\r
-\r
-#include <Library/ReportStatusCodeLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/PcdLib.h>\r
-#include <Library/UefiRuntimeServicesTableLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/DevicePathLib.h>\r
-#include <Library/OemHookStatusCodeLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/UefiRuntimeLib.h>\r
-\r
-#include <Guid/StatusCodeDataTypeId.h>\r
-#include <Guid/StatusCodeDataTypeDebug.h>\r
-#include <Guid/EventGroup.h>\r
-\r
-#include <Protocol/StatusCode.h>\r
-\r
-extern EFI_STATUS_CODE_DATA *mStatusCodeData;\r
-\r
-/**\r
- Locate the report status code service.\r
-\r
- It first tries to retrieve ReportStatusCode() in Runtime Services Table.\r
- If not found, it then tries to retrieve ReportStatusCode() API of Report Status Code Protocol.\r
-\r
- @return Function pointer to the report status code service.\r
- NULL is returned if no status code service is available.\r
-\r
-**/\r
-EFI_REPORT_STATUS_CODE\r
-InternalGetReportStatusCode (\r
- VOID\r
- );\r
-\r
-/**\r
- Internal worker function that reports a status code through the status code service.\r
-\r
- If status code service is not cached, then this function checks if status code service is\r
- available in system. If status code service is not available, then EFI_UNSUPPORTED is\r
- returned. If status code service is present, then it is cached in mReportStatusCode.\r
- Finally this function reports status code through the status code service.\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. This is an optional parameter that may be\r
- NULL.\r
- @param Data Pointer to the extended data buffer. This is an\r
- optional parameter that may be NULL.\r
-\r
- @retval EFI_SUCCESS The status code was reported.\r
- @retval EFI_UNSUPPORTED Status code service is not available.\r
- @retval EFI_UNSUPPORTED Status code type is not supported.\r
-\r
-**/\r
-EFI_STATUS\r
-InternalReportStatusCode (\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 EFI_STATUS_CODE_DATA *Data OPTIONAL\r
- );\r
-\r
-#endif\r
-\r
#\r
# The following information is for reference only and not required by the build tools.\r
#\r
-# VALID_ARCHITECTURES = IA32 X64 EBC\r
+# VALID_ARCHITECTURES = IA32 X64 IPF EBC\r
#\r
\r
[Sources.common]\r
ReportStatusCodeLib.c\r
- RuntimeDxeSupport.c\r
- ReportStatusCodeLibInternal.h\r
\r
[Packages]\r
MdePkg/MdePkg.dec\r
BaseMemoryLib\r
BaseLib\r
DebugLib\r
- UefiRuntimeServicesTableLib\r
UefiBootServicesTableLib\r
- OemHookStatusCodeLib\r
DevicePathLib\r
- MemoryAllocationLib\r
UefiRuntimeLib\r
\r
[Guids]\r
+++ /dev/null
-/** @file\r
- Library constructor & destructor, event handlers, and other internal worker functions.\r
-\r
- Copyright (c) 2006 - 2009, Intel Corporation<BR>\r
- All rights reserved. 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
-EFI_EVENT mStatusCodeVirtualAddressChangeEvent;\r
-EFI_STATUS_CODE_DATA *mStatusCodeData;\r
-EFI_RUNTIME_SERVICES *mStatusCodeInternalRT;\r
-EFI_REPORT_STATUS_CODE mReportStatusCode = NULL;\r
-\r
-/**\r
- Locate the report status code service.\r
-\r
- It first tries to retrieve ReportStatusCode() in Runtime Services Table.\r
- If not found, it then tries to retrieve ReportStatusCode() API of Report Status Code Protocol.\r
-\r
- @return Function pointer to the report status code service.\r
- NULL is returned if no status code service is available.\r
-\r
-**/\r
-EFI_REPORT_STATUS_CODE\r
-InternalGetReportStatusCode (\r
- VOID\r
- )\r
-{\r
- EFI_STATUS_CODE_PROTOCOL *StatusCodeProtocol;\r
- EFI_STATUS Status;\r
-\r
- if (!EfiAtRuntime ()) {\r
- //\r
- // Check gBS just in case. ReportStatusCode is called before gBS is initialized.\r
- //\r
- if (gBS != NULL) {\r
- Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID**) &StatusCodeProtocol);\r
- if (!EFI_ERROR (Status) && StatusCodeProtocol != NULL) {\r
- return StatusCodeProtocol->ReportStatusCode;\r
- }\r
- }\r
- }\r
-\r
- return NULL;\r
-}\r
-\r
-/**\r
- Internal worker function that reports a status code through the status code service.\r
-\r
- If status code service is not cached, then this function checks if status code service is\r
- available in system. If status code service is not available, then EFI_UNSUPPORTED is\r
- returned. If status code service is present, then it is cached in mReportStatusCode.\r
- Finally this function reports status code through the status code service.\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. This is an optional parameter that may be\r
- NULL.\r
- @param Data Pointer to the extended data buffer. This is an\r
- optional parameter that may be NULL.\r
-\r
- @retval EFI_SUCCESS The status code was reported.\r
- @retval EFI_UNSUPPORTED Status code service is not available.\r
- @retval EFI_UNSUPPORTED Status code type is not supported.\r
-\r
-**/\r
-EFI_STATUS\r
-InternalReportStatusCode (\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 EFI_STATUS_CODE_DATA *Data OPTIONAL\r
- )\r
-{\r
- if ((ReportProgressCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ||\r
- (ReportErrorCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ||\r
- (ReportDebugCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE)) {\r
- //\r
- // If mReportStatusCode is NULL, then check if status code service is available in system.\r
- //\r
- if (mReportStatusCode == NULL) {\r
- mReportStatusCode = InternalGetReportStatusCode ();\r
- if (mReportStatusCode == NULL) {\r
- return EFI_UNSUPPORTED;\r
- }\r
- }\r
- \r
- //\r
- // A status code service is present in system, so pass in all the parameters to the service.\r
- //\r
- return (*mReportStatusCode) (Type, Value, Instance, (EFI_GUID *)CallerId, Data);\r
- }\r
- \r
- return EFI_UNSUPPORTED;\r
-}\r
-\r
-/**\r
- Notification function of EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE.\r
-\r
- @param Event Event whose notification function is being invoked.\r
- @param Context Pointer to the notification function's context\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-ReportStatusCodeLibVirtualAddressChange (\r
- IN EFI_EVENT Event,\r
- IN VOID *Context\r
- )\r
-{\r
- if (mReportStatusCode != NULL) {\r
- mStatusCodeInternalRT->ConvertPointer (0, (VOID **) &mReportStatusCode);\r
- }\r
- mStatusCodeInternalRT->ConvertPointer (0, (VOID **) &mStatusCodeData);\r
- mStatusCodeInternalRT->ConvertPointer (0, (VOID **) &mStatusCodeInternalRT);\r
-}\r
-\r
-/**\r
- The constructor function of Runtime DXE Report Status Code Lib.\r
-\r
- This function allocates memory for extended status code data, caches\r
- the report status code service, and registers events.\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
-ReportStatusCodeLibConstruct (\r
- IN EFI_HANDLE ImageHandle,\r
- IN EFI_SYSTEM_TABLE *SystemTable\r
- )\r
-{\r
- EFI_STATUS Status;\r
-\r
- //\r
- // Library should not use the gRT directly, for it may be converted by other library instance.\r
- // \r
- mStatusCodeInternalRT = gRT;\r
-\r
- mStatusCodeData = AllocateRuntimePool (sizeof (EFI_STATUS_CODE_DATA) + EFI_STATUS_CODE_DATA_MAX_SIZE);\r
- ASSERT (mStatusCodeData != NULL);\r
- //\r
- // Cache the report status code service\r
- // \r
- mReportStatusCode = InternalGetReportStatusCode ();\r
-\r
- //\r
- // Register notify function for EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE\r
- // \r
- Status = gBS->CreateEventEx (\r
- EVT_NOTIFY_SIGNAL,\r
- TPL_NOTIFY,\r
- ReportStatusCodeLibVirtualAddressChange,\r
- NULL,\r
- &gEfiEventVirtualAddressChangeGuid,\r
- &mStatusCodeVirtualAddressChangeEvent\r
- );\r
- ASSERT_EFI_ERROR (Status);\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
- The destructor function of Runtime DXE Report Status Code Lib.\r
- \r
- The destructor function frees memory allocated by constructor, and closes related events.\r
- It will ASSERT() if that related operation 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
-ReportStatusCodeLibDestruct (\r
- IN EFI_HANDLE ImageHandle,\r
- IN EFI_SYSTEM_TABLE *SystemTable\r
- )\r
-{\r
- EFI_STATUS Status;\r
-\r
- ASSERT (gBS != NULL);\r
- Status = gBS->CloseEvent (mStatusCodeVirtualAddressChangeEvent);\r
- ASSERT_EFI_ERROR (Status);\r
-\r
- FreePool (mStatusCodeData);\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r