2 Status code driver for IA32/X64/EBC architecture.
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
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.
13 Module Name: DxeStatusCodeIpf.c
17 #include "DxeStatusCode.h"
21 // Delaration of DXE status code controller
23 DXE_STATUS_CODE_CONTROLLER gDxeStatusCode
= {
25 // Initialize nest status as non nested.
33 Main entry for Extended SAL ReportStatusCode Services
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
40 @param Arg6 Efi status code data
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
47 @return Value returned in SAL_RETURN_REGS
52 ReportEsalServiceEntry (
61 IN SAL_EXTENDED_SAL_PROC ExtendedSalProc
,
62 IN BOOLEAN VirtualMode
,
66 SAL_RETURN_REGS ReturnVal
;
67 DXE_STATUS_CODE_CONTROLLER
*DxeStatusCode
;
71 case ReportStatusCodeService
:
73 DxeStatusCode
= (DXE_STATUS_CODE_CONTROLLER
*) Global
;
76 // Use atom operation to avoid the reentant of report.
77 // If current status is not zero, then the function is reentrancy.
79 if (InterlockedCompareExchange32 (&DxeStatusCode
->StatusCodeNestStatus
, 0, 1)) {
80 ReturnVal
.Status
= EFI_DEVICE_ERROR
;
84 if (FeaturePcdGet (PcdStatusCodeUseEfiSerial
) || FeaturePcdGet (PcdStatusCodeUseHardSerial
)) {
85 SerialStatusCodeReportWorker (
86 (EFI_STATUS_CODE_TYPE
) Arg2
,
87 (EFI_STATUS_CODE_VALUE
) Arg3
,
90 (EFI_STATUS_CODE_DATA
*) Arg6
93 if (FeaturePcdGet (PcdStatusCodeUseRuntimeMemory
)) {
94 RtMemoryStatusCodeReportWorker (
95 DxeStatusCode
->RtMemoryStatusCodeTable
[VirtualMode
],
96 (EFI_STATUS_CODE_TYPE
) Arg2
,
97 (EFI_STATUS_CODE_VALUE
) Arg3
,
101 if (FeaturePcdGet (PcdStatusCodeUseDataHub
)) {
102 DataHubStatusCodeReportWorker (
103 (EFI_STATUS_CODE_TYPE
) Arg2
,
104 (EFI_STATUS_CODE_VALUE
) Arg3
,
107 (EFI_STATUS_CODE_DATA
*) Arg6
110 if (FeaturePcdGet (PcdStatusCodeUseOEM
)) {
111 OemHookStatusCodeReport (
112 (EFI_STATUS_CODE_TYPE
) Arg2
,
113 (EFI_STATUS_CODE_VALUE
) Arg3
,
116 (EFI_STATUS_CODE_DATA
*) Arg6
121 // Restore the nest status of report
123 InterlockedCompareExchange32 (&DxeStatusCode
->StatusCodeNestStatus
, 1, 0);
125 ReturnVal
.Status
= EFI_SUCCESS
;
130 ReturnVal
.Status
= EFI_SAL_INVALID_ARGUMENT
;
139 Install the ReportStatusCode runtime service.
141 @param ImageHandle Image handle of the loaded driver
142 @param SystemTable Pointer to the System Table
144 @return The function always returns success.
148 DxeStatusCodeDriverEntry (
149 IN EFI_HANDLE ImageHandle
,
150 IN EFI_SYSTEM_TABLE
*SystemTable
154 // Dispatch initialization request to supported devices
156 InitializationDispatcherWorker ();
159 // Initialize ESAL capabilities.
162 &gEfiExtendedSalStatusCodeServicesProtocolGuid
,
164 ReportEsalServiceEntry
,
174 Virtual address change notification call back. It converts physical mode global pointer to
177 @param Event Event whose notification function is being invoked.
178 @param Context Pointer to the notification function¡¯s context, which is
179 always zero in current implementation.
184 VirtualAddressChangeCallBack (
189 gDxeStatusCode
.RtMemoryStatusCodeTable
[VIRTUAL_MODE
] =
190 gDxeStatusCode
.RtMemoryStatusCodeTable
[PHYSICAL_MODE
];
193 // Convert the physical mode pointer to virtual mode point.
197 (VOID
**) &gDxeStatusCode
.RtMemoryStatusCodeTable
[VIRTUAL_MODE
]