2 Status Code Handler Driver which produces general handlers and hook them
3 onto the DXE status code router.
5 Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
10 #include "StatusCodeHandlerRuntimeDxe.h"
12 EFI_EVENT mVirtualAddressChangeEvent
= NULL
;
13 static EFI_EVENT mExitBootServicesEvent
= NULL
;
14 EFI_RSC_HANDLER_PROTOCOL
*mRscHandlerProtocol
= NULL
;
17 Unregister status code callback functions only available at boot time from
18 report status code router when exiting boot services.
20 @param Event Event whose notification function is being invoked.
21 @param Context Pointer to the notification function's context, which is
22 always zero in current implementation.
27 UnregisterBootTimeHandlers (
32 if (FeaturePcdGet (PcdStatusCodeUseSerial
)) {
33 mRscHandlerProtocol
->Unregister (SerialStatusCodeReportWorker
);
38 Virtual address change notification call back. It converts global pointer
41 @param Event Event whose notification function is being invoked.
42 @param Context Pointer to the notification function's context, which is
43 always zero in current implementation.
48 VirtualAddressChangeCallBack (
54 // Convert memory status code table to virtual address;
58 (VOID
**) &mRtMemoryStatusCodeTable
63 Dispatch initialization request to sub status code devices based on
64 customized feature flags.
68 InitializationDispatcherWorker (
72 EFI_PEI_HOB_POINTERS Hob
;
74 MEMORY_STATUSCODE_PACKET_HEADER
*PacketHeader
;
75 MEMORY_STATUSCODE_RECORD
*Record
;
77 UINTN MaxRecordNumber
;
80 // If enable UseSerial, then initialize serial port.
81 // if enable UseRuntimeMemory, then initialize runtime memory status code worker.
83 if (FeaturePcdGet (PcdStatusCodeUseSerial
)) {
85 // Call Serial Port Lib API to initialize serial port.
87 Status
= SerialPortInitialize ();
88 ASSERT_EFI_ERROR (Status
);
90 if (FeaturePcdGet (PcdStatusCodeUseMemory
)) {
91 Status
= RtMemoryStatusCodeInitializeWorker ();
92 ASSERT_EFI_ERROR (Status
);
96 // Replay Status code which saved in GUID'ed HOB to all supported devices.
98 if (FeaturePcdGet (PcdStatusCodeReplayIn
)) {
100 // Journal GUID'ed HOBs to find all record entry, if found,
101 // then output record to support replay device.
103 Hob
.Raw
= GetFirstGuidHob (&gMemoryStatusCodeRecordGuid
);
104 if (Hob
.Raw
!= NULL
) {
105 PacketHeader
= (MEMORY_STATUSCODE_PACKET_HEADER
*) GET_GUID_HOB_DATA (Hob
.Guid
);
106 Record
= (MEMORY_STATUSCODE_RECORD
*) (PacketHeader
+ 1);
107 MaxRecordNumber
= (UINTN
) PacketHeader
->RecordIndex
;
108 if (PacketHeader
->PacketIndex
> 0) {
110 // Record has been wrapped around. So, record number has arrived at max number.
112 MaxRecordNumber
= (UINTN
) PacketHeader
->MaxRecordsNumber
;
114 for (Index
= 0; Index
< MaxRecordNumber
; Index
++) {
116 // Dispatch records to devices based on feature flag.
118 if (FeaturePcdGet (PcdStatusCodeUseSerial
)) {
119 SerialStatusCodeReportWorker (
120 Record
[Index
].CodeType
,
122 Record
[Index
].Instance
,
127 if (FeaturePcdGet (PcdStatusCodeUseMemory
)) {
128 RtMemoryStatusCodeReportWorker (
129 Record
[Index
].CodeType
,
131 Record
[Index
].Instance
,
142 Entry point of DXE Status Code Driver.
144 This function is the entry point of this DXE Status Code Driver.
145 It initializes registers status code handlers, and registers event for EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE.
147 @param ImageHandle The firmware allocated handle for the EFI image.
148 @param SystemTable A pointer to the EFI System Table.
150 @retval EFI_SUCCESS The entry point is executed successfully.
155 StatusCodeHandlerRuntimeDxeEntry (
156 IN EFI_HANDLE ImageHandle
,
157 IN EFI_SYSTEM_TABLE
*SystemTable
162 Status
= gBS
->LocateProtocol (
163 &gEfiRscHandlerProtocolGuid
,
165 (VOID
**) &mRscHandlerProtocol
167 ASSERT_EFI_ERROR (Status
);
170 // Dispatch initialization request to supported devices
172 InitializationDispatcherWorker ();
174 if (FeaturePcdGet (PcdStatusCodeUseSerial
)) {
175 mRscHandlerProtocol
->Register (SerialStatusCodeReportWorker
, TPL_HIGH_LEVEL
);
177 if (FeaturePcdGet (PcdStatusCodeUseMemory
)) {
178 mRscHandlerProtocol
->Register (RtMemoryStatusCodeReportWorker
, TPL_HIGH_LEVEL
);
181 Status
= gBS
->CreateEventEx (
184 UnregisterBootTimeHandlers
,
186 &gEfiEventExitBootServicesGuid
,
187 &mExitBootServicesEvent
190 Status
= gBS
->CreateEventEx (
193 VirtualAddressChangeCallBack
,
195 &gEfiEventVirtualAddressChangeGuid
,
196 &mVirtualAddressChangeEvent
198 ASSERT_EFI_ERROR (Status
);