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