diff --git a/MsWheaPkg/DummyErrorDriver/DummyErrorDriver.c b/MsWheaPkg/DummyErrorDriver/DummyErrorDriver.c index 0da3896d..73c115b1 100644 --- a/MsWheaPkg/DummyErrorDriver/DummyErrorDriver.c +++ b/MsWheaPkg/DummyErrorDriver/DummyErrorDriver.c @@ -1,10 +1,10 @@ -/** @file +/** @file DummyErrorDriver.c Raises various ReportStatusCode calls found throughout project MU. -Can be used to test parsing functions and telemetry functionality. +Can be used to test parsing functions and telemetry functionality. -Uncomment calls to ReportStatusCode to create HwErrRecs. Use HwhMenu +Uncomment calls to ReportStatusCode to create HwErrRecs. Use HwhMenu frontpage extension to easily view records. Copyright (c) Microsoft Corporation. All rights reserved. @@ -25,7 +25,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent @param[in] SystemTable A pointer to the EFI System Table. @retval EFI_SUCCESS The entry point executed successfully. - @retval other Some error occured when executing this entry point. + @retval other Some error occurred when executing this entry point. **/ EFI_STATUS @@ -52,9 +52,9 @@ DummyErrorDriverEntryPoint ( EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, sizeof(UINTN), &SetValueEnableDisable); - + if(EFI_ERROR(Status)) { - DEBUG((DEBUG_INFO, __FUNCTION__" Could not set the enable/disable variable!\n")); + DEBUG((DEBUG_INFO, "%a Could not set the enable/disable variable!\n", __FUNCTION__)); } break; diff --git a/MsWheaPkg/EnableDisableErrors/EnableDisableErrors.c b/MsWheaPkg/EnableDisableErrors/EnableDisableErrors.c index b03a4672..789f6adf 100644 --- a/MsWheaPkg/EnableDisableErrors/EnableDisableErrors.c +++ b/MsWheaPkg/EnableDisableErrors/EnableDisableErrors.c @@ -1,6 +1,6 @@ -/** @file - - +/** @file + + Copyright (c) Microsoft Corporation. All rights reserved. SPDX-License-Identifier: BSD-2-Clause-Patent @@ -35,7 +35,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent /** * Deletes all WHEA Error Records - * + * * @retval void **/ VOID @@ -61,29 +61,29 @@ DeleteAllWheaErrors(VOID) } /** - * Created to test uefi appliation which enables/disables errors. - * - * Simply run the application in the shell and add an argument after the + * Created to test uefi application which enables/disables errors. + * + * Simply run the application in the shell and add an argument after the * .efi file which is one of the following: - * + * * For now, let's say 0 = No errors * 1 = Errors every boot - * 2 = Errors only on next boot + * 2 = Errors only on next boot * 3 = Delete Currently Stored Variables * 4 = Raise an error right now. Can take 2 additional string arguments - * to populate extradata1 and extradata2 in UEFI Generic section data + * to populate extradata1 and extradata2 in UEFI Generic section data * struct * Expand this later - * + * * @param[in] ImageHandle * @param[in] SystemTable - * + * * @retval EFI_SUCCESS The desired value was written to the variable * EFI_PROTOCOL_ERROR The shell parameter protocol could not be found * EFI_NOT_FOUND The variable could not be written to * EFI_INVALID_PARAMETER The shell parameter was not a valid option * -**/ +**/ EFI_STATUS EFIAPI EnableDisableErrorsEntry( @@ -112,23 +112,23 @@ EnableDisableErrorsEntry( return EFI_PROTOCOL_ERROR; } - // Make sure theres an argument to view (beides the name of this file) + // Make sure theres an argument to view (besides the name of this file) if(ShellParams->Argc > 1) { // Convert the argument into Ascii so it can be converted to a digit - UnicodeStrnToAsciiStrS(ShellParams->Argv[1], - StrnLenS(ShellParams->Argv[1], MAX_NUM_DIGITS_READ), - Argument, - MAX_NUM_DIGITS_READ + 1, + UnicodeStrnToAsciiStrS(ShellParams->Argv[1], + StrnLenS(ShellParams->Argv[1], MAX_NUM_DIGITS_READ), + Argument, + MAX_NUM_DIGITS_READ + 1, &TempNum ); // Get decimal version of input Result = AsciiStrDecimalToUintn(Argument); - + // Check these individually because I suspect it may be possible to pass in a number like "1.3" but haven't tried if(Result == SET_NO_ERRORS || Result == SET_CONT_ERRORS || Result == SET_ONE_TIME_ERRORS) { - + // Set the variable Status = gRT->SetVariable(L"EnableDisableErrors", &gRaiseTelemetryErrorsAtBoot, @@ -136,7 +136,7 @@ EnableDisableErrorsEntry( EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, sizeof(UINTN), &Result - ); + ); // Debug print if we couldn't set the value if(EFI_ERROR(Status)) { @@ -146,7 +146,7 @@ EnableDisableErrorsEntry( // Check if the user wants to generate an immediate error } else if (Result == GEN_ERROR_DIGIT) { - + // Allocate space for the strings they may have passed in. Zero fill it so the data is empty if they // did not supply anything ExtraData1 = AllocateZeroPool(MAX_CHARS_EXTRA_DATA + 1); @@ -163,26 +163,26 @@ EnableDisableErrorsEntry( ExtraData2[MAX_CHARS_EXTRA_DATA] = '\0'; // If there is a second argument to fill into the extra data 1 - if (ShellParams->Argc > 2) { - + if (ShellParams->Argc > 2) { + // Fill it in - UnicodeStrnToAsciiStrS(ShellParams->Argv[2], - StrnLenS(ShellParams->Argv[2], MAX_CHARS_EXTRA_DATA), - ExtraData1, - MAX_CHARS_EXTRA_DATA + 1, + UnicodeStrnToAsciiStrS(ShellParams->Argv[2], + StrnLenS(ShellParams->Argv[2], MAX_CHARS_EXTRA_DATA), + ExtraData1, + MAX_CHARS_EXTRA_DATA + 1, &TempNum ); - // If there is a third argument to fill into the extradata2 + // If there is a third argument to fill into the extradata2 if (ShellParams->Argc > 3) { - + // Fill it in - UnicodeStrnToAsciiStrS(ShellParams->Argv[3], - StrnLenS(ShellParams->Argv[3], MAX_CHARS_EXTRA_DATA), - ExtraData2, - MAX_CHARS_EXTRA_DATA + 1, + UnicodeStrnToAsciiStrS(ShellParams->Argv[3], + StrnLenS(ShellParams->Argv[3], MAX_CHARS_EXTRA_DATA), + ExtraData2, + MAX_CHARS_EXTRA_DATA + 1, &TempNum - ); + ); } } @@ -196,12 +196,12 @@ EnableDisableErrorsEntry( DeleteAllWheaErrors(); } - // Debug print that we did not recieve a valid digit + // Debug print that we did not receive a valid digit else { DEBUG((DEBUG_INFO, "%a Parameter argument was invalid\n",__FUNCTION__)); return EFI_INVALID_PARAMETER; } - } + } // Debug print that we need the user to input some arguments else { diff --git a/MsWheaPkg/HwErrBert/BertHelper.h b/MsWheaPkg/HwErrBert/BertHelper.h index ba3aa1ef..1315aad9 100644 --- a/MsWheaPkg/HwErrBert/BertHelper.h +++ b/MsWheaPkg/HwErrBert/BertHelper.h @@ -1,5 +1,5 @@ -/** @file -- +/** @file -- Copyright (C) Microsoft Corporation. All rights reserved. @@ -12,7 +12,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent // // ACPI table information used to initialize tables. // -#define BOOT_ERROR_REGION_SIZE 0x1000 +#define BOOT_ERROR_REGION_SIZE 0x1000 #define EFI_HW_ERR_REC_VAR_NAME L"HwErrRec" #define EFI_HW_ERR_REC_VAR_NAME_LEN 13 // Buffer length covers at least "HwErrRec####\0" @@ -43,6 +43,7 @@ BertSetAcpiTable ( ); VOID +EFIAPI BertHeaderCreator ( BERT_CONTEXT *Context, UINT32 ErrorBlockSize diff --git a/MsWheaPkg/HwErrBert/HwErrBert.inf b/MsWheaPkg/HwErrBert/HwErrBert.inf index afc4e3e4..d004d815 100644 --- a/MsWheaPkg/HwErrBert/HwErrBert.inf +++ b/MsWheaPkg/HwErrBert/HwErrBert.inf @@ -25,6 +25,7 @@ [Sources] HwErrorBert.c BertHelper.c + BertHelper.h [Packages] MdePkg/MdePkg.dec @@ -48,7 +49,7 @@ [Protocols] gEfiAcpiTableProtocolGuid ## CONSUMES -[Pcd] +[Pcd] gMsWheaPkgTokenSpaceGuid.PcdVariableHardwareErrorRecordAttributeSupported gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemId gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemTableId diff --git a/MsWheaPkg/HwErrBert/HwErrorBert.c b/MsWheaPkg/HwErrBert/HwErrorBert.c index aadd4620..67e1ec84 100644 --- a/MsWheaPkg/HwErrBert/HwErrorBert.c +++ b/MsWheaPkg/HwErrBert/HwErrorBert.c @@ -1,7 +1,7 @@ /** @file -- HwErrorBert.c At EBS, driver will generate BERT table with all HwErrRec from flash storage. -At ReadyToBoot, driver will delete HwErrRec from flash. +At ReadyToBoot, driver will delete HwErrRec from flash. Copyright (C) Microsoft Corporation. All rights reserved. SPDX-License-Identifier: BSD-2-Clause-Patent @@ -49,7 +49,7 @@ SetupBert() { DEBUG((DEBUG_WARN, "%a: leaving because list of entries to catalogue was empty.\n", __FUNCTION__)); return; } - + DEBUG((DEBUG_VERBOSE, "%a - %x CPER entries to publish to BERT\n", __FUNCTION__, mVarNameListCount)); // Create & publish BERT Header @@ -67,7 +67,7 @@ SetupBert() { Buffer = NULL; NamePtr = &mVarNameList[Index * EFI_HW_ERR_REC_VAR_NAME_LEN]; DEBUG((DEBUG_VERBOSE, "%a - Publishing %s\n", __FUNCTION__, NamePtr)); - + // // Call, get variable size; call again, get variable // @@ -95,7 +95,7 @@ SetupBert() { NULL, &Size, Buffer); - + if (!EFI_ERROR (Status) && ValidateCperHeader((EFI_COMMON_ERROR_RECORD_HEADER *)Buffer, Size)) { // We got a CPER, time to add it to BERT! if (!BertAddAllCperSections(Context.BertHeader, Buffer)) { @@ -137,7 +137,7 @@ GenerateVariableList() { // Go through all the variables on flash while (TRUE) { - // Get ready to recieve the next name + // Get ready to receive the next name NewNameSize = NameSize; Status = gRT->GetNextVariableName(&NewNameSize, Name, &Guid); @@ -179,7 +179,7 @@ GenerateVariableList() { mVarNameListCount++; } - // We succeded! Let's not say otherwise. + // We succeeded! Let's not say otherwise. Status = EFI_SUCCESS; cleanup: @@ -206,7 +206,7 @@ ClearVariables() { UINT32 Index = 0; EFI_STATUS Status = EFI_SUCCESS; CHAR16 *NamePtr = NULL; - + DEBUG((DEBUG_VERBOSE, "%a enter: number of elements to clear = %x\n", __FUNCTION__, mVarNameListCount)); if (mVarNameList == NULL) { @@ -217,7 +217,7 @@ ClearVariables() { for (Index = 0; Index < mVarNameListCount; Index ++) { NamePtr = &mVarNameList[Index * EFI_HW_ERR_REC_VAR_NAME_LEN]; Status = gRT->SetVariable(NamePtr, &gEfiHardwareErrorVariableGuid, 0, 0, NULL); - + // Can't really do much if this fails if (EFI_ERROR(Status)) { DEBUG((DEBUG_ERROR, "Clearing variable %s failed with %r \n", NamePtr, Status)); @@ -289,7 +289,7 @@ ReadyToBootHandlerCallback( /** -Entry to +Entry to @param[in] ImageHandle The image handle. @param[in] SystemTable The system table. @@ -301,7 +301,7 @@ EFIAPI HwErrorBertEntry ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable - ) + ) { EFI_STATUS Status; @@ -334,13 +334,13 @@ HwErrorBertEntry ( } cleanup: - // If anything goes wrong, we will need to close the events. + // If anything goes wrong, we will need to close the events. ASSERT_EFI_ERROR(Status); if (EFI_ERROR(Status)) { if(mReadyToBootEvent != NULL) { Status = gBS->CloseEvent(mReadyToBootEvent); } - + if(mExitBootServicesEvent != NULL) { Status = gBS->CloseEvent(mExitBootServicesEvent); } diff --git a/MsWheaPkg/Library/MsWheaEarlyStorageLib/MsWheaEarlyStorageLib.c b/MsWheaPkg/Library/MsWheaEarlyStorageLib/MsWheaEarlyStorageLib.c index eed57787..6ccc2f78 100644 --- a/MsWheaPkg/Library/MsWheaEarlyStorageLib/MsWheaEarlyStorageLib.c +++ b/MsWheaPkg/Library/MsWheaEarlyStorageLib/MsWheaEarlyStorageLib.c @@ -1,6 +1,6 @@ /** @file -- MsWheaEarlyStorageLib.c -This header defines APIs to utilize special memory for MsWheaReport during +This header defines APIs to utilize special memory for MsWheaReport during early stage. Copyright (C) Microsoft Corporation. All rights reserved. @@ -24,7 +24,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent /** -This routine has the highest previlege to read any byte(s) on the CMOS +This routine has the highest privilege to read any byte(s) on the CMOS @param[in] Ptr The pointer to hold read data @param[in] Size The size of intended read data @@ -48,8 +48,8 @@ __MsWheaCMOSRawRead ( EFI_STATUS Status; mBuf = Ptr; - if ((mBuf == NULL) || - (Size == 0) || + if ((mBuf == NULL) || + (Size == 0) || ((UINT8)(PcdGet32(PcdMsWheaReportEarlyStorageCapacity) - Size) < Offset)) { Status = EFI_INVALID_PARAMETER; goto Cleanup; @@ -60,7 +60,7 @@ __MsWheaCMOSRawRead ( if ((mIndex >= 0) && (mIndex <= 127)) { IoWrite8(PCAT_RTC_LO_ADDRESS_PORT, mIndex); mBuf[i] = IoRead8(PCAT_RTC_LO_DATA_PORT); - } + } else { IoWrite8(PCAT_RTC_HI_ADDRESS_PORT, mIndex); mBuf[i] = IoRead8(PCAT_RTC_HI_DATA_PORT); @@ -74,7 +74,7 @@ Cleanup: /** -This routine has the highest previlege to write any byte(s) on the CMOS +This routine has the highest privilege to write any byte(s) on the CMOS @param[in] Ptr The pointer to hold intended written data @param[in] Size The size of intended written data @@ -98,8 +98,8 @@ __MsWheaCMOSRawWrite ( EFI_STATUS Status; mBuf = Ptr; - if ((mBuf == NULL) || - (Size == 0) || + if ((mBuf == NULL) || + (Size == 0) || ((UINT8)(PcdGet32(PcdMsWheaReportEarlyStorageCapacity) - Size) < Offset)) { Status = EFI_INVALID_PARAMETER; goto Cleanup; @@ -110,7 +110,7 @@ __MsWheaCMOSRawWrite ( if ((mIndex >= 0) && (mIndex <= 127)) { IoWrite8(PCAT_RTC_LO_ADDRESS_PORT, mIndex); IoWrite8(PCAT_RTC_LO_DATA_PORT, mBuf[i]); - } + } else { IoWrite8(PCAT_RTC_HI_ADDRESS_PORT, mIndex); IoWrite8(PCAT_RTC_HI_DATA_PORT, mBuf[i]); @@ -124,7 +124,7 @@ Cleanup: /** -This routine has the highest previlege to 'clear' any byte(s) on the CMOS +This routine has the highest privilege to 'clear' any byte(s) on the CMOS @param[in] Size The size of intended clear region @param[in] Offset The offset of clear data, starting from the beginning of CMOS @@ -144,7 +144,7 @@ __MsWheaCMOSRawClear ( UINT8 i; EFI_STATUS Status; - if ((Size == 0) || + if ((Size == 0) || ((UINT8)(PcdGet32(PcdMsWheaReportEarlyStorageCapacity) - Size) < Offset)) { Status = EFI_INVALID_PARAMETER; goto Cleanup; @@ -155,7 +155,7 @@ __MsWheaCMOSRawClear ( if ((mIndex >= 0) && (mIndex <= 127)) { IoWrite8(PCAT_RTC_LO_ADDRESS_PORT, mIndex); IoWrite8(PCAT_RTC_LO_DATA_PORT, PcdGet8(PcdMsWheaEarlyStorageDefaultValue)); - } + } else { IoWrite8(PCAT_RTC_HI_ADDRESS_PORT, mIndex); IoWrite8(PCAT_RTC_HI_DATA_PORT, PcdGet8(PcdMsWheaEarlyStorageDefaultValue)); diff --git a/MsWheaPkg/Library/MsWheaEarlyStorageLib/MsWheaEarlyStorageLib.inf b/MsWheaPkg/Library/MsWheaEarlyStorageLib/MsWheaEarlyStorageLib.inf index eb48868b..42ef890c 100644 --- a/MsWheaPkg/Library/MsWheaEarlyStorageLib/MsWheaEarlyStorageLib.inf +++ b/MsWheaPkg/Library/MsWheaEarlyStorageLib/MsWheaEarlyStorageLib.inf @@ -1,6 +1,6 @@ ## @file -- MsWheaEarlyStorageLib.inf # -# This header defines APIs to utilize special memory for MsWheaReport during +# This header defines APIs to utilize special memory for MsWheaReport during # early stage. # # Copyright (C) Microsoft Corporation. All rights reserved. @@ -43,3 +43,6 @@ gMsWheaPkgTokenSpaceGuid.PcdMsWheaReportEarlyStorageCapacity [Guids] + +[BuildOptions] + *_GCC5_*_CC_FLAGS = -Wno-unused-function diff --git a/MsWheaPkg/MsWheaPkg.ci.yaml b/MsWheaPkg/MsWheaPkg.ci.yaml index 8d857be0..e8a147b9 100644 --- a/MsWheaPkg/MsWheaPkg.ci.yaml +++ b/MsWheaPkg/MsWheaPkg.ci.yaml @@ -7,7 +7,6 @@ { ## options defined ci/Plugin/CompilerPlugin "CompilerPlugin": { - "skip": true, "DscPath": "MsWheaPkg.dsc" }, @@ -39,8 +38,8 @@ ## options defined ci/Plugin/DscCompleteCheck "DscCompleteCheck": { - "IgnoreInf": [], - "DscPath": "MsWheaPkg.dsc" + "IgnoreInf": [], + "DscPath": "MsWheaPkg.dsc" }, ## options defined ci/Plugin/GuidCheck @@ -59,12 +58,15 @@ ## options defined ci/Plugin/SpellCheck "SpellCheck": { - "AuditOnly": true, "IgnoreStandardPaths": [ # Standard Plugin defined paths that should be ignore ], "IgnoreFiles": [ # use gitignore syntax to ignore errors in matching files ], "ExtendWords": [ # words to extend to the dictionary for this package + "MSCHANGE", + "BERTs", + "DXEIPL", + "hwerrrec" ], "AdditionalIncludePaths": [] # Additional paths to spell check relative to package root (wildcards supported) } diff --git a/MsWheaPkg/MsWheaPkg.dsc b/MsWheaPkg/MsWheaPkg.dsc index f4f79b17..9002a060 100644 --- a/MsWheaPkg/MsWheaPkg.dsc +++ b/MsWheaPkg/MsWheaPkg.dsc @@ -33,15 +33,20 @@ BaseLib|MdePkg/Library/BaseLib/BaseLib.inf BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf -##MSCHANGE Begin -!if $(TARGET) == DEBUG - #if debug is enabled provide StackCookie support lib so that we can link to /GS exports +[LibraryClasses.X64] RngLib|MdePkg/Library/BaseRngLib/BaseRngLib.inf +!if $(TARGET) == DEBUG +!if $(TOOL_CHAIN_TAG) == VS2017 or $(TOOL_CHAIN_TAG) == VS2015 or $(TOOL_CHAIN_TAG) == VS2019 + #if debug is enabled provide StackCookie support lib so that we can link to /GS exports NULL|MdePkg/Library/BaseBinSecurityLibRng/BaseBinSecurityLibRng.inf + BaseBinSecurityLib|MdePkg/Library/BaseBinSecurityLibRng/BaseBinSecurityLibRng.inf +!else + # otherwise use the null version for GCC and CLANG + BaseBinSecurityLib|MdePkg/Library/BaseBinSecurityLibNull/BaseBinSecurityLibNull.inf +!endif !endif -##MSCHANGE End - +[LibraryClasses] UefiLib|MdePkg/Library/UefiLib/UefiLib.inf PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf @@ -124,7 +129,7 @@ # Check HWErrRec headers MsWheaPkg/Test/UnitTests/Library/LibraryClass/CheckHwErrRecHeaderTestsApp.inf - + # Raises Report Status Codes MsWheaPkg/DummyErrorDriver/DummyErrorDriver.inf diff --git a/MsWheaPkg/MsWheaReport/Dxe/MsWheaReportDxe.c b/MsWheaPkg/MsWheaReport/Dxe/MsWheaReportDxe.c index e4e2ab65..fe6ceae4 100644 --- a/MsWheaPkg/MsWheaReport/Dxe/MsWheaReportDxe.c +++ b/MsWheaPkg/MsWheaReport/Dxe/MsWheaReportDxe.c @@ -2,7 +2,7 @@ This Dxe driver will produce a RSC listener that listens to reported status codes. -Certains errors will be stored to flash upon reproting, under gEfiHardwareErrorVariableGuid +Certain errors will be stored to flash upon reproting, under gEfiHardwareErrorVariableGuid with VarName "HwErrRecXXXX", where "XXXX" are hexadecimal digits; Copyright (C) Microsoft Corporation. All rights reserved. @@ -73,6 +73,7 @@ with specifications. Malformed data will fail the entire reporting. **/ STATIC EFI_STATUS +EFIAPI MsWheaReportHandlerDxe( IN MS_WHEA_ERROR_ENTRY_MD *MsWheaEntryMD ) @@ -80,7 +81,7 @@ MsWheaReportHandlerDxe( EFI_STATUS Status; DEBUG((DEBUG_INFO, "%a: enter...\n", __FUNCTION__)); - + if (mExitBootHasOccurred != FALSE) { // This function is locked due to Exit Boot has occurred Status = EFI_ACCESS_DENIED; @@ -113,22 +114,23 @@ Added module phase information and route reported status code value and extended for further processing. @param[in] CodeType Indicates the type of status code being reported. -@param[in] Value Describes the current status of a hardware or software entity. This - includes information about the class and subclass that is used to +@param[in] Value Describes the current status of a hardware or software entity. This + includes information about the class and subclass that is used to classify the entity as well as an operation. -@param[in] Instance The enumeration of a hardware or software entity within the system. +@param[in] Instance The enumeration of a hardware or software entity within the system. Valid instance numbers start with 1. -@param[in] CallerId This optional parameter may be used to identify the caller. This +@param[in] 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[in] Data This optional parameter may be used to pass additional data. @retval EFI_SUCCESS Operation is successful -@retval Others Any other error that rises from Variable Services, Boot Services, +@retval Others Any other error that rises from Variable Services, Boot Services, Runtime Services, etc. **/ STATIC EFI_STATUS +EFIAPI MsWheaRscHandlerDxe ( IN EFI_STATUS_CODE_TYPE CodeType, IN EFI_STATUS_CODE_VALUE Value, @@ -163,6 +165,7 @@ This routine processes the reported errors during PEI phase through hob list **/ STATIC EFI_STATUS +EFIAPI MsWheaProcHob ( VOID ) @@ -194,8 +197,8 @@ MsWheaProcHob ( } } else { - DEBUG((DEBUG_ERROR, "%a: Bad entry: EntrySize: %08X, PayloadSize: %08X\n", __FUNCTION__, - EntrySize, + DEBUG((DEBUG_ERROR, "%a: Bad entry: EntrySize: %08X, PayloadSize: %08X\n", __FUNCTION__, + EntrySize, MsWheaEntryMD->PayloadSize)); } @@ -235,7 +238,7 @@ MsWheaProcList ( if (MsWheaListEntry->PayloadPtr != NULL) { MsWheaReportEntry = MsWheaListEntry->PayloadPtr; MsWheaEntryMD = (MS_WHEA_ERROR_ENTRY_MD *) MsWheaReportEntry; - + Status = MsWheaReportHandlerDxe(MsWheaEntryMD); if (EFI_ERROR(Status) != FALSE) { @@ -245,13 +248,13 @@ MsWheaProcList ( MsWheaDeleteReportEvent(&mMsWheaEntryList); } - + DEBUG((DEBUG_INFO, "%a: exit...\n", __FUNCTION__)); return Status; } /** -Process all previously reported status errors during PEI/early Dxe/previous boots +Process all previously reported status errors during PEI/early Dxe/previous boots @retval EFI_SUCCESS Operation is successful @retval Others See each individual function for more details @@ -263,7 +266,7 @@ MsWheaProcessPrevError ( ) { EFI_STATUS Status; - + Status = MsWheaESProcess(MsWheaReportHandlerDxe); if (EFI_ERROR(Status) != FALSE) { DEBUG((DEBUG_WARN, "%a: CMOS entries process failed %r\n", __FUNCTION__, Status)); @@ -286,11 +289,12 @@ MsWheaProcessPrevError ( Callback of exit boot event. This will unregister RSC handler in this module. @param[in] Event Event whose notification function is being invoked. -@param[in] Context The pointer to the notification function's context, which is +@param[in] Context The pointer to the notification function's context, which is implementation-dependent. **/ STATIC VOID +EFIAPI MsWheaReportDxeExitBoot ( IN EFI_EVENT Event, IN VOID *Context @@ -317,11 +321,12 @@ MsWheaReportDxeExitBoot ( Register Exit Boot callback and process previous errors when variable service is ready @param[in] Event Event whose notification function is being invoked. -@param[in] Context The pointer to the notification function's context, which is +@param[in] Context The pointer to the notification function's context, which is implementation-dependent. **/ STATIC VOID +EFIAPI MsWheaArchCallback ( IN EFI_EVENT Event, IN VOID *Context @@ -331,7 +336,7 @@ MsWheaArchCallback ( if ((Event == mWriteArchAvailEvent) && (mWriteArchAvailable == FALSE)) { mWriteArchAvailable = TRUE; - } + } else if ((Event == mVarArchAvailEvent) && (mVarArchAvailable == FALSE)) { mVarArchAvailable = TRUE; } @@ -364,7 +369,7 @@ Populates the current time for WHEA records @param[in,out] *CurrentTime A pointer to an EFI_TIME variable which will contain the curren time after this function executes -@retval BOOLEAN True if *CurrentTime was populated. +@retval BOOLEAN True if *CurrentTime was populated. False otherwise. **/ BOOLEAN @@ -380,7 +385,7 @@ PopulateTime(EFI_TIME* CurrentTime) Gets the Record ID variable and increments it for WHEA records @param[in,out] *RecordID Pointer to a UINT64 which will contain the record ID to be put on the next WHEA Record -@param[in] *RecordIDGuid Pointer to guid used to get the record ID variable +@param[in] *RecordIDGuid Pointer to guid used to get the record ID variable @retval EFI_SUCCESS The firmware has successfully stored the variable and its data as defined by the Attributes. @@ -391,9 +396,9 @@ Gets the Record ID variable and increments it for WHEA records @retval EFI_DEVICE_ERROR The variable could not be retrieved due to a hardware error. @retval EFI_WRITE_PROTECTED The variable in question is read-only. @retval EFI_WRITE_PROTECTED The variable in question cannot be deleted. -@retval EFI_SECURITY_VIOLATION The variable could not be written due to EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACESS being set, +@retval EFI_SECURITY_VIOLATION The variable could not be written due to EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS being set, but the AuthInfo does NOT pass the validation check carried out by the firmware. -@retval EFI_NOT_FOUND The variable trying to be updated or deleted was not found. +@retval EFI_NOT_FOUND The variable trying to be updated or deleted was not found. **/ EFI_STATUS GetRecordID(UINT64* RecordID, EFI_GUID *RecordIDGuid) @@ -405,7 +410,7 @@ GetRecordID(UINT64* RecordID, EFI_GUID *RecordIDGuid) DEBUG ((DEBUG_INFO, "%a Record ID variable not retrieved, initializing to 0\n", __FUNCTION__)); *RecordID = 0; - + } (*RecordID)++; //increment the record ID number @@ -420,10 +425,10 @@ GetRecordID(UINT64* RecordID, EFI_GUID *RecordIDGuid) } /** -Register Write Archetecture and Variable Archetecture callbacks +Register Write Architecture and Variable Architecture callbacks @param[in] Event Event whose notification function is being invoked. -@param[in] Context The pointer to the notification function's context, which is +@param[in] Context The pointer to the notification function's context, which is implementation-dependent. **/ STATIC @@ -434,25 +439,25 @@ MsWheaRegisterCallbacks ( { VOID *Registration; // Just a dummy, not used - // register for Write Archetecture Protocol Callback - mWriteArchAvailEvent = EfiCreateProtocolNotifyEvent(&gEfiVariableWriteArchProtocolGuid, - TPL_CALLBACK, - MsWheaArchCallback, - NULL, + // register for Write Architecture Protocol Callback + mWriteArchAvailEvent = EfiCreateProtocolNotifyEvent(&gEfiVariableWriteArchProtocolGuid, + TPL_CALLBACK, + MsWheaArchCallback, + NULL, &Registration); - // register for Variable Archetecture Protocol Callback - mVarArchAvailEvent = EfiCreateProtocolNotifyEvent(&gEfiVariableArchProtocolGuid, - TPL_CALLBACK, - MsWheaArchCallback, - NULL, + // register for Variable Architecture Protocol Callback + mVarArchAvailEvent = EfiCreateProtocolNotifyEvent(&gEfiVariableArchProtocolGuid, + TPL_CALLBACK, + MsWheaArchCallback, + NULL, &Registration); // register for Clock Architecture Protocol Callback - mClockArchAvailEvent = EfiCreateProtocolNotifyEvent(&gEfiRealTimeClockArchProtocolGuid, - TPL_CALLBACK, - MsWheaArchCallback, - NULL, + mClockArchAvailEvent = EfiCreateProtocolNotifyEvent(&gEfiRealTimeClockArchProtocolGuid, + TPL_CALLBACK, + MsWheaArchCallback, + NULL, &Registration); } @@ -469,7 +474,7 @@ EFIAPI MsWheaReportDxeEntry ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable - ) + ) { EFI_STATUS Status = EFI_SUCCESS; @@ -477,7 +482,7 @@ MsWheaReportDxeEntry ( // init linked list, all fields should be 0 InitializeListHead(&mMsWheaEntryList); - + // locate the RSC protocol Status = gBS->LocateProtocol(&gEfiRscHandlerProtocolGuid, NULL, (VOID**)&mRscHandlerProtocol); if (EFI_ERROR(Status) != FALSE) { diff --git a/MsWheaPkg/MsWheaReport/Dxe/MsWheaReportHER.c b/MsWheaPkg/MsWheaReport/Dxe/MsWheaReportHER.c index b72e69f5..b5689246 100644 --- a/MsWheaPkg/MsWheaReport/Dxe/MsWheaReportHER.c +++ b/MsWheaPkg/MsWheaReport/Dxe/MsWheaReportHER.c @@ -1,6 +1,6 @@ /** @file -- MsWheaReportHER.c -This source implements backend routines to support storing persistent hardware +This source implements backend routines to support storing persistent hardware error records in UEFI. Copyright (C) Microsoft Corporation. All rights reserved. @@ -23,7 +23,7 @@ Note: Caller is responsible for freeing the valid returned buffer!!! @param[out] PayloadSize The pointer to payload length, this will be updated to the totally allocated/operated size if operation succeeded -@retval NULL if any errors, otherwise filled and allocated buffer will be returned. +@retval NULL if any errors, otherwise filled and allocated buffer will be returned. **/ STATIC @@ -41,9 +41,9 @@ MsWheaAnFBuffer ( EFI_COMMON_ERROR_RECORD_HEADER *CperHdr; EFI_ERROR_SECTION_DESCRIPTOR *CperErrSecDscp; MU_TELEMETRY_CPER_SECTION_DATA *MuTelemetryData; - + DEBUG((DEBUG_INFO, "%a: enter...\n", __FUNCTION__)); - + if ((MsWheaEntryMD == NULL) || (PayloadSize == NULL)) { Status = EFI_INVALID_PARAMETER; goto Cleanup; @@ -51,7 +51,7 @@ MsWheaAnFBuffer ( ErrorPayloadSize = sizeof(MU_TELEMETRY_CPER_SECTION_DATA); - Buffer = AllocateZeroPool(sizeof(EFI_COMMON_ERROR_RECORD_HEADER) + + Buffer = AllocateZeroPool(sizeof(EFI_COMMON_ERROR_RECORD_HEADER) + sizeof(EFI_ERROR_SECTION_DESCRIPTOR) + ErrorPayloadSize); if (Buffer == NULL) { @@ -70,10 +70,10 @@ MsWheaAnFBuffer ( BufferIndex += sizeof(MU_TELEMETRY_CPER_SECTION_DATA); // Fill out error type based headers according to UEFI Spec... - CreateHeadersDefault(CperHdr, - CperErrSecDscp, - MuTelemetryData, - MsWheaEntryMD, + CreateHeadersDefault(CperHdr, + CperErrSecDscp, + MuTelemetryData, + MsWheaEntryMD, ErrorPayloadSize); // Update PayloadSize as the recorded error has Headers and Payload merged @@ -86,8 +86,8 @@ MsWheaAnFBuffer ( /** -This routine accepts the pointer to a UINT16 number. It will iterate through each HwErrRecXXXX and stops -after 0xFFFF iterations or spotted a slot that returns EFI_NOT_FOUND. +This routine accepts the pointer to a UINT16 number. It will iterate through each HwErrRecXXXX and stops +after 0xFFFF iterations or spotted a slot that returns EFI_NOT_FOUND. @param[out] next The pointer to output result holder @@ -107,7 +107,7 @@ MsWheaFindNextAvailableSlot ( UINT32 Index = 0; UINTN Size = 0; CHAR16 VarName[EFI_HW_ERR_REC_VAR_NAME_LEN]; - + if (next == NULL) { Status = EFI_INVALID_PARAMETER; goto Cleanup; @@ -165,7 +165,7 @@ MsWheaClearAllEntries ( UINTN NameSize; UINTN NewNameSize; EFI_GUID Guid; - + DEBUG((DEBUG_ERROR, "%a enter\n", __FUNCTION__)); NameSize = sizeof(CHAR16); @@ -228,7 +228,7 @@ MsWheaClearAllEntries ( if (Name) { FreePool(Name); } - + DEBUG((DEBUG_ERROR, "%a exit...\n", __FUNCTION__)); return Status; @@ -236,14 +236,14 @@ MsWheaClearAllEntries ( /** -This routine accepts the pointer to the MS WHEA entry metadata, error specific data payload and its size +This routine accepts the pointer to the MS WHEA entry metadata, error specific data payload and its size then store on the flash as HwErrRec awaiting to be picked up by OS (Refer to UEFI Spec 2.7A) @param[in] MsWheaEntryMD The pointer to reported MS WHEA error metadata @retval EFI_SUCCESS Entry addition is successful. @retval EFI_INVALID_PARAMETER Input has NULL pointer as input. -@retval EFI_OUT_OF_RESOURCES Not enough spcae for the requested space. +@retval EFI_OUT_OF_RESOURCES Not enough space for the requested space. **/ EFI_STATUS @@ -258,7 +258,7 @@ MsWheaReportHERAdd ( UINT32 Size = 0; CHAR16 VarName[EFI_HW_ERR_REC_VAR_NAME_LEN]; UINT32 Attributes; - + // 1. Find an available variable name for next write Status = MsWheaFindNextAvailableSlot(&Index); if (EFI_ERROR(Status)) { diff --git a/MsWheaPkg/MsWheaReport/Dxe/MsWheaReportHER.h b/MsWheaPkg/MsWheaReport/Dxe/MsWheaReportHER.h index 4584b0c9..a8f26269 100644 --- a/MsWheaPkg/MsWheaReport/Dxe/MsWheaReportHER.h +++ b/MsWheaPkg/MsWheaReport/Dxe/MsWheaReportHER.h @@ -28,14 +28,14 @@ MsWheaClearAllEntries ( /** -This routine accepts the pointer to the MS WHEA entry metadata, error specific data payload and its size +This routine accepts the pointer to the MS WHEA entry metadata, error specific data payload and its size then store on the flash as HwErrRec awaiting to be picked up by OS (Refer to UEFI Spec 2.7A) @param[in] MsWheaEntryMD The pointer to reported MS WHEA error metadata @retval EFI_SUCCESS Entry addition is successful. @retval EFI_INVALID_PARAMETER Input has NULL pointer as input. -@retval EFI_OUT_OF_RESOURCES Not enough spcae for the requested space. +@retval EFI_OUT_OF_RESOURCES Not enough space for the requested space. **/ EFI_STATUS diff --git a/MsWheaPkg/MsWheaReport/Dxe/MsWheaReportList.c b/MsWheaPkg/MsWheaReport/Dxe/MsWheaReportList.c index 5cd6bef8..8c4a71ae 100644 --- a/MsWheaPkg/MsWheaReport/Dxe/MsWheaReportList.c +++ b/MsWheaPkg/MsWheaReport/Dxe/MsWheaReportList.c @@ -42,7 +42,7 @@ CreateNewEntry ( } MsWheaListEntry->Signature = MS_WHEA_LIST_ENTRY_SIGNATURE; - + MsWheaListEntry->PayloadPtr = AllocateZeroPool(sizeof(MS_WHEA_ERROR_ENTRY_MD)); if (MsWheaListEntry->PayloadPtr == NULL) { FreePool(MsWheaListEntry); @@ -65,7 +65,7 @@ Cleanup: /** -This routine accepts the MS WHEA linked list and the reported data and data length, then add the data to the +This routine accepts the MS WHEA linked list and the reported data and data length, then add the data to the existed list, First In First Out (FIFO) @param[in] MsWheaLinkedList Supplies a MS WHEA error linked list header. @@ -73,7 +73,7 @@ existed list, First In First Out (FIFO) @retval EFI_SUCCESS Entry addition is successful. @retval EFI_INVALID_PARAMETER Input has NULL pointer as input. -@retval EFI_OUT_OF_RESOURCES Not enough spcae for the requested space. +@retval EFI_OUT_OF_RESOURCES Not enough space for the requested space. **/ EFI_STATUS @@ -85,7 +85,7 @@ MsWheaAddReportEvent( { EFI_STATUS Status; MS_WHEA_LIST_ENTRY *MsWheaListEntry = NULL; - + // Caller has to supply valid pointers to linked list and data. if (MsWheaLinkedList == NULL) { Status = EFI_INVALID_PARAMETER; @@ -101,7 +101,7 @@ MsWheaAddReportEvent( // Added the initialized entry into the linked list InsertTailList(MsWheaLinkedList, &MsWheaListEntry->Link); - + Status = EFI_SUCCESS; Cleanup: diff --git a/MsWheaPkg/MsWheaReport/Dxe/MsWheaReportList.h b/MsWheaPkg/MsWheaReport/Dxe/MsWheaReportList.h index e211edc4..a3c53c49 100644 --- a/MsWheaPkg/MsWheaReport/Dxe/MsWheaReportList.h +++ b/MsWheaPkg/MsWheaReport/Dxe/MsWheaReportList.h @@ -24,7 +24,7 @@ typedef struct MS_WHEA_LIST_ENTRY_T_DEF { /** -This routine accepts the MS WHEA metadata and the reported data and data length, then add the data to the +This routine accepts the MS WHEA metadata and the reported data and data length, then add the data to the existed list, First In First Out (FIFO) @param[in] MsWheaLinkedList Supplies a MS WHEA error linked list header. @@ -33,7 +33,7 @@ existed list, First In First Out (FIFO) @retval EFI_SUCCESS Entry addition is successful. @retval EFI_INVALID_PARAMETER Input has NULL pointer as input. -@retval EFI_OUT_OF_RESOURCES Not enough spcae for the requested space. +@retval EFI_OUT_OF_RESOURCES Not enough space for the requested space. **/ EFI_STATUS diff --git a/MsWheaPkg/MsWheaReport/MsWheaEarlyStorageMgr.c b/MsWheaPkg/MsWheaReport/MsWheaEarlyStorageMgr.c index 9fb089c0..78d1e361 100644 --- a/MsWheaPkg/MsWheaReport/MsWheaEarlyStorageMgr.c +++ b/MsWheaPkg/MsWheaReport/MsWheaEarlyStorageMgr.c @@ -43,7 +43,7 @@ This is a helper function that reads the early storage region with an offset of @param[in] Ptr The pointer to hold intended read data @param[in] Size The size of intended read data -@param[in] Offset The offset of read data, ranging from 0 to +@param[in] Offset The offset of read data, ranging from 0 to PcdMsWheaReportEarlyStorageCapacity - MS_WHEA_EARLY_STORAGE_DATA_OFFSET @retval EFI_SUCCESS Operation is successful @@ -77,7 +77,7 @@ This is a helper function that writes the early storage region with an offset of @param[in] Ptr The pointer to hold intended written data @param[in] Size The size of intended written data -@param[in] Offset The offset of written data, ranging from 0 to +@param[in] Offset The offset of written data, ranging from 0 to PcdMsWheaReportEarlyStorageCapacity - MS_WHEA_EARLY_STORAGE_DATA_OFFSET @retval EFI_SUCCESS Operation is successful @@ -109,7 +109,7 @@ Cleanup: This is a helper function that clears the early storage region with an offset of header size. @param[in] Size The size of intended clear data -@param[in] Offset The offset of clear data, ranging from 0 to +@param[in] Offset The offset of clear data, ranging from 0 to PcdMsWheaReportEarlyStorageCapacity - MS_WHEA_EARLY_STORAGE_DATA_OFFSET @retval EFI_SUCCESS Operation is successful @@ -389,11 +389,11 @@ Cleanup: /** -This routine finds a contiguous memory that has default value of specified size in data region +This routine finds a contiguous memory that has default value of specified size in data region from the MS WHEA store. @param[in] Size The size of intended clear data -@param[out] Offset The pointer to receive returned offset value, starting from +@param[out] Offset The pointer to receive returned offset value, starting from Early MS_WHEA_EARLY_STORAGE_DATA_OFFSET @retval EFI_SUCCESS Operation is successful @@ -443,9 +443,9 @@ MsWheaESInit ( // Clear the rest of the Early Storage store. MsWheaESClearAllData(); - // Zero all the fields in the + // Zero all the fields in the SetMem(&Header, MS_WHEA_EARLY_STORAGE_HEADER_SIZE, 0); - + // Sign the header signature. Header.Signature = MS_WHEA_EARLY_STORAGE_SIGNATURE; Header.ActiveRange = 0; @@ -457,7 +457,7 @@ Cleanup: } /** -This routine will extract necessary Rev 0 information from supplied metadata and store onto the next +This routine will extract necessary Rev 0 information from supplied metadata and store onto the next contiguously available Early Storage data region @param[in] MsWheaEntryMD The pointer to reported MS WHEA error metadata @@ -507,7 +507,7 @@ This routine will read Rev 0 information from specified offset on Early Storage metadata based on read value @param[out] MsWheaEntryMD The pointer to reported MS WHEA error metadata -@param[in, out] Offset The pointer to specified offset, will be updated to the end of +@param[in, out] Offset The pointer to specified offset, will be updated to the end of processed data upon successful operation @retval EFI_SUCCESS Operation is successful @@ -562,14 +562,14 @@ Cleanup: /** -This routine will Set Early Storage header IsStorageFull flag and mark the system stage if the signature is +This routine will Set Early Storage header IsStorageFull flag and mark the system stage if the signature is legit -@param[in] Phase Current envirnment stage by the time of report +@param[in] Phase Current environment stage by the time of report @retval EFI_SUCCESS Operation is successful @retval EFI_NOT_FOUND Early Storage header region is not valid -@retval Others See MsWheaESFindSlot and MsWheaESReadData for more +@retval Others See MsWheaESFindSlot and MsWheaESReadData for more details **/ @@ -665,7 +665,7 @@ This routine will store data onto Early Storage data region based on supplied MS @param[in] MsWheaEntryMD The pointer to reported MS WHEA error metadata @retval EFI_SUCCESS Operation is successful -@retval Others See MsWheaESFindSlot and MsWheaESWriteData for more +@retval Others See MsWheaESFindSlot and MsWheaESWriteData for more details **/ EFI_STATUS @@ -720,7 +720,7 @@ This routine processes the stored errors on Early Storage data region @retval EFI_SUCCESS Operation is successful @retval EFI_INVALID_PARAMETER Null pointer detected -@retval Others See implementation specific functions and MS_WHEA_ERR_REPORT_PS_FN +@retval Others See implementation specific functions and MS_WHEA_ERR_REPORT_PS_FN definition for more details **/ EFI_STATUS @@ -738,7 +738,7 @@ MsWheaESProcess ( DEBUG((DEBUG_INFO, "%a: enter...\n", __FUNCTION__)); if (ReportFn == NULL) { - DEBUG((DEBUG_ERROR, "%a: Input fucntion pointer cannot be null!\n", __FUNCTION__)); + DEBUG((DEBUG_ERROR, "%a: Input function pointer cannot be null!\n", __FUNCTION__)); Status = EFI_INVALID_PARAMETER; goto Cleanup; } @@ -763,8 +763,8 @@ MsWheaESProcess ( while ((Header.ActiveRange >= sizeof(MS_WHEA_EARLY_STORAGE_ENTRY_COMMON)) && (Index <= (Header.ActiveRange - sizeof(MS_WHEA_EARLY_STORAGE_ENTRY_COMMON)))) { - Status = MsWheaESReadData(&mRevInfo, - sizeof(mRevInfo), + Status = MsWheaESReadData(&mRevInfo, + sizeof(mRevInfo), Index + OFFSET_OF(MS_WHEA_EARLY_STORAGE_ENTRY_COMMON, Rev)); if (EFI_ERROR(Status) != FALSE) { DEBUG((DEBUG_ERROR, "%a: Early Storage storage read Index %d failed: %r\n", __FUNCTION__, Index, Status)); @@ -792,7 +792,7 @@ MsWheaESProcess ( // This is needed incase there is leftover garbage in default/failed cases MsWheaESClearAllData(); - // Zero all the fields in the + // Zero all the fields in the SetMem(&Header, MS_WHEA_EARLY_STORAGE_HEADER_SIZE, 0); // Sign the header signature. diff --git a/MsWheaPkg/MsWheaReport/MsWheaReportCommon.c b/MsWheaPkg/MsWheaReport/MsWheaReportCommon.c index 0b2231b3..5f0807f2 100644 --- a/MsWheaPkg/MsWheaReport/MsWheaReportCommon.c +++ b/MsWheaPkg/MsWheaReport/MsWheaReportCommon.c @@ -28,7 +28,7 @@ Zeroed: Flags, PersistenceInfo; @param[in] PayloadSize Length of entire payload to be included within this entry, refer to UEFI Spec for more information @param[in] ErrorSeverity Error severity of this entry -@param[in] ErrorStatusCode Reported Status Code from ReportStatucCode* function +@param[in] ErrorStatusCode Reported Status Code from ReportStatusCode* function @param[in] PartitionIdGuid PartitionID for error source identification, default to zero guid if not supplied by caller @@ -65,7 +65,7 @@ CreateCperHdrDefaultMin ( CperHdr->ErrorSeverity = ErrorSeverity; CperHdr->ValidationBits = EFI_ERROR_RECORD_HEADER_PLATFORM_ID_VALID; CperHdr->RecordLength = (UINT32)(sizeof(EFI_COMMON_ERROR_RECORD_HEADER) + sizeof(EFI_ERROR_SECTION_DESCRIPTOR) + PayloadSize); - + if(PopulateTime(&CurrentTime)){ CperHdr->ValidationBits |= (EFI_ERROR_RECORD_HEADER_TIME_STAMP_VALID); CperHdr->TimeStamp.Seconds = DecimalToBcd8(CurrentTime.Second); @@ -97,7 +97,7 @@ CreateCperHdrDefaultMin ( if(EFI_ERROR(GetRecordID(&RecordID, &gMsWheaReportRecordIDGuid))) { DEBUG ((DEBUG_INFO, "%a - RECORD ID NOT UPDATED\n", __FUNCTION__)); } - + //Even if the record id was not updated, the value is either 0 or the previously incremented value CperHdr->RecordID = RecordID; CperHdr->Flags |= EFI_HW_ERROR_FLAGS_PREVERR; @@ -196,7 +196,7 @@ Cleanup: /** This routine will populate certain MS WHEA metadata fields based on supplied information -@param[in] Value Reported Status Code from ReportStatucCode* function +@param[in] Value Reported Status Code from ReportStatusCode* function @param[in] CurrentPhase Supplies the boot phase the reporting module is in @param[in] ReportHdr Supplies the pointer to reported MS WHEA header, will be treated as wildcard if cannot decode signature @@ -328,7 +328,7 @@ Cleanup: /** This routine will filter status code based on status type, decode reported extended data , if any, generate MS WHEA metadata based on decoded information and either 1. pass generated metadata to supplied -callback function for further processing or 2. store onto CMOS if boot phase and error severtiy meets +callback function for further processing or 2. store onto CMOS if boot phase and error severity meets certain requirements @param[in] CodeType Indicates the type of status code being reported. @@ -368,7 +368,7 @@ ReportHwErrRecRouter ( MS_WHEA_ERROR_ENTRY_MD MsWheaEntryMD; if (ReportFn == NULL) { - DEBUG((DEBUG_ERROR, "%a: Input fucntion pointer cannot be null!\n", __FUNCTION__)); + DEBUG((DEBUG_ERROR, "%a: Input function pointer cannot be null!\n", __FUNCTION__)); Status = EFI_INVALID_PARAMETER; goto Cleanup; } diff --git a/MsWheaPkg/MsWheaReport/MsWheaReportCommon.h b/MsWheaPkg/MsWheaReport/MsWheaReportCommon.h index f982350b..5897f66b 100644 --- a/MsWheaPkg/MsWheaReport/MsWheaReportCommon.h +++ b/MsWheaPkg/MsWheaReport/MsWheaReportCommon.h @@ -27,7 +27,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent /** Definition wrapper to unify all bert/hwerrrec related specification versioning **/ -#define MS_WHEA_SECTION_REVISION 0x0100 // Set Section Descriptor Revision to 1.0 as per UEFI Spec 2.7A +#define MS_WHEA_SECTION_REVISION 0x0100 // Set Section Descriptor Revision to 1.0 as per UEFI Spec 2.7A #define EFI_HW_ERR_REC_VAR_NAME L"HwErrRec" #define EFI_HW_ERR_REC_VAR_NAME_LEN 16 // Buffer length covers at least "HwErrRec####\0" @@ -64,7 +64,7 @@ typedef struct MS_WHEA_ERROR_ENTRY_MD_T_DEF { #pragma pack() /** -This routine accepts the Common Platform Error Record header and Section +This routine accepts the Common Platform Error Record header and Section Descriptor and correspthen store on the flash as HwErrRec awaiting to be picked up by OS (Refer to UEFI Spec 2.7A) @@ -72,7 +72,7 @@ Descriptor and correspthen store on the flash as HwErrRec awaiting to be picked @retval EFI_SUCCESS Entry addition is successful. @retval EFI_INVALID_PARAMETER Input has NULL pointer as input. -@retval EFI_OUT_OF_RESOURCES Not enough spcae for the requested space. +@retval EFI_OUT_OF_RESOURCES Not enough space for the requested space. **/ typedef EFI_STATUS @@ -88,17 +88,17 @@ This routine will fill CPER related headers with certain preset values; Presets: NotificationType: gEfiEventNotificationTypeBootGuid; SectionType: gMuTelemetrySectionTypeGuid; Zeroed: CPER Header: Flags, RecordID; Section Descriptor: SectionFlags, FruId, FruString; -@param[out] CperHdr Supplies a pointer to CPER header structure +@param[out] CperHdr Supplies a pointer to CPER header structure @param[out] CperErrSecDscp Supplies a pointer to CPER Section Decsriptor structure @param[out] MuTelemetryData Supplies a pointer to Mu telemetry data structure @param[in] MsWheaEntryMD Supplies a pointer to reported MS WHEA error metadata -@param[in] PayloadSize Length of entire payload to be included within this entry, refer to +@param[in] PayloadSize Length of entire payload to be included within this entry, refer to UEFI Spec for more information @retval EFI_SUCCESS The operation completed successfully @retval EFI_INVALID_PARAMETER Any required input pointer is NULL **/ -EFI_STATUS +EFI_STATUS EFIAPI CreateHeadersDefault ( OUT EFI_COMMON_ERROR_RECORD_HEADER *CperHdr, @@ -109,29 +109,29 @@ CreateHeadersDefault ( ); /** -This routine will filter status code based on status type, decode reported extended data , if any, +This routine will filter status code based on status type, decode reported extended data , if any, generate MS WHEA metadata based on decoded information and either 1. pass generated metadata to supplied -callback function for further processing or 2. store onto CMOS if boot phase and error severtiy meets +callback function for further processing or 2. store onto CMOS if boot phase and error severity meets certain requirements @param[in] CodeType Indicates the type of status code being reported. @param[in] Value Describes the current status of a hardware or software entity. This - includes information about the class and subclass that is used to + includes information about the class and subclass that is used to classify the entity as well as an operation. -@param[in] Instance The enumeration of a hardware or software entity within the system. +@param[in] Instance The enumeration of a hardware or software entity within the system. Valid instance numbers start with 1. -@param[in] CallerId This optional parameter may be used to identify the caller. This - parameter allows the status code driver to apply different rules to +@param[in] 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[in] Data This optional parameter may be used to pass additional data. -@param[in] CurrentPhase This is passed by the RSC handler by indicating what to do next +@param[in] CurrentPhase This is passed by the RSC handler by indicating what to do next (store critical information on the CMOS) -@param[in] ReportFn Function pointer collect input argument and save to HwErrRec for OS - to process +@param[in] ReportFn Function pointer collect input argument and save to HwErrRec for OS + to process @retval EFI_SUCCESS The operation completed successfully @retval EFI_INVALID_PARAMETER Any required input pointer is NULL -@retval Others Any other error that rises from Variable Services, Boot Services, +@retval Others Any other error that rises from Variable Services, Boot Services, Runtime Services, etc. **/ EFI_STATUS @@ -152,7 +152,7 @@ Populates the current time for WHEA records @param[in,out] *CurrentTime A pointer to an EFI_TIME variable which will contain the curren time after this function executes -@retval BOOLEAN True if *CurrentTime was populated. +@retval BOOLEAN True if *CurrentTime was populated. False otherwise. **/ BOOLEAN @@ -162,7 +162,7 @@ PopulateTime(EFI_TIME* CurrentTime); Gets the Record ID variable and increments it for WHEA records @param[in,out] *RecordID Pointer to a UINT64 which will contain the record ID to be put on the next WHEA Record -@param[in] *RecordIDGuid Pointer to guid used to get the record ID variable +@param[in] *RecordIDGuid Pointer to guid used to get the record ID variable @retval EFI_SUCCESS The firmware has successfully stored the variable and its data as defined by the Attributes. @@ -173,12 +173,12 @@ Gets the Record ID variable and increments it for WHEA records @retval EFI_DEVICE_ERROR The variable could not be retrieved due to a hardware error. @retval EFI_WRITE_PROTECTED The variable in question is read-only. @retval EFI_WRITE_PROTECTED The variable in question cannot be deleted. -@retval EFI_SECURITY_VIOLATION The variable could not be written due to EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACESS being set, +@retval EFI_SECURITY_VIOLATION The variable could not be written due to EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS being set, but the AuthInfo does NOT pass the validation check carried out by the firmware. -@retval EFI_NOT_FOUND The variable trying to be updated or deleted was not found. +@retval EFI_NOT_FOUND The variable trying to be updated or deleted was not found. **/ EFI_STATUS -GetRecordID(UINT64* RecordID, +GetRecordID(UINT64* RecordID, EFI_GUID *RecordIDGuid ); diff --git a/MsWheaPkg/MsWheaReport/Pei/MsWheaReportPei.c b/MsWheaPkg/MsWheaReport/Pei/MsWheaReportPei.c index f38c3f10..d2dbcacf 100644 --- a/MsWheaPkg/MsWheaReport/Pei/MsWheaReportPei.c +++ b/MsWheaPkg/MsWheaReport/Pei/MsWheaReportPei.c @@ -2,7 +2,7 @@ This Pei module will produce a RSC listener that listens to reported status codes. -Certains errors will be collected and added to Hob List and waiting to be collected +Certain errors will be collected and added to Hob List and waiting to be collected and/or stored during Dxe phase; Copyright (C) Microsoft Corporation. All rights reserved. @@ -26,7 +26,7 @@ Handler function that validates input arguments, and create a hob list entry for @retval EFI_SUCCESS Operation is successful @retval EFI_OUT_OF_RESOURCES List cannot make the space for requested error block payload -@retval EFI_INVALID_PARAMETER Null pointer or zero length payload detected or length and header +@retval EFI_INVALID_PARAMETER Null pointer or zero length payload detected or length and header length field exceeds variable limit **/ STATIC @@ -40,11 +40,11 @@ MsWheaReportHandlerPei( UINT32 Size; VOID *MsWheaReportEntry = NULL; - if ((MsWheaEntryMD == NULL) || - ((sizeof(EFI_COMMON_ERROR_RECORD_HEADER) + - sizeof(EFI_ERROR_SECTION_DESCRIPTOR) + - sizeof(AUTHENTICATED_VARIABLE_HEADER) + - EFI_HW_ERR_REC_VAR_NAME_LEN * sizeof(CHAR16)) > + if ((MsWheaEntryMD == NULL) || + ((sizeof(EFI_COMMON_ERROR_RECORD_HEADER) + + sizeof(EFI_ERROR_SECTION_DESCRIPTOR) + + sizeof(AUTHENTICATED_VARIABLE_HEADER) + + EFI_HW_ERR_REC_VAR_NAME_LEN * sizeof(CHAR16)) > PcdGet32 (PcdMaxHardwareErrorVariableSize)) ) { Status = EFI_INVALID_PARAMETER; goto Cleanup; @@ -58,7 +58,7 @@ MsWheaReportHandlerPei( Status = EFI_OUT_OF_RESOURCES; goto Cleanup; } - + ZeroMem(MsWheaReportEntry, Size); Index = 0; @@ -78,18 +78,18 @@ for further processing. @param[in] PeiServices Pointer to PEI services table. @param[in] CodeType Indicates the type of status code being reported. -@param[in] Value Describes the current status of a hardware or software entity. This - includes information about the class and subclass that is used to +@param[in] Value Describes the current status of a hardware or software entity. This + includes information about the class and subclass that is used to classify the entity as well as an operation. -@param[in] Instance The enumeration of a hardware or software entity within the system. +@param[in] Instance The enumeration of a hardware or software entity within the system. Valid instance numbers start with 1. -@param[in] CallerId This optional parameter may be used to identify the caller. This +@param[in] 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[in] Data This optional parameter may be used to pass additional data. @retval EFI_SUCCESS Operation is successful -@retval Others Any other error that rises from Variable Services, Boot Services, +@retval Others Any other error that rises from Variable Services, Boot Services, Runtime Services, etc. **/ STATIC @@ -123,7 +123,7 @@ PopulateTime(EFI_TIME* CurrentTime) //A do-nothing function so MsWHeaReportCommon.c doesn't encounter an error when calling GetRecordID() during Pei phase. //Dxe phase drivers actually populate time, see GetRecordID() in MsWheaReportDxe.c EFI_STATUS -GetRecordID(UINT64* RecordID, +GetRecordID(UINT64* RecordID, EFI_GUID *RecordIDGuid OPTIONAL ) { @@ -143,7 +143,7 @@ EFIAPI MsWheaReportPeiEntry ( IN EFI_PEI_FILE_HANDLE FileHandle, IN CONST EFI_PEI_SERVICES **PeiServices - ) + ) { EFI_STATUS Status = EFI_SUCCESS; @@ -158,18 +158,18 @@ MsWheaReportPeiEntry ( 0, NULL, (VOID**)&RscHandlerPpi); - + if (EFI_ERROR(Status) != FALSE) { - DEBUG((DEBUG_ERROR, __FUNCTION__ ": failed to locate PEI RSC Handler PPI (%r)\n", Status)); + DEBUG((DEBUG_ERROR, "%a: failed to locate PEI RSC Handler PPI (%r)\n", __FUNCTION__, Status)); goto Cleanup; } Status = RscHandlerPpi->Register(MsWheaRscHandlerPei); if (EFI_ERROR(Status) != FALSE) { - DEBUG((DEBUG_ERROR, __FUNCTION__ ": failed to register PEI RSC Handler PPI (%r)\n", Status)); + DEBUG((DEBUG_ERROR, "%a: failed to register PEI RSC Handler PPI (%r)\n", __FUNCTION__, Status)); } Cleanup: - DEBUG((DEBUG_INFO, __FUNCTION__ ": exit (%r)\n", Status)); + DEBUG((DEBUG_INFO, "%a: exit (%r)\n", __FUNCTION__, Status)); return Status; } diff --git a/MsWheaPkg/Test/UnitTests/Library/LibraryClass/CheckHwErrRecHeaderTestsApp.c b/MsWheaPkg/Test/UnitTests/Library/LibraryClass/CheckHwErrRecHeaderTestsApp.c index 8202263f..32d59cf5 100644 --- a/MsWheaPkg/Test/UnitTests/Library/LibraryClass/CheckHwErrRecHeaderTestsApp.c +++ b/MsWheaPkg/Test/UnitTests/Library/LibraryClass/CheckHwErrRecHeaderTestsApp.c @@ -57,11 +57,11 @@ typedef struct { EFI_COMMON_ERROR_RECORD_HEADER *Err = NULL; //PASS -STATIC BASIC_TEST_CONTEXT mBasicRecordTest1 = { +STATIC BASIC_TEST_CONTEXT mBasicRecordTest1 = { BaseSecDescLength + (BaseSecLength * 1) + (BaseSecHeadLength * 1), BaseSecDescLength + (BaseSecLength * 1) + (BaseSecHeadLength * 1), BaseSecCount * 1, - {TRUE, BaseSecLength, BaseSecDescLength + (BaseSecHeadLength * 1) + (BaseSecLength * 0)}, + {TRUE, BaseSecLength, BaseSecDescLength + (BaseSecHeadLength * 1) + (BaseSecLength * 0)}, {FALSE, 0, 0}, {FALSE, 0, 0}, {FALSE, 0, 0}, @@ -69,12 +69,12 @@ STATIC BASIC_TEST_CONTEXT mBasicRecordTest1 = { TRUE }; -//FAIL BECAUSE SIZE AND LENGTH DO NOT MATCH -STATIC BASIC_TEST_CONTEXT mBasicRecordTest2 = { +//FAIL BECAUSE SIZE AND LENGTH DO NOT MATCH +STATIC BASIC_TEST_CONTEXT mBasicRecordTest2 = { BaseSecDescLength + (BaseSecLength * 1) + (BaseSecHeadLength * 1), BaseSecDescLength + (BaseSecLength * 1) + (BaseSecHeadLength * 1) + 1, BaseSecCount * 1, - {TRUE, BaseSecLength, BaseSecDescLength + (BaseSecHeadLength * 1) + (BaseSecLength * 0)}, + {TRUE, BaseSecLength, BaseSecDescLength + (BaseSecHeadLength * 1) + (BaseSecLength * 0)}, {FALSE, 0, 0}, {FALSE, 0, 0}, {FALSE, 0, 0}, @@ -83,11 +83,11 @@ STATIC BASIC_TEST_CONTEXT mBasicRecordTest2 = { }; //PASS -STATIC BASIC_TEST_CONTEXT mBasicRecordTest3 = { +STATIC BASIC_TEST_CONTEXT mBasicRecordTest3 = { BaseSecDescLength + (BaseSecLength * 2) + (BaseSecHeadLength * 2), BaseSecDescLength + (BaseSecLength * 2) + (BaseSecHeadLength * 2), BaseSecCount * 2, - {TRUE, BaseSecLength, BaseSecDescLength + (BaseSecHeadLength * 2) + (BaseSecLength * 0)}, + {TRUE, BaseSecLength, BaseSecDescLength + (BaseSecHeadLength * 2) + (BaseSecLength * 0)}, {TRUE, BaseSecLength, BaseSecDescLength + (BaseSecHeadLength * 2) + (BaseSecLength * 1)}, {FALSE, 0, 0}, {FALSE, 0, 0}, @@ -96,11 +96,11 @@ STATIC BASIC_TEST_CONTEXT mBasicRecordTest3 = { }; //FAIL BECAUSE DECLARED SECTION 2 SIZE AND OFFSET WOULD RUN OFF THE END OF THE STRUCTURE -STATIC BASIC_TEST_CONTEXT mBasicRecordTest4 = { +STATIC BASIC_TEST_CONTEXT mBasicRecordTest4 = { BaseSecDescLength + (BaseSecLength * 2) + (BaseSecHeadLength * 2), BaseSecDescLength + (BaseSecLength * 2) + (BaseSecHeadLength * 2), BaseSecCount * 2, - {TRUE, BaseSecLength, BaseSecDescLength + (BaseSecHeadLength * 2) + (BaseSecLength * 0)}, + {TRUE, BaseSecLength, BaseSecDescLength + (BaseSecHeadLength * 2) + (BaseSecLength * 0)}, {TRUE, BaseSecLength + 1, BaseSecDescLength + (BaseSecHeadLength * 2) + (BaseSecLength * 1)}, {FALSE, 0, 0}, {FALSE, 0, 0}, @@ -108,12 +108,12 @@ STATIC BASIC_TEST_CONTEXT mBasicRecordTest4 = { FALSE }; -//FAIL BECAUSE SIZE ISN'T LARGE ENOUGH TO HOLD THE SPECIFIED NUMBER OF HEADERS -STATIC BASIC_TEST_CONTEXT mBasicRecordTest5 = { +//FAIL BECAUSE SIZE ISN'T LARGE ENOUGH TO HOLD THE SPECIFIED NUMBER OF HEADERS +STATIC BASIC_TEST_CONTEXT mBasicRecordTest5 = { BaseSecDescLength + (BaseSecLength * 0) + (BaseSecHeadLength * 1), BaseSecDescLength + (BaseSecLength * 0) + (BaseSecHeadLength * 1), BaseSecCount * 2, - {FALSE, 0, 0}, + {FALSE, 0, 0}, {FALSE, 0, 0}, {FALSE, 0, 0}, {FALSE, 0, 0}, @@ -122,11 +122,11 @@ STATIC BASIC_TEST_CONTEXT mBasicRecordTest5 = { }; //PASS -STATIC BASIC_TEST_CONTEXT mBasicRecordTest6 = { +STATIC BASIC_TEST_CONTEXT mBasicRecordTest6 = { BaseSecDescLength + (BaseSecLength * 3) + (BaseSecHeadLength * 3), BaseSecDescLength + (BaseSecLength * 3) + (BaseSecHeadLength * 3), BaseSecCount * 3, - {TRUE, BaseSecLength, BaseSecDescLength + (BaseSecHeadLength * 3) + (BaseSecLength * 0)}, + {TRUE, BaseSecLength, BaseSecDescLength + (BaseSecHeadLength * 3) + (BaseSecLength * 0)}, {TRUE, BaseSecLength, BaseSecDescLength + (BaseSecHeadLength * 3) + (BaseSecLength * 1)}, {TRUE, BaseSecLength, BaseSecDescLength + (BaseSecHeadLength * 3) + (BaseSecLength * 2)}, {FALSE, 0, 0}, @@ -135,11 +135,11 @@ STATIC BASIC_TEST_CONTEXT mBasicRecordTest6 = { }; //FAIL BECAUSE SECTION 2 AND 3 ARE NOT CONTIGUOUS -STATIC BASIC_TEST_CONTEXT mBasicRecordTest7 = { +STATIC BASIC_TEST_CONTEXT mBasicRecordTest7 = { BaseSecDescLength + (BaseSecLength * 3) + (BaseSecHeadLength * 3), BaseSecDescLength + (BaseSecLength * 3) + (BaseSecHeadLength * 3), BaseSecCount * 3, - {TRUE, BaseSecLength, BaseSecDescLength + (BaseSecHeadLength * 3) + (BaseSecLength * 0)}, + {TRUE, BaseSecLength, BaseSecDescLength + (BaseSecHeadLength * 3) + (BaseSecLength * 0)}, {TRUE, BaseSecLength, BaseSecDescLength + (BaseSecHeadLength * 3) + (BaseSecLength * 1)}, {TRUE, BaseSecLength, BaseSecDescLength + (BaseSecHeadLength * 3) + (BaseSecLength * 2) + 1}, {FALSE, 0, 0}, @@ -148,11 +148,11 @@ STATIC BASIC_TEST_CONTEXT mBasicRecordTest7 = { }; //FAIL BECAUSE NOT ENOUGH SPACE FOR THE SPECIFIED NUMBER OF SECTIONS -STATIC BASIC_TEST_CONTEXT mBasicRecordTest8 = { +STATIC BASIC_TEST_CONTEXT mBasicRecordTest8 = { BaseSecDescLength + (BaseSecLength * 2) + (BaseSecHeadLength * 2), BaseSecDescLength + (BaseSecLength * 2) + (BaseSecHeadLength * 2), BaseSecCount * 3, - {TRUE, BaseSecLength, BaseSecDescLength + (BaseSecHeadLength * 3) + (BaseSecLength * 0)}, + {TRUE, BaseSecLength, BaseSecDescLength + (BaseSecHeadLength * 3) + (BaseSecLength * 0)}, {TRUE, BaseSecLength, BaseSecDescLength + (BaseSecHeadLength * 3) + (BaseSecLength * 1)}, {TRUE, BaseSecLength, BaseSecDescLength + (BaseSecHeadLength * 3) + (BaseSecLength * 2)}, {FALSE, 0, 0}, @@ -161,11 +161,11 @@ STATIC BASIC_TEST_CONTEXT mBasicRecordTest8 = { }; //PASS -STATIC BASIC_TEST_CONTEXT mBasicRecordTest9 = { +STATIC BASIC_TEST_CONTEXT mBasicRecordTest9 = { BaseSecDescLength + (BaseSecLength * 3) + (BaseSecHeadLength * 3) + 64, BaseSecDescLength + (BaseSecLength * 3) + (BaseSecHeadLength * 3) + 64, BaseSecCount * 3, - {TRUE, BaseSecLength, BaseSecDescLength + (BaseSecHeadLength * 3) + (BaseSecLength * 0)}, + {TRUE, BaseSecLength, BaseSecDescLength + (BaseSecHeadLength * 3) + (BaseSecLength * 0)}, {TRUE, BaseSecLength + 64, BaseSecDescLength + (BaseSecHeadLength * 3) + (BaseSecLength * 1)}, {TRUE, BaseSecLength, BaseSecDescLength + (BaseSecHeadLength * 3) + (BaseSecLength * 2) + 64}, {FALSE, 0, 0}, @@ -174,11 +174,11 @@ STATIC BASIC_TEST_CONTEXT mBasicRecordTest9 = { }; //PASS -STATIC BASIC_TEST_CONTEXT mBasicRecordTest10 = { +STATIC BASIC_TEST_CONTEXT mBasicRecordTest10 = { BaseSecDescLength + (BaseSecLength * 4) + (BaseSecHeadLength * 4) + 64, BaseSecDescLength + (BaseSecLength * 4) + (BaseSecHeadLength * 4) + 64, BaseSecCount * 4, - {TRUE, BaseSecLength, BaseSecDescLength + (BaseSecHeadLength * 4) + (BaseSecLength * 0)}, + {TRUE, BaseSecLength, BaseSecDescLength + (BaseSecHeadLength * 4) + (BaseSecLength * 0)}, {TRUE, BaseSecLength + 64, BaseSecDescLength + (BaseSecHeadLength * 4) + (BaseSecLength * 1)}, {TRUE, BaseSecLength, BaseSecDescLength + (BaseSecHeadLength * 4) + (BaseSecLength * 2) + 64}, {TRUE, BaseSecLength, BaseSecDescLength + (BaseSecHeadLength * 4) + (BaseSecLength * 3) + 64}, @@ -187,11 +187,11 @@ STATIC BASIC_TEST_CONTEXT mBasicRecordTest10 = { }; //PASS -STATIC BASIC_TEST_CONTEXT mBasicRecordTest11 = { +STATIC BASIC_TEST_CONTEXT mBasicRecordTest11 = { BaseSecDescLength + (BaseSecLength * 5) + (BaseSecHeadLength * 5) + 64, BaseSecDescLength + (BaseSecLength * 5) + (BaseSecHeadLength * 5) + 64, BaseSecCount * 5, - {TRUE, BaseSecLength, BaseSecDescLength + (BaseSecHeadLength * 5) + (BaseSecLength * 0)}, + {TRUE, BaseSecLength, BaseSecDescLength + (BaseSecHeadLength * 5) + (BaseSecLength * 0)}, {TRUE, BaseSecLength + 64, BaseSecDescLength + (BaseSecHeadLength * 5) + (BaseSecLength * 1)}, {TRUE, BaseSecLength, BaseSecDescLength + (BaseSecHeadLength * 5) + (BaseSecLength * 2) + 64}, {TRUE, BaseSecLength, BaseSecDescLength + (BaseSecHeadLength * 5) + (BaseSecLength * 3) + 64}, @@ -199,108 +199,108 @@ STATIC BASIC_TEST_CONTEXT mBasicRecordTest11 = { TRUE }; //FAIL BECAUSE OF UINTN OVERFLOW -STATIC BASIC_TEST_CONTEXT mBasicRecordTest12 = { +STATIC BASIC_TEST_CONTEXT mBasicRecordTest12 = { BaseSecDescLength + (BaseSecLength * 5) + (BaseSecHeadLength * 5) + 64, BaseSecDescLength + (BaseSecLength * 5) + (BaseSecHeadLength * 5) + 64, BaseSecCount * 5, - {TRUE, BaseSecLength, BaseSecDescLength + (BaseSecHeadLength * 5) + (BaseSecLength * 0)}, + {TRUE, BaseSecLength, BaseSecDescLength + (BaseSecHeadLength * 5) + (BaseSecLength * 0)}, {TRUE, BaseSecLength + 64, BaseSecDescLength + (BaseSecHeadLength * 5) + (BaseSecLength * 1)}, {TRUE, BaseSecLength, BaseSecDescLength + (BaseSecHeadLength * 5) + (BaseSecLength * 2) + 64}, {TRUE, BaseSecLength, BaseSecDescLength + (BaseSecHeadLength * 5) + (BaseSecLength * 3) + 64}, - {TRUE, MAX_UINT64, BaseSecDescLength + (BaseSecHeadLength * 5) + (BaseSecLength * 4) + 64}, + {TRUE, MAX_UINT32, BaseSecDescLength + (BaseSecHeadLength * 5) + (BaseSecLength * 4) + 64}, FALSE }; //FAIL BECAUSE SIZE IS GREATER THAN THE SIZE OF HEADERS + SECTIONS -STATIC BASIC_TEST_CONTEXT mBasicRecordTest13 = { +STATIC BASIC_TEST_CONTEXT mBasicRecordTest13 = { BaseSecDescLength + (BaseSecLength * 5) + (BaseSecHeadLength * 5) + 1, BaseSecDescLength + (BaseSecLength * 5) + (BaseSecHeadLength * 5) + 1, BaseSecCount * 5, - {TRUE, BaseSecLength, BaseSecDescLength + (BaseSecHeadLength * 5) + (BaseSecLength * 0)}, + {TRUE, BaseSecLength, BaseSecDescLength + (BaseSecHeadLength * 5) + (BaseSecLength * 0)}, {TRUE, BaseSecLength, BaseSecDescLength + (BaseSecHeadLength * 5) + (BaseSecLength * 1)}, {TRUE, BaseSecLength, BaseSecDescLength + (BaseSecHeadLength * 5) + (BaseSecLength * 2)}, {TRUE, BaseSecLength, BaseSecDescLength + (BaseSecHeadLength * 5) + (BaseSecLength * 3)}, {TRUE, BaseSecLength, BaseSecDescLength + (BaseSecHeadLength * 5) + (BaseSecLength * 4)}, FALSE - }; + }; -//FAIL BECAUSE THERE IS SPACE BETWEEEN SECTIONS 4 AND 5 -STATIC BASIC_TEST_CONTEXT mBasicRecordTest14 = { +//FAIL BECAUSE THERE IS SPACE BETWEEN SECTIONS 4 AND 5 +STATIC BASIC_TEST_CONTEXT mBasicRecordTest14 = { BaseSecDescLength + (BaseSecLength * 5) + (BaseSecHeadLength * 5) + 1, BaseSecDescLength + (BaseSecLength * 5) + (BaseSecHeadLength * 5) + 1, BaseSecCount * 5, - {TRUE, BaseSecLength, BaseSecDescLength + (BaseSecHeadLength * 5) + (BaseSecLength * 0)}, + {TRUE, BaseSecLength, BaseSecDescLength + (BaseSecHeadLength * 5) + (BaseSecLength * 0)}, {TRUE, BaseSecLength, BaseSecDescLength + (BaseSecHeadLength * 5) + (BaseSecLength * 1)}, {TRUE, BaseSecLength, BaseSecDescLength + (BaseSecHeadLength * 5) + (BaseSecLength * 2)}, {TRUE, BaseSecLength, BaseSecDescLength + (BaseSecHeadLength * 5) + (BaseSecLength * 3)}, {TRUE, BaseSecLength, BaseSecDescLength + (BaseSecHeadLength * 5) + (BaseSecLength * 4) + 1}, FALSE - }; + }; //FAIL BECAUSE SECTIONS 4 AND 5 INTERSECT -STATIC BASIC_TEST_CONTEXT mBasicRecordTest15 = { +STATIC BASIC_TEST_CONTEXT mBasicRecordTest15 = { BaseSecDescLength + (BaseSecLength * 5) + (BaseSecHeadLength * 5) + 1, BaseSecDescLength + (BaseSecLength * 5) + (BaseSecHeadLength * 5) + 1, BaseSecCount * 5, - {TRUE, BaseSecLength, BaseSecDescLength + (BaseSecHeadLength * 5) + (BaseSecLength * 0)}, + {TRUE, BaseSecLength, BaseSecDescLength + (BaseSecHeadLength * 5) + (BaseSecLength * 0)}, {TRUE, BaseSecLength, BaseSecDescLength + (BaseSecHeadLength * 5) + (BaseSecLength * 1)}, {TRUE, BaseSecLength, BaseSecDescLength + (BaseSecHeadLength * 5) + (BaseSecLength * 2)}, {TRUE, BaseSecLength + 1, BaseSecDescLength + (BaseSecHeadLength * 5) + (BaseSecLength * 3)}, {TRUE, BaseSecLength, BaseSecDescLength + (BaseSecHeadLength * 5) + (BaseSecLength * 4)}, FALSE - }; + }; //FAIL BECAUSE LENGTH OF SECTION 5 IS ZERO -STATIC BASIC_TEST_CONTEXT mBasicRecordTest16 = { +STATIC BASIC_TEST_CONTEXT mBasicRecordTest16 = { BaseSecDescLength + (BaseSecLength * 2) + (BaseSecHeadLength * 2), BaseSecDescLength + (BaseSecLength * 2) + (BaseSecHeadLength * 2), BaseSecCount * 2, - {TRUE, BaseSecLength, BaseSecDescLength + (BaseSecHeadLength * 2) + (BaseSecLength * 0)}, + {TRUE, BaseSecLength, BaseSecDescLength + (BaseSecHeadLength * 2) + (BaseSecLength * 0)}, {TRUE, 0, BaseSecDescLength + (BaseSecHeadLength * 2) + (BaseSecLength * 1)}, {FALSE, 0, 0}, {FALSE, 0, 0}, {FALSE, 0, 0}, FALSE - }; + }; //FAIL BECAUSE SECTION 2 OFFSET IS BEFORE THE SECTION HEAD ITSELF -STATIC BASIC_TEST_CONTEXT mBasicRecordTest17 = { +STATIC BASIC_TEST_CONTEXT mBasicRecordTest17 = { BaseSecDescLength + (BaseSecLength * 2) + (BaseSecHeadLength * 2), BaseSecDescLength + (BaseSecLength * 2) + (BaseSecHeadLength * 2), BaseSecCount * 2, - {TRUE, BaseSecLength, BaseSecDescLength + (BaseSecHeadLength * 2) + (BaseSecLength * 0)}, + {TRUE, BaseSecLength, BaseSecDescLength + (BaseSecHeadLength * 2) + (BaseSecLength * 0)}, {TRUE, BaseSecLength, BaseSecDescLength}, {FALSE, 0, 0}, {FALSE, 0, 0}, {FALSE, 0, 0}, FALSE - }; + }; //FAIL BECAUSE SECTION 2 OFFSET FALLS WITHIN THE SECTION 2 HEADER -STATIC BASIC_TEST_CONTEXT mBasicRecordTest18 = { +STATIC BASIC_TEST_CONTEXT mBasicRecordTest18 = { BaseSecDescLength + (BaseSecLength * 2) + (BaseSecHeadLength * 2), BaseSecDescLength + (BaseSecLength * 2) + (BaseSecHeadLength * 2), BaseSecCount * 2, - {TRUE, BaseSecLength, BaseSecDescLength + (BaseSecHeadLength * 2) + (BaseSecLength * 0)}, + {TRUE, BaseSecLength, BaseSecDescLength + (BaseSecHeadLength * 2) + (BaseSecLength * 0)}, {TRUE, BaseSecLength, BaseSecDescLength + (BaseSecHeadLength * 1) + 20}, {FALSE, 0, 0}, {FALSE, 0, 0}, {FALSE, 0, 0}, FALSE - }; + }; //FAIL BECAUSE SECTION 1 OFFSET FALLS WITHIN THE SECTION 1 HEADER -STATIC BASIC_TEST_CONTEXT mBasicRecordTest19 = { +STATIC BASIC_TEST_CONTEXT mBasicRecordTest19 = { BaseSecDescLength + (BaseSecLength * 2) + (BaseSecHeadLength * 2), BaseSecDescLength + (BaseSecLength * 2) + (BaseSecHeadLength * 2), BaseSecCount * 2, - {TRUE, BaseSecLength, BaseSecDescLength + (BaseSecHeadLength * 0) + 20}, + {TRUE, BaseSecLength, BaseSecDescLength + (BaseSecHeadLength * 0) + 20}, {TRUE, BaseSecLength, BaseSecDescLength + (BaseSecHeadLength * 2) + (BaseSecLength * 1)}, {FALSE, 0, 0}, {FALSE, 0, 0}, {FALSE, 0, 0}, FALSE - }; + }; ///================================================================================================ ///================================================================================================ /// @@ -313,7 +313,7 @@ STATIC BASIC_TEST_CONTEXT mBasicRecordTest19 = { Simple clean up method to make sure tests clean up even if interrupted and fail in the middle. **/ STATIC -UNIT_TEST_STATUS +VOID EFIAPI CleanupErr ( IN UNIT_TEST_FRAMEWORK_HANDLE Framework, @@ -323,8 +323,6 @@ CleanupErr ( if (Err != NULL) { FreePool(Err); } - - return UNIT_TEST_PASSED; } ///================================================================================================ @@ -338,7 +336,7 @@ STATIC UNIT_TEST_STATUS EFIAPI ErrorRecordHeaderTest(IN UNIT_TEST_FRAMEWORK_HANDLE Framework, - IN UNIT_TEST_CONTEXT Context) + IN UNIT_TEST_CONTEXT Context) { EFI_ERROR_SECTION_DESCRIPTOR *SectionHeader; @@ -367,7 +365,7 @@ ErrorRecordHeaderTest(IN UNIT_TEST_FRAMEWORK_HANDLE Framework, } } - + if(ValidateCperHeader(Err, Btc->Size) == Btc->ExpectedResult) { @@ -399,7 +397,7 @@ ErrorRecordHeaderTest(IN UNIT_TEST_FRAMEWORK_HANDLE Framework, @param[in] SystemTable A pointer to the EFI System Table. @retval EFI_SUCCESS The entry point executed successfully. - @retval other Some error occured when executing this entry point. + @retval other Some error occurred when executing this entry point. **/ EFI_STATUS diff --git a/MsWheaPkg/Test/UnitTests/MsWheaEarlyStorageUnitTestApp/MsWheaEarlyUnitTestApp.c b/MsWheaPkg/Test/UnitTests/MsWheaEarlyStorageUnitTestApp/MsWheaEarlyUnitTestApp.c index 5796ffd2..d648f1cc 100644 --- a/MsWheaPkg/Test/UnitTests/MsWheaEarlyStorageUnitTestApp/MsWheaEarlyUnitTestApp.c +++ b/MsWheaPkg/Test/UnitTests/MsWheaEarlyStorageUnitTestApp/MsWheaEarlyUnitTestApp.c @@ -203,7 +203,7 @@ MsWheaESCleanUp ( // This is needed incase there is leftover garbage in default/failed cases MsWheaESClearAllData(); - // Zero all the fields in the + // Zero all the fields in the SetMem(&UnitTestHeader, sizeof(MS_WHEA_EARLY_STORAGE_HEADER), 0); // Sign the header signature. @@ -227,7 +227,7 @@ MsWheaESCleanUp ( /** - This rountine should verify internal checksum vs BaseLib checksum + This routine should verify internal checksum vs BaseLib checksum **/ UNIT_TEST_STATUS EFIAPI @@ -261,7 +261,7 @@ MsWheaESChecksumTest ( } /** - This rountine should verify ES will ignore inactive data region corruption + This routine should verify ES will ignore inactive data region corruption **/ UNIT_TEST_STATUS EFIAPI @@ -288,7 +288,7 @@ MsWheaESDataCorruptTest ( } /** - This rountine should verify ES can catch header region corruption + This routine should verify ES can catch header region corruption **/ UNIT_TEST_STATUS EFIAPI @@ -318,7 +318,7 @@ MsWheaESHeaderCorruptTest ( } /** - This rountine should verify ES header can be updated with proper API + This routine should verify ES header can be updated with proper API **/ UNIT_TEST_STATUS EFIAPI @@ -347,7 +347,7 @@ MsWheaESHeaderUpdateTest ( } /** - This rountine should verify ES content can be updated with proper API and catch data corruption + This routine should verify ES content can be updated with proper API and catch data corruption **/ UNIT_TEST_STATUS EFIAPI @@ -399,7 +399,7 @@ MsWheaESContentUpdateTest ( } /** - This rountine should verify ES find slot plays well with active range field + This routine should verify ES find slot plays well with active range field **/ UNIT_TEST_STATUS EFIAPI @@ -423,7 +423,7 @@ MsWheaESFindSlotTest ( } /** - This rountine should verify ES recover bad state early storage properly + This routine should verify ES recover bad state early storage properly **/ UNIT_TEST_STATUS EFIAPI @@ -440,7 +440,7 @@ MsWheaESInitTest ( // Should fail UT_ASSERT_FALSE (MsWheaESRegionIsValid(NULL)); - // Holy grail to retore evrything + // Holy grail to retore everything MsWheaESInit (); MsWheaESReadHeader(&UnitTestHeader); @@ -451,7 +451,7 @@ MsWheaESInitTest ( } /** - This rountine should verify ES store/converted supported metadata properly + This routine should verify ES store/converted supported metadata properly **/ UNIT_TEST_STATUS EFIAPI @@ -499,7 +499,7 @@ MsWheaESStoreEntryTest ( } /** - This rountine should verify ES restore save ES records to metadata properly + This routine should verify ES restore save ES records to metadata properly **/ UNIT_TEST_STATUS EFIAPI @@ -545,7 +545,7 @@ MsWheaESProcessTest ( @param[in] SystemTable A pointer to the EFI System Table. @retval EFI_SUCCESS The entry point executed successfully. - @retval other Some error occured when executing this entry point. + @retval other Some error occurred when executing this entry point. **/ EFI_STATUS diff --git a/MsWheaPkg/Test/UnitTests/MsWheaEarlyStorageUnitTestApp/MsWheaEarlyUnitTestApp.inf b/MsWheaPkg/Test/UnitTests/MsWheaEarlyStorageUnitTestApp/MsWheaEarlyUnitTestApp.inf index 141ea9d4..d6f04032 100644 --- a/MsWheaPkg/Test/UnitTests/MsWheaEarlyStorageUnitTestApp/MsWheaEarlyUnitTestApp.inf +++ b/MsWheaPkg/Test/UnitTests/MsWheaEarlyStorageUnitTestApp/MsWheaEarlyUnitTestApp.inf @@ -59,4 +59,5 @@ gMsWheaPkgTokenSpaceGuid.PcdMsWheaEarlyStorageDefaultValue [BuildOptions.Common] - MSFT:*_*_*_CC_FLAGS = /D INTERNAL_UNIT_TEST \ No newline at end of file + MSFT:*_*_*_CC_FLAGS = /D INTERNAL_UNIT_TEST + GCC:*_*_*_CC_FLAGS = -D INTERNAL_UNIT_TEST \ No newline at end of file diff --git a/MsWheaPkg/Test/UnitTests/MsWheaReportUnitTestApp/MsWheaReportUnitTestApp.c b/MsWheaPkg/Test/UnitTests/MsWheaReportUnitTestApp/MsWheaReportUnitTestApp.c index d73c0322..7b3cd8ee 100644 --- a/MsWheaPkg/Test/UnitTests/MsWheaReportUnitTestApp/MsWheaReportUnitTestApp.c +++ b/MsWheaPkg/Test/UnitTests/MsWheaReportUnitTestApp/MsWheaReportUnitTestApp.c @@ -701,7 +701,7 @@ MsWheaCommonCleanUp ( /** - This rountine should store 2 Fatal Ex errors on flash + This routine should store 2 Fatal Ex errors on flash **/ UNIT_TEST_STATUS EFIAPI @@ -755,7 +755,7 @@ Cleanup: /** - This rountine should store 2 Non Fatal Ex errors on flash + This routine should store 2 Non Fatal Ex errors on flash **/ UNIT_TEST_STATUS EFIAPI @@ -808,7 +808,7 @@ Cleanup: /** - This rountine should not store any errors on flash + This routine should not store any errors on flash **/ UNIT_TEST_STATUS EFIAPI @@ -891,7 +891,7 @@ Cleanup: /** - This rountine should store one short error for each supported severity on flash + This routine should store one short error for each supported severity on flash **/ UNIT_TEST_STATUS EFIAPI @@ -961,7 +961,7 @@ Cleanup: /** - This rountine should try to store as many errors on flash with a fixed size, test should fail with + This routine should try to store as many errors on flash with a fixed size, test should fail with out of resources before the designated count is reached **/ UNIT_TEST_STATUS @@ -1021,9 +1021,9 @@ Cleanup: /** - This rountine should verify changes regarding variable services: + This routine should verify changes regarding variable services: 1. Deleted hw error records should not count towards the hw error record space quota - 2. HwError record quata state should not trigger variable store reclaim + 2. HwError record quota state should not trigger variable store reclaim **/ UNIT_TEST_STATUS EFIAPI @@ -1148,7 +1148,7 @@ Cleanup: /** - This rountine should verify report works at all the supported TPLs + This routine should verify report works at all the supported TPLs **/ UNIT_TEST_STATUS EFIAPI @@ -1224,7 +1224,7 @@ Cleanup: @param[in] SystemTable A pointer to the EFI System Table. @retval EFI_SUCCESS The entry point executed successfully. - @retval other Some error occured when executing this entry point. + @retval other Some error occurred when executing this entry point. **/ EFI_STATUS diff --git a/MsWheaPkg/readme.md b/MsWheaPkg/readme.md index f14a59ed..87fe190a 100644 --- a/MsWheaPkg/readme.md +++ b/MsWheaPkg/readme.md @@ -3,7 +3,7 @@ ## About This package contains drivers and infrastructure for reporting errors and telemetry through the CPER (Common Platform Error Record) HwErrRecord interface, specifically targeting systems that also leverage WHEA (Windows Hardware Error Architecture). -The MsWhea drivers provide the same functionality at different stages of UEFI by binding to the REPORT_STATUS_CODE interface. Together, they store hardware errors and corrected faults into non-volatile memory that is later picked up by Windows. In Windows, this can be emitted as telemetry which is then used to idenitfy errors and patterns for devices (as of time of writing any event besides EFI_GENERIC_ERROR_INFO will be sent). +The MsWhea drivers provide the same functionality at different stages of UEFI by binding to the REPORT_STATUS_CODE interface. Together, they store hardware errors and corrected faults into non-volatile memory that is later picked up by Windows. In Windows, this can be emitted as telemetry which is then used to identify errors and patterns for devices (as of time of writing any event besides EFI_GENERIC_ERROR_INFO will be sent). Project MU has updated design which defines a specific section type under `gMuTelemetrySectionTypeGuid` to be used in CPER header for WHEA telemetry. All reported data will be formatted to this section. Please refer to `MuTelemetryCperSection.h` for field definitions.