Add in more library for ECP.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2833 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
qwang12 2007-06-28 07:12:34 +00:00
parent 3eb9473ea9
commit b38907a6d4
28 changed files with 5481 additions and 0 deletions

View File

@ -0,0 +1,60 @@
/*++
Copyright (c) 2004 - 2005, 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:
MemoryStatusCodeLib.h
Abstract:
Lib to provide memory status code reporting.
--*/
#ifndef _PEI_MEMORY_STATUS_CODE_LIB_H_
#define _PEI_MEMORY_STATUS_CODE_LIB_H_
//
// Statements that include other files
//
#include "Tiano.h"
#include "Pei.h"
//
// Publicly exported data
//
extern BOOLEAN mRunningFromMemory;
//
// Initialization function
//
VOID
MemoryInitializeStatusCode (
IN EFI_FFS_FILE_HEADER *FfsHeader,
IN EFI_PEI_SERVICES **PeiServices
)
;
//
// Status code reporting function
//
EFI_STATUS
MemoryReportStatusCode (
IN EFI_PEI_SERVICES **PeiServices,
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
)
;
#endif

View File

@ -0,0 +1,93 @@
/*++
Copyright (c) 2004 - 2007, 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:
SimpleCpuIoLib.h
Abstract:
Light weight monolithic Cpu Io Lib to support PEI Modules.
--*/
#ifndef _PEI_SIMPLE_CPU_IO_LIB_H_
#define _PEI_SIMPLE_CPU_IO_LIB_H_
//
// Base IO Class Functions
//
UINT8
IoRead8 (
IN UINT64 Address
)
;
UINT16
IoRead16 (
IN UINT64 Address
)
;
UINT32
IoRead32 (
IN UINT64 Address
)
;
VOID
IoWrite8 (
IN UINT64 Address,
IN UINT8 Data
)
;
VOID
IoWrite16 (
IN UINT64 Address,
IN UINT16 Data
)
;
VOID
IoWrite32 (
IN UINT64 Address,
IN UINT32 Data
)
;
UINT32
MemRead32 (
IN UINT64 Address
)
;
UINT64
MemRead64 (
IN UINT64 Address
)
;
VOID
MemWrite32 (
IN UINT64 Address,
IN UINT32 Data
)
;
VOID
MemWrite64 (
IN UINT64 Address,
IN UINT64 Data
)
;
#endif

View File

