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