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.
14 Module Name: SerialStatusCodeWorker.c
19 EFI_SERIAL_IO_PROTOCOL
*mSerialIoProtocol
;
22 Initialize serial status code worker.
24 @return The function always return EFI_SUCCESS
28 EfiSerialStatusCodeInitializeWorker (
34 Status
= gBS
->LocateProtocol (
35 &gEfiSerialIoProtocolGuid
,
37 (VOID
**) &mSerialIoProtocol
40 ASSERT_EFI_ERROR (Status
);
47 Convert status code value and extended data to readable ASCII string, send string to serial I/O device.
49 @param CodeType Indicates the type of status code being reported. Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.
51 @param Value Describes the current status of a hardware or software entity.
52 This included information about the class and subclass that is used to classify the entity
53 as well as an operation. For progress codes, the operation is the current activity.
54 For error codes, it is the exception. For debug codes, it is not defined at this time.
55 Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.
56 Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.
58 @param Instance The enumeration of a hardware or software entity within the system.
59 A system may contain multiple entities that match a class/subclass pairing.
60 The instance differentiates between them. An instance of 0 indicates that instance information is unavailable,
61 not meaningful, or not relevant. Valid instance numbers start with 1.
64 @param CallerId This optional parameter may be used to identify the caller.
65 This parameter allows the status code driver to apply different rules to different callers.
66 Type EFI_GUID is defined in InstallProtocolInterface() in the EFI 1.10 Specification.
69 @param Data This optional parameter may be used to pass additional data
71 @retval EFI_SUCCESS Success to report status code to serial I/O.
72 @retval EFI_DEVICE_ERROR EFI serial device can not work after ExitBootService() is called .
76 SerialStatusCodeReportWorker (
77 IN EFI_STATUS_CODE_TYPE CodeType
,
78 IN EFI_STATUS_CODE_VALUE Value
,
80 IN EFI_GUID
*CallerId
,
81 IN EFI_STATUS_CODE_DATA
*Data OPTIONAL
87 CHAR8 Buffer
[EFI_STATUS_CODE_DATA_MAX_SIZE
];
92 EFI_DEBUG_INFO
*DebugInfo
;
95 if (FeaturePcdGet (PcdStatusCodeUseEfiSerial
) && EfiAtRuntime ()) {
96 return EFI_DEVICE_ERROR
;
102 ReportStatusCodeExtractAssertInfo (CodeType
, Value
, Data
, &Filename
, &Description
, &LineNumber
)) {
104 // Print ASSERT() information into output buffer.
106 CharCount
= AsciiSPrint (
108 EFI_STATUS_CODE_DATA_MAX_SIZE
,
109 "\n\rDXE_ASSERT!: %a (%d): %a\n\r",
114 } else if (Data
!= NULL
&&
115 ReportStatusCodeExtractDebugInfo (Data
, &ErrorLevel
, &Marker
, &Format
)) {
117 // Print DEBUG() information into output buffer.
119 CharCount
= AsciiVSPrint (
121 EFI_STATUS_CODE_DATA_MAX_SIZE
,
125 } else if (Data
!= NULL
&&
126 CompareGuid (&Data
->Type
, &gEfiStatusCodeSpecificDataGuid
) &&
127 (CodeType
& EFI_STATUS_CODE_TYPE_MASK
) == EFI_DEBUG_CODE
) {
129 // Print specific data into output buffer.
131 DebugInfo
= (EFI_DEBUG_INFO
*) (Data
+ 1);
132 Marker
= (VA_LIST
) (DebugInfo
+ 1);
133 Format
= (CHAR8
*) (((UINT64
*) Marker
) + 12);
135 CharCount
= AsciiVSPrint (Buffer
, EFI_STATUS_CODE_DATA_MAX_SIZE
, Format
, Marker
);
136 } else if ((CodeType
& EFI_STATUS_CODE_TYPE_MASK
) == EFI_ERROR_CODE
) {
138 // Print ERROR information into output buffer.
140 CharCount
= AsciiSPrint (
142 EFI_STATUS_CODE_DATA_MAX_SIZE
,
143 "ERROR: C%x:V%x I%x",
150 // Make sure we don't try to print values that weren't
151 // intended to be printed, especially NULL GUID pointers.
154 if (CallerId
!= NULL
) {
155 CharCount
+= AsciiSPrint (
156 &Buffer
[CharCount
- 1],
157 (EFI_STATUS_CODE_DATA_MAX_SIZE
- (sizeof (Buffer
[0]) * CharCount
)),
164 CharCount
+= AsciiSPrint (
165 &Buffer
[CharCount
- 1],
166 (EFI_STATUS_CODE_DATA_MAX_SIZE
- (sizeof (Buffer
[0]) * CharCount
)),
172 CharCount
+= AsciiSPrint (
173 &Buffer
[CharCount
- 1],
174 (EFI_STATUS_CODE_DATA_MAX_SIZE
- (sizeof (Buffer
[0]) * CharCount
)),
177 } else if ((CodeType
& EFI_STATUS_CODE_TYPE_MASK
) == EFI_PROGRESS_CODE
) {
178 CharCount
= AsciiSPrint (
180 EFI_STATUS_CODE_DATA_MAX_SIZE
,
181 "PROGRESS CODE: V%x I%x\n\r",
186 CharCount
= AsciiSPrint (
188 EFI_STATUS_CODE_DATA_MAX_SIZE
,
189 "Undefined: C%x:V%x I%x\n\r",
197 if (FeaturePcdGet (PcdStatusCodeUseHardSerial
)) {
199 // Callout to SerialPort Lib function to do print.
201 SerialPortWrite ((UINT8
*) Buffer
, CharCount
);
203 if (FeaturePcdGet (PcdStatusCodeUseEfiSerial
)) {
204 mSerialIoProtocol
->Write (