X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=IntelFrameworkModulePkg%2FLibrary%2FPeiReportStatusCodeLib%2FReportStatusCodeLib.c;h=24606289c02db0df410ce07ecf551a24a88b6adf;hb=5e7ea54b33633bffb8208fc7a3ce5e50709721f3;hp=d027dc4a8e9e5b0ab99c8abd099ac24652536b3f;hpb=15cd6a822c3b96cc3d5e12d4ec271b686e7d0bd8;p=mirror_edk2.git diff --git a/IntelFrameworkModulePkg/Library/PeiReportStatusCodeLib/ReportStatusCodeLib.c b/IntelFrameworkModulePkg/Library/PeiReportStatusCodeLib/ReportStatusCodeLib.c index d027dc4a8e..24606289c0 100644 --- a/IntelFrameworkModulePkg/Library/PeiReportStatusCodeLib/ReportStatusCodeLib.c +++ b/IntelFrameworkModulePkg/Library/PeiReportStatusCodeLib/ReportStatusCodeLib.c @@ -1,7 +1,7 @@ /** @file - Report Status Code Library for PEI Phase. + Instance of Report Status Code Library for PEI Phase. - Copyright (c) 2006 - 2008, Intel Corporation
+ Copyright (c) 2006 - 2009, 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 @@ -16,6 +16,7 @@ #include #include +#include #include #include @@ -25,21 +26,17 @@ #include #include -#include - // // Define the maximum extended data size that is supported in the PEI phase // #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 - database. If a Status Code Protocol is not present, then EFI_UNSUPPORTED is - 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. + This function 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. @param Type Status code type. @param Value Status code value. @@ -50,9 +47,9 @@ @param Data Pointer to the extended data buffer. This is an optional parameter that may be NULL. - @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 Protocol is not available. + @retval EFI_SUCCESS The status code was reported. + @retval EFI_UNSUPPORTED Status code type is not supported. + @retval Others Failed to report status code. **/ EFI_STATUS @@ -68,10 +65,10 @@ InternalReportStatusCode ( EFI_STATUS Status; if ((ReportProgressCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) || - (ReportErrorCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) || - (ReportDebugCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE)) { + (ReportErrorCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) || + (ReportDebugCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE)) { PeiServices = GetPeiServicesTablePointer (); - Status = (*PeiServices)->ReportStatusCode ( + Status = (*PeiServices)->ReportStatusCode ( PeiServices, Type, Value, @@ -130,7 +127,7 @@ CodeTypeToPostCode ( // Convert Value to an 8 bit post 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) | (((Value & EFI_STATUS_CODE_SUBCLASS_MASK) >> 16) & 0x1f)); return TRUE; @@ -237,7 +234,7 @@ EFIAPI ReportStatusCodeExtractDebugInfo ( IN CONST EFI_STATUS_CODE_DATA *Data, OUT UINT32 *ErrorLevel, - OUT VA_LIST *Marker, + OUT BASE_LIST *Marker, OUT CHAR8 **Format ) { @@ -263,10 +260,15 @@ ReportStatusCodeExtractDebugInfo ( *ErrorLevel = DebugInfo->ErrorLevel; // - // The first 12 * UINTN bytes of the string are really an - // argument stack to support varargs on the Format string. + // The first 12 * sizeof (UINT64) bytes following EFI_DEBUG_INFO are for variable arguments + // of format in DEBUG string. Its address is returned in Marker and has to be 64-bit aligned. + // It must be noticed that EFI_DEBUG_INFO follows EFI_STATUS_CODE_DATA, whose size is + // 20 bytes. The size of EFI_DEBUG_INFO is 4 bytes, so we can ensure that Marker + // returned is 64-bit aligned. + // 64-bit aligned is a must, otherwise retrieving 64-bit parameter from BASE_LIST will + // cause unalignment exception. // - *Marker = (VA_LIST) (DebugInfo + 1); + *Marker = (BASE_LIST) (DebugInfo + 1); *Format = (CHAR8 *)(((UINT64 *)*Marker) + 12); return TRUE; @@ -342,6 +344,9 @@ ReportStatusCodeWithDevicePath ( ) { ASSERT (DevicePath != NULL); + // + // EFI_UNSUPPORTED is returned for device path is not supported in PEI phase. + // return EFI_UNSUPPORTED; } @@ -458,7 +463,13 @@ ReportStatusCodeEx ( EFI_STATUS_CODE_DATA *StatusCodeData; UINT64 Buffer[MAX_EXTENDED_DATA_SIZE / sizeof (UINT64)]; + // + // If ExtendedData is NULL and ExtendedDataSize is not zero, then ASSERT(). + // ASSERT (!((ExtendedData == NULL) && (ExtendedDataSize != 0))); + // + // If ExtendedData is not NULL and ExtendedDataSize is zero, then ASSERT(). + // ASSERT (!((ExtendedData != NULL) && (ExtendedDataSize == 0))); if (ExtendedDataSize > (MAX_EXTENDED_DATA_SIZE - sizeof (EFI_STATUS_CODE_DATA))) { @@ -471,7 +482,9 @@ ReportStatusCodeEx ( ExtendedDataGuid = &gEfiStatusCodeSpecificDataGuid; } CopyGuid (&StatusCodeData->Type, ExtendedDataGuid); - CopyMem (StatusCodeData + 1, ExtendedData, ExtendedDataSize); + if (ExtendedData != NULL) { + CopyMem (StatusCodeData + 1, ExtendedData, ExtendedDataSize); + } if (CallerId == NULL) { CallerId = &gEfiCallerIdGuid; } @@ -497,7 +510,7 @@ ReportProgressCodeEnabled ( 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); } @@ -519,7 +532,7 @@ ReportErrorCodeEnabled ( 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); } @@ -541,5 +554,5 @@ ReportDebugCodeEnabled ( 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); }