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