]> git.proxmox.com Git - mirror_edk2.git/blame - IntelFrameworkModulePkg/Universal/StatusCode/Dxe/SerialStatusCodeWorker.c
Update HiiGetBrowserData API
[mirror_edk2.git] / IntelFrameworkModulePkg / Universal / StatusCode / Dxe / SerialStatusCodeWorker.c
CommitLineData
ad1a1798 1/** @file\r
2 Serial I/O status code reporting worker.\r
3\r
4 Copyright (c) 2006, Intel Corporation \r
5 All rights reserved. This program and the accompanying materials \r
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
ad1a1798 13**/\r
14\r
ad1a1798 15#include "DxeStatusCode.h"\r
16\r
ad1a1798 17EFI_SERIAL_IO_PROTOCOL *mSerialIoProtocol;\r
18\r
19/**\r
20 Initialize serial status code worker.\r
21 \r
22 @return The function always return EFI_SUCCESS\r
23\r
24**/\r
25EFI_STATUS\r
26EfiSerialStatusCodeInitializeWorker (\r
27 VOID\r
28 )\r
29{\r
30 EFI_STATUS Status;\r
31\r
32 Status = gBS->LocateProtocol (\r
33 &gEfiSerialIoProtocolGuid,\r
34 NULL,\r
35 (VOID **) &mSerialIoProtocol\r
36 );\r
37\r
38 ASSERT_EFI_ERROR (Status);\r
39\r
40 return EFI_SUCCESS;\r
41}\r
42\r
43\r
44/**\r
45 Convert status code value and extended data to readable ASCII string, send string to serial I/O device.\r
46 \r
47 @param CodeType Indicates the type of status code being reported. Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.\r
48 \r
49 @param Value Describes the current status of a hardware or software entity. \r
50 This included information about the class and subclass that is used to classify the entity \r
51 as well as an operation. For progress codes, the operation is the current activity. \r
52 For error codes, it is the exception. For debug codes, it is not defined at this time. \r
53 Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below. \r
54 Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.\r
55 \r
56 @param Instance The enumeration of a hardware or software entity within the system. \r
57 A system may contain multiple entities that match a class/subclass pairing. \r
58 The instance differentiates between them. An instance of 0 indicates that instance information is unavailable, \r
59 not meaningful, or not relevant. Valid instance numbers start with 1.\r
60\r
61\r
62 @param CallerId This optional parameter may be used to identify the caller. \r
63 This parameter allows the status code driver to apply different rules to different callers. \r
8a7d75b0 64 Type EFI_GUID is defined in InstallProtocolInterface() in the UEFI 2.0 Specification.\r
ad1a1798 65\r
66\r
67 @param Data This optional parameter may be used to pass additional data\r
68 \r
69 @retval EFI_SUCCESS Success to report status code to serial I/O.\r
70 @retval EFI_DEVICE_ERROR EFI serial device can not work after ExitBootService() is called .\r
71\r
72**/\r
73EFI_STATUS\r
74SerialStatusCodeReportWorker (\r
75 IN EFI_STATUS_CODE_TYPE CodeType,\r
76 IN EFI_STATUS_CODE_VALUE Value,\r
77 IN UINT32 Instance,\r
78 IN EFI_GUID *CallerId,\r
79 IN EFI_STATUS_CODE_DATA *Data OPTIONAL\r
80 )\r
81{\r
82 CHAR8 *Filename;\r
83 CHAR8 *Description;\r
84 CHAR8 *Format;\r
85 CHAR8 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE];\r
86 UINT32 ErrorLevel;\r
87 UINT32 LineNumber;\r
88 UINTN CharCount;\r
89 VA_LIST Marker;\r
ad1a1798 90 EFI_TPL CurrentTpl;\r
91\r
92\r
93 if (FeaturePcdGet (PcdStatusCodeUseEfiSerial)) {\r
94 if (EfiAtRuntime ()) {\r
95 return EFI_DEVICE_ERROR;\r
96 }\r
97 CurrentTpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);\r
98 gBS->RestoreTPL (CurrentTpl);\r
99\r
100 if (CurrentTpl > TPL_CALLBACK ) {\r
101 return EFI_DEVICE_ERROR;\r
102 }\r
103 }\r
104\r
105 Buffer[0] = '\0';\r
106\r
107 if (Data != NULL &&\r
108 ReportStatusCodeExtractAssertInfo (CodeType, Value, Data, &Filename, &Description, &LineNumber)) {\r
109 //\r
110 // Print ASSERT() information into output buffer.\r
111 //\r
112 CharCount = AsciiSPrint (\r
113 Buffer,\r
114 EFI_STATUS_CODE_DATA_MAX_SIZE,\r
115 "\n\rDXE_ASSERT!: %a (%d): %a\n\r",\r
116 Filename,\r
117 LineNumber,\r
118 Description\r
119 );\r
120 } else if (Data != NULL &&\r
121 ReportStatusCodeExtractDebugInfo (Data, &ErrorLevel, &Marker, &Format)) {\r
122 //\r
123 // Print DEBUG() information into output buffer.\r
124 //\r
125 CharCount = AsciiVSPrint (\r
126 Buffer, \r
127 EFI_STATUS_CODE_DATA_MAX_SIZE, \r
128 Format, \r
129 Marker\r
130 );\r
ad1a1798 131 } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) {\r
132 //\r
133 // Print ERROR information into output buffer.\r
134 //\r
135 CharCount = AsciiSPrint (\r
136 Buffer, \r
137 EFI_STATUS_CODE_DATA_MAX_SIZE, \r
138 "ERROR: C%x:V%x I%x", \r
139 CodeType, \r
140 Value, \r
141 Instance\r
142 );\r
143\r
144 //\r
145 // Make sure we don't try to print values that weren't \r
146 // intended to be printed, especially NULL GUID pointers.\r
147 //\r
148 \r
149 if (CallerId != NULL) {\r
150 CharCount += AsciiSPrint (\r
151 &Buffer[CharCount - 1],\r
152 (EFI_STATUS_CODE_DATA_MAX_SIZE - (sizeof (Buffer[0]) * CharCount)),\r
153 " %g",\r
154 CallerId\r
155 );\r
156 }\r
157\r
158 if (Data != NULL) {\r
159 CharCount += AsciiSPrint (\r
160 &Buffer[CharCount - 1],\r
161 (EFI_STATUS_CODE_DATA_MAX_SIZE - (sizeof (Buffer[0]) * CharCount)),\r
162 " %x",\r
163 Data\r
164 );\r
165 }\r
166\r
167 CharCount += AsciiSPrint (\r
168 &Buffer[CharCount - 1],\r
169 (EFI_STATUS_CODE_DATA_MAX_SIZE - (sizeof (Buffer[0]) * CharCount)),\r
170 "\n\r"\r
171 );\r
172 } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) {\r
173 CharCount = AsciiSPrint (\r
174 Buffer, \r
175 EFI_STATUS_CODE_DATA_MAX_SIZE, \r
176 "PROGRESS CODE: V%x I%x\n\r", \r
177 Value, \r
178 Instance\r
179 );\r
180 } else {\r
181 CharCount = AsciiSPrint (\r
182 Buffer, \r
183 EFI_STATUS_CODE_DATA_MAX_SIZE, \r
184 "Undefined: C%x:V%x I%x\n\r", \r
185 CodeType, \r
186 Value, \r
187 Instance\r
188 );\r
189 }\r
190\r
191\r
192 if (FeaturePcdGet (PcdStatusCodeUseHardSerial)) {\r
193 //\r
194 // Callout to SerialPort Lib function to do print.\r
195 //\r
196 SerialPortWrite ((UINT8 *) Buffer, CharCount);\r
197 }\r
198 if (FeaturePcdGet (PcdStatusCodeUseEfiSerial)) {\r
199 mSerialIoProtocol->Write (\r
200 mSerialIoProtocol,\r
201 &CharCount,\r
202 Buffer\r
203 );\r
204 }\r
205\r
206 return EFI_SUCCESS;\r
207}\r
bcd70414 208\r