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 PEI_NT_THUNK_PPI
*NtThunkPpi
;
52 // Locate NtThunkPpi for retrieving standard output handle
54 Status
= PeiServicesLocatePpi (
61 ASSERT_EFI_ERROR (Status
);
63 mWinNt
= (EFI_WIN_NT_THUNK_PROTOCOL
*) NtThunkPpi
->NtThunk ();
67 // Cache standard output handle.
69 mStdOut
= mWinNt
->GetStdHandle (STD_OUTPUT_HANDLE
);
75 Report status code to OEM device.
77 @param CodeType Indicates the type of status code being reported. Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.
79 @param Value Describes the current status of a hardware or software entity.
80 This included information about the class and subclass that is used to classify the entity
81 as well as an operation. For progress codes, the operation is the current activity.
82 For error codes, it is the exception. For debug codes, it is not defined at this time.
83 Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.
84 Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.
86 @param Instance The enumeration of a hardware or software entity within the system.
87 A system may contain multiple entities that match a class/subclass pairing.
88 The instance differentiates between them. An instance of 0 indicates that instance information is unavailable,
89 not meaningful, or not relevant. Valid instance numbers start with 1.
92 @param CallerId This optional parameter may be used to identify the caller.
93 This parameter allows the status code driver to apply different rules to different callers.
94 Type EFI_GUID is defined in InstallProtocolInterface() in the EFI 1.10 Specification.
97 @param Data This optional parameter may be used to pass additional data
99 @return The function always return EFI_SUCCESS.
104 OemHookStatusCodeReport (
105 IN EFI_STATUS_CODE_TYPE CodeType
,
106 IN EFI_STATUS_CODE_VALUE Value
,
108 IN EFI_GUID
*CallerId
, OPTIONAL
109 IN EFI_STATUS_CODE_DATA
*Data OPTIONAL
115 CHAR8 Buffer
[EFI_STATUS_CODE_DATA_MAX_SIZE
];
120 EFI_DEBUG_INFO
*DebugInfo
;
125 ReportStatusCodeExtractAssertInfo (CodeType
, Value
, Data
, &Filename
, &Description
, &LineNumber
)) {
127 // Print ASSERT() information into output buffer.
129 CharCount
= AsciiSPrint (
131 EFI_STATUS_CODE_DATA_MAX_SIZE
,
132 "\n\rASSERT!: %a (%d): %a\n\r",
139 // Callout to standard output.
151 } else if (Data
!= NULL
&&
152 ReportStatusCodeExtractDebugInfo (Data
, &ErrorLevel
, &Marker
, &Format
)) {
154 // Print DEBUG() information into output buffer.
156 CharCount
= AsciiVSPrint (
158 EFI_STATUS_CODE_DATA_MAX_SIZE
,
162 } else if (Data
!= NULL
&&
163 CompareGuid (&Data
->Type
, &gEfiStatusCodeSpecificDataGuid
) &&
164 (CodeType
& EFI_STATUS_CODE_TYPE_MASK
) == EFI_DEBUG_CODE
) {
166 // Print specific data into output buffer.
168 DebugInfo
= (EFI_DEBUG_INFO
*) (Data
+ 1);
169 Marker
= (VA_LIST
) (DebugInfo
+ 1);
170 Format
= (CHAR8
*) (((UINT64
*) Marker
) + 12);
172 CharCount
= AsciiVSPrint (Buffer
, EFI_STATUS_CODE_DATA_MAX_SIZE
, Format
, Marker
);
173 } else if ((CodeType
& EFI_STATUS_CODE_TYPE_MASK
) == EFI_ERROR_CODE
) {
175 // Print ERROR information into output buffer.
177 CharCount
= AsciiSPrint (
179 EFI_STATUS_CODE_DATA_MAX_SIZE
,
180 "ERROR: C%x:V%x I%x",
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 (
216 EFI_STATUS_CODE_DATA_MAX_SIZE
,
217 "PROGRESS CODE: V%x I%x\n\r",
222 CharCount
= AsciiSPrint (
224 EFI_STATUS_CODE_DATA_MAX_SIZE
,
225 "Undefined: C%x:V%x I%x\n\r",
233 // Callout to standard output.