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
;
83 UINTN MaxRecordNumber
;
86 // If enable UseSerial, then initialize serial port.
87 // if enable UseRuntimeMemory, then initialize runtime memory status code worker.
89 if (FeaturePcdGet (PcdStatusCodeUseSerial
)) {
91 // Call Serial Port Lib API to initialize serial port.
93 Status
= SerialPortInitialize ();
94 ASSERT_EFI_ERROR (Status
);
96 if (FeaturePcdGet (PcdStatusCodeUseMemory
)) {
97 Status
= RtMemoryStatusCodeInitializeWorker ();
98 ASSERT_EFI_ERROR (Status
);
102 // Replay Status code which saved in GUID'ed HOB to all supported devices.
104 if (FeaturePcdGet (PcdStatusCodeReplayIn
)) {
106 // Journal GUID'ed HOBs to find all record entry, if found,
107 // then output record to support replay device.
109 Hob
.Raw
= GetFirstGuidHob (&gMemoryStatusCodeRecordGuid
);
110 if (Hob
.Raw
!= NULL
) {
111 PacketHeader
= (MEMORY_STATUSCODE_PACKET_HEADER
*) GET_GUID_HOB_DATA (Hob
.Guid
);
112 Record
= (MEMORY_STATUSCODE_RECORD
*) (PacketHeader
+ 1);
113 MaxRecordNumber
= (UINTN
) PacketHeader
->RecordIndex
;
114 if (PacketHeader
->PacketIndex
> 0) {
116 // Record has been wrapped around. So, record number has arrived at max number.
118 MaxRecordNumber
= (UINTN
) PacketHeader
->MaxRecordsNumber
;
120 for (Index
= 0; Index
< MaxRecordNumber
; Index
++) {
122 // Dispatch records to devices based on feature flag.
124 if (FeaturePcdGet (PcdStatusCodeUseSerial
)) {
125 SerialStatusCodeReportWorker (
126 Record
[Index
].CodeType
,
128 Record
[Index
].Instance
,
133 if (FeaturePcdGet (PcdStatusCodeUseMemory
)) {
134 RtMemoryStatusCodeReportWorker (
135 Record
[Index
].CodeType
,
137 Record
[Index
].Instance
,
148 Entry point of DXE Status Code Driver.
150 This function is the entry point of this DXE Status Code Driver.
151 It initializes registers status code handlers, and registers event for EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE.
153 @param ImageHandle The firmware allocated handle for the EFI image.
154 @param SystemTable A pointer to the EFI System Table.
156 @retval EFI_SUCCESS The entry point is executed successfully.
161 StatusCodeHandlerRuntimeDxeEntry (
162 IN EFI_HANDLE ImageHandle
,
163 IN EFI_SYSTEM_TABLE
*SystemTable
168 Status
= gBS
->LocateProtocol (
169 &gEfiRscHandlerProtocolGuid
,
171 (VOID
**) &mRscHandlerProtocol
173 ASSERT_EFI_ERROR (Status
);
176 // Dispatch initialization request to supported devices
178 InitializationDispatcherWorker ();
180 if (FeaturePcdGet (PcdStatusCodeUseSerial
)) {
181 mRscHandlerProtocol
->Register (SerialStatusCodeReportWorker
, TPL_HIGH_LEVEL
);
183 if (FeaturePcdGet (PcdStatusCodeUseMemory
)) {
184 mRscHandlerProtocol
->Register (RtMemoryStatusCodeReportWorker
, TPL_HIGH_LEVEL
);
187 Status
= gBS
->CreateEventEx (
190 UnregisterBootTimeHandlers
,
192 &gEfiEventExitBootServicesGuid
,
193 &mExitBootServicesEvent
196 Status
= gBS
->CreateEventEx (
199 VirtualAddressChangeCallBack
,
201 &gEfiEventVirtualAddressChangeGuid
,
202 &mVirtualAddressChangeEvent
204 ASSERT_EFI_ERROR (Status
);