Refine code for PeiReportStatusCodeLib.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8306 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
xli24 2009-05-13 07:43:45 +00:00
parent 133ed0bf9d
commit 0ad78d0779
2 changed files with 33 additions and 24 deletions

View File

@ -1,7 +1,10 @@
#/** @file #/** @file
# Report status code library # Instance of Report Status Code Library for PEI Phase.
#
# Instance of Report Status Code Library for PEI Phase. It first tries to report status
# code via PEI Status Code Service. If the service is not available, it then tries calling
# OEM Hook Status Code Library.
# #
# ReportStatusCodeLib for PEIM which depends upon Pei Services table
# Copyright (c) 2006 - 2009, Intel Corporation. # Copyright (c) 2006 - 2009, Intel Corporation.
# #
# All rights reserved. This program and the accompanying materials # All rights reserved. This program and the accompanying materials
@ -21,12 +24,11 @@
MODULE_TYPE = PEIM MODULE_TYPE = PEIM
VERSION_STRING = 1.0 VERSION_STRING = 1.0
LIBRARY_CLASS = ReportStatusCodeLib|SEC PEIM PEI_CORE LIBRARY_CLASS = ReportStatusCodeLib|SEC PEIM PEI_CORE
EFI_SPECIFICATION_VERSION = 0x00020000
# #
# The following information is for reference only and not required by the build tools. # The following information is for reference only and not required by the build tools.
# #
# VALID_ARCHITECTURES = IA32 X64 IPF EBC # VALID_ARCHITECTURES = IA32 X64 IPF EBC (EBC is for build only)
# #
[Sources.common] [Sources.common]
@ -48,8 +50,8 @@
[Guids] [Guids]
gEfiStatusCodeSpecificDataGuid # ALWAYS_CONSUMED gEfiStatusCodeSpecificDataGuid ## CONSUMES
gEfiStatusCodeDataTypeDebugGuid # ALWAYS_CONSUMED gEfiStatusCodeDataTypeDebugGuid ## CONSUMES
[Pcd.common] [Pcd.common]

View File

@ -1,7 +1,7 @@
/** @file /** @file
Report Status Code Library for PEI Phase. Instance of Report Status Code Library for PEI Phase.
Copyright (c) 2006 - 2008, Intel Corporation<BR> Copyright (c) 2006 - 2009, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials All rights reserved. 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
@ -33,13 +33,11 @@
#define MAX_EXTENDED_DATA_SIZE 0x200 #define MAX_EXTENDED_DATA_SIZE 0x200
/** /**
Internal worker function that reports a status code through the Status Code Protocol Internal worker function that reports a status code through the PEI Status Code Service or
OEM Hook Status Code Library.
This function checks to see if a Status Code Protocol is present in the handle This function first tries to report status code via PEI Status Code Service. If the service
database. If a Status Code Protocol is not present, then EFI_UNSUPPORTED is is not available, it then tries calling OEM Hook Status Code Library.
returned. If a Status Code Protocol is present, then it is cached in gStatusCode,
and the ReportStatusCode() service of the Status Code Protocol is called passing in
Type, Value, Instance, CallerId, and Data. The result of this call is returned.
@param Type Status code type. @param Type Status code type.
@param Value Status code value. @param Value Status code value.
@ -50,9 +48,9 @@
@param Data Pointer to the extended data buffer. This is an @param Data Pointer to the extended data buffer. This is an
optional parameter that may be NULL. optional parameter that may be NULL.
@retval EFI_SUCCESS The status code was reported. @retval EFI_SUCCESS The status code was reported.
@retval EFI_OUT_OF_RESOURCES There were not enough resources to report the status code. @retval EFI_UNSUPPORTED Status code type is not supported.
@retval EFI_UNSUPPORTED Status Code Protocol is not available. @retval Others Failed to report status code.
**/ **/
EFI_STATUS EFI_STATUS
@ -68,10 +66,10 @@ InternalReportStatusCode (
EFI_STATUS Status; EFI_STATUS Status;
if ((ReportProgressCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) || if ((ReportProgressCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ||
(ReportErrorCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) || (ReportErrorCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ||
(ReportDebugCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE)) { (ReportDebugCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE)) {
PeiServices = GetPeiServicesTablePointer (); PeiServices = GetPeiServicesTablePointer ();
Status = (*PeiServices)->ReportStatusCode ( Status = (*PeiServices)->ReportStatusCode (
PeiServices, PeiServices,
Type, Type,
Value, Value,
@ -130,7 +128,7 @@ CodeTypeToPostCode (
// Convert Value to an 8 bit post code // Convert Value to an 8 bit post code
// //
if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) || if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ||
((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ) { ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE)) {
*PostCode = (UINT8) ((((Value & EFI_STATUS_CODE_CLASS_MASK) >> 24) << 5) | *PostCode = (UINT8) ((((Value & EFI_STATUS_CODE_CLASS_MASK) >> 24) << 5) |
(((Value & EFI_STATUS_CODE_SUBCLASS_MASK) >> 16) & 0x1f)); (((Value & EFI_STATUS_CODE_SUBCLASS_MASK) >> 16) & 0x1f));
return TRUE; return TRUE;
@ -342,6 +340,9 @@ ReportStatusCodeWithDevicePath (
) )
{ {
ASSERT (DevicePath != NULL); ASSERT (DevicePath != NULL);
//
// EFI_UNSUPPORTED is returned for device path is not supported in PEI phase.
//
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
@ -458,7 +459,13 @@ ReportStatusCodeEx (
EFI_STATUS_CODE_DATA *StatusCodeData; EFI_STATUS_CODE_DATA *StatusCodeData;
UINT64 Buffer[MAX_EXTENDED_DATA_SIZE / sizeof (UINT64)]; UINT64 Buffer[MAX_EXTENDED_DATA_SIZE / sizeof (UINT64)];
//
// If ExtendedData is NULL and ExtendedDataSize is not zero, then ASSERT().
//
ASSERT (!((ExtendedData == NULL) && (ExtendedDataSize != 0))); ASSERT (!((ExtendedData == NULL) && (ExtendedDataSize != 0)));
//
// If ExtendedData is not NULL and ExtendedDataSize is zero, then ASSERT().
//
ASSERT (!((ExtendedData != NULL) && (ExtendedDataSize == 0))); ASSERT (!((ExtendedData != NULL) && (ExtendedDataSize == 0)));
if (ExtendedDataSize > (MAX_EXTENDED_DATA_SIZE - sizeof (EFI_STATUS_CODE_DATA))) { if (ExtendedDataSize > (MAX_EXTENDED_DATA_SIZE - sizeof (EFI_STATUS_CODE_DATA))) {
@ -499,7 +506,7 @@ ReportProgressCodeEnabled (
VOID VOID
) )
{ {
return (BOOLEAN) ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED) != 0); return (BOOLEAN) ((PcdGet8 (PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED) != 0);
} }
@ -521,7 +528,7 @@ ReportErrorCodeEnabled (
VOID VOID
) )
{ {
return (BOOLEAN) ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED) != 0); return (BOOLEAN) ((PcdGet8 (PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED) != 0);
} }
@ -543,5 +550,5 @@ ReportDebugCodeEnabled (
VOID VOID
) )
{ {
return (BOOLEAN) ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED) != 0); return (BOOLEAN) ((PcdGet8 (PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED) != 0);
} }