]> git.proxmox.com Git - mirror_edk2.git/blob - EdkModulePkg/Universal/StatusCode/Dxe/Ipf/DxeStatusCodeIpf.c
756c2744958cfeb5dd0bbed81b94af8d8fec9945
[mirror_edk2.git] / EdkModulePkg / Universal / StatusCode / Dxe / Ipf / DxeStatusCodeIpf.c
1 /** @file
2 Status code driver for IA32/X64/EBC architecture.
3
4 // Copyright (c) 2006, Intel Corporation. All rights reserved.
5 // This software and associated documentation (if any) is furnished
6 // under a license and may only be used or copied in accordance
7 // with the terms of the license. Except as permitted by such
8 // license, no part of this software or documentation may be
9 // reproduced, stored in a retrieval system, or transmitted in any
10 // form or by any means without the express written consent of
11 // Intel Corporation.
12
13 Module Name: DxeStatusCodeIpf.c
14
15 **/
16
17 #include "DxeStatusCode.h"
18
19
20 //
21 // Delaration of DXE status code controller
22 //
23 DXE_STATUS_CODE_CONTROLLER gDxeStatusCode = {
24 //
25 // Initialize nest status as non nested.
26 //
27 0,
28 {NULL, NULL}
29 };
30
31 /**
32
33 Main entry for Extended SAL ReportStatusCode Services
34
35 @param FunctionId Function Id which needed to be called
36 @param Arg2 Efi status code type
37 @param Arg3 Efi status code value
38 @param Arg4 Instance number
39 @param Arg5 Caller Id
40 @param Arg6 Efi status code data
41 @param Arg7 Not used
42 @param Arg8 Not used
43 @param ExtendedSalProc Esal Proc pointer
44 @param VirtualMode If this function is called in virtual mode
45 @param Global This module's global variable pointer
46
47 @return Value returned in SAL_RETURN_REGS
48
49 --*/
50 SAL_RETURN_REGS
51 EFIAPI
52 ReportEsalServiceEntry (
53 IN UINT64 FunctionId,
54 IN UINT64 Arg2,
55 IN UINT64 Arg3,
56 IN UINT64 Arg4,
57 IN UINT64 Arg5,
58 IN UINT64 Arg6,
59 IN UINT64 Arg7,
60 IN UINT64 Arg8,
61 IN SAL_EXTENDED_SAL_PROC ExtendedSalProc,
62 IN BOOLEAN VirtualMode,
63 IN VOID *Global
64 )
65 {
66 SAL_RETURN_REGS ReturnVal;
67 DXE_STATUS_CODE_CONTROLLER *DxeStatusCode;
68
69 switch (FunctionId) {
70
71 case ReportStatusCodeService:
72
73 DxeStatusCode = (DXE_STATUS_CODE_CONTROLLER *) Global;
74
75 //
76 // Use atom operation to avoid the reentant of report.
77 // If current status is not zero, then the function is reentrancy.
78 //
79 if (InterlockedCompareExchange32 (&DxeStatusCode->StatusCodeNestStatus, 0, 1)) {
80 ReturnVal.Status = EFI_DEVICE_ERROR ;
81 return ReturnVal;
82 }
83
84 if (FeaturePcdGet (PcdStatusCodeUseEfiSerial) || FeaturePcdGet (PcdStatusCodeUseHardSerial)) {
85 SerialStatusCodeReportWorker (
86 (EFI_STATUS_CODE_TYPE) Arg2,
87 (EFI_STATUS_CODE_VALUE) Arg3,
88 (UINT32) Arg4,
89 (EFI_GUID *) Arg5,
90 (EFI_STATUS_CODE_DATA *) Arg6
91 );
92 }
93 if (FeaturePcdGet (PcdStatusCodeUseRuntimeMemory)) {
94 RtMemoryStatusCodeReportWorker (
95 DxeStatusCode->RtMemoryStatusCodeTable[VirtualMode],
96 (EFI_STATUS_CODE_TYPE) Arg2,
97 (EFI_STATUS_CODE_VALUE) Arg3,
98 (UINT32) Arg4
99 );
100 }
101 if (FeaturePcdGet (PcdStatusCodeUseDataHub)) {
102 DataHubStatusCodeReportWorker (
103 (EFI_STATUS_CODE_TYPE) Arg2,
104 (EFI_STATUS_CODE_VALUE) Arg3,
105 (UINT32) Arg4,
106 (EFI_GUID *) Arg5,
107 (EFI_STATUS_CODE_DATA *) Arg6
108 );
109 }
110 if (FeaturePcdGet (PcdStatusCodeUseOEM)) {
111 OemHookStatusCodeReport (
112 (EFI_STATUS_CODE_TYPE) Arg2,
113 (EFI_STATUS_CODE_VALUE) Arg3,
114 (UINT32) Arg4,
115 (EFI_GUID *) Arg5,
116 (EFI_STATUS_CODE_DATA *) Arg6
117 );
118 }
119
120 //
121 // Restore the nest status of report
122 //
123 InterlockedCompareExchange32 (&DxeStatusCode->StatusCodeNestStatus, 1, 0);
124
125 ReturnVal.Status = EFI_SUCCESS;
126
127 break;
128
129 default:
130 ReturnVal.Status = EFI_SAL_INVALID_ARGUMENT;
131 break;
132 }
133
134 return ReturnVal;
135 }
136
137 /**
138
139 Install the ReportStatusCode runtime service.
140
141 @param ImageHandle Image handle of the loaded driver
142 @param SystemTable Pointer to the System Table
143
144 @return The function always returns success.
145
146 **/
147 EFI_STATUS
148 EFIAPI
149 DxeStatusCodeDriverEntry (
150 IN EFI_HANDLE ImageHandle,
151 IN EFI_SYSTEM_TABLE *SystemTable
152 )
153 {
154 //
155 // Dispatch initialization request to supported devices
156 //
157 InitializationDispatcherWorker ();
158
159 //
160 // Initialize ESAL capabilities.
161 //
162 RegisterEsalClass (
163 &gEfiExtendedSalStatusCodeServicesProtocolGuid,
164 &gDxeStatusCode,
165 ReportEsalServiceEntry,
166 StatusCode,
167 NULL
168 );
169
170 return EFI_SUCCESS;
171 }
172
173
174 /**
175 Virtual address change notification call back. It converts physical mode global pointer to
176 virtual mode.
177
178 @param Event Event whose notification function is being invoked.
179 @param Context Pointer to the notification function¡¯s context, which is
180 always zero in current implementation.
181
182 **/
183 VOID
184 EFIAPI
185 VirtualAddressChangeCallBack (
186 IN EFI_EVENT Event,
187 IN VOID *Context
188 )
189 {
190 gDxeStatusCode.RtMemoryStatusCodeTable[VIRTUAL_MODE] =
191 gDxeStatusCode.RtMemoryStatusCodeTable[PHYSICAL_MODE];
192
193 //
194 // Convert the physical mode pointer to virtual mode point.
195 //
196 EfiConvertPointer (
197 0,
198 (VOID **) &gDxeStatusCode.RtMemoryStatusCodeTable[VIRTUAL_MODE]
199 );
200 }
201