]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Update directory/file names for status code runtime dxe driver.
authorxli24 <xli24@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 27 Apr 2009 06:35:40 +0000 (06:35 +0000)
committerxli24 <xli24@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 27 Apr 2009 06:35:40 +0000 (06:35 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8180 6f19259b-4bc3-4df7-8a09-765794883524

13 files changed:
IntelFrameworkModulePkg/Universal/StatusCode/Dxe/DataHubStatusCodeWorker.c [deleted file]
IntelFrameworkModulePkg/Universal/StatusCode/Dxe/DxeStatusCode.c [deleted file]
IntelFrameworkModulePkg/Universal/StatusCode/Dxe/DxeStatusCode.h [deleted file]
IntelFrameworkModulePkg/Universal/StatusCode/Dxe/DxeStatusCode.inf [deleted file]
IntelFrameworkModulePkg/Universal/StatusCode/Dxe/DxeStatusCodeCommon.c [deleted file]
IntelFrameworkModulePkg/Universal/StatusCode/Dxe/RtMemoryStatusCodeWorker.c [deleted file]
IntelFrameworkModulePkg/Universal/StatusCode/Dxe/SerialStatusCodeWorker.c [deleted file]
IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/DataHubStatusCodeWorker.c [new file with mode: 0644]
IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/RtMemoryStatusCodeWorker.c [new file with mode: 0644]
IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/SerialStatusCodeWorker.c [new file with mode: 0644]
IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/StatusCodeRuntimeDxe.c [new file with mode: 0644]
IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/StatusCodeRuntimeDxe.h [new file with mode: 0644]
IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/StatusCodeRuntimeDxe.inf [new file with mode: 0644]

diff --git a/IntelFrameworkModulePkg/Universal/StatusCode/Dxe/DataHubStatusCodeWorker.c b/IntelFrameworkModulePkg/Universal/StatusCode/Dxe/DataHubStatusCodeWorker.c
deleted file mode 100644 (file)
index e55113c..0000000
+++ /dev/null
@@ -1,379 +0,0 @@
-/** @file\r
-  Data Hub status code worker.\r
-\r
-  Copyright (c) 2006 - 2009, Intel Corporation\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 "DxeStatusCode.h"\r
-\r
-//\r
-// Initialize FIFO to cache records.\r
-//\r
-LIST_ENTRY                mRecordsFifo          = INITIALIZE_LIST_HEAD_VARIABLE (mRecordsFifo);\r
-LIST_ENTRY                mRecordsBuffer        = INITIALIZE_LIST_HEAD_VARIABLE (mRecordsBuffer);\r
-UINT32                    mLogDataHubStatus     = 0;\r
-EFI_EVENT                 mLogDataHubEvent;\r
-//\r
-// Cache data hub protocol.\r
-//\r
-EFI_DATA_HUB_PROTOCOL     *mDataHubProtocol;\r
-\r
-\r
-/**\r
-  Retrieve one record of from free record buffer. This record is removed from\r
-  free record buffer.\r
-\r
-  This function retrieves one record from free record buffer.\r
-  If the pool has been exhausted, then new memory would be allocated for it.\r
-\r
-  @return  Pointer to the free record.\r
-           NULL means failure to allocate new memeory for free record buffer.\r
-\r
-**/\r
-DATA_HUB_STATUS_CODE_DATA_RECORD *\r
-AcquireRecordBuffer (\r
-  VOID\r
-  )\r
-{\r
-  DATAHUB_STATUSCODE_RECORD *Record;\r
-  EFI_TPL                   CurrentTpl;\r
-  LIST_ENTRY                *Node;\r
-  UINT32                    Index;\r
-\r
-  CurrentTpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);\r
-\r
-  if (!IsListEmpty (&mRecordsBuffer)) {\r
-    //\r
-    // Strip one entry from free record buffer.\r
-    //\r
-    Node = GetFirstNode (&mRecordsBuffer);\r
-    RemoveEntryList (Node);\r
-\r
-    Record = BASE_CR (Node, DATAHUB_STATUSCODE_RECORD, Node);\r
-  } else {\r
-    if (CurrentTpl > TPL_NOTIFY) {\r
-      //\r
-      // Memory management should work at <=TPL_NOTIFY\r
-      // \r
-      gBS->RestoreTPL (CurrentTpl);\r
-      return NULL;\r
-    }\r
-\r
-    //\r
-    // If free record buffer is exhausted, then allocate 16 new records for it.\r
-    //\r
-    gBS->RestoreTPL (CurrentTpl);\r
-    Record   = (DATAHUB_STATUSCODE_RECORD *) AllocateZeroPool (sizeof (DATAHUB_STATUSCODE_RECORD) * 16);\r
-    if (Record == NULL) {\r
-      return NULL;\r
-    }\r
-\r
-    CurrentTpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);\r
-    //\r
-    // Here we only insert 15 new records to the free record buffer, for the first record\r
-    // will be returned immediately.\r
-    //\r
-    for (Index = 1; Index < 16; Index++) {\r
-      InsertTailList (&mRecordsBuffer, &Record[Index].Node);\r
-    }\r
-  }\r
-\r
-  Record->Signature = DATAHUB_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
-\r
-/**\r
-  Retrieve one record from Records FIFO. The record would be removed from FIFO.\r
-\r
-  @return   Point to record, which is ready to be logged.\r
-            NULL means the FIFO of record is empty.\r
-\r
-**/\r
-DATA_HUB_STATUS_CODE_DATA_RECORD *\r
-RetrieveRecord (\r
-  VOID\r
-  )\r
-{\r
-  DATA_HUB_STATUS_CODE_DATA_RECORD  *RecordData;\r
-  DATAHUB_STATUSCODE_RECORD         *Record;\r
-  LIST_ENTRY                        *Node;\r
-  EFI_TPL                           CurrentTpl;\r
-\r
-  RecordData = NULL;\r
-\r
-  CurrentTpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);\r
-\r
-  if (!IsListEmpty (&mRecordsFifo)) {\r
-    Node = GetFirstNode (&mRecordsFifo);\r
-    Record = CR (Node, DATAHUB_STATUSCODE_RECORD, Node, DATAHUB_STATUS_CODE_SIGNATURE);\r
-    ASSERT (Record != NULL);\r
-\r
-    RemoveEntryList (&Record->Node);\r
-    RecordData = (DATA_HUB_STATUS_CODE_DATA_RECORD *) Record->Data;\r
-  }\r
-\r
-  gBS->RestoreTPL (CurrentTpl);\r
-\r
-  return RecordData;\r
-}\r
-\r
-/**\r
-  Release given record and return it to free record buffer.\r
-  \r
-  @param RecordData  Pointer to the record to release.\r
-\r
-**/\r
-VOID\r
-ReleaseRecord (\r
-  DATA_HUB_STATUS_CODE_DATA_RECORD  *RecordData\r
-  )\r
-{\r
-  DATAHUB_STATUSCODE_RECORD         *Record;\r
-  EFI_TPL                           CurrentTpl;\r
-\r
-  Record = CR (RecordData, DATAHUB_STATUSCODE_RECORD, Data[0], DATAHUB_STATUS_CODE_SIGNATURE);\r
-  ASSERT (Record != NULL);\r
-\r
-  CurrentTpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);\r
-\r
-  InsertTailList (&mRecordsBuffer, &Record->Node);\r
-  Record->Signature = 0;\r
-\r
-  gBS->RestoreTPL (CurrentTpl);\r
-}\r
-\r
-/**\r
-  Report status code into DataHub.\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     Function is reentered.\r
-  @retval EFI_DEVICE_ERROR     Function is called at runtime.\r
-  @retval EFI_OUT_OF_RESOURCES Fail to allocate memory for free record buffer.\r
-\r
-**/\r
-EFI_STATUS\r
-DataHubStatusCodeReportWorker (\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
-  DATA_HUB_STATUS_CODE_DATA_RECORD  *Record;\r
-  UINT32                            ErrorLevel;\r
-  VA_LIST                           Marker;\r
-  CHAR8                             *Format;\r
-  UINTN                             CharCount;\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 (&mLogDataHubStatus, 0, 0) == 1) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  //\r
-  // See whether in runtime phase or not.\r
-  //\r
-  if (EfiAtRuntime ()) {\r
-    return EFI_DEVICE_ERROR;\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
-  //\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
-    CopyMem (&Record->CallerId, CallerId, sizeof (EFI_GUID));\r
-  }\r
-\r
-  if (Data != NULL) {\r
-    if (ReportStatusCodeExtractDebugInfo (Data, &ErrorLevel, &Marker, &Format)) {\r
-      CharCount = UnicodeVSPrintAsciiFormat (\r
-                    (CHAR16 *) (Record + 1),\r
-                    EFI_STATUS_CODE_DATA_MAX_SIZE,\r
-                    Format,\r
-                    Marker\r
-                    );\r
-      //\r
-      // Change record data type to DebugType.\r
-      //\r
-      CopyGuid (&Record->Data.Type, &gEfiStatusCodeDataTypeDebugGuid);\r
-      Record->Data.HeaderSize = Data->HeaderSize;\r
-      Record->Data.Size = (UINT16) ((CharCount + 1) * sizeof (CHAR16));\r
-    } else {\r
-      //\r
-      // Copy status code data header\r
-      //\r
-      CopyMem (&Record->Data, Data, sizeof (EFI_STATUS_CODE_DATA));\r
-\r
-      if (Data->Size > EFI_STATUS_CODE_DATA_MAX_SIZE) {\r
-        Record->Data.Size = EFI_STATUS_CODE_DATA_MAX_SIZE;\r
-      }\r
-      CopyMem ((VOID *) (Record + 1), Data + 1, Record->Data.Size);\r
-    }\r
-  }\r
-\r
-  gBS->SignalEvent (mLogDataHubEvent);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
-  The Event handler which will be notified to log data in Data Hub.\r
-\r
-  @param  Event       Instance of the EFI_EVENT to signal whenever data is\r
-                      available to be logged in the system.\r
-  @param  Context     Context of the event.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-LogDataHubEventCallBack (\r
-  IN  EFI_EVENT     Event,\r
-  IN  VOID          *Context\r
-  )\r
-{\r
-  DATA_HUB_STATUS_CODE_DATA_RECORD  *Record;\r
-  UINT32                            Size;\r
-  UINT64                            DataRecordClass;\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 (&mLogDataHubStatus, 0, 1) == 1) {\r
-    return;\r
-  }\r
-\r
-  //\r
-  // Log DataRecord in Data Hub.\r
-  // Journal records fifo to find all record entry.\r
-  //\r
-  while (TRUE) {\r
-    //\r
-    // Retrieve record from record FIFO until no more record can be retrieved.\r
-    //\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
-    mDataHubProtocol->LogData (\r
-                        mDataHubProtocol,\r
-                        &gEfiDataHubStatusCodeRecordGuid,\r
-                        &gEfiStatusCodeRuntimeProtocolGuid,\r
-                        DataRecordClass,\r
-                        Record,\r
-                        Size\r
-                        );\r
-\r
-    ReleaseRecord (Record);\r
-  }\r
-\r
-  //\r
-  // Restore the nest status of report\r
-  //\r
-  InterlockedCompareExchange32 (&mLogDataHubStatus, 1, 0);\r
-}\r
-\r
-\r
-/**\r
-  Locate Data Hub Protocol and create event for logging data\r
-  as initialization for data hub status code worker.\r
-\r
-  @retval EFI_SUCCESS  Initialization is successful.\r
-\r
-**/\r
-EFI_STATUS\r
-DataHubStatusCodeInitializeWorker (\r
-  VOID\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
-                  EVT_NOTIFY_SIGNAL,\r
-                  TPL_CALLBACK,\r
-                  LogDataHubEventCallBack,\r
-                  NULL,\r
-                  &mLogDataHubEvent\r
-                  );\r
-\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
diff --git a/IntelFrameworkModulePkg/Universal/StatusCode/Dxe/DxeStatusCode.c b/IntelFrameworkModulePkg/Universal/StatusCode/Dxe/DxeStatusCode.c
deleted file mode 100644 (file)
index 55ae84a..0000000
+++ /dev/null
@@ -1,161 +0,0 @@
-/** @file\r
-  Status Code Architectural Protocol implementation as defined in Tiano\r
-  Architecture Specification.\r
-\r
-  This driver has limited functionality at runtime and will not log to Data Hub\r
-  at runtime.\r
-\r
-  Notes:\r
-  This driver assumes the following ReportStatusCode strategy:\r
-  PEI       -> uses PeiReportStatusCode\r
-  DXE IPL   -> uses PeiReportStatusCode\r
-  early DXE -> uses PeiReportStatusCode via HOB\r
-  DXE       -> This driver\r
-  RT        -> This driver\r
-\r
-  Copyright (c) 2006 - 2009, Intel Corporation                                                         \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 "DxeStatusCode.h"\r
-\r
-/**\r
-  Dispatch initialization request to sub status code devices based on \r
-  customized feature flags.\r
\r
-**/\r
-VOID\r
-InitializationDispatcherWorker (\r
-  VOID\r
-  )\r
-{\r
-  EFI_PEI_HOB_POINTERS              Hob;\r
-  EFI_STATUS                        Status;\r
-  MEMORY_STATUSCODE_PACKET_HEADER   *PacketHeader;\r
-  MEMORY_STATUSCODE_RECORD          *Record;\r
-  UINTN                             ExpectedPacketIndex;\r
-  UINTN                             Index;\r
-  VOID                              *HobStart;\r
-\r
-  //\r
-  // If enable UseSerial, then initialize serial port.\r
-  // if enable UseRuntimeMemory, then initialize runtime memory status code worker.\r
-  // if enable UseDataHub, then initialize data hub status code worker.\r
-  //\r
-  if (FeaturePcdGet (PcdStatusCodeUseEfiSerial)) {\r
-    Status = EfiSerialStatusCodeInitializeWorker ();\r
-    ASSERT_EFI_ERROR (Status);\r
-  }\r
-  if (FeaturePcdGet (PcdStatusCodeUseHardSerial)) {\r
-    //\r
-    // Call Serial Port Lib API to initialize serial port.\r
-    //\r
-    Status = SerialPortInitialize ();\r
-    ASSERT_EFI_ERROR (Status);\r
-  }\r
-  if (FeaturePcdGet (PcdStatusCodeUseRuntimeMemory)) {\r
-    Status = RtMemoryStatusCodeInitializeWorker ();\r
-    ASSERT_EFI_ERROR (Status);\r
-  }\r
-  if (FeaturePcdGet (PcdStatusCodeUseDataHub)) {\r
-    Status = DataHubStatusCodeInitializeWorker ();\r
-    ASSERT_EFI_ERROR (Status);\r
-  }\r
-  if (FeaturePcdGet (PcdStatusCodeUseOEM)) {\r
-    //\r
-    // Call OEM hook status code library API to initialize OEM device for status code.\r
-    //\r
-    Status = OemHookStatusCodeInitialize ();\r
-    ASSERT_EFI_ERROR (Status);\r
-  }\r
-\r
-  //\r
-  // Replay Status code which saved in GUID'ed HOB to all supported devices. \r
-  //\r
-\r
-  // \r
-  // Journal GUID'ed HOBs to find all record entry, if found, \r
-  // then output record to support replay device.\r
-  //\r
-  ExpectedPacketIndex = 0;\r
-  Hob.Raw   = GetFirstGuidHob (&gMemoryStatusCodeRecordGuid);\r
-  HobStart  = Hob.Raw;\r
-  while (Hob.Raw != NULL) {\r
-    PacketHeader = (MEMORY_STATUSCODE_PACKET_HEADER *) GET_GUID_HOB_DATA (Hob.Guid);\r
-    if (PacketHeader->PacketIndex == ExpectedPacketIndex) {\r
-      Record = (MEMORY_STATUSCODE_RECORD *) (PacketHeader + 1);\r
-      for (Index = 0; Index < PacketHeader->RecordIndex; Index++) {\r
-        //\r
-        // Dispatch records to devices based on feature flag.\r
-        //\r
-        if (FeaturePcdGet (PcdStatusCodeReplayInSerial) && \r
-            (FeaturePcdGet (PcdStatusCodeUseHardSerial) ||\r
-             FeaturePcdGet (PcdStatusCodeUseEfiSerial))) {\r
-          SerialStatusCodeReportWorker (\r
-            Record[Index].CodeType,\r
-            Record[Index].Value,\r
-            Record[Index].Instance,\r
-            NULL,\r
-            NULL\r
-            );\r
-        }\r
-        if (FeaturePcdGet (PcdStatusCodeReplayInRuntimeMemory) &&\r
-            FeaturePcdGet (PcdStatusCodeUseRuntimeMemory)) {\r
-          RtMemoryStatusCodeReportWorker (\r
-            Record[Index].CodeType,\r
-            Record[Index].Value,\r
-            Record[Index].Instance\r
-            );\r
-        }\r
-        if (FeaturePcdGet (PcdStatusCodeReplayInDataHub) &&\r
-            FeaturePcdGet (PcdStatusCodeUseDataHub)) {\r
-          DataHubStatusCodeReportWorker (\r
-            Record[Index].CodeType,\r
-            Record[Index].Value,\r
-            Record[Index].Instance,\r
-            NULL,\r
-            NULL\r
-            );\r
-        }\r
-        if (FeaturePcdGet (PcdStatusCodeReplayInOEM) &&\r
-            FeaturePcdGet (PcdStatusCodeUseOEM)) {\r
-          //\r
-          // Call OEM hook status code library API to report status code to OEM device\r
-          //\r
-          OemHookStatusCodeReport (\r
-            Record[Index].CodeType,\r
-            Record[Index].Value,\r
-            Record[Index].Instance,\r
-            NULL,\r
-            NULL\r
-            );\r
-        }\r
-      }\r
-      ExpectedPacketIndex++;\r
-\r
-      //\r
-      // See whether there is gap of packet or not\r
-      //\r
-      if (HobStart != NULL) {\r
-        HobStart  = NULL;\r
-        Hob.Raw   = HobStart;\r
-        continue;\r
-      }\r
-    } else if (HobStart != NULL) {\r
-      //\r
-      // Cache the found packet for improve the performance\r
-      //\r
-      HobStart = Hob.Raw;\r
-    }\r
-\r
-    Hob.Raw = GetNextGuidHob (&gMemoryStatusCodeRecordGuid, Hob.Raw);\r
-  }\r
-}\r
-\r
diff --git a/IntelFrameworkModulePkg/Universal/StatusCode/Dxe/DxeStatusCode.h b/IntelFrameworkModulePkg/Universal/StatusCode/Dxe/DxeStatusCode.h
deleted file mode 100644 (file)
index dbf356b..0000000
+++ /dev/null
@@ -1,241 +0,0 @@
-/** @file\r
-  Internal include file of Status Code Runtime DXE Driver.\r
-\r
-  Copyright (c) 2006 - 2009, Intel Corporation\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
-#ifndef __STATUS_CODE_RUNTIME_DXE_H__\r
-#define __STATUS_CODE_RUNTIME_DXE_H__\r
-\r
-\r
-#include <FrameworkDxe.h>\r
-#include <FrameworkModuleDxe.h>\r
-#include <Guid/DataHubStatusCodeRecord.h>\r
-#include <Protocol/DataHub.h>\r
-#include <Protocol/SerialIo.h>\r
-#include <Guid/MemoryStatusCodeRecord.h>\r
-#include <Protocol/StatusCode.h>\r
-#include <Guid/StatusCodeDataTypeId.h>\r
-#include <Guid/EventGroup.h>\r
-\r
-#include <Library/BaseLib.h>\r
-#include <Library/SynchronizationLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/ReportStatusCodeLib.h>\r
-#include <Library/PrintLib.h>\r
-#include <Library/PcdLib.h>\r
-#include <Library/HobLib.h>\r
-#include <Library/UefiDriverEntryPoint.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/UefiLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/UefiRuntimeLib.h>\r
-#include <Library/SerialPortLib.h>\r
-#include <Library/OemHookStatusCodeLib.h>\r
-\r
-//\r
-// Data hub worker definition\r
-//\r
-#define DATAHUB_STATUS_CODE_SIGNATURE             SIGNATURE_32 ('B', 'D', 'H', 'S')\r
-\r
-typedef struct {\r
-  UINTN       Signature;\r
-  LIST_ENTRY  Node;\r
-  UINT8       Data[sizeof(DATA_HUB_STATUS_CODE_DATA_RECORD) + EFI_STATUS_CODE_DATA_MAX_SIZE];\r
-} DATAHUB_STATUSCODE_RECORD;\r
-\r
-\r
-//\r
-// Runtime memory status code worker definition\r
-//\r
-typedef struct {\r
-  UINT32   RecordIndex;\r
-  UINT32   NumberOfRecords;\r
-  UINT32   MaxRecordsNumber;\r
-} RUNTIME_MEMORY_STATUSCODE_HEADER;\r
-\r
-extern RUNTIME_MEMORY_STATUSCODE_HEADER  *mRtMemoryStatusCodeTable;\r
-\r
-/**\r
-  Report status code to all supported device.\r
-\r
-  This function implements EFI_STATUS_CODE_PROTOCOL.ReportStatusCode().\r
-  It calls into the workers which dispatches the platform specific listeners.\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
-EFIAPI\r
-ReportDispatcher (\r
-  IN EFI_STATUS_CODE_TYPE     CodeType,\r
-  IN EFI_STATUS_CODE_VALUE    Value,\r
-  IN UINT32                   Instance,\r
-  IN EFI_GUID                 *CallerId  OPTIONAL,\r
-  IN EFI_STATUS_CODE_DATA     *Data      OPTIONAL\r
-  );\r
-\r
-/**\r
-  Dispatch initialization request to sub status code devices based on \r
-  customized feature flags.\r
\r
-**/\r
-VOID\r
-InitializationDispatcherWorker (\r
-  VOID\r
-  );\r
-\r
-\r
-/**\r
-  Locates Serial I/O Protocol as initialization for serial status code worker.\r
\r
-  @retval EFI_SUCCESS  Serial I/O Protocol is successfully located.\r
-\r
-**/\r
-EFI_STATUS\r
-EfiSerialStatusCodeInitializeWorker (\r
-  VOID\r
-  );\r
-\r
-\r
-/**\r
-  Convert status code value and extended data to readable ASCII string, send string to serial I/O device.\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      Status code reported to serial I/O successfully.\r
-  @retval EFI_DEVICE_ERROR EFI serial device cannot work after ExitBootService() is called.\r
-  @retval EFI_DEVICE_ERROR EFI serial device cannot work with TPL higher than TPL_CALLBACK.\r
-\r
-**/\r
-EFI_STATUS\r
-SerialStatusCodeReportWorker (\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
-  Initialize runtime memory status code table as initialization for runtime memory status code worker\r
\r
-  @retval EFI_SUCCESS  Runtime memory status code table successfully initialized.\r
-\r
-**/\r
-EFI_STATUS\r
-RtMemoryStatusCodeInitializeWorker (\r
-  VOID\r
-  );\r
-\r
-/**\r
-  Report status code into runtime memory. If the runtime pool is full, roll back to the \r
-  first record and overwrite it.\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
\r
-  @retval EFI_SUCCESS             Status code successfully recorded in runtime memory status code table.\r
-\r
-**/\r
-EFI_STATUS\r
-RtMemoryStatusCodeReportWorker (\r
-  IN EFI_STATUS_CODE_TYPE               CodeType,\r
-  IN EFI_STATUS_CODE_VALUE              Value,\r
-  IN UINT32                             Instance\r
-  );\r
-\r
-/**\r
-  Locate Data Hub Protocol and create event for logging data\r
-  as initialization for data hub status code worker.\r
-\r
-  @retval EFI_SUCCESS  Initialization is successful.\r
-\r
-**/\r
-EFI_STATUS\r
-DataHubStatusCodeInitializeWorker (\r
-  VOID\r
-  );\r
-\r
-\r
-/**\r
-  Report status code into DataHub.\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     Function is reentered.\r
-  @retval EFI_DEVICE_ERROR     Function is called at runtime.\r
-  @retval EFI_OUT_OF_RESOURCES Fail to allocate memory for free record buffer.\r
-\r
-**/\r
-EFI_STATUS\r
-DataHubStatusCodeReportWorker (\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
-/**\r
-  Virtual address change notification call back. It converts global pointer\r
-  to virtual address.\r
-\r
-  @param  Event         Event whose notification function is being invoked.\r
-  @param  Context       Pointer to the notification function's context, which is\r
-                        always zero in current implementation.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-VirtualAddressChangeCallBack (\r
-  IN EFI_EVENT  Event,\r
-  IN VOID       *Context\r
-  );\r
-\r
-#endif\r
diff --git a/IntelFrameworkModulePkg/Universal/StatusCode/Dxe/DxeStatusCode.inf b/IntelFrameworkModulePkg/Universal/StatusCode/Dxe/DxeStatusCode.inf
deleted file mode 100644 (file)
index 3df5174..0000000
+++ /dev/null
@@ -1,104 +0,0 @@
-#/** @file\r
-#  Status Code Runtime Dxe driver that supports multiple devices and produces\r
-#  Status Code Runtime Protocol.\r
-#\r
-#  Copyright (c) 2006 - 2009, Intel Corporation.\r
-#\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
-#  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
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = DxeStatusCode\r
-  FILE_GUID                      = FEDE0A1B-BCA2-4A9F-BB2B-D9FD7DEC2E9F\r
-  MODULE_TYPE                    = DXE_RUNTIME_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-  EFI_SPECIFICATION_VERSION      = 0x00020000\r
-  ENTRY_POINT                    = DxeStatusCodeDriverEntry\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
-#\r
-#  VIRTUAL_ADDRESS_MAP_CALLBACK  =  VirtualAddressChangeCallBack\r
-#\r
-\r
-[Sources.common]\r
-  SerialStatusCodeWorker.c\r
-  RtMemoryStatusCodeWorker.c\r
-  DataHubStatusCodeWorker.c\r
-  DxeStatusCode.c\r
-  DxeStatusCode.h\r
-\r
-[Sources.Ia32]\r
-  DxeStatusCodeCommon.c\r
-\r
-[Sources.X64]\r
-  DxeStatusCodeCommon.c\r
-\r
-[Sources.EBC]\r
-  DxeStatusCodeCommon.c\r
-\r
-\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  IntelFrameworkPkg/IntelFrameworkPkg.dec\r
-  IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec\r
-\r
-[LibraryClasses]\r
-  OemHookStatusCodeLib\r
-  SerialPortLib\r
-  UefiRuntimeLib\r
-  MemoryAllocationLib\r
-  UefiLib\r
-  UefiBootServicesTableLib\r
-  UefiDriverEntryPoint\r
-  HobLib\r
-  PcdLib\r
-  PrintLib\r
-  ReportStatusCodeLib\r
-  DebugLib\r
-  BaseMemoryLib\r
-  BaseLib\r
-  SynchronizationLib\r
-\r
-\r
-[Guids]\r
-  gEfiDataHubStatusCodeRecordGuid               ## SOMETIMES_CONSUMES (Needed if Data Hub is supported for status code.)\r
-  gEfiStatusCodeDataTypeDebugGuid               ## SOMETIMES_CONSUMES (Needed if Data Hub is supported for status code.)\r
-  gMemoryStatusCodeRecordGuid                   ## CONSUMES ## HOB\r
-  gEfiEventVirtualAddressChangeGuid             ## CONSUMES ## Event\r
-\r
-\r
-[Protocols]\r
-  gEfiStatusCodeRuntimeProtocolGuid             ## PRODUCES\r
-  gEfiDataHubProtocolGuid                       ## SOMETIMES_CONSUMES (Needed if Data Hub is supported for status code.)\r
-  gEfiSerialIoProtocolGuid                      ## SOMETIMES_CONSUMES (Needed if Serial is supported for status code.)\r
-\r
-\r
-[FeaturePcd.common]\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdStatusCodeReplayInOEM\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdStatusCodeReplayInRuntimeMemory\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdStatusCodeReplayInDataHub\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdStatusCodeReplayInSerial\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdStatusCodeUseOEM\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdStatusCodeUseDataHub\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdStatusCodeUseRuntimeMemory\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdStatusCodeUseEfiSerial\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdStatusCodeUseHardSerial\r
-\r
-\r
-[Pcd.common]\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdStatusCodeRuntimeMemorySize\r
-\r
-[Depex]\r
-  TRUE
\ No newline at end of file
diff --git a/IntelFrameworkModulePkg/Universal/StatusCode/Dxe/DxeStatusCodeCommon.c b/IntelFrameworkModulePkg/Universal/StatusCode/Dxe/DxeStatusCodeCommon.c
deleted file mode 100644 (file)
index 8711279..0000000
+++ /dev/null
@@ -1,193 +0,0 @@
-/** @file\r
-  Status code driver for IA32/X64/EBC architecture.\r
-\r
-  Copyright (c) 2006, Intel Corporation\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 "DxeStatusCode.h"\r
-\r
-EFI_EVENT    mVirtualAddressChangeEvent = NULL;\r
-EFI_HANDLE   mHandle = NULL;\r
-\r
-//\r
-// Declaration of status code protocol.\r
-//\r
-EFI_STATUS_CODE_PROTOCOL  mEfiStatusCodeProtocol  = {\r
-  ReportDispatcher\r
-};\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
-/**\r
-  Entry point of DXE Status Code Driver.\r
-\r
-  This function is the entry point of this DXE Status Code Driver.\r
-  It installs Status Code Runtime Protocol, and registers event for EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE.\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
-DxeStatusCodeDriverEntry (\r
-  IN EFI_HANDLE         ImageHandle,\r
-  IN EFI_SYSTEM_TABLE   *SystemTable\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-\r
-  //\r
-  // Dispatch initialization request to supported devices\r
-  //\r
-  InitializationDispatcherWorker ();\r
-\r
-  //\r
-  // Install Status Code Runtime Protocol implementation as defined in PI Specification.\r
-  //\r
-  Status = gBS->InstallMultipleProtocolInterfaces (\r
-                  &mHandle,\r
-                  &gEfiStatusCodeRuntimeProtocolGuid,\r
-                  &mEfiStatusCodeProtocol,\r
-                  NULL\r
-                  );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  Status = gBS->CreateEventEx (\r
-                  EVT_NOTIFY_SIGNAL,\r
-                  TPL_NOTIFY,\r
-                  VirtualAddressChangeCallBack,\r
-                  NULL,\r
-                  &gEfiEventVirtualAddressChangeGuid,\r
-                  &mVirtualAddressChangeEvent\r
-                  );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Report status code to all supported device.\r
-\r
-  This function implements EFI_STATUS_CODE_PROTOCOL.ReportStatusCode().\r
-  It calls into the workers which dispatches the platform specific listeners.\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
-EFIAPI\r
-ReportDispatcher (\r
-  IN EFI_STATUS_CODE_TYPE     CodeType,\r
-  IN EFI_STATUS_CODE_VALUE    Value,\r
-  IN UINT32                   Instance,\r
-  IN EFI_GUID                 *CallerId  OPTIONAL,\r
-  IN EFI_STATUS_CODE_DATA     *Data      OPTIONAL\r
-  )\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
-  if (FeaturePcdGet (PcdStatusCodeUseEfiSerial) || FeaturePcdGet (PcdStatusCodeUseHardSerial)) {\r
-    SerialStatusCodeReportWorker (\r
-      CodeType,\r
-      Value,\r
-      Instance,\r
-      CallerId,\r
-      Data\r
-      );\r
-  }\r
-  if (FeaturePcdGet (PcdStatusCodeUseRuntimeMemory)) {\r
-    RtMemoryStatusCodeReportWorker (\r
-      CodeType,\r
-      Value,\r
-      Instance\r
-      );\r
-  }\r
-  if (FeaturePcdGet (PcdStatusCodeUseDataHub)) {\r
-    DataHubStatusCodeReportWorker (\r
-      CodeType,\r
-      Value,\r
-      Instance,\r
-      CallerId,\r
-      Data\r
-      );\r
-  }\r
-  if (FeaturePcdGet (PcdStatusCodeUseOEM)) {\r
-    //\r
-    // Call OEM hook status code library API to report status code to OEM device\r
-    //\r
-    OemHookStatusCodeReport (\r
-      CodeType,\r
-      Value,\r
-      Instance,\r
-      CallerId,\r
-      Data\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
-/**\r
-  Virtual address change notification call back. It converts global pointer\r
-  to virtual address.\r
-\r
-  @param  Event         Event whose notification function is being invoked.\r
-  @param  Context       Pointer to the notification function's context, which is\r
-                        always zero in current implementation.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-VirtualAddressChangeCallBack (\r
-  IN EFI_EVENT        Event,\r
-  IN VOID             *Context\r
-  )\r
-{\r
-  //\r
-  // Convert memory status code table to virtual address;\r
-  //\r
-  EfiConvertPointer (\r
-    0,\r
-    (VOID **) &mRtMemoryStatusCodeTable\r
-    );\r
-}\r
-\r
diff --git a/IntelFrameworkModulePkg/Universal/StatusCode/Dxe/RtMemoryStatusCodeWorker.c b/IntelFrameworkModulePkg/Universal/StatusCode/Dxe/RtMemoryStatusCodeWorker.c
deleted file mode 100644 (file)
index 3c75f41..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-/** @file\r
-  Runtime memory status code worker.\r
-\r
-  Copyright (c) 2006 - 2009, Intel Corporation                                                         \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 "DxeStatusCode.h"\r
-\r
-RUNTIME_MEMORY_STATUSCODE_HEADER  *mRtMemoryStatusCodeTable;\r
-\r
-/**\r
-  Initialize runtime memory status code table as initialization for runtime memory status code worker\r
\r
-  @retval EFI_SUCCESS  Runtime memory status code table successfully initialized.\r
-\r
-**/\r
-EFI_STATUS\r
-RtMemoryStatusCodeInitializeWorker (\r
-  VOID\r
-  )\r
-{\r
-  //\r
-  // Allocate runtime memory status code pool.\r
-  //\r
-  mRtMemoryStatusCodeTable = AllocateRuntimePool (\r
-                               sizeof (RUNTIME_MEMORY_STATUSCODE_HEADER) +\r
-                               PcdGet16 (PcdStatusCodeRuntimeMemorySize) *\r
-                               1024\r
-                               );\r
-  ASSERT (mRtMemoryStatusCodeTable != NULL);\r
-\r
-  mRtMemoryStatusCodeTable->RecordIndex      = 0;\r
-  mRtMemoryStatusCodeTable->NumberOfRecords  = 0;\r
-  mRtMemoryStatusCodeTable->MaxRecordsNumber = \r
-    (PcdGet16 (PcdStatusCodeRuntimeMemorySize) * 1024) / sizeof (MEMORY_STATUSCODE_RECORD);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
-  Report status code into runtime memory. If the runtime pool is full, roll back to the \r
-  first record and overwrite it.\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
\r
-  @retval EFI_SUCCESS             Status code successfully recorded in runtime memory status code table.\r
-\r
-**/\r
-EFI_STATUS\r
-RtMemoryStatusCodeReportWorker (\r
-  IN EFI_STATUS_CODE_TYPE               CodeType,\r
-  IN EFI_STATUS_CODE_VALUE              Value,\r
-  IN UINT32                             Instance\r
-  )\r
-{\r
-  MEMORY_STATUSCODE_RECORD              *Record;\r
-\r
-  //\r
-  // Locate current record buffer.\r
-  //\r
-  Record = (MEMORY_STATUSCODE_RECORD *) (mRtMemoryStatusCodeTable + 1);\r
-  Record = &Record[mRtMemoryStatusCodeTable->RecordIndex++];\r
-\r
-  //\r
-  // Save status code.\r
-  //\r
-  Record->CodeType = CodeType;\r
-  Record->Value    = Value;\r
-  Record->Instance = Instance;\r
-\r
-  //\r
-  // If record index equals to max record number, then wrap around record index to zero.\r
-  //\r
-  // The reader of status code should compare the number of records with max records number,\r
-  // If it is equal to or larger than the max number, then the wrap-around had happened,\r
-  // so the first record is pointed by record index.\r
-  // If it is less then max number, index of the first record is zero.\r
-  //\r
-  mRtMemoryStatusCodeTable->NumberOfRecords++;\r
-  if (mRtMemoryStatusCodeTable->RecordIndex == mRtMemoryStatusCodeTable->MaxRecordsNumber) {\r
-    //\r
-    // Wrap around record index.\r
-    //\r
-    mRtMemoryStatusCodeTable->RecordIndex = 0;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-\r
diff --git a/IntelFrameworkModulePkg/Universal/StatusCode/Dxe/SerialStatusCodeWorker.c b/IntelFrameworkModulePkg/Universal/StatusCode/Dxe/SerialStatusCodeWorker.c
deleted file mode 100644 (file)
index d9ec8c5..0000000
+++ /dev/null
@@ -1,194 +0,0 @@
-/** @file\r
-  Serial I/O status code reporting worker.\r
-\r
-  Copyright (c) 2006 - 2009, Intel Corporation                                                         \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 "DxeStatusCode.h"\r
-\r
-EFI_SERIAL_IO_PROTOCOL *mSerialIoProtocol;\r
-\r
-/**\r
-  Locates Serial I/O Protocol as initialization for serial status code worker.\r
\r
-  @retval EFI_SUCCESS  Serial I/O Protocol is successfully located.\r
-\r
-**/\r
-EFI_STATUS\r
-EfiSerialStatusCodeInitializeWorker (\r
-  VOID\r
-  )\r
-{\r
-  EFI_STATUS Status;\r
-\r
-  Status = gBS->LocateProtocol (\r
-             &gEfiSerialIoProtocolGuid,\r
-             NULL,\r
-             (VOID **) &mSerialIoProtocol\r
-             );\r
-\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
-  Convert status code value and extended data to readable ASCII string, send string to serial I/O device.\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      Status code reported to serial I/O successfully.\r
-  @retval EFI_DEVICE_ERROR EFI serial device cannot work after ExitBootService() is called.\r
-  @retval EFI_DEVICE_ERROR EFI serial device cannot work with TPL higher than TPL_CALLBACK.\r
-\r
-**/\r
-EFI_STATUS\r
-SerialStatusCodeReportWorker (\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
-  CHAR8           *Filename;\r
-  CHAR8           *Description;\r
-  CHAR8           *Format;\r
-  CHAR8           Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE];\r
-  UINT32          ErrorLevel;\r
-  UINT32          LineNumber;\r
-  UINTN           CharCount;\r
-  VA_LIST         Marker;\r
-\r
-  if (FeaturePcdGet (PcdStatusCodeUseEfiSerial)) {\r
-    if (EfiAtRuntime ()) {\r
-      return EFI_DEVICE_ERROR;\r
-    }\r
-    if (EfiGetCurrentTpl () > TPL_CALLBACK ) {\r
-      return EFI_DEVICE_ERROR;\r
-    }\r
-  }\r
-\r
-  Buffer[0] = '\0';\r
-\r
-  if (Data != NULL &&\r
-      ReportStatusCodeExtractAssertInfo (CodeType, Value, Data, &Filename, &Description, &LineNumber)) {\r
-    //\r
-    // Print ASSERT() information into output buffer.\r
-    //\r
-    CharCount = AsciiSPrint (\r
-                  Buffer,\r
-                  EFI_STATUS_CODE_DATA_MAX_SIZE,\r
-                  "\n\rDXE_ASSERT!: %a (%d): %a\n\r",\r
-                  Filename,\r
-                  LineNumber,\r
-                  Description\r
-                  );\r
-  } else if (Data != NULL &&\r
-             ReportStatusCodeExtractDebugInfo (Data, &ErrorLevel, &Marker, &Format)) {\r
-    //\r
-    // Print DEBUG() information into output buffer.\r
-    //\r
-    CharCount = AsciiVSPrint (\r
-                  Buffer, \r
-                  EFI_STATUS_CODE_DATA_MAX_SIZE, \r
-                  Format, \r
-                  Marker\r
-                  );\r
-  } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) {\r
-    //\r
-    // Print ERROR information into output buffer.\r
-    //\r
-    CharCount = AsciiSPrint (\r
-                  Buffer, \r
-                  EFI_STATUS_CODE_DATA_MAX_SIZE, \r
-                  "ERROR: C%x:V%x I%x", \r
-                  CodeType, \r
-                  Value, \r
-                  Instance\r
-                  );\r
-   \r
-    if (CallerId != NULL) {\r
-      CharCount += AsciiSPrint (\r
-                     &Buffer[CharCount - 1],\r
-                     (EFI_STATUS_CODE_DATA_MAX_SIZE - (sizeof (Buffer[0]) * CharCount)),\r
-                     " %g",\r
-                     CallerId\r
-                     );\r
-    }\r
-\r
-    if (Data != NULL) {\r
-      CharCount += AsciiSPrint (\r
-                     &Buffer[CharCount - 1],\r
-                     (EFI_STATUS_CODE_DATA_MAX_SIZE - (sizeof (Buffer[0]) * CharCount)),\r
-                     " %x",\r
-                     Data\r
-                     );\r
-    }\r
-\r
-    CharCount += AsciiSPrint (\r
-                   &Buffer[CharCount - 1],\r
-                   (EFI_STATUS_CODE_DATA_MAX_SIZE - (sizeof (Buffer[0]) * CharCount)),\r
-                   "\n\r"\r
-                   );\r
-  } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) {\r
-    //\r
-    // Print PROGRESS information into output buffer.\r
-    //\r
-    CharCount = AsciiSPrint (\r
-                  Buffer, \r
-                  EFI_STATUS_CODE_DATA_MAX_SIZE, \r
-                  "PROGRESS CODE: V%x I%x\n\r", \r
-                  Value, \r
-                  Instance\r
-                  );\r
-  } else {\r
-    //\r
-    // Code type is not defined.\r
-    //\r
-    CharCount = AsciiSPrint (\r
-                  Buffer, \r
-                  EFI_STATUS_CODE_DATA_MAX_SIZE, \r
-                  "Undefined: C%x:V%x I%x\n\r", \r
-                  CodeType, \r
-                  Value, \r
-                  Instance\r
-                  );\r
-  }\r
-\r
-\r
-  if (FeaturePcdGet (PcdStatusCodeUseHardSerial)) {\r
-    //\r
-    // Call SerialPort Lib function to do print.\r
-    //\r
-    SerialPortWrite ((UINT8 *) Buffer, CharCount);\r
-  }\r
-  if (FeaturePcdGet (PcdStatusCodeUseEfiSerial)) {\r
-    mSerialIoProtocol->Write (\r
-      mSerialIoProtocol,\r
-      &CharCount,\r
-      Buffer\r
-      );\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
diff --git a/IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/DataHubStatusCodeWorker.c b/IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/DataHubStatusCodeWorker.c
new file mode 100644 (file)
index 0000000..743f618
--- /dev/null
@@ -0,0 +1,379 @@
+/** @file\r
+  Data Hub status code worker.\r
+\r
+  Copyright (c) 2006 - 2009, Intel Corporation\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 "StatusCodeRuntimeDxe.h"\r
+\r
+//\r
+// Initialize FIFO to cache records.\r
+//\r
+LIST_ENTRY                mRecordsFifo          = INITIALIZE_LIST_HEAD_VARIABLE (mRecordsFifo);\r
+LIST_ENTRY                mRecordsBuffer        = INITIALIZE_LIST_HEAD_VARIABLE (mRecordsBuffer);\r
+UINT32                    mLogDataHubStatus     = 0;\r
+EFI_EVENT                 mLogDataHubEvent;\r
+//\r
+// Cache data hub protocol.\r
+//\r
+EFI_DATA_HUB_PROTOCOL     *mDataHubProtocol;\r
+\r
+\r
+/**\r
+  Retrieve one record of from free record buffer. This record is removed from\r
+  free record buffer.\r
+\r
+  This function retrieves one record from free record buffer.\r
+  If the pool has been exhausted, then new memory would be allocated for it.\r
+\r
+  @return  Pointer to the free record.\r
+           NULL means failure to allocate new memeory for free record buffer.\r
+\r
+**/\r
+DATA_HUB_STATUS_CODE_DATA_RECORD *\r
+AcquireRecordBuffer (\r
+  VOID\r
+  )\r
+{\r
+  DATAHUB_STATUSCODE_RECORD *Record;\r
+  EFI_TPL                   CurrentTpl;\r
+  LIST_ENTRY                *Node;\r
+  UINT32                    Index;\r
+\r
+  CurrentTpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);\r
+\r
+  if (!IsListEmpty (&mRecordsBuffer)) {\r
+    //\r
+    // Strip one entry from free record buffer.\r
+    //\r
+    Node = GetFirstNode (&mRecordsBuffer);\r
+    RemoveEntryList (Node);\r
+\r
+    Record = BASE_CR (Node, DATAHUB_STATUSCODE_RECORD, Node);\r
+  } else {\r
+    if (CurrentTpl > TPL_NOTIFY) {\r
+      //\r
+      // Memory management should work at <=TPL_NOTIFY\r
+      // \r
+      gBS->RestoreTPL (CurrentTpl);\r
+      return NULL;\r
+    }\r
+\r
+    //\r
+    // If free record buffer is exhausted, then allocate 16 new records for it.\r
+    //\r
+    gBS->RestoreTPL (CurrentTpl);\r
+    Record   = (DATAHUB_STATUSCODE_RECORD *) AllocateZeroPool (sizeof (DATAHUB_STATUSCODE_RECORD) * 16);\r
+    if (Record == NULL) {\r
+      return NULL;\r
+    }\r
+\r
+    CurrentTpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);\r
+    //\r
+    // Here we only insert 15 new records to the free record buffer, for the first record\r
+    // will be returned immediately.\r
+    //\r
+    for (Index = 1; Index < 16; Index++) {\r
+      InsertTailList (&mRecordsBuffer, &Record[Index].Node);\r
+    }\r
+  }\r
+\r
+  Record->Signature = DATAHUB_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
+\r
+/**\r
+  Retrieve one record from Records FIFO. The record would be removed from FIFO.\r
+\r
+  @return   Point to record, which is ready to be logged.\r
+            NULL means the FIFO of record is empty.\r
+\r
+**/\r
+DATA_HUB_STATUS_CODE_DATA_RECORD *\r
+RetrieveRecord (\r
+  VOID\r
+  )\r
+{\r
+  DATA_HUB_STATUS_CODE_DATA_RECORD  *RecordData;\r
+  DATAHUB_STATUSCODE_RECORD         *Record;\r
+  LIST_ENTRY                        *Node;\r
+  EFI_TPL                           CurrentTpl;\r
+\r
+  RecordData = NULL;\r
+\r
+  CurrentTpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);\r
+\r
+  if (!IsListEmpty (&mRecordsFifo)) {\r
+    Node = GetFirstNode (&mRecordsFifo);\r
+    Record = CR (Node, DATAHUB_STATUSCODE_RECORD, Node, DATAHUB_STATUS_CODE_SIGNATURE);\r
+    ASSERT (Record != NULL);\r
+\r
+    RemoveEntryList (&Record->Node);\r
+    RecordData = (DATA_HUB_STATUS_CODE_DATA_RECORD *) Record->Data;\r
+  }\r
+\r
+  gBS->RestoreTPL (CurrentTpl);\r
+\r
+  return RecordData;\r
+}\r
+\r
+/**\r
+  Release given record and return it to free record buffer.\r
+  \r
+  @param RecordData  Pointer to the record to release.\r
+\r
+**/\r
+VOID\r
+ReleaseRecord (\r
+  DATA_HUB_STATUS_CODE_DATA_RECORD  *RecordData\r
+  )\r
+{\r
+  DATAHUB_STATUSCODE_RECORD         *Record;\r
+  EFI_TPL                           CurrentTpl;\r
+\r
+  Record = CR (RecordData, DATAHUB_STATUSCODE_RECORD, Data[0], DATAHUB_STATUS_CODE_SIGNATURE);\r
+  ASSERT (Record != NULL);\r
+\r
+  CurrentTpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);\r
+\r
+  InsertTailList (&mRecordsBuffer, &Record->Node);\r
+  Record->Signature = 0;\r
+\r
+  gBS->RestoreTPL (CurrentTpl);\r
+}\r
+\r
+/**\r
+  Report status code into DataHub.\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     Function is reentered.\r
+  @retval EFI_DEVICE_ERROR     Function is called at runtime.\r
+  @retval EFI_OUT_OF_RESOURCES Fail to allocate memory for free record buffer.\r
+\r
+**/\r
+EFI_STATUS\r
+DataHubStatusCodeReportWorker (\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
+  DATA_HUB_STATUS_CODE_DATA_RECORD  *Record;\r
+  UINT32                            ErrorLevel;\r
+  VA_LIST                           Marker;\r
+  CHAR8                             *Format;\r
+  UINTN                             CharCount;\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 (&mLogDataHubStatus, 0, 0) == 1) {\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+\r
+  //\r
+  // See whether in runtime phase or not.\r
+  //\r
+  if (EfiAtRuntime ()) {\r
+    return EFI_DEVICE_ERROR;\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
+  //\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
+    CopyMem (&Record->CallerId, CallerId, sizeof (EFI_GUID));\r
+  }\r
+\r
+  if (Data != NULL) {\r
+    if (ReportStatusCodeExtractDebugInfo (Data, &ErrorLevel, &Marker, &Format)) {\r
+      CharCount = UnicodeVSPrintAsciiFormat (\r
+                    (CHAR16 *) (Record + 1),\r
+                    EFI_STATUS_CODE_DATA_MAX_SIZE,\r
+                    Format,\r
+                    Marker\r
+                    );\r
+      //\r
+      // Change record data type to DebugType.\r
+      //\r
+      CopyGuid (&Record->Data.Type, &gEfiStatusCodeDataTypeDebugGuid);\r
+      Record->Data.HeaderSize = Data->HeaderSize;\r
+      Record->Data.Size = (UINT16) ((CharCount + 1) * sizeof (CHAR16));\r
+    } else {\r
+      //\r
+      // Copy status code data header\r
+      //\r
+      CopyMem (&Record->Data, Data, sizeof (EFI_STATUS_CODE_DATA));\r
+\r
+      if (Data->Size > EFI_STATUS_CODE_DATA_MAX_SIZE) {\r
+        Record->Data.Size = EFI_STATUS_CODE_DATA_MAX_SIZE;\r
+      }\r
+      CopyMem ((VOID *) (Record + 1), Data + 1, Record->Data.Size);\r
+    }\r
+  }\r
+\r
+  gBS->SignalEvent (mLogDataHubEvent);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+/**\r
+  The Event handler which will be notified to log data in Data Hub.\r
+\r
+  @param  Event       Instance of the EFI_EVENT to signal whenever data is\r
+                      available to be logged in the system.\r
+  @param  Context     Context of the event.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+LogDataHubEventCallBack (\r
+  IN  EFI_EVENT     Event,\r
+  IN  VOID          *Context\r
+  )\r
+{\r
+  DATA_HUB_STATUS_CODE_DATA_RECORD  *Record;\r
+  UINT32                            Size;\r
+  UINT64                            DataRecordClass;\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 (&mLogDataHubStatus, 0, 1) == 1) {\r
+    return;\r
+  }\r
+\r
+  //\r
+  // Log DataRecord in Data Hub.\r
+  // Journal records fifo to find all record entry.\r
+  //\r
+  while (TRUE) {\r
+    //\r
+    // Retrieve record from record FIFO until no more record can be retrieved.\r
+    //\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
+    mDataHubProtocol->LogData (\r
+                        mDataHubProtocol,\r
+                        &gEfiDataHubStatusCodeRecordGuid,\r
+                        &gEfiStatusCodeRuntimeProtocolGuid,\r
+                        DataRecordClass,\r
+                        Record,\r
+                        Size\r
+                        );\r
+\r
+    ReleaseRecord (Record);\r
+  }\r
+\r
+  //\r
+  // Restore the nest status of report\r
+  //\r
+  InterlockedCompareExchange32 (&mLogDataHubStatus, 1, 0);\r
+}\r
+\r
+\r
+/**\r
+  Locate Data Hub Protocol and create event for logging data\r
+  as initialization for data hub status code worker.\r
+\r
+  @retval EFI_SUCCESS  Initialization is successful.\r
+\r
+**/\r
+EFI_STATUS\r
+DataHubStatusCodeInitializeWorker (\r
+  VOID\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
+                  EVT_NOTIFY_SIGNAL,\r
+                  TPL_CALLBACK,\r
+                  LogDataHubEventCallBack,\r
+                  NULL,\r
+                  &mLogDataHubEvent\r
+                  );\r
+\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
diff --git a/IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/RtMemoryStatusCodeWorker.c b/IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/RtMemoryStatusCodeWorker.c
new file mode 100644 (file)
index 0000000..e67c31d
--- /dev/null
@@ -0,0 +1,105 @@
+/** @file\r
+  Runtime memory status code worker.\r
+\r
+  Copyright (c) 2006 - 2009, Intel Corporation                                                         \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 "StatusCodeRuntimeDxe.h"\r
+\r
+RUNTIME_MEMORY_STATUSCODE_HEADER  *mRtMemoryStatusCodeTable;\r
+\r
+/**\r
+  Initialize runtime memory status code table as initialization for runtime memory status code worker\r
\r
+  @retval EFI_SUCCESS  Runtime memory status code table successfully initialized.\r
+\r
+**/\r
+EFI_STATUS\r
+RtMemoryStatusCodeInitializeWorker (\r
+  VOID\r
+  )\r
+{\r
+  //\r
+  // Allocate runtime memory status code pool.\r
+  //\r
+  mRtMemoryStatusCodeTable = AllocateRuntimePool (\r
+                               sizeof (RUNTIME_MEMORY_STATUSCODE_HEADER) +\r
+                               PcdGet16 (PcdStatusCodeRuntimeMemorySize) *\r
+                               1024\r
+                               );\r
+  ASSERT (mRtMemoryStatusCodeTable != NULL);\r
+\r
+  mRtMemoryStatusCodeTable->RecordIndex      = 0;\r
+  mRtMemoryStatusCodeTable->NumberOfRecords  = 0;\r
+  mRtMemoryStatusCodeTable->MaxRecordsNumber = \r
+    (PcdGet16 (PcdStatusCodeRuntimeMemorySize) * 1024) / sizeof (MEMORY_STATUSCODE_RECORD);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+/**\r
+  Report status code into runtime memory. If the runtime pool is full, roll back to the \r
+  first record and overwrite it.\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
\r
+  @retval EFI_SUCCESS             Status code successfully recorded in runtime memory status code table.\r
+\r
+**/\r
+EFI_STATUS\r
+RtMemoryStatusCodeReportWorker (\r
+  IN EFI_STATUS_CODE_TYPE               CodeType,\r
+  IN EFI_STATUS_CODE_VALUE              Value,\r
+  IN UINT32                             Instance\r
+  )\r
+{\r
+  MEMORY_STATUSCODE_RECORD              *Record;\r
+\r
+  //\r
+  // Locate current record buffer.\r
+  //\r
+  Record = (MEMORY_STATUSCODE_RECORD *) (mRtMemoryStatusCodeTable + 1);\r
+  Record = &Record[mRtMemoryStatusCodeTable->RecordIndex++];\r
+\r
+  //\r
+  // Save status code.\r
+  //\r
+  Record->CodeType = CodeType;\r
+  Record->Value    = Value;\r
+  Record->Instance = Instance;\r
+\r
+  //\r
+  // If record index equals to max record number, then wrap around record index to zero.\r
+  //\r
+  // The reader of status code should compare the number of records with max records number,\r
+  // If it is equal to or larger than the max number, then the wrap-around had happened,\r
+  // so the first record is pointed by record index.\r
+  // If it is less then max number, index of the first record is zero.\r
+  //\r
+  mRtMemoryStatusCodeTable->NumberOfRecords++;\r
+  if (mRtMemoryStatusCodeTable->RecordIndex == mRtMemoryStatusCodeTable->MaxRecordsNumber) {\r
+    //\r
+    // Wrap around record index.\r
+    //\r
+    mRtMemoryStatusCodeTable->RecordIndex = 0;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+\r
diff --git a/IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/SerialStatusCodeWorker.c b/IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/SerialStatusCodeWorker.c
new file mode 100644 (file)
index 0000000..710a808
--- /dev/null
@@ -0,0 +1,194 @@
+/** @file\r
+  Serial I/O status code reporting worker.\r
+\r
+  Copyright (c) 2006 - 2009, Intel Corporation                                                         \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 "StatusCodeRuntimeDxe.h"\r
+\r
+EFI_SERIAL_IO_PROTOCOL *mSerialIoProtocol;\r
+\r
+/**\r
+  Locates Serial I/O Protocol as initialization for serial status code worker.\r
\r
+  @retval EFI_SUCCESS  Serial I/O Protocol is successfully located.\r
+\r
+**/\r
+EFI_STATUS\r
+EfiSerialStatusCodeInitializeWorker (\r
+  VOID\r
+  )\r
+{\r
+  EFI_STATUS Status;\r
+\r
+  Status = gBS->LocateProtocol (\r
+             &gEfiSerialIoProtocolGuid,\r
+             NULL,\r
+             (VOID **) &mSerialIoProtocol\r
+             );\r
+\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+/**\r
+  Convert status code value and extended data to readable ASCII string, send string to serial I/O device.\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      Status code reported to serial I/O successfully.\r
+  @retval EFI_DEVICE_ERROR EFI serial device cannot work after ExitBootService() is called.\r
+  @retval EFI_DEVICE_ERROR EFI serial device cannot work with TPL higher than TPL_CALLBACK.\r
+\r
+**/\r
+EFI_STATUS\r
+SerialStatusCodeReportWorker (\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
+  CHAR8           *Filename;\r
+  CHAR8           *Description;\r
+  CHAR8           *Format;\r
+  CHAR8           Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE];\r
+  UINT32          ErrorLevel;\r
+  UINT32          LineNumber;\r
+  UINTN           CharCount;\r
+  VA_LIST         Marker;\r
+\r
+  if (FeaturePcdGet (PcdStatusCodeUseEfiSerial)) {\r
+    if (EfiAtRuntime ()) {\r
+      return EFI_DEVICE_ERROR;\r
+    }\r
+    if (EfiGetCurrentTpl () > TPL_CALLBACK ) {\r
+      return EFI_DEVICE_ERROR;\r
+    }\r
+  }\r
+\r
+  Buffer[0] = '\0';\r
+\r
+  if (Data != NULL &&\r
+      ReportStatusCodeExtractAssertInfo (CodeType, Value, Data, &Filename, &Description, &LineNumber)) {\r
+    //\r
+    // Print ASSERT() information into output buffer.\r
+    //\r
+    CharCount = AsciiSPrint (\r
+                  Buffer,\r
+                  EFI_STATUS_CODE_DATA_MAX_SIZE,\r
+                  "\n\rDXE_ASSERT!: %a (%d): %a\n\r",\r
+                  Filename,\r
+                  LineNumber,\r
+                  Description\r
+                  );\r
+  } else if (Data != NULL &&\r
+             ReportStatusCodeExtractDebugInfo (Data, &ErrorLevel, &Marker, &Format)) {\r
+    //\r
+    // Print DEBUG() information into output buffer.\r
+    //\r
+    CharCount = AsciiVSPrint (\r
+                  Buffer, \r
+                  EFI_STATUS_CODE_DATA_MAX_SIZE, \r
+                  Format, \r
+                  Marker\r
+                  );\r
+  } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) {\r
+    //\r
+    // Print ERROR information into output buffer.\r
+    //\r
+    CharCount = AsciiSPrint (\r
+                  Buffer, \r
+                  EFI_STATUS_CODE_DATA_MAX_SIZE, \r
+                  "ERROR: C%x:V%x I%x", \r
+                  CodeType, \r
+                  Value, \r
+                  Instance\r
+                  );\r
+   \r
+    if (CallerId != NULL) {\r
+      CharCount += AsciiSPrint (\r
+                     &Buffer[CharCount - 1],\r
+                     (EFI_STATUS_CODE_DATA_MAX_SIZE - (sizeof (Buffer[0]) * CharCount)),\r
+                     " %g",\r
+                     CallerId\r
+                     );\r
+    }\r
+\r
+    if (Data != NULL) {\r
+      CharCount += AsciiSPrint (\r
+                     &Buffer[CharCount - 1],\r
+                     (EFI_STATUS_CODE_DATA_MAX_SIZE - (sizeof (Buffer[0]) * CharCount)),\r
+                     " %x",\r
+                     Data\r
+                     );\r
+    }\r
+\r
+    CharCount += AsciiSPrint (\r
+                   &Buffer[CharCount - 1],\r
+                   (EFI_STATUS_CODE_DATA_MAX_SIZE - (sizeof (Buffer[0]) * CharCount)),\r
+                   "\n\r"\r
+                   );\r
+  } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) {\r
+    //\r
+    // Print PROGRESS information into output buffer.\r
+    //\r
+    CharCount = AsciiSPrint (\r
+                  Buffer, \r
+                  EFI_STATUS_CODE_DATA_MAX_SIZE, \r
+                  "PROGRESS CODE: V%x I%x\n\r", \r
+                  Value, \r
+                  Instance\r
+                  );\r
+  } else {\r
+    //\r
+    // Code type is not defined.\r
+    //\r
+    CharCount = AsciiSPrint (\r
+                  Buffer, \r
+                  EFI_STATUS_CODE_DATA_MAX_SIZE, \r
+                  "Undefined: C%x:V%x I%x\n\r", \r
+                  CodeType, \r
+                  Value, \r
+                  Instance\r
+                  );\r
+  }\r
+\r
+\r
+  if (FeaturePcdGet (PcdStatusCodeUseHardSerial)) {\r
+    //\r
+    // Call SerialPort Lib function to do print.\r
+    //\r
+    SerialPortWrite ((UINT8 *) Buffer, CharCount);\r
+  }\r
+  if (FeaturePcdGet (PcdStatusCodeUseEfiSerial)) {\r
+    mSerialIoProtocol->Write (\r
+      mSerialIoProtocol,\r
+      &CharCount,\r
+      Buffer\r
+      );\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
diff --git a/IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/StatusCodeRuntimeDxe.c b/IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/StatusCodeRuntimeDxe.c
new file mode 100644 (file)
index 0000000..1265115
--- /dev/null
@@ -0,0 +1,325 @@
+/** @file\r
+  Status code driver for IA32/X64/EBC architecture.\r
+\r
+  Copyright (c) 2006 - 2009, Intel Corporation\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 "StatusCodeRuntimeDxe.h"\r
+\r
+EFI_EVENT    mVirtualAddressChangeEvent = NULL;\r
+EFI_HANDLE   mHandle = NULL;\r
+\r
+//\r
+// Declaration of status code protocol.\r
+//\r
+EFI_STATUS_CODE_PROTOCOL  mEfiStatusCodeProtocol  = {\r
+  ReportDispatcher\r
+};\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
+/**\r
+  Entry point of DXE Status Code Driver.\r
+\r
+  This function is the entry point of this DXE Status Code Driver.\r
+  It installs Status Code Runtime Protocol, and registers event for EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE.\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
+StatusCodeRuntimeDxeEntry (\r
+  IN EFI_HANDLE         ImageHandle,\r
+  IN EFI_SYSTEM_TABLE   *SystemTable\r
+  )\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  //\r
+  // Dispatch initialization request to supported devices\r
+  //\r
+  InitializationDispatcherWorker ();\r
+\r
+  //\r
+  // Install Status Code Runtime Protocol implementation as defined in PI Specification.\r
+  //\r
+  Status = gBS->InstallMultipleProtocolInterfaces (\r
+                  &mHandle,\r
+                  &gEfiStatusCodeRuntimeProtocolGuid,\r
+                  &mEfiStatusCodeProtocol,\r
+                  NULL\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  Status = gBS->CreateEventEx (\r
+                  EVT_NOTIFY_SIGNAL,\r
+                  TPL_NOTIFY,\r
+                  VirtualAddressChangeCallBack,\r
+                  NULL,\r
+                  &gEfiEventVirtualAddressChangeGuid,\r
+                  &mVirtualAddressChangeEvent\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+  Report status code to all supported device.\r
+\r
+  This function implements EFI_STATUS_CODE_PROTOCOL.ReportStatusCode().\r
+  It calls into the workers which dispatches the platform specific listeners.\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
+EFIAPI\r
+ReportDispatcher (\r
+  IN EFI_STATUS_CODE_TYPE     CodeType,\r
+  IN EFI_STATUS_CODE_VALUE    Value,\r
+  IN UINT32                   Instance,\r
+  IN EFI_GUID                 *CallerId  OPTIONAL,\r
+  IN EFI_STATUS_CODE_DATA     *Data      OPTIONAL\r
+  )\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
+  if (FeaturePcdGet (PcdStatusCodeUseEfiSerial) || FeaturePcdGet (PcdStatusCodeUseHardSerial)) {\r
+    SerialStatusCodeReportWorker (\r
+      CodeType,\r
+      Value,\r
+      Instance,\r
+      CallerId,\r
+      Data\r
+      );\r
+  }\r
+  if (FeaturePcdGet (PcdStatusCodeUseRuntimeMemory)) {\r
+    RtMemoryStatusCodeReportWorker (\r
+      CodeType,\r
+      Value,\r
+      Instance\r
+      );\r
+  }\r
+  if (FeaturePcdGet (PcdStatusCodeUseDataHub)) {\r
+    DataHubStatusCodeReportWorker (\r
+      CodeType,\r
+      Value,\r
+      Instance,\r
+      CallerId,\r
+      Data\r
+      );\r
+  }\r
+  if (FeaturePcdGet (PcdStatusCodeUseOEM)) {\r
+    //\r
+    // Call OEM hook status code library API to report status code to OEM device\r
+    //\r
+    OemHookStatusCodeReport (\r
+      CodeType,\r
+      Value,\r
+      Instance,\r
+      CallerId,\r
+      Data\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
+/**\r
+  Virtual address change notification call back. It converts global pointer\r
+  to virtual address.\r
+\r
+  @param  Event         Event whose notification function is being invoked.\r
+  @param  Context       Pointer to the notification function's context, which is\r
+                        always zero in current implementation.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+VirtualAddressChangeCallBack (\r
+  IN EFI_EVENT        Event,\r
+  IN VOID             *Context\r
+  )\r
+{\r
+  //\r
+  // Convert memory status code table to virtual address;\r
+  //\r
+  EfiConvertPointer (\r
+    0,\r
+    (VOID **) &mRtMemoryStatusCodeTable\r
+    );\r
+}\r
+\r
+/**\r
+  Dispatch initialization request to sub status code devices based on \r
+  customized feature flags.\r
\r
+**/\r
+VOID\r
+InitializationDispatcherWorker (\r
+  VOID\r
+  )\r
+{\r
+  EFI_PEI_HOB_POINTERS              Hob;\r
+  EFI_STATUS                        Status;\r
+  MEMORY_STATUSCODE_PACKET_HEADER   *PacketHeader;\r
+  MEMORY_STATUSCODE_RECORD          *Record;\r
+  UINTN                             ExpectedPacketIndex;\r
+  UINTN                             Index;\r
+  VOID                              *HobStart;\r
+\r
+  //\r
+  // If enable UseSerial, then initialize serial port.\r
+  // if enable UseRuntimeMemory, then initialize runtime memory status code worker.\r
+  // if enable UseDataHub, then initialize data hub status code worker.\r
+  //\r
+  if (FeaturePcdGet (PcdStatusCodeUseEfiSerial)) {\r
+    Status = EfiSerialStatusCodeInitializeWorker ();\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
+  if (FeaturePcdGet (PcdStatusCodeUseHardSerial)) {\r
+    //\r
+    // Call Serial Port Lib API to initialize serial port.\r
+    //\r
+    Status = SerialPortInitialize ();\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
+  if (FeaturePcdGet (PcdStatusCodeUseRuntimeMemory)) {\r
+    Status = RtMemoryStatusCodeInitializeWorker ();\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
+  if (FeaturePcdGet (PcdStatusCodeUseDataHub)) {\r
+    Status = DataHubStatusCodeInitializeWorker ();\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
+  if (FeaturePcdGet (PcdStatusCodeUseOEM)) {\r
+    //\r
+    // Call OEM hook status code library API to initialize OEM device for status code.\r
+    //\r
+    Status = OemHookStatusCodeInitialize ();\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
+\r
+  //\r
+  // Replay Status code which saved in GUID'ed HOB to all supported devices. \r
+  //\r
+\r
+  // \r
+  // Journal GUID'ed HOBs to find all record entry, if found, \r
+  // then output record to support replay device.\r
+  //\r
+  ExpectedPacketIndex = 0;\r
+  Hob.Raw   = GetFirstGuidHob (&gMemoryStatusCodeRecordGuid);\r
+  HobStart  = Hob.Raw;\r
+  while (Hob.Raw != NULL) {\r
+    PacketHeader = (MEMORY_STATUSCODE_PACKET_HEADER *) GET_GUID_HOB_DATA (Hob.Guid);\r
+    if (PacketHeader->PacketIndex == ExpectedPacketIndex) {\r
+      Record = (MEMORY_STATUSCODE_RECORD *) (PacketHeader + 1);\r
+      for (Index = 0; Index < PacketHeader->RecordIndex; Index++) {\r
+        //\r
+        // Dispatch records to devices based on feature flag.\r
+        //\r
+        if (FeaturePcdGet (PcdStatusCodeReplayInSerial) && \r
+            (FeaturePcdGet (PcdStatusCodeUseHardSerial) ||\r
+             FeaturePcdGet (PcdStatusCodeUseEfiSerial))) {\r
+          SerialStatusCodeReportWorker (\r
+            Record[Index].CodeType,\r
+            Record[Index].Value,\r
+            Record[Index].Instance,\r
+            NULL,\r
+            NULL\r
+            );\r
+        }\r
+        if (FeaturePcdGet (PcdStatusCodeReplayInRuntimeMemory) &&\r
+            FeaturePcdGet (PcdStatusCodeUseRuntimeMemory)) {\r
+          RtMemoryStatusCodeReportWorker (\r
+            Record[Index].CodeType,\r
+            Record[Index].Value,\r
+            Record[Index].Instance\r
+            );\r
+        }\r
+        if (FeaturePcdGet (PcdStatusCodeReplayInDataHub) &&\r
+            FeaturePcdGet (PcdStatusCodeUseDataHub)) {\r
+          DataHubStatusCodeReportWorker (\r
+            Record[Index].CodeType,\r
+            Record[Index].Value,\r
+            Record[Index].Instance,\r
+            NULL,\r
+            NULL\r
+            );\r
+        }\r
+        if (FeaturePcdGet (PcdStatusCodeReplayInOEM) &&\r
+            FeaturePcdGet (PcdStatusCodeUseOEM)) {\r
+          //\r
+          // Call OEM hook status code library API to report status code to OEM device\r
+          //\r
+          OemHookStatusCodeReport (\r
+            Record[Index].CodeType,\r
+            Record[Index].Value,\r
+            Record[Index].Instance,\r
+            NULL,\r
+            NULL\r
+            );\r
+        }\r
+      }\r
+      ExpectedPacketIndex++;\r
+\r
+      //\r
+      // See whether there is gap of packet or not\r
+      //\r
+      if (HobStart != NULL) {\r
+        HobStart  = NULL;\r
+        Hob.Raw   = HobStart;\r
+        continue;\r
+      }\r
+    } else if (HobStart != NULL) {\r
+      //\r
+      // Cache the found packet for improve the performance\r
+      //\r
+      HobStart = Hob.Raw;\r
+    }\r
+\r
+    Hob.Raw = GetNextGuidHob (&gMemoryStatusCodeRecordGuid, Hob.Raw);\r
+  }\r
+}\r
diff --git a/IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/StatusCodeRuntimeDxe.h b/IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/StatusCodeRuntimeDxe.h
new file mode 100644 (file)
index 0000000..dbf356b
--- /dev/null
@@ -0,0 +1,241 @@
+/** @file\r
+  Internal include file of Status Code Runtime DXE Driver.\r
+\r
+  Copyright (c) 2006 - 2009, Intel Corporation\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
+#ifndef __STATUS_CODE_RUNTIME_DXE_H__\r
+#define __STATUS_CODE_RUNTIME_DXE_H__\r
+\r
+\r
+#include <FrameworkDxe.h>\r
+#include <FrameworkModuleDxe.h>\r
+#include <Guid/DataHubStatusCodeRecord.h>\r
+#include <Protocol/DataHub.h>\r
+#include <Protocol/SerialIo.h>\r
+#include <Guid/MemoryStatusCodeRecord.h>\r
+#include <Protocol/StatusCode.h>\r
+#include <Guid/StatusCodeDataTypeId.h>\r
+#include <Guid/EventGroup.h>\r
+\r
+#include <Library/BaseLib.h>\r
+#include <Library/SynchronizationLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/ReportStatusCodeLib.h>\r
+#include <Library/PrintLib.h>\r
+#include <Library/PcdLib.h>\r
+#include <Library/HobLib.h>\r
+#include <Library/UefiDriverEntryPoint.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/UefiRuntimeLib.h>\r
+#include <Library/SerialPortLib.h>\r
+#include <Library/OemHookStatusCodeLib.h>\r
+\r
+//\r
+// Data hub worker definition\r
+//\r
+#define DATAHUB_STATUS_CODE_SIGNATURE             SIGNATURE_32 ('B', 'D', 'H', 'S')\r
+\r
+typedef struct {\r
+  UINTN       Signature;\r
+  LIST_ENTRY  Node;\r
+  UINT8       Data[sizeof(DATA_HUB_STATUS_CODE_DATA_RECORD) + EFI_STATUS_CODE_DATA_MAX_SIZE];\r
+} DATAHUB_STATUSCODE_RECORD;\r
+\r
+\r
+//\r
+// Runtime memory status code worker definition\r
+//\r
+typedef struct {\r
+  UINT32   RecordIndex;\r
+  UINT32   NumberOfRecords;\r
+  UINT32   MaxRecordsNumber;\r
+} RUNTIME_MEMORY_STATUSCODE_HEADER;\r
+\r
+extern RUNTIME_MEMORY_STATUSCODE_HEADER  *mRtMemoryStatusCodeTable;\r
+\r
+/**\r
+  Report status code to all supported device.\r
+\r
+  This function implements EFI_STATUS_CODE_PROTOCOL.ReportStatusCode().\r
+  It calls into the workers which dispatches the platform specific listeners.\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
+EFIAPI\r
+ReportDispatcher (\r
+  IN EFI_STATUS_CODE_TYPE     CodeType,\r
+  IN EFI_STATUS_CODE_VALUE    Value,\r
+  IN UINT32                   Instance,\r
+  IN EFI_GUID                 *CallerId  OPTIONAL,\r
+  IN EFI_STATUS_CODE_DATA     *Data      OPTIONAL\r
+  );\r
+\r
+/**\r
+  Dispatch initialization request to sub status code devices based on \r
+  customized feature flags.\r
\r
+**/\r
+VOID\r
+InitializationDispatcherWorker (\r
+  VOID\r
+  );\r
+\r
+\r
+/**\r
+  Locates Serial I/O Protocol as initialization for serial status code worker.\r
\r
+  @retval EFI_SUCCESS  Serial I/O Protocol is successfully located.\r
+\r
+**/\r
+EFI_STATUS\r
+EfiSerialStatusCodeInitializeWorker (\r
+  VOID\r
+  );\r
+\r
+\r
+/**\r
+  Convert status code value and extended data to readable ASCII string, send string to serial I/O device.\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      Status code reported to serial I/O successfully.\r
+  @retval EFI_DEVICE_ERROR EFI serial device cannot work after ExitBootService() is called.\r
+  @retval EFI_DEVICE_ERROR EFI serial device cannot work with TPL higher than TPL_CALLBACK.\r
+\r
+**/\r
+EFI_STATUS\r
+SerialStatusCodeReportWorker (\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
+  Initialize runtime memory status code table as initialization for runtime memory status code worker\r
\r
+  @retval EFI_SUCCESS  Runtime memory status code table successfully initialized.\r
+\r
+**/\r
+EFI_STATUS\r
+RtMemoryStatusCodeInitializeWorker (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Report status code into runtime memory. If the runtime pool is full, roll back to the \r
+  first record and overwrite it.\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
\r
+  @retval EFI_SUCCESS             Status code successfully recorded in runtime memory status code table.\r
+\r
+**/\r
+EFI_STATUS\r
+RtMemoryStatusCodeReportWorker (\r
+  IN EFI_STATUS_CODE_TYPE               CodeType,\r
+  IN EFI_STATUS_CODE_VALUE              Value,\r
+  IN UINT32                             Instance\r
+  );\r
+\r
+/**\r
+  Locate Data Hub Protocol and create event for logging data\r
+  as initialization for data hub status code worker.\r
+\r
+  @retval EFI_SUCCESS  Initialization is successful.\r
+\r
+**/\r
+EFI_STATUS\r
+DataHubStatusCodeInitializeWorker (\r
+  VOID\r
+  );\r
+\r
+\r
+/**\r
+  Report status code into DataHub.\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     Function is reentered.\r
+  @retval EFI_DEVICE_ERROR     Function is called at runtime.\r
+  @retval EFI_OUT_OF_RESOURCES Fail to allocate memory for free record buffer.\r
+\r
+**/\r
+EFI_STATUS\r
+DataHubStatusCodeReportWorker (\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
+/**\r
+  Virtual address change notification call back. It converts global pointer\r
+  to virtual address.\r
+\r
+  @param  Event         Event whose notification function is being invoked.\r
+  @param  Context       Pointer to the notification function's context, which is\r
+                        always zero in current implementation.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+VirtualAddressChangeCallBack (\r
+  IN EFI_EVENT  Event,\r
+  IN VOID       *Context\r
+  );\r
+\r
+#endif\r
diff --git a/IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/StatusCodeRuntimeDxe.inf b/IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/StatusCodeRuntimeDxe.inf
new file mode 100644 (file)
index 0000000..1163ff7
--- /dev/null
@@ -0,0 +1,93 @@
+#/** @file\r
+#  Status Code Runtime Dxe driver that supports multiple devices and produces\r
+#  Status Code Runtime Protocol.\r
+#\r
+#  Copyright (c) 2006 - 2009, Intel Corporation.\r
+#\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
+#  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
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = StatusCodeRuntimeDxe\r
+  FILE_GUID                      = FEDE0A1B-BCA2-4A9F-BB2B-D9FD7DEC2E9F\r
+  MODULE_TYPE                    = DXE_RUNTIME_DRIVER\r
+  VERSION_STRING                 = 1.0\r
+  EFI_SPECIFICATION_VERSION      = 0x00020000\r
+  ENTRY_POINT                    = StatusCodeRuntimeDxeEntry\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
+#\r
+#  VIRTUAL_ADDRESS_MAP_CALLBACK  =  VirtualAddressChangeCallBack\r
+#\r
+\r
+[Sources.common]\r
+  SerialStatusCodeWorker.c\r
+  RtMemoryStatusCodeWorker.c\r
+  DataHubStatusCodeWorker.c\r
+  StatusCodeRuntimeDxe.h\r
+  StatusCodeRuntimeDxe.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  IntelFrameworkPkg/IntelFrameworkPkg.dec\r
+  IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec\r
+\r
+[LibraryClasses]\r
+  OemHookStatusCodeLib\r
+  SerialPortLib\r
+  UefiRuntimeLib\r
+  MemoryAllocationLib\r
+  UefiLib\r
+  UefiBootServicesTableLib\r
+  UefiDriverEntryPoint\r
+  HobLib\r
+  PcdLib\r
+  PrintLib\r
+  ReportStatusCodeLib\r
+  DebugLib\r
+  BaseMemoryLib\r
+  BaseLib\r
+  SynchronizationLib\r
+\r
+\r
+[Guids]\r
+  gEfiDataHubStatusCodeRecordGuid               ## SOMETIMES_CONSUMES (Needed if Data Hub is supported for status code.)\r
+  gEfiStatusCodeDataTypeDebugGuid               ## SOMETIMES_CONSUMES (Needed if Data Hub is supported for status code.)\r
+  gMemoryStatusCodeRecordGuid                   ## CONSUMES ## HOB\r
+  gEfiEventVirtualAddressChangeGuid             ## CONSUMES ## Event\r
+\r
+\r
+[Protocols]\r
+  gEfiStatusCodeRuntimeProtocolGuid             ## PRODUCES\r
+  gEfiDataHubProtocolGuid                       ## SOMETIMES_CONSUMES (Needed if Data Hub is supported for status code.)\r
+  gEfiSerialIoProtocolGuid                      ## SOMETIMES_CONSUMES (Needed if Serial is supported for status code.)\r
+\r
+\r
+[FeaturePcd.common]\r
+  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdStatusCodeReplayInOEM\r
+  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdStatusCodeReplayInRuntimeMemory\r
+  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdStatusCodeReplayInDataHub\r
+  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdStatusCodeReplayInSerial\r
+  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdStatusCodeUseOEM\r
+  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdStatusCodeUseDataHub\r
+  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdStatusCodeUseRuntimeMemory\r
+  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdStatusCodeUseEfiSerial\r
+  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdStatusCodeUseHardSerial\r
+\r
+\r
+[Pcd.common]\r
+  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdStatusCodeRuntimeMemorySize\r
+\r
+[Depex]\r
+  TRUE
\ No newline at end of file