]> git.proxmox.com Git - mirror_edk2.git/blame - EdkModulePkg/Universal/StatusCode/Dxe/Ipf/DxeStatusCodeIpf.c
Partially make EdkModulePkg pass intel IPF compiler with /W4 /WX switched on.
[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
47EFI_STATUS\r
48EFIAPI\r
49ReportDispatcher (\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
60STATIC\r
61EFI_STATUS_CODE_PROTOCOL mEfiStatusCodeProtocol = {\r
62 ReportDispatcher\r
63};\r
64\r
56836fe9 65//\r
53f491d3 66// Delaration of DXE status code controller\r
56836fe9 67//\r
68DXE_STATUS_CODE_CONTROLLER gDxeStatusCode = {\r
69 //\r
53f491d3 70 // Initialize nest status as non nested.\r
71 //\r
56836fe9 72 0,\r
73 {NULL, NULL}\r
74};\r
75\r
53f491d3 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
103EFI_STATUS\r
104EFIAPI\r
105ReportDispatcher (\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
56836fe9 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
53f491d3 173 @param Arg4 Instance number\r
56836fe9 174 @param Arg5 Caller Id\r
175 @param Arg6 Efi status code data\r
53f491d3 176 @param Arg7 Not used\r
177 @param Arg8 Not used\r
178 @param ExtendedSalProc Esal Proc pointer\r
56836fe9 179 @param VirtualMode If this function is called in virtual mode\r
180 @param Global This module's global variable pointer\r
53f491d3 181\r
56836fe9 182 @return Value returned in SAL_RETURN_REGS\r
183\r
184--*/\r
1cc8ee78 185STATIC\r
56836fe9 186SAL_RETURN_REGS\r
187EFIAPI\r
188ReportEsalServiceEntry (\r
189 IN UINT64 FunctionId,\r
190 IN UINT64 Arg2,\r
191 IN UINT64 Arg3,\r
192 IN UINT64 Arg4,\r
193 IN UINT64 Arg5,\r
194 IN UINT64 Arg6,\r
195 IN UINT64 Arg7,\r
196 IN UINT64 Arg8,\r
197 IN SAL_EXTENDED_SAL_PROC ExtendedSalProc,\r
198 IN BOOLEAN VirtualMode,\r
199 IN VOID *Global\r
200 )\r
201{\r
202 SAL_RETURN_REGS ReturnVal;\r
203 DXE_STATUS_CODE_CONTROLLER *DxeStatusCode;\r
204\r
205 switch (FunctionId) {\r
206\r
207 case ReportStatusCodeService:\r
208\r
209 DxeStatusCode = (DXE_STATUS_CODE_CONTROLLER *) Global;\r
210\r
211 //\r
212 // Use atom operation to avoid the reentant of report.\r
213 // If current status is not zero, then the function is reentrancy.\r
214 //\r
97fc032b 215 if (1 == InterlockedCompareExchange32 (&DxeStatusCode->StatusCodeNestStatus, 0, 1)) {\r
216 ReturnVal.Status = EFI_DEVICE_ERROR;\r
56836fe9 217 return ReturnVal;\r
218 }\r
219\r
220 if (FeaturePcdGet (PcdStatusCodeUseEfiSerial) || FeaturePcdGet (PcdStatusCodeUseHardSerial)) {\r
221 SerialStatusCodeReportWorker (\r
222 (EFI_STATUS_CODE_TYPE) Arg2,\r
223 (EFI_STATUS_CODE_VALUE) Arg3,\r
224 (UINT32) Arg4,\r
225 (EFI_GUID *) Arg5,\r
226 (EFI_STATUS_CODE_DATA *) Arg6\r
227 );\r
228 }\r
229 if (FeaturePcdGet (PcdStatusCodeUseRuntimeMemory)) {\r
230 RtMemoryStatusCodeReportWorker (\r
231 DxeStatusCode->RtMemoryStatusCodeTable[VirtualMode],\r
232 (EFI_STATUS_CODE_TYPE) Arg2,\r
233 (EFI_STATUS_CODE_VALUE) Arg3,\r
234 (UINT32) Arg4\r
235 );\r
236 }\r
237 if (FeaturePcdGet (PcdStatusCodeUseDataHub)) {\r
238 DataHubStatusCodeReportWorker (\r
239 (EFI_STATUS_CODE_TYPE) Arg2,\r
240 (EFI_STATUS_CODE_VALUE) Arg3,\r
241 (UINT32) Arg4,\r
242 (EFI_GUID *) Arg5,\r
243 (EFI_STATUS_CODE_DATA *) Arg6\r
244 );\r
245 }\r
246 if (FeaturePcdGet (PcdStatusCodeUseOEM)) {\r
247 OemHookStatusCodeReport (\r
248 (EFI_STATUS_CODE_TYPE) Arg2,\r
249 (EFI_STATUS_CODE_VALUE) Arg3,\r
250 (UINT32) Arg4,\r
251 (EFI_GUID *) Arg5,\r
252 (EFI_STATUS_CODE_DATA *) Arg6\r
253 );\r
254 }\r
255\r
256 //\r
257 // Restore the nest status of report\r
258 //\r
259 InterlockedCompareExchange32 (&DxeStatusCode->StatusCodeNestStatus, 1, 0);\r
260\r
261 ReturnVal.Status = EFI_SUCCESS;\r
262\r
263 break;\r
264\r
265 default:\r
266 ReturnVal.Status = EFI_SAL_INVALID_ARGUMENT;\r
267 break;\r
268 }\r
269\r
270 return ReturnVal;\r
271}\r
272\r
273/**\r
274\r
275 Install the ReportStatusCode runtime service.\r
276\r
277 @param ImageHandle Image handle of the loaded driver\r
278 @param SystemTable Pointer to the System Table\r
279\r
280 @return The function always returns success.\r
281\r
282**/\r
283EFI_STATUS\r
56836fe9 284DxeStatusCodeDriverEntry (\r
285 IN EFI_HANDLE ImageHandle,\r
286 IN EFI_SYSTEM_TABLE *SystemTable\r
287 )\r
288{\r
53f491d3 289 EFI_STATUS Status;\r
290 EFI_HANDLE Handle = NULL;\r
97fc032b 291\r
56836fe9 292 //\r
293 // Dispatch initialization request to supported devices\r
294 //\r
295 InitializationDispatcherWorker ();\r
296\r
53f491d3 297 //\r
298 // Install Status Code Architectural Protocol implementation as defined in Tiano\r
299 // Architecture Specification.\r
300 //\r
301 Status = gBS->InstallMultipleProtocolInterfaces (\r
302 &Handle,\r
303 &gEfiStatusCodeRuntimeProtocolGuid,\r
304 &mEfiStatusCodeProtocol,\r
305 NULL\r
306 );\r
307 ASSERT_EFI_ERROR (Status);\r
308\r
56836fe9 309 //\r
310 // Initialize ESAL capabilities.\r
311 //\r
97fc032b 312 Status = RegisterEsalClass (\r
313 &gEfiExtendedSalStatusCodeServicesProtocolGuid,\r
53f491d3 314 &gDxeStatusCode,\r
97fc032b 315 ReportEsalServiceEntry,\r
316 StatusCode,\r
317 NULL\r
318 );\r
319 ASSERT_EFI_ERROR (Status);\r
56836fe9 320\r
321 return EFI_SUCCESS;\r
322}\r
323\r
324\r
325/**\r
53f491d3 326 Virtual address change notification call back. It converts physical mode global pointer to\r
56836fe9 327 virtual mode.\r
328\r
329 @param Event Event whose notification function is being invoked.\r
511710d6 330 @param Context Pointer to the notification function's context, which is\r
56836fe9 331 always zero in current implementation.\r
332\r
333**/\r
334VOID\r
335EFIAPI\r
336VirtualAddressChangeCallBack (\r
337 IN EFI_EVENT Event,\r
338 IN VOID *Context\r
339 )\r
340{\r
53f491d3 341 gDxeStatusCode.RtMemoryStatusCodeTable[VIRTUAL_MODE] =\r
56836fe9 342 gDxeStatusCode.RtMemoryStatusCodeTable[PHYSICAL_MODE];\r
343\r
344 //\r
345 // Convert the physical mode pointer to virtual mode point.\r
346 //\r
347 EfiConvertPointer (\r
348 0,\r
349 (VOID **) &gDxeStatusCode.RtMemoryStatusCodeTable[VIRTUAL_MODE]\r
350 );\r
351}\r
352\r