/** @file\r
- Memory status code worker in PEI.\r
+ PEI memory status code worker.\r
\r
- Copyright (c) 2006, Intel Corporation\r
- All rights reserved. This program and the accompanying materials\r
+ Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+ 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
- Module Name: MemoryStatusCodeWorker.c\r
-\r
**/\r
\r
-#include "PeiStatusCode.h"\r
+#include "StatusCodePei.h"\r
\r
/**\r
- Create one memory status code GUID'ed HOB, use PacketIndex\r
- to identify the packet.\r
-\r
- @param PacketIndex Index of records packet.\r
+ Create the first memory status code GUID'ed HOB as initialization for memory status code worker.\r
\r
- @return Always return pointer of memory status code packet.\r
+ @retval EFI_SUCCESS The GUID'ed HOB is created successfully.\r
\r
**/\r
-STATIC\r
-MEMORY_STATUSCODE_PACKET_HEADER *\r
-CreateMemoryStatusCodePacket (\r
- UINT16 PacketIndex\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 =\r
- (MEMORY_STATUSCODE_PACKET_HEADER *) BuildGuidHob (\r
- &gMemoryStatusCodeRecordGuid,\r
- PcdGet16 (PcdStatusCodeMemorySize) *\r
- 1024 +\r
- sizeof (MEMORY_STATUSCODE_PACKET_HEADER)\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->MaxRecordsNumber = (PcdGet16 (PcdStatusCodeMemorySize) * 1024) / sizeof (MEMORY_STATUSCODE_RECORD);\r
+ PacketHeader->PacketIndex = 0;\r
PacketHeader->RecordIndex = 0;\r
\r
- return PacketHeader;\r
-}\r
-\r
-\r
-\r
-/**\r
- Initialize memory status code.\r
- Create one GUID'ed HOB with PCD defined size. If create required size\r
- GUID'ed HOB failed, then ASSERT().\r
-\r
- @return The function always return EFI_SUCCESS\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
- @param CodeType Indicates the type of status code being reported. Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.\r
+ Report status code into GUID'ed HOB.\r
\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 classify the entity\r
- as well as an operation. 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
- Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.\r
- Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.\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 Instance The enumeration of a hardware or software entity within the system.\r
- A system may contain multiple entities that match a class/subclass pairing.\r
- The instance differentiates between them. An instance of 0 indicates that instance information is unavailable,\r
- not meaningful, or not relevant. Valid instance numbers start with 1.\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
- @return The function always return EFI_SUCCESS.\r
+ @retval EFI_SUCCESS The function always return EFI_SUCCESS.\r
\r
**/\r
EFI_STATUS\r
\r
EFI_PEI_HOB_POINTERS Hob;\r
MEMORY_STATUSCODE_PACKET_HEADER *PacketHeader;\r
- MEMORY_STATUSCODE_RECORD *Record = NULL;\r
- UINT16 PacketIndex = 0;;\r
+ MEMORY_STATUSCODE_RECORD *Record;\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
+ // Find GUID'ed HOBs to locate current record buffer. \r
//\r
Hob.Raw = GetFirstGuidHob (&gMemoryStatusCodeRecordGuid);\r
- while (Hob.Raw != NULL) {\r
- PacketHeader = (MEMORY_STATUSCODE_PACKET_HEADER *) GET_GUID_HOB_DATA (Hob.Guid);\r
+ ASSERT (Hob.Raw != NULL);\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
+ 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
- Hob.Raw = GetNextGuidHob (&gMemoryStatusCodeRecordGuid, Hob.Raw);\r
- }\r
+ //\r
+ // Save status code.\r
+ //\r
+ Record->CodeType = CodeType;\r
+ Record->Instance = Instance;\r
+ Record->Value = Value;\r
\r
- if (NULL == Record) {\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
- // In order to save status code , create new packet.\r
+ // Wrap around record index.\r
//\r
- PacketHeader = CreateMemoryStatusCodePacket (PacketIndex);\r
-\r
- Record = (MEMORY_STATUSCODE_RECORD *) (PacketHeader + 1);\r
- Record = &Record[PacketHeader->RecordIndex++];\r
+ PacketHeader->RecordIndex = 0;\r
+ PacketHeader->PacketIndex ++;\r
}\r
\r
- Record->CodeType = CodeType;\r
- Record->Instance = Instance;\r
- Record->Value = Value;\r
-\r
return EFI_SUCCESS;\r
}\r
\r