2 Serial I/O status code reporting worker.
4 Copyright (c) 2006, 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.
14 #include "PeiStatusCode.h"
17 Convert status code value and extended data to readable ASCII string, send string to serial I/O device.
19 @param CodeType Indicates the type of status code being reported. Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.
21 @param Value Describes the current status of a hardware or software entity.
22 This included information about the class and subclass that is used to classify the entity
23 as well as an operation. For progress codes, the operation is the current activity.
24 For error codes, it is the exception. For debug codes, it is not defined at this time.
25 Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.
26 Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.
28 @param Instance The enumeration of a hardware or software entity within the system.
29 A system may contain multiple entities that match a class/subclass pairing.
30 The instance differentiates between them. An instance of 0 indicates that instance information is unavailable,
31 not meaningful, or not relevant. Valid instance numbers start with 1.
34 @param CallerId This optional parameter may be used to identify the caller.
35 This parameter allows the status code driver to apply different rules to different callers.
36 Type EFI_GUID is defined in InstallProtocolInterface() in the UEFI 2.0 Specification.
39 @param Data This optional parameter may be used to pass additional data
41 @return The function always return EFI_SUCCESS.
45 SerialStatusCodeReportWorker (
46 IN EFI_STATUS_CODE_TYPE CodeType
,
47 IN EFI_STATUS_CODE_VALUE Value
,
49 IN CONST EFI_GUID
*CallerId
,
50 IN CONST EFI_STATUS_CODE_DATA
*Data OPTIONAL
56 CHAR8 Buffer
[EFI_STATUS_CODE_DATA_MAX_SIZE
];
65 ReportStatusCodeExtractAssertInfo (CodeType
, Value
, Data
, &Filename
, &Description
, &LineNumber
)) {
67 // Print ASSERT() information into output buffer.
69 CharCount
= AsciiSPrint (
71 EFI_STATUS_CODE_DATA_MAX_SIZE
,
72 "\n\rPEI_ASSERT!: %a (%d): %a\n\r",
77 } else if (Data
!= NULL
&&
78 ReportStatusCodeExtractDebugInfo (Data
, &ErrorLevel
, &Marker
, &Format
)) {
80 // Print DEBUG() information into output buffer.
82 CharCount
= AsciiVSPrint (
84 EFI_STATUS_CODE_DATA_MAX_SIZE
,
88 } else if ((CodeType
& EFI_STATUS_CODE_TYPE_MASK
) == EFI_ERROR_CODE
) {
90 // Print ERROR information into output buffer.
92 CharCount
= AsciiSPrint (
94 EFI_STATUS_CODE_DATA_MAX_SIZE
,
102 // Make sure we don't try to print values that weren't intended to be printed, especially NULL GUID pointers.
105 if (CallerId
!= NULL
) {
106 CharCount
+= AsciiSPrint (
107 &Buffer
[CharCount
- 1],
108 (EFI_STATUS_CODE_DATA_MAX_SIZE
- (sizeof (Buffer
[0]) * CharCount
)),
115 CharCount
+= AsciiSPrint (
116 &Buffer
[CharCount
- 1],
117 (EFI_STATUS_CODE_DATA_MAX_SIZE
- (sizeof (Buffer
[0]) * CharCount
)),
123 CharCount
+= AsciiSPrint (
124 &Buffer
[CharCount
- 1],
125 (EFI_STATUS_CODE_DATA_MAX_SIZE
- (sizeof (Buffer
[0]) * CharCount
)),
128 } else if ((CodeType
& EFI_STATUS_CODE_TYPE_MASK
) == EFI_PROGRESS_CODE
) {
129 CharCount
= AsciiSPrint (
131 EFI_STATUS_CODE_DATA_MAX_SIZE
,
132 "PROGRESS CODE: V%x I%x\n\r",
137 CharCount
= AsciiSPrint (
139 EFI_STATUS_CODE_DATA_MAX_SIZE
,
140 "Undefined: C%x:V%x I%x\n\r",
148 // Callout to SerialPort Lib function to do print.
150 SerialPortWrite ((UINT8
*) Buffer
, CharCount
);