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