]>
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 |
5ee9264a | 11 | Copyright (c) 2006 - 2010, Intel Corporation<BR>\r |
50a64e5b | 12 | All rights reserved. This program and the accompanying materials\r |
13 | are licensed and made available under the terms and conditions of the BSD License\r | |
14 | which accompanies this distribution. 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 | |
42 | #define DEBUG_POOL 0x00000010 // Alloc & Free's\r | |
43 | #define DEBUG_PAGE 0x00000020 // Alloc & Free's\r | |
44 | #define DEBUG_INFO 0x00000040 // Verbose\r | |
c759eb45 | 45 | #define DEBUG_DISPATCH 0x00000080 // PEI/DXE 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 | |
49 | #define DEBUG_NET 0x00004000 // SNI Driver\r | |
50 | #define DEBUG_UNDI 0x00010000 // UNDI Driver\r | |
51 | #define DEBUG_LOADFILE 0x00020000 // UNDI Driver\r | |
52 | #define DEBUG_EVENT 0x00080000 // Event messages\r | |
53 | #define DEBUG_ERROR 0x80000000 // Error\r | |
54 | \r | |
55 | //\r | |
56 | // Aliases of debug message mask bits\r | |
57 | //\r | |
58 | #define EFI_D_INIT DEBUG_INIT\r | |
59 | #define EFI_D_WARN DEBUG_WARN\r | |
60 | #define EFI_D_LOAD DEBUG_LOAD\r | |
61 | #define EFI_D_FS DEBUG_FS\r | |
62 | #define EFI_D_POOL DEBUG_POOL\r | |
63 | #define EFI_D_PAGE DEBUG_PAGE\r | |
64 | #define EFI_D_INFO DEBUG_INFO\r | |
c759eb45 | 65 | #define EFI_D_DISPATCH DEBUG_DISPATCH\r |
fb3df220 | 66 | #define EFI_D_VARIABLE DEBUG_VARIABLE\r |
67 | #define EFI_D_BM DEBUG_BM\r | |
68 | #define EFI_D_BLKIO DEBUG_BLKIO\r | |
69 | #define EFI_D_NET DEBUG_NET\r | |
70 | #define EFI_D_UNDI DEBUG_UNDI\r | |
71 | #define EFI_D_LOADFILE DEBUG_LOADFILE\r | |
72 | #define EFI_D_EVENT DEBUG_EVENT\r | |
73 | #define EFI_D_ERROR DEBUG_ERROR\r | |
74 | \r | |
75 | /**\r | |
fb3df220 | 76 | Prints a debug message to the debug output device if the specified error level is enabled.\r |
77 | \r | |
78 | If any bit in ErrorLevel is also set in PcdDebugPrintErrorLevel, then print \r | |
79 | the message specified by Format and the associated variable argument list to \r | |
80 | the debug output device.\r | |
81 | \r | |
82 | If Format is NULL, then ASSERT().\r | |
83 | \r | |
84 | @param ErrorLevel The error level of the debug message.\r | |
85 | @param Format Format string for the debug message to print.\r | |
285010e7 | 86 | @param ... Variable argument list whose contents are accessed \r |
87 | based on the format string specified by Format.\r | |
fb3df220 | 88 | \r |
89 | **/\r | |
90 | VOID\r | |
91 | EFIAPI\r | |
92 | DebugPrint (\r | |
93 | IN UINTN ErrorLevel,\r | |
94 | IN CONST CHAR8 *Format,\r | |
95 | ...\r | |
96 | );\r | |
97 | \r | |
98 | \r | |
99 | /**\r | |
fb3df220 | 100 | Prints an assert message containing a filename, line number, and description. \r |
101 | This may be followed by a breakpoint or a dead loop.\r | |
102 | \r | |
103 | Print a message of the form "ASSERT <FileName>(<LineNumber>): <Description>\n"\r | |
104 | to the debug output device. If DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED bit of \r | |
105 | PcdDebugProperyMask is set then CpuBreakpoint() is called. Otherwise, if \r | |
106 | DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED bit of PcdDebugProperyMask is set then \r | |
107 | CpuDeadLoop() is called. If neither of these bits are set, then this function \r | |
108 | returns immediately after the message is printed to the debug output device.\r | |
584125bc | 109 | DebugAssert() must actively prevent recursion. If DebugAssert() is called while\r |
fb3df220 | 110 | processing another DebugAssert(), then DebugAssert() must return immediately.\r |
111 | \r | |
584125bc | 112 | If FileName is NULL, then a <FileName> string of "(NULL) Filename" is printed.\r |
584125bc | 113 | If Description is NULL, then a <Description> string of "(NULL) Description" is printed.\r |
fb3df220 | 114 | \r |
115 | @param FileName Pointer to the name of the source file that generated the assert condition.\r | |
116 | @param LineNumber The line number in the source file that generated the assert condition\r | |
117 | @param Description Pointer to the description of the assert condition.\r | |
118 | \r | |
119 | **/\r | |
120 | VOID\r | |
121 | EFIAPI\r | |
122 | DebugAssert (\r | |
123 | IN CONST CHAR8 *FileName,\r | |
124 | IN UINTN LineNumber,\r | |
125 | IN CONST CHAR8 *Description\r | |
126 | );\r | |
127 | \r | |
128 | \r | |
129 | /**\r | |
fb3df220 | 130 | Fills a target buffer with PcdDebugClearMemoryValue, and returns the target buffer.\r |
131 | \r | |
132 | This function fills Length bytes of Buffer with the value specified by \r | |
133 | PcdDebugClearMemoryValue, and returns Buffer.\r | |
134 | \r | |
135 | If Buffer is NULL, then ASSERT().\r | |
2281e7a9 | 136 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). \r |
fb3df220 | 137 | \r |
eceb3a4c | 138 | @param Buffer Pointer to the target buffer to be filled with PcdDebugClearMemoryValue.\r |
fb3df220 | 139 | @param Length Number of bytes in Buffer to fill with zeros PcdDebugClearMemoryValue. \r |
140 | \r | |
eceb3a4c | 141 | @return Buffer Pointer to the target buffer filled with PcdDebugClearMemoryValue.\r |
fb3df220 | 142 | \r |
143 | **/\r | |
144 | VOID *\r | |
145 | EFIAPI\r | |
146 | DebugClearMemory (\r | |
147 | OUT VOID *Buffer,\r | |
148 | IN UINTN Length\r | |
149 | );\r | |
150 | \r | |
151 | \r | |
152 | /**\r | |
fb3df220 | 153 | Returns TRUE if ASSERT() macros are enabled.\r |
154 | \r | |
155 | This function returns TRUE if the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of \r | |
156 | PcdDebugProperyMask is set. Otherwise FALSE is returned.\r | |
157 | \r | |
158 | @retval TRUE The DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is set.\r | |
159 | @retval FALSE The DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is clear.\r | |
160 | \r | |
161 | **/\r | |
162 | BOOLEAN\r | |
163 | EFIAPI\r | |
164 | DebugAssertEnabled (\r | |
165 | VOID\r | |
166 | );\r | |
167 | \r | |
168 | \r | |
3e5c3238 | 169 | /** \r |
170 | Returns TRUE if DEBUG() macros are enabled.\r | |
fb3df220 | 171 | \r |
172 | This function returns TRUE if the DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of \r | |
173 | PcdDebugProperyMask is set. Otherwise FALSE is returned.\r | |
174 | \r | |
175 | @retval TRUE The DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of PcdDebugProperyMask is set.\r | |
176 | @retval FALSE The DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of PcdDebugProperyMask is clear.\r | |
177 | \r | |
178 | **/\r | |
179 | BOOLEAN\r | |
180 | EFIAPI\r | |
181 | DebugPrintEnabled (\r | |
182 | VOID\r | |
183 | );\r | |
184 | \r | |
185 | \r | |
3e5c3238 | 186 | /** \r |
187 | Returns TRUE if DEBUG_CODE() macros are enabled.\r | |
fb3df220 | 188 | \r |
189 | This function returns TRUE if the DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of \r | |
190 | PcdDebugProperyMask is set. Otherwise FALSE is returned.\r | |
191 | \r | |
192 | @retval TRUE The DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is set.\r | |
193 | @retval FALSE The DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is clear.\r | |
194 | \r | |
195 | **/\r | |
196 | BOOLEAN\r | |
197 | EFIAPI\r | |
198 | DebugCodeEnabled (\r | |
199 | VOID\r | |
200 | );\r | |
201 | \r | |
202 | \r | |
3e5c3238 | 203 | /** \r |
204 | Returns TRUE if DEBUG_CLEAR_MEMORY() macro is enabled.\r | |
fb3df220 | 205 | \r |
eceb3a4c | 206 | This function returns TRUE if the DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED bit of \r |
fb3df220 | 207 | PcdDebugProperyMask is set. Otherwise FALSE is returned.\r |
208 | \r | |
eceb3a4c LG |
209 | @retval TRUE The DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED bit of PcdDebugProperyMask is set.\r |
210 | @retval FALSE The DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED bit of PcdDebugProperyMask is clear.\r | |
fb3df220 | 211 | \r |
212 | **/\r | |
213 | BOOLEAN\r | |
214 | EFIAPI\r | |
215 | DebugClearMemoryEnabled (\r | |
216 | VOID\r | |
217 | );\r | |
218 | \r | |
219 | \r | |
3e5c3238 | 220 | /** \r |
fb3df220 | 221 | Internal worker macro that calls DebugAssert().\r |
222 | \r | |
1a2f870c | 223 | This macro calls DebugAssert(), passing in the filename, line number, and an\r |
224 | expression that evaluated to FALSE.\r | |
fb3df220 | 225 | \r |
1a2f870c | 226 | @param Expression Boolean expression that evaluated to FALSE\r |
fb3df220 | 227 | \r |
228 | **/\r | |
229 | #define _ASSERT(Expression) DebugAssert (__FILE__, __LINE__, #Expression)\r | |
230 | \r | |
231 | \r | |
3e5c3238 | 232 | /** \r |
fb3df220 | 233 | Internal worker macro that calls DebugPrint().\r |
234 | \r | |
235 | This macro calls DebugPrint() passing in the debug error level, a format \r | |
236 | string, and a variable argument list.\r | |
237 | \r | |
238 | @param Expression Expression containing an error level, a format string, \r | |
239 | and a variable argument list based on the format string.\r | |
240 | \r | |
241 | **/\r | |
242 | #define _DEBUG(Expression) DebugPrint Expression\r | |
243 | \r | |
244 | \r | |
3e5c3238 | 245 | /** \r |
1a2f870c | 246 | Macro that calls DebugAssert() if an expression evaluates to FALSE.\r |
fb3df220 | 247 | \r |
c9ec7047 | 248 | If MDEPKG_NDEBUG is not defined and the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED \r |
249 | bit of PcdDebugProperyMask is set, then this macro evaluates the Boolean \r | |
250 | expression specified by Expression. If Expression evaluates to FALSE, then \r | |
251 | DebugAssert() is called passing in the source filename, source line number, \r | |
252 | and Expression.\r | |
fb3df220 | 253 | \r |
254 | @param Expression Boolean expression\r | |
255 | \r | |
256 | **/\r | |
c9ec7047 | 257 | #if !defined(MDEPKG_NDEBUG) \r |
258 | #define ASSERT(Expression) \\r | |
259 | do { \\r | |
260 | if (DebugAssertEnabled ()) { \\r | |
261 | if (!(Expression)) { \\r | |
262 | _ASSERT (Expression); \\r | |
263 | } \\r | |
264 | } \\r | |
265 | } while (FALSE)\r | |
266 | #else\r | |
267 | #define ASSERT(Expression)\r | |
268 | #endif\r | |
fb3df220 | 269 | \r |
3e5c3238 | 270 | /** \r |
fb3df220 | 271 | Macro that calls DebugPrint().\r |
272 | \r | |
c9ec7047 | 273 | If MDEPKG_NDEBUG is not defined and the DEBUG_PROPERTY_DEBUG_PRINT_ENABLED \r |
274 | bit of PcdDebugProperyMask is set, then this macro passes Expression to \r | |
275 | DebugPrint().\r | |
fb3df220 | 276 | \r |
277 | @param Expression Expression containing an error level, a format string, \r | |
278 | and a variable argument list based on the format string.\r | |
279 | \r | |
280 | \r | |
281 | **/\r | |
c9ec7047 | 282 | #if !defined(MDEPKG_NDEBUG) \r |
283 | #define DEBUG(Expression) \\r | |
284 | do { \\r | |
285 | if (DebugPrintEnabled ()) { \\r | |
286 | _DEBUG (Expression); \\r | |
287 | } \\r | |
288 | } while (FALSE)\r | |
289 | #else\r | |
290 | #define DEBUG(Expression)\r | |
291 | #endif\r | |
fb3df220 | 292 | \r |
3e5c3238 | 293 | /** \r |
fb3df220 | 294 | Macro that calls DebugAssert() if an EFI_STATUS evaluates to an error code.\r |
295 | \r | |
c9ec7047 | 296 | If MDEPKG_NDEBUG is not defined and the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED \r |
297 | bit of PcdDebugProperyMask is set, then this macro evaluates the EFI_STATUS \r | |
298 | value specified by StatusParameter. If StatusParameter is an error code, \r | |
299 | then DebugAssert() is called passing in the source filename, source line \r | |
300 | number, and StatusParameter.\r | |
fb3df220 | 301 | \r |
302 | @param StatusParameter EFI_STATUS value to evaluate.\r | |
303 | \r | |
304 | **/\r | |
c9ec7047 | 305 | #if !defined(MDEPKG_NDEBUG)\r |
306 | #define ASSERT_EFI_ERROR(StatusParameter) \\r | |
307 | do { \\r | |
308 | if (DebugAssertEnabled ()) { \\r | |
309 | if (EFI_ERROR (StatusParameter)) { \\r | |
310 | DEBUG ((EFI_D_ERROR, "\nASSERT_EFI_ERROR (Status = %r)\n", StatusParameter)); \\r | |
311 | _ASSERT (!EFI_ERROR (StatusParameter)); \\r | |
312 | } \\r | |
313 | } \\r | |
314 | } while (FALSE)\r | |
315 | #else\r | |
316 | #define ASSERT_EFI_ERROR(StatusParameter)\r | |
317 | #endif\r | |
fb3df220 | 318 | \r |
3e5c3238 | 319 | /** \r |
fb3df220 | 320 | Macro that calls DebugAssert() if a protocol is already installed in the \r |
321 | handle database.\r | |
322 | \r | |
c9ec7047 | 323 | If MDEPKG_NDEBUG is defined or the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit \r |
324 | of PcdDebugProperyMask is clear, then return.\r | |
fb3df220 | 325 | \r |
326 | If Handle is NULL, then a check is made to see if the protocol specified by Guid \r | |
327 | is present on any handle in the handle database. If Handle is not NULL, then \r | |
328 | a check is made to see if the protocol specified by Guid is present on the \r | |
329 | handle specified by Handle. If the check finds the protocol, then DebugAssert() \r | |
330 | is called passing in the source filename, source line number, and Guid.\r | |
331 | \r | |
332 | If Guid is NULL, then ASSERT().\r | |
333 | \r | |
334 | @param Handle The handle to check for the protocol. This is an optional \r | |
335 | parameter that may be NULL. If it is NULL, then the entire \r | |
336 | handle database is searched.\r | |
337 | \r | |
338 | @param Guid Pointer to a protocol GUID.\r | |
339 | \r | |
340 | **/\r | |
c9ec7047 | 341 | #if !defined(MDEPKG_NDEBUG)\r |
342 | #define ASSERT_PROTOCOL_ALREADY_INSTALLED(Handle, Guid) \\r | |
343 | do { \\r | |
344 | if (DebugAssertEnabled ()) { \\r | |
345 | VOID *Instance; \\r | |
346 | ASSERT (Guid != NULL); \\r | |
347 | if (Handle == NULL) { \\r | |
348 | if (!EFI_ERROR (gBS->LocateProtocol ((EFI_GUID *)Guid, NULL, &Instance))) { \\r | |
349 | _ASSERT (Guid already installed in database); \\r | |
350 | } \\r | |
351 | } else { \\r | |
352 | if (!EFI_ERROR (gBS->HandleProtocol (Handle, (EFI_GUID *)Guid, &Instance))) { \\r | |
353 | _ASSERT (Guid already installed on Handle); \\r | |
354 | } \\r | |
355 | } \\r | |
356 | } \\r | |
357 | } while (FALSE)\r | |
358 | #else\r | |
359 | #define ASSERT_PROTOCOL_ALREADY_INSTALLED(Handle, Guid)\r | |
360 | #endif\r | |
fb3df220 | 361 | \r |
362 | /**\r | |
363 | Macro that marks the beginning of debug source code.\r | |
364 | \r | |
365 | If the DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is set, \r | |
366 | then this macro marks the beginning of source code that is included in a module.\r | |
367 | Otherwise, the source lines between DEBUG_CODE_BEGIN() and DEBUG_CODE_END() \r | |
368 | are not included in a module.\r | |
369 | \r | |
370 | **/\r | |
371 | #define DEBUG_CODE_BEGIN() do { if (DebugCodeEnabled ()) { UINT8 __DebugCodeLocal\r | |
372 | \r | |
373 | \r | |
3e5c3238 | 374 | /** \r |
fb3df220 | 375 | Macro that marks the end of debug source code.\r |
376 | \r | |
377 | If the DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is set, \r | |
378 | then this macro marks the end of source code that is included in a module. \r | |
379 | Otherwise, the source lines between DEBUG_CODE_BEGIN() and DEBUG_CODE_END() \r | |
380 | are not included in a module.\r | |
381 | \r | |
382 | **/\r | |
383 | #define DEBUG_CODE_END() __DebugCodeLocal = 0; __DebugCodeLocal++; } } while (FALSE)\r | |
384 | \r | |
385 | \r | |
3e5c3238 | 386 | /** \r |
fb3df220 | 387 | Macro that declares a section of debug source code.\r |
388 | \r | |
389 | If the DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is set, \r | |
390 | then the source code specified by Expression is included in a module. \r | |
391 | Otherwise, the source specified by Expression is not included in a module.\r | |
392 | \r | |
393 | **/\r | |
394 | #define DEBUG_CODE(Expression) \\r | |
395 | DEBUG_CODE_BEGIN (); \\r | |
396 | Expression \\r | |
397 | DEBUG_CODE_END ()\r | |
398 | \r | |
399 | \r | |
3e5c3238 | 400 | /** \r |
fb3df220 | 401 | Macro that calls DebugClearMemory() to clear a buffer to a default value.\r |
402 | \r | |
403 | If the DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED bit of PcdDebugProperyMask is set, \r | |
404 | then this macro calls DebugClearMemory() passing in Address and Length.\r | |
405 | \r | |
406 | @param Address Pointer to a buffer.\r | |
407 | @param Length The number of bytes in the buffer to set.\r | |
408 | \r | |
409 | **/\r | |
410 | #define DEBUG_CLEAR_MEMORY(Address, Length) \\r | |
411 | do { \\r | |
412 | if (DebugClearMemoryEnabled ()) { \\r | |
413 | DebugClearMemory (Address, Length); \\r | |
414 | } \\r | |
415 | } while (FALSE)\r | |
416 | \r | |
417 | \r | |
418 | /**\r | |
fb3df220 | 419 | Macro that calls DebugAssert() if the containing record does not have a \r |
420 | matching signature. If the signatures matches, then a pointer to the data \r | |
421 | structure that contains a specified field of that data structure is returned. \r | |
422 | This is a light weight method hide information by placing a public data \r | |
423 | structure inside a larger private data structure and using a pointer to the \r | |
424 | public data structure to retrieve a pointer to the private data structure.\r | |
425 | \r | |
c9ec7047 | 426 | If MDEPKG_NDEBUG is defined or the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit \r |
427 | of PcdDebugProperyMask is clear, then this macro computes the offset, in bytes,\r | |
428 | of field specified by Field from the beginning of the data structure specified \r | |
429 | by TYPE. This offset is subtracted from Record, and is used to return a pointer \r | |
430 | to a data structure of the type specified by TYPE.\r | |
431 | \r | |
432 | If MDEPKG_NDEBUG is not defined and the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit\r | |
433 | of PcdDebugProperyMask is set, then this macro computes the offset, in bytes, \r | |
434 | of field specified by Field from the beginning of the data structure specified \r | |
435 | by TYPE. This offset is subtracted from Record, and is used to compute a pointer\r | |
436 | to a data structure of the type specified by TYPE. The Signature field of the \r | |
437 | data structure specified by TYPE is compared to TestSignature. If the signatures \r | |
438 | match, then a pointer to the pointer to a data structure of the type specified by \r | |
439 | TYPE is returned. If the signatures do not match, then DebugAssert() is called \r | |
440 | with a description of "CR has a bad signature" and Record is returned. \r | |
fb3df220 | 441 | \r |
442 | If the data type specified by TYPE does not contain the field specified by Field, \r | |
443 | then the module will not compile.\r | |
444 | \r | |
445 | If TYPE does not contain a field called Signature, then the module will not \r | |
446 | compile.\r | |
447 | \r | |
448 | @param Record Pointer to the field specified by Field within a data \r | |
449 | structure of type TYPE.\r | |
450 | \r | |
451 | @param TYPE The name of the data structure type to return This \r | |
452 | data structure must contain the field specified by Field. \r | |
453 | \r | |
454 | @param Field The name of the field in the data structure specified \r | |
455 | by TYPE to which Record points.\r | |
456 | \r | |
457 | @param TestSignature The 32-bit signature value to match.\r | |
458 | \r | |
459 | **/\r | |
c9ec7047 | 460 | #if !defined(MDEPKG_NDEBUG)\r |
461 | #define CR(Record, TYPE, Field, TestSignature) \\r | |
462 | (DebugAssertEnabled () && (BASE_CR (Record, TYPE, Field)->Signature != TestSignature)) ? \\r | |
463 | (TYPE *) (_ASSERT (CR has Bad Signature), Record) : \\r | |
464 | BASE_CR (Record, TYPE, Field)\r | |
465 | #else\r | |
466 | #define CR(Record, TYPE, Field, TestSignature) \\r | |
467 | BASE_CR (Record, TYPE, Field)\r | |
468 | #endif\r | |
fb3df220 | 469 | \r |
470 | #endif\r |