2007-07-13 08:45:00 +02:00
|
|
|
/** @file
|
|
|
|
Status code driver for IA32/X64/EBC architecture.
|
|
|
|
|
2009-04-27 08:35:40 +02:00
|
|
|
Copyright (c) 2006 - 2009, Intel Corporation
|
2007-07-16 05:28:26 +02:00
|
|
|
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.
|
2007-07-13 08:45:00 +02:00
|
|
|
|
|
|
|
**/
|
|
|
|
|
2009-04-27 08:35:40 +02:00
|
|
|
#include "StatusCodeRuntimeDxe.h"
|
2007-07-13 08:45:00 +02:00
|
|
|
|
2009-04-27 08:14:50 +02:00
|
|
|
EFI_EVENT mVirtualAddressChangeEvent = NULL;
|
|
|
|
EFI_HANDLE mHandle = NULL;
|
2007-07-13 08:45:00 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// Declaration of status code protocol.
|
|
|
|
//
|
|
|
|
EFI_STATUS_CODE_PROTOCOL mEfiStatusCodeProtocol = {
|
|
|
|
ReportDispatcher
|
|
|
|
};
|
|
|
|
|
|
|
|
//
|
2009-04-27 08:14:50 +02:00
|
|
|
// Report operation nest status.
|
|
|
|
// If it is set, then the report operation has nested.
|
2007-07-13 08:45:00 +02:00
|
|
|
//
|
2009-04-27 08:14:50 +02:00
|
|
|
UINT32 mStatusCodeNestStatus = 0;
|
2007-07-13 08:45:00 +02:00
|
|
|
|
|
|
|
/**
|
2009-04-27 08:14:50 +02:00
|
|
|
Entry point of DXE Status Code Driver.
|
2007-07-13 08:45:00 +02:00
|
|
|
|
2009-04-27 08:14:50 +02:00
|
|
|
This function is the entry point of this DXE Status Code Driver.
|
|
|
|
It installs Status Code Runtime Protocol, and registers event for EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE.
|
2007-07-16 05:28:26 +02:00
|
|
|
|
2009-04-27 08:14:50 +02:00
|
|
|
@param ImageHandle The firmware allocated handle for the EFI image.
|
|
|
|
@param SystemTable A pointer to the EFI System Table.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The entry point is executed successfully.
|
2007-07-13 08:45:00 +02:00
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
2009-04-14 01:07:44 +02:00
|
|
|
EFIAPI
|
2009-04-27 08:35:40 +02:00
|
|
|
StatusCodeRuntimeDxeEntry (
|
2007-07-13 08:45:00 +02:00
|
|
|
IN EFI_HANDLE ImageHandle,
|
|
|
|
IN EFI_SYSTEM_TABLE *SystemTable
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Dispatch initialization request to supported devices
|
|
|
|
//
|
|
|
|
InitializationDispatcherWorker ();
|
|
|
|
|
|
|
|
//
|
2009-04-27 08:14:50 +02:00
|
|
|
// Install Status Code Runtime Protocol implementation as defined in PI Specification.
|
2007-07-13 08:45:00 +02:00
|
|
|
//
|
|
|
|
Status = gBS->InstallMultipleProtocolInterfaces (
|
2009-04-27 08:14:50 +02:00
|
|
|
&mHandle,
|
2007-07-13 08:45:00 +02:00
|
|
|
&gEfiStatusCodeRuntimeProtocolGuid,
|
|
|
|
&mEfiStatusCodeProtocol,
|
|
|
|
NULL
|
|
|
|
);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
|
2009-02-04 02:29:55 +01:00
|
|
|
Status = gBS->CreateEventEx (
|
|
|
|
EVT_NOTIFY_SIGNAL,
|
2007-07-16 05:28:26 +02:00
|
|
|
TPL_NOTIFY,
|
|
|
|
VirtualAddressChangeCallBack,
|
|
|
|
NULL,
|
2009-04-27 08:14:50 +02:00
|
|
|
&gEfiEventVirtualAddressChangeGuid,
|
|
|
|
&mVirtualAddressChangeEvent
|
2007-07-16 05:28:26 +02:00
|
|
|
);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
|
2009-04-27 08:14:50 +02:00
|
|
|
return EFI_SUCCESS;
|
2007-07-13 08:45:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2007-07-16 05:28:26 +02:00
|
|
|
Report status code to all supported device.
|
2009-04-27 08:14:50 +02:00
|
|
|
|
|
|
|
This function implements EFI_STATUS_CODE_PROTOCOL.ReportStatusCode().
|
|
|
|
It calls into the workers which dispatches the platform specific listeners.
|
|
|
|
|
2009-04-27 08:19:31 +02:00
|
|
|
@param CodeType Indicates the type of status code being reported.
|
2009-04-27 08:14:50 +02:00
|
|
|
@param Value Describes the current status of a hardware or software entity.
|
|
|
|
This included information about the class and subclass that is used to
|
|
|
|
classify the entity as well as an operation.
|
|
|
|
@param Instance The enumeration of a hardware or software entity within
|
|
|
|
the system. Valid instance numbers start with 1.
|
|
|
|
@param CallerId This optional parameter may be used to identify the caller.
|
|
|
|
This parameter allows the status code driver to apply different rules to
|
|
|
|
different callers.
|
|
|
|
@param Data This optional parameter may be used to pass additional data.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The function completed successfully
|
|
|
|
@retval EFI_DEVICE_ERROR The function should not be completed due to a device error.
|
2007-07-13 08:45:00 +02:00
|
|
|
|
|
|
|
**/
|
2007-07-16 05:28:26 +02:00
|
|
|
EFI_STATUS
|
2007-07-13 08:45:00 +02:00
|
|
|
EFIAPI
|
|
|
|
ReportDispatcher (
|
|
|
|
IN EFI_STATUS_CODE_TYPE CodeType,
|
|
|
|
IN EFI_STATUS_CODE_VALUE Value,
|
|
|
|
IN UINT32 Instance,
|
|
|
|
IN EFI_GUID *CallerId OPTIONAL,
|
|
|
|
IN EFI_STATUS_CODE_DATA *Data OPTIONAL
|
|
|
|
)
|
|
|
|
{
|
|
|
|
//
|
|
|
|
// Use atom operation to avoid the reentant of report.
|
|
|
|
// If current status is not zero, then the function is reentrancy.
|
|
|
|
//
|
2009-04-27 08:14:50 +02:00
|
|
|
if (InterlockedCompareExchange32 (&mStatusCodeNestStatus, 0, 1) == 1) {
|
2007-07-13 08:45:00 +02:00
|
|
|
return EFI_DEVICE_ERROR;
|
|
|
|
}
|
|
|
|
|
2009-06-16 03:16:27 +02:00
|
|
|
if (FeaturePcdGet (PcdStatusCodeUseSerial)) {
|
2007-07-13 08:45:00 +02:00
|
|
|
SerialStatusCodeReportWorker (
|
|
|
|
CodeType,
|
|
|
|
Value,
|
|
|
|
Instance,
|
|
|
|
CallerId,
|
|
|
|
Data
|
|
|
|
);
|
|
|
|
}
|
2009-06-16 03:16:27 +02:00
|
|
|
if (FeaturePcdGet (PcdStatusCodeUseMemory)) {
|
2007-07-13 08:45:00 +02:00
|
|
|
RtMemoryStatusCodeReportWorker (
|
|
|
|
CodeType,
|
|
|
|
Value,
|
|
|
|
Instance
|
|
|
|
);
|
|
|
|
}
|
|
|
|
if (FeaturePcdGet (PcdStatusCodeUseDataHub)) {
|
|
|
|
DataHubStatusCodeReportWorker (
|
|
|
|
CodeType,
|
|
|
|
Value,
|
|
|
|
Instance,
|
|
|
|
CallerId,
|
|
|
|
Data
|
|
|
|
);
|
|
|
|
}
|
|
|
|
if (FeaturePcdGet (PcdStatusCodeUseOEM)) {
|
2009-04-27 08:14:50 +02:00
|
|
|
//
|
|
|
|
// Call OEM hook status code library API to report status code to OEM device
|
|
|
|
//
|
2007-07-13 08:45:00 +02:00
|
|
|
OemHookStatusCodeReport (
|
|
|
|
CodeType,
|
|
|
|
Value,
|
|
|
|
Instance,
|
|
|
|
CallerId,
|
|
|
|
Data
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Restore the nest status of report
|
|
|
|
//
|
2009-04-27 08:14:50 +02:00
|
|
|
InterlockedCompareExchange32 (&mStatusCodeNestStatus, 1, 0);
|
2007-07-13 08:45:00 +02:00
|
|
|
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2007-07-16 05:28:26 +02:00
|
|
|
Virtual address change notification call back. It converts global pointer
|
2007-07-13 08:45:00 +02:00
|
|
|
to virtual address.
|
|
|
|
|
|
|
|
@param Event Event whose notification function is being invoked.
|
|
|
|
@param Context Pointer to the notification function's context, which is
|
|
|
|
always zero in current implementation.
|
|
|
|
|
|
|
|
**/
|
|
|
|
VOID
|
|
|
|
EFIAPI
|
|
|
|
VirtualAddressChangeCallBack (
|
|
|
|
IN EFI_EVENT Event,
|
|
|
|
IN VOID *Context
|
|
|
|
)
|
|
|
|
{
|
|
|
|
//
|
|
|
|
// Convert memory status code table to virtual address;
|
|
|
|
//
|
|
|
|
EfiConvertPointer (
|
2007-07-16 05:28:26 +02:00
|
|
|
0,
|
2009-04-27 08:14:50 +02:00
|
|
|
(VOID **) &mRtMemoryStatusCodeTable
|
2007-07-13 08:45:00 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2009-04-27 08:35:40 +02:00
|
|
|
/**
|
|
|
|
Dispatch initialization request to sub status code devices based on
|
|
|
|
customized feature flags.
|
|
|
|
|
|
|
|
**/
|
|
|
|
VOID
|
|
|
|
InitializationDispatcherWorker (
|
|
|
|
VOID
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_PEI_HOB_POINTERS Hob;
|
|
|
|
EFI_STATUS Status;
|
|
|
|
MEMORY_STATUSCODE_PACKET_HEADER *PacketHeader;
|
|
|
|
MEMORY_STATUSCODE_RECORD *Record;
|
|
|
|
UINTN ExpectedPacketIndex;
|
|
|
|
UINTN Index;
|
|
|
|
VOID *HobStart;
|
|
|
|
|
|
|
|
//
|
|
|
|
// If enable UseSerial, then initialize serial port.
|
|
|
|
// if enable UseRuntimeMemory, then initialize runtime memory status code worker.
|
|
|
|
// if enable UseDataHub, then initialize data hub status code worker.
|
|
|
|
//
|
2009-06-16 03:16:27 +02:00
|
|
|
if (FeaturePcdGet (PcdStatusCodeUseSerial)) {
|
2009-04-27 08:35:40 +02:00
|
|
|
//
|
|
|
|
// Call Serial Port Lib API to initialize serial port.
|
|
|
|
//
|
|
|
|
Status = SerialPortInitialize ();
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
}
|
2009-06-16 03:16:27 +02:00
|
|
|
if (FeaturePcdGet (PcdStatusCodeUseMemory)) {
|
2009-04-27 08:35:40 +02:00
|
|
|
Status = RtMemoryStatusCodeInitializeWorker ();
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
}
|
|
|
|
if (FeaturePcdGet (PcdStatusCodeUseDataHub)) {
|
|
|
|
Status = DataHubStatusCodeInitializeWorker ();
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
}
|
|
|
|
if (FeaturePcdGet (PcdStatusCodeUseOEM)) {
|
|
|
|
//
|
|
|
|
// Call OEM hook status code library API to initialize OEM device for status code.
|
|
|
|
//
|
|
|
|
Status = OemHookStatusCodeInitialize ();
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Replay Status code which saved in GUID'ed HOB to all supported devices.
|
|
|
|
//
|
2009-06-16 03:16:27 +02:00
|
|
|
if (FeaturePcdGet (PcdStatusCodeReplayIn)) {
|
|
|
|
//
|
|
|
|
// Journal GUID'ed HOBs to find all record entry, if found,
|
|
|
|
// then output record to support replay device.
|
|
|
|
//
|
|
|
|
ExpectedPacketIndex = 0;
|
|
|
|
Hob.Raw = GetFirstGuidHob (&gMemoryStatusCodeRecordGuid);
|
|
|
|
HobStart = Hob.Raw;
|
|
|
|
while (Hob.Raw != NULL) {
|
|
|
|
PacketHeader = (MEMORY_STATUSCODE_PACKET_HEADER *) GET_GUID_HOB_DATA (Hob.Guid);
|
|
|
|
if (PacketHeader->PacketIndex == ExpectedPacketIndex) {
|
|
|
|
Record = (MEMORY_STATUSCODE_RECORD *) (PacketHeader + 1);
|
|
|
|
for (Index = 0; Index < PacketHeader->RecordIndex; Index++) {
|
2009-04-27 08:35:40 +02:00
|
|
|
//
|
2009-06-16 03:16:27 +02:00
|
|
|
// Dispatch records to devices based on feature flag.
|
2009-04-27 08:35:40 +02:00
|
|
|
//
|
2009-06-16 03:16:27 +02:00
|
|
|
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
|
|
|
|
);
|
|
|
|
}
|
2009-04-27 08:35:40 +02:00
|
|
|
}
|
2009-06-16 03:16:27 +02:00
|
|
|
ExpectedPacketIndex++;
|
|
|
|
|
|
|
|
//
|
|
|
|
// See whether there is gap of packet or not
|
|
|
|
//
|
|
|
|
if (HobStart != NULL) {
|
|
|
|
HobStart = NULL;
|
|
|
|
Hob.Raw = HobStart;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
} else if (HobStart != NULL) {
|
|
|
|
//
|
|
|
|
// Cache the found packet for improve the performance
|
|
|
|
//
|
|
|
|
HobStart = Hob.Raw;
|
2009-04-27 08:35:40 +02:00
|
|
|
}
|
2009-06-16 03:16:27 +02:00
|
|
|
|
|
|
|
Hob.Raw = GetNextGuidHob (&gMemoryStatusCodeRecordGuid, Hob.Raw);
|
2009-04-27 08:35:40 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|