2 * Status code driver for IPF architecture.
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
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.
13 Module Name: DxeStatusCodeIpf.c
17 #include "DxeStatusCode.h"
21 Report status code to all supported device.
22 Calls into the workers which dispatches the platform specific
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.
44 @return Always return EFI_SUCCESS.
50 IN EFI_STATUS_CODE_TYPE Type
,
51 IN EFI_STATUS_CODE_VALUE Value
,
53 IN EFI_GUID
*CallerId OPTIONAL
,
54 IN EFI_STATUS_CODE_DATA
*Data OPTIONAL
58 // Declaration of status code protocol.
61 EFI_STATUS_CODE_PROTOCOL mEfiStatusCodeProtocol
= {
66 // Delaration of DXE status code controller
68 DXE_STATUS_CODE_CONTROLLER gDxeStatusCode
= {
70 // Initialize nest status as non nested.
77 Report status code to all supported device.
78 Calls into the workers which dispatches the platform specific
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.
100 @return Always return EFI_SUCCESS.
106 IN EFI_STATUS_CODE_TYPE CodeType
,
107 IN EFI_STATUS_CODE_VALUE Value
,
109 IN EFI_GUID
*CallerId OPTIONAL
,
110 IN EFI_STATUS_CODE_DATA
*Data OPTIONAL
114 // Use atom operation to avoid the reentant of report.
115 // If current status is not zero, then the function is reentrancy.
117 if (1 == InterlockedCompareExchange32 (&gDxeStatusCode
.StatusCodeNestStatus
, 0, 1)) {
118 return EFI_DEVICE_ERROR
;
121 if (FeaturePcdGet (PcdStatusCodeUseEfiSerial
) || FeaturePcdGet (PcdStatusCodeUseHardSerial
)) {
122 SerialStatusCodeReportWorker (
130 if (FeaturePcdGet (PcdStatusCodeUseRuntimeMemory
)) {
131 RtMemoryStatusCodeReportWorker (
132 gDxeStatusCode
.RtMemoryStatusCodeTable
[PHYSICAL_MODE
],
138 if (FeaturePcdGet (PcdStatusCodeUseDataHub
)) {
139 DataHubStatusCodeReportWorker (
147 if (FeaturePcdGet (PcdStatusCodeUseOEM
)) {
148 OemHookStatusCodeReport (
158 // Restore the nest status of report
160 InterlockedCompareExchange32 (&gDxeStatusCode
.StatusCodeNestStatus
, 1, 0);
168 Main entry for Extended SAL ReportStatusCode Services
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
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
182 @return Value returned in SAL_RETURN_REGS
187 ReportEsalServiceEntry (
188 IN UINT64 FunctionId
,
196 IN SAL_EXTENDED_SAL_PROC ExtendedSalProc
,
197 IN BOOLEAN VirtualMode
,
201 SAL_RETURN_REGS ReturnVal
;
202 DXE_STATUS_CODE_CONTROLLER
*DxeStatusCode
;
204 switch (FunctionId
) {
206 case ReportStatusCodeService
:
208 DxeStatusCode
= (DXE_STATUS_CODE_CONTROLLER
*) Global
;
211 // Use atom operation to avoid the reentant of report.
212 // If current status is not zero, then the function is reentrancy.
214 if (1 == InterlockedCompareExchange32 (&DxeStatusCode
->StatusCodeNestStatus
, 0, 1)) {
215 ReturnVal
.Status
= EFI_DEVICE_ERROR
;
219 if (FeaturePcdGet (PcdStatusCodeUseEfiSerial
) || FeaturePcdGet (PcdStatusCodeUseHardSerial
)) {
220 SerialStatusCodeReportWorker (
221 (EFI_STATUS_CODE_TYPE
) Arg2
,
222 (EFI_STATUS_CODE_VALUE
) Arg3
,
225 (EFI_STATUS_CODE_DATA
*) Arg6
228 if (FeaturePcdGet (PcdStatusCodeUseRuntimeMemory
)) {
229 RtMemoryStatusCodeReportWorker (
230 DxeStatusCode
->RtMemoryStatusCodeTable
[VirtualMode
],
231 (EFI_STATUS_CODE_TYPE
) Arg2
,
232 (EFI_STATUS_CODE_VALUE
) Arg3
,
236 if (FeaturePcdGet (PcdStatusCodeUseDataHub
)) {
237 DataHubStatusCodeReportWorker (
238 (EFI_STATUS_CODE_TYPE
) Arg2
,
239 (EFI_STATUS_CODE_VALUE
) Arg3
,
242 (EFI_STATUS_CODE_DATA
*) Arg6
245 if (FeaturePcdGet (PcdStatusCodeUseOEM
)) {
246 OemHookStatusCodeReport (
247 (EFI_STATUS_CODE_TYPE
) Arg2
,
248 (EFI_STATUS_CODE_VALUE
) Arg3
,
251 (EFI_STATUS_CODE_DATA
*) Arg6
256 // Restore the nest status of report
258 InterlockedCompareExchange32 (&DxeStatusCode
->StatusCodeNestStatus
, 1, 0);
260 ReturnVal
.Status
= EFI_SUCCESS
;
265 ReturnVal
.Status
= EFI_SAL_INVALID_ARGUMENT
;
274 Install the ReportStatusCode runtime service.
276 @param ImageHandle Image handle of the loaded driver
277 @param SystemTable Pointer to the System Table
279 @return The function always returns success.
283 DxeStatusCodeDriverEntry (
284 IN EFI_HANDLE ImageHandle
,
285 IN EFI_SYSTEM_TABLE
*SystemTable
289 EFI_HANDLE Handle
= NULL
;
292 // Dispatch initialization request to supported devices
294 InitializationDispatcherWorker ();
297 // Install Status Code Architectural Protocol implementation as defined in Tiano
298 // Architecture Specification.
300 Status
= gBS
->InstallMultipleProtocolInterfaces (
302 &gEfiStatusCodeRuntimeProtocolGuid
,
303 &mEfiStatusCodeProtocol
,
306 ASSERT_EFI_ERROR (Status
);
309 // Initialize ESAL capabilities.
311 Status
= RegisterEsalClass (
312 &gEfiExtendedSalStatusCodeServicesProtocolGuid
,
314 ReportEsalServiceEntry
,
318 ASSERT_EFI_ERROR (Status
);
325 Virtual address change notification call back. It converts physical mode global pointer to
328 @param Event Event whose notification function is being invoked.
329 @param Context Pointer to the notification function's context, which is
330 always zero in current implementation.
335 VirtualAddressChangeCallBack (
340 gDxeStatusCode
.RtMemoryStatusCodeTable
[VIRTUAL_MODE
] =
341 gDxeStatusCode
.RtMemoryStatusCodeTable
[PHYSICAL_MODE
];
344 // Convert the physical mode pointer to virtual mode point.
348 (VOID
**) &gDxeStatusCode
.RtMemoryStatusCodeTable
[VIRTUAL_MODE
]