Fix the issues that StatusCode can't work when PcdStatusCodeUseMemory is set to TRUE or PcdStatusCodeUseDataHub is set to TRUE.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10631 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@ -1,7 +1,7 @@
|
|||||||
/** @file
|
/** @file
|
||||||
PEI memory status code worker.
|
PEI memory status code worker.
|
||||||
|
|
||||||
Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
@ -15,19 +15,19 @@
|
|||||||
#include "StatusCodePei.h"
|
#include "StatusCodePei.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Worker function to create one memory status code GUID'ed HOB,
|
Create the first memory status code GUID'ed HOB as initialization for memory status code worker.
|
||||||
using PacketIndex to identify the packet.
|
|
||||||
|
|
||||||
@param PacketIndex Index of records packet.
|
@retval EFI_SUCCESS The GUID'ed HOB is created successfully.
|
||||||
|
|
||||||
@return Pointer to the memory status code packet.
|
|
||||||
|
|
||||||
**/
|
**/
|
||||||
MEMORY_STATUSCODE_PACKET_HEADER *
|
EFI_STATUS
|
||||||
CreateMemoryStatusCodePacket (
|
MemoryStatusCodeInitializeWorker (
|
||||||
UINT16 PacketIndex
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
//
|
||||||
|
// Create memory status code GUID'ed HOB.
|
||||||
|
//
|
||||||
MEMORY_STATUSCODE_PACKET_HEADER *PacketHeader;
|
MEMORY_STATUSCODE_PACKET_HEADER *PacketHeader;
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -40,28 +40,9 @@ CreateMemoryStatusCodePacket (
|
|||||||
ASSERT (PacketHeader != NULL);
|
ASSERT (PacketHeader != NULL);
|
||||||
|
|
||||||
PacketHeader->MaxRecordsNumber = (PcdGet16 (PcdStatusCodeMemorySize) * 1024) / sizeof (MEMORY_STATUSCODE_RECORD);
|
PacketHeader->MaxRecordsNumber = (PcdGet16 (PcdStatusCodeMemorySize) * 1024) / sizeof (MEMORY_STATUSCODE_RECORD);
|
||||||
PacketHeader->PacketIndex = PacketIndex;
|
PacketHeader->PacketIndex = 0;
|
||||||
PacketHeader->RecordIndex = 0;
|
PacketHeader->RecordIndex = 0;
|
||||||
|
|
||||||
return PacketHeader;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Create the first memory status code GUID'ed HOB as initialization for memory status code worker.
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS The GUID'ed HOB is created successfully.
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
MemoryStatusCodeInitializeWorker (
|
|
||||||
VOID
|
|
||||||
)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// Create first memory status code GUID'ed HOB.
|
|
||||||
//
|
|
||||||
CreateMemoryStatusCodePacket (0);
|
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,49 +79,40 @@ MemoryStatusCodeReportWorker (
|
|||||||
EFI_PEI_HOB_POINTERS Hob;
|
EFI_PEI_HOB_POINTERS Hob;
|
||||||
MEMORY_STATUSCODE_PACKET_HEADER *PacketHeader;
|
MEMORY_STATUSCODE_PACKET_HEADER *PacketHeader;
|
||||||
MEMORY_STATUSCODE_RECORD *Record;
|
MEMORY_STATUSCODE_RECORD *Record;
|
||||||
UINT16 PacketIndex;
|
|
||||||
|
|
||||||
Record = NULL;
|
|
||||||
PacketIndex = 0;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Journal GUID'ed HOBs to find empty record entry. if found, then save status code in it.
|
// Find GUID'ed HOBs to locate current record buffer.
|
||||||
// otherwise, create a new GUID'ed HOB.
|
|
||||||
//
|
//
|
||||||
Hob.Raw = GetFirstGuidHob (&gMemoryStatusCodeRecordGuid);
|
Hob.Raw = GetFirstGuidHob (&gMemoryStatusCodeRecordGuid);
|
||||||
while (Hob.Raw != NULL) {
|
ASSERT (Hob.Raw != NULL);
|
||||||
PacketHeader = (MEMORY_STATUSCODE_PACKET_HEADER *) GET_GUID_HOB_DATA (Hob.Guid);
|
|
||||||
|
|
||||||
//
|
PacketHeader = (MEMORY_STATUSCODE_PACKET_HEADER *) GET_GUID_HOB_DATA (Hob.Guid);
|
||||||
// Check whether pccket is full or not.
|
Record = (MEMORY_STATUSCODE_RECORD *) (PacketHeader + 1);
|
||||||
//
|
Record = &Record[PacketHeader->RecordIndex++];
|
||||||
if (PacketHeader->RecordIndex < PacketHeader->MaxRecordsNumber) {
|
|
||||||
Record = (MEMORY_STATUSCODE_RECORD *) (PacketHeader + 1);
|
|
||||||
Record = &Record[PacketHeader->RecordIndex++];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// Cache number of found packet in PacketIndex.
|
|
||||||
//
|
|
||||||
PacketIndex++;
|
|
||||||
|
|
||||||
Hob.Raw = GetNextGuidHob (&gMemoryStatusCodeRecordGuid, Hob.Raw);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Record == NULL) {
|
|
||||||
//
|
|
||||||
// No available entry found, so create new packet.
|
|
||||||
//
|
|
||||||
PacketHeader = CreateMemoryStatusCodePacket (PacketIndex);
|
|
||||||
|
|
||||||
Record = (MEMORY_STATUSCODE_RECORD *) (PacketHeader + 1);
|
|
||||||
Record = &Record[PacketHeader->RecordIndex++];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Save status code.
|
||||||
|
//
|
||||||
Record->CodeType = CodeType;
|
Record->CodeType = CodeType;
|
||||||
Record->Instance = Instance;
|
Record->Instance = Instance;
|
||||||
Record->Value = Value;
|
Record->Value = Value;
|
||||||
|
|
||||||
|
//
|
||||||
|
// If record index equals to max record number, then wrap around record index to zero.
|
||||||
|
//
|
||||||
|
// The reader of status code should compare the number of records with max records number,
|
||||||
|
// If it is equal to or larger than the max number, then the wrap-around had happened,
|
||||||
|
// so the first record is pointed by record index.
|
||||||
|
// If it is less then max number, index of the first record is zero.
|
||||||
|
//
|
||||||
|
if (PacketHeader->RecordIndex == PacketHeader->MaxRecordsNumber) {
|
||||||
|
//
|
||||||
|
// Wrap around record index.
|
||||||
|
//
|
||||||
|
PacketHeader->RecordIndex = 0;
|
||||||
|
PacketHeader->PacketIndex ++;
|
||||||
|
}
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/** @file
|
/** @file
|
||||||
Data Hub status code worker.
|
Data Hub status code worker.
|
||||||
|
|
||||||
Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
@ -24,7 +24,7 @@ EFI_EVENT mLogDataHubEvent;
|
|||||||
//
|
//
|
||||||
// Cache data hub protocol.
|
// Cache data hub protocol.
|
||||||
//
|
//
|
||||||
EFI_DATA_HUB_PROTOCOL *mDataHubProtocol;
|
EFI_DATA_HUB_PROTOCOL *mDataHubProtocol = NULL;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -189,6 +189,7 @@ DataHubStatusCodeReportWorker (
|
|||||||
BASE_LIST Marker;
|
BASE_LIST Marker;
|
||||||
CHAR8 *Format;
|
CHAR8 *Format;
|
||||||
UINTN CharCount;
|
UINTN CharCount;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Use atom operation to avoid the reentant of report.
|
// Use atom operation to avoid the reentant of report.
|
||||||
@ -205,6 +206,13 @@ DataHubStatusCodeReportWorker (
|
|||||||
return EFI_DEVICE_ERROR;
|
return EFI_DEVICE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mDataHubProtocol == NULL) {
|
||||||
|
Status = DataHubStatusCodeInitializeWorker ();
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Record = AcquireRecordBuffer ();
|
Record = AcquireRecordBuffer ();
|
||||||
if (Record == NULL) {
|
if (Record == NULL) {
|
||||||
//
|
//
|
||||||
@ -358,7 +366,10 @@ DataHubStatusCodeInitializeWorker (
|
|||||||
NULL,
|
NULL,
|
||||||
(VOID **) &mDataHubProtocol
|
(VOID **) &mDataHubProtocol
|
||||||
);
|
);
|
||||||
ASSERT_EFI_ERROR (Status);
|
if (EFI_ERROR (Status)) {
|
||||||
|
mDataHubProtocol = NULL;
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Create a Notify Event to log data in Data Hub
|
// Create a Notify Event to log data in Data Hub
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/** @file
|
/** @file
|
||||||
Status code driver for IA32/X64/EBC architecture.
|
Status code driver for IA32/X64/EBC architecture.
|
||||||
|
|
||||||
Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
@ -205,9 +205,8 @@ InitializationDispatcherWorker (
|
|||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
MEMORY_STATUSCODE_PACKET_HEADER *PacketHeader;
|
MEMORY_STATUSCODE_PACKET_HEADER *PacketHeader;
|
||||||
MEMORY_STATUSCODE_RECORD *Record;
|
MEMORY_STATUSCODE_RECORD *Record;
|
||||||
UINTN ExpectedPacketIndex;
|
|
||||||
UINTN Index;
|
UINTN Index;
|
||||||
VOID *HobStart;
|
UINTN MaxRecordNumber;
|
||||||
|
|
||||||
//
|
//
|
||||||
// If enable UseSerial, then initialize serial port.
|
// If enable UseSerial, then initialize serial port.
|
||||||
@ -226,8 +225,7 @@ InitializationDispatcherWorker (
|
|||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
}
|
}
|
||||||
if (FeaturePcdGet (PcdStatusCodeUseDataHub)) {
|
if (FeaturePcdGet (PcdStatusCodeUseDataHub)) {
|
||||||
Status = DataHubStatusCodeInitializeWorker ();
|
DataHubStatusCodeInitializeWorker ();
|
||||||
ASSERT_EFI_ERROR (Status);
|
|
||||||
}
|
}
|
||||||
if (FeaturePcdGet (PcdStatusCodeUseOEM)) {
|
if (FeaturePcdGet (PcdStatusCodeUseOEM)) {
|
||||||
//
|
//
|
||||||
@ -245,73 +243,59 @@ InitializationDispatcherWorker (
|
|||||||
// Journal GUID'ed HOBs to find all record entry, if found,
|
// Journal GUID'ed HOBs to find all record entry, if found,
|
||||||
// then output record to support replay device.
|
// then output record to support replay device.
|
||||||
//
|
//
|
||||||
ExpectedPacketIndex = 0;
|
|
||||||
Hob.Raw = GetFirstGuidHob (&gMemoryStatusCodeRecordGuid);
|
Hob.Raw = GetFirstGuidHob (&gMemoryStatusCodeRecordGuid);
|
||||||
HobStart = Hob.Raw;
|
if (Hob.Raw != NULL) {
|
||||||
while (Hob.Raw != NULL) {
|
|
||||||
PacketHeader = (MEMORY_STATUSCODE_PACKET_HEADER *) GET_GUID_HOB_DATA (Hob.Guid);
|
PacketHeader = (MEMORY_STATUSCODE_PACKET_HEADER *) GET_GUID_HOB_DATA (Hob.Guid);
|
||||||
if (PacketHeader->PacketIndex == ExpectedPacketIndex) {
|
Record = (MEMORY_STATUSCODE_RECORD *) (PacketHeader + 1);
|
||||||
Record = (MEMORY_STATUSCODE_RECORD *) (PacketHeader + 1);
|
MaxRecordNumber = (UINTN) PacketHeader->RecordIndex;
|
||||||
for (Index = 0; Index < PacketHeader->RecordIndex; Index++) {
|
if (PacketHeader->PacketIndex > 0) {
|
||||||
//
|
|
||||||
// Dispatch records to devices based on feature flag.
|
|
||||||
//
|
|
||||||
if (FeaturePcdGet (PcdStatusCodeUseSerial)) {
|
|
||||||
SerialStatusCodeReportWorker (
|
|
||||||
Record[Index].CodeType,
|
|
||||||
Record[Index].Value,
|
|
||||||
Record[Index].Instance,
|
|
||||||
NULL,
|
|
||||||
NULL
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (FeaturePcdGet (PcdStatusCodeUseMemory)) {
|
|
||||||
RtMemoryStatusCodeReportWorker (
|
|
||||||
Record[Index].CodeType,
|
|
||||||
Record[Index].Value,
|
|
||||||
Record[Index].Instance
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (FeaturePcdGet (PcdStatusCodeUseDataHub)) {
|
|
||||||
DataHubStatusCodeReportWorker (
|
|
||||||
Record[Index].CodeType,
|
|
||||||
Record[Index].Value,
|
|
||||||
Record[Index].Instance,
|
|
||||||
NULL,
|
|
||||||
NULL
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (FeaturePcdGet (PcdStatusCodeUseOEM)) {
|
|
||||||
//
|
|
||||||
// Call OEM hook status code library API to report status code to OEM device
|
|
||||||
//
|
|
||||||
OemHookStatusCodeReport (
|
|
||||||
Record[Index].CodeType,
|
|
||||||
Record[Index].Value,
|
|
||||||
Record[Index].Instance,
|
|
||||||
NULL,
|
|
||||||
NULL
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ExpectedPacketIndex++;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// See whether there is gap of packet or not
|
// Record has been wrapped around. So, record number has arrived at max number.
|
||||||
//
|
//
|
||||||
if (HobStart != NULL) {
|
MaxRecordNumber = (UINTN) PacketHeader->MaxRecordsNumber;
|
||||||
HobStart = NULL;
|
}
|
||||||
Hob.Raw = HobStart;
|
for (Index = 0; Index < MaxRecordNumber; Index++) {
|
||||||
continue;
|
//
|
||||||
}
|
// Dispatch records to devices based on feature flag.
|
||||||
} else if (HobStart != NULL) {
|
//
|
||||||
//
|
if (FeaturePcdGet (PcdStatusCodeUseSerial)) {
|
||||||
// Cache the found packet for improve the performance
|
SerialStatusCodeReportWorker (
|
||||||
//
|
Record[Index].CodeType,
|
||||||
HobStart = Hob.Raw;
|
Record[Index].Value,
|
||||||
|
Record[Index].Instance,
|
||||||
|
NULL,
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (FeaturePcdGet (PcdStatusCodeUseMemory)) {
|
||||||
|
RtMemoryStatusCodeReportWorker (
|
||||||
|
Record[Index].CodeType,
|
||||||
|
Record[Index].Value,
|
||||||
|
Record[Index].Instance
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (FeaturePcdGet (PcdStatusCodeUseDataHub)) {
|
||||||
|
DataHubStatusCodeReportWorker (
|
||||||
|
Record[Index].CodeType,
|
||||||
|
Record[Index].Value,
|
||||||
|
Record[Index].Instance,
|
||||||
|
NULL,
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (FeaturePcdGet (PcdStatusCodeUseOEM)) {
|
||||||
|
//
|
||||||
|
// Call OEM hook status code library API to report status code to OEM device
|
||||||
|
//
|
||||||
|
OemHookStatusCodeReport (
|
||||||
|
Record[Index].CodeType,
|
||||||
|
Record[Index].Value,
|
||||||
|
Record[Index].Instance,
|
||||||
|
NULL,
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Hob.Raw = GetNextGuidHob (&gMemoryStatusCodeRecordGuid, Hob.Raw);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user