2 Status code driver for IA32/X64/EBC 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.
15 #include "DxeStatusCode.h"
18 // Event for Exit Boot Services Callback
20 EFI_EVENT mExitBootServicesEvent
= NULL
;
23 Report status code to all supported device.
24 Calls into the workers which dispatches the platform specific
27 @param Type Indicates the type of status code being reported.
28 The type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.
29 @param Value Describes the current status of a hardware or software entity.
30 This includes information about the class and subclass that is used to classify the entity
31 as well as an operation. For progress codes, the operation is the current activity.
32 For error codes, it is the exception. For debug codes, it is not defined at this time.
33 Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.
34 Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.
35 @param Instance The enumeration of a hardware or software entity within the system.
36 A system may contain multiple entities that match a class/subclass pairing.
37 The instance differentiates between them. An instance of 0 indicates that instance
38 information is unavailable, not meaningful, or not relevant. Valid instance numbers start with 1.
39 @param CallerId This optional parameter may be used to identify the caller.
40 This parameter allows the status code driver to apply different rules to different callers.
41 @param Data This optional parameter may be used to pass additional data.
42 Type EFI_STATUS_CODE_DATA is defined in "Related Definitions" below.
43 The contents of this data type may have additional GUID-specific data. The standard GUIDs and
44 their associated data structures are defined in the Intel? Platform Innovation Framework for EFI Status Codes Specification.
46 @return Always return EFI_SUCCESS.
52 IN EFI_STATUS_CODE_TYPE Type
,
53 IN EFI_STATUS_CODE_VALUE Value
,
55 IN EFI_GUID
*CallerId OPTIONAL
,
56 IN EFI_STATUS_CODE_DATA
*Data OPTIONAL
60 // Declaration of status code protocol.
62 EFI_STATUS_CODE_PROTOCOL mEfiStatusCodeProtocol
= {
67 // Delaration of DXE status code controller
69 DXE_STATUS_CODE_CONTROLLER gDxeStatusCode
= {
71 // Initialize nest status as non nested.
79 Install the ReportStatusCode runtime service.
81 @param ImageHandle Image handle of the loaded driver
82 @param SystemTable Pointer to the System Table
84 @return The function always returns success.
89 DxeStatusCodeDriverEntry (
90 IN EFI_HANDLE ImageHandle
,
91 IN EFI_SYSTEM_TABLE
*SystemTable
94 EFI_HANDLE Handle
= NULL
;
98 // Dispatch initialization request to supported devices
100 InitializationDispatcherWorker ();
103 // Install Status Code Architectural Protocol implementation as defined in Tiano
104 // Architecture Specification.
106 Status
= gBS
->InstallMultipleProtocolInterfaces (
108 &gEfiStatusCodeRuntimeProtocolGuid
,
109 &mEfiStatusCodeProtocol
,
112 ASSERT_EFI_ERROR (Status
);
114 Status
= gBS
->CreateEventEx (
117 VirtualAddressChangeCallBack
,
119 &gEfiEventExitBootServicesGuid
,
120 &mExitBootServicesEvent
122 ASSERT_EFI_ERROR (Status
);
128 Report status code to all supported device.
129 Calls into the workers which dispatches the platform specific
132 @param CodeType Indicates the type of status code being reported.
133 The type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.
134 @param Value Describes the current status of a hardware or software entity.
135 This includes information about the class and subclass that is used to classify the entity
136 as well as an operation. For progress codes, the operation is the current activity.
137 For error codes, it is the exception. For debug codes, it is not defined at this time.
138 Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.
139 Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.
140 @param Instance The enumeration of a hardware or software entity within the system.
141 A system may contain multiple entities that match a class/subclass pairing.
142 The instance differentiates between them. An instance of 0 indicates that instance
143 information is unavailable, not meaningful, or not relevant. Valid instance numbers start with 1.
144 @param CallerId This optional parameter may be used to identify the caller.
145 This parameter allows the status code driver to apply different rules to different callers.
146 @param Data This optional parameter may be used to pass additional data.
147 Type EFI_STATUS_CODE_DATA is defined in "Related Definitions" below.
148 The contents of this data type may have additional GUID-specific data. The standard GUIDs and
149 their associated data structures are defined in the Intel? Platform Innovation Framework for EFI Status Codes Specification.
151 @return Always return EFI_SUCCESS.
157 IN EFI_STATUS_CODE_TYPE CodeType
,
158 IN EFI_STATUS_CODE_VALUE Value
,
160 IN EFI_GUID
*CallerId OPTIONAL
,
161 IN EFI_STATUS_CODE_DATA
*Data OPTIONAL
165 // Use atom operation to avoid the reentant of report.
166 // If current status is not zero, then the function is reentrancy.
168 if (1 == InterlockedCompareExchange32 (&gDxeStatusCode
.StatusCodeNestStatus
, 0, 1)) {
169 return EFI_DEVICE_ERROR
;
172 if (FeaturePcdGet (PcdStatusCodeUseEfiSerial
) || FeaturePcdGet (PcdStatusCodeUseHardSerial
)) {
173 SerialStatusCodeReportWorker (
181 if (FeaturePcdGet (PcdStatusCodeUseRuntimeMemory
)) {
182 RtMemoryStatusCodeReportWorker (
183 gDxeStatusCode
.RtMemoryStatusCodeTable
[PHYSICAL_MODE
],
189 if (FeaturePcdGet (PcdStatusCodeUseDataHub
)) {
190 DataHubStatusCodeReportWorker (
198 if (FeaturePcdGet (PcdStatusCodeUseOEM
)) {
199 OemHookStatusCodeReport (
209 // Restore the nest status of report
211 InterlockedCompareExchange32 (&gDxeStatusCode
.StatusCodeNestStatus
, 1, 0);
218 Virtual address change notification call back. It converts global pointer
221 @param Event Event whose notification function is being invoked.
222 @param Context Pointer to the notification function's context, which is
223 always zero in current implementation.
228 VirtualAddressChangeCallBack (
234 // Convert memory status code table to virtual address;
238 (VOID
**) &gDxeStatusCode
.RtMemoryStatusCodeTable
[PHYSICAL_MODE
]