]>
Commit | Line | Data |
---|---|---|
3af9b388 | 1 | /** @file\r |
2 | Status Code Handler Driver which produces general handlers and hook them\r | |
3 | onto the DXE status code router.\r | |
4 | \r | |
d1102dba | 5 | Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r |
e5eed7d3 | 6 | This program and the accompanying materials\r |
3af9b388 | 7 | are licensed and made available under the terms and conditions of the BSD License\r |
8 | which accompanies this distribution. The full text of the license may be found at\r | |
9 | http://opensource.org/licenses/bsd-license.php\r | |
10 | \r | |
11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
12 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
13 | \r | |
14 | **/\r | |
15 | \r | |
16 | #include "StatusCodeHandlerRuntimeDxe.h"\r | |
17 | \r | |
18 | EFI_EVENT mVirtualAddressChangeEvent = NULL;\r | |
19 | EFI_EVENT mExitBootServicesEvent = NULL;\r | |
20 | EFI_RSC_HANDLER_PROTOCOL *mRscHandlerProtocol = NULL;\r | |
21 | \r | |
22 | /**\r | |
23 | Unregister status code callback functions only available at boot time from\r | |
24 | report status code router when exiting boot services.\r | |
25 | \r | |
26 | @param Event Event whose notification function is being invoked.\r | |
27 | @param Context Pointer to the notification function's context, which is\r | |
28 | always zero in current implementation.\r | |
29 | \r | |
30 | **/\r | |
31 | VOID\r | |
32 | EFIAPI\r | |
33 | UnregisterBootTimeHandlers (\r | |
34 | IN EFI_EVENT Event,\r | |
35 | IN VOID *Context\r | |
36 | )\r | |
37 | {\r | |
38 | if (FeaturePcdGet (PcdStatusCodeUseSerial)) {\r | |
39 | mRscHandlerProtocol->Unregister (SerialStatusCodeReportWorker);\r | |
40 | }\r | |
41 | }\r | |
42 | \r | |
43 | /**\r | |
44 | Virtual address change notification call back. It converts global pointer\r | |
45 | to virtual address.\r | |
46 | \r | |
47 | @param Event Event whose notification function is being invoked.\r | |
48 | @param Context Pointer to the notification function's context, which is\r | |
49 | always zero in current implementation.\r | |
50 | \r | |
51 | **/\r | |
52 | VOID\r | |
53 | EFIAPI\r | |
54 | VirtualAddressChangeCallBack (\r | |
55 | IN EFI_EVENT Event,\r | |
56 | IN VOID *Context\r | |
57 | )\r | |
58 | {\r | |
59 | //\r | |
60 | // Convert memory status code table to virtual address;\r | |
61 | //\r | |
62 | EfiConvertPointer (\r | |
63 | 0,\r | |
64 | (VOID **) &mRtMemoryStatusCodeTable\r | |
65 | );\r | |
66 | }\r | |
67 | \r | |
68 | /**\r | |
d1102dba | 69 | Dispatch initialization request to sub status code devices based on\r |
3af9b388 | 70 | customized feature flags.\r |
d1102dba | 71 | \r |
3af9b388 | 72 | **/\r |
73 | VOID\r | |
74 | InitializationDispatcherWorker (\r | |
75 | VOID\r | |
76 | )\r | |
77 | {\r | |
78 | EFI_PEI_HOB_POINTERS Hob;\r | |
79 | EFI_STATUS Status;\r | |
80 | MEMORY_STATUSCODE_PACKET_HEADER *PacketHeader;\r | |
81 | MEMORY_STATUSCODE_RECORD *Record;\r | |
3af9b388 | 82 | UINTN Index;\r |
be63a20a | 83 | UINTN MaxRecordNumber;\r |
3af9b388 | 84 | \r |
85 | //\r | |
86 | // If enable UseSerial, then initialize serial port.\r | |
87 | // if enable UseRuntimeMemory, then initialize runtime memory status code worker.\r | |
88 | //\r | |
89 | if (FeaturePcdGet (PcdStatusCodeUseSerial)) {\r | |
90 | //\r | |
91 | // Call Serial Port Lib API to initialize serial port.\r | |
92 | //\r | |
93 | Status = SerialPortInitialize ();\r | |
94 | ASSERT_EFI_ERROR (Status);\r | |
95 | }\r | |
96 | if (FeaturePcdGet (PcdStatusCodeUseMemory)) {\r | |
97 | Status = RtMemoryStatusCodeInitializeWorker ();\r | |
98 | ASSERT_EFI_ERROR (Status);\r | |
99 | }\r | |
100 | \r | |
101 | //\r | |
d1102dba | 102 | // Replay Status code which saved in GUID'ed HOB to all supported devices.\r |
3af9b388 | 103 | //\r |
104 | if (FeaturePcdGet (PcdStatusCodeReplayIn)) {\r | |
d1102dba LG |
105 | //\r |
106 | // Journal GUID'ed HOBs to find all record entry, if found,\r | |
3af9b388 | 107 | // then output record to support replay device.\r |
108 | //\r | |
3af9b388 | 109 | Hob.Raw = GetFirstGuidHob (&gMemoryStatusCodeRecordGuid);\r |
be63a20a | 110 | if (Hob.Raw != NULL) {\r |
3af9b388 | 111 | PacketHeader = (MEMORY_STATUSCODE_PACKET_HEADER *) GET_GUID_HOB_DATA (Hob.Guid);\r |
be63a20a LG |
112 | Record = (MEMORY_STATUSCODE_RECORD *) (PacketHeader + 1);\r |
113 | MaxRecordNumber = (UINTN) PacketHeader->RecordIndex;\r | |
114 | if (PacketHeader->PacketIndex > 0) {\r | |
3af9b388 | 115 | //\r |
be63a20a | 116 | // Record has been wrapped around. So, record number has arrived at max number.\r |
3af9b388 | 117 | //\r |
be63a20a LG |
118 | MaxRecordNumber = (UINTN) PacketHeader->MaxRecordsNumber;\r |
119 | }\r | |
120 | for (Index = 0; Index < MaxRecordNumber; Index++) {\r | |
3af9b388 | 121 | //\r |
be63a20a | 122 | // Dispatch records to devices based on feature flag.\r |
3af9b388 | 123 | //\r |
be63a20a LG |
124 | if (FeaturePcdGet (PcdStatusCodeUseSerial)) {\r |
125 | SerialStatusCodeReportWorker (\r | |
126 | Record[Index].CodeType,\r | |
127 | Record[Index].Value,\r | |
128 | Record[Index].Instance,\r | |
129 | NULL,\r | |
130 | NULL\r | |
131 | );\r | |
132 | }\r | |
133 | if (FeaturePcdGet (PcdStatusCodeUseMemory)) {\r | |
134 | RtMemoryStatusCodeReportWorker (\r | |
135 | Record[Index].CodeType,\r | |
136 | Record[Index].Value,\r | |
137 | Record[Index].Instance,\r | |
138 | NULL,\r | |
139 | NULL\r | |
140 | );\r | |
141 | }\r | |
3af9b388 | 142 | }\r |
3af9b388 | 143 | }\r |
144 | }\r | |
145 | }\r | |
146 | \r | |
147 | /**\r | |
148 | Entry point of DXE Status Code Driver.\r | |
149 | \r | |
150 | This function is the entry point of this DXE Status Code Driver.\r | |
151 | It initializes registers status code handlers, and registers event for EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE.\r | |
152 | \r | |
153 | @param ImageHandle The firmware allocated handle for the EFI image.\r | |
154 | @param SystemTable A pointer to the EFI System Table.\r | |
d1102dba | 155 | \r |
3af9b388 | 156 | @retval EFI_SUCCESS The entry point is executed successfully.\r |
157 | \r | |
158 | **/\r | |
159 | EFI_STATUS\r | |
160 | EFIAPI\r | |
161 | StatusCodeHandlerRuntimeDxeEntry (\r | |
162 | IN EFI_HANDLE ImageHandle,\r | |
163 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
164 | )\r | |
165 | {\r | |
166 | EFI_STATUS Status;\r | |
167 | \r | |
168 | Status = gBS->LocateProtocol (\r | |
169 | &gEfiRscHandlerProtocolGuid,\r | |
170 | NULL,\r | |
171 | (VOID **) &mRscHandlerProtocol\r | |
172 | );\r | |
173 | ASSERT_EFI_ERROR (Status);\r | |
174 | \r | |
175 | //\r | |
176 | // Dispatch initialization request to supported devices\r | |
177 | //\r | |
178 | InitializationDispatcherWorker ();\r | |
179 | \r | |
180 | if (FeaturePcdGet (PcdStatusCodeUseSerial)) {\r | |
181 | mRscHandlerProtocol->Register (SerialStatusCodeReportWorker, TPL_HIGH_LEVEL);\r | |
182 | }\r | |
183 | if (FeaturePcdGet (PcdStatusCodeUseMemory)) {\r | |
184 | mRscHandlerProtocol->Register (RtMemoryStatusCodeReportWorker, TPL_HIGH_LEVEL);\r | |
185 | }\r | |
186 | \r | |
187 | Status = gBS->CreateEventEx (\r | |
188 | EVT_NOTIFY_SIGNAL,\r | |
189 | TPL_NOTIFY,\r | |
190 | UnregisterBootTimeHandlers,\r | |
191 | NULL,\r | |
192 | &gEfiEventExitBootServicesGuid,\r | |
193 | &mExitBootServicesEvent\r | |
194 | );\r | |
195 | \r | |
196 | Status = gBS->CreateEventEx (\r | |
197 | EVT_NOTIFY_SIGNAL,\r | |
198 | TPL_NOTIFY,\r | |
199 | VirtualAddressChangeCallBack,\r | |
200 | NULL,\r | |
201 | &gEfiEventVirtualAddressChangeGuid,\r | |
202 | &mVirtualAddressChangeEvent\r | |
203 | );\r | |
204 | ASSERT_EFI_ERROR (Status);\r | |
205 | \r | |
206 | return EFI_SUCCESS;\r | |
207 | }\r |