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 // Include common header file for this module.
21 #include "CommonHeader.h"
23 #include "PeiStatusCode.h"
26 Convert status code value and extended data to readable ASCII string, send string to serial I/O device.
28 @param CodeType Indicates the type of status code being reported. Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.
30 @param Value Describes the current status of a hardware or software entity.
31 This included information about the class and subclass that is used to classify the entity
32 as well as an operation. For progress codes, the operation is the current activity.
33 For error codes, it is the exception. For debug codes, it is not defined at this time.
34 Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.
35 Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.
37 @param Instance The enumeration of a hardware or software entity within the system.
38 A system may contain multiple entities that match a class/subclass pairing.
39 The instance differentiates between them. An instance of 0 indicates that instance information is unavailable,
40 not meaningful, or not relevant. Valid instance numbers start with 1.
43 @param CallerId This optional parameter may be used to identify the caller.
44 This parameter allows the status code driver to apply different rules to different callers.
45 Type EFI_GUID is defined in InstallProtocolInterface() in the EFI 1.10 Specification.
48 @param Data This optional parameter may be used to pass additional data
50 @return The function always return EFI_SUCCESS.
54 SerialStatusCodeReportWorker (
55 IN EFI_STATUS_CODE_TYPE CodeType
,
56 IN EFI_STATUS_CODE_VALUE Value
,
58 IN EFI_GUID
*CallerId
,
59 IN EFI_STATUS_CODE_DATA
*Data OPTIONAL
65 CHAR8 Buffer
[EFI_STATUS_CODE_DATA_MAX_SIZE
];
70 EFI_DEBUG_INFO
*DebugInfo
;
75 ReportStatusCodeExtractAssertInfo (CodeType
, Value
, Data
, &Filename
, &Description
, &LineNumber
)) {
77 // Print ASSERT() information into output buffer.
79 CharCount
= AsciiSPrint (
81 EFI_STATUS_CODE_DATA_MAX_SIZE
,
82 "\n\rPEI_ASSERT!: %a (%d): %a\n\r",
87 } else if (Data
!= NULL
&&
88 ReportStatusCodeExtractDebugInfo (Data
, &ErrorLevel
, &Marker
, &Format
)) {
90 // Print DEBUG() information into output buffer.
92 CharCount
= AsciiVSPrint (
94 EFI_STATUS_CODE_DATA_MAX_SIZE
,
98 } else if (Data
!= NULL
&&
99 CompareGuid (&Data
->Type
, &gEfiStatusCodeSpecificDataGuid
) &&
100 (CodeType
& EFI_STATUS_CODE_TYPE_MASK
) == EFI_DEBUG_CODE
) {
102 // Print specific data into output buffer.
104 DebugInfo
= (EFI_DEBUG_INFO
*) (Data
+ 1);
105 Marker
= (VA_LIST
) (DebugInfo
+ 1);
106 Format
= (CHAR8
*) (((UINT64
*) Marker
) + 12);
108 CharCount
= AsciiVSPrint (Buffer
, EFI_STATUS_CODE_DATA_MAX_SIZE
, Format
, Marker
);
109 } else if ((CodeType
& EFI_STATUS_CODE_TYPE_MASK
) == EFI_ERROR_CODE
) {
111 // Print ERROR information into output buffer.
113 CharCount
= AsciiSPrint (
115 EFI_STATUS_CODE_DATA_MAX_SIZE
,
116 "ERROR: C%x:V%x I%x",
123 // Make sure we don't try to print values that weren't intended to be printed, especially NULL GUID pointers.
126 if (CallerId
!= NULL
) {
127 CharCount
+= AsciiSPrint (
128 &Buffer
[CharCount
- 1],
129 (EFI_STATUS_CODE_DATA_MAX_SIZE
- (sizeof (Buffer
[0]) * CharCount
)),
136 CharCount
+= AsciiSPrint (
137 &Buffer
[CharCount
- 1],
138 (EFI_STATUS_CODE_DATA_MAX_SIZE
- (sizeof (Buffer
[0]) * CharCount
)),
144 CharCount
+= AsciiSPrint (
145 &Buffer
[CharCount
- 1],
146 (EFI_STATUS_CODE_DATA_MAX_SIZE
- (sizeof (Buffer
[0]) * CharCount
)),
149 } else if ((CodeType
& EFI_STATUS_CODE_TYPE_MASK
) == EFI_PROGRESS_CODE
) {
150 CharCount
= AsciiSPrint (
152 EFI_STATUS_CODE_DATA_MAX_SIZE
,
153 "PROGRESS CODE: V%x I%x\n\r",
158 CharCount
= AsciiSPrint (
160 EFI_STATUS_CODE_DATA_MAX_SIZE
,
161 "Undefined: C%x:V%x I%x\n\r",
169 // Callout to SerialPort Lib function to do print.
171 SerialPortWrite ((UINT8
*) Buffer
, CharCount
);