]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EdkCompatibilityPkg/Sample/Platform/Generic/RuntimeDxe/StatusCode/Lib/BsDataHubStatusCode/BsDataHubStatusCode.c
EdkCompatibilityPkg: Remove EdkCompatibilityPkg
[mirror_edk2.git] / EdkCompatibilityPkg / Sample / Platform / Generic / RuntimeDxe / StatusCode / Lib / BsDataHubStatusCode / BsDataHubStatusCode.c
diff --git a/EdkCompatibilityPkg/Sample/Platform/Generic/RuntimeDxe/StatusCode/Lib/BsDataHubStatusCode/BsDataHubStatusCode.c b/EdkCompatibilityPkg/Sample/Platform/Generic/RuntimeDxe/StatusCode/Lib/BsDataHubStatusCode/BsDataHubStatusCode.c
deleted file mode 100644 (file)
index 2e60634..0000000
+++ /dev/null
@@ -1,391 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2004 - 2016, 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
-Module Name:\r
-\r
-  BsDataHubStatusCode.c\r
-\r
-Abstract:\r
-\r
-  This implements a status code listener that logs status codes into the data\r
-  hub.  This is only active during non-runtime DXE.\r
-  The status codes are recorded in a extensible buffer, and a event is signalled\r
-  to log them to the data hub. The recorder is the producer of the status code in\r
-  buffer and the event notify function the consumer.\r
-\r
---*/\r
-\r
-#include "BsDataHubStatusCode.h"\r
-\r
-//\r
-// Initialize FIFO to cache records.\r
-//\r
-STATIC EFI_LIST_ENTRY   mRecordsFifo    = INITIALIZE_LIST_HEAD_VARIABLE (mRecordsFifo);\r
-STATIC EFI_LIST_ENTRY   mRecordsBuffer  = INITIALIZE_LIST_HEAD_VARIABLE (mRecordsBuffer);\r
-STATIC EFI_EVENT        mLogDataHubEvent;\r
-STATIC BOOLEAN          mEventHandlerActive = FALSE;\r
-\r
-//\r
-// Cache data hub protocol.\r
-//\r
-STATIC EFI_DATA_HUB_PROTOCOL     *mDataHubProtocol;\r
-\r
-STATIC\r
-DATA_HUB_STATUS_CODE_DATA_RECORD *\r
-AcquireRecordBuffer (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Return one DATAHUB_STATUSCODE_RECORD space.\r
-  The size of free record pool would be extend, if the pool is empty.\r
-\r
-Arguments:\r
-\r
-  None\r
-\r
-Returns:\r
-\r
-  A pointer to the new allocated node or NULL if non available\r
-\r
---*/\r
-{\r
-  DATAHUB_STATUSCODE_RECORD *Record;\r
-  EFI_TPL                   CurrentTpl;\r
-  EFI_LIST_ENTRY            *Node;\r
-  UINT32                    Index;\r
-\r
-  Record     = NULL;\r
-  CurrentTpl = gBS->RaiseTPL (EFI_TPL_HIGH_LEVEL);\r
-\r
-  if (!IsListEmpty (&mRecordsBuffer)) {\r
-    Node = GetFirstNode (&mRecordsBuffer);\r
-    RemoveEntryList (Node);\r
-\r
-    Record = _CR (Node, DATAHUB_STATUSCODE_RECORD, Node);\r
-  } else {\r
-    if (CurrentTpl > EFI_TPL_NOTIFY) {\r
-      gBS->RestoreTPL (CurrentTpl);\r
-      return NULL;\r
-    }\r
-\r
-    gBS->RestoreTPL (CurrentTpl);\r
-    \r
-    gBS->AllocatePool (EfiBootServicesData, sizeof (DATAHUB_STATUSCODE_RECORD) * 16, (VOID **) &Record);\r
-    if (Record == NULL) {\r
-      return NULL;\r
-    }\r
-    EfiCommonLibZeroMem (Record, sizeof (DATAHUB_STATUSCODE_RECORD) * 16);    \r
-\r
-\r
-    CurrentTpl = gBS->RaiseTPL (EFI_TPL_HIGH_LEVEL);\r
-    for (Index = 1; Index < 16; Index++) {\r
-      InsertTailList (&mRecordsBuffer, &Record[Index].Node);\r
-    }\r
-  }\r
-\r
-  Record->Signature = BS_DATA_HUB_STATUS_CODE_SIGNATURE;\r
-  InsertTailList (&mRecordsFifo, &Record->Node);\r
-\r
-  gBS->RestoreTPL (CurrentTpl);\r
-\r
-  return (DATA_HUB_STATUS_CODE_DATA_RECORD *) (Record->Data);\r
-}\r
-\r
-STATIC\r
-DATA_HUB_STATUS_CODE_DATA_RECORD *\r
-RetrieveRecord (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Retrieve one record from Records FIFO. The record would be removed from FIFO and \r
-  release to free record buffer.\r
-\r
-Arguments:\r
-\r
-  None\r
-\r
-Returns:\r
-\r
-  Point to record which is ready to be logged, or NULL if the FIFO of record is empty.\r
-\r
---*/  \r
-{\r
-  DATA_HUB_STATUS_CODE_DATA_RECORD  *RecordData;\r
-  DATAHUB_STATUSCODE_RECORD   *Record;\r
-  EFI_LIST_ENTRY              *Node;\r
-  EFI_TPL                     CurrentTpl;\r
-  \r
-  RecordData = NULL;\r
-  \r
-  CurrentTpl = gBS->RaiseTPL (EFI_TPL_HIGH_LEVEL);\r
-\r
-  if (!IsListEmpty (&mRecordsFifo)) {\r
-    Node = GetFirstNode (&mRecordsFifo);\r
-    Record = CR (Node, DATAHUB_STATUSCODE_RECORD, Node, BS_DATA_HUB_STATUS_CODE_SIGNATURE);\r
-\r
-    RemoveEntryList (&Record->Node);\r
-    InsertTailList (&mRecordsBuffer, &Record->Node);\r
-    Record->Signature = 0;\r
-    RecordData = (DATA_HUB_STATUS_CODE_DATA_RECORD *) Record->Data;\r
-  }\r
-\r
-  gBS->RestoreTPL (CurrentTpl);\r
-\r
-  return RecordData;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-BsDataHubReportStatusCode (\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
-\r
-Routine Description:\r
-\r
-  Boot service report status code listener.  This function logs the status code\r
-  into the data hub.\r
-\r
-Arguments:\r
-\r
-  Same as gRT->ReportStatusCode (See Tiano Runtime Specification)\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  DATA_HUB_STATUS_CODE_DATA_RECORD  *Record;\r
-  UINT32                     ErrorLevel;\r
-  VA_LIST                    Marker;\r
-  CHAR8                      *Format;\r
-  CHAR16                     FormatBuffer[BYTES_PER_RECORD];\r
-  UINTN                      Index;\r
-\r
-  //\r
-  // See whether in runtime phase or not.\r
-  //\r
-  if (EfiAtRuntime ()) {\r
-    //\r
-    // For now all we do is post code at runtime\r
-    //\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  //\r
-  // Discard new DataHubRecord caused by DataHub->LogData()\r
-  //\r
-  if (mEventHandlerActive) {\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  Record = AcquireRecordBuffer ();\r
-  if (Record == NULL) {\r
-    //\r
-    // There are no empty record buffer in private buffers\r
-    //\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-  //\r
-  // Construct Data Hub Extended Data\r
-  //\r
-  Record->CodeType = CodeType;\r
-  Record->Value    = Value;\r
-  Record->Instance = Instance;\r
-\r
-  if (CallerId != NULL) {\r
-    EfiCopyMem (&Record->CallerId, CallerId, sizeof (EFI_GUID));\r
-  }\r
-\r
-  if (Data != NULL) {\r
-    if (ReportStatusCodeExtractDebugInfo (Data, &ErrorLevel, &Marker, &Format)) {\r
-      //\r
-      // Convert Ascii Format string to Unicode.\r
-      //\r
-      for (Index = 0; Format[Index] != '\0' && Index < (BYTES_PER_RECORD - 1); Index += 1) {\r
-        FormatBuffer[Index] = (CHAR16) Format[Index];\r
-      }\r
-\r
-      FormatBuffer[Index] = L'\0';\r
-\r
-      //\r
-      // Put processed string into the buffer\r
-      //\r
-      Index = VSPrint (\r
-                (CHAR16 *) (Record + 1),\r
-                BYTES_PER_RECORD - (sizeof (DATA_HUB_STATUS_CODE_DATA_RECORD)),\r
-                FormatBuffer,\r
-                Marker\r
-                );\r
-                \r
-      EfiCopyMem (&Record->Data.Type, &gEfiStatusCodeDataTypeDebugGuid, sizeof (EFI_GUID));\r
-      Record->Data.HeaderSize = Data->HeaderSize;\r
-      Record->Data.Size = (UINT16) (Index * sizeof (CHAR16));\r
-    } else {\r
-      //\r
-      // Copy status code data header\r
-      //\r
-      EfiCopyMem (&Record->Data, Data, sizeof (EFI_STATUS_CODE_DATA));\r
-\r
-      if (Data->Size > BYTES_PER_RECORD - sizeof (DATA_HUB_STATUS_CODE_DATA_RECORD)) {\r
-        Record->Data.Size = (UINT16) (BYTES_PER_RECORD - sizeof (DATA_HUB_STATUS_CODE_DATA_RECORD));\r
-      } \r
-      EfiCopyMem ((VOID *) (Record + 1), Data + 1, Record->Data.Size);\r
-    }\r
-  }\r
-\r
-  gBS->SignalEvent (mLogDataHubEvent);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-VOID\r
-EFIAPI\r
-LogDataHubEventHandler (\r
-  IN  EFI_EVENT     Event,\r
-  IN  VOID          *Context\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  The Event handler which will be notified to log data in Data Hub.\r
-\r
-Arguments:\r
-\r
-  Event     -   Instance of the EFI_EVENT to signal whenever data is\r
-                available to be logged in the system.\r
-  Context   -   Context of the event.\r
-\r
-Returns:\r
-\r
-  None.\r
-\r
---*/\r
-{\r
-  DATA_HUB_STATUS_CODE_DATA_RECORD  *Record;\r
-  UINT32                            Size;\r
-  UINT64                            DataRecordClass;\r
-\r
-  //\r
-  // Set global flag so we don't recurse if DataHub->LogData eventually causes new DataHubRecord\r
-  //\r
-  mEventHandlerActive = TRUE;\r
-  \r
-  //\r
-  // Log DataRecord in Data Hub.\r
-  // Journal records fifo to find all record entry.\r
-  //\r
-  while (1) {\r
-    Record = RetrieveRecord ();\r
-    if (Record == NULL) {\r
-      break;\r
-    }\r
-    //\r
-    // Add in the size of the header we added.\r
-    //\r
-    Size = sizeof (DATA_HUB_STATUS_CODE_DATA_RECORD) + (UINT32) Record->Data.Size;\r
-\r
-    if ((Record->CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) {\r
-      DataRecordClass = EFI_DATA_RECORD_CLASS_PROGRESS_CODE;\r
-    } else if ((Record->CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) {\r
-      DataRecordClass = EFI_DATA_RECORD_CLASS_ERROR;\r
-    } else if ((Record->CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) {\r
-      DataRecordClass = EFI_DATA_RECORD_CLASS_DEBUG;\r
-    } else {\r
-      //\r
-      // Should never get here.\r
-      //\r
-      DataRecordClass = EFI_DATA_RECORD_CLASS_DEBUG |\r
-        EFI_DATA_RECORD_CLASS_ERROR |\r
-        EFI_DATA_RECORD_CLASS_DATA |\r
-        EFI_DATA_RECORD_CLASS_PROGRESS_CODE;\r
-    }\r
-\r
-    //\r
-    // Log DataRecord in Data Hub\r
-    //\r
-    \r
-    mDataHubProtocol->LogData (\r
-                        mDataHubProtocol,\r
-                        &gEfiStatusCodeGuid,\r
-                        &gEfiStatusCodeRuntimeProtocolGuid,\r
-                        DataRecordClass,\r
-                        Record,\r
-                        Size\r
-                        );\r
-\r
-  }\r
-\r
-  mEventHandlerActive = FALSE;\r
-\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-BsDataHubInitializeStatusCode (\r
-  IN EFI_HANDLE         ImageHandle,\r
-  IN EFI_SYSTEM_TABLE   *SystemTable\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Install a data hub listener.\r
-\r
-Arguments:\r
-\r
-  (Standard EFI Image entry - EFI_IMAGE_ENTRY_POINT)\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS - Logging Hub protocol installed\r
-  Other       - No protocol installed, unload driver.\r
-\r
---*/\r
-{\r
-  EFI_STATUS              Status;\r
-\r
-  Status = gBS->LocateProtocol (\r
-                  &gEfiDataHubProtocolGuid, \r
-                  NULL, \r
-                  (VOID **) &mDataHubProtocol\r
-                  );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  //\r
-  // Create a Notify Event to log data in Data Hub\r
-  //\r
-  Status = gBS->CreateEvent (\r
-                  EFI_EVENT_NOTIFY_SIGNAL,\r
-                  EFI_TPL_CALLBACK,\r
-                  LogDataHubEventHandler,\r
-                  NULL,\r
-                  &mLogDataHubEvent\r
-                  );\r
-\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r