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