]>
Commit | Line | Data |
---|---|---|
3eb9473e | 1 | /*++\r |
2 | \r | |
9a8e70ce | 3 | Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.<BR>\r |
f57387d5 | 4 | This program and the accompanying materials \r |
3eb9473e | 5 | are licensed and made available under the terms and conditions of the BSD License \r |
6 | which accompanies this distribution. The full text of the license may be found at \r | |
7 | http://opensource.org/licenses/bsd-license.php \r | |
8 | \r | |
9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r | |
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r | |
11 | \r | |
12 | Module Name:\r | |
13 | \r | |
14 | EfiDebug.h\r | |
15 | \r | |
16 | Abstract:\r | |
17 | \r | |
18 | EFI Debug macros. The work needs tobe done in library. The Debug\r | |
19 | macros them selves are standard for all files, including the core.\r | |
20 | \r | |
21 | There needs to be code linked in that produces the following macros:\r | |
22 | \r | |
23 | EfiDebugAssert(file, linenumber, assertion string) - worker function for \r | |
24 | ASSERT. filename and line number of where this ASSERT() is located\r | |
25 | is passed in along with the stringized version of the assertion.\r | |
26 | \r | |
27 | EfiDebugPrint - Worker function for debug print\r | |
28 | \r | |
29 | _DEBUG_SET_MEM(address, length, value) - Set memory at address to value\r | |
30 | for legnth bytes. This macro is used to initialzed uninitialized memory\r | |
31 | or memory that is free'ed, so it will not be used by mistake. \r | |
32 | \r | |
33 | --*/\r | |
34 | \r | |
35 | #ifndef _EFI_DEBUG_H_\r | |
36 | #define _EFI_DEBUG_H_\r | |
37 | \r | |
38 | #ifdef EFI_DEBUG\r | |
39 | \r | |
40 | VOID\r | |
41 | EfiDebugAssert (\r | |
42 | IN CHAR8 *FileName,\r | |
43 | IN INTN LineNumber,\r | |
44 | IN CHAR8 *Description\r | |
45 | );\r | |
46 | \r | |
47 | VOID\r | |
48 | EfiDebugPrint (\r | |
49 | IN UINTN ErrorLevel,\r | |
50 | IN CHAR8 *Format,\r | |
51 | ...\r | |
52 | );\r | |
53 | \r | |
54 | VOID\r | |
55 | EfiDebugVPrint (\r | |
56 | IN UINTN ErrorLevel,\r | |
57 | IN CHAR8 *Format,\r | |
58 | IN VA_LIST Marker\r | |
59 | );\r | |
60 | \r | |
61 | //\r | |
62 | // Define macros for the above functions so we can make them go away\r | |
63 | // in non-debug builds.\r | |
64 | //\r | |
65 | #define EFI_DEBUG_VPRINT(ErrorLevel, Format, Marker) \\r | |
66 | EfiDebugVPrint(ErrorLevel, Format, Marker) \r | |
67 | \r | |
68 | #define EFI_DEBUG_ASSERT(FileName, LineNumber, Description) \\r | |
69 | EfiDebugAssert (FileName, LineNumber, Description)\r | |
70 | \r | |
71 | #define _DEBUG_ASSERT(assertion) \\r | |
72 | EfiDebugAssert (__FILE__, __LINE__, #assertion)\r | |
73 | \r | |
74 | #define _DEBUG(arg) DebugPrint arg\r | |
75 | \r | |
76 | //\r | |
77 | // Define ASSERT() macro, if assertion is FALSE trigger the ASSERT\r | |
78 | //\r | |
79 | #define ASSERT(assertion) if(!(assertion)) \\r | |
80 | _DEBUG_ASSERT(assertion)\r | |
81 | \r | |
82 | #define ASSERT_LOCKED(l) if(!(l)->Lock) _DEBUG_ASSERT(l not locked)\r | |
83 | \r | |
84 | //\r | |
85 | // DEBUG((DebugLevel, "format string", ...)) - if DebugLevel is active do \r | |
86 | // the a debug print.\r | |
87 | //\r | |
88 | #define DEBUG(arg) EfiDebugPrint arg\r | |
89 | \r | |
90 | #define DEBUG_CODE(code) code\r | |
91 | \r | |
92 | #define CR(record, TYPE, field, signature) \\r | |
93 | _CR(record, TYPE, field)->Signature != signature ? \\r | |
94 | (TYPE *) (_DEBUG_ASSERT("CR has Bad Signature"), record) : \\r | |
95 | _CR(record, TYPE, field)\r | |
96 | \r | |
97 | #define _DEBUG_SET_MEM(address, length, data) EfiCommonLibSetMem(address, length, data)\r | |
98 | \r | |
99 | //\r | |
100 | // Generate an ASSERT if the protocol specified by GUID is already installed on Handle.\r | |
101 | // If Handle is NULL, then an ASSERT is generated if the protocol specified by GUID \r | |
102 | // is present anywhere in the handle database\r | |
103 | //\r | |
104 | #define ASSERT_PROTOCOL_ALREADY_INSTALLED(Handle, Guid) \\r | |
105 | DEBUG_CODE ( { \\r | |
106 | VOID *Instance; \\r | |
107 | if (Handle == NULL) { \\r | |
108 | ASSERT(EFI_ERROR(gBS->LocateProtocol (Guid, NULL, &Instance))); \\r | |
109 | } else { \\r | |
110 | ASSERT(EFI_ERROR(gBS->HandleProtocol (Handle, Guid, &Instance))); \\r | |
111 | } } ) \r | |
112 | \r | |
113 | #else\r | |
114 | #define ASSERT(a) \r | |
115 | #define ASSERT_LOCKED(l) \r | |
116 | #define DEBUG(arg) \r | |
117 | #define DEBUG_CODE(code) \r | |
118 | #define CR(Record, TYPE, Field, Signature) \\r | |
119 | _CR(Record, TYPE, Field) \r | |
120 | #define _DEBUG_SET_MEM(address, length, data) \r | |
121 | #define EFI_DEBUG_VPRINT(ErrorLevel, Format, Marker) \r | |
122 | #define EFI_DEBUG_ASSERT(FileName, LineNumber, Description) \r | |
123 | #define ASSERT_PROTOCOL_ALREADY_INSTALLED(Handle, Guid)\r | |
124 | #endif\r | |
125 | \r | |
126 | //\r | |
127 | // Generate an ASSERT if Status is an error code\r | |
128 | //\r | |
129 | //#define ASSERT_EFI_ERROR(status) ASSERT(!EFI_ERROR(status))\r | |
130 | #define ASSERT_EFI_ERROR(status) if (EFI_ERROR(status)) \\r | |
131 | DEBUG_CODE ( { \\r | |
132 | DEBUG((EFI_D_ERROR, "\nASSERT!Status = 0x%x Info :",status)); \\r | |
133 | ASSERT(!EFI_ERROR(status)); \\r | |
134 | } ) \r | |
135 | \r | |
136 | #ifdef EFI_DEBUG_CLEAR_MEMORY\r | |
137 | #define DEBUG_SET_MEMORY(address,length) \\r | |
138 | _DEBUG_SET_MEM(address, length, EFI_BAD_POINTER_AS_BYTE)\r | |
139 | #else\r | |
140 | #define DEBUG_SET_MEMORY(address,length)\r | |
141 | #endif\r | |
142 | \r | |
143 | #define EFI_D_INIT 0x00000001 // Initialization style messages\r | |
144 | #define EFI_D_WARN 0x00000002 // Warnings\r | |
145 | #define EFI_D_LOAD 0x00000004 // Load events\r | |
146 | #define EFI_D_FS 0x00000008 // EFI File system\r | |
147 | #define EFI_D_POOL 0x00000010 // Alloc & Free's\r | |
148 | #define EFI_D_PAGE 0x00000020 // Alloc & Free's\r | |
9a8e70ce | 149 | #define EFI_D_INFO 0x00000040 // Informational debug messages\r |
3eb9473e | 150 | #define EFI_D_VARIABLE 0x00000100 // Variable\r |
151 | #define EFI_D_BM 0x00000400 // Boot Manager (BDS)\r | |
152 | #define EFI_D_BLKIO 0x00001000 // BlkIo Driver\r | |
153 | #define EFI_D_NET 0x00004000 // SNI Driver\r | |
154 | #define EFI_D_UNDI 0x00010000 // UNDI Driver\r | |
155 | #define EFI_D_LOADFILE 0x00020000 // UNDI Driver\r | |
156 | #define EFI_D_EVENT 0x00080000 // Event messages\r | |
9a8e70ce | 157 | #define EFI_D_VERBOSE 0x00400000 // Detailed debug messages that may significantly impact boot performance\r |
3eb9473e | 158 | #define EFI_D_ERROR 0x80000000 // Error\r |
159 | \r | |
160 | #define EFI_D_GENERIC (EFI_D_ERROR | EFI_D_INIT | EFI_D_WARN | EFI_D_INFO | \\r | |
9a8e70ce | 161 | EFI_D_BLKIO | EFI_D_NET | EFI_D_UNDI | EFI_D_VERBOSE) \r |
3eb9473e | 162 | \r |
163 | #define EFI_D_INTRINSIC ( EFI_D_EVENT | EFI_D_POOL | EFI_D_PAGE | \\r | |
164 | EFI_D_BM | EFI_D_LOAD | EFI_D_VARIABLE ) \r | |
165 | \r | |
166 | #define EFI_D_RESERVED (EFI_D_GENERIC | EFI_D_INTRINSIC) \r | |
167 | \r | |
90d44b32 | 168 | #define EFI_DBUG_MASK (EFI_D_ERROR | EFI_D_INFO | EFI_D_WARN)\r |
3eb9473e | 169 | \r |
170 | #endif\r |