@ -0,0 +1,521 @@
/*++
Copyright (c) 2004 - 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:
MemoryStatusCode.c
Abstract:
Lib to provide memory journal status code reporting Routines.
--*/
#include "MemoryStatusCode.h"
#include "PeiLib.h"
#include "MonoStatusCode.h"
//
// Global variable. Not accessible while running from flash.
// After we relocate ourselves into memory, we update this
// and use it to determine if we are running from flash or memory.
//
BOOLEAN mRunningFromMemory = FALSE;
//
// Global variable used to replace the PPI once we start running from memory.
//
PEI_STATUS_CODE_MEMORY_PPI mStatusCodeMemoryPpi = { 0, 0, 0, 0 };
//
// PPI descriptor for the MonoStatusCode PEIM, see MonoStatusCode.c
//
extern EFI_PEI_PPI_DESCRIPTOR mPpiListStatusCode;
VOID
EFIAPI
MemoryInitializeStatusCode (
IN EFI_FFS_FILE_HEADER *FfsHeader,
IN EFI_PEI_SERVICES **PeiServices
)
/*++
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:
FfsHeader - FV this PEIM was loaded from.
PeiServices - General purpose services available to every PEIM.
Returns:
None
--*/
{
EFI_STATUS Status;
MEMORY_STATUS_CODE_INSTANCE *PrivateData;
PEI_STATUS_CODE_MEMORY_PPI *StatusCodeMemoryPpi;
PEI_STATUS_CODE_PPI *ReportStatusCodePpi;
EFI_PHYSICAL_ADDRESS Buffer;
VOID *StartPointer;
UINTN Length;
UINTN LastEntry;
EFI_PEI_PPI_DESCRIPTOR *ReportStatusCodeDescriptor;
EFI_PEI_PPI_DESCRIPTOR *StatusCodeMemoryDescriptor;
//
// Determine if we are being called after relocation into memory.
//
if (!mRunningFromMemory) {
//
// If we are not running from memory, we need to allocate some heap and
// install the PPI
//
//
// Allocate heap storage for the journal
//
Status = (*PeiServices)->AllocatePool (
PeiServices,
PEI_STATUS_CODE_HEAP_LENGTH,
&StartPointer
);
//
// This is not a required feature to boot.
//
if (EFI_ERROR (Status)) {
return ;
}
//
// Allocate heap storage for private data
// The private data contains the FFS header for this PEIM,
// a PPI containing information about the status code journal, and
// a notification for the LoadFile service, to relocate the PEIM into
// memory.
//
Status = (*PeiServices)->AllocatePool (
PeiServices,
sizeof (MEMORY_STATUS_CODE_INSTANCE),
&PrivateData
);
//
// This is not a required feature to boot.
//
if (EFI_ERROR (Status)) {
return ;
}
//
// Update the contents of the private data.
//
PrivateData->Signature = MEMORY_STATUS_CODE_SIGNATURE;
PrivateData->This = PrivateData;
PrivateData->FfsHeader = FfsHeader;
PrivateData->PpiDescriptor.Flags = (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST);
PrivateData->PpiDescriptor.Guid = &gPeiStatusCodeMemoryPpiGuid;
PrivateData->PpiDescriptor.Ppi = &PrivateData->StatusCodeMemoryPpi;
PrivateData->StatusCodeMemoryPpi.FirstEntry = 0;
PrivateData->StatusCodeMemoryPpi.LastEntry = 0;
PrivateData->StatusCodeMemoryPpi.Address = (EFI_PHYSICAL_ADDRESS) (UINTN) StartPointer;
PrivateData->StatusCodeMemoryPpi.Length = PEI_STATUS_CODE_HEAP_LENGTH;
#if (PI_SPECIFICATION_VERSION < 0x00010000)
PrivateData->NotifyDescriptor.Flags =
(
EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK |
EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
);
PrivateData->NotifyDescriptor.Guid = &gPeiFvFileLoaderPpiGuid;
PrivateData->NotifyDescriptor.Notify = LoadImageCallback;
#endif
//
// Publish the PPI
//
Status = (*PeiServices)->InstallPpi (PeiServices, &PrivateData->PpiDescriptor);
if (EFI_ERROR (Status)) {
return ;
}
//
// Post a callback to relocate to memory
//
#if (PI_SPECIFICATION_VERSION < 0x00010000)
Status = (**PeiServices).NotifyPpi (PeiServices, &PrivateData->NotifyDescriptor);
if (EFI_ERROR (Status)) {
return ;
}
#endif
} else {
//
// If we are running from memory, we need to copy from the heap to a RT
// memory buffer.
//
//
// Locate Journal
//
Status = (*PeiServices)->LocatePpi (
PeiServices,
&gPeiStatusCodeMemoryPpiGuid,
0,
&StatusCodeMemoryDescriptor,
&StatusCodeMemoryPpi
);
if (EFI_ERROR (Status)) {
return ;
}
//
// Get private data
//
PrivateData = MEMORY_STATUS_CODE_FROM_DESCRIPTOR_THIS (StatusCodeMemoryDescriptor);
//
// At this point, we need to fix up any addresses that we have as the heap
// has moved.
//
PrivateData->PpiDescriptor.Ppi = &PrivateData->StatusCodeMemoryPpi;
PrivateData->PpiDescriptor.Guid = &gPeiStatusCodeMemoryPpiGuid;
PrivateData->StatusCodeMemoryPpi.Address = PrivateData->StatusCodeMemoryPpi.Address +
(UINTN) PrivateData - (UINTN) PrivateData->This;
PrivateData->This = PrivateData;
#if (PI_SPECIFICATION_VERSION < 0x00010000)
PrivateData->NotifyDescriptor.Guid = &gPeiFvFileLoaderPpiGuid;
PrivateData->NotifyDescriptor.Notify = LoadImageCallback;
#endif
//
// Allocate RT memory.
//
Status = (*PeiServices)->AllocatePages (
PeiServices,
EfiRuntimeServicesData,
PEI_STATUS_CODE_RT_PAGES,
&Buffer
);
if (EFI_ERROR (Status)) {
return ;
}
DEBUG_CODE (
EfiCommonLibZeroMem ((VOID *) (UINTN) Buffer, PEI_STATUS_CODE_RT_LENGTH);
)
//
// Copy the heap to the allocated memory.
// Unwind the rolling queue to start at 0 in the new space. We need to do
// this because the new queue is much bigger than the heap allocation.
//
if (PEI_STATUS_CODE_RT_LENGTH <= PEI_STATUS_CODE_HEAP_LENGTH) {
return ;
}
if (StatusCodeMemoryPpi->LastEntry >= StatusCodeMemoryPpi->FirstEntry) {
LastEntry = StatusCodeMemoryPpi->LastEntry - StatusCodeMemoryPpi->FirstEntry;
StartPointer = (VOID *) ((UINTN) StatusCodeMemoryPpi->Address + (StatusCodeMemoryPpi->FirstEntry * sizeof (EFI_STATUS_CODE_ENTRY)));
Length = (StatusCodeMemoryPpi->LastEntry - StatusCodeMemoryPpi->FirstEntry) * sizeof (EFI_STATUS_CODE_ENTRY);
(*PeiServices)->CopyMem ((VOID *) (UINTN) Buffer, StartPointer, Length);
} else {
//
// The last entry will be the new last entry after moving heap to buffer
//
LastEntry = (PEI_STATUS_CODE_MAX_HEAP_ENTRY - StatusCodeMemoryPpi->FirstEntry) + StatusCodeMemoryPpi->LastEntry;
//
// Copy from the first entry to the end of the heap
//
StartPointer = (VOID *) ((UINTN) StatusCodeMemoryPpi->Address + (StatusCodeMemoryPpi->FirstEntry * sizeof (EFI_STATUS_CODE_ENTRY)));
Length = PEI_STATUS_CODE_HEAP_LENGTH - (StatusCodeMemoryPpi->FirstEntry * sizeof (EFI_STATUS_CODE_ENTRY));
(*PeiServices)->CopyMem ((VOID *) (UINTN) Buffer, StartPointer, Length);
//
// Copy from the start to the heap to the last entry
//
StartPointer = (VOID *) (UINTN) StatusCodeMemoryPpi->Address;
(*PeiServices)->CopyMem (
(VOID *) (UINTN) (Buffer + Length),
StartPointer,
(StatusCodeMemoryPpi->LastEntry * sizeof (EFI_STATUS_CODE_ENTRY))
);
};
//
// Update the PPI to NULL, so it will not be used.
//
StatusCodeMemoryPpi->FirstEntry = 0;
StatusCodeMemoryPpi->LastEntry = 0;
StatusCodeMemoryPpi->Address = 0;
StatusCodeMemoryPpi->Length = 0;
//
// Update in memory version of PPI that will be used.
//
mStatusCodeMemoryPpi.FirstEntry = 0;
mStatusCodeMemoryPpi.LastEntry = LastEntry;
mStatusCodeMemoryPpi.Address = (EFI_PHYSICAL_ADDRESS) (UINTN) Buffer;
mStatusCodeMemoryPpi.Length = PEI_STATUS_CODE_RT_LENGTH;
//
// Reinstall the report status code function
//
//
// Locate status code PPI
//
Status = (*PeiServices)->LocatePpi (
PeiServices,
&gPeiStatusCodePpiGuid,
0,
&ReportStatusCodeDescriptor,
&ReportStatusCodePpi
);
if (EFI_ERROR (Status)) {
return ;
}
//
// Reinstall the ReportStatusCode interface using the memory-based
// descriptor
//
Status = (*PeiServices)->ReInstallPpi (
PeiServices,
ReportStatusCodeDescriptor,
&mPpiListStatusCode
);
if (EFI_ERROR (Status)) {
EFI_BREAKPOINT ();
return ;
}
//
// Publish a GUIDed HOB that contains a pointer to the status code PPI
// structure. This is a bit of a short cut as I just used the PPI GUID to
// identify the HOB. This HOB is caught by the DXE status code memory
// listener and used to find the journal.
//
StatusCodeMemoryPpi = &mStatusCodeMemoryPpi;
Status = PeiBuildHobGuidData (
PeiServices,
&gPeiStatusCodeMemoryPpiGuid,
&StatusCodeMemoryPpi,
sizeof (VOID *)
);
if (EFI_ERROR (Status)) {
EFI_BREAKPOINT ();
return ;
}
}
}
EFI_STATUS
EFIAPI
MemoryReportStatusCode (
IN EFI_PEI_SERVICES **PeiServices,
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:
Provide a memory status code
Arguments:
Same as ReportStatusCode PPI
Returns:
EFI_SUCCESS This function always returns success
--*/
{
EFI_STATUS Status;
PEI_STATUS_CODE_MEMORY_PPI *StatusCodeMemoryPpi;
EFI_STATUS_CODE_ENTRY *CurrentEntry;
UINTN LastEntry;
MEMORY_STATUS_CODE_INSTANCE *PrivateData;
EFI_PEI_PPI_DESCRIPTOR *StatusCodeMemoryDescriptor;
//
// We don't care to log debug codes.
//
if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) {
return EFI_SUCCESS;
}
if (!mRunningFromMemory) {
//
// If we are called from DXE and have not been reinstalled into memory, we
// can no longer locate the journal, so we can no longer log status codes.
//
if (!PeiServices) {
return EFI_SUCCESS;
}
//
// Locate Journal
//
Status = (*PeiServices)->LocatePpi (
PeiServices,
&gPeiStatusCodeMemoryPpiGuid,
0,
&StatusCodeMemoryDescriptor,
&StatusCodeMemoryPpi
);
if (EFI_ERROR (Status)) {
return EFI_SUCCESS;
}
//
// Determine the last entry in the journal.
// This is needed to properly implement the rolling queue.
//
LastEntry = PEI_STATUS_CODE_MAX_HEAP_ENTRY;
//
// Get private data
//
PrivateData = MEMORY_STATUS_CODE_FROM_DESCRIPTOR_THIS (StatusCodeMemoryDescriptor);
//
// Once memory gets installed, heap gets moved to real memory.
// We need to fix up the pointers to match the move.
//
PrivateData->PpiDescriptor.Ppi = &PrivateData->StatusCodeMemoryPpi;
PrivateData->PpiDescriptor.Guid = &gPeiStatusCodeMemoryPpiGuid;
PrivateData->StatusCodeMemoryPpi.Address = PrivateData->StatusCodeMemoryPpi.Address +
(UINTN) PrivateData - (UINTN) PrivateData->This;
PrivateData->This = PrivateData;
#if (PI_SPECIFICATION_VERSION < 0x00010000)
PrivateData->NotifyDescriptor.Guid = &gPeiFvFileLoaderPpiGuid;
PrivateData->NotifyDescriptor.Notify = LoadImageCallback;
#endif
StatusCodeMemoryPpi = PrivateData->PpiDescriptor.Ppi;
} else {
//
// Use global/memory copy of the PPI
//
StatusCodeMemoryPpi = &mStatusCodeMemoryPpi;
//
// Determine the last entry in the journal.
// This is needed to properly implement the rolling queue.
//
LastEntry = PEI_STATUS_CODE_MAX_RT_ENTRY;
}
//
// Return if we are using a cleared PPI somehow
//
if (!StatusCodeMemoryPpi->Address || !StatusCodeMemoryPpi->Length) {
return EFI_SUCCESS;
}
//
// Update the latest entry in the journal (may actually be first due to rolling
// queue).
//
CurrentEntry = (EFI_STATUS_CODE_ENTRY *) (UINTN) (StatusCodeMemoryPpi->Address + (StatusCodeMemoryPpi->LastEntry * sizeof (EFI_STATUS_CODE_ENTRY)));
StatusCodeMemoryPpi->LastEntry = (StatusCodeMemoryPpi->LastEntry + 1) % LastEntry;
if (StatusCodeMemoryPpi->LastEntry == StatusCodeMemoryPpi->FirstEntry) {
StatusCodeMemoryPpi->FirstEntry = (StatusCodeMemoryPpi->FirstEntry + 1) % LastEntry;
}
CurrentEntry->Type = CodeType;
CurrentEntry->Value = Value;
CurrentEntry->Instance = Instance;
return EFI_SUCCESS;
}
#if (PI_SPECIFICATION_VERSION < 0x00010000)
EFI_STATUS
EFIAPI
LoadImageCallback (
IN EFI_PEI_SERVICES **PeiServices,
IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,
IN VOID *Ppi
)
/*++
Routine Description:
Relocate the PEIM into memory.
Once load protocol becomes available, relocate our PEIM into memory.
The primary benefit is to eliminate the blackout window that we would have in
the memory log between the end of PEI and the status code DXE driver taking
control. If we don't do this, we cannot determine where our memory journal
is located and cannot function.
A second benefit is speed optimization throughout DXE.
Arguments:
PeiServices - General purpose services available to every PEIM.
NotifyDescriptor - Information about the notify event.
Ppi - Context
Returns:
EFI_SUCCESS This function always returns success.
--*/
{
EFI_STATUS Status;
EFI_PHYSICAL_ADDRESS ImageAddress;
EFI_PHYSICAL_ADDRESS EntryPoint;
UINT64 ImageSize;
MEMORY_STATUS_CODE_INSTANCE *PrivateData;
//
// Relocate to memory
//
if (!mRunningFromMemory) {
//
// Use the callback descriptor to get the FfsHeader
//
PrivateData = MEMORY_STATUS_CODE_FROM_NOTIFY_THIS (NotifyDescriptor);
Status = ((EFI_PEI_FV_FILE_LOADER_PPI *) Ppi)->FvLoadFile (
Ppi,
PrivateData->FfsHeader,
&ImageAddress,
&ImageSize,
&EntryPoint
);
if (EFI_ERROR (Status)) {
return EFI_SUCCESS;
}
//
// Set the flag in the loaded image that indicates the PEIM is executing
// from memory.
//
#ifdef EFI_NT_EMULATOR
//
// For NT32, we should also relocate image here, because if the DLL
// is already load, we will NOT load it twice. This feature is added to
// prevent loading driver twice in DXE phase cause system crash.
//
* (BOOLEAN *) ((UINTN) &mRunningFromMemory + (UINTN) EntryPoint - (UINTN) InstallMonoStatusCode) = TRUE;
#else
* (BOOLEAN *) ((UINTN) &mRunningFromMemory + (UINTN) EntryPoint - (UINTN) InstallMonoStatusCode) = TRUE;
#endif
Status = ((EFI_PEIM_ENTRY_POINT )(UINTN) EntryPoint) (PrivateData->FfsHeader, PeiServices);
if (EFI_ERROR (Status)) {
return EFI_SUCCESS;
}
}
return EFI_SUCCESS;
}
#endif

