2 Serial I/O status code reporting worker.
4 Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
5 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 "StatusCodeHandlerPei.h"
17 Convert status code value and extended data to readable ASCII string, send string to serial I/O device.
19 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
20 @param CodeType Indicates the type of status code being reported.
21 @param Value Describes the current status of a hardware or
22 software entity. This includes information about the class and
23 subclass that is used to classify the entity as well as an operation.
24 For progress codes, the operation is the current activity.
25 For error codes, it is the exception.For debug codes,it is not defined at this time.
26 @param Instance The enumeration of a hardware or software entity within
27 the system. A system may contain multiple entities that match a class/subclass
28 pairing. The instance differentiates between them. An instance of 0 indicates
29 that instance information is unavailable, not meaningful, or not relevant.
30 Valid instance numbers start with 1.
31 @param CallerId This optional parameter may be used to identify the caller.
32 This parameter allows the status code driver to apply different rules to
34 @param Data This optional parameter may be used to pass additional data.
36 @retval EFI_SUCCESS Status code reported to serial I/O successfully.
41 SerialStatusCodeReportWorker (
42 IN CONST EFI_PEI_SERVICES
**PeiServices
,
43 IN EFI_STATUS_CODE_TYPE CodeType
,
44 IN EFI_STATUS_CODE_VALUE Value
,
46 IN CONST EFI_GUID
*CallerId
,
47 IN CONST EFI_STATUS_CODE_DATA
*Data OPTIONAL
53 CHAR8 Buffer
[MAX_DEBUG_MESSAGE_LENGTH
];
62 ReportStatusCodeExtractAssertInfo (CodeType
, Value
, Data
, &Filename
, &Description
, &LineNumber
)) {
64 // Print ASSERT() information into output buffer.
66 CharCount
= AsciiSPrint (
69 "\n\rPEI_ASSERT!: %a (%d): %a\n\r",
74 } else if (Data
!= NULL
&&
75 ReportStatusCodeExtractDebugInfo (Data
, &ErrorLevel
, &Marker
, &Format
)) {
77 // Print DEBUG() information into output buffer.
79 CharCount
= AsciiBSPrint (
85 } else if ((CodeType
& EFI_STATUS_CODE_TYPE_MASK
) == EFI_ERROR_CODE
) {
87 // Print ERROR information into output buffer.
89 CharCount
= AsciiSPrint (
92 "ERROR: C%08x:V%08x I%x",
98 ASSERT(CharCount
> 0);
100 if (CallerId
!= NULL
) {
101 CharCount
+= AsciiSPrint (
103 (sizeof (Buffer
) - (sizeof (Buffer
[0]) * CharCount
)),
110 CharCount
+= AsciiSPrint (
112 (sizeof (Buffer
) - (sizeof (Buffer
[0]) * CharCount
)),
118 CharCount
+= AsciiSPrint (
120 (sizeof (Buffer
) - (sizeof (Buffer
[0]) * CharCount
)),
123 } else if ((CodeType
& EFI_STATUS_CODE_TYPE_MASK
) == EFI_PROGRESS_CODE
) {
125 // Print PROGRESS information into output buffer.
127 CharCount
= AsciiSPrint (
130 "PROGRESS CODE: V%08x I%x\n\r",
134 } else if (Data
!= NULL
&&
135 CompareGuid (&Data
->Type
, &gEfiStatusCodeDataTypeStringGuid
) &&
136 ((EFI_STATUS_CODE_STRING_DATA
*) Data
)->StringType
== EfiStringAscii
) {
138 // EFI_STATUS_CODE_STRING_DATA
140 CharCount
= AsciiSPrint (
144 ((EFI_STATUS_CODE_STRING_DATA
*) Data
)->String
.Ascii
148 // Code type is not defined.
150 CharCount
= AsciiSPrint (
153 "Undefined: C%08x:V%08x I%x\n\r",
161 // Call SerialPort Lib function to do print.
163 SerialPortWrite ((UINT8
*) Buffer
, CharCount
);