2 OEM hook status code library functions with no library constructor/destructor
4 Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
5 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: UnixOemHookStatusCodeLib.c
16 #include <Guid/StatusCodeDataTypeId.h>
17 #include <Guid/StatusCodeDataTypeDebug.h>
19 #include <Library/OemHookStatusCodeLib.h>
20 #include <Library/DebugLib.h>
21 #include <Library/HobLib.h>
22 #include <Library/PrintLib.h>
23 #include <Library/BaseMemoryLib.h>
24 #include <Library/ReportStatusCodeLib.h>
27 // Cache of UnixThunk protocol
29 EFI_UNIX_THUNK_PROTOCOL
*mUnix
;
32 // Cache of standard output handle .
38 Initialize OEM status code device .
40 @return Always return EFI_SUCCESS.
45 OemHookStatusCodeInitialize (
49 EFI_HOB_GUID_TYPE
*GuidHob
;
52 // Retrieve UnixThunkProtocol from GUID'ed HOB
54 GuidHob
= GetFirstGuidHob (&gEfiUnixThunkProtocolGuid
);
55 ASSERT (GuidHob
!= NULL
);
56 mUnix
= (EFI_UNIX_THUNK_PROTOCOL
*)(*(UINTN
*)(GET_GUID_HOB_DATA (GuidHob
)));
57 ASSERT (mUnix
!= NULL
);
60 // Cache standard output handle.
68 Report status code to OEM device.
70 @param CodeType Indicates the type of status code being reported. Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.
72 @param Value Describes the current status of a hardware or software entity.
73 This included information about the class and subclass that is used to classify the entity
74 as well as an operation. For progress codes, the operation is the current activity.
75 For error codes, it is the exception. For debug codes, it is not defined at this time.
76 Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.
77 Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.
79 @param Instance The enumeration of a hardware or software entity within the system.
80 A system may contain multiple entities that match a class/subclass pairing.
81 The instance differentiates between them. An instance of 0 indicates that instance information is unavailable,
82 not meaningful, or not relevant. Valid instance numbers start with 1.
85 @param CallerId This optional parameter may be used to identify the caller.
86 This parameter allows the status code driver to apply different rules to different callers.
87 Type EFI_GUID is defined in InstallProtocolInterface() in the EFI 1.10 Specification.
90 @param Data This optional parameter may be used to pass additional data
92 @return The function always return EFI_SUCCESS.
97 OemHookStatusCodeReport (
98 IN EFI_STATUS_CODE_TYPE CodeType
,
99 IN EFI_STATUS_CODE_VALUE Value
,
101 IN EFI_GUID
*CallerId
, OPTIONAL
102 IN EFI_STATUS_CODE_DATA
*Data OPTIONAL
108 CHAR8 Buffer
[EFI_STATUS_CODE_DATA_MAX_SIZE
];
117 ReportStatusCodeExtractAssertInfo (CodeType
, Value
, Data
, &Filename
, &Description
, &LineNumber
)) {
119 // Print ASSERT() information into output buffer.
121 CharCount
= AsciiSPrint (
124 "\n\rASSERT!: %a (%d): %a\n\r",
131 // Callout to standard output.
141 } else if (Data
!= NULL
&&
142 ReportStatusCodeExtractDebugInfo (Data
, &ErrorLevel
, &Marker
, &Format
)) {
144 // Print DEBUG() information into output buffer.
146 CharCount
= AsciiBSPrint (
152 } else if ((CodeType
& EFI_STATUS_CODE_TYPE_MASK
) == EFI_ERROR_CODE
) {
154 // Print ERROR information into output buffer.
156 CharCount
= AsciiSPrint (
159 "ERROR: C%x:V%x I%x",
166 // Make sure we don't try to print values that weren't intended to be printed, especially NULL GUID pointers.
169 if (CallerId
!= NULL
) {
170 CharCount
+= AsciiSPrint (
171 &Buffer
[CharCount
- 1],
172 (sizeof (Buffer
) - (sizeof (Buffer
[0]) * CharCount
)),
179 CharCount
+= AsciiSPrint (
180 &Buffer
[CharCount
- 1],
181 (sizeof (Buffer
) - (sizeof (Buffer
[0]) * CharCount
)),
187 CharCount
+= AsciiSPrint (
188 &Buffer
[CharCount
- 1],
189 (sizeof (Buffer
) - (sizeof (Buffer
[0]) * CharCount
)),
192 } else if ((CodeType
& EFI_STATUS_CODE_TYPE_MASK
) == EFI_PROGRESS_CODE
) {
193 CharCount
= AsciiSPrint (
196 "PROGRESS CODE: V%x I%x\n\r",
201 CharCount
= AsciiSPrint (
204 "Undefined: C%x:V%x I%x\n\r",
212 // Callout to standard output.