]>
Commit | Line | Data |
---|---|---|
7aa2023e | 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: Nt32OemHookStatusCodeLib.c\r | |
14 | \r | |
15 | **/\r | |
16 | \r | |
17 | //\r | |
18 | // Cache of WinNtThunk protocol \r | |
19 | //\r | |
20 | STATIC\r | |
21 | EFI_WIN_NT_THUNK_PROTOCOL *mWinNt;\r | |
22 | \r | |
23 | //\r | |
24 | // Cache of standard output handle . \r | |
25 | //\r | |
26 | STATIC\r | |
27 | HANDLE 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 | |
42 | EFI_HOB_GUID_TYPE *GuidHob;\r | |
43 | \r | |
44 | //\r | |
45 | // Retrieve WinNtThunkProtocol from GUID'ed HOB\r | |
46 | //\r | |
47 | GuidHob = GetFirstGuidHob (&gEfiWinNtThunkProtocolGuid);\r | |
48 | ASSERT (GuidHob != NULL);\r | |
49 | mWinNt = (EFI_WIN_NT_THUNK_PROTOCOL *)(*(UINTN *)(GET_GUID_HOB_DATA (GuidHob)));\r | |
50 | ASSERT (mWinNt != NULL);\r | |
51 | \r | |
52 | //\r | |
53 | // Cache standard output handle.\r | |
54 | //\r | |
55 | mStdOut = mWinNt->GetStdHandle (STD_OUTPUT_HANDLE);\r | |
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 | mWinNt->WriteFile (\r | |
128 | mStdOut,\r | |
129 | Buffer,\r | |
130 | CharCount,\r | |
131 | &CharCount,\r | |
132 | NULL\r | |
133 | );\r | |
134 | \r | |
135 | return EFI_SUCCESS;\r | |
136 | \r | |
137 | } else if (Data != NULL &&\r | |
138 | ReportStatusCodeExtractDebugInfo (Data, &ErrorLevel, &Marker, &Format)) {\r | |
139 | //\r | |
140 | // Print DEBUG() information into output buffer.\r | |
141 | //\r | |
142 | CharCount = AsciiVSPrint (\r | |
143 | Buffer, \r | |
144 | EFI_STATUS_CODE_DATA_MAX_SIZE, \r | |
145 | Format, \r | |
146 | Marker\r | |
147 | );\r | |
148 | } else if (Data != NULL && \r | |
149 | CompareGuid (&Data->Type, &gEfiStatusCodeSpecificDataGuid) &&\r | |
150 | (CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) {\r | |
151 | //\r | |
152 | // Print specific data into output buffer.\r | |
153 | //\r | |
154 | DebugInfo = (EFI_DEBUG_INFO *) (Data + 1);\r | |
155 | Marker = (VA_LIST) (DebugInfo + 1);\r | |
156 | Format = (CHAR8 *) (((UINT64 *) Marker) + 12);\r | |
157 | \r | |
158 | CharCount = AsciiVSPrint (Buffer, EFI_STATUS_CODE_DATA_MAX_SIZE, Format, Marker);\r | |
159 | } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) {\r | |
160 | //\r | |
161 | // Print ERROR information into output buffer.\r | |
162 | //\r | |
163 | CharCount = AsciiSPrint (\r | |
164 | Buffer, \r | |
165 | EFI_STATUS_CODE_DATA_MAX_SIZE, \r | |
166 | "ERROR: C%x:V%x I%x", \r | |
167 | CodeType, \r | |
168 | Value, \r | |
169 | Instance\r | |
170 | );\r | |
171 | \r | |
172 | //\r | |
173 | // Make sure we don't try to print values that weren't intended to be printed, especially NULL GUID pointers.\r | |
174 | //\r | |
175 | \r | |
176 | if (CallerId != NULL) {\r | |
177 | CharCount += AsciiSPrint (\r | |
178 | &Buffer[CharCount - 1],\r | |
179 | (EFI_STATUS_CODE_DATA_MAX_SIZE - (sizeof (Buffer[0]) * CharCount)),\r | |
180 | " %g",\r | |
181 | CallerId\r | |
182 | );\r | |
183 | }\r | |
184 | \r | |
185 | if (Data != NULL) {\r | |
186 | CharCount += AsciiSPrint (\r | |
187 | &Buffer[CharCount - 1],\r | |
188 | (EFI_STATUS_CODE_DATA_MAX_SIZE - (sizeof (Buffer[0]) * CharCount)),\r | |
189 | " %x",\r | |
190 | Data\r | |
191 | );\r | |
192 | }\r | |
193 | \r | |
194 | CharCount += AsciiSPrint (\r | |
195 | &Buffer[CharCount - 1],\r | |
196 | (EFI_STATUS_CODE_DATA_MAX_SIZE - (sizeof (Buffer[0]) * CharCount)),\r | |
197 | "\n\r"\r | |
198 | );\r | |
199 | } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) {\r | |
200 | CharCount = AsciiSPrint (\r | |
201 | Buffer, \r | |
202 | EFI_STATUS_CODE_DATA_MAX_SIZE, \r | |
203 | "PROGRESS CODE: V%x I%x\n\r", \r | |
204 | Value, \r | |
205 | Instance\r | |
206 | );\r | |
207 | } else {\r | |
208 | CharCount = AsciiSPrint (\r | |
209 | Buffer, \r | |
210 | EFI_STATUS_CODE_DATA_MAX_SIZE, \r | |
211 | "Undefined: C%x:V%x I%x\n\r", \r | |
212 | CodeType, \r | |
213 | Value, \r | |
214 | Instance\r | |
215 | );\r | |
216 | }\r | |
217 | \r | |
218 | //\r | |
219 | // Callout to standard output.\r | |
220 | //\r | |
221 | mWinNt->WriteFile (\r | |
222 | mStdOut,\r | |
223 | Buffer,\r | |
224 | CharCount,\r | |
225 | &CharCount,\r | |
226 | NULL\r | |
227 | );\r | |
228 | \r | |
229 | return EFI_SUCCESS;\r | |
230 | }\r | |
231 | \r |