summaryrefslogtreecommitdiff
path: root/IntelFrameworkModulePkg/Universal/StatusCode/Pei
diff options
context:
space:
mode:
Diffstat (limited to 'IntelFrameworkModulePkg/Universal/StatusCode/Pei')
-rw-r--r--IntelFrameworkModulePkg/Universal/StatusCode/Pei/CommonHeader.h44
-rw-r--r--IntelFrameworkModulePkg/Universal/StatusCode/Pei/MemoryStausCodeWorker.c156
-rw-r--r--IntelFrameworkModulePkg/Universal/StatusCode/Pei/PeiStatusCode.c151
-rw-r--r--IntelFrameworkModulePkg/Universal/StatusCode/Pei/PeiStatusCode.h144
-rw-r--r--IntelFrameworkModulePkg/Universal/StatusCode/Pei/PeiStatusCode.inf140
-rw-r--r--IntelFrameworkModulePkg/Universal/StatusCode/Pei/PeiStatusCode.msa111
-rw-r--r--IntelFrameworkModulePkg/Universal/StatusCode/Pei/SerialStatusCodeWorker.c174
7 files changed, 920 insertions, 0 deletions
diff --git a/IntelFrameworkModulePkg/Universal/StatusCode/Pei/CommonHeader.h b/IntelFrameworkModulePkg/Universal/StatusCode/Pei/CommonHeader.h
new file mode 100644
index 0000000000..2521548f6f
--- /dev/null
+++ b/IntelFrameworkModulePkg/Universal/StatusCode/Pei/CommonHeader.h
@@ -0,0 +1,44 @@
+/**@file
+ Common header file shared by all source files.
+
+ This file includes package header files, library classes and protocol, PPI & GUID definitions.
+
+ Copyright (c) 2006, Intel Corporation.
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+**/
+
+#ifndef __COMMON_HEADER_H_
+#define __COMMON_HEADER_H_
+
+
+//
+// The package level header files this module uses
+//
+#include <FrameworkPei.h>
+//
+// The protocols, PPI and GUID defintions for this module
+//
+#include <Guid/MemoryStatusCodeRecord.h>
+#include <Guid/StatusCodeDataTypeId.h>
+#include <Ppi/StatusCode.h>
+//
+// The Library classes this module consumes
+//
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/DebugLib.h>
+#include <Library/PrintLib.h>
+#include <Library/ReportStatusCodeLib.h>
+#include <Library/SerialPortLib.h>
+#include <Library/HobLib.h>
+#include <Library/PcdLib.h>
+#include <Library/PeiServicesLib.h>
+#include <Library/OemHookStatusCodeLib.h>
+#include <Library/PeimEntryPoint.h>
+
+#endif
diff --git a/IntelFrameworkModulePkg/Universal/StatusCode/Pei/MemoryStausCodeWorker.c b/IntelFrameworkModulePkg/Universal/StatusCode/Pei/MemoryStausCodeWorker.c
new file mode 100644
index 0000000000..195e3e2183
--- /dev/null
+++ b/IntelFrameworkModulePkg/Universal/StatusCode/Pei/MemoryStausCodeWorker.c
@@ -0,0 +1,156 @@
+/** @file
+ Memory status code worker in PEI.
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ Module Name: MemoryStatusCodeWorker.c
+
+**/
+
+//
+// Include common header file for this module.
+//
+#include "CommonHeader.h"
+
+#include "PeiStatusCode.h"
+
+/**
+ Create one memory status code GUID'ed HOB, use PacketIndex
+ to identify the packet.
+
+ @param PacketIndex Index of records packet.
+
+ @return Always return pointer of memory status code packet.
+
+**/
+STATIC
+MEMORY_STATUSCODE_PACKET_HEADER *
+CreateMemoryStatusCodePacket (
+ UINT16 PacketIndex
+ )
+{
+ MEMORY_STATUSCODE_PACKET_HEADER *PacketHeader;
+
+ //
+ // Build GUID'ed HOB with PCD defined size.
+ //
+ PacketHeader =
+ (MEMORY_STATUSCODE_PACKET_HEADER *) BuildGuidHob (
+ &gMemoryStatusCodeRecordGuid,
+ PcdGet16 (PcdStatusCodeMemorySize) *
+ 1024 +
+ sizeof (MEMORY_STATUSCODE_PACKET_HEADER)
+ );
+ ASSERT (PacketHeader != NULL);
+
+ PacketHeader->MaxRecordsNumber = (PcdGet16 (PcdStatusCodeMemorySize) * 1024)/ sizeof (MEMORY_STATUSCODE_RECORD);
+ PacketHeader->PacketIndex = PacketIndex;
+ PacketHeader->RecordIndex = 0;
+
+ return PacketHeader;
+}
+
+
+
+/**
+ Initialize memory status code.
+ Create one GUID'ed HOB with PCD defined size. If create required size
+ GUID'ed HOB failed, then ASSERT().
+
+ @return The function always return EFI_SUCCESS
+
+**/
+EFI_STATUS
+MemoryStatusCodeInitializeWorker (
+ VOID
+ )
+{
+ //
+ // Create first memory status code GUID'ed HOB.
+ //
+ CreateMemoryStatusCodePacket (0);
+
+ return EFI_SUCCESS;
+}
+
+
+/**
+ Report status code into GUID'ed HOB..
+
+ @param CodeType Indicates the type of status code being reported. Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.
+
+ @param Value Describes the current status of a hardware or software entity.
+ This included information about the class and subclass that is used to classify the entity
+ as well as an operation. For progress codes, the operation is the current activity.
+ For error codes, it is the exception. For debug codes, it is not defined at this time.
+ Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.
+ Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.
+
+ @param Instance The enumeration of a hardware or software entity within the system.
+ A system may contain multiple entities that match a class/subclass pairing.
+ The instance differentiates between them. An instance of 0 indicates that instance information is unavailable,
+ not meaningful, or not relevant. Valid instance numbers start with 1.
+
+ @return The function always return EFI_SUCCESS.
+
+**/
+EFI_STATUS
+MemoryStatusCodeReportWorker (
+ IN EFI_STATUS_CODE_TYPE CodeType,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN UINT32 Instance
+ )
+{
+
+ EFI_PEI_HOB_POINTERS Hob;
+ MEMORY_STATUSCODE_PACKET_HEADER *PacketHeader;
+ MEMORY_STATUSCODE_RECORD *Record = NULL;
+ UINT16 PacketIndex = 0;;
+
+ //
+ // Journal GUID'ed HOBs to find empty record entry, if found, then save status code in it.
+ // otherwise, create a new GUID'ed HOB.
+ //
+ Hob.Raw = GetFirstGuidHob (&gMemoryStatusCodeRecordGuid);
+ while (Hob.Raw != NULL) {
+ PacketHeader = (MEMORY_STATUSCODE_PACKET_HEADER *) GET_GUID_HOB_DATA (Hob.Guid);
+
+ //
+ // Check whether pccket is full or not.
+ //
+ if (PacketHeader->RecordIndex < PacketHeader->MaxRecordsNumber) {
+ Record = (MEMORY_STATUSCODE_RECORD *) (PacketHeader + 1);
+ Record = &Record[PacketHeader->RecordIndex++];
+ break;
+ }
+ //
+ // Cache number of found packet in PacketIndex.
+ //
+ PacketIndex++;
+
+ Hob.Raw = GetNextGuidHob (&gMemoryStatusCodeRecordGuid, Hob.Raw);
+ }
+
+ if (NULL == Record) {
+ //
+ // In order to save status code , create new packet.
+ //
+ PacketHeader = CreateMemoryStatusCodePacket (PacketIndex);
+
+ Record = (MEMORY_STATUSCODE_RECORD *) (PacketHeader + 1);
+ Record = &Record[PacketHeader->RecordIndex++];
+ }
+
+ Record->CodeType = CodeType;
+ Record->Instance = Instance;
+ Record->Value = Value;
+
+ return EFI_SUCCESS;
+}
diff --git a/IntelFrameworkModulePkg/Universal/StatusCode/Pei/PeiStatusCode.c b/IntelFrameworkModulePkg/Universal/StatusCode/Pei/PeiStatusCode.c
new file mode 100644
index 0000000000..0a697cc211
--- /dev/null
+++ b/IntelFrameworkModulePkg/Universal/StatusCode/Pei/PeiStatusCode.c
@@ -0,0 +1,151 @@
+
+/** @file
+ Generic PeiStatusCode Module.
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ Module Name: PeiStatusCode.c
+
+**/
+
+//
+// Include common header file for this module.
+//
+#include "CommonHeader.h"
+
+#include "PeiStatusCode.h"
+
+STATIC
+EFI_PEI_PROGRESS_CODE_PPI mStatusCodePpi = {
+ ReportDispatcher
+ };
+
+STATIC
+EFI_PEI_PPI_DESCRIPTOR mStatusCodePpiDescriptor = {
+ EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
+ &gEfiPeiStatusCodePpiGuid,
+ &mStatusCodePpi
+ };
+
+/**
+ Report status code to all supported device.
+
+
+ @param PeiServices
+
+ @param CodeType Indicates the type of status code being reported.
+ The type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.
+ @param Value Describes the current status of a hardware or software entity.
+ This includes information about the class and subclass that is used to classify the entity
+ as well as an operation. For progress codes, the operation is the current activity.
+ For error codes, it is the exception. For debug codes, it is not defined at this time.
+ Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.
+ Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.
+ @param Instance The enumeration of a hardware or software entity within the system.
+ A system may contain multiple entities that match a class/subclass pairing.
+ The instance differentiates between them. An instance of 0 indicates that instance
+ information is unavailable, not meaningful, or not relevant. Valid instance numbers start with 1.
+ @param CallerId This optional parameter may be used to identify the caller.
+ This parameter allows the status code driver to apply different rules to different callers.
+ @param Data This optional parameter may be used to pass additional data.
+ Type EFI_STATUS_CODE_DATA is defined in "Related Definitions" below.
+ The contents of this data type may have additional GUID-specific data. The standard GUIDs and
+ their associated data structures are defined in the Intel? Platform Innovation Framework for EFI Status Codes Specification.
+
+ @return Always return EFI_SUCCESS.
+
+**/
+EFI_STATUS
+EFIAPI
+ReportDispatcher (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_STATUS_CODE_TYPE CodeType,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN UINT32 Instance,
+ IN EFI_GUID *CallerId OPTIONAL,
+ IN EFI_STATUS_CODE_DATA *Data OPTIONAL
+ )
+{
+ if (FeaturePcdGet (PcdStatusCodeUseSerial)) {
+ SerialStatusCodeReportWorker (
+ CodeType,
+ Value,
+ Instance,
+ CallerId,
+ Data
+ );
+ }
+ if (FeaturePcdGet (PcdStatusCodeUseMemory)) {
+ MemoryStatusCodeReportWorker (
+ CodeType,
+ Value,
+ Instance
+ );
+ }
+ if (FeaturePcdGet (PcdStatusCodeUseOEM)) {
+ OemHookStatusCodeReport (
+ CodeType,
+ Value,
+ Instance,
+ CallerId,
+ Data
+ );
+ }
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Initialize PEI status codes and publish the status code
+ PPI.
+
+ @param FfsHeader FV this PEIM was loaded from.
+ @param PeiServices General purpose services available to every PEIM.
+
+ @return The function always returns success.
+
+**/
+EFI_STATUS
+PeiStatusCodeDriverEntry (
+ IN EFI_FFS_FILE_HEADER *FfsHeader,
+ IN EFI_PEI_SERVICES **PeiServices
+ )
+{
+ EFI_STATUS Status;
+
+ //
+ // Dispatch initialization request to sub-statuscode-devices.
+ // If enable UseSerial, then initialize serial port.
+ // if enable UseMemory, then initialize memory status code worker.
+ // if enable UseOEM, then initialize Oem status code.
+ //
+ if (FeaturePcdGet (PcdStatusCodeUseSerial)) {
+ Status = SerialPortInitialize();
+ ASSERT_EFI_ERROR (Status);
+ }
+ if (FeaturePcdGet (PcdStatusCodeUseMemory)) {
+ Status = MemoryStatusCodeInitializeWorker ();
+ ASSERT_EFI_ERROR (Status);
+ }
+ if (FeaturePcdGet (PcdStatusCodeUseOEM)) {
+ Status = OemHookStatusCodeInitialize ();
+ ASSERT_EFI_ERROR (Status);
+ }
+
+ //
+ // Install PeiStatusCodePpi.
+ // PeiServices use this Ppi to output status code.
+ // use library
+ Status = PeiServicesInstallPpi (&mStatusCodePpiDescriptor);
+ ASSERT_EFI_ERROR (Status);
+
+ return EFI_SUCCESS;
+}
+
diff --git a/IntelFrameworkModulePkg/Universal/StatusCode/Pei/PeiStatusCode.h b/IntelFrameworkModulePkg/Universal/StatusCode/Pei/PeiStatusCode.h
new file mode 100644
index 0000000000..c8c004d6cd
--- /dev/null
+++ b/IntelFrameworkModulePkg/Universal/StatusCode/Pei/PeiStatusCode.h
@@ -0,0 +1,144 @@
+
+/** @file
+ Heade file of status code PEIM
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ Module Name: PeiStatusCode.h
+
+**/
+
+#ifndef __PEI_STATUS_CODE_H__
+#define __PEI_STATUS_CODE_H__
+
+
+//
+// Include common header file for this module.
+//
+#include "CommonHeader.h"
+
+/**
+ Convert status code value and extended data to readable ASCII string, send string to serial I/O device.
+
+ @param CodeType Indicates the type of status code being reported. Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.
+
+ @param Value Describes the current status of a hardware or software entity.
+ This included information about the class and subclass that is used to classify the entity
+ as well as an operation. For progress codes, the operation is the current activity.
+ For error codes, it is the exception. For debug codes, it is not defined at this time.
+ Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.
+ Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.
+
+ @param Instance The enumeration of a hardware or software entity within the system.
+ A system may contain multiple entities that match a class/subclass pairing.
+ The instance differentiates between them. An instance of 0 indicates that instance information is unavailable,
+ not meaningful, or not relevant. Valid instance numbers start with 1.
+
+
+ @param CallerId This optional parameter may be used to identify the caller.
+ This parameter allows the status code driver to apply different rules to different callers.
+ Type EFI_GUID is defined in InstallProtocolInterface() in the EFI 1.10 Specification.
+
+
+ @param Data This optional parameter may be used to pass additional data
+
+ @return The function always return EFI_SUCCESS.
+
+**/
+EFI_STATUS
+SerialStatusCodeReportWorker (
+ IN EFI_STATUS_CODE_TYPE CodeType,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN UINT32 Instance,
+ IN EFI_GUID *CallerId,
+ IN EFI_STATUS_CODE_DATA *Data OPTIONAL
+ );
+
+
+/**
+ Initialize memory status code.
+ Create one GUID'ed HOB with PCD defined size. If create required size
+ GUID'ed HOB failed, then ASSERT().
+
+ @return The function always return EFI_SUCCESS
+
+**/
+EFI_STATUS
+MemoryStatusCodeInitializeWorker (
+ VOID
+ );
+
+/**
+ Report status code into GUID'ed HOB.
+
+ @param CodeType Indicates the type of status code being reported. Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.
+
+ @param Value Describes the current status of a hardware or software entity.
+ This included information about the class and subclass that is used to classify the entity
+ as well as an operation. For progress codes, the operation is the current activity.
+ For error codes, it is the exception. For debug codes, it is not defined at this time.
+ Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.
+ Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.
+
+ @param Instance The enumeration of a hardware or software entity within the system.
+ A system may contain multiple entities that match a class/subclass pairing.
+ The instance differentiates between them. An instance of 0 indicates that instance information is unavailable,
+ not meaningful, or not relevant. Valid instance numbers start with 1.
+
+ @return The function always return EFI_SUCCESS.
+
+**/
+EFI_STATUS
+MemoryStatusCodeReportWorker (
+ IN EFI_STATUS_CODE_TYPE CodeType,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN UINT32 Instance
+ );
+
+/**
+ Report status code to all supported device.
+
+
+ @param PeiServices
+
+ @param Type Indicates the type of status code being reported.
+ The type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.
+ @param Value Describes the current status of a hardware or software entity.
+ This includes information about the class and subclass that is used to classify the entity
+ as well as an operation. For progress codes, the operation is the current activity.
+ For error codes, it is the exception. For debug codes, it is not defined at this time.
+ Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.
+ Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.
+ @param Instance The enumeration of a hardware or software entity within the system.
+ A system may contain multiple entities that match a class/subclass pairing.
+ The instance differentiates between them. An instance of 0 indicates that instance
+ information is unavailable, not meaningful, or not relevant. Valid instance numbers start with 1.
+ @param CallerId This optional parameter may be used to identify the caller.
+ This parameter allows the status code driver to apply different rules to different callers.
+ @param Data This optional parameter may be used to pass additional data.
+ Type EFI_STATUS_CODE_DATA is defined in "Related Definitions" below.
+ The contents of this data type may have additional GUID-specific data. The standard GUIDs and
+ their associated data structures are defined in the Intel? Platform Innovation Framework for EFI Status Codes Specification.
+
+ @return Always return EFI_SUCCESS.
+
+**/
+EFI_STATUS
+EFIAPI
+ReportDispatcher (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_STATUS_CODE_TYPE Type,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN UINT32 Instance,
+ IN EFI_GUID *CallerId OPTIONAL,
+ IN EFI_STATUS_CODE_DATA *Data OPTIONAL
+ );
+
+#endif
diff --git a/IntelFrameworkModulePkg/Universal/StatusCode/Pei/PeiStatusCode.inf b/IntelFrameworkModulePkg/Universal/StatusCode/Pei/PeiStatusCode.inf
new file mode 100644
index 0000000000..2812509df2
--- /dev/null
+++ b/IntelFrameworkModulePkg/Universal/StatusCode/Pei/PeiStatusCode.inf
@@ -0,0 +1,140 @@
+#/** @file
+# Generic Status code Pei driver
+#
+# Customized output devices based on feature flags.
+# Copyright (c) 2006, Intel Corporation.
+#
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+#
+#**/
+
+################################################################################
+#
+# Defines Section - statements that will be processed to create a Makefile.
+#
+################################################################################
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = PeiStatusCode
+ FILE_GUID = 1EC0F53A-FDE0-4576-8F25-7A1A410F58EB
+ MODULE_TYPE = PEIM
+ VERSION_STRING = 1.0
+ EDK_RELEASE_VERSION = 0x00020000
+ EFI_SPECIFICATION_VERSION = 0x00020000
+
+ ENTRY_POINT = PeiStatusCodeDriverEntry
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64 IPF EBC
+#
+
+################################################################################
+#
+# Sources Section - list of files that are required for the build to succeed.
+#
+################################################################################
+
+[Sources.common]
+ PeiStatusCode.c
+ MemoryStausCodeWorker.c
+ SerialStatusCodeWorker.c
+ PeiStatusCode.h
+ CommonHeader.h
+
+
+################################################################################
+#
+# Includes Section - list of Include locations that are required for
+# this module.
+#
+################################################################################
+
+[Includes]
+ $(WORKSPACE)/MdePkg/Include/Library
+ $(WORKSPACE)/IntelFrameworkPkg/Include
+ $(WORKSPACE)/IntelFrameworkModulePkg/Include
+ $(WORKSPACE)/IntelFrameworkModulePkg/Include/Library
+
+################################################################################
+#
+# Package Dependency Section - list of Package files that are required for
+# this module.
+#
+################################################################################
+
+[Packages]
+ MdePkg/MdePkg.dec
+ IntelFrameworkPkg/IntelFrameworkPkg.dec
+ IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec
+
+################################################################################
+#
+# Library Class Section - list of Library Classes that are required for
+# this module.
+#
+################################################################################
+
+[LibraryClasses]
+ PeimEntryPoint
+ OemHookStatusCodeLib
+ PeiServicesLib
+ PcdLib
+ HobLib
+ SerialPortLib
+ ReportStatusCodeLib
+ PrintLib
+ DebugLib
+ BaseMemoryLib
+ BaseLib
+
+
+################################################################################
+#
+# Guid C Name Section - list of Guids that this module uses or produces.
+#
+################################################################################
+
+[Guids]
+ gMemoryStatusCodeRecordGuid # SOMETIMES_CONSUMED
+
+
+################################################################################
+#
+# PPI C Name Section - list of PPI and PPI Notify C Names that this module
+# uses or produces.
+#
+################################################################################
+
+[Ppis]
+ gEfiPeiStatusCodePpiGuid # PPI ALWAYS_CONSUMED
+
+
+################################################################################
+#
+# Pcd FEATURE_FLAG - list of PCDs that this module is coded for.
+#
+################################################################################
+
+[PcdsFeatureFlag.common]
+ PcdStatusCodeUseOEM|gEfiIntelFrameworkModulePkgTokenSpaceGuid
+ PcdStatusCodeUseMemory|gEfiIntelFrameworkModulePkgTokenSpaceGuid
+ PcdStatusCodeUseSerial|gEfiIntelFrameworkModulePkgTokenSpaceGuid
+
+
+################################################################################
+#
+# Pcd DYNAMIC - list of PCDs that this module is coded for.
+#
+################################################################################
+
+[PcdsDynamic.common]
+ PcdStatusCodeMemorySize|gEfiIntelFrameworkModulePkgTokenSpaceGuid
+
diff --git a/IntelFrameworkModulePkg/Universal/StatusCode/Pei/PeiStatusCode.msa b/IntelFrameworkModulePkg/Universal/StatusCode/Pei/PeiStatusCode.msa
new file mode 100644
index 0000000000..d0cd00d7fa
--- /dev/null
+++ b/IntelFrameworkModulePkg/Universal/StatusCode/Pei/PeiStatusCode.msa
@@ -0,0 +1,111 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+ <MsaHeader>
+ <ModuleName>PeiStatusCode</ModuleName>
+ <ModuleType>PEIM</ModuleType>
+ <GuidValue>1EC0F53A-FDE0-4576-8F25-7A1A410F58EB</GuidValue>
+ <Version>1.0</Version>
+ <Abstract>Generic Status code Pei driver</Abstract>
+ <Description>Customized output devices based on feature flags.</Description>
+ <Copyright>Copyright (c) 2006, Intel Corporation.</Copyright>
+ <License>All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>
+ <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>
+ </MsaHeader>
+ <ModuleDefinitions>
+ <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>
+ <BinaryModule>false</BinaryModule>
+ <OutputFileBasename>PeiStatusCode</OutputFileBasename>
+ </ModuleDefinitions>
+ <LibraryClassDefinitions>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>BaseLib</Keyword>
+ </LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>BaseMemoryLib</Keyword>
+ </LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>DebugLib</Keyword>
+ </LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>PrintLib</Keyword>
+ </LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>ReportStatusCodeLib</Keyword>
+ </LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>SerialPortLib</Keyword>
+ </LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>HobLib</Keyword>
+ </LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>PcdLib</Keyword>
+ </LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>PeiServicesLib</Keyword>
+ </LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>OemHookStatusCodeLib</Keyword>
+ </LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>PeimEntryPoint</Keyword>
+ </LibraryClass>
+ </LibraryClassDefinitions>
+ <SourceFiles>
+ <Filename>PeiStatusCode.h</Filename>
+ <Filename>SerialStatusCodeWorker.c</Filename>
+ <Filename>MemoryStausCodeWorker.c</Filename>
+ <Filename>PeiStatusCode.c</Filename>
+ </SourceFiles>
+ <PackageDependencies>
+ <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
+ <Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
+ </PackageDependencies>
+ <PPIs>
+ <Ppi Usage="ALWAYS_CONSUMED">
+ <PpiCName>gEfiPeiStatusCodePpiGuid</PpiCName>
+ </Ppi>
+ </PPIs>
+ <Guids>
+ <GuidCNames Usage="SOMETIMES_CONSUMED">
+ <GuidCName>gMemoryStatusCodeRecordGuid</GuidCName>
+ </GuidCNames>
+ <GuidCNames Usage="SOMETIMES_CONSUMED">
+ <GuidCName>gEfiStatusCodeSpecificDataGuid</GuidCName>
+ </GuidCNames>
+ </Guids>
+ <Externs>
+ <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>
+ <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>
+ <Extern>
+ <ModuleEntryPoint>PeiStatusCodeDriverEntry</ModuleEntryPoint>
+ </Extern>
+ </Externs>
+ <PcdCoded>
+ <PcdEntry PcdItemType="FEATURE_FLAG">
+ <C_Name>PcdStatusCodeUseSerial</C_Name>
+ <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>
+ <HelpText/>
+ </PcdEntry>
+ <PcdEntry PcdItemType="FEATURE_FLAG">
+ <C_Name>PcdStatusCodeUseMemory</C_Name>
+ <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>
+ <HelpText/>
+ </PcdEntry>
+ <PcdEntry PcdItemType="FEATURE_FLAG">
+ <C_Name>PcdStatusCodeUseOEM</C_Name>
+ <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>
+ <HelpText/>
+ </PcdEntry>
+ <PcdEntry PcdItemType="DYNAMIC">
+ <C_Name>PcdStatusCodeMemorySize</C_Name>
+ <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>
+ <HelpText/>
+ </PcdEntry>
+ </PcdCoded>
+</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
index 0000000000..2efc23ceac
--- /dev/null
+++ b/IntelFrameworkModulePkg/Universal/StatusCode/Pei/SerialStatusCodeWorker.c
@@ -0,0 +1,174 @@
+
+/** @file
+ Serial I/O status code reporting worker.
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ Module Name: SerialStatusCodeWorker.c
+
+**/
+
+//
+// Include common header file for this module.
+//
+#include "CommonHeader.h"
+
+#include "PeiStatusCode.h"
+
+/**
+ Convert status code value and extended data to readable ASCII string, send string to serial I/O device.
+
+ @param CodeType Indicates the type of status code being reported. Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.
+
+ @param Value Describes the current status of a hardware or software entity.
+ This included information about the class and subclass that is used to classify the entity
+ as well as an operation. For progress codes, the operation is the current activity.
+ For error codes, it is the exception. For debug codes, it is not defined at this time.
+ Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.
+ Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.
+
+ @param Instance The enumeration of a hardware or software entity within the system.
+ A system may contain multiple entities that match a class/subclass pairing.
+ The instance differentiates between them. An instance of 0 indicates that instance information is unavailable,
+ not meaningful, or not relevant. Valid instance numbers start with 1.
+
+
+ @param CallerId This optional parameter may be used to identify the caller.
+ This parameter allows the status code driver to apply different rules to different callers.
+ Type EFI_GUID is defined in InstallProtocolInterface() in the EFI 1.10 Specification.
+
+
+ @param Data This optional parameter may be used to pass additional data
+
+ @return The function always return EFI_SUCCESS.
+
+**/
+EFI_STATUS
+SerialStatusCodeReportWorker (
+ IN EFI_STATUS_CODE_TYPE CodeType,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN UINT32 Instance,
+ IN EFI_GUID *CallerId,
+ IN EFI_STATUS_CODE_DATA *Data OPTIONAL
+ )
+{
+ CHAR8 *Filename;
+ CHAR8 *Description;
+ CHAR8 *Format;
+ CHAR8 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE];
+ UINT32 ErrorLevel;
+ UINT32 LineNumber;
+ UINTN CharCount;
+ VA_LIST Marker;
+ EFI_DEBUG_INFO *DebugInfo;
+
+ Buffer[0] = '\0';
+
+ if (Data != NULL &&
+ ReportStatusCodeExtractAssertInfo (CodeType, Value, Data, &Filename, &Description, &LineNumber)) {
+ //
+ // Print ASSERT() information into output buffer.
+ //
+ CharCount = AsciiSPrint (
+ Buffer,
+ EFI_STATUS_CODE_DATA_MAX_SIZE,
+ "\n\rPEI_ASSERT!: %a (%d): %a\n\r",
+ Filename,
+ LineNumber,
+ Description
+ );
+ } else if (Data != NULL &&
+ ReportStatusCodeExtractDebugInfo (Data, &ErrorLevel, &Marker, &Format)) {
+ //
+ // Print DEBUG() information into output buffer.
+ //
+ CharCount = AsciiVSPrint (
+ Buffer,
+ EFI_STATUS_CODE_DATA_MAX_SIZE,
+ Format,
+ Marker
+ );
+ } else if (Data != NULL &&
+ CompareGuid (&Data->Type, &gEfiStatusCodeSpecificDataGuid) &&
+ (CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) {
+ //
+ // Print specific data into output buffer.
+ //
+ DebugInfo = (EFI_DEBUG_INFO *) (Data + 1);
+ Marker = (VA_LIST) (DebugInfo + 1);
+ Format = (CHAR8 *) (((UINT64 *) Marker) + 12);
+
+ CharCount = AsciiVSPrint (Buffer, EFI_STATUS_CODE_DATA_MAX_SIZE, Format, Marker);
+ } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) {
+ //
+ // Print ERROR information into output buffer.
+ //
+ CharCount = AsciiSPrint (
+ Buffer,
+ EFI_STATUS_CODE_DATA_MAX_SIZE,
+ "ERROR: C%x:V%x I%x",
+ CodeType,
+ Value,
+ Instance
+ );
+
+ //
+ // Make sure we don't try to print values that weren't intended to be printed, especially NULL GUID pointers.
+ //
+
+ if (CallerId != NULL) {
+ CharCount += AsciiSPrint (
+ &Buffer[CharCount - 1],
+ (EFI_STATUS_CODE_DATA_MAX_SIZE - (sizeof (Buffer[0]) * CharCount)),
+ " %g",
+ CallerId
+ );
+ }
+
+ if (Data != NULL) {
+ CharCount += AsciiSPrint (
+ &Buffer[CharCount - 1],
+ (EFI_STATUS_CODE_DATA_MAX_SIZE - (sizeof (Buffer[0]) * CharCount)),
+ " %x",
+ Data
+ );
+ }
+
+ CharCount += AsciiSPrint (
+ &Buffer[CharCount - 1],
+ (EFI_STATUS_CODE_DATA_MAX_SIZE - (sizeof (Buffer[0]) * CharCount)),
+ "\n\r"
+ );
+ } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) {
+ CharCount = AsciiSPrint (
+ Buffer,
+ EFI_STATUS_CODE_DATA_MAX_SIZE,
+ "PROGRESS CODE: V%x I%x\n\r",
+ Value,
+ Instance
+ );
+ } else {
+ CharCount = AsciiSPrint (
+ Buffer,
+ EFI_STATUS_CODE_DATA_MAX_SIZE,
+ "Undefined: C%x:V%x I%x\n\r",
+ CodeType,
+ Value,
+ Instance
+ );
+ }
+
+ //
+ // Callout to SerialPort Lib function to do print.
+ //
+ SerialPortWrite ((UINT8 *) Buffer, CharCount);
+
+ return EFI_SUCCESS;
+}