]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | * Status code driver for IPF architecture.\r | |
3 | \r | |
4 | Copyright (c) 2006, Intel Corporation\r | |
5 | All rights reserved. This program and the accompanying materials\r | |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
13 | Module Name: DxeStatusCodeIpf.c\r | |
14 | \r | |
15 | **/\r | |
16 | \r | |
17 | #include "DxeStatusCode.h"\r | |
18 | \r | |
19 | \r | |
20 | /**\r | |
21 | Report status code to all supported device.\r | |
22 | Calls into the workers which dispatches the platform specific\r | |
23 | listeners.\r | |
24 | \r | |
25 | @param Type Indicates the type of status code being reported.\r | |
26 | The type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.\r | |
27 | @param Value Describes the current status of a hardware or software entity.\r | |
28 | This includes information about the class and subclass that is used to classify the entity\r | |
29 | as well as an operation. For progress codes, the operation is the current activity.\r | |
30 | For error codes, it is the exception. For debug codes, it is not defined at this time.\r | |
31 | Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.\r | |
32 | Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.\r | |
33 | @param Instance The enumeration of a hardware or software entity within the system.\r | |
34 | A system may contain multiple entities that match a class/subclass pairing.\r | |
35 | The instance differentiates between them. An instance of 0 indicates that instance\r | |
36 | information is unavailable, not meaningful, or not relevant. Valid instance numbers start with 1.\r | |
37 | @param CallerId This optional parameter may be used to identify the caller.\r | |
38 | This parameter allows the status code driver to apply different rules to different callers.\r | |
39 | @param Data This optional parameter may be used to pass additional data.\r | |
40 | Type EFI_STATUS_CODE_DATA is defined in "Related Definitions" below.\r | |
41 | The contents of this data type may have additional GUID-specific data. The standard GUIDs and\r | |
42 | their associated data structures are defined in the Intel? Platform Innovation Framework for EFI Status Codes Specification.\r | |
43 | \r | |
44 | @return Always return EFI_SUCCESS.\r | |
45 | \r | |
46 | **/\r | |
47 | EFI_STATUS\r | |
48 | EFIAPI\r | |
49 | ReportDispatcher (\r | |
50 | IN EFI_STATUS_CODE_TYPE Type,\r | |
51 | IN EFI_STATUS_CODE_VALUE Value,\r | |
52 | IN UINT32 Instance,\r | |
53 | IN EFI_GUID *CallerId OPTIONAL,\r | |
54 | IN EFI_STATUS_CODE_DATA *Data OPTIONAL\r | |
55 | );\r | |
56 | \r | |
57 | //\r | |
58 | // Declaration of status code protocol.\r | |
59 | //\r | |
60 | STATIC\r | |
61 | EFI_STATUS_CODE_PROTOCOL mEfiStatusCodeProtocol = {\r | |
62 | ReportDispatcher\r | |
63 | };\r | |
64 | \r | |
65 | //\r | |
66 | // Delaration of DXE status code controller\r | |
67 | //\r | |
68 | DXE_STATUS_CODE_CONTROLLER gDxeStatusCode = {\r | |
69 | //\r | |
70 | // Initialize nest status as non nested.\r | |
71 | //\r | |
72 | 0,\r | |
73 | {NULL, NULL}\r | |
74 | };\r | |
75 | \r | |
76 | /**\r | |
77 | Report status code to all supported device.\r | |
78 | Calls into the workers which dispatches the platform specific\r | |
79 | listeners.\r | |
80 | \r | |
81 | @param CodeType Indicates the type of status code being reported.\r | |
82 | The type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.\r | |
83 | @param Value Describes the current status of a hardware or software entity.\r | |
84 | This includes information about the class and subclass that is used to classify the entity\r | |
85 | as well as an operation. For progress codes, the operation is the current activity.\r | |
86 | For error codes, it is the exception. For debug codes, it is not defined at this time.\r | |
87 | Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.\r | |
88 | Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.\r | |
89 | @param Instance The enumeration of a hardware or software entity within the system.\r | |
90 | A system may contain multiple entities that match a class/subclass pairing.\r | |
91 | The instance differentiates between them. An instance of 0 indicates that instance\r | |
92 | information is unavailable, not meaningful, or not relevant. Valid instance numbers start with 1.\r | |
93 | @param CallerId This optional parameter may be used to identify the caller.\r | |
94 | This parameter allows the status code driver to apply different rules to different callers.\r | |
95 | @param Data This optional parameter may be used to pass additional data.\r | |
96 | Type EFI_STATUS_CODE_DATA is defined in "Related Definitions" below.\r | |
97 | The contents of this data type may have additional GUID-specific data. The standard GUIDs and\r | |
98 | their associated data structures are defined in the Intel? Platform Innovation Framework for EFI Status Codes Specification.\r | |
99 | \r | |
100 | @return Always return EFI_SUCCESS.\r | |
101 | \r | |
102 | **/\r | |
103 | EFI_STATUS\r | |
104 | EFIAPI\r | |
105 | ReportDispatcher (\r | |
106 | IN EFI_STATUS_CODE_TYPE CodeType,\r | |
107 | IN EFI_STATUS_CODE_VALUE Value,\r | |
108 | IN UINT32 Instance,\r | |
109 | IN EFI_GUID *CallerId OPTIONAL,\r | |
110 | IN EFI_STATUS_CODE_DATA *Data OPTIONAL\r | |
111 | )\r | |
112 | {\r | |
113 | //\r | |
114 | // Use atom operation to avoid the reentant of report.\r | |
115 | // If current status is not zero, then the function is reentrancy.\r | |
116 | //\r | |
117 | if (1 == InterlockedCompareExchange32 (&gDxeStatusCode.StatusCodeNestStatus, 0, 1)) {\r | |
118 | return EFI_DEVICE_ERROR;\r | |
119 | }\r | |
120 | \r | |
121 | if (FeaturePcdGet (PcdStatusCodeUseEfiSerial) || FeaturePcdGet (PcdStatusCodeUseHardSerial)) {\r | |
122 | SerialStatusCodeReportWorker (\r | |
123 | CodeType,\r | |
124 | Value,\r | |
125 | Instance,\r | |
126 | CallerId,\r | |
127 | Data\r | |
128 | );\r | |
129 | }\r | |
130 | if (FeaturePcdGet (PcdStatusCodeUseRuntimeMemory)) {\r | |
131 | RtMemoryStatusCodeReportWorker (\r | |
132 | gDxeStatusCode.RtMemoryStatusCodeTable[PHYSICAL_MODE],\r | |
133 | CodeType,\r | |
134 | Value,\r | |
135 | Instance\r | |
136 | );\r | |
137 | }\r | |
138 | if (FeaturePcdGet (PcdStatusCodeUseDataHub)) {\r | |
139 | DataHubStatusCodeReportWorker (\r | |
140 | CodeType,\r | |
141 | Value,\r | |
142 | Instance,\r | |
143 | CallerId,\r | |
144 | Data\r | |
145 | );\r | |
146 | }\r | |
147 | if (FeaturePcdGet (PcdStatusCodeUseOEM)) {\r | |
148 | OemHookStatusCodeReport (\r | |
149 | CodeType,\r | |
150 | Value,\r | |
151 | Instance,\r | |
152 | CallerId,\r | |
153 | Data\r | |
154 | );\r | |
155 | }\r | |
156 | \r | |
157 | //\r | |
158 | // Restore the nest status of report\r | |
159 | //\r | |
160 | InterlockedCompareExchange32 (&gDxeStatusCode.StatusCodeNestStatus, 1, 0);\r | |
161 | \r | |
162 | return EFI_SUCCESS;\r | |
163 | }\r | |
164 | \r | |
165 | \r | |
166 | /**\r | |
167 | \r | |
168 | Main entry for Extended SAL ReportStatusCode Services\r | |
169 | \r | |
170 | @param FunctionId Function Id which needed to be called\r | |
171 | @param Arg2 Efi status code type\r | |
172 | @param Arg3 Efi status code value\r | |
173 | @param Arg4 Instance number\r | |
174 | @param Arg5 Caller Id\r | |
175 | @param Arg6 Efi status code data\r | |
176 | @param Arg7 Not used\r | |
177 | @param Arg8 Not used\r | |
178 | @param ExtendedSalProc Esal Proc pointer\r | |
179 | @param VirtualMode If this function is called in virtual mode\r | |
180 | @param Global This module's global variable pointer\r | |
181 | \r | |
182 | @return Value returned in SAL_RETURN_REGS\r | |
183 | \r | |
184 | --*/\r | |
185 | SAL_RETURN_REGS\r | |
186 | EFIAPI\r | |
187 | ReportEsalServiceEntry (\r | |
188 | IN UINT64 FunctionId,\r | |
189 | IN UINT64 Arg2,\r | |
190 | IN UINT64 Arg3,\r | |
191 | IN UINT64 Arg4,\r | |
192 | IN UINT64 Arg5,\r | |
193 | IN UINT64 Arg6,\r | |
194 | IN UINT64 Arg7,\r | |
195 | IN UINT64 Arg8,\r | |
196 | IN SAL_EXTENDED_SAL_PROC ExtendedSalProc,\r | |
197 | IN BOOLEAN VirtualMode,\r | |
198 | IN VOID *Global\r | |
199 | )\r | |
200 | {\r | |
201 | SAL_RETURN_REGS ReturnVal;\r | |
202 | DXE_STATUS_CODE_CONTROLLER *DxeStatusCode;\r | |
203 | \r | |
204 | switch (FunctionId) {\r | |
205 | \r | |
206 | case ReportStatusCodeService:\r | |
207 | \r | |
208 | DxeStatusCode = (DXE_STATUS_CODE_CONTROLLER *) Global;\r | |
209 | \r | |
210 | //\r | |
211 | // Use atom operation to avoid the reentant of report.\r | |
212 | // If current status is not zero, then the function is reentrancy.\r | |
213 | //\r | |
214 | if (1 == InterlockedCompareExchange32 (&DxeStatusCode->StatusCodeNestStatus, 0, 1)) {\r | |
215 | ReturnVal.Status = EFI_DEVICE_ERROR;\r | |
216 | return ReturnVal;\r | |
217 | }\r | |
218 | \r | |
219 | if (FeaturePcdGet (PcdStatusCodeUseEfiSerial) || FeaturePcdGet (PcdStatusCodeUseHardSerial)) {\r | |
220 | SerialStatusCodeReportWorker (\r | |
221 | (EFI_STATUS_CODE_TYPE) Arg2,\r | |
222 | (EFI_STATUS_CODE_VALUE) Arg3,\r | |
223 | (UINT32) Arg4,\r | |
224 | (EFI_GUID *) Arg5,\r | |
225 | (EFI_STATUS_CODE_DATA *) Arg6\r | |
226 | );\r | |
227 | }\r | |
228 | if (FeaturePcdGet (PcdStatusCodeUseRuntimeMemory)) {\r | |
229 | RtMemoryStatusCodeReportWorker (\r | |
230 | DxeStatusCode->RtMemoryStatusCodeTable[VirtualMode],\r | |
231 | (EFI_STATUS_CODE_TYPE) Arg2,\r | |
232 | (EFI_STATUS_CODE_VALUE) Arg3,\r | |
233 | (UINT32) Arg4\r | |
234 | );\r | |
235 | }\r | |
236 | if (FeaturePcdGet (PcdStatusCodeUseDataHub)) {\r | |
237 | DataHubStatusCodeReportWorker (\r | |
238 | (EFI_STATUS_CODE_TYPE) Arg2,\r | |
239 | (EFI_STATUS_CODE_VALUE) Arg3,\r | |
240 | (UINT32) Arg4,\r | |
241 | (EFI_GUID *) Arg5,\r | |
242 | (EFI_STATUS_CODE_DATA *) Arg6\r | |
243 | );\r | |
244 | }\r | |
245 | if (FeaturePcdGet (PcdStatusCodeUseOEM)) {\r | |
246 | OemHookStatusCodeReport (\r | |
247 | (EFI_STATUS_CODE_TYPE) Arg2,\r | |
248 | (EFI_STATUS_CODE_VALUE) Arg3,\r | |
249 | (UINT32) Arg4,\r | |
250 | (EFI_GUID *) Arg5,\r | |
251 | (EFI_STATUS_CODE_DATA *) Arg6\r | |
252 | );\r | |
253 | }\r | |
254 | \r | |
255 | //\r | |
256 | // Restore the nest status of report\r | |
257 | //\r | |
258 | InterlockedCompareExchange32 (&DxeStatusCode->StatusCodeNestStatus, 1, 0);\r | |
259 | \r | |
260 | ReturnVal.Status = EFI_SUCCESS;\r | |
261 | \r | |
262 | break;\r | |
263 | \r | |
264 | default:\r | |
265 | ReturnVal.Status = EFI_SAL_INVALID_ARGUMENT;\r | |
266 | break;\r | |
267 | }\r | |
268 | \r | |
269 | return ReturnVal;\r | |
270 | }\r | |
271 | \r | |
272 | /**\r | |
273 | \r | |
274 | Install the ReportStatusCode runtime service.\r | |
275 | \r | |
276 | @param ImageHandle Image handle of the loaded driver\r | |
277 | @param SystemTable Pointer to the System Table\r | |
278 | \r | |
279 | @return The function always returns success.\r | |
280 | \r | |
281 | **/\r | |
282 | EFI_STATUS\r | |
283 | DxeStatusCodeDriverEntry (\r | |
284 | IN EFI_HANDLE ImageHandle,\r | |
285 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
286 | )\r | |
287 | {\r | |
288 | EFI_STATUS Status;\r | |
289 | EFI_HANDLE Handle = NULL;\r | |
290 | \r | |
291 | //\r | |
292 | // Dispatch initialization request to supported devices\r | |
293 | //\r | |
294 | InitializationDispatcherWorker ();\r | |
295 | \r | |
296 | //\r | |
297 | // Install Status Code Architectural Protocol implementation as defined in Tiano\r | |
298 | // Architecture Specification.\r | |
299 | //\r | |
300 | Status = gBS->InstallMultipleProtocolInterfaces (\r | |
301 | &Handle,\r | |
302 | &gEfiStatusCodeRuntimeProtocolGuid,\r | |
303 | &mEfiStatusCodeProtocol,\r | |
304 | NULL\r | |
305 | );\r | |
306 | ASSERT_EFI_ERROR (Status);\r | |
307 | \r | |
308 | //\r | |
309 | // Initialize ESAL capabilities.\r | |
310 | //\r | |
311 | Status = RegisterEsalClass (\r | |
312 | &gEfiExtendedSalStatusCodeServicesProtocolGuid,\r | |
313 | &gDxeStatusCode,\r | |
314 | ReportEsalServiceEntry,\r | |
315 | StatusCode,\r | |
316 | NULL\r | |
317 | );\r | |
318 | ASSERT_EFI_ERROR (Status);\r | |
319 | \r | |
320 | return EFI_SUCCESS;\r | |
321 | }\r | |
322 | \r | |
323 | \r | |
324 | /**\r | |
325 | Virtual address change notification call back. It converts physical mode global pointer to\r | |
326 | virtual mode.\r | |
327 | \r | |
328 | @param Event Event whose notification function is being invoked.\r | |
329 | @param Context Pointer to the notification function's context, which is\r | |
330 | always zero in current implementation.\r | |
331 | \r | |
332 | **/\r | |
333 | VOID\r | |
334 | EFIAPI\r | |
335 | VirtualAddressChangeCallBack (\r | |
336 | IN EFI_EVENT Event,\r | |
337 | IN VOID *Context\r | |
338 | )\r | |
339 | {\r | |
340 | gDxeStatusCode.RtMemoryStatusCodeTable[VIRTUAL_MODE] =\r | |
341 | gDxeStatusCode.RtMemoryStatusCodeTable[PHYSICAL_MODE];\r | |
342 | \r | |
343 | //\r | |
344 | // Convert the physical mode pointer to virtual mode point.\r | |
345 | //\r | |
346 | EfiConvertPointer (\r | |
347 | 0,\r | |
348 | (VOID **) &gDxeStatusCode.RtMemoryStatusCodeTable[VIRTUAL_MODE]\r | |
349 | );\r | |
350 | }\r | |
351 | \r |