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