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
9 #include "StatusCodeHandlerRuntimeDxe.h"
12 Convert status code value and extended data to readable ASCII string, send string to serial I/O device.
14 @param CodeType Indicates the type of status code being reported.
15 @param Value Describes the current status of a hardware or software entity.
16 This included information about the class and subclass that is used to
17 classify the entity as well as an operation.
18 @param Instance The enumeration of a hardware or software entity within
19 the system. Valid instance numbers start with 1.
20 @param CallerId This optional parameter may be used to identify the caller.
21 This parameter allows the status code driver to apply different rules to
23 @param Data This optional parameter may be used to pass additional data.
25 @retval EFI_SUCCESS Status code reported to serial I/O successfully.
26 @retval EFI_DEVICE_ERROR EFI serial device cannot work after ExitBootService() is called.
27 @retval EFI_DEVICE_ERROR EFI serial device cannot work with TPL higher than TPL_CALLBACK.
32 SerialStatusCodeReportWorker (
33 IN EFI_STATUS_CODE_TYPE CodeType
,
34 IN EFI_STATUS_CODE_VALUE Value
,
36 IN EFI_GUID
*CallerId
,
37 IN EFI_STATUS_CODE_DATA
*Data OPTIONAL
43 CHAR8 Buffer
[MAX_DEBUG_MESSAGE_LENGTH
];
52 ReportStatusCodeExtractAssertInfo (CodeType
, Value
, Data
, &Filename
, &Description
, &LineNumber
)) {
54 // Print ASSERT() information into output buffer.
56 CharCount
= AsciiSPrint (
59 "\n\rDXE_ASSERT!: %a (%d): %a\n\r",
64 } else if (Data
!= NULL
&&
65 ReportStatusCodeExtractDebugInfo (Data
, &ErrorLevel
, &Marker
, &Format
)) {
67 // Print DEBUG() information into output buffer.
69 CharCount
= AsciiBSPrint (
75 } else if ((CodeType
& EFI_STATUS_CODE_TYPE_MASK
) == EFI_ERROR_CODE
) {
77 // Print ERROR information into output buffer.
79 CharCount
= AsciiSPrint (
82 "ERROR: C%08x:V%08x I%x",
87 ASSERT (CharCount
> 0);
89 if (CallerId
!= NULL
) {
90 CharCount
+= AsciiSPrint (
92 (sizeof (Buffer
) - (sizeof (Buffer
[0]) * CharCount
)),
99 CharCount
+= AsciiSPrint (
101 (sizeof (Buffer
) - (sizeof (Buffer
[0]) * CharCount
)),
107 CharCount
+= AsciiSPrint (
109 (sizeof (Buffer
) - (sizeof (Buffer
[0]) * CharCount
)),
112 } else if ((CodeType
& EFI_STATUS_CODE_TYPE_MASK
) == EFI_PROGRESS_CODE
) {
114 // Print PROGRESS information into output buffer.
116 CharCount
= AsciiSPrint (
119 "PROGRESS CODE: V%08x I%x\n\r",
123 } else if (Data
!= NULL
&&
124 CompareGuid (&Data
->Type
, &gEfiStatusCodeDataTypeStringGuid
) &&
125 ((EFI_STATUS_CODE_STRING_DATA
*) Data
)->StringType
== EfiStringAscii
) {
127 // EFI_STATUS_CODE_STRING_DATA
129 CharCount
= AsciiSPrint (
133 ((EFI_STATUS_CODE_STRING_DATA
*) Data
)->String
.Ascii
137 // Code type is not defined.
139 CharCount
= AsciiSPrint (
142 "Undefined: C%08x:V%08x I%x\n\r",
150 // Call SerialPort Lib function to do print.
152 SerialPortWrite ((UINT8
*) Buffer
, CharCount
);
155 // If register an unregister function of gEfiEventExitBootServicesGuid,
156 // then some log called in ExitBootServices() will be lost,
157 // so unregister the handler after receive the value of exit boot service.
159 if ((CodeType
& EFI_STATUS_CODE_TYPE_MASK
) == EFI_PROGRESS_CODE
&&
160 Value
== (EFI_SOFTWARE_EFI_BOOT_SERVICE
| EFI_SW_BS_PC_EXIT_BOOT_SERVICES
)) {
161 UnregisterSerialBootTimeHandlers();