3 Serial I/O status code reporting worker.
5 Copyright (c) 2006, Intel Corporation. All rights reserved.
6 This software and associated documentation (if any) is furnished
7 under a license and may only be used or copied in accordance
8 with the terms of the license. Except as permitted by such
9 license, no part of this software or documentation may be
10 reproduced, stored in a retrieval system, or transmitted in any
11 form or by any means without the express written consent of
14 Module Name: SerialStatusCodeWorker.c
18 EFI_SERIAL_IO_PROTOCOL
*SerialIoProtocol
;
21 Initialize serial status code worker.
23 @return The function always return EFI_SUCCESS
27 EfiSerialStatusCodeInitializeWorker (
33 Status
= gBS
->LocateProtocol (
34 &gEfiSerialIoProtocolGuid
,
36 (VOID
**) &SerialIoProtocol
39 ASSERT_EFI_ERROR (Status
);
46 Convert status code value and extended data to readable ASCII string, send string to serial I/O device.
48 @param CodeType Indicates the type of status code being reported. Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions¡± below.
50 @param Value Describes the current status of a hardware or software entity.
51 This included information about the class and subclass that is used to classify the entity
52 as well as an operation. For progress codes, the operation is the current activity.
53 For error codes, it is the exception. For debug codes, it is not defined at this time.
54 Type EFI_STATUS_CODE_VALUE is defined in ¡°Related Definitions¡± below.
55 Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.
57 @param Instance The enumeration of a hardware or software entity within the system.
58 A system may contain multiple entities that match a class/subclass pairing.
59 The instance differentiates between them. An instance of 0 indicates that instance information is unavailable,
60 not meaningful, or not relevant. Valid instance numbers start with 1.
63 @param CallerId This optional parameter may be used to identify the caller.
64 This parameter allows the status code driver to apply different rules to different callers.
65 Type EFI_GUID is defined in InstallProtocolInterface() in the EFI 1.10 Specification.
68 @param Data This optional parameter may be used to pass additional data
70 @return The function always return EFI_SUCCESS.
74 SerialStatusCodeReportWorker (
75 IN EFI_STATUS_CODE_TYPE CodeType
,
76 IN EFI_STATUS_CODE_VALUE Value
,
78 IN EFI_GUID
*CallerId
,
79 IN EFI_STATUS_CODE_DATA
*Data OPTIONAL
85 CHAR8 Buffer
[EFI_STATUS_CODE_DATA_MAX_SIZE
];
90 EFI_DEBUG_INFO
*DebugInfo
;
95 ReportStatusCodeExtractAssertInfo (CodeType
, Value
, Data
, &Filename
, &Description
, &LineNumber
)) {
97 // Print ASSERT() information into output buffer.
99 CharCount
= AsciiSPrint (
101 EFI_STATUS_CODE_DATA_MAX_SIZE
,
102 "\n\rDXE_ASSERT!: %a (%d): %a\n\r",
107 } else if (Data
!= NULL
&&
108 ReportStatusCodeExtractDebugInfo (Data
, &ErrorLevel
, &Marker
, &Format
)) {
110 // Print DEBUG() information into output buffer.
112 CharCount
= AsciiVSPrint (
114 EFI_STATUS_CODE_DATA_MAX_SIZE
,
118 } else if (Data
!= NULL
&&
119 CompareGuid (&Data
->Type
, &gEfiStatusCodeSpecificDataGuid
) &&
120 (CodeType
& EFI_STATUS_CODE_TYPE_MASK
) == EFI_DEBUG_CODE
) {
122 // Print specific data into output buffer.
124 DebugInfo
= (EFI_DEBUG_INFO
*) (Data
+ 1);
125 Marker
= (VA_LIST
) (DebugInfo
+ 1);
126 Format
= (CHAR8
*) (((UINT64
*) Marker
) + 12);
128 CharCount
= AsciiVSPrint (Buffer
, EFI_STATUS_CODE_DATA_MAX_SIZE
, Format
, Marker
);
129 } else if ((CodeType
& EFI_STATUS_CODE_TYPE_MASK
) == EFI_ERROR_CODE
) {
131 // Print ERROR information into output buffer.
133 CharCount
= AsciiSPrint (Buffer
, EFI_STATUS_CODE_DATA_MAX_SIZE
, "ERROR: C%x:V%x I%x", CodeType
, Value
, Instance
);
136 // Make sure we don't try to print values that weren't intended to be printed, especially NULL GUID pointers.
139 if (CallerId
!= NULL
) {
140 CharCount
+= AsciiSPrint (
141 &Buffer
[CharCount
- 1],
142 (EFI_STATUS_CODE_DATA_MAX_SIZE
- (sizeof (Buffer
[0]) * CharCount
)),
149 CharCount
+= AsciiSPrint (
150 &Buffer
[CharCount
- 1],
151 (EFI_STATUS_CODE_DATA_MAX_SIZE
- (sizeof (Buffer
[0]) * CharCount
)),
157 CharCount
+= AsciiSPrint (
158 &Buffer
[CharCount
- 1],
159 (EFI_STATUS_CODE_DATA_MAX_SIZE
- (sizeof (Buffer
[0]) * CharCount
)),
162 } else if ((CodeType
& EFI_STATUS_CODE_TYPE_MASK
) == EFI_PROGRESS_CODE
) {
163 CharCount
= AsciiSPrint (Buffer
, EFI_STATUS_CODE_DATA_MAX_SIZE
, "PROGRESS CODE: V%x I%x\n\r", Value
, Instance
);
165 CharCount
= AsciiSPrint (Buffer
, EFI_STATUS_CODE_DATA_MAX_SIZE
, "Undefined: C%x:V%x I%x\n\r", CodeType
, Value
, Instance
);
169 if (FeaturePcdGet (PcdStatusCodeUseHardSerial
)) {
171 // Callout to SerialPort Lib function to do print.
173 SerialPortWrite (Buffer
, CharCount
);
175 if (FeaturePcdGet (PcdStatusCodeUseEfiSerial
)) {
176 SerialIoProtocol
->Write (