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