]> git.proxmox.com Git - mirror_edk2.git/blob - IntelFrameworkModulePkg/Universal/StatusCode/Dxe/DxeStatusCodeCommon.c
Adjust the code so that global variable placed at beginning of file.
[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 EFIAPI
89 DxeStatusCodeDriverEntry (
90 IN EFI_HANDLE ImageHandle,
91 IN EFI_SYSTEM_TABLE *SystemTable
92 )
93 {
94 EFI_HANDLE Handle = NULL;
95 EFI_STATUS Status;
96
97 //
98 // Dispatch initialization request to supported devices
99 //
100 InitializationDispatcherWorker ();
101
102 //
103 // Install Status Code Architectural Protocol implementation as defined in Tiano
104 // Architecture Specification.
105 //
106 Status = gBS->InstallMultipleProtocolInterfaces (
107 &Handle,
108 &gEfiStatusCodeRuntimeProtocolGuid,
109 &mEfiStatusCodeProtocol,
110 NULL
111 );
112 ASSERT_EFI_ERROR (Status);
113
114 Status = gBS->CreateEventEx (
115 EVT_NOTIFY_SIGNAL,
116 TPL_NOTIFY,
117 VirtualAddressChangeCallBack,
118 NULL,
119 &gEfiEventExitBootServicesGuid,
120 &mExitBootServicesEvent
121 );
122 ASSERT_EFI_ERROR (Status);
123
124 return Status;
125 }
126
127 /**
128 Report status code to all supported device.
129 Calls into the workers which dispatches the platform specific
130 listeners.
131
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.
150
151 @return Always return EFI_SUCCESS.
152
153 **/
154 EFI_STATUS
155 EFIAPI
156 ReportDispatcher (
157 IN EFI_STATUS_CODE_TYPE CodeType,
158 IN EFI_STATUS_CODE_VALUE Value,
159 IN UINT32 Instance,
160 IN EFI_GUID *CallerId OPTIONAL,
161 IN EFI_STATUS_CODE_DATA *Data OPTIONAL
162 )
163 {
164 //
165 // Use atom operation to avoid the reentant of report.
166 // If current status is not zero, then the function is reentrancy.
167 //
168 if (1 == InterlockedCompareExchange32 (&gDxeStatusCode.StatusCodeNestStatus, 0, 1)) {
169 return EFI_DEVICE_ERROR;
170 }
171
172 if (FeaturePcdGet (PcdStatusCodeUseEfiSerial) || FeaturePcdGet (PcdStatusCodeUseHardSerial)) {
173 SerialStatusCodeReportWorker (
174 CodeType,
175 Value,
176 Instance,
177 CallerId,
178 Data
179 );
180 }
181 if (FeaturePcdGet (PcdStatusCodeUseRuntimeMemory)) {
182 RtMemoryStatusCodeReportWorker (
183 gDxeStatusCode.RtMemoryStatusCodeTable[PHYSICAL_MODE],
184 CodeType,
185 Value,
186 Instance
187 );
188 }
189 if (FeaturePcdGet (PcdStatusCodeUseDataHub)) {
190 DataHubStatusCodeReportWorker (
191 CodeType,
192 Value,
193 Instance,
194 CallerId,
195 Data
196 );
197 }
198 if (FeaturePcdGet (PcdStatusCodeUseOEM)) {
199 OemHookStatusCodeReport (
200 CodeType,
201 Value,
202 Instance,
203 CallerId,
204 Data
205 );
206 }
207
208 //
209 // Restore the nest status of report
210 //
211 InterlockedCompareExchange32 (&gDxeStatusCode.StatusCodeNestStatus, 1, 0);
212
213 return EFI_SUCCESS;
214 }
215
216
217 /**
218 Virtual address change notification call back. It converts global pointer
219 to virtual address.
220
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.
224
225 **/
226 VOID
227 EFIAPI
228 VirtualAddressChangeCallBack (
229 IN EFI_EVENT Event,
230 IN VOID *Context
231 )
232 {
233 //
234 // Convert memory status code table to virtual address;
235 //
236 EfiConvertPointer (
237 0,
238 (VOID **) &gDxeStatusCode.RtMemoryStatusCodeTable[PHYSICAL_MODE]
239 );
240 }
241