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