View File

@ -0,0 +1,103 @@
/*++
Copyright (c) 2004, 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:
MemoryStatusCode.h
Abstract:
Lib to provide status code reporting via memory.
--*/
#ifndef _PEI_MEMORY_STATUS_CODE_H_
#define _PEI_MEMORY_STATUS_CODE_H_
//
// Statements that include other files
//
#include "Tiano.h"
#include "Pei.h"
#include "SimpleCpuIoLib.h"
#include "EfiCommonLib.h"
//
// Produced PPI
//
#include EFI_PPI_PRODUCER (StatusCodeMemory)
#include EFI_PPI_PRODUCER (StatusCode)
//
// Ppi Consumed For Notification
//
#include EFI_PPI_CONSUMER (MemoryDiscovered)
#if (PI_SPECIFICATION_VERSION < 0x00010000)
#include EFI_PPI_CONSUMER (LoadFile)
#endif
//
// Private data
//
//
// Define the amount of heap to use before memory is allocated
//
#define PEI_STATUS_CODE_HEAP_LENGTH 512
#define PEI_STATUS_CODE_MAX_HEAP_ENTRY (PEI_STATUS_CODE_HEAP_LENGTH / sizeof (EFI_STATUS_CODE_ENTRY))
//
// Define the number of 4K pages of BS memory to allocate (1MB)
//
#define PEI_STATUS_CODE_RT_PAGES (128)
#define PEI_STATUS_CODE_RT_LENGTH (PEI_STATUS_CODE_RT_PAGES * 1024 * 4)
#define PEI_STATUS_CODE_MAX_RT_ENTRY (PEI_STATUS_CODE_RT_LENGTH / sizeof (EFI_STATUS_CODE_ENTRY))
//
// Define a private data structure
//
#define MEMORY_STATUS_CODE_SIGNATURE EFI_SIGNATURE_32 ('M', 'S', 'C', 'S')
typedef struct _MEMORY_STATUS_CODE_INSTANCE {
UINT32 Signature;
struct _MEMORY_STATUS_CODE_INSTANCE *This;
EFI_FFS_FILE_HEADER *FfsHeader;
EFI_PEI_PPI_DESCRIPTOR PpiDescriptor;
PEI_STATUS_CODE_MEMORY_PPI StatusCodeMemoryPpi;
#if (PI_SPECIFICATION_VERSION < 0x00010000)
EFI_PEI_NOTIFY_DESCRIPTOR NotifyDescriptor;
#endif
} MEMORY_STATUS_CODE_INSTANCE;
#define MEMORY_STATUS_CODE_FROM_DESCRIPTOR_THIS(a) \
PEI_CR (a, \
MEMORY_STATUS_CODE_INSTANCE, \
PpiDescriptor, \
MEMORY_STATUS_CODE_SIGNATURE \
)
#define MEMORY_STATUS_CODE_FROM_NOTIFY_THIS(a) \
PEI_CR (a, \
MEMORY_STATUS_CODE_INSTANCE, \
NotifyDescriptor, \
MEMORY_STATUS_CODE_SIGNATURE \
)
//
// Private function declarations
//
EFI_STATUS
EFIAPI
LoadImageCallback (
IN EFI_PEI_SERVICES **PeiServices,
IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,
IN VOID *Ppi
)
;
#endif

View File

