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
);
84 if (PcdGetBool (PcdStatusCodeUseMemory
)) {
85 Status
= RtMemoryStatusCodeInitializeWorker ();
86 ASSERT_EFI_ERROR (Status
);
90 // Replay Status code which saved in GUID'ed HOB to all supported devices.
92 if (FeaturePcdGet (PcdStatusCodeReplayIn
)) {
94 // Journal GUID'ed HOBs to find all record entry, if found,
95 // then output record to support replay device.
97 Hob
.Raw
= GetFirstGuidHob (&gMemoryStatusCodeRecordGuid
);
98 if (Hob
.Raw
!= NULL
) {
99 PacketHeader
= (MEMORY_STATUSCODE_PACKET_HEADER
*) GET_GUID_HOB_DATA (Hob
.Guid
);
100 Record
= (MEMORY_STATUSCODE_RECORD
*) (PacketHeader
+ 1);
101 MaxRecordNumber
= (UINTN
) PacketHeader
->RecordIndex
;
102 if (PacketHeader
->PacketIndex
> 0) {
104 // Record has been wrapped around. So, record number has arrived at max number.
106 MaxRecordNumber
= (UINTN
) PacketHeader
->MaxRecordsNumber
;
108 for (Index
= 0; Index
< MaxRecordNumber
; Index
++) {
110 // Dispatch records to devices based on feature flag.
112 if (PcdGetBool (PcdStatusCodeUseSerial
)) {
113 SerialStatusCodeReportWorker (
114 Record
[Index
].CodeType
,
116 Record
[Index
].Instance
,
121 if (PcdGetBool (PcdStatusCodeUseMemory
)) {
122 RtMemoryStatusCodeReportWorker (
123 Record
[Index
].CodeType
,
125 Record
[Index
].Instance
,
136 Entry point of DXE Status Code Driver.
138 This function is the entry point of this DXE Status Code Driver.
139 It initializes registers status code handlers, and registers event for EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE.
141 @param ImageHandle The firmware allocated handle for the EFI image.
142 @param SystemTable A pointer to the EFI System Table.
144 @retval EFI_SUCCESS The entry point is executed successfully.
149 StatusCodeHandlerRuntimeDxeEntry (
150 IN EFI_HANDLE ImageHandle
,
151 IN EFI_SYSTEM_TABLE
*SystemTable
156 Status
= gBS
->LocateProtocol (
157 &gEfiRscHandlerProtocolGuid
,
159 (VOID
**) &mRscHandlerProtocol
161 ASSERT_EFI_ERROR (Status
);
164 // Dispatch initialization request to supported devices
166 InitializationDispatcherWorker ();
168 if (PcdGetBool (PcdStatusCodeUseSerial
)) {
169 mRscHandlerProtocol
->Register (SerialStatusCodeReportWorker
, TPL_HIGH_LEVEL
);
171 if (PcdGetBool (PcdStatusCodeUseMemory
)) {
172 mRscHandlerProtocol
->Register (RtMemoryStatusCodeReportWorker
, TPL_HIGH_LEVEL
);
175 Status
= gBS
->CreateEventEx (
178 VirtualAddressChangeCallBack
,
180 &gEfiEventVirtualAddressChangeGuid
,
181 &mVirtualAddressChangeEvent
183 ASSERT_EFI_ERROR (Status
);