acmacros.h revision 69450
1189251Ssam/****************************************************************************** 2189251Ssam * 3189251Ssam * Name: acmacros.h - C macros for the entire subsystem. 4189251Ssam * $Revision: 56 $ 5252726Srpaulo * 6252726Srpaulo *****************************************************************************/ 7189251Ssam 8189251Ssam/****************************************************************************** 9189251Ssam * 10189251Ssam * 1. Copyright Notice 11189251Ssam * 12252726Srpaulo * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights 13252726Srpaulo * reserved. 14252726Srpaulo * 15252726Srpaulo * 2. License 16252726Srpaulo * 17252726Srpaulo * 2.1. This is your license from Intel Corp. under its intellectual property 18252726Srpaulo * rights. You may have additional license terms from the party that provided 19252726Srpaulo * you this software, covering your right to use that party's intellectual 20252726Srpaulo * property rights. 21252726Srpaulo * 22252726Srpaulo * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 23189251Ssam * copy of the source code appearing in this file ("Covered Code") an 24252726Srpaulo * irrevocable, perpetual, worldwide license under Intel's copyrights in the 25189251Ssam * base code distributed originally by Intel ("Original Intel Code") to copy, 26252726Srpaulo * make derivatives, distribute, use and display any portion of the Covered 27252726Srpaulo * Code in any form, with the right to sublicense such rights; and 28189251Ssam * 29189251Ssam * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 30189251Ssam * license (with the right to sublicense), under only those claims of Intel 31189251Ssam * patents that are infringed by the Original Intel Code, to make, use, sell, 32189251Ssam * offer to sell, and import the Covered Code and derivative works thereof 33189251Ssam * solely to the minimum extent necessary to exercise the above copyright 34189251Ssam * license, and in no event shall the patent license extend to any additions 35189251Ssam * to or modifications of the Original Intel Code. No other license or right 36189251Ssam * is granted directly or by implication, estoppel or otherwise; 37189251Ssam * 38189251Ssam * The above copyright and patent license is granted only if the following 39189251Ssam * conditions are met: 40189251Ssam * 41189251Ssam * 3. Conditions 42189251Ssam * 43189251Ssam * 3.1. Redistribution of Source with Rights to Further Distribute Source. 44252726Srpaulo * Redistribution of source code of any substantial portion of the Covered 45214734Srpaulo * Code or modification with rights to further distribute source must include 46214734Srpaulo * the above Copyright Notice, the above License, this list of Conditions, 47189251Ssam * and the following Disclaimer and Export Compliance provision. In addition, 48189251Ssam * Licensee must cause all Covered Code to which Licensee contributes to 49189251Ssam * contain a file documenting the changes Licensee made to create that Covered 50189251Ssam * Code and the date of any change. Licensee must include in that file the 51189251Ssam * documentation of any changes made by any predecessor Licensee. Licensee 52189251Ssam * must include a prominent statement that the modification is derived, 53189251Ssam * directly or indirectly, from Original Intel Code. 54189251Ssam * 55189251Ssam * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 56189251Ssam * Redistribution of source code of any substantial portion of the Covered 57189251Ssam * Code or modification without rights to further distribute source must 58189251Ssam * include the following Disclaimer and Export Compliance provision in the 59189251Ssam * documentation and/or other materials provided with distribution. In 60189251Ssam * addition, Licensee may not authorize further sublicense of source of any 61189251Ssam * portion of the Covered Code, and must include terms to the effect that the 62189251Ssam * license from Licensee to its licensee is limited to the intellectual 63189251Ssam * property embodied in the software Licensee provides to its licensee, and 64189251Ssam * not to intellectual property embodied in modifications its licensee may 65189251Ssam * make. 66189251Ssam * 67189251Ssam * 3.3. Redistribution of Executable. Redistribution in executable form of any 68189251Ssam * substantial portion of the Covered Code or modification must reproduce the 69189251Ssam * above Copyright Notice, and the following Disclaimer and Export Compliance 70189251Ssam * provision in the documentation and/or other materials provided with the 71189251Ssam * distribution. 72189251Ssam * 73189251Ssam * 3.4. Intel retains all right, title, and interest in and to the Original 74189251Ssam * Intel Code. 75189251Ssam * 76189251Ssam * 3.5. Neither the name Intel nor any other trademark owned or controlled by 77189251Ssam * Intel shall be used in advertising or otherwise to promote the sale, use or 78189251Ssam * other dealings in products derived from or relating to the Covered Code 79189251Ssam * without prior written authorization from Intel. 80189251Ssam * 81189251Ssam * 4. Disclaimer and Export Compliance 82189251Ssam * 83189251Ssam * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 84189251Ssam * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 85189251Ssam * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 86189251Ssam * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 87189251Ssam * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 88189251Ssam * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 89189251Ssam * PARTICULAR PURPOSE. 90189251Ssam * 91189251Ssam * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 92189251Ssam * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 93189251Ssam * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 94189251Ssam * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 95189251Ssam * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 96189251Ssam * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 97189251Ssam * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 98189251Ssam * LIMITED REMEDY. 99189251Ssam * 100189251Ssam * 4.3. Licensee shall not export, either directly or indirectly, any of this 101189251Ssam * software or system incorporating such software without first obtaining any 102189251Ssam * required license or other approval from the U. S. Department of Commerce or 103189251Ssam * any other agency or department of the United States Government. In the 104189251Ssam * event Licensee exports any such software from the United States or 105189251Ssam * re-exports any such software from a foreign destination, Licensee shall 106189251Ssam * ensure that the distribution and export/re-export of the software is in 107189251Ssam * compliance with all laws, regulations, orders, or other restrictions of the 108189251Ssam * U.S. Export Administration Regulations. Licensee agrees that neither it nor 109189251Ssam * any of its subsidiaries will export/re-export any technical data, process, 110189251Ssam * software, or service, directly or indirectly, to any country for which the 111189251Ssam * United States government or any agency thereof requires an export license, 112189251Ssam * other governmental approval, or letter of assurance, without first obtaining 113189251Ssam * such license, approval or letter. 114189251Ssam * 115189251Ssam *****************************************************************************/ 116189251Ssam 117189251Ssam#ifndef __ACMACROS_H__ 118189251Ssam#define __ACMACROS_H__ 119189251Ssam 120189251Ssam/* 121189251Ssam * Data manipulation macros 122189251Ssam */ 123189251Ssam 124189251Ssam#ifndef LOWORD 125189251Ssam#define LOWORD(l) ((UINT16)(NATIVE_UINT)(l)) 126214734Srpaulo#endif 127189251Ssam 128189251Ssam#ifndef HIWORD 129189251Ssam#define HIWORD(l) ((UINT16)((((NATIVE_UINT)(l)) >> 16) & 0xFFFF)) 130189251Ssam#endif 131189251Ssam 132189251Ssam#ifndef LOBYTE 133189251Ssam#define LOBYTE(l) ((UINT8)(UINT16)(l)) 134189251Ssam#endif 135252726Srpaulo 136252726Srpaulo#ifndef HIBYTE 137252726Srpaulo#define HIBYTE(l) ((UINT8)((((UINT16)(l)) >> 8) & 0xFF)) 138189251Ssam#endif 139189251Ssam 140252726Srpaulo#define BIT0(x) ((((x) & 0x01) > 0) ? 1 : 0) 141252726Srpaulo#define BIT1(x) ((((x) & 0x02) > 0) ? 1 : 0) 142252726Srpaulo#define BIT2(x) ((((x) & 0x04) > 0) ? 1 : 0) 143252726Srpaulo 144252726Srpaulo#define BIT3(x) ((((x) & 0x08) > 0) ? 1 : 0) 145252726Srpaulo#define BIT4(x) ((((x) & 0x10) > 0) ? 1 : 0) 146252726Srpaulo#define BIT5(x) ((((x) & 0x20) > 0) ? 1 : 0) 147252726Srpaulo#define BIT6(x) ((((x) & 0x40) > 0) ? 1 : 0) 148252726Srpaulo#define BIT7(x) ((((x) & 0x80) > 0) ? 1 : 0) 149252726Srpaulo 150252726Srpaulo#define LOW_BASE(w) ((UINT16) ((w) & 0x0000FFFF)) 151189251Ssam#define MID_BASE(b) ((UINT8) (((b) & 0x00FF0000) >> 16)) 152189251Ssam#define HI_BASE(b) ((UINT8) (((b) & 0xFF000000) >> 24)) 153189251Ssam#define LOW_LIMIT(w) ((UINT16) ((w) & 0x0000FFFF)) 154189251Ssam#define HI_LIMIT(b) ((UINT8) (((b) & 0x00FF0000) >> 16)) 155189251Ssam 156189251Ssam 157189251Ssam /* 158189251Ssam * Extract a byte of data using a pointer. Any more than a byte and we 159189251Ssam * get into potential aligment issues -- see the STORE macros below 160189251Ssam */ 161189251Ssam#define GET8(addr) (*(UINT8*)(addr)) 162189251Ssam 163189251Ssam 164189251Ssam/* 165189251Ssam * Macros for moving data around to/from buffers that are possibly unaligned. 166189251Ssam * If the hardware supports the transfer of unaligned data, just do the store. 167189251Ssam * Otherwise, we have to move one byte at a time. 168189251Ssam */ 169189251Ssam 170189251Ssam#ifdef _HW_ALIGNMENT_SUPPORT 171189251Ssam 172189251Ssam/* The hardware supports unaligned transfers, just do the move */ 173189251Ssam 174189251Ssam#define MOVE_UNALIGNED16_TO_16(d,s) *(UINT16*)(d) = *(UINT16*)(s) 175189251Ssam#define MOVE_UNALIGNED32_TO_32(d,s) *(UINT32*)(d) = *(UINT32*)(s) 176189251Ssam#define MOVE_UNALIGNED16_TO_32(d,s) *(UINT32*)(d) = *(UINT16*)(s) 177189251Ssam 178189251Ssam#else 179189251Ssam/* 180189251Ssam * The hardware does not support unaligned transfers. We must move the 181189251Ssam * data one byte at a time. These macros work whether the source or 182189251Ssam * the destination (or both) is/are unaligned. 183189251Ssam */ 184189251Ssam 185189251Ssam#define MOVE_UNALIGNED16_TO_16(d,s) {((UINT8 *)(d))[0] = ((UINT8 *)(s))[0];\ 186189251Ssam ((UINT8 *)(d))[1] = ((UINT8 *)(s))[1];} 187189251Ssam 188189251Ssam#define MOVE_UNALIGNED32_TO_32(d,s) {((UINT8 *)(d))[0] = ((UINT8 *)(s))[0];\ 189189251Ssam ((UINT8 *)(d))[1] = ((UINT8 *)(s))[1];\ 190189251Ssam ((UINT8 *)(d))[2] = ((UINT8 *)(s))[2];\ 191189251Ssam ((UINT8 *)(d))[3] = ((UINT8 *)(s))[3];} 192189251Ssam 193189251Ssam#define MOVE_UNALIGNED16_TO_32(d,s) {(*(UINT32*)(d)) = 0; MOVE_UNALIGNED16_TO_16(d,s);} 194189251Ssam 195189251Ssam#endif 196189251Ssam 197189251Ssam 198189251Ssam/* 199189251Ssam * Fast power-of-two math macros for non-optimized compilers 200189251Ssam */ 201189251Ssam 202189251Ssam#define _DIV(value,PowerOf2) ((UINT32) ((value) >> (PowerOf2))) 203189251Ssam#define _MUL(value,PowerOf2) ((UINT32) ((value) << (PowerOf2))) 204189251Ssam#define _MOD(value,Divisor) ((UINT32) ((value) & ((Divisor) -1))) 205189251Ssam 206189251Ssam#define DIV_2(a) _DIV(a,1) 207189251Ssam#define MUL_2(a) _MUL(a,1) 208189251Ssam#define MOD_2(a) _MOD(a,2) 209189251Ssam 210189251Ssam#define DIV_4(a) _DIV(a,2) 211189251Ssam#define MUL_4(a) _MUL(a,2) 212189251Ssam#define MOD_4(a) _MOD(a,4) 213189251Ssam 214189251Ssam#define DIV_8(a) _DIV(a,3) 215189251Ssam#define MUL_8(a) _MUL(a,3) 216189251Ssam#define MOD_8(a) _MOD(a,8) 217189251Ssam 218189251Ssam#define DIV_16(a) _DIV(a,4) 219189251Ssam#define MUL_16(a) _MUL(a,4) 220189251Ssam#define MOD_16(a) _MOD(a,16) 221252726Srpaulo 222252726Srpaulo/* 223252726Srpaulo * Divide and Modulo 224252726Srpaulo */ 225252726Srpaulo#define ACPI_DIVIDE(n,d) ((n) / (d)) 226252726Srpaulo#define ACPI_MODULO(n,d) ((n) % (d)) 227252726Srpaulo 228252726Srpaulo/* 229189251Ssam * Rounding macros (Power of two boundaries only) 230189251Ssam */ 231189251Ssam 232189251Ssam#define ROUND_DOWN(value,boundary) ((value) & (~((boundary)-1))) 233189251Ssam#define ROUND_UP(value,boundary) (((value) + ((boundary)-1)) & (~((boundary)-1))) 234189251Ssam 235189251Ssam#define ROUND_DOWN_TO_32_BITS(a) ROUND_DOWN(a,4) 236189251Ssam#define ROUND_DOWN_TO_64_BITS(a) ROUND_DOWN(a,8) 237189251Ssam#define ROUND_DOWN_TO_NATIVE_WORD(a) ROUND_DOWN(a,ALIGNED_ADDRESS_BOUNDARY) 238189251Ssam 239189251Ssam#define ROUND_UP_TO_32BITS(a) ROUND_UP(a,4) 240189251Ssam#define ROUND_UP_TO_64BITS(a) ROUND_UP(a,8) 241189251Ssam#define ROUND_UP_TO_NATIVE_WORD(a) ROUND_UP(a,ALIGNED_ADDRESS_BOUNDARY) 242189251Ssam 243252726Srpaulo#define ROUND_PTR_UP_TO_4(a,b) ((b *)(((NATIVE_UINT)(a) + 3) & ~3)) 244252726Srpaulo#define ROUND_PTR_UP_TO_8(a,b) ((b *)(((NATIVE_UINT)(a) + 7) & ~7)) 245252726Srpaulo 246252726Srpaulo#define ROUND_UP_TO_1K(a) (((a) + 1023) >> 10) 247252726Srpaulo 248252726Srpaulo#ifdef DEBUG_ASSERT 249189251Ssam#undef DEBUG_ASSERT 250189251Ssam#endif 251189251Ssam 252189251Ssam 253189251Ssam/* Macros for GAS addressing */ 254189251Ssam 255189251Ssam#define ACPI_PCI_DEVICE_MASK (UINT64) 0x0000FFFF00000000 256189251Ssam#define ACPI_PCI_FUNCTION_MASK (UINT64) 0x00000000FFFF0000 257189251Ssam#define ACPI_PCI_REGISTER_MASK (UINT64) 0x000000000000FFFF 258189251Ssam 259189251Ssam#define ACPI_PCI_FUNCTION(a) (UINT32) ((((a) & ACPI_PCI_FUNCTION_MASK) >> 16)) 260189251Ssam#define ACPI_PCI_DEVICE(a) (UINT32) ((((a) & ACPI_PCI_DEVICE_MASK) >> 32)) 261189251Ssam#define ACPI_PCI_REGISTER(a) (UINT32) (((a) & ACPI_PCI_REGISTER_MASK)) 262189251Ssam#define ACPI_PCI_DEVFUN(a) (UINT32) ((ACPI_PCI_DEVICE(a) << 16) | ACPI_PCI_FUNCTION(a)) 263189251Ssam 264189251Ssam 265189251Ssam/* 266189251Ssam * An ACPI_HANDLE (which is actually an ACPI_NAMESPACE_NODE *) can appear in some contexts, 267189251Ssam * such as on apObjStack, where a pointer to an ACPI_OPERAND_OBJECT can also 268189251Ssam * appear. This macro is used to distinguish them. 269189251Ssam * 270189251Ssam * The DataType field is the first field in both structures. 271189251Ssam */ 272189251Ssam 273189251Ssam#define VALID_DESCRIPTOR_TYPE(d,t) (((ACPI_NAMESPACE_NODE *)d)->DataType == t) 274189251Ssam 275189251Ssam 276189251Ssam/* Macro to test the object type */ 277189251Ssam 278189251Ssam#define IS_THIS_OBJECT_TYPE(d,t) (((ACPI_OPERAND_OBJECT *)d)->Common.Type == (UINT8)t) 279189251Ssam 280189251Ssam/* Macro to check the table flags for SINGLE or MULTIPLE tables are allowed */ 281189251Ssam 282189251Ssam#define IS_SINGLE_TABLE(x) (((x) & 0x01) == ACPI_TABLE_SINGLE ? 1 : 0) 283189251Ssam 284189251Ssam/* 285189251Ssam * Macro to check if a pointer is within an ACPI table. 286189251Ssam * Parameter (a) is the pointer to check. Parameter (b) must be defined 287189251Ssam * as a pointer to an ACPI_TABLE_HEADER. (b+1) then points past the header, 288189251Ssam * and ((UINT8 *)b+b->Length) points one byte past the end of the table. 289189251Ssam */ 290189251Ssam 291189251Ssam#ifndef _IA16 292189251Ssam#define IS_IN_ACPI_TABLE(a,b) (((UINT8 *)(a) >= (UINT8 *)(b + 1)) &&\ 293189251Ssam ((UINT8 *)(a) < ((UINT8 *)b + b->Length))) 294189251Ssam 295189251Ssam#else 296189251Ssam#define IS_IN_ACPI_TABLE(a,b) (_segment)(a) == (_segment)(b) &&\ 297189251Ssam (((UINT8 *)(a) >= (UINT8 *)(b + 1)) &&\ 298189251Ssam ((UINT8 *)(a) < ((UINT8 *)b + b->Length))) 299189251Ssam#endif 300189251Ssam 301189251Ssam/* 302189251Ssam * Macros for the master AML opcode table 303189251Ssam */ 304189251Ssam 305189251Ssam#ifdef ACPI_DEBUG 306189251Ssam#define OP_INFO_ENTRY(Flags,Name,PArgs,IArgs) {Flags,PArgs,IArgs,Name} 307189251Ssam#else 308189251Ssam#define OP_INFO_ENTRY(Flags,Name,PArgs,IArgs) {Flags,PArgs,IArgs} 309189251Ssam#endif 310189251Ssam 311189251Ssam#define ARG_TYPE_WIDTH 5 312189251Ssam#define ARG_1(x) ((UINT32)(x)) 313189251Ssam#define ARG_2(x) ((UINT32)(x) << (1 * ARG_TYPE_WIDTH)) 314189251Ssam#define ARG_3(x) ((UINT32)(x) << (2 * ARG_TYPE_WIDTH)) 315189251Ssam#define ARG_4(x) ((UINT32)(x) << (3 * ARG_TYPE_WIDTH)) 316189251Ssam#define ARG_5(x) ((UINT32)(x) << (4 * ARG_TYPE_WIDTH)) 317189251Ssam#define ARG_6(x) ((UINT32)(x) << (5 * ARG_TYPE_WIDTH)) 318189251Ssam 319189251Ssam#define ARGI_LIST1(a) (ARG_1(a)) 320189251Ssam#define ARGI_LIST2(a,b) (ARG_1(b)|ARG_2(a)) 321189251Ssam#define ARGI_LIST3(a,b,c) (ARG_1(c)|ARG_2(b)|ARG_3(a)) 322189251Ssam#define ARGI_LIST4(a,b,c,d) (ARG_1(d)|ARG_2(c)|ARG_3(b)|ARG_4(a)) 323189251Ssam#define ARGI_LIST5(a,b,c,d,e) (ARG_1(e)|ARG_2(d)|ARG_3(c)|ARG_4(b)|ARG_5(a)) 324189251Ssam#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)) 325189251Ssam 326189251Ssam#define ARGP_LIST1(a) (ARG_1(a)) 327189251Ssam#define ARGP_LIST2(a,b) (ARG_1(a)|ARG_2(b)) 328252726Srpaulo#define ARGP_LIST3(a,b,c) (ARG_1(a)|ARG_2(b)|ARG_3(c)) 329252726Srpaulo#define ARGP_LIST4(a,b,c,d) (ARG_1(a)|ARG_2(b)|ARG_3(c)|ARG_4(d)) 330189251Ssam#define ARGP_LIST5(a,b,c,d,e) (ARG_1(a)|ARG_2(b)|ARG_3(c)|ARG_4(d)|ARG_5(e)) 331#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)) 332 333#define GET_CURRENT_ARG_TYPE(List) (List & ((UINT32) 0x1F)) 334#define INCREMENT_ARG_LIST(List) (List >>= ((UINT32) ARG_TYPE_WIDTH)) 335 336 337/* 338 * Reporting macros that are never compiled out 339 */ 340 341#define PARAM_LIST(pl) pl 342 343/* 344 * Error reporting. These versions add callers module and line#. Since 345 * _THIS_MODULE gets compiled out when ACPI_DEBUG isn't defined, only 346 * use it in debug mode. 347 */ 348 349#ifdef ACPI_DEBUG 350 351#define REPORT_INFO(fp) {_ReportInfo(_THIS_MODULE,__LINE__,_COMPONENT); \ 352 DebugPrintRaw PARAM_LIST(fp);} 353#define REPORT_ERROR(fp) {_ReportError(_THIS_MODULE,__LINE__,_COMPONENT); \ 354 DebugPrintRaw PARAM_LIST(fp);} 355#define REPORT_WARNING(fp) {_ReportWarning(_THIS_MODULE,__LINE__,_COMPONENT); \ 356 DebugPrintRaw PARAM_LIST(fp);} 357 358#else 359 360#define REPORT_INFO(fp) {_ReportInfo("ACPI",__LINE__,_COMPONENT); \ 361 DebugPrintRaw PARAM_LIST(fp);} 362#define REPORT_ERROR(fp) {_ReportError("ACPI",__LINE__,_COMPONENT); \ 363 DebugPrintRaw PARAM_LIST(fp);} 364#define REPORT_WARNING(fp) {_ReportWarning("ACPI",__LINE__,_COMPONENT); \ 365 DebugPrintRaw PARAM_LIST(fp);} 366 367#endif 368 369/* Error reporting. These versions pass thru the module and line# */ 370 371#define _REPORT_INFO(a,b,c,fp) {_ReportInfo(a,b,c); \ 372 DebugPrintRaw PARAM_LIST(fp);} 373#define _REPORT_ERROR(a,b,c,fp) {_ReportError(a,b,c); \ 374 DebugPrintRaw PARAM_LIST(fp);} 375#define _REPORT_WARNING(a,b,c,fp) {_ReportWarning(a,b,c); \ 376 DebugPrintRaw PARAM_LIST(fp);} 377 378/* Buffer dump macros */ 379 380#define DUMP_BUFFER(a,b) AcpiCmDumpBuffer((UINT8 *)a,b,DB_BYTE_DISPLAY,_COMPONENT) 381 382/* 383 * Debug macros that are conditionally compiled 384 */ 385 386#ifdef ACPI_DEBUG 387 388#define MODULE_NAME(name) static char *_THIS_MODULE = name; 389 390/* 391 * Function entry tracing. 392 * The first parameter should be the procedure name as a quoted string. This is declared 393 * as a local string ("_ProcName) so that it can be also used by the function exit macros below. 394 */ 395 396#define FUNCTION_TRACE(a) char * _ProcName = a;\ 397 FunctionTrace(_THIS_MODULE,__LINE__,_COMPONENT,a) 398#define FUNCTION_TRACE_PTR(a,b) char * _ProcName = a;\ 399 FunctionTracePtr(_THIS_MODULE,__LINE__,_COMPONENT,a,(void *)b) 400#define FUNCTION_TRACE_U32(a,b) char * _ProcName = a;\ 401 FunctionTraceU32(_THIS_MODULE,__LINE__,_COMPONENT,a,(UINT32)b) 402#define FUNCTION_TRACE_STR(a,b) char * _ProcName = a;\ 403 FunctionTraceStr(_THIS_MODULE,__LINE__,_COMPONENT,a,(NATIVE_CHAR *)b) 404/* 405 * Function exit tracing. 406 * WARNING: These macros include a return statement. This is usually considered 407 * bad form, but having a separate exit macro is very ugly and difficult to maintain. 408 * One of the FUNCTION_TRACE macros above must be used in conjunction with these macros 409 * so that "_ProcName" is defined. 410 */ 411#define return_VOID {FunctionExit(_THIS_MODULE,__LINE__,_COMPONENT,_ProcName);return;} 412#define return_ACPI_STATUS(s) {FunctionStatusExit(_THIS_MODULE,__LINE__,_COMPONENT,_ProcName,s);return(s);} 413#define return_VALUE(s) {FunctionValueExit(_THIS_MODULE,__LINE__,_COMPONENT,_ProcName,(NATIVE_UINT)s);return(s);} 414#define return_PTR(s) {FunctionPtrExit(_THIS_MODULE,__LINE__,_COMPONENT,_ProcName,(UINT8 *)s);return(s);} 415 416 417/* Conditional execution */ 418 419#define DEBUG_EXEC(a) a 420#define NORMAL_EXEC(a) 421 422#define DEBUG_DEFINE(a) a; 423#define DEBUG_ONLY_MEMBERS(a) a; 424 425 426/* Stack and buffer dumping */ 427 428#define DUMP_STACK_ENTRY(a) AcpiAmlDumpOperand(a) 429#define DUMP_OPERANDS(a,b,c,d,e) AcpiAmlDumpOperands(a,b,c,d,e,_THIS_MODULE,__LINE__) 430 431 432#define DUMP_ENTRY(a,b) AcpiNsDumpEntry (a,b) 433#define DUMP_TABLES(a,b) AcpiNsDumpTables(a,b) 434#define DUMP_PATHNAME(a,b,c,d) AcpiNsDumpPathname(a,b,c,d) 435#define DUMP_RESOURCE_LIST(a) AcpiRsDumpResourceList(a) 436#define BREAK_MSG(a) AcpiOsBreakpoint (a) 437 438/* 439 * Generate INT3 on ACPI_ERROR (Debug only!) 440 */ 441 442#define ERROR_BREAK 443#ifdef ERROR_BREAK 444#define BREAK_ON_ERROR(lvl) if ((lvl)&ACPI_ERROR) AcpiOsBreakpoint("Fatal error encountered\n") 445#else 446#define BREAK_ON_ERROR(lvl) 447#endif 448 449/* 450 * Master debug print macros 451 * Print iff: 452 * 1) Debug print for the current component is enabled 453 * 2) Debug error level or trace level for the print statement is enabled 454 * 455 */ 456 457#define TEST_DEBUG_SWITCH(lvl) if (((lvl) & AcpiDbgLevel) && (_COMPONENT & AcpiDbgLayer)) 458 459#define DEBUG_PRINT(lvl,fp) TEST_DEBUG_SWITCH(lvl) {\ 460 DebugPrintPrefix (_THIS_MODULE,__LINE__);\ 461 DebugPrintRaw PARAM_LIST(fp);\ 462 BREAK_ON_ERROR(lvl);} 463 464#define DEBUG_PRINT_RAW(lvl,fp) TEST_DEBUG_SWITCH(lvl) {\ 465 DebugPrintRaw PARAM_LIST(fp);} 466 467 468/* Assert macros */ 469 470#define ACPI_ASSERT(exp) if(!(exp)) \ 471 AcpiOsDbgAssert(#exp, __FILE__, __LINE__, "Failed Assertion") 472 473#define DEBUG_ASSERT(msg, exp) if(!(exp)) \ 474 AcpiOsDbgAssert(#exp, __FILE__, __LINE__, msg) 475 476 477#else 478/* 479 * This is the non-debug case -- make everything go away, 480 * leaving no executable debug code! 481 */ 482 483#define MODULE_NAME(name) 484#define _THIS_MODULE "" 485 486#define DEBUG_EXEC(a) 487#define NORMAL_EXEC(a) a; 488 489#define DEBUG_DEFINE(a) 490#define DEBUG_ONLY_MEMBERS(a) 491#define FUNCTION_TRACE(a) 492#define FUNCTION_TRACE_PTR(a,b) 493#define FUNCTION_TRACE_U32(a,b) 494#define FUNCTION_TRACE_STR(a,b) 495#define FUNCTION_EXIT 496#define FUNCTION_STATUS_EXIT(s) 497#define FUNCTION_VALUE_EXIT(s) 498#define DUMP_STACK_ENTRY(a) 499#define DUMP_OPERANDS(a,b,c,d,e) 500#define DUMP_ENTRY(a,b) 501#define DUMP_TABLES(a,b) 502#define DUMP_PATHNAME(a,b,c,d) 503#define DUMP_RESOURCE_LIST(a) 504#define DEBUG_PRINT(l,f) 505#define DEBUG_PRINT_RAW(l,f) 506#define BREAK_MSG(a) 507 508#define return_VOID return 509#define return_ACPI_STATUS(s) return(s) 510#define return_VALUE(s) return(s) 511#define return_PTR(s) return(s) 512 513#define ACPI_ASSERT(exp) 514#define DEBUG_ASSERT(msg, exp) 515 516#endif 517 518/* 519 * Some code only gets executed when the debugger is built in. 520 * Note that this is entirely independent of whether the 521 * DEBUG_PRINT stuff (set by ACPI_DEBUG) is on, or not. 522 */ 523#ifdef ENABLE_DEBUGGER 524#define DEBUGGER_EXEC(a) a 525#else 526#define DEBUGGER_EXEC(a) 527#endif 528 529 530/* 531 * For 16-bit code, we want to shrink some things even though 532 * we are using ACPI_DEBUG to get the debug output 533 */ 534#ifdef _IA16 535#undef DEBUG_ONLY_MEMBERS 536#define DEBUG_ONLY_MEMBERS(a) 537#undef OP_INFO_ENTRY 538#define OP_INFO_ENTRY(Flags,Name,PArgs,IArgs) {Flags,PArgs,IArgs} 539#endif 540 541 542#ifdef ACPI_DEBUG 543 544/* 545 * 1) Set name to blanks 546 * 2) Copy the object name 547 */ 548 549#define ADD_OBJECT_NAME(a,b) MEMSET (a->Common.Name, ' ', sizeof (a->Common.Name));\ 550 STRNCPY (a->Common.Name, AcpiGbl_NsTypeNames[b], sizeof (a->Common.Name)) 551 552#else 553 554#define ADD_OBJECT_NAME(a,b) 555 556#endif 557 558 559#endif /* ACMACROS_H */ 560