]>
Commit | Line | Data |
---|---|---|
2287f237 | 1 | /** @file\r |
9ba6cd30 | 2 | Debug Library based on report status code library.\r |
2287f237 | 3 | \r |
a1158366 | 4 | Note that if the debug message length is larger than the maximum allowable\r |
5 | record length, then the debug message will be ignored directly.\r | |
6 | \r | |
9fb1f7ef | 7 | Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>\r |
c0a00b14 | 8 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
2287f237 | 9 | \r |
10 | **/\r | |
11 | \r | |
4569c9e6 | 12 | #include <PiPei.h>\r |
79bc7a89 | 13 | \r |
2287f237 | 14 | #include <Guid/StatusCodeDataTypeId.h>\r |
3a6064fa | 15 | #include <Guid/StatusCodeDataTypeDebug.h>\r |
2287f237 | 16 | \r |
17 | #include <Library/DebugLib.h>\r | |
18 | #include <Library/BaseLib.h>\r | |
19 | #include <Library/BaseMemoryLib.h>\r | |
20 | #include <Library/ReportStatusCodeLib.h>\r | |
21 | #include <Library/PcdLib.h>\r | |
c77b88d6 | 22 | #include <Library/DebugPrintErrorLevelLib.h>\r |
2287f237 | 23 | \r |
9fb1f7ef BB |
24 | //\r |
25 | // VA_LIST can not initialize to NULL for all compiler, so we use this to\r | |
26 | // indicate a null VA_LIST\r | |
27 | //\r | |
28 | VA_LIST mVaListNull;\r | |
29 | \r | |
2287f237 | 30 | /**\r |
2287f237 | 31 | Prints a debug message to the debug output device if the specified error level is enabled.\r |
32 | \r | |
0a6f4824 LG |
33 | If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function\r |
34 | GetDebugPrintErrorLevel (), then print the message specified by Format and the\r | |
c77b88d6 | 35 | associated variable argument list to the debug output device.\r |
2287f237 | 36 | \r |
37 | If Format is NULL, then ASSERT().\r | |
38 | \r | |
a1158366 | 39 | If the length of the message string specificed by Format is larger than the maximum allowable\r |
40 | record length, then directly return and not print it.\r | |
41 | \r | |
2287f237 | 42 | @param ErrorLevel The error level of the debug message.\r |
43 | @param Format Format string for the debug message to print.\r | |
0a6f4824 | 44 | @param ... Variable argument list whose contents are accessed\r |
967c09fa | 45 | based on the format string specified by Format.\r |
2287f237 | 46 | \r |
47 | **/\r | |
48 | VOID\r | |
49 | EFIAPI\r | |
50 | DebugPrint (\r | |
51 | IN UINTN ErrorLevel,\r | |
52 | IN CONST CHAR8 *Format,\r | |
53 | ...\r | |
54 | )\r | |
9fb1f7ef BB |
55 | {\r |
56 | VA_LIST Marker;\r | |
57 | \r | |
58 | VA_START (Marker, Format);\r | |
59 | DebugVPrint (ErrorLevel, Format, Marker);\r | |
60 | VA_END (Marker);\r | |
61 | }\r | |
62 | \r | |
63 | /**\r | |
64 | Prints a debug message to the debug output device if the specified\r | |
65 | error level is enabled base on Null-terminated format string and a\r | |
66 | VA_LIST argument list or a BASE_LIST argument list.\r | |
67 | \r | |
68 | If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function\r | |
69 | GetDebugPrintErrorLevel (), then print the message specified by Format and\r | |
70 | the associated variable argument list to the debug output device.\r | |
71 | \r | |
72 | Only one list type is used.\r | |
73 | If BaseListMarker == NULL, then use VaListMarker.\r | |
74 | Otherwise use BaseListMarker and the VaListMarker should be initilized as\r | |
75 | mVaListNull.\r | |
76 | \r | |
77 | If Format is NULL, then ASSERT().\r | |
78 | \r | |
79 | @param ErrorLevel The error level of the debug message.\r | |
80 | @param Format Format string for the debug message to print.\r | |
81 | @param VaListMarker VA_LIST marker for the variable argument list.\r | |
82 | @param BaseListMarker BASE_LIST marker for the variable argument list.\r | |
83 | \r | |
84 | **/\r | |
85 | VOID\r | |
86 | DebugPrintMarker (\r | |
87 | IN UINTN ErrorLevel,\r | |
88 | IN CONST CHAR8 *Format,\r | |
89 | IN VA_LIST VaListMarker,\r | |
90 | IN BASE_LIST BaseListMarker\r | |
91 | )\r | |
2287f237 | 92 | {\r |
6916d99c | 93 | UINT64 Buffer[(EFI_STATUS_CODE_DATA_MAX_SIZE / sizeof (UINT64)) + 1];\r |
2287f237 | 94 | EFI_DEBUG_INFO *DebugInfo;\r |
95 | UINTN TotalSize;\r | |
d5cbc27b | 96 | UINTN DestBufferSize;\r |
9fb1f7ef | 97 | BASE_LIST BaseListMarkerPointer;\r |
ca9938b8 | 98 | CHAR8 *FormatString;\r |
99 | BOOLEAN Long;\r | |
2287f237 | 100 | \r |
101 | //\r | |
102 | // If Format is NULL, then ASSERT().\r | |
103 | //\r | |
104 | ASSERT (Format != NULL);\r | |
105 | \r | |
106 | //\r | |
107 | // Check driver Debug Level value and global debug level\r | |
108 | //\r | |
c77b88d6 | 109 | if ((ErrorLevel & GetDebugPrintErrorLevel ()) == 0) {\r |
2287f237 | 110 | return;\r |
111 | }\r | |
112 | \r | |
ca9938b8 | 113 | //\r |
0fac539f | 114 | // Compute the total size of the record.\r |
0a6f4824 | 115 | // Note that the passing-in format string and variable parameters will be constructed to\r |
0fac539f | 116 | // the following layout:\r |
ca9938b8 | 117 | //\r |
9fb1f7ef BB |
118 | // Buffer->|------------------------|\r |
119 | // | Padding | 4 bytes\r | |
120 | // DebugInfo->|------------------------|\r | |
121 | // | EFI_DEBUG_INFO | sizeof(EFI_DEBUG_INFO)\r | |
122 | // BaseListMarkerPointer->|------------------------|\r | |
123 | // | ... |\r | |
124 | // | variable arguments | 12 * sizeof (UINT64)\r | |
125 | // | ... |\r | |
126 | // |------------------------|\r | |
127 | // | Format String |\r | |
128 | // |------------------------|<- (UINT8 *)Buffer + sizeof(Buffer)\r | |
0fac539f | 129 | //\r |
130 | TotalSize = 4 + sizeof (EFI_DEBUG_INFO) + 12 * sizeof (UINT64) + AsciiStrSize (Format);\r | |
ca9938b8 | 131 | \r |
ca9938b8 | 132 | //\r |
9fb1f7ef | 133 | // If the TotalSize is larger than the maximum record size, then truncate it.\r |
ca9938b8 | 134 | //\r |
1ca88083 | 135 | if (TotalSize > sizeof (Buffer)) {\r |
9fb1f7ef | 136 | TotalSize = sizeof (Buffer);\r |
2287f237 | 137 | }\r |
138 | \r | |
139 | //\r | |
ca9938b8 | 140 | // Fill in EFI_DEBUG_INFO\r |
2287f237 | 141 | //\r |
9fb1f7ef BB |
142 | // Here we skip the first 4 bytes of Buffer, because we must ensure BaseListMarkerPointer is\r |
143 | // 64-bit aligned, otherwise retrieving 64-bit parameter from BaseListMarkerPointer will cause\r | |
9ba6cd30 | 144 | // exception on IPF. Buffer starts at 64-bit aligned address, so skipping 4 types (sizeof(EFI_DEBUG_INFO))\r |
9fb1f7ef | 145 | // just makes address of BaseListMarkerPointer, which follows DebugInfo, 64-bit aligned.\r |
9ba6cd30 | 146 | //\r |
6916d99c | 147 | DebugInfo = (EFI_DEBUG_INFO *)(Buffer) + 1;\r |
2287f237 | 148 | DebugInfo->ErrorLevel = (UINT32)ErrorLevel;\r |
9fb1f7ef | 149 | BaseListMarkerPointer = (BASE_LIST)(DebugInfo + 1);\r |
3d7dfb38 | 150 | FormatString = (CHAR8 *)((UINT64 *)(DebugInfo + 1) + 12);\r |
ca9938b8 | 151 | \r |
152 | //\r | |
153 | // Copy the Format string into the record\r | |
154 | //\r | |
d5cbc27b HW |
155 | // According to the content structure of Buffer shown above, the size of\r |
156 | // the FormatString buffer is the size of Buffer minus the Padding\r | |
157 | // (4 bytes), minus the size of EFI_DEBUG_INFO, minus the size of\r | |
158 | // variable arguments (12 * sizeof (UINT64)).\r | |
159 | //\r | |
160 | DestBufferSize = sizeof (Buffer) - 4 - sizeof (EFI_DEBUG_INFO) - 12 * sizeof (UINT64);\r | |
161 | AsciiStrCpyS (FormatString, DestBufferSize / sizeof (CHAR8), Format);\r | |
2287f237 | 162 | \r |
163 | //\r | |
9ba6cd30 | 164 | // The first 12 * sizeof (UINT64) bytes following EFI_DEBUG_INFO are for variable arguments\r |
165 | // of format in DEBUG string, which is followed by the DEBUG format string.\r | |
166 | // Here we will process the variable arguments and pack them in this area.\r | |
2287f237 | 167 | //\r |
ca9938b8 | 168 | for (; *Format != '\0'; Format++) {\r |
9ba6cd30 | 169 | //\r |
170 | // Only format with prefix % is processed.\r | |
171 | //\r | |
ca9938b8 | 172 | if (*Format != '%') {\r |
173 | continue;\r | |
174 | }\r | |
175 | Long = FALSE;\r | |
176 | //\r | |
177 | // Parse Flags and Width\r | |
178 | //\r | |
3d747a89 | 179 | for (Format++; TRUE; Format++) {\r |
180 | if (*Format == '.' || *Format == '-' || *Format == '+' || *Format == ' ') {\r | |
9ba6cd30 | 181 | //\r |
182 | // These characters in format field are omitted.\r | |
183 | //\r | |
3d747a89 | 184 | continue;\r |
185 | }\r | |
186 | if (*Format >= '0' && *Format <= '9') {\r | |
187 | //\r | |
188 | // These characters in format field are omitted.\r | |
189 | //\r | |
190 | continue;\r | |
191 | }\r | |
192 | if (*Format == 'L' || *Format == 'l') {\r | |
9ba6cd30 | 193 | //\r |
194 | // 'L" or "l" in format field means the number being printed is a UINT64\r | |
195 | //\r | |
ca9938b8 | 196 | Long = TRUE;\r |
3d747a89 | 197 | continue;\r |
198 | }\r | |
199 | if (*Format == '*') {\r | |
9ba6cd30 | 200 | //\r |
201 | // '*' in format field means the precision of the field is specified by\r | |
202 | // a UINTN argument in the argument list.\r | |
203 | //\r | |
9fb1f7ef BB |
204 | if (BaseListMarker == NULL) {\r |
205 | BASE_ARG (BaseListMarkerPointer, UINTN) = VA_ARG (VaListMarker, UINTN);\r | |
206 | } else {\r | |
207 | BASE_ARG (BaseListMarkerPointer, UINTN) = BASE_ARG (BaseListMarker, UINTN);\r | |
208 | }\r | |
3d747a89 | 209 | continue;\r |
210 | }\r | |
211 | if (*Format == '\0') {\r | |
ca9938b8 | 212 | //\r |
213 | // Make no output if Format string terminates unexpectedly when\r | |
0a6f4824 | 214 | // looking up for flag, width, precision and type.\r |
ca9938b8 | 215 | //\r |
216 | Format--;\r | |
ca9938b8 | 217 | }\r |
3d747a89 | 218 | //\r |
219 | // When valid argument type detected or format string terminates unexpectedly,\r | |
220 | // the inner loop is done.\r | |
221 | //\r | |
222 | break;\r | |
223 | }\r | |
0a6f4824 | 224 | \r |
ca9938b8 | 225 | //\r |
9ba6cd30 | 226 | // Pack variable arguments into the storage area following EFI_DEBUG_INFO.\r |
ca9938b8 | 227 | //\r |
3d747a89 | 228 | if ((*Format == 'p') && (sizeof (VOID *) > 4)) {\r |
229 | Long = TRUE;\r | |
230 | }\r | |
94e3eee6 | 231 | if (*Format == 'p' || *Format == 'X' || *Format == 'x' || *Format == 'd' || *Format == 'u') {\r |
ca9938b8 | 232 | if (Long) {\r |
9fb1f7ef BB |
233 | if (BaseListMarker == NULL) {\r |
234 | BASE_ARG (BaseListMarkerPointer, INT64) = VA_ARG (VaListMarker, INT64);\r | |
235 | } else {\r | |
236 | BASE_ARG (BaseListMarkerPointer, INT64) = BASE_ARG (BaseListMarker, INT64);\r | |
237 | }\r | |
ca9938b8 | 238 | } else {\r |
9fb1f7ef BB |
239 | if (BaseListMarker == NULL) {\r |
240 | BASE_ARG (BaseListMarkerPointer, int) = VA_ARG (VaListMarker, int);\r | |
241 | } else {\r | |
242 | BASE_ARG (BaseListMarkerPointer, int) = BASE_ARG (BaseListMarker, int);\r | |
243 | }\r | |
ca9938b8 | 244 | }\r |
3d747a89 | 245 | } else if (*Format == 's' || *Format == 'S' || *Format == 'a' || *Format == 'g' || *Format == 't') {\r |
9fb1f7ef BB |
246 | if (BaseListMarker == NULL) {\r |
247 | BASE_ARG (BaseListMarkerPointer, VOID *) = VA_ARG (VaListMarker, VOID *);\r | |
248 | } else {\r | |
249 | BASE_ARG (BaseListMarkerPointer, VOID *) = BASE_ARG (BaseListMarker, VOID *);\r | |
250 | }\r | |
3d747a89 | 251 | } else if (*Format == 'c') {\r |
9fb1f7ef BB |
252 | if (BaseListMarker == NULL) {\r |
253 | BASE_ARG (BaseListMarkerPointer, UINTN) = VA_ARG (VaListMarker, UINTN);\r | |
254 | } else {\r | |
255 | BASE_ARG (BaseListMarkerPointer, UINTN) = BASE_ARG (BaseListMarker, UINTN);\r | |
256 | }\r | |
3d747a89 | 257 | } else if (*Format == 'r') {\r |
9fb1f7ef BB |
258 | if (BaseListMarker == NULL) {\r |
259 | BASE_ARG (BaseListMarkerPointer, RETURN_STATUS) = VA_ARG (VaListMarker, RETURN_STATUS);\r | |
260 | } else {\r | |
261 | BASE_ARG (BaseListMarkerPointer, RETURN_STATUS) = BASE_ARG (BaseListMarker, RETURN_STATUS);\r | |
262 | }\r | |
ca9938b8 | 263 | }\r |
264 | \r | |
265 | //\r | |
266 | // If the converted BASE_LIST is larger than the 12 * sizeof (UINT64) allocated bytes, then ASSERT()\r | |
0a6f4824 | 267 | // This indicates that the DEBUG() macro is passing in more argument than can be handled by\r |
ca9938b8 | 268 | // the EFI_DEBUG_INFO record\r |
269 | //\r | |
9fb1f7ef | 270 | ASSERT ((CHAR8 *)BaseListMarkerPointer <= FormatString);\r |
ca9938b8 | 271 | \r |
272 | //\r | |
273 | // If the converted BASE_LIST is larger than the 12 * sizeof (UINT64) allocated bytes, then return\r | |
274 | //\r | |
9fb1f7ef | 275 | if ((CHAR8 *)BaseListMarkerPointer > FormatString) {\r |
ca9938b8 | 276 | return;\r |
277 | }\r | |
2287f237 | 278 | }\r |
2287f237 | 279 | \r |
ca9938b8 | 280 | //\r |
281 | // Send the DebugInfo record\r | |
282 | //\r | |
2287f237 | 283 | REPORT_STATUS_CODE_EX (\r |
284 | EFI_DEBUG_CODE,\r | |
285 | (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_DC_UNSPECIFIED),\r | |
286 | 0,\r | |
287 | NULL,\r | |
288 | &gEfiStatusCodeDataTypeDebugGuid,\r | |
289 | DebugInfo,\r | |
290 | TotalSize\r | |
291 | );\r | |
292 | }\r | |
293 | \r | |
9fb1f7ef BB |
294 | /**\r |
295 | Prints a debug message to the debug output device if the specified\r | |
296 | error level is enabled.\r | |
297 | \r | |
298 | If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function\r | |
299 | GetDebugPrintErrorLevel (), then print the message specified by Format and\r | |
300 | the associated variable argument list to the debug output device.\r | |
301 | \r | |
302 | If Format is NULL, then ASSERT().\r | |
303 | \r | |
304 | @param ErrorLevel The error level of the debug message.\r | |
305 | @param Format Format string for the debug message to print.\r | |
306 | @param VaListMarker VA_LIST marker for the variable argument list.\r | |
307 | \r | |
308 | **/\r | |
309 | VOID\r | |
310 | EFIAPI\r | |
311 | DebugVPrint (\r | |
312 | IN UINTN ErrorLevel,\r | |
313 | IN CONST CHAR8 *Format,\r | |
314 | IN VA_LIST VaListMarker\r | |
315 | )\r | |
316 | {\r | |
317 | DebugPrintMarker (ErrorLevel, Format, VaListMarker, NULL);\r | |
318 | }\r | |
319 | \r | |
320 | /**\r | |
321 | Prints a debug message to the debug output device if the specified\r | |
322 | error level is enabled.\r | |
323 | This function use BASE_LIST which would provide a more compatible\r | |
324 | service than VA_LIST.\r | |
325 | \r | |
326 | If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function\r | |
327 | GetDebugPrintErrorLevel (), then print the message specified by Format and\r | |
328 | the associated variable argument list to the debug output device.\r | |
329 | \r | |
330 | If Format is NULL, then ASSERT().\r | |
331 | \r | |
332 | @param ErrorLevel The error level of the debug message.\r | |
333 | @param Format Format string for the debug message to print.\r | |
334 | @param BaseListMarker BASE_LIST marker for the variable argument list.\r | |
335 | \r | |
336 | **/\r | |
337 | VOID\r | |
338 | EFIAPI\r | |
339 | DebugBPrint (\r | |
340 | IN UINTN ErrorLevel,\r | |
341 | IN CONST CHAR8 *Format,\r | |
342 | IN BASE_LIST BaseListMarker\r | |
343 | )\r | |
344 | {\r | |
345 | DebugPrintMarker (ErrorLevel, Format, mVaListNull, BaseListMarker);\r | |
346 | }\r | |
347 | \r | |
2287f237 | 348 | /**\r |
0a6f4824 | 349 | Prints an assert message containing a filename, line number, and description.\r |
2287f237 | 350 | This may be followed by a breakpoint or a dead loop.\r |
351 | \r | |
352 | Print a message of the form "ASSERT <FileName>(<LineNumber>): <Description>\n"\r | |
0a6f4824 LG |
353 | to the debug output device. If DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED bit of\r |
354 | PcdDebugProperyMask is set then CpuBreakpoint() is called. Otherwise, if\r | |
355 | DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED bit of PcdDebugProperyMask is set then\r | |
356 | CpuDeadLoop() is called. If neither of these bits are set, then this function\r | |
2287f237 | 357 | returns immediately after the message is printed to the debug output device.\r |
584125bc | 358 | DebugAssert() must actively prevent recursion. If DebugAssert() is called while\r |
2287f237 | 359 | processing another DebugAssert(), then DebugAssert() must return immediately.\r |
360 | \r | |
361 | If FileName is NULL, then a <FileName> string of "(NULL) Filename" is printed.\r | |
2287f237 | 362 | If Description is NULL, then a <Description> string of "(NULL) Description" is printed.\r |
363 | \r | |
364 | @param FileName Pointer to the name of the source file that generated the assert condition.\r | |
365 | @param LineNumber The line number in the source file that generated the assert condition\r | |
366 | @param Description Pointer to the description of the assert condition.\r | |
367 | \r | |
368 | **/\r | |
369 | VOID\r | |
370 | EFIAPI\r | |
371 | DebugAssert (\r | |
372 | IN CONST CHAR8 *FileName,\r | |
373 | IN UINTN LineNumber,\r | |
374 | IN CONST CHAR8 *Description\r | |
375 | )\r | |
376 | {\r | |
377 | UINT64 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE / sizeof(UINT64)];\r | |
378 | EFI_DEBUG_ASSERT_DATA *AssertData;\r | |
ea1b39e6 | 379 | UINTN HeaderSize;\r |
2287f237 | 380 | UINTN TotalSize;\r |
381 | CHAR8 *Temp;\r | |
1ffe7cc5 | 382 | UINTN ModuleNameSize;\r |
9ba6cd30 | 383 | UINTN FileNameSize;\r |
384 | UINTN DescriptionSize;\r | |
2287f237 | 385 | \r |
386 | //\r | |
ea1b39e6 | 387 | // Get string size\r |
2287f237 | 388 | //\r |
ea1b39e6 | 389 | HeaderSize = sizeof (EFI_DEBUG_ASSERT_DATA);\r |
1ffe7cc5 BA |
390 | //\r |
391 | // Compute string size of module name enclosed by []\r | |
392 | //\r | |
393 | ModuleNameSize = 2 + AsciiStrSize (gEfiCallerBaseName);\r | |
ea1b39e6 LG |
394 | FileNameSize = AsciiStrSize (FileName);\r |
395 | DescriptionSize = AsciiStrSize (Description);\r | |
2287f237 | 396 | \r |
ea1b39e6 LG |
397 | //\r |
398 | // Make sure it will all fit in the passed in buffer.\r | |
399 | //\r | |
1ffe7cc5 | 400 | if (HeaderSize + ModuleNameSize + FileNameSize + DescriptionSize > sizeof (Buffer)) {\r |
2287f237 | 401 | //\r |
1ffe7cc5 | 402 | // remove module name if it's too long to be filled into buffer\r |
2287f237 | 403 | //\r |
1ffe7cc5 BA |
404 | ModuleNameSize = 0;\r |
405 | if (HeaderSize + FileNameSize + DescriptionSize > sizeof (Buffer)) {\r | |
ea1b39e6 | 406 | //\r |
1ffe7cc5 | 407 | // FileName + Description is too long to be filled into buffer.\r |
ea1b39e6 | 408 | //\r |
1ffe7cc5 BA |
409 | if (HeaderSize + FileNameSize < sizeof (Buffer)) {\r |
410 | //\r | |
411 | // Description has enough buffer to be truncated.\r | |
412 | //\r | |
413 | DescriptionSize = sizeof (Buffer) - HeaderSize - FileNameSize;\r | |
414 | } else {\r | |
415 | //\r | |
416 | // FileName is too long to be filled into buffer.\r | |
417 | // FileName will be truncated. Reserved one byte for Description NULL terminator.\r | |
418 | //\r | |
419 | DescriptionSize = 1;\r | |
420 | FileNameSize = sizeof (Buffer) - HeaderSize - DescriptionSize;\r | |
421 | }\r | |
ea1b39e6 | 422 | }\r |
2287f237 | 423 | }\r |
ea1b39e6 LG |
424 | //\r |
425 | // Fill in EFI_DEBUG_ASSERT_DATA\r | |
426 | //\r | |
427 | AssertData = (EFI_DEBUG_ASSERT_DATA *)Buffer;\r | |
428 | AssertData->LineNumber = (UINT32)LineNumber;\r | |
429 | TotalSize = sizeof (EFI_DEBUG_ASSERT_DATA);\r | |
430 | \r | |
1ffe7cc5 BA |
431 | Temp = (CHAR8 *)(AssertData + 1);\r |
432 | \r | |
433 | //\r | |
434 | // Copy Ascii [ModuleName].\r | |
435 | //\r | |
436 | if (ModuleNameSize != 0) {\r | |
437 | CopyMem(Temp, "[", 1);\r | |
438 | CopyMem(Temp + 1, gEfiCallerBaseName, ModuleNameSize - 3);\r | |
439 | CopyMem(Temp + ModuleNameSize - 2, "] ", 2);\r | |
440 | }\r | |
441 | \r | |
ea1b39e6 LG |
442 | //\r |
443 | // Copy Ascii FileName including NULL terminator.\r | |
444 | //\r | |
1ffe7cc5 | 445 | Temp = CopyMem (Temp + ModuleNameSize, FileName, FileNameSize);\r |
ea1b39e6 | 446 | Temp[FileNameSize - 1] = 0;\r |
1ffe7cc5 | 447 | TotalSize += (ModuleNameSize + FileNameSize);\r |
ea1b39e6 LG |
448 | \r |
449 | //\r | |
450 | // Copy Ascii Description include NULL terminator.\r | |
451 | //\r | |
856d6438 | 452 | Temp = CopyMem (Temp + FileNameSize, Description, DescriptionSize);\r |
ea1b39e6 LG |
453 | Temp[DescriptionSize - 1] = 0;\r |
454 | TotalSize += DescriptionSize;\r | |
455 | \r | |
456 | REPORT_STATUS_CODE_EX (\r | |
457 | (EFI_ERROR_CODE | EFI_ERROR_UNRECOVERED),\r | |
458 | (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_EC_ILLEGAL_SOFTWARE_STATE),\r | |
459 | 0,\r | |
460 | NULL,\r | |
461 | NULL,\r | |
462 | AssertData,\r | |
463 | TotalSize\r | |
464 | );\r | |
2287f237 | 465 | \r |
466 | //\r | |
467 | // Generate a Breakpoint, DeadLoop, or NOP based on PCD settings\r | |
468 | //\r | |
9ba6cd30 | 469 | if ((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED) != 0) {\r |
2287f237 | 470 | CpuBreakpoint ();\r |
9ba6cd30 | 471 | } else if ((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED) != 0) {\r |
2287f237 | 472 | CpuDeadLoop ();\r |
473 | }\r | |
474 | }\r | |
475 | \r | |
476 | \r | |
477 | /**\r | |
2287f237 | 478 | Fills a target buffer with PcdDebugClearMemoryValue, and returns the target buffer.\r |
479 | \r | |
0a6f4824 | 480 | This function fills Length bytes of Buffer with the value specified by\r |
2287f237 | 481 | PcdDebugClearMemoryValue, and returns Buffer.\r |
482 | \r | |
483 | If Buffer is NULL, then ASSERT().\r | |
0a6f4824 | 484 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r |
2287f237 | 485 | \r |
9ba6cd30 | 486 | @param Buffer Pointer to the target buffer to be filled with PcdDebugClearMemoryValue.\r |
0a6f4824 | 487 | @param Length Number of bytes in Buffer to fill with zeros PcdDebugClearMemoryValue.\r |
2287f237 | 488 | \r |
9ba6cd30 | 489 | @return Buffer Pointer to the target buffer filled with PcdDebugClearMemoryValue.\r |
2287f237 | 490 | \r |
491 | **/\r | |
492 | VOID *\r | |
493 | EFIAPI\r | |
494 | DebugClearMemory (\r | |
495 | OUT VOID *Buffer,\r | |
496 | IN UINTN Length\r | |
497 | )\r | |
498 | {\r | |
2287f237 | 499 | ASSERT (Buffer != NULL);\r |
500 | \r | |
9ba6cd30 | 501 | return SetMem (Buffer, Length, PcdGet8 (PcdDebugClearMemoryValue));\r |
2287f237 | 502 | }\r |
503 | \r | |
504 | \r | |
505 | /**\r | |
2287f237 | 506 | Returns TRUE if ASSERT() macros are enabled.\r |
507 | \r | |
0a6f4824 | 508 | This function returns TRUE if the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of\r |
2287f237 | 509 | PcdDebugProperyMask is set. Otherwise FALSE is returned.\r |
510 | \r | |
511 | @retval TRUE The DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is set.\r | |
512 | @retval FALSE The DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is clear.\r | |
513 | \r | |
514 | **/\r | |
515 | BOOLEAN\r | |
516 | EFIAPI\r | |
517 | DebugAssertEnabled (\r | |
518 | VOID\r | |
519 | )\r | |
520 | {\r | |
9ba6cd30 | 521 | return (BOOLEAN) ((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED) != 0);\r |
2287f237 | 522 | }\r |
523 | \r | |
524 | \r | |
0a6f4824 | 525 | /**\r |
9ba6cd30 | 526 | Returns TRUE if DEBUG() macros are enabled.\r |
2287f237 | 527 | \r |
0a6f4824 | 528 | This function returns TRUE if the DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of\r |
2287f237 | 529 | PcdDebugProperyMask is set. Otherwise FALSE is returned.\r |
530 | \r | |
531 | @retval TRUE The DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of PcdDebugProperyMask is set.\r | |
532 | @retval FALSE The DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of PcdDebugProperyMask is clear.\r | |
533 | \r | |
534 | **/\r | |
535 | BOOLEAN\r | |
536 | EFIAPI\r | |
537 | DebugPrintEnabled (\r | |
538 | VOID\r | |
539 | )\r | |
540 | {\r | |
9ba6cd30 | 541 | return (BOOLEAN) ((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_PRINT_ENABLED) != 0);\r |
2287f237 | 542 | }\r |
543 | \r | |
544 | \r | |
0a6f4824 | 545 | /**\r |
9ba6cd30 | 546 | Returns TRUE if DEBUG_CODE() macros are enabled.\r |
2287f237 | 547 | \r |
0a6f4824 | 548 | This function returns TRUE if the DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of\r |
2287f237 | 549 | PcdDebugProperyMask is set. Otherwise FALSE is returned.\r |
550 | \r | |
551 | @retval TRUE The DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is set.\r | |
552 | @retval FALSE The DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is clear.\r | |
553 | \r | |
554 | **/\r | |
555 | BOOLEAN\r | |
556 | EFIAPI\r | |
557 | DebugCodeEnabled (\r | |
558 | VOID\r | |
559 | )\r | |
560 | {\r | |
9ba6cd30 | 561 | return (BOOLEAN) ((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_CODE_ENABLED) != 0);\r |
2287f237 | 562 | }\r |
563 | \r | |
564 | \r | |
0a6f4824 | 565 | /**\r |
9ba6cd30 | 566 | Returns TRUE if DEBUG_CLEAR_MEMORY() macro is enabled.\r |
2287f237 | 567 | \r |
0a6f4824 | 568 | This function returns TRUE if the DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED bit of\r |
2287f237 | 569 | PcdDebugProperyMask is set. Otherwise FALSE is returned.\r |
570 | \r | |
9ba6cd30 | 571 | @retval TRUE The DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED bit of PcdDebugProperyMask is set.\r |
572 | @retval FALSE The DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED bit of PcdDebugProperyMask is clear.\r | |
2287f237 | 573 | \r |
574 | **/\r | |
575 | BOOLEAN\r | |
576 | EFIAPI\r | |
577 | DebugClearMemoryEnabled (\r | |
578 | VOID\r | |
579 | )\r | |
580 | {\r | |
9ba6cd30 | 581 | return (BOOLEAN) ((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED) != 0);\r |
2287f237 | 582 | }\r |
30aba8d3 LG |
583 | \r |
584 | /**\r | |
585 | Returns TRUE if any one of the bit is set both in ErrorLevel and PcdFixedDebugPrintErrorLevel.\r | |
586 | \r | |
587 | This function compares the bit mask of ErrorLevel and PcdFixedDebugPrintErrorLevel.\r | |
588 | \r | |
589 | @retval TRUE Current ErrorLevel is supported.\r | |
590 | @retval FALSE Current ErrorLevel is not supported.\r | |
591 | \r | |
592 | **/\r | |
593 | BOOLEAN\r | |
594 | EFIAPI\r | |
595 | DebugPrintLevelEnabled (\r | |
596 | IN CONST UINTN ErrorLevel\r | |
597 | )\r | |
598 | {\r | |
599 | return (BOOLEAN) ((ErrorLevel & PcdGet32(PcdFixedDebugPrintErrorLevel)) != 0);\r | |
600 | }\r |