]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EdkCompatibilityPkg/Compatibility/PiSmmStatusCodeOnFrameworkSmmStatusCodeThunk/PiSmmStatusCodeOnFrameworkSmmStatusCodeThunk.c
MdeModulePkg CapsuleApp: Do not parse bits in CapsuleFlags of ESRT
[mirror_edk2.git] / EdkCompatibilityPkg / Compatibility / PiSmmStatusCodeOnFrameworkSmmStatusCodeThunk / PiSmmStatusCodeOnFrameworkSmmStatusCodeThunk.c
index 92eed5a0d02b02880d891055c41c5ad82c512e60..699b120759d25da4460c3048a5bbe1f1cb865029 100644 (file)
@@ -8,7 +8,7 @@
   Note that Framework SMM Status Code Protocol and PI SMM Status Code Protocol have identical protocol\r
   GUID and interface structure, but they are in different handle databases.\r
 \r
-  Copyright (c) 2010, Intel Corporation.  All rights reserved<BR>\r
+  Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials are licensed and made available under \r
   the terms and conditions of the BSD License that accompanies this distribution.  \r
   The full text of the license may be found at\r
@@ -211,301 +211,9 @@ ReportDispatcher (
   @retval EFI_SUCCESS      The function completed successfully.\r
   @retval EFI_DEVICE_ERROR The function should not be completed due to a device error.\r
 \r
-**/\r
-EFI_STATUS\r
-SmmStatusCodeHandler (\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 OPTIONAL\r
-  )\r
-{\r
-  return mFrameworkSmmStatusCode->ReportStatusCode (\r
-                                    mFrameworkSmmStatusCode,\r
-                                    CodeType,\r
-                                    Value,\r
-                                    Instance,\r
-                                    CallerId,\r
-                                    Data\r
-                                    );                            \r
-}\r
-\r
-/**\r
-  Entry point of PI SMM Status Code Protocol on Framework SMM Status Code Protocol thunk driver.\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 entry point is executed successfully.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-SmmStatusCodeThunkMain (\r
-  IN EFI_HANDLE         ImageHandle,\r
-  IN EFI_SYSTEM_TABLE   *SystemTable\r
-  )\r
-{\r
-  EFI_STATUS     Status;\r
-  EFI_HANDLE     Handle;\r
-\r
-  //\r
-  // Locate Framework SMM Status Code Protocol in UEFI handle database.\r
-  //\r
-  Status = SystemTable->BootServices->LocateProtocol (\r
-                                        &gEfiSmmStatusCodeProtocolGuid,\r
-                                        NULL,\r
-                                        (VOID **)&mFrameworkSmmStatusCode\r
-                                        );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  //\r
-  // Registers status code handler to route status codes into Framework SMM Status Code Protocol.\r
-  //\r
-  Register (SmmStatusCodeHandler);\r
-\r
-  Handle     = NULL;\r
-  \r
-  //\r
-  // Install SmmRscHandler Protocol\r
-  //\r
-  Status = gSmst->SmmInstallProtocolInterface (\r
-                    &Handle,\r
-                    &gEfiSmmRscHandlerProtocolGuid,\r
-                    EFI_NATIVE_INTERFACE,\r
-                    &mSmmRscHandlerProtocol\r
-                    );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  //\r
-  // Install SmmStatusCode Protocol\r
-  //\r
-  Status = gSmst->SmmInstallProtocolInterface (\r
-                    &Handle,\r
-                    &gEfiSmmStatusCodeProtocolGuid,\r
-                    EFI_NATIVE_INTERFACE,\r
-                    &mSmmStatusCodeProtocol\r
-                    );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-/** @file\r
-  PI SMM Status Code Protocol on Framework SMM Status Code Protocol Thunk.\r
-\r
-  This thunk driver produces PI SMM Status Code Protocol and SMM Report Status Code Handler Protocol.\r
-  And it registers a status code handler within itself to route status codes into Framework SMM Status\r
-  Code Protocol.\r
-\r
-  Note that Framework SMM Status Code Protocol and PI SMM Status Code Protocol have identical protocol\r
-  GUID and interface structure, but they are in different handle databases.\r
-\r
-  Copyright (c) 2010, Intel Corporation.  All rights reserved<BR>\r
-  This program and the accompanying materials are licensed and made available under \r
-  the terms and conditions of the BSD License that accompanies this distribution.  \r
-  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 "PiSmmStatusCodeOnFrameworkSmmStatusCodeThunk.h"\r
-\r
-LIST_ENTRY   mCallbackListHead          = INITIALIZE_LIST_HEAD_VARIABLE (mCallbackListHead);\r
-\r
-//\r
-// Report operation nest status.\r
-// If it is set, then the report operation has nested.\r
-//\r
-UINT32       mStatusCodeNestStatus = 0;\r
-\r
-EFI_SMM_STATUS_CODE_PROTOCOL  mSmmStatusCodeProtocol  = {\r
-  ReportDispatcher\r
-};\r
-\r
-EFI_SMM_RSC_HANDLER_PROTOCOL  mSmmRscHandlerProtocol = {\r
-  Register,\r
-  Unregister\r
-  };\r
-\r
-EFI_SMM_STATUS_CODE_PROTOCOL  *mFrameworkSmmStatusCode;\r
-\r
-/**\r
-  Register the callback function for ReportStatusCode() notification.\r
-  \r
-  When this function is called the function pointer is added to an internal list and any future calls to\r
-  ReportStatusCode() will be forwarded to the Callback function.\r
-\r
-  @param[in] Callback           A pointer to a function of type EFI_PEI_RSC_HANDLER_CALLBACK that is called\r
-                                when a call to ReportStatusCode() occurs.\r
-                        \r
-  @retval EFI_SUCCESS           Function was successfully registered.\r
-  @retval EFI_INVALID_PARAMETER The callback function was NULL.\r
-  @retval EFI_OUT_OF_RESOURCES  The internal buffer ran out of space. No more functions can be\r
-                                registered.\r
-  @retval EFI_ALREADY_STARTED   The function was already registered. It can't be registered again.\r
-  \r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
-Register (\r
-  IN EFI_SMM_RSC_HANDLER_CALLBACK   Callback\r
-  )\r
-{\r
-  LIST_ENTRY                      *Link;\r
-  SMM_RSC_HANDLER_CALLBACK_ENTRY  *CallbackEntry;\r
-\r
-  if (Callback == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  for (Link = GetFirstNode (&mCallbackListHead); !IsNull (&mCallbackListHead, Link); Link = GetNextNode (&mCallbackListHead, Link)) {\r
-    CallbackEntry = CR (Link, SMM_RSC_HANDLER_CALLBACK_ENTRY, Node, SMM_RSC_HANDLER_CALLBACK_ENTRY_SIGNATURE);\r
-    if (CallbackEntry->RscHandlerCallback == Callback) {\r
-      //\r
-      // If the function was already registered. It can't be registered again.\r
-      //\r
-      return EFI_ALREADY_STARTED;\r
-    }\r
-  }\r
-\r
-  CallbackEntry = (SMM_RSC_HANDLER_CALLBACK_ENTRY *)AllocatePool (sizeof (SMM_RSC_HANDLER_CALLBACK_ENTRY));\r
-  ASSERT (CallbackEntry != NULL);\r
-\r
-  CallbackEntry->Signature          = SMM_RSC_HANDLER_CALLBACK_ENTRY_SIGNATURE;\r
-  CallbackEntry->RscHandlerCallback = Callback;\r
-\r
-  InsertTailList (&mCallbackListHead, &CallbackEntry->Node);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Remove a previously registered callback function from the notification list.\r
-  \r
-  ReportStatusCode() messages will no longer be forwarded to the Callback function.\r
-  \r
-  @param[in] Callback           A pointer to a function of type EFI_PEI_RSC_HANDLER_CALLBACK that is to be\r
-                                unregistered.\r
-\r
-  @retval EFI_SUCCESS           The function was successfully unregistered.\r
-  @retval EFI_INVALID_PARAMETER The callback function was NULL.\r
-  @retval EFI_NOT_FOUND         The callback function was not found to be unregistered.\r
-                        \r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-Unregister (\r
-  IN EFI_SMM_RSC_HANDLER_CALLBACK Callback\r
-  )\r
-{\r
-  LIST_ENTRY                        *Link;\r
-  SMM_RSC_HANDLER_CALLBACK_ENTRY    *CallbackEntry;\r
-\r
-  if (Callback == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  for (Link = GetFirstNode (&mCallbackListHead); !IsNull (&mCallbackListHead, Link); Link = GetNextNode (&mCallbackListHead, Link)) {\r
-    CallbackEntry = CR (Link, SMM_RSC_HANDLER_CALLBACK_ENTRY, Node, SMM_RSC_HANDLER_CALLBACK_ENTRY_SIGNATURE);\r
-    if (CallbackEntry->RscHandlerCallback == Callback) {\r
-      //\r
-      // If the function is found in list, delete it and return.\r
-      //\r
-      RemoveEntryList (&CallbackEntry->Node);\r
-      FreePool (CallbackEntry);\r
-      return EFI_SUCCESS;\r
-    }\r
-  }\r
-\r
-  return EFI_NOT_FOUND;\r
-}\r
-\r
-\r
-/**\r
-  Provides an interface that a software module can call to report a status code.\r
-\r
-  @param  This             EFI_SMM_STATUS_CODE_PROTOCOL instance.\r
-  @param  Type             Indicates the type of status code being reported.\r
-  @param  Value            Describes the current status of a hardware or software entity.\r
-                           This included information about the class and subclass that is used to\r
-                           classify the entity as well as an operation.\r
-  @param  Instance         The enumeration of a hardware or software entity within\r
-                           the system. Valid instance numbers start with 1.\r
-  @param  CallerId         This optional parameter may be used to identify the caller.\r
-                           This parameter allows the status code driver to apply different rules to\r
-                           different callers.\r
-  @param  Data             This optional parameter may be used to pass additional data.\r
-\r
-  @retval EFI_SUCCESS           The function completed successfully\r
-  @retval EFI_DEVICE_ERROR      The function should not be completed due to a device error.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-ReportDispatcher (\r
-  IN CONST EFI_SMM_STATUS_CODE_PROTOCOL  *This,\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
-  LIST_ENTRY                        *Link;\r
-  SMM_RSC_HANDLER_CALLBACK_ENTRY    *CallbackEntry;\r
-\r
-  //\r
-  // Use atom operation to avoid the reentant of report.\r
-  // If current status is not zero, then the function is reentrancy.\r
-  //\r
-  if (InterlockedCompareExchange32 (&mStatusCodeNestStatus, 0, 1) == 1) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  for (Link = GetFirstNode (&mCallbackListHead); !IsNull (&mCallbackListHead, Link); Link = GetNextNode (&mCallbackListHead, Link)) {\r
-    CallbackEntry = CR (Link, SMM_RSC_HANDLER_CALLBACK_ENTRY, Node, SMM_RSC_HANDLER_CALLBACK_ENTRY_SIGNATURE);\r
-\r
-    CallbackEntry->RscHandlerCallback (\r
-                     Type,\r
-                     Value,\r
-                     Instance,\r
-                     (EFI_GUID*)CallerId,\r
-                     Data\r
-                     );\r
-\r
-  }\r
-\r
-  //\r
-  // Restore the nest status of report\r
-  //\r
-  InterlockedCompareExchange32 (&mStatusCodeNestStatus, 1, 0);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  This SMM Status Code Handler routes status codes to Framework SMM Status Code Protocol.\r
\r
-  @param  CodeType         Indicates the type of status code being reported.\r
-  @param  Value            Describes the current status of a hardware or software entity.\r
-                           This included information about the class and subclass that is used to\r
-                           classify the entity as well as an operation.\r
-  @param  Instance         The enumeration of a hardware or software entity within\r
-                           the system. Valid instance numbers start with 1.\r
-  @param  CallerId         This optional parameter may be used to identify the caller.\r
-                           This parameter allows the status code driver to apply different rules to\r
-                           different callers.\r
-  @param  Data             This optional parameter may be used to pass additional data.\r
-\r
-  @retval EFI_SUCCESS      The function completed successfully.\r
-  @retval EFI_DEVICE_ERROR The function should not be completed due to a device error.\r
-\r
-**/\r
-EFI_STATUS\r
 SmmStatusCodeHandler (\r
   IN EFI_STATUS_CODE_TYPE     CodeType,\r
   IN EFI_STATUS_CODE_VALUE    Value,\r