@ -0,0 +1,50 @@
#/*++
#
# Copyright (c) 2004, 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:
#
# MemoryStatusCode.inf
#
# Abstract:
#
# Library producing a memory status code functionality.
#
#--*/
[defines]
BASE_NAME = MemoryStatusCodeLib
COMPONENT_TYPE = LIBRARY
[sources.common]
MemoryStatusCode.c
MemoryStatusCode.h
[includes.common]
$(EDK_SOURCE)\Foundation
$(EDK_SOURCE)\Foundation\Framework
$(EDK_SOURCE)\Foundation\Efi
.
$(EDK_SOURCE)\Foundation\Include
$(EDK_SOURCE)\Foundation\Efi\Include
$(EDK_SOURCE)\Foundation\Framework\Include
$(EDK_SOURCE)\Foundation\Include\IndustryStandard
$(EDK_SOURCE)\Foundation\Core\Dxe
$(EDK_SOURCE)\Foundation\Library\Dxe\Include
$(EDK_SOURCE)\Foundation\Include\Pei
$(EDK_SOURCE)\Foundation\Library\Pei\Include
$(EDK_SOURCE)\Sample\Platform\Generic\MonoStatusCode\Pei
$(EDK_SOURCE)\Sample\Platform\Generic\MonoStatusCode\Library\Pei\Include
[libraries.platform]
EdkPpiLib
EdkFrameworkPpiLib
[nmake.common]

View File

