Home | History | Annotate | Line # | Download | only in include
acbuffer.h revision 1.1.1.9
      1      1.1  christos /******************************************************************************
      2      1.1  christos  *
      3      1.1  christos  * Name: acbuffer.h - Support for buffers returned by ACPI predefined names
      4      1.1  christos  *
      5      1.1  christos  *****************************************************************************/
      6      1.1  christos 
      7      1.1  christos /*
      8  1.1.1.9  christos  * Copyright (C) 2000 - 2021, Intel Corp.
      9      1.1  christos  * All rights reserved.
     10      1.1  christos  *
     11      1.1  christos  * Redistribution and use in source and binary forms, with or without
     12      1.1  christos  * modification, are permitted provided that the following conditions
     13      1.1  christos  * are met:
     14      1.1  christos  * 1. Redistributions of source code must retain the above copyright
     15      1.1  christos  *    notice, this list of conditions, and the following disclaimer,
     16      1.1  christos  *    without modification.
     17      1.1  christos  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
     18      1.1  christos  *    substantially similar to the "NO WARRANTY" disclaimer below
     19      1.1  christos  *    ("Disclaimer") and any redistribution must be conditioned upon
     20      1.1  christos  *    including a substantially similar Disclaimer requirement for further
     21      1.1  christos  *    binary redistribution.
     22      1.1  christos  * 3. Neither the names of the above-listed copyright holders nor the names
     23      1.1  christos  *    of any contributors may be used to endorse or promote products derived
     24      1.1  christos  *    from this software without specific prior written permission.
     25      1.1  christos  *
     26      1.1  christos  * Alternatively, this software may be distributed under the terms of the
     27      1.1  christos  * GNU General Public License ("GPL") version 2 as published by the Free
     28      1.1  christos  * Software Foundation.
     29      1.1  christos  *
     30      1.1  christos  * NO WARRANTY
     31      1.1  christos  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     32      1.1  christos  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     33  1.1.1.9  christos  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     34      1.1  christos  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     35      1.1  christos  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     36      1.1  christos  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     37      1.1  christos  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     38      1.1  christos  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     39      1.1  christos  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
     40      1.1  christos  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     41      1.1  christos  * POSSIBILITY OF SUCH DAMAGES.
     42      1.1  christos  */
     43      1.1  christos 
     44      1.1  christos #ifndef __ACBUFFER_H__
     45      1.1  christos #define __ACBUFFER_H__
     46      1.1  christos 
     47      1.1  christos /*
     48      1.1  christos  * Contains buffer structures for these predefined names:
     49      1.1  christos  * _FDE, _GRT, _GTM, _PLD, _SRT
     50      1.1  christos  */
     51      1.1  christos 
     52      1.1  christos /*
     53      1.1  christos  * Note: C bitfields are not used for this reason:
     54      1.1  christos  *
     55      1.1  christos  * "Bitfields are great and easy to read, but unfortunately the C language
     56      1.1  christos  * does not specify the layout of bitfields in memory, which means they are
     57      1.1  christos  * essentially useless for dealing with packed data in on-disk formats or
     58      1.1  christos  * binary wire protocols." (Or ACPI tables and buffers.) "If you ask me,
     59      1.1  christos  * this decision was a design error in C. Ritchie could have picked an order
     60      1.1  christos  * and stuck with it." Norman Ramsey.
     61      1.1  christos  * See http://stackoverflow.com/a/1053662/41661
     62      1.1  christos  */
     63      1.1  christos 
     64      1.1  christos 
     65      1.1  christos /* _FDE return value */
     66      1.1  christos 
     67      1.1  christos typedef struct acpi_fde_info
     68      1.1  christos {
     69      1.1  christos     UINT32              Floppy0;
     70      1.1  christos     UINT32              Floppy1;
     71      1.1  christos     UINT32              Floppy2;
     72      1.1  christos     UINT32              Floppy3;
     73      1.1  christos     UINT32              Tape;
     74      1.1  christos 
     75      1.1  christos } ACPI_FDE_INFO;
     76      1.1  christos 
     77      1.1  christos /*
     78      1.1  christos  * _GRT return value
     79      1.1  christos  * _SRT input value
     80      1.1  christos  */
     81      1.1  christos typedef struct acpi_grt_info
     82      1.1  christos {
     83      1.1  christos     UINT16              Year;
     84      1.1  christos     UINT8               Month;
     85      1.1  christos     UINT8               Day;
     86      1.1  christos     UINT8               Hour;
     87      1.1  christos     UINT8               Minute;
     88      1.1  christos     UINT8               Second;
     89      1.1  christos     UINT8               Valid;
     90      1.1  christos     UINT16              Milliseconds;
     91      1.1  christos     UINT16              Timezone;
     92      1.1  christos     UINT8               Daylight;
     93      1.1  christos     UINT8               Reserved[3];
     94      1.1  christos 
     95      1.1  christos } ACPI_GRT_INFO;
     96      1.1  christos 
     97      1.1  christos /* _GTM return value */
     98      1.1  christos 
     99      1.1  christos typedef struct acpi_gtm_info
    100      1.1  christos {
    101      1.1  christos     UINT32              PioSpeed0;
    102      1.1  christos     UINT32              DmaSpeed0;
    103      1.1  christos     UINT32              PioSpeed1;
    104      1.1  christos     UINT32              DmaSpeed1;
    105      1.1  christos     UINT32              Flags;
    106      1.1  christos 
    107      1.1  christos } ACPI_GTM_INFO;
    108      1.1  christos 
    109      1.1  christos /*
    110      1.1  christos  * Formatted _PLD return value. The minimum size is a package containing
    111      1.1  christos  * one buffer.
    112      1.1  christos  * Revision 1: Buffer is 16 bytes (128 bits)
    113      1.1  christos  * Revision 2: Buffer is 20 bytes (160 bits)
    114      1.1  christos  *
    115      1.1  christos  * Note: This structure is returned from the AcpiDecodePldBuffer
    116      1.1  christos  * interface.
    117      1.1  christos  */
    118      1.1  christos typedef struct acpi_pld_info
    119      1.1  christos {
    120      1.1  christos     UINT8               Revision;
    121      1.1  christos     UINT8               IgnoreColor;
    122  1.1.1.3  christos     UINT8               Red;
    123  1.1.1.3  christos     UINT8               Green;
    124  1.1.1.3  christos     UINT8               Blue;
    125      1.1  christos     UINT16              Width;
    126      1.1  christos     UINT16              Height;
    127      1.1  christos     UINT8               UserVisible;
    128      1.1  christos     UINT8               Dock;
    129      1.1  christos     UINT8               Lid;
    130      1.1  christos     UINT8               Panel;
    131      1.1  christos     UINT8               VerticalPosition;
    132      1.1  christos     UINT8               HorizontalPosition;
    133      1.1  christos     UINT8               Shape;
    134      1.1  christos     UINT8               GroupOrientation;
    135      1.1  christos     UINT8               GroupToken;
    136      1.1  christos     UINT8               GroupPosition;
    137      1.1  christos     UINT8               Bay;
    138      1.1  christos     UINT8               Ejectable;
    139      1.1  christos     UINT8               OspmEjectRequired;
    140      1.1  christos     UINT8               CabinetNumber;
    141      1.1  christos     UINT8               CardCageNumber;
    142      1.1  christos     UINT8               Reference;
    143      1.1  christos     UINT8               Rotation;
    144      1.1  christos     UINT8               Order;
    145      1.1  christos     UINT8               Reserved;
    146      1.1  christos     UINT16              VerticalOffset;
    147      1.1  christos     UINT16              HorizontalOffset;
    148      1.1  christos 
    149      1.1  christos } ACPI_PLD_INFO;
    150      1.1  christos 
    151      1.1  christos 
    152      1.1  christos /*
    153      1.1  christos  * Macros to:
    154      1.1  christos  *     1) Convert a _PLD buffer to internal ACPI_PLD_INFO format - ACPI_PLD_GET*
    155      1.1  christos  *        (Used by AcpiDecodePldBuffer)
    156      1.1  christos  *     2) Construct a _PLD buffer - ACPI_PLD_SET*
    157      1.1  christos  *        (Intended for BIOS use only)
    158      1.1  christos  */
    159      1.1  christos #define ACPI_PLD_REV1_BUFFER_SIZE               16 /* For Revision 1 of the buffer (From ACPI spec) */
    160  1.1.1.4  christos #define ACPI_PLD_REV2_BUFFER_SIZE               20 /* For Revision 2 of the buffer (From ACPI spec) */
    161      1.1  christos #define ACPI_PLD_BUFFER_SIZE                    20 /* For Revision 2 of the buffer (From ACPI spec) */
    162      1.1  christos 
    163      1.1  christos /* First 32-bit dword, bits 0:32 */
    164      1.1  christos 
    165      1.1  christos #define ACPI_PLD_GET_REVISION(dword)            ACPI_GET_BITS (dword, 0, ACPI_7BIT_MASK)
    166      1.1  christos #define ACPI_PLD_SET_REVISION(dword,value)      ACPI_SET_BITS (dword, 0, ACPI_7BIT_MASK, value)     /* Offset 0, Len 7 */
    167      1.1  christos 
    168      1.1  christos #define ACPI_PLD_GET_IGNORE_COLOR(dword)        ACPI_GET_BITS (dword, 7, ACPI_1BIT_MASK)
    169      1.1  christos #define ACPI_PLD_SET_IGNORE_COLOR(dword,value)  ACPI_SET_BITS (dword, 7, ACPI_1BIT_MASK, value)     /* Offset 7, Len 1 */
    170      1.1  christos 
    171  1.1.1.3  christos #define ACPI_PLD_GET_RED(dword)                 ACPI_GET_BITS (dword, 8, ACPI_8BIT_MASK)
    172  1.1.1.3  christos #define ACPI_PLD_SET_RED(dword,value)           ACPI_SET_BITS (dword, 8, ACPI_8BIT_MASK, value)    /* Offset 8, Len 8 */
    173  1.1.1.3  christos 
    174  1.1.1.3  christos #define ACPI_PLD_GET_GREEN(dword)               ACPI_GET_BITS (dword, 16, ACPI_8BIT_MASK)
    175  1.1.1.3  christos #define ACPI_PLD_SET_GREEN(dword,value)         ACPI_SET_BITS (dword, 16, ACPI_8BIT_MASK, value)    /* Offset 16, Len 8 */
    176  1.1.1.3  christos 
    177  1.1.1.3  christos #define ACPI_PLD_GET_BLUE(dword)                ACPI_GET_BITS (dword, 24, ACPI_8BIT_MASK)
    178  1.1.1.3  christos #define ACPI_PLD_SET_BLUE(dword,value)          ACPI_SET_BITS (dword, 24, ACPI_8BIT_MASK, value)    /* Offset 24, Len 8 */
    179      1.1  christos 
    180      1.1  christos /* Second 32-bit dword, bits 33:63 */
    181      1.1  christos 
    182      1.1  christos #define ACPI_PLD_GET_WIDTH(dword)               ACPI_GET_BITS (dword, 0, ACPI_16BIT_MASK)
    183      1.1  christos #define ACPI_PLD_SET_WIDTH(dword,value)         ACPI_SET_BITS (dword, 0, ACPI_16BIT_MASK, value)    /* Offset 32+0=32, Len 16 */
    184      1.1  christos 
    185      1.1  christos #define ACPI_PLD_GET_HEIGHT(dword)              ACPI_GET_BITS (dword, 16, ACPI_16BIT_MASK)
    186      1.1  christos #define ACPI_PLD_SET_HEIGHT(dword,value)        ACPI_SET_BITS (dword, 16, ACPI_16BIT_MASK, value)   /* Offset 32+16=48, Len 16 */
    187      1.1  christos 
    188      1.1  christos /* Third 32-bit dword, bits 64:95 */
    189      1.1  christos 
    190      1.1  christos #define ACPI_PLD_GET_USER_VISIBLE(dword)        ACPI_GET_BITS (dword, 0, ACPI_1BIT_MASK)
    191      1.1  christos #define ACPI_PLD_SET_USER_VISIBLE(dword,value)  ACPI_SET_BITS (dword, 0, ACPI_1BIT_MASK, value)     /* Offset 64+0=64, Len 1 */
    192      1.1  christos 
    193      1.1  christos #define ACPI_PLD_GET_DOCK(dword)                ACPI_GET_BITS (dword, 1, ACPI_1BIT_MASK)
    194      1.1  christos #define ACPI_PLD_SET_DOCK(dword,value)          ACPI_SET_BITS (dword, 1, ACPI_1BIT_MASK, value)     /* Offset 64+1=65, Len 1 */
    195      1.1  christos 
    196      1.1  christos #define ACPI_PLD_GET_LID(dword)                 ACPI_GET_BITS (dword, 2, ACPI_1BIT_MASK)
    197      1.1  christos #define ACPI_PLD_SET_LID(dword,value)           ACPI_SET_BITS (dword, 2, ACPI_1BIT_MASK, value)     /* Offset 64+2=66, Len 1 */
    198      1.1  christos 
    199      1.1  christos #define ACPI_PLD_GET_PANEL(dword)               ACPI_GET_BITS (dword, 3, ACPI_3BIT_MASK)
    200      1.1  christos #define ACPI_PLD_SET_PANEL(dword,value)         ACPI_SET_BITS (dword, 3, ACPI_3BIT_MASK, value)     /* Offset 64+3=67, Len 3 */
    201      1.1  christos 
    202      1.1  christos #define ACPI_PLD_GET_VERTICAL(dword)            ACPI_GET_BITS (dword, 6, ACPI_2BIT_MASK)
    203      1.1  christos #define ACPI_PLD_SET_VERTICAL(dword,value)      ACPI_SET_BITS (dword, 6, ACPI_2BIT_MASK, value)     /* Offset 64+6=70, Len 2 */
    204      1.1  christos 
    205      1.1  christos #define ACPI_PLD_GET_HORIZONTAL(dword)          ACPI_GET_BITS (dword, 8, ACPI_2BIT_MASK)
    206      1.1  christos #define ACPI_PLD_SET_HORIZONTAL(dword,value)    ACPI_SET_BITS (dword, 8, ACPI_2BIT_MASK, value)     /* Offset 64+8=72, Len 2 */
    207      1.1  christos 
    208      1.1  christos #define ACPI_PLD_GET_SHAPE(dword)               ACPI_GET_BITS (dword, 10, ACPI_4BIT_MASK)
    209      1.1  christos #define ACPI_PLD_SET_SHAPE(dword,value)         ACPI_SET_BITS (dword, 10, ACPI_4BIT_MASK, value)    /* Offset 64+10=74, Len 4 */
    210      1.1  christos 
    211      1.1  christos #define ACPI_PLD_GET_ORIENTATION(dword)         ACPI_GET_BITS (dword, 14, ACPI_1BIT_MASK)
    212      1.1  christos #define ACPI_PLD_SET_ORIENTATION(dword,value)   ACPI_SET_BITS (dword, 14, ACPI_1BIT_MASK, value)    /* Offset 64+14=78, Len 1 */
    213      1.1  christos 
    214      1.1  christos #define ACPI_PLD_GET_TOKEN(dword)               ACPI_GET_BITS (dword, 15, ACPI_8BIT_MASK)
    215      1.1  christos #define ACPI_PLD_SET_TOKEN(dword,value)         ACPI_SET_BITS (dword, 15, ACPI_8BIT_MASK, value)    /* Offset 64+15=79, Len 8 */
    216      1.1  christos 
    217      1.1  christos #define ACPI_PLD_GET_POSITION(dword)            ACPI_GET_BITS (dword, 23, ACPI_8BIT_MASK)
    218      1.1  christos #define ACPI_PLD_SET_POSITION(dword,value)      ACPI_SET_BITS (dword, 23, ACPI_8BIT_MASK, value)    /* Offset 64+23=87, Len 8 */
    219      1.1  christos 
    220      1.1  christos #define ACPI_PLD_GET_BAY(dword)                 ACPI_GET_BITS (dword, 31, ACPI_1BIT_MASK)
    221      1.1  christos #define ACPI_PLD_SET_BAY(dword,value)           ACPI_SET_BITS (dword, 31, ACPI_1BIT_MASK, value)    /* Offset 64+31=95, Len 1 */
    222      1.1  christos 
    223      1.1  christos /* Fourth 32-bit dword, bits 96:127 */
    224      1.1  christos 
    225      1.1  christos #define ACPI_PLD_GET_EJECTABLE(dword)           ACPI_GET_BITS (dword, 0, ACPI_1BIT_MASK)
    226      1.1  christos #define ACPI_PLD_SET_EJECTABLE(dword,value)     ACPI_SET_BITS (dword, 0, ACPI_1BIT_MASK, value)     /* Offset 96+0=96, Len 1 */
    227      1.1  christos 
    228      1.1  christos #define ACPI_PLD_GET_OSPM_EJECT(dword)          ACPI_GET_BITS (dword, 1, ACPI_1BIT_MASK)
    229      1.1  christos #define ACPI_PLD_SET_OSPM_EJECT(dword,value)    ACPI_SET_BITS (dword, 1, ACPI_1BIT_MASK, value)     /* Offset 96+1=97, Len 1 */
    230      1.1  christos 
    231      1.1  christos #define ACPI_PLD_GET_CABINET(dword)             ACPI_GET_BITS (dword, 2, ACPI_8BIT_MASK)
    232      1.1  christos #define ACPI_PLD_SET_CABINET(dword,value)       ACPI_SET_BITS (dword, 2, ACPI_8BIT_MASK, value)     /* Offset 96+2=98, Len 8 */
    233      1.1  christos 
    234      1.1  christos #define ACPI_PLD_GET_CARD_CAGE(dword)           ACPI_GET_BITS (dword, 10, ACPI_8BIT_MASK)
    235      1.1  christos #define ACPI_PLD_SET_CARD_CAGE(dword,value)     ACPI_SET_BITS (dword, 10, ACPI_8BIT_MASK, value)    /* Offset 96+10=106, Len 8 */
    236      1.1  christos 
    237      1.1  christos #define ACPI_PLD_GET_REFERENCE(dword)           ACPI_GET_BITS (dword, 18, ACPI_1BIT_MASK)
    238      1.1  christos #define ACPI_PLD_SET_REFERENCE(dword,value)     ACPI_SET_BITS (dword, 18, ACPI_1BIT_MASK, value)    /* Offset 96+18=114, Len 1 */
    239      1.1  christos 
    240      1.1  christos #define ACPI_PLD_GET_ROTATION(dword)            ACPI_GET_BITS (dword, 19, ACPI_4BIT_MASK)
    241      1.1  christos #define ACPI_PLD_SET_ROTATION(dword,value)      ACPI_SET_BITS (dword, 19, ACPI_4BIT_MASK, value)    /* Offset 96+19=115, Len 4 */
    242      1.1  christos 
    243      1.1  christos #define ACPI_PLD_GET_ORDER(dword)               ACPI_GET_BITS (dword, 23, ACPI_5BIT_MASK)
    244      1.1  christos #define ACPI_PLD_SET_ORDER(dword,value)         ACPI_SET_BITS (dword, 23, ACPI_5BIT_MASK, value)    /* Offset 96+23=119, Len 5 */
    245      1.1  christos 
    246      1.1  christos /* Fifth 32-bit dword, bits 128:159 (Revision 2 of _PLD only) */
    247      1.1  christos 
    248      1.1  christos #define ACPI_PLD_GET_VERT_OFFSET(dword)         ACPI_GET_BITS (dword, 0, ACPI_16BIT_MASK)
    249      1.1  christos #define ACPI_PLD_SET_VERT_OFFSET(dword,value)   ACPI_SET_BITS (dword, 0, ACPI_16BIT_MASK, value)    /* Offset 128+0=128, Len 16 */
    250      1.1  christos 
    251      1.1  christos #define ACPI_PLD_GET_HORIZ_OFFSET(dword)        ACPI_GET_BITS (dword, 16, ACPI_16BIT_MASK)
    252      1.1  christos #define ACPI_PLD_SET_HORIZ_OFFSET(dword,value)  ACPI_SET_BITS (dword, 16, ACPI_16BIT_MASK, value)   /* Offset 128+16=144, Len 16 */
    253      1.1  christos 
    254      1.1  christos 
    255      1.1  christos #endif /* ACBUFFER_H */
    256