]> git.proxmox.com Git - mirror_edk2.git/blob - IntelFrameworkModulePkg/Universal/StatusCode/Dxe/DxeStatusCodeCommon.c
use the GUIDed versions of events: EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE and EVT_SIGNAL_E...
[mirror_edk2.git] / IntelFrameworkModulePkg / Universal / StatusCode / Dxe / DxeStatusCodeCommon.c
1 /** @file
2 Status code driver for IA32/X64/EBC 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 **/
14
15 #include "DxeStatusCode.h"
16
17 //
18 // Event for Exit Boot Services Callback
19 //
20 EFI_EVENT mExitBootServicesEvent = NULL;
21
22 /**
23 Report status code to all supported device.
24 Calls into the workers which dispatches the platform specific
25 listeners.
26
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.
45
46 @return Always return EFI_SUCCESS.
47
48 **/
49 EFI_STATUS
50 EFIAPI
51 ReportDispatcher (
52 IN EFI_STATUS_CODE_TYPE Type,
53 IN EFI_STATUS_CODE_VALUE Value,
54 IN UINT32 Instance,
55 IN EFI_GUID *CallerId OPTIONAL,
56 IN EFI_STATUS_CODE_DATA *Data OPTIONAL
57 );
58
59 //
60 // Declaration of status code protocol.
61 //
62 EFI_STATUS_CODE_PROTOCOL mEfiStatusCodeProtocol = {
63 ReportDispatcher
64 };
65
66 //
67 // Delaration of DXE status code controller
68 //
69 DXE_STATUS_CODE_CONTROLLER gDxeStatusCode = {
70 //
71 // Initialize nest status as non nested.
72 //
73 0,
74 {NULL, NULL}
75 };
76
77 /**
78
79 Install the ReportStatusCode runtime service.
80
81 @param ImageHandle Image handle of the loaded driver
82 @param SystemTable Pointer to the System Table
83
84 @return The function always returns success.
85
86 **/
87 EFI_STATUS
88 DxeStatusCodeDriverEntry (
89 IN EFI_HANDLE ImageHandle,
90 IN EFI_SYSTEM_TABLE *SystemTable
91 )
92 {
93 EFI_HANDLE Handle = NULL;
94 EFI_STATUS Status;
95
96 //
97 // Dispatch initialization request to supported devices
98 //
99 InitializationDispatcherWorker ();
100
101 //
102 // Install Status Code Architectural Protocol implementation as defined in Tiano
103 // Architecture Specification.
104 //
105 Status = gBS->InstallMultipleProtocolInterfaces (
106 &Handle,
107 &gEfiStatusCodeRuntimeProtocolGuid,
108 &mEfiStatusCodeProtocol,
109 NULL
110 );
111 ASSERT_EFI_ERROR (Status);
112
113 Status = gBS->CreateEventEx (
114 EVT_NOTIFY_SIGNAL,
115 TPL_NOTIFY,
116 VirtualAddressChangeCallBack,
117 NULL,
118 &gEfiEventExitBootServicesGuid,
119 &mExitBootServicesEvent
120 );
121 ASSERT_EFI_ERROR (Status);
122
123 return Status;
124 }
125
126 /**
127 Report status code to all supported device.
128 Calls into the workers which dispatches the platform specific
129 listeners.
130
131 @param CodeType Indicates the type of status code being reported.
132 The type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.
133 @param Value Describes the current status of a hardware or software entity.
134 This includes information about the class and subclass that is used to classify the entity
135 as well as an operation. For progress codes, the operation is the current activity.
136 For error codes, it is the exception. For debug codes, it is not defined at this time.
137 Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.
138 Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.
139 @param Instance The enumeration of a hardware or software entity within the system.
140 A system may contain multiple entities that match a class/subclass pairing.
141 The instance differentiates between them. An instance of 0 indicates that instance
142 information is unavailable, not meaningful, or not relevant. Valid instance numbers start with 1.
143 @param CallerId This optional parameter may be used to identify the caller.
144 This parameter allows the status code driver to apply different rules to different callers.
145 @param Data This optional parameter may be used to pass additional data.
146 Type EFI_STATUS_CODE_DATA is defined in "Related Definitions" below.
147 The contents of this data type may have additional GUID-specific data. The standard GUIDs and
148 their associated data structures are defined in the Intel? Platform Innovation Framework for EFI Status Codes Specification.
149
150 @return Always return EFI_SUCCESS.
151
152 **/
153 EFI_STATUS
154 EFIAPI
155 ReportDispatcher (
156 IN EFI_STATUS_CODE_TYPE CodeType,
157 IN EFI_STATUS_CODE_VALUE Value,
158 IN UINT32 Instance,
159 IN EFI_GUID *CallerId OPTIONAL,
160 IN EFI_STATUS_CODE_DATA *Data OPTIONAL
161 )
162 {
163 //
164 // Use atom operation to avoid the reentant of report.
165 // If current status is not zero, then the function is reentrancy.
166 //
167 if (1 == InterlockedCompareExchange32 (&gDxeStatusCode.StatusCodeNestStatus, 0, 1)) {
168 return EFI_DEVICE_ERROR;
169 }
170
171 if (FeaturePcdGet (PcdStatusCodeUseEfiSerial) || FeaturePcdGet (PcdStatusCodeUseHardSerial)) {
172 SerialStatusCodeReportWorker (
173 CodeType,
174 Value,
175 Instance,
176 CallerId,
177 Data
178 );
179 }
180 if (FeaturePcdGet (PcdStatusCodeUseRuntimeMemory)) {
181 RtMemoryStatusCodeReportWorker (
182 gDxeStatusCode.RtMemoryStatusCodeTable[PHYSICAL_MODE],
183 CodeType,
184 Value,
185 Instance
186 );
187 }
188 if (FeaturePcdGet (PcdStatusCodeUseDataHub)) {
189 DataHubStatusCodeReportWorker (
190 CodeType,
191 Value,
192 Instance,
193 CallerId,
194 Data
195 );
196 }
197 if (FeaturePcdGet (PcdStatusCodeUseOEM)) {
198 OemHookStatusCodeReport (
199 CodeType,
200 Value,
201 Instance,
202 CallerId,
203 Data
204 );
205 }
206
207 //
208 // Restore the nest status of report
209 //
210 InterlockedCompareExchange32 (&gDxeStatusCode.StatusCodeNestStatus, 1, 0);
211
212 return EFI_SUCCESS;
213 }
214
215
216 /**
217 Virtual address change notification call back. It converts global pointer
218 to virtual address.
219
220 @param Event Event whose notification function is being invoked.
221 @param Context Pointer to the notification function's context, which is
222 always zero in current implementation.
223
224 **/
225 VOID
226 EFIAPI
227 VirtualAddressChangeCallBack (
228 IN EFI_EVENT Event,
229 IN VOID *Context
230 )
231 {
232 //
233 // Convert memory status code table to virtual address;
234 //
235 EfiConvertPointer (
236 0,
237 (VOID **) &gDxeStatusCode.RtMemoryStatusCodeTable[PHYSICAL_MODE]
238 );
239 }
240