acmacros.h revision 67754
1178825Sdfr/******************************************************************************
2178825Sdfr *
3178825Sdfr * Name: acmacros.h - C macros for the entire subsystem.
4178825Sdfr *       $Revision: 50 $
5178825Sdfr *
6178825Sdfr *****************************************************************************/
7178825Sdfr
8178825Sdfr/******************************************************************************
9178825Sdfr *
10178825Sdfr * 1. Copyright Notice
11178825Sdfr *
12178825Sdfr * Some or all of this work - Copyright (c) 1999, Intel Corp.  All rights
13178825Sdfr * reserved.
14178825Sdfr *
15178825Sdfr * 2. License
16178825Sdfr *
17178825Sdfr * 2.1. This is your license from Intel Corp. under its intellectual property
18178825Sdfr * rights.  You may have additional license terms from the party that provided
19178825Sdfr * you this software, covering your right to use that party's intellectual
20178825Sdfr * property rights.
21178825Sdfr *
22178825Sdfr * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23178825Sdfr * copy of the source code appearing in this file ("Covered Code") an
24178825Sdfr * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25178825Sdfr * base code distributed originally by Intel ("Original Intel Code") to copy,
26178825Sdfr * make derivatives, distribute, use and display any portion of the Covered
27178825Sdfr * Code in any form, with the right to sublicense such rights; and
28178825Sdfr *
29178825Sdfr * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30178825Sdfr * license (with the right to sublicense), under only those claims of Intel
31178825Sdfr * patents that are infringed by the Original Intel Code, to make, use, sell,
32178825Sdfr * offer to sell, and import the Covered Code and derivative works thereof
33178825Sdfr * solely to the minimum extent necessary to exercise the above copyright
34178825Sdfr * license, and in no event shall the patent license extend to any additions
35178825Sdfr * to or modifications of the Original Intel Code.  No other license or right
36178825Sdfr * is granted directly or by implication, estoppel or otherwise;
37178825Sdfr *
38178825Sdfr * The above copyright and patent license is granted only if the following
39178825Sdfr * conditions are met:
40178825Sdfr *
41178825Sdfr * 3. Conditions
42178825Sdfr *
43178825Sdfr * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44178825Sdfr * Redistribution of source code of any substantial portion of the Covered
45178825Sdfr * Code or modification with rights to further distribute source must include
46178825Sdfr * the above Copyright Notice, the above License, this list of Conditions,
47178825Sdfr * and the following Disclaimer and Export Compliance provision.  In addition,
48178825Sdfr * Licensee must cause all Covered Code to which Licensee contributes to
49178825Sdfr * contain a file documenting the changes Licensee made to create that Covered
50178825Sdfr * Code and the date of any change.  Licensee must include in that file the
51178825Sdfr * documentation of any changes made by any predecessor Licensee.  Licensee
52178825Sdfr * must include a prominent statement that the modification is derived,
53178825Sdfr * directly or indirectly, from Original Intel Code.
54178825Sdfr *
55178825Sdfr * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56178825Sdfr * Redistribution of source code of any substantial portion of the Covered
57178825Sdfr * Code or modification without rights to further distribute source must
58178825Sdfr * include the following Disclaimer and Export Compliance provision in the
59178825Sdfr * documentation and/or other materials provided with distribution.  In
60178825Sdfr * addition, Licensee may not authorize further sublicense of source of any
61178825Sdfr * portion of the Covered Code, and must include terms to the effect that the
62178825Sdfr * license from Licensee to its licensee is limited to the intellectual
63178825Sdfr * property embodied in the software Licensee provides to its licensee, and
64178825Sdfr * not to intellectual property embodied in modifications its licensee may
65178825Sdfr * make.
66178825Sdfr *
67178825Sdfr * 3.3. Redistribution of Executable. Redistribution in executable form of any
68178825Sdfr * substantial portion of the Covered Code or modification must reproduce the
69178825Sdfr * above Copyright Notice, and the following Disclaimer and Export Compliance
70178825Sdfr * provision in the documentation and/or other materials provided with the
71178825Sdfr * distribution.
72178825Sdfr *
73178825Sdfr * 3.4. Intel retains all right, title, and interest in and to the Original
74178825Sdfr * Intel Code.
75178825Sdfr *
76178825Sdfr * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77178825Sdfr * Intel shall be used in advertising or otherwise to promote the sale, use or
78178825Sdfr * other dealings in products derived from or relating to the Covered Code
79178825Sdfr * without prior written authorization from Intel.
80178825Sdfr *
81178825Sdfr * 4. Disclaimer and Export Compliance
82178825Sdfr *
83178825Sdfr * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84178825Sdfr * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85178825Sdfr * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
86178825Sdfr * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
87178825Sdfr * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
88178825Sdfr * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
89178825Sdfr * PARTICULAR PURPOSE.
90178825Sdfr *
91178825Sdfr * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92178825Sdfr * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93178825Sdfr * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94178825Sdfr * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95178825Sdfr * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96178825Sdfr * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
97178825Sdfr * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
98178825Sdfr * LIMITED REMEDY.
99178825Sdfr *
100178825Sdfr * 4.3. Licensee shall not export, either directly or indirectly, any of this
101178825Sdfr * software or system incorporating such software without first obtaining any
102178825Sdfr * required license or other approval from the U. S. Department of Commerce or
103178825Sdfr * any other agency or department of the United States Government.  In the
104178825Sdfr * event Licensee exports any such software from the United States or
105178825Sdfr * re-exports any such software from a foreign destination, Licensee shall
106178825Sdfr * ensure that the distribution and export/re-export of the software is in
107178825Sdfr * compliance with all laws, regulations, orders, or other restrictions of the
108178825Sdfr * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109178825Sdfr * any of its subsidiaries will export/re-export any technical data, process,
110178825Sdfr * software, or service, directly or indirectly, to any country for which the
111178825Sdfr * United States government or any agency thereof requires an export license,
112178825Sdfr * other governmental approval, or letter of assurance, without first obtaining
113178825Sdfr * such license, approval or letter.
114178825Sdfr *
115178825Sdfr *****************************************************************************/
116178825Sdfr
117178825Sdfr#ifndef __ACMACROS_H__
118178825Sdfr#define __ACMACROS_H__
119178825Sdfr
120178825Sdfr/*
121178825Sdfr * Data manipulation macros
122178825Sdfr */
123178825Sdfr
124178825Sdfr#ifndef LOWORD
125178825Sdfr#define LOWORD(l)                       ((UINT16)(NATIVE_UINT)(l))
126178825Sdfr#endif
127178825Sdfr
128178825Sdfr#ifndef HIWORD
129178825Sdfr#define HIWORD(l)                       ((UINT16)((((NATIVE_UINT)(l)) >> 16) & 0xFFFF))
130178825Sdfr#endif
131178825Sdfr
132178825Sdfr#ifndef LOBYTE
133178825Sdfr#define LOBYTE(l)                       ((UINT8)(UINT16)(l))
134178825Sdfr#endif
135178825Sdfr
136178825Sdfr#ifndef HIBYTE
137178825Sdfr#define HIBYTE(l)                       ((UINT8)((((UINT16)(l)) >> 8) & 0xFF))
138178825Sdfr#endif
139178825Sdfr
140178825Sdfr#define BIT0(x)                         ((((x) & 0x01) > 0) ? 1 : 0)
141178825Sdfr#define BIT1(x)                         ((((x) & 0x02) > 0) ? 1 : 0)
142178825Sdfr#define BIT2(x)                         ((((x) & 0x04) > 0) ? 1 : 0)
143178825Sdfr
144178825Sdfr#define BIT3(x)                         ((((x) & 0x08) > 0) ? 1 : 0)
145178825Sdfr#define BIT4(x)                         ((((x) & 0x10) > 0) ? 1 : 0)
146178825Sdfr#define BIT5(x)                         ((((x) & 0x20) > 0) ? 1 : 0)
147178825Sdfr#define BIT6(x)                         ((((x) & 0x40) > 0) ? 1 : 0)
148178825Sdfr#define BIT7(x)                         ((((x) & 0x80) > 0) ? 1 : 0)
149178825Sdfr
150178825Sdfr#define LOW_BASE(w)                     ((UINT16) ((w) & 0x0000FFFF))
151178825Sdfr#define MID_BASE(b)                     ((UINT8) (((b) & 0x00FF0000) >> 16))
152178825Sdfr#define HI_BASE(b)                      ((UINT8) (((b) & 0xFF000000) >> 24))
153178825Sdfr#define LOW_LIMIT(w)                    ((UINT16) ((w) & 0x0000FFFF))
154178825Sdfr#define HI_LIMIT(b)                     ((UINT8) (((b) & 0x00FF0000) >> 16))
155178825Sdfr
156178825Sdfr
157178825Sdfr /*
158178825Sdfr  * Extract a byte of data using a pointer.  Any more than a byte and we
159178825Sdfr  * get into potential aligment issues -- see the STORE macros below
160178825Sdfr  */
161178825Sdfr#define GET8(addr)                      (*(UINT8*)(addr))
162178825Sdfr
163178825Sdfr
164178825Sdfr/*
165178825Sdfr * Macros for moving data around to/from buffers that are possibly unaligned.
166178825Sdfr * If the hardware supports the transfer of unaligned data, just do the store.
167178825Sdfr * Otherwise, we have to move one byte at a time.
168178825Sdfr */
169178825Sdfr
170178825Sdfr#ifdef _HW_ALIGNMENT_SUPPORT
171178825Sdfr
172178825Sdfr/* The hardware supports unaligned transfers, just do the move */
173178825Sdfr
174178825Sdfr#define MOVE_UNALIGNED16_TO_16(d,s)     *(UINT16*)(d) = *(UINT16*)(s)
175178825Sdfr#define MOVE_UNALIGNED32_TO_32(d,s)     *(UINT32*)(d) = *(UINT32*)(s)
176178825Sdfr#define MOVE_UNALIGNED16_TO_32(d,s)     *(UINT32*)(d) = *(UINT16*)(s)
177178825Sdfr
178178825Sdfr#else
179178825Sdfr/*
180 * The hardware does not support unaligned transfers.  We must move the
181 * data one byte at a time.  These macros work whether the source or
182 * the destination (or both) is/are unaligned.
183 */
184
185#define MOVE_UNALIGNED16_TO_16(d,s)     {((UINT8 *)(d))[0] = ((UINT8 *)(s))[0];\
186                                         ((UINT8 *)(d))[1] = ((UINT8 *)(s))[1];}
187
188#define MOVE_UNALIGNED32_TO_32(d,s)     {((UINT8 *)(d))[0] = ((UINT8 *)(s))[0];\
189                                         ((UINT8 *)(d))[1] = ((UINT8 *)(s))[1];\
190                                         ((UINT8 *)(d))[2] = ((UINT8 *)(s))[2];\
191                                         ((UINT8 *)(d))[3] = ((UINT8 *)(s))[3];}
192
193#define MOVE_UNALIGNED16_TO_32(d,s)     {(*(UINT32*)(d)) = 0; MOVE_UNALIGNED16_TO_16(d,s);}
194
195#endif
196
197
198/*
199 * Fast power-of-two math macros for non-optimized compilers
200 */
201
202#define _DIV(value,PowerOf2)            ((UINT32) ((value) >> (PowerOf2)))
203#define _MUL(value,PowerOf2)            ((UINT32) ((value) << (PowerOf2)))
204#define _MOD(value,Divisor)             ((UINT32) ((value) & ((Divisor) -1)))
205
206#define DIV_2(a)                        _DIV(a,1)
207#define MUL_2(a)                        _MUL(a,1)
208#define MOD_2(a)                        _MOD(a,2)
209
210#define DIV_4(a)                        _DIV(a,2)
211#define MUL_4(a)                        _MUL(a,2)
212#define MOD_4(a)                        _MOD(a,4)
213
214#define DIV_8(a)                        _DIV(a,3)
215#define MUL_8(a)                        _MUL(a,3)
216#define MOD_8(a)                        _MOD(a,8)
217
218#define DIV_16(a)                       _DIV(a,4)
219#define MUL_16(a)                       _MUL(a,4)
220#define MOD_16(a)                       _MOD(a,16)
221
222
223/*
224 * Rounding macros (Power of two boundaries only)
225 */
226
227#define ROUND_DOWN(value,boundary)      ((value) & (~((boundary)-1)))
228#define ROUND_UP(value,boundary)        (((value) + ((boundary)-1)) & (~((boundary)-1)))
229
230#define ROUND_DOWN_TO_32_BITS(a)        ROUND_DOWN(a,4)
231#define ROUND_DOWN_TO_NATIVE_WORD(a)    ROUND_DOWN(a,ALIGNED_ADDRESS_BOUNDARY)
232
233#define ROUND_UP_TO_32BITS(a)           ROUND_UP(a,4)
234#define ROUND_UP_TO_NATIVE_WORD(a)      ROUND_UP(a,ALIGNED_ADDRESS_BOUNDARY)
235
236#define ROUND_PTR_UP_TO_4(a,b)          ((b *)(((NATIVE_UINT)(a) + 3) & ~3))
237
238#ifdef DEBUG_ASSERT
239#undef DEBUG_ASSERT
240#endif
241
242
243/*
244 * An ACPI_HANDLE (which is actually an ACPI_NAMESPACE_NODE *) can appear in some contexts,
245 * such as on apObjStack, where a pointer to an ACPI_OPERAND_OBJECT  can also
246 * appear.  This macro is used to distinguish them.
247 *
248 * The DataType field is the first field in both structures.
249 */
250
251#define VALID_DESCRIPTOR_TYPE(d,t)      (((ACPI_NAMESPACE_NODE *)d)->DataType == t)
252
253
254/* Macro to test the object type */
255
256#define IS_THIS_OBJECT_TYPE(d,t)        (((ACPI_OPERAND_OBJECT  *)d)->Common.Type == (UINT8)t)
257
258/* Macro to check the table flags for SINGLE or MULTIPLE tables are allowed */
259
260#define IS_SINGLE_TABLE(x)              (((x) & 0x01) == ACPI_TABLE_SINGLE ? 1 : 0)
261
262/*
263 * Macro to check if a pointer is within an ACPI table.
264 * Parameter (a) is the pointer to check.  Parameter (b) must be defined
265 * as a pointer to an ACPI_TABLE_HEADER.  (b+1) then points past the header,
266 * and ((UINT8 *)b+b->Length) points one byte past the end of the table.
267 */
268
269#ifndef _IA16
270#define IS_IN_ACPI_TABLE(a,b)           (((UINT8 *)(a) >= (UINT8 *)(b + 1)) &&\
271                                        ((UINT8 *)(a) < ((UINT8 *)b + b->Length)))
272
273#else
274#define IS_IN_ACPI_TABLE(a,b)           (_segment)(a) == (_segment)(b) &&\
275                                        (((UINT8 *)(a) >= (UINT8 *)(b + 1)) &&\
276                                        ((UINT8 *)(a) < ((UINT8 *)b + b->Length)))
277#endif
278
279/*
280 * Macros for the master AML opcode table
281 */
282
283#ifdef ACPI_DEBUG
284#define OP_INFO_ENTRY(Flags,Name,PArgs,IArgs)     {Flags,PArgs,IArgs,Name}
285#else
286#define OP_INFO_ENTRY(Flags,Name,PArgs,IArgs)     {Flags,PArgs,IArgs}
287#endif
288
289#define ARG_TYPE_WIDTH                  5
290#define ARG_1(x)                        ((UINT32)(x))
291#define ARG_2(x)                        ((UINT32)(x) << (1 * ARG_TYPE_WIDTH))
292#define ARG_3(x)                        ((UINT32)(x) << (2 * ARG_TYPE_WIDTH))
293#define ARG_4(x)                        ((UINT32)(x) << (3 * ARG_TYPE_WIDTH))
294#define ARG_5(x)                        ((UINT32)(x) << (4 * ARG_TYPE_WIDTH))
295#define ARG_6(x)                        ((UINT32)(x) << (5 * ARG_TYPE_WIDTH))
296
297#define ARGI_LIST1(a)                   (ARG_1(a))
298#define ARGI_LIST2(a,b)                 (ARG_1(b)|ARG_2(a))
299#define ARGI_LIST3(a,b,c)               (ARG_1(c)|ARG_2(b)|ARG_3(a))
300#define ARGI_LIST4(a,b,c,d)             (ARG_1(d)|ARG_2(c)|ARG_3(b)|ARG_4(a))
301#define ARGI_LIST5(a,b,c,d,e)           (ARG_1(e)|ARG_2(d)|ARG_3(c)|ARG_4(b)|ARG_5(a))
302#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))
303
304#define ARGP_LIST1(a)                   (ARG_1(a))
305#define ARGP_LIST2(a,b)                 (ARG_1(a)|ARG_2(b))
306#define ARGP_LIST3(a,b,c)               (ARG_1(a)|ARG_2(b)|ARG_3(c))
307#define ARGP_LIST4(a,b,c,d)             (ARG_1(a)|ARG_2(b)|ARG_3(c)|ARG_4(d))
308#define ARGP_LIST5(a,b,c,d,e)           (ARG_1(a)|ARG_2(b)|ARG_3(c)|ARG_4(d)|ARG_5(e))
309#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))
310
311#define GET_CURRENT_ARG_TYPE(List)      (List & ((UINT32) 0x1F))
312#define INCREMENT_ARG_LIST(List)        (List >>= ((UINT32) ARG_TYPE_WIDTH))
313
314
315/*
316 * Reporting macros that are never compiled out
317 */
318
319#define PARAM_LIST(pl)                  pl
320
321/*
322 * Error reporting.  These versions add callers module and line#.  Since
323 * _THIS_MODULE gets compiled out when ACPI_DEBUG isn't defined, only
324 * use it in debug mode.
325 */
326
327#ifdef ACPI_DEBUG
328
329#define REPORT_INFO(fp)                 {_ReportInfo(_THIS_MODULE,__LINE__,_COMPONENT); \
330                                            DebugPrintRaw PARAM_LIST(fp);}
331#define REPORT_ERROR(fp)                {_ReportError(_THIS_MODULE,__LINE__,_COMPONENT); \
332                                            DebugPrintRaw PARAM_LIST(fp);}
333#define REPORT_WARNING(fp)              {_ReportWarning(_THIS_MODULE,__LINE__,_COMPONENT); \
334                                            DebugPrintRaw PARAM_LIST(fp);}
335
336#else
337
338#define REPORT_INFO(fp)                 {_ReportInfo("",__LINE__,_COMPONENT); \
339                                            DebugPrintRaw PARAM_LIST(fp);}
340#define REPORT_ERROR(fp)                {_ReportError("",__LINE__,_COMPONENT); \
341                                            DebugPrintRaw PARAM_LIST(fp);}
342#define REPORT_WARNING(fp)              {_ReportWarning("",__LINE__,_COMPONENT); \
343                                            DebugPrintRaw PARAM_LIST(fp);}
344
345#endif
346
347/* Error reporting.  These versions pass thru the module and line# */
348
349#define _REPORT_INFO(a,b,c,fp)          {_ReportInfo(a,b,c); \
350                                            DebugPrintRaw PARAM_LIST(fp);}
351#define _REPORT_ERROR(a,b,c,fp)         {_ReportError(a,b,c); \
352                                            DebugPrintRaw PARAM_LIST(fp);}
353#define _REPORT_WARNING(a,b,c,fp)       {_ReportWarning(a,b,c); \
354                                            DebugPrintRaw PARAM_LIST(fp);}
355
356/* Buffer dump macros */
357
358#define DUMP_BUFFER(a,b)                AcpiCmDumpBuffer((UINT8 *)a,b,DB_BYTE_DISPLAY,_COMPONENT)
359
360/*
361 * Debug macros that are conditionally compiled
362 */
363
364#ifdef ACPI_DEBUG
365
366#define MODULE_NAME(name)               static char *_THIS_MODULE = name;
367
368/*
369 * Function entry tracing.
370 * The first parameter should be the procedure name as a quoted string.  This is declared
371 * as a local string ("_ProcName) so that it can be also used by the function exit macros below.
372 */
373
374#define FUNCTION_TRACE(a)               char * _ProcName = a;\
375                                        FunctionTrace(_THIS_MODULE,__LINE__,_COMPONENT,a)
376#define FUNCTION_TRACE_PTR(a,b)         char * _ProcName = a;\
377                                        FunctionTracePtr(_THIS_MODULE,__LINE__,_COMPONENT,a,(void *)b)
378#define FUNCTION_TRACE_U32(a,b)         char * _ProcName = a;\
379                                        FunctionTraceU32(_THIS_MODULE,__LINE__,_COMPONENT,a,(UINT32)b)
380#define FUNCTION_TRACE_STR(a,b)         char * _ProcName = a;\
381                                        FunctionTraceStr(_THIS_MODULE,__LINE__,_COMPONENT,a,(NATIVE_CHAR *)b)
382/*
383 * Function exit tracing.
384 * WARNING: These macros include a return statement.  This is usually considered
385 * bad form, but having a separate exit macro is very ugly and difficult to maintain.
386 * One of the FUNCTION_TRACE macros above must be used in conjunction with these macros
387 * so that "_ProcName" is defined.
388 */
389#define return_VOID                     {FunctionExit(_THIS_MODULE,__LINE__,_COMPONENT,_ProcName);return;}
390#define return_ACPI_STATUS(s)           {FunctionStatusExit(_THIS_MODULE,__LINE__,_COMPONENT,_ProcName,s);return(s);}
391#define return_VALUE(s)                 {FunctionValueExit(_THIS_MODULE,__LINE__,_COMPONENT,_ProcName,(NATIVE_UINT)s);return(s);}
392#define return_PTR(s)                   {FunctionPtrExit(_THIS_MODULE,__LINE__,_COMPONENT,_ProcName,(UINT8 *)s);return(s);}
393
394
395/* Conditional execution */
396
397#define DEBUG_EXEC(a)                   a;
398#define NORMAL_EXEC(a)
399
400#define DEBUG_DEFINE(a)                 a;
401#define DEBUG_ONLY_MEMBERS(a)           a;
402
403
404/* Stack and buffer dumping */
405
406#define DUMP_STACK_ENTRY(a)             AcpiAmlDumpOperand(a)
407#define DUMP_OPERANDS(a,b,c,d,e)        AcpiAmlDumpOperands(a,b,c,d,e,_THIS_MODULE,__LINE__)
408
409
410#define DUMP_ENTRY(a,b)                 AcpiNsDumpEntry (a,b)
411#define DUMP_TABLES(a,b)                AcpiNsDumpTables(a,b)
412#define DUMP_PATHNAME(a,b,c,d)          AcpiNsDumpPathname(a,b,c,d)
413#define DUMP_RESOURCE_LIST(a)           AcpiRsDumpResourceList(a)
414#define BREAK_MSG(a)                    AcpiOsBreakpoint (a)
415
416/*
417 * Generate INT3 on ACPI_ERROR (Debug only!)
418 */
419
420#define ERROR_BREAK
421#ifdef  ERROR_BREAK
422#define BREAK_ON_ERROR(lvl)             if ((lvl)&ACPI_ERROR) AcpiOsBreakpoint("Fatal error encountered\n")
423#else
424#define BREAK_ON_ERROR(lvl)
425#endif
426
427/*
428 * Master debug print macros
429 * Print iff:
430 *    1) Debug print for the current component is enabled
431 *    2) Debug error level or trace level for the print statement is enabled
432 *
433 */
434
435#define TEST_DEBUG_SWITCH(lvl)          if (((lvl) & AcpiDbgLevel) && (_COMPONENT & AcpiDbgLayer))
436
437#define DEBUG_PRINT(lvl,fp)             TEST_DEBUG_SWITCH(lvl) {\
438                                            DebugPrintPrefix (_THIS_MODULE,__LINE__);\
439                                            DebugPrintRaw PARAM_LIST(fp);\
440                                            BREAK_ON_ERROR(lvl);}
441
442#define DEBUG_PRINT_RAW(lvl,fp)         TEST_DEBUG_SWITCH(lvl) {\
443                                            DebugPrintRaw PARAM_LIST(fp);}
444
445
446/* Assert macros */
447
448#define ACPI_ASSERT(exp)                if(!(exp)) \
449                                            AcpiOsDbgAssert(#exp, __FILE__, __LINE__, "Failed Assertion")
450
451#define DEBUG_ASSERT(msg, exp)          if(!(exp)) \
452                                            AcpiOsDbgAssert(#exp, __FILE__, __LINE__, msg)
453
454
455#else
456/*
457 * This is the non-debug case -- make everything go away,
458 * leaving no executable debug code!
459 */
460
461#define MODULE_NAME(name)
462#define _THIS_MODULE ""
463
464#define DEBUG_EXEC(a)
465#define NORMAL_EXEC(a)                  a;
466
467#define DEBUG_DEFINE(a)
468#define DEBUG_ONLY_MEMBERS(a)
469#define FUNCTION_TRACE(a)
470#define FUNCTION_TRACE_PTR(a,b)
471#define FUNCTION_TRACE_U32(a,b)
472#define FUNCTION_TRACE_STR(a,b)
473#define FUNCTION_EXIT
474#define FUNCTION_STATUS_EXIT(s)
475#define FUNCTION_VALUE_EXIT(s)
476#define DUMP_STACK_ENTRY(a)
477#define DUMP_OPERANDS(a,b,c,d,e)
478#define DUMP_ENTRY(a,b)
479#define DUMP_TABLES(a,b)
480#define DUMP_PATHNAME(a,b,c,d)
481#define DUMP_RESOURCE_LIST(a)
482#define DEBUG_PRINT(l,f)
483#define DEBUG_PRINT_RAW(l,f)
484#define BREAK_MSG(a)
485
486#define return_VOID                     return
487#define return_ACPI_STATUS(s)           return(s)
488#define return_VALUE(s)                 return(s)
489#define return_PTR(s)                   return(s)
490
491#define ACPI_ASSERT(exp)
492#define DEBUG_ASSERT(msg, exp)
493
494#endif
495
496/*
497 * Some code only gets executed when the debugger is built in.
498 * Note that this is entirely independent of whether the
499 * DEBUG_PRINT stuff (set by ACPI_DEBUG) is on, or not.
500 */
501#ifdef ENABLE_DEBUGGER
502#define DEBUGGER_EXEC(a)                a;
503#else
504#define DEBUGGER_EXEC(a)
505#endif
506
507
508/*
509 * For 16-bit code, we want to shrink some things even though
510 * we are using ACPI_DEBUG to get the debug output
511 */
512#ifdef _IA16
513#undef DEBUG_ONLY_MEMBERS
514#define DEBUG_ONLY_MEMBERS(a)
515#undef OP_INFO_ENTRY
516#define OP_INFO_ENTRY(Flags,Name,PArgs,IArgs)     {Flags,PArgs,IArgs}
517#endif
518
519
520#ifdef ACPI_DEBUG
521
522/*
523 * 1) Set name to blanks
524 * 2) Copy the object name
525 */
526
527#define ADD_OBJECT_NAME(a,b)            MEMSET (a->Common.Name, ' ', sizeof (a->Common.Name));\
528                                        STRNCPY (a->Common.Name, AcpiGbl_NsTypeNames[b], sizeof (a->Common.Name))
529
530#else
531
532#define ADD_OBJECT_NAME(a,b)
533
534#endif
535
536#endif /* ACMACROS_H */
537