]> git.proxmox.com Git - mirror_edk2.git/blob - IntelFrameworkModulePkg/Universal/StatusCode/Pei/SerialStatusCodeWorker.c
Clean up: update "EFI" to "UEFI" if applicable.
[mirror_edk2.git] / IntelFrameworkModulePkg / Universal / StatusCode / Pei / SerialStatusCodeWorker.c
1
2 /** @file
3 Serial I/O status code reporting worker.
4
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
10
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.
13
14 Module Name: SerialStatusCodeWorker.c
15
16 **/
17
18 #include "PeiStatusCode.h"
19 #include "DebugInfo.h"
20
21 /**
22 Convert status code value and extended data to readable ASCII string, send string to serial I/O device.
23
24 @param CodeType Indicates the type of status code being reported. Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.
25
26 @param Value Describes the current status of a hardware or software entity.
27 This included information about the class and subclass that is used to classify the entity
28 as well as an operation. For progress codes, the operation is the current activity.
29 For error codes, it is the exception. For debug codes, it is not defined at this time.
30 Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.
31 Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.
32
33 @param Instance The enumeration of a hardware or software entity within the system.
34 A system may contain multiple entities that match a class/subclass pairing.
35 The instance differentiates between them. An instance of 0 indicates that instance information is unavailable,
36 not meaningful, or not relevant. Valid instance numbers start with 1.
37
38
39 @param CallerId This optional parameter may be used to identify the caller.
40 This parameter allows the status code driver to apply different rules to different callers.
41 Type EFI_GUID is defined in InstallProtocolInterface() in the UEFI 2.0 Specification.
42
43
44 @param Data This optional parameter may be used to pass additional data
45
46 @return The function always return EFI_SUCCESS.
47
48 **/
49 EFI_STATUS
50 SerialStatusCodeReportWorker (
51 IN EFI_STATUS_CODE_TYPE CodeType,
52 IN EFI_STATUS_CODE_VALUE Value,
53 IN UINT32 Instance,
54 IN CONST EFI_GUID *CallerId,
55 IN CONST EFI_STATUS_CODE_DATA *Data OPTIONAL
56 )
57 {
58 CHAR8 *Filename;
59 CHAR8 *Description;
60 CHAR8 *Format;
61 CHAR8 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE];
62 UINT32 ErrorLevel;
63 UINT32 LineNumber;
64 UINTN CharCount;
65 VA_LIST Marker;
66 EFI_DEBUG_INFO *DebugInfo;
67
68 Buffer[0] = '\0';
69
70 if (Data != NULL &&
71 ReportStatusCodeExtractAssertInfo (CodeType, Value, Data, &Filename, &Description, &LineNumber)) {
72 //
73 // Print ASSERT() information into output buffer.
74 //
75 CharCount = AsciiSPrint (
76 Buffer,
77 EFI_STATUS_CODE_DATA_MAX_SIZE,
78 "\n\rPEI_ASSERT!: %a (%d): %a\n\r",
79 Filename,
80 LineNumber,
81 Description
82 );
83 } else if (Data != NULL &&
84 ReportStatusCodeExtractDebugInfo (Data, &ErrorLevel, &Marker, &Format)) {
85 //
86 // Print DEBUG() information into output buffer.
87 //
88 CharCount = AsciiVSPrint (
89 Buffer,
90 EFI_STATUS_CODE_DATA_MAX_SIZE,
91 Format,
92 Marker
93 );
94 } else if (Data != NULL &&
95 CompareGuid (&Data->Type, &gEfiStatusCodeSpecificDataGuid) &&
96 (CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) {
97 //
98 // Print specific data into output buffer.
99 //
100 DebugInfo = (EFI_DEBUG_INFO *) (Data + 1);
101 Marker = (VA_LIST) (DebugInfo + 1);
102 Format = (CHAR8 *) (((UINT64 *) Marker) + 12);
103
104 CharCount = AsciiVSPrint (Buffer, EFI_STATUS_CODE_DATA_MAX_SIZE, Format, Marker);
105 } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) {
106 //
107 // Print ERROR information into output buffer.
108 //
109 CharCount = AsciiSPrint (
110 Buffer,
111 EFI_STATUS_CODE_DATA_MAX_SIZE,
112 "ERROR: C%x:V%x I%x",
113 CodeType,
114 Value,
115 Instance
116 );
117
118 //
119 // Make sure we don't try to print values that weren't intended to be printed, especially NULL GUID pointers.
120 //
121
122 if (CallerId != NULL) {
123 CharCount += AsciiSPrint (
124 &Buffer[CharCount - 1],
125 (EFI_STATUS_CODE_DATA_MAX_SIZE - (sizeof (Buffer[0]) * CharCount)),
126 " %g",
127 CallerId
128 );
129 }
130
131 if (Data != NULL) {
132 CharCount += AsciiSPrint (
133 &Buffer[CharCount - 1],
134 (EFI_STATUS_CODE_DATA_MAX_SIZE - (sizeof (Buffer[0]) * CharCount)),
135 " %x",
136 Data
137 );
138 }
139
140 CharCount += AsciiSPrint (
141 &Buffer[CharCount - 1],
142 (EFI_STATUS_CODE_DATA_MAX_SIZE - (sizeof (Buffer[0]) * CharCount)),
143 "\n\r"
144 );
145 } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) {
146 CharCount = AsciiSPrint (
147 Buffer,
148 EFI_STATUS_CODE_DATA_MAX_SIZE,
149 "PROGRESS CODE: V%x I%x\n\r",
150 Value,
151 Instance
152 );
153 } else {
154 CharCount = AsciiSPrint (
155 Buffer,
156 EFI_STATUS_CODE_DATA_MAX_SIZE,
157 "Undefined: C%x:V%x I%x\n\r",
158 CodeType,
159 Value,
160 Instance
161 );
162 }
163
164 //
165 // Callout to SerialPort Lib function to do print.
166 //
167 SerialPortWrite ((UINT8 *) Buffer, CharCount);
168
169 return EFI_SUCCESS;
170 }