xref: /onnv-gate/usr/src/uts/intel/sys/acpi/acmacros.h (revision 11225:eb6056029d84)
10Sstevel@tonic-gate /******************************************************************************
20Sstevel@tonic-gate  *
30Sstevel@tonic-gate  * Name: acmacros.h - C macros for the entire subsystem.
40Sstevel@tonic-gate  *
50Sstevel@tonic-gate  *****************************************************************************/
60Sstevel@tonic-gate 
70Sstevel@tonic-gate /******************************************************************************
80Sstevel@tonic-gate  *
90Sstevel@tonic-gate  * 1. Copyright Notice
100Sstevel@tonic-gate  *
119980SDana.Myers@Sun.COM  * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp.
120Sstevel@tonic-gate  * All rights reserved.
130Sstevel@tonic-gate  *
140Sstevel@tonic-gate  * 2. License
150Sstevel@tonic-gate  *
160Sstevel@tonic-gate  * 2.1. This is your license from Intel Corp. under its intellectual property
170Sstevel@tonic-gate  * rights.  You may have additional license terms from the party that provided
180Sstevel@tonic-gate  * you this software, covering your right to use that party's intellectual
190Sstevel@tonic-gate  * property rights.
200Sstevel@tonic-gate  *
210Sstevel@tonic-gate  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
220Sstevel@tonic-gate  * copy of the source code appearing in this file ("Covered Code") an
230Sstevel@tonic-gate  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
240Sstevel@tonic-gate  * base code distributed originally by Intel ("Original Intel Code") to copy,
250Sstevel@tonic-gate  * make derivatives, distribute, use and display any portion of the Covered
260Sstevel@tonic-gate  * Code in any form, with the right to sublicense such rights; and
270Sstevel@tonic-gate  *
280Sstevel@tonic-gate  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
290Sstevel@tonic-gate  * license (with the right to sublicense), under only those claims of Intel
300Sstevel@tonic-gate  * patents that are infringed by the Original Intel Code, to make, use, sell,
310Sstevel@tonic-gate  * offer to sell, and import the Covered Code and derivative works thereof
320Sstevel@tonic-gate  * solely to the minimum extent necessary to exercise the above copyright
330Sstevel@tonic-gate  * license, and in no event shall the patent license extend to any additions
340Sstevel@tonic-gate  * to or modifications of the Original Intel Code.  No other license or right
350Sstevel@tonic-gate  * is granted directly or by implication, estoppel or otherwise;
360Sstevel@tonic-gate  *
370Sstevel@tonic-gate  * The above copyright and patent license is granted only if the following
380Sstevel@tonic-gate  * conditions are met:
390Sstevel@tonic-gate  *
400Sstevel@tonic-gate  * 3. Conditions
410Sstevel@tonic-gate  *
420Sstevel@tonic-gate  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
430Sstevel@tonic-gate  * Redistribution of source code of any substantial portion of the Covered
440Sstevel@tonic-gate  * Code or modification with rights to further distribute source must include
450Sstevel@tonic-gate  * the above Copyright Notice, the above License, this list of Conditions,
460Sstevel@tonic-gate  * and the following Disclaimer and Export Compliance provision.  In addition,
470Sstevel@tonic-gate  * Licensee must cause all Covered Code to which Licensee contributes to
480Sstevel@tonic-gate  * contain a file documenting the changes Licensee made to create that Covered
490Sstevel@tonic-gate  * Code and the date of any change.  Licensee must include in that file the
500Sstevel@tonic-gate  * documentation of any changes made by any predecessor Licensee.  Licensee
510Sstevel@tonic-gate  * must include a prominent statement that the modification is derived,
520Sstevel@tonic-gate  * directly or indirectly, from Original Intel Code.
530Sstevel@tonic-gate  *
540Sstevel@tonic-gate  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
550Sstevel@tonic-gate  * Redistribution of source code of any substantial portion of the Covered
560Sstevel@tonic-gate  * Code or modification without rights to further distribute source must
570Sstevel@tonic-gate  * include the following Disclaimer and Export Compliance provision in the
580Sstevel@tonic-gate  * documentation and/or other materials provided with distribution.  In
590Sstevel@tonic-gate  * addition, Licensee may not authorize further sublicense of source of any
600Sstevel@tonic-gate  * portion of the Covered Code, and must include terms to the effect that the
610Sstevel@tonic-gate  * license from Licensee to its licensee is limited to the intellectual
620Sstevel@tonic-gate  * property embodied in the software Licensee provides to its licensee, and
630Sstevel@tonic-gate  * not to intellectual property embodied in modifications its licensee may
640Sstevel@tonic-gate  * make.
650Sstevel@tonic-gate  *
660Sstevel@tonic-gate  * 3.3. Redistribution of Executable. Redistribution in executable form of any
670Sstevel@tonic-gate  * substantial portion of the Covered Code or modification must reproduce the
680Sstevel@tonic-gate  * above Copyright Notice, and the following Disclaimer and Export Compliance
690Sstevel@tonic-gate  * provision in the documentation and/or other materials provided with the
700Sstevel@tonic-gate  * distribution.
710Sstevel@tonic-gate  *
720Sstevel@tonic-gate  * 3.4. Intel retains all right, title, and interest in and to the Original
730Sstevel@tonic-gate  * Intel Code.
740Sstevel@tonic-gate  *
750Sstevel@tonic-gate  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
760Sstevel@tonic-gate  * Intel shall be used in advertising or otherwise to promote the sale, use or
770Sstevel@tonic-gate  * other dealings in products derived from or relating to the Covered Code
780Sstevel@tonic-gate  * without prior written authorization from Intel.
790Sstevel@tonic-gate  *
800Sstevel@tonic-gate  * 4. Disclaimer and Export Compliance
810Sstevel@tonic-gate  *
820Sstevel@tonic-gate  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
830Sstevel@tonic-gate  * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
840Sstevel@tonic-gate  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
850Sstevel@tonic-gate  * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
860Sstevel@tonic-gate  * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
870Sstevel@tonic-gate  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
880Sstevel@tonic-gate  * PARTICULAR PURPOSE.
890Sstevel@tonic-gate  *
900Sstevel@tonic-gate  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
910Sstevel@tonic-gate  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
920Sstevel@tonic-gate  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
930Sstevel@tonic-gate  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
940Sstevel@tonic-gate  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
950Sstevel@tonic-gate  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
960Sstevel@tonic-gate  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
970Sstevel@tonic-gate  * LIMITED REMEDY.
980Sstevel@tonic-gate  *
990Sstevel@tonic-gate  * 4.3. Licensee shall not export, either directly or indirectly, any of this
1000Sstevel@tonic-gate  * software or system incorporating such software without first obtaining any
1010Sstevel@tonic-gate  * required license or other approval from the U. S. Department of Commerce or
1020Sstevel@tonic-gate  * any other agency or department of the United States Government.  In the
1030Sstevel@tonic-gate  * event Licensee exports any such software from the United States or
1040Sstevel@tonic-gate  * re-exports any such software from a foreign destination, Licensee shall
1050Sstevel@tonic-gate  * ensure that the distribution and export/re-export of the software is in
1060Sstevel@tonic-gate  * compliance with all laws, regulations, orders, or other restrictions of the
1070Sstevel@tonic-gate  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
1080Sstevel@tonic-gate  * any of its subsidiaries will export/re-export any technical data, process,
1090Sstevel@tonic-gate  * software, or service, directly or indirectly, to any country for which the
1100Sstevel@tonic-gate  * United States government or any agency thereof requires an export license,
1110Sstevel@tonic-gate  * other governmental approval, or letter of assurance, without first obtaining
1120Sstevel@tonic-gate  * such license, approval or letter.
1130Sstevel@tonic-gate  *
1140Sstevel@tonic-gate  *****************************************************************************/
1150Sstevel@tonic-gate 
1160Sstevel@tonic-gate #ifndef __ACMACROS_H__
1170Sstevel@tonic-gate #define __ACMACROS_H__
1180Sstevel@tonic-gate 
1190Sstevel@tonic-gate 
1200Sstevel@tonic-gate /*
1217851SDana.Myers@Sun.COM  * Extract data using a pointer. Any more than a byte and we
1221560Smyers  * get into potential aligment issues -- see the STORE macros below.
1231560Smyers  * Use with care.
1240Sstevel@tonic-gate  */
1251560Smyers #define ACPI_GET8(ptr)                  *ACPI_CAST_PTR (UINT8, ptr)
1261560Smyers #define ACPI_GET16(ptr)                 *ACPI_CAST_PTR (UINT16, ptr)
1271560Smyers #define ACPI_GET32(ptr)                 *ACPI_CAST_PTR (UINT32, ptr)
1281560Smyers #define ACPI_GET64(ptr)                 *ACPI_CAST_PTR (UINT64, ptr)
1291560Smyers #define ACPI_SET8(ptr)                  *ACPI_CAST_PTR (UINT8, ptr)
1301560Smyers #define ACPI_SET16(ptr)                 *ACPI_CAST_PTR (UINT16, ptr)
1311560Smyers #define ACPI_SET32(ptr)                 *ACPI_CAST_PTR (UINT32, ptr)
1321560Smyers #define ACPI_SET64(ptr)                 *ACPI_CAST_PTR (UINT64, ptr)
1330Sstevel@tonic-gate 
1341560Smyers /*
1357851SDana.Myers@Sun.COM  * printf() format helpers
1367851SDana.Myers@Sun.COM  */
1377851SDana.Myers@Sun.COM 
1387851SDana.Myers@Sun.COM /* Split 64-bit integer into two 32-bit values. Use with %8.8X%8.8X */
1397851SDana.Myers@Sun.COM 
1407851SDana.Myers@Sun.COM #define ACPI_FORMAT_UINT64(i)           ACPI_HIDWORD(i), ACPI_LODWORD(i)
1417851SDana.Myers@Sun.COM 
1427851SDana.Myers@Sun.COM #if ACPI_MACHINE_WIDTH == 64
1437851SDana.Myers@Sun.COM #define ACPI_FORMAT_NATIVE_UINT(i)      ACPI_FORMAT_UINT64(i)
1447851SDana.Myers@Sun.COM #else
1457851SDana.Myers@Sun.COM #define ACPI_FORMAT_NATIVE_UINT(i)      0, (i)
1467851SDana.Myers@Sun.COM #endif
1477851SDana.Myers@Sun.COM 
1487851SDana.Myers@Sun.COM 
1497851SDana.Myers@Sun.COM /*
1500Sstevel@tonic-gate  * Macros for moving data around to/from buffers that are possibly unaligned.
1510Sstevel@tonic-gate  * If the hardware supports the transfer of unaligned data, just do the store.
1520Sstevel@tonic-gate  * Otherwise, we have to move one byte at a time.
1530Sstevel@tonic-gate  */
1540Sstevel@tonic-gate #ifdef ACPI_BIG_ENDIAN
1550Sstevel@tonic-gate /*
1560Sstevel@tonic-gate  * Macros for big-endian machines
1570Sstevel@tonic-gate  */
1580Sstevel@tonic-gate 
1590Sstevel@tonic-gate /* These macros reverse the bytes during the move, converting little-endian to big endian */
1600Sstevel@tonic-gate 
1610Sstevel@tonic-gate                                                      /* Big Endian      <==        Little Endian */
1620Sstevel@tonic-gate                                                      /*  Hi...Lo                     Lo...Hi     */
1630Sstevel@tonic-gate /* 16-bit source, 16/32/64 destination */
1640Sstevel@tonic-gate 
1657851SDana.Myers@Sun.COM #define ACPI_MOVE_16_TO_16(d, s)        {((  UINT8 *)(void *)(d))[0] = ((UINT8 *)(void *)(s))[1];\
1660Sstevel@tonic-gate                                          ((  UINT8 *)(void *)(d))[1] = ((UINT8 *)(void *)(s))[0];}
1670Sstevel@tonic-gate 
1687851SDana.Myers@Sun.COM #define ACPI_MOVE_16_TO_32(d, s)        {(*(UINT32 *)(void *)(d))=0;\
1690Sstevel@tonic-gate                                            ((UINT8 *)(void *)(d))[2] = ((UINT8 *)(void *)(s))[1];\
1700Sstevel@tonic-gate                                            ((UINT8 *)(void *)(d))[3] = ((UINT8 *)(void *)(s))[0];}
1710Sstevel@tonic-gate 
1727851SDana.Myers@Sun.COM #define ACPI_MOVE_16_TO_64(d, s)        {(*(UINT64 *)(void *)(d))=0;\
1730Sstevel@tonic-gate                                            ((UINT8 *)(void *)(d))[6] = ((UINT8 *)(void *)(s))[1];\
1740Sstevel@tonic-gate                                            ((UINT8 *)(void *)(d))[7] = ((UINT8 *)(void *)(s))[0];}
1750Sstevel@tonic-gate 
1760Sstevel@tonic-gate /* 32-bit source, 16/32/64 destination */
1770Sstevel@tonic-gate 
1787851SDana.Myers@Sun.COM #define ACPI_MOVE_32_TO_16(d, s)        ACPI_MOVE_16_TO_16(d, s)    /* Truncate to 16 */
1790Sstevel@tonic-gate 
1807851SDana.Myers@Sun.COM #define ACPI_MOVE_32_TO_32(d, s)        {((  UINT8 *)(void *)(d))[0] = ((UINT8 *)(void *)(s))[3];\
1810Sstevel@tonic-gate                                          ((  UINT8 *)(void *)(d))[1] = ((UINT8 *)(void *)(s))[2];\
1820Sstevel@tonic-gate                                          ((  UINT8 *)(void *)(d))[2] = ((UINT8 *)(void *)(s))[1];\
1830Sstevel@tonic-gate                                          ((  UINT8 *)(void *)(d))[3] = ((UINT8 *)(void *)(s))[0];}
1840Sstevel@tonic-gate 
1857851SDana.Myers@Sun.COM #define ACPI_MOVE_32_TO_64(d, s)        {(*(UINT64 *)(void *)(d))=0;\
1860Sstevel@tonic-gate                                            ((UINT8 *)(void *)(d))[4] = ((UINT8 *)(void *)(s))[3];\
1870Sstevel@tonic-gate                                            ((UINT8 *)(void *)(d))[5] = ((UINT8 *)(void *)(s))[2];\
1880Sstevel@tonic-gate                                            ((UINT8 *)(void *)(d))[6] = ((UINT8 *)(void *)(s))[1];\
1890Sstevel@tonic-gate                                            ((UINT8 *)(void *)(d))[7] = ((UINT8 *)(void *)(s))[0];}
1900Sstevel@tonic-gate 
1910Sstevel@tonic-gate /* 64-bit source, 16/32/64 destination */
1920Sstevel@tonic-gate 
1937851SDana.Myers@Sun.COM #define ACPI_MOVE_64_TO_16(d, s)        ACPI_MOVE_16_TO_16(d, s)    /* Truncate to 16 */
1940Sstevel@tonic-gate 
1957851SDana.Myers@Sun.COM #define ACPI_MOVE_64_TO_32(d, s)        ACPI_MOVE_32_TO_32(d, s)    /* Truncate to 32 */
1960Sstevel@tonic-gate 
1977851SDana.Myers@Sun.COM #define ACPI_MOVE_64_TO_64(d, s)        {((  UINT8 *)(void *)(d))[0] = ((UINT8 *)(void *)(s))[7];\
1980Sstevel@tonic-gate                                          ((  UINT8 *)(void *)(d))[1] = ((UINT8 *)(void *)(s))[6];\
1990Sstevel@tonic-gate                                          ((  UINT8 *)(void *)(d))[2] = ((UINT8 *)(void *)(s))[5];\
2000Sstevel@tonic-gate                                          ((  UINT8 *)(void *)(d))[3] = ((UINT8 *)(void *)(s))[4];\
2010Sstevel@tonic-gate                                          ((  UINT8 *)(void *)(d))[4] = ((UINT8 *)(void *)(s))[3];\
2020Sstevel@tonic-gate                                          ((  UINT8 *)(void *)(d))[5] = ((UINT8 *)(void *)(s))[2];\
2030Sstevel@tonic-gate                                          ((  UINT8 *)(void *)(d))[6] = ((UINT8 *)(void *)(s))[1];\
2040Sstevel@tonic-gate                                          ((  UINT8 *)(void *)(d))[7] = ((UINT8 *)(void *)(s))[0];}
2050Sstevel@tonic-gate #else
2060Sstevel@tonic-gate /*
2070Sstevel@tonic-gate  * Macros for little-endian machines
2080Sstevel@tonic-gate  */
2090Sstevel@tonic-gate 
2101560Smyers #ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED
2110Sstevel@tonic-gate 
2120Sstevel@tonic-gate /* The hardware supports unaligned transfers, just do the little-endian move */
2130Sstevel@tonic-gate 
2140Sstevel@tonic-gate /* 16-bit source, 16/32/64 destination */
2150Sstevel@tonic-gate 
2167851SDana.Myers@Sun.COM #define ACPI_MOVE_16_TO_16(d, s)        *(UINT16 *)(void *)(d) = *(UINT16 *)(void *)(s)
2177851SDana.Myers@Sun.COM #define ACPI_MOVE_16_TO_32(d, s)        *(UINT32 *)(void *)(d) = *(UINT16 *)(void *)(s)
2187851SDana.Myers@Sun.COM #define ACPI_MOVE_16_TO_64(d, s)        *(UINT64 *)(void *)(d) = *(UINT16 *)(void *)(s)
2190Sstevel@tonic-gate 
2200Sstevel@tonic-gate /* 32-bit source, 16/32/64 destination */
2210Sstevel@tonic-gate 
2227851SDana.Myers@Sun.COM #define ACPI_MOVE_32_TO_16(d, s)        ACPI_MOVE_16_TO_16(d, s)    /* Truncate to 16 */
2237851SDana.Myers@Sun.COM #define ACPI_MOVE_32_TO_32(d, s)        *(UINT32 *)(void *)(d) = *(UINT32 *)(void *)(s)
2247851SDana.Myers@Sun.COM #define ACPI_MOVE_32_TO_64(d, s)        *(UINT64 *)(void *)(d) = *(UINT32 *)(void *)(s)
2250Sstevel@tonic-gate 
2260Sstevel@tonic-gate /* 64-bit source, 16/32/64 destination */
2270Sstevel@tonic-gate 
2287851SDana.Myers@Sun.COM #define ACPI_MOVE_64_TO_16(d, s)        ACPI_MOVE_16_TO_16(d, s)    /* Truncate to 16 */
2297851SDana.Myers@Sun.COM #define ACPI_MOVE_64_TO_32(d, s)        ACPI_MOVE_32_TO_32(d, s)    /* Truncate to 32 */
2307851SDana.Myers@Sun.COM #define ACPI_MOVE_64_TO_64(d, s)        *(UINT64 *)(void *)(d) = *(UINT64 *)(void *)(s)
2310Sstevel@tonic-gate 
2320Sstevel@tonic-gate #else
2330Sstevel@tonic-gate /*
2347851SDana.Myers@Sun.COM  * The hardware does not support unaligned transfers. We must move the
2357851SDana.Myers@Sun.COM  * data one byte at a time. These macros work whether the source or
2369980SDana.Myers@Sun.COM  * the destination (or both) is/are unaligned. (Little-endian move)
2370Sstevel@tonic-gate  */
2380Sstevel@tonic-gate 
2390Sstevel@tonic-gate /* 16-bit source, 16/32/64 destination */
2400Sstevel@tonic-gate 
2417851SDana.Myers@Sun.COM #define ACPI_MOVE_16_TO_16(d, s)        {((  UINT8 *)(void *)(d))[0] = ((UINT8 *)(void *)(s))[0];\
2420Sstevel@tonic-gate                                          ((  UINT8 *)(void *)(d))[1] = ((UINT8 *)(void *)(s))[1];}
2430Sstevel@tonic-gate 
2447851SDana.Myers@Sun.COM #define ACPI_MOVE_16_TO_32(d, s)        {(*(UINT32 *)(void *)(d)) = 0; ACPI_MOVE_16_TO_16(d, s);}
2457851SDana.Myers@Sun.COM #define ACPI_MOVE_16_TO_64(d, s)        {(*(UINT64 *)(void *)(d)) = 0; ACPI_MOVE_16_TO_16(d, s);}
2460Sstevel@tonic-gate 
2470Sstevel@tonic-gate /* 32-bit source, 16/32/64 destination */
2480Sstevel@tonic-gate 
2497851SDana.Myers@Sun.COM #define ACPI_MOVE_32_TO_16(d, s)        ACPI_MOVE_16_TO_16(d, s)    /* Truncate to 16 */
2500Sstevel@tonic-gate 
2517851SDana.Myers@Sun.COM #define ACPI_MOVE_32_TO_32(d, s)        {((  UINT8 *)(void *)(d))[0] = ((UINT8 *)(void *)(s))[0];\
2520Sstevel@tonic-gate                                          ((  UINT8 *)(void *)(d))[1] = ((UINT8 *)(void *)(s))[1];\
2530Sstevel@tonic-gate                                          ((  UINT8 *)(void *)(d))[2] = ((UINT8 *)(void *)(s))[2];\
2540Sstevel@tonic-gate                                          ((  UINT8 *)(void *)(d))[3] = ((UINT8 *)(void *)(s))[3];}
2550Sstevel@tonic-gate 
2567851SDana.Myers@Sun.COM #define ACPI_MOVE_32_TO_64(d, s)        {(*(UINT64 *)(void *)(d)) = 0; ACPI_MOVE_32_TO_32(d, s);}
2570Sstevel@tonic-gate 
2580Sstevel@tonic-gate /* 64-bit source, 16/32/64 destination */
2590Sstevel@tonic-gate 
2607851SDana.Myers@Sun.COM #define ACPI_MOVE_64_TO_16(d, s)        ACPI_MOVE_16_TO_16(d, s)    /* Truncate to 16 */
2617851SDana.Myers@Sun.COM #define ACPI_MOVE_64_TO_32(d, s)        ACPI_MOVE_32_TO_32(d, s)    /* Truncate to 32 */
2627851SDana.Myers@Sun.COM #define ACPI_MOVE_64_TO_64(d, s)        {((  UINT8 *)(void *)(d))[0] = ((UINT8 *)(void *)(s))[0];\
2630Sstevel@tonic-gate                                          ((  UINT8 *)(void *)(d))[1] = ((UINT8 *)(void *)(s))[1];\
2640Sstevel@tonic-gate                                          ((  UINT8 *)(void *)(d))[2] = ((UINT8 *)(void *)(s))[2];\
2650Sstevel@tonic-gate                                          ((  UINT8 *)(void *)(d))[3] = ((UINT8 *)(void *)(s))[3];\
2660Sstevel@tonic-gate                                          ((  UINT8 *)(void *)(d))[4] = ((UINT8 *)(void *)(s))[4];\
2670Sstevel@tonic-gate                                          ((  UINT8 *)(void *)(d))[5] = ((UINT8 *)(void *)(s))[5];\
2680Sstevel@tonic-gate                                          ((  UINT8 *)(void *)(d))[6] = ((UINT8 *)(void *)(s))[6];\
2690Sstevel@tonic-gate                                          ((  UINT8 *)(void *)(d))[7] = ((UINT8 *)(void *)(s))[7];}
2700Sstevel@tonic-gate #endif
2710Sstevel@tonic-gate #endif
2720Sstevel@tonic-gate 
2730Sstevel@tonic-gate 
2740Sstevel@tonic-gate /*
2750Sstevel@tonic-gate  * Fast power-of-two math macros for non-optimized compilers
2760Sstevel@tonic-gate  */
2777851SDana.Myers@Sun.COM #define _ACPI_DIV(value, PowerOf2)      ((UINT32) ((value) >> (PowerOf2)))
2787851SDana.Myers@Sun.COM #define _ACPI_MUL(value, PowerOf2)      ((UINT32) ((value) << (PowerOf2)))
2797851SDana.Myers@Sun.COM #define _ACPI_MOD(value, Divisor)       ((UINT32) ((value) & ((Divisor) -1)))
2800Sstevel@tonic-gate 
2817851SDana.Myers@Sun.COM #define ACPI_DIV_2(a)                   _ACPI_DIV(a, 1)
2827851SDana.Myers@Sun.COM #define ACPI_MUL_2(a)                   _ACPI_MUL(a, 1)
2837851SDana.Myers@Sun.COM #define ACPI_MOD_2(a)                   _ACPI_MOD(a, 2)
2840Sstevel@tonic-gate 
2857851SDana.Myers@Sun.COM #define ACPI_DIV_4(a)                   _ACPI_DIV(a, 2)
2867851SDana.Myers@Sun.COM #define ACPI_MUL_4(a)                   _ACPI_MUL(a, 2)
2877851SDana.Myers@Sun.COM #define ACPI_MOD_4(a)                   _ACPI_MOD(a, 4)
2880Sstevel@tonic-gate 
2897851SDana.Myers@Sun.COM #define ACPI_DIV_8(a)                   _ACPI_DIV(a, 3)
2907851SDana.Myers@Sun.COM #define ACPI_MUL_8(a)                   _ACPI_MUL(a, 3)
2917851SDana.Myers@Sun.COM #define ACPI_MOD_8(a)                   _ACPI_MOD(a, 8)
2920Sstevel@tonic-gate 
2937851SDana.Myers@Sun.COM #define ACPI_DIV_16(a)                  _ACPI_DIV(a, 4)
2947851SDana.Myers@Sun.COM #define ACPI_MUL_16(a)                  _ACPI_MUL(a, 4)
2957851SDana.Myers@Sun.COM #define ACPI_MOD_16(a)                  _ACPI_MOD(a, 16)
2960Sstevel@tonic-gate 
2977851SDana.Myers@Sun.COM #define ACPI_DIV_32(a)                  _ACPI_DIV(a, 5)
2987851SDana.Myers@Sun.COM #define ACPI_MUL_32(a)                  _ACPI_MUL(a, 5)
2997851SDana.Myers@Sun.COM #define ACPI_MOD_32(a)                  _ACPI_MOD(a, 32)
3000Sstevel@tonic-gate 
3010Sstevel@tonic-gate /*
3020Sstevel@tonic-gate  * Rounding macros (Power of two boundaries only)
3030Sstevel@tonic-gate  */
3047851SDana.Myers@Sun.COM #define ACPI_ROUND_DOWN(value, boundary)    (((ACPI_SIZE)(value)) & \
3057851SDana.Myers@Sun.COM                                                 (~(((ACPI_SIZE) boundary)-1)))
3060Sstevel@tonic-gate 
3077851SDana.Myers@Sun.COM #define ACPI_ROUND_UP(value, boundary)      ((((ACPI_SIZE)(value)) + \
3087851SDana.Myers@Sun.COM                                                 (((ACPI_SIZE) boundary)-1)) & \
3097851SDana.Myers@Sun.COM                                                 (~(((ACPI_SIZE) boundary)-1)))
3101560Smyers 
3117851SDana.Myers@Sun.COM /* Note: sizeof(ACPI_SIZE) evaluates to either 4 or 8 (32- vs 64-bit mode) */
3120Sstevel@tonic-gate 
3137851SDana.Myers@Sun.COM #define ACPI_ROUND_DOWN_TO_32BIT(a)         ACPI_ROUND_DOWN(a, 4)
3147851SDana.Myers@Sun.COM #define ACPI_ROUND_DOWN_TO_64BIT(a)         ACPI_ROUND_DOWN(a, 8)
3157851SDana.Myers@Sun.COM #define ACPI_ROUND_DOWN_TO_NATIVE_WORD(a)   ACPI_ROUND_DOWN(a, sizeof(ACPI_SIZE))
3160Sstevel@tonic-gate 
3177851SDana.Myers@Sun.COM #define ACPI_ROUND_UP_TO_32BIT(a)           ACPI_ROUND_UP(a, 4)
3187851SDana.Myers@Sun.COM #define ACPI_ROUND_UP_TO_64BIT(a)           ACPI_ROUND_UP(a, 8)
3197851SDana.Myers@Sun.COM #define ACPI_ROUND_UP_TO_NATIVE_WORD(a)     ACPI_ROUND_UP(a, sizeof(ACPI_SIZE))
3200Sstevel@tonic-gate 
3211560Smyers #define ACPI_ROUND_BITS_UP_TO_BYTES(a)      ACPI_DIV_8((a) + 7)
3221560Smyers #define ACPI_ROUND_BITS_DOWN_TO_BYTES(a)    ACPI_DIV_8((a))
3231560Smyers 
3241560Smyers #define ACPI_ROUND_UP_TO_1K(a)              (((a) + 1023) >> 10)
3250Sstevel@tonic-gate 
3260Sstevel@tonic-gate /* Generic (non-power-of-two) rounding */
3270Sstevel@tonic-gate 
3287851SDana.Myers@Sun.COM #define ACPI_ROUND_UP_TO(value, boundary)   (((value) + ((boundary)-1)) / (boundary))
3291560Smyers 
3307851SDana.Myers@Sun.COM #define ACPI_IS_MISALIGNED(value)           (((ACPI_SIZE) value) & (sizeof(ACPI_SIZE)-1))
3310Sstevel@tonic-gate 
3320Sstevel@tonic-gate /*
3330Sstevel@tonic-gate  * Bitmask creation
3340Sstevel@tonic-gate  * Bit positions start at zero.
3350Sstevel@tonic-gate  * MASK_BITS_ABOVE creates a mask starting AT the position and above
3360Sstevel@tonic-gate  * MASK_BITS_BELOW creates a mask starting one bit BELOW the position
3370Sstevel@tonic-gate  */
3381560Smyers #define ACPI_MASK_BITS_ABOVE(position)      (~((ACPI_INTEGER_MAX) << ((UINT32) (position))))
3391560Smyers #define ACPI_MASK_BITS_BELOW(position)      ((ACPI_INTEGER_MAX) << ((UINT32) (position)))
3400Sstevel@tonic-gate 
3410Sstevel@tonic-gate /* Bitfields within ACPI registers */
3420Sstevel@tonic-gate 
3430Sstevel@tonic-gate #define ACPI_REGISTER_PREPARE_BITS(Val, Pos, Mask)      ((Val << Pos) & Mask)
3440Sstevel@tonic-gate #define ACPI_REGISTER_INSERT_VALUE(Reg, Pos, Mask, Val)  Reg = (Reg & (~(Mask))) | ACPI_REGISTER_PREPARE_BITS(Val, Pos, Mask)
3450Sstevel@tonic-gate 
3462623Smyers #define ACPI_INSERT_BITS(Target, Mask, Source)          Target = ((Target & (~(Mask))) | (Source & Mask))
3472623Smyers 
3480Sstevel@tonic-gate /*
3497851SDana.Myers@Sun.COM  * An ACPI_NAMESPACE_NODE can appear in some contexts
3507851SDana.Myers@Sun.COM  * where a pointer to an ACPI_OPERAND_OBJECT can also
3517851SDana.Myers@Sun.COM  * appear. This macro is used to distinguish them.
3520Sstevel@tonic-gate  *
3530Sstevel@tonic-gate  * The "Descriptor" field is the first field in both structures.
3540Sstevel@tonic-gate  */
3552623Smyers #define ACPI_GET_DESCRIPTOR_TYPE(d)     (((ACPI_DESCRIPTOR *)(void *)(d))->Common.DescriptorType)
3567851SDana.Myers@Sun.COM #define ACPI_SET_DESCRIPTOR_TYPE(d, t)  (((ACPI_DESCRIPTOR *)(void *)(d))->Common.DescriptorType = t)
3570Sstevel@tonic-gate 
3580Sstevel@tonic-gate /*
3590Sstevel@tonic-gate  * Macros for the master AML opcode table
3600Sstevel@tonic-gate  */
3617851SDana.Myers@Sun.COM #if defined (ACPI_DISASSEMBLER) || defined (ACPI_DEBUG_OUTPUT)
3627851SDana.Myers@Sun.COM #define ACPI_OP(Name, PArgs, IArgs, ObjType, Class, Type, Flags) \
3637851SDana.Myers@Sun.COM     {Name, (UINT32)(PArgs), (UINT32)(IArgs), (UINT32)(Flags), ObjType, Class, Type}
3640Sstevel@tonic-gate #else
3657851SDana.Myers@Sun.COM #define ACPI_OP(Name, PArgs, IArgs, ObjType, Class, Type, Flags) \
3667851SDana.Myers@Sun.COM     {(UINT32)(PArgs), (UINT32)(IArgs), (UINT32)(Flags), ObjType, Class, Type}
3670Sstevel@tonic-gate #endif
3680Sstevel@tonic-gate 
3690Sstevel@tonic-gate #define ARG_TYPE_WIDTH                  5
3700Sstevel@tonic-gate #define ARG_1(x)                        ((UINT32)(x))
3710Sstevel@tonic-gate #define ARG_2(x)                        ((UINT32)(x) << (1 * ARG_TYPE_WIDTH))
3720Sstevel@tonic-gate #define ARG_3(x)                        ((UINT32)(x) << (2 * ARG_TYPE_WIDTH))
3730Sstevel@tonic-gate #define ARG_4(x)                        ((UINT32)(x) << (3 * ARG_TYPE_WIDTH))
3740Sstevel@tonic-gate #define ARG_5(x)                        ((UINT32)(x) << (4 * ARG_TYPE_WIDTH))
3750Sstevel@tonic-gate #define ARG_6(x)                        ((UINT32)(x) << (5 * ARG_TYPE_WIDTH))
3760Sstevel@tonic-gate 
3770Sstevel@tonic-gate #define ARGI_LIST1(a)                   (ARG_1(a))
3787851SDana.Myers@Sun.COM #define ARGI_LIST2(a, b)                (ARG_1(b)|ARG_2(a))
3797851SDana.Myers@Sun.COM #define ARGI_LIST3(a, b, c)             (ARG_1(c)|ARG_2(b)|ARG_3(a))
3807851SDana.Myers@Sun.COM #define ARGI_LIST4(a, b, c, d)          (ARG_1(d)|ARG_2(c)|ARG_3(b)|ARG_4(a))
3817851SDana.Myers@Sun.COM #define ARGI_LIST5(a, b, c, d, e)       (ARG_1(e)|ARG_2(d)|ARG_3(c)|ARG_4(b)|ARG_5(a))
3827851SDana.Myers@Sun.COM #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))
3830Sstevel@tonic-gate 
3840Sstevel@tonic-gate #define ARGP_LIST1(a)                   (ARG_1(a))
3857851SDana.Myers@Sun.COM #define ARGP_LIST2(a, b)                (ARG_1(a)|ARG_2(b))
3867851SDana.Myers@Sun.COM #define ARGP_LIST3(a, b, c)             (ARG_1(a)|ARG_2(b)|ARG_3(c))
3877851SDana.Myers@Sun.COM #define ARGP_LIST4(a, b, c, d)          (ARG_1(a)|ARG_2(b)|ARG_3(c)|ARG_4(d))
3887851SDana.Myers@Sun.COM #define ARGP_LIST5(a, b, c, d, e)       (ARG_1(a)|ARG_2(b)|ARG_3(c)|ARG_4(d)|ARG_5(e))
3897851SDana.Myers@Sun.COM #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))
3900Sstevel@tonic-gate 
3910Sstevel@tonic-gate #define GET_CURRENT_ARG_TYPE(List)      (List & ((UINT32) 0x1F))
3920Sstevel@tonic-gate #define INCREMENT_ARG_LIST(List)        (List >>= ((UINT32) ARG_TYPE_WIDTH))
3930Sstevel@tonic-gate 
3941560Smyers /*
3951560Smyers  * Ascii error messages can be configured out
3961560Smyers  */
3971560Smyers #ifndef ACPI_NO_ERROR_MESSAGES
3980Sstevel@tonic-gate /*
3991560Smyers  * Error reporting. Callers module and line number are inserted by AE_INFO,
4001560Smyers  * the plist contains a set of parens to allow variable-length lists.
4011560Smyers  * These macros are used for both the debug and non-debug versions of the code.
4020Sstevel@tonic-gate  */
4037851SDana.Myers@Sun.COM #define ACPI_ERROR_NAMESPACE(s, e)      AcpiNsReportError (AE_INFO, s, e);
4047851SDana.Myers@Sun.COM #define ACPI_ERROR_METHOD(s, n, p, e)   AcpiNsReportMethodError (AE_INFO, s, n, p, e);
405*11225SDana.Myers@Sun.COM #define ACPI_WARN_PREDEFINED(plist)     AcpiUtPredefinedWarning plist
406*11225SDana.Myers@Sun.COM #define ACPI_INFO_PREDEFINED(plist)     AcpiUtPredefinedInfo plist
4070Sstevel@tonic-gate 
4080Sstevel@tonic-gate #else
4090Sstevel@tonic-gate 
4101560Smyers /* No error messages */
4110Sstevel@tonic-gate 
4127851SDana.Myers@Sun.COM #define ACPI_ERROR_NAMESPACE(s, e)
4137851SDana.Myers@Sun.COM #define ACPI_ERROR_METHOD(s, n, p, e)
414*11225SDana.Myers@Sun.COM #define ACPI_WARN_PREDEFINED(plist)
415*11225SDana.Myers@Sun.COM #define ACPI_INFO_PREDEFINED(plist)
4169980SDana.Myers@Sun.COM 
4179980SDana.Myers@Sun.COM #endif /* ACPI_NO_ERROR_MESSAGES */
4180Sstevel@tonic-gate 
4190Sstevel@tonic-gate /*
4200Sstevel@tonic-gate  * Debug macros that are conditionally compiled
4210Sstevel@tonic-gate  */
4220Sstevel@tonic-gate #ifdef ACPI_DEBUG_OUTPUT
423347Smyers /*
424347Smyers  * Function entry tracing
425347Smyers  */
426347Smyers #define ACPI_FUNCTION_TRACE(a)          ACPI_FUNCTION_NAME(a) \
427347Smyers                                             AcpiUtTrace(ACPI_DEBUG_PARAMETERS)
4287851SDana.Myers@Sun.COM #define ACPI_FUNCTION_TRACE_PTR(a, b)   ACPI_FUNCTION_NAME(a) \
4297851SDana.Myers@Sun.COM                                             AcpiUtTracePtr(ACPI_DEBUG_PARAMETERS, (void *)b)
4307851SDana.Myers@Sun.COM #define ACPI_FUNCTION_TRACE_U32(a, b)   ACPI_FUNCTION_NAME(a) \
4317851SDana.Myers@Sun.COM                                             AcpiUtTraceU32(ACPI_DEBUG_PARAMETERS, (UINT32)b)
4327851SDana.Myers@Sun.COM #define ACPI_FUNCTION_TRACE_STR(a, b)   ACPI_FUNCTION_NAME(a) \
4337851SDana.Myers@Sun.COM                                             AcpiUtTraceStr(ACPI_DEBUG_PARAMETERS, (char *)b)
434347Smyers 
435347Smyers #define ACPI_FUNCTION_ENTRY()           AcpiUtTrackStackPtr()
4360Sstevel@tonic-gate 
4370Sstevel@tonic-gate /*
4380Sstevel@tonic-gate  * Function exit tracing.
4397851SDana.Myers@Sun.COM  * WARNING: These macros include a return statement. This is usually considered
4400Sstevel@tonic-gate  * bad form, but having a separate exit macro is very ugly and difficult to maintain.
4410Sstevel@tonic-gate  * One of the FUNCTION_TRACE macros above must be used in conjunction with these macros
442347Smyers  * so that "_AcpiFunctionName" is defined.
443941Smyers  *
444941Smyers  * Note: the DO_WHILE0 macro is used to prevent some compilers from complaining
445941Smyers  * about these constructs.
4460Sstevel@tonic-gate  */
4470Sstevel@tonic-gate #ifdef ACPI_USE_DO_WHILE_0
4480Sstevel@tonic-gate #define ACPI_DO_WHILE0(a)               do a while(0)
4490Sstevel@tonic-gate #else
4500Sstevel@tonic-gate #define ACPI_DO_WHILE0(a)               a
4510Sstevel@tonic-gate #endif
4520Sstevel@tonic-gate 
453941Smyers #define return_VOID                     ACPI_DO_WHILE0 ({ \
454941Smyers                                             AcpiUtExit (ACPI_DEBUG_PARAMETERS); \
455941Smyers                                             return;})
456941Smyers /*
457941Smyers  * There are two versions of most of the return macros. The default version is
458941Smyers  * safer, since it avoids side-effects by guaranteeing that the argument will
459941Smyers  * not be evaluated twice.
4601560Smyers  *
461941Smyers  * A less-safe version of the macros is provided for optional use if the
462941Smyers  * compiler uses excessive CPU stack (for example, this may happen in the
463941Smyers  * debug case if code optimzation is disabled.)
464941Smyers  */
465941Smyers #ifndef ACPI_SIMPLE_RETURN_MACROS
466941Smyers 
467941Smyers #define return_ACPI_STATUS(s)           ACPI_DO_WHILE0 ({ \
468941Smyers                                             register ACPI_STATUS _s = (s); \
469941Smyers                                             AcpiUtStatusExit (ACPI_DEBUG_PARAMETERS, _s); \
470941Smyers                                             return (_s); })
471941Smyers #define return_PTR(s)                   ACPI_DO_WHILE0 ({ \
472941Smyers                                             register void *_s = (void *) (s); \
473941Smyers                                             AcpiUtPtrExit (ACPI_DEBUG_PARAMETERS, (UINT8 *) _s); \
474941Smyers                                             return (_s); })
475941Smyers #define return_VALUE(s)                 ACPI_DO_WHILE0 ({ \
476941Smyers                                             register ACPI_INTEGER _s = (s); \
477941Smyers                                             AcpiUtValueExit (ACPI_DEBUG_PARAMETERS, _s); \
478941Smyers                                             return (_s); })
479941Smyers #define return_UINT8(s)                 ACPI_DO_WHILE0 ({ \
480941Smyers                                             register UINT8 _s = (UINT8) (s); \
4811560Smyers                                             AcpiUtValueExit (ACPI_DEBUG_PARAMETERS, (ACPI_INTEGER) _s); \
482941Smyers                                             return (_s); })
483941Smyers #define return_UINT32(s)                ACPI_DO_WHILE0 ({ \
484941Smyers                                             register UINT32 _s = (UINT32) (s); \
4851560Smyers                                             AcpiUtValueExit (ACPI_DEBUG_PARAMETERS, (ACPI_INTEGER) _s); \
486941Smyers                                             return (_s); })
487941Smyers #else /* Use original less-safe macros */
488941Smyers 
489941Smyers #define return_ACPI_STATUS(s)           ACPI_DO_WHILE0 ({ \
490941Smyers                                             AcpiUtStatusExit (ACPI_DEBUG_PARAMETERS, (s)); \
491941Smyers                                             return((s)); })
492941Smyers #define return_PTR(s)                   ACPI_DO_WHILE0 ({ \
493941Smyers                                             AcpiUtPtrExit (ACPI_DEBUG_PARAMETERS, (UINT8 *) (s)); \
494941Smyers                                             return((s)); })
495941Smyers #define return_VALUE(s)                 ACPI_DO_WHILE0 ({ \
496941Smyers                                             AcpiUtValueExit (ACPI_DEBUG_PARAMETERS, (ACPI_INTEGER) (s)); \
497941Smyers                                             return((s)); })
498941Smyers #define return_UINT8(s)                 return_VALUE(s)
499941Smyers #define return_UINT32(s)                return_VALUE(s)
500941Smyers 
501941Smyers #endif /* ACPI_SIMPLE_RETURN_MACROS */
502941Smyers 
5030Sstevel@tonic-gate 
5040Sstevel@tonic-gate /* Conditional execution */
5050Sstevel@tonic-gate 
5060Sstevel@tonic-gate #define ACPI_DEBUG_EXEC(a)              a
5070Sstevel@tonic-gate #define ACPI_DEBUG_ONLY_MEMBERS(a)      a;
5080Sstevel@tonic-gate #define _VERBOSE_STRUCTURES
5090Sstevel@tonic-gate 
5100Sstevel@tonic-gate 
5117851SDana.Myers@Sun.COM /* Various object display routines for debug */
5120Sstevel@tonic-gate 
5137851SDana.Myers@Sun.COM #define ACPI_DUMP_STACK_ENTRY(a)        AcpiExDumpOperand((a), 0)
5147851SDana.Myers@Sun.COM #define ACPI_DUMP_OPERANDS(a, b ,c)     AcpiExDumpOperands(a, b, c)
5157851SDana.Myers@Sun.COM #define ACPI_DUMP_ENTRY(a, b)           AcpiNsDumpEntry (a, b)
5167851SDana.Myers@Sun.COM #define ACPI_DUMP_PATHNAME(a, b, c, d)  AcpiNsDumpPathname(a, b, c, d)
5177851SDana.Myers@Sun.COM #define ACPI_DUMP_BUFFER(a, b)          AcpiUtDumpBuffer((UINT8 *) a, b, DB_BYTE_DISPLAY, _COMPONENT)
5180Sstevel@tonic-gate 
5190Sstevel@tonic-gate #else
5200Sstevel@tonic-gate /*
5210Sstevel@tonic-gate  * This is the non-debug case -- make everything go away,
5220Sstevel@tonic-gate  * leaving no executable debug code!
5230Sstevel@tonic-gate  */
5240Sstevel@tonic-gate #define ACPI_DEBUG_EXEC(a)
5250Sstevel@tonic-gate #define ACPI_DEBUG_ONLY_MEMBERS(a)
5260Sstevel@tonic-gate #define ACPI_FUNCTION_TRACE(a)
5277851SDana.Myers@Sun.COM #define ACPI_FUNCTION_TRACE_PTR(a, b)
5287851SDana.Myers@Sun.COM #define ACPI_FUNCTION_TRACE_U32(a, b)
5297851SDana.Myers@Sun.COM #define ACPI_FUNCTION_TRACE_STR(a, b)
5300Sstevel@tonic-gate #define ACPI_FUNCTION_EXIT
5310Sstevel@tonic-gate #define ACPI_FUNCTION_STATUS_EXIT(s)
5320Sstevel@tonic-gate #define ACPI_FUNCTION_VALUE_EXIT(s)
5330Sstevel@tonic-gate #define ACPI_FUNCTION_ENTRY()
5340Sstevel@tonic-gate #define ACPI_DUMP_STACK_ENTRY(a)
5357851SDana.Myers@Sun.COM #define ACPI_DUMP_OPERANDS(a, b, c)
5367851SDana.Myers@Sun.COM #define ACPI_DUMP_ENTRY(a, b)
5377851SDana.Myers@Sun.COM #define ACPI_DUMP_TABLES(a, b)
5387851SDana.Myers@Sun.COM #define ACPI_DUMP_PATHNAME(a, b, c, d)
5397851SDana.Myers@Sun.COM #define ACPI_DUMP_BUFFER(a, b)
5400Sstevel@tonic-gate #define ACPI_DEBUG_PRINT(pl)
5410Sstevel@tonic-gate #define ACPI_DEBUG_PRINT_RAW(pl)
5420Sstevel@tonic-gate 
5430Sstevel@tonic-gate #define return_VOID                     return
5440Sstevel@tonic-gate #define return_ACPI_STATUS(s)           return(s)
5450Sstevel@tonic-gate #define return_VALUE(s)                 return(s)
546941Smyers #define return_UINT8(s)                 return(s)
547941Smyers #define return_UINT32(s)                return(s)
5480Sstevel@tonic-gate #define return_PTR(s)                   return(s)
5490Sstevel@tonic-gate 
5509980SDana.Myers@Sun.COM #endif /* ACPI_DEBUG_OUTPUT */
5510Sstevel@tonic-gate 
5520Sstevel@tonic-gate /*
5530Sstevel@tonic-gate  * Some code only gets executed when the debugger is built in.
5540Sstevel@tonic-gate  * Note that this is entirely independent of whether the
5550Sstevel@tonic-gate  * DEBUG_PRINT stuff (set by ACPI_DEBUG_OUTPUT) is on, or not.
5560Sstevel@tonic-gate  */
5570Sstevel@tonic-gate #ifdef ACPI_DEBUGGER
5580Sstevel@tonic-gate #define ACPI_DEBUGGER_EXEC(a)           a
5590Sstevel@tonic-gate #else
5600Sstevel@tonic-gate #define ACPI_DEBUGGER_EXEC(a)
5610Sstevel@tonic-gate #endif
5620Sstevel@tonic-gate 
5630Sstevel@tonic-gate 
5640Sstevel@tonic-gate /*
5650Sstevel@tonic-gate  * Memory allocation tracking (DEBUG ONLY)
5660Sstevel@tonic-gate  */
5677851SDana.Myers@Sun.COM #define ACPI_MEM_PARAMETERS         _COMPONENT, _AcpiModuleName, __LINE__
5687851SDana.Myers@Sun.COM 
5690Sstevel@tonic-gate #ifndef ACPI_DBG_TRACK_ALLOCATIONS
5700Sstevel@tonic-gate 
5710Sstevel@tonic-gate /* Memory allocation */
5720Sstevel@tonic-gate 
5737851SDana.Myers@Sun.COM #define ACPI_ALLOCATE(a)            AcpiUtAllocate((ACPI_SIZE) (a), ACPI_MEM_PARAMETERS)
5747851SDana.Myers@Sun.COM #define ACPI_ALLOCATE_ZEROED(a)     AcpiUtAllocateZeroed((ACPI_SIZE) (a), ACPI_MEM_PARAMETERS)
5752623Smyers #define ACPI_FREE(a)                AcpiOsFree(a)
5760Sstevel@tonic-gate #define ACPI_MEM_TRACKING(a)
5770Sstevel@tonic-gate 
5780Sstevel@tonic-gate #else
5790Sstevel@tonic-gate 
5800Sstevel@tonic-gate /* Memory allocation */
5810Sstevel@tonic-gate 
5827851SDana.Myers@Sun.COM #define ACPI_ALLOCATE(a)            AcpiUtAllocateAndTrack((ACPI_SIZE) (a), ACPI_MEM_PARAMETERS)
5837851SDana.Myers@Sun.COM #define ACPI_ALLOCATE_ZEROED(a)     AcpiUtAllocateZeroedAndTrack((ACPI_SIZE) (a), ACPI_MEM_PARAMETERS)
5847851SDana.Myers@Sun.COM #define ACPI_FREE(a)                AcpiUtFreeAndTrack(a, ACPI_MEM_PARAMETERS)
5852623Smyers #define ACPI_MEM_TRACKING(a)        a
5860Sstevel@tonic-gate 
5870Sstevel@tonic-gate #endif /* ACPI_DBG_TRACK_ALLOCATIONS */
5880Sstevel@tonic-gate 
5897851SDana.Myers@Sun.COM 
5907851SDana.Myers@Sun.COM /*
5917851SDana.Myers@Sun.COM  * Macros used for ACPICA utilities only
5927851SDana.Myers@Sun.COM  */
5937851SDana.Myers@Sun.COM 
5947851SDana.Myers@Sun.COM /* Generate a UUID */
5957851SDana.Myers@Sun.COM 
5967851SDana.Myers@Sun.COM #define ACPI_INIT_UUID(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) \
5977851SDana.Myers@Sun.COM     (a) & 0xFF, ((a) >> 8) & 0xFF, ((a) >> 16) & 0xFF, ((a) >> 24) & 0xFF, \
5987851SDana.Myers@Sun.COM     (b) & 0xFF, ((b) >> 8) & 0xFF, \
5997851SDana.Myers@Sun.COM     (c) & 0xFF, ((c) >> 8) & 0xFF, \
6007851SDana.Myers@Sun.COM     (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7)
6017851SDana.Myers@Sun.COM 
6027851SDana.Myers@Sun.COM #define ACPI_IS_OCTAL_DIGIT(d)              (((char)(d) >= '0') && ((char)(d) <= '7'))
6037851SDana.Myers@Sun.COM 
6047851SDana.Myers@Sun.COM 
6050Sstevel@tonic-gate #endif /* ACMACROS_H */
606