Home | History | Annotate | Line # | Download | only in include
      1   1.1    jruoho /******************************************************************************
      2   1.1    jruoho  *
      3   1.1    jruoho  * Name: acmacros.h - C macros for the entire subsystem.
      4   1.1    jruoho  *
      5   1.1    jruoho  *****************************************************************************/
      6   1.1    jruoho 
      7  1.21  christos /******************************************************************************
      8  1.21  christos  *
      9  1.21  christos  * 1. Copyright Notice
     10  1.21  christos  *
     11  1.22  christos  * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
     12   1.1    jruoho  * All rights reserved.
     13   1.1    jruoho  *
     14  1.21  christos  * 2. License
     15  1.21  christos  *
     16  1.21  christos  * 2.1. This is your license from Intel Corp. under its intellectual property
     17  1.21  christos  * rights. You may have additional license terms from the party that provided
     18  1.21  christos  * you this software, covering your right to use that party's intellectual
     19  1.21  christos  * property rights.
     20  1.21  christos  *
     21  1.21  christos  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
     22  1.21  christos  * copy of the source code appearing in this file ("Covered Code") an
     23  1.21  christos  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
     24  1.21  christos  * base code distributed originally by Intel ("Original Intel Code") to copy,
     25  1.21  christos  * make derivatives, distribute, use and display any portion of the Covered
     26  1.21  christos  * Code in any form, with the right to sublicense such rights; and
     27  1.21  christos  *
     28  1.21  christos  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
     29  1.21  christos  * license (with the right to sublicense), under only those claims of Intel
     30  1.21  christos  * patents that are infringed by the Original Intel Code, to make, use, sell,
     31  1.21  christos  * offer to sell, and import the Covered Code and derivative works thereof
     32  1.21  christos  * solely to the minimum extent necessary to exercise the above copyright
     33  1.21  christos  * license, and in no event shall the patent license extend to any additions
     34  1.21  christos  * to or modifications of the Original Intel Code. No other license or right
     35  1.21  christos  * is granted directly or by implication, estoppel or otherwise;
     36  1.21  christos  *
     37  1.21  christos  * The above copyright and patent license is granted only if the following
     38  1.21  christos  * conditions are met:
     39  1.21  christos  *
     40  1.21  christos  * 3. Conditions
     41  1.21  christos  *
     42  1.21  christos  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
     43  1.21  christos  * Redistribution of source code of any substantial portion of the Covered
     44  1.21  christos  * Code or modification with rights to further distribute source must include
     45  1.21  christos  * the above Copyright Notice, the above License, this list of Conditions,
     46  1.21  christos  * and the following Disclaimer and Export Compliance provision. In addition,
     47  1.21  christos  * Licensee must cause all Covered Code to which Licensee contributes to
     48  1.21  christos  * contain a file documenting the changes Licensee made to create that Covered
     49  1.21  christos  * Code and the date of any change. Licensee must include in that file the
     50  1.21  christos  * documentation of any changes made by any predecessor Licensee. Licensee
     51  1.21  christos  * must include a prominent statement that the modification is derived,
     52  1.21  christos  * directly or indirectly, from Original Intel Code.
     53  1.21  christos  *
     54  1.21  christos  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
     55  1.21  christos  * Redistribution of source code of any substantial portion of the Covered
     56  1.21  christos  * Code or modification without rights to further distribute source must
     57  1.21  christos  * include the following Disclaimer and Export Compliance provision in the
     58  1.21  christos  * documentation and/or other materials provided with distribution. In
     59  1.21  christos  * addition, Licensee may not authorize further sublicense of source of any
     60  1.21  christos  * portion of the Covered Code, and must include terms to the effect that the
     61  1.21  christos  * license from Licensee to its licensee is limited to the intellectual
     62  1.21  christos  * property embodied in the software Licensee provides to its licensee, and
     63  1.21  christos  * not to intellectual property embodied in modifications its licensee may
     64  1.21  christos  * make.
     65  1.21  christos  *
     66  1.21  christos  * 3.3. Redistribution of Executable. Redistribution in executable form of any
     67  1.21  christos  * substantial portion of the Covered Code or modification must reproduce the
     68  1.21  christos  * above Copyright Notice, and the following Disclaimer and Export Compliance
     69  1.21  christos  * provision in the documentation and/or other materials provided with the
     70  1.21  christos  * distribution.
     71  1.21  christos  *
     72  1.21  christos  * 3.4. Intel retains all right, title, and interest in and to the Original
     73  1.21  christos  * Intel Code.
     74  1.21  christos  *
     75  1.21  christos  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
     76  1.21  christos  * Intel shall be used in advertising or otherwise to promote the sale, use or
     77  1.21  christos  * other dealings in products derived from or relating to the Covered Code
     78  1.21  christos  * without prior written authorization from Intel.
     79  1.21  christos  *
     80  1.21  christos  * 4. Disclaimer and Export Compliance
     81  1.21  christos  *
     82  1.21  christos  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
     83  1.21  christos  * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
     84  1.21  christos  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
     85  1.21  christos  * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
     86  1.21  christos  * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
     87  1.21  christos  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
     88  1.21  christos  * PARTICULAR PURPOSE.
     89  1.21  christos  *
     90  1.21  christos  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
     91  1.21  christos  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
     92  1.21  christos  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
     93  1.21  christos  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
     94  1.21  christos  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
     95  1.21  christos  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
     96  1.21  christos  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
     97  1.21  christos  * LIMITED REMEDY.
     98  1.21  christos  *
     99  1.21  christos  * 4.3. Licensee shall not export, either directly or indirectly, any of this
    100  1.21  christos  * software or system incorporating such software without first obtaining any
    101  1.21  christos  * required license or other approval from the U. S. Department of Commerce or
    102  1.21  christos  * any other agency or department of the United States Government. In the
    103  1.21  christos  * event Licensee exports any such software from the United States or
    104  1.21  christos  * re-exports any such software from a foreign destination, Licensee shall
    105  1.21  christos  * ensure that the distribution and export/re-export of the software is in
    106  1.21  christos  * compliance with all laws, regulations, orders, or other restrictions of the
    107  1.21  christos  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
    108  1.21  christos  * any of its subsidiaries will export/re-export any technical data, process,
    109  1.21  christos  * software, or service, directly or indirectly, to any country for which the
    110  1.21  christos  * United States government or any agency thereof requires an export license,
    111  1.21  christos  * other governmental approval, or letter of assurance, without first obtaining
    112  1.21  christos  * such license, approval or letter.
    113  1.21  christos  *
    114  1.21  christos  *****************************************************************************
    115  1.21  christos  *
    116  1.21  christos  * Alternatively, you may choose to be licensed under the terms of the
    117  1.21  christos  * following license:
    118  1.21  christos  *
    119   1.3    jruoho  * Redistribution and use in source and binary forms, with or without
    120   1.3    jruoho  * modification, are permitted provided that the following conditions
    121   1.3    jruoho  * are met:
    122   1.3    jruoho  * 1. Redistributions of source code must retain the above copyright
    123   1.3    jruoho  *    notice, this list of conditions, and the following disclaimer,
    124   1.3    jruoho  *    without modification.
    125   1.3    jruoho  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
    126   1.3    jruoho  *    substantially similar to the "NO WARRANTY" disclaimer below
    127   1.3    jruoho  *    ("Disclaimer") and any redistribution must be conditioned upon
    128   1.3    jruoho  *    including a substantially similar Disclaimer requirement for further
    129   1.3    jruoho  *    binary redistribution.
    130   1.3    jruoho  * 3. Neither the names of the above-listed copyright holders nor the names
    131   1.3    jruoho  *    of any contributors may be used to endorse or promote products derived
    132   1.3    jruoho  *    from this software without specific prior written permission.
    133   1.3    jruoho  *
    134   1.3    jruoho  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    135   1.3    jruoho  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    136  1.18  christos  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    137   1.3    jruoho  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    138  1.21  christos  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    139  1.21  christos  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    140  1.21  christos  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    141  1.21  christos  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    142  1.21  christos  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    143  1.21  christos  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    144  1.21  christos  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    145  1.21  christos  *
    146  1.21  christos  * Alternatively, you may choose to be licensed under the terms of the
    147  1.21  christos  * GNU General Public License ("GPL") version 2 as published by the Free
    148  1.21  christos  * Software Foundation.
    149  1.21  christos  *
    150  1.21  christos  *****************************************************************************/
    151   1.1    jruoho 
    152   1.1    jruoho #ifndef __ACMACROS_H__
    153   1.1    jruoho #define __ACMACROS_H__
    154   1.1    jruoho 
    155   1.1    jruoho 
    156   1.1    jruoho /*
    157   1.1    jruoho  * Extract data using a pointer. Any more than a byte and we
    158  1.12  christos  * get into potential alignment issues -- see the STORE macros below.
    159   1.1    jruoho  * Use with care.
    160   1.1    jruoho  */
    161   1.4  christos #define ACPI_CAST8(ptr)                 ACPI_CAST_PTR (UINT8, (ptr))
    162   1.4  christos #define ACPI_CAST16(ptr)                ACPI_CAST_PTR (UINT16, (ptr))
    163   1.4  christos #define ACPI_CAST32(ptr)                ACPI_CAST_PTR (UINT32, (ptr))
    164   1.4  christos #define ACPI_CAST64(ptr)                ACPI_CAST_PTR (UINT64, (ptr))
    165   1.4  christos #define ACPI_GET8(ptr)                  (*ACPI_CAST8 (ptr))
    166   1.4  christos #define ACPI_GET16(ptr)                 (*ACPI_CAST16 (ptr))
    167   1.4  christos #define ACPI_GET32(ptr)                 (*ACPI_CAST32 (ptr))
    168   1.4  christos #define ACPI_GET64(ptr)                 (*ACPI_CAST64 (ptr))
    169   1.4  christos #define ACPI_SET8(ptr, val)             (*ACPI_CAST8 (ptr) = (UINT8) (val))
    170   1.4  christos #define ACPI_SET16(ptr, val)            (*ACPI_CAST16 (ptr) = (UINT16) (val))
    171   1.4  christos #define ACPI_SET32(ptr, val)            (*ACPI_CAST32 (ptr) = (UINT32) (val))
    172   1.4  christos #define ACPI_SET64(ptr, val)            (*ACPI_CAST64 (ptr) = (UINT64) (val))
    173   1.1    jruoho 
    174   1.1    jruoho /*
    175  1.12  christos  * printf() format helper. This macro is a workaround for the difficulties
    176   1.5  christos  * with emitting 64-bit integers and 64-bit pointers with the same code
    177   1.5  christos  * for both 32-bit and 64-bit hosts.
    178   1.1    jruoho  */
    179   1.1    jruoho #define ACPI_FORMAT_UINT64(i)           ACPI_HIDWORD(i), ACPI_LODWORD(i)
    180   1.1    jruoho 
    181   1.1    jruoho 
    182   1.1    jruoho /*
    183   1.1    jruoho  * Macros for moving data around to/from buffers that are possibly unaligned.
    184   1.1    jruoho  * If the hardware supports the transfer of unaligned data, just do the store.
    185   1.1    jruoho  * Otherwise, we have to move one byte at a time.
    186   1.1    jruoho  */
    187   1.1    jruoho #ifdef ACPI_BIG_ENDIAN
    188   1.1    jruoho /*
    189   1.1    jruoho  * Macros for big-endian machines
    190   1.1    jruoho  */
    191   1.1    jruoho 
    192   1.1    jruoho /* These macros reverse the bytes during the move, converting little-endian to big endian */
    193   1.1    jruoho 
    194   1.1    jruoho                                                      /* Big Endian      <==        Little Endian */
    195   1.1    jruoho                                                      /*  Hi...Lo                     Lo...Hi     */
    196   1.1    jruoho /* 16-bit source, 16/32/64 destination */
    197   1.1    jruoho 
    198   1.2    jruoho #define ACPI_MOVE_16_TO_16(d, s)        {((  UINT8 *)(void *)(d))[0] = ((const UINT8 *)(const void *)(s))[1];\
    199   1.2    jruoho                                          ((  UINT8 *)(void *)(d))[1] = ((const UINT8 *)(const void *)(s))[0];}
    200   1.1    jruoho 
    201   1.1    jruoho #define ACPI_MOVE_16_TO_32(d, s)        {(*(UINT32 *)(void *)(d))=0;\
    202   1.2    jruoho                                            ((UINT8 *)(void *)(d))[2] = ((const UINT8 *)(const void *)(s))[1];\
    203   1.2    jruoho                                            ((UINT8 *)(void *)(d))[3] = ((const UINT8 *)(const void *)(s))[0];}
    204   1.1    jruoho 
    205   1.1    jruoho #define ACPI_MOVE_16_TO_64(d, s)        {(*(UINT64 *)(void *)(d))=0;\
    206   1.2    jruoho                                            ((UINT8 *)(void *)(d))[6] = ((const UINT8 *)(const void *)(s))[1];\
    207   1.2    jruoho                                            ((UINT8 *)(void *)(d))[7] = ((const UINT8 *)(const void *)(s))[0];}
    208   1.1    jruoho 
    209   1.1    jruoho /* 32-bit source, 16/32/64 destination */
    210   1.1    jruoho 
    211   1.1    jruoho #define ACPI_MOVE_32_TO_16(d, s)        ACPI_MOVE_16_TO_16(d, s)    /* Truncate to 16 */
    212   1.1    jruoho 
    213   1.2    jruoho #define ACPI_MOVE_32_TO_32(d, s)        {((  UINT8 *)(void *)(d))[0] = ((const UINT8 *)(const void *)(s))[3];\
    214   1.2    jruoho                                          ((  UINT8 *)(void *)(d))[1] = ((const UINT8 *)(const void *)(s))[2];\
    215   1.2    jruoho                                          ((  UINT8 *)(void *)(d))[2] = ((const UINT8 *)(const void *)(s))[1];\
    216   1.2    jruoho                                          ((  UINT8 *)(void *)(d))[3] = ((const UINT8 *)(const void *)(s))[0];}
    217   1.1    jruoho 
    218   1.1    jruoho #define ACPI_MOVE_32_TO_64(d, s)        {(*(UINT64 *)(void *)(d))=0;\
    219   1.2    jruoho                                            ((UINT8 *)(void *)(d))[4] = ((const UINT8 *)(const void *)(s))[3];\
    220   1.2    jruoho                                            ((UINT8 *)(void *)(d))[5] = ((const UINT8 *)(const void *)(s))[2];\
    221   1.2    jruoho                                            ((UINT8 *)(void *)(d))[6] = ((const UINT8 *)(const void *)(s))[1];\
    222   1.2    jruoho                                            ((UINT8 *)(void *)(d))[7] = ((const UINT8 *)(const void *)(s))[0];}
    223   1.1    jruoho 
    224   1.1    jruoho /* 64-bit source, 16/32/64 destination */
    225   1.1    jruoho 
    226   1.1    jruoho #define ACPI_MOVE_64_TO_16(d, s)        ACPI_MOVE_16_TO_16(d, s)    /* Truncate to 16 */
    227   1.1    jruoho 
    228   1.1    jruoho #define ACPI_MOVE_64_TO_32(d, s)        ACPI_MOVE_32_TO_32(d, s)    /* Truncate to 32 */
    229   1.1    jruoho 
    230   1.2    jruoho #define ACPI_MOVE_64_TO_64(d, s)        {((  UINT8 *)(void *)(d))[0] = ((const UINT8 *)(const void *)(s))[7];\
    231   1.2    jruoho                                          ((  UINT8 *)(void *)(d))[1] = ((const UINT8 *)(const void *)(s))[6];\
    232   1.2    jruoho                                          ((  UINT8 *)(void *)(d))[2] = ((const UINT8 *)(const void *)(s))[5];\
    233   1.2    jruoho                                          ((  UINT8 *)(void *)(d))[3] = ((const UINT8 *)(const void *)(s))[4];\
    234   1.2    jruoho                                          ((  UINT8 *)(void *)(d))[4] = ((const UINT8 *)(const void *)(s))[3];\
    235   1.2    jruoho                                          ((  UINT8 *)(void *)(d))[5] = ((const UINT8 *)(const void *)(s))[2];\
    236   1.2    jruoho                                          ((  UINT8 *)(void *)(d))[6] = ((const UINT8 *)(const void *)(s))[1];\
    237   1.2    jruoho                                          ((  UINT8 *)(void *)(d))[7] = ((const UINT8 *)(const void *)(s))[0];}
    238   1.1    jruoho #else
    239   1.1    jruoho /*
    240   1.1    jruoho  * Macros for little-endian machines
    241   1.1    jruoho  */
    242   1.1    jruoho 
    243   1.1    jruoho #ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED
    244   1.1    jruoho 
    245   1.1    jruoho /* The hardware supports unaligned transfers, just do the little-endian move */
    246   1.1    jruoho 
    247   1.1    jruoho /* 16-bit source, 16/32/64 destination */
    248   1.1    jruoho 
    249   1.2    jruoho #define ACPI_MOVE_16_TO_16(d, s)        *(UINT16 *)(void *)(d) = *(const UINT16 *)(const void *)(s)
    250   1.2    jruoho #define ACPI_MOVE_16_TO_32(d, s)        *(UINT32 *)(void *)(d) = *(const UINT16 *)(const void *)(s)
    251   1.2    jruoho #define ACPI_MOVE_16_TO_64(d, s)        *(UINT64 *)(void *)(d) = *(const UINT16 *)(const void *)(s)
    252   1.1    jruoho 
    253   1.1    jruoho /* 32-bit source, 16/32/64 destination */
    254   1.1    jruoho 
    255   1.1    jruoho #define ACPI_MOVE_32_TO_16(d, s)        ACPI_MOVE_16_TO_16(d, s)    /* Truncate to 16 */
    256   1.2    jruoho #define ACPI_MOVE_32_TO_32(d, s)        *(UINT32 *)(void *)(d) = *(const UINT32 *)(const void *)(s)
    257   1.2    jruoho #define ACPI_MOVE_32_TO_64(d, s)        *(UINT64 *)(void *)(d) = *(const UINT32 *)(const void *)(s)
    258   1.1    jruoho 
    259   1.1    jruoho /* 64-bit source, 16/32/64 destination */
    260   1.1    jruoho 
    261   1.1    jruoho #define ACPI_MOVE_64_TO_16(d, s)        ACPI_MOVE_16_TO_16(d, s)    /* Truncate to 16 */
    262   1.1    jruoho #define ACPI_MOVE_64_TO_32(d, s)        ACPI_MOVE_32_TO_32(d, s)    /* Truncate to 32 */
    263   1.2    jruoho #define ACPI_MOVE_64_TO_64(d, s)        *(UINT64 *)(void *)(d) = *(const UINT64 *)(const void *)(s)
    264   1.1    jruoho 
    265   1.1    jruoho #else
    266   1.1    jruoho /*
    267   1.1    jruoho  * The hardware does not support unaligned transfers. We must move the
    268   1.1    jruoho  * data one byte at a time. These macros work whether the source or
    269   1.1    jruoho  * the destination (or both) is/are unaligned. (Little-endian move)
    270   1.1    jruoho  */
    271   1.1    jruoho 
    272   1.1    jruoho /* 16-bit source, 16/32/64 destination */
    273   1.1    jruoho 
    274   1.2    jruoho #define ACPI_MOVE_16_TO_16(d, s)        {((  UINT8 *)(void *)(d))[0] = ((const UINT8 *)(const void *)(s))[0];\
    275   1.2    jruoho                                          ((  UINT8 *)(void *)(d))[1] = ((const UINT8 *)(const void *)(s))[1];}
    276   1.1    jruoho 
    277   1.1    jruoho #define ACPI_MOVE_16_TO_32(d, s)        {(*(UINT32 *)(void *)(d)) = 0; ACPI_MOVE_16_TO_16(d, s);}
    278   1.1    jruoho #define ACPI_MOVE_16_TO_64(d, s)        {(*(UINT64 *)(void *)(d)) = 0; ACPI_MOVE_16_TO_16(d, s);}
    279   1.1    jruoho 
    280   1.1    jruoho /* 32-bit source, 16/32/64 destination */
    281   1.1    jruoho 
    282   1.1    jruoho #define ACPI_MOVE_32_TO_16(d, s)        ACPI_MOVE_16_TO_16(d, s)    /* Truncate to 16 */
    283   1.1    jruoho 
    284   1.2    jruoho #define ACPI_MOVE_32_TO_32(d, s)        {((  UINT8 *)(void *)(d))[0] = ((const UINT8 *)(const void *)(s))[0];\
    285   1.2    jruoho                                          ((  UINT8 *)(void *)(d))[1] = ((const UINT8 *)(const void *)(s))[1];\
    286   1.2    jruoho                                          ((  UINT8 *)(void *)(d))[2] = ((const UINT8 *)(const void *)(s))[2];\
    287   1.2    jruoho                                          ((  UINT8 *)(void *)(d))[3] = ((const UINT8 *)(const void *)(s))[3];}
    288   1.1    jruoho 
    289   1.1    jruoho #define ACPI_MOVE_32_TO_64(d, s)        {(*(UINT64 *)(void *)(d)) = 0; ACPI_MOVE_32_TO_32(d, s);}
    290   1.1    jruoho 
    291   1.1    jruoho /* 64-bit source, 16/32/64 destination */
    292   1.1    jruoho 
    293   1.1    jruoho #define ACPI_MOVE_64_TO_16(d, s)        ACPI_MOVE_16_TO_16(d, s)    /* Truncate to 16 */
    294   1.1    jruoho #define ACPI_MOVE_64_TO_32(d, s)        ACPI_MOVE_32_TO_32(d, s)    /* Truncate to 32 */
    295   1.2    jruoho #define ACPI_MOVE_64_TO_64(d, s)        {((  UINT8 *)(void *)(d))[0] = ((const UINT8 *)(const void *)(s))[0];\
    296   1.2    jruoho                                          ((  UINT8 *)(void *)(d))[1] = ((const UINT8 *)(const void *)(s))[1];\
    297   1.2    jruoho                                          ((  UINT8 *)(void *)(d))[2] = ((const UINT8 *)(const void *)(s))[2];\
    298   1.2    jruoho                                          ((  UINT8 *)(void *)(d))[3] = ((const UINT8 *)(const void *)(s))[3];\
    299   1.2    jruoho                                          ((  UINT8 *)(void *)(d))[4] = ((const UINT8 *)(const void *)(s))[4];\
    300   1.2    jruoho                                          ((  UINT8 *)(void *)(d))[5] = ((const UINT8 *)(const void *)(s))[5];\
    301   1.2    jruoho                                          ((  UINT8 *)(void *)(d))[6] = ((const UINT8 *)(const void *)(s))[6];\
    302   1.2    jruoho                                          ((  UINT8 *)(void *)(d))[7] = ((const UINT8 *)(const void *)(s))[7];}
    303   1.1    jruoho #endif
    304   1.1    jruoho #endif
    305   1.1    jruoho 
    306   1.1    jruoho 
    307   1.1    jruoho /*
    308   1.1    jruoho  * Fast power-of-two math macros for non-optimized compilers
    309   1.1    jruoho  */
    310   1.1    jruoho #define _ACPI_DIV(value, PowerOf2)      ((UINT32) ((value) >> (PowerOf2)))
    311   1.1    jruoho #define _ACPI_MUL(value, PowerOf2)      ((UINT32) ((value) << (PowerOf2)))
    312   1.1    jruoho #define _ACPI_MOD(value, Divisor)       ((UINT32) ((value) & ((Divisor) -1)))
    313   1.1    jruoho 
    314   1.1    jruoho #define ACPI_DIV_2(a)                   _ACPI_DIV(a, 1)
    315   1.1    jruoho #define ACPI_MUL_2(a)                   _ACPI_MUL(a, 1)
    316   1.1    jruoho #define ACPI_MOD_2(a)                   _ACPI_MOD(a, 2)
    317   1.1    jruoho 
    318   1.1    jruoho #define ACPI_DIV_4(a)                   _ACPI_DIV(a, 2)
    319   1.1    jruoho #define ACPI_MUL_4(a)                   _ACPI_MUL(a, 2)
    320   1.1    jruoho #define ACPI_MOD_4(a)                   _ACPI_MOD(a, 4)
    321   1.1    jruoho 
    322   1.1    jruoho #define ACPI_DIV_8(a)                   _ACPI_DIV(a, 3)
    323   1.1    jruoho #define ACPI_MUL_8(a)                   _ACPI_MUL(a, 3)
    324   1.1    jruoho #define ACPI_MOD_8(a)                   _ACPI_MOD(a, 8)
    325   1.1    jruoho 
    326   1.1    jruoho #define ACPI_DIV_16(a)                  _ACPI_DIV(a, 4)
    327   1.1    jruoho #define ACPI_MUL_16(a)                  _ACPI_MUL(a, 4)
    328   1.1    jruoho #define ACPI_MOD_16(a)                  _ACPI_MOD(a, 16)
    329   1.1    jruoho 
    330   1.1    jruoho #define ACPI_DIV_32(a)                  _ACPI_DIV(a, 5)
    331   1.1    jruoho #define ACPI_MUL_32(a)                  _ACPI_MUL(a, 5)
    332   1.1    jruoho #define ACPI_MOD_32(a)                  _ACPI_MOD(a, 32)
    333   1.1    jruoho 
    334   1.7  christos /* Test for ASCII character */
    335   1.7  christos 
    336   1.7  christos #define ACPI_IS_ASCII(c)                ((c) < 0x80)
    337   1.7  christos 
    338   1.7  christos /* Signed integers */
    339   1.7  christos 
    340   1.7  christos #define ACPI_SIGN_POSITIVE              0
    341   1.7  christos #define ACPI_SIGN_NEGATIVE              1
    342   1.7  christos 
    343   1.7  christos 
    344   1.1    jruoho /*
    345   1.1    jruoho  * Rounding macros (Power of two boundaries only)
    346   1.1    jruoho  */
    347   1.1    jruoho #define ACPI_ROUND_DOWN(value, boundary)    (((ACPI_SIZE)(value)) & \
    348   1.1    jruoho                                                 (~(((ACPI_SIZE) boundary)-1)))
    349   1.1    jruoho 
    350   1.1    jruoho #define ACPI_ROUND_UP(value, boundary)      ((((ACPI_SIZE)(value)) + \
    351   1.1    jruoho                                                 (((ACPI_SIZE) boundary)-1)) & \
    352   1.1    jruoho                                                 (~(((ACPI_SIZE) boundary)-1)))
    353   1.1    jruoho 
    354   1.1    jruoho /* Note: sizeof(ACPI_SIZE) evaluates to either 4 or 8 (32- vs 64-bit mode) */
    355   1.1    jruoho 
    356   1.1    jruoho #define ACPI_ROUND_DOWN_TO_32BIT(a)         ACPI_ROUND_DOWN(a, 4)
    357   1.1    jruoho #define ACPI_ROUND_DOWN_TO_64BIT(a)         ACPI_ROUND_DOWN(a, 8)
    358   1.1    jruoho #define ACPI_ROUND_DOWN_TO_NATIVE_WORD(a)   ACPI_ROUND_DOWN(a, sizeof(ACPI_SIZE))
    359   1.1    jruoho 
    360   1.1    jruoho #define ACPI_ROUND_UP_TO_32BIT(a)           ACPI_ROUND_UP(a, 4)
    361   1.1    jruoho #define ACPI_ROUND_UP_TO_64BIT(a)           ACPI_ROUND_UP(a, 8)
    362   1.1    jruoho #define ACPI_ROUND_UP_TO_NATIVE_WORD(a)     ACPI_ROUND_UP(a, sizeof(ACPI_SIZE))
    363   1.1    jruoho 
    364   1.1    jruoho #define ACPI_ROUND_BITS_UP_TO_BYTES(a)      ACPI_DIV_8((a) + 7)
    365   1.1    jruoho #define ACPI_ROUND_BITS_DOWN_TO_BYTES(a)    ACPI_DIV_8((a))
    366   1.1    jruoho 
    367   1.1    jruoho #define ACPI_ROUND_UP_TO_1K(a)              (((a) + 1023) >> 10)
    368   1.1    jruoho 
    369   1.1    jruoho /* Generic (non-power-of-two) rounding */
    370   1.1    jruoho 
    371   1.1    jruoho #define ACPI_ROUND_UP_TO(value, boundary)   (((value) + ((boundary)-1)) / (boundary))
    372   1.1    jruoho 
    373   1.1    jruoho #define ACPI_IS_MISALIGNED(value)           (((ACPI_SIZE) value) & (sizeof(ACPI_SIZE)-1))
    374   1.1    jruoho 
    375  1.12  christos /* Generic bit manipulation */
    376  1.12  christos 
    377  1.12  christos #ifndef ACPI_USE_NATIVE_BIT_FINDER
    378  1.12  christos 
    379  1.12  christos #define __ACPI_FIND_LAST_BIT_2(a, r)        ((((UINT8)  (a)) & 0x02) ? (r)+1 : (r))
    380  1.12  christos #define __ACPI_FIND_LAST_BIT_4(a, r)        ((((UINT8)  (a)) & 0x0C) ? \
    381  1.12  christos                                              __ACPI_FIND_LAST_BIT_2  ((a)>>2,  (r)+2) : \
    382  1.12  christos                                              __ACPI_FIND_LAST_BIT_2  ((a), (r)))
    383  1.12  christos #define __ACPI_FIND_LAST_BIT_8(a, r)        ((((UINT8)  (a)) & 0xF0) ? \
    384  1.12  christos                                              __ACPI_FIND_LAST_BIT_4  ((a)>>4,  (r)+4) : \
    385  1.12  christos                                              __ACPI_FIND_LAST_BIT_4  ((a), (r)))
    386  1.12  christos #define __ACPI_FIND_LAST_BIT_16(a, r)       ((((UINT16) (a)) & 0xFF00) ? \
    387  1.12  christos                                              __ACPI_FIND_LAST_BIT_8  ((a)>>8,  (r)+8) : \
    388  1.12  christos                                              __ACPI_FIND_LAST_BIT_8  ((a), (r)))
    389  1.12  christos #define __ACPI_FIND_LAST_BIT_32(a, r)       ((((UINT32) (a)) & 0xFFFF0000) ? \
    390  1.12  christos                                              __ACPI_FIND_LAST_BIT_16 ((a)>>16, (r)+16) : \
    391  1.12  christos                                              __ACPI_FIND_LAST_BIT_16 ((a), (r)))
    392  1.12  christos #define __ACPI_FIND_LAST_BIT_64(a, r)       ((((UINT64) (a)) & 0xFFFFFFFF00000000) ? \
    393  1.12  christos                                              __ACPI_FIND_LAST_BIT_32 ((a)>>32, (r)+32) : \
    394  1.12  christos                                              __ACPI_FIND_LAST_BIT_32 ((a), (r)))
    395  1.12  christos 
    396  1.12  christos #define ACPI_FIND_LAST_BIT_8(a)             ((a) ? __ACPI_FIND_LAST_BIT_8 (a, 1) : 0)
    397  1.12  christos #define ACPI_FIND_LAST_BIT_16(a)            ((a) ? __ACPI_FIND_LAST_BIT_16 (a, 1) : 0)
    398  1.12  christos #define ACPI_FIND_LAST_BIT_32(a)            ((a) ? __ACPI_FIND_LAST_BIT_32 (a, 1) : 0)
    399  1.12  christos #define ACPI_FIND_LAST_BIT_64(a)            ((a) ? __ACPI_FIND_LAST_BIT_64 (a, 1) : 0)
    400  1.12  christos 
    401  1.12  christos #define __ACPI_FIND_FIRST_BIT_2(a, r)       ((((UINT8) (a)) & 0x01) ? (r) : (r)+1)
    402  1.12  christos #define __ACPI_FIND_FIRST_BIT_4(a, r)       ((((UINT8) (a)) & 0x03) ? \
    403  1.12  christos                                              __ACPI_FIND_FIRST_BIT_2  ((a), (r)) : \
    404  1.12  christos                                              __ACPI_FIND_FIRST_BIT_2  ((a)>>2, (r)+2))
    405  1.12  christos #define __ACPI_FIND_FIRST_BIT_8(a, r)       ((((UINT8) (a)) & 0x0F) ? \
    406  1.12  christos                                              __ACPI_FIND_FIRST_BIT_4  ((a), (r)) : \
    407  1.12  christos                                              __ACPI_FIND_FIRST_BIT_4  ((a)>>4, (r)+4))
    408  1.12  christos #define __ACPI_FIND_FIRST_BIT_16(a, r)      ((((UINT16) (a)) & 0x00FF) ? \
    409  1.12  christos                                              __ACPI_FIND_FIRST_BIT_8  ((a), (r)) : \
    410  1.12  christos                                              __ACPI_FIND_FIRST_BIT_8  ((a)>>8, (r)+8))
    411  1.12  christos #define __ACPI_FIND_FIRST_BIT_32(a, r)      ((((UINT32) (a)) & 0x0000FFFF) ? \
    412  1.12  christos                                              __ACPI_FIND_FIRST_BIT_16 ((a), (r)) : \
    413  1.12  christos                                              __ACPI_FIND_FIRST_BIT_16 ((a)>>16, (r)+16))
    414  1.12  christos #define __ACPI_FIND_FIRST_BIT_64(a, r)      ((((UINT64) (a)) & 0x00000000FFFFFFFF) ? \
    415  1.12  christos                                              __ACPI_FIND_FIRST_BIT_32 ((a), (r)) : \
    416  1.12  christos                                              __ACPI_FIND_FIRST_BIT_32 ((a)>>32, (r)+32))
    417  1.12  christos 
    418  1.12  christos #define ACPI_FIND_FIRST_BIT_8(a)            ((a) ? __ACPI_FIND_FIRST_BIT_8 (a, 1) : 0)
    419  1.12  christos #define ACPI_FIND_FIRST_BIT_16(a)           ((a) ? __ACPI_FIND_FIRST_BIT_16 (a, 1) : 0)
    420  1.12  christos #define ACPI_FIND_FIRST_BIT_32(a)           ((a) ? __ACPI_FIND_FIRST_BIT_32 (a, 1) : 0)
    421  1.12  christos #define ACPI_FIND_FIRST_BIT_64(a)           ((a) ? __ACPI_FIND_FIRST_BIT_64 (a, 1) : 0)
    422  1.12  christos 
    423  1.12  christos #endif /* ACPI_USE_NATIVE_BIT_FINDER */
    424  1.12  christos 
    425  1.12  christos /* Generic (power-of-two) rounding */
    426  1.12  christos 
    427  1.12  christos #define ACPI_ROUND_UP_POWER_OF_TWO_8(a)     ((UINT8) \
    428  1.12  christos                                             (((UINT16) 1) <<  ACPI_FIND_LAST_BIT_8  ((a)  - 1)))
    429  1.12  christos #define ACPI_ROUND_DOWN_POWER_OF_TWO_8(a)   ((UINT8) \
    430  1.12  christos                                             (((UINT16) 1) << (ACPI_FIND_LAST_BIT_8  ((a)) - 1)))
    431  1.12  christos #define ACPI_ROUND_UP_POWER_OF_TWO_16(a)    ((UINT16) \
    432  1.12  christos                                             (((UINT32) 1) <<  ACPI_FIND_LAST_BIT_16 ((a)  - 1)))
    433  1.12  christos #define ACPI_ROUND_DOWN_POWER_OF_TWO_16(a)  ((UINT16) \
    434  1.12  christos                                             (((UINT32) 1) << (ACPI_FIND_LAST_BIT_16 ((a)) - 1)))
    435  1.12  christos #define ACPI_ROUND_UP_POWER_OF_TWO_32(a)    ((UINT32) \
    436  1.12  christos                                             (((UINT64) 1) <<  ACPI_FIND_LAST_BIT_32 ((a)  - 1)))
    437  1.12  christos #define ACPI_ROUND_DOWN_POWER_OF_TWO_32(a)  ((UINT32) \
    438  1.12  christos                                             (((UINT64) 1) << (ACPI_FIND_LAST_BIT_32 ((a)) - 1)))
    439  1.12  christos #define ACPI_IS_ALIGNED(a, s)               (((a) & ((s) - 1)) == 0)
    440  1.12  christos #define ACPI_IS_POWER_OF_TWO(a)             ACPI_IS_ALIGNED(a, a)
    441  1.12  christos 
    442   1.1    jruoho /*
    443   1.1    jruoho  * Bitmask creation
    444   1.1    jruoho  * Bit positions start at zero.
    445   1.1    jruoho  * MASK_BITS_ABOVE creates a mask starting AT the position and above
    446   1.1    jruoho  * MASK_BITS_BELOW creates a mask starting one bit BELOW the position
    447  1.12  christos  * MASK_BITS_ABOVE/BELOW accepts a bit offset to create a mask
    448  1.12  christos  * MASK_BITS_ABOVE/BELOW_32/64 accepts a bit width to create a mask
    449  1.12  christos  * Note: The ACPI_INTEGER_BIT_SIZE check is used to bypass compiler
    450  1.12  christos  * differences with the shift operator
    451   1.1    jruoho  */
    452   1.1    jruoho #define ACPI_MASK_BITS_ABOVE(position)      (~((ACPI_UINT64_MAX) << ((UINT32) (position))))
    453   1.1    jruoho #define ACPI_MASK_BITS_BELOW(position)      ((ACPI_UINT64_MAX) << ((UINT32) (position)))
    454  1.12  christos #define ACPI_MASK_BITS_ABOVE_32(width)      ((UINT32) ACPI_MASK_BITS_ABOVE(width))
    455  1.12  christos #define ACPI_MASK_BITS_BELOW_32(width)      ((UINT32) ACPI_MASK_BITS_BELOW(width))
    456  1.12  christos #define ACPI_MASK_BITS_ABOVE_64(width)      ((width) == ACPI_INTEGER_BIT_SIZE ? \
    457  1.12  christos                                                 ACPI_UINT64_MAX : \
    458  1.12  christos                                                 ACPI_MASK_BITS_ABOVE(width))
    459  1.12  christos #define ACPI_MASK_BITS_BELOW_64(width)      ((width) == ACPI_INTEGER_BIT_SIZE ? \
    460  1.12  christos                                                 (UINT64) 0 : \
    461  1.12  christos                                                 ACPI_MASK_BITS_BELOW(width))
    462   1.1    jruoho 
    463   1.1    jruoho /* Bitfields within ACPI registers */
    464   1.1    jruoho 
    465   1.4  christos #define ACPI_REGISTER_PREPARE_BITS(Val, Pos, Mask) \
    466   1.4  christos     ((Val << Pos) & Mask)
    467   1.1    jruoho 
    468   1.4  christos #define ACPI_REGISTER_INSERT_VALUE(Reg, Pos, Mask, Val) \
    469   1.4  christos     Reg = (Reg & (~(Mask))) | ACPI_REGISTER_PREPARE_BITS(Val, Pos, Mask)
    470   1.4  christos 
    471   1.4  christos #define ACPI_INSERT_BITS(Target, Mask, Source) \
    472   1.4  christos     Target = ((Target & (~(Mask))) | (Source & Mask))
    473   1.4  christos 
    474   1.4  christos /* Generic bitfield macros and masks */
    475   1.4  christos 
    476   1.4  christos #define ACPI_GET_BITS(SourcePtr, Position, Mask) \
    477   1.9  christos     ((*(SourcePtr) >> (Position)) & (Mask))
    478   1.4  christos 
    479   1.4  christos #define ACPI_SET_BITS(TargetPtr, Position, Mask, Value) \
    480   1.9  christos     (*(TargetPtr) |= (((Value) & (Mask)) << (Position)))
    481   1.4  christos 
    482   1.4  christos #define ACPI_1BIT_MASK      0x00000001
    483   1.4  christos #define ACPI_2BIT_MASK      0x00000003
    484   1.4  christos #define ACPI_3BIT_MASK      0x00000007
    485   1.4  christos #define ACPI_4BIT_MASK      0x0000000F
    486   1.4  christos #define ACPI_5BIT_MASK      0x0000001F
    487   1.4  christos #define ACPI_6BIT_MASK      0x0000003F
    488   1.4  christos #define ACPI_7BIT_MASK      0x0000007F
    489   1.4  christos #define ACPI_8BIT_MASK      0x000000FF
    490   1.4  christos #define ACPI_16BIT_MASK     0x0000FFFF
    491   1.4  christos #define ACPI_24BIT_MASK     0x00FFFFFF
    492   1.4  christos 
    493   1.4  christos /* Macros to extract flag bits from position zero */
    494   1.4  christos 
    495   1.4  christos #define ACPI_GET_1BIT_FLAG(Value)                   ((Value) & ACPI_1BIT_MASK)
    496   1.4  christos #define ACPI_GET_2BIT_FLAG(Value)                   ((Value) & ACPI_2BIT_MASK)
    497   1.4  christos #define ACPI_GET_3BIT_FLAG(Value)                   ((Value) & ACPI_3BIT_MASK)
    498   1.4  christos #define ACPI_GET_4BIT_FLAG(Value)                   ((Value) & ACPI_4BIT_MASK)
    499   1.4  christos 
    500   1.4  christos /* Macros to extract flag bits from position one and above */
    501   1.4  christos 
    502   1.4  christos #define ACPI_EXTRACT_1BIT_FLAG(Field, Position)     (ACPI_GET_1BIT_FLAG ((Field) >> Position))
    503   1.4  christos #define ACPI_EXTRACT_2BIT_FLAG(Field, Position)     (ACPI_GET_2BIT_FLAG ((Field) >> Position))
    504   1.4  christos #define ACPI_EXTRACT_3BIT_FLAG(Field, Position)     (ACPI_GET_3BIT_FLAG ((Field) >> Position))
    505   1.4  christos #define ACPI_EXTRACT_4BIT_FLAG(Field, Position)     (ACPI_GET_4BIT_FLAG ((Field) >> Position))
    506   1.4  christos 
    507   1.4  christos /* ACPI Pathname helpers */
    508   1.4  christos 
    509   1.4  christos #define ACPI_IS_ROOT_PREFIX(c)      ((c) == (UINT8) 0x5C) /* Backslash */
    510   1.4  christos #define ACPI_IS_PARENT_PREFIX(c)    ((c) == (UINT8) 0x5E) /* Carat */
    511   1.4  christos #define ACPI_IS_PATH_SEPARATOR(c)   ((c) == (UINT8) 0x2E) /* Period (dot) */
    512   1.1    jruoho 
    513   1.1    jruoho /*
    514   1.4  christos  * An object of type ACPI_NAMESPACE_NODE can appear in some contexts
    515   1.4  christos  * where a pointer to an object of type ACPI_OPERAND_OBJECT can also
    516   1.1    jruoho  * appear. This macro is used to distinguish them.
    517   1.1    jruoho  *
    518   1.4  christos  * The "DescriptorType" field is the second field in both structures.
    519   1.1    jruoho  */
    520   1.4  christos #define ACPI_GET_DESCRIPTOR_PTR(d)      (((ACPI_DESCRIPTOR *)(void *)(d))->Common.CommonPointer)
    521   1.4  christos #define ACPI_SET_DESCRIPTOR_PTR(d, p)   (((ACPI_DESCRIPTOR *)(void *)(d))->Common.CommonPointer = (p))
    522   1.1    jruoho #define ACPI_GET_DESCRIPTOR_TYPE(d)     (((ACPI_DESCRIPTOR *)(void *)(d))->Common.DescriptorType)
    523   1.4  christos #define ACPI_SET_DESCRIPTOR_TYPE(d, t)  (((ACPI_DESCRIPTOR *)(void *)(d))->Common.DescriptorType = (t))
    524   1.1    jruoho 
    525   1.1    jruoho /*
    526   1.1    jruoho  * Macros for the master AML opcode table
    527   1.1    jruoho  */
    528   1.1    jruoho #if defined (ACPI_DISASSEMBLER) || defined (ACPI_DEBUG_OUTPUT)
    529   1.1    jruoho #define ACPI_OP(Name, PArgs, IArgs, ObjType, Class, Type, Flags) \
    530   1.1    jruoho     {Name, (UINT32)(PArgs), (UINT32)(IArgs), (UINT32)(Flags), ObjType, Class, Type}
    531   1.1    jruoho #else
    532   1.1    jruoho #define ACPI_OP(Name, PArgs, IArgs, ObjType, Class, Type, Flags) \
    533   1.1    jruoho     {(UINT32)(PArgs), (UINT32)(IArgs), (UINT32)(Flags), ObjType, Class, Type}
    534   1.1    jruoho #endif
    535   1.1    jruoho 
    536   1.1    jruoho #define ARG_TYPE_WIDTH                  5
    537   1.1    jruoho #define ARG_1(x)                        ((UINT32)(x))
    538   1.1    jruoho #define ARG_2(x)                        ((UINT32)(x) << (1 * ARG_TYPE_WIDTH))
    539   1.1    jruoho #define ARG_3(x)                        ((UINT32)(x) << (2 * ARG_TYPE_WIDTH))
    540   1.1    jruoho #define ARG_4(x)                        ((UINT32)(x) << (3 * ARG_TYPE_WIDTH))
    541   1.1    jruoho #define ARG_5(x)                        ((UINT32)(x) << (4 * ARG_TYPE_WIDTH))
    542   1.1    jruoho #define ARG_6(x)                        ((UINT32)(x) << (5 * ARG_TYPE_WIDTH))
    543   1.1    jruoho 
    544   1.1    jruoho #define ARGI_LIST1(a)                   (ARG_1(a))
    545   1.1    jruoho #define ARGI_LIST2(a, b)                (ARG_1(b)|ARG_2(a))
    546   1.1    jruoho #define ARGI_LIST3(a, b, c)             (ARG_1(c)|ARG_2(b)|ARG_3(a))
    547   1.1    jruoho #define ARGI_LIST4(a, b, c, d)          (ARG_1(d)|ARG_2(c)|ARG_3(b)|ARG_4(a))
    548   1.1    jruoho #define ARGI_LIST5(a, b, c, d, e)       (ARG_1(e)|ARG_2(d)|ARG_3(c)|ARG_4(b)|ARG_5(a))
    549   1.1    jruoho #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))
    550   1.1    jruoho 
    551   1.1    jruoho #define ARGP_LIST1(a)                   (ARG_1(a))
    552   1.1    jruoho #define ARGP_LIST2(a, b)                (ARG_1(a)|ARG_2(b))
    553   1.1    jruoho #define ARGP_LIST3(a, b, c)             (ARG_1(a)|ARG_2(b)|ARG_3(c))
    554   1.1    jruoho #define ARGP_LIST4(a, b, c, d)          (ARG_1(a)|ARG_2(b)|ARG_3(c)|ARG_4(d))
    555   1.1    jruoho #define ARGP_LIST5(a, b, c, d, e)       (ARG_1(a)|ARG_2(b)|ARG_3(c)|ARG_4(d)|ARG_5(e))
    556   1.1    jruoho #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))
    557   1.1    jruoho 
    558   1.1    jruoho #define GET_CURRENT_ARG_TYPE(List)      (List & ((UINT32) 0x1F))
    559   1.1    jruoho #define INCREMENT_ARG_LIST(List)        (List >>= ((UINT32) ARG_TYPE_WIDTH))
    560   1.1    jruoho 
    561   1.1    jruoho /*
    562   1.1    jruoho  * Ascii error messages can be configured out
    563   1.1    jruoho  */
    564   1.1    jruoho #ifndef ACPI_NO_ERROR_MESSAGES
    565   1.1    jruoho /*
    566  1.12  christos  * Error reporting. The callers module and line number are inserted by AE_INFO,
    567   1.1    jruoho  * the plist contains a set of parens to allow variable-length lists.
    568   1.1    jruoho  * These macros are used for both the debug and non-debug versions of the code.
    569   1.1    jruoho  */
    570  1.14  christos #define ACPI_ERROR_NAMESPACE(s, p, e)       AcpiUtPrefixedNamespaceError (AE_INFO, s, p, e);
    571   1.4  christos #define ACPI_ERROR_METHOD(s, n, p, e)       AcpiUtMethodError (AE_INFO, s, n, p, e);
    572   1.4  christos #define ACPI_WARN_PREDEFINED(plist)         AcpiUtPredefinedWarning plist
    573   1.4  christos #define ACPI_INFO_PREDEFINED(plist)         AcpiUtPredefinedInfo plist
    574   1.4  christos #define ACPI_BIOS_ERROR_PREDEFINED(plist)   AcpiUtPredefinedBiosError plist
    575  1.15  christos #define ACPI_ERROR_ONLY(s)                  s
    576   1.1    jruoho 
    577   1.1    jruoho #else
    578   1.1    jruoho 
    579   1.1    jruoho /* No error messages */
    580   1.1    jruoho 
    581  1.15  christos #define ACPI_ERROR_NAMESPACE(s, p, e)
    582   1.1    jruoho #define ACPI_ERROR_METHOD(s, n, p, e)
    583   1.1    jruoho #define ACPI_WARN_PREDEFINED(plist)
    584   1.1    jruoho #define ACPI_INFO_PREDEFINED(plist)
    585   1.4  christos #define ACPI_BIOS_ERROR_PREDEFINED(plist)
    586  1.15  christos #define ACPI_ERROR_ONLY(s)
    587   1.1    jruoho 
    588   1.1    jruoho #endif /* ACPI_NO_ERROR_MESSAGES */
    589   1.1    jruoho 
    590   1.4  christos #if (!ACPI_REDUCED_HARDWARE)
    591   1.4  christos #define ACPI_HW_OPTIONAL_FUNCTION(addr)     addr
    592   1.1    jruoho #else
    593   1.4  christos #define ACPI_HW_OPTIONAL_FUNCTION(addr)     NULL
    594   1.1    jruoho #endif
    595   1.1    jruoho 
    596   1.1    jruoho 
    597   1.1    jruoho /*
    598   1.1    jruoho  * Macros used for ACPICA utilities only
    599   1.1    jruoho  */
    600   1.1    jruoho 
    601   1.1    jruoho /* Generate a UUID */
    602   1.1    jruoho 
    603   1.1    jruoho #define ACPI_INIT_UUID(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) \
    604   1.1    jruoho     (a) & 0xFF, ((a) >> 8) & 0xFF, ((a) >> 16) & 0xFF, ((a) >> 24) & 0xFF, \
    605   1.1    jruoho     (b) & 0xFF, ((b) >> 8) & 0xFF, \
    606   1.1    jruoho     (c) & 0xFF, ((c) >> 8) & 0xFF, \
    607   1.1    jruoho     (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7)
    608   1.1    jruoho 
    609   1.1    jruoho #define ACPI_IS_OCTAL_DIGIT(d)              (((char)(d) >= '0') && ((char)(d) <= '7'))
    610   1.1    jruoho 
    611   1.1    jruoho 
    612  1.13  christos /*
    613  1.16  christos  * Macros used for the ASL-/ASL+ converter utility
    614  1.13  christos  */
    615  1.13  christos #ifdef ACPI_ASL_COMPILER
    616  1.13  christos 
    617  1.13  christos #define ASL_CV_LABEL_FILENODE(a)         CvLabelFileNode(a);
    618  1.13  christos #define ASL_CV_CAPTURE_COMMENTS_ONLY(a)   CvCaptureCommentsOnly (a);
    619  1.13  christos #define ASL_CV_CAPTURE_COMMENTS(a)       CvCaptureComments (a);
    620  1.13  christos #define ASL_CV_TRANSFER_COMMENTS(a)      CvTransferComments (a);
    621  1.13  christos #define ASL_CV_CLOSE_PAREN(a,b)          CvCloseParenWriteComment(a,b);
    622  1.13  christos #define ASL_CV_CLOSE_BRACE(a,b)          CvCloseBraceWriteComment(a,b);
    623  1.13  christos #define ASL_CV_SWITCH_FILES(a,b)         CvSwitchFiles(a,b);
    624  1.13  christos #define ASL_CV_CLEAR_OP_COMMENTS(a)       CvClearOpComments(a);
    625  1.13  christos #define ASL_CV_PRINT_ONE_COMMENT(a,b,c,d) CvPrintOneCommentType (a,b,c,d);
    626  1.13  christos #define ASL_CV_PRINT_ONE_COMMENT_LIST(a,b) CvPrintOneCommentList (a,b);
    627  1.13  christos #define ASL_CV_FILE_HAS_SWITCHED(a)       CvFileHasSwitched(a)
    628  1.17  christos #define ASL_CV_INIT_FILETREE(a,b)      CvInitFileTree(a,b);
    629  1.13  christos 
    630  1.13  christos #else
    631  1.13  christos 
    632  1.13  christos #define ASL_CV_LABEL_FILENODE(a)
    633  1.13  christos #define ASL_CV_CAPTURE_COMMENTS_ONLY(a)
    634  1.13  christos #define ASL_CV_CAPTURE_COMMENTS(a)
    635  1.13  christos #define ASL_CV_TRANSFER_COMMENTS(a)
    636  1.13  christos #define ASL_CV_CLOSE_PAREN(a,b)          AcpiOsPrintf (")");
    637  1.13  christos #define ASL_CV_CLOSE_BRACE(a,b)          AcpiOsPrintf ("}");
    638  1.13  christos #define ASL_CV_SWITCH_FILES(a,b)
    639  1.13  christos #define ASL_CV_CLEAR_OP_COMMENTS(a)
    640  1.13  christos #define ASL_CV_PRINT_ONE_COMMENT(a,b,c,d)
    641  1.13  christos #define ASL_CV_PRINT_ONE_COMMENT_LIST(a,b)
    642  1.13  christos #define ASL_CV_FILE_HAS_SWITCHED(a)       0
    643  1.17  christos #define ASL_CV_INIT_FILETREE(a,b)
    644  1.13  christos 
    645  1.13  christos #endif
    646  1.13  christos 
    647   1.1    jruoho #endif /* ACMACROS_H */
    648