Leverages SMM Status Code Protocol, instead of OemHookStatusCodeLib.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9962 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
xli24 2010-02-10 03:41:24 +00:00
parent 787ef908e4
commit 19796be360
3 changed files with 71 additions and 36 deletions

View File

@ -2,7 +2,7 @@
Internal Header file of Report Status Code Library for RUNTIME
DXE Phase.
Copyright (c) 2006 - 2009, Intel Corporation<BR>
Copyright (c) 2006 - 2010, Intel Corporation<BR>
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
@ -25,35 +25,19 @@
#include <Library/UefiRuntimeServicesTableLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/DevicePathLib.h>
#include <Library/OemHookStatusCodeLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Guid/StatusCodeDataTypeId.h>
#include <Guid/StatusCodeDataTypeDebug.h>
#include <Guid/EventGroup.h>
#include <Protocol/SmmStatusCode.h>
#include <Protocol/StatusCode.h>
#include <Protocol/SmmBase.h>
extern EFI_STATUS_CODE_DATA *mStatusCodeData;
/**
Locate the report status code service.
In SMM, it retrieves OemHookStatusCodeReport() from customized OEM Hook Status Code Lib.
Otherwise, it first tries to retrieve ReportStatusCode() in Runtime Services Table.
If not found, it then tries to retrieve ReportStatusCode() API of Report Status Code Protocol.
@return Function pointer to the report status code service.
NULL is returned if no status code service is available.
**/
EFI_REPORT_STATUS_CODE
InternalGetReportStatusCode (
VOID
);
/**
Internal worker function that reports a status code through the status code service.

View File

@ -2,10 +2,10 @@
# Report status code library instance which supports logging message in SMM, as well as DXE & runtime phase.
#
# This library instance supports status code report in SMM, as well as DXE & runtime phase.
# In SMM, it logs message via customized OemHookStatusCodeLib.
# In SMM, it logs message via SMM Status Code Protocol.
# Otherwise, it logs message to ReportStatusCode() in framework runtime services table or runtime report status code protocol.
#
# Copyright (c) 2006 - 2009, Intel Corporation.
# Copyright (c) 2006 - 2010, 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
@ -33,7 +33,7 @@
# VALID_ARCHITECTURES = IA32 X64 EBC
#
[Sources.common]
[Sources]
ReportStatusCodeLib.c
SmmRuntimeDxeSupport.c
ReportStatusCodeLibInternal.h
@ -52,7 +52,6 @@
DebugLib
UefiRuntimeServicesTableLib
UefiBootServicesTableLib
OemHookStatusCodeLib
DevicePathLib
MemoryAllocationLib
@ -66,8 +65,8 @@
[Protocols]
gEfiStatusCodeRuntimeProtocolGuid ## CONSUMES
gEfiSmmBaseProtocolGuid ## CONSUMES
gEfiSmmStatusCodeProtocolGuid ## CONSUMES
[Pcd.common]
[Pcd]
gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask

View File

@ -1,7 +1,7 @@
/** @file
Library constructor & destructor, event handlers, and other internal worker functions.
Copyright (c) 2006 - 2009, Intel Corporation<BR>
Copyright (c) 2006 - 2010, Intel Corporation<BR>
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
@ -14,19 +14,71 @@
#include "ReportStatusCodeLibInternal.h"
EFI_EVENT mVirtualAddressChangeEvent;
EFI_EVENT mExitBootServicesEvent;
EFI_STATUS_CODE_DATA *mStatusCodeData;
BOOLEAN mInSmm;
EFI_SMM_BASE_PROTOCOL *mSmmBase;
EFI_RUNTIME_SERVICES *mInternalRT;
BOOLEAN mHaveExitedBootServices = FALSE;
EFI_REPORT_STATUS_CODE mReportStatusCode = NULL;
EFI_EVENT mVirtualAddressChangeEvent;
EFI_EVENT mExitBootServicesEvent;
EFI_STATUS_CODE_DATA *mStatusCodeData;
BOOLEAN mInSmm;
EFI_SMM_BASE_PROTOCOL *mSmmBase;
EFI_RUNTIME_SERVICES *mInternalRT;
BOOLEAN mHaveExitedBootServices = FALSE;
EFI_REPORT_STATUS_CODE mReportStatusCode = NULL;
EFI_SMM_STATUS_CODE_PROTOCOL *mSmmStatusCodeProtocol;
/**
Locates and caches SMM Status Code Protocol.
**/
VOID
SmmStatusCodeInitialize (
VOID
)
{
EFI_STATUS Status;
Status = gBS->LocateProtocol (&gEfiSmmStatusCodeProtocolGuid, NULL, (VOID **) &mSmmStatusCodeProtocol);
if (EFI_ERROR (Status)) {
mSmmStatusCodeProtocol = NULL;
}
}
/**
Report status code via SMM Status Code Protocol.
@param Type Indicates the type of status code being reported.
@param Value Describes the current status of a hardware or software entity.
This included information about the class and subclass that is used to classify the entity
as well as an operation. For progress codes, the operation is the current activity.
For error codes, it is the exception. For debug codes, it is not defined at this time.
@param Instance The enumeration of a hardware or software entity within the system.
A system may contain multiple entities that match a class/subclass pairing.
The instance differentiates between them. An instance of 0 indicates that instance information is unavailable,
not meaningful, or not relevant. Valid instance numbers start with 1.
@param CallerId This optional parameter may be used to identify the caller.
This parameter allows the status code driver to apply different rules to different callers.
@param Data This optional parameter may be used to pass additional data
@retval EFI_SUCCESS Always return EFI_SUCCESS.
**/
EFI_STATUS
SmmStatusCodeReport (
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
)
{
if (mSmmStatusCodeProtocol != NULL) {
(mSmmStatusCodeProtocol->ReportStatusCode) (mSmmStatusCodeProtocol, Type, Value, Instance, CallerId, Data);
}
return EFI_SUCCESS;
}
/**
Locate the report status code service.
In SMM, it retrieves OemHookStatusCodeReport() from customized OEM Hook Status Code Lib.
In SMM, it tries to retrieve SMM Status Code Protocol.
Otherwise, it first tries to retrieve ReportStatusCode() in Runtime Services Table.
If not found, it then tries to retrieve ReportStatusCode() API of Report Status Code Protocol.
@ -43,7 +95,7 @@ InternalGetReportStatusCode (
EFI_STATUS Status;
if (mInSmm) {
return (EFI_REPORT_STATUS_CODE) OemHookStatusCodeReport;
return (EFI_REPORT_STATUS_CODE) SmmStatusCodeReport;
} else if (mInternalRT != NULL && mInternalRT->Hdr.Revision < 0x20000) {
return ((FRAMEWORK_EFI_RUNTIME_SERVICES*)mInternalRT)->ReportStatusCode;
} else if (!mHaveExitedBootServices) {
@ -187,7 +239,7 @@ ReportStatusCodeLibConstruct (
(VOID **) &mStatusCodeData
);
ASSERT_EFI_ERROR (Status);
OemHookStatusCodeInitialize ();
SmmStatusCodeInitialize ();
return EFI_SUCCESS;
}
}