TianoCore EDK2 master
Loading...
Searching...
No Matches
MemoryStatusCodeWorker.c
Go to the documentation of this file.
1
10#include "StatusCodeHandlerMm.h"
11
12RUNTIME_MEMORY_STATUSCODE_HEADER *mMmMemoryStatusCodeTable;
13
22 VOID
23 )
24{
25 EFI_STATUS Status;
26
27 //
28 // Allocate MM memory status code pool.
29 //
30 mMmMemoryStatusCodeTable = (RUNTIME_MEMORY_STATUSCODE_HEADER *)AllocateZeroPool (sizeof (RUNTIME_MEMORY_STATUSCODE_HEADER) + PcdGet16 (PcdStatusCodeMemorySize) * 1024);
31 ASSERT (mMmMemoryStatusCodeTable != NULL);
32
33 mMmMemoryStatusCodeTable->MaxRecordsNumber = (PcdGet16 (PcdStatusCodeMemorySize) * 1024) / sizeof (MEMORY_STATUSCODE_RECORD);
34 Status = gMmst->MmInstallConfigurationTable (
35 gMmst,
36 &gMemoryStatusCodeRecordGuid,
37 &mMmMemoryStatusCodeTable,
38 sizeof (mMmMemoryStatusCodeTable)
39 );
40 return Status;
41}
42
62EFIAPI
64 IN EFI_STATUS_CODE_TYPE CodeType,
66 IN UINT32 Instance,
67 IN EFI_GUID *CallerId,
68 IN EFI_STATUS_CODE_DATA *Data OPTIONAL
69 )
70{
72
73 //
74 // Locate current record buffer.
75 //
76 Record = (MEMORY_STATUSCODE_RECORD *)(mMmMemoryStatusCodeTable + 1);
77 Record = &Record[mMmMemoryStatusCodeTable->RecordIndex++];
78
79 //
80 // Save status code.
81 //
82 Record->CodeType = CodeType;
83 Record->Value = Value;
84 Record->Instance = Instance;
85
86 //
87 // If record index equals to max record number, then wrap around record index to zero.
88 //
89 // The reader of status code should compare the number of records with max records number,
90 // If it is equal to or larger than the max number, then the wrap-around had happened,
91 // so the first record is pointed by record index.
92 // If it is less then max number, index of the first record is zero.
93 //
94 mMmMemoryStatusCodeTable->NumberOfRecords++;
95 if (mMmMemoryStatusCodeTable->RecordIndex == mMmMemoryStatusCodeTable->MaxRecordsNumber) {
96 //
97 // Wrap around record index.
98 //
99 mMmMemoryStatusCodeTable->RecordIndex = 0;
100 }
101
102 return EFI_SUCCESS;
103}
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
#define NULL
Definition: Base.h:319
#define IN
Definition: Base.h:279
#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
EFI_STATUS EFIAPI MemoryStatusCodeReportWorker(IN EFI_STATUS_CODE_TYPE CodeType, IN EFI_STATUS_CODE_VALUE Value, IN UINT32 Instance, IN EFI_GUID *CallerId, IN EFI_STATUS_CODE_DATA *Data OPTIONAL)
EFI_STATUS MemoryStatusCodeInitializeWorker(VOID)
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