+++ /dev/null
-/** @file\r
- PEI memory status code worker.\r
-\r
- Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
- SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "StatusCodePei.h"\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 memory status code GUID'ed HOB.\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 = 0;\r
- PacketHeader->RecordIndex = 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 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
-\r
- @retval EFI_SUCCESS The function always return EFI_SUCCESS.\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
- )\r
-{\r
-\r
- EFI_PEI_HOB_POINTERS Hob;\r
- MEMORY_STATUSCODE_PACKET_HEADER *PacketHeader;\r
- MEMORY_STATUSCODE_RECORD *Record;\r
-\r
- //\r
- // Find GUID'ed HOBs to locate current record buffer.\r
- //\r
- Hob.Raw = GetFirstGuidHob (&gMemoryStatusCodeRecordGuid);\r
- ASSERT (Hob.Raw != NULL);\r
-\r
- PacketHeader = (MEMORY_STATUSCODE_PACKET_HEADER *) GET_GUID_HOB_DATA (Hob.Guid);\r
- Record = (MEMORY_STATUSCODE_RECORD *) (PacketHeader + 1);\r
- Record = &Record[PacketHeader->RecordIndex++];\r
-\r
- //\r
- // Save status code.\r
- //\r
- Record->CodeType = CodeType;\r
- Record->Instance = Instance;\r
- Record->Value = Value;\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
- if (PacketHeader->RecordIndex == PacketHeader->MaxRecordsNumber) {\r
- //\r
- // Wrap around record index.\r
- //\r
- PacketHeader->RecordIndex = 0;\r
- PacketHeader->PacketIndex ++;\r
- }\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r