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