summaryrefslogtreecommitdiff
path: root/EdkModulePkg/Library/EdkRuntimeStatusCodeLib
diff options
context:
space:
mode:
authorbbahnsen <bbahnsen@6f19259b-4bc3-4df7-8a09-765794883524>2006-04-21 22:54:32 +0000
committerbbahnsen <bbahnsen@6f19259b-4bc3-4df7-8a09-765794883524>2006-04-21 22:54:32 +0000
commit878ddf1fc3540a715f63594ed22b6929e881afb4 (patch)
treec56c44dac138137b510e1fba7c3efe5e4d84bea2 /EdkModulePkg/Library/EdkRuntimeStatusCodeLib
downloadedk2-platforms-878ddf1fc3540a715f63594ed22b6929e881afb4.tar.xz
Initial import.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@3 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'EdkModulePkg/Library/EdkRuntimeStatusCodeLib')
-rw-r--r--EdkModulePkg/Library/EdkRuntimeStatusCodeLib/BsDataHubStatusCode/BsDataHubStatusCode.c397
-rw-r--r--EdkModulePkg/Library/EdkRuntimeStatusCodeLib/BsDataHubStatusCode/BsDataHubStatusCode.h130
-rw-r--r--EdkModulePkg/Library/EdkRuntimeStatusCodeLib/BsDataHubStatusCode/BsDataHubStatusCode.mbd30
-rw-r--r--EdkModulePkg/Library/EdkRuntimeStatusCodeLib/BsDataHubStatusCode/BsDataHubStatusCode.msa72
-rw-r--r--EdkModulePkg/Library/EdkRuntimeStatusCodeLib/BsDataHubStatusCode/build.xml47
-rw-r--r--EdkModulePkg/Library/EdkRuntimeStatusCodeLib/RtMemoryStatusCode/RtMemoryStatusCode.c188
-rw-r--r--EdkModulePkg/Library/EdkRuntimeStatusCodeLib/RtMemoryStatusCode/RtMemoryStatusCode.mbd30
-rw-r--r--EdkModulePkg/Library/EdkRuntimeStatusCodeLib/RtMemoryStatusCode/RtMemoryStatusCode.msa52
-rw-r--r--EdkModulePkg/Library/EdkRuntimeStatusCodeLib/RtMemoryStatusCode/build.xml47
-rw-r--r--EdkModulePkg/Library/EdkRuntimeStatusCodeLib/RtPlatformStatusCode/RtPlatformStatusCode.c130
-rw-r--r--EdkModulePkg/Library/EdkRuntimeStatusCodeLib/RtPlatformStatusCode/RtPlatformStatusCode.mbd30
-rw-r--r--EdkModulePkg/Library/EdkRuntimeStatusCodeLib/RtPlatformStatusCode/RtPlatformStatusCode.msa54
-rw-r--r--EdkModulePkg/Library/EdkRuntimeStatusCodeLib/RtPlatformStatusCode/build.xml47
13 files changed, 1254 insertions, 0 deletions
diff --git a/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/BsDataHubStatusCode/BsDataHubStatusCode.c b/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/BsDataHubStatusCode/BsDataHubStatusCode.c
new file mode 100644
index 0000000000..d72aae11a3
--- /dev/null
+++ b/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/BsDataHubStatusCode/BsDataHubStatusCode.c
@@ -0,0 +1,397 @@
+/*++
+
+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:
+
+ BsDataHubStatusCode.c
+
+Abstract:
+
+ This implements a status code listener that logs status codes into the data
+ hub. This is only active during non-runtime DXE.
+
+--*/
+#include "BsDataHubStatusCode.h"
+
+//
+// Globals only work at BootService Time. NOT at Runtime!
+//
+static EFI_DATA_HUB_PROTOCOL *mDataHub;
+static LIST_ENTRY mRecordBuffer;
+static INTN mRecordNum;
+static EFI_EVENT mLogDataHubEvent;
+static EFI_LOCK mStatusCodeReportLock;
+static BOOLEAN mEventHandlerActive = FALSE;
+
+STATUS_CODE_RECORD_LIST *
+GetRecordBuffer (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Returned buffer of length BYTES_PER_RECORD
+
+Arguments:
+
+ None
+
+Returns:
+
+ Entry in mRecordBuffer or NULL if non available
+
+--*/
+{
+ STATUS_CODE_RECORD_LIST *Buffer;
+
+ gBS->AllocatePool (EfiBootServicesData, sizeof (STATUS_CODE_RECORD_LIST), (VOID **) &Buffer);
+ if (Buffer == NULL) {
+ return NULL;
+ }
+
+ ZeroMem (Buffer, sizeof (STATUS_CODE_RECORD_LIST));
+ Buffer->Signature = BS_DATA_HUB_STATUS_CODE_SIGNATURE;
+
+ return Buffer;
+}
+
+DATA_HUB_STATUS_CODE_DATA_RECORD *
+AquireEmptyRecordBuffer (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Allocate a mRecordBuffer entry in the form of a pointer.
+
+Arguments:
+
+ None
+
+Returns:
+
+ Pointer to new buffer. NULL if none exist.
+
+--*/
+{
+ STATUS_CODE_RECORD_LIST *DataBuffer;
+
+ if (mRecordNum < MAX_RECORD_NUM) {
+ DataBuffer = GetRecordBuffer ();
+ if (DataBuffer != NULL) {
+ EfiAcquireLock (&mStatusCodeReportLock);
+ InsertTailList (&mRecordBuffer, &DataBuffer->Link);
+ mRecordNum++;
+ EfiReleaseLock (&mStatusCodeReportLock);
+ return (DATA_HUB_STATUS_CODE_DATA_RECORD *) DataBuffer->RecordBuffer;
+ }
+ }
+
+ return NULL;
+}
+
+EFI_STATUS
+ReleaseRecordBuffer (
+ IN STATUS_CODE_RECORD_LIST *RecordBuffer
+ )
+/*++
+
+Routine Description:
+
+ Release a mRecordBuffer entry allocated by AquireEmptyRecordBuffer ().
+
+Arguments:
+
+ RecordBuffer - Data to free
+
+Returns:
+
+ EFI_SUCCESS - If DataRecord is valid
+ EFI_UNSUPPORTED - The record list has empty
+
+--*/
+{
+ ASSERT (RecordBuffer != NULL);
+ if (mRecordNum <= 0) {
+ return EFI_UNSUPPORTED;
+ }
+
+ EfiAcquireLock (&mStatusCodeReportLock);
+ RemoveEntryList (&RecordBuffer->Link);
+ mRecordNum--;
+ EfiReleaseLock (&mStatusCodeReportLock);
+ gBS->FreePool (RecordBuffer);
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+BsDataHubReportStatusCode (
+ 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
+ )
+/*++
+
+Routine Description:
+
+ Boot service report status code listener. This function logs the status code
+ into the data hub.
+
+Arguments:
+
+ Same as ReportStatusCode (See Tiano Runtime Specification)
+
+Returns:
+
+ None
+
+--*/
+{
+ DATA_HUB_STATUS_CODE_DATA_RECORD *DataHub;
+ UINT32 ErrorLevel;
+ VA_LIST Marker;
+ CHAR8 *Format;
+ UINTN Index;
+ CHAR16 FormatBuffer[BYTES_PER_RECORD];
+
+ if (EfiAtRuntime ()) {
+ //
+ // For now all we do is post code at runtime
+ //
+ return EFI_SUCCESS;
+ }
+ //
+ // If we had an error while in our event handler, then do nothing so
+ // that we don't get in an endless loop.
+ //
+ if (mEventHandlerActive) {
+ return EFI_SUCCESS;
+ }
+
+ DataHub = (DATA_HUB_STATUS_CODE_DATA_RECORD *) AquireEmptyRecordBuffer ();
+ if (DataHub == NULL) {
+ //
+ // There are no empty record buffer in private buffers
+ //
+ return EFI_OUT_OF_RESOURCES;
+ }
+ //
+ // Construct Data Hub Extended Data
+ //
+ DataHub->CodeType = CodeType;
+ DataHub->Value = Value;
+ DataHub->Instance = Instance;
+
+ if (CallerId != NULL) {
+ CopyMem (&DataHub->CallerId, CallerId, sizeof (EFI_GUID));
+ } else {
+ ZeroMem (&DataHub->CallerId, sizeof (EFI_GUID));
+ }
+
+ if (Data == NULL) {
+ ZeroMem (&DataHub->Data, sizeof (EFI_STATUS_CODE_DATA));
+ } else {
+ //
+ // Copy generic Header
+ //
+ CopyMem (&DataHub->Data, Data, sizeof (EFI_STATUS_CODE_DATA));
+
+ if (ReportStatusCodeExtractDebugInfo (Data, &ErrorLevel, &Marker, &Format)) {
+ //
+ // Convert Ascii Format string to Unicode.
+ //
+ for (Index = 0; Format[Index] != '\0' && Index < (BYTES_PER_RECORD - 1); Index += 1) {
+ FormatBuffer[Index] = (CHAR16) Format[Index];
+ }
+
+ FormatBuffer[Index] = L'\0';
+
+ //
+ // Put processed string into the buffer
+ //
+ Index = UnicodeVSPrint (
+ (CHAR16 *) (DataHub + 1),
+ BYTES_PER_RECORD - (sizeof (DATA_HUB_STATUS_CODE_DATA_RECORD)),
+ FormatBuffer,
+ Marker
+ );
+
+ //
+ // DATA_HUB_STATUS_CODE_DATA_RECORD followed by VSPrint String Buffer
+ //
+ DataHub->Data.Size = (UINT16) (Index * sizeof (CHAR16));
+
+ } else {
+ //
+ // Default behavior is to copy optional data
+ //
+ if (Data->Size > (BYTES_PER_RECORD - sizeof (DATA_HUB_STATUS_CODE_DATA_RECORD))) {
+ DataHub->Data.Size = (UINT16) (BYTES_PER_RECORD - sizeof (DATA_HUB_STATUS_CODE_DATA_RECORD));
+ }
+
+ CopyMem (DataHub + 1, Data + 1, DataHub->Data.Size);
+ }
+ }
+
+ gBS->SignalEvent (mLogDataHubEvent);
+
+ return EFI_SUCCESS;
+}
+
+VOID
+EFIAPI
+LogDataHubEventHandler (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+/*++
+
+Routine Description:
+
+ The Event handler which will be notified to log data in Data Hub.
+
+Arguments:
+
+ Event - Instance of the EFI_EVENT to signal whenever data is
+ available to be logged in the system.
+ Context - Context of the event.
+
+Returns:
+
+ None.
+
+--*/
+{
+ EFI_STATUS Status;
+ DATA_HUB_STATUS_CODE_DATA_RECORD *DataRecord;
+ UINTN Size;
+ UINT64 DataRecordClass;
+ LIST_ENTRY *Link;
+ STATUS_CODE_RECORD_LIST *BufferEntry;
+
+ //
+ // Set our global flag so we don't recurse if we get an error here.
+ //
+ mEventHandlerActive = TRUE;
+
+ //
+ // Log DataRecord in Data Hub.
+ // If there are multiple DataRecords, Log all of them.
+ //
+ for (Link = mRecordBuffer.ForwardLink; Link != &mRecordBuffer;) {
+ BufferEntry = CR (Link, STATUS_CODE_RECORD_LIST, Link, BS_DATA_HUB_STATUS_CODE_SIGNATURE);
+ DataRecord = (DATA_HUB_STATUS_CODE_DATA_RECORD *) (BufferEntry->RecordBuffer);
+ Link = Link->ForwardLink;
+
+ //
+ // Add in the size of the header we added.
+ //
+ Size = sizeof (DATA_HUB_STATUS_CODE_DATA_RECORD) + DataRecord->Data.Size;
+
+ if ((DataRecord->CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) {
+ DataRecordClass = EFI_DATA_RECORD_CLASS_PROGRESS_CODE;
+ } else if ((DataRecord->CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) {
+ DataRecordClass = EFI_DATA_RECORD_CLASS_ERROR;
+ } else if ((DataRecord->CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) {
+ DataRecordClass = EFI_DATA_RECORD_CLASS_DEBUG;
+ } else {
+ //
+ // Should never get here.
+ //
+ DataRecordClass = EFI_DATA_RECORD_CLASS_DEBUG |
+ EFI_DATA_RECORD_CLASS_ERROR |
+ EFI_DATA_RECORD_CLASS_DATA |
+ EFI_DATA_RECORD_CLASS_PROGRESS_CODE;
+ }
+
+ if (((DataRecord->Instance & EFI_D_ERROR) != 0) &&
+ (((DataRecord->Instance & EFI_D_POOL) != 0) || ((DataRecord->Instance & EFI_D_PAGE) != 0))
+ ) {
+ //
+ // If memory error, do not call LogData ().
+ //
+ DebugPrint ((UINTN)-1, "Memory Error\n");
+ Status = EFI_OUT_OF_RESOURCES;
+ } else {
+ //
+ // Log DataRecord in Data Hub
+ //
+ Status = mDataHub->LogData (
+ mDataHub,
+ &gEfiStatusCodeGuid,
+ &gEfiStatusCodeRuntimeProtocolGuid,
+ DataRecordClass,
+ DataRecord,
+ (UINT32) Size
+ );
+ }
+
+ ReleaseRecordBuffer (BufferEntry);
+ }
+
+ mEventHandlerActive = FALSE;
+
+ return ;
+}
+
+VOID
+BsDataHubStatusCodeInitialize (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Install a data hub listener.
+
+Arguments:
+
+ (Standard EFI Image entry - EFI_IMAGE_ENTRY_POINT)
+
+Returns:
+
+ EFI_SUCCESS - Logging Hub protocol installed
+ Other - No protocol installed, unload driver.
+
+--*/
+{
+ EFI_STATUS Status;
+
+ Status = gBS->LocateProtocol (&gEfiDataHubProtocolGuid, NULL, (VOID **) &mDataHub);
+ //
+ // Should never fail due to dependency grammer
+ //
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Initialize FIFO
+ //
+ InitializeListHead (&mRecordBuffer);
+ mRecordNum = 0;
+
+ EfiInitializeLock (&mStatusCodeReportLock, EFI_TPL_HIGH_LEVEL);
+
+ //
+ // Create a Notify Event to log data in Data Hub
+ //
+ Status = gBS->CreateEvent (
+ EFI_EVENT_NOTIFY_SIGNAL,
+ EFI_TPL_CALLBACK,
+ LogDataHubEventHandler,
+ NULL,
+ &mLogDataHubEvent
+ );
+
+}
diff --git a/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/BsDataHubStatusCode/BsDataHubStatusCode.h b/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/BsDataHubStatusCode/BsDataHubStatusCode.h
new file mode 100644
index 0000000000..f15a90e5e2
--- /dev/null
+++ b/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/BsDataHubStatusCode/BsDataHubStatusCode.h
@@ -0,0 +1,130 @@
+/*++
+
+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:
+
+ BsDataHubStatusCode.h
+
+Abstract:
+
+ Header for the status code data hub logging component
+
+--*/
+
+#ifndef _EFI_BS_DATA_HUB_STATUS_CODE_H_
+#define _EFI_BS_DATA_HUB_STATUS_CODE_H_
+
+//
+// Private data declarations
+//
+#define MAX_RECORD_NUM 1000
+#define BYTES_PER_RECORD EFI_STATUS_CODE_DATA_MAX_SIZE
+#define EMPTY_RECORD_TAG 0xFF
+
+#define BS_DATA_HUB_STATUS_CODE_SIGNATURE EFI_SIGNATURE_32 ('B', 'D', 'H', 'S')
+
+typedef struct {
+ UINTN Signature;
+ LIST_ENTRY Link;
+ UINT8 RecordBuffer[BYTES_PER_RECORD];
+} STATUS_CODE_RECORD_LIST;
+
+//
+// Function prototypes
+//
+STATUS_CODE_RECORD_LIST *
+GetRecordBuffer (
+ VOID
+ )
+;
+
+/*++
+
+Routine Description:
+
+ Returned buffer of length BYTES_PER_RECORD
+
+Arguments:
+
+ None
+
+Returns:
+
+ Entry in mRecordBuffer or NULL if non available
+
+--*/
+DATA_HUB_STATUS_CODE_DATA_RECORD *
+AquireEmptyRecordBuffer (
+ VOID
+ )
+;
+
+/*++
+
+Routine Description:
+
+ Allocate a mRecordBuffer entry in the form of a pointer.
+
+Arguments:
+
+ None
+
+Returns:
+
+ Pointer to new buffer. NULL if none exist.
+
+--*/
+EFI_STATUS
+ReleaseRecordBuffer (
+ IN STATUS_CODE_RECORD_LIST *RecordBuffer
+ )
+;
+
+/*++
+
+Routine Description:
+
+ Release a mRecordBuffer entry allocated by AquireEmptyRecordBuffer ().
+
+Arguments:
+
+ RecordBuffer - Data to free
+
+Returns:
+
+ EFI_SUCCESS - If RecordBuffer is valid
+ EFI_UNSUPPORTED - The record list has empty
+
+--*/
+VOID
+EFIAPI
+LogDataHubEventHandler (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+;
+
+/*++
+
+Routine Description:
+
+ Event Handler that log in Status code in Data Hub.
+
+Arguments:
+
+ (Standard EFI Event Handler - EFI_EVENT_NOTIFY)
+
+Returns:
+
+ NONE
+
+--*/
+#endif
diff --git a/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/BsDataHubStatusCode/BsDataHubStatusCode.mbd b/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/BsDataHubStatusCode/BsDataHubStatusCode.mbd
new file mode 100644
index 0000000000..ce1bd63b0d
--- /dev/null
+++ b/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/BsDataHubStatusCode/BsDataHubStatusCode.mbd
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<LibraryModuleBuildDescription xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MbdLibHeader>
+ <BaseName>EdkBsDataHubStatusCodeLib</BaseName>
+ <Guid>041bf780-dc3e-49ab-8d67-4b86075440ea</Guid>
+ <Version>0</Version>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004 - 2005, 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>
+ <Created>2006-03-12 17:09</Created>
+ <Modified>2006-03-19 15:19</Modified>
+ </MbdLibHeader>
+</LibraryModuleBuildDescription>
diff --git a/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/BsDataHubStatusCode/BsDataHubStatusCode.msa b/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/BsDataHubStatusCode/BsDataHubStatusCode.msa
new file mode 100644
index 0000000000..7eff726640
--- /dev/null
+++ b/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/BsDataHubStatusCode/BsDataHubStatusCode.msa
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<LibraryModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MsaLibHeader>
+ <BaseName>EdkBsDataHubStatusCodeLib</BaseName>
+ <ModuleType>DXE_DRIVER</ModuleType>
+ <ComponentType>LIBRARY</ComponentType>
+ <Guid>041bf780-dc3e-49ab-8d67-4b86075440ea</Guid>
+ <Version>0</Version>
+ <Abstract>Component description file for the PEI library.</Abstract>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004 - 2005, 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>0</Specification>
+ <Created>2006-03-12 17:09</Created>
+ <Updated>2006-03-19 15:19</Updated>
+ </MsaLibHeader>
+ <LibraryClassDefinitions>
+ <LibraryClass Usage="ALWAYS_PRODUCED">EdkBsDataHubStatusCodeLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">UefiLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">DebugLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">BaseLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">BaseMemoryLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">DxeRuntimeDriverLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">ReportStatusCodeLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">PrintLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">UefiBootServicesTableLib</LibraryClass>
+ </LibraryClassDefinitions>
+ <SourceFiles>
+ <Filename>BsDataHubStatusCode.c</Filename>
+ <Filename>BsDataHubStatusCode.h</Filename>
+ </SourceFiles>
+ <Includes>
+ <PackageName>MdePkg</PackageName>
+ <PackageName>EdkModulePkg</PackageName>
+ </Includes>
+ <Protocols>
+ <Protocol Usage="ALWAYS_CONSUMED">StatusCode</Protocol>
+ <Protocol Usage="ALWAYS_CONSUMED">DataHub</Protocol>
+ </Protocols>
+ <Events>
+ <CreateEvents>
+ <Event>
+ <C_Name>EFI_EVENT_NOTIFY_SIGNAL</C_Name>
+ </Event>
+ </CreateEvents>
+ </Events>
+ <DataHubs>
+ <DataHubRecord>gEfiStatusCodeGuid</DataHubRecord>
+ </DataHubs>
+ <Guids>
+ <GuidEntry Usage="ALWAYS_CONSUMED">
+ <C_Name>StatusCode</C_Name>
+ </GuidEntry>
+ </Guids>
+</LibraryModuleSurfaceArea>
diff --git a/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/BsDataHubStatusCode/build.xml b/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/BsDataHubStatusCode/build.xml
new file mode 100644
index 0000000000..308ca95b11
--- /dev/null
+++ b/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/BsDataHubStatusCode/build.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?><!-- 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.-->
+<project basedir="." default="EdkBsDataHubStatusCodeLib"><!--Apply external ANT tasks-->
+ <taskdef resource="GenBuild.tasks"/>
+ <taskdef resource="net/sf/antcontrib/antlib.xml"/>
+ <property environment="env"/>
+ <property name="WORKSPACE_DIR" value="${env.WORKSPACE}"/>
+ <import file="${WORKSPACE_DIR}\Tools\Conf\BuildMacro.xml"/><!--MODULE_RELATIVE PATH is relative to PACKAGE_DIR-->
+ <property name="MODULE_RELATIVE_PATH" value="Library\EdkRuntimeStatusCodeLib\BsDataHubStatusCode"/>
+ <property name="MODULE_DIR" value="${PACKAGE_DIR}\${MODULE_RELATIVE_PATH}"/>
+ <property name="COMMON_FILE" value="${WORKSPACE_DIR}\Tools\Conf\Common.xml"/>
+ <target name="EdkBsDataHubStatusCodeLib">
+ <GenBuild baseName="EdkBsDataHubStatusCodeLib" mbdFilename="${MODULE_DIR}\BsDataHubStatusCode.mbd" msaFilename="${MODULE_DIR}\BsDataHubStatusCode.msa"/>
+ </target>
+ <target depends="EdkBsDataHubStatusCodeLib_clean" name="clean"/>
+ <target depends="EdkBsDataHubStatusCodeLib_cleanall" name="cleanall"/>
+ <target name="EdkBsDataHubStatusCodeLib_clean">
+ <OutputDirSetup baseName="EdkBsDataHubStatusCodeLib" mbdFilename="${MODULE_DIR}\BsDataHubStatusCode.mbd" msaFilename="${MODULE_DIR}\BsDataHubStatusCode.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\EdkBsDataHubStatusCodeLib_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\EdkBsDataHubStatusCodeLib_build.xml" target="clean"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}" excludes="*.xml"/>
+ </target>
+ <target name="EdkBsDataHubStatusCodeLib_cleanall">
+ <OutputDirSetup baseName="EdkBsDataHubStatusCodeLib" mbdFilename="${MODULE_DIR}\BsDataHubStatusCode.mbd" msaFilename="${MODULE_DIR}\BsDataHubStatusCode.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\EdkBsDataHubStatusCodeLib_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\EdkBsDataHubStatusCodeLib_build.xml" target="cleanall"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}"/>
+ <delete dir="${DEST_DIR_DEBUG}"/>
+ <delete>
+ <fileset dir="${BIN_DIR}" includes="**EdkBsDataHubStatusCodeLib*"/>
+ </delete>
+ </target>
+</project> \ No newline at end of file
diff --git a/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/RtMemoryStatusCode/RtMemoryStatusCode.c b/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/RtMemoryStatusCode/RtMemoryStatusCode.c
new file mode 100644
index 0000000000..375a338a85
--- /dev/null
+++ b/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/RtMemoryStatusCode/RtMemoryStatusCode.c
@@ -0,0 +1,188 @@
+/*++
+
+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:
+
+ RtMemoryStatusCode.c
+
+Abstract:
+
+ EFI lib to provide memory journal status code reporting routines.
+
+--*/
+
+#include <Ppi/StatusCodeMemory.h>
+
+//
+// Global variables
+//
+PEI_STATUS_CODE_MEMORY_PPI mStatusCodeMemoryPpi = { 0, 0, 0, 0 };
+
+//
+// Function implementations
+//
+EFI_STATUS
+RtMemoryReportStatusCode (
+ 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
+ )
+/*++
+
+Routine Description:
+
+ Log a status code to a memory journal. If no memory journal exists,
+ we will just return.
+
+Arguments:
+
+ Same as ReportStatusCode AP
+
+Returns:
+
+ EFI_SUCCESS This function always returns success
+
+--*/
+{
+ EFI_STATUS_CODE_ENTRY *CurrentEntry;
+ UINTN MaxEntry;
+
+ //
+ // We don't care to log debug codes.
+ //
+ if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) {
+ return EFI_SUCCESS;
+ }
+ //
+ // Update the latest entry in the journal.
+ //
+ MaxEntry = mStatusCodeMemoryPpi.Length / sizeof (EFI_STATUS_CODE_ENTRY);
+ if (!MaxEntry) {
+ //
+ // If we don't have any entries, then we can return.
+ // This effectively means that no memory buffer was passed forward from PEI.
+ //
+ return EFI_SUCCESS;
+ }
+
+ CurrentEntry = (EFI_STATUS_CODE_ENTRY *) (UINTN) (mStatusCodeMemoryPpi.Address + (mStatusCodeMemoryPpi.LastEntry * sizeof (EFI_STATUS_CODE_ENTRY)));
+
+ mStatusCodeMemoryPpi.LastEntry = (mStatusCodeMemoryPpi.LastEntry + 1) % MaxEntry;
+ if (mStatusCodeMemoryPpi.LastEntry == mStatusCodeMemoryPpi.FirstEntry) {
+ mStatusCodeMemoryPpi.FirstEntry = (mStatusCodeMemoryPpi.FirstEntry + 1) % MaxEntry;
+ }
+
+ CurrentEntry->Type = CodeType;
+ CurrentEntry->Value = Value;
+ CurrentEntry->Instance = Instance;
+
+ return EFI_SUCCESS;
+}
+
+VOID
+RtMemoryStatusCodeInitialize (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Initialization routine.
+ Allocates heap space for storing Status Codes.
+ Installs a PPI to point to that heap space.
+ Installs a callback to switch to memory.
+ Installs a callback to
+
+Arguments:
+
+ (Standard EFI Image entry - EFI_IMAGE_ENTRY_POINT)
+
+Returns:
+
+ None
+
+--*/
+{
+ EFI_HOB_GUID_TYPE *GuidHob;
+ PEI_STATUS_CODE_MEMORY_PPI **StatusCodeMemoryPpi;
+
+ GuidHob = GetFirstGuidHob (&gPeiStatusCodeMemoryPpiGuid);
+ if (GuidHob == NULL) {
+ return;
+ }
+
+ StatusCodeMemoryPpi = GET_GUID_HOB_DATA (GuidHob);
+
+ //
+ // Copy data to our structure since the HOB will go away at runtime
+ //
+ // BUGBUG: Virtualize for RT
+ //
+ mStatusCodeMemoryPpi.FirstEntry = (*StatusCodeMemoryPpi)->FirstEntry;
+ mStatusCodeMemoryPpi.LastEntry = (*StatusCodeMemoryPpi)->LastEntry;
+ mStatusCodeMemoryPpi.Address = (*StatusCodeMemoryPpi)->Address;
+ mStatusCodeMemoryPpi.Length = (*StatusCodeMemoryPpi)->Length;
+}
+
+VOID
+PlaybackStatusCodes (
+ IN EFI_REPORT_STATUS_CODE ReportStatusCodeFunc
+ )
+/*++
+
+Routine Description:
+
+ Call the input ReportStatusCode function with every status code recorded in
+ the journal.
+
+Arguments:
+
+ ReportStatusCode ReportStatusCode function to call.
+
+Returns:
+
+ None
+
+--*/
+{
+ UINTN MaxEntry;
+ EFI_STATUS_CODE_ENTRY *CurrentEntry;
+ UINTN Counter;
+
+ if (ReportStatusCodeFunc == RtMemoryReportStatusCode) {
+ return ;
+ }
+ //
+ // Playback prior status codes to current listeners
+ //
+ MaxEntry = mStatusCodeMemoryPpi.Length / sizeof (EFI_STATUS_CODE_ENTRY);
+ for (Counter = mStatusCodeMemoryPpi.FirstEntry; Counter != mStatusCodeMemoryPpi.LastEntry; Counter++) {
+ //
+ // Check if we have to roll back to beginning of queue buffer
+ //
+ if (Counter == MaxEntry) {
+ Counter = 0;
+ }
+ //
+ // Play current entry
+ //
+ CurrentEntry = (EFI_STATUS_CODE_ENTRY *) (UINTN) (mStatusCodeMemoryPpi.Address + (Counter * sizeof (EFI_STATUS_CODE_ENTRY)));
+ ReportStatusCodeFunc (
+ CurrentEntry->Type,
+ CurrentEntry->Value,
+ CurrentEntry->Instance,
+ NULL,
+ NULL
+ );
+ }
+}
diff --git a/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/RtMemoryStatusCode/RtMemoryStatusCode.mbd b/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/RtMemoryStatusCode/RtMemoryStatusCode.mbd
new file mode 100644
index 0000000000..1795204d66
--- /dev/null
+++ b/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/RtMemoryStatusCode/RtMemoryStatusCode.mbd
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<LibraryModuleBuildDescription xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MbdLibHeader>
+ <BaseName>EdkRtMemoryStatusCodeLib</BaseName>
+ <Guid>1517564b-ab66-42b7-8903-731a95f314f9</Guid>
+ <Version>0</Version>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004 - 2005, 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>
+ <Created>2006-03-12 17:09</Created>
+ <Modified>2006-03-19 15:19</Modified>
+ </MbdLibHeader>
+</LibraryModuleBuildDescription>
diff --git a/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/RtMemoryStatusCode/RtMemoryStatusCode.msa b/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/RtMemoryStatusCode/RtMemoryStatusCode.msa
new file mode 100644
index 0000000000..84d38e3293
--- /dev/null
+++ b/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/RtMemoryStatusCode/RtMemoryStatusCode.msa
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<LibraryModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MsaLibHeader>
+ <BaseName>EdkRtMemoryStatusCodeLib</BaseName>
+ <ModuleType>DXE_DRIVER</ModuleType>
+ <ComponentType>LIBRARY</ComponentType>
+ <Guid>1517564b-ab66-42b7-8903-731a95f314f9</Guid>
+ <Version>0</Version>
+ <Abstract>Component description file for the PEI library.</Abstract>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004 - 2005, 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>0</Specification>
+ <Created>2006-03-12 17:09</Created>
+ <Updated>2006-03-19 15:19</Updated>
+ </MsaLibHeader>
+ <LibraryClassDefinitions>
+ <LibraryClass Usage="ALWAYS_PRODUCED">EdkRtMemoryStatusCodeLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">UefiLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">DebugLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">BaseLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">DxeRuntimeDriverLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">ReportStatusCodeLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">PrintLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">HobLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">UefiBootServicesTableLib</LibraryClass>
+ </LibraryClassDefinitions>
+ <SourceFiles>
+ <Filename>RtMemoryStatusCode.c</Filename>
+ </SourceFiles>
+ <Includes>
+ <PackageName>MdePkg</PackageName>
+ <PackageName>EdkModulePkg</PackageName>
+ </Includes>
+</LibraryModuleSurfaceArea>
diff --git a/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/RtMemoryStatusCode/build.xml b/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/RtMemoryStatusCode/build.xml
new file mode 100644
index 0000000000..0f02e4e8f7
--- /dev/null
+++ b/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/RtMemoryStatusCode/build.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?><!-- 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.-->
+<project basedir="." default="EdkRtMemoryStatusCodeLib"><!--Apply external ANT tasks-->
+ <taskdef resource="GenBuild.tasks"/>
+ <taskdef resource="net/sf/antcontrib/antlib.xml"/>
+ <property environment="env"/>
+ <property name="WORKSPACE_DIR" value="${env.WORKSPACE}"/>
+ <import file="${WORKSPACE_DIR}\Tools\Conf\BuildMacro.xml"/><!--MODULE_RELATIVE PATH is relative to PACKAGE_DIR-->
+ <property name="MODULE_RELATIVE_PATH" value="Library\EdkRuntimeStatusCodeLib\RtMemoryStatusCode"/>
+ <property name="MODULE_DIR" value="${PACKAGE_DIR}\${MODULE_RELATIVE_PATH}"/>
+ <property name="COMMON_FILE" value="${WORKSPACE_DIR}\Tools\Conf\Common.xml"/>
+ <target name="EdkRtMemoryStatusCodeLib">
+ <GenBuild baseName="EdkRtMemoryStatusCodeLib" mbdFilename="${MODULE_DIR}\RtMemoryStatusCode.mbd" msaFilename="${MODULE_DIR}\RtMemoryStatusCode.msa"/>
+ </target>
+ <target depends="EdkRtMemoryStatusCodeLib_clean" name="clean"/>
+ <target depends="EdkRtMemoryStatusCodeLib_cleanall" name="cleanall"/>
+ <target name="EdkRtMemoryStatusCodeLib_clean">
+ <OutputDirSetup baseName="EdkRtMemoryStatusCodeLib" mbdFilename="${MODULE_DIR}\RtMemoryStatusCode.mbd" msaFilename="${MODULE_DIR}\RtMemoryStatusCode.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\EdkRtMemoryStatusCodeLib_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\EdkRtMemoryStatusCodeLib_build.xml" target="clean"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}" excludes="*.xml"/>
+ </target>
+ <target name="EdkRtMemoryStatusCodeLib_cleanall">
+ <OutputDirSetup baseName="EdkRtMemoryStatusCodeLib" mbdFilename="${MODULE_DIR}\RtMemoryStatusCode.mbd" msaFilename="${MODULE_DIR}\RtMemoryStatusCode.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\EdkRtMemoryStatusCodeLib_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\EdkRtMemoryStatusCodeLib_build.xml" target="cleanall"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}"/>
+ <delete dir="${DEST_DIR_DEBUG}"/>
+ <delete>
+ <fileset dir="${BIN_DIR}" includes="**EdkRtMemoryStatusCodeLib*"/>
+ </delete>
+ </target>
+</project> \ No newline at end of file
diff --git a/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/RtPlatformStatusCode/RtPlatformStatusCode.c b/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/RtPlatformStatusCode/RtPlatformStatusCode.c
new file mode 100644
index 0000000000..47f7f96511
--- /dev/null
+++ b/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/RtPlatformStatusCode/RtPlatformStatusCode.c
@@ -0,0 +1,130 @@
+/*++
+
+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:
+
+ RtPlatformStatusCode.c
+
+Abstract:
+
+ Contains NT32 specific implementations required to use status codes.
+
+--*/
+
+//
+// Globals only work at BootService Time. NOT at Runtime!
+//
+//
+
+typedef
+EFI_STATUS
+(EFIAPI *REPORT_STATUS_CODE_FUNCTION) (
+ 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
+ );
+
+REPORT_STATUS_CODE_FUNCTION mPeiReportStatusCode;
+
+//
+// Function implementations
+//
+EFI_STATUS
+RtPlatformReportStatusCode (
+ 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
+ )
+/*++
+
+Routine Description:
+
+ Call all status code listeners in the MonoStatusCode.
+
+Arguments:
+
+ Same as ReportStatusCode service
+
+Returns:
+
+ EFI_SUCCESS Always returns success.
+
+--*/
+{
+ RtMemoryReportStatusCode (CodeType, Value, Instance, CallerId, Data);
+ if (EfiAtRuntime ()) {
+ //
+ // For now all we do is post code at runtime
+ //
+ return EFI_SUCCESS;
+ }
+
+ BsDataHubReportStatusCode (CodeType, Value, Instance, CallerId, Data);
+
+ //
+ // Call back into PEI to get status codes. This is because SecMain contains
+ // status code that reports to Win32.
+ //
+ if (mPeiReportStatusCode != NULL) {
+ return mPeiReportStatusCode (CodeType, Value, Instance, CallerId, Data);
+ }
+
+ return EFI_SUCCESS;
+}
+
+VOID
+RtPlatformStatusCodeInitialize (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Initialize the status code listeners.
+
+Arguments:
+
+ (Standard EFI Image entry - EFI_IMAGE_ENTRY_POINT)
+
+Returns:
+
+ None
+
+--*/
+{
+ EFI_HOB_GUID_TYPE *GuidHob;
+ void *Pointer;
+
+ RtMemoryStatusCodeInitialize ();
+ BsDataHubStatusCodeInitialize ();
+
+ //
+ // Play any prior status codes to the data hub.
+ //
+ PlaybackStatusCodes (BsDataHubReportStatusCode);
+
+ //
+ // If PEI has a ReportStatusCode callback find it and use it before StdErr
+ // is connected.
+ //
+ mPeiReportStatusCode = NULL;
+
+ GuidHob = GetFirstGuidHob (&gEfiStatusCodeRuntimeProtocolGuid);
+ if (NULL == GuidHob) {
+ return;
+ }
+ Pointer = GET_GUID_HOB_DATA (GuidHob);
+ mPeiReportStatusCode = (REPORT_STATUS_CODE_FUNCTION) (*(UINTN *) Pointer);
+}
diff --git a/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/RtPlatformStatusCode/RtPlatformStatusCode.mbd b/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/RtPlatformStatusCode/RtPlatformStatusCode.mbd
new file mode 100644
index 0000000000..64591313c7
--- /dev/null
+++ b/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/RtPlatformStatusCode/RtPlatformStatusCode.mbd
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<LibraryModuleBuildDescription xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MbdLibHeader>
+ <BaseName>EdkRtPlatformStatusCodeLib</BaseName>
+ <Guid>68b157b5-9534-43ff-9cd3-6705e4e1d56c</Guid>
+ <Version>0</Version>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004 - 2005, 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>
+ <Created>2006-03-12 17:09</Created>
+ <Modified>2006-03-19 15:19</Modified>
+ </MbdLibHeader>
+</LibraryModuleBuildDescription>
diff --git a/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/RtPlatformStatusCode/RtPlatformStatusCode.msa b/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/RtPlatformStatusCode/RtPlatformStatusCode.msa
new file mode 100644
index 0000000000..2225ca5b2b
--- /dev/null
+++ b/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/RtPlatformStatusCode/RtPlatformStatusCode.msa
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<LibraryModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MsaLibHeader>
+ <BaseName>EdkRtPlatformStatusCodeLib</BaseName>
+ <ModuleType>DXE_DRIVER</ModuleType>
+ <ComponentType>LIBRARY</ComponentType>
+ <Guid>68b157b5-9534-43ff-9cd3-6705e4e1d56c</Guid>
+ <Version>0</Version>
+ <Abstract>Component description file for the PEI library.</Abstract>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004 - 2005, 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>0</Specification>
+ <Created>2006-03-12 17:09</Created>
+ <Updated>2006-03-19 15:19</Updated>
+ </MsaLibHeader>
+ <LibraryClassDefinitions>
+ <LibraryClass Usage="ALWAYS_PRODUCED">EdkRtPlatformStatusCodeLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">UefiLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">DebugLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">BaseLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">DxeRuntimeDriverLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">ReportStatusCodeLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">PrintLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">HobLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">EdkBsDataHubStatusCodeLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">EdkRtMemoryStatusCodeLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">UefiBootServicesTableLib</LibraryClass>
+ </LibraryClassDefinitions>
+ <SourceFiles>
+ <Filename>RtPlatformStatusCode.c</Filename>
+ </SourceFiles>
+ <Includes>
+ <PackageName>MdePkg</PackageName>
+ <PackageName>EdkModulePkg</PackageName>
+ </Includes>
+</LibraryModuleSurfaceArea>
diff --git a/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/RtPlatformStatusCode/build.xml b/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/RtPlatformStatusCode/build.xml
new file mode 100644
index 0000000000..34d4d7563c
--- /dev/null
+++ b/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/RtPlatformStatusCode/build.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?><!-- 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.-->
+<project basedir="." default="EdkRtPlatformStatusCodeLib"><!--Apply external ANT tasks-->
+ <taskdef resource="GenBuild.tasks"/>
+ <taskdef resource="net/sf/antcontrib/antlib.xml"/>
+ <property environment="env"/>
+ <property name="WORKSPACE_DIR" value="${env.WORKSPACE}"/>
+ <import file="${WORKSPACE_DIR}\Tools\Conf\BuildMacro.xml"/><!--MODULE_RELATIVE PATH is relative to PACKAGE_DIR-->
+ <property name="MODULE_RELATIVE_PATH" value="Library\EdkRuntimeStatusCodeLib\RtPlatformStatusCode"/>
+ <property name="MODULE_DIR" value="${PACKAGE_DIR}\${MODULE_RELATIVE_PATH}"/>
+ <property name="COMMON_FILE" value="${WORKSPACE_DIR}\Tools\Conf\Common.xml"/>
+ <target name="EdkRtPlatformStatusCodeLib">
+ <GenBuild baseName="EdkRtPlatformStatusCodeLib" mbdFilename="${MODULE_DIR}\RtPlatformStatusCode.mbd" msaFilename="${MODULE_DIR}\RtPlatformStatusCode.msa"/>
+ </target>
+ <target depends="EdkRtPlatformStatusCodeLib_clean" name="clean"/>
+ <target depends="EdkRtPlatformStatusCodeLib_cleanall" name="cleanall"/>
+ <target name="EdkRtPlatformStatusCodeLib_clean">
+ <OutputDirSetup baseName="EdkRtPlatformStatusCodeLib" mbdFilename="${MODULE_DIR}\RtPlatformStatusCode.mbd" msaFilename="${MODULE_DIR}\RtPlatformStatusCode.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\EdkRtPlatformStatusCodeLib_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\EdkRtPlatformStatusCodeLib_build.xml" target="clean"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}" excludes="*.xml"/>
+ </target>
+ <target name="EdkRtPlatformStatusCodeLib_cleanall">
+ <OutputDirSetup baseName="EdkRtPlatformStatusCodeLib" mbdFilename="${MODULE_DIR}\RtPlatformStatusCode.mbd" msaFilename="${MODULE_DIR}\RtPlatformStatusCode.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\EdkRtPlatformStatusCodeLib_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\EdkRtPlatformStatusCodeLib_build.xml" target="cleanall"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}"/>
+ <delete dir="${DEST_DIR_DEBUG}"/>
+ <delete>
+ <fileset dir="${BIN_DIR}" includes="**EdkRtPlatformStatusCodeLib*"/>
+ </delete>
+ </target>
+</project> \ No newline at end of file