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
18 // Include common header file for this module.
20 #include "CommonHeader.h"
23 // Cache of WinNtThunk protocol
26 EFI_WIN_NT_THUNK_PROTOCOL
*mWinNt
;
29 // Cache of standard output handle .
36 Initialize OEM status code device .
38 @return Always return EFI_SUCCESS.
43 OemHookStatusCodeInitialize (
47 EFI_HOB_GUID_TYPE
*GuidHob
;
50 // Retrieve WinNtThunkProtocol from GUID'ed HOB
52 GuidHob
= GetFirstGuidHob (&gEfiWinNtThunkProtocolGuid
);
53 ASSERT (GuidHob
!= NULL
);
54 mWinNt
= (EFI_WIN_NT_THUNK_PROTOCOL
*)(*(UINTN
*)(GET_GUID_HOB_DATA (GuidHob
)));
55 ASSERT (mWinNt
!= NULL
);
58 // Cache standard output handle.
60 mStdOut
= mWinNt
->GetStdHandle (STD_OUTPUT_HANDLE
);
66 Report status code to OEM device.
68 @param CodeType Indicates the type of status code being reported. Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.
70 @param Value Describes the current status of a hardware or software entity.
71 This included information about the class and subclass that is used to classify the entity
72 as well as an operation. For progress codes, the operation is the current activity.
73 For error codes, it is the exception. For debug codes, it is not defined at this time.
74 Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.
75 Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.
77 @param Instance The enumeration of a hardware or software entity within the system.
78 A system may contain multiple entities that match a class/subclass pairing.
79 The instance differentiates between them. An instance of 0 indicates that instance information is unavailable,
80 not meaningful, or not relevant. Valid instance numbers start with 1.
83 @param CallerId This optional parameter may be used to identify the caller.
84 This parameter allows the status code driver to apply different rules to different callers.
85 Type EFI_GUID is defined in InstallProtocolInterface() in the EFI 1.10 Specification.
88 @param Data This optional parameter may be used to pass additional data
90 @return The function always return EFI_SUCCESS.
95 OemHookStatusCodeReport (
96 IN EFI_STATUS_CODE_TYPE CodeType
,
97 IN EFI_STATUS_CODE_VALUE Value
,
99 IN EFI_GUID
*CallerId
, OPTIONAL
100 IN EFI_STATUS_CODE_DATA
*Data OPTIONAL
106 CHAR8 Buffer
[EFI_STATUS_CODE_DATA_MAX_SIZE
];
111 EFI_DEBUG_INFO
*DebugInfo
;
116 ReportStatusCodeExtractAssertInfo (CodeType
, Value
, Data
, &Filename
, &Description
, &LineNumber
)) {
118 // Print ASSERT() information into output buffer.
120 CharCount
= AsciiSPrint (
122 EFI_STATUS_CODE_DATA_MAX_SIZE
,
123 "\n\rASSERT!: %a (%d): %a\n\r",
130 // Callout to standard output.
142 } else if (Data
!= NULL
&&
143 ReportStatusCodeExtractDebugInfo (Data
, &ErrorLevel
, &Marker
, &Format
)) {
145 // Print DEBUG() information into output buffer.
147 CharCount
= AsciiVSPrint (
149 EFI_STATUS_CODE_DATA_MAX_SIZE
,
153 } else if (Data
!= NULL
&&
154 CompareGuid (&Data
->Type
, &gEfiStatusCodeSpecificDataGuid
) &&
155 (CodeType
& EFI_STATUS_CODE_TYPE_MASK
) == EFI_DEBUG_CODE
) {
157 // Print specific data into output buffer.
159 DebugInfo
= (EFI_DEBUG_INFO
*) (Data
+ 1);
160 Marker
= (VA_LIST
) (DebugInfo
+ 1);
161 Format
= (CHAR8
*) (((UINT64
*) Marker
) + 12);
163 CharCount
= AsciiVSPrint (Buffer
, EFI_STATUS_CODE_DATA_MAX_SIZE
, Format
, Marker
);
164 } else if ((CodeType
& EFI_STATUS_CODE_TYPE_MASK
) == EFI_ERROR_CODE
) {
166 // Print ERROR information into output buffer.
168 CharCount
= AsciiSPrint (
170 EFI_STATUS_CODE_DATA_MAX_SIZE
,
171 "ERROR: C%x:V%x I%x",
178 // Make sure we don't try to print values that weren't intended to be printed, especially NULL GUID pointers.
181 if (CallerId
!= NULL
) {
182 CharCount
+= AsciiSPrint (
183 &Buffer
[CharCount
- 1],
184 (EFI_STATUS_CODE_DATA_MAX_SIZE
- (sizeof (Buffer
[0]) * CharCount
)),
191 CharCount
+= AsciiSPrint (
192 &Buffer
[CharCount
- 1],
193 (EFI_STATUS_CODE_DATA_MAX_SIZE
- (sizeof (Buffer
[0]) * CharCount
)),
199 CharCount
+= AsciiSPrint (
200 &Buffer
[CharCount
- 1],
201 (EFI_STATUS_CODE_DATA_MAX_SIZE
- (sizeof (Buffer
[0]) * CharCount
)),
204 } else if ((CodeType
& EFI_STATUS_CODE_TYPE_MASK
) == EFI_PROGRESS_CODE
) {
205 CharCount
= AsciiSPrint (
207 EFI_STATUS_CODE_DATA_MAX_SIZE
,
208 "PROGRESS CODE: V%x I%x\n\r",
213 CharCount
= AsciiSPrint (
215 EFI_STATUS_CODE_DATA_MAX_SIZE
,
216 "Undefined: C%x:V%x I%x\n\r",
224 // Callout to standard output.