2 OEM hook status code library functions with no library constructor/destructor
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: Nt32OemHookStatusCodeLib.c
20 // Cache of WinNtThunk protocol
22 EFI_WIN_NT_THUNK_PROTOCOL
*mWinNt
;
25 // Cache of standard output handle .
31 Initialize OEM status code device .
33 @return Always return EFI_SUCCESS.
38 OemHookStatusCodeInitialize (
42 PEI_NT_THUNK_PPI
*NtThunkPpi
;
45 if (FeaturePcdGet (PcdNt32StatusCodeLibUseForPei
)) {
47 // Locate NtThunkPpi for retrieving standard output handle
49 Status
= PeiServicesLocatePpi (
56 ASSERT_EFI_ERROR (Status
);
58 mWinNt
= (EFI_WIN_NT_THUNK_PROTOCOL
*) NtThunkPpi
->NtThunk ();
60 EFI_HOB_GUID_TYPE
*GuidHob
;
63 // Retrieve WinNtThunkProtocol from GUID'ed HOB
65 GuidHob
= GetFirstGuidHob (&gEfiWinNtThunkProtocolGuid
);
66 ASSERT (GuidHob
!= NULL
);
67 mWinNt
= (EFI_WIN_NT_THUNK_PROTOCOL
*)(*(UINTN
*)(GET_GUID_HOB_DATA (GuidHob
)));
68 ASSERT (mWinNt
!= NULL
);
72 // Cache standard output handle.
74 mStdOut
= mWinNt
->GetStdHandle (STD_OUTPUT_HANDLE
);
80 Report status code to OEM device.
82 @param CodeType Indicates the type of status code being reported. Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions¡± below.
84 @param Value Describes the current status of a hardware or software entity.
85 This included information about the class and subclass that is used to classify the entity
86 as well as an operation. For progress codes, the operation is the current activity.
87 For error codes, it is the exception. For debug codes, it is not defined at this time.
88 Type EFI_STATUS_CODE_VALUE is defined in ¡°Related Definitions¡± below.
89 Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.
91 @param Instance The enumeration of a hardware or software entity within the system.
92 A system may contain multiple entities that match a class/subclass pairing.
93 The instance differentiates between them. An instance of 0 indicates that instance information is unavailable,
94 not meaningful, or not relevant. Valid instance numbers start with 1.
97 @param CallerId This optional parameter may be used to identify the caller.
98 This parameter allows the status code driver to apply different rules to different callers.
99 Type EFI_GUID is defined in InstallProtocolInterface() in the EFI 1.10 Specification.
102 @param Data This optional parameter may be used to pass additional data
104 @return The function always return EFI_SUCCESS.
109 OemHookStatusCodeReport (
110 IN EFI_STATUS_CODE_TYPE CodeType
,
111 IN EFI_STATUS_CODE_VALUE Value
,
113 IN EFI_GUID
*CallerId
, OPTIONAL
114 IN EFI_STATUS_CODE_DATA
*Data OPTIONAL
120 CHAR8 Buffer
[EFI_STATUS_CODE_DATA_MAX_SIZE
];
125 EFI_DEBUG_INFO
*DebugInfo
;
130 ReportStatusCodeExtractAssertInfo (CodeType
, Value
, Data
, &Filename
, &Description
, &LineNumber
)) {
132 // Print ASSERT() information into output buffer.
134 CharCount
= AsciiSPrint (
136 EFI_STATUS_CODE_DATA_MAX_SIZE
,
137 "\n\rASSERT!: %a (%d): %a\n\r",
144 // Callout to standard output.
158 } else if (Data
!= NULL
&&
159 ReportStatusCodeExtractDebugInfo (Data
, &ErrorLevel
, &Marker
, &Format
)) {
161 // Print DEBUG() information into output buffer.
163 CharCount
= AsciiVSPrint (
165 EFI_STATUS_CODE_DATA_MAX_SIZE
,
169 } else if (Data
!= NULL
&&
170 CompareGuid (&Data
->Type
, &gEfiStatusCodeSpecificDataGuid
) &&
171 (CodeType
& EFI_STATUS_CODE_TYPE_MASK
) == EFI_DEBUG_CODE
) {
173 // Print specific data into output buffer.
175 DebugInfo
= (EFI_DEBUG_INFO
*) (Data
+ 1);
176 Marker
= (VA_LIST
) (DebugInfo
+ 1);
177 Format
= (CHAR8
*) (((UINT64
*) Marker
) + 12);
179 CharCount
= AsciiVSPrint (Buffer
, EFI_STATUS_CODE_DATA_MAX_SIZE
, Format
, Marker
);
180 } else if ((CodeType
& EFI_STATUS_CODE_TYPE_MASK
) == EFI_ERROR_CODE
) {
182 // Print ERROR information into output buffer.
184 CharCount
= AsciiSPrint (Buffer
, EFI_STATUS_CODE_DATA_MAX_SIZE
, "ERROR: C%x:V%x I%x", CodeType
, Value
, Instance
);
187 // Make sure we don't try to print values that weren't intended to be printed, especially NULL GUID pointers.
190 if (CallerId
!= NULL
) {
191 CharCount
+= AsciiSPrint (
192 &Buffer
[CharCount
- 1],
193 (EFI_STATUS_CODE_DATA_MAX_SIZE
- (sizeof (Buffer
[0]) * CharCount
)),
200 CharCount
+= AsciiSPrint (
201 &Buffer
[CharCount
- 1],
202 (EFI_STATUS_CODE_DATA_MAX_SIZE
- (sizeof (Buffer
[0]) * CharCount
)),
208 CharCount
+= AsciiSPrint (
209 &Buffer
[CharCount
- 1],
210 (EFI_STATUS_CODE_DATA_MAX_SIZE
- (sizeof (Buffer
[0]) * CharCount
)),
213 } else if ((CodeType
& EFI_STATUS_CODE_TYPE_MASK
) == EFI_PROGRESS_CODE
) {
214 CharCount
= AsciiSPrint (Buffer
, EFI_STATUS_CODE_DATA_MAX_SIZE
, "PROGRESS CODE: V%x I%x\n\r", Value
, Instance
);
216 CharCount
= AsciiSPrint (Buffer
, EFI_STATUS_CODE_DATA_MAX_SIZE
, "Undefined: C%x:V%x I%x\n\r", CodeType
, Value
, Instance
);
220 // Callout to standard output.