2 Status Code Handler Driver which produces general handlers and hook them
3 onto the DXE status code router.
5 Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #include "StatusCodeHandlerRuntimeDxe.h"
18 EFI_EVENT mVirtualAddressChangeEvent
= NULL
;
19 EFI_EVENT mExitBootServicesEvent
= NULL
;
20 EFI_RSC_HANDLER_PROTOCOL
*mRscHandlerProtocol
= NULL
;
23 Unregister status code callback functions only available at boot time from
24 report status code router when exiting boot services.
26 @param Event Event whose notification function is being invoked.
27 @param Context Pointer to the notification function's context, which is
28 always zero in current implementation.
33 UnregisterBootTimeHandlers (
38 if (FeaturePcdGet (PcdStatusCodeUseSerial
)) {
39 mRscHandlerProtocol
->Unregister (SerialStatusCodeReportWorker
);
44 Virtual address change notification call back. It converts global pointer
47 @param Event Event whose notification function is being invoked.
48 @param Context Pointer to the notification function's context, which is
49 always zero in current implementation.
54 VirtualAddressChangeCallBack (
60 // Convert memory status code table to virtual address;
64 (VOID
**) &mRtMemoryStatusCodeTable
69 Dispatch initialization request to sub status code devices based on
70 customized feature flags.
74 InitializationDispatcherWorker (
78 EFI_PEI_HOB_POINTERS Hob
;
80 MEMORY_STATUSCODE_PACKET_HEADER
*PacketHeader
;
81 MEMORY_STATUSCODE_RECORD
*Record
;
82 UINTN ExpectedPacketIndex
;
87 // If enable UseSerial, then initialize serial port.
88 // if enable UseRuntimeMemory, then initialize runtime memory status code worker.
90 if (FeaturePcdGet (PcdStatusCodeUseSerial
)) {
92 // Call Serial Port Lib API to initialize serial port.
94 Status
= SerialPortInitialize ();
95 ASSERT_EFI_ERROR (Status
);
97 if (FeaturePcdGet (PcdStatusCodeUseMemory
)) {
98 Status
= RtMemoryStatusCodeInitializeWorker ();
99 ASSERT_EFI_ERROR (Status
);
103 // Replay Status code which saved in GUID'ed HOB to all supported devices.
105 if (FeaturePcdGet (PcdStatusCodeReplayIn
)) {
107 // Journal GUID'ed HOBs to find all record entry, if found,
108 // then output record to support replay device.
110 ExpectedPacketIndex
= 0;
111 Hob
.Raw
= GetFirstGuidHob (&gMemoryStatusCodeRecordGuid
);
113 while (Hob
.Raw
!= NULL
) {
114 PacketHeader
= (MEMORY_STATUSCODE_PACKET_HEADER
*) GET_GUID_HOB_DATA (Hob
.Guid
);
115 if (PacketHeader
->PacketIndex
== ExpectedPacketIndex
) {
116 Record
= (MEMORY_STATUSCODE_RECORD
*) (PacketHeader
+ 1);
117 for (Index
= 0; Index
< PacketHeader
->RecordIndex
; Index
++) {
119 // Dispatch records to devices based on feature flag.
121 if (FeaturePcdGet (PcdStatusCodeUseSerial
)) {
122 SerialStatusCodeReportWorker (
123 Record
[Index
].CodeType
,
125 Record
[Index
].Instance
,
130 if (FeaturePcdGet (PcdStatusCodeUseMemory
)) {
131 RtMemoryStatusCodeReportWorker (
132 Record
[Index
].CodeType
,
134 Record
[Index
].Instance
,
140 ExpectedPacketIndex
++;
143 // See whether there is gap of packet or not
145 if (HobStart
!= NULL
) {
150 } else if (HobStart
!= NULL
) {
152 // Cache the found packet for improve the performance
157 Hob
.Raw
= GetNextGuidHob (&gMemoryStatusCodeRecordGuid
, Hob
.Raw
);
163 Entry point of DXE Status Code Driver.
165 This function is the entry point of this DXE Status Code Driver.
166 It initializes registers status code handlers, and registers event for EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE.
168 @param ImageHandle The firmware allocated handle for the EFI image.
169 @param SystemTable A pointer to the EFI System Table.
171 @retval EFI_SUCCESS The entry point is executed successfully.
176 StatusCodeHandlerRuntimeDxeEntry (
177 IN EFI_HANDLE ImageHandle
,
178 IN EFI_SYSTEM_TABLE
*SystemTable
183 Status
= gBS
->LocateProtocol (
184 &gEfiRscHandlerProtocolGuid
,
186 (VOID
**) &mRscHandlerProtocol
188 ASSERT_EFI_ERROR (Status
);
191 // Dispatch initialization request to supported devices
193 InitializationDispatcherWorker ();
195 if (FeaturePcdGet (PcdStatusCodeUseSerial
)) {
196 mRscHandlerProtocol
->Register (SerialStatusCodeReportWorker
, TPL_HIGH_LEVEL
);
198 if (FeaturePcdGet (PcdStatusCodeUseMemory
)) {
199 mRscHandlerProtocol
->Register (RtMemoryStatusCodeReportWorker
, TPL_HIGH_LEVEL
);
202 Status
= gBS
->CreateEventEx (
205 UnregisterBootTimeHandlers
,
207 &gEfiEventExitBootServicesGuid
,
208 &mExitBootServicesEvent
211 Status
= gBS
->CreateEventEx (
214 VirtualAddressChangeCallBack
,
216 &gEfiEventVirtualAddressChangeGuid
,
217 &mVirtualAddressChangeEvent
219 ASSERT_EFI_ERROR (Status
);