/* 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. */
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)
/* 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. */
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;
  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++];
  Record->CodeType = CodeType;
  Record->Instance = Instance;
  Record->Value    = Value;
  if (PacketHeader->RecordIndex == PacketHeader->MaxRecordsNumber) {
    PacketHeader->RecordIndex = 0;
    PacketHeader->PacketIndex++;
  }
  return EFI_SUCCESS;
}