2 Serial I/O status code reporting worker.
4 Copyright (c) 2006 - 2009, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #include "DxeStatusCode.h"
17 EFI_SERIAL_IO_PROTOCOL
*mSerialIoProtocol
;
20 Locates Serial I/O Protocol as initialization for serial status code worker.
22 @retval EFI_SUCCESS Serial I/O Protocol is successfully located.
26 EfiSerialStatusCodeInitializeWorker (
32 Status
= gBS
->LocateProtocol (
33 &gEfiSerialIoProtocolGuid
,
35 (VOID
**) &mSerialIoProtocol
38 ASSERT_EFI_ERROR (Status
);
45 Convert status code value and extended data to readable ASCII string, send string to serial I/O device.
47 @param CodeType Indicates the type of status code being reported.
48 @param Value Describes the current status of a hardware or software entity.
49 This included information about the class and subclass that is used to
50 classify the entity as well as an operation.
51 @param Instance The enumeration of a hardware or software entity within
52 the system. Valid instance numbers start with 1.
53 @param CallerId This optional parameter may be used to identify the caller.
54 This parameter allows the status code driver to apply different rules to
56 @param Data This optional parameter may be used to pass additional data.
58 @retval EFI_SUCCESS Status code reported to serial I/O successfully.
59 @retval EFI_DEVICE_ERROR EFI serial device cannot work after ExitBootService() is called.
60 @retval EFI_DEVICE_ERROR EFI serial device cannot work with TPL higher than TPL_CALLBACK.
64 SerialStatusCodeReportWorker (
65 IN EFI_STATUS_CODE_TYPE CodeType
,
66 IN EFI_STATUS_CODE_VALUE Value
,
68 IN EFI_GUID
*CallerId
,
69 IN EFI_STATUS_CODE_DATA
*Data OPTIONAL
75 CHAR8 Buffer
[EFI_STATUS_CODE_DATA_MAX_SIZE
];
81 if (FeaturePcdGet (PcdStatusCodeUseEfiSerial
)) {
82 if (EfiAtRuntime ()) {
83 return EFI_DEVICE_ERROR
;
85 if (EfiGetCurrentTpl () > TPL_CALLBACK
) {
86 return EFI_DEVICE_ERROR
;
93 ReportStatusCodeExtractAssertInfo (CodeType
, Value
, Data
, &Filename
, &Description
, &LineNumber
)) {
95 // Print ASSERT() information into output buffer.
97 CharCount
= AsciiSPrint (
99 EFI_STATUS_CODE_DATA_MAX_SIZE
,
100 "\n\rDXE_ASSERT!: %a (%d): %a\n\r",
105 } else if (Data
!= NULL
&&
106 ReportStatusCodeExtractDebugInfo (Data
, &ErrorLevel
, &Marker
, &Format
)) {
108 // Print DEBUG() information into output buffer.
110 CharCount
= AsciiVSPrint (
112 EFI_STATUS_CODE_DATA_MAX_SIZE
,
116 } else if ((CodeType
& EFI_STATUS_CODE_TYPE_MASK
) == EFI_ERROR_CODE
) {
118 // Print ERROR information into output buffer.
120 CharCount
= AsciiSPrint (
122 EFI_STATUS_CODE_DATA_MAX_SIZE
,
123 "ERROR: C%x:V%x I%x",
129 if (CallerId
!= NULL
) {
130 CharCount
+= AsciiSPrint (
131 &Buffer
[CharCount
- 1],
132 (EFI_STATUS_CODE_DATA_MAX_SIZE
- (sizeof (Buffer
[0]) * CharCount
)),
139 CharCount
+= AsciiSPrint (
140 &Buffer
[CharCount
- 1],
141 (EFI_STATUS_CODE_DATA_MAX_SIZE
- (sizeof (Buffer
[0]) * CharCount
)),
147 CharCount
+= AsciiSPrint (
148 &Buffer
[CharCount
- 1],
149 (EFI_STATUS_CODE_DATA_MAX_SIZE
- (sizeof (Buffer
[0]) * CharCount
)),
152 } else if ((CodeType
& EFI_STATUS_CODE_TYPE_MASK
) == EFI_PROGRESS_CODE
) {
154 // Print PROGRESS information into output buffer.
156 CharCount
= AsciiSPrint (
158 EFI_STATUS_CODE_DATA_MAX_SIZE
,
159 "PROGRESS CODE: V%x I%x\n\r",
165 // Code type is not defined.
167 CharCount
= AsciiSPrint (
169 EFI_STATUS_CODE_DATA_MAX_SIZE
,
170 "Undefined: C%x:V%x I%x\n\r",
178 if (FeaturePcdGet (PcdStatusCodeUseHardSerial
)) {
180 // Call SerialPort Lib function to do print.
182 SerialPortWrite ((UINT8
*) Buffer
, CharCount
);
184 if (FeaturePcdGet (PcdStatusCodeUseEfiSerial
)) {
185 mSerialIoProtocol
->Write (