]>
Commit | Line | Data |
---|---|---|
fb3df220 | 1 | /** @file\r |
50a64e5b | 2 | Provides services to print debug and assert messages to a debug output device.\r |
d80b2f71 | 3 | \r |
4 | The Debug library supports debug print and asserts based on a combination of macros and code.\r | |
5 | The debug library can be turned on and off so that the debug code does not increase the size of an image.\r | |
c9ec7047 | 6 | \r |
5ee9264a | 7 | Note that a reserved macro named MDEPKG_NDEBUG is introduced for the intention\r |
8 | of size reduction when compiler optimization is disabled. If MDEPKG_NDEBUG is\r | |
9 | defined, then debug and assert related macros wrapped by it are the NULL implementations.\r | |
c9ec7047 | 10 | \r |
6859cc8b | 11 | Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r |
af2dc6a7 | 12 | This program and the accompanying materials are licensed and made available under \r |
13 | the terms and conditions of the BSD License that accompanies this distribution. \r | |
14 | The full text of the license may be found at\r | |
15 | http://opensource.org/licenses/bsd-license.php.\r | |
fb3df220 | 16 | \r |
50a64e5b | 17 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r |
18 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
fb3df220 | 19 | \r |
20 | **/\r | |
21 | \r | |
22 | #ifndef __DEBUG_LIB_H__\r | |
23 | #define __DEBUG_LIB_H__\r | |
24 | \r | |
25 | //\r | |
26 | // Declare bits for PcdDebugPropertyMask\r | |
27 | //\r | |
28 | #define DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED 0x01\r | |
29 | #define DEBUG_PROPERTY_DEBUG_PRINT_ENABLED 0x02\r | |
30 | #define DEBUG_PROPERTY_DEBUG_CODE_ENABLED 0x04\r | |
31 | #define DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED 0x08\r | |
32 | #define DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED 0x10\r | |
33 | #define DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED 0x20\r | |
34 | \r | |
35 | //\r | |
36 | // Declare bits for PcdDebugPrintErrorLevel and the ErrorLevel parameter of DebugPrint()\r | |
37 | //\r | |
38 | #define DEBUG_INIT 0x00000001 // Initialization\r | |
39 | #define DEBUG_WARN 0x00000002 // Warnings\r | |
40 | #define DEBUG_LOAD 0x00000004 // Load events\r | |
41 | #define DEBUG_FS 0x00000008 // EFI File system\r | |
34c1508f LE |
42 | #define DEBUG_POOL 0x00000010 // Alloc & Free (pool)\r |
43 | #define DEBUG_PAGE 0x00000020 // Alloc & Free (page)\r | |
9a8e70ce | 44 | #define DEBUG_INFO 0x00000040 // Informational debug messages\r |
3ae55b76 | 45 | #define DEBUG_DISPATCH 0x00000080 // PEI/DXE/SMM Dispatchers\r |
fb3df220 | 46 | #define DEBUG_VARIABLE 0x00000100 // Variable\r |
47 | #define DEBUG_BM 0x00000400 // Boot Manager\r | |
48 | #define DEBUG_BLKIO 0x00001000 // BlkIo Driver\r | |
6859cc8b | 49 | #define DEBUG_NET 0x00004000 // Network Io Driver\r |
fb3df220 | 50 | #define DEBUG_UNDI 0x00010000 // UNDI Driver\r |
48d97c8b | 51 | #define DEBUG_LOADFILE 0x00020000 // LoadFile\r |
fb3df220 | 52 | #define DEBUG_EVENT 0x00080000 // Event messages\r |
5a2e7dd2 | 53 | #define DEBUG_GCD 0x00100000 // Global Coherency Database changes\r |
54 | #define DEBUG_CACHE 0x00200000 // Memory range cachability changes\r | |
34c1508f LE |
55 | #define DEBUG_VERBOSE 0x00400000 // Detailed debug messages that may\r |
56 | // significantly impact boot performance\r | |
fb3df220 | 57 | #define DEBUG_ERROR 0x80000000 // Error\r |
58 | \r | |
59 | //\r | |
60 | // Aliases of debug message mask bits\r | |
61 | //\r | |
62 | #define EFI_D_INIT DEBUG_INIT\r | |
63 | #define EFI_D_WARN DEBUG_WARN\r | |
64 | #define EFI_D_LOAD DEBUG_LOAD\r | |
65 | #define EFI_D_FS DEBUG_FS\r | |
66 | #define EFI_D_POOL DEBUG_POOL\r | |
67 | #define EFI_D_PAGE DEBUG_PAGE\r | |
68 | #define EFI_D_INFO DEBUG_INFO\r | |
c759eb45 | 69 | #define EFI_D_DISPATCH DEBUG_DISPATCH\r |
fb3df220 | 70 | #define EFI_D_VARIABLE DEBUG_VARIABLE\r |
71 | #define EFI_D_BM DEBUG_BM\r | |
72 | #define EFI_D_BLKIO DEBUG_BLKIO\r | |
73 | #define EFI_D_NET DEBUG_NET\r | |
74 | #define EFI_D_UNDI DEBUG_UNDI\r | |
75 | #define EFI_D_LOADFILE DEBUG_LOADFILE\r | |
76 | #define EFI_D_EVENT DEBUG_EVENT\r | |
9a8e70ce | 77 | #define EFI_D_VERBOSE DEBUG_VERBOSE\r |
fb3df220 | 78 | #define EFI_D_ERROR DEBUG_ERROR\r |
79 | \r | |
80 | /**\r | |
fb3df220 | 81 | Prints a debug message to the debug output device if the specified error level is enabled.\r |
82 | \r | |
2891fc8b | 83 | If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function \r |
84 | GetDebugPrintErrorLevel (), then print the message specified by Format and the \r | |
85 | associated variable argument list to the debug output device.\r | |
fb3df220 | 86 | \r |
87 | If Format is NULL, then ASSERT().\r | |
88 | \r | |
89 | @param ErrorLevel The error level of the debug message.\r | |
af2dc6a7 | 90 | @param Format The format string for the debug message to print.\r |
91 | @param ... The variable argument list whose contents are accessed \r | |
285010e7 | 92 | based on the format string specified by Format.\r |
fb3df220 | 93 | \r |
94 | **/\r | |
95 | VOID\r | |
96 | EFIAPI\r | |
97 | DebugPrint (\r | |
98 | IN UINTN ErrorLevel,\r | |
99 | IN CONST CHAR8 *Format,\r | |
100 | ...\r | |
101 | );\r | |
102 | \r | |
103 | \r | |
104 | /**\r | |
fb3df220 | 105 | Prints an assert message containing a filename, line number, and description. \r |
106 | This may be followed by a breakpoint or a dead loop.\r | |
107 | \r | |
108 | Print a message of the form "ASSERT <FileName>(<LineNumber>): <Description>\n"\r | |
109 | to the debug output device. If DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED bit of \r | |
110 | PcdDebugProperyMask is set then CpuBreakpoint() is called. Otherwise, if \r | |
111 | DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED bit of PcdDebugProperyMask is set then \r | |
112 | CpuDeadLoop() is called. If neither of these bits are set, then this function \r | |
113 | returns immediately after the message is printed to the debug output device.\r | |
584125bc | 114 | DebugAssert() must actively prevent recursion. If DebugAssert() is called while\r |
fb3df220 | 115 | processing another DebugAssert(), then DebugAssert() must return immediately.\r |
116 | \r | |
584125bc | 117 | If FileName is NULL, then a <FileName> string of "(NULL) Filename" is printed.\r |
584125bc | 118 | If Description is NULL, then a <Description> string of "(NULL) Description" is printed.\r |
fb3df220 | 119 | \r |
af2dc6a7 | 120 | @param FileName The pointer to the name of the source file that generated the assert condition.\r |
fb3df220 | 121 | @param LineNumber The line number in the source file that generated the assert condition\r |
af2dc6a7 | 122 | @param Description The pointer to the description of the assert condition.\r |
fb3df220 | 123 | \r |
124 | **/\r | |
125 | VOID\r | |
126 | EFIAPI\r | |
127 | DebugAssert (\r | |
128 | IN CONST CHAR8 *FileName,\r | |
129 | IN UINTN LineNumber,\r | |
130 | IN CONST CHAR8 *Description\r | |
131 | );\r | |
132 | \r | |
133 | \r | |
134 | /**\r | |
fb3df220 | 135 | Fills a target buffer with PcdDebugClearMemoryValue, and returns the target buffer.\r |
136 | \r | |
137 | This function fills Length bytes of Buffer with the value specified by \r | |
138 | PcdDebugClearMemoryValue, and returns Buffer.\r | |
139 | \r | |
140 | If Buffer is NULL, then ASSERT().\r | |
2281e7a9 | 141 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). \r |
fb3df220 | 142 | \r |
af2dc6a7 | 143 | @param Buffer The pointer to the target buffer to be filled with PcdDebugClearMemoryValue.\r |
144 | @param Length The number of bytes in Buffer to fill with zeros PcdDebugClearMemoryValue. \r | |
fb3df220 | 145 | \r |
af2dc6a7 | 146 | @return Buffer The pointer to the target buffer filled with PcdDebugClearMemoryValue.\r |
fb3df220 | 147 | \r |
148 | **/\r | |
149 | VOID *\r | |
150 | EFIAPI\r | |
151 | DebugClearMemory (\r | |
152 | OUT VOID *Buffer,\r | |
153 | IN UINTN Length\r | |
154 | );\r | |
155 | \r | |
156 | \r | |
157 | /**\r | |
fb3df220 | 158 | Returns TRUE if ASSERT() macros are enabled.\r |
159 | \r | |
160 | This function returns TRUE if the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of \r | |
af2dc6a7 | 161 | PcdDebugProperyMask is set. Otherwise, FALSE is returned.\r |
fb3df220 | 162 | \r |
163 | @retval TRUE The DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is set.\r | |
164 | @retval FALSE The DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is clear.\r | |
165 | \r | |
166 | **/\r | |
167 | BOOLEAN\r | |
168 | EFIAPI\r | |
169 | DebugAssertEnabled (\r | |
170 | VOID\r | |
171 | );\r | |
172 | \r | |
173 | \r | |
3e5c3238 | 174 | /** \r |
175 | Returns TRUE if DEBUG() macros are enabled.\r | |
fb3df220 | 176 | \r |
177 | This function returns TRUE if the DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of \r | |
af2dc6a7 | 178 | PcdDebugProperyMask is set. Otherwise, FALSE is returned.\r |
fb3df220 | 179 | \r |
180 | @retval TRUE The DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of PcdDebugProperyMask is set.\r | |
181 | @retval FALSE The DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of PcdDebugProperyMask is clear.\r | |
182 | \r | |
183 | **/\r | |
184 | BOOLEAN\r | |
185 | EFIAPI\r | |
186 | DebugPrintEnabled (\r | |
187 | VOID\r | |
188 | );\r | |
189 | \r | |
190 | \r | |
3e5c3238 | 191 | /** \r |
192 | Returns TRUE if DEBUG_CODE() macros are enabled.\r | |
fb3df220 | 193 | \r |
194 | This function returns TRUE if the DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of \r | |
af2dc6a7 | 195 | PcdDebugProperyMask is set. Otherwise, FALSE is returned.\r |
fb3df220 | 196 | \r |
197 | @retval TRUE The DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is set.\r | |
198 | @retval FALSE The DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is clear.\r | |
199 | \r | |
200 | **/\r | |
201 | BOOLEAN\r | |
202 | EFIAPI\r | |
203 | DebugCodeEnabled (\r | |
204 | VOID\r | |
205 | );\r | |
206 | \r | |
207 | \r | |
3e5c3238 | 208 | /** \r |
209 | Returns TRUE if DEBUG_CLEAR_MEMORY() macro is enabled.\r | |
fb3df220 | 210 | \r |
eceb3a4c | 211 | This function returns TRUE if the DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED bit of \r |
af2dc6a7 | 212 | PcdDebugProperyMask is set. Otherwise, FALSE is returned.\r |
fb3df220 | 213 | \r |
eceb3a4c LG |
214 | @retval TRUE The DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED bit of PcdDebugProperyMask is set.\r |
215 | @retval FALSE The DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED bit of PcdDebugProperyMask is clear.\r | |
fb3df220 | 216 | \r |
217 | **/\r | |
218 | BOOLEAN\r | |
219 | EFIAPI\r | |
220 | DebugClearMemoryEnabled (\r | |
221 | VOID\r | |
222 | );\r | |
223 | \r | |
5ea9d0c3 LG |
224 | /**\r |
225 | Returns TRUE if any one of the bit is set both in ErrorLevel and PcdFixedDebugPrintErrorLevel.\r | |
226 | \r | |
227 | This function compares the bit mask of ErrorLevel and PcdFixedDebugPrintErrorLevel.\r | |
228 | \r | |
229 | @retval TRUE Current ErrorLevel is supported.\r | |
230 | @retval FALSE Current ErrorLevel is not supported.\r | |
231 | \r | |
232 | **/\r | |
233 | BOOLEAN\r | |
234 | EFIAPI\r | |
235 | DebugPrintLevelEnabled (\r | |
236 | IN CONST UINTN ErrorLevel\r | |
237 | );\r | |
fb3df220 | 238 | \r |
3e5c3238 | 239 | /** \r |
fb3df220 | 240 | Internal worker macro that calls DebugAssert().\r |
241 | \r | |
1a2f870c | 242 | This macro calls DebugAssert(), passing in the filename, line number, and an\r |
243 | expression that evaluated to FALSE.\r | |
fb3df220 | 244 | \r |
1a2f870c | 245 | @param Expression Boolean expression that evaluated to FALSE\r |
fb3df220 | 246 | \r |
247 | **/\r | |
248 | #define _ASSERT(Expression) DebugAssert (__FILE__, __LINE__, #Expression)\r | |
249 | \r | |
250 | \r | |
3e5c3238 | 251 | /** \r |
fb3df220 | 252 | Internal worker macro that calls DebugPrint().\r |
253 | \r | |
254 | This macro calls DebugPrint() passing in the debug error level, a format \r | |
255 | string, and a variable argument list.\r | |
79142ebf | 256 | __VA_ARGS__ is not supported by EBC compiler, Microsoft Visual Studio .NET 2003\r |
6e6f5e03 | 257 | and Microsoft Windows Server 2003 Driver Development Kit (Microsoft WINDDK) version 3790.1830.\r |
fb3df220 | 258 | \r |
259 | @param Expression Expression containing an error level, a format string, \r | |
260 | and a variable argument list based on the format string.\r | |
261 | \r | |
262 | **/\r | |
fb3df220 | 263 | \r |
d9a55c78 | 264 | #if !defined(MDE_CPU_EBC) && (!defined (_MSC_VER) || _MSC_VER > 1400)\r |
5ea9d0c3 LG |
265 | #define _DEBUG_PRINT(PrintLevel, ...) \\r |
266 | do { \\r | |
267 | if (DebugPrintLevelEnabled (PrintLevel)) { \\r | |
268 | DebugPrint (PrintLevel, ##__VA_ARGS__); \\r | |
269 | } \\r | |
270 | } while (FALSE)\r | |
271 | #define _DEBUG(Expression) _DEBUG_PRINT Expression\r | |
272 | #else\r | |
273 | #define _DEBUG(Expression) DebugPrint Expression\r | |
274 | #endif\r | |
fb3df220 | 275 | \r |
3e5c3238 | 276 | /** \r |
1a2f870c | 277 | Macro that calls DebugAssert() if an expression evaluates to FALSE.\r |
fb3df220 | 278 | \r |
c9ec7047 | 279 | If MDEPKG_NDEBUG is not defined and the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED \r |
280 | bit of PcdDebugProperyMask is set, then this macro evaluates the Boolean \r | |
281 | expression specified by Expression. If Expression evaluates to FALSE, then \r | |
282 | DebugAssert() is called passing in the source filename, source line number, \r | |
283 | and Expression.\r | |
fb3df220 | 284 | \r |
af2dc6a7 | 285 | @param Expression Boolean expression.\r |
fb3df220 | 286 | \r |
287 | **/\r | |
c9ec7047 | 288 | #if !defined(MDEPKG_NDEBUG) \r |
289 | #define ASSERT(Expression) \\r | |
290 | do { \\r | |
291 | if (DebugAssertEnabled ()) { \\r | |
292 | if (!(Expression)) { \\r | |
293 | _ASSERT (Expression); \\r | |
90eda6fc | 294 | ANALYZER_UNREACHABLE (); \\r |
c9ec7047 | 295 | } \\r |
296 | } \\r | |
297 | } while (FALSE)\r | |
298 | #else\r | |
299 | #define ASSERT(Expression)\r | |
300 | #endif\r | |
fb3df220 | 301 | \r |
3e5c3238 | 302 | /** \r |
fb3df220 | 303 | Macro that calls DebugPrint().\r |
304 | \r | |
c9ec7047 | 305 | If MDEPKG_NDEBUG is not defined and the DEBUG_PROPERTY_DEBUG_PRINT_ENABLED \r |
306 | bit of PcdDebugProperyMask is set, then this macro passes Expression to \r | |
307 | DebugPrint().\r | |
fb3df220 | 308 | \r |
309 | @param Expression Expression containing an error level, a format string, \r | |
310 | and a variable argument list based on the format string.\r | |
311 | \r | |
312 | \r | |
313 | **/\r | |
c9ec7047 | 314 | #if !defined(MDEPKG_NDEBUG) \r |
315 | #define DEBUG(Expression) \\r | |
316 | do { \\r | |
317 | if (DebugPrintEnabled ()) { \\r | |
318 | _DEBUG (Expression); \\r | |
319 | } \\r | |
320 | } while (FALSE)\r | |
321 | #else\r | |
322 | #define DEBUG(Expression)\r | |
323 | #endif\r | |
fb3df220 | 324 | \r |
3e5c3238 | 325 | /** \r |
fb3df220 | 326 | Macro that calls DebugAssert() if an EFI_STATUS evaluates to an error code.\r |
327 | \r | |
c9ec7047 | 328 | If MDEPKG_NDEBUG is not defined and the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED \r |
329 | bit of PcdDebugProperyMask is set, then this macro evaluates the EFI_STATUS \r | |
330 | value specified by StatusParameter. If StatusParameter is an error code, \r | |
331 | then DebugAssert() is called passing in the source filename, source line \r | |
332 | number, and StatusParameter.\r | |
fb3df220 | 333 | \r |
334 | @param StatusParameter EFI_STATUS value to evaluate.\r | |
335 | \r | |
336 | **/\r | |
c9ec7047 | 337 | #if !defined(MDEPKG_NDEBUG)\r |
338 | #define ASSERT_EFI_ERROR(StatusParameter) \\r | |
339 | do { \\r | |
340 | if (DebugAssertEnabled ()) { \\r | |
341 | if (EFI_ERROR (StatusParameter)) { \\r | |
342 | DEBUG ((EFI_D_ERROR, "\nASSERT_EFI_ERROR (Status = %r)\n", StatusParameter)); \\r | |
343 | _ASSERT (!EFI_ERROR (StatusParameter)); \\r | |
344 | } \\r | |
345 | } \\r | |
346 | } while (FALSE)\r | |
347 | #else\r | |
348 | #define ASSERT_EFI_ERROR(StatusParameter)\r | |
349 | #endif\r | |
fb3df220 | 350 | \r |
08bcaf20 LE |
351 | /**\r |
352 | Macro that calls DebugAssert() if a RETURN_STATUS evaluates to an error code.\r | |
353 | \r | |
354 | If MDEPKG_NDEBUG is not defined and the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED\r | |
355 | bit of PcdDebugProperyMask is set, then this macro evaluates the\r | |
356 | RETURN_STATUS value specified by StatusParameter. If StatusParameter is an\r | |
357 | error code, then DebugAssert() is called passing in the source filename,\r | |
358 | source line number, and StatusParameter.\r | |
359 | \r | |
360 | @param StatusParameter RETURN_STATUS value to evaluate.\r | |
361 | \r | |
362 | **/\r | |
363 | #if !defined(MDEPKG_NDEBUG)\r | |
364 | #define ASSERT_RETURN_ERROR(StatusParameter) \\r | |
365 | do { \\r | |
366 | if (DebugAssertEnabled ()) { \\r | |
367 | if (RETURN_ERROR (StatusParameter)) { \\r | |
368 | DEBUG ((DEBUG_ERROR, "\nASSERT_RETURN_ERROR (Status = %r)\n", \\r | |
369 | StatusParameter)); \\r | |
370 | _ASSERT (!RETURN_ERROR (StatusParameter)); \\r | |
371 | } \\r | |
372 | } \\r | |
373 | } while (FALSE)\r | |
374 | #else\r | |
375 | #define ASSERT_RETURN_ERROR(StatusParameter)\r | |
376 | #endif\r | |
377 | \r | |
3e5c3238 | 378 | /** \r |
fb3df220 | 379 | Macro that calls DebugAssert() if a protocol is already installed in the \r |
380 | handle database.\r | |
381 | \r | |
c9ec7047 | 382 | If MDEPKG_NDEBUG is defined or the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit \r |
383 | of PcdDebugProperyMask is clear, then return.\r | |
fb3df220 | 384 | \r |
385 | If Handle is NULL, then a check is made to see if the protocol specified by Guid \r | |
386 | is present on any handle in the handle database. If Handle is not NULL, then \r | |
387 | a check is made to see if the protocol specified by Guid is present on the \r | |
388 | handle specified by Handle. If the check finds the protocol, then DebugAssert() \r | |
389 | is called passing in the source filename, source line number, and Guid.\r | |
390 | \r | |
391 | If Guid is NULL, then ASSERT().\r | |
392 | \r | |
393 | @param Handle The handle to check for the protocol. This is an optional \r | |
394 | parameter that may be NULL. If it is NULL, then the entire \r | |
395 | handle database is searched.\r | |
396 | \r | |
af2dc6a7 | 397 | @param Guid The pointer to a protocol GUID.\r |
fb3df220 | 398 | \r |
399 | **/\r | |
c9ec7047 | 400 | #if !defined(MDEPKG_NDEBUG)\r |
401 | #define ASSERT_PROTOCOL_ALREADY_INSTALLED(Handle, Guid) \\r | |
402 | do { \\r | |
403 | if (DebugAssertEnabled ()) { \\r | |
404 | VOID *Instance; \\r | |
405 | ASSERT (Guid != NULL); \\r | |
406 | if (Handle == NULL) { \\r | |
407 | if (!EFI_ERROR (gBS->LocateProtocol ((EFI_GUID *)Guid, NULL, &Instance))) { \\r | |
408 | _ASSERT (Guid already installed in database); \\r | |
409 | } \\r | |
410 | } else { \\r | |
411 | if (!EFI_ERROR (gBS->HandleProtocol (Handle, (EFI_GUID *)Guid, &Instance))) { \\r | |
412 | _ASSERT (Guid already installed on Handle); \\r | |
413 | } \\r | |
414 | } \\r | |
415 | } \\r | |
416 | } while (FALSE)\r | |
417 | #else\r | |
418 | #define ASSERT_PROTOCOL_ALREADY_INSTALLED(Handle, Guid)\r | |
419 | #endif\r | |
fb3df220 | 420 | \r |
421 | /**\r | |
422 | Macro that marks the beginning of debug source code.\r | |
423 | \r | |
424 | If the DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is set, \r | |
425 | then this macro marks the beginning of source code that is included in a module.\r | |
426 | Otherwise, the source lines between DEBUG_CODE_BEGIN() and DEBUG_CODE_END() \r | |
427 | are not included in a module.\r | |
428 | \r | |
429 | **/\r | |
430 | #define DEBUG_CODE_BEGIN() do { if (DebugCodeEnabled ()) { UINT8 __DebugCodeLocal\r | |
431 | \r | |
432 | \r | |
3e5c3238 | 433 | /** \r |
af2dc6a7 | 434 | The macro that marks the end of debug source code.\r |
fb3df220 | 435 | \r |
436 | If the DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is set, \r | |
437 | then this macro marks the end of source code that is included in a module. \r | |
438 | Otherwise, the source lines between DEBUG_CODE_BEGIN() and DEBUG_CODE_END() \r | |
439 | are not included in a module.\r | |
440 | \r | |
441 | **/\r | |
442 | #define DEBUG_CODE_END() __DebugCodeLocal = 0; __DebugCodeLocal++; } } while (FALSE)\r | |
443 | \r | |
444 | \r | |
3e5c3238 | 445 | /** \r |
af2dc6a7 | 446 | The macro that declares a section of debug source code.\r |
fb3df220 | 447 | \r |
448 | If the DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is set, \r | |
449 | then the source code specified by Expression is included in a module. \r | |
450 | Otherwise, the source specified by Expression is not included in a module.\r | |
451 | \r | |
452 | **/\r | |
453 | #define DEBUG_CODE(Expression) \\r | |
454 | DEBUG_CODE_BEGIN (); \\r | |
455 | Expression \\r | |
456 | DEBUG_CODE_END ()\r | |
457 | \r | |
458 | \r | |
3e5c3238 | 459 | /** \r |
af2dc6a7 | 460 | The macro that calls DebugClearMemory() to clear a buffer to a default value.\r |
fb3df220 | 461 | \r |
462 | If the DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED bit of PcdDebugProperyMask is set, \r | |
463 | then this macro calls DebugClearMemory() passing in Address and Length.\r | |
464 | \r | |
af2dc6a7 | 465 | @param Address The pointer to a buffer.\r |
fb3df220 | 466 | @param Length The number of bytes in the buffer to set.\r |
467 | \r | |
468 | **/\r | |
469 | #define DEBUG_CLEAR_MEMORY(Address, Length) \\r | |
470 | do { \\r | |
471 | if (DebugClearMemoryEnabled ()) { \\r | |
472 | DebugClearMemory (Address, Length); \\r | |
473 | } \\r | |
474 | } while (FALSE)\r | |
475 | \r | |
476 | \r | |
477 | /**\r | |
fb3df220 | 478 | Macro that calls DebugAssert() if the containing record does not have a \r |
479 | matching signature. If the signatures matches, then a pointer to the data \r | |
480 | structure that contains a specified field of that data structure is returned. \r | |
af2dc6a7 | 481 | This is a lightweight method hide information by placing a public data \r |
fb3df220 | 482 | structure inside a larger private data structure and using a pointer to the \r |
483 | public data structure to retrieve a pointer to the private data structure.\r | |
484 | \r | |
c9ec7047 | 485 | If MDEPKG_NDEBUG is defined or the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit \r |
486 | of PcdDebugProperyMask is clear, then this macro computes the offset, in bytes,\r | |
af2dc6a7 | 487 | of the field specified by Field from the beginning of the data structure specified \r |
c9ec7047 | 488 | by TYPE. This offset is subtracted from Record, and is used to return a pointer \r |
489 | to a data structure of the type specified by TYPE.\r | |
490 | \r | |
491 | If MDEPKG_NDEBUG is not defined and the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit\r | |
492 | of PcdDebugProperyMask is set, then this macro computes the offset, in bytes, \r | |
493 | of field specified by Field from the beginning of the data structure specified \r | |
494 | by TYPE. This offset is subtracted from Record, and is used to compute a pointer\r | |
495 | to a data structure of the type specified by TYPE. The Signature field of the \r | |
496 | data structure specified by TYPE is compared to TestSignature. If the signatures \r | |
497 | match, then a pointer to the pointer to a data structure of the type specified by \r | |
498 | TYPE is returned. If the signatures do not match, then DebugAssert() is called \r | |
499 | with a description of "CR has a bad signature" and Record is returned. \r | |
fb3df220 | 500 | \r |
501 | If the data type specified by TYPE does not contain the field specified by Field, \r | |
502 | then the module will not compile.\r | |
503 | \r | |
504 | If TYPE does not contain a field called Signature, then the module will not \r | |
505 | compile.\r | |
506 | \r | |
af2dc6a7 | 507 | @param Record The pointer to the field specified by Field within a data \r |
fb3df220 | 508 | structure of type TYPE.\r |
509 | \r | |
510 | @param TYPE The name of the data structure type to return This \r | |
511 | data structure must contain the field specified by Field. \r | |
512 | \r | |
513 | @param Field The name of the field in the data structure specified \r | |
514 | by TYPE to which Record points.\r | |
515 | \r | |
516 | @param TestSignature The 32-bit signature value to match.\r | |
517 | \r | |
518 | **/\r | |
c9ec7047 | 519 | #if !defined(MDEPKG_NDEBUG)\r |
520 | #define CR(Record, TYPE, Field, TestSignature) \\r | |
521 | (DebugAssertEnabled () && (BASE_CR (Record, TYPE, Field)->Signature != TestSignature)) ? \\r | |
522 | (TYPE *) (_ASSERT (CR has Bad Signature), Record) : \\r | |
523 | BASE_CR (Record, TYPE, Field)\r | |
524 | #else\r | |
525 | #define CR(Record, TYPE, Field, TestSignature) \\r | |
526 | BASE_CR (Record, TYPE, Field)\r | |
527 | #endif\r | |
fb3df220 | 528 | \r |
529 | #endif\r |