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