]> git.proxmox.com Git - mirror_edk2.git/blob - EdkModulePkg/Universal/StatusCode/Dxe/Ipf/DxeStatusCodeIpf.c
Follow up EDKT247-253
[mirror_edk2.git] / EdkModulePkg / Universal / StatusCode / Dxe / Ipf / DxeStatusCodeIpf.c
1 /** @file
2 * Status code driver for IPF 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: 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 (1 == 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 DxeStatusCodeDriverEntry (
149 IN EFI_HANDLE ImageHandle,
150 IN EFI_SYSTEM_TABLE *SystemTable
151 )
152 {
153 EFI_STATUS Status;
154
155 //
156 // Dispatch initialization request to supported devices
157 //
158 InitializationDispatcherWorker ();
159
160 //
161 // Initialize ESAL capabilities.
162 //
163 Status = RegisterEsalClass (
164 &gEfiExtendedSalStatusCodeServicesProtocolGuid,
165 &gDxeStatusCode,
166 ReportEsalServiceEntry,
167 StatusCode,
168 NULL
169 );
170 ASSERT_EFI_ERROR (Status);
171
172 return EFI_SUCCESS;
173 }
174
175
176 /**
177 Virtual address change notification call back. It converts physical mode global pointer to
178 virtual mode.
179
180 @param Event Event whose notification function is being invoked.
181 @param Context Pointer to the notification function¡¯s context, which is
182 always zero in current implementation.
183
184 **/
185 VOID
186 EFIAPI
187 VirtualAddressChangeCallBack (
188 IN EFI_EVENT Event,
189 IN VOID *Context
190 )
191 {
192 gDxeStatusCode.RtMemoryStatusCodeTable[VIRTUAL_MODE] =
193 gDxeStatusCode.RtMemoryStatusCodeTable[PHYSICAL_MODE];
194
195 //
196 // Convert the physical mode pointer to virtual mode point.
197 //
198 EfiConvertPointer (
199 0,
200 (VOID **) &gDxeStatusCode.RtMemoryStatusCodeTable[VIRTUAL_MODE]
201 );
202 }
203