TianoCore EDK2 master
Loading...
Searching...
No Matches
MemoryStausCodeWorker.c
Go to the documentation of this file.
1
10
19 VOID
20 )
21{
22 //
23 // Create memory status code GUID'ed HOB.
24 //
26
27 //
28 // Build GUID'ed HOB with PCD defined size.
29 //
30 PacketHeader = BuildGuidHob (
31 &gMemoryStatusCodeRecordGuid,
32 PcdGet16 (PcdStatusCodeMemorySize) * 1024 + sizeof (MEMORY_STATUSCODE_PACKET_HEADER)
33 );
34 ASSERT (PacketHeader != NULL);
35
36 PacketHeader->MaxRecordsNumber = (PcdGet16 (PcdStatusCodeMemorySize) * 1024) / sizeof (MEMORY_STATUSCODE_RECORD);
37 PacketHeader->PacketIndex = 0;
38 PacketHeader->RecordIndex = 0;
39
40 return EFI_SUCCESS;
41}
42
70EFIAPI
72 IN CONST EFI_PEI_SERVICES **PeiServices,
73 IN EFI_STATUS_CODE_TYPE CodeType,
75 IN UINT32 Instance,
76 IN CONST EFI_GUID *CallerId,
77 IN CONST EFI_STATUS_CODE_DATA *Data OPTIONAL
78 )
79{
83
84 //
85 // Find GUID'ed HOBs to locate current record buffer.
86 //
87 Hob.Raw = GetFirstGuidHob (&gMemoryStatusCodeRecordGuid);
88 ASSERT (Hob.Raw != NULL);
89
90 PacketHeader = (MEMORY_STATUSCODE_PACKET_HEADER *)GET_GUID_HOB_DATA (Hob.Guid);
91 Record = (MEMORY_STATUSCODE_RECORD *)(PacketHeader + 1);
92 Record = &Record[PacketHeader->RecordIndex++];
93
94 //
95 // Save status code.
96 //
97 Record->CodeType = CodeType;
98 Record->Instance = Instance;
99 Record->Value = Value;
100
101 //
102 // If record index equals to max record number, then wrap around record index to zero.
103 //
104 // The reader of status code should compare the number of records with max records number,
105 // If it is equal to or larger than the max number, then the wrap-around had happened,
106 // so the first record is pointed by record index.
107 // If it is less then max number, index of the first record is zero.
108 //
109 if (PacketHeader->RecordIndex == PacketHeader->MaxRecordsNumber) {
110 //
111 // Wrap around record index.
112 //
113 PacketHeader->RecordIndex = 0;
114 PacketHeader->PacketIndex++;
115 }
116
117 return EFI_SUCCESS;
118}
VOID *EFIAPI GetFirstGuidHob(IN CONST EFI_GUID *Guid)
Definition: HobLib.c:215
VOID *EFIAPI BuildGuidHob(IN CONST EFI_GUID *Guid, IN UINTN DataLength)
Definition: HobLib.c:336
#define NULL
Definition: Base.h:319
#define CONST
Definition: Base.h:259
#define IN
Definition: Base.h:279
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_STATUS MemoryStatusCodeInitializeWorker(VOID)
#define PcdGet16(TokenName)
Definition: PcdLib.h:349
UINT32 EFI_STATUS_CODE_VALUE
Definition: PiStatusCode.h:67
UINT32 EFI_STATUS_CODE_TYPE
Definition: PiStatusCode.h:24
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
Definition: Base.h:213
EFI_STATUS_CODE_VALUE Value
EFI_STATUS_CODE_TYPE CodeType