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
19 Convert status code value and extended data to readable ASCII string, send string to serial I/O device.
21 @param CodeType Indicates the type of status code being reported. Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions¡± below.
23 @param Value Describes the current status of a hardware or software entity.
24 This included information about the class and subclass that is used to classify the entity
25 as well as an operation. For progress codes, the operation is the current activity.
26 For error codes, it is the exception. For debug codes, it is not defined at this time.
27 Type EFI_STATUS_CODE_VALUE is defined in ¡°Related Definitions¡± below.
28 Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.
30 @param Instance The enumeration of a hardware or software entity within the system.
31 A system may contain multiple entities that match a class/subclass pairing.
32 The instance differentiates between them. An instance of 0 indicates that instance information is unavailable,
33 not meaningful, or not relevant. Valid instance numbers start with 1.
36 @param CallerId This optional parameter may be used to identify the caller.
37 This parameter allows the status code driver to apply different rules to different callers.
38 Type EFI_GUID is defined in InstallProtocolInterface() in the EFI 1.10 Specification.
41 @param Data This optional parameter may be used to pass additional data
43 @return The function always return EFI_SUCCESS.
47 SerialStatusCodeReportWorker (
48 IN EFI_STATUS_CODE_TYPE CodeType
,
49 IN EFI_STATUS_CODE_VALUE Value
,
51 IN EFI_GUID
*CallerId
,
52 IN EFI_STATUS_CODE_DATA
*Data OPTIONAL
58 CHAR8 Buffer
[EFI_STATUS_CODE_DATA_MAX_SIZE
];
63 EFI_DEBUG_INFO
*DebugInfo
;
68 ReportStatusCodeExtractAssertInfo (CodeType
, Value
, Data
, &Filename
, &Description
, &LineNumber
)) {
70 // Print ASSERT() information into output buffer.
72 CharCount
= AsciiSPrint (
74 EFI_STATUS_CODE_DATA_MAX_SIZE
,
75 "\n\rPEI_ASSERT!: %a (%d): %a\n\r",
80 } else if (Data
!= NULL
&&
81 ReportStatusCodeExtractDebugInfo (Data
, &ErrorLevel
, &Marker
, &Format
)) {
83 // Print DEBUG() information into output buffer.
85 CharCount
= AsciiVSPrint (
87 EFI_STATUS_CODE_DATA_MAX_SIZE
,
91 } else if (Data
!= NULL
&&
92 CompareGuid (&Data
->Type
, &gEfiStatusCodeSpecificDataGuid
) &&
93 (CodeType
& EFI_STATUS_CODE_TYPE_MASK
) == EFI_DEBUG_CODE
) {
95 // Print specific data into output buffer.
97 DebugInfo
= (EFI_DEBUG_INFO
*) (Data
+ 1);
98 Marker
= (VA_LIST
) (DebugInfo
+ 1);
99 Format
= (CHAR8
*) (((UINT64
*) Marker
) + 12);
101 CharCount
= AsciiVSPrint (Buffer
, EFI_STATUS_CODE_DATA_MAX_SIZE
, Format
, Marker
);
102 } else if ((CodeType
& EFI_STATUS_CODE_TYPE_MASK
) == EFI_ERROR_CODE
) {
104 // Print ERROR information into output buffer.
106 CharCount
= AsciiSPrint (Buffer
, EFI_STATUS_CODE_DATA_MAX_SIZE
, "ERROR: C%x:V%x I%x", CodeType
, Value
, Instance
);
109 // Make sure we don't try to print values that weren't intended to be printed, especially NULL GUID pointers.
112 if (CallerId
!= NULL
) {
113 CharCount
+= AsciiSPrint (
114 &Buffer
[CharCount
- 1],
115 (EFI_STATUS_CODE_DATA_MAX_SIZE
- (sizeof (Buffer
[0]) * CharCount
)),
122 CharCount
+= AsciiSPrint (
123 &Buffer
[CharCount
- 1],
124 (EFI_STATUS_CODE_DATA_MAX_SIZE
- (sizeof (Buffer
[0]) * CharCount
)),
130 CharCount
+= AsciiSPrint (
131 &Buffer
[CharCount
- 1],
132 (EFI_STATUS_CODE_DATA_MAX_SIZE
- (sizeof (Buffer
[0]) * CharCount
)),
135 } else if ((CodeType
& EFI_STATUS_CODE_TYPE_MASK
) == EFI_PROGRESS_CODE
) {
136 CharCount
= AsciiSPrint (Buffer
, EFI_STATUS_CODE_DATA_MAX_SIZE
, "PROGRESS CODE: V%x I%x\n\r", Value
, Instance
);
138 CharCount
= AsciiSPrint (Buffer
, EFI_STATUS_CODE_DATA_MAX_SIZE
, "Undefined: C%x:V%x I%x\n\r", CodeType
, Value
, Instance
);
142 // Callout to SerialPort Lib function to do print.
144 SerialPortWrite ((UINT8
*) Buffer
, CharCount
);