]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/StatusCodeHandler/Pei/SerialStatusCodeWorker.c
MdeModulePkg: Clean up source files
[mirror_edk2.git] / MdeModulePkg / Universal / StatusCodeHandler / Pei / SerialStatusCodeWorker.c
CommitLineData
3af9b388 1/** @file\r
2 Serial I/O status code reporting worker.\r
3\r
d1102dba 4 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
e5eed7d3 5 This program and the accompanying materials\r
3af9b388 6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php\r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12**/\r
13\r
14#include "StatusCodeHandlerPei.h"\r
15\r
16/**\r
17 Convert status code value and extended data to readable ASCII string, send string to serial I/O device.\r
18\r
19 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
20 @param CodeType Indicates the type of status code being reported.\r
21 @param Value Describes the current status of a hardware or\r
22 software entity. This includes information about the class and\r
23 subclass that is used to classify the entity as well as an operation.\r
24 For progress codes, the operation is the current activity.\r
25 For error codes, it is the exception.For debug codes,it is not defined at this time.\r
26 @param Instance The enumeration of a hardware or software entity within\r
27 the system. A system may contain multiple entities that match a class/subclass\r
28 pairing. The instance differentiates between them. An instance of 0 indicates\r
29 that instance information is unavailable, not meaningful, or not relevant.\r
30 Valid instance numbers start with 1.\r
31 @param CallerId This optional parameter may be used to identify the caller.\r
32 This parameter allows the status code driver to apply different rules to\r
33 different callers.\r
34 @param Data This optional parameter may be used to pass additional data.\r
35\r
36 @retval EFI_SUCCESS Status code reported to serial I/O successfully.\r
37\r
38**/\r
39EFI_STATUS\r
4a5b245a 40EFIAPI\r
3af9b388 41SerialStatusCodeReportWorker (\r
42 IN CONST EFI_PEI_SERVICES **PeiServices,\r
43 IN EFI_STATUS_CODE_TYPE CodeType,\r
44 IN EFI_STATUS_CODE_VALUE Value,\r
45 IN UINT32 Instance,\r
46 IN CONST EFI_GUID *CallerId,\r
47 IN CONST EFI_STATUS_CODE_DATA *Data OPTIONAL\r
48 )\r
49{\r
50 CHAR8 *Filename;\r
51 CHAR8 *Description;\r
52 CHAR8 *Format;\r
90eaa3c1 53 CHAR8 Buffer[MAX_DEBUG_MESSAGE_LENGTH];\r
3af9b388 54 UINT32 ErrorLevel;\r
55 UINT32 LineNumber;\r
56 UINTN CharCount;\r
57 BASE_LIST Marker;\r
58\r
59 Buffer[0] = '\0';\r
60\r
61 if (Data != NULL &&\r
62 ReportStatusCodeExtractAssertInfo (CodeType, Value, Data, &Filename, &Description, &LineNumber)) {\r
63 //\r
64 // Print ASSERT() information into output buffer.\r
65 //\r
66 CharCount = AsciiSPrint (\r
67 Buffer,\r
68 sizeof (Buffer),\r
69 "\n\rPEI_ASSERT!: %a (%d): %a\n\r",\r
70 Filename,\r
71 LineNumber,\r
72 Description\r
73 );\r
74 } else if (Data != NULL &&\r
75 ReportStatusCodeExtractDebugInfo (Data, &ErrorLevel, &Marker, &Format)) {\r
76 //\r
77 // Print DEBUG() information into output buffer.\r
78 //\r
79 CharCount = AsciiBSPrint (\r
80 Buffer,\r
81 sizeof (Buffer),\r
82 Format,\r
83 Marker\r
84 );\r
85 } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) {\r
86 //\r
87 // Print ERROR information into output buffer.\r
88 //\r
89 CharCount = AsciiSPrint (\r
90 Buffer,\r
91 sizeof (Buffer),\r
5d0f0ac4 92 "ERROR: C%08x:V%08x I%x",\r
3af9b388 93 CodeType,\r
94 Value,\r
95 Instance\r
96 );\r
d1102dba 97\r
c9325700 98 ASSERT(CharCount > 0);\r
d1102dba 99\r
3af9b388 100 if (CallerId != NULL) {\r
101 CharCount += AsciiSPrint (\r
30d636c8 102 &Buffer[CharCount],\r
3af9b388 103 (sizeof (Buffer) - (sizeof (Buffer[0]) * CharCount)),\r
104 " %g",\r
105 CallerId\r
106 );\r
107 }\r
108\r
109 if (Data != NULL) {\r
110 CharCount += AsciiSPrint (\r
30d636c8 111 &Buffer[CharCount],\r
3af9b388 112 (sizeof (Buffer) - (sizeof (Buffer[0]) * CharCount)),\r
113 " %x",\r
114 Data\r
115 );\r
116 }\r
117\r
118 CharCount += AsciiSPrint (\r
30d636c8 119 &Buffer[CharCount],\r
3af9b388 120 (sizeof (Buffer) - (sizeof (Buffer[0]) * CharCount)),\r
121 "\n\r"\r
122 );\r
123 } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) {\r
124 //\r
125 // Print PROGRESS information into output buffer.\r
126 //\r
127 CharCount = AsciiSPrint (\r
128 Buffer,\r
129 sizeof (Buffer),\r
5d0f0ac4 130 "PROGRESS CODE: V%08x I%x\n\r",\r
3af9b388 131 Value,\r
132 Instance\r
133 );\r
bc369e79 134 } else if (Data != NULL &&\r
135 CompareGuid (&Data->Type, &gEfiStatusCodeDataTypeStringGuid) &&\r
96a25163 136 ((EFI_STATUS_CODE_STRING_DATA *) Data)->StringType == EfiStringAscii) {\r
137 //\r
138 // EFI_STATUS_CODE_STRING_DATA\r
139 //\r
140 CharCount = AsciiSPrint (\r
141 Buffer,\r
142 sizeof (Buffer),\r
143 "%a\n\r",\r
144 ((EFI_STATUS_CODE_STRING_DATA *) Data)->String.Ascii\r
145 );\r
3af9b388 146 } else {\r
147 //\r
148 // Code type is not defined.\r
149 //\r
150 CharCount = AsciiSPrint (\r
151 Buffer,\r
152 sizeof (Buffer),\r
5d0f0ac4 153 "Undefined: C%08x:V%08x I%x\n\r",\r
3af9b388 154 CodeType,\r
155 Value,\r
156 Instance\r
157 );\r
158 }\r
159\r
160 //\r
161 // Call SerialPort Lib function to do print.\r
162 //\r
163 SerialPortWrite ((UINT8 *) Buffer, CharCount);\r
164\r
165 return EFI_SUCCESS;\r
166}\r
167\r