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
))
55 // Print ASSERT() information into output buffer.
57 CharCount
= AsciiSPrint (
60 "\n\rDXE_ASSERT!: %a (%d): %a\n\r",
65 } else if ((Data
!= NULL
) &&
66 ReportStatusCodeExtractDebugInfo (Data
, &ErrorLevel
, &Marker
, &Format
))
69 // Print DEBUG() information into output buffer.
71 CharCount
= AsciiBSPrint (
77 } else if ((CodeType
& EFI_STATUS_CODE_TYPE_MASK
) == EFI_ERROR_CODE
) {
79 // Print ERROR information into output buffer.
81 CharCount
= AsciiSPrint (
84 "ERROR: C%08x:V%08x I%x",
89 ASSERT (CharCount
> 0);
91 if (CallerId
!= NULL
) {
92 CharCount
+= AsciiSPrint (
94 (sizeof (Buffer
) - (sizeof (Buffer
[0]) * CharCount
)),
101 CharCount
+= AsciiSPrint (
103 (sizeof (Buffer
) - (sizeof (Buffer
[0]) * CharCount
)),
109 CharCount
+= AsciiSPrint (
111 (sizeof (Buffer
) - (sizeof (Buffer
[0]) * CharCount
)),
114 } else if ((CodeType
& EFI_STATUS_CODE_TYPE_MASK
) == EFI_PROGRESS_CODE
) {
116 // Print PROGRESS information into output buffer.
118 CharCount
= AsciiSPrint (
121 "PROGRESS CODE: V%08x I%x\n\r",
125 } else if ((Data
!= NULL
) &&
126 CompareGuid (&Data
->Type
, &gEfiStatusCodeDataTypeStringGuid
) &&
127 (((EFI_STATUS_CODE_STRING_DATA
*)Data
)->StringType
== EfiStringAscii
))
130 // EFI_STATUS_CODE_STRING_DATA
132 CharCount
= AsciiSPrint (
136 ((EFI_STATUS_CODE_STRING_DATA
*)Data
)->String
.Ascii
140 // Code type is not defined.
142 CharCount
= AsciiSPrint (
145 "Undefined: C%08x:V%08x I%x\n\r",
153 // Call SerialPort Lib function to do print.
155 SerialPortWrite ((UINT8
*)Buffer
, CharCount
);
158 // If register an unregister function of gEfiEventExitBootServicesGuid,
159 // then some log called in ExitBootServices() will be lost,
160 // so unregister the handler after receive the value of exit boot service.
162 if (((CodeType
& EFI_STATUS_CODE_TYPE_MASK
) == EFI_PROGRESS_CODE
) &&
163 (Value
== (EFI_SOFTWARE_EFI_BOOT_SERVICE
| EFI_SW_BS_PC_EXIT_BOOT_SERVICES
)))
165 UnregisterSerialBootTimeHandlers ();