]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/RuntimeDxeSupport.c
Refine DxeReportStatusCodeLib and RuntimeDxeReportStatusCodeLib.
[mirror_edk2.git] / MdeModulePkg / Library / RuntimeDxeReportStatusCodeLib / RuntimeDxeSupport.c
diff --git a/MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/RuntimeDxeSupport.c b/MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/RuntimeDxeSupport.c
deleted file mode 100644 (file)
index fd9f8f7..0000000
+++ /dev/null
@@ -1,207 +0,0 @@
-/** @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