]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | Serial I/O status code reporting worker.\r | |
3 | \r | |
4 | Copyright (c) 2006 - 2014, 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 | |
12 | \r | |
13 | **/\r | |
14 | \r | |
15 | #include "StatusCodeHandlerRuntimeDxe.h"\r | |
16 | \r | |
17 | /**\r | |
18 | Convert status code value and extended data to readable ASCII string, send string to serial I/O device.\r | |
19 | \r | |
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 | |
34 | \r | |
35 | **/\r | |
36 | EFI_STATUS\r | |
37 | EFIAPI\r | |
38 | SerialStatusCodeReportWorker (\r | |
39 | IN EFI_STATUS_CODE_TYPE CodeType,\r | |
40 | IN EFI_STATUS_CODE_VALUE Value,\r | |
41 | IN UINT32 Instance,\r | |
42 | IN EFI_GUID *CallerId,\r | |
43 | IN EFI_STATUS_CODE_DATA *Data OPTIONAL\r | |
44 | )\r | |
45 | {\r | |
46 | CHAR8 *Filename;\r | |
47 | CHAR8 *Description;\r | |
48 | CHAR8 *Format;\r | |
49 | CHAR8 Buffer[MAX_DEBUG_MESSAGE_LENGTH];\r | |
50 | UINT32 ErrorLevel;\r | |
51 | UINT32 LineNumber;\r | |
52 | UINTN CharCount;\r | |
53 | BASE_LIST Marker;\r | |
54 | \r | |
55 | Buffer[0] = '\0';\r | |
56 | \r | |
57 | if (Data != NULL &&\r | |
58 | ReportStatusCodeExtractAssertInfo (CodeType, Value, Data, &Filename, &Description, &LineNumber)) {\r | |
59 | //\r | |
60 | // Print ASSERT() information into output buffer.\r | |
61 | //\r | |
62 | CharCount = AsciiSPrint (\r | |
63 | Buffer,\r | |
64 | sizeof (Buffer),\r | |
65 | "\n\rDXE_ASSERT!: %a (%d): %a\n\r",\r | |
66 | Filename,\r | |
67 | LineNumber,\r | |
68 | Description\r | |
69 | );\r | |
70 | } else if (Data != NULL &&\r | |
71 | ReportStatusCodeExtractDebugInfo (Data, &ErrorLevel, &Marker, &Format)) {\r | |
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 | |
88 | "ERROR: C%08x:V%08x I%x", \r | |
89 | CodeType, \r | |
90 | Value, \r | |
91 | Instance\r | |
92 | );\r | |
93 | ASSERT (CharCount > 0);\r | |
94 | \r | |
95 | if (CallerId != NULL) {\r | |
96 | CharCount += AsciiSPrint (\r | |
97 | &Buffer[CharCount],\r | |
98 | (sizeof (Buffer) - (sizeof (Buffer[0]) * CharCount)),\r | |
99 | " %g",\r | |
100 | CallerId\r | |
101 | );\r | |
102 | }\r | |
103 | \r | |
104 | if (Data != NULL) {\r | |
105 | CharCount += AsciiSPrint (\r | |
106 | &Buffer[CharCount],\r | |
107 | (sizeof (Buffer) - (sizeof (Buffer[0]) * CharCount)),\r | |
108 | " %x",\r | |
109 | Data\r | |
110 | );\r | |
111 | }\r | |
112 | \r | |
113 | CharCount += AsciiSPrint (\r | |
114 | &Buffer[CharCount],\r | |
115 | (sizeof (Buffer) - (sizeof (Buffer[0]) * CharCount)),\r | |
116 | "\n\r"\r | |
117 | );\r | |
118 | } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) {\r | |
119 | //\r | |
120 | // Print PROGRESS information into output buffer.\r | |
121 | //\r | |
122 | CharCount = AsciiSPrint (\r | |
123 | Buffer, \r | |
124 | sizeof (Buffer), \r | |
125 | "PROGRESS CODE: V%08x I%x\n\r", \r | |
126 | Value, \r | |
127 | Instance\r | |
128 | );\r | |
129 | } else if (Data != NULL &&\r | |
130 | CompareGuid (&Data->Type, &gEfiStatusCodeDataTypeStringGuid) &&\r | |
131 | ((EFI_STATUS_CODE_STRING_DATA *) Data)->StringType == EfiStringAscii) {\r | |
132 | //\r | |
133 | // EFI_STATUS_CODE_STRING_DATA\r | |
134 | //\r | |
135 | CharCount = AsciiSPrint (\r | |
136 | Buffer,\r | |
137 | sizeof (Buffer),\r | |
138 | "%a\n\r",\r | |
139 | ((EFI_STATUS_CODE_STRING_DATA *) Data)->String.Ascii\r | |
140 | );\r | |
141 | } else {\r | |
142 | //\r | |
143 | // Code type is not defined.\r | |
144 | //\r | |
145 | CharCount = AsciiSPrint (\r | |
146 | Buffer, \r | |
147 | sizeof (Buffer), \r | |
148 | "Undefined: C%08x:V%08x I%x\n\r", \r | |
149 | CodeType, \r | |
150 | Value, \r | |
151 | Instance\r | |
152 | );\r | |
153 | }\r | |
154 | \r | |
155 | //\r | |
156 | // Call SerialPort Lib function to do print.\r | |
157 | //\r | |
158 | SerialPortWrite ((UINT8 *) Buffer, CharCount);\r | |
159 | \r | |
160 | return EFI_SUCCESS;\r | |
161 | }\r | |
162 | \r |