]> git.proxmox.com Git - mirror_edk2.git/blame - IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/SerialStatusCodeWorker.c
IntelFrameworkModulePkg: Clean up source files
[mirror_edk2.git] / IntelFrameworkModulePkg / Universal / StatusCode / RuntimeDxe / SerialStatusCodeWorker.c
CommitLineData
ad1a1798 1/** @file\r
2 Serial I/O status code reporting worker.\r
3\r
0a6f4824
LG
4 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
5 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
ad1a1798 12\r
ad1a1798 13**/\r
14\r
20e7a774 15#include "StatusCodeRuntimeDxe.h"\r
ad1a1798 16\r
ad1a1798 17/**\r
18 Convert status code value and extended data to readable ASCII string, send string to serial I/O device.\r
0a6f4824 19\r
a8cbf345 20 @param CodeType Indicates the type of status code being reported.\r
21 @param Value Describes the current status of a hardware or software entity.\r
22 This included information about the class and subclass that is used to\r
23 classify the entity as well as an operation.\r
24 @param Instance The enumeration of a hardware or software entity within\r
25 the system. Valid instance numbers start with 1.\r
26 @param CallerId This optional parameter may be used to identify the caller.\r
27 This parameter allows the status code driver to apply different rules to\r
28 different callers.\r
29 @param Data This optional parameter may be used to pass additional data.\r
30\r
31 @retval EFI_SUCCESS Status code reported to serial I/O successfully.\r
32 @retval EFI_DEVICE_ERROR EFI serial device cannot work after ExitBootService() is called.\r
33 @retval EFI_DEVICE_ERROR EFI serial device cannot work with TPL higher than TPL_CALLBACK.\r
ad1a1798 34\r
35**/\r
36EFI_STATUS\r
37SerialStatusCodeReportWorker (\r
38 IN EFI_STATUS_CODE_TYPE CodeType,\r
39 IN EFI_STATUS_CODE_VALUE Value,\r
40 IN UINT32 Instance,\r
41 IN EFI_GUID *CallerId,\r
42 IN EFI_STATUS_CODE_DATA *Data OPTIONAL\r
43 )\r
44{\r
45 CHAR8 *Filename;\r
46 CHAR8 *Description;\r
47 CHAR8 *Format;\r
48 CHAR8 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE];\r
49 UINT32 ErrorLevel;\r
50 UINT32 LineNumber;\r
51 UINTN CharCount;\r
ca9938b8 52 BASE_LIST Marker;\r
ad1a1798 53\r
ad1a1798 54 Buffer[0] = '\0';\r
55\r
56 if (Data != NULL &&\r
57 ReportStatusCodeExtractAssertInfo (CodeType, Value, Data, &Filename, &Description, &LineNumber)) {\r
58 //\r
59 // Print ASSERT() information into output buffer.\r
60 //\r
61 CharCount = AsciiSPrint (\r
62 Buffer,\r
1ca88083 63 sizeof (Buffer),\r
ad1a1798 64 "\n\rDXE_ASSERT!: %a (%d): %a\n\r",\r
65 Filename,\r
66 LineNumber,\r
67 Description\r
68 );\r
69 } else if (Data != NULL &&\r
70 ReportStatusCodeExtractDebugInfo (Data, &ErrorLevel, &Marker, &Format)) {\r
71 //\r
72 // Print DEBUG() information into output buffer.\r
73 //\r
ca9938b8 74 CharCount = AsciiBSPrint (\r
0a6f4824
LG
75 Buffer,\r
76 sizeof (Buffer),\r
77 Format,\r
ad1a1798 78 Marker\r
79 );\r
ad1a1798 80 } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) {\r
81 //\r
82 // Print ERROR information into output buffer.\r
83 //\r
84 CharCount = AsciiSPrint (\r
0a6f4824
LG
85 Buffer,\r
86 sizeof (Buffer),\r
87 "ERROR: C%08x:V%08x I%x",\r
88 CodeType,\r
89 Value,\r
ad1a1798 90 Instance\r
91 );\r
0a6f4824 92\r
ad1a1798 93 if (CallerId != NULL) {\r
94 CharCount += AsciiSPrint (\r
af03df86 95 &Buffer[CharCount],\r
1ca88083 96 (sizeof (Buffer) - (sizeof (Buffer[0]) * CharCount)),\r
ad1a1798 97 " %g",\r
98 CallerId\r
99 );\r
100 }\r
101\r
102 if (Data != NULL) {\r
103 CharCount += AsciiSPrint (\r
af03df86 104 &Buffer[CharCount],\r
1ca88083 105 (sizeof (Buffer) - (sizeof (Buffer[0]) * CharCount)),\r
ad1a1798 106 " %x",\r
107 Data\r
108 );\r
109 }\r
110\r
111 CharCount += AsciiSPrint (\r
af03df86 112 &Buffer[CharCount],\r
1ca88083 113 (sizeof (Buffer) - (sizeof (Buffer[0]) * CharCount)),\r
ad1a1798 114 "\n\r"\r
115 );\r
116 } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) {\r
a8cbf345 117 //\r
118 // Print PROGRESS information into output buffer.\r
119 //\r
ad1a1798 120 CharCount = AsciiSPrint (\r
0a6f4824
LG
121 Buffer,\r
122 sizeof (Buffer),\r
123 "PROGRESS CODE: V%08x I%x\n\r",\r
124 Value,\r
ad1a1798 125 Instance\r
126 );\r
10c9a2e3 127 } else if (Data != NULL &&\r
128 CompareGuid (&Data->Type, &gEfiStatusCodeDataTypeStringGuid) &&\r
5d4a0dbc 129 ((EFI_STATUS_CODE_STRING_DATA *) Data)->StringType == EfiStringAscii) {\r
130 //\r
131 // EFI_STATUS_CODE_STRING_DATA\r
132 //\r
133 CharCount = AsciiSPrint (\r
134 Buffer,\r
135 sizeof (Buffer),\r
136 "%a\n\r",\r
137 ((EFI_STATUS_CODE_STRING_DATA *) Data)->String.Ascii\r
138 );\r
ad1a1798 139 } else {\r
a8cbf345 140 //\r
141 // Code type is not defined.\r
142 //\r
ad1a1798 143 CharCount = AsciiSPrint (\r
0a6f4824
LG
144 Buffer,\r
145 sizeof (Buffer),\r
146 "Undefined: C%08x:V%08x I%x\n\r",\r
147 CodeType,\r
148 Value,\r
ad1a1798 149 Instance\r
150 );\r
151 }\r
152\r
d2c315e6
LG
153 //\r
154 // Call SerialPort Lib function to do print.\r
155 //\r
156 SerialPortWrite ((UINT8 *) Buffer, CharCount);\r
ad1a1798 157\r
158 return EFI_SUCCESS;\r
159}\r
bcd70414 160\r