TianoCore EDK2 master
Loading...
Searching...
No Matches
SerialStatusCodeWorker.c
Go to the documentation of this file.
1
9
34EFIAPI
36 IN CONST EFI_PEI_SERVICES **PeiServices,
37 IN EFI_STATUS_CODE_TYPE CodeType,
39 IN UINT32 Instance,
40 IN CONST EFI_GUID *CallerId,
41 IN CONST EFI_STATUS_CODE_DATA *Data OPTIONAL
42 )
43{
44 CHAR8 *Filename;
45 CHAR8 *Description;
46 CHAR8 *Format;
47 CHAR8 Buffer[MAX_DEBUG_MESSAGE_LENGTH];
48 UINT32 ErrorLevel;
49 UINT32 LineNumber;
50 UINTN CharCount;
51 BASE_LIST Marker;
52
53 Buffer[0] = '\0';
54
55 if ((Data != NULL) &&
56 ReportStatusCodeExtractAssertInfo (CodeType, Value, Data, &Filename, &Description, &LineNumber))
57 {
58 //
59 // Print ASSERT() information into output buffer.
60 //
61 CharCount = AsciiSPrint (
62 Buffer,
63 sizeof (Buffer),
64 "\n\rPEI_ASSERT!: %a (%d): %a\n\r",
65 Filename,
66 LineNumber,
67 Description
68 );
69 } else if ((Data != NULL) &&
70 ReportStatusCodeExtractDebugInfo (Data, &ErrorLevel, &Marker, &Format))
71 {
72 //
73 // Print DEBUG() information into output buffer.
74 //
75 CharCount = AsciiBSPrint (
76 Buffer,
77 sizeof (Buffer),
78 Format,
79 Marker
80 );
81 } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) {
82 //
83 // Print ERROR information into output buffer.
84 //
85 CharCount = AsciiSPrint (
86 Buffer,
87 sizeof (Buffer),
88 "ERROR: C%08x:V%08x I%x",
89 CodeType,
90 Value,
91 Instance
92 );
93
94 ASSERT (CharCount > 0);
95
96 if (CallerId != NULL) {
97 CharCount += AsciiSPrint (
98 &Buffer[CharCount],
99 (sizeof (Buffer) - (sizeof (Buffer[0]) * CharCount)),
100 " %g",
101 CallerId
102 );
103 }
104
105 if (Data != NULL) {
106 CharCount += AsciiSPrint (
107 &Buffer[CharCount],
108 (sizeof (Buffer) - (sizeof (Buffer[0]) * CharCount)),
109 " %x",
110 Data
111 );
112 }
113
114 CharCount += AsciiSPrint (
115 &Buffer[CharCount],
116 (sizeof (Buffer) - (sizeof (Buffer[0]) * CharCount)),
117 "\n\r"
118 );
119 } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) {
120 //
121 // Print PROGRESS information into output buffer.
122 //
123 CharCount = AsciiSPrint (
124 Buffer,
125 sizeof (Buffer),
126 "PROGRESS CODE: V%08x I%x\n\r",
127 Value,
128 Instance
129 );
130 } else if ((Data != NULL) &&
131 CompareGuid (&Data->Type, &gEfiStatusCodeDataTypeStringGuid) &&
132 (((EFI_STATUS_CODE_STRING_DATA *)Data)->StringType == EfiStringAscii))
133 {
134 //
135 // EFI_STATUS_CODE_STRING_DATA
136 //
137 CharCount = AsciiSPrint (
138 Buffer,
139 sizeof (Buffer),
140 "%a",
141 ((EFI_STATUS_CODE_STRING_DATA *)Data)->String.Ascii
142 );
143 } else {
144 //
145 // Code type is not defined.
146 //
147 CharCount = AsciiSPrint (
148 Buffer,
149 sizeof (Buffer),
150 "Undefined: C%08x:V%08x I%x\n\r",
151 CodeType,
152 Value,
153 Instance
154 );
155 }
156
157 //
158 // Call SerialPort Lib function to do print.
159 //
160 SerialPortWrite ((UINT8 *)Buffer, CharCount);
161
162 return EFI_SUCCESS;
163}
UINT64 UINTN
UINTN EFIAPI SerialPortWrite(IN UINT8 *Buffer, IN UINTN NumberOfBytes)
Definition: SerialPortLib.c:52
BOOLEAN EFIAPI CompareGuid(IN CONST GUID *Guid1, IN CONST GUID *Guid2)
Definition: MemLibGuid.c:73
BOOLEAN EFIAPI ReportStatusCodeExtractDebugInfo(IN CONST EFI_STATUS_CODE_DATA *Data, OUT UINT32 *ErrorLevel, OUT BASE_LIST *Marker, OUT CHAR8 **Format)
BOOLEAN EFIAPI ReportStatusCodeExtractAssertInfo(IN EFI_STATUS_CODE_TYPE CodeType, IN EFI_STATUS_CODE_VALUE Value, IN CONST EFI_STATUS_CODE_DATA *Data, OUT CHAR8 **Filename, OUT CHAR8 **Description, OUT UINT32 *LineNumber)
UINTN EFIAPI AsciiBSPrint(OUT CHAR8 *StartOfBuffer, IN UINTN BufferSize, IN CONST CHAR8 *FormatString, IN BASE_LIST Marker)
Definition: PrintLib.c:763
UINTN EFIAPI AsciiSPrint(OUT CHAR8 *StartOfBuffer, IN UINTN BufferSize, IN CONST CHAR8 *FormatString,...)
Definition: PrintLib.c:813
#define NULL
Definition: Base.h:319
#define CONST
Definition: Base.h:259
#define IN
Definition: Base.h:279
UINTN * BASE_LIST
Definition: Base.h:711
EFI_STATUS EFIAPI SerialStatusCodeReportWorker(IN CONST EFI_PEI_SERVICES **PeiServices, IN EFI_STATUS_CODE_TYPE CodeType, IN EFI_STATUS_CODE_VALUE Value, IN UINT32 Instance, IN CONST EFI_GUID *CallerId, IN CONST EFI_STATUS_CODE_DATA *Data OPTIONAL)
UINT32 EFI_STATUS_CODE_VALUE
Definition: PiStatusCode.h:67
#define EFI_PROGRESS_CODE
Definition: PiStatusCode.h:43
UINT32 EFI_STATUS_CODE_TYPE
Definition: PiStatusCode.h:24
#define EFI_STATUS_CODE_TYPE_MASK
Definition: PiStatusCode.h:32
@ EfiStringAscii
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
Definition: Base.h:213