]>
Commit | Line | Data |
---|---|---|
3af9b388 | 1 | /** @file\r |
2 | Serial I/O status code reporting worker.\r | |
3 | \r | |
d1102dba | 4 | Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r |
9d510e61 | 5 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
3af9b388 | 6 | **/\r |
7 | \r | |
8 | #include "StatusCodeHandlerPei.h"\r | |
9 | \r | |
10 | /**\r | |
11 | Convert status code value and extended data to readable ASCII string, send string to serial I/O device.\r | |
12 | \r | |
13 | @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r | |
14 | @param CodeType Indicates the type of status code being reported.\r | |
15 | @param Value Describes the current status of a hardware or\r | |
16 | software entity. This includes information about the class and\r | |
17 | subclass that is used to classify the entity as well as an operation.\r | |
18 | For progress codes, the operation is the current activity.\r | |
19 | For error codes, it is the exception.For debug codes,it is not defined at this time.\r | |
20 | @param Instance The enumeration of a hardware or software entity within\r | |
21 | the system. A system may contain multiple entities that match a class/subclass\r | |
22 | pairing. The instance differentiates between them. An instance of 0 indicates\r | |
23 | that instance information is unavailable, not meaningful, or not relevant.\r | |
24 | Valid instance numbers start with 1.\r | |
25 | @param CallerId This optional parameter may be used to identify the caller.\r | |
26 | This parameter allows the status code driver to apply different rules to\r | |
27 | different callers.\r | |
28 | @param Data This optional parameter may be used to pass additional data.\r | |
29 | \r | |
30 | @retval EFI_SUCCESS Status code reported to serial I/O successfully.\r | |
31 | \r | |
32 | **/\r | |
33 | EFI_STATUS\r | |
4a5b245a | 34 | EFIAPI\r |
3af9b388 | 35 | SerialStatusCodeReportWorker (\r |
1436aea4 MK |
36 | IN CONST EFI_PEI_SERVICES **PeiServices,\r |
37 | IN EFI_STATUS_CODE_TYPE CodeType,\r | |
38 | IN EFI_STATUS_CODE_VALUE Value,\r | |
39 | IN UINT32 Instance,\r | |
40 | IN CONST EFI_GUID *CallerId,\r | |
41 | IN CONST EFI_STATUS_CODE_DATA *Data OPTIONAL\r | |
3af9b388 | 42 | )\r |
43 | {\r | |
1436aea4 MK |
44 | CHAR8 *Filename;\r |
45 | CHAR8 *Description;\r | |
46 | CHAR8 *Format;\r | |
47 | CHAR8 Buffer[MAX_DEBUG_MESSAGE_LENGTH];\r | |
48 | UINT32 ErrorLevel;\r | |
49 | UINT32 LineNumber;\r | |
50 | UINTN CharCount;\r | |
51 | BASE_LIST Marker;\r | |
3af9b388 | 52 | \r |
53 | Buffer[0] = '\0';\r | |
54 | \r | |
1436aea4 MK |
55 | if ((Data != NULL) &&\r |
56 | ReportStatusCodeExtractAssertInfo (CodeType, Value, Data, &Filename, &Description, &LineNumber))\r | |
57 | {\r | |
3af9b388 | 58 | //\r |
59 | // Print ASSERT() information into output buffer.\r | |
60 | //\r | |
61 | CharCount = AsciiSPrint (\r | |
62 | Buffer,\r | |
63 | sizeof (Buffer),\r | |
64 | "\n\rPEI_ASSERT!: %a (%d): %a\n\r",\r | |
65 | Filename,\r | |
66 | LineNumber,\r | |
67 | Description\r | |
68 | );\r | |
1436aea4 MK |
69 | } else if ((Data != NULL) &&\r |
70 | ReportStatusCodeExtractDebugInfo (Data, &ErrorLevel, &Marker, &Format))\r | |
71 | {\r | |
3af9b388 | 72 | //\r |
73 | // Print DEBUG() information into output buffer.\r | |
74 | //\r | |
75 | CharCount = AsciiBSPrint (\r | |
76 | Buffer,\r | |
77 | sizeof (Buffer),\r | |
78 | Format,\r | |
79 | Marker\r | |
80 | );\r | |
81 | } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) {\r | |
82 | //\r | |
83 | // Print ERROR information into output buffer.\r | |
84 | //\r | |
85 | CharCount = AsciiSPrint (\r | |
86 | Buffer,\r | |
87 | sizeof (Buffer),\r | |
5d0f0ac4 | 88 | "ERROR: C%08x:V%08x I%x",\r |
3af9b388 | 89 | CodeType,\r |
90 | Value,\r | |
91 | Instance\r | |
92 | );\r | |
d1102dba | 93 | \r |
1436aea4 | 94 | ASSERT (CharCount > 0);\r |
d1102dba | 95 | \r |
3af9b388 | 96 | if (CallerId != NULL) {\r |
97 | CharCount += AsciiSPrint (\r | |
30d636c8 | 98 | &Buffer[CharCount],\r |
3af9b388 | 99 | (sizeof (Buffer) - (sizeof (Buffer[0]) * CharCount)),\r |
100 | " %g",\r | |
101 | CallerId\r | |
102 | );\r | |
103 | }\r | |
104 | \r | |
105 | if (Data != NULL) {\r | |
106 | CharCount += AsciiSPrint (\r | |
30d636c8 | 107 | &Buffer[CharCount],\r |
3af9b388 | 108 | (sizeof (Buffer) - (sizeof (Buffer[0]) * CharCount)),\r |
109 | " %x",\r | |
110 | Data\r | |
111 | );\r | |
112 | }\r | |
113 | \r | |
114 | CharCount += AsciiSPrint (\r | |
30d636c8 | 115 | &Buffer[CharCount],\r |
3af9b388 | 116 | (sizeof (Buffer) - (sizeof (Buffer[0]) * CharCount)),\r |
117 | "\n\r"\r | |
118 | );\r | |
119 | } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) {\r | |
120 | //\r | |
121 | // Print PROGRESS information into output buffer.\r | |
122 | //\r | |
123 | CharCount = AsciiSPrint (\r | |
124 | Buffer,\r | |
125 | sizeof (Buffer),\r | |
5d0f0ac4 | 126 | "PROGRESS CODE: V%08x I%x\n\r",\r |
3af9b388 | 127 | Value,\r |
128 | Instance\r | |
129 | );\r | |
1436aea4 | 130 | } else if ((Data != NULL) &&\r |
bc369e79 | 131 | CompareGuid (&Data->Type, &gEfiStatusCodeDataTypeStringGuid) &&\r |
1436aea4 MK |
132 | (((EFI_STATUS_CODE_STRING_DATA *)Data)->StringType == EfiStringAscii))\r |
133 | {\r | |
96a25163 | 134 | //\r |
135 | // EFI_STATUS_CODE_STRING_DATA\r | |
136 | //\r | |
137 | CharCount = AsciiSPrint (\r | |
138 | Buffer,\r | |
139 | sizeof (Buffer),\r | |
58ae92a9 | 140 | "%a",\r |
1436aea4 | 141 | ((EFI_STATUS_CODE_STRING_DATA *)Data)->String.Ascii\r |
96a25163 | 142 | );\r |
3af9b388 | 143 | } else {\r |
144 | //\r | |
145 | // Code type is not defined.\r | |
146 | //\r | |
147 | CharCount = AsciiSPrint (\r | |
148 | Buffer,\r | |
149 | sizeof (Buffer),\r | |
5d0f0ac4 | 150 | "Undefined: C%08x:V%08x I%x\n\r",\r |
3af9b388 | 151 | CodeType,\r |
152 | Value,\r | |
153 | Instance\r | |
154 | );\r | |
155 | }\r | |
156 | \r | |
157 | //\r | |
158 | // Call SerialPort Lib function to do print.\r | |
159 | //\r | |
1436aea4 | 160 | SerialPortWrite ((UINT8 *)Buffer, CharCount);\r |
3af9b388 | 161 | \r |
162 | return EFI_SUCCESS;\r | |
163 | }\r |