2 Status code driver for IA32/X64/EBC architecture.
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
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.
149 DxeStatusCodeDriverEntry (
150 IN EFI_HANDLE ImageHandle
,
151 IN EFI_SYSTEM_TABLE
*SystemTable
155 // Dispatch initialization request to supported devices
157 InitializationDispatcherWorker ();
160 // Initialize ESAL capabilities.
163 &gEfiExtendedSalStatusCodeServicesProtocolGuid
,
165 ReportEsalServiceEntry
,
175 Virtual address change notification call back. It converts physical mode global pointer to
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.
185 VirtualAddressChangeCallBack (
190 gDxeStatusCode
.RtMemoryStatusCodeTable
[VIRTUAL_MODE
] =
191 gDxeStatusCode
.RtMemoryStatusCodeTable
[PHYSICAL_MODE
];
194 // Convert the physical mode pointer to virtual mode point.
198 (VOID
**) &gDxeStatusCode
.RtMemoryStatusCodeTable
[VIRTUAL_MODE
]