]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Enable Report Status Code Router introduced in PI 1.2 for PEI and DXE.
authorxli24 <xli24@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 3 Nov 2009 02:39:10 +0000 (02:39 +0000)
committerxli24 <xli24@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 3 Nov 2009 02:39:10 +0000 (02:39 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9388 6f19259b-4bc3-4df7-8a09-765794883524

26 files changed:
IntelFrameworkModulePkg/IntelFrameworkModulePkg.dsc
IntelFrameworkModulePkg/Universal/StatusCodeHandler/Pei/MemoryStausCodeWorker.c [new file with mode: 0644]
IntelFrameworkModulePkg/Universal/StatusCodeHandler/Pei/SerialStatusCodeWorker.c [new file with mode: 0644]
IntelFrameworkModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.c [new file with mode: 0644]
IntelFrameworkModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.h [new file with mode: 0644]
IntelFrameworkModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.inf [new file with mode: 0644]
IntelFrameworkModulePkg/Universal/StatusCodeHandler/RuntimeDxe/MemoryStatusCodeWorker.c [new file with mode: 0644]
IntelFrameworkModulePkg/Universal/StatusCodeHandler/RuntimeDxe/SerialStatusCodeWorker.c [new file with mode: 0644]
IntelFrameworkModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandlerRuntimeDxe.c [new file with mode: 0644]
IntelFrameworkModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandlerRuntimeDxe.h [new file with mode: 0644]
IntelFrameworkModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandlerRuntimeDxe.inf [new file with mode: 0644]
MdeModulePkg/Include/Guid/StatusCodeCallbackGuid.h [new file with mode: 0644]
MdeModulePkg/MdeModulePkg.dec
MdeModulePkg/MdeModulePkg.dsc
MdeModulePkg/Universal/ReportStatusCodeRouter/Pei/ReportStatusCodeRouterPei.c [new file with mode: 0644]
MdeModulePkg/Universal/ReportStatusCodeRouter/Pei/ReportStatusCodeRouterPei.h [new file with mode: 0644]
MdeModulePkg/Universal/ReportStatusCodeRouter/Pei/ReportStatusCodeRouterPei.inf [new file with mode: 0644]
MdeModulePkg/Universal/ReportStatusCodeRouter/RuntimeDxe/ReportStatusCodeRouterRuntimeDxe.c [new file with mode: 0644]
MdeModulePkg/Universal/ReportStatusCodeRouter/RuntimeDxe/ReportStatusCodeRouterRuntimeDxe.h [new file with mode: 0644]
MdeModulePkg/Universal/ReportStatusCodeRouter/RuntimeDxe/ReportStatusCodeRouterRuntimeDxe.inf [new file with mode: 0644]
Nt32Pkg/Nt32Pkg.dsc
Nt32Pkg/Nt32Pkg.fdf
Nt32Pkg/WinNtOemHookStatusCodeHandlerDxe/WinNtOemHookStatusCodeHandlerDxe.c [new file with mode: 0644]
Nt32Pkg/WinNtOemHookStatusCodeHandlerDxe/WinNtOemHookStatusCodeHandlerDxe.inf [new file with mode: 0644]
Nt32Pkg/WinNtOemHookStatusCodeHandlerPei/WinNtOemHookStatusCodeHandlerPei.c [new file with mode: 0644]
Nt32Pkg/WinNtOemHookStatusCodeHandlerPei/WinNtOemHookStatusCodeHandlerPei.inf [new file with mode: 0644]

index 7996c05dfec533412daecc08df07c7d27c469692..ea77789d2a08fe42b121e5ba8a100285c6f62d31 100644 (file)
 \r
 [Components.IA32]\r
   IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/StatusCodeRuntimeDxe.inf\r
+  IntelFrameworkModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.inf\r
+  IntelFrameworkModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandlerRuntimeDxe.inf\r
 \r
 [Components.X64]\r
   IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/StatusCodeRuntimeDxe.inf\r
-\r
+  IntelFrameworkModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.inf\r
+  IntelFrameworkModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandlerRuntimeDxe.inf\r
diff --git a/IntelFrameworkModulePkg/Universal/StatusCodeHandler/Pei/MemoryStausCodeWorker.c b/IntelFrameworkModulePkg/Universal/StatusCodeHandler/Pei/MemoryStausCodeWorker.c
new file mode 100644 (file)
index 0000000..f04a174
--- /dev/null
@@ -0,0 +1,153 @@
+/** @file\r
+  PEI 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 "StatusCodeHandlerPei.h"\r
+\r
+/**\r
+  Worker function to create one memory status code GUID'ed HOB,\r
+  using PacketIndex to identify the packet.\r
+\r
+  @param   PacketIndex    Index of records packet.\r
+\r
+  @return  Pointer to the memory status code packet.\r
+\r
+**/\r
+MEMORY_STATUSCODE_PACKET_HEADER *\r
+CreateMemoryStatusCodePacket (\r
+  UINT16 PacketIndex\r
+  )\r
+{\r
+  MEMORY_STATUSCODE_PACKET_HEADER *PacketHeader;\r
+\r
+  //\r
+  // Build GUID'ed HOB with PCD defined size.\r
+  //\r
+  PacketHeader = BuildGuidHob (\r
+                   &gMemoryStatusCodeRecordGuid,\r
+                   PcdGet16 (PcdStatusCodeMemorySize) * 1024 + sizeof (MEMORY_STATUSCODE_PACKET_HEADER)\r
+                   );\r
+  ASSERT (PacketHeader != NULL);\r
+\r
+  PacketHeader->MaxRecordsNumber = (PcdGet16 (PcdStatusCodeMemorySize) * 1024) / sizeof (MEMORY_STATUSCODE_RECORD);\r
+  PacketHeader->PacketIndex      = PacketIndex;\r
+  PacketHeader->RecordIndex      = 0;\r
+\r
+  return PacketHeader;\r
+}\r
+\r
+/**\r
+  Create the first memory status code GUID'ed HOB as initialization for memory status code worker.\r
+\r
+  @retval EFI_SUCCESS  The GUID'ed HOB is created successfully.\r
+\r
+**/\r
+EFI_STATUS\r
+MemoryStatusCodeInitializeWorker (\r
+  VOID\r
+  )\r
+{\r
+  //\r
+  // Create first memory status code GUID'ed HOB.\r
+  //\r
+  CreateMemoryStatusCodePacket (0);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+/**\r
+  Report status code into GUID'ed HOB.\r
+\r
+  This function reports status code into GUID'ed HOB. If not all packets are full, then\r
+  write status code into available entry. Otherwise, create a new packet for it.\r
+\r
+  @param  PeiServices      An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
+  @param  CodeType         Indicates the type of status code being reported.\r
+  @param  Value            Describes the current status of a hardware or\r
+                           software entity. This includes information about the class and\r
+                           subclass that is used to classify the entity as well as an operation.\r
+                           For progress codes, the operation is the current activity.\r
+                           For error codes, it is the exception.For debug codes,it is not defined at this time.\r
+  @param  Instance         The enumeration of a hardware or software entity within\r
+                           the system. A system may contain multiple entities that match a class/subclass\r
+                           pairing. The instance differentiates between them. An instance of 0 indicates\r
+                           that instance information is unavailable, not meaningful, or not relevant.\r
+                           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 always return EFI_SUCCESS.\r
+\r
+**/\r
+EFI_STATUS\r
+MemoryStatusCodeReportWorker (\r
+  IN CONST  EFI_PEI_SERVICES    **PeiServices,\r
+  IN EFI_STATUS_CODE_TYPE       CodeType,\r
+  IN EFI_STATUS_CODE_VALUE      Value,\r
+  IN UINT32                     Instance,\r
+  IN CONST EFI_GUID             *CallerId,\r
+  IN CONST EFI_STATUS_CODE_DATA *Data OPTIONAL\r
+  )\r
+{\r
+\r
+  EFI_PEI_HOB_POINTERS              Hob;\r
+  MEMORY_STATUSCODE_PACKET_HEADER   *PacketHeader;\r
+  MEMORY_STATUSCODE_RECORD          *Record;\r
+  UINT16                            PacketIndex;\r
+\r
+  Record      = NULL;\r
+  PacketIndex = 0;\r
+\r
+  //\r
+  // Journal GUID'ed HOBs to find empty record entry. if found, then save status code in it.\r
+  // otherwise, create a new GUID'ed HOB.\r
+  //\r
+  Hob.Raw = GetFirstGuidHob (&gMemoryStatusCodeRecordGuid);\r
+  while (Hob.Raw != NULL) {\r
+    PacketHeader = (MEMORY_STATUSCODE_PACKET_HEADER *) GET_GUID_HOB_DATA (Hob.Guid);\r
+\r
+    //\r
+    // Check whether pccket is full or not.\r
+    //\r
+    if (PacketHeader->RecordIndex < PacketHeader->MaxRecordsNumber) {\r
+      Record = (MEMORY_STATUSCODE_RECORD *) (PacketHeader + 1);\r
+      Record = &Record[PacketHeader->RecordIndex++];\r
+      break;\r
+    }\r
+    //\r
+    // Cache number of found packet in PacketIndex.\r
+    //\r
+    PacketIndex++;\r
+\r
+    Hob.Raw = GetNextGuidHob (&gMemoryStatusCodeRecordGuid, Hob.Raw);\r
+  }\r
+\r
+  if (Record == NULL) {\r
+    //\r
+    // No available entry found, so create new packet.\r
+    //\r
+    PacketHeader = CreateMemoryStatusCodePacket (PacketIndex);\r
+\r
+    Record = (MEMORY_STATUSCODE_RECORD *) (PacketHeader + 1);\r
+    Record = &Record[PacketHeader->RecordIndex++];\r
+  }\r
+\r
+  Record->CodeType = CodeType;\r
+  Record->Instance = Instance;\r
+  Record->Value    = Value;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
diff --git a/IntelFrameworkModulePkg/Universal/StatusCodeHandler/Pei/SerialStatusCodeWorker.c b/IntelFrameworkModulePkg/Universal/StatusCodeHandler/Pei/SerialStatusCodeWorker.c
new file mode 100644 (file)
index 0000000..e6ff3d0
--- /dev/null
@@ -0,0 +1,152 @@
+/** @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
+#include "StatusCodeHandlerPei.h"\r
+\r
+/**\r
+  Convert status code value and extended data to readable ASCII string, send string to serial I/O device.\r
+\r
+  @param  PeiServices      An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
+  @param  CodeType         Indicates the type of status code being reported.\r
+  @param  Value            Describes the current status of a hardware or\r
+                           software entity. This includes information about the class and\r
+                           subclass that is used to classify the entity as well as an operation.\r
+                           For progress codes, the operation is the current activity.\r
+                           For error codes, it is the exception.For debug codes,it is not defined at this time.\r
+  @param  Instance         The enumeration of a hardware or software entity within\r
+                           the system. A system may contain multiple entities that match a class/subclass\r
+                           pairing. The instance differentiates between them. An instance of 0 indicates\r
+                           that instance information is unavailable, not meaningful, or not relevant.\r
+                           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
+\r
+**/\r
+EFI_STATUS\r
+SerialStatusCodeReportWorker (\r
+  IN CONST  EFI_PEI_SERVICES        **PeiServices,\r
+  IN EFI_STATUS_CODE_TYPE           CodeType,\r
+  IN EFI_STATUS_CODE_VALUE          Value,\r
+  IN UINT32                         Instance,\r
+  IN CONST EFI_GUID                 *CallerId,\r
+  IN CONST 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
+  BASE_LIST       Marker;\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
+                  sizeof (Buffer),\r
+                  "\n\rPEI_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 = AsciiBSPrint (\r
+                  Buffer,\r
+                  sizeof (Buffer),\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
+                  sizeof (Buffer),\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
+                     (sizeof (Buffer) - (sizeof (Buffer[0]) * CharCount)),\r
+                     " %g",\r
+                     CallerId\r
+                     );\r
+    }\r
+\r
+    if (Data != NULL) {\r
+      CharCount += AsciiSPrint (\r
+                     &Buffer[CharCount - 1],\r
+                     (sizeof (Buffer) - (sizeof (Buffer[0]) * CharCount)),\r
+                     " %x",\r
+                     Data\r
+                     );\r
+    }\r
+\r
+    CharCount += AsciiSPrint (\r
+                   &Buffer[CharCount - 1],\r
+                   (sizeof (Buffer) - (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
+                  sizeof (Buffer),\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
+                  sizeof (Buffer),\r
+                  "Undefined: C%x:V%x I%x\n\r",\r
+                  CodeType,\r
+                  Value,\r
+                  Instance\r
+                  );\r
+  }\r
+\r
+  //\r
+  // Call SerialPort Lib function to do print.\r
+  //\r
+  SerialPortWrite ((UINT8 *) Buffer, CharCount);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
diff --git a/IntelFrameworkModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.c b/IntelFrameworkModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.c
new file mode 100644 (file)
index 0000000..cdd5325
--- /dev/null
@@ -0,0 +1,69 @@
+/** @file\r
+  Report Status Code Handler PEIM which produces general handlers and hook them\r
+  onto the PEI status code router.\r
+\r
+  Copyright (c) 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 "StatusCodeHandlerPei.h"\r
+\r
+/**\r
+  Entry point of Status Code PEIM.\r
+  \r
+  This function is the entry point of this Status Code PEIM.\r
+  It initializes supported status code devices according to PCD settings,\r
+  and installs Status Code PPI.\r
+\r
+  @param  FileHandle  Handle of the file being invoked.\r
+  @param  PeiServices Describes the list of possible PEI Services.\r
+\r
+  @retval EFI_SUCESS  The entry point of DXE IPL PEIM executes successfully.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+StatusCodeHandlerPeiEntry (\r
+  IN       EFI_PEI_FILE_HANDLE  FileHandle,\r
+  IN CONST EFI_PEI_SERVICES     **PeiServices\r
+  )\r
+{\r
+  EFI_STATUS                  Status;\r
+  EFI_PEI_RSC_HANDLER_PPI     *RscHandlerPpi;\r
+\r
+  Status = PeiServicesLocatePpi (\r
+             &gEfiPeiRscHandlerPpiGuid,\r
+             0,\r
+             NULL,\r
+             (VOID **) &RscHandlerPpi\r
+             );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  //\r
+  // Dispatch initialization request to sub-statuscode-devices.\r
+  // If enable UseSerial, then initialize serial port.\r
+  // if enable UseMemory, then initialize memory status code worker.\r
+  //\r
+  if (FeaturePcdGet (PcdStatusCodeUseSerial)) {\r
+    Status = SerialPortInitialize();\r
+    ASSERT_EFI_ERROR (Status);\r
+    Status = RscHandlerPpi->Register (SerialStatusCodeReportWorker);                     \r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
+  if (FeaturePcdGet (PcdStatusCodeUseMemory)) {\r
+    Status = MemoryStatusCodeInitializeWorker ();\r
+    ASSERT_EFI_ERROR (Status);\r
+    Status = RscHandlerPpi->Register (MemoryStatusCodeReportWorker);                     \r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
diff --git a/IntelFrameworkModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.h b/IntelFrameworkModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.h
new file mode 100644 (file)
index 0000000..31c998b
--- /dev/null
@@ -0,0 +1,117 @@
+/** @file\r
+  Internal include file for Status Code Handler PEIM.\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_HANDLER_PEI_H__\r
+#define __STATUS_CODE_HANDLER_PEI_H__\r
+\r
+\r
+#include <Ppi/ReportStatusCodeHandler.h>\r
+\r
+#include <Guid/MemoryStatusCodeRecord.h>\r
+#include <Guid/StatusCodeDataTypeId.h>\r
+#include <Guid/StatusCodeDataTypeDebug.h>\r
+\r
+#include <Library/DebugLib.h>\r
+#include <Library/PrintLib.h>\r
+#include <Library/ReportStatusCodeLib.h>\r
+#include <Library/SerialPortLib.h>\r
+#include <Library/HobLib.h>\r
+#include <Library/PcdLib.h>\r
+#include <Library/PeiServicesLib.h>\r
+#include <Library/PeimEntryPoint.h>\r
+\r
+/**\r
+  Convert status code value and extended data to readable ASCII string, send string to serial I/O device.\r
+\r
+  @param  PeiServices      An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
+  @param  CodeType         Indicates the type of status code being reported.\r
+  @param  Value            Describes the current status of a hardware or\r
+                           software entity. This includes information about the class and\r
+                           subclass that is used to classify the entity as well as an operation.\r
+                           For progress codes, the operation is the current activity.\r
+                           For error codes, it is the exception.For debug codes,it is not defined at this time.\r
+  @param  Instance         The enumeration of a hardware or software entity within\r
+                           the system. A system may contain multiple entities that match a class/subclass\r
+                           pairing. The instance differentiates between them. An instance of 0 indicates\r
+                           that instance information is unavailable, not meaningful, or not relevant.\r
+                           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
+\r
+**/\r
+EFI_STATUS\r
+SerialStatusCodeReportWorker (\r
+  IN CONST  EFI_PEI_SERVICES        **PeiServices,\r
+  IN EFI_STATUS_CODE_TYPE           CodeType,\r
+  IN EFI_STATUS_CODE_VALUE          Value,\r
+  IN UINT32                         Instance,\r
+  IN CONST EFI_GUID                 *CallerId,\r
+  IN CONST EFI_STATUS_CODE_DATA     *Data OPTIONAL\r
+  );\r
+\r
+\r
+/**\r
+  Create the first memory status code GUID'ed HOB as initialization for memory status code worker.\r
+\r
+  @retval EFI_SUCCESS  The GUID'ed HOB is created successfully.\r
+\r
+**/\r
+EFI_STATUS\r
+MemoryStatusCodeInitializeWorker (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Report status code into GUID'ed HOB.\r
+\r
+  This function reports status code into GUID'ed HOB. If not all packets are full, then\r
+  write status code into available entry. Otherwise, create a new packet for it.\r
+\r
+  @param  PeiServices      An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
+  @param  CodeType         Indicates the type of status code being reported.\r
+  @param  Value            Describes the current status of a hardware or\r
+                           software entity. This includes information about the class and\r
+                           subclass that is used to classify the entity as well as an operation.\r
+                           For progress codes, the operation is the current activity.\r
+                           For error codes, it is the exception.For debug codes,it is not defined at this time.\r
+  @param  Instance         The enumeration of a hardware or software entity within\r
+                           the system. A system may contain multiple entities that match a class/subclass\r
+                           pairing. The instance differentiates between them. An instance of 0 indicates\r
+                           that instance information is unavailable, not meaningful, or not relevant.\r
+                           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 always return EFI_SUCCESS.\r
+\r
+**/\r
+EFI_STATUS\r
+MemoryStatusCodeReportWorker (\r
+  IN CONST  EFI_PEI_SERVICES    **PeiServices,\r
+  IN EFI_STATUS_CODE_TYPE       CodeType,\r
+  IN EFI_STATUS_CODE_VALUE      Value,\r
+  IN UINT32                     Instance,\r
+  IN CONST EFI_GUID             *CallerId,\r
+  IN CONST EFI_STATUS_CODE_DATA *Data OPTIONAL\r
+  );\r
+\r
+#endif\r
+\r
+\r
diff --git a/IntelFrameworkModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.inf b/IntelFrameworkModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.inf
new file mode 100644 (file)
index 0000000..db4ad8f
--- /dev/null
@@ -0,0 +1,64 @@
+#/** @file\r
+#  Report Status Code Handler PEIM which produces general handlers and hook them\r
+#  onto the PEI status code router.\r
+#\r
+#  Copyright (c) 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                      = StatusCodeHandlerPei\r
+  FILE_GUID                      = 9D225237-FA01-464C-A949-BAABC02D31D0\r
+  MODULE_TYPE                    = PEIM\r
+  ENTRY_POINT                    = StatusCodeHandlerPeiEntry\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC (EBC is only for build)\r
+#\r
+\r
+[Sources.common]\r
+  StatusCodeHandlerPei.c\r
+  StatusCodeHandlerPei.h\r
+  SerialStatusCodeWorker.c\r
+  MemoryStausCodeWorker.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec\r
+\r
+[LibraryClasses]\r
+  PeimEntryPoint\r
+  PeiServicesLib\r
+  PcdLib\r
+  HobLib\r
+  SerialPortLib\r
+  ReportStatusCodeLib\r
+  PrintLib\r
+  DebugLib\r
+\r
+[Guids]\r
+  gMemoryStatusCodeRecordGuid                   ## SOMETIMES_CONSUMES ## HOB\r
+\r
+[Ppis]\r
+  gEfiPeiRscHandlerPpiGuid                      ## CONSUMES\r
+\r
+[FeaturePcd.common]\r
+  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdStatusCodeUseMemory\r
+  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdStatusCodeUseSerial\r
+\r
+[Pcd.common]\r
+  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdStatusCodeMemorySize|1|PcdStatusCodeUseMemory\r
+\r
+[Depex]\r
+  gEfiPeiRscHandlerPpiGuid\r
diff --git a/IntelFrameworkModulePkg/Universal/StatusCodeHandler/RuntimeDxe/MemoryStatusCodeWorker.c b/IntelFrameworkModulePkg/Universal/StatusCodeHandler/RuntimeDxe/MemoryStatusCodeWorker.c
new file mode 100644 (file)
index 0000000..2d8fcad
--- /dev/null
@@ -0,0 +1,110 @@
+/** @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 "StatusCodeHandlerRuntimeDxe.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 (PcdStatusCodeMemorySize) * 1024\r
+                               );\r
+  ASSERT (mRtMemoryStatusCodeTable != NULL);\r
+\r
+  mRtMemoryStatusCodeTable->RecordIndex      = 0;\r
+  mRtMemoryStatusCodeTable->NumberOfRecords  = 0;\r
+  mRtMemoryStatusCodeTable->MaxRecordsNumber = \r
+    (PcdGet16 (PcdStatusCodeMemorySize) * 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
+  @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 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
+  IN EFI_GUID                           *CallerId,\r
+  IN EFI_STATUS_CODE_DATA               *Data OPTIONAL\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/StatusCodeHandler/RuntimeDxe/SerialStatusCodeWorker.c b/IntelFrameworkModulePkg/Universal/StatusCodeHandler/RuntimeDxe/SerialStatusCodeWorker.c
new file mode 100644 (file)
index 0000000..879eec3
--- /dev/null
@@ -0,0 +1,148 @@
+/** @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 "StatusCodeHandlerRuntimeDxe.h"\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
+  BASE_LIST       Marker;\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
+                  sizeof (Buffer),\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 = AsciiBSPrint (\r
+                  Buffer, \r
+                  sizeof (Buffer), \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
+                  sizeof (Buffer), \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
+                     (sizeof (Buffer) - (sizeof (Buffer[0]) * CharCount)),\r
+                     " %g",\r
+                     CallerId\r
+                     );\r
+    }\r
+\r
+    if (Data != NULL) {\r
+      CharCount += AsciiSPrint (\r
+                     &Buffer[CharCount - 1],\r
+                     (sizeof (Buffer) - (sizeof (Buffer[0]) * CharCount)),\r
+                     " %x",\r
+                     Data\r
+                     );\r
+    }\r
+\r
+    CharCount += AsciiSPrint (\r
+                   &Buffer[CharCount - 1],\r
+                   (sizeof (Buffer) - (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
+                  sizeof (Buffer), \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
+                  sizeof (Buffer), \r
+                  "Undefined: C%x:V%x I%x\n\r", \r
+                  CodeType, \r
+                  Value, \r
+                  Instance\r
+                  );\r
+  }\r
+\r
+  //\r
+  // Call SerialPort Lib function to do print.\r
+  //\r
+  SerialPortWrite ((UINT8 *) Buffer, CharCount);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
diff --git a/IntelFrameworkModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandlerRuntimeDxe.c b/IntelFrameworkModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandlerRuntimeDxe.c
new file mode 100644 (file)
index 0000000..497afaa
--- /dev/null
@@ -0,0 +1,222 @@
+/** @file\r
+  Status Code Handler Driver which produces general handlers and hook them\r
+  onto the DXE status code router.\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 "StatusCodeHandlerRuntimeDxe.h"\r
+\r
+EFI_EVENT                 mVirtualAddressChangeEvent = NULL;\r
+EFI_EVENT                 mExitBootServicesEvent     = NULL;\r
+EFI_RSC_HANDLER_PROTOCOL  *mRscHandlerProtocol       = NULL;\r
+\r
+/**\r
+  Unregister status code callback functions only available at boot time from\r
+  report status code router when exiting boot services.\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
+UnregisterBootTimeHandlers (\r
+  IN EFI_EVENT        Event,\r
+  IN VOID             *Context\r
+  )\r
+{\r
+  if (FeaturePcdGet (PcdStatusCodeUseSerial)) {\r
+    mRscHandlerProtocol->Unregister (SerialStatusCodeReportWorker);\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
+  //\r
+  if (FeaturePcdGet (PcdStatusCodeUseSerial)) {\r
+    //\r
+    // Call Serial Port Lib API to initialize serial port.\r
+    //\r
+    Status = SerialPortInitialize ();\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
+  if (FeaturePcdGet (PcdStatusCodeUseMemory)) {\r
+    Status = RtMemoryStatusCodeInitializeWorker ();\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
+\r
+  //\r
+  // Replay Status code which saved in GUID'ed HOB to all supported devices. \r
+  //\r
+  if (FeaturePcdGet (PcdStatusCodeReplayIn)) {\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 (PcdStatusCodeUseSerial)) {\r
+            SerialStatusCodeReportWorker (\r
+              Record[Index].CodeType,\r
+              Record[Index].Value,\r
+              Record[Index].Instance,\r
+              NULL,\r
+              NULL\r
+              );\r
+          }\r
+          if (FeaturePcdGet (PcdStatusCodeUseMemory)) {\r
+            RtMemoryStatusCodeReportWorker (\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
+\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 initializes registers status code handlers, 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
+StatusCodeHandlerRuntimeDxeEntry (\r
+  IN EFI_HANDLE         ImageHandle,\r
+  IN EFI_SYSTEM_TABLE   *SystemTable\r
+  )\r
+{\r
+  EFI_STATUS                Status;\r
+\r
+  Status = gBS->LocateProtocol (\r
+                  &gEfiRscHandlerProtocolGuid,\r
+                  NULL,\r
+                  (VOID **) &mRscHandlerProtocol\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  //\r
+  // Dispatch initialization request to supported devices\r
+  //\r
+  InitializationDispatcherWorker ();\r
+\r
+  if (FeaturePcdGet (PcdStatusCodeUseSerial)) {\r
+    mRscHandlerProtocol->Register (SerialStatusCodeReportWorker, TPL_HIGH_LEVEL);\r
+  }\r
+  if (FeaturePcdGet (PcdStatusCodeUseMemory)) {\r
+    mRscHandlerProtocol->Register (RtMemoryStatusCodeReportWorker, TPL_HIGH_LEVEL);\r
+  }\r
+\r
+  Status = gBS->CreateEventEx (\r
+                  EVT_NOTIFY_SIGNAL,\r
+                  TPL_NOTIFY,\r
+                  UnregisterBootTimeHandlers,\r
+                  NULL,\r
+                  &gEfiEventExitBootServicesGuid,\r
+                  &mExitBootServicesEvent\r
+                  );\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
diff --git a/IntelFrameworkModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandlerRuntimeDxe.h b/IntelFrameworkModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandlerRuntimeDxe.h
new file mode 100644 (file)
index 0000000..9986f11
--- /dev/null
@@ -0,0 +1,126 @@
+/** @file\r
+  Internal include file for Status Code Handler 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_HANDLER_RUNTIME_DXE_H__\r
+#define __STATUS_CODE_HANDLER_RUNTIME_DXE_H__\r
+\r
+#include <Protocol/ReportStatusCodeHandler.h>\r
+\r
+#include <Guid/MemoryStatusCodeRecord.h>\r
+#include <Guid/StatusCodeDataTypeId.h>\r
+#include <Guid/StatusCodeDataTypeDebug.h>\r
+#include <Guid/EventGroup.h>\r
+\r
+#include <Library/SynchronizationLib.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/MemoryAllocationLib.h>\r
+#include <Library/UefiRuntimeLib.h>\r
+#include <Library/SerialPortLib.h>\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
+  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
+  @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 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
+  IN EFI_GUID                           *CallerId,\r
+  IN EFI_STATUS_CODE_DATA               *Data OPTIONAL\r
+  );\r
+\r
+#endif\r
diff --git a/IntelFrameworkModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandlerRuntimeDxe.inf b/IntelFrameworkModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandlerRuntimeDxe.inf
new file mode 100644 (file)
index 0000000..a69a0dc
--- /dev/null
@@ -0,0 +1,71 @@
+#/** @file\r
+#  Status Code Handler Driver which produces general handlers and hook them\r
+#  onto the DXE status code router.\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                      = StatusCodeHandlerRuntimeDxe\r
+  FILE_GUID                      = 6C2004EF-4E0E-4BE4-B14C-340EB4AA5891\r
+  MODULE_TYPE                    = DXE_RUNTIME_DRIVER\r
+  ENTRY_POINT                    = StatusCodeHandlerRuntimeDxeEntry\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#\r
+\r
+[Sources.common]\r
+  StatusCodeHandlerRuntimeDxe.c\r
+  StatusCodeHandlerRuntimeDxe.h\r
+  SerialStatusCodeWorker.c\r
+  MemoryStatusCodeWorker.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec\r
+\r
+[LibraryClasses]\r
+  SerialPortLib\r
+  UefiRuntimeLib\r
+  MemoryAllocationLib\r
+  UefiBootServicesTableLib\r
+  UefiDriverEntryPoint\r
+  HobLib\r
+  PcdLib\r
+  PrintLib\r
+  ReportStatusCodeLib\r
+  DebugLib\r
+  SynchronizationLib\r
+\r
+[Guids]\r
+  gEfiStatusCodeDataTypeDebugGuid               ## SOMETIMES_CONSUMES (Needed if Data Hub is supported for status code.)\r
+  gMemoryStatusCodeRecordGuid                   ## CONSUMES ## HOB\r
+  gEfiEventVirtualAddressChangeGuid             ## CONSUMES ## Event\r
+  gEfiEventExitBootServicesGuid                 ## CONSUMES ## Event\r
+\r
+[Protocols]\r
+  gEfiRscHandlerProtocolGuid                    ## CONSUMES\r
+\r
+[FeaturePcd]\r
+  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdStatusCodeReplayIn\r
+  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdStatusCodeUseMemory\r
+  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdStatusCodeUseSerial\r
+\r
+[Pcd]\r
+  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdStatusCodeMemorySize |128| PcdStatusCodeUseMemory\r
+\r
+[Depex]\r
+  gEfiRscHandlerProtocolGuid\r
diff --git a/MdeModulePkg/Include/Guid/StatusCodeCallbackGuid.h b/MdeModulePkg/Include/Guid/StatusCodeCallbackGuid.h
new file mode 100644 (file)
index 0000000..ab4a8cb
--- /dev/null
@@ -0,0 +1,26 @@
+/** @file\r
+  GUID used to identify HOB for pointers to callback functios registered on\r
+  PEI report status code router.\r
+  \r
+  Copyright (c) 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_CALLBACK_H__\r
+#define __STATUS_CODE_CALLBACK_H__\r
+\r
+#define STATUS_CODE_CALLBACK_GUID \\r
+  { \\r
+    0xe701458c, 0x4900, 0x4ca5, {0xb7, 0x72, 0x3d, 0x37, 0x94, 0x9f, 0x79, 0x27} \\r
+  }\r
+\r
+extern EFI_GUID gStatusCodeCallbackGuid;\r
+\r
+#endif\r
index d3ca875c220d705500004e35c3c25c15cd05975f..4cbafb42c40b2a6a105fc1f6e20f443f671b4ef4 100644 (file)
   ## Include/Guid/NicIp4ConfigNvData.h\r
   gEfiNicIp4ConfigVariableGuid   = {0xd8944553, 0xc4dd, 0x41f4, { 0x9b, 0x30, 0xe1, 0x39, 0x7c, 0xfb, 0x26, 0x7b }}\r
 \r
+  ## Include/Guid/StatusCodeCallbackGuid.h\r
+  gStatusCodeCallbackGuid   = {0xe701458c, 0x4900, 0x4ca5, {0xb7, 0x72, 0x3d, 0x37, 0x94, 0x9f, 0x79, 0x27}}\r
+\r
 [Protocols.common]\r
   ## Load File protocol provides capability to load and unload EFI image into memory and execute it.\r
   #  Include/Protocol/LoadPe32Image.h\r
index 4d1d94184883dc13dd8eba4a39caa1bde09f35cd..c6773224ebbe62e226cfc5ba20486362464d778e 100644 (file)
   MdeModulePkg/Universal/PCD/Dxe/Pcd.inf\r
   MdeModulePkg/Universal/PCD/Pei/Pcd.inf\r
   MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatformDriOverrideDxe.inf\r
+\r
+  MdeModulePkg/Universal/ReportStatusCodeRouter/Pei/ReportStatusCodeRouterPei.inf\r
+  MdeModulePkg/Universal/ReportStatusCodeRouter/RuntimeDxe/ReportStatusCodeRouterRuntimeDxe.inf\r
+\r
   MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf\r
   MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf\r
   MdeModulePkg/Application/VariableInfo/VariableInfo.inf\r
diff --git a/MdeModulePkg/Universal/ReportStatusCodeRouter/Pei/ReportStatusCodeRouterPei.c b/MdeModulePkg/Universal/ReportStatusCodeRouter/Pei/ReportStatusCodeRouterPei.c
new file mode 100644 (file)
index 0000000..eb5b490
--- /dev/null
@@ -0,0 +1,268 @@
+/** @file\r
+  Report Status Code Router PEIM which produces Report Stataus Code Handler PPI and Status Code PPI.\r
+\r
+  Copyright (c) 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 "ReportStatusCodeRouterPei.h"\r
+\r
+EFI_PEI_RSC_HANDLER_PPI     mRscHandlerPpi = {\r
+  Register,\r
+  Unregister\r
+  };\r
+\r
+EFI_PEI_PROGRESS_CODE_PPI     mStatusCodePpi = {\r
+  ReportDispatcher\r
+  };\r
+\r
+EFI_PEI_PPI_DESCRIPTOR   mStatusCodePpiList[] = {\r
+  {\r
+    EFI_PEI_PPI_DESCRIPTOR_PPI,\r
+    &gEfiPeiRscHandlerPpiGuid,\r
+    &mRscHandlerPpi\r
+  },\r
+  {\r
+    EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,\r
+    &gEfiPeiStatusCodePpiGuid,\r
+    &mStatusCodePpi\r
+  }\r
+};\r
+\r
+/**\r
+  Worker function to create one memory status code GUID'ed HOB,\r
+  using PacketIndex to identify the packet.\r
+\r
+  @param   PacketIndex    Index of records packet.\r
+\r
+  @return  Pointer to the memory status code packet.\r
+\r
+**/\r
+UINTN *\r
+CreateRscHandlerCallbackPacket (\r
+  VOID\r
+  )\r
+{\r
+  UINTN  *NumberOfEntries;\r
+\r
+  //\r
+  // Build GUID'ed HOB with PCD defined size.\r
+  //\r
+  NumberOfEntries = BuildGuidHob (\r
+                      &gStatusCodeCallbackGuid,\r
+                      sizeof (EFI_PEI_RSC_HANDLER_CALLBACK) * 64 + sizeof (UINTN)\r
+                      );\r
+  ASSERT (NumberOfEntries != NULL);\r
+\r
+  *NumberOfEntries = 0;\r
+\r
+  return NumberOfEntries;\r
+}\r
+\r
+/**\r
+  Register the callback function for ReportStatusCode() notification.\r
+  \r
+  When this function is called the function pointer is added to an internal list and any future calls to\r
+  ReportStatusCode() will be forwarded to the Callback function.\r
+\r
+  @param[in] Callback           A pointer to a function of type EFI_PEI_RSC_HANDLER_CALLBACK that is called\r
+                                when a call to ReportStatusCode() occurs.\r
+                        \r
+  @retval EFI_SUCCESS           Function was successfully registered.\r
+  @retval EFI_INVALID_PARAMETER The callback function was NULL.\r
+  @retval EFI_OUT_OF_RESOURCES  The internal buffer ran out of space. No more functions can be\r
+                                registered.\r
+  @retval EFI_ALREADY_STARTED   The function was already registered. It can't be registered again.\r
+  \r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Register (\r
+  IN EFI_PEI_RSC_HANDLER_CALLBACK Callback\r
+  )\r
+{\r
+  EFI_PEI_HOB_POINTERS          Hob;\r
+  EFI_PEI_RSC_HANDLER_CALLBACK  *CallbackEntry;\r
+  UINTN                         *NumberOfEntries;\r
+  UINTN                         Index;\r
+  UINTN                         *FreePacket;\r
+\r
+  if (Callback == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  Hob.Raw  = GetFirstGuidHob (&gStatusCodeCallbackGuid);\r
+  FreePacket = NULL;\r
+  while (Hob.Raw != NULL) {\r
+    NumberOfEntries = GET_GUID_HOB_DATA (Hob);\r
+    CallbackEntry   = (EFI_PEI_RSC_HANDLER_CALLBACK *) (NumberOfEntries + 1);\r
+    if (*NumberOfEntries < 64) {\r
+      FreePacket = NumberOfEntries;\r
+    }\r
+    for (Index = 0; Index < *NumberOfEntries; Index++) {\r
+      if (CallbackEntry[Index] == Callback) {\r
+        //\r
+        // If the function was already registered. It can't be registered again.\r
+        //\r
+        return EFI_ALREADY_STARTED;\r
+      }\r
+    }\r
+    Hob.Raw = GET_NEXT_HOB (Hob);\r
+    Hob.Raw = GetNextGuidHob (&gStatusCodeCallbackGuid, Hob.Raw);\r
+  }\r
+\r
+  if (FreePacket == NULL) {\r
+    FreePacket = CreateRscHandlerCallbackPacket();\r
+  }\r
+\r
+  CallbackEntry = (EFI_PEI_RSC_HANDLER_CALLBACK *) (FreePacket + 1);\r
+  CallbackEntry[*FreePacket] = Callback;\r
+  *FreePacket += 1;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+  Remove a previously registered callback function from the notification list.\r
+  \r
+  ReportStatusCode() messages will no longer be forwarded to the Callback function.\r
+  \r
+  @param[in] Callback           A pointer to a function of type EFI_PEI_RSC_HANDLER_CALLBACK that is to be\r
+                                unregistered.\r
+\r
+  @retval EFI_SUCCESS           The function was successfully unregistered.\r
+  @retval EFI_INVALID_PARAMETER The callback function was NULL.\r
+  @retval EFI_NOT_FOUND         The callback function was not found to be unregistered.\r
+                        \r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Unregister (\r
+  IN EFI_PEI_RSC_HANDLER_CALLBACK Callback\r
+  )\r
+{\r
+  EFI_PEI_HOB_POINTERS            Hob;\r
+  EFI_PEI_RSC_HANDLER_CALLBACK    *CallbackEntry;\r
+  UINTN                           *NumberOfEntries;\r
+  UINTN                           Index;\r
+\r
+  if (Callback == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  Hob.Raw  = GetFirstGuidHob (&gStatusCodeCallbackGuid);\r
+  while (Hob.Raw != NULL) {\r
+    NumberOfEntries = GET_GUID_HOB_DATA (Hob);\r
+    CallbackEntry   = (EFI_PEI_RSC_HANDLER_CALLBACK *) (NumberOfEntries + 1);\r
+    for (Index = 0; Index < *NumberOfEntries; Index++) {\r
+      if (CallbackEntry[Index] == Callback) {\r
+        CallbackEntry[Index] = CallbackEntry[*NumberOfEntries - 1];\r
+        *NumberOfEntries -= 1;\r
+        return EFI_SUCCESS;\r
+      }\r
+    }\r
+    Hob.Raw = GET_NEXT_HOB (Hob);\r
+    Hob.Raw = GetNextGuidHob (&gStatusCodeCallbackGuid, Hob.Raw);\r
+  }\r
+\r
+  return EFI_NOT_FOUND;\r
+}\r
+\r
+/**\r
+  Publishes an interface that allows PEIMs to report status codes.\r
+\r
+  This function implements EFI_PEI_PROGRESS_CODE_PPI.ReportStatusCode().\r
+  It publishes an interface that allows PEIMs to report status codes.\r
+\r
+  @param  PeiServices      An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
+  @param  CodeType         Indicates the type of status code being reported.\r
+  @param  Value            Describes the current status of a hardware or\r
+                           software entity. This includes information about the class and\r
+                           subclass that is used to classify the entity as well as an operation.\r
+                           For progress codes, the operation is the current activity.\r
+                           For error codes, it is the exception.For debug codes,it is not defined at this time.\r
+  @param  Instance         The enumeration of a hardware or software entity within\r
+                           the system. A system may contain multiple entities that match a class/subclass\r
+                           pairing. The instance differentiates between them. An instance of 0 indicates\r
+                           that instance information is unavailable, not meaningful, or not relevant.\r
+                           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
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ReportDispatcher (\r
+  IN CONST EFI_PEI_SERVICES         **PeiServices,\r
+  IN EFI_STATUS_CODE_TYPE           CodeType,\r
+  IN EFI_STATUS_CODE_VALUE          Value,\r
+  IN UINT32                         Instance,\r
+  IN CONST EFI_GUID                 *CallerId OPTIONAL,\r
+  IN CONST EFI_STATUS_CODE_DATA     *Data OPTIONAL\r
+  )\r
+{\r
+  EFI_PEI_HOB_POINTERS            Hob;\r
+  EFI_PEI_RSC_HANDLER_CALLBACK    *CallbackEntry;\r
+  UINTN                           *NumberOfEntries;\r
+  UINTN                           Index;\r
+\r
+  Hob.Raw  = GetFirstGuidHob (&gStatusCodeCallbackGuid);\r
+  while (Hob.Raw != NULL) {\r
+    NumberOfEntries = GET_GUID_HOB_DATA (Hob);\r
+    CallbackEntry   = (EFI_PEI_RSC_HANDLER_CALLBACK *) (NumberOfEntries + 1);\r
+    for (Index = 0; Index < *NumberOfEntries; Index++) {\r
+      CallbackEntry[Index](\r
+        PeiServices,\r
+        CodeType,\r
+        Value,\r
+        Instance,\r
+        CallerId,\r
+        Data\r
+        );\r
+    }\r
+    Hob.Raw = GET_NEXT_HOB (Hob);\r
+    Hob.Raw = GetNextGuidHob (&gStatusCodeCallbackGuid, Hob.Raw);\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+  Entry point of Status Code PEIM.\r
+  \r
+  This function is the entry point of this Status Code Router PEIM.\r
+  It produces Report Stataus Code Handler PPI and Status Code PPI.\r
+\r
+  @param  FileHandle  Handle of the file being invoked.\r
+  @param  PeiServices Describes the list of possible PEI Services.\r
+\r
+  @retval EFI_SUCESS  The entry point of DXE IPL PEIM executes successfully.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+GenericStatusCodePeiEntry (\r
+  IN       EFI_PEI_FILE_HANDLE  FileHandle,\r
+  IN CONST EFI_PEI_SERVICES     **PeiServices\r
+  )\r
+{\r
+  EFI_STATUS     Status;\r
+\r
+  CreateRscHandlerCallbackPacket ();\r
+\r
+  Status = PeiServicesInstallPpi (mStatusCodePpiList);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
diff --git a/MdeModulePkg/Universal/ReportStatusCodeRouter/Pei/ReportStatusCodeRouterPei.h b/MdeModulePkg/Universal/ReportStatusCodeRouter/Pei/ReportStatusCodeRouterPei.h
new file mode 100644 (file)
index 0000000..2fd2c7b
--- /dev/null
@@ -0,0 +1,109 @@
+/** @file\r
+  Internal include file for Report Status Code Router PEIM.\r
+\r
+  Copyright (c) 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 __PEI_REPORT_STATUS_CODE_ROUTER_H__\r
+#define __PEI_REPORT_STATUS_CODE_ROUTER_H__\r
+\r
+\r
+#include <Ppi/ReportStatusCodeHandler.h>\r
+#include <Ppi/StatusCode.h>\r
+\r
+#include <Guid/StatusCodeCallbackGuid.h>\r
+\r
+#include <Library/DebugLib.h>\r
+#include <Library/HobLib.h>\r
+#include <Library/PeiServicesLib.h>\r
+#include <Library/PeimEntryPoint.h>\r
+\r
+/**\r
+  Register the callback function for ReportStatusCode() notification.\r
+  \r
+  When this function is called the function pointer is added to an internal list and any future calls to\r
+  ReportStatusCode() will be forwarded to the Callback function.\r
+\r
+  @param[in] Callback           A pointer to a function of type EFI_PEI_RSC_HANDLER_CALLBACK that is called\r
+                                when a call to ReportStatusCode() occurs.\r
+                        \r
+  @retval EFI_SUCCESS           Function was successfully registered.\r
+  @retval EFI_INVALID_PARAMETER The callback function was NULL.\r
+  @retval EFI_OUT_OF_RESOURCES  The internal buffer ran out of space. No more functions can be\r
+                                registered.\r
+  @retval EFI_ALREADY_STARTED   The function was already registered. It can't be registered again.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Register (\r
+  IN EFI_PEI_RSC_HANDLER_CALLBACK Callback\r
+  );\r
+\r
+/**\r
+  Remove a previously registered callback function from the notification list.\r
+  \r
+  ReportStatusCode() messages will no longer be forwarded to the Callback function.\r
+  \r
+  @param[in] Callback           A pointer to a function of type EFI_PEI_RSC_HANDLER_CALLBACK that is to be\r
+                                unregistered.\r
+\r
+  @retval EFI_SUCCESS           The function was successfully unregistered.\r
+  @retval EFI_INVALID_PARAMETER The callback function was NULL.\r
+  @retval EFI_NOT_FOUND         The callback function was not found to be unregistered.\r
+                        \r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Unregister (\r
+  IN EFI_PEI_RSC_HANDLER_CALLBACK Callback\r
+  );\r
+\r
+/**\r
+  Publishes an interface that allows PEIMs to report status codes.\r
+\r
+  This function implements EFI_PEI_PROGRESS_CODE_PPI.ReportStatusCode().\r
+  It publishes an interface that allows PEIMs to report status codes.\r
+\r
+  @param  PeiServices      An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
+  @param  CodeType         Indicates the type of status code being reported.\r
+  @param  Value            Describes the current status of a hardware or\r
+                           software entity. This includes information about the class and\r
+                           subclass that is used to classify the entity as well as an operation.\r
+                           For progress codes, the operation is the current activity.\r
+                           For error codes, it is the exception.For debug codes,it is not defined at this time.\r
+  @param  Instance         The enumeration of a hardware or software entity within\r
+                           the system. A system may contain multiple entities that match a class/subclass\r
+                           pairing. The instance differentiates between them. An instance of 0 indicates\r
+                           that instance information is unavailable, not meaningful, or not relevant.\r
+                           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
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ReportDispatcher (\r
+  IN CONST EFI_PEI_SERVICES         **PeiServices,\r
+  IN EFI_STATUS_CODE_TYPE           CodeType,\r
+  IN EFI_STATUS_CODE_VALUE          Value,\r
+  IN UINT32                         Instance,\r
+  IN CONST EFI_GUID                 *CallerId OPTIONAL,\r
+  IN CONST EFI_STATUS_CODE_DATA     *Data OPTIONAL\r
+  );\r
+\r
+#endif\r
+\r
+\r
diff --git a/MdeModulePkg/Universal/ReportStatusCodeRouter/Pei/ReportStatusCodeRouterPei.inf b/MdeModulePkg/Universal/ReportStatusCodeRouter/Pei/ReportStatusCodeRouterPei.inf
new file mode 100644 (file)
index 0000000..f87d2d8
--- /dev/null
@@ -0,0 +1,53 @@
+#/** @file\r
+#  Report Status Code Router PEIM which produces Report Stataus Code Handler PPI and Status Code PPI.\r
+#\r
+#  Copyright (c) 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                      = ReportStatusCodeRouterPei\r
+  FILE_GUID                      = A3610442-E69F-4DF3-82CA-2360C4031A23\r
+  MODULE_TYPE                    = PEIM\r
+  ENTRY_POINT                    = GenericStatusCodePeiEntry\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC (EBC is only for build)\r
+#\r
+\r
+[Sources.common]\r
+  ReportStatusCodeRouterPei.c\r
+  ReportStatusCodeRouterPei.h\r
+\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  MdeModulePkg/MdeModulePkg.dec\r
+\r
+[LibraryClasses]\r
+  PeimEntryPoint\r
+  PeiServicesLib\r
+  DebugLib\r
+  HobLib\r
+\r
+[Guids]\r
+  gStatusCodeCallbackGuid                       ## CONSUMES ## HOB\r
+\r
+[Ppis]\r
+  gEfiPeiRscHandlerPpiGuid                      ## PRODUCES\r
+  gEfiPeiStatusCodePpiGuid                      ## PRODUCES\r
+\r
+\r
+[Depex]\r
+  TRUE\r
diff --git a/MdeModulePkg/Universal/ReportStatusCodeRouter/RuntimeDxe/ReportStatusCodeRouterRuntimeDxe.c b/MdeModulePkg/Universal/ReportStatusCodeRouter/RuntimeDxe/ReportStatusCodeRouterRuntimeDxe.c
new file mode 100644 (file)
index 0000000..aa2fa10
--- /dev/null
@@ -0,0 +1,334 @@
+/** @file\r
+  Report Status Code Router Driver which produces Report Stataus Code Handler Protocol\r
+  and Status Code Runtime Protocol.\r
+\r
+  Copyright (c) 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 "ReportStatusCodeRouterRuntimeDxe.h"\r
+\r
+EFI_HANDLE   mHandle                    = NULL;\r
+LIST_ENTRY   mCallbackListHead          = INITIALIZE_LIST_HEAD_VARIABLE (mCallbackListHead);\r
+EFI_EVENT    mVirtualAddressChangeEvent = NULL;\r
+\r
+//\r
+// Report operation nest status.\r
+// If it is set, then the report operation has nested.\r
+//\r
+UINT32       mStatusCodeNestStatus = 0;\r
+\r
+EFI_STATUS_CODE_PROTOCOL  mStatusCodeProtocol  = {\r
+  ReportDispatcher\r
+};\r
+\r
+EFI_RSC_HANDLER_PROTOCOL  mRscHandlerProtocol = {\r
+  Register,\r
+  Unregister\r
+  };\r
+\r
+/**\r
+  Register the callback function for ReportStatusCode() notification.\r
+  \r
+  When this function is called the function pointer is added to an internal list and any future calls to\r
+  ReportStatusCode() will be forwarded to the Callback function. During the bootservices,\r
+  this is the callback for which this service can be invoked. The report status code router\r
+  will create an event such that the callback function is only invoked at the TPL for which it was\r
+  registered. The entity that registers for the callback should also register for an event upon\r
+  generation of exit boot services and invoke the unregister service.\r
+  If the handler does not have a TPL dependency, it should register for a callback at TPL high. The\r
+  router infrastructure will support making callbacks at runtime, but the caller for runtime invocation\r
+  must meet the following criteria:\r
+  1. must be a runtime driver type so that its memory is not reclaimed\r
+  2. not unregister at exit boot services so that the router will still have its callback address\r
+  3. the caller must be self-contained (eg. Not call out into any boot-service interfaces) and be\r
+  runtime safe, in general.\r
+  \r
+  @param[in] Callback   A pointer to a function of type EFI_RSC_HANDLER_CALLBACK that is called when\r
+                        a call to ReportStatusCode() occurs.\r
+  @param[in] Tpl        TPL at which callback can be safely invoked.   \r
+  \r
+  @retval  EFI_SUCCESS              Function was successfully registered.\r
+  @retval  EFI_INVALID_PARAMETER    The callback function was NULL.\r
+  @retval  EFI_OUT_OF_RESOURCES     The internal buffer ran out of space. No more functions can be\r
+                                    registered.\r
+  @retval  EFI_ALREADY_STARTED      The function was already registered. It can't be registered again.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Register (\r
+  IN EFI_RSC_HANDLER_CALLBACK   Callback,\r
+  IN EFI_TPL                    Tpl\r
+  )\r
+{\r
+  LIST_ENTRY                    *Link;\r
+  RSC_HANDLER_CALLBACK_ENTRY    *CallbackEntry;\r
+\r
+  if (Callback == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  for (Link = GetFirstNode (&mCallbackListHead); !IsNull (&mCallbackListHead, Link); Link = GetNextNode (&mCallbackListHead, Link)) {\r
+    CallbackEntry = CR (Link, RSC_HANDLER_CALLBACK_ENTRY, Node, RSC_HANDLER_CALLBACK_ENTRY_SIGNATURE);\r
+    if (CallbackEntry->RscHandlerCallback == Callback) {\r
+      //\r
+      // If the function was already registered. It can't be registered again.\r
+      //\r
+      return EFI_ALREADY_STARTED;\r
+    }\r
+  }\r
+\r
+  CallbackEntry = AllocatePool (sizeof (RSC_HANDLER_CALLBACK_ENTRY));\r
+  ASSERT (CallbackEntry != NULL);\r
+\r
+  CallbackEntry->Signature          = RSC_HANDLER_CALLBACK_ENTRY_SIGNATURE;\r
+  CallbackEntry->RscHandlerCallback = Callback;\r
+  CallbackEntry->Tpl                = Tpl;\r
+\r
+  InsertTailList (&mCallbackListHead, &CallbackEntry->Node);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+  Remove a previously registered callback function from the notification list.\r
+  \r
+  A callback function must be unregistered before it is deallocated. It is important that any registered\r
+  callbacks that are not runtime complaint be unregistered when ExitBootServices() is called.\r
+  \r
+  @param[in]  Callback  A pointer to a function of type EFI_RSC_HANDLER_CALLBACK that is to be\r
+                        unregistered.\r
+                        \r
+  @retval EFI_SUCCESS           The function was successfully unregistered.\r
+  @retval EFI_INVALID_PARAMETER The callback function was NULL.\r
+  @retval EFI_NOT_FOUND         The callback function was not found to be unregistered.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Unregister (\r
+  IN EFI_RSC_HANDLER_CALLBACK Callback\r
+  )\r
+{\r
+  LIST_ENTRY                    *Link;\r
+  RSC_HANDLER_CALLBACK_ENTRY    *CallbackEntry;\r
+\r
+  if (Callback == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  for (Link = GetFirstNode (&mCallbackListHead); !IsNull (&mCallbackListHead, Link); Link = GetNextNode (&mCallbackListHead, Link)) {\r
+    CallbackEntry = CR (Link, RSC_HANDLER_CALLBACK_ENTRY, Node, RSC_HANDLER_CALLBACK_ENTRY_SIGNATURE);\r
+    if (CallbackEntry->RscHandlerCallback == Callback) {\r
+      //\r
+      // If the function is found in list, delete it and return.\r
+      //\r
+      RemoveEntryList (&CallbackEntry->Node);\r
+      FreePool (CallbackEntry);\r
+      return EFI_SUCCESS;\r
+    }\r
+  }\r
+\r
+  return EFI_NOT_FOUND;\r
+}\r
+\r
+/**\r
+  Event callback function to invoke status code handler in list.\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
+RscHandlerNotification (\r
+  IN EFI_EVENT        Event,\r
+  IN VOID             *Context\r
+  )\r
+{\r
+  RSC_EVENT_CONTEXT  *RscContext;\r
+\r
+  RscContext = (RSC_EVENT_CONTEXT *) Context;\r
+\r
+  RscContext->RscHandlerCallback (\r
+                RscContext->Type,\r
+                RscContext->Value,\r
+                RscContext->Instance,\r
+                RscContext->CallerId,\r
+                RscContext->Data\r
+                );\r
+}\r
+\r
+/**\r
+  Provides an interface that a software module can call to report a status code.\r
+\r
+  @param  Type             Indicates the type of status code being reported.\r
+  @param  Value            Describes the current status of a hardware or software entity.\r
+                           This included information about the class and subclass that is used to\r
+                           classify the entity as well as an operation.\r
+  @param  Instance         The enumeration of a hardware or software entity within\r
+                           the system. Valid instance numbers start with 1.\r
+  @param  CallerId         This optional parameter may be used to identify the caller.\r
+                           This parameter allows the status code driver to apply different rules to\r
+                           different callers.\r
+  @param  Data             This optional parameter may be used to pass additional data.\r
+\r
+  @retval EFI_SUCCESS           The function completed successfully\r
+  @retval EFI_DEVICE_ERROR      The function should not be completed due to a device error.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ReportDispatcher (\r
+  IN EFI_STATUS_CODE_TYPE     Type,\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
+  LIST_ENTRY                    *Link;\r
+  RSC_HANDLER_CALLBACK_ENTRY    *CallbackEntry;\r
+  RSC_EVENT_CONTEXT             Context;\r
+  EFI_EVENT                     Event;\r
+  EFI_STATUS                    Status;\r
+\r
+  //\r
+  // Use atom operation to avoid the reentant of report.\r
+  // If current status is not zero, then the function is reentrancy.\r
+  //\r
+  if (InterlockedCompareExchange32 (&mStatusCodeNestStatus, 0, 1) == 1) {\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+\r
+  for (Link = GetFirstNode (&mCallbackListHead); !IsNull (&mCallbackListHead, Link); Link = GetNextNode (&mCallbackListHead, Link)) {\r
+    CallbackEntry = CR (Link, RSC_HANDLER_CALLBACK_ENTRY, Node, RSC_HANDLER_CALLBACK_ENTRY_SIGNATURE);\r
+\r
+    if ((CallbackEntry->Tpl == TPL_HIGH_LEVEL) || EfiAtRuntime ()) {\r
+      CallbackEntry->RscHandlerCallback (\r
+                       Type,\r
+                       Value,\r
+                       Instance,\r
+                       CallerId,\r
+                       Data\r
+                       );\r
+      continue;\r
+    }\r
+\r
+    Context.RscHandlerCallback = CallbackEntry->RscHandlerCallback;\r
+    Context.Type               = Type;\r
+    Context.Value              = Value;\r
+    Context.Instance           = Instance;\r
+    Context.CallerId           = CallerId;\r
+    Context.Data               = Data;\r
+\r
+    Status = gBS->CreateEvent (\r
+                    EVT_NOTIFY_SIGNAL,\r
+                    CallbackEntry->Tpl,\r
+                    RscHandlerNotification,\r
+                    &Context,\r
+                    &Event\r
+                    );\r
+    ASSERT_EFI_ERROR (Status);\r
+\r
+    Status = gBS->SignalEvent (Event);\r
+    ASSERT_EFI_ERROR (Status);\r
+\r
+    Status = gBS->CloseEvent (Event);\r
+    ASSERT_EFI_ERROR (Status);\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
+  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
+  EFI_STATUS                                   Status;\r
+  LIST_ENTRY                    *Link;\r
+  RSC_HANDLER_CALLBACK_ENTRY    *CallbackEntry;\r
+\r
+  for (Link = GetFirstNode (&mCallbackListHead); !IsNull (&mCallbackListHead, Link); Link = GetNextNode (&mCallbackListHead, Link)) {\r
+    CallbackEntry = CR (Link, RSC_HANDLER_CALLBACK_ENTRY, Node, RSC_HANDLER_CALLBACK_ENTRY_SIGNATURE);\r
+    Status = EfiConvertFunctionPointer (0, (VOID **) &CallbackEntry->RscHandlerCallback);\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
+\r
+  Status = EfiConvertList (\r
+             0,\r
+             &mCallbackListHead\r
+             );\r
+  ASSERT_EFI_ERROR (Status);\r
+}\r
+\r
+/**\r
+  Entry point of Generic Status Code Driver.\r
+\r
+  This function is the entry point of this Generic Status Code Driver.\r
+  It installs eport Stataus Code Handler Protocol  and Status Code Runtime Protocol,\r
+  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
+GenericStatusCodeRuntimeDxeEntry (\r
+  IN EFI_HANDLE         ImageHandle,\r
+  IN EFI_SYSTEM_TABLE   *SystemTable\r
+  )\r
+{\r
+  EFI_STATUS     Status;\r
+\r
+  Status = gBS->InstallMultipleProtocolInterfaces (\r
+                  &mHandle,\r
+                  &gEfiRscHandlerProtocolGuid,\r
+                  &mRscHandlerProtocol,\r
+                  &gEfiStatusCodeRuntimeProtocolGuid,\r
+                  &mStatusCodeProtocol,\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
diff --git a/MdeModulePkg/Universal/ReportStatusCodeRouter/RuntimeDxe/ReportStatusCodeRouterRuntimeDxe.h b/MdeModulePkg/Universal/ReportStatusCodeRouter/RuntimeDxe/ReportStatusCodeRouterRuntimeDxe.h
new file mode 100644 (file)
index 0000000..a87ad5f
--- /dev/null
@@ -0,0 +1,137 @@
+/** @file\r
+  Internal include file for Report Status Code Router Driver.\r
+\r
+  Copyright (c) 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 __REPORT_STATUS_CODE_ROUTER_RUNTIME_DXE_H__\r
+#define __REPORT_STATUS_CODE_ROUTER_RUNTIME_DXE_H__\r
+\r
+\r
+#include <Protocol/ReportStatusCodeHandler.h>\r
+#include <Protocol/StatusCode.h>\r
+\r
+#include <Guid/EventGroup.h>\r
+\r
+#include <Library/BaseLib.h>\r
+#include <Library/SynchronizationLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/PcdLib.h>\r
+#include <Library/HobLib.h>\r
+#include <Library/UefiDriverEntryPoint.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/UefiRuntimeLib.h>\r
+\r
+#define RSC_HANDLER_CALLBACK_ENTRY_SIGNATURE  SIGNATURE_32 ('r', 'h', 'c', 'e')\r
+\r
+typedef struct {\r
+  UINTN                     Signature;\r
+  EFI_RSC_HANDLER_CALLBACK  RscHandlerCallback;\r
+  EFI_TPL                   Tpl;\r
+  LIST_ENTRY                Node;\r
+} RSC_HANDLER_CALLBACK_ENTRY;\r
+\r
+typedef struct {\r
+  EFI_RSC_HANDLER_CALLBACK RscHandlerCallback;\r
+  EFI_STATUS_CODE_TYPE     Type;\r
+  EFI_STATUS_CODE_VALUE    Value;\r
+  UINT32                   Instance;\r
+  EFI_GUID                 *CallerId;\r
+  EFI_STATUS_CODE_DATA     *Data;\r
+} RSC_EVENT_CONTEXT;\r
+\r
+/**\r
+  Register the callback function for ReportStatusCode() notification.\r
+  \r
+  When this function is called the function pointer is added to an internal list and any future calls to\r
+  ReportStatusCode() will be forwarded to the Callback function. During the bootservices,\r
+  this is the callback for which this service can be invoked. The report status code router\r
+  will create an event such that the callback function is only invoked at the TPL for which it was\r
+  registered. The entity that registers for the callback should also register for an event upon\r
+  generation of exit boot services and invoke the unregister service.\r
+  If the handler does not have a TPL dependency, it should register for a callback at TPL high. The\r
+  router infrastructure will support making callbacks at runtime, but the caller for runtime invocation\r
+  must meet the following criteria:\r
+  1. must be a runtime driver type so that its memory is not reclaimed\r
+  2. not unregister at exit boot services so that the router will still have its callback address\r
+  3. the caller must be self-contained (eg. Not call out into any boot-service interfaces) and be\r
+  runtime safe, in general.\r
+  \r
+  @param[in] Callback   A pointer to a function of type EFI_RSC_HANDLER_CALLBACK that is called when\r
+                        a call to ReportStatusCode() occurs.\r
+  @param[in] Tpl        TPL at which callback can be safely invoked.   \r
+  \r
+  @retval  EFI_SUCCESS              Function was successfully registered.\r
+  @retval  EFI_INVALID_PARAMETER    The callback function was NULL.\r
+  @retval  EFI_OUT_OF_RESOURCES     The internal buffer ran out of space. No more functions can be\r
+                                    registered.\r
+  @retval  EFI_ALREADY_STARTED      The function was already registered. It can't be registered again.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Register (\r
+  IN EFI_RSC_HANDLER_CALLBACK   Callback,\r
+  IN EFI_TPL                    Tpl\r
+  );\r
+\r
+/**\r
+  Remove a previously registered callback function from the notification list.\r
+  \r
+  A callback function must be unregistered before it is deallocated. It is important that any registered\r
+  callbacks that are not runtime complaint be unregistered when ExitBootServices() is called.\r
+  \r
+  @param[in]  Callback  A pointer to a function of type EFI_RSC_HANDLER_CALLBACK that is to be\r
+                        unregistered.\r
+                        \r
+  @retval EFI_SUCCESS           The function was successfully unregistered.\r
+  @retval EFI_INVALID_PARAMETER The callback function was NULL.\r
+  @retval EFI_NOT_FOUND         The callback function was not found to be unregistered.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Unregister (\r
+  IN EFI_RSC_HANDLER_CALLBACK Callback\r
+  );\r
+\r
+/**\r
+  Provides an interface that a software module can call to report a status code.\r
+\r
+  @param  Type             Indicates the type of status code being reported.\r
+  @param  Value            Describes the current status of a hardware or software entity.\r
+                           This included information about the class and subclass that is used to\r
+                           classify the entity as well as an operation.\r
+  @param  Instance         The enumeration of a hardware or software entity within\r
+                           the system. Valid instance numbers start with 1.\r
+  @param  CallerId         This optional parameter may be used to identify the caller.\r
+                           This parameter allows the status code driver to apply different rules to\r
+                           different callers.\r
+  @param  Data             This optional parameter may be used to pass additional data.\r
+\r
+  @retval EFI_SUCCESS           The function completed successfully\r
+  @retval EFI_DEVICE_ERROR      The function should not be completed due to a device error.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ReportDispatcher (\r
+  IN EFI_STATUS_CODE_TYPE     Type,\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
+#endif\r
+\r
+\r
diff --git a/MdeModulePkg/Universal/ReportStatusCodeRouter/RuntimeDxe/ReportStatusCodeRouterRuntimeDxe.inf b/MdeModulePkg/Universal/ReportStatusCodeRouter/RuntimeDxe/ReportStatusCodeRouterRuntimeDxe.inf
new file mode 100644 (file)
index 0000000..b740db4
--- /dev/null
@@ -0,0 +1,58 @@
+#/** @file\r
+#  Report Status Code Router Driver which produces Report Stataus Code Handler Protocol\r
+#  and Status Code Runtime Protocol.\r
+#\r
+#  Copyright (c) 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                      = ReportStatusCodeRouterRuntimeDxe\r
+  FILE_GUID                      = D93CE3D8-A7EB-4730-8C8E-CC466A9ECC3C\r
+  MODULE_TYPE                    = DXE_RUNTIME_DRIVER\r
+  ENTRY_POINT                    = GenericStatusCodeRuntimeDxeEntry\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#\r
+\r
+[Sources.common]\r
+  ReportStatusCodeRouterRuntimeDxe.c\r
+  ReportStatusCodeRouterRuntimeDxe.h\r
+\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  MdeModulePkg/MdeModulePkg.dec\r
+\r
+[LibraryClasses]\r
+  UefiRuntimeLib\r
+  MemoryAllocationLib\r
+  UefiBootServicesTableLib\r
+  UefiDriverEntryPoint\r
+  HobLib\r
+  PcdLib\r
+  DebugLib\r
+  BaseLib\r
+  SynchronizationLib\r
+\r
+[Guids]\r
+  gEfiEventVirtualAddressChangeGuid               ## CONSUMES ## Event\r
+\r
+[Protocols]\r
+  gEfiRscHandlerProtocolGuid                      ## PRODUCES\r
+  gEfiStatusCodeRuntimeProtocolGuid               ## PRODUCES\r
+\r
+[Depex]\r
+  TRUE\r
index 8b130f04c85e5332b18b22c127cd1ec2f680b01b..406ef8ffe52b6a5f32449f954f786f6241310217 100644 (file)
    <LibraryClasses>\r
       PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf\r
   }\r
-  IntelFrameworkModulePkg/Universal/StatusCode/Pei/StatusCodePei.inf\r
+  MdeModulePkg/Universal/ReportStatusCodeRouter/Pei/ReportStatusCodeRouterPei.inf\r
+  IntelFrameworkModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.inf\r
+  Nt32Pkg/WinNtOemHookStatusCodeHandlerPei/WinNtOemHookStatusCodeHandlerPei.inf\r
   Nt32Pkg/BootModePei/BootModePei.inf\r
   Nt32Pkg/WinNtFlashMapPei/WinNtFlashMapPei.inf\r
   MdeModulePkg/Universal/Variable/Pei/VariablePei.inf\r
   IntelFrameworkModulePkg/Universal/DataHubStdErrDxe/DataHubStdErrDxe.inf\r
   Nt32Pkg/MiscSubClassPlatformDxe/MiscSubClassPlatformDxe.inf\r
   Nt32Pkg/TimerDxe/TimerDxe.inf\r
-  IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/StatusCodeRuntimeDxe.inf\r
+  MdeModulePkg/Universal/ReportStatusCodeRouter/RuntimeDxe/ReportStatusCodeRouterRuntimeDxe.inf\r
+  IntelFrameworkModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandlerRuntimeDxe.inf\r
+  Nt32Pkg/WinNtOemHookStatusCodeHandlerDxe/WinNtOemHookStatusCodeHandlerDxe.inf\r
   MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf\r
   MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf\r
   MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf\r
index 15d070a14548d54e29a9e8418a54934f18b99942..d2d8ccea76db775ad7f81c3ad371e59a18ae7dda 100644 (file)
@@ -1,6 +1,6 @@
 # This is NT32 FDF file with UEFI HII features enabled\r
 #\r
-# Copyright (c) 2007, Intel Corporation\r
+# Copyright (c) 2007 - 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
@@ -154,7 +154,9 @@ FvNameGuid         = 6D99E806-3D38-42c2-A095-5F4300BFD7DC
   ##\r
 APRIORI PEI {\r
   INF  MdeModulePkg/Universal/PCD/Pei/Pcd.inf\r
-  INF  IntelFrameworkModulePkg/Universal/StatusCode/Pei/StatusCodePei.inf\r
+  INF  MdeModulePkg/Universal/ReportStatusCodeRouter/Pei/ReportStatusCodeRouterPei.inf\r
+  INF  IntelFrameworkModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.inf\r
+  INF  Nt32Pkg/WinNtOemHookStatusCodeHandlerPei/WinNtOemHookStatusCodeHandlerPei.inf\r
   }\r
 APRIORI DXE {\r
   INF  MdeModulePkg/Universal/PCD/Dxe/Pcd.inf\r
@@ -163,7 +165,9 @@ APRIORI DXE {
 \r
 INF  MdeModulePkg/Core/Pei/PeiMain.inf\r
 INF  MdeModulePkg/Universal/PCD/Pei/Pcd.inf\r
-INF  IntelFrameworkModulePkg/Universal/StatusCode/Pei/StatusCodePei.inf\r
+INF  MdeModulePkg/Universal/ReportStatusCodeRouter/Pei/ReportStatusCodeRouterPei.inf\r
+INF  IntelFrameworkModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.inf\r
+INF  Nt32Pkg/WinNtOemHookStatusCodeHandlerPei/WinNtOemHookStatusCodeHandlerPei.inf\r
 INF  Nt32Pkg/BootModePei/BootModePei.inf\r
 INF  Nt32Pkg/WinNtFlashMapPei/WinNtFlashMapPei.inf\r
 INF  Nt32Pkg/WinNtAutoScanPei/WinNtAutoScanPei.inf\r
@@ -194,7 +198,9 @@ INF  MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf
 INF  IntelFrameworkModulePkg/Universal/DataHubStdErrDxe/DataHubStdErrDxe.inf\r
 INF  Nt32Pkg/MiscSubClassPlatformDxe/MiscSubClassPlatformDxe.inf\r
 INF  Nt32Pkg/TimerDxe/TimerDxe.inf\r
-INF  IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/StatusCodeRuntimeDxe.inf\r
+INF  MdeModulePkg/Universal/ReportStatusCodeRouter/RuntimeDxe/ReportStatusCodeRouterRuntimeDxe.inf\r
+INF  IntelFrameworkModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandlerRuntimeDxe.inf\r
+INF  Nt32Pkg/WinNtOemHookStatusCodeHandlerDxe/WinNtOemHookStatusCodeHandlerDxe.inf\r
 INF  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf\r
 INF  MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf\r
 INF  MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf\r
diff --git a/Nt32Pkg/WinNtOemHookStatusCodeHandlerDxe/WinNtOemHookStatusCodeHandlerDxe.c b/Nt32Pkg/WinNtOemHookStatusCodeHandlerDxe/WinNtOemHookStatusCodeHandlerDxe.c
new file mode 100644 (file)
index 0000000..dce9f96
--- /dev/null
@@ -0,0 +1,68 @@
+/** @file\r
+  OEM hook status code handler driver which produces general handler and hook it\r
+  onto the DXE status code router.\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
+//\r
+// The package level header files this module uses\r
+//\r
+#include <WinNtDxe.h>\r
+\r
+//\r
+// The protocols, PPI and GUID defintions for this module\r
+//\r
+#include <Protocol/ReportStatusCodeHandler.h>\r
+\r
+//\r
+// The Library classes this module consumes\r
+//\r
+#include <Library/DebugLib.h>\r
+#include <Library/UefiDriverEntryPoint.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/OemHookStatusCodeLib.h>\r
+\r
+/**\r
+  Entry point of OEM hook status code handler driver.\r
+\r
+  This function is the entry point of this OEM hook status code handler driver.\r
+  It initializes registers OEM status code handler.\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
+WinNtOemHookStatusCodeHandlerDxeEntry (\r
+  IN EFI_HANDLE         ImageHandle,\r
+  IN EFI_SYSTEM_TABLE   *SystemTable\r
+  )\r
+{\r
+  EFI_STATUS                Status;\r
+  EFI_RSC_HANDLER_PROTOCOL  *RscHandlerProtocol;\r
+\r
+  Status = gBS->LocateProtocol (\r
+                  &gEfiRscHandlerProtocolGuid,\r
+                  NULL,\r
+                  (VOID **) &RscHandlerProtocol\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  OemHookStatusCodeInitialize ();\r
+\r
+  RscHandlerProtocol->Register (OemHookStatusCodeReport, TPL_HIGH_LEVEL);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
diff --git a/Nt32Pkg/WinNtOemHookStatusCodeHandlerDxe/WinNtOemHookStatusCodeHandlerDxe.inf b/Nt32Pkg/WinNtOemHookStatusCodeHandlerDxe/WinNtOemHookStatusCodeHandlerDxe.inf
new file mode 100644 (file)
index 0000000..dfd3c06
--- /dev/null
@@ -0,0 +1,51 @@
+#/** @file\r
+# OEM hook status code handler driver which produces general handler and hook it\r
+# onto the DXE status code router.\r
+#\r
+# Copyright (c) 2007 - 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
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = WinNtOemHookStatusCodeHandlerDxe\r
+  FILE_GUID                      = CA4233AD-847E-4E5D-AD3F-21CABFE5E23C\r
+  MODULE_TYPE                    = DXE_DRIVER\r
+  ENTRY_POINT                    = WinNtOemHookStatusCodeHandlerDxeEntry\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32\r
+#\r
+#  HOB Guid C Name: gEfiWinNtThunkProtocolGuid Hob Type: GUID_EXTENSION\r
+#\r
+\r
+[Sources.common]\r
+  WinNtOemHookStatusCodeHandlerDxe.c\r
+\r
+\r
+[Packages]\r
+  Nt32Pkg/Nt32Pkg.dec\r
+  MdePkg/MdePkg.dec\r
+  IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec\r
+\r
+[LibraryClasses]\r
+  DebugLib\r
+  UefiDriverEntryPoint\r
+  UefiBootServicesTableLib\r
+  OemHookStatusCodeLib\r
+\r
+[Protocols]\r
+  gEfiRscHandlerProtocolGuid                    ## CONSUMES\r
+\r
+[Depex]\r
+  gEfiRscHandlerProtocolGuid\r
diff --git a/Nt32Pkg/WinNtOemHookStatusCodeHandlerPei/WinNtOemHookStatusCodeHandlerPei.c b/Nt32Pkg/WinNtOemHookStatusCodeHandlerPei/WinNtOemHookStatusCodeHandlerPei.c
new file mode 100644 (file)
index 0000000..e9ab12a
--- /dev/null
@@ -0,0 +1,89 @@
+/** @file\r
+  OEM hook status code handler PEIM which produces general handler and hook it\r
+  onto the PEI status code router.\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
+//\r
+// The package level header files this module uses\r
+//\r
+#include <WinNtPeim.h>\r
+\r
+//\r
+// The protocols, PPI and GUID defintions for this module\r
+//\r
+#include <Ppi/ReportStatusCodeHandler.h>\r
+//\r
+// The Library classes this module consumes\r
+//\r
+#include <Library/DebugLib.h>\r
+#include <Library/PeiServicesLib.h>\r
+#include <Library/PeimEntryPoint.h>\r
+#include <Library/OemHookStatusCodeLib.h>\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+OemHookStatusCodeReportWrapper (\r
+  IN CONST EFI_PEI_SERVICES         **PeiServices,\r
+  IN       EFI_STATUS_CODE_TYPE     CodeType,\r
+  IN       EFI_STATUS_CODE_VALUE    Value,\r
+  IN       UINT32                   Instance,\r
+  IN CONST EFI_GUID                 *CallerId, OPTIONAL\r
+  IN CONST EFI_STATUS_CODE_DATA     *Data      OPTIONAL\r
+  )\r
+{\r
+  return OemHookStatusCodeReport (\r
+           CodeType,\r
+           Value,\r
+           Instance,\r
+           (EFI_GUID *) CallerId,\r
+           (EFI_STATUS_CODE_DATA *) Data\r
+           );\r
+}\r
+\r
+/**\r
+  Entry point of OEM hook status code handler PEIM.\r
+  \r
+  This function is the entry point of this OEM hook status code handler PEIM.\r
+  It initializes and registers OEM status code handler.\r
+\r
+  @param  FileHandle  Handle of the file being invoked.\r
+  @param  PeiServices Describes the list of possible PEI Services.\r
+\r
+  @retval EFI_SUCESS  The entry point executes successfully.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+WinNtOemHookStatusCodeHandlerPeiEntry (\r
+  IN       EFI_PEI_FILE_HANDLE  FileHandle,\r
+  IN CONST EFI_PEI_SERVICES     **PeiServices\r
+  )\r
+{\r
+  EFI_STATUS                  Status;\r
+  EFI_PEI_RSC_HANDLER_PPI     *RscHandlerPpi;\r
+\r
+  Status = PeiServicesLocatePpi (\r
+             &gEfiPeiRscHandlerPpiGuid,\r
+             0,\r
+             NULL,\r
+             (VOID **) &RscHandlerPpi\r
+             );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  OemHookStatusCodeInitialize ();\r
+\r
+  Status = RscHandlerPpi->Register (OemHookStatusCodeReportWrapper);                     \r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
diff --git a/Nt32Pkg/WinNtOemHookStatusCodeHandlerPei/WinNtOemHookStatusCodeHandlerPei.inf b/Nt32Pkg/WinNtOemHookStatusCodeHandlerPei/WinNtOemHookStatusCodeHandlerPei.inf
new file mode 100644 (file)
index 0000000..b5a18a7
--- /dev/null
@@ -0,0 +1,51 @@
+#/** @file\r
+# OEM hook status code handler PEIM which produces general handler and hook it\r
+# onto the PEI status code router.\r
+#\r
+# Copyright (c) 2007 - 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
+#**/\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = WinNtOemHookStatusCodeHandlerPei\r
+  FILE_GUID                      = D233D6BD-F1B1-425A-BF45-5CAF2B88EDDC\r
+  MODULE_TYPE                    = PEIM\r
+  ENTRY_POINT                    = WinNtOemHookStatusCodeHandlerPeiEntry\r
+\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32\r
+#\r
+\r
+[Sources.common]\r
+  WinNtOemHookStatusCodeHandlerPei.c\r
+\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec\r
+  Nt32Pkg/Nt32Pkg.dec\r
+\r
+[LibraryClasses]\r
+  PeimEntryPoint\r
+  PeiServicesLib\r
+  DebugLib\r
+  OemHookStatusCodeLib\r
+\r
+[Ppis]\r
+  gEfiPeiRscHandlerPpiGuid                      ## CONSUMES\r
+\r
+[Depex]\r
+  gEfiPeiRscHandlerPpiGuid\r