]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - IntelFrameworkModulePkg/Universal/StatusCode/Dxe/DxeStatusCodeCommon.c
Patch to remove STATIC modifier. This is on longer recommended by EFI Framework codin...
[mirror_edk2.git] / IntelFrameworkModulePkg / Universal / StatusCode / Dxe / DxeStatusCodeCommon.c
... / ...
CommitLineData
1/** @file\r
2 Status code driver for IA32/X64/EBC architecture.\r
3\r
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
12\r
13**/\r
14\r
15#include "DxeStatusCode.h"\r
16\r
17//\r
18// Event for Exit Boot Services Callback\r
19//\r
20EFI_EVENT mExitBootServicesEvent = NULL;\r
21\r
22/**\r
23 Report status code to all supported device.\r
24 Calls into the workers which dispatches the platform specific\r
25 listeners.\r
26\r
27 @param Type Indicates the type of status code being reported.\r
28 The type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.\r
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
34 Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.\r
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
38 information is unavailable, not meaningful, or not relevant. Valid instance numbers start with 1.\r
39 @param CallerId This optional parameter may be used to identify the caller.\r
40 This parameter allows the status code driver to apply different rules to different callers.\r
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
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
49EFI_STATUS\r
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
62EFI_STATUS_CODE_PROTOCOL mEfiStatusCodeProtocol = {\r
63 ReportDispatcher\r
64};\r
65\r
66//\r
67// Delaration of DXE status code controller\r
68//\r
69DXE_STATUS_CODE_CONTROLLER gDxeStatusCode = {\r
70 //\r
71 // Initialize nest status as non nested.\r
72 //\r
73 0,\r
74 {NULL, NULL}\r
75};\r
76\r
77/**\r
78\r
79 Install the ReportStatusCode runtime service.\r
80\r
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
113 Status = gBS->CreateEvent (\r
114 EVT_SIGNAL_EXIT_BOOT_SERVICES,\r
115 TPL_NOTIFY,\r
116 VirtualAddressChangeCallBack,\r
117 NULL,\r
118 &mExitBootServicesEvent\r
119 );\r
120 ASSERT_EFI_ERROR (Status);\r
121\r
122 return Status;\r
123}\r
124\r
125/**\r
126 Report status code to all supported device.\r
127 Calls into the workers which dispatches the platform specific\r
128 listeners.\r
129\r
130 @param CodeType Indicates the type of status code being reported.\r
131 The type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.\r
132 @param Value Describes the current status of a hardware or software entity.\r
133 This includes information about the class and subclass that is used to classify the entity\r
134 as well as an operation. For progress codes, the operation is the current activity.\r
135 For error codes, it is the exception. For debug codes, it is not defined at this time.\r
136 Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.\r
137 Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.\r
138 @param Instance The enumeration of a hardware or software entity within the system.\r
139 A system may contain multiple entities that match a class/subclass pairing.\r
140 The instance differentiates between them. An instance of 0 indicates that instance\r
141 information is unavailable, not meaningful, or not relevant. Valid instance numbers start with 1.\r
142 @param CallerId This optional parameter may be used to identify the caller.\r
143 This parameter allows the status code driver to apply different rules to different callers.\r
144 @param Data This optional parameter may be used to pass additional data.\r
145 Type EFI_STATUS_CODE_DATA is defined in "Related Definitions" below.\r
146 The contents of this data type may have additional GUID-specific data. The standard GUIDs and\r
147 their associated data structures are defined in the Intel? Platform Innovation Framework for EFI Status Codes Specification.\r
148\r
149 @return Always return EFI_SUCCESS.\r
150\r
151**/\r
152EFI_STATUS\r
153EFIAPI\r
154ReportDispatcher (\r
155 IN EFI_STATUS_CODE_TYPE CodeType,\r
156 IN EFI_STATUS_CODE_VALUE Value,\r
157 IN UINT32 Instance,\r
158 IN EFI_GUID *CallerId OPTIONAL,\r
159 IN EFI_STATUS_CODE_DATA *Data OPTIONAL\r
160 )\r
161{\r
162 //\r
163 // Use atom operation to avoid the reentant of report.\r
164 // If current status is not zero, then the function is reentrancy.\r
165 //\r
166 if (1 == InterlockedCompareExchange32 (&gDxeStatusCode.StatusCodeNestStatus, 0, 1)) {\r
167 return EFI_DEVICE_ERROR;\r
168 }\r
169\r
170 if (FeaturePcdGet (PcdStatusCodeUseEfiSerial) || FeaturePcdGet (PcdStatusCodeUseHardSerial)) {\r
171 SerialStatusCodeReportWorker (\r
172 CodeType,\r
173 Value,\r
174 Instance,\r
175 CallerId,\r
176 Data\r
177 );\r
178 }\r
179 if (FeaturePcdGet (PcdStatusCodeUseRuntimeMemory)) {\r
180 RtMemoryStatusCodeReportWorker (\r
181 gDxeStatusCode.RtMemoryStatusCodeTable[PHYSICAL_MODE],\r
182 CodeType,\r
183 Value,\r
184 Instance\r
185 );\r
186 }\r
187 if (FeaturePcdGet (PcdStatusCodeUseDataHub)) {\r
188 DataHubStatusCodeReportWorker (\r
189 CodeType,\r
190 Value,\r
191 Instance,\r
192 CallerId,\r
193 Data\r
194 );\r
195 }\r
196 if (FeaturePcdGet (PcdStatusCodeUseOEM)) {\r
197 OemHookStatusCodeReport (\r
198 CodeType,\r
199 Value,\r
200 Instance,\r
201 CallerId,\r
202 Data\r
203 );\r
204 }\r
205\r
206 //\r
207 // Restore the nest status of report\r
208 //\r
209 InterlockedCompareExchange32 (&gDxeStatusCode.StatusCodeNestStatus, 1, 0);\r
210\r
211 return EFI_SUCCESS;\r
212}\r
213\r
214\r
215/**\r
216 Virtual address change notification call back. It converts global pointer\r
217 to virtual address.\r
218\r
219 @param Event Event whose notification function is being invoked.\r
220 @param Context Pointer to the notification function's context, which is\r
221 always zero in current implementation.\r
222\r
223**/\r
224VOID\r
225EFIAPI\r
226VirtualAddressChangeCallBack (\r
227 IN EFI_EVENT Event,\r
228 IN VOID *Context\r
229 )\r
230{\r
231 //\r
232 // Convert memory status code table to virtual address;\r
233 //\r
234 EfiConvertPointer (\r
235 0,\r
236 (VOID **) &gDxeStatusCode.RtMemoryStatusCodeTable[PHYSICAL_MODE]\r
237 );\r
238}\r
239\r