]> git.proxmox.com Git - mirror_edk2.git/commitdiff
1. add EdkSerialPortLibNull.inf
authorvanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 29 Jun 2007 03:38:49 +0000 (03:38 +0000)
committervanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 29 Jun 2007 03:38:49 +0000 (03:38 +0000)
2. add StatusCode Dxe and Pei modules

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2877 6f19259b-4bc3-4df7-8a09-765794883524

23 files changed:
IntelFrameworkModulePkg/IntelFrameworkModulePkg.dsc
IntelFrameworkModulePkg/Library/EdkSerialPortLibNull/CommonHeader.h [new file with mode: 0644]
IntelFrameworkModulePkg/Library/EdkSerialPortLibNull/EdkSerialPortLibNull.inf [new file with mode: 0644]
IntelFrameworkModulePkg/Library/EdkSerialPortLibNull/EdkSerialPortLibNull.msa [new file with mode: 0644]
IntelFrameworkModulePkg/Library/EdkSerialPortLibNull/SerialPortLibNull.c [new file with mode: 0644]
IntelFrameworkModulePkg/Universal/StatusCode/Dxe/Common/DxeStatusCodeCommon.c [new file with mode: 0644]
IntelFrameworkModulePkg/Universal/StatusCode/Dxe/Common/StatusCode.dxs [new file with mode: 0644]
IntelFrameworkModulePkg/Universal/StatusCode/Dxe/CommonHeader.h [new file with mode: 0644]
IntelFrameworkModulePkg/Universal/StatusCode/Dxe/DataHubStatusCodeWorker.c [new file with mode: 0644]
IntelFrameworkModulePkg/Universal/StatusCode/Dxe/DxeStatusCode.c [new file with mode: 0644]
IntelFrameworkModulePkg/Universal/StatusCode/Dxe/DxeStatusCode.h [new file with mode: 0644]
IntelFrameworkModulePkg/Universal/StatusCode/Dxe/DxeStatusCode.inf [new file with mode: 0644]
IntelFrameworkModulePkg/Universal/StatusCode/Dxe/DxeStatusCode.msa [new file with mode: 0644]
IntelFrameworkModulePkg/Universal/StatusCode/Dxe/EntryPoint.c [new file with mode: 0644]
IntelFrameworkModulePkg/Universal/StatusCode/Dxe/RtMemoryStatusCodeWorker.c [new file with mode: 0644]
IntelFrameworkModulePkg/Universal/StatusCode/Dxe/SerialStatusCodeWorker.c [new file with mode: 0644]
IntelFrameworkModulePkg/Universal/StatusCode/Pei/CommonHeader.h [new file with mode: 0644]
IntelFrameworkModulePkg/Universal/StatusCode/Pei/MemoryStausCodeWorker.c [new file with mode: 0644]
IntelFrameworkModulePkg/Universal/StatusCode/Pei/PeiStatusCode.c [new file with mode: 0644]
IntelFrameworkModulePkg/Universal/StatusCode/Pei/PeiStatusCode.h [new file with mode: 0644]
IntelFrameworkModulePkg/Universal/StatusCode/Pei/PeiStatusCode.inf [new file with mode: 0644]
IntelFrameworkModulePkg/Universal/StatusCode/Pei/PeiStatusCode.msa [new file with mode: 0644]
IntelFrameworkModulePkg/Universal/StatusCode/Pei/SerialStatusCodeWorker.c [new file with mode: 0644]

index dc6278bdbfb4c0e92dbff7b8923eaedf8fad380e..e3cba061e19d0235e2b8ea1ff2084214896f3a60 100644 (file)
@@ -9,7 +9,7 @@
 #    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
 #    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
+#\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
 #    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
   PrintLib|${WORKSPACE}/MdePkg/Library/BasePrintLib/BasePrintLib.inf\r
   TimerLib|${WORKSPACE}/MdePkg/Library/BaseTimerLibNullTemplate/BaseTimerLibNullTemplate.inf\r
   UefiDecompressLib|${WORKSPACE}/MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf\r
   PrintLib|${WORKSPACE}/MdePkg/Library/BasePrintLib/BasePrintLib.inf\r
   TimerLib|${WORKSPACE}/MdePkg/Library/BaseTimerLibNullTemplate/BaseTimerLibNullTemplate.inf\r
   UefiDecompressLib|${WORKSPACE}/MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf\r
+  OemHookStatusCodeLib|${WORKSPACE}/IntelFrameworkModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.inf\r
+  SerialPortLib|${WORKSPACE}/IntelFrameworkModulePkg/Library/EdkSerialPortLibNull/EdkSerialPortLibNull.inf\r
+\r
+[LibraryClasses.common.PEIM]\r
+  HobLib|$(WORKSPACE)/MdePkg/Library/PeiHobLib/PeiHobLib.inf\r
+  PeiServicesTablePointerLib|$(WORKSPACE)/MdePkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf\r
+  PcdLib|$(WORKSPACE)/MdePkg/Library/PeiPcdLib/PeiPcdLib.inf\r
+  IoLib|$(WORKSPACE)/MdePkg/Library/PeiIoLibCpuIo/PeiIoLibCpuIo.inf\r
+  DebugLib|$(WORKSPACE)/MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf\r
+  PeimEntryPoint|$(WORKSPACE)/MdePkg/Library/PeimEntryPoint/PeimEntryPoint.inf\r
+  PeiServicesLib|$(WORKSPACE)/MdePkg/Library/PeiServicesLib/PeiServicesLib.inf\r
+  BaseMemoryLib|$(WORKSPACE)/MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf\r
+  MemoryAllocationLib|$(WORKSPACE)/MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf\r
+  ReportStatusCodeLib|$(WORKSPACE)/IntelFrameworkPkg/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf\r
 \r
 [LibraryClasses.common.DXE_DRIVER]\r
   HobLib|${WORKSPACE}/MdePkg/Library/DxeHobLib/DxeHobLib.inf\r
 \r
 [LibraryClasses.common.DXE_DRIVER]\r
   HobLib|${WORKSPACE}/MdePkg/Library/DxeHobLib/DxeHobLib.inf\r
   FvbServiceLib|${WORKSPACE}/MdeModulePkg/Library/EdkFvbServiceLib/EdkFvbServiceLib.inf\r
   ReportStatusCodeLib|${WORKSPACE}/IntelFrameworkPkg/Library/DxeReportStatusCodeLibFramework/DxeReportStatusCodeLib.inf\r
 \r
   FvbServiceLib|${WORKSPACE}/MdeModulePkg/Library/EdkFvbServiceLib/EdkFvbServiceLib.inf\r
   ReportStatusCodeLib|${WORKSPACE}/IntelFrameworkPkg/Library/DxeReportStatusCodeLibFramework/DxeReportStatusCodeLib.inf\r
 \r
+[LibraryClasses.common.DXE_RUNTIME_DRIVER]\r
+  HobLib|${WORKSPACE}/MdePkg/Library/DxeHobLib/DxeHobLib.inf\r
+  MemoryAllocationLib|${WORKSPACE}/MdePkg/Library/DxeMemoryAllocationLib/DxeMemoryAllocationLib.inf\r
+  PcdLib|${WORKSPACE}/MdePkg/Library/DxePcdLib/DxePcdLib.inf\r
+  DxeServiceTableLib|${WORKSPACE}/MdePkg/Library/DxeServicesTableLib/DxeServicesTableLib.inf\r
+  UefiBootServicesTableLib|${WORKSPACE}/MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf\r
+  DebugLib|${WORKSPACE}/MdePkg/Library/UefiDebugLibConOut/UefiDebugLibConOut.inf\r
+  UefiDriverEntryPoint|${WORKSPACE}/MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf\r
+  UefiLib|${WORKSPACE}/MdePkg/Library/UefiLib/UefiLib.inf\r
+  UefiRuntimeLib|${WORKSPACE}/MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf\r
+  UefiRuntimeServicesTableLib|${WORKSPACE}/MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf\r
+  ReportStatusCodeLib|${WORKSPACE}/IntelFrameworkPkg/Library/DxeReportStatusCodeLibFramework/DxeReportStatusCodeLib.inf\r
+\r
 ################################################################################\r
 #\r
 # Pcd Section - list of all EDK II PCD Entries defined by this Platform\r
 ################################################################################\r
 #\r
 # Pcd Section - list of all EDK II PCD Entries defined by this Platform\r
   PcdDebugPrintErrorLevel|gEfiMdePkgTokenSpaceGuid|0x80000000\r
   PcdPciExpressBaseAddress|gEfiMdePkgTokenSpaceGuid|0xE0000000\r
   PcdFSBClock|gEfiMdePkgTokenSpaceGuid|200000000\r
   PcdDebugPrintErrorLevel|gEfiMdePkgTokenSpaceGuid|0x80000000\r
   PcdPciExpressBaseAddress|gEfiMdePkgTokenSpaceGuid|0xE0000000\r
   PcdFSBClock|gEfiMdePkgTokenSpaceGuid|200000000\r
-  \r
+\r
+[PcdsDynamic.common]\r
+  PcdStatusCodeMemorySize|gEfiIntelFrameworkModulePkgTokenSpaceGuid|1\r
+  PcdStatusCodeRuntimeMemorySize|gEfiIntelFrameworkModulePkgTokenSpaceGuid|4\r
+\r
 ################################################################################\r
 #\r
 # Components Section - list of all EDK II Modules needed by this Platform\r
 ################################################################################\r
 #\r
 # Components Section - list of all EDK II Modules needed by this Platform\r
   $(WORKSPACE)\IntelFrameworkModulePkg\Bus\Pci\IdeBus\Dxe\IdeBus.inf\r
   $(WORKSPACE)\IntelFrameworkModulePkg\Universal\DataHub\DataHub\Dxe\DataHub.inf\r
   $(WORKSPACE)\IntelFrameworkModulePkg\Universal\DataHub\DataHubStdErr\Dxe\DataHubStdErr.inf\r
   $(WORKSPACE)\IntelFrameworkModulePkg\Bus\Pci\IdeBus\Dxe\IdeBus.inf\r
   $(WORKSPACE)\IntelFrameworkModulePkg\Universal\DataHub\DataHub\Dxe\DataHub.inf\r
   $(WORKSPACE)\IntelFrameworkModulePkg\Universal\DataHub\DataHubStdErr\Dxe\DataHubStdErr.inf\r
