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