2 Status Code Handler Driver which produces general handlers and hook them
3 onto the DXE status code router.
5 Copyright (c) 2006 - 2020, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
10 #include "StatusCodeHandlerRuntimeDxe.h"
12 EFI_EVENT mVirtualAddressChangeEvent
= NULL
;
13 EFI_RSC_HANDLER_PROTOCOL
*mRscHandlerProtocol
= NULL
;
16 Unregister status code callback functions only available at boot time from
17 report status code router when exiting boot services.
22 UnregisterSerialBootTimeHandlers (
26 if (PcdGetBool (PcdStatusCodeUseSerial
)) {
27 mRscHandlerProtocol
->Unregister (SerialStatusCodeReportWorker
);
32 Virtual address change notification call back. It converts global pointer
35 @param Event Event whose notification function is being invoked.
36 @param Context Pointer to the notification function's context, which is
37 always zero in current implementation.
42 VirtualAddressChangeCallBack (
48 // Convert memory status code table to virtual address;
52 (VOID
**)&mRtMemoryStatusCodeTable
57 Dispatch initialization request to sub status code devices based on
58 customized feature flags.
62 InitializationDispatcherWorker (
66 EFI_PEI_HOB_POINTERS Hob
;
68 MEMORY_STATUSCODE_PACKET_HEADER
*PacketHeader
;
69 MEMORY_STATUSCODE_RECORD
*Record
;
71 UINTN MaxRecordNumber
;
74 // If enable UseSerial, then initialize serial port.
75 // if enable UseRuntimeMemory, then initialize runtime memory status code worker.
77 if (PcdGetBool (PcdStatusCodeUseSerial
)) {
79 // Call Serial Port Lib API to initialize serial port.
81 Status
= SerialPortInitialize ();
82 ASSERT_EFI_ERROR (Status
);
85 if (PcdGetBool (PcdStatusCodeUseMemory
)) {
86 Status
= RtMemoryStatusCodeInitializeWorker ();
87 ASSERT_EFI_ERROR (Status
);
91 // Replay Status code which saved in GUID'ed HOB to all supported devices.
93 if (FeaturePcdGet (PcdStatusCodeReplayIn
)) {
95 // Journal GUID'ed HOBs to find all record entry, if found,
96 // then output record to support replay device.
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) {
105 // Record has been wrapped around. So, record number has arrived at max number.
107 MaxRecordNumber
= (UINTN
)PacketHeader
->MaxRecordsNumber
;
110 for (Index
= 0; Index
< MaxRecordNumber
; Index
++) {
112 // Dispatch records to devices based on feature flag.
114 if (PcdGetBool (PcdStatusCodeUseSerial
)) {
115 SerialStatusCodeReportWorker (
116 Record
[Index
].CodeType
,
118 Record
[Index
].Instance
,
124 if (PcdGetBool (PcdStatusCodeUseMemory
)) {
125 RtMemoryStatusCodeReportWorker (
126 Record
[Index
].CodeType
,
128 Record
[Index
].Instance
,
139 Entry point of DXE Status Code Driver.
141 This function is the entry point of this DXE Status Code Driver.
142 It initializes registers status code handlers, and registers event for EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE.
144 @param ImageHandle The firmware allocated handle for the EFI image.
145 @param SystemTable A pointer to the EFI System Table.
147 @retval EFI_SUCCESS The entry point is executed successfully.
152 StatusCodeHandlerRuntimeDxeEntry (
153 IN EFI_HANDLE ImageHandle
,
154 IN EFI_SYSTEM_TABLE
*SystemTable
159 Status
= gBS
->LocateProtocol (
160 &gEfiRscHandlerProtocolGuid
,
162 (VOID
**)&mRscHandlerProtocol
164 ASSERT_EFI_ERROR (Status
);
167 // Dispatch initialization request to supported devices
169 InitializationDispatcherWorker ();
171 if (PcdGetBool (PcdStatusCodeUseSerial
)) {
172 mRscHandlerProtocol
->Register (SerialStatusCodeReportWorker
, TPL_HIGH_LEVEL
);
175 if (PcdGetBool (PcdStatusCodeUseMemory
)) {
176 mRscHandlerProtocol
->Register (RtMemoryStatusCodeReportWorker
, TPL_HIGH_LEVEL
);
179 Status
= gBS
->CreateEventEx (
182 VirtualAddressChangeCallBack
,
184 &gEfiEventVirtualAddressChangeGuid
,
185 &mVirtualAddressChangeEvent
187 ASSERT_EFI_ERROR (Status
);