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