acmacros.h revision 70243
1/******************************************************************************
2 *
3 * Name: acmacros.h - C macros for the entire subsystem.
4 *       $Revision: 59 $
5 *
6 *****************************************************************************/
7
8/******************************************************************************
9 *
10 * 1. Copyright Notice
11 *
12 * Some or all of this work - Copyright (c) 1999, 2000, Intel Corp.
13 * All rights reserved.
14 *
15 * 2. License
16 *
17 * 2.1. This is your license from Intel Corp. under its intellectual property
18 * rights.  You may have additional license terms from the party that provided
19 * you this software, covering your right to use that party's intellectual
20 * property rights.
21 *
22 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23 * copy of the source code appearing in this file ("Covered Code") an
24 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25 * base code distributed originally by Intel ("Original Intel Code") to copy,
26 * make derivatives, distribute, use and display any portion of the Covered
27 * Code in any form, with the right to sublicense such rights; and
28 *
29 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30 * license (with the right to sublicense), under only those claims of Intel
31 * patents that are infringed by the Original Intel Code, to make, use, sell,
32 * offer to sell, and import the Covered Code and derivative works thereof
33 * solely to the minimum extent necessary to exercise the above copyright
34 * license, and in no event shall the patent license extend to any additions
35 * to or modifications of the Original Intel Code.  No other license or right
36 * is granted directly or by implication, estoppel or otherwise;
37 *
38 * The above copyright and patent license is granted only if the following
39 * conditions are met:
40 *
41 * 3. Conditions
42 *
43 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44 * Redistribution of source code of any substantial portion of the Covered
45 * Code or modification with rights to further distribute source must include
46 * the above Copyright Notice, the above License, this list of Conditions,
47 * and the following Disclaimer and Export Compliance provision.  In addition,
48 * Licensee must cause all Covered Code to which Licensee contributes to
49 * contain a file documenting the changes Licensee made to create that Covered
50 * Code and the date of any change.  Licensee must include in that file the
51 * documentation of any changes made by any predecessor Licensee.  Licensee
52 * must include a prominent statement that the modification is derived,
53 * directly or indirectly, from Original Intel Code.
54 *
55 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56 * Redistribution of source code of any substantial portion of the Covered
57 * Code or modification without rights to further distribute source must
58 * include the following Disclaimer and Export Compliance provision in the
59 * documentation and/or other materials provided with distribution.  In
60 * addition, Licensee may not authorize further sublicense of source of any
61 * portion of the Covered Code, and must include terms to the effect that the
62 * license from Licensee to its licensee is limited to the intellectual
63 * property embodied in the software Licensee provides to its licensee, and
64 * not to intellectual property embodied in modifications its licensee may
65 * make.
66 *
67 * 3.3. Redistribution of Executable. Redistribution in executable form of any
68 * substantial portion of the Covered Code or modification must reproduce the
69 * above Copyright Notice, and the following Disclaimer and Export Compliance
70 * provision in the documentation and/or other materials provided with the
71 * distribution.
72 *
73 * 3.4. Intel retains all right, title, and interest in and to the Original
74 * Intel Code.
75 *
76 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77 * Intel shall be used in advertising or otherwise to promote the sale, use or
78 * other dealings in products derived from or relating to the Covered Code
79 * without prior written authorization from Intel.
80 *
81 * 4. Disclaimer and Export Compliance
82 *
83 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84 * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
86 * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
87 * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
88 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
89 * PARTICULAR PURPOSE.
90 *
91 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
97 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
98 * LIMITED REMEDY.
99 *
100 * 4.3. Licensee shall not export, either directly or indirectly, any of this
101 * software or system incorporating such software without first obtaining any
102 * required license or other approval from the U. S. Department of Commerce or
103 * any other agency or department of the United States Government.  In the
104 * event Licensee exports any such software from the United States or
105 * re-exports any such software from a foreign destination, Licensee shall
106 * ensure that the distribution and export/re-export of the software is in
107 * compliance with all laws, regulations, orders, or other restrictions of the
108 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109 * any of its subsidiaries will export/re-export any technical data, process,
110 * software, or service, directly or indirectly, to any country for which the
111 * United States government or any agency thereof requires an export license,
112 * other governmental approval, or letter of assurance, without first obtaining
113 * such license, approval or letter.
114 *
115 *****************************************************************************/
116
117#ifndef __ACMACROS_H__
118#define __ACMACROS_H__
119
120/*
121 * Data manipulation macros
122 */
123
124#ifndef LOWORD
125#define LOWORD(l)                       ((UINT16)(NATIVE_UINT)(l))
126#endif
127
128#ifndef HIWORD
129#define HIWORD(l)                       ((UINT16)((((NATIVE_UINT)(l)) >> 16) & 0xFFFF))
130#endif
131
132#ifndef LOBYTE
133#define LOBYTE(l)                       ((UINT8)(UINT16)(l))
134#endif
135
136#ifndef HIBYTE
137#define HIBYTE(l)                       ((UINT8)((((UINT16)(l)) >> 8) & 0xFF))
138#endif
139
140#define BIT0(x)                         ((((x) & 0x01) > 0) ? 1 : 0)
141#define BIT1(x)                         ((((x) & 0x02) > 0) ? 1 : 0)
142#define BIT2(x)                         ((((x) & 0x04) > 0) ? 1 : 0)
143
144#define BIT3(x)                         ((((x) & 0x08) > 0) ? 1 : 0)
145#define BIT4(x)                         ((((x) & 0x10) > 0) ? 1 : 0)
146#define BIT5(x)                         ((((x) & 0x20) > 0) ? 1 : 0)
147#define BIT6(x)                         ((((x) & 0x40) > 0) ? 1 : 0)
148#define BIT7(x)                         ((((x) & 0x80) > 0) ? 1 : 0)
149
150#define LOW_BASE(w)                     ((UINT16) ((w) & 0x0000FFFF))
151#define MID_BASE(b)                     ((UINT8) (((b) & 0x00FF0000) >> 16))
152#define HI_BASE(b)                      ((UINT8) (((b) & 0xFF000000) >> 24))
153#define LOW_LIMIT(w)                    ((UINT16) ((w) & 0x0000FFFF))
154#define HI_LIMIT(b)                     ((UINT8) (((b) & 0x00FF0000) >> 16))
155
156
157#ifdef _IA16
158#define ACPI_GET_ADDRESS(a)             ((a).Lo)
159#define ACPI_STORE_ADDRESS(a,b)         {(a).Hi=0;(a).Lo=(b);}
160#define ACPI_VALID_ADDRESS(a)           ((a).Hi && (a).Lo)
161#else
162#define ACPI_GET_ADDRESS(a)             (a)
163#define ACPI_STORE_ADDRESS(a,b)         ((a)=(b))
164#define ACPI_VALID_ADDRESS(a)           (a)
165#endif
166 /*
167  * Extract a byte of data using a pointer.  Any more than a byte and we
168  * get into potential aligment issues -- see the STORE macros below
169  */
170#define GET8(addr)                      (*(UINT8*)(addr))
171
172
173/*
174 * Macros for moving data around to/from buffers that are possibly unaligned.
175 * If the hardware supports the transfer of unaligned data, just do the store.
176 * Otherwise, we have to move one byte at a time.
177 */
178
179#ifdef _HW_ALIGNMENT_SUPPORT
180
181/* The hardware supports unaligned transfers, just do the move */
182
183#define MOVE_UNALIGNED16_TO_16(d,s)     *(UINT16*)(d) = *(UINT16*)(s)
184#define MOVE_UNALIGNED32_TO_32(d,s)     *(UINT32*)(d) = *(UINT32*)(s)
185#define MOVE_UNALIGNED16_TO_32(d,s)     *(UINT32*)(d) = *(UINT16*)(s)
186
187#else
188/*
189 * The hardware does not support unaligned transfers.  We must move the
190 * data one byte at a time.  These macros work whether the source or
191 * the destination (or both) is/are unaligned.
192 */
193
194#define MOVE_UNALIGNED16_TO_16(d,s)     {((UINT8 *)(d))[0] = ((UINT8 *)(s))[0];\
195                                         ((UINT8 *)(d))[1] = ((UINT8 *)(s))[1];}
196
197#define MOVE_UNALIGNED32_TO_32(d,s)     {((UINT8 *)(d))[0] = ((UINT8 *)(s))[0];\
198                                         ((UINT8 *)(d))[1] = ((UINT8 *)(s))[1];\
199                                         ((UINT8 *)(d))[2] = ((UINT8 *)(s))[2];\
200                                         ((UINT8 *)(d))[3] = ((UINT8 *)(s))[3];}
201
202#define MOVE_UNALIGNED16_TO_32(d,s)     {(*(UINT32*)(d)) = 0; MOVE_UNALIGNED16_TO_16(d,s);}
203
204#endif
205
206
207/*
208 * Fast power-of-two math macros for non-optimized compilers
209 */
210
211#define _DIV(value,PowerOf2)            ((UINT32) ((value) >> (PowerOf2)))
212#define _MUL(value,PowerOf2)            ((UINT32) ((value) << (PowerOf2)))
213#define _MOD(value,Divisor)             ((UINT32) ((value) & ((Divisor) -1)))
214
215#define DIV_2(a)                        _DIV(a,1)
216#define MUL_2(a)                        _MUL(a,1)
217#define MOD_2(a)                        _MOD(a,2)
218
219#define DIV_4(a)                        _DIV(a,2)
220#define MUL_4(a)                        _MUL(a,2)
221#define MOD_4(a)                        _MOD(a,4)
222
223#define DIV_8(a)                        _DIV(a,3)
224#define MUL_8(a)                        _MUL(a,3)
225#define MOD_8(a)                        _MOD(a,8)
226
227#define DIV_16(a)                       _DIV(a,4)
228#define MUL_16(a)                       _MUL(a,4)
229#define MOD_16(a)                       _MOD(a,16)
230
231/*
232 * Divide and Modulo
233 */
234#define ACPI_DIVIDE(n,d)                ((n) / (d))
235#define ACPI_MODULO(n,d)                ((n) % (d))
236
237/*
238 * Rounding macros (Power of two boundaries only)
239 */
240
241#define ROUND_DOWN(value,boundary)      ((value) & (~((boundary)-1)))
242#define ROUND_UP(value,boundary)        (((value) + ((boundary)-1)) & (~((boundary)-1)))
243
244#define ROUND_DOWN_TO_32_BITS(a)        ROUND_DOWN(a,4)
245#define ROUND_DOWN_TO_64_BITS(a)        ROUND_DOWN(a,8)
246#define ROUND_DOWN_TO_NATIVE_WORD(a)    ROUND_DOWN(a,ALIGNED_ADDRESS_BOUNDARY)
247
248#define ROUND_UP_TO_32BITS(a)           ROUND_UP(a,4)
249#define ROUND_UP_TO_64BITS(a)           ROUND_UP(a,8)
250#define ROUND_UP_TO_NATIVE_WORD(a)      ROUND_UP(a,ALIGNED_ADDRESS_BOUNDARY)
251
252#define ROUND_PTR_UP_TO_4(a,b)          ((b *)(((NATIVE_UINT)(a) + 3) & ~3))
253#define ROUND_PTR_UP_TO_8(a,b)          ((b *)(((NATIVE_UINT)(a) + 7) & ~7))
254
255#define ROUND_UP_TO_1K(a)               (((a) + 1023) >> 10)
256
257#ifdef DEBUG_ASSERT
258#undef DEBUG_ASSERT
259#endif
260
261
262/* Macros for GAS addressing */
263
264#define ACPI_PCI_DEVICE_MASK            (UINT64) 0x0000FFFF00000000
265#define ACPI_PCI_FUNCTION_MASK          (UINT64) 0x00000000FFFF0000
266#define ACPI_PCI_REGISTER_MASK          (UINT64) 0x000000000000FFFF
267
268#define ACPI_PCI_FUNCTION(a)            (UINT32) ((((a) & ACPI_PCI_FUNCTION_MASK) >> 16))
269#define ACPI_PCI_DEVICE(a)              (UINT32) ((((a) & ACPI_PCI_DEVICE_MASK) >> 32))
270
271#ifndef _IA16
272#define ACPI_PCI_REGISTER(a)            (UINT32) (((a) & ACPI_PCI_REGISTER_MASK))
273#define ACPI_PCI_DEVFUN(a)              (UINT32) ((ACPI_PCI_DEVICE(a) << 16) | ACPI_PCI_FUNCTION(a))
274
275#else
276#define ACPI_PCI_REGISTER(a)            (UINT32) (((a) & 0x0000FFFF))
277#define ACPI_PCI_DEVFUN(a)              (UINT32) ((((a) & 0xFFFF0000) >> 16))
278
279#endif
280
281/*
282 * An ACPI_HANDLE (which is actually an ACPI_NAMESPACE_NODE *) can appear in some contexts,
283 * such as on apObjStack, where a pointer to an ACPI_OPERAND_OBJECT  can also
284 * appear.  This macro is used to distinguish them.
285 *
286 * The DataType field is the first field in both structures.
287 */
288
289#define VALID_DESCRIPTOR_TYPE(d,t)      (((ACPI_NAMESPACE_NODE *)d)->DataType == t)
290
291
292/* Macro to test the object type */
293
294#define IS_THIS_OBJECT_TYPE(d,t)        (((ACPI_OPERAND_OBJECT  *)d)->Common.Type == (UINT8)t)
295
296/* Macro to check the table flags for SINGLE or MULTIPLE tables are allowed */
297
298#define IS_SINGLE_TABLE(x)              (((x) & 0x01) == ACPI_TABLE_SINGLE ? 1 : 0)
299
300/*
301 * Macro to check if a pointer is within an ACPI table.
302 * Parameter (a) is the pointer to check.  Parameter (b) must be defined
303 * as a pointer to an ACPI_TABLE_HEADER.  (b+1) then points past the header,
304 * and ((UINT8 *)b+b->Length) points one byte past the end of the table.
305 */
306
307#ifndef _IA16
308#define IS_IN_ACPI_TABLE(a,b)           (((UINT8 *)(a) >= (UINT8 *)(b + 1)) &&\
309                                        ((UINT8 *)(a) < ((UINT8 *)b + b->Length)))
310
311#else
312#define IS_IN_ACPI_TABLE(a,b)           (_segment)(a) == (_segment)(b) &&\
313                                        (((UINT8 *)(a) >= (UINT8 *)(b + 1)) &&\
314                                        ((UINT8 *)(a) < ((UINT8 *)b + b->Length)))
315#endif
316
317/*
318 * Macros for the master AML opcode table
319 */
320
321#ifdef ACPI_DEBUG
322#define OP_INFO_ENTRY(Flags,Name,PArgs,IArgs)     {Flags,PArgs,IArgs,Name}
323#else
324#define OP_INFO_ENTRY(Flags,Name,PArgs,IArgs)     {Flags,PArgs,IArgs}
325#endif
326
327#define ARG_TYPE_WIDTH                  5
328#define ARG_1(x)                        ((UINT32)(x))
329#define ARG_2(x)                        ((UINT32)(x) << (1 * ARG_TYPE_WIDTH))
330#define ARG_3(x)                        ((UINT32)(x) << (2 * ARG_TYPE_WIDTH))
331#define ARG_4(x)                        ((UINT32)(x) << (3 * ARG_TYPE_WIDTH))
332#define ARG_5(x)                        ((UINT32)(x) << (4 * ARG_TYPE_WIDTH))
333#define ARG_6(x)                        ((UINT32)(x) << (5 * ARG_TYPE_WIDTH))
334
335#define ARGI_LIST1(a)                   (ARG_1(a))
336#define ARGI_LIST2(a,b)                 (ARG_1(b)|ARG_2(a))
337#define ARGI_LIST3(a,b,c)               (ARG_1(c)|ARG_2(b)|ARG_3(a))
338#define ARGI_LIST4(a,b,c,d)             (ARG_1(d)|ARG_2(c)|ARG_3(b)|ARG_4(a))
339#define ARGI_LIST5(a,b,c,d,e)           (ARG_1(e)|ARG_2(d)|ARG_3(c)|ARG_4(b)|ARG_5(a))
340#define ARGI_LIST6(a,b,c,d,e,f)         (ARG_1(f)|ARG_2(e)|ARG_3(d)|ARG_4(c)|ARG_5(b)|ARG_6(a))
341
342#define ARGP_LIST1(a)                   (ARG_1(a))
343#define ARGP_LIST2(a,b)                 (ARG_1(a)|ARG_2(b))
344#define ARGP_LIST3(a,b,c)               (ARG_1(a)|ARG_2(b)|ARG_3(c))
345#define ARGP_LIST4(a,b,c,d)             (ARG_1(a)|ARG_2(b)|ARG_3(c)|ARG_4(d))
346#define ARGP_LIST5(a,b,c,d,e)           (ARG_1(a)|ARG_2(b)|ARG_3(c)|ARG_4(d)|ARG_5(e))
347#define ARGP_LIST6(a,b,c,d,e,f)         (ARG_1(a)|ARG_2(b)|ARG_3(c)|ARG_4(d)|ARG_5(e)|ARG_6(f))
348
349#define GET_CURRENT_ARG_TYPE(List)      (List & ((UINT32) 0x1F))
350#define INCREMENT_ARG_LIST(List)        (List >>= ((UINT32) ARG_TYPE_WIDTH))
351
352
353/*
354 * Reporting macros that are never compiled out
355 */
356
357#define PARAM_LIST(pl)                  pl
358
359/*
360 * Error reporting.  These versions add callers module and line#.  Since
361 * _THIS_MODULE gets compiled out when ACPI_DEBUG isn't defined, only
362 * use it in debug mode.
363 */
364
365#ifdef ACPI_DEBUG
366
367#define REPORT_INFO(fp)                 {_ReportInfo(_THIS_MODULE,__LINE__,_COMPONENT); \
368                                            DebugPrintRaw PARAM_LIST(fp);}
369#define REPORT_ERROR(fp)                {_ReportError(_THIS_MODULE,__LINE__,_COMPONENT); \
370                                            DebugPrintRaw PARAM_LIST(fp);}
371#define REPORT_WARNING(fp)              {_ReportWarning(_THIS_MODULE,__LINE__,_COMPONENT); \
372                                            DebugPrintRaw PARAM_LIST(fp);}
373
374#else
375
376#define REPORT_INFO(fp)                 {_ReportInfo("ACPI",__LINE__,_COMPONENT); \
377                                            DebugPrintRaw PARAM_LIST(fp);}
378#define REPORT_ERROR(fp)                {_ReportError("ACPI",__LINE__,_COMPONENT); \
379                                            DebugPrintRaw PARAM_LIST(fp);}
380#define REPORT_WARNING(fp)              {_ReportWarning("ACPI",__LINE__,_COMPONENT); \
381                                            DebugPrintRaw PARAM_LIST(fp);}
382
383#endif
384
385/* Error reporting.  These versions pass thru the module and line# */
386
387#define _REPORT_INFO(a,b,c,fp)          {_ReportInfo(a,b,c); \
388                                            DebugPrintRaw PARAM_LIST(fp);}
389#define _REPORT_ERROR(a,b,c,fp)         {_ReportError(a,b,c); \
390                                            DebugPrintRaw PARAM_LIST(fp);}
391#define _REPORT_WARNING(a,b,c,fp)       {_ReportWarning(a,b,c); \
392                                            DebugPrintRaw PARAM_LIST(fp);}
393
394/* Buffer dump macros */
395
396#define DUMP_BUFFER(a,b)                AcpiCmDumpBuffer((UINT8 *)a,b,DB_BYTE_DISPLAY,_COMPONENT)
397
398/*
399 * Debug macros that are conditionally compiled
400 */
401
402#ifdef ACPI_DEBUG
403
404#define MODULE_NAME(name)               static char *_THIS_MODULE = name;
405
406/*
407 * Function entry tracing.
408 * The first parameter should be the procedure name as a quoted string.  This is declared
409 * as a local string ("_ProcName) so that it can be also used by the function exit macros below.
410 */
411
412#define FUNCTION_TRACE(a)               char * _ProcName = a;\
413                                        FunctionTrace(_THIS_MODULE,__LINE__,_COMPONENT,a)
414#define FUNCTION_TRACE_PTR(a,b)         char * _ProcName = a;\
415                                        FunctionTracePtr(_THIS_MODULE,__LINE__,_COMPONENT,a,(void *)b)
416#define FUNCTION_TRACE_U32(a,b)         char * _ProcName = a;\
417                                        FunctionTraceU32(_THIS_MODULE,__LINE__,_COMPONENT,a,(UINT32)b)
418#define FUNCTION_TRACE_STR(a,b)         char * _ProcName = a;\
419                                        FunctionTraceStr(_THIS_MODULE,__LINE__,_COMPONENT,a,(NATIVE_CHAR *)b)
420/*
421 * Function exit tracing.
422 * WARNING: These macros include a return statement.  This is usually considered
423 * bad form, but having a separate exit macro is very ugly and difficult to maintain.
424 * One of the FUNCTION_TRACE macros above must be used in conjunction with these macros
425 * so that "_ProcName" is defined.
426 */
427#define return_VOID                     {FunctionExit(_THIS_MODULE,__LINE__,_COMPONENT,_ProcName);return;}
428#define return_ACPI_STATUS(s)           {FunctionStatusExit(_THIS_MODULE,__LINE__,_COMPONENT,_ProcName,s);return(s);}
429#define return_VALUE(s)                 {FunctionValueExit(_THIS_MODULE,__LINE__,_COMPONENT,_ProcName,(NATIVE_UINT)s);return(s);}
430#define return_PTR(s)                   {FunctionPtrExit(_THIS_MODULE,__LINE__,_COMPONENT,_ProcName,(UINT8 *)s);return(s);}
431
432
433/* Conditional execution */
434
435#define DEBUG_EXEC(a)                   a
436#define NORMAL_EXEC(a)
437
438#define DEBUG_DEFINE(a)                 a;
439#define DEBUG_ONLY_MEMBERS(a)           a;
440
441
442/* Stack and buffer dumping */
443
444#define DUMP_STACK_ENTRY(a)             AcpiAmlDumpOperand(a)
445#define DUMP_OPERANDS(a,b,c,d,e)        AcpiAmlDumpOperands(a,b,c,d,e,_THIS_MODULE,__LINE__)
446
447
448#define DUMP_ENTRY(a,b)                 AcpiNsDumpEntry (a,b)
449#define DUMP_TABLES(a,b)                AcpiNsDumpTables(a,b)
450#define DUMP_PATHNAME(a,b,c,d)          AcpiNsDumpPathname(a,b,c,d)
451#define DUMP_RESOURCE_LIST(a)           AcpiRsDumpResourceList(a)
452#define BREAK_MSG(a)                    AcpiOsBreakpoint (a)
453
454/*
455 * Generate INT3 on ACPI_ERROR (Debug only!)
456 */
457
458#define ERROR_BREAK
459#ifdef  ERROR_BREAK
460#define BREAK_ON_ERROR(lvl)             if ((lvl)&ACPI_ERROR) AcpiOsBreakpoint("Fatal error encountered\n")
461#else
462#define BREAK_ON_ERROR(lvl)
463#endif
464
465/*
466 * Master debug print macros
467 * Print iff:
468 *    1) Debug print for the current component is enabled
469 *    2) Debug error level or trace level for the print statement is enabled
470 *
471 */
472
473#define TEST_DEBUG_SWITCH(lvl)          if (((lvl) & AcpiDbgLevel) && (_COMPONENT & AcpiDbgLayer))
474
475#define DEBUG_PRINT(lvl,fp)             TEST_DEBUG_SWITCH(lvl) {\
476                                            DebugPrintPrefix (_THIS_MODULE,__LINE__);\
477                                            DebugPrintRaw PARAM_LIST(fp);\
478                                            BREAK_ON_ERROR(lvl);}
479
480#define DEBUG_PRINT_RAW(lvl,fp)         TEST_DEBUG_SWITCH(lvl) {\
481                                            DebugPrintRaw PARAM_LIST(fp);}
482
483
484/* Assert macros */
485
486#define ACPI_ASSERT(exp)                if(!(exp)) \
487                                            AcpiOsDbgAssert(#exp, __FILE__, __LINE__, "Failed Assertion")
488
489#define DEBUG_ASSERT(msg, exp)          if(!(exp)) \
490                                            AcpiOsDbgAssert(#exp, __FILE__, __LINE__, msg)
491
492
493#else
494/*
495 * This is the non-debug case -- make everything go away,
496 * leaving no executable debug code!
497 */
498
499#define MODULE_NAME(name)
500#define _THIS_MODULE ""
501
502#define DEBUG_EXEC(a)
503#define NORMAL_EXEC(a)                  a;
504
505#define DEBUG_DEFINE(a)
506#define DEBUG_ONLY_MEMBERS(a)
507#define FUNCTION_TRACE(a)
508#define FUNCTION_TRACE_PTR(a,b)
509#define FUNCTION_TRACE_U32(a,b)
510#define FUNCTION_TRACE_STR(a,b)
511#define FUNCTION_EXIT
512#define FUNCTION_STATUS_EXIT(s)
513#define FUNCTION_VALUE_EXIT(s)
514#define DUMP_STACK_ENTRY(a)
515#define DUMP_OPERANDS(a,b,c,d,e)
516#define DUMP_ENTRY(a,b)
517#define DUMP_TABLES(a,b)
518#define DUMP_PATHNAME(a,b,c,d)
519#define DUMP_RESOURCE_LIST(a)
520#define DEBUG_PRINT(l,f)
521#define DEBUG_PRINT_RAW(l,f)
522#define BREAK_MSG(a)
523
524#define return_VOID                     return
525#define return_ACPI_STATUS(s)           return(s)
526#define return_VALUE(s)                 return(s)
527#define return_PTR(s)                   return(s)
528
529#define ACPI_ASSERT(exp)
530#define DEBUG_ASSERT(msg, exp)
531
532#endif
533
534/*
535 * Some code only gets executed when the debugger is built in.
536 * Note that this is entirely independent of whether the
537 * DEBUG_PRINT stuff (set by ACPI_DEBUG) is on, or not.
538 */
539#ifdef ENABLE_DEBUGGER
540#define DEBUGGER_EXEC(a)                a
541#else
542#define DEBUGGER_EXEC(a)
543#endif
544
545
546/*
547 * For 16-bit code, we want to shrink some things even though
548 * we are using ACPI_DEBUG to get the debug output
549 */
550#ifdef _IA16
551#undef DEBUG_ONLY_MEMBERS
552#define DEBUG_ONLY_MEMBERS(a)
553#undef OP_INFO_ENTRY
554#define OP_INFO_ENTRY(Flags,Name,PArgs,IArgs)     {Flags,PArgs,IArgs}
555#endif
556
557
558#ifdef ACPI_DEBUG
559
560/*
561 * 1) Set name to blanks
562 * 2) Copy the object name
563 */
564
565#define ADD_OBJECT_NAME(a,b)            MEMSET (a->Common.Name, ' ', sizeof (a->Common.Name));\
566                                        STRNCPY (a->Common.Name, AcpiGbl_NsTypeNames[b], sizeof (a->Common.Name))
567
568#else
569
570#define ADD_OBJECT_NAME(a,b)
571
572#endif
573
574
575#endif /* ACMACROS_H */
576