]>
Commit | Line | Data |
---|---|---|
c9093a06 | 1 | /** @file\r |
2 | OEM hook status code library functions with no library constructor/destructor\r | |
3 | \r | |
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 | |
12 | \r | |
13 | Module Name: UnixOemHookStatusCodeLib.c\r | |
14 | \r | |
15 | **/\r | |
16 | \r | |
17 | //\r | |
18 | // Cache of UnixThunk protocol \r | |
19 | //\r | |
20 | STATIC\r | |
21 | EFI_UNIX_THUNK_PROTOCOL *mUnix;\r | |
22 | \r | |
23 | //\r | |
24 | // Cache of standard output handle . \r | |
25 | //\r | |
26 | STATIC\r | |
27 | int mStdOut;\r | |
28 | \r | |
29 | /**\r | |
30 | \r | |
31 | Initialize OEM status code device .\r | |
32 | \r | |
33 | @return Always return EFI_SUCCESS.\r | |
34 | \r | |
35 | **/\r | |
36 | EFI_STATUS\r | |
37 | EFIAPI\r | |
38 | OemHookStatusCodeInitialize (\r | |
39 | VOID\r | |
40 | )\r | |
41 | {\r | |
318275b2 | 42 | EFI_HOB_GUID_TYPE *GuidHob;\r |
c9093a06 | 43 | \r |
318275b2 | 44 | //\r |
45 | // Retrieve UnixThunkProtocol from GUID'ed HOB\r | |
46 | //\r | |
47 | GuidHob = GetFirstGuidHob (&gEfiUnixThunkProtocolGuid);\r | |
48 | ASSERT (GuidHob != NULL);\r | |
49 | mUnix = (EFI_UNIX_THUNK_PROTOCOL *)(*(UINTN *)(GET_GUID_HOB_DATA (GuidHob)));\r | |
50 | ASSERT (mUnix != NULL);\r | |
c9093a06 | 51 | \r |
52 | //\r | |
53 | // Cache standard output handle.\r | |
54 | //\r | |
55 | mStdOut = 1; | |
56 | \r | |
57 | return EFI_SUCCESS;\r | |
58 | }\r | |
59 | \r | |
60 | /**\r | |
61 | Report status code to OEM device.\r | |
62 | \r | |
63 | @param CodeType Indicates the type of status code being reported. Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.\r | |
64 | \r | |
65 | @param Value Describes the current status of a hardware or software entity. \r | |
66 | This included information about the class and subclass that is used to classify the entity \r | |
67 | as well as an operation. For progress codes, the operation is the current activity. \r | |
68 | For error codes, it is the exception. For debug codes, it is not defined at this time. \r | |
69 | Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below. \r | |
70 | Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.\r | |
71 | \r | |
72 | @param Instance The enumeration of a hardware or software entity within the system. \r | |
73 | A system may contain multiple entities that match a class/subclass pairing. \r | |
74 | The instance differentiates between them. An instance of 0 indicates that instance information is unavailable, \r | |
75 | not meaningful, or not relevant. Valid instance numbers start with 1.\r | |
76 | \r | |
77 | \r | |
78 | @param CallerId This optional parameter may be used to identify the caller. \r | |
79 | This parameter allows the status code driver to apply different rules to different callers. \r | |
80 | Type EFI_GUID is defined in InstallProtocolInterface() in the EFI 1.10 Specification.\r | |
81 | \r | |
82 | \r | |
83 | @param Data This optional parameter may be used to pass additional data\r | |
84 | \r | |
85 | @return The function always return EFI_SUCCESS.\r | |
86 | \r | |
87 | **/\r | |
88 | EFI_STATUS\r | |
89 | EFIAPI\r | |
90 | OemHookStatusCodeReport (\r | |
91 | IN EFI_STATUS_CODE_TYPE CodeType,\r | |
92 | IN EFI_STATUS_CODE_VALUE Value,\r | |
93 | IN UINT32 Instance,\r | |
94 | IN EFI_GUID *CallerId, OPTIONAL\r | |
95 | IN EFI_STATUS_CODE_DATA *Data OPTIONAL\r | |
96 | )\r | |
97 | {\r | |
98 | CHAR8 *Filename;\r | |
99 | CHAR8 *Description;\r | |
100 | CHAR8 *Format;\r | |
101 | CHAR8 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE];\r | |
102 | UINT32 ErrorLevel;\r | |
103 | UINT32 LineNumber;\r | |
104 | UINTN CharCount;\r | |
105 | VA_LIST Marker;\r | |
106 | EFI_DEBUG_INFO *DebugInfo;\r | |
107 | \r | |
108 | Buffer[0] = '\0';\r | |
109 | \r | |
110 | if (Data != NULL &&\r | |
111 | ReportStatusCodeExtractAssertInfo (CodeType, Value, Data, &Filename, &Description, &LineNumber)) {\r | |
112 | //\r | |
113 | // Print ASSERT() information into output buffer.\r | |
114 | //\r | |
115 | CharCount = AsciiSPrint (\r | |
116 | Buffer,\r | |
117 | EFI_STATUS_CODE_DATA_MAX_SIZE,\r | |
118 | "\n\rASSERT!: %a (%d): %a\n\r",\r | |
119 | Filename,\r | |
120 | LineNumber,\r | |
121 | Description\r | |
122 | );\r | |
123 | \r | |
124 | //\r | |
125 | // Callout to standard output.\r | |
126 | //\r | |
127 | mUnix->Write (\r | |
128 | mStdOut,\r | |
129 | Buffer,\r | |
130 | CharCount\r | |
131 | ); | |
132 | \r | |
133 | return EFI_SUCCESS;\r | |
134 | \r | |
135 | } else if (Data != NULL &&\r | |
136 | ReportStatusCodeExtractDebugInfo (Data, &ErrorLevel, &Marker, &Format)) {\r | |
137 | //\r | |
138 | // Print DEBUG() information into output buffer.\r | |
139 | //\r | |
140 | CharCount = AsciiVSPrint (\r | |
141 | Buffer, \r | |
142 | EFI_STATUS_CODE_DATA_MAX_SIZE, \r | |
143 | Format, \r | |
144 | Marker\r | |
145 | );\r | |
146 | } else if (Data != NULL && \r | |
147 | CompareGuid (&Data->Type, &gEfiStatusCodeSpecificDataGuid) &&\r | |
148 | (CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) {\r | |
149 | //\r | |
150 | // Print specific data into output buffer.\r | |
151 | //\r | |
152 | DebugInfo = (EFI_DEBUG_INFO *) (Data + 1);\r | |
153 | Marker = (VA_LIST) (DebugInfo + 1);\r | |
154 | Format = (CHAR8 *) (((UINT64 *) Marker) + 12);\r | |
155 | \r | |
156 | CharCount = AsciiVSPrint (Buffer, EFI_STATUS_CODE_DATA_MAX_SIZE, Format, Marker);\r | |
157 | } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) {\r | |
158 | //\r | |
159 | // Print ERROR information into output buffer.\r | |
160 | //\r | |
161 | CharCount = AsciiSPrint (\r | |
162 | Buffer, \r | |
163 | EFI_STATUS_CODE_DATA_MAX_SIZE, \r | |
164 | "ERROR: C%x:V%x I%x", \r | |
165 | CodeType, \r | |
166 | Value, \r | |
167 | Instance\r | |
168 | );\r | |
169 | \r | |
170 | //\r | |
171 | // Make sure we don't try to print values that weren't intended to be printed, especially NULL GUID pointers.\r | |
172 | //\r | |
173 | \r | |
174 | if (CallerId != NULL) {\r | |
175 | CharCount += AsciiSPrint (\r | |
176 | &Buffer[CharCount - 1],\r | |
177 | (EFI_STATUS_CODE_DATA_MAX_SIZE - (sizeof (Buffer[0]) * CharCount)),\r | |
178 | " %g",\r | |
179 | CallerId\r | |
180 | );\r | |
181 | }\r | |
182 | \r | |
183 | if (Data != NULL) {\r | |
184 | CharCount += AsciiSPrint (\r | |
185 | &Buffer[CharCount - 1],\r | |
186 | (EFI_STATUS_CODE_DATA_MAX_SIZE - (sizeof (Buffer[0]) * CharCount)),\r | |
187 | " %x",\r | |
188 | Data\r | |
189 | );\r | |
190 | }\r | |
191 | \r | |
192 | CharCount += AsciiSPrint (\r | |
193 | &Buffer[CharCount - 1],\r | |
194 | (EFI_STATUS_CODE_DATA_MAX_SIZE - (sizeof (Buffer[0]) * CharCount)),\r | |
195 | "\n\r"\r | |
196 | );\r | |
197 | } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) {\r | |
198 | CharCount = AsciiSPrint (\r | |
199 | Buffer, \r | |
200 | EFI_STATUS_CODE_DATA_MAX_SIZE, \r | |
201 | "PROGRESS CODE: V%x I%x\n\r", \r | |
202 | Value, \r | |
203 | Instance\r | |
204 | );\r | |
205 | } else {\r | |
206 | CharCount = AsciiSPrint (\r | |
207 | Buffer, \r | |
208 | EFI_STATUS_CODE_DATA_MAX_SIZE, \r | |
209 | "Undefined: C%x:V%x I%x\n\r", \r | |
210 | CodeType, \r | |
211 | Value, \r | |
212 | Instance\r | |
213 | );\r | |
214 | }\r | |
215 | \r | |
216 | //\r | |
217 | // Callout to standard output.\r | |
218 | //\r | |
219 | mUnix->Write (\r | |
220 | mStdOut,\r | |
221 | Buffer,\r | |
222 | CharCount\r | |
223 | );\r | |
224 | \r | |
225 | return EFI_SUCCESS;\r | |
226 | }\r | |
227 | \r |