+  $(WORKSPACE)\IntelFrameworkModulePkg\Universal\DataHub\DataHubStdErr\Dxe\DataHubStdErr.inf\r
+  $(WORKSPACE)\IntelFrameworkModulePkg\Universal\StatusCode\Dxe\DxeStatusCode.inf\r
+  $(WORKSPACE)\IntelFrameworkModulePkg\Universal\StatusCode\Pei\PeiStatusCode.inf\r
diff --git a/IntelFrameworkModulePkg/Library/EdkSerialPortLibNull/CommonHeader.h b/IntelFrameworkModulePkg/Library/EdkSerialPortLibNull/CommonHeader.h
new file mode 100644 (file)
index 0000000..3097ab7
--- /dev/null
@@ -0,0 +1,31 @@
+/**@file\r
+  Common header file shared by all source files.\r
+\r
+  This file includes package header files, library classes and protocol, PPI & GUID definitions.\r
+\r
+  Copyright (c) 2006, Intel Corporation.\r
+  All rights reserved. This program and the accompanying materials\r
+   are licensed and made available under the terms and conditions of the BSD License\r
+   which accompanies this distribution. The full text of the license may be found at\r
+   http://opensource.org/licenses/bsd-license.php\r
+   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
+#ifndef __COMMON_HEADER_H_\r
+#define __COMMON_HEADER_H_\r
+\r
+\r
+//\r
+// The package level header files this module uses\r
+//\r
+#include <PiPei.h>\r
+//\r
+// The protocols, PPI and GUID defintions for this module\r
+//\r
+//\r
+// The Library classes this module consumes\r
+//\r
+#include <Library/SerialPortLib.h>\r
+\r
+#endif\r
diff --git a/IntelFrameworkModulePkg/Library/EdkSerialPortLibNull/EdkSerialPortLibNull.inf b/IntelFrameworkModulePkg/Library/EdkSerialPortLibNull/EdkSerialPortLibNull.inf
new file mode 100644 (file)
index 0000000..8a872d1
--- /dev/null
@@ -0,0 +1,59 @@
+#/** @file\r
+# Memory Status Code Library for UEFI drivers\r
+#\r
+# Lib to provide memory journal status code reporting Routines\r
+# Copyright (c) 2006, 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
+################################################################################\r
+#\r
+# Defines Section - statements that will be processed to create a Makefile.\r
+#\r
+################################################################################\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = EdkSerialPortLibNull\r
+  FILE_GUID                      = E4541241-8897-411a-91F8-7D7E45837146\r
+  MODULE_TYPE                    = PEIM\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = SerialPortLib\r
+  EDK_RELEASE_VERSION            = 0x00020000\r
+  EFI_SPECIFICATION_VERSION      = 0x00020000\r
+\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
+################################################################################\r
+#\r
+# Sources Section - list of files that are required for the build to succeed.\r
+#\r
+################################################################################\r
+\r
+[Sources.common]\r
+  SerialPortLibNull.c\r
+\r
+\r
+################################################################################\r
+#\r
+# Package Dependency Section - list of Package files that are required for\r
+#                              this module.\r
+#\r
+################################################################################\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  IntelFrameworkPkg/IntelFrameworkPkg.dec\r
+\r
diff --git a/IntelFrameworkModulePkg/Library/EdkSerialPortLibNull/EdkSerialPortLibNull.msa b/IntelFrameworkModulePkg/Library/EdkSerialPortLibNull/EdkSerialPortLibNull.msa
new file mode 100644 (file)
index 0000000..9c992ea
--- /dev/null
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\r
+  <MsaHeader>\r
+    <ModuleName>EdkSerialPortLibNull</ModuleName>\r
+    <ModuleType>PEIM</ModuleType>\r
+    <GuidValue>E4541241-8897-411a-91F8-7D7E45837146</GuidValue>\r
+    <Version>1.0</Version>\r
+    <Abstract>Memory Status Code Library for UEFI drivers</Abstract>\r
+    <Description>Lib to provide memory journal status code reporting Routines</Description>\r
+    <Copyright>Copyright (c) 2006, Intel Corporation.</Copyright>\r
+    <License>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.</License>\r
+    <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION   0x00000052</Specification>\r
+  </MsaHeader>\r
+  <ModuleDefinitions>\r
+    <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>\r
+    <BinaryModule>false</BinaryModule>\r
+    <OutputFileBasename>EdkSerialPortLibNull</OutputFileBasename>\r
+  </ModuleDefinitions>\r
+  <LibraryClassDefinitions>\r
+    <LibraryClass Usage="ALWAYS_PRODUCED">\r
+      <Keyword>SerialPortLib</Keyword>\r
+    </LibraryClass>\r
+  </LibraryClassDefinitions>\r
+  <SourceFiles>\r
+    <Filename>SerialPortLibNull.c</Filename>\r
+  </SourceFiles>\r
+  <PackageDependencies>\r
+    <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+    <Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>\r
+  </PackageDependencies>\r
+  <Externs>\r
+    <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
+    <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
+  </Externs>\r
+</ModuleSurfaceArea>
\ No newline at end of file
diff --git a/IntelFrameworkModulePkg/Library/EdkSerialPortLibNull/SerialPortLibNull.c b/IntelFrameworkModulePkg/Library/EdkSerialPortLibNull/SerialPortLibNull.c
new file mode 100644 (file)
index 0000000..4782a9c
--- /dev/null
@@ -0,0 +1,85 @@
+/** @file\r
+  Serial I/O Port library functions with no library constructor/destructor\r
+\r
+  Copyright (c) 2006, Intel Corporation\r
+  All rights reserved. This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+  Module Name:  SerialPortLibNull.c\r
+\r
+**/\r
+\r
+//\r
+// The package level header files this module uses\r
+//\r
+#include <FrameworkPei.h>\r
+//\r
+// The protocols, PPI and GUID defintions for this module\r
+//\r
+//\r
+// The Library classes this module consumes\r
+//\r
+#include <Library/SerialPortLib.h>\r
+\r
+/*\r
+\r
+  Programmed hardware of Serial port.\r
+\r
+  @return    Always return EFI_UNSUPPORTED.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+SerialPortInitialize (\r
+  VOID\r
+  )\r
+{\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+/**\r
+  Write data to serial device.\r
+\r
+  @param  Buffer           Point of data buffer which need to be writed.\r
+  @param  NumberOfBytes    Number of output bytes which are cached in Buffer.\r
+\r
+  @retval 0                Write data failed.\r
+  @retval !0               Actual number of bytes writed to serial device.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+SerialPortWrite (\r
+  IN UINT8     *Buffer,\r
+  IN UINTN     NumberOfBytes\r
+)\r
+{\r
+  return 0;\r
+}\r
+\r
+\r
+/**\r
+  Read data from serial device and save the datas in buffer.\r
+\r
+  @param  Buffer           Point of data buffer which need to be writed.\r
+  @param  NumberOfBytes    Number of output bytes which are cached in Buffer.\r
+\r
+  @retval 0                Read data failed.\r
+  @retval !0               Aactual number of bytes read from serial device.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+SerialPortRead (\r
+  OUT UINT8     *Buffer,\r
+  IN  UINTN     NumberOfBytes\r
+)\r
+{\r
+  return 0;\r
+}\r
+\r
diff --git a/IntelFrameworkModulePkg/Universal/StatusCode/Dxe/Common/DxeStatusCodeCommon.c b/IntelFrameworkModulePkg/Universal/StatusCode/Dxe/Common/DxeStatusCodeCommon.c
new file mode 100644 (file)
index 0000000..54c9ac0
--- /dev/null
@@ -0,0 +1,233 @@
+/** @file\r
+  Status code driver for IA32/X64/EBC architecture.\r
+\r
+  Copyright (c) 2006, Intel Corporation                                                         \r
+  All rights reserved. This program and the accompanying materials                          \r
+  are licensed and made available under the terms and conditions of the BSD License         \r
+  which accompanies this distribution.  The full text of the license may be found at        \r
+  http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                            \r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+  Module Name:  DxeStatusCodeCommon.c\r
+\r
+**/\r
+//\r
+// Include common header file for this module.\r
+//\r
+#include "CommonHeader.h"\r
+\r
+#include "DxeStatusCode.h"\r
+\r
+\r
+/**\r
+  Report status code to all supported device. \r
+  Calls into the workers which dispatches the platform specific\r
+  listeners. \r
+\r
+  @param  Type          Indicates the type of status code being reported.  \r
+                        The type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.\r
+  @param  Value         Describes the current status of a hardware or software entity.  \r
+                        This includes information about the class and subclass that is used to classify the entity \r
+                        as well as an operation.  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
+                        Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.  \r
+                        Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.\r
+  @param  Instance      The enumeration of a hardware or software entity within the system.  \r
+                        A system may contain multiple entities that match a class/subclass pairing.  \r
+                        The instance differentiates between them.  An instance of 0 indicates that instance \r
+                        information is unavailable, not meaningful, or not relevant.  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 different callers.\r
+  @param  Data          This optional parameter may be used to pass additional data.  \r
+                        Type EFI_STATUS_CODE_DATA is defined in "Related Definitions" below.  \r
+                        The contents of this data type may have additional GUID-specific data.  The standard GUIDs and \r
+                        their associated data structures are defined in the Intel? Platform Innovation Framework for EFI Status Codes Specification.\r
+\r
+  @return               Always return EFI_SUCCESS.\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
+//\r
+// Declaration of status code protocol.\r
+//\r
+STATIC\r
+EFI_STATUS_CODE_PROTOCOL  mEfiStatusCodeProtocol  = {\r
+  ReportDispatcher\r
+};\r
+\r
+//\r
+// Delaration of DXE status code controller \r
+//\r
+DXE_STATUS_CODE_CONTROLLER gDxeStatusCode = {\r
+  //\r
+  // Initialize nest status as non nested. \r
+  // \r
+  0,\r
+  {NULL, NULL}\r
+};\r
+\r
+/**\r
+\r
+  Install the ReportStatusCode runtime service.\r
\r
+  @param ImageHandle     Image handle of the loaded driver\r
+  @param SystemTable     Pointer to the System Table\r
+\r
+  @return                The function always returns success.\r
+\r
+**/\r
+EFI_STATUS\r
+DxeStatusCodeDriverEntry (\r
+  IN EFI_HANDLE         ImageHandle,\r
+  IN EFI_SYSTEM_TABLE   *SystemTable\r
+  )\r
+{\r
+  EFI_HANDLE  Handle       = NULL;\r
+  EFI_STATUS  Status;\r
+\r
+  //\r
+  // Dispatch initialization request to supported devices\r
+  //\r
+  InitializationDispatcherWorker ();\r
+\r
+  //\r
+  // Install Status Code Architectural Protocol implementation as defined in Tiano\r
+  // Architecture Specification.\r
+  //\r
+  Status = gBS->InstallMultipleProtocolInterfaces (\r
+                  &Handle,\r
+                  &gEfiStatusCodeRuntimeProtocolGuid,\r
+                  &mEfiStatusCodeProtocol,\r
+                  NULL\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  return Status;\r
+}\r
+\r
+/**\r
+  Report status code to all supported device. \r
+  Calls into the workers which dispatches the platform specific\r
+  listeners. \r
+\r
+  @param  CodeType      Indicates the type of status code being reported.  \r
+                        The type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.\r
+  @param  Value         Describes the current status of a hardware or software entity.  \r
+                        This includes information about the class and subclass that is used to classify the entity \r
+                        as well as an operation.  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
+                        Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.  \r
+                        Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.\r
+  @param  Instance      The enumeration of a hardware or software entity within the system.  \r
+                        A system may contain multiple entities that match a class/subclass pairing.  \r
+                        The instance differentiates between them.  An instance of 0 indicates that instance \r
+                        information is unavailable, not meaningful, or not relevant.  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 different callers.\r
+  @param  Data          This optional parameter may be used to pass additional data.  \r
+                        Type EFI_STATUS_CODE_DATA is defined in "Related Definitions" below.  \r
+                        The contents of this data type may have additional GUID-specific data.  The standard GUIDs and \r
+                        their associated data structures are defined in the Intel? Platform Innovation Framework for EFI Status Codes Specification.\r
+\r
+  @return               Always return EFI_SUCCESS.\r
+\r
+**/\r
+EFI_STATUS \r
+EFIAPI\r
+ReportDispatcher (\r
+  IN EFI_STATUS_CODE_TYPE     CodeType,\r
+  IN EFI_STATUS_CODE_VALUE    Value,\r
+  IN UINT32                   Instance,\r
+  IN EFI_GUID                 *CallerId  OPTIONAL,\r
+  IN EFI_STATUS_CODE_DATA     *Data      OPTIONAL\r
+  )\r
+{\r
+  //\r
+  // Use atom operation to avoid the reentant of report.\r
+  // If current status is not zero, then the function is reentrancy.\r
+  //\r
+  if (1 == InterlockedCompareExchange32 (&gDxeStatusCode.StatusCodeNestStatus, 0, 1)) {\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+\r
+  if (FeaturePcdGet (PcdStatusCodeUseEfiSerial) || FeaturePcdGet (PcdStatusCodeUseHardSerial)) {\r
+    SerialStatusCodeReportWorker (\r
+      CodeType,\r
+      Value,\r
+      Instance,\r
+      CallerId,\r
+      Data\r
+      );\r
+  }\r
+  if (FeaturePcdGet (PcdStatusCodeUseRuntimeMemory)) {\r
+    RtMemoryStatusCodeReportWorker (\r
+      gDxeStatusCode.RtMemoryStatusCodeTable[PHYSICAL_MODE],\r
+      CodeType,\r
+      Value,\r
+      Instance\r
+      );\r
+  }\r
+  if (FeaturePcdGet (PcdStatusCodeUseDataHub)) {\r
+    DataHubStatusCodeReportWorker (\r
+      CodeType,\r
+      Value,\r
+      Instance,\r
+      CallerId,\r
+      Data\r
+      );\r
+  }\r
+  if (FeaturePcdGet (PcdStatusCodeUseOEM)) {\r
+    OemHookStatusCodeReport (\r
+      CodeType,\r
+      Value,\r
+      Instance,\r
+      CallerId,\r
+      Data\r
+      );\r
+  }\r
+\r
+  //\r
+  // Restore the nest status of report\r
+  //\r
+  InterlockedCompareExchange32 (&gDxeStatusCode.StatusCodeNestStatus, 1, 0);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+/**\r
+  Virtual address change notification call back. It converts global pointer \r
+  to virtual address.\r
+\r
+  @param  Event         Event whose notification function is being invoked.\r
+  @param  Context       Pointer to the notification function's context, which is\r
+                        always zero in current implementation.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+VirtualAddressChangeCallBack (\r
+  IN EFI_EVENT        Event,\r
+  IN VOID             *Context\r
+  )\r
+{\r
+  //\r
+  // Convert memory status code table to virtual address;\r
+  //\r
+  EfiConvertPointer (\r
+    0, \r
+    (VOID **) &gDxeStatusCode.RtMemoryStatusCodeTable[PHYSICAL_MODE]\r
+    );\r
+}\r
+\r
diff --git a/IntelFrameworkModulePkg/Universal/StatusCode/Dxe/Common/StatusCode.dxs b/IntelFrameworkModulePkg/Universal/StatusCode/Dxe/Common/StatusCode.dxs
new file mode 100644 (file)
index 0000000..e1c0053
--- /dev/null
@@ -0,0 +1,30 @@
+//\r
+// Include common header file for this module.\r
+//\r
+#include "CommonHeader.h"\r
+\r
+#/*++\r
+#\r
+# Copyright (c) 2006, Intel Corporation                                                         \r
+# All rights reserved. This program and the accompanying materials                          \r
+# are licensed and made available under the terms and conditions of the BSD License         \r
+# which accompanies this distribution.  The full text of the license may be found at        \r
+# http://opensource.org/licenses/bsd-license.php                                            \r
+#                                                                                           \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+# \r
+# Module Name:\r
+#\r
+#   StatusCode.dxs\r
+#\r
+# Abstract:\r
+#\r
+#   Dependency expression source file.\r
+#  \r
+#--*/  \r
+#include <DxeDepex.h>\r
+\r
+DEPENDENCY_START\r
+  EFI_DATA_HUB_PROTOCOL_GUID AND EFI_CPU_IO_PROTOCOL_GUID\r
+DEPENDENCY_END\r
diff --git a/IntelFrameworkModulePkg/Universal/StatusCode/Dxe/CommonHeader.h b/IntelFrameworkModulePkg/Universal/StatusCode/Dxe/CommonHeader.h
new file mode 100644 (file)
index 0000000..32ebf0f
--- /dev/null
@@ -0,0 +1,70 @@
+/**@file\r
+  Common header file shared by all source files.\r
+\r
+  This file includes package header files, library classes and protocol, PPI & GUID definitions.\r
+\r
+  Copyright (c) 2006, Intel Corporation.\r
+  All rights reserved. This program and the accompanying materials\r
+   are licensed and made available under the terms and conditions of the BSD License\r
+   which accompanies this distribution. The full text of the license may be found at\r
+   http://opensource.org/licenses/bsd-license.php\r
+   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
+#ifndef __COMMON_HEADER_H_\r
+#define __COMMON_HEADER_H_\r
+\r
+\r
+//\r
+// The package level header files this module uses\r
+//\r
+#include <FrameworkDxe.h>\r
+//\r
+// The protocols, PPI and GUID defintions for this module\r
+//\r
+#include <Guid/StatusCode.h>\r
+#include <Protocol/DataHub.h>\r
+#include <Protocol/SerialIo.h>\r
+#include <Guid/MemoryStatusCodeRecord.h>\r
+#include <Protocol/StatusCode.h>\r
+#include <Guid/StatusCodeDataTypeId.h>\r
+//\r
+// The Library classes this module consumes\r
+//\r
+#include <Library/BaseLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/ReportStatusCodeLib.h>\r
+#include <Library/PrintLib.h>\r
+#include <Library/PcdLib.h>\r
+#include <Library/HobLib.h>\r
+#include <Library/UefiDriverEntryPoint.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/UefiRuntimeLib.h>\r
+#include <Library/SerialPortLib.h>\r
+#include <Library/OemHookStatusCodeLib.h>\r
+\r
+//\r
+// Declaration for callback Event.\r
+//\r
+VOID\r
+EFIAPI\r
+VirtualAddressChangeCallBack (\r
+  IN EFI_EVENT  Event,\r
+  IN VOID       *Context\r
+  );\r
+\r
+//\r
+// Declaration for original Entry Point.\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+DxeStatusCodeDriverEntry (\r
+  IN EFI_HANDLE           ImageHandle,\r
+  IN EFI_SYSTEM_TABLE     *SystemTable\r
+  );\r
+\r
+#endif\r
diff --git a/IntelFrameworkModulePkg/Universal/StatusCode/Dxe/DataHubStatusCodeWorker.c b/IntelFrameworkModulePkg/Universal/StatusCode/Dxe/DataHubStatusCodeWorker.c
new file mode 100644 (file)
index 0000000..0723af5
--- /dev/null
@@ -0,0 +1,335 @@
+/** @file\r
+  Data Hub status code worker in DXE.\r
+\r
+  Copyright (c) 2006, Intel Corporation\r
+  All rights reserved. This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+  Module Name:  DataHubStatusCodeWorker.c\r
+\r
+**/\r
+//\r
+// Include common header file for this module.\r
+//\r
+#include "CommonHeader.h"\r
+\r
+#include "DxeStatusCode.h"\r
+\r
+//\r
+// Initialize FIFO to cache records.\r
+//\r
+STATIC\r
+LIST_ENTRY                mRecordsFifo          = INITIALIZE_LIST_HEAD_VARIABLE (mRecordsFifo);\r
+STATIC\r
+LIST_ENTRY                mRecordsBuffer        = INITIALIZE_LIST_HEAD_VARIABLE (mRecordsBuffer);\r
+STATIC\r
+EFI_EVENT                 mLogDataHubEvent;\r
+//\r
+// Cache data hub protocol.\r
+//\r
+STATIC\r
+EFI_DATA_HUB_PROTOCOL     *mDataHubProtocol;\r
+\r
+\r
+/**\r
+  Return one DATAHUB_STATUSCODE_RECORD space.\r
+  The size of free record pool would be extend, if the pool is empty.\r
+\r
+\r
+  @retval  NULL   Can not allocate free memeory for record.\r
+  @retval  !NULL  Point to buffer of record.\r
+\r
+**/\r
+STATIC\r
+DATAHUB_STATUSCODE_RECORD *\r
+AcquireRecordBuffer (\r
+  VOID\r
+  )\r
+{\r
+  DATAHUB_STATUSCODE_RECORD *Record;\r
+  EFI_TPL                   CurrentTpl;\r
+  LIST_ENTRY                *Node;\r
+  UINT32                    Index;\r
+\r
+  CurrentTpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);\r
+\r
+  if (!IsListEmpty (&mRecordsBuffer)) {\r
+    Node = GetFirstNode (&mRecordsBuffer);\r
+    RemoveEntryList (Node);\r
+\r
+    Record = _CR (Node, DATAHUB_STATUSCODE_RECORD, Node);\r
+  } else {\r
+    if (CurrentTpl > TPL_NOTIFY) {\r
+      gBS->RestoreTPL (CurrentTpl);\r
+      return NULL;\r
+    }\r
+\r
+    gBS->RestoreTPL (CurrentTpl);\r
+    Record   = (DATAHUB_STATUSCODE_RECORD *) AllocateZeroPool (sizeof (DATAHUB_STATUSCODE_RECORD) * 16);\r
+    if (NULL == Record) {\r
+      return NULL;\r
+    }\r
+\r
+    CurrentTpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);\r
+    for (Index = 1; Index < 16; Index++) {\r
+      InsertTailList (&mRecordsBuffer, &Record[Index].Node);\r
+    }\r
+  }\r
+\r
+  Record->Signature = DATAHUB_STATUS_CODE_SIGNATURE;\r
+  InsertTailList (&mRecordsFifo, &Record->Node);\r
+\r
+  gBS->RestoreTPL (CurrentTpl);\r
+\r
+  return Record;\r
+}\r
+\r
+\r
+/**\r
+  Retrieve one record from Records FIFO. The record would be removed from FIFO and\r
+  release to free record buffer.\r
+\r
+  @return   !NULL   Point to record, which is ready to be logged.\r
+  @return   NULL    the FIFO of record is empty.\r
+\r
+**/\r
+STATIC\r
+DATAHUB_STATUSCODE_RECORD *\r
+RetrieveRecord (\r
+  VOID\r
+  )\r
+{\r
+  DATAHUB_STATUSCODE_RECORD   *Record = NULL;\r
+  LIST_ENTRY                  *Node;\r
+  EFI_TPL                     CurrentTpl;\r
+\r
+  CurrentTpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);\r
+\r
+  if (!IsListEmpty (&mRecordsFifo)) {\r
+    Node = GetFirstNode (&mRecordsFifo);\r
+    Record = CR (Node, DATAHUB_STATUSCODE_RECORD, Node, DATAHUB_STATUS_CODE_SIGNATURE);\r
+\r
+    RemoveEntryList (&Record->Node);\r
+    InsertTailList (&mRecordsBuffer, &Record->Node);\r
+    Record->Signature = 0;\r
+  }\r
+\r
+  gBS->RestoreTPL (CurrentTpl);\r
+\r
+  return Record;\r
+}\r
+\r
+\r
+/**\r
+  Report status code into DataHub.\r
+\r
+  @param  CodeType      Indicates the type of status code being reported.  Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.\r
+\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 classify the entity\r
+                        as well as an operation.  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
+                        Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.\r
+                        Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.\r
+\r
+  @param  Instance      The enumeration of a hardware or software entity within the system.\r
+                        A system may contain multiple entities that match a class/subclass pairing.\r
+                        The instance differentiates between them.  An instance of 0 indicates that instance information is unavailable,\r
+                        not meaningful, or not relevant.  Valid instance numbers start with 1.\r
+\r
+\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 different callers.\r
+                        Type EFI_GUID is defined in InstallProtocolInterface() in the EFI 1.10 Specification.\r
+\r
+\r
+  @param  Data          This optional parameter may be used to pass additional data\r
+\r
+  @retval EFI_OUT_OF_RESOURCES   Can not acquire record buffer.\r
+  @retval EFI_DEVICE_ERROR       EFI serial device can not work after ExitBootService() is called .\r
+  @retval EFI_SUCCESS            Success to cache status code and signal log data event.\r
+\r
+**/\r
+EFI_STATUS\r
+DataHubStatusCodeReportWorker (\r
+  IN EFI_STATUS_CODE_TYPE     CodeType,\r
+  IN EFI_STATUS_CODE_VALUE    Value,\r
+  IN UINT32                   Instance,\r
+  IN EFI_GUID                 *CallerId,\r
+  IN EFI_STATUS_CODE_DATA     *Data OPTIONAL\r
+  )\r
+{\r
+  DATAHUB_STATUSCODE_RECORD  *Record;\r
+  UINT32                     ErrorLevel;\r
+  VA_LIST                    Marker;\r
+  CHAR8                      *Format;\r
+  UINTN                      CharCount;\r
+\r
+  //\r
+  // See whether in runtime phase or not.\r
+  //\r
+  if (EfiAtRuntime ()) {\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+\r
+  Record = AcquireRecordBuffer ();\r
+  if (Record == NULL) {\r
+    //\r
+    // There are no empty record buffer in private buffers\r
+    //\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+  //\r
+  // Construct Data Hub Extended Data\r
+  //\r
+  Record->CodeType = CodeType;\r
+  Record->Value    = Value;\r
+  Record->Instance = Instance;\r
+\r
+  if (CallerId != NULL) {\r
+    CopyMem (&Record->CallerId, CallerId, sizeof (EFI_GUID));\r
+  }\r
+\r
+  if (Data != NULL) {\r
+    if (ReportStatusCodeExtractDebugInfo (Data, &ErrorLevel, &Marker, &Format)) {\r
+      CharCount = UnicodeVSPrintAsciiFormat (\r
+                    (CHAR16 *) Record->ExtendData,\r
+                    EFI_STATUS_CODE_DATA_MAX_SIZE,\r
+                    Format,\r
+                    Marker\r
+                    );\r
+      //\r
+      // Change record data type from DebugType to String Type.\r
+      //\r
+      CopyGuid (&Record->Data.Type, &gEfiStatusCodeDataTypeStringGuid);\r
+      Record->Data.HeaderSize = Data->HeaderSize;\r
+      Record->Data.Size = (UINT16) ((CharCount + 1) * sizeof (CHAR16));\r
+    } else {\r
+      //\r
+      // Copy status code data header\r
+      //\r
+      CopyMem (&Record->Data, Data, sizeof (EFI_STATUS_CODE_DATA));\r
+\r
+      if (Data->Size > EFI_STATUS_CODE_DATA_MAX_SIZE) {\r
+        Record->Data.Size = EFI_STATUS_CODE_DATA_MAX_SIZE;\r
+      }\r
+      CopyMem (Record->ExtendData, Data + 1, Record->Data.Size);\r
+    }\r
+  }\r
+\r
+  gBS->SignalEvent (mLogDataHubEvent);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+/**\r
+  The Event handler which will be notified to log data in Data Hub.\r
+\r
+  @param  Event       Instance of the EFI_EVENT to signal whenever data is\r
+                      available to be logged in the system.\r
+  @param  Context     Context of the event.\r
+\r
+**/\r
+STATIC\r
+VOID\r
+EFIAPI\r
+LogDataHubEventCallBack (\r
+  IN  EFI_EVENT     Event,\r
+  IN  VOID          *Context\r
+  )\r
+{\r
+  DATAHUB_STATUSCODE_RECORD         *Record;\r
+  UINT32                            Size;\r
+  UINT64                            DataRecordClass;\r
+\r
+  //\r
+  // Log DataRecord in Data Hub.\r
+  // Journal records fifo to find all record entry.\r
+  //\r
+  while (1) {\r
+    Record = RetrieveRecord ();\r
+    if (Record == NULL) {\r
+      break;\r
+    }\r
+    //\r
+    // Add in the size of the header we added.\r
+    //\r
+    Size = sizeof (DATAHUB_STATUSCODE_RECORD) + (UINT32) Record->Data.Size;\r
+\r
+    if ((Record->CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) {\r
+      DataRecordClass = EFI_DATA_RECORD_CLASS_PROGRESS_CODE;\r
+    } else if ((Record->CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) {\r
+      DataRecordClass = EFI_DATA_RECORD_CLASS_ERROR;\r
+    } else if ((Record->CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) {\r
+      DataRecordClass = EFI_DATA_RECORD_CLASS_DEBUG;\r
+    } else {\r
+      //\r
+      // Should never get here.\r
+      //\r
+      DataRecordClass = EFI_DATA_RECORD_CLASS_DEBUG |\r
+        EFI_DATA_RECORD_CLASS_ERROR |\r
+        EFI_DATA_RECORD_CLASS_DATA |\r
+        EFI_DATA_RECORD_CLASS_PROGRESS_CODE;\r
+    }\r
+\r
+    //\r
+    // Log DataRecord in Data Hub\r
+    //\r
+\r
+    mDataHubProtocol->LogData (\r
+                        mDataHubProtocol,\r
+                        &gEfiStatusCodeGuid,\r
+                        &gEfiStatusCodeRuntimeProtocolGuid,\r
+                        DataRecordClass,\r
+                        Record,\r
+                        Size\r
+                        );\r
+\r
+  }\r
+}\r
+\r
+\r
+/**\r
+  Initialize data hubstatus code.\r
+  Create a data hub listener.\r
+\r
+  @return  The function always return EFI_SUCCESS\r
+\r
+**/\r
+EFI_STATUS\r
+DataHubStatusCodeInitializeWorker (\r
+  VOID\r
+  )\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  Status = gBS->LocateProtocol (\r
+                  &gEfiDataHubProtocolGuid, \r
+                  NULL, \r
+                  (VOID **) &mDataHubProtocol\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  //\r
+  // Create a Notify Event to log data in Data Hub\r
+  //\r
+  Status = gBS->CreateEvent (\r
+                  EVT_NOTIFY_SIGNAL,\r
+                  TPL_CALLBACK,\r
+                  LogDataHubEventCallBack,\r
+                  NULL,\r
+                  &mLogDataHubEvent\r
+                  );\r
+\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
diff --git a/IntelFrameworkModulePkg/Universal/StatusCode/Dxe/DxeStatusCode.c b/IntelFrameworkModulePkg/Universal/StatusCode/Dxe/DxeStatusCode.c
new file mode 100644 (file)
index 0000000..ec7ea8b
--- /dev/null
@@ -0,0 +1,160 @@
+/** @file\r
+  Status Code Architectural Protocol implementation as defined in Tiano\r
+  Architecture Specification.\r
+\r
+  This driver has limited functionality at runtime and will not log to Data Hub\r
+  at runtime.\r
+\r
+  Notes:\r
+  This driver assumes the following ReportStatusCode strategy:\r
+  PEI       -> uses PeiReportStatusCode\r
+  DXE IPL   -> uses PeiReportStatusCode\r
+  early DXE -> uses PeiReportStatusCode via HOB\r
+  DXE       -> This driver\r
+  RT        -> This driver\r
+\r
+  Copyright (c) 2006, 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
+  Module Name:  DxeStatusCode.c\r
+\r
+**/\r
+\r
+//\r
+// Include common header file for this module.\r
+//\r
+#include "CommonHeader.h"\r
+\r
+#include "DxeStatusCode.h"\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 = 0;\r
+  UINTN                             Index;\r
+  VOID                              *HobStart;\r
+\r
+  //\r
+  // If enable UseSerial, then initialize serial port.\r
+  // if enable UseRuntimeMemory, then initialize runtime memory status code worker.\r
+  // if enable UseDataHub, then initialize data hub status code worker.\r
+  //\r
+  if (FeaturePcdGet (PcdStatusCodeUseEfiSerial)) {\r
+    Status = EfiSerialStatusCodeInitializeWorker ();\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
+  if (FeaturePcdGet (PcdStatusCodeUseHardSerial)) {\r
+    Status = SerialPortInitialize ();\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
+  if (FeaturePcdGet (PcdStatusCodeUseRuntimeMemory)) {\r
+    Status = RtMemoryStatusCodeInitializeWorker ();\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
+  if (FeaturePcdGet (PcdStatusCodeUseDataHub)) {\r
+    Status = DataHubStatusCodeInitializeWorker ();\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
+  if (FeaturePcdGet (PcdStatusCodeUseOEM)) {\r
+    Status = OemHookStatusCodeInitialize ();\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
+\r
+  //\r
+  // Replay Status code which saved in GUID'ed HOB to all supported device. \r
+  //\r
+\r
+  // \r
+  // Journal GUID'ed HOBs to find all record entry, if found, \r
+  // then output record to support replay device.\r
+  //\r
+  Hob.Raw   = GetFirstGuidHob (&gMemoryStatusCodeRecordGuid);\r
+  HobStart  = Hob.Raw;\r
+  while (Hob.Raw != NULL) {\r
+    PacketHeader = (MEMORY_STATUSCODE_PACKET_HEADER *) GET_GUID_HOB_DATA (Hob.Guid);\r
+    if (PacketHeader->PacketIndex == ExpectedPacketIndex) {\r
+      Record = (MEMORY_STATUSCODE_RECORD *) (PacketHeader + 1);\r
+      for (Index = 0; Index < PacketHeader->RecordIndex; Index++) {\r
+        //\r
+        // Dispatch records to devices based on feature flag.\r
+        //\r
+        if (FeaturePcdGet (PcdStatusCodeReplayInSerial) && \r
+            (FeaturePcdGet (PcdStatusCodeUseHardSerial) ||\r
+             FeaturePcdGet (PcdStatusCodeUseEfiSerial))) {\r
+          SerialStatusCodeReportWorker (\r
+            Record[Index].CodeType,\r
+            Record[Index].Value,\r
+            Record[Index].Instance,\r
+            NULL,\r
+            NULL\r
+            );\r
+        }\r
+        if (FeaturePcdGet (PcdStatusCodeReplayInRuntimeMemory) &&\r
+            FeaturePcdGet (PcdStatusCodeUseRuntimeMemory)) {\r
+          RtMemoryStatusCodeReportWorker (\r
+            gDxeStatusCode.RtMemoryStatusCodeTable[PHYSICAL_MODE],\r
+            Record[Index].CodeType,\r
+            Record[Index].Value,\r
+            Record[Index].Instance\r
+            );\r
+        }\r
+        if (FeaturePcdGet (PcdStatusCodeReplayInDataHub) &&\r
+            FeaturePcdGet (PcdStatusCodeUseDataHub)) {\r
+          DataHubStatusCodeReportWorker (\r
+            Record[Index].CodeType,\r
+            Record[Index].Value,\r
+            Record[Index].Instance,\r
+            NULL,\r
+            NULL\r
+            );\r
+        }\r
+        if (FeaturePcdGet (PcdStatusCodeReplayInOEM) &&\r
+            FeaturePcdGet (PcdStatusCodeUseOEM)) {\r
+          OemHookStatusCodeReport (\r
+            Record[Index].CodeType,\r
+            Record[Index].Value,\r
+            Record[Index].Instance,\r
+            NULL,\r
+            NULL\r
+            );\r
+        }\r
+      }\r
+      ExpectedPacketIndex++;\r
+\r
+      //\r
+      // See whether there is gap of packet or not\r
+      //\r
+      if (NULL != HobStart) {\r
+        HobStart  = NULL;\r
+        Hob.Raw   = HobStart;\r
+        continue;\r
+      }\r
+    } else if (HobStart != NULL) {\r
+      //\r
+      // Cache the found packet for improve the performance\r
+      //\r
+      HobStart = Hob.Raw;\r
+    }\r
+\r
+    Hob.Raw = GetNextGuidHob (&gMemoryStatusCodeRecordGuid, Hob.Raw);\r
+  }\r
+}\r
+\r
diff --git a/IntelFrameworkModulePkg/Universal/StatusCode/Dxe/DxeStatusCode.h b/IntelFrameworkModulePkg/Universal/StatusCode/Dxe/DxeStatusCode.h
new file mode 100644 (file)
index 0000000..596c173
--- /dev/null
@@ -0,0 +1,245 @@
+/*++\r
+\r
+  Copyright (c) 2006, Intel Corporation                                                         \r
+  All rights reserved. This program and the accompanying materials                          \r
+  are licensed and made available under the terms and conditions of the BSD License         \r
+  which accompanies this distribution.  The full text of the license may be found at        \r
+  http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                            \r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  DxeStatusCode.h\r
+\r
+Abstract:\r
+\r
+  Header file of EFI DXE/RT Status Code.\r
+\r
+--*/\r
+\r
+#ifndef __DXE_STATUS_CODE_H__\r
+#define __DXE_STATUS_CODE_H__\r
+\r
+//\r
+// Include common header file for this module.\r
+//\r
+#include "CommonHeader.h"\r
+\r
+//\r
+// Data hub worker definition \r
+//\r
+#define MAX_NUMBER_DATAHUB_RECORDS                1000\r
+#define DATAHUB_BYTES_PER_RECORD                  EFI_STATUS_CODE_DATA_MAX_SIZE\r
+#define EMPTY_RECORD_TAG                          0xFF\r
+#define DATAHUB_STATUS_CODE_SIGNATURE             EFI_SIGNATURE_32 ('B', 'D', 'H', 'S')\r
+\r
+//\r
+// Address type of pointer.\r
+// The point type always equal to PHYSICAL_MODE on IA32/X64/EBC architecture\r
+// Otherwise, VIRTUAL_MODE/PHYSICAL_MODE would be used on Ipf architecture, \r
+// \r
+typedef enum {\r
+  PHYSICAL_MODE,\r
+  VIRTUAL_MODE\r
+} PROCESSOR_MODE;\r
+\r
+typedef struct {\r
+  UINTN                     Signature;\r
+  LIST_ENTRY                Node;\r
+  EFI_STATUS_CODE_TYPE      CodeType;\r
+  EFI_STATUS_CODE_VALUE     Value;\r
+  UINT32                    Instance;\r
+  EFI_GUID                  CallerId;\r
+  EFI_STATUS_CODE_DATA      Data;\r
+  UINT8                     ExtendData[EFI_STATUS_CODE_DATA_MAX_SIZE];\r
+} DATAHUB_STATUSCODE_RECORD;\r
+\r
+\r
+//\r
+// Runtime memory status code worker definition \r
+// \r
+typedef struct {\r
+  UINT32   RecordIndex;\r
+  UINT32   NumberOfRecords;\r
+  UINT32   MaxRecordsNumber;\r
+} RUNTIME_MEMORY_STATUSCODE_HEADER;\r
+\r
+\r
+typedef struct {\r
+  //\r
+  // Report operation nest status. \r
+  // If it is set, then the report operation has nested.\r
+  // \r
+  UINT32                            StatusCodeNestStatus;\r
+  //\r
+  // Runtime status code management header, the records buffer is following it.\r
+  // \r
+  RUNTIME_MEMORY_STATUSCODE_HEADER  *RtMemoryStatusCodeTable[2];\r
+} DXE_STATUS_CODE_CONTROLLER;\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
+\r
+/**\r
+  Initialize serial status code worker.\r
\r
+  @return  The function always return EFI_SUCCESS\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.  Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.\r
\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 classify the entity \r
+                        as well as an operation.  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
+                        Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.  \r
+                        Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.\r
\r
+  @param  Instance      The enumeration of a hardware or software entity within the system.  \r
+                        A system may contain multiple entities that match a class/subclass pairing. \r
+                        The instance differentiates between them.  An instance of 0 indicates that instance information is unavailable, \r
+                        not meaningful, or not relevant.  Valid instance numbers start with 1.\r
+\r
+\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 different callers. \r
+                        Type EFI_GUID is defined in InstallProtocolInterface() in the EFI 1.10 Specification.\r
+\r
+\r
+  @param  Data          This optional parameter may be used to pass additional data\r
\r
+  @retval EFI_SUCCESS         Success to report status code to serial I/O.\r
+  @retval EFI_DEVICE_ERROR    EFI serial device can not work after ExitBootService() is called .\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.\r
\r
+  @return  The function always return EFI_SUCCESS\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  RtMemoryStatusCodeTable      \r
+                        Point to Runtime memory table header.\r
+\r
+  @param  CodeType      Indicates the type of status code being reported.  Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.\r
\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 classify the entity \r
+                        as well as an operation.  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
+                        Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.  \r
+                        Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.\r
\r
+  @param  Instance      The enumeration of a hardware or software entity within the system.  \r
+                        A system may contain multiple entities that match a class/subclass pairing. \r
+                        The instance differentiates between them.  An instance of 0 indicates that instance information is unavailable, \r
+                        not meaningful, or not relevant.  Valid instance numbers start with 1.\r
\r
+  @return               The function always return EFI_SUCCESS.\r
+\r
+**/\r
+EFI_STATUS\r
+RtMemoryStatusCodeReportWorker (\r
+  RUNTIME_MEMORY_STATUSCODE_HEADER      *RtMemoryStatusCodeTable,\r
+  IN EFI_STATUS_CODE_TYPE               CodeType,\r
+  IN EFI_STATUS_CODE_VALUE              Value,\r
+  IN UINT32                             Instance\r
+  );\r
+\r
+/**\r
+  Initialize data hubstatus code.\r
+  Create a data hub listener.\r
\r
+  @return  The function always return EFI_SUCCESS\r
+\r
+**/\r
+EFI_STATUS\r
+DataHubStatusCodeInitializeWorker (\r
+  VOID\r
+  );\r
+\r
+\r
+/**\r
+  Report status code into DataHub.\r
\r
+  @param  CodeType      Indicates the type of status code being reported.  Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.\r
\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 classify the entity \r
+                        as well as an operation.  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
+                        Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.  \r
+                        Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.\r
\r
+  @param  Instance      The enumeration of a hardware or software entity within the system.  \r
+                        A system may contain multiple entities that match a class/subclass pairing. \r
+                        The instance differentiates between them.  An instance of 0 indicates that instance information is unavailable, \r
+                        not meaningful, or not relevant.  Valid instance numbers start with 1.\r
+\r
+\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 different callers. \r
+                        Type EFI_GUID is defined in InstallProtocolInterface() in the EFI 1.10 Specification.\r
+\r
+\r
+  @param  Data          This optional parameter may be used to pass additional data\r
\r
+  @retval EFI_OUT_OF_RESOURCES   Can not acquire record buffer.\r
+  @retval EFI_DEVICE_ERROR       EFI serial device can not work after ExitBootService() is called .\r
+  @retval EFI_SUCCESS            Success to cache status code and signal log data event.\r
+\r
+**/\r
+EFI_STATUS\r
+DataHubStatusCodeReportWorker (\r
+  IN EFI_STATUS_CODE_TYPE     CodeType,\r
+  IN EFI_STATUS_CODE_VALUE    Value,\r
+  IN UINT32                   Instance,\r
+  IN EFI_GUID                 *CallerId,\r
+  IN EFI_STATUS_CODE_DATA     *Data OPTIONAL\r
+  );\r
+\r
+//\r
+// declaration of DXE status code controller.\r
+// \r
+extern DXE_STATUS_CODE_CONTROLLER gDxeStatusCode;\r
+\r
+#endif\r
diff --git a/IntelFrameworkModulePkg/Universal/StatusCode/Dxe/DxeStatusCode.inf b/IntelFrameworkModulePkg/Universal/StatusCode/Dxe/DxeStatusCode.inf
new file mode 100644 (file)
index 0000000..6470814
--- /dev/null
@@ -0,0 +1,170 @@
+#/** @file\r
+# DXE status code driver.\r
+#\r
+# Status Code Architectural Protocol implementation as defined in Tiano\r
+#  Architecture Specification. This driver has limited functionality\r
+#  at runtime and will not log to Data Hub at runtime.\r
+# Copyright (c) 2006, 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
+################################################################################\r
+#\r
+# Defines Section - statements that will be processed to create a Makefile.\r
+#\r
+################################################################################\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = DxeStatusCode\r
+  FILE_GUID                      = FEDE0A1B-BCA2-4A9F-BB2B-D9FD7DEC2E9F\r
+  MODULE_TYPE                    = DXE_RUNTIME_DRIVER\r
+  VERSION_STRING                 = 1.0\r
+  EDK_RELEASE_VERSION            = 0x00020000\r
+  EFI_SPECIFICATION_VERSION      = 0x00020000\r
+\r
+  ENTRY_POINT                    = InitializeDxeStatusCode\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 EBC\r
+#\r
+#  VIRTUAL_ADDRESS_MAP_CALLBACK  =  VirtualAddressChangeCallBack\r
+#\r
+\r
+################################################################################\r
+#\r
+# Sources Section - list of files that are required for the build to succeed.\r
+#\r
+################################################################################\r
+\r
+[Sources.common]\r
+  SerialStatusCodeWorker.c\r
+  RtMemoryStatusCodeWorker.c\r
+  DataHubStatusCodeWorker.c\r
+  DxeStatusCode.c\r
+  DxeStatusCode.h\r
+  CommonHeader.h\r
+  EntryPoint.c\r
+\r
+[Sources.Ia32]\r
+  Common/StatusCode.dxs\r
+  Common/DxeStatusCodeCommon.c\r
+\r
+[Sources.X64]\r
+  Common/StatusCode.dxs\r
+  Common/DxeStatusCodeCommon.c\r
+\r
+[Sources.EBC]\r
+  Common/StatusCode.dxs\r
+  Common/DxeStatusCodeCommon.c\r
+\r
+\r
+################################################################################\r
+#\r
+# Includes Section - list of Include locations that are required for\r
+#                    this module.\r
+#\r
+################################################################################\r
+\r
+[Includes]\r
+  $(WORKSPACE)/MdePkg/Include/Library\r
+  $(WORKSPACE)/IntelFrameworkModulePkg/Include\r
+  $(WORKSPACE)/IntelFrameworkModulePkg/Include/Library\r
+\r
+################################################################################\r
+#\r
+# Package Dependency Section - list of Package files that are required for\r
+#                              this module.\r
+#\r
+################################################################################\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  IntelFrameworkPkg/IntelFrameworkPkg.dec\r
+  IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec\r
+\r
+################################################################################\r
+#\r
+# Library Class Section - list of Library Classes that are required for\r
+#                         this module.\r
+#\r
+################################################################################\r
+\r
+[LibraryClasses]\r
+  OemHookStatusCodeLib\r
+  SerialPortLib\r
+  UefiRuntimeLib\r
+  MemoryAllocationLib\r
+  UefiLib\r
+  UefiBootServicesTableLib\r
+  UefiDriverEntryPoint\r
+  HobLib\r
+  PcdLib\r
+  PrintLib\r
+  ReportStatusCodeLib\r
+  DebugLib\r
+  BaseMemoryLib\r
+  BaseLib\r
+\r
+\r
+################################################################################\r
+#\r
+# Guid C Name Section - list of Guids that this module uses or produces.\r
+#\r
+################################################################################\r
+\r
+[Guids]\r
+  gEfiStatusCodeGuid                            # SOMETIMES_CONSUMED\r
+  gMemoryStatusCodeRecordGuid                   # SOMETIMES_CONSUMED\r
+  gEfiStatusCodeDataTypeStringGuid              # SOMETIMES_CONSUMED\r
+  gEfiStatusCodeSpecificDataGuid                # SOMETIMES_CONSUMED\r
+\r
+################################################################################\r
+#\r
+# Protocol C Name Section - list of Protocol and Protocol Notify C Names\r
+#                           that this module uses or produces.\r
+#\r
+################################################################################\r
+\r
+[Protocols]\r
+  gEfiStatusCodeRuntimeProtocolGuid             # PROTOCOL ALWAYS_CONSUMED\r
+  gEfiDataHubProtocolGuid                       # PROTOCOL ALWAYS_CONSUMED\r
+  gEfiSerialIoProtocolGuid                      # PROTOCOL ALWAYS_CONSUMED\r
+\r
+\r
+################################################################################\r
+#\r
+# Pcd FEATURE_FLAG - list of PCDs that this module is coded for.\r
+#\r
+################################################################################\r
+\r
+[PcdsFeatureFlag.common]\r
+  PcdStatusCodeReplayInOEM|gEfiIntelFrameworkModulePkgTokenSpaceGuid\r
+  PcdStatusCodeReplayInRuntimeMemory|gEfiIntelFrameworkModulePkgTokenSpaceGuid\r
+  PcdStatusCodeReplayInDataHub|gEfiIntelFrameworkModulePkgTokenSpaceGuid\r
+  PcdStatusCodeReplayInSerial|gEfiIntelFrameworkModulePkgTokenSpaceGuid\r
+  PcdStatusCodeUseOEM|gEfiIntelFrameworkModulePkgTokenSpaceGuid\r
+  PcdStatusCodeUseDataHub|gEfiIntelFrameworkModulePkgTokenSpaceGuid\r
+  PcdStatusCodeUseRuntimeMemory|gEfiIntelFrameworkModulePkgTokenSpaceGuid\r
+  PcdStatusCodeUseEfiSerial|gEfiIntelFrameworkModulePkgTokenSpaceGuid\r
+  PcdStatusCodeUseHardSerial|gEfiIntelFrameworkModulePkgTokenSpaceGuid\r
+\r
+\r
+################################################################################\r
+#\r
+# Pcd DYNAMIC - list of PCDs that this module is coded for.\r
+#\r
+################################################################################\r
+\r
+[PcdsDynamic.common]\r
+  PcdStatusCodeRuntimeMemorySize|gEfiIntelFrameworkModulePkgTokenSpaceGuid\r
+\r
diff --git a/IntelFrameworkModulePkg/Universal/StatusCode/Dxe/DxeStatusCode.msa b/IntelFrameworkModulePkg/Universal/StatusCode/Dxe/DxeStatusCode.msa
new file mode 100644 (file)
index 0000000..5935bdd
--- /dev/null
@@ -0,0 +1,184 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0  http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd" xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\r
+  <MsaHeader>\r
+    <ModuleName>DxeStatusCode</ModuleName>\r
+    <ModuleType>DXE_RUNTIME_DRIVER</ModuleType>\r
+    <GuidValue>FEDE0A1B-BCA2-4A9F-BB2B-D9FD7DEC2E9F</GuidValue>\r
+    <Version>1.0</Version>\r
+    <Abstract>DXE status code driver.</Abstract>\r
+    <Description>\r
+      Status Code Architectural Protocol implementation as defined in Tiano\r
+      Architecture Specification. This driver has limited functionality \r
+      at runtime and will not log to Data Hub at runtime.\r
+    </Description>\r
+    <Copyright>Copyright (c) 2006, Intel Corporation.</Copyright>\r
+    <License>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.</License>\r
+    <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION   0x00000052</Specification>\r
+  </MsaHeader>\r
+  <ModuleDefinitions>\r
+    <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>\r
+    <BinaryModule>false</BinaryModule>\r
+    <OutputFileBasename>DxeStatusCode</OutputFileBasename>\r
+  </ModuleDefinitions>\r
+  <LibraryClassDefinitions>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>BaseLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>BaseMemoryLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>DebugLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>ReportStatusCodeLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>PrintLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>PcdLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>HobLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiDriverEntryPoint</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiBootServicesTableLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>MemoryAllocationLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiRuntimeLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>SerialPortLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>OemHookStatusCodeLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED" SupArchList="IPF">\r
+      <Keyword>EdkDxeSalLib</Keyword>\r
+    </LibraryClass>\r
+  </LibraryClassDefinitions>\r
+  <SourceFiles>\r
+    <Filename>DxeStatusCode.h</Filename>\r
+    <Filename>DxeStatusCode.c</Filename>\r
+    <Filename>DataHubStatusCodeWorker.c</Filename>\r
+    <Filename>RtMemoryStatusCodeWorker.c</Filename>\r
+    <Filename>SerialStatusCodeWorker.c</Filename>\r
+    <Filename SupArchList="IA32">Common/DxeStatusCodeCommon.c</Filename>\r
+    <Filename SupArchList="IA32">Common/StatusCode.dxs</Filename>\r
+    <Filename SupArchList="X64">Common/DxeStatusCodeCommon.c</Filename>\r
+    <Filename SupArchList="X64">Common/StatusCode.dxs</Filename>\r
+    <Filename SupArchList="EBC">Common/DxeStatusCodeCommon.c</Filename>\r
+    <Filename SupArchList="EBC">Common/StatusCode.dxs</Filename>\r
+    <Filename SupArchList="IPF">Ipf/DxeStatusCodeIpf.c</Filename>\r
+    <Filename SupArchList="IPF">Ipf/StatusCode.dxs</Filename>\r
+  </SourceFiles>\r
+  <PackageDependencies>\r
+    <Package PackageGuid="5E0E9358-46B6-4AE2-8218-4AB8B9BBDCEC"/>\r
+    <Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>\r
+  </PackageDependencies>\r
+  <Protocols>\r
+    <Protocol Usage="ALWAYS_CONSUMED">\r
+      <ProtocolCName>gEfiExtendedSalStatusCodeServicesProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+    <Protocol Usage="ALWAYS_CONSUMED">\r
+      <ProtocolCName>gEfiSerialIoProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+    <Protocol Usage="ALWAYS_CONSUMED">\r
+      <ProtocolCName>gEfiDataHubProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+    <Protocol Usage="ALWAYS_CONSUMED">\r
+      <ProtocolCName>gEfiStatusCodeRuntimeProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+  </Protocols>\r
+  <Guids> \r
+    <GuidCNames Usage="SOMETIMES_CONSUMED">\r
+      <GuidCName>gMemoryStatusCodeRecordGuid</GuidCName>\r
+    </GuidCNames>\r
+    <GuidCNames Usage="SOMETIMES_CONSUMED">\r
+      <GuidCName>gEfiStatusCodeDataTypeStringGuid</GuidCName>\r
+    </GuidCNames>\r
+    <GuidCNames Usage="SOMETIMES_CONSUMED">\r
+      <GuidCName>gEfiStatusCodeSpecificDataGuid</GuidCName>\r
+    </GuidCNames>\r
+    <GuidCNames Usage="SOMETIMES_CONSUMED">\r
+      <GuidCName>gEfiStatusCodeGuid</GuidCName>\r
+    </GuidCNames>\r
+  </Guids>\r
+  <Externs>\r
+    <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
+    <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
+    <Extern>\r
+      <ModuleEntryPoint>DxeStatusCodeDriverEntry</ModuleEntryPoint>\r
+    </Extern>\r
+    <Extern>\r
+      <SetVirtualAddressMapCallBack>VirtualAddressChangeCallBack</SetVirtualAddressMapCallBack>\r
+    </Extern>\r
+  </Externs>\r
+  <PcdCoded>\r
+    <PcdEntry PcdItemType="FEATURE_FLAG">\r
+      <C_Name>PcdStatusCodeUseHardSerial</C_Name>\r
+      <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>\r
+      <HelpText/>\r
+    </PcdEntry>\r
+    <PcdEntry PcdItemType="FEATURE_FLAG">\r
+      <C_Name>PcdStatusCodeUseEfiSerial</C_Name>\r
+      <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>\r
+      <HelpText/>\r
+    </PcdEntry>\r
+    <PcdEntry PcdItemType="FEATURE_FLAG">\r
+      <C_Name>PcdStatusCodeUseRuntimeMemory</C_Name>\r
+      <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>\r
+      <HelpText/>\r
+    </PcdEntry>\r
+    <PcdEntry PcdItemType="FEATURE_FLAG">\r
+      <C_Name>PcdStatusCodeUseDataHub</C_Name>\r
+      <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>\r
+      <HelpText/>\r
+    </PcdEntry>\r
+    <PcdEntry PcdItemType="FEATURE_FLAG">\r
+      <C_Name>PcdStatusCodeUseOEM</C_Name>\r
+      <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>\r
+      <HelpText/>\r
+    </PcdEntry>\r
+    <PcdEntry PcdItemType="FEATURE_FLAG">\r
+      <C_Name>PcdStatusCodeReplayInSerial</C_Name>\r
+      <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>\r
+      <HelpText/>\r
+    </PcdEntry>\r
+    <PcdEntry PcdItemType="FEATURE_FLAG">\r
+      <C_Name>PcdStatusCodeReplayInDataHub</C_Name>\r
+      <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>\r
+      <HelpText/>\r
+    </PcdEntry>\r
+    <PcdEntry PcdItemType="FEATURE_FLAG">\r
+      <C_Name>PcdStatusCodeReplayInRuntimeMemory</C_Name>\r
+      <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>\r
+      <HelpText/>\r
+    </PcdEntry>\r
+    <PcdEntry PcdItemType="FEATURE_FLAG">\r
+      <C_Name>PcdStatusCodeReplayInOEM</C_Name>\r
+      <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>\r
+      <HelpText/>\r
+    </PcdEntry>\r
+    <PcdEntry PcdItemType="DYNAMIC">\r
+      <C_Name>PcdStatusCodeRuntimeMemorySize</C_Name>\r
+      <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>\r
+      <HelpText/>\r
+    </PcdEntry>\r
+  </PcdCoded>\r
+</ModuleSurfaceArea>
\ No newline at end of file
diff --git a/IntelFrameworkModulePkg/Universal/StatusCode/Dxe/EntryPoint.c b/IntelFrameworkModulePkg/Universal/StatusCode/Dxe/EntryPoint.c
new file mode 100644 (file)
index 0000000..46450f3
--- /dev/null
@@ -0,0 +1,59 @@
+/**@file\r
+  Entry Point Source file.\r
+\r
+  This file contains the user entry point\r
+\r
+  Copyright (c) 2006, Intel Corporation.\r
+  All rights reserved. This program and the accompanying materials\r
+   are licensed and made available under the terms and conditions of the BSD License\r
+   which accompanies this distribution. The full text of the license may be found at\r
+   http://opensource.org/licenses/bsd-license.php\r
+   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 common header file for this module.\r
+//\r
+#include "CommonHeader.h"\r
+\r
+//\r
+// Event for Exit Boot Services Callback\r
+//\r
+STATIC EFI_EVENT mExitBootServicesEvent = NULL;\r
+\r
+/**\r
+  The user Entry Point for module DxeStatusCode. The user code starts with this function.\r
+\r
+  @param[in] ImageHandle    The firmware allocated handle for the EFI image.\r
+  @param[in] SystemTable    A pointer to the EFI System Table.\r
+\r
+  @retval EFI_SUCCESS       The entry point is executed successfully.\r
+  @retval other             Some error occurs when executing this entry point.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+InitializeDxeStatusCode(\r
+  IN EFI_HANDLE           ImageHandle,\r
+  IN EFI_SYSTEM_TABLE     *SystemTable\r
+  )\r
+{\r
+  EFI_STATUS              Status;\r
+\r
+  Status = gBS->CreateEvent (\r
+                  EVT_SIGNAL_EXIT_BOOT_SERVICES,\r
+                  TPL_NOTIFY,\r
+                  VirtualAddressChangeCallBack,\r
+                  NULL,\r
+                  &mExitBootServicesEvent\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  //\r
+  // Call the original Entry Point\r
+  //\r
+  Status = DxeStatusCodeDriverEntry (ImageHandle, SystemTable);\r
+\r
+  return Status;\r
+}\r
diff --git a/IntelFrameworkModulePkg/Universal/StatusCode/Dxe/RtMemoryStatusCodeWorker.c b/IntelFrameworkModulePkg/Universal/StatusCode/Dxe/RtMemoryStatusCodeWorker.c
new file mode 100644 (file)
index 0000000..db0f103
--- /dev/null
@@ -0,0 +1,125 @@
+/** @file\r
+  Runtime memory status code worker in DXE.\r
+\r
+  Copyright (c) 2006, Intel Corporation                                                         \r
+  All rights reserved. This program and the accompanying materials                          \r
+  are licensed and made available under the terms and conditions of the BSD License         \r
+  which accompanies this distribution.  The full text of the license may be found at        \r
+  http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                            \r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+  Module Name:  RtMemoryStatusCodeWorker.c\r
+\r
+**/\r
+\r
+//\r
+// Include common header file for this module.\r
+//\r
+#include "CommonHeader.h"\r
+\r
+#include "DxeStatusCode.h"\r
+\r
+/**\r
+  Initialize runtime memory status code.\r
\r
+  @return  The function always return EFI_SUCCESS\r
+\r
+**/\r
+EFI_STATUS\r
+RtMemoryStatusCodeInitializeWorker (\r
+  VOID\r
+  )\r
+{\r
+  RUNTIME_MEMORY_STATUSCODE_HEADER  *RtMemoryStatusCodeTable;\r
+\r
+  //\r
+  // Allocate runtime memory status code pool.\r
+  //\r
+  RtMemoryStatusCodeTable = \r
+    (RUNTIME_MEMORY_STATUSCODE_HEADER *) AllocatePool (\r
+                                           sizeof (RUNTIME_MEMORY_STATUSCODE_HEADER) +\r
+                                           PcdGet16 (PcdStatusCodeRuntimeMemorySize) *\r
+                                           1024\r
+                                           );\r
+\r
+  ASSERT (NULL != RtMemoryStatusCodeTable);\r
+\r
+  RtMemoryStatusCodeTable->RecordIndex                  = 0;\r
+  RtMemoryStatusCodeTable->NumberOfRecords              = 0;\r
+  RtMemoryStatusCodeTable->MaxRecordsNumber             = \r
+    (PcdGet16 (PcdStatusCodeRuntimeMemorySize) * 1024) / sizeof (MEMORY_STATUSCODE_RECORD);\r
+\r
+  gDxeStatusCode.RtMemoryStatusCodeTable[PHYSICAL_MODE] = RtMemoryStatusCodeTable;\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  RtMemoryStatusCodeTable      \r
+                        Point to Runtime memory table header.\r
+\r
+  @param  CodeType      Indicates the type of status code being reported.  Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.\r
\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 classify the entity \r
+                        as well as an operation.  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
+                        Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.  \r
+                        Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.\r
\r
+  @param  Instance      The enumeration of a hardware or software entity within the system.  \r
+                        A system may contain multiple entities that match a class/subclass pairing. \r
+                        The instance differentiates between them.  An instance of 0 indicates that instance information is unavailable, \r
+                        not meaningful, or not relevant.  Valid instance numbers start with 1.\r
\r
+  @return               The function always return EFI_SUCCESS.\r
+\r
+**/\r
+EFI_STATUS\r
+RtMemoryStatusCodeReportWorker (\r
+  RUNTIME_MEMORY_STATUSCODE_HEADER      *RtMemoryStatusCodeTable,\r
+  IN EFI_STATUS_CODE_TYPE               CodeType,\r
+  IN EFI_STATUS_CODE_VALUE              Value,\r
+  IN UINT32                             Instance\r
+  )\r
+{\r
+  MEMORY_STATUSCODE_RECORD              *Record;\r
+\r
+  ASSERT (NULL != RtMemoryStatusCodeTable);\r
+\r
+  //\r
+  // Locate current record buffer.\r
+  //\r
+  Record                  = (MEMORY_STATUSCODE_RECORD *) (RtMemoryStatusCodeTable + 1);\r
+  Record                  = &Record[RtMemoryStatusCodeTable->RecordIndex++];\r
+\r
+  //\r
+  // Save status code.\r
+  //\r
+  Record->CodeType        = CodeType;\r
+  Record->Value           = Value;\r
+  Record->Instance        = Instance;\r
+\r
+  //\r
+  // Record total number of records, we compare the number with max records number,\r
+  // if it is bigger than the max number, then the roll back had happened, the record index points to \r
+  // the first record. if it is less then max number, then the zero index is the first record.\r
+  //\r
+  RtMemoryStatusCodeTable->NumberOfRecords++;\r
+  if (RtMemoryStatusCodeTable->RecordIndex == RtMemoryStatusCodeTable->MaxRecordsNumber) {\r
+    //\r
+    // Roll back record index.\r
+    //\r
+    RtMemoryStatusCodeTable->RecordIndex = 0;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+\r
diff --git a/IntelFrameworkModulePkg/Universal/StatusCode/Dxe/SerialStatusCodeWorker.c b/IntelFrameworkModulePkg/Universal/StatusCode/Dxe/SerialStatusCodeWorker.c
new file mode 100644 (file)
index 0000000..efc8f38
--- /dev/null
@@ -0,0 +1,228 @@
+\r
+/** @file\r
+  Serial I/O status code reporting worker.\r
+\r
+  Copyright (c) 2006, Intel Corporation                                                         \r
+  All rights reserved. This program and the accompanying materials                          \r
+  are licensed and made available under the terms and conditions of the BSD License         \r
+  which accompanies this distribution.  The full text of the license may be found at        \r
+  http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                            \r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+  Module Name:  SerialStatusCodeWorker.c\r
+\r
+**/\r
+\r
+//\r
+// Include common header file for this module.\r
+//\r
+#include "CommonHeader.h"\r
+\r
+#include "DxeStatusCode.h"\r
+\r
+STATIC\r
+EFI_SERIAL_IO_PROTOCOL *mSerialIoProtocol;\r
+\r
+/**\r
+  Initialize serial status code worker.\r
\r
+  @return  The function always return EFI_SUCCESS\r
+\r
+**/\r
+EFI_STATUS\r
+EfiSerialStatusCodeInitializeWorker (\r
+  VOID\r
+  )\r
+{\r
+  EFI_STATUS Status;\r
+\r
+  Status = gBS->LocateProtocol (\r
+             &gEfiSerialIoProtocolGuid,\r
+             NULL,\r
+             (VOID **) &mSerialIoProtocol\r
+             );\r
+\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+/**\r
+  Convert status code value and extended data to readable ASCII string, send string to serial I/O device.\r
\r
+  @param  CodeType      Indicates the type of status code being reported.  Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.\r
\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 classify the entity \r
+                        as well as an operation.  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
+                        Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.  \r
+                        Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.\r
\r
+  @param  Instance      The enumeration of a hardware or software entity within the system.  \r
+                        A system may contain multiple entities that match a class/subclass pairing. \r
+                        The instance differentiates between them.  An instance of 0 indicates that instance information is unavailable, \r
+                        not meaningful, or not relevant.  Valid instance numbers start with 1.\r
+\r
+\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 different callers. \r
+                        Type EFI_GUID is defined in InstallProtocolInterface() in the EFI 1.10 Specification.\r
+\r
+\r
+  @param  Data          This optional parameter may be used to pass additional data\r
\r
+  @retval EFI_SUCCESS         Success to report status code to serial I/O.\r
+  @retval EFI_DEVICE_ERROR    EFI serial device can not work after ExitBootService() is called .\r
+\r
+**/\r
+EFI_STATUS\r
+SerialStatusCodeReportWorker (\r
+  IN EFI_STATUS_CODE_TYPE     CodeType,\r
+  IN EFI_STATUS_CODE_VALUE    Value,\r
+  IN UINT32                   Instance,\r
+  IN EFI_GUID                 *CallerId,\r
+  IN EFI_STATUS_CODE_DATA     *Data OPTIONAL\r
+  )\r
+{\r
+  CHAR8           *Filename;\r
+  CHAR8           *Description;\r
+  CHAR8           *Format;\r
+  CHAR8           Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE];\r
+  UINT32          ErrorLevel;\r
+  UINT32          LineNumber;\r
+  UINTN           CharCount;\r
+  VA_LIST         Marker;\r
+  EFI_DEBUG_INFO  *DebugInfo;\r
+  EFI_TPL         CurrentTpl;\r
+\r
+\r
+  if (FeaturePcdGet (PcdStatusCodeUseEfiSerial)) {\r
+    if (EfiAtRuntime ()) {\r
+      return EFI_DEVICE_ERROR;\r
+    }\r
+    CurrentTpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);\r
+    gBS->RestoreTPL (CurrentTpl);\r
+\r
+    if (CurrentTpl > TPL_CALLBACK ) {\r
+      return EFI_DEVICE_ERROR;\r
+    }\r
+  }\r
+\r
+  Buffer[0] = '\0';\r
+\r
+  if (Data != NULL &&\r
+      ReportStatusCodeExtractAssertInfo (CodeType, Value, Data, &Filename, &Description, &LineNumber)) {\r
+    //\r
+    // Print ASSERT() information into output buffer.\r
+    //\r
+    CharCount = AsciiSPrint (\r
+                  Buffer,\r
+                  EFI_STATUS_CODE_DATA_MAX_SIZE,\r
+                  "\n\rDXE_ASSERT!: %a (%d): %a\n\r",\r
+                  Filename,\r
+                  LineNumber,\r
+                  Description\r
+                  );\r
+  } else if (Data != NULL &&\r
+             ReportStatusCodeExtractDebugInfo (Data, &ErrorLevel, &Marker, &Format)) {\r
+    //\r
+    // Print DEBUG() information into output buffer.\r
+    //\r
+    CharCount = AsciiVSPrint (\r
+                  Buffer, \r
+                  EFI_STATUS_CODE_DATA_MAX_SIZE, \r
+                  Format, \r
+                  Marker\r
+                  );\r
+  } else if (Data != NULL && \r
+             CompareGuid (&Data->Type, &gEfiStatusCodeSpecificDataGuid) &&\r
+             (CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) {\r
+    //\r
+    // Print specific data into output buffer.\r
+    //\r
+    DebugInfo = (EFI_DEBUG_INFO *) (Data + 1);\r
+    Marker    = (VA_LIST) (DebugInfo + 1);\r
+    Format    = (CHAR8 *) (((UINT64 *) Marker) + 12);\r
+\r
+    CharCount = AsciiVSPrint (Buffer, EFI_STATUS_CODE_DATA_MAX_SIZE, Format, Marker);\r
+  } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) {\r
+    //\r
+    // Print ERROR information into output buffer.\r
+    //\r
+    CharCount = AsciiSPrint (\r
+                  Buffer, \r
+                  EFI_STATUS_CODE_DATA_MAX_SIZE, \r
+                  "ERROR: C%x:V%x I%x", \r
+                  CodeType, \r
+                  Value, \r
+                  Instance\r
+                  );\r
+\r
+    //\r
+    // Make sure we don't try to print values that weren't \r
+    // intended to be printed, especially NULL GUID pointers.\r
+    //\r
+    \r
+    if (CallerId != NULL) {\r
+      CharCount += AsciiSPrint (\r
+                     &Buffer[CharCount - 1],\r
+                     (EFI_STATUS_CODE_DATA_MAX_SIZE - (sizeof (Buffer[0]) * CharCount)),\r
+                     " %g",\r
+                     CallerId\r
+                     );\r
+    }\r
+\r
+    if (Data != NULL) {\r
+      CharCount += AsciiSPrint (\r
+                     &Buffer[CharCount - 1],\r
+                     (EFI_STATUS_CODE_DATA_MAX_SIZE - (sizeof (Buffer[0]) * CharCount)),\r
+                     " %x",\r
+                     Data\r
+                     );\r
+    }\r
+\r
+    CharCount += AsciiSPrint (\r
+                   &Buffer[CharCount - 1],\r
+                   (EFI_STATUS_CODE_DATA_MAX_SIZE - (sizeof (Buffer[0]) * CharCount)),\r
+                   "\n\r"\r
+                   );\r
+  } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) {\r
+    CharCount = AsciiSPrint (\r
+                  Buffer, \r
+                  EFI_STATUS_CODE_DATA_MAX_SIZE, \r
+                  "PROGRESS CODE: V%x I%x\n\r", \r
+                  Value, \r
+                  Instance\r
+                  );\r
+  } else {\r
+    CharCount = AsciiSPrint (\r
+                  Buffer, \r
+                  EFI_STATUS_CODE_DATA_MAX_SIZE, \r
+                  "Undefined: C%x:V%x I%x\n\r", \r
+                  CodeType, \r
+                  Value, \r
+                  Instance\r
+                  );\r
+  }\r
+\r
+\r
+  if (FeaturePcdGet (PcdStatusCodeUseHardSerial)) {\r
+    //\r
+    // Callout to SerialPort Lib function to do print.\r
+    //\r
+    SerialPortWrite ((UINT8 *) Buffer, CharCount);\r
+  }\r
+  if (FeaturePcdGet (PcdStatusCodeUseEfiSerial)) {\r
+    mSerialIoProtocol->Write (\r
+      mSerialIoProtocol,\r
+      &CharCount,\r
+      Buffer\r
+      );\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
diff --git a/IntelFrameworkModulePkg/Universal/StatusCode/Pei/CommonHeader.h b/IntelFrameworkModulePkg/Universal/StatusCode/Pei/CommonHeader.h
new file mode 100644 (file)
index 0000000..2521548
--- /dev/null
@@ -0,0 +1,44 @@
+/**@file\r
+  Common header file shared by all source files.\r
+\r
+  This file includes package header files, library classes and protocol, PPI & GUID definitions.\r
+\r
+  Copyright (c) 2006, Intel Corporation.\r
+  All rights reserved. This program and the accompanying materials\r
+   are licensed and made available under the terms and conditions of the BSD License\r
+   which accompanies this distribution. The full text of the license may be found at\r
+   http://opensource.org/licenses/bsd-license.php\r
+   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
+#ifndef __COMMON_HEADER_H_\r
+#define __COMMON_HEADER_H_\r
+\r
+\r
+//\r
+// The package level header files this module uses\r
+//\r
+#include <FrameworkPei.h>\r
+//\r
+// The protocols, PPI and GUID defintions for this module\r
+//\r
+#include <Guid/MemoryStatusCodeRecord.h>\r
+#include <Guid/StatusCodeDataTypeId.h>\r
+#include <Ppi/StatusCode.h>\r
+//\r
+// The Library classes this module consumes\r
+//\r
+#include <Library/BaseLib.h>\r
+#include <Library/BaseMemoryLib.h>\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/OemHookStatusCodeLib.h>\r
+#include <Library/PeimEntryPoint.h>\r
+\r
+#endif\r
diff --git a/IntelFrameworkModulePkg/Universal/StatusCode/Pei/MemoryStausCodeWorker.c b/IntelFrameworkModulePkg/Universal/StatusCode/Pei/MemoryStausCodeWorker.c
new file mode 100644 (file)
index 0000000..195e3e2
--- /dev/null
@@ -0,0 +1,156 @@
+/** @file\r
+  Memory status code worker in PEI.\r
+\r
+  Copyright (c) 2006, Intel Corporation                                                         \r
+  All rights reserved. This program and the accompanying materials                          \r
+  are licensed and made available under the terms and conditions of the BSD License         \r
+  which accompanies this distribution.  The full text of the license may be found at        \r
+  http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                            \r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+  Module Name:  MemoryStatusCodeWorker.c\r
+\r
+**/\r
+\r
+//\r
+// Include common header file for this module.\r
+//\r
+#include "CommonHeader.h"\r
+\r
+#include "PeiStatusCode.h"\r
+\r
+/**\r
+  Create one memory status code GUID'ed HOB, use PacketIndex \r
+  to identify the packet.\r
+\r
+  @param   PacketIndex    Index of records packet. \r
\r
+  @return                 Always return pointer of memory status code packet.\r
+\r
+**/\r
+STATIC\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 =\r
+    (MEMORY_STATUSCODE_PACKET_HEADER *) BuildGuidHob (\r
+                                          &gMemoryStatusCodeRecordGuid, \r
+                                          PcdGet16 (PcdStatusCodeMemorySize) * \r
+                                          1024 +\r
+                                          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
+\r
+/**\r
+  Initialize memory status code.\r
+  Create one GUID'ed HOB with PCD defined size. If create required size \r
+  GUID'ed HOB failed, then ASSERT().\r
\r
+  @return           The function always return EFI_SUCCESS\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
+  @param  CodeType      Indicates the type of status code being reported.  Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.\r
\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 classify the entity \r
+                        as well as an operation.  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
+                        Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.  \r
+                        Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.\r
\r
+  @param  Instance      The enumeration of a hardware or software entity within the system.  \r
+                        A system may contain multiple entities that match a class/subclass pairing. \r
+                        The instance differentiates between them.  An instance of 0 indicates that instance information is unavailable, \r
+                        not meaningful, or not relevant.  Valid instance numbers start with 1.\r
\r
+  @return               The function always return EFI_SUCCESS.\r
+\r
+**/\r
+EFI_STATUS\r
+MemoryStatusCodeReportWorker (\r
+  IN EFI_STATUS_CODE_TYPE     CodeType,\r
+  IN EFI_STATUS_CODE_VALUE    Value,\r
+  IN UINT32                   Instance\r
+  )\r
+{\r
+\r
+  EFI_PEI_HOB_POINTERS              Hob;\r
+  MEMORY_STATUSCODE_PACKET_HEADER   *PacketHeader;\r
+  MEMORY_STATUSCODE_RECORD          *Record     = NULL;\r
+  UINT16                            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 (NULL == Record) {\r
+    //\r
+    // In order to save status code , 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/StatusCode/Pei/PeiStatusCode.c b/IntelFrameworkModulePkg/Universal/StatusCode/Pei/PeiStatusCode.c
new file mode 100644 (file)
index 0000000..0a697cc
--- /dev/null
@@ -0,0 +1,151 @@
+\r
+/** @file\r
+  Generic PeiStatusCode Module.\r
+\r
+  Copyright (c) 2006, Intel Corporation                                                         \r
+  All rights reserved. This program and the accompanying materials                          \r
+  are licensed and made available under the terms and conditions of the BSD License         \r
+  which accompanies this distribution.  The full text of the license may be found at        \r
+  http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                            \r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r
+\r
+  Module Name:  PeiStatusCode.c\r
+\r
+**/\r
+\r
+//\r
+// Include common header file for this module.\r
+//\r
+#include "CommonHeader.h"\r
+\r
+#include "PeiStatusCode.h"\r
+\r
+STATIC\r
+EFI_PEI_PROGRESS_CODE_PPI     mStatusCodePpi           = { \r
+  ReportDispatcher\r
+  };\r
+\r
+STATIC\r
+EFI_PEI_PPI_DESCRIPTOR        mStatusCodePpiDescriptor = {\r
+  EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,\r
+  &gEfiPeiStatusCodePpiGuid,\r
+  &mStatusCodePpi\r
+  };\r
+\r
+/**\r
+  Report status code to all supported device.\r
+  \r
+  \r
+  @param  PeiServices\r
+\r
+  @param  CodeType      Indicates the type of status code being reported.  \r
+                        The type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.\r
+  @param  Value         Describes the current status of a hardware or software entity.  \r
+                        This includes information about the class and subclass that is used to classify the entity \r
+                        as well as an operation.  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
+                        Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.  \r
+                        Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.\r
+  @param  Instance      The enumeration of a hardware or software entity within the system.  \r
+                        A system may contain multiple entities that match a class/subclass pairing.  \r
+                        The instance differentiates between them.  An instance of 0 indicates that instance \r
+                        information is unavailable, not meaningful, or not relevant.  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 different callers.\r
+  @param  Data          This optional parameter may be used to pass additional data.  \r
+                        Type EFI_STATUS_CODE_DATA is defined in "Related Definitions" below.  \r
+                        The contents of this data type may have additional GUID-specific data.  The standard GUIDs and \r
+                        their associated data structures are defined in the Intel? Platform Innovation Framework for EFI Status Codes Specification.\r
+\r
+  @return               Always return EFI_SUCCESS.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ReportDispatcher (\r
+  IN EFI_PEI_SERVICES         **PeiServices,\r
+  IN EFI_STATUS_CODE_TYPE     CodeType,\r
+  IN EFI_STATUS_CODE_VALUE    Value,\r
+  IN UINT32                   Instance,\r
+  IN EFI_GUID                 *CallerId OPTIONAL,\r
+  IN EFI_STATUS_CODE_DATA     *Data OPTIONAL\r
+  )\r
+{\r
+  if (FeaturePcdGet (PcdStatusCodeUseSerial)) {\r
+    SerialStatusCodeReportWorker (\r
+      CodeType,\r
+      Value,\r
+      Instance,\r
+      CallerId,\r
+      Data\r
+      );\r
+  }\r
+  if (FeaturePcdGet (PcdStatusCodeUseMemory)) {\r
+    MemoryStatusCodeReportWorker (\r
+      CodeType,\r
+      Value,\r
+      Instance\r
+      );\r
+  }\r
+  if (FeaturePcdGet (PcdStatusCodeUseOEM)) {\r
+    OemHookStatusCodeReport (\r
+      CodeType,\r
+      Value,\r
+      Instance,\r
+      CallerId,\r
+      Data\r
+      );\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+  Initialize PEI status codes and publish the status code \r
+  PPI.\r
+\r
+  @param   FfsHeader       FV this PEIM was loaded from.\r
+  @param   PeiServices     General purpose services available to every PEIM.\r
\r
+  @return                  The function always returns success.\r
+\r
+**/\r
+EFI_STATUS\r
+PeiStatusCodeDriverEntry (\r
+  IN EFI_FFS_FILE_HEADER       *FfsHeader,\r
+  IN EFI_PEI_SERVICES          **PeiServices\r
+  )\r
+{\r
+  EFI_STATUS                  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
+  // if enable UseOEM, then initialize Oem status code.\r
+  //\r
+  if (FeaturePcdGet (PcdStatusCodeUseSerial)) {\r
+    Status = SerialPortInitialize();\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
+  if (FeaturePcdGet (PcdStatusCodeUseMemory)) {\r
+    Status = MemoryStatusCodeInitializeWorker ();\r
+    ASSERT_EFI_ERROR  (Status);\r
+  }\r
+  if (FeaturePcdGet (PcdStatusCodeUseOEM)) {\r
+    Status = OemHookStatusCodeInitialize ();\r
+    ASSERT_EFI_ERROR  (Status);\r
+  }\r
+\r
+  //\r
+  // Install PeiStatusCodePpi. \r
+  // PeiServices use this Ppi to output status code.\r
+  // use library\r
+  Status = PeiServicesInstallPpi (&mStatusCodePpiDescriptor);\r
+  ASSERT_EFI_ERROR (Status);\r
+  \r
+  return EFI_SUCCESS;\r
+}\r
+\r
diff --git a/IntelFrameworkModulePkg/Universal/StatusCode/Pei/PeiStatusCode.h b/IntelFrameworkModulePkg/Universal/StatusCode/Pei/PeiStatusCode.h
new file mode 100644 (file)
index 0000000..c8c004d
--- /dev/null
@@ -0,0 +1,144 @@
+\r
+/** @file\r
+  Heade file of status code PEIM\r
+\r
+  Copyright (c) 2006, Intel Corporation                                                         \r
+  All rights reserved. This program and the accompanying materials                          \r
+  are licensed and made available under the terms and conditions of the BSD License         \r
+  which accompanies this distribution.  The full text of the license may be found at        \r
+  http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                            \r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+  Module Name:  PeiStatusCode.h\r
+\r
+**/\r
+\r
+#ifndef __PEI_STATUS_CODE_H__\r
+#define __PEI_STATUS_CODE_H__\r
+\r
+\r
+//\r
+// Include common header file for this module.\r
+//\r
+#include "CommonHeader.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.  Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.\r
\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 classify the entity \r
+                        as well as an operation.  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
+                        Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.  \r
+                        Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.\r
\r
+  @param  Instance      The enumeration of a hardware or software entity within the system.  \r
+                        A system may contain multiple entities that match a class/subclass pairing. \r
+                        The instance differentiates between them.  An instance of 0 indicates that instance information is unavailable, \r
+                        not meaningful, or not relevant.  Valid instance numbers start with 1.\r
+\r
+\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 different callers. \r
+                        Type EFI_GUID is defined in InstallProtocolInterface() in the EFI 1.10 Specification.\r
+\r
+\r
+  @param  Data          This optional parameter may be used to pass additional data\r
\r
+  @return               The function always return EFI_SUCCESS.\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
+/**\r
+  Initialize memory status code.\r
+  Create one GUID'ed HOB with PCD defined size. If create required size \r
+  GUID'ed HOB failed, then ASSERT().\r
\r
+  @return           The function always return EFI_SUCCESS\r
+\r
+**/\r
+EFI_STATUS\r
+MemoryStatusCodeInitializeWorker (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Report status code into GUID'ed HOB.\r
\r
+  @param  CodeType      Indicates the type of status code being reported.  Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.\r
\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 classify the entity \r
+                        as well as an operation.  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
+                        Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.  \r
+                        Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.\r
\r
+  @param  Instance      The enumeration of a hardware or software entity within the system.  \r
+                        A system may contain multiple entities that match a class/subclass pairing. \r
+                        The instance differentiates between them.  An instance of 0 indicates that instance information is unavailable, \r
+                        not meaningful, or not relevant.  Valid instance numbers start with 1.\r
\r
+  @return               The function always return EFI_SUCCESS.\r
+\r
+**/\r
+EFI_STATUS\r
+MemoryStatusCodeReportWorker (\r
+  IN EFI_STATUS_CODE_TYPE     CodeType,\r
+  IN EFI_STATUS_CODE_VALUE    Value,\r
+  IN UINT32                   Instance\r
+  );\r
+\r
+/**\r
+  Report status code to all supported device.\r
+  \r
+  \r
+  @param  PeiServices\r
+\r
+  @param  Type          Indicates the type of status code being reported.  \r
+                        The type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.\r
+  @param  Value         Describes the current status of a hardware or software entity.  \r
+                        This includes information about the class and subclass that is used to classify the entity \r
+                        as well as an operation.  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
+                        Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.  \r
+                        Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.\r
+  @param  Instance      The enumeration of a hardware or software entity within the system.  \r
+                        A system may contain multiple entities that match a class/subclass pairing.  \r
+                        The instance differentiates between them.  An instance of 0 indicates that instance \r
+                        information is unavailable, not meaningful, or not relevant.  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 different callers.\r
+  @param  Data          This optional parameter may be used to pass additional data.  \r
+                        Type EFI_STATUS_CODE_DATA is defined in "Related Definitions" below.  \r
+                        The contents of this data type may have additional GUID-specific data.  The standard GUIDs and \r
+                        their associated data structures are defined in the Intel? Platform Innovation Framework for EFI Status Codes Specification.\r
+\r
+  @return               Always return EFI_SUCCESS.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ReportDispatcher (\r
+  IN EFI_PEI_SERVICES         **PeiServices,\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
diff --git a/IntelFrameworkModulePkg/Universal/StatusCode/Pei/PeiStatusCode.inf b/IntelFrameworkModulePkg/Universal/StatusCode/Pei/PeiStatusCode.inf
new file mode 100644 (file)
index 0000000..2812509
--- /dev/null
@@ -0,0 +1,140 @@
+#/** @file\r
+# Generic Status code Pei driver\r
+#\r
+# Customized output devices based on feature flags.\r
+# Copyright (c) 2006, 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
+################################################################################\r
+#\r
+# Defines Section - statements that will be processed to create a Makefile.\r
+#\r
+################################################################################\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = PeiStatusCode\r
+  FILE_GUID                      = 1EC0F53A-FDE0-4576-8F25-7A1A410F58EB\r
+  MODULE_TYPE                    = PEIM\r
+  VERSION_STRING                 = 1.0\r
+  EDK_RELEASE_VERSION            = 0x00020000\r
+  EFI_SPECIFICATION_VERSION      = 0x00020000\r
+\r
+  ENTRY_POINT                    = PeiStatusCodeDriverEntry\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
+################################################################################\r
+#\r
+# Sources Section - list of files that are required for the build to succeed.\r
+#\r
+################################################################################\r
+\r
+[Sources.common]\r
+  PeiStatusCode.c\r
+  MemoryStausCodeWorker.c\r
+  SerialStatusCodeWorker.c\r
+  PeiStatusCode.h\r
+  CommonHeader.h\r
+\r
+\r
+################################################################################\r
+#\r
+# Includes Section - list of Include locations that are required for\r
+#                    this module.\r
+#\r
+################################################################################\r
+\r
+[Includes]\r
+  $(WORKSPACE)/MdePkg/Include/Library\r
+  $(WORKSPACE)/IntelFrameworkPkg/Include\r
+  $(WORKSPACE)/IntelFrameworkModulePkg/Include\r
+  $(WORKSPACE)/IntelFrameworkModulePkg/Include/Library\r
+\r
+################################################################################\r
+#\r
+# Package Dependency Section - list of Package files that are required for\r
+#                              this module.\r
+#\r
+################################################################################\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  IntelFrameworkPkg/IntelFrameworkPkg.dec\r
+  IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec\r
+\r
+################################################################################\r
+#\r
+# Library Class Section - list of Library Classes that are required for\r
+#                         this module.\r
+#\r
+################################################################################\r
+\r
+[LibraryClasses]\r
+  PeimEntryPoint\r
+  OemHookStatusCodeLib\r
+  PeiServicesLib\r
+  PcdLib\r
+  HobLib\r
+  SerialPortLib\r
+  ReportStatusCodeLib\r
+  PrintLib\r
+  DebugLib\r
+  BaseMemoryLib\r
+  BaseLib\r
+\r
+\r
+################################################################################\r
+#\r
+# Guid C Name Section - list of Guids that this module uses or produces.\r
+#\r
+################################################################################\r
+\r
+[Guids]\r
+  gMemoryStatusCodeRecordGuid                   # SOMETIMES_CONSUMED\r
+\r
+\r
+################################################################################\r
+#\r
+# PPI C Name Section - list of PPI and PPI Notify C Names that this module\r
+#                      uses or produces.\r
+#\r
+################################################################################\r
+\r
+[Ppis]\r
+  gEfiPeiStatusCodePpiGuid                      # PPI ALWAYS_CONSUMED\r
+\r
+\r
+################################################################################\r
+#\r
+# Pcd FEATURE_FLAG - list of PCDs that this module is coded for.\r
+#\r
+################################################################################\r
+\r
+[PcdsFeatureFlag.common]\r
+  PcdStatusCodeUseOEM|gEfiIntelFrameworkModulePkgTokenSpaceGuid\r
+  PcdStatusCodeUseMemory|gEfiIntelFrameworkModulePkgTokenSpaceGuid\r
+  PcdStatusCodeUseSerial|gEfiIntelFrameworkModulePkgTokenSpaceGuid\r
+\r
+\r
+################################################################################\r
+#\r
+# Pcd DYNAMIC - list of PCDs that this module is coded for.\r
+#\r
+################################################################################\r
+\r
+[PcdsDynamic.common]\r
+  PcdStatusCodeMemorySize|gEfiIntelFrameworkModulePkgTokenSpaceGuid\r
+\r
diff --git a/IntelFrameworkModulePkg/Universal/StatusCode/Pei/PeiStatusCode.msa b/IntelFrameworkModulePkg/Universal/StatusCode/Pei/PeiStatusCode.msa
new file mode 100644 (file)
index 0000000..d0cd00d
--- /dev/null
@@ -0,0 +1,111 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0  http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd" xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\r
+  <MsaHeader>\r
+    <ModuleName>PeiStatusCode</ModuleName>\r
+    <ModuleType>PEIM</ModuleType>\r
+    <GuidValue>1EC0F53A-FDE0-4576-8F25-7A1A410F58EB</GuidValue>\r
+    <Version>1.0</Version>\r
+    <Abstract>Generic Status code Pei driver</Abstract>\r
+    <Description>Customized output devices based on feature flags.</Description>\r
+    <Copyright>Copyright (c) 2006, Intel Corporation.</Copyright>\r
+    <License>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.</License>\r
+    <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION   0x00000052</Specification>\r
+  </MsaHeader>\r
+  <ModuleDefinitions>\r
+    <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>\r
+    <BinaryModule>false</BinaryModule>\r
+    <OutputFileBasename>PeiStatusCode</OutputFileBasename>\r
+  </ModuleDefinitions>\r
+  <LibraryClassDefinitions>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>BaseLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>BaseMemoryLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>DebugLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>PrintLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>ReportStatusCodeLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>SerialPortLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>HobLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>PcdLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>PeiServicesLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>OemHookStatusCodeLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>PeimEntryPoint</Keyword>\r
+    </LibraryClass>\r
+  </LibraryClassDefinitions>\r
+  <SourceFiles>\r
+    <Filename>PeiStatusCode.h</Filename>\r
+    <Filename>SerialStatusCodeWorker.c</Filename>\r
+    <Filename>MemoryStausCodeWorker.c</Filename>\r
+    <Filename>PeiStatusCode.c</Filename>\r
+  </SourceFiles>\r
+  <PackageDependencies>\r
+    <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+    <Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>\r
+  </PackageDependencies>\r
+  <PPIs>\r
+    <Ppi Usage="ALWAYS_CONSUMED">\r
+      <PpiCName>gEfiPeiStatusCodePpiGuid</PpiCName>\r
+    </Ppi>\r
+  </PPIs>\r
+  <Guids>\r
+    <GuidCNames Usage="SOMETIMES_CONSUMED">\r
+      <GuidCName>gMemoryStatusCodeRecordGuid</GuidCName>\r
+    </GuidCNames>\r
+    <GuidCNames Usage="SOMETIMES_CONSUMED">\r
+      <GuidCName>gEfiStatusCodeSpecificDataGuid</GuidCName>\r
+    </GuidCNames>\r
+  </Guids>\r
+  <Externs>\r
+    <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
+    <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
+    <Extern>\r
+      <ModuleEntryPoint>PeiStatusCodeDriverEntry</ModuleEntryPoint>\r
+    </Extern>\r
+  </Externs>\r
+  <PcdCoded>\r
+    <PcdEntry PcdItemType="FEATURE_FLAG">\r
+      <C_Name>PcdStatusCodeUseSerial</C_Name>\r
+      <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>\r
+      <HelpText/>\r
+    </PcdEntry>\r
+    <PcdEntry PcdItemType="FEATURE_FLAG">\r
+      <C_Name>PcdStatusCodeUseMemory</C_Name>\r
+      <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>\r
+      <HelpText/>\r
+    </PcdEntry>\r
+    <PcdEntry PcdItemType="FEATURE_FLAG">\r
+      <C_Name>PcdStatusCodeUseOEM</C_Name>\r
+      <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>\r
+      <HelpText/>\r
+    </PcdEntry>\r
+    <PcdEntry PcdItemType="DYNAMIC">\r
+      <C_Name>PcdStatusCodeMemorySize</C_Name>\r
+      <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>\r
+      <HelpText/>\r
+    </PcdEntry>\r
+  </PcdCoded>\r
+</ModuleSurfaceArea>
\ No newline at end of file
diff --git a/IntelFrameworkModulePkg/Universal/StatusCode/Pei/SerialStatusCodeWorker.c b/IntelFrameworkModulePkg/Universal/StatusCode/Pei/SerialStatusCodeWorker.c
new file mode 100644 (file)
index 0000000..2efc23c
--- /dev/null
@@ -0,0 +1,174 @@
+\r
+/** @file\r
+  Serial I/O status code reporting worker.\r
+\r
+  Copyright (c) 2006, Intel Corporation                                                         \r
+  All rights reserved. This program and the accompanying materials                          \r
+  are licensed and made available under the terms and conditions of the BSD License         \r
+  which accompanies this distribution.  The full text of the license may be found at        \r
+  http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                            \r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+  Module Name:  SerialStatusCodeWorker.c\r
+\r
+**/\r
+\r
+//\r
+// Include common header file for this module.\r
+//\r
+#include "CommonHeader.h"\r
+\r
+#include "PeiStatusCode.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.  Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.\r
\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 classify the entity \r
+                        as well as an operation.  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
+                        Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.  \r
+                        Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.\r
\r
+  @param  Instance      The enumeration of a hardware or software entity within the system.  \r
+                        A system may contain multiple entities that match a class/subclass pairing. \r
+                        The instance differentiates between them.  An instance of 0 indicates that instance information is unavailable, \r
+                        not meaningful, or not relevant.  Valid instance numbers start with 1.\r
+\r
+\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 different callers. \r
+                        Type EFI_GUID is defined in InstallProtocolInterface() in the EFI 1.10 Specification.\r
+\r
+\r
+  @param  Data          This optional parameter may be used to pass additional data\r
\r
+  @return               The function always return EFI_SUCCESS.\r
+\r
+**/\r
+EFI_STATUS\r
+SerialStatusCodeReportWorker (\r
+  IN EFI_STATUS_CODE_TYPE     CodeType,\r
+  IN EFI_STATUS_CODE_VALUE    Value,\r
+  IN UINT32                   Instance,\r
+  IN EFI_GUID                 *CallerId,\r
+  IN EFI_STATUS_CODE_DATA     *Data OPTIONAL\r
+  )\r
+{\r
+  CHAR8           *Filename;\r
+  CHAR8           *Description;\r
+  CHAR8           *Format;\r
+  CHAR8           Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE];\r
+  UINT32          ErrorLevel;\r
+  UINT32          LineNumber;\r
+  UINTN           CharCount;\r
+  VA_LIST         Marker;\r
+  EFI_DEBUG_INFO  *DebugInfo;\r
+\r
+  Buffer[0] = '\0';\r
+\r
+  if (Data != NULL &&\r
+      ReportStatusCodeExtractAssertInfo (CodeType, Value, Data, &Filename, &Description, &LineNumber)) {\r
+    //\r
+    // Print ASSERT() information into output buffer.\r
+    //\r
+    CharCount = AsciiSPrint (\r
+                  Buffer,\r
+                  EFI_STATUS_CODE_DATA_MAX_SIZE,\r
+                  "\n\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 = AsciiVSPrint (\r
+                  Buffer, \r
+                  EFI_STATUS_CODE_DATA_MAX_SIZE, \r
+                  Format, \r
+                  Marker\r
+                  );\r
+  } else if (Data != NULL && \r
+             CompareGuid (&Data->Type, &gEfiStatusCodeSpecificDataGuid) &&\r
+             (CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) {\r
+    //\r
+    // Print specific data into output buffer.\r
+    //\r
+    DebugInfo = (EFI_DEBUG_INFO *) (Data + 1);\r
+    Marker    = (VA_LIST) (DebugInfo + 1);\r
+    Format    = (CHAR8 *) (((UINT64 *) Marker) + 12);\r
+\r
+    CharCount = AsciiVSPrint (Buffer, EFI_STATUS_CODE_DATA_MAX_SIZE, Format, Marker);\r
+  } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) {\r
+    //\r
+    // Print ERROR information into output buffer.\r
+    //\r
+    CharCount = AsciiSPrint (\r
+                  Buffer, \r
+                  EFI_STATUS_CODE_DATA_MAX_SIZE, \r
+                  "ERROR: C%x:V%x I%x", \r
+                  CodeType, \r
+                  Value, \r
+                  Instance\r
+                  );\r
+\r
+    //\r
+    // Make sure we don't try to print values that weren't intended to be printed, especially NULL GUID pointers.\r
+    //\r
+    \r
+    if (CallerId != NULL) {\r
+      CharCount += AsciiSPrint (\r
+                     &Buffer[CharCount - 1],\r
+                     (EFI_STATUS_CODE_DATA_MAX_SIZE - (sizeof (Buffer[0]) * CharCount)),\r
+                     " %g",\r
+                     CallerId\r
+                     );\r
+    }\r
+\r
+    if (Data != NULL) {\r
+      CharCount += AsciiSPrint (\r
+                     &Buffer[CharCount - 1],\r
+                     (EFI_STATUS_CODE_DATA_MAX_SIZE - (sizeof (Buffer[0]) * CharCount)),\r
+                     " %x",\r
+                     Data\r
+                     );\r
+    }\r
+\r
+    CharCount += AsciiSPrint (\r
+                   &Buffer[CharCount - 1],\r
+                   (EFI_STATUS_CODE_DATA_MAX_SIZE - (sizeof (Buffer[0]) * CharCount)),\r
+                   "\n\r"\r
+                   );\r
+  } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) {\r
+    CharCount = AsciiSPrint (\r
+                  Buffer, \r
+                  EFI_STATUS_CODE_DATA_MAX_SIZE, \r
+                  "PROGRESS CODE: V%x I%x\n\r", \r
+                  Value, \r
+                  Instance\r
+                  );\r
+  } else {\r
+    CharCount = AsciiSPrint (\r
+                  Buffer, \r
+                  EFI_STATUS_CODE_DATA_MAX_SIZE, \r
+                  "Undefined: C%x:V%x I%x\n\r", \r
+                  CodeType, \r
+                  Value, \r
+                  Instance\r
+                  );\r
+  }\r
+\r
+  //\r
+  // Callout to SerialPort Lib function to do print.\r
+  //\r
+  SerialPortWrite ((UINT8 *) Buffer, CharCount);\r
+\r
+  return EFI_SUCCESS;\r
+}\r