acmacros.h revision 91116
1/****************************************************************************** 2 * 3 * Name: acmacros.h - C macros for the entire subsystem. 4 * $Revision: 115 $ 5 * 6 *****************************************************************************/ 7 8/****************************************************************************** 9 * 10 * 1. Copyright Notice 11 * 12 * Some or all of this work - Copyright (c) 1999 - 2002, 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/* 122 * Data manipulation macros 123 */ 124 125#define ACPI_LOWORD(l) ((UINT16)(NATIVE_UINT)(l)) 126#define ACPI_HIWORD(l) ((UINT16)((((NATIVE_UINT)(l)) >> 16) & 0xFFFF)) 127#define ACPI_LOBYTE(l) ((UINT8)(UINT16)(l)) 128#define ACPI_HIBYTE(l) ((UINT8)((((UINT16)(l)) >> 8) & 0xFF)) 129 130 131#ifdef _IA16 132/* 133 * For 16-bit addresses, we have to assume that the upper 32 bits 134 * are zero. 135 */ 136#define ACPI_LODWORD(l) (l) 137#define ACPI_HIDWORD(l) (0) 138 139#define ACPI_GET_ADDRESS(a) ((a).Lo) 140#define ACPI_STORE_ADDRESS(a,b) {(a).Hi=0;(a).Lo=(b);} 141#define ACPI_VALID_ADDRESS(a) ((a).Hi | (a).Lo) 142 143#else 144#ifdef ACPI_NO_INTEGER64_SUPPORT 145/* 146 * ACPI_INTEGER is 32-bits, no 64-bit support on this platform 147 */ 148#define ACPI_LODWORD(l) ((UINT32)(l)) 149#define ACPI_HIDWORD(l) (0) 150 151#define ACPI_GET_ADDRESS(a) (a) 152#define ACPI_STORE_ADDRESS(a,b) ((a)=(b)) 153#define ACPI_VALID_ADDRESS(a) (a) 154 155#else 156 157/* 158 * Full 64-bit address/integer on both 32-bit and 64-bit platforms 159 */ 160#define ACPI_LODWORD(l) ((UINT32)(UINT64)(l)) 161#define ACPI_HIDWORD(l) ((UINT32)(((*(UINT64_STRUCT *)(&l))).Hi)) 162 163#define ACPI_GET_ADDRESS(a) (a) 164#define ACPI_STORE_ADDRESS(a,b) ((a)=(b)) 165#define ACPI_VALID_ADDRESS(a) (a) 166#endif 167#endif 168 169 /* 170 * Extract a byte of data using a pointer. Any more than a byte and we 171 * get into potential aligment issues -- see the STORE macros below 172 */ 173#define ACPI_GET8(addr) (*(UINT8*)(addr)) 174 175/* Pointer arithmetic */ 176 177#define ACPI_PTR_ADD(t,a,b) (t *) ((char *)(a) + (b)) 178#define ACPI_PTR_DIFF(a,b) (NATIVE_UINT) ((char *)(a) - (char *)(b)) 179 180/* Pointer/Integer type conversions */ 181 182#define ACPI_TO_POINTER(i) ACPI_PTR_ADD (void,NULL,(NATIVE_UINT)i) 183#define ACPI_TO_INTEGER(p) ACPI_PTR_DIFF (p,NULL) 184#define ACPI_OFFSET(d,o) ((ACPI_SIZE) ACPI_TO_INTEGER (&(((d *)0)->o))) 185#define ACPI_FADT_OFFSET(o) ACPI_OFFSET (FADT_DESCRIPTOR, o) 186 187 188#ifdef _IA16 189#define ACPI_PHYSADDR_TO_PTR(i) (void *)(i) 190#define ACPI_PTR_TO_PHYSADDR(i) (char *)(i) 191#else 192#define ACPI_PHYSADDR_TO_PTR(i) ACPI_TO_POINTER(i) 193#define ACPI_PTR_TO_PHYSADDR(i) ACPI_TO_INTEGER(i) 194#endif 195 196/* 197 * Macros for moving data around to/from buffers that are possibly unaligned. 198 * If the hardware supports the transfer of unaligned data, just do the store. 199 * Otherwise, we have to move one byte at a time. 200 */ 201 202#ifdef _HW_ALIGNMENT_SUPPORT 203 204/* The hardware supports unaligned transfers, just do the move */ 205 206#define ACPI_MOVE_UNALIGNED16_TO_16(d,s) *(UINT16 *)(d) = *(UINT16 *)(s) 207#define ACPI_MOVE_UNALIGNED32_TO_32(d,s) *(UINT32 *)(d) = *(UINT32 *)(s) 208#define ACPI_MOVE_UNALIGNED16_TO_32(d,s) *(UINT32 *)(d) = *(UINT16 *)(s) 209#define ACPI_MOVE_UNALIGNED64_TO_64(d,s) *(UINT64 *)(d) = *(UINT64 *)(s) 210 211#else 212/* 213 * The hardware does not support unaligned transfers. We must move the 214 * data one byte at a time. These macros work whether the source or 215 * the destination (or both) is/are unaligned. 216 */ 217 218#define ACPI_MOVE_UNALIGNED16_TO_16(d,s) {((UINT8 *)(d))[0] = ((UINT8 *)(s))[0];\ 219 ((UINT8 *)(d))[1] = ((UINT8 *)(s))[1];} 220 221#define ACPI_MOVE_UNALIGNED32_TO_32(d,s) {((UINT8 *)(d))[0] = ((UINT8 *)(s))[0];\ 222 ((UINT8 *)(d))[1] = ((UINT8 *)(s))[1];\ 223 ((UINT8 *)(d))[2] = ((UINT8 *)(s))[2];\ 224 ((UINT8 *)(d))[3] = ((UINT8 *)(s))[3];} 225 226#define ACPI_MOVE_UNALIGNED16_TO_32(d,s) {(*(UINT32*)(d)) = 0; ACPI_MOVE_UNALIGNED16_TO_16(d,s);} 227 228#define ACPI_MOVE_UNALIGNED64_TO_64(d,s) {((UINT8 *)(d))[0] = ((UINT8 *)(s))[0];\ 229 ((UINT8 *)(d))[1] = ((UINT8 *)(s))[1];\ 230 ((UINT8 *)(d))[2] = ((UINT8 *)(s))[2];\ 231 ((UINT8 *)(d))[3] = ((UINT8 *)(s))[3];\ 232 ((UINT8 *)(d))[4] = ((UINT8 *)(s))[4];\ 233 ((UINT8 *)(d))[5] = ((UINT8 *)(s))[5];\ 234 ((UINT8 *)(d))[6] = ((UINT8 *)(s))[6];\ 235 ((UINT8 *)(d))[7] = ((UINT8 *)(s))[7];} 236 237#endif 238 239 240/* 241 * Fast power-of-two math macros for non-optimized compilers 242 */ 243 244#define _ACPI_DIV(value,PowerOf2) ((UINT32) ((value) >> (PowerOf2))) 245#define _ACPI_MUL(value,PowerOf2) ((UINT32) ((value) << (PowerOf2))) 246#define _ACPI_MOD(value,Divisor) ((UINT32) ((value) & ((Divisor) -1))) 247 248#define ACPI_DIV_2(a) _ACPI_DIV(a,1) 249#define ACPI_MUL_2(a) _ACPI_MUL(a,1) 250#define ACPI_MOD_2(a) _ACPI_MOD(a,2) 251 252#define ACPI_DIV_4(a) _ACPI_DIV(a,2) 253#define ACPI_MUL_4(a) _ACPI_MUL(a,2) 254#define ACPI_MOD_4(a) _ACPI_MOD(a,4) 255 256#define ACPI_DIV_8(a) _ACPI_DIV(a,3) 257#define ACPI_MUL_8(a) _ACPI_MUL(a,3) 258#define ACPI_MOD_8(a) _ACPI_MOD(a,8) 259 260#define ACPI_DIV_16(a) _ACPI_DIV(a,4) 261#define ACPI_MUL_16(a) _ACPI_MUL(a,4) 262#define ACPI_MOD_16(a) _ACPI_MOD(a,16) 263 264 265/* 266 * Rounding macros (Power of two boundaries only) 267 */ 268#define ACPI_ROUND_DOWN(value,boundary) (((NATIVE_UINT)(value)) & (~((boundary)-1))) 269#define ACPI_ROUND_UP(value,boundary) ((((NATIVE_UINT)(value)) + ((boundary)-1)) & (~((boundary)-1))) 270 271#define ACPI_ROUND_DOWN_TO_32_BITS(a) ACPI_ROUND_DOWN(a,4) 272#define ACPI_ROUND_DOWN_TO_64_BITS(a) ACPI_ROUND_DOWN(a,8) 273#define ACPI_ROUND_DOWN_TO_NATIVE_WORD(a) ACPI_ROUND_DOWN(a,ALIGNED_ADDRESS_BOUNDARY) 274 275#define ACPI_ROUND_UP_TO_32BITS(a) ACPI_ROUND_UP(a,4) 276#define ACPI_ROUND_UP_TO_64BITS(a) ACPI_ROUND_UP(a,8) 277#define ACPI_ROUND_UP_TO_NATIVE_WORD(a) ACPI_ROUND_UP(a,ALIGNED_ADDRESS_BOUNDARY) 278 279 280#define ACPI_ROUND_BITS_UP_TO_BYTES(a) ACPI_DIV_8((a) + 7) 281#define ACPI_ROUND_BITS_DOWN_TO_BYTES(a) ACPI_DIV_8((a)) 282 283#define ACPI_ROUND_UP_TO_1K(a) (((a) + 1023) >> 10) 284 285/* Generic (non-power-of-two) rounding */ 286 287#define ACPI_ROUND_UP_TO(value,boundary) (((value) + ((boundary)-1)) / (boundary)) 288 289/* 290 * Bitmask creation 291 * Bit positions start at zero. 292 * MASK_BITS_ABOVE creates a mask starting AT the position and above 293 * MASK_BITS_BELOW creates a mask starting one bit BELOW the position 294 */ 295#define ACPI_MASK_BITS_ABOVE(position) (~(((ACPI_INTEGER)(-1)) << ((UINT32) (position)))) 296#define ACPI_MASK_BITS_BELOW(position) (((ACPI_INTEGER)(-1)) << ((UINT32) (position))) 297 298#define ACPI_IS_OCTAL_DIGIT(d) (((char)(d) >= '0') && ((char)(d) <= '7')) 299 300/* Macros for GAS addressing */ 301 302#ifndef _IA16 303 304#define ACPI_PCI_DEVICE_MASK (UINT64) 0x0000FFFF00000000 305#define ACPI_PCI_FUNCTION_MASK (UINT64) 0x00000000FFFF0000 306#define ACPI_PCI_REGISTER_MASK (UINT64) 0x000000000000FFFF 307 308#define ACPI_PCI_FUNCTION(a) (UINT16) ((((a) & ACPI_PCI_FUNCTION_MASK) >> 16)) 309#define ACPI_PCI_DEVICE(a) (UINT16) ((((a) & ACPI_PCI_DEVICE_MASK) >> 32)) 310#define ACPI_PCI_REGISTER(a) (UINT16) (((a) & ACPI_PCI_REGISTER_MASK)) 311 312#else 313 314/* No support for GAS and PCI IDs in 16-bit mode */ 315 316#define ACPI_PCI_FUNCTION(a) (UINT16) ((a) & 0xFFFF0000) 317#define ACPI_PCI_DEVICE(a) (UINT16) ((a) & 0x0000FFFF) 318#define ACPI_PCI_REGISTER(a) (UINT16) ((a) & 0x0000FFFF) 319 320#endif 321 322 323/* Bitfields within ACPI registers */ 324 325#define ACPI_REGISTER_PREPARE_BITS(Val, Pos, Mask) ((Val << Pos) & Mask) 326#define ACPI_REGISTER_INSERT_VALUE(Reg, Pos, Mask, Val) Reg = (Reg & (~(Mask))) | ACPI_REGISTER_PREPARE_BITS(Val, Pos, Mask) 327 328/* 329 * An ACPI_NAMESPACE_NODE * can appear in some contexts, 330 * where a pointer to an ACPI_OPERAND_OBJECT can also 331 * appear. This macro is used to distinguish them. 332 * 333 * The "Descriptor" field is the first field in both structures. 334 */ 335#define ACPI_GET_DESCRIPTOR_TYPE(d) (((ACPI_NAMESPACE_NODE *)d)->Descriptor) 336#define ACPI_SET_DESCRIPTOR_TYPE(d,t) (((ACPI_NAMESPACE_NODE *)d)->Descriptor = t) 337 338 339/* Macro to test the object type */ 340 341#define ACPI_GET_OBJECT_TYPE(d) (((ACPI_OPERAND_OBJECT *)d)->Common.Type) 342 343/* Macro to check the table flags for SINGLE or MULTIPLE tables are allowed */ 344 345#define ACPI_IS_SINGLE_TABLE(x) (((x) & 0x01) == ACPI_TABLE_SINGLE ? 1 : 0) 346 347/* 348 * Macro to check if a pointer is within an ACPI table. 349 * Parameter (a) is the pointer to check. Parameter (b) must be defined 350 * as a pointer to an ACPI_TABLE_HEADER. (b+1) then points past the header, 351 * and ((UINT8 *)b+b->Length) points one byte past the end of the table. 352 */ 353#ifndef _IA16 354#define ACPI_IS_IN_ACPI_TABLE(a,b) (((UINT8 *)(a) >= (UINT8 *)(b + 1)) &&\ 355 ((UINT8 *)(a) < ((UINT8 *)b + b->Length))) 356 357#else 358#define ACPI_IS_IN_ACPI_TABLE(a,b) (_segment)(a) == (_segment)(b) &&\ 359 (((UINT8 *)(a) >= (UINT8 *)(b + 1)) &&\ 360 ((UINT8 *)(a) < ((UINT8 *)b + b->Length))) 361#endif 362 363/* 364 * Macros for the master AML opcode table 365 */ 366#ifdef ACPI_DEBUG 367#define ACPI_OP(Name,PArgs,IArgs,ObjType,Class,Type,Flags) {Name,PArgs,IArgs,Flags,ObjType,Class,Type} 368#else 369#define ACPI_OP(Name,PArgs,IArgs,ObjType,Class,Type,Flags) {PArgs,IArgs,Flags,ObjType,Class,Type} 370#endif 371 372#define ARG_TYPE_WIDTH 5 373#define ARG_1(x) ((UINT32)(x)) 374#define ARG_2(x) ((UINT32)(x) << (1 * ARG_TYPE_WIDTH)) 375#define ARG_3(x) ((UINT32)(x) << (2 * ARG_TYPE_WIDTH)) 376#define ARG_4(x) ((UINT32)(x) << (3 * ARG_TYPE_WIDTH)) 377#define ARG_5(x) ((UINT32)(x) << (4 * ARG_TYPE_WIDTH)) 378#define ARG_6(x) ((UINT32)(x) << (5 * ARG_TYPE_WIDTH)) 379 380#define ARGI_LIST1(a) (ARG_1(a)) 381#define ARGI_LIST2(a,b) (ARG_1(b)|ARG_2(a)) 382#define ARGI_LIST3(a,b,c) (ARG_1(c)|ARG_2(b)|ARG_3(a)) 383#define ARGI_LIST4(a,b,c,d) (ARG_1(d)|ARG_2(c)|ARG_3(b)|ARG_4(a)) 384#define ARGI_LIST5(a,b,c,d,e) (ARG_1(e)|ARG_2(d)|ARG_3(c)|ARG_4(b)|ARG_5(a)) 385#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)) 386 387#define ARGP_LIST1(a) (ARG_1(a)) 388#define ARGP_LIST2(a,b) (ARG_1(a)|ARG_2(b)) 389#define ARGP_LIST3(a,b,c) (ARG_1(a)|ARG_2(b)|ARG_3(c)) 390#define ARGP_LIST4(a,b,c,d) (ARG_1(a)|ARG_2(b)|ARG_3(c)|ARG_4(d)) 391#define ARGP_LIST5(a,b,c,d,e) (ARG_1(a)|ARG_2(b)|ARG_3(c)|ARG_4(d)|ARG_5(e)) 392#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)) 393 394#define GET_CURRENT_ARG_TYPE(List) (List & ((UINT32) 0x1F)) 395#define INCREMENT_ARG_LIST(List) (List >>= ((UINT32) ARG_TYPE_WIDTH)) 396 397 398/* 399 * Build a GAS structure from earlier ACPI table entries (V1.0 and 0.71 extensions) 400 * 401 * 1) Address space 402 * 2) Length in bytes -- convert to length in bits 403 * 3) Bit offset is zero 404 * 4) Reserved field is zero 405 * 5) Expand address to 64 bits 406 */ 407#define ASL_BUILD_GAS_FROM_ENTRY(a,b,c,d) {a.AddressSpaceId = (UINT8) d;\ 408 a.RegisterBitWidth = (UINT8) ACPI_MUL_8 (b);\ 409 a.RegisterBitOffset = 0;\ 410 a.Reserved = 0;\ 411 ACPI_STORE_ADDRESS (a.Address,c);} 412 413/* ACPI V1.0 entries -- address space is always I/O */ 414 415#define ASL_BUILD_GAS_FROM_V1_ENTRY(a,b,c) ASL_BUILD_GAS_FROM_ENTRY(a,b,c,ACPI_ADR_SPACE_SYSTEM_IO) 416 417 418/* 419 * Reporting macros that are never compiled out 420 */ 421 422#define ACPI_PARAM_LIST(pl) pl 423 424/* 425 * Error reporting. These versions add callers module and line#. Since 426 * _THIS_MODULE gets compiled out when ACPI_DEBUG isn't defined, only 427 * use it in debug mode. 428 */ 429 430#ifdef ACPI_DEBUG 431 432#define ACPI_REPORT_INFO(fp) {AcpiUtReportInfo(_THIS_MODULE,__LINE__,_COMPONENT); \ 433 AcpiOsPrintf ACPI_PARAM_LIST(fp);} 434#define ACPI_REPORT_ERROR(fp) {AcpiUtReportError(_THIS_MODULE,__LINE__,_COMPONENT); \ 435 AcpiOsPrintf ACPI_PARAM_LIST(fp);} 436#define ACPI_REPORT_WARNING(fp) {AcpiUtReportWarning(_THIS_MODULE,__LINE__,_COMPONENT); \ 437 AcpiOsPrintf ACPI_PARAM_LIST(fp);} 438 439#else 440 441#define ACPI_REPORT_INFO(fp) {AcpiUtReportInfo("ACPI",__LINE__,_COMPONENT); \ 442 AcpiOsPrintf ACPI_PARAM_LIST(fp);} 443#define ACPI_REPORT_ERROR(fp) {AcpiUtReportError("ACPI",__LINE__,_COMPONENT); \ 444 AcpiOsPrintf ACPI_PARAM_LIST(fp);} 445#define ACPI_REPORT_WARNING(fp) {AcpiUtReportWarning("ACPI",__LINE__,_COMPONENT); \ 446 AcpiOsPrintf ACPI_PARAM_LIST(fp);} 447 448#endif 449 450/* Error reporting. These versions pass thru the module and line# */ 451 452#define _ACPI_REPORT_INFO(a,b,c,fp) {AcpiUtReportInfo(a,b,c); \ 453 AcpiOsPrintf ACPI_PARAM_LIST(fp);} 454#define _ACPI_REPORT_ERROR(a,b,c,fp) {AcpiUtReportError(a,b,c); \ 455 AcpiOsPrintf ACPI_PARAM_LIST(fp);} 456#define _ACPI_REPORT_WARNING(a,b,c,fp) {AcpiUtReportWarning(a,b,c); \ 457 AcpiOsPrintf ACPI_PARAM_LIST(fp);} 458 459/* 460 * Debug macros that are conditionally compiled 461 */ 462 463#ifdef ACPI_DEBUG 464 465#define ACPI_MODULE_NAME(name) static char *_THIS_MODULE = name; 466 467/* 468 * Function entry tracing. 469 * The first parameter should be the procedure name as a quoted string. This is declared 470 * as a local string ("_ProcName) so that it can be also used by the function exit macros below. 471 */ 472 473#define ACPI_FUNCTION_NAME(a) ACPI_DEBUG_PRINT_INFO _Dbg; \ 474 _Dbg.ComponentId = _COMPONENT; \ 475 _Dbg.ProcName = a; \ 476 _Dbg.ModuleName = _THIS_MODULE; 477 478#define ACPI_FUNCTION_TRACE(a) ACPI_FUNCTION_NAME(a)\ 479 AcpiUtTrace(__LINE__,&_Dbg) 480#define ACPI_FUNCTION_TRACE_PTR(a,b) ACPI_FUNCTION_NAME(a)\ 481 AcpiUtTracePtr(__LINE__,&_Dbg,(void *)b) 482#define ACPI_FUNCTION_TRACE_U32(a,b) ACPI_FUNCTION_NAME(a)\ 483 AcpiUtTraceU32(__LINE__,&_Dbg,(UINT32)b) 484#define ACPI_FUNCTION_TRACE_STR(a,b) ACPI_FUNCTION_NAME(a)\ 485 AcpiUtTraceStr(__LINE__,&_Dbg,(NATIVE_CHAR *)b) 486 487#define ACPI_FUNCTION_ENTRY() AcpiUtTrackStackPtr() 488 489/* 490 * Function exit tracing. 491 * WARNING: These macros include a return statement. This is usually considered 492 * bad form, but having a separate exit macro is very ugly and difficult to maintain. 493 * One of the FUNCTION_TRACE macros above must be used in conjunction with these macros 494 * so that "_ProcName" is defined. 495 */ 496#define return_VOID {AcpiUtExit(__LINE__,&_Dbg);return;} 497#define return_ACPI_STATUS(s) {AcpiUtStatusExit(__LINE__,&_Dbg,s);return(s);} 498#define return_VALUE(s) {AcpiUtValueExit(__LINE__,&_Dbg,s);return(s);} 499#define return_PTR(s) {AcpiUtPtrExit(__LINE__,&_Dbg,(UINT8 *)s);return(s);} 500 501 502/* Conditional execution */ 503 504#define ACPI_DEBUG_EXEC(a) a 505#define ACPI_NORMAL_EXEC(a) 506 507#define ACPI_DEBUG_DEFINE(a) a; 508#define ACPI_DEBUG_ONLY_MEMBERS(a) a; 509#define _OPCODE_NAMES 510#define _VERBOSE_STRUCTURES 511 512 513/* Stack and buffer dumping */ 514 515#define ACPI_DUMP_STACK_ENTRY(a) AcpiExDumpOperand(a) 516#define ACPI_DUMP_OPERANDS(a,b,c,d,e) AcpiExDumpOperands(a,b,c,d,e,_THIS_MODULE,__LINE__) 517 518 519#define ACPI_DUMP_ENTRY(a,b) AcpiNsDumpEntry (a,b) 520#define ACPI_DUMP_TABLES(a,b) AcpiNsDumpTables(a,b) 521#define ACPI_DUMP_PATHNAME(a,b,c,d) AcpiNsDumpPathname(a,b,c,d) 522#define ACPI_DUMP_RESOURCE_LIST(a) AcpiRsDumpResourceList(a) 523#define ACPI_DUMP_BUFFER(a,b) AcpiUtDumpBuffer((UINT8 *)a,b,DB_BYTE_DISPLAY,_COMPONENT) 524#define ACPI_BREAK_MSG(a) AcpiOsSignal (ACPI_SIGNAL_BREAKPOINT,(a)) 525 526 527/* 528 * Generate INT3 on ACPI_ERROR (Debug only!) 529 */ 530 531#define ACPI_ERROR_BREAK 532#ifdef ACPI_ERROR_BREAK 533#define ACPI_BREAK_ON_ERROR(lvl) if ((lvl)&ACPI_ERROR) \ 534 AcpiOsSignal(ACPI_SIGNAL_BREAKPOINT,"Fatal error encountered\n") 535#else 536#define ACPI_BREAK_ON_ERROR(lvl) 537#endif 538 539/* 540 * Master debug print macros 541 * Print iff: 542 * 1) Debug print for the current component is enabled 543 * 2) Debug error level or trace level for the print statement is enabled 544 */ 545 546#define ACPI_DEBUG_PRINT(pl) AcpiUtDebugPrint ACPI_PARAM_LIST(pl) 547#define ACPI_DEBUG_PRINT_RAW(pl) AcpiUtDebugPrintRaw ACPI_PARAM_LIST(pl) 548 549 550#else 551/* 552 * This is the non-debug case -- make everything go away, 553 * leaving no executable debug code! 554 */ 555 556#define ACPI_MODULE_NAME(name) 557#define _THIS_MODULE "" 558 559#define ACPI_DEBUG_EXEC(a) 560#define ACPI_NORMAL_EXEC(a) a; 561 562#define ACPI_DEBUG_DEFINE(a) 563#define ACPI_DEBUG_ONLY_MEMBERS(a) 564#define ACPI_FUNCTION_NAME(a) 565#define ACPI_FUNCTION_TRACE(a) 566#define ACPI_FUNCTION_TRACE_PTR(a,b) 567#define ACPI_FUNCTION_TRACE_U32(a,b) 568#define ACPI_FUNCTION_TRACE_STR(a,b) 569#define ACPI_FUNCTION_EXIT 570#define ACPI_FUNCTION_STATUS_EXIT(s) 571#define ACPI_FUNCTION_VALUE_EXIT(s) 572#define ACPI_FUNCTION_ENTRY() 573#define ACPI_DUMP_STACK_ENTRY(a) 574#define ACPI_DUMP_OPERANDS(a,b,c,d,e) 575#define ACPI_DUMP_ENTRY(a,b) 576#define ACPI_DUMP_TABLES(a,b) 577#define ACPI_DUMP_PATHNAME(a,b,c,d) 578#define ACPI_DUMP_RESOURCE_LIST(a) 579#define ACPI_DUMP_BUFFER(a,b) 580#define ACPI_DEBUG_PRINT(pl) 581#define ACPI_DEBUG_PRINT_RAW(pl) 582#define ACPI_BREAK_MSG(a) 583 584#define return_VOID return 585#define return_ACPI_STATUS(s) return(s) 586#define return_VALUE(s) return(s) 587#define return_PTR(s) return(s) 588 589#endif 590 591/* 592 * Some code only gets executed when the debugger is built in. 593 * Note that this is entirely independent of whether the 594 * DEBUG_PRINT stuff (set by ACPI_DEBUG) is on, or not. 595 */ 596#ifdef ENABLE_DEBUGGER 597#define ACPI_DEBUGGER_EXEC(a) a 598#else 599#define ACPI_DEBUGGER_EXEC(a) 600#endif 601 602 603/* 604 * For 16-bit code, we want to shrink some things even though 605 * we are using ACPI_DEBUG to get the debug output 606 */ 607#ifdef _IA16 608#undef ACPI_DEBUG_ONLY_MEMBERS 609#undef _VERBOSE_STRUCTURES 610#define ACPI_DEBUG_ONLY_MEMBERS(a) 611#endif 612 613 614#ifdef ACPI_DEBUG 615/* 616 * 1) Set name to blanks 617 * 2) Copy the object name 618 */ 619#define ACPI_ADD_OBJECT_NAME(a,b) ACPI_MEMSET (a->Common.Name, ' ', sizeof (a->Common.Name));\ 620 ACPI_STRNCPY (a->Common.Name, AcpiGbl_NsTypeNames[b], sizeof (a->Common.Name)) 621#else 622 623#define ACPI_ADD_OBJECT_NAME(a,b) 624#endif 625 626 627/* 628 * Memory allocation tracking (DEBUG ONLY) 629 */ 630 631#ifndef ACPI_DBG_TRACK_ALLOCATIONS 632 633/* Memory allocation */ 634 635#define ACPI_MEM_ALLOCATE(a) AcpiUtAllocate(a,_COMPONENT,_THIS_MODULE,__LINE__) 636#define ACPI_MEM_CALLOCATE(a) AcpiUtCallocate(a, _COMPONENT,_THIS_MODULE,__LINE__) 637#define ACPI_MEM_FREE(a) AcpiOsFree(a) 638#define ACPI_MEM_TRACKING(a) 639 640 641#else 642 643/* Memory allocation */ 644 645#define ACPI_MEM_ALLOCATE(a) AcpiUtAllocateAndTrack(a,_COMPONENT,_THIS_MODULE,__LINE__) 646#define ACPI_MEM_CALLOCATE(a) AcpiUtCallocateAndTrack(a, _COMPONENT,_THIS_MODULE,__LINE__) 647#define ACPI_MEM_FREE(a) AcpiUtFreeAndTrack(a,_COMPONENT,_THIS_MODULE,__LINE__) 648#define ACPI_MEM_TRACKING(a) a 649 650#endif /* ACPI_DBG_TRACK_ALLOCATIONS */ 651 652 653#define ACPI_GET_STACK_POINTER _asm {mov eax, ebx} 654 655#endif /* ACMACROS_H */ 656