--- /dev/null
+/** @file\r
+ PEI memory status code worker.\r
+\r
+ Copyright (c) 2006 - 2009, Intel Corporation\r
+ All rights reserved. This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "StatusCodeHandlerPei.h"\r
+\r
+/**\r
+ Worker function to create one memory status code GUID'ed HOB,\r
+ using PacketIndex to identify the packet.\r
+\r
+ @param PacketIndex Index of records packet.\r
+\r
+ @return Pointer to the memory status code packet.\r
+\r
+**/\r
+MEMORY_STATUSCODE_PACKET_HEADER *\r
+CreateMemoryStatusCodePacket (\r
+ UINT16 PacketIndex\r
+ )\r
+{\r
+ MEMORY_STATUSCODE_PACKET_HEADER *PacketHeader;\r
+\r
+ //\r
+ // Build GUID'ed HOB with PCD defined size.\r
+ //\r
+ PacketHeader = BuildGuidHob (\r
+ &gMemoryStatusCodeRecordGuid,\r
+ PcdGet16 (PcdStatusCodeMemorySize) * 1024 + sizeof (MEMORY_STATUSCODE_PACKET_HEADER)\r
+ );\r
+ ASSERT (PacketHeader != NULL);\r
+\r
+ PacketHeader->MaxRecordsNumber = (PcdGet16 (PcdStatusCodeMemorySize) * 1024) / sizeof (MEMORY_STATUSCODE_RECORD);\r
+ PacketHeader->PacketIndex = PacketIndex;\r
+ PacketHeader->RecordIndex = 0;\r
+\r
+ return PacketHeader;\r
+}\r
+\r
+/**\r
+ Create the first memory status code GUID'ed HOB as initialization for memory status code worker.\r
+\r
+ @retval EFI_SUCCESS The GUID'ed HOB is created successfully.\r
+\r
+**/\r
+EFI_STATUS\r
+MemoryStatusCodeInitializeWorker (\r
+ VOID\r
+ )\r
+{\r
+ //\r
+ // Create first memory status code GUID'ed HOB.\r
+ //\r
+ CreateMemoryStatusCodePacket (0);\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+\r
+/**\r
+ Report status code into GUID'ed HOB.\r
+\r
+ This function reports status code into GUID'ed HOB. If not all packets are full, then\r
+ write status code into available entry. Otherwise, create a new packet for it.\r
+\r
+ @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
+ @param CodeType Indicates the type of status code being reported.\r
+ @param Value Describes the current status of a hardware or\r
+ software entity. This includes information about the class and\r
+ subclass that is used to classify the entity as well as an operation.\r
+ For progress codes, the operation is the current activity.\r
+ For error codes, it is the exception.For debug codes,it is not defined at this time.\r
+ @param Instance The enumeration of a hardware or software entity within\r
+ the system. A system may contain multiple entities that match a class/subclass\r
+ pairing. The instance differentiates between them. An instance of 0 indicates\r
+ that instance information is unavailable, not meaningful, or not relevant.\r
+ Valid instance numbers start with 1.\r
+ @param CallerId This optional parameter may be used to identify the caller.\r
+ This parameter allows the status code driver to apply different rules to\r
+ different callers.\r
+ @param Data This optional parameter may be used to pass additional data.\r
+\r
+ @retval EFI_SUCCESS The function always return EFI_SUCCESS.\r
+\r
+**/\r
+EFI_STATUS\r
+MemoryStatusCodeReportWorker (\r
+ IN CONST EFI_PEI_SERVICES **PeiServices,\r
+ IN EFI_STATUS_CODE_TYPE CodeType,\r
+ IN EFI_STATUS_CODE_VALUE Value,\r
+ IN UINT32 Instance,\r
+ IN CONST EFI_GUID *CallerId,\r
+ IN CONST EFI_STATUS_CODE_DATA *Data OPTIONAL\r
+ )\r
+{\r
+\r
+ EFI_PEI_HOB_POINTERS Hob;\r
+ MEMORY_STATUSCODE_PACKET_HEADER *PacketHeader;\r
+ MEMORY_STATUSCODE_RECORD *Record;\r
+ UINT16 PacketIndex;\r
+\r
+ Record = NULL;\r
+ PacketIndex = 0;\r
+\r
+ //\r
+ // Journal GUID'ed HOBs to find empty record entry. if found, then save status code in it.\r
+ // otherwise, create a new GUID'ed HOB.\r
+ //\r
+ Hob.Raw = GetFirstGuidHob (&gMemoryStatusCodeRecordGuid);\r
+ while (Hob.Raw != NULL) {\r
+ PacketHeader = (MEMORY_STATUSCODE_PACKET_HEADER *) GET_GUID_HOB_DATA (Hob.Guid);\r
+\r
+ //\r
+ // Check whether pccket is full or not.\r
+ //\r
+ if (PacketHeader->RecordIndex < PacketHeader->MaxRecordsNumber) {\r
+ Record = (MEMORY_STATUSCODE_RECORD *) (PacketHeader + 1);\r
+ Record = &Record[PacketHeader->RecordIndex++];\r
+ break;\r
+ }\r
+ //\r
+ // Cache number of found packet in PacketIndex.\r
+ //\r
+ PacketIndex++;\r
+\r
+ Hob.Raw = GetNextGuidHob (&gMemoryStatusCodeRecordGuid, Hob.Raw);\r
+ }\r
+\r
+ if (Record == NULL) {\r
+ //\r
+ // No available entry found, so create new packet.\r
+ //\r
+ PacketHeader = CreateMemoryStatusCodePacket (PacketIndex);\r
+\r
+ Record = (MEMORY_STATUSCODE_RECORD *) (PacketHeader + 1);\r
+ Record = &Record[PacketHeader->RecordIndex++];\r
+ }\r
+\r
+ Record->CodeType = CodeType;\r
+ Record->Instance = Instance;\r
+ Record->Value = Value;\r
+\r
+ return EFI_SUCCESS;\r
+}\r
--- /dev/null
+/** @file\r
+ Serial I/O status code reporting worker.\r
+\r
+ Copyright (c) 2006 - 2009, Intel Corporation\r
+ All rights reserved. This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+**/\r
+\r
+#include "StatusCodeHandlerPei.h"\r
+\r
+/**\r
+ Convert status code value and extended data to readable ASCII string, send string to serial I/O device.\r
+\r
+ @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
+ @param CodeType Indicates the type of status code being reported.\r
+ @param Value Describes the current status of a hardware or\r
+ software entity. This includes information about the class and\r
+ subclass that is used to classify the entity as well as an operation.\r
+ For progress codes, the operation is the current activity.\r
+ For error codes, it is the exception.For debug codes,it is not defined at this time.\r
+ @param Instance The enumeration of a hardware or software entity within\r
+ the system. A system may contain multiple entities that match a class/subclass\r
+ pairing. The instance differentiates between them. An instance of 0 indicates\r
+ that instance information is unavailable, not meaningful, or not relevant.\r
+ Valid instance numbers start with 1.\r
+ @param CallerId This optional parameter may be used to identify the caller.\r
+ This parameter allows the status code driver to apply different rules to\r
+ different callers.\r
+ @param Data This optional parameter may be used to pass additional data.\r
+\r
+ @retval EFI_SUCCESS Status code reported to serial I/O successfully.\r
+\r
+**/\r
+EFI_STATUS\r
+SerialStatusCodeReportWorker (\r
+ IN CONST EFI_PEI_SERVICES **PeiServices,\r
+ IN EFI_STATUS_CODE_TYPE CodeType,\r
+ IN EFI_STATUS_CODE_VALUE Value,\r
+ IN UINT32 Instance,\r
+ IN CONST EFI_GUID *CallerId,\r
+ IN CONST EFI_STATUS_CODE_DATA *Data OPTIONAL\r
+ )\r
+{\r
+ CHAR8 *Filename;\r
+ CHAR8 *Description;\r
+ CHAR8 *Format;\r
+ CHAR8 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE];\r
+ UINT32 ErrorLevel;\r
+ UINT32 LineNumber;\r
+ UINTN CharCount;\r
+ BASE_LIST Marker;\r
+\r
+ Buffer[0] = '\0';\r
+\r
+ if (Data != NULL &&\r
+ ReportStatusCodeExtractAssertInfo (CodeType, Value, Data, &Filename, &Description, &LineNumber)) {\r
+ //\r
+ // Print ASSERT() information into output buffer.\r
+ //\r
+ CharCount = AsciiSPrint (\r
+ Buffer,\r
+ sizeof (Buffer),\r
+ "\n\rPEI_ASSERT!: %a (%d): %a\n\r",\r
+ Filename,\r
+ LineNumber,\r
+ Description\r
+ );\r
+ } else if (Data != NULL &&\r
+ ReportStatusCodeExtractDebugInfo (Data, &ErrorLevel, &Marker, &Format)) {\r
+ //\r
+ // Print DEBUG() information into output buffer.\r
+ //\r
+ CharCount = AsciiBSPrint (\r
+ Buffer,\r
+ sizeof (Buffer),\r
+ Format,\r
+ Marker\r
+ );\r
+ } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) {\r
+ //\r
+ // Print ERROR information into output buffer.\r
+ //\r
+ CharCount = AsciiSPrint (\r
+ Buffer,\r
+ sizeof (Buffer),\r
+ "ERROR: C%x:V%x I%x",\r
+ CodeType,\r
+ Value,\r
+ Instance\r
+ );\r
+\r
+ if (CallerId != NULL) {\r
+ CharCount += AsciiSPrint (\r
+ &Buffer[CharCount - 1],\r
+ (sizeof (Buffer) - (sizeof (Buffer[0]) * CharCount)),\r
+ " %g",\r
+ CallerId\r
+ );\r
+ }\r
+\r
+ if (Data != NULL) {\r
+ CharCount += AsciiSPrint (\r
+ &Buffer[CharCount - 1],\r
+ (sizeof (Buffer) - (sizeof (Buffer[0]) * CharCount)),\r
+ " %x",\r
+ Data\r
+ );\r
+ }\r
+\r
+ CharCount += AsciiSPrint (\r
+ &Buffer[CharCount - 1],\r
+ (sizeof (Buffer) - (sizeof (Buffer[0]) * CharCount)),\r
+ "\n\r"\r
+ );\r
+ } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) {\r
+ //\r
+ // Print PROGRESS information into output buffer.\r
+ //\r
+ CharCount = AsciiSPrint (\r
+ Buffer,\r
+ sizeof (Buffer),\r
+ "PROGRESS CODE: V%x I%x\n\r",\r
+ Value,\r
+ Instance\r
+ );\r
+ } else {\r
+ //\r
+ // Code type is not defined.\r
+ //\r
+ CharCount = AsciiSPrint (\r
+ Buffer,\r
+ sizeof (Buffer),\r
+ "Undefined: C%x:V%x I%x\n\r",\r
+ CodeType,\r
+ Value,\r
+ Instance\r
+ );\r
+ }\r
+\r
+ //\r
+ // Call SerialPort Lib function to do print.\r
+ //\r
+ SerialPortWrite ((UINT8 *) Buffer, CharCount);\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
--- /dev/null
+/** @file\r
+ Report Status Code Handler PEIM which produces general handlers and hook them\r
+ onto the PEI status code router.\r
+\r
+ Copyright (c) 2009, Intel Corporation\r
+ All rights reserved. This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "StatusCodeHandlerPei.h"\r
+\r
+/**\r
+ Entry point of Status Code PEIM.\r
+ \r
+ This function is the entry point of this Status Code PEIM.\r
+ It initializes supported status code devices according to PCD settings,\r
+ and installs Status Code PPI.\r
+\r
+ @param FileHandle Handle of the file being invoked.\r
+ @param PeiServices Describes the list of possible PEI Services.\r
+\r
+ @retval EFI_SUCESS The entry point of DXE IPL PEIM executes successfully.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+StatusCodeHandlerPeiEntry (\r
+ IN EFI_PEI_FILE_HANDLE FileHandle,\r
+ IN CONST EFI_PEI_SERVICES **PeiServices\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_PEI_RSC_HANDLER_PPI *RscHandlerPpi;\r
+\r
+ Status = PeiServicesLocatePpi (\r
+ &gEfiPeiRscHandlerPpiGuid,\r
+ 0,\r
+ NULL,\r
+ (VOID **) &RscHandlerPpi\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ //\r
+ // Dispatch initialization request to sub-statuscode-devices.\r
+ // If enable UseSerial, then initialize serial port.\r
+ // if enable UseMemory, then initialize memory status code worker.\r
+ //\r
+ if (FeaturePcdGet (PcdStatusCodeUseSerial)) {\r
+ Status = SerialPortInitialize();\r
+ ASSERT_EFI_ERROR (Status);\r
+ Status = RscHandlerPpi->Register (SerialStatusCodeReportWorker); \r
+ ASSERT_EFI_ERROR (Status);\r
+ }\r
+ if (FeaturePcdGet (PcdStatusCodeUseMemory)) {\r
+ Status = MemoryStatusCodeInitializeWorker ();\r
+ ASSERT_EFI_ERROR (Status);\r
+ Status = RscHandlerPpi->Register (MemoryStatusCodeReportWorker); \r
+ ASSERT_EFI_ERROR (Status);\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
--- /dev/null
+/** @file\r
+ Internal include file for Status Code Handler PEIM.\r
+\r
+ Copyright (c) 2006 - 2009, Intel Corporation\r
+ All rights reserved. This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#ifndef __STATUS_CODE_HANDLER_PEI_H__\r
+#define __STATUS_CODE_HANDLER_PEI_H__\r
+\r
+\r
+#include <Ppi/ReportStatusCodeHandler.h>\r
+\r
+#include <Guid/MemoryStatusCodeRecord.h>\r
+#include <Guid/StatusCodeDataTypeId.h>\r
+#include <Guid/StatusCodeDataTypeDebug.h>\r
+\r
+#include <Library/DebugLib.h>\r
+#include <Library/PrintLib.h>\r
+#include <Library/ReportStatusCodeLib.h>\r
+#include <Library/SerialPortLib.h>\r
+#include <Library/HobLib.h>\r
+#include <Library/PcdLib.h>\r
+#include <Library/PeiServicesLib.h>\r
+#include <Library/PeimEntryPoint.h>\r
+\r
+/**\r
+ Convert status code value and extended data to readable ASCII string, send string to serial I/O device.\r
+\r
+ @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
+ @param CodeType Indicates the type of status code being reported.\r
+ @param Value Describes the current status of a hardware or\r
+ software entity. This includes information about the class and\r
+ subclass that is used to classify the entity as well as an operation.\r
+ For progress codes, the operation is the current activity.\r
+ For error codes, it is the exception.For debug codes,it is not defined at this time.\r
+ @param Instance The enumeration of a hardware or software entity within\r
+ the system. A system may contain multiple entities that match a class/subclass\r
+ pairing. The instance differentiates between them. An instance of 0 indicates\r
+ that instance information is unavailable, not meaningful, or not relevant.\r
+ Valid instance numbers start with 1.\r
+ @param CallerId This optional parameter may be used to identify the caller.\r
+ This parameter allows the status code driver to apply different rules to\r
+ different callers.\r
+ @param Data This optional parameter may be used to pass additional data.\r
+\r
+ @retval EFI_SUCCESS Status code reported to serial I/O successfully.\r
+\r
+**/\r
+EFI_STATUS\r
+SerialStatusCodeReportWorker (\r
+ IN CONST EFI_PEI_SERVICES **PeiServices,\r
+ IN EFI_STATUS_CODE_TYPE CodeType,\r
+ IN EFI_STATUS_CODE_VALUE Value,\r
+ IN UINT32 Instance,\r
+ IN CONST EFI_GUID *CallerId,\r
+ IN CONST EFI_STATUS_CODE_DATA *Data OPTIONAL\r
+ );\r
+\r
+\r
+/**\r
+ Create the first memory status code GUID'ed HOB as initialization for memory status code worker.\r
+\r
+ @retval EFI_SUCCESS The GUID'ed HOB is created successfully.\r
+\r
+**/\r
+EFI_STATUS\r
+MemoryStatusCodeInitializeWorker (\r
+ VOID\r
+ );\r
+\r
+/**\r
+ Report status code into GUID'ed HOB.\r
+\r
+ This function reports status code into GUID'ed HOB. If not all packets are full, then\r
+ write status code into available entry. Otherwise, create a new packet for it.\r
+\r
+ @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
+ @param CodeType Indicates the type of status code being reported.\r
+ @param Value Describes the current status of a hardware or\r
+ software entity. This includes information about the class and\r
+ subclass that is used to classify the entity as well as an operation.\r
+ For progress codes, the operation is the current activity.\r
+ For error codes, it is the exception.For debug codes,it is not defined at this time.\r
+ @param Instance The enumeration of a hardware or software entity within\r
+ the system. A system may contain multiple entities that match a class/subclass\r
+ pairing. The instance differentiates between them. An instance of 0 indicates\r
+ that instance information is unavailable, not meaningful, or not relevant.\r
+ Valid instance numbers start with 1.\r
+ @param CallerId This optional parameter may be used to identify the caller.\r
+ This parameter allows the status code driver to apply different rules to\r
+ different callers.\r
+ @param Data This optional parameter may be used to pass additional data.\r
+\r
+ @retval EFI_SUCCESS The function always return EFI_SUCCESS.\r
+\r
+**/\r
+EFI_STATUS\r
+MemoryStatusCodeReportWorker (\r
+ IN CONST EFI_PEI_SERVICES **PeiServices,\r
+ IN EFI_STATUS_CODE_TYPE CodeType,\r
+ IN EFI_STATUS_CODE_VALUE Value,\r
+ IN UINT32 Instance,\r
+ IN CONST EFI_GUID *CallerId,\r
+ IN CONST EFI_STATUS_CODE_DATA *Data OPTIONAL\r
+ );\r
+\r
+#endif\r
+\r
+\r
--- /dev/null
+#/** @file\r
+# Report Status Code Handler PEIM which produces general handlers and hook them\r
+# onto the PEI status code router.\r
+#\r
+# Copyright (c) 2009, Intel Corporation.\r
+#\r
+# All rights reserved. This program and the accompanying materials\r
+# are licensed and made available under the terms and conditions of the BSD License\r
+# which accompanies this distribution. The full text of the license may be found at\r
+# http://opensource.org/licenses/bsd-license.php\r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+#**/\r
+\r
+[Defines]\r
+ INF_VERSION = 0x00010005\r
+ BASE_NAME = StatusCodeHandlerPei\r
+ FILE_GUID = 9D225237-FA01-464C-A949-BAABC02D31D0\r
+ MODULE_TYPE = PEIM\r
+ ENTRY_POINT = StatusCodeHandlerPeiEntry\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+# VALID_ARCHITECTURES = IA32 X64 IPF EBC (EBC is only for build)\r
+#\r
+\r
+[Sources.common]\r
+ StatusCodeHandlerPei.c\r
+ StatusCodeHandlerPei.h\r
+ SerialStatusCodeWorker.c\r
+ MemoryStausCodeWorker.c\r
+\r
+[Packages]\r
+ MdePkg/MdePkg.dec\r
+ MdeModulePkg/MdeModulePkg.dec\r
+\r
+[LibraryClasses]\r
+ PeimEntryPoint\r
+ PeiServicesLib\r
+ PcdLib\r
+ HobLib\r
+ SerialPortLib\r
+ ReportStatusCodeLib\r
+ PrintLib\r
+ DebugLib\r
+\r
+[Guids]\r
+ gMemoryStatusCodeRecordGuid ## SOMETIMES_CONSUMES ## HOB\r
+\r
+[Ppis]\r
+ gEfiPeiRscHandlerPpiGuid ## CONSUMES\r
+\r
+[FeaturePcd.common]\r
+ gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseMemory\r
+ gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseSerial\r
+\r
+[Pcd.common]\r
+ gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeMemorySize|1|PcdStatusCodeUseMemory\r
+\r
+[Depex]\r
+ gEfiPeiRscHandlerPpiGuid\r
--- /dev/null
+/** @file\r
+ Runtime memory status code worker.\r
+\r
+ Copyright (c) 2006 - 2009, Intel Corporation \r
+ All rights reserved. This program and the accompanying materials \r
+ are licensed and made available under the terms and conditions of the BSD License \r
+ which accompanies this distribution. The full text of the license may be found at \r
+ http://opensource.org/licenses/bsd-license.php \r
+ \r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
+\r
+**/\r
+\r
+#include "StatusCodeHandlerRuntimeDxe.h"\r
+\r
+RUNTIME_MEMORY_STATUSCODE_HEADER *mRtMemoryStatusCodeTable;\r
+\r
+/**\r
+ Initialize runtime memory status code table as initialization for runtime memory status code worker\r
+ \r
+ @retval EFI_SUCCESS Runtime memory status code table successfully initialized.\r
+\r
+**/\r
+EFI_STATUS\r
+RtMemoryStatusCodeInitializeWorker (\r
+ VOID\r
+ )\r
+{\r
+ //\r
+ // Allocate runtime memory status code pool.\r
+ //\r
+ mRtMemoryStatusCodeTable = AllocateRuntimePool (\r
+ sizeof (RUNTIME_MEMORY_STATUSCODE_HEADER) +\r
+ PcdGet16 (PcdStatusCodeMemorySize) * 1024\r
+ );\r
+ ASSERT (mRtMemoryStatusCodeTable != NULL);\r
+\r
+ mRtMemoryStatusCodeTable->RecordIndex = 0;\r
+ mRtMemoryStatusCodeTable->NumberOfRecords = 0;\r
+ mRtMemoryStatusCodeTable->MaxRecordsNumber = \r
+ (PcdGet16 (PcdStatusCodeMemorySize) * 1024) / sizeof (MEMORY_STATUSCODE_RECORD);\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+\r
+/**\r
+ Report status code into runtime memory. If the runtime pool is full, roll back to the \r
+ first record and overwrite it.\r
+ \r
+ @param CodeType Indicates the type of status code being reported.\r
+ @param Value Describes the current status of a hardware or software entity.\r
+ This included information about the class and subclass that is used to\r
+ classify the entity as well as an operation.\r
+ @param Instance The enumeration of a hardware or software entity within\r
+ the system. Valid instance numbers start with 1.\r
+ @param CallerId This optional parameter may be used to identify the caller.\r
+ This parameter allows the status code driver to apply different rules to\r
+ different callers.\r
+ @param Data This optional parameter may be used to pass additional data.\r
+ \r
+ @retval EFI_SUCCESS Status code successfully recorded in runtime memory status code table.\r
+\r
+**/\r
+EFI_STATUS\r
+RtMemoryStatusCodeReportWorker (\r
+ IN EFI_STATUS_CODE_TYPE CodeType,\r
+ IN EFI_STATUS_CODE_VALUE Value,\r
+ IN UINT32 Instance,\r
+ IN EFI_GUID *CallerId,\r
+ IN EFI_STATUS_CODE_DATA *Data OPTIONAL\r
+ )\r
+{\r
+ MEMORY_STATUSCODE_RECORD *Record;\r
+\r
+ //\r
+ // Locate current record buffer.\r
+ //\r
+ Record = (MEMORY_STATUSCODE_RECORD *) (mRtMemoryStatusCodeTable + 1);\r
+ Record = &Record[mRtMemoryStatusCodeTable->RecordIndex++];\r
+\r
+ //\r
+ // Save status code.\r
+ //\r
+ Record->CodeType = CodeType;\r
+ Record->Value = Value;\r
+ Record->Instance = Instance;\r
+\r
+ //\r
+ // If record index equals to max record number, then wrap around record index to zero.\r
+ //\r
+ // The reader of status code should compare the number of records with max records number,\r
+ // If it is equal to or larger than the max number, then the wrap-around had happened,\r
+ // so the first record is pointed by record index.\r
+ // If it is less then max number, index of the first record is zero.\r
+ //\r
+ mRtMemoryStatusCodeTable->NumberOfRecords++;\r
+ if (mRtMemoryStatusCodeTable->RecordIndex == mRtMemoryStatusCodeTable->MaxRecordsNumber) {\r
+ //\r
+ // Wrap around record index.\r
+ //\r
+ mRtMemoryStatusCodeTable->RecordIndex = 0;\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+\r
+\r
--- /dev/null
+/** @file\r
+ Serial I/O status code reporting worker.\r
+\r
+ Copyright (c) 2006 - 2009, Intel Corporation \r
+ All rights reserved. This program and the accompanying materials \r
+ are licensed and made available under the terms and conditions of the BSD License \r
+ which accompanies this distribution. The full text of the license may be found at \r
+ http://opensource.org/licenses/bsd-license.php \r
+ \r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
+\r
+**/\r
+\r
+#include "StatusCodeHandlerRuntimeDxe.h"\r
+\r
+/**\r
+ Convert status code value and extended data to readable ASCII string, send string to serial I/O device.\r
+ \r
+ @param CodeType Indicates the type of status code being reported.\r
+ @param Value Describes the current status of a hardware or software entity.\r
+ This included information about the class and subclass that is used to\r
+ classify the entity as well as an operation.\r
+ @param Instance The enumeration of a hardware or software entity within\r
+ the system. Valid instance numbers start with 1.\r
+ @param CallerId This optional parameter may be used to identify the caller.\r
+ This parameter allows the status code driver to apply different rules to\r
+ different callers.\r
+ @param Data This optional parameter may be used to pass additional data.\r
+\r
+ @retval EFI_SUCCESS Status code reported to serial I/O successfully.\r
+ @retval EFI_DEVICE_ERROR EFI serial device cannot work after ExitBootService() is called.\r
+ @retval EFI_DEVICE_ERROR EFI serial device cannot work with TPL higher than TPL_CALLBACK.\r
+\r
+**/\r
+EFI_STATUS\r
+SerialStatusCodeReportWorker (\r
+ IN EFI_STATUS_CODE_TYPE CodeType,\r
+ IN EFI_STATUS_CODE_VALUE Value,\r
+ IN UINT32 Instance,\r
+ IN EFI_GUID *CallerId,\r
+ IN EFI_STATUS_CODE_DATA *Data OPTIONAL\r
+ )\r
+{\r
+ CHAR8 *Filename;\r
+ CHAR8 *Description;\r
+ CHAR8 *Format;\r
+ CHAR8 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE];\r
+ UINT32 ErrorLevel;\r
+ UINT32 LineNumber;\r
+ UINTN CharCount;\r
+ BASE_LIST Marker;\r
+\r
+ Buffer[0] = '\0';\r
+\r
+ if (Data != NULL &&\r
+ ReportStatusCodeExtractAssertInfo (CodeType, Value, Data, &Filename, &Description, &LineNumber)) {\r
+ //\r
+ // Print ASSERT() information into output buffer.\r
+ //\r
+ CharCount = AsciiSPrint (\r
+ Buffer,\r
+ sizeof (Buffer),\r
+ "\n\rDXE_ASSERT!: %a (%d): %a\n\r",\r
+ Filename,\r
+ LineNumber,\r
+ Description\r
+ );\r
+ } else if (Data != NULL &&\r
+ ReportStatusCodeExtractDebugInfo (Data, &ErrorLevel, &Marker, &Format)) {\r
+ //\r
+ // Print DEBUG() information into output buffer.\r
+ //\r
+ CharCount = AsciiBSPrint (\r
+ Buffer, \r
+ sizeof (Buffer), \r
+ Format, \r
+ Marker\r
+ );\r
+ } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) {\r
+ //\r
+ // Print ERROR information into output buffer.\r
+ //\r
+ CharCount = AsciiSPrint (\r
+ Buffer, \r
+ sizeof (Buffer), \r
+ "ERROR: C%x:V%x I%x", \r
+ CodeType, \r
+ Value, \r
+ Instance\r
+ );\r
+ \r
+ if (CallerId != NULL) {\r
+ CharCount += AsciiSPrint (\r
+ &Buffer[CharCount - 1],\r
+ (sizeof (Buffer) - (sizeof (Buffer[0]) * CharCount)),\r
+ " %g",\r
+ CallerId\r
+ );\r
+ }\r
+\r
+ if (Data != NULL) {\r
+ CharCount += AsciiSPrint (\r
+ &Buffer[CharCount - 1],\r
+ (sizeof (Buffer) - (sizeof (Buffer[0]) * CharCount)),\r
+ " %x",\r
+ Data\r
+ );\r
+ }\r
+\r
+ CharCount += AsciiSPrint (\r
+ &Buffer[CharCount - 1],\r
+ (sizeof (Buffer) - (sizeof (Buffer[0]) * CharCount)),\r
+ "\n\r"\r
+ );\r
+ } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) {\r
+ //\r
+ // Print PROGRESS information into output buffer.\r
+ //\r
+ CharCount = AsciiSPrint (\r
+ Buffer, \r
+ sizeof (Buffer), \r
+ "PROGRESS CODE: V%x I%x\n\r", \r
+ Value, \r
+ Instance\r
+ );\r
+ } else {\r
+ //\r
+ // Code type is not defined.\r
+ //\r
+ CharCount = AsciiSPrint (\r
+ Buffer, \r
+ sizeof (Buffer), \r
+ "Undefined: C%x:V%x I%x\n\r", \r
+ CodeType, \r
+ Value, \r
+ Instance\r
+ );\r
+ }\r
+\r
+ //\r
+ // Call SerialPort Lib function to do print.\r
+ //\r
+ SerialPortWrite ((UINT8 *) Buffer, CharCount);\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
--- /dev/null
+/** @file\r
+ Status Code Handler Driver which produces general handlers and hook them\r
+ onto the DXE status code router.\r
+\r
+ Copyright (c) 2006 - 2009, Intel Corporation\r
+ All rights reserved. This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "StatusCodeHandlerRuntimeDxe.h"\r
+\r
+EFI_EVENT mVirtualAddressChangeEvent = NULL;\r
+EFI_EVENT mExitBootServicesEvent = NULL;\r
+EFI_RSC_HANDLER_PROTOCOL *mRscHandlerProtocol = NULL;\r
+\r
+/**\r
+ Unregister status code callback functions only available at boot time from\r
+ report status code router when exiting boot services.\r
+\r
+ @param Event Event whose notification function is being invoked.\r
+ @param Context Pointer to the notification function's context, which is\r
+ always zero in current implementation.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+UnregisterBootTimeHandlers (\r
+ IN EFI_EVENT Event,\r
+ IN VOID *Context\r
+ )\r
+{\r
+ if (FeaturePcdGet (PcdStatusCodeUseSerial)) {\r
+ mRscHandlerProtocol->Unregister (SerialStatusCodeReportWorker);\r
+ }\r
+}\r
+\r
+/**\r
+ Virtual address change notification call back. It converts global pointer\r
+ to virtual address.\r
+\r
+ @param Event Event whose notification function is being invoked.\r
+ @param Context Pointer to the notification function's context, which is\r
+ always zero in current implementation.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+VirtualAddressChangeCallBack (\r
+ IN EFI_EVENT Event,\r
+ IN VOID *Context\r
+ )\r
+{\r
+ //\r
+ // Convert memory status code table to virtual address;\r
+ //\r
+ EfiConvertPointer (\r
+ 0,\r
+ (VOID **) &mRtMemoryStatusCodeTable\r
+ );\r
+}\r
+\r
+/**\r
+ Dispatch initialization request to sub status code devices based on \r
+ customized feature flags.\r
+ \r
+**/\r
+VOID\r
+InitializationDispatcherWorker (\r
+ VOID\r
+ )\r
+{\r
+ EFI_PEI_HOB_POINTERS Hob;\r
+ EFI_STATUS Status;\r
+ MEMORY_STATUSCODE_PACKET_HEADER *PacketHeader;\r
+ MEMORY_STATUSCODE_RECORD *Record;\r
+ UINTN ExpectedPacketIndex;\r
+ UINTN Index;\r
+ VOID *HobStart;\r
+\r
+ //\r
+ // If enable UseSerial, then initialize serial port.\r
+ // if enable UseRuntimeMemory, then initialize runtime memory status code worker.\r
+ //\r
+ if (FeaturePcdGet (PcdStatusCodeUseSerial)) {\r
+ //\r
+ // Call Serial Port Lib API to initialize serial port.\r
+ //\r
+ Status = SerialPortInitialize ();\r
+ ASSERT_EFI_ERROR (Status);\r
+ }\r
+ if (FeaturePcdGet (PcdStatusCodeUseMemory)) {\r
+ Status = RtMemoryStatusCodeInitializeWorker ();\r
+ ASSERT_EFI_ERROR (Status);\r
+ }\r
+\r
+ //\r
+ // Replay Status code which saved in GUID'ed HOB to all supported devices. \r
+ //\r
+ if (FeaturePcdGet (PcdStatusCodeReplayIn)) {\r
+ // \r
+ // Journal GUID'ed HOBs to find all record entry, if found, \r
+ // then output record to support replay device.\r
+ //\r
+ ExpectedPacketIndex = 0;\r
+ Hob.Raw = GetFirstGuidHob (&gMemoryStatusCodeRecordGuid);\r
+ HobStart = Hob.Raw;\r
+ while (Hob.Raw != NULL) {\r
+ PacketHeader = (MEMORY_STATUSCODE_PACKET_HEADER *) GET_GUID_HOB_DATA (Hob.Guid);\r
+ if (PacketHeader->PacketIndex == ExpectedPacketIndex) {\r
+ Record = (MEMORY_STATUSCODE_RECORD *) (PacketHeader + 1);\r
+ for (Index = 0; Index < PacketHeader->RecordIndex; Index++) {\r
+ //\r
+ // Dispatch records to devices based on feature flag.\r
+ //\r
+ if (FeaturePcdGet (PcdStatusCodeUseSerial)) {\r
+ SerialStatusCodeReportWorker (\r
+ Record[Index].CodeType,\r
+ Record[Index].Value,\r
+ Record[Index].Instance,\r
+ NULL,\r
+ NULL\r
+ );\r
+ }\r
+ if (FeaturePcdGet (PcdStatusCodeUseMemory)) {\r
+ RtMemoryStatusCodeReportWorker (\r
+ Record[Index].CodeType,\r
+ Record[Index].Value,\r
+ Record[Index].Instance,\r
+ NULL,\r
+ NULL\r
+ );\r
+ }\r
+ }\r
+ ExpectedPacketIndex++;\r
+ \r
+ //\r
+ // See whether there is gap of packet or not\r
+ //\r
+ if (HobStart != NULL) {\r
+ HobStart = NULL;\r
+ Hob.Raw = HobStart;\r
+ continue;\r
+ }\r
+ } else if (HobStart != NULL) {\r
+ //\r
+ // Cache the found packet for improve the performance\r
+ //\r
+ HobStart = Hob.Raw;\r
+ }\r
+ \r
+ Hob.Raw = GetNextGuidHob (&gMemoryStatusCodeRecordGuid, Hob.Raw);\r
+ }\r
+ }\r
+}\r
+\r
+/**\r
+ Entry point of DXE Status Code Driver.\r
+\r
+ This function is the entry point of this DXE Status Code Driver.\r
+ It initializes registers status code handlers, and registers event for EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE.\r
+\r
+ @param ImageHandle The firmware allocated handle for the EFI image.\r
+ @param SystemTable A pointer to the EFI System Table.\r
+ \r
+ @retval EFI_SUCCESS The entry point is executed successfully.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+StatusCodeHandlerRuntimeDxeEntry (\r
+ IN EFI_HANDLE ImageHandle,\r
+ IN EFI_SYSTEM_TABLE *SystemTable\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ Status = gBS->LocateProtocol (\r
+ &gEfiRscHandlerProtocolGuid,\r
+ NULL,\r
+ (VOID **) &mRscHandlerProtocol\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ //\r
+ // Dispatch initialization request to supported devices\r
+ //\r
+ InitializationDispatcherWorker ();\r
+\r
+ if (FeaturePcdGet (PcdStatusCodeUseSerial)) {\r
+ mRscHandlerProtocol->Register (SerialStatusCodeReportWorker, TPL_HIGH_LEVEL);\r
+ }\r
+ if (FeaturePcdGet (PcdStatusCodeUseMemory)) {\r
+ mRscHandlerProtocol->Register (RtMemoryStatusCodeReportWorker, TPL_HIGH_LEVEL);\r
+ }\r
+\r
+ Status = gBS->CreateEventEx (\r
+ EVT_NOTIFY_SIGNAL,\r
+ TPL_NOTIFY,\r
+ UnregisterBootTimeHandlers,\r
+ NULL,\r
+ &gEfiEventExitBootServicesGuid,\r
+ &mExitBootServicesEvent\r
+ );\r
+\r
+ Status = gBS->CreateEventEx (\r
+ EVT_NOTIFY_SIGNAL,\r
+ TPL_NOTIFY,\r
+ VirtualAddressChangeCallBack,\r
+ NULL,\r
+ &gEfiEventVirtualAddressChangeGuid,\r
+ &mVirtualAddressChangeEvent\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ return EFI_SUCCESS;\r
+}\r
--- /dev/null
+/** @file\r
+ Internal include file for Status Code Handler Driver.\r
+\r
+ Copyright (c) 2006 - 2009, Intel Corporation\r
+ All rights reserved. This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#ifndef __STATUS_CODE_HANDLER_RUNTIME_DXE_H__\r
+#define __STATUS_CODE_HANDLER_RUNTIME_DXE_H__\r
+\r
+#include <Protocol/ReportStatusCodeHandler.h>\r
+\r
+#include <Guid/MemoryStatusCodeRecord.h>\r
+#include <Guid/StatusCodeDataTypeId.h>\r
+#include <Guid/StatusCodeDataTypeDebug.h>\r
+#include <Guid/EventGroup.h>\r
+\r
+#include <Library/SynchronizationLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/ReportStatusCodeLib.h>\r
+#include <Library/PrintLib.h>\r
+#include <Library/PcdLib.h>\r
+#include <Library/HobLib.h>\r
+#include <Library/UefiDriverEntryPoint.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/UefiRuntimeLib.h>\r
+#include <Library/SerialPortLib.h>\r
+\r
+//\r
+// Runtime memory status code worker definition\r
+//\r
+typedef struct {\r
+ UINT32 RecordIndex;\r
+ UINT32 NumberOfRecords;\r
+ UINT32 MaxRecordsNumber;\r
+} RUNTIME_MEMORY_STATUSCODE_HEADER;\r
+\r
+extern RUNTIME_MEMORY_STATUSCODE_HEADER *mRtMemoryStatusCodeTable;\r
+\r
+/**\r
+ Locates Serial I/O Protocol as initialization for serial status code worker.\r
+ \r
+ @retval EFI_SUCCESS Serial I/O Protocol is successfully located.\r
+\r
+**/\r
+EFI_STATUS\r
+EfiSerialStatusCodeInitializeWorker (\r
+ VOID\r
+ );\r
+\r
+\r
+/**\r
+ Convert status code value and extended data to readable ASCII string, send string to serial I/O device.\r
+ \r
+ @param CodeType Indicates the type of status code being reported.\r
+ @param Value Describes the current status of a hardware or software entity.\r
+ This included information about the class and subclass that is used to\r
+ classify the entity as well as an operation.\r
+ @param Instance The enumeration of a hardware or software entity within\r
+ the system. Valid instance numbers start with 1.\r
+ @param CallerId This optional parameter may be used to identify the caller.\r
+ This parameter allows the status code driver to apply different rules to\r
+ different callers.\r
+ @param Data This optional parameter may be used to pass additional data.\r
+\r
+ @retval EFI_SUCCESS Status code reported to serial I/O successfully.\r
+ @retval EFI_DEVICE_ERROR EFI serial device cannot work after ExitBootService() is called.\r
+ @retval EFI_DEVICE_ERROR EFI serial device cannot work with TPL higher than TPL_CALLBACK.\r
+\r
+**/\r
+EFI_STATUS\r
+SerialStatusCodeReportWorker (\r
+ IN EFI_STATUS_CODE_TYPE CodeType,\r
+ IN EFI_STATUS_CODE_VALUE Value,\r
+ IN UINT32 Instance,\r
+ IN EFI_GUID *CallerId,\r
+ IN EFI_STATUS_CODE_DATA *Data OPTIONAL\r
+ );\r
+\r
+/**\r
+ Initialize runtime memory status code table as initialization for runtime memory status code worker\r
+ \r
+ @retval EFI_SUCCESS Runtime memory status code table successfully initialized.\r
+\r
+**/\r
+EFI_STATUS\r
+RtMemoryStatusCodeInitializeWorker (\r
+ VOID\r
+ );\r
+\r
+/**\r
+ Report status code into runtime memory. If the runtime pool is full, roll back to the \r
+ first record and overwrite it.\r
+ \r
+ @param CodeType Indicates the type of status code being reported.\r
+ @param Value Describes the current status of a hardware or software entity.\r
+ This included information about the class and subclass that is used to\r
+ classify the entity as well as an operation.\r
+ @param Instance The enumeration of a hardware or software entity within\r
+ the system. Valid instance numbers start with 1.\r
+ @param CallerId This optional parameter may be used to identify the caller.\r
+ This parameter allows the status code driver to apply different rules to\r
+ different callers.\r
+ @param Data This optional parameter may be used to pass additional data.\r
+ \r
+ @retval EFI_SUCCESS Status code successfully recorded in runtime memory status code table.\r
+\r
+**/\r
+EFI_STATUS\r
+RtMemoryStatusCodeReportWorker (\r
+ IN EFI_STATUS_CODE_TYPE CodeType,\r
+ IN EFI_STATUS_CODE_VALUE Value,\r
+ IN UINT32 Instance,\r
+ IN EFI_GUID *CallerId,\r
+ IN EFI_STATUS_CODE_DATA *Data OPTIONAL\r
+ );\r
+\r
+#endif\r
--- /dev/null
+#/** @file\r
+# Status Code Handler Driver which produces general handlers and hook them\r
+# onto the DXE status code router.\r
+#\r
+# Copyright (c) 2006 - 2009, Intel Corporation.\r
+#\r
+# All rights reserved. This program and the accompanying materials\r
+# are licensed and made available under the terms and conditions of the BSD License\r
+# which accompanies this distribution. The full text of the license may be found at\r
+# http://opensource.org/licenses/bsd-license.php\r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+#**/\r
+\r
+[Defines]\r
+ INF_VERSION = 0x00010005\r
+ BASE_NAME = StatusCodeHandlerRuntimeDxe\r
+ FILE_GUID = 6C2004EF-4E0E-4BE4-B14C-340EB4AA5891\r
+ MODULE_TYPE = DXE_RUNTIME_DRIVER\r
+ ENTRY_POINT = StatusCodeHandlerRuntimeDxeEntry\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+# VALID_ARCHITECTURES = IA32 X64 IPF EBC\r
+#\r
+\r
+[Sources.common]\r
+ StatusCodeHandlerRuntimeDxe.c\r
+ StatusCodeHandlerRuntimeDxe.h\r
+ SerialStatusCodeWorker.c\r
+ MemoryStatusCodeWorker.c\r
+\r
+[Packages]\r
+ MdePkg/MdePkg.dec\r
+ MdeModulePkg/MdeModulePkg.dec\r
+\r
+[LibraryClasses]\r
+ SerialPortLib\r
+ UefiRuntimeLib\r
+ MemoryAllocationLib\r
+ UefiBootServicesTableLib\r
+ UefiDriverEntryPoint\r
+ HobLib\r
+ PcdLib\r
+ PrintLib\r
+ ReportStatusCodeLib\r
+ DebugLib\r
+ SynchronizationLib\r
+\r
+[Guids]\r
+ gMemoryStatusCodeRecordGuid ## CONSUMES ## HOB\r
+ gEfiEventVirtualAddressChangeGuid ## CONSUMES ## Event\r
+ gEfiEventExitBootServicesGuid ## CONSUMES ## Event\r
+\r
+[Protocols]\r
+ gEfiRscHandlerProtocolGuid ## CONSUMES\r
+\r
+[FeaturePcd]\r
+ gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeReplayIn\r
+ gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseMemory\r
+ gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseSerial\r
+\r
+[Pcd]\r
+ gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeMemorySize |128| PcdStatusCodeUseMemory\r
+\r
+[Depex]\r
+ gEfiRscHandlerProtocolGuid\r
--- /dev/null
+/** @file\r
+ Runtime memory status code worker.\r
+\r
+ Copyright (c) 2006 - 2009, Intel Corporation \r
+ All rights reserved. This program and the accompanying materials \r
+ are licensed and made available under the terms and conditions of the BSD License \r
+ which accompanies this distribution. The full text of the license may be found at \r
+ http://opensource.org/licenses/bsd-license.php \r
+ \r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
+\r
+**/\r
+\r
+#include "StatusCodeHandlerSmm.h"\r
+\r
+RUNTIME_MEMORY_STATUSCODE_HEADER *mSmmMemoryStatusCodeTable;\r
+\r
+/**\r
+ Initialize SMM memory status code table as initialization for memory status code worker\r
+ \r
+ @retval EFI_SUCCESS SMM memory status code table successfully initialized.\r
+\r
+**/\r
+EFI_STATUS\r
+MemoryStatusCodeInitializeWorker (\r
+ VOID\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ //\r
+ // Allocate SMM memory status code pool.\r
+ //\r
+ Status = gSmst->SmmAllocatePool (\r
+ EfiRuntimeServicesData,\r
+ sizeof (RUNTIME_MEMORY_STATUSCODE_HEADER) + PcdGet16 (PcdStatusCodeMemorySize) * 1024,\r
+ (VOID**)&mSmmMemoryStatusCodeTable\r
+ );\r
+\r
+ ASSERT_EFI_ERROR(Status);\r
+ ASSERT (mSmmMemoryStatusCodeTable != NULL);\r
+\r
+ mSmmMemoryStatusCodeTable->RecordIndex = 0;\r
+ mSmmMemoryStatusCodeTable->NumberOfRecords = 0;\r
+ mSmmMemoryStatusCodeTable->MaxRecordsNumber = \r
+ (PcdGet16 (PcdStatusCodeMemorySize) * 1024) / sizeof (MEMORY_STATUSCODE_RECORD);\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+\r
+/**\r
+ Report status code into runtime memory. If the runtime pool is full, roll back to the \r
+ first record and overwrite it.\r
+ \r
+ @param CodeType Indicates the type of status code being reported.\r
+ @param Value Describes the current status of a hardware or software entity.\r
+ This included information about the class and subclass that is used to\r
+ classify the entity as well as an operation.\r
+ @param Instance The enumeration of a hardware or software entity within\r
+ the system. Valid instance numbers start with 1.\r
+ @param CallerId This optional parameter may be used to identify the caller.\r
+ This parameter allows the status code driver to apply different rules to\r
+ different callers.\r
+ @param Data This optional parameter may be used to pass additional data.\r
+ \r
+ @retval EFI_SUCCESS Status code successfully recorded in runtime memory status code table.\r
+\r
+**/\r
+EFI_STATUS\r
+MemoryStatusCodeReportWorker (\r
+ IN EFI_STATUS_CODE_TYPE CodeType,\r
+ IN EFI_STATUS_CODE_VALUE Value,\r
+ IN UINT32 Instance,\r
+ IN EFI_GUID *CallerId,\r
+ IN EFI_STATUS_CODE_DATA *Data OPTIONAL\r
+ )\r
+{\r
+ MEMORY_STATUSCODE_RECORD *Record;\r
+\r
+ //\r
+ // Locate current record buffer.\r
+ //\r
+ Record = (MEMORY_STATUSCODE_RECORD *) (mSmmMemoryStatusCodeTable + 1);\r
+ Record = &Record[mSmmMemoryStatusCodeTable->RecordIndex++];\r
+\r
+ //\r
+ // Save status code.\r
+ //\r
+ Record->CodeType = CodeType;\r
+ Record->Value = Value;\r
+ Record->Instance = Instance;\r
+\r
+ //\r
+ // If record index equals to max record number, then wrap around record index to zero.\r
+ //\r
+ // The reader of status code should compare the number of records with max records number,\r
+ // If it is equal to or larger than the max number, then the wrap-around had happened,\r
+ // so the first record is pointed by record index.\r
+ // If it is less then max number, index of the first record is zero.\r
+ //\r
+ mSmmMemoryStatusCodeTable->NumberOfRecords++;\r
+ if (mSmmMemoryStatusCodeTable->RecordIndex == mSmmMemoryStatusCodeTable->MaxRecordsNumber) {\r
+ //\r
+ // Wrap around record index.\r
+ //\r
+ mSmmMemoryStatusCodeTable->RecordIndex = 0;\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+\r
+\r
--- /dev/null
+/** @file\r
+ Serial I/O status code reporting worker.\r
+\r
+ Copyright (c) 2009, Intel Corporation \r
+ All rights reserved. This program and the accompanying materials \r
+ are licensed and made available under the terms and conditions of the BSD License \r
+ which accompanies this distribution. The full text of the license may be found at \r
+ http://opensource.org/licenses/bsd-license.php \r
+ \r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
+\r
+**/\r
+\r
+#include "StatusCodeHandlerSmm.h"\r
+\r
+/**\r
+ Convert status code value and extended data to readable ASCII string, send string to serial I/O device.\r
+ \r
+ @param CodeType Indicates the type of status code being reported.\r
+ @param Value Describes the current status of a hardware or software entity.\r
+ This included information about the class and subclass that is used to\r
+ classify the entity as well as an operation.\r
+ @param Instance The enumeration of a hardware or software entity within\r
+ the system. Valid instance numbers start with 1.\r
+ @param CallerId This optional parameter may be used to identify the caller.\r
+ This parameter allows the status code driver to apply different rules to\r
+ different callers.\r
+ @param Data This optional parameter may be used to pass additional data.\r
+\r
+ @retval EFI_SUCCESS Status code reported to serial I/O successfully.\r
+ @retval EFI_DEVICE_ERROR EFI serial device cannot work after ExitBootService() is called.\r
+ @retval EFI_DEVICE_ERROR EFI serial device cannot work with TPL higher than TPL_CALLBACK.\r
+\r
+**/\r
+EFI_STATUS\r
+SerialStatusCodeReportWorker (\r
+ IN EFI_STATUS_CODE_TYPE CodeType,\r
+ IN EFI_STATUS_CODE_VALUE Value,\r
+ IN UINT32 Instance,\r
+ IN EFI_GUID *CallerId,\r
+ IN EFI_STATUS_CODE_DATA *Data OPTIONAL\r
+ )\r
+{\r
+ CHAR8 *Filename;\r
+ CHAR8 *Description;\r
+ CHAR8 *Format;\r
+ CHAR8 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE];\r
+ UINT32 ErrorLevel;\r
+ UINT32 LineNumber;\r
+ UINTN CharCount;\r
+ BASE_LIST Marker;\r
+\r
+ Buffer[0] = '\0';\r
+\r
+ if (Data != NULL &&\r
+ ReportStatusCodeExtractAssertInfo (CodeType, Value, Data, &Filename, &Description, &LineNumber)) {\r
+ //\r
+ // Print ASSERT() information into output buffer.\r
+ //\r
+ CharCount = AsciiSPrint (\r
+ Buffer,\r
+ sizeof (Buffer),\r
+ "\n\rDXE_ASSERT!: %a (%d): %a\n\r",\r
+ Filename,\r
+ LineNumber,\r
+ Description\r
+ );\r
+ } else if (Data != NULL &&\r
+ ReportStatusCodeExtractDebugInfo (Data, &ErrorLevel, &Marker, &Format)) {\r
+ //\r
+ // Print DEBUG() information into output buffer.\r
+ //\r
+ CharCount = AsciiBSPrint (\r
+ Buffer, \r
+ sizeof (Buffer), \r
+ Format, \r
+ Marker\r
+ );\r
+ } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) {\r
+ //\r
+ // Print ERROR information into output buffer.\r
+ //\r
+ CharCount = AsciiSPrint (\r
+ Buffer, \r
+ sizeof (Buffer), \r
+ "ERROR: C%x:V%x I%x", \r
+ CodeType, \r
+ Value, \r
+ Instance\r
+ );\r
+ \r
+ if (CallerId != NULL) {\r
+ CharCount += AsciiSPrint (\r
+ &Buffer[CharCount - 1],\r
+ (sizeof (Buffer) - (sizeof (Buffer[0]) * CharCount)),\r
+ " %g",\r
+ CallerId\r
+ );\r
+ }\r
+\r
+ if (Data != NULL) {\r
+ CharCount += AsciiSPrint (\r
+ &Buffer[CharCount - 1],\r
+ (sizeof (Buffer) - (sizeof (Buffer[0]) * CharCount)),\r
+ " %x",\r
+ Data\r
+ );\r
+ }\r
+\r
+ CharCount += AsciiSPrint (\r
+ &Buffer[CharCount - 1],\r
+ (sizeof (Buffer) - (sizeof (Buffer[0]) * CharCount)),\r
+ "\n\r"\r
+ );\r
+ } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) {\r
+ //\r
+ // Print PROGRESS information into output buffer.\r
+ //\r
+ CharCount = AsciiSPrint (\r
+ Buffer, \r
+ sizeof (Buffer), \r
+ "PROGRESS CODE: V%x I%x\n\r", \r
+ Value, \r
+ Instance\r
+ );\r
+ } else {\r
+ //\r
+ // Code type is not defined.\r
+ //\r
+ CharCount = AsciiSPrint (\r
+ Buffer, \r
+ sizeof (Buffer), \r
+ "Undefined: C%x:V%x I%x\n\r", \r
+ CodeType, \r
+ Value, \r
+ Instance\r
+ );\r
+ }\r
+\r
+ //\r
+ // Call SerialPort Lib function to do print.\r
+ //\r
+ SerialPortWrite ((UINT8 *) Buffer, CharCount);\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
--- /dev/null
+/** @file\r
+ Status Code Handler Driver which produces general handlers and hook them\r
+ onto the SMM status code router.\r
+\r
+ Copyright (c) 2009, Intel Corporation\r
+ All rights reserved. This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "StatusCodeHandlerSmm.h"\r
+\r
+EFI_SMM_RSC_HANDLER_PROTOCOL *mRscHandlerProtocol = NULL;\r
+\r
+\r
+/**\r
+ Dispatch initialization request to sub status code devices based on \r
+ customized feature flags.\r
+ \r
+**/\r
+VOID\r
+InitializationDispatcherWorker (\r
+ VOID\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ //\r
+ // If enable UseSerial, then initialize serial port.\r
+ // if enable UseRuntimeMemory, then initialize runtime memory status code worker.\r
+ //\r
+ if (FeaturePcdGet (PcdStatusCodeUseSerial)) {\r
+ //\r
+ // Call Serial Port Lib API to initialize serial port.\r
+ //\r
+ Status = SerialPortInitialize ();\r
+ ASSERT_EFI_ERROR (Status);\r
+ }\r
+ if (FeaturePcdGet (PcdStatusCodeUseMemory)) {\r
+ Status = MemoryStatusCodeInitializeWorker ();\r
+ ASSERT_EFI_ERROR (Status);\r
+ }\r
+}\r
+\r
+/**\r
+ Entry point of SMM Status Code Driver.\r
+\r
+ This function is the entry point of SMM Status Code Driver.\r
+\r
+ @param ImageHandle The firmware allocated handle for the EFI image.\r
+ @param SystemTable A pointer to the EFI System Table.\r
+ \r
+ @retval EFI_SUCCESS The entry point is executed successfully.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+StatusCodeHandlerSmmEntry (\r
+ IN EFI_HANDLE ImageHandle,\r
+ IN EFI_SYSTEM_TABLE *SystemTable\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ Status = gSmst->SmmLocateProtocol (\r
+ &gEfiSmmRscHandlerProtocolGuid,\r
+ NULL,\r
+ (VOID **) &mRscHandlerProtocol\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ //\r
+ // Dispatch initialization request to supported devices\r
+ //\r
+ InitializationDispatcherWorker ();\r
+\r
+ if (FeaturePcdGet (PcdStatusCodeUseSerial)) {\r
+ mRscHandlerProtocol->Register (SerialStatusCodeReportWorker);\r
+ }\r
+ if (FeaturePcdGet (PcdStatusCodeUseMemory)) {\r
+ mRscHandlerProtocol->Register (MemoryStatusCodeReportWorker);\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
+}\r
--- /dev/null
+/** @file\r
+ Internal include file for Status Code Handler Driver.\r
+\r
+ Copyright (c) 2009, Intel Corporation\r
+ All rights reserved. This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#ifndef __STATUS_CODE_HANDLER_SMM_H__\r
+#define __STATUS_CODE_HANDLER_SMM_H__\r
+\r
+#include <Protocol/SmmReportStatusCodeHandler.h>\r
+\r
+#include <Guid/MemoryStatusCodeRecord.h>\r
+#include <Guid/StatusCodeDataTypeId.h>\r
+#include <Guid/StatusCodeDataTypeDebug.h>\r
+\r
+#include <Library/SynchronizationLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/ReportStatusCodeLib.h>\r
+#include <Library/PrintLib.h>\r
+#include <Library/PcdLib.h>\r
+#include <Library/UefiDriverEntryPoint.h>\r
+#include <Library/SmmServicesTableLib.h>\r
+#include <Library/SerialPortLib.h>\r
+\r
+//\r
+// Runtime memory status code worker definition\r
+//\r
+typedef struct {\r
+ UINT32 RecordIndex;\r
+ UINT32 NumberOfRecords;\r
+ UINT32 MaxRecordsNumber;\r
+} RUNTIME_MEMORY_STATUSCODE_HEADER;\r
+\r
+extern RUNTIME_MEMORY_STATUSCODE_HEADER *mSmmMemoryStatusCodeTable;\r
+\r
+/**\r
+ Locates Serial I/O Protocol as initialization for serial status code worker.\r
+ \r
+ @retval EFI_SUCCESS Serial I/O Protocol is successfully located.\r
+\r
+**/\r
+EFI_STATUS\r
+EfiSerialStatusCodeInitializeWorker (\r
+ VOID\r
+ );\r
+\r
+\r
+/**\r
+ Convert status code value and extended data to readable ASCII string, send string to serial I/O device.\r
+ \r
+ @param CodeType Indicates the type of status code being reported.\r
+ @param Value Describes the current status of a hardware or software entity.\r
+ This included information about the class and subclass that is used to\r
+ classify the entity as well as an operation.\r
+ @param Instance The enumeration of a hardware or software entity within\r
+ the system. Valid instance numbers start with 1.\r
+ @param CallerId This optional parameter may be used to identify the caller.\r
+ This parameter allows the status code driver to apply different rules to\r
+ different callers.\r
+ @param Data This optional parameter may be used to pass additional data.\r
+\r
+ @retval EFI_SUCCESS Status code reported to serial I/O successfully.\r
+ @retval EFI_DEVICE_ERROR EFI serial device cannot work after ExitBootService() is called.\r
+ @retval EFI_DEVICE_ERROR EFI serial device cannot work with TPL higher than TPL_CALLBACK.\r
+\r
+**/\r
+EFI_STATUS\r
+SerialStatusCodeReportWorker (\r
+ IN EFI_STATUS_CODE_TYPE CodeType,\r
+ IN EFI_STATUS_CODE_VALUE Value,\r
+ IN UINT32 Instance,\r
+ IN EFI_GUID *CallerId,\r
+ IN EFI_STATUS_CODE_DATA *Data OPTIONAL\r
+ );\r
+\r
+/**\r
+ Initialize runtime memory status code table as initialization for runtime memory status code worker\r
+ \r
+ @retval EFI_SUCCESS Runtime memory status code table successfully initialized.\r
+\r
+**/\r
+EFI_STATUS\r
+MemoryStatusCodeInitializeWorker (\r
+ VOID\r
+ );\r
+\r
+/**\r
+ Report status code into runtime memory. If the runtime pool is full, roll back to the \r
+ first record and overwrite it.\r
+ \r
+ @param CodeType Indicates the type of status code being reported.\r
+ @param Value Describes the current status of a hardware or software entity.\r
+ This included information about the class and subclass that is used to\r
+ classify the entity as well as an operation.\r
+ @param Instance The enumeration of a hardware or software entity within\r
+ the system. Valid instance numbers start with 1.\r
+ @param CallerId This optional parameter may be used to identify the caller.\r
+ This parameter allows the status code driver to apply different rules to\r
+ different callers.\r
+ @param Data This optional parameter may be used to pass additional data.\r
+ \r
+ @retval EFI_SUCCESS Status code successfully recorded in runtime memory status code table.\r
+\r
+**/\r
+EFI_STATUS\r
+MemoryStatusCodeReportWorker (\r
+ IN EFI_STATUS_CODE_TYPE CodeType,\r
+ IN EFI_STATUS_CODE_VALUE Value,\r
+ IN UINT32 Instance,\r
+ IN EFI_GUID *CallerId,\r
+ IN EFI_STATUS_CODE_DATA *Data OPTIONAL\r
+ );\r
+\r
+#endif\r
--- /dev/null
+#/** @file\r
+# Status Code Handler Driver which produces general handlers and hook them\r
+# onto the SMM status code router.\r
+#\r
+# Copyright (c) 2009, Intel Corporation.\r
+#\r
+# All rights reserved. This program and the accompanying materials\r
+# are licensed and made available under the terms and conditions of the BSD License\r
+# which accompanies this distribution. The full text of the license may be found at\r
+# http://opensource.org/licenses/bsd-license.php\r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+#**/\r
+\r
+[Defines]\r
+ INF_VERSION = 0x00010005\r
+ BASE_NAME = StatusCodeHandlerSmm\r
+ FILE_GUID = 79CD78D8-6EDC-4978-BD02-3299C387AB17\r
+ MODULE_TYPE = DXE_SMM_DRIVER\r
+ PI_SPECIFICATION_VERSION = 0x0001000A\r
+ \r
+ ENTRY_POINT = StatusCodeHandlerSmmEntry\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+# VALID_ARCHITECTURES = IA32 X64\r
+#\r
+\r
+[Sources.common]\r
+ StatusCodeHandlerSmm.c\r
+ StatusCodeHandlerSmm.h\r
+ SerialStatusCodeWorker.c\r
+ MemoryStatusCodeWorker.c\r
+\r
+[Packages]\r
+ MdePkg/MdePkg.dec\r
+ MdeModulePkg/MdeModulePkg.dec\r
+\r
+[LibraryClasses]\r
+ SerialPortLib\r
+ SmmServicesTableLib\r
+ UefiDriverEntryPoint\r
+ PcdLib\r
+ PrintLib\r
+ ReportStatusCodeLib\r
+ DebugLib\r
+ SynchronizationLib\r
+\r
+[Guids]\r
+ gMemoryStatusCodeRecordGuid ## CONSUMES ## HOB\r
+\r
+[Protocols]\r
+ gEfiSmmRscHandlerProtocolGuid ## CONSUMES\r
+\r
+[FeaturePcd]\r
+ gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseMemory\r
+ gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseSerial\r
+\r
+[Pcd]\r
+ gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeMemorySize |128| PcdStatusCodeUseMemory\r
+\r
+[Depex]\r
+ gEfiSmmRscHandlerProtocolGuid\r