@ -0,0 +1,491 @@
/*++
Copyright (c) 2004 - 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.
The status codes are recorded in a extensiable buffer, and a event is signalled
to log them to the data hub. The recorder is the producer of the status code in
buffer and the event notify function the consummer.
--*/
#include "BsDataHubStatusCode.h"
//
// Globals only work at BootService Time. NOT at Runtime!
//
static EFI_DATA_HUB_PROTOCOL *mDataHub;
static EFI_LIST_ENTRY *mRecordHead;
static EFI_LIST_ENTRY *mRecordTail;
static INTN mRecordNum = 0;
static EFI_EVENT mLogDataHubEvent;
static EFI_LOCK mStatusCodeReportLock = EFI_INITIALIZE_LOCK_VARIABLE(EFI_TPL_HIGH_LEVEL);
static BOOLEAN mEventHandlerActive = FALSE;
STATUS_CODE_RECORD_LIST *
AllocateRecordBuffer (
VOID
)
/*++
Routine Description:
Allocate a new record list node and initialize it.
Inserting the node into the list isn't the task of this function.
Arguments:
None
Returns:
A pointer to the new allocated node or NULL if non available
--*/
{
STATUS_CODE_RECORD_LIST *DataBuffer;
DataBuffer = NULL;
gBS->AllocatePool (EfiBootServicesData, sizeof (STATUS_CODE_RECORD_LIST), &DataBuffer);
if (DataBuffer == NULL) {
return NULL;
}
EfiCommonLibZeroMem (DataBuffer, sizeof (STATUS_CODE_RECORD_LIST));
DataBuffer->Signature = BS_DATA_HUB_STATUS_CODE_SIGNATURE;
return DataBuffer;
}
DATA_HUB_STATUS_CODE_DATA_RECORD *
AquireEmptyRecordBuffer (
VOID
)
/*++
Routine Description:
Acquire an empty record buffer from the record list if there's free node,
or allocate one new node and insert it to the list if the list is full and
the function isn't run in EFI_TPL_HIGH_LEVEL.
Arguments:
None
Returns:
Pointer to new record buffer. NULL if none available.
--*/
{
EFI_TPL OldTpl;
STATUS_CODE_RECORD_LIST *DataBuffer;
DataBuffer = NULL;
//
// This function must be reentrant because an event with higher priority may interrupt it
// and also report status code.
//
EfiAcquireLock (&mStatusCodeReportLock);
if (mRecordTail != mRecordHead->ForwardLink) {
if (mRecordNum != 0) {
mRecordHead = mRecordHead->ForwardLink;
}
DataBuffer = CR (mRecordHead, STATUS_CODE_RECORD_LIST, Link, BS_DATA_HUB_STATUS_CODE_SIGNATURE);
mRecordNum++;
EfiReleaseLock (&mStatusCodeReportLock);
//
// Initalize the record buffer is the responsibility of the producer,
// because the consummer is in a lock so must keep it short.
//
EfiCommonLibZeroMem (&DataBuffer->RecordBuffer[0], BYTES_PER_BUFFER);
} else if (mRecordNum < MAX_RECORD_NUM) {
//
// The condition of "mRecordNum < MAX_RECORD_NUM" is not promised,
// because mRecodeNum may be increased out of this lock.
//
EfiReleaseLock (&mStatusCodeReportLock);
//
// Can't allocate additional buffer in EFI_TPL_HIGH_LEVEL.
// Reporting too many status code in EFI_TPL_HIGH_LEVEL may cause status code lost.
//
OldTpl = gBS->RaiseTPL (EFI_TPL_HIGH_LEVEL);
if (OldTpl == EFI_TPL_HIGH_LEVEL) {
return NULL;
}
gBS->RestoreTPL (OldTpl);
DataBuffer = AllocateRecordBuffer ();
if (DataBuffer == NULL) {
return NULL;
}
EfiAcquireLock (&mStatusCodeReportLock);
InsertHeadList (mRecordHead, &DataBuffer->Link);
mRecordHead = mRecordHead->ForwardLink;
mRecordNum++;
EfiReleaseLock (&mStatusCodeReportLock);
} else {
EfiReleaseLock (&mStatusCodeReportLock);
return NULL;
}
return (DATA_HUB_STATUS_CODE_DATA_RECORD *) DataBuffer->RecordBuffer;
}
EFI_STATUS
ReleaseRecordBuffer (
IN STATUS_CODE_RECORD_LIST *RecordBuffer
)
/*++
Routine Description:
Release a buffer in the list, remove some nodes to keep the list inital length.
Arguments:
RecordBuffer - Buffer to release
Returns:
EFI_SUCCESS - If DataRecord is valid
EFI_UNSUPPORTED - The record list has empty
--*/
{
ASSERT (RecordBuffer != NULL);
//
// The consummer needn't to be reentrient and the producer won't do any meaningful thing
// when consummer is logging records.
//
if (mRecordNum <= 0) {
return EFI_UNSUPPORTED;
} else if (mRecordNum > INITIAL_RECORD_NUM) {
mRecordTail = mRecordTail->ForwardLink;
RemoveEntryList (&RecordBuffer->Link);
mRecordNum--;
gBS->FreePool (RecordBuffer);
} else {
if (mRecordNum != 1) {
mRecordTail = mRecordTail->ForwardLink;
}
mRecordNum--;
}
return EFI_SUCCESS;
}
EFI_BOOTSERVICE
EFI_STATUS
EFIAPI
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 gRT->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];
DataHub = NULL;
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) {
EfiCopyMem (&DataHub->CallerId, CallerId, sizeof (EFI_GUID));
} else {
EfiZeroMem (&DataHub->CallerId, sizeof (EFI_GUID));
}
if (Data == NULL) {
EfiZeroMem (&DataHub->Data, sizeof (EFI_STATUS_CODE_DATA));
} else {
//
// Copy generic Header
//
EfiCopyMem (&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 = VSPrint (
(UINT16 *) (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));
}
EfiCopyMem (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;
EFI_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.
//
Link = mRecordTail;
while (mRecordNum != 0) {
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 ().
//
ErrorPrint (L"ERROR", "Memory Error\n");
Status = EFI_OUT_OF_RESOURCES;
} else {
//
// We don't log EFI_D_POOL and EFI_D_PAGE debug info to datahub
// to avoid recursive logging due to the memory allocation in datahub
//
if (DataRecordClass != EFI_DATA_RECORD_CLASS_DEBUG ||
((DataRecord->Instance & EFI_D_POOL) == 0 && (DataRecord->Instance & EFI_D_PAGE) == 0)) {
//
// Log DataRecord in Data Hub
//
Status = mDataHub->LogData (
mDataHub,
&gEfiStatusCodeGuid,
&gEfiStatusCodeRuntimeProtocolGuid,
DataRecordClass,
DataRecord,
(UINT32) Size
);
}
}
ReleaseRecordBuffer (BufferEntry);
}
mEventHandlerActive = FALSE;
return ;
}
EFI_BOOTSERVICE
EFI_STATUS
BsDataHubInitializeStatusCode (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
/*++
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_CODE_RECORD_LIST *DataBuffer;
UINTN Index1;
DataBuffer = NULL;
Status = gBS->LocateProtocol (&gEfiDataHubProtocolGuid, NULL, &mDataHub);
//
// Should never fail due to dependency grammer
//
ASSERT_EFI_ERROR (Status);
//
// Initialize a record list with length not greater than INITIAL_RECORD_NUM.
// If no buffer can be allocated, return EFI_OUT_OF_RESOURCES.
//
DataBuffer = AllocateRecordBuffer ();
if (DataBuffer == NULL) {
return EFI_OUT_OF_RESOURCES;
}
mRecordHead = &DataBuffer->Link;
mRecordTail = mRecordHead;
InitializeListHead (mRecordHead);
for (Index1 = 1; Index1 < INITIAL_RECORD_NUM; Index1++) {
DataBuffer = AllocateRecordBuffer ();
if (DataBuffer == NULL) {
break;
}
InsertHeadList (mRecordHead, &DataBuffer->Link);
}
//
// Create a Notify Event to log data in Data Hub
//
Status = gBS->CreateEvent (
EFI_EVENT_NOTIFY_SIGNAL,
EFI_TPL_CALLBACK,
LogDataHubEventHandler,
NULL,
&mLogDataHubEvent
);
return EFI_SUCCESS;
}

View File

@ -0,0 +1,156 @@
/*++
Copyright (c) 2004 - 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_
// Statements that include other files.
//
#include "Tiano.h"
#include "EfiCommonLib.h"
#include "EfiRuntimeLib.h"
#include "EfiPrintLib.h"
#include "EfiStatusCode.h"
//
// Dependent protocols
//
#include EFI_PROTOCOL_DEPENDENCY (DataHub)
//
// Consumed protocols
//
#include EFI_ARCH_PROTOCOL_CONSUMER (StatusCode)
//
// GUID definitions
//
#include EFI_GUID_DEFINITION (StatusCode)
#include EFI_GUID_DEFINITION (StatusCodeCallerId)
#include EFI_GUID_DEFINITION (StatusCodeDataTypeId)
//
// Private data declarations
//
#define MAX_RECORD_NUM 1000
#define INITIAL_RECORD_NUM 20
#define BYTES_PER_RECORD EFI_STATUS_CODE_DATA_MAX_SIZE
#define BYTES_PER_BUFFER (BYTES_PER_RECORD * sizeof (UINT8))
#define BS_DATA_HUB_STATUS_CODE_SIGNATURE EFI_SIGNATURE_32 ('B', 'D', 'H', 'S')
typedef struct {
UINTN Signature;
EFI_LIST_ENTRY Link;
UINT8 RecordBuffer[BYTES_PER_RECORD];
} STATUS_CODE_RECORD_LIST;
//
// Function prototypes
//
STATUS_CODE_RECORD_LIST *
AllocateRecordBuffer (
VOID
);
/*++
Routine Description:
Allocate a new record list node and initialize it.
Inserting the node into the list isn't the task of this function.
Arguments:
None
Returns:
A pointer to the new allocated node or NULL if non available
--*/
DATA_HUB_STATUS_CODE_DATA_RECORD *
AquireEmptyRecordBuffer (
VOID
);
/*++
Routine Description:
Acquire an empty record buffer from the record list if there's free node,
or allocate one new node and insert it to the list if the list is full and
the function isn't run in EFI_TPL_HIGH_LEVEL.
Arguments:
None
Returns:
Pointer to new record buffer. NULL if none available.
--*/
EFI_STATUS
ReleaseRecordBuffer (
IN STATUS_CODE_RECORD_LIST *RecordBuffer
);
/*++
Routine Description:
Release a buffer in the list, remove some nodes to keep the list inital length.
Arguments:
RecordBuffer - Buffer to release
Returns:
EFI_SUCCESS - If DataRecord is valid
EFI_UNSUPPORTED - The record list has empty
--*/
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.
--*/
#endif

View File

@ -0,0 +1,45 @@
#/*++
#
# Copyright (c) 2004, 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.inf
#
# Abstract:
#
# Library producing a data hub logger for status code functionality.
#
#--*/
[defines]
BASE_NAME = BsDataHubStatusCodeLib
COMPONENT_TYPE = LIBRARY
[sources.common]
BsDataHubStatusCode.c
BsDataHubStatusCode.h
[includes.common]
$(EDK_SOURCE)\Foundation
$(EDK_SOURCE)\Foundation\Framework
$(EDK_SOURCE)\Foundation\Efi
.
$(EDK_SOURCE)\Foundation\Include
$(EDK_SOURCE)\Foundation\Efi\Include
$(EDK_SOURCE)\Foundation\Framework\Include
$(EDK_SOURCE)\Foundation\Include\IndustryStandard
$(EDK_SOURCE)\Foundation\Core\Dxe
$(EDK_SOURCE)\Foundation\Library\Dxe\Include
[libraries.common]
PrintLib
[nmake.common]

View File

@ -0,0 +1,90 @@
/*++
Copyright (c) 2004, 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:
BsSerialStatusCode.h
Abstract:
Lib to provide Serial I/O status code routines. This uses the PEI library
print functions.
--*/
#ifndef _EFI_BS_SERIAL_STATUS_CODE_H_
#define _EFI_BS_SERIAL_STATUS_CODE_H_
//
// Statements that include other files
//
#include "Tiano.h"
#include "Pei.h"
#include "PeiLib.h"
#include "EfiRuntimeLib.h"
#include "BsSerialStatusCodeLib.h"
//
// GUID consumed
//
#include EFI_GUID_DEFINITION (StatusCodeDataTypeId)
//
// ---------------------------------------------
// UART Register Offsets
// ---------------------------------------------
//
#define BAUD_LOW_OFFSET 0x00
#define BAUD_HIGH_OFFSET 0x01
#define IER_OFFSET 0x01
#define LCR_SHADOW_OFFSET 0x01
#define FCR_SHADOW_OFFSET 0x02
#define IR_CONTROL_OFFSET 0x02
#define FCR_OFFSET 0x02
#define EIR_OFFSET 0x02
#define BSR_OFFSET 0x03
#define LCR_OFFSET 0x03
#define MCR_OFFSET 0x04
#define LSR_OFFSET 0x05
#define MSR_OFFSET 0x06
//
// ---------------------------------------------
// UART Register Bit Defines
// ---------------------------------------------
//
#define LSR_TXRDY 0x20
#define LSR_RXDA 0x01
#define DLAB 0x01
//
// Globals for Serial Port settings
//
extern UINT16 gComBase;
extern UINTN gBps;
extern UINT8 gData;
extern UINT8 gStop;
extern UINT8 gParity;
extern UINT8 gBreakSet;
VOID
DebugSerialPrint (
IN UINT8 *OutputString
)
;
VOID
DebugSerialWrite (
IN UINT8 Character
)
;
#endif

View File

@ -0,0 +1,47 @@
#/*++
#
# Copyright (c) 2004, 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:
#
# BsSerialStatusCode.inf
#
# Abstract:
#
# Library producing a serial port status code functionality.
#
#--*/
[defines]
BASE_NAME = BsSerialStatusCodeLib
COMPONENT_TYPE = LIBRARY
[sources.common]
BsSerialStatusCode.c
BsSerialStatusCode.h
[includes.common]
$(EDK_SOURCE)\Foundation\Framework
$(EDK_SOURCE)\Foundation
$(EDK_SOURCE)\Foundation\Efi
.
..\Include
$(EDK_SOURCE)\Foundation\Include
$(EDK_SOURCE)\Foundation\Efi\Include
$(EDK_SOURCE)\Foundation\Framework\Include
$(EDK_SOURCE)\Foundation\Include\IndustryStandard
$(EDK_SOURCE)\Foundation\Core\Dxe
$(EDK_SOURCE)\Foundation\Library\Dxe\Include
$(EDK_SOURCE)\Foundation\Include\Pei
$(EDK_SOURCE)\Foundation\Library\Pei\Include
[libraries.platform]
[nmake.common]

View File

@ -0,0 +1,53 @@
/*++
Copyright (c) 2004 - 2005, 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:
BsDataHubStatusCodeLib.h
Abstract:
Lib to provide data hub status code reporting.
--*/
#ifndef _EFI_BS_DATA_HUB_STATUS_CODE_LIB_H_
#define _EFI_BS_DATA_HUB_STATUS_CODE_LIB_H_
//
// Statements that include other files
//
#include "Tiano.h"
//
// Initialization function
//
VOID
BsDataHubInitializeStatusCode (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
;
//
// Status code reporting function
//
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
)
;
#endif

View File

@ -0,0 +1,53 @@
/*++
Copyright (c) 2004 - 2005, 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:
BsSerialStatusCodeLib.h
Abstract:
Lib to provide Serial I/O status code reporting.
--*/
#ifndef _EFI_BS_SERIAL_STATUS_CODE_LIB_H_
#define _EFI_BS_SERIAL_STATUS_CODE_LIB_H_
//
// Statements that include other files
//
#include "Tiano.h"
//
// Initialization function
//
VOID
BsSerialInitializeStatusCode (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
;
//
// Status code reporting function
//
EFI_STATUS
BsSerialReportStatusCode (
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
)
;
#endif

View File

@ -0,0 +1,49 @@
/*++
Copyright (c) 2004 - 2005, 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:
RtLedStatusCodeLib.h
Abstract:
Lib to provide status code reporting via LED.
--*/
#ifndef _RT_LED_STATUS_CODE_H_
#define _RT_LED_STATUS_CODE_H_
#include "Tiano.h"
//
// Initialization function
//
VOID
RtLedInitializeStatusCode (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
;
//
// Status code reporting function
//
EFI_STATUS
RtLedReportStatusCode (
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
)
;
#endif

View File

@ -0,0 +1,72 @@
/*++
Copyright (c) 2004 - 2005, 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:
RtMemoryStatusCodeLib.h
Abstract:
Lib to provide memory status code reporting.
--*/
#ifndef _EFI_RT_MEMORY_STATUS_CODE_LIB_H_
#define _EFI_RT_MEMORY_STATUS_CODE_LIB_H_
//
// Statements that include other files
//
#include "Tiano.h"
//
// Initialization function
//
VOID
RtMemoryInitializeStatusCode (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
;
//
// Status code reporting function
//
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
)
;
//
// Playback all prior status codes to a listener
//
typedef
EFI_STATUS
(*PLATFORM_REPORT_STATUS_CODE) (
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
);
VOID
PlaybackStatusCodes (
IN PLATFORM_REPORT_STATUS_CODE ReportStatusCode
)
;
#endif

View File

@ -0,0 +1,54 @@
/*++
Copyright (c) 2004 - 2005, 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:
RtPlatformStatusCodeLib.h
Abstract:
Lib to provide platform implementations necessary for the Monolithic status
code to work.
--*/
#ifndef _EFI_PLATFORM_STATUS_CODE_LIB_H_
#define _EFI_PLATFORM_STATUS_CODE_LIB_H_
//
// Statements that include other files
//
#include "Tiano.h"
//
// Initialization function
//
VOID
RtPlatformInitializeStatusCode (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
;
//
// Status code reporting function
//
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
)
;
#endif

View File

@ -0,0 +1,43 @@
/*++
Copyright (c) 2004 - 2005, 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:
RtPort80StatusCodeLib.h
Abstract:
Lib to provide status code reporting via port 80.
--*/
#ifndef _EFI_PORT_80_STATUS_CODE_H_
#define _EFI_PORT_80_STATUS_CODE_H_
//
// Statements that include other files
//
#include "Tiano.h"
//
// Status code reporting function
//
EFI_STATUS
RtPort80ReportStatusCode (
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
)
;
#endif

View File

@ -0,0 +1,366 @@
/*++
Copyright (c) 2004 - 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:
RtLedStatusCode.c
Abstract:
Lib to provide LED status code reporting Routines.
In general you should use PPI's, but some times a monolithic driver
is better. The best justification for monolithic code is debug.
--*/
#include "RtLedStatusCode.h"
//
// Prepare the data to initialize LPC chipset for Server Io Configuration
// This is hardcoded init value and would vary from platform to platform.
//
static SIO_INIT_DATA mSioInitData[] = {
//
// Program magic values in ServerI/O configuration registers
//
{
REG_SERVERIO_CNF1,
0x19
},
{
REG_SERVERIO_CNF2,
0x22
},
{
REG_SERVERIO_CNF3,
0x76
},
{
REG_SERVERIO_CNF4,
0x26
},
//
// Force the parallel port to be disabled, override reg 30 setting
//
{
REG_SERVERIO_CNF6,
0x02
},
//
// Select GPIO device and setup GPIO base address
//
{
REG_LOGICAL_DEVICE,
SIO_GPIO
},
{
ACTIVATE,
LOGICAL_DEVICE_OFF
},
{
BASE_ADDRESS_HIGH,
SIO_GPIO_HIGH
},
{
BASE_ADDRESS_LOW,
SIO_GPIO_LOW
},
{
ACTIVATE,
LOGICAL_DEVICE_ON
},
//
// Select DLED STB, post code LED, ZZ_POST_CLK_LED_L
//
{
GPIO_GPSEL,
0x43
},
//
// Push pull output enable
//
{
GPIO_GPCFG1,
PUSH_PULL | OUTPUT_BUFFER_EN
},
//
// Disable Event IRQ routing
//
{
GPIO_GPEVR,
GPIO_EVENT_OFF
},
//
// Select DLED STB, ZZ_POST_DATA_LED_L
//
{
GPIO_GPSEL,
0x54
},
//
// Push pull output enable
//
{
GPIO_GPCFG1,
PUSH_PULL | OUTPUT_BUFFER_EN
},
//
// Disable Event IRQ routing
//
{
GPIO_GPEVR,
GPIO_EVENT_OFF
},
//
// Select Select ACPI_MODE_IND_L
//
{
GPIO_GPSEL,
0x63
},
//
// Push pull output enable
//
{
GPIO_GPCFG1,
PUSH_PULL | OUTPUT_BUFFER_EN
},
{
0xff,
0xff
}
};
VOID
RtLedInitializeStatusCode (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
/*++
Routine Description:
Initialization routine. Initializes LPC47817 to configure GPIO for LED
Arguments:
None
Returns:
None
--*/
{
UINT8 OutputData;
UINT16 ConfigPort;
UINT16 DataPort;
UINT32 Index;
//
// hard code for sio init
//
ConfigPort = CONFIG_PORT0;
DataPort = DATA_PORT0;
//
// Initialize Sio from table to enable SererIoCfg and GPIO
//
Index = 0;
while ((mSioInitData[Index]).RegAddress != 0xff) {
OutputData = (UINT8) mSioInitData[Index].RegAddress;
IoWrite8 (ConfigPort, OutputData);
OutputData = (UINT8) mSioInitData[Index].RegValue;
IoWrite8 (DataPort, OutputData);
Index++;
}
return ;
}
BOOLEAN
CodeTypeToProgressCode (
IN EFI_STATUS_CODE_TYPE CodeType,
IN EFI_STATUS_CODE_VALUE Value,
OUT UINT8 *PostCode
)
{
//
// Convert Value to an 8 bit post code
//
if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE)) {
*PostCode = (UINT8) (((Value & EFI_STATUS_CODE_CLASS_MASK) >> 24) << 5);
*PostCode |= (UINT8) (((Value & EFI_STATUS_CODE_SUBCLASS_MASK) >> 16) & 0x1f);
return TRUE;
}
return FALSE;
}
VOID
SendDataToPort (
IN UINT8 Data,
IN UINT16 DataOffset
)
/*++
Routine Description:
Writes the data to control LED output at desired port
Arguments:
Data - Data in bit0 is the relevant data
DataOffset - Port address to access GPIO54
Returns:
None
--*/
{
UINT8 PinData;
//
// Read current Pin State of GPIO54
//
PinData = IoRead8 (DataOffset);
//
// Set GPIO54 pin to zero
//
PinData &= 0xEF;
if (Data & 0x01) {
//
// Set GPIO54 pin to 1 if data is 1
// otherwise it will be set to 0
//
PinData |= LED_MASK_BIT;
}
IoWrite8 (DataOffset, PinData);
}
VOID
StrobeData (
IN UINT16 StrobeOffset
)
/*++
Routine Description:
Controls the strobe to move the value from LSB to MSB in steps.
Arguments:
StrobeOffset - Port address to access GPIO43. This pin controls the shifting
of bit value from LSB to MSB
Returns:
None
--*/
{
UINT8 StrobeData;
StrobeData = IoRead8 (StrobeOffset);
//
// Make bit 3 of data to be zero
//
StrobeData &= 0xF7;
IoWrite8 (StrobeOffset, StrobeData);
//
// Make bit 3 as 1 to perform the strobe to shift the data in 74HCT164
//
StrobeData |= STROBE_MASK_BIT;
IoWrite8 (StrobeOffset, StrobeData);
}
VOID
SendDataToLed (
UINT8 Data
)
{
UINT16 GpioBase;
UINT16 DataOffset;
UINT16 StrobeOffset;
UINTN Index;
UINTN DataBitPosition;
UINT8 TempData;
GpioBase = GPIO_BASE (SIO_GPIO_HIGH, SIO_GPIO_LOW);
DataOffset = (UINT16) (GpioBase + LED_DATA_OFFSET);
StrobeOffset = (UINT16) (GpioBase + LED_STROBE_OFFSET);
DataBitPosition = 7;
Data = (UINT8) (~Data);
TempData = Data;
for (Index = 0; Index < 8; Index++) {
SendDataToPort ((UINT8) (TempData >> DataBitPosition), DataOffset);
StrobeData (StrobeOffset);
DataBitPosition--;
}
//
// To fix 5 Volt leakage problem
//
SendDataToPort (0, DataOffset);
}
EFI_STATUS
RtLedReportStatusCode (
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:
Provide a LED status code
Arguments:
Same as ReportStatusCode PPI
Returns:
Status - EFI_SUCCESS if the interface could be successfully
installed
--*/
{
UINT8 ProgressCode;
if (CodeTypeToProgressCode (CodeType, Value, &ProgressCode)) {
SendDataToLed (ProgressCode);
}
return EFI_SUCCESS;
}

View File

@ -0,0 +1,89 @@
/*++
Copyright (c) 2004, 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:
RtLedStatusCode.h
Abstract:
Lib to provide status code reporting via LED.
--*/
#ifndef _EFI_LED_STATUS_CODE_H_
#define _EFI_LED_STATUS_CODE_H_
//
// Statements that include other files
//
#include "Tiano.h"
#include "EfiCommonLib.h"
#include "EfiRuntimeLib.h"
#include "EfiStatusCode.h"
//
// SIOINIT data
//
typedef struct {
UINT8 RegAddress;
UINT8 RegValue;
} SIO_INIT_DATA;
#define LED_DATA_OFFSET 0x0E
#define LED_STROBE_OFFSET 0x0A
#define LED_MASK_BIT 0x10
#define STROBE_MASK_BIT 0x08
#define GPIO_BASE(a, b) (UINT16) ((a << 8) | (b))
#define SIO_GPIO_HIGH 0x08
#define SIO_GPIO_LOW 0x00
#define CONFIG_PORT0 0x2E
#define DATA_PORT0 0x2F
//
// logical device in NSPC87417
//
#define SIO_GPIO 0x7
//
// Global register in NSPC87417
//
#define REG_LOGICAL_DEVICE 0x07
#define REG_SERVERIO_CNF1 0x21
#define REG_SERVERIO_CNF2 0x22
#define REG_SERVERIO_CNF3 0x23
#define REG_SERVERIO_CNF4 0x24
#define REG_SERVERIO_CNF6 0x26
#define ACTIVATE 0x30
#define LOGICAL_DEVICE_ON 0x01
#define LOGICAL_DEVICE_OFF 0x00
#define BASE_ADDRESS_HIGH 0x60
#define BASE_ADDRESS_LOW 0x61
//
// Register for GPIO
//
#define GPIO_GPSEL 0xF0
#define GPIO_GPCFG1 0xF1
#define PUSH_PULL 0x02
#define OUTPUT_BUFFER_EN 0x01
#define GPIO_GPEVR 0xF2
#define GPIO_EVENT_OFF 0x00
#endif

View File

@ -0,0 +1,44 @@
#/*++
#
# Copyright (c) 2004, 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:
#
# RtLedStatusCode.inf
#
# Abstract:
#
# Library producing a LED status code functionality.
#
#--*/
[defines]
BASE_NAME = RtLedStatusCodeLib
COMPONENT_TYPE = LIBRARY
[sources.common]
RtLedStatusCode.c
RtLedStatusCode.h
[includes.common]
$(EDK_SOURCE)\Foundation
$(EDK_SOURCE)\Foundation\Framework
$(EDK_SOURCE)\Foundation\Efi
.
$(EDK_SOURCE)\Foundation\Include
$(EDK_SOURCE)\Foundation\Efi\Include
$(EDK_SOURCE)\Foundation\Framework\Include
$(EDK_SOURCE)\Foundation\Include\IndustryStandard
$(EDK_SOURCE)\Foundation\Core\Dxe
$(EDK_SOURCE)\Foundation\Library\Dxe\Include
[libraries.platform]
[nmake.common]

View File

@ -0,0 +1,203 @@
/*++
Copyright (c) 2004 - 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 "RtMemoryStatusCode.h"
//
// Global variables
//
PEI_STATUS_CODE_MEMORY_PPI mStatusCodeMemoryPpi = { 0, 0, 0, 0 };
//
// Function implementations
//
EFI_STATUS
EFIAPI
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
EFIAPI
RtMemoryInitializeStatusCode (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
/*++
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_STATUS Status;
VOID *HobList;
PEI_STATUS_CODE_MEMORY_PPI **StatusCodeMemoryPpi;
//
// Locate the HOB that contains the PPI structure for the memory journal
// We don't check for more than one.
//
EfiLibGetSystemConfigurationTable (
&gEfiHobListGuid,
&HobList
);
Status = GetNextGuidHob (
&HobList,
&gPeiStatusCodeMemoryPpiGuid,
(VOID **) &StatusCodeMemoryPpi,
NULL
);
if (EFI_ERROR (Status)) {
return ;
}
//
// 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
EFIAPI
PlaybackStatusCodes (
IN EFI_REPORT_STATUS_CODE ReportStatusCode
)
/*++
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 (ReportStatusCode == 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)));
ReportStatusCode (
CurrentEntry->Type,
CurrentEntry->Value,
CurrentEntry->Instance,
NULL,
NULL
);
}
}

View File

@ -0,0 +1,45 @@
/*++
Copyright (c) 2004, 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.h
Abstract:
EFI library to provide status code reporting via a memory journal.
--*/
#ifndef _EFI_RT_MEMORY_STATUS_CODE_H_
#define _EFI_RT_MEMORY_STATUS_CODE_H_
//
// Statements that include other files
//
#include "Tiano.h"
#include "Pei.h"
#include "TianoCommon.h"
#include "EfiRuntimeLib.h"
#include "EfiHobLib.h"
#include "RtPlatformStatusCodeLib.h"
//
// Consumed protocols
//
#include EFI_PPI_CONSUMER (StatusCodeMemory)
//
// Consumed GUID
//
#include EFI_GUID_DEFINITION (Hob)
#endif

View File

@ -0,0 +1,49 @@
#/*++
#
# Copyright (c) 2004, 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.inf
#
# Abstract:
#
# Library producing a memory status code functionality.
#
#--*/
[defines]
BASE_NAME = RtMemoryStatusCodeLib
COMPONENT_TYPE = LIBRARY
[sources.common]
RtMemoryStatusCode.c
RtMemoryStatusCode.h
[includes.common]
$(EDK_SOURCE)\Foundation
$(EDK_SOURCE)\Foundation\Framework
$(EDK_SOURCE)\Foundation\Efi
.
..\Include
$(EDK_SOURCE)\Foundation\Include
$(EDK_SOURCE)\Foundation\Efi\Include
$(EDK_SOURCE)\Foundation\Framework\Include
$(EDK_SOURCE)\Foundation\Include\IndustryStandard
$(EDK_SOURCE)\Foundation\Core\Dxe
$(EDK_SOURCE)\Foundation\Library\Dxe\Include
$(EDK_SOURCE)\Foundation\Include\Pei
$(EDK_SOURCE)\Foundation\Library\Pei\Include
[libraries.platform]
EdkPpiLib
[nmake.common]

View File

@ -0,0 +1,144 @@
/*++
Copyright (c) 2004 - 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.
--*/
//
// Statements that include other files.
//
#include "Tiano.h"
#include "EfiCommonLib.h"
#include "EfiRuntimeLib.h"
#include "EfiStatusCode.h"
#include "EfiHobLib.h"
#include "RtMemoryStatusCodeLib.h"
#include "BsDataHubStatusCodeLib.h"
//
// Consumed protocols
//
#include EFI_ARCH_PROTOCOL_CONSUMER (StatusCode)
//
// GUID definitions
//
#include EFI_GUID_DEFINITION (Hob)
//
// Globals only work at BootService Time. NOT at Runtime!
//
EFI_REPORT_STATUS_CODE mPeiReportStatusCode;
//
// Function implementations
//
EFI_STATUS
EFIAPI
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
EFIAPI
RtPlatformInitializeStatusCode (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
/*++
Routine Description:
Initialize the status code listeners.
Arguments:
(Standard EFI Image entry - EFI_IMAGE_ENTRY_POINT)
Returns:
None
--*/
{
EFI_STATUS Status;
VOID *HobList;
VOID *Pointer;
RtMemoryInitializeStatusCode (ImageHandle, SystemTable);
BsDataHubInitializeStatusCode (ImageHandle, SystemTable);
//
// 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;
Status = EfiLibGetSystemConfigurationTable (&gEfiHobListGuid, &HobList);
if (!EFI_ERROR (Status)) {
Status = GetNextGuidHob (&HobList, &gEfiStatusCodeRuntimeProtocolGuid, &Pointer, NULL);
if (!EFI_ERROR (Status)) {
mPeiReportStatusCode = (EFI_REPORT_STATUS_CODE) (*(UINTN *) Pointer);
}
}
}

View File

@ -0,0 +1,47 @@
#/*++
#
# Copyright (c) 2004, 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.inf
#
# Abstract:
#
# Library selecting the listeners for the platform
#
#--*/
[defines]
BASE_NAME = RtPlatformStatusCodeLib
COMPONENT_TYPE = LIBRARY
[sources.common]
RtPlatformStatusCode.c
[includes.common]
$(EDK_SOURCE)\Foundation\Framework
$(EDK_SOURCE)\Foundation
$(EDK_SOURCE)\Foundation\Efi
.
..\..\Include
$(EDK_SOURCE)\Foundation\Include
$(EDK_SOURCE)\Foundation\Efi\Include
$(EDK_SOURCE)\Foundation\Framework\Include
$(EDK_SOURCE)\Foundation\Include\IndustryStandard
$(EDK_SOURCE)\Foundation\Core\Dxe
$(EDK_SOURCE)\Foundation\Library\Dxe\Include
[libraries.common]
HobLib
RtMemoryStatusCodeLib
BsDataHubStatusCodeLib
[nmake.common]

View File

@ -0,0 +1,63 @@
/*++
Copyright (c) 2004 - 2007, 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:
RtPort80StatusCode.c
Abstract:
Lib to provide port 80 status code reporting Routines. This routine
does not use PPI's but is monolithic.
In general you should use PPI's, but some times a monolithic driver
is better. The best justification for monolithic code is debug.
--*/
#include "RtPort80StatusCode.h"
EFI_STATUS
EFIAPI
RtPort80ReportStatusCode (
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:
Provide a port 80 status code
Arguments:
Same as ReportStatusCode PPI
Returns:
EFI_SUCCESS Always returns success.
--*/
{
UINT8 Port80Code;
//
// Progress or error code, Output Port 80h card
//
if (CodeTypeToPostCode (CodeType, Value, &Port80Code)) {
IoWrite8 (0x80, Port80Code);
}
return EFI_SUCCESS;
}

View File

@ -0,0 +1,33 @@
/*++
Copyright (c) 2004, 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:
RtPort80StatusCode.h
Abstract:
Lib to provide status code reporting via port 80.
--*/
#ifndef _EFI_PORT_80_STATUS_CODE_H_
#define _EFI_PORT_80_STATUS_CODE_H_
//
// Statements that include other files
//
#include "Tiano.h"
#include "EfiCommonLib.h"
#include "EfiRuntimeLib.h"
#include "EfiStatusCode.h"
#endif

View File

@ -0,0 +1,44 @@
#/*++
#
# Copyright (c) 2004, 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:
#
# RtPort80StatusCode.inf
#
# Abstract:
#
# Library producing a port 80 status code functionality.
#
#--*/
[defines]
BASE_NAME = RtPort80StatusCodeLib
COMPONENT_TYPE = LIBRARY
[sources.common]
RtPort80StatusCode.c
RtPort80StatusCode.h
[includes.common]
$(EDK_SOURCE)\Foundation
$(EDK_SOURCE)\Foundation\Framework
$(EDK_SOURCE)\Foundation\Efi
.
$(EDK_SOURCE)\Foundation\Include
$(EDK_SOURCE)\Foundation\Efi\Include
$(EDK_SOURCE)\Foundation\Framework\Include
$(EDK_SOURCE)\Foundation\Include\IndustryStandard
$(EDK_SOURCE)\Foundation\Core\Dxe
$(EDK_SOURCE)\Foundation\Library\Dxe\Include
[libraries.platform]
[nmake.common]