3 Serial I/O status code reporting worker.
5 Copyright (c) 2006, Intel Corporation
6 All rights reserved. This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14 Module Name: SerialStatusCodeWorker.c
19 Convert status code value and extended data to readable ASCII string, send string to serial I/O device.
21 @param CodeType Indicates the type of status code being reported. Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions¡± below.
23 @param Value Describes the current status of a hardware or software entity.
24 This included information about the class and subclass that is used to classify the entity
25 as well as an operation. For progress codes, the operation is the current activity.
26 For error codes, it is the exception. For debug codes, it is not defined at this time.
27 Type EFI_STATUS_CODE_VALUE is defined in ¡°Related Definitions¡± below.
28 Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.
30 @param Instance The enumeration of a hardware or software entity within the system.
31 A system may contain multiple entities that match a class/subclass pairing.
32 The instance differentiates between them. An instance of 0 indicates that instance information is unavailable,
33 not meaningful, or not relevant. Valid instance numbers start with 1.
36 @param CallerId This optional parameter may be used to identify the caller.
37 This parameter allows the status code driver to apply different rules to different callers.
38 Type EFI_GUID is defined in InstallProtocolInterface() in the EFI 1.10 Specification.
41 @param Data This optional parameter may be used to pass additional data
43 @return The function always return EFI_SUCCESS.
47 SerialStatusCodeReportWorker (
48 IN EFI_STATUS_CODE_TYPE CodeType
,
49 IN EFI_STATUS_CODE_VALUE Value
,
51 IN EFI_GUID
*CallerId
,
52 IN EFI_STATUS_CODE_DATA
*Data OPTIONAL
58 CHAR8 Buffer
[EFI_STATUS_CODE_DATA_MAX_SIZE
];
63 EFI_DEBUG_INFO
*DebugInfo
;
68 ReportStatusCodeExtractAssertInfo (CodeType
, Value
, Data
, &Filename
, &Description
, &LineNumber
)) {
70 // Print ASSERT() information into output buffer.
72 CharCount
= AsciiSPrint (
74 EFI_STATUS_CODE_DATA_MAX_SIZE
,
75 "\n\rPEI_ASSERT!: %a (%d): %a\n\r",
80 } else if (Data
!= NULL
&&
81 ReportStatusCodeExtractDebugInfo (Data
, &ErrorLevel
, &Marker
, &Format
)) {
83 // Print DEBUG() information into output buffer.
85 CharCount
= AsciiVSPrint (
87 EFI_STATUS_CODE_DATA_MAX_SIZE
,
91 } else if (Data
!= NULL
&&
92 CompareGuid (&Data
->Type
, &gEfiStatusCodeSpecificDataGuid
) &&
93 (CodeType
& EFI_STATUS_CODE_TYPE_MASK
) == EFI_DEBUG_CODE
) {
95 // Print specific data into output buffer.
97 DebugInfo
= (EFI_DEBUG_INFO
*) (Data
+ 1);
98 Marker
= (VA_LIST
) (DebugInfo
+ 1);
99 Format
= (CHAR8
*) (((UINT64
*) Marker
) + 12);
101 CharCount
= AsciiVSPrint (Buffer
, EFI_STATUS_CODE_DATA_MAX_SIZE
, Format
, Marker
);
102 } else if ((CodeType
& EFI_STATUS_CODE_TYPE_MASK
) == EFI_ERROR_CODE
) {
104 // Print ERROR information into output buffer.
106 CharCount
= AsciiSPrint (
108 EFI_STATUS_CODE_DATA_MAX_SIZE
,
109 "ERROR: C%x:V%x I%x",
116 // Make sure we don't try to print values that weren't intended to be printed, especially NULL GUID pointers.
119 if (CallerId
!= NULL
) {
120 CharCount
+= AsciiSPrint (
121 &Buffer
[CharCount
- 1],
122 (EFI_STATUS_CODE_DATA_MAX_SIZE
- (sizeof (Buffer
[0]) * CharCount
)),
129 CharCount
+= AsciiSPrint (
130 &Buffer
[CharCount
- 1],
131 (EFI_STATUS_CODE_DATA_MAX_SIZE
- (sizeof (Buffer
[0]) * CharCount
)),
137 CharCount
+= AsciiSPrint (
138 &Buffer
[CharCount
- 1],
139 (EFI_STATUS_CODE_DATA_MAX_SIZE
- (sizeof (Buffer
[0]) * CharCount
)),
142 } else if ((CodeType
& EFI_STATUS_CODE_TYPE_MASK
) == EFI_PROGRESS_CODE
) {
143 CharCount
= AsciiSPrint (
145 EFI_STATUS_CODE_DATA_MAX_SIZE
,
146 "PROGRESS CODE: V%x I%x\n\r",
151 CharCount
= AsciiSPrint (
153 EFI_STATUS_CODE_DATA_MAX_SIZE
,
154 "Undefined: C%x:V%x I%x\n\r",
162 // Callout to SerialPort Lib function to do print.
164 SerialPortWrite ((UINT8
*) Buffer
, CharCount
);