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