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