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