From af1a266670d040d2f4083ff309d732d648afba2a Mon Sep 17 00:00:00 2001 From: Angelos Mouzakitis Date: Tue, 10 Oct 2023 14:33:42 +0000 Subject: Add submodule dependency files Change-Id: Iaf8d18082d3991dec7c0ebbea540f092188eb4ec --- .../StatusCodeHandler/Pei/MemoryStausCodeWorker.c | 121 ++++++++++++++++ .../StatusCodeHandler/Pei/SerialStatusCodeWorker.c | 161 +++++++++++++++++++++ .../StatusCodeHandler/Pei/StatusCodeHandlerPei.c | 63 ++++++++ .../StatusCodeHandler/Pei/StatusCodeHandlerPei.h | 119 +++++++++++++++ .../StatusCodeHandler/Pei/StatusCodeHandlerPei.inf | 65 +++++++++ .../StatusCodeHandler/Pei/StatusCodeHandlerPei.uni | 16 ++ .../Pei/StatusCodeHandlerPeiExtra.uni | 14 ++ 7 files changed, 559 insertions(+) create mode 100644 roms/edk2/MdeModulePkg/Universal/StatusCodeHandler/Pei/MemoryStausCodeWorker.c create mode 100644 roms/edk2/MdeModulePkg/Universal/StatusCodeHandler/Pei/SerialStatusCodeWorker.c create mode 100644 roms/edk2/MdeModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.c create mode 100644 roms/edk2/MdeModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.h create mode 100644 roms/edk2/MdeModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.inf create mode 100644 roms/edk2/MdeModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.uni create mode 100644 roms/edk2/MdeModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPeiExtra.uni (limited to 'roms/edk2/MdeModulePkg/Universal/StatusCodeHandler/Pei') diff --git a/roms/edk2/MdeModulePkg/Universal/StatusCodeHandler/Pei/MemoryStausCodeWorker.c b/roms/edk2/MdeModulePkg/Universal/StatusCodeHandler/Pei/MemoryStausCodeWorker.c new file mode 100644 index 000000000..6c116707f --- /dev/null +++ b/roms/edk2/MdeModulePkg/Universal/StatusCodeHandler/Pei/MemoryStausCodeWorker.c @@ -0,0 +1,121 @@ +/** @file + PEI memory status code worker. + + Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include "StatusCodeHandlerPei.h" + +/** + Create the first memory status code GUID'ed HOB as initialization for memory status code worker. + + @retval EFI_SUCCESS The GUID'ed HOB is created successfully. + +**/ +EFI_STATUS +MemoryStatusCodeInitializeWorker ( + VOID + ) +{ + // + // Create memory status code GUID'ed HOB. + // + MEMORY_STATUSCODE_PACKET_HEADER *PacketHeader; + + // + // Build GUID'ed HOB with PCD defined size. + // + PacketHeader = BuildGuidHob ( + &gMemoryStatusCodeRecordGuid, + PcdGet16 (PcdStatusCodeMemorySize) * 1024 + sizeof (MEMORY_STATUSCODE_PACKET_HEADER) + ); + ASSERT (PacketHeader != NULL); + + PacketHeader->MaxRecordsNumber = (PcdGet16 (PcdStatusCodeMemorySize) * 1024) / sizeof (MEMORY_STATUSCODE_RECORD); + PacketHeader->PacketIndex = 0; + PacketHeader->RecordIndex = 0; + + return EFI_SUCCESS; +} + + +/** + Report status code into GUID'ed HOB. + + This function reports status code into GUID'ed HOB. If not all packets are full, then + write status code into available entry. Otherwise, create a new packet for it. + + @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation. + @param CodeType Indicates the type of status code being reported. + @param 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. + 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 The function always return EFI_SUCCESS. + +**/ +EFI_STATUS +EFIAPI +MemoryStatusCodeReportWorker ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN EFI_STATUS_CODE_TYPE CodeType, + IN EFI_STATUS_CODE_VALUE Value, + IN UINT32 Instance, + IN CONST EFI_GUID *CallerId, + IN CONST EFI_STATUS_CODE_DATA *Data OPTIONAL + ) +{ + + EFI_PEI_HOB_POINTERS Hob; + MEMORY_STATUSCODE_PACKET_HEADER *PacketHeader; + MEMORY_STATUSCODE_RECORD *Record; + + // + // Find GUID'ed HOBs to locate current record buffer. + // + Hob.Raw = GetFirstGuidHob (&gMemoryStatusCodeRecordGuid); + ASSERT (Hob.Raw != NULL); + + PacketHeader = (MEMORY_STATUSCODE_PACKET_HEADER *) GET_GUID_HOB_DATA (Hob.Guid); + Record = (MEMORY_STATUSCODE_RECORD *) (PacketHeader + 1); + Record = &Record[PacketHeader->RecordIndex++]; + + // + // Save status code. + // + Record->CodeType = CodeType; + Record->Instance = Instance; + Record->Value = Value; + + // + // If record index equals to max record number, then wrap around record index to zero. + // + // The reader of status code should compare the number of records with max records number, + // If it is equal to or larger than the max number, then the wrap-around had happened, + // so the first record is pointed by record index. + // If it is less then max number, index of the first record is zero. + // + if (PacketHeader->RecordIndex == PacketHeader->MaxRecordsNumber) { + // + // Wrap around record index. + // + PacketHeader->RecordIndex = 0; + PacketHeader->PacketIndex ++; + } + + return EFI_SUCCESS; +} + diff --git a/roms/edk2/MdeModulePkg/Universal/StatusCodeHandler/Pei/SerialStatusCodeWorker.c b/roms/edk2/MdeModulePkg/Universal/StatusCodeHandler/Pei/SerialStatusCodeWorker.c new file mode 100644 index 000000000..3aa5642b6 --- /dev/null +++ b/roms/edk2/MdeModulePkg/Universal/StatusCodeHandler/Pei/SerialStatusCodeWorker.c @@ -0,0 +1,161 @@ +/** @file + Serial I/O status code reporting worker. + + Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include "StatusCodeHandlerPei.h" + +/** + Convert status code value and extended data to readable ASCII string, send string to serial I/O device. + + @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation. + @param CodeType Indicates the type of status code being reported. + @param 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. + 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 Status code reported to serial I/O successfully. + +**/ +EFI_STATUS +EFIAPI +SerialStatusCodeReportWorker ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN EFI_STATUS_CODE_TYPE CodeType, + IN EFI_STATUS_CODE_VALUE Value, + IN UINT32 Instance, + IN CONST EFI_GUID *CallerId, + IN CONST EFI_STATUS_CODE_DATA *Data OPTIONAL + ) +{ + CHAR8 *Filename; + CHAR8 *Description; + CHAR8 *Format; + CHAR8 Buffer[MAX_DEBUG_MESSAGE_LENGTH]; + UINT32 ErrorLevel; + UINT32 LineNumber; + UINTN CharCount; + BASE_LIST Marker; + + Buffer[0] = '\0'; + + if (Data != NULL && + ReportStatusCodeExtractAssertInfo (CodeType, Value, Data, &Filename, &Description, &LineNumber)) { + // + // Print ASSERT() information into output buffer. + // + CharCount = AsciiSPrint ( + Buffer, + sizeof (Buffer), + "\n\rPEI_ASSERT!: %a (%d): %a\n\r", + Filename, + LineNumber, + Description + ); + } else if (Data != NULL && + ReportStatusCodeExtractDebugInfo (Data, &ErrorLevel, &Marker, &Format)) { + // + // Print DEBUG() information into output buffer. + // + CharCount = AsciiBSPrint ( + Buffer, + sizeof (Buffer), + Format, + Marker + ); + } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) { + // + // Print ERROR information into output buffer. + // + CharCount = AsciiSPrint ( + Buffer, + sizeof (Buffer), + "ERROR: C%08x:V%08x I%x", + CodeType, + Value, + Instance + ); + + ASSERT(CharCount > 0); + + if (CallerId != NULL) { + CharCount += AsciiSPrint ( + &Buffer[CharCount], + (sizeof (Buffer) - (sizeof (Buffer[0]) * CharCount)), + " %g", + CallerId + ); + } + + if (Data != NULL) { + CharCount += AsciiSPrint ( + &Buffer[CharCount], + (sizeof (Buffer) - (sizeof (Buffer[0]) * CharCount)), + " %x", + Data + ); + } + + CharCount += AsciiSPrint ( + &Buffer[CharCount], + (sizeof (Buffer) - (sizeof (Buffer[0]) * CharCount)), + "\n\r" + ); + } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) { + // + // Print PROGRESS information into output buffer. + // + CharCount = AsciiSPrint ( + Buffer, + sizeof (Buffer), + "PROGRESS CODE: V%08x I%x\n\r", + Value, + Instance + ); + } else if (Data != NULL && + CompareGuid (&Data->Type, &gEfiStatusCodeDataTypeStringGuid) && + ((EFI_STATUS_CODE_STRING_DATA *) Data)->StringType == EfiStringAscii) { + // + // EFI_STATUS_CODE_STRING_DATA + // + CharCount = AsciiSPrint ( + Buffer, + sizeof (Buffer), + "%a", + ((EFI_STATUS_CODE_STRING_DATA *) Data)->String.Ascii + ); + } else { + // + // Code type is not defined. + // + CharCount = AsciiSPrint ( + Buffer, + sizeof (Buffer), + "Undefined: C%08x:V%08x I%x\n\r", + CodeType, + Value, + Instance + ); + } + + // + // Call SerialPort Lib function to do print. + // + SerialPortWrite ((UINT8 *) Buffer, CharCount); + + return EFI_SUCCESS; +} + diff --git a/roms/edk2/MdeModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.c b/roms/edk2/MdeModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.c new file mode 100644 index 000000000..9b2ea4ee8 --- /dev/null +++ b/roms/edk2/MdeModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.c @@ -0,0 +1,63 @@ +/** @file + Report Status Code Handler PEIM which produces general handlers and hook them + onto the PEI status code router. + + Copyright (c) 2009 - 2020, Intel Corporation. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include "StatusCodeHandlerPei.h" + +/** + Entry point of Status Code PEIM. + + This function is the entry point of this Status Code PEIM. + It initializes supported status code devices according to PCD settings, + and installs Status Code PPI. + + @param FileHandle Handle of the file being invoked. + @param PeiServices Describes the list of possible PEI Services. + + @retval EFI_SUCESS The entry point of DXE IPL PEIM executes successfully. + +**/ +EFI_STATUS +EFIAPI +StatusCodeHandlerPeiEntry ( + IN EFI_PEI_FILE_HANDLE FileHandle, + IN CONST EFI_PEI_SERVICES **PeiServices + ) +{ + EFI_STATUS Status; + EFI_PEI_RSC_HANDLER_PPI *RscHandlerPpi; + + Status = PeiServicesLocatePpi ( + &gEfiPeiRscHandlerPpiGuid, + 0, + NULL, + (VOID **) &RscHandlerPpi + ); + ASSERT_EFI_ERROR (Status); + + // + // Dispatch initialization request to sub-statuscode-devices. + // If enable UseSerial, then initialize serial port. + // if enable UseMemory, then initialize memory status code worker. + // + if (PcdGetBool (PcdStatusCodeUseSerial)) { + Status = SerialPortInitialize(); + ASSERT_EFI_ERROR (Status); + Status = RscHandlerPpi->Register (SerialStatusCodeReportWorker); + ASSERT_EFI_ERROR (Status); + } + if (PcdGetBool (PcdStatusCodeUseMemory)) { + Status = MemoryStatusCodeInitializeWorker (); + ASSERT_EFI_ERROR (Status); + Status = RscHandlerPpi->Register (MemoryStatusCodeReportWorker); + ASSERT_EFI_ERROR (Status); + } + + return EFI_SUCCESS; +} + diff --git a/roms/edk2/MdeModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.h b/roms/edk2/MdeModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.h new file mode 100644 index 000000000..34901f29e --- /dev/null +++ b/roms/edk2/MdeModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.h @@ -0,0 +1,119 @@ +/** @file + Internal include file for Status Code Handler PEIM. + + Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef __STATUS_CODE_HANDLER_PEI_H__ +#define __STATUS_CODE_HANDLER_PEI_H__ + + +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// +// Define the maximum message length +// +#define MAX_DEBUG_MESSAGE_LENGTH 0x100 + +/** + Convert status code value and extended data to readable ASCII string, send string to serial I/O device. + + @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation. + @param CodeType Indicates the type of status code being reported. + @param 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. + 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 Status code reported to serial I/O successfully. + +**/ +EFI_STATUS +EFIAPI +SerialStatusCodeReportWorker ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN EFI_STATUS_CODE_TYPE CodeType, + IN EFI_STATUS_CODE_VALUE Value, + IN UINT32 Instance, + IN CONST EFI_GUID *CallerId, + IN CONST EFI_STATUS_CODE_DATA *Data OPTIONAL + ); + + +/** + Create the first memory status code GUID'ed HOB as initialization for memory status code worker. + + @retval EFI_SUCCESS The GUID'ed HOB is created successfully. + +**/ +EFI_STATUS +MemoryStatusCodeInitializeWorker ( + VOID + ); + +/** + Report status code into GUID'ed HOB. + + This function reports status code into GUID'ed HOB. If not all packets are full, then + write status code into available entry. Otherwise, create a new packet for it. + + @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation. + @param CodeType Indicates the type of status code being reported. + @param 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. + 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 The function always return EFI_SUCCESS. + +**/ +EFI_STATUS +EFIAPI +MemoryStatusCodeReportWorker ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN EFI_STATUS_CODE_TYPE CodeType, + IN EFI_STATUS_CODE_VALUE Value, + IN UINT32 Instance, + IN CONST EFI_GUID *CallerId, + IN CONST EFI_STATUS_CODE_DATA *Data OPTIONAL + ); + +#endif + + diff --git a/roms/edk2/MdeModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.inf b/roms/edk2/MdeModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.inf new file mode 100644 index 000000000..64380ddfa --- /dev/null +++ b/roms/edk2/MdeModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.inf @@ -0,0 +1,65 @@ +## @file +# Report Status Code Handler PEIM which produces general handlers and hook them onto the PEI status code router. +# +# Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = StatusCodeHandlerPei + MODULE_UNI_FILE = StatusCodeHandlerPei.uni + FILE_GUID = 9D225237-FA01-464C-A949-BAABC02D31D0 + MODULE_TYPE = PEIM + VERSION_STRING = 1.0 + ENTRY_POINT = StatusCodeHandlerPeiEntry + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = IA32 X64 EBC (EBC is only for build) +# + +[Sources] + StatusCodeHandlerPei.c + StatusCodeHandlerPei.h + SerialStatusCodeWorker.c + MemoryStausCodeWorker.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + +[LibraryClasses] + PeimEntryPoint + PeiServicesLib + PcdLib + HobLib + SerialPortLib + ReportStatusCodeLib + PrintLib + DebugLib + BaseMemoryLib + +[Guids] + ## SOMETIMES_PRODUCES ## HOB + ## SOMETIMES_CONSUMES ## HOB + gMemoryStatusCodeRecordGuid + gEfiStatusCodeDataTypeStringGuid ## SOMETIMES_CONSUMES ## UNDEFINED + +[Ppis] + gEfiPeiRscHandlerPpiGuid ## CONSUMES + +[Pcd] + gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseSerial ## CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseMemory ## CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeMemorySize|1|gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseMemory ## SOMETIMES_CONSUMES + +[Depex] + gEfiPeiRscHandlerPpiGuid + +[UserExtensions.TianoCore."ExtraFiles"] + StatusCodeHandlerPeiExtra.uni diff --git a/roms/edk2/MdeModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.uni b/roms/edk2/MdeModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.uni new file mode 100644 index 000000000..6464cb9fe --- /dev/null +++ b/roms/edk2/MdeModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.uni @@ -0,0 +1,16 @@ +// /** @file +// Report Status Code Handler PEIM which produces general handlers and hook them onto the PEI status code router. +// +// This is the Report Status Code Handler PEIM that produces general handlers and hooks them onto the PEI status code router. +// +// Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.
+// +// SPDX-License-Identifier: BSD-2-Clause-Patent +// +// **/ + + +#string STR_MODULE_ABSTRACT #language en-US "PEIM that produces general handlers and hooks them onto the PEI status code router" + +#string STR_MODULE_DESCRIPTION #language en-US "This is the Report Status Code Handler PEIM that produces general handlers and hooks them onto the PEI status code router." + diff --git a/roms/edk2/MdeModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPeiExtra.uni b/roms/edk2/MdeModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPeiExtra.uni new file mode 100644 index 000000000..6ee6903ed --- /dev/null +++ b/roms/edk2/MdeModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPeiExtra.uni @@ -0,0 +1,14 @@ +// /** @file +// StatusCodeHandlerPei Localized Strings and Content +// +// Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.
+// +// SPDX-License-Identifier: BSD-2-Clause-Patent +// +// **/ + +#string STR_PROPERTIES_MODULE_NAME +#language en-US +"Status Code Handler PEI Module" + + -- cgit