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