TianoCore EDK2 master
Loading...
Searching...
No Matches
StatusCodeHandlerRuntimeDxe.c
Go to the documentation of this file.
1
11
12EFI_EVENT mVirtualAddressChangeEvent = NULL;
13EFI_RSC_HANDLER_PROTOCOL *mRscHandlerProtocol = NULL;
14
20VOID
21EFIAPI
23 VOID
24 )
25{
26 if (PcdGetBool (PcdStatusCodeUseSerial)) {
27 mRscHandlerProtocol->Unregister (SerialStatusCodeReportWorker);
28 }
29}
30
40VOID
41EFIAPI
43 IN EFI_EVENT Event,
44 IN VOID *Context
45 )
46{
47 //
48 // Convert memory status code table to virtual address;
49 //
51 0,
52 (VOID **)&mRtMemoryStatusCodeTable
53 );
54}
55
61VOID
63 VOID
64 )
65{
67 EFI_STATUS Status;
70 UINTN Index;
71 UINTN MaxRecordNumber;
72
73 //
74 // If enable UseSerial, then initialize serial port.
75 // if enable UseRuntimeMemory, then initialize runtime memory status code worker.
76 //
77 if (PcdGetBool (PcdStatusCodeUseSerial)) {
78 //
79 // Call Serial Port Lib API to initialize serial port.
80 //
81 Status = SerialPortInitialize ();
82 ASSERT_EFI_ERROR (Status);
83 }
84
85 if (PcdGetBool (PcdStatusCodeUseMemory)) {
87 ASSERT_EFI_ERROR (Status);
88 }
89
90 //
91 // Replay Status code which saved in GUID'ed HOB to all supported devices.
92 //
93 if (FeaturePcdGet (PcdStatusCodeReplayIn)) {
94 //
95 // Journal GUID'ed HOBs to find all record entry, if found,
96 // then output record to support replay device.
97 //
98 Hob.Raw = GetFirstGuidHob (&gMemoryStatusCodeRecordGuid);
99 if (Hob.Raw != NULL) {
100 PacketHeader = (MEMORY_STATUSCODE_PACKET_HEADER *)GET_GUID_HOB_DATA (Hob.Guid);
101 Record = (MEMORY_STATUSCODE_RECORD *)(PacketHeader + 1);
102 MaxRecordNumber = (UINTN)PacketHeader->RecordIndex;
103 if (PacketHeader->PacketIndex > 0) {
104 //
105 // Record has been wrapped around. So, record number has arrived at max number.
106 //
107 MaxRecordNumber = (UINTN)PacketHeader->MaxRecordsNumber;
108 }
109
110 for (Index = 0; Index < MaxRecordNumber; Index++) {
111 //
112 // Dispatch records to devices based on feature flag.
113 //
114 if (PcdGetBool (PcdStatusCodeUseSerial)) {
116 Record[Index].CodeType,
117 Record[Index].Value,
118 Record[Index].Instance,
119 NULL,
120 NULL
121 );
122 }
123
124 if (PcdGetBool (PcdStatusCodeUseMemory)) {
126 Record[Index].CodeType,
127 Record[Index].Value,
128 Record[Index].Instance,
129 NULL,
130 NULL
131 );
132 }
133 }
134 }
135 }
136}
137
151EFIAPI
153 IN EFI_HANDLE ImageHandle,
154 IN EFI_SYSTEM_TABLE *SystemTable
155 )
156{
157 EFI_STATUS Status;
158
159 Status = gBS->LocateProtocol (
160 &gEfiRscHandlerProtocolGuid,
161 NULL,
162 (VOID **)&mRscHandlerProtocol
163 );
164 ASSERT_EFI_ERROR (Status);
165
166 //
167 // Dispatch initialization request to supported devices
168 //
170
171 if (PcdGetBool (PcdStatusCodeUseSerial)) {
172 mRscHandlerProtocol->Register (SerialStatusCodeReportWorker, TPL_HIGH_LEVEL);
173 }
174
175 if (PcdGetBool (PcdStatusCodeUseMemory)) {
176 mRscHandlerProtocol->Register (RtMemoryStatusCodeReportWorker, TPL_HIGH_LEVEL);
177 }
178
179 Status = gBS->CreateEventEx (
180 EVT_NOTIFY_SIGNAL,
181 TPL_NOTIFY,
183 NULL,
184 &gEfiEventVirtualAddressChangeGuid,
185 &mVirtualAddressChangeEvent
186 );
187 ASSERT_EFI_ERROR (Status);
188
189 return EFI_SUCCESS;
190}
UINT64 UINTN
RETURN_STATUS EFIAPI SerialPortInitialize(VOID)
Definition: SerialPortLib.c:25
VOID *EFIAPI GetFirstGuidHob(IN CONST EFI_GUID *Guid)
Definition: HobLib.c:215
#define NULL
Definition: Base.h:319
#define IN
Definition: Base.h:279
#define ASSERT_EFI_ERROR(StatusParameter)
Definition: DebugLib.h:462
#define PcdGetBool(TokenName)
Definition: PcdLib.h:401
#define FeaturePcdGet(TokenName)
Definition: PcdLib.h:50
EFI_STATUS EFIAPI SerialStatusCodeReportWorker(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 EFIAPI RtMemoryStatusCodeReportWorker(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 RtMemoryStatusCodeInitializeWorker(VOID)
VOID EFIAPI VirtualAddressChangeCallBack(IN EFI_EVENT Event, IN VOID *Context)
VOID InitializationDispatcherWorker(VOID)
VOID EFIAPI UnregisterSerialBootTimeHandlers(VOID)
EFI_STATUS EFIAPI StatusCodeHandlerRuntimeDxeEntry(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_EVENT
Definition: UefiBaseType.h:37
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
EFI_BOOT_SERVICES * gBS
EFI_STATUS EFIAPI EfiConvertPointer(IN UINTN DebugDisposition, IN OUT VOID **Address)
Definition: RuntimeLib.c:561