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