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.
16 #include "DxeStatusCode.h"
17 #include "DebugInfo.h"
20 EFI_SERIAL_IO_PROTOCOL
*mSerialIoProtocol
;
23 Initialize serial status code worker.
25 @return The function always return EFI_SUCCESS
29 EfiSerialStatusCodeInitializeWorker (
35 Status
= gBS
->LocateProtocol (
36 &gEfiSerialIoProtocolGuid
,
38 (VOID
**) &mSerialIoProtocol
41 ASSERT_EFI_ERROR (Status
);
48 Convert status code value and extended data to readable ASCII string, send string to serial I/O device.
50 @param CodeType Indicates the type of status code being reported. Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.
52 @param Value Describes the current status of a hardware or software entity.
53 This included information about the class and subclass that is used to classify the entity
54 as well as an operation. For progress codes, the operation is the current activity.
55 For error codes, it is the exception. For debug codes, it is not defined at this time.
56 Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.
57 Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.
59 @param Instance The enumeration of a hardware or software entity within the system.
60 A system may contain multiple entities that match a class/subclass pairing.
61 The instance differentiates between them. An instance of 0 indicates that instance information is unavailable,
62 not meaningful, or not relevant. Valid instance numbers start with 1.
65 @param CallerId This optional parameter may be used to identify the caller.
66 This parameter allows the status code driver to apply different rules to different callers.
67 Type EFI_GUID is defined in InstallProtocolInterface() in the EFI 1.10 Specification.
70 @param Data This optional parameter may be used to pass additional data
72 @retval EFI_SUCCESS Success to report status code to serial I/O.
73 @retval EFI_DEVICE_ERROR EFI serial device can not work after ExitBootService() is called .
77 SerialStatusCodeReportWorker (
78 IN EFI_STATUS_CODE_TYPE CodeType
,
79 IN EFI_STATUS_CODE_VALUE Value
,
81 IN EFI_GUID
*CallerId
,
82 IN EFI_STATUS_CODE_DATA
*Data OPTIONAL
88 CHAR8 Buffer
[EFI_STATUS_CODE_DATA_MAX_SIZE
];
93 EFI_DEBUG_INFO
*DebugInfo
;
97 if (FeaturePcdGet (PcdStatusCodeUseEfiSerial
)) {
98 if (EfiAtRuntime ()) {
99 return EFI_DEVICE_ERROR
;
101 CurrentTpl
= gBS
->RaiseTPL (TPL_HIGH_LEVEL
);
102 gBS
->RestoreTPL (CurrentTpl
);
104 if (CurrentTpl
> TPL_CALLBACK
) {
105 return EFI_DEVICE_ERROR
;
112 ReportStatusCodeExtractAssertInfo (CodeType
, Value
, Data
, &Filename
, &Description
, &LineNumber
)) {
114 // Print ASSERT() information into output buffer.
116 CharCount
= AsciiSPrint (
118 EFI_STATUS_CODE_DATA_MAX_SIZE
,
119 "\n\rDXE_ASSERT!: %a (%d): %a\n\r",
124 } else if (Data
!= NULL
&&
125 ReportStatusCodeExtractDebugInfo (Data
, &ErrorLevel
, &Marker
, &Format
)) {
127 // Print DEBUG() information into output buffer.
129 CharCount
= AsciiVSPrint (
131 EFI_STATUS_CODE_DATA_MAX_SIZE
,
135 } else if (Data
!= NULL
&&
136 CompareGuid (&Data
->Type
, &gEfiStatusCodeSpecificDataGuid
) &&
137 (CodeType
& EFI_STATUS_CODE_TYPE_MASK
) == EFI_DEBUG_CODE
) {
139 // Print specific data into output buffer.
141 DebugInfo
= (EFI_DEBUG_INFO
*) (Data
+ 1);
142 Marker
= (VA_LIST
) (DebugInfo
+ 1);
143 Format
= (CHAR8
*) (((UINT64
*) Marker
) + 12);
145 CharCount
= AsciiVSPrint (Buffer
, EFI_STATUS_CODE_DATA_MAX_SIZE
, Format
, Marker
);
146 } else if ((CodeType
& EFI_STATUS_CODE_TYPE_MASK
) == EFI_ERROR_CODE
) {
148 // Print ERROR information into output buffer.
150 CharCount
= AsciiSPrint (
152 EFI_STATUS_CODE_DATA_MAX_SIZE
,
153 "ERROR: C%x:V%x I%x",
160 // Make sure we don't try to print values that weren't
161 // intended to be printed, especially NULL GUID pointers.
164 if (CallerId
!= NULL
) {
165 CharCount
+= AsciiSPrint (
166 &Buffer
[CharCount
- 1],
167 (EFI_STATUS_CODE_DATA_MAX_SIZE
- (sizeof (Buffer
[0]) * CharCount
)),
174 CharCount
+= AsciiSPrint (
175 &Buffer
[CharCount
- 1],
176 (EFI_STATUS_CODE_DATA_MAX_SIZE
- (sizeof (Buffer
[0]) * CharCount
)),
182 CharCount
+= AsciiSPrint (
183 &Buffer
[CharCount
- 1],
184 (EFI_STATUS_CODE_DATA_MAX_SIZE
- (sizeof (Buffer
[0]) * CharCount
)),
187 } else if ((CodeType
& EFI_STATUS_CODE_TYPE_MASK
) == EFI_PROGRESS_CODE
) {
188 CharCount
= AsciiSPrint (
190 EFI_STATUS_CODE_DATA_MAX_SIZE
,
191 "PROGRESS CODE: V%x I%x\n\r",
196 CharCount
= AsciiSPrint (
198 EFI_STATUS_CODE_DATA_MAX_SIZE
,
199 "Undefined: C%x:V%x I%x\n\r",
207 if (FeaturePcdGet (PcdStatusCodeUseHardSerial
)) {
209 // Callout to SerialPort Lib function to do print.
211 SerialPortWrite ((UINT8
*) Buffer
, CharCount
);
213 if (FeaturePcdGet (PcdStatusCodeUseEfiSerial
)) {
214 mSerialIoProtocol
->Write (