2 Serial I/O status code reporting worker.
4 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
8 #include "StatusCodeHandlerPei.h"
11 Convert status code value and extended data to readable ASCII string, send string to serial I/O device.
13 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
14 @param CodeType Indicates the type of status code being reported.
15 @param Value Describes the current status of a hardware or
16 software entity. This includes information about the class and
17 subclass that is used to classify the entity as well as an operation.
18 For progress codes, the operation is the current activity.
19 For error codes, it is the exception.For debug codes,it is not defined at this time.
20 @param Instance The enumeration of a hardware or software entity within
21 the system. A system may contain multiple entities that match a class/subclass
22 pairing. The instance differentiates between them. An instance of 0 indicates
23 that instance information is unavailable, not meaningful, or not relevant.
24 Valid instance numbers start with 1.
25 @param CallerId This optional parameter may be used to identify the caller.
26 This parameter allows the status code driver to apply different rules to
28 @param Data This optional parameter may be used to pass additional data.
30 @retval EFI_SUCCESS Status code reported to serial I/O successfully.
35 SerialStatusCodeReportWorker (
36 IN CONST EFI_PEI_SERVICES
**PeiServices
,
37 IN EFI_STATUS_CODE_TYPE CodeType
,
38 IN EFI_STATUS_CODE_VALUE Value
,
40 IN CONST EFI_GUID
*CallerId
,
41 IN CONST EFI_STATUS_CODE_DATA
*Data OPTIONAL
47 CHAR8 Buffer
[MAX_DEBUG_MESSAGE_LENGTH
];
56 ReportStatusCodeExtractAssertInfo (CodeType
, Value
, Data
, &Filename
, &Description
, &LineNumber
)) {
58 // Print ASSERT() information into output buffer.
60 CharCount
= AsciiSPrint (
63 "\n\rPEI_ASSERT!: %a (%d): %a\n\r",
68 } else if (Data
!= NULL
&&
69 ReportStatusCodeExtractDebugInfo (Data
, &ErrorLevel
, &Marker
, &Format
)) {
71 // Print DEBUG() information into output buffer.
73 CharCount
= AsciiBSPrint (
79 } else if ((CodeType
& EFI_STATUS_CODE_TYPE_MASK
) == EFI_ERROR_CODE
) {
81 // Print ERROR information into output buffer.
83 CharCount
= AsciiSPrint (
86 "ERROR: C%08x:V%08x I%x",
92 ASSERT(CharCount
> 0);
94 if (CallerId
!= NULL
) {
95 CharCount
+= AsciiSPrint (
97 (sizeof (Buffer
) - (sizeof (Buffer
[0]) * CharCount
)),
104 CharCount
+= AsciiSPrint (
106 (sizeof (Buffer
) - (sizeof (Buffer
[0]) * CharCount
)),
112 CharCount
+= AsciiSPrint (
114 (sizeof (Buffer
) - (sizeof (Buffer
[0]) * CharCount
)),
117 } else if ((CodeType
& EFI_STATUS_CODE_TYPE_MASK
) == EFI_PROGRESS_CODE
) {
119 // Print PROGRESS information into output buffer.
121 CharCount
= AsciiSPrint (
124 "PROGRESS CODE: V%08x I%x\n\r",
128 } else if (Data
!= NULL
&&
129 CompareGuid (&Data
->Type
, &gEfiStatusCodeDataTypeStringGuid
) &&
130 ((EFI_STATUS_CODE_STRING_DATA
*) Data
)->StringType
== EfiStringAscii
) {
132 // EFI_STATUS_CODE_STRING_DATA
134 CharCount
= AsciiSPrint (
138 ((EFI_STATUS_CODE_STRING_DATA
*) Data
)->String
.Ascii
142 // Code type is not defined.
144 CharCount
= AsciiSPrint (
147 "Undefined: C%08x:V%08x I%x\n\r",
155 // Call SerialPort Lib function to do print.
157 SerialPortWrite ((UINT8
*) Buffer
, CharCount
);