X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=IntelFrameworkModulePkg%2FUniversal%2FStatusCode%2FPei%2FMemoryStausCodeWorker.c;h=f0b36f23a20ddfce066ff9916eb39a633554ea8f;hp=e767e6b147d2469890e4c2e9b818165542c3d561;hb=c945216e70ce93c2c1166bc286624aeff591eff1;hpb=be63a20a025d5a7b792bf6ff33b91d22323e19d8 diff --git a/IntelFrameworkModulePkg/Universal/StatusCode/Pei/MemoryStausCodeWorker.c b/IntelFrameworkModulePkg/Universal/StatusCode/Pei/MemoryStausCodeWorker.c index e767e6b147..f0b36f23a2 100644 --- a/IntelFrameworkModulePkg/Universal/StatusCode/Pei/MemoryStausCodeWorker.c +++ b/IntelFrameworkModulePkg/Universal/StatusCode/Pei/MemoryStausCodeWorker.c @@ -1,7 +1,7 @@ /** @file PEI memory status code worker. - Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.
+ Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -15,19 +15,19 @@ #include "StatusCodePei.h" /** - Worker function to create one memory status code GUID'ed HOB, - using PacketIndex to identify the packet. - - @param PacketIndex Index of records packet. + Create the first memory status code GUID'ed HOB as initialization for memory status code worker. - @return Pointer to the memory status code packet. + @retval EFI_SUCCESS The GUID'ed HOB is created successfully. **/ -MEMORY_STATUSCODE_PACKET_HEADER * -CreateMemoryStatusCodePacket ( - UINT16 PacketIndex +EFI_STATUS +MemoryStatusCodeInitializeWorker ( + VOID ) { + // + // Create memory status code GUID'ed HOB. + // MEMORY_STATUSCODE_PACKET_HEADER *PacketHeader; // @@ -40,28 +40,9 @@ CreateMemoryStatusCodePacket ( ASSERT (PacketHeader != NULL); PacketHeader->MaxRecordsNumber = (PcdGet16 (PcdStatusCodeMemorySize) * 1024) / sizeof (MEMORY_STATUSCODE_RECORD); - PacketHeader->PacketIndex = PacketIndex; + PacketHeader->PacketIndex = 0; PacketHeader->RecordIndex = 0; - return PacketHeader; -} - -/** - 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 first memory status code GUID'ed HOB. - // - CreateMemoryStatusCodePacket (0); - return EFI_SUCCESS; } @@ -98,49 +79,40 @@ MemoryStatusCodeReportWorker ( EFI_PEI_HOB_POINTERS Hob; MEMORY_STATUSCODE_PACKET_HEADER *PacketHeader; MEMORY_STATUSCODE_RECORD *Record; - UINT16 PacketIndex; - - Record = NULL; - PacketIndex = 0; // - // Journal GUID'ed HOBs to find empty record entry. if found, then save status code in it. - // otherwise, create a new GUID'ed HOB. + // Find GUID'ed HOBs to locate current record buffer. // Hob.Raw = GetFirstGuidHob (&gMemoryStatusCodeRecordGuid); - while (Hob.Raw != NULL) { - PacketHeader = (MEMORY_STATUSCODE_PACKET_HEADER *) GET_GUID_HOB_DATA (Hob.Guid); + ASSERT (Hob.Raw != NULL); - // - // Check whether pccket is full or not. - // - if (PacketHeader->RecordIndex < PacketHeader->MaxRecordsNumber) { - Record = (MEMORY_STATUSCODE_RECORD *) (PacketHeader + 1); - Record = &Record[PacketHeader->RecordIndex++]; - break; - } - // - // Cache number of found packet in PacketIndex. - // - PacketIndex++; + PacketHeader = (MEMORY_STATUSCODE_PACKET_HEADER *) GET_GUID_HOB_DATA (Hob.Guid); + Record = (MEMORY_STATUSCODE_RECORD *) (PacketHeader + 1); + Record = &Record[PacketHeader->RecordIndex++]; - Hob.Raw = GetNextGuidHob (&gMemoryStatusCodeRecordGuid, Hob.Raw); - } + // + // Save status code. + // + Record->CodeType = CodeType; + Record->Instance = Instance; + Record->Value = Value; - if (Record == NULL) { + // + // 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) { // - // No available entry found, so create new packet. + // Wrap around record index. // - PacketHeader = CreateMemoryStatusCodePacket (PacketIndex); - - Record = (MEMORY_STATUSCODE_RECORD *) (PacketHeader + 1); - Record = &Record[PacketHeader->RecordIndex++]; + PacketHeader->RecordIndex = 0; + PacketHeader->PacketIndex ++; } - Record->CodeType = CodeType; - Record->Instance = Instance; - Record->Value = Value; - return EFI_SUCCESS; }