Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */
0002 /******************************************************************************
0003  *
0004  * Name: acbuffer.h - Support for buffers returned by ACPI predefined names
0005  *
0006  * Copyright (C) 2000 - 2022, Intel Corp.
0007  *
0008  *****************************************************************************/
0009 
0010 #ifndef __ACBUFFER_H__
0011 #define __ACBUFFER_H__
0012 
0013 /*
0014  * Contains buffer structures for these predefined names:
0015  * _FDE, _GRT, _GTM, _PLD, _SRT
0016  */
0017 
0018 /*
0019  * Note: C bitfields are not used for this reason:
0020  *
0021  * "Bitfields are great and easy to read, but unfortunately the C language
0022  * does not specify the layout of bitfields in memory, which means they are
0023  * essentially useless for dealing with packed data in on-disk formats or
0024  * binary wire protocols." (Or ACPI tables and buffers.) "If you ask me,
0025  * this decision was a design error in C. Ritchie could have picked an order
0026  * and stuck with it." Norman Ramsey.
0027  * See http://stackoverflow.com/a/1053662/41661
0028  */
0029 
0030 /* _FDE return value */
0031 
0032 struct acpi_fde_info {
0033     u32 floppy0;
0034     u32 floppy1;
0035     u32 floppy2;
0036     u32 floppy3;
0037     u32 tape;
0038 };
0039 
0040 /*
0041  * _GRT return value
0042  * _SRT input value
0043  */
0044 struct acpi_grt_info {
0045     u16 year;
0046     u8 month;
0047     u8 day;
0048     u8 hour;
0049     u8 minute;
0050     u8 second;
0051     u8 valid;
0052     u16 milliseconds;
0053     u16 timezone;
0054     u8 daylight;
0055     u8 reserved[3];
0056 };
0057 
0058 /* _GTM return value */
0059 
0060 struct acpi_gtm_info {
0061     u32 pio_speed0;
0062     u32 dma_speed0;
0063     u32 pio_speed1;
0064     u32 dma_speed1;
0065     u32 flags;
0066 };
0067 
0068 /*
0069  * Formatted _PLD return value. The minimum size is a package containing
0070  * one buffer.
0071  * Revision 1: Buffer is 16 bytes (128 bits)
0072  * Revision 2: Buffer is 20 bytes (160 bits)
0073  *
0074  * Note: This structure is returned from the acpi_decode_pld_buffer
0075  * interface.
0076  */
0077 struct acpi_pld_info {
0078     u8 revision;
0079     u8 ignore_color;
0080     u8 red;
0081     u8 green;
0082     u8 blue;
0083     u16 width;
0084     u16 height;
0085     u8 user_visible;
0086     u8 dock;
0087     u8 lid;
0088     u8 panel;
0089     u8 vertical_position;
0090     u8 horizontal_position;
0091     u8 shape;
0092     u8 group_orientation;
0093     u8 group_token;
0094     u8 group_position;
0095     u8 bay;
0096     u8 ejectable;
0097     u8 ospm_eject_required;
0098     u8 cabinet_number;
0099     u8 card_cage_number;
0100     u8 reference;
0101     u8 rotation;
0102     u8 order;
0103     u8 reserved;
0104     u16 vertical_offset;
0105     u16 horizontal_offset;
0106 };
0107 
0108 /*
0109  * Macros to:
0110  *     1) Convert a _PLD buffer to internal struct acpi_pld_info format - ACPI_PLD_GET*
0111  *        (Used by acpi_decode_pld_buffer)
0112  *     2) Construct a _PLD buffer - ACPI_PLD_SET*
0113  *        (Intended for BIOS use only)
0114  */
0115 #define ACPI_PLD_REV1_BUFFER_SIZE               16  /* For Revision 1 of the buffer (From ACPI spec) */
0116 #define ACPI_PLD_REV2_BUFFER_SIZE               20  /* For Revision 2 of the buffer (From ACPI spec) */
0117 #define ACPI_PLD_BUFFER_SIZE                    20  /* For Revision 2 of the buffer (From ACPI spec) */
0118 
0119 /* First 32-bit dword, bits 0:32 */
0120 
0121 #define ACPI_PLD_GET_REVISION(dword)            ACPI_GET_BITS (dword, 0, ACPI_7BIT_MASK)
0122 #define ACPI_PLD_SET_REVISION(dword,value)      ACPI_SET_BITS (dword, 0, ACPI_7BIT_MASK, value) /* Offset 0, Len 7 */
0123 
0124 #define ACPI_PLD_GET_IGNORE_COLOR(dword)        ACPI_GET_BITS (dword, 7, ACPI_1BIT_MASK)
0125 #define ACPI_PLD_SET_IGNORE_COLOR(dword,value)  ACPI_SET_BITS (dword, 7, ACPI_1BIT_MASK, value) /* Offset 7, Len 1 */
0126 
0127 #define ACPI_PLD_GET_RED(dword)                 ACPI_GET_BITS (dword, 8, ACPI_8BIT_MASK)
0128 #define ACPI_PLD_SET_RED(dword,value)           ACPI_SET_BITS (dword, 8, ACPI_8BIT_MASK, value) /* Offset 8, Len 8 */
0129 
0130 #define ACPI_PLD_GET_GREEN(dword)               ACPI_GET_BITS (dword, 16, ACPI_8BIT_MASK)
0131 #define ACPI_PLD_SET_GREEN(dword,value)         ACPI_SET_BITS (dword, 16, ACPI_8BIT_MASK, value)    /* Offset 16, Len 8 */
0132 
0133 #define ACPI_PLD_GET_BLUE(dword)                ACPI_GET_BITS (dword, 24, ACPI_8BIT_MASK)
0134 #define ACPI_PLD_SET_BLUE(dword,value)          ACPI_SET_BITS (dword, 24, ACPI_8BIT_MASK, value)    /* Offset 24, Len 8 */
0135 
0136 /* Second 32-bit dword, bits 33:63 */
0137 
0138 #define ACPI_PLD_GET_WIDTH(dword)               ACPI_GET_BITS (dword, 0, ACPI_16BIT_MASK)
0139 #define ACPI_PLD_SET_WIDTH(dword,value)         ACPI_SET_BITS (dword, 0, ACPI_16BIT_MASK, value)    /* Offset 32+0=32, Len 16 */
0140 
0141 #define ACPI_PLD_GET_HEIGHT(dword)              ACPI_GET_BITS (dword, 16, ACPI_16BIT_MASK)
0142 #define ACPI_PLD_SET_HEIGHT(dword,value)        ACPI_SET_BITS (dword, 16, ACPI_16BIT_MASK, value)   /* Offset 32+16=48, Len 16 */
0143 
0144 /* Third 32-bit dword, bits 64:95 */
0145 
0146 #define ACPI_PLD_GET_USER_VISIBLE(dword)        ACPI_GET_BITS (dword, 0, ACPI_1BIT_MASK)
0147 #define ACPI_PLD_SET_USER_VISIBLE(dword,value)  ACPI_SET_BITS (dword, 0, ACPI_1BIT_MASK, value) /* Offset 64+0=64, Len 1 */
0148 
0149 #define ACPI_PLD_GET_DOCK(dword)                ACPI_GET_BITS (dword, 1, ACPI_1BIT_MASK)
0150 #define ACPI_PLD_SET_DOCK(dword,value)          ACPI_SET_BITS (dword, 1, ACPI_1BIT_MASK, value) /* Offset 64+1=65, Len 1 */
0151 
0152 #define ACPI_PLD_GET_LID(dword)                 ACPI_GET_BITS (dword, 2, ACPI_1BIT_MASK)
0153 #define ACPI_PLD_SET_LID(dword,value)           ACPI_SET_BITS (dword, 2, ACPI_1BIT_MASK, value) /* Offset 64+2=66, Len 1 */
0154 
0155 #define ACPI_PLD_GET_PANEL(dword)               ACPI_GET_BITS (dword, 3, ACPI_3BIT_MASK)
0156 #define ACPI_PLD_SET_PANEL(dword,value)         ACPI_SET_BITS (dword, 3, ACPI_3BIT_MASK, value) /* Offset 64+3=67, Len 3 */
0157 
0158 #define ACPI_PLD_GET_VERTICAL(dword)            ACPI_GET_BITS (dword, 6, ACPI_2BIT_MASK)
0159 #define ACPI_PLD_SET_VERTICAL(dword,value)      ACPI_SET_BITS (dword, 6, ACPI_2BIT_MASK, value) /* Offset 64+6=70, Len 2 */
0160 
0161 #define ACPI_PLD_GET_HORIZONTAL(dword)          ACPI_GET_BITS (dword, 8, ACPI_2BIT_MASK)
0162 #define ACPI_PLD_SET_HORIZONTAL(dword,value)    ACPI_SET_BITS (dword, 8, ACPI_2BIT_MASK, value) /* Offset 64+8=72, Len 2 */
0163 
0164 #define ACPI_PLD_GET_SHAPE(dword)               ACPI_GET_BITS (dword, 10, ACPI_4BIT_MASK)
0165 #define ACPI_PLD_SET_SHAPE(dword,value)         ACPI_SET_BITS (dword, 10, ACPI_4BIT_MASK, value)    /* Offset 64+10=74, Len 4 */
0166 
0167 #define ACPI_PLD_GET_ORIENTATION(dword)         ACPI_GET_BITS (dword, 14, ACPI_1BIT_MASK)
0168 #define ACPI_PLD_SET_ORIENTATION(dword,value)   ACPI_SET_BITS (dword, 14, ACPI_1BIT_MASK, value)    /* Offset 64+14=78, Len 1 */
0169 
0170 #define ACPI_PLD_GET_TOKEN(dword)               ACPI_GET_BITS (dword, 15, ACPI_8BIT_MASK)
0171 #define ACPI_PLD_SET_TOKEN(dword,value)         ACPI_SET_BITS (dword, 15, ACPI_8BIT_MASK, value)    /* Offset 64+15=79, Len 8 */
0172 
0173 #define ACPI_PLD_GET_POSITION(dword)            ACPI_GET_BITS (dword, 23, ACPI_8BIT_MASK)
0174 #define ACPI_PLD_SET_POSITION(dword,value)      ACPI_SET_BITS (dword, 23, ACPI_8BIT_MASK, value)    /* Offset 64+23=87, Len 8 */
0175 
0176 #define ACPI_PLD_GET_BAY(dword)                 ACPI_GET_BITS (dword, 31, ACPI_1BIT_MASK)
0177 #define ACPI_PLD_SET_BAY(dword,value)           ACPI_SET_BITS (dword, 31, ACPI_1BIT_MASK, value)    /* Offset 64+31=95, Len 1 */
0178 
0179 /* Fourth 32-bit dword, bits 96:127 */
0180 
0181 #define ACPI_PLD_GET_EJECTABLE(dword)           ACPI_GET_BITS (dword, 0, ACPI_1BIT_MASK)
0182 #define ACPI_PLD_SET_EJECTABLE(dword,value)     ACPI_SET_BITS (dword, 0, ACPI_1BIT_MASK, value) /* Offset 96+0=96, Len 1 */
0183 
0184 #define ACPI_PLD_GET_OSPM_EJECT(dword)          ACPI_GET_BITS (dword, 1, ACPI_1BIT_MASK)
0185 #define ACPI_PLD_SET_OSPM_EJECT(dword,value)    ACPI_SET_BITS (dword, 1, ACPI_1BIT_MASK, value) /* Offset 96+1=97, Len 1 */
0186 
0187 #define ACPI_PLD_GET_CABINET(dword)             ACPI_GET_BITS (dword, 2, ACPI_8BIT_MASK)
0188 #define ACPI_PLD_SET_CABINET(dword,value)       ACPI_SET_BITS (dword, 2, ACPI_8BIT_MASK, value) /* Offset 96+2=98, Len 8 */
0189 
0190 #define ACPI_PLD_GET_CARD_CAGE(dword)           ACPI_GET_BITS (dword, 10, ACPI_8BIT_MASK)
0191 #define ACPI_PLD_SET_CARD_CAGE(dword,value)     ACPI_SET_BITS (dword, 10, ACPI_8BIT_MASK, value)    /* Offset 96+10=106, Len 8 */
0192 
0193 #define ACPI_PLD_GET_REFERENCE(dword)           ACPI_GET_BITS (dword, 18, ACPI_1BIT_MASK)
0194 #define ACPI_PLD_SET_REFERENCE(dword,value)     ACPI_SET_BITS (dword, 18, ACPI_1BIT_MASK, value)    /* Offset 96+18=114, Len 1 */
0195 
0196 #define ACPI_PLD_GET_ROTATION(dword)            ACPI_GET_BITS (dword, 19, ACPI_4BIT_MASK)
0197 #define ACPI_PLD_SET_ROTATION(dword,value)      ACPI_SET_BITS (dword, 19, ACPI_4BIT_MASK, value)    /* Offset 96+19=115, Len 4 */
0198 
0199 #define ACPI_PLD_GET_ORDER(dword)               ACPI_GET_BITS (dword, 23, ACPI_5BIT_MASK)
0200 #define ACPI_PLD_SET_ORDER(dword,value)         ACPI_SET_BITS (dword, 23, ACPI_5BIT_MASK, value)    /* Offset 96+23=119, Len 5 */
0201 
0202 /* Fifth 32-bit dword, bits 128:159 (Revision 2 of _PLD only) */
0203 
0204 #define ACPI_PLD_GET_VERT_OFFSET(dword)         ACPI_GET_BITS (dword, 0, ACPI_16BIT_MASK)
0205 #define ACPI_PLD_SET_VERT_OFFSET(dword,value)   ACPI_SET_BITS (dword, 0, ACPI_16BIT_MASK, value)    /* Offset 128+0=128, Len 16 */
0206 
0207 #define ACPI_PLD_GET_HORIZ_OFFSET(dword)        ACPI_GET_BITS (dword, 16, ACPI_16BIT_MASK)
0208 #define ACPI_PLD_SET_HORIZ_OFFSET(dword,value)  ACPI_SET_BITS (dword, 16, ACPI_16BIT_MASK, value)   /* Offset 128+16=144, Len 16 */
0209 
0210 /* Panel position defined in _PLD section of ACPI Specification 6.3 */
0211 
0212 #define ACPI_PLD_PANEL_TOP      0
0213 #define ACPI_PLD_PANEL_BOTTOM   1
0214 #define ACPI_PLD_PANEL_LEFT     2
0215 #define ACPI_PLD_PANEL_RIGHT    3
0216 #define ACPI_PLD_PANEL_FRONT    4
0217 #define ACPI_PLD_PANEL_BACK     5
0218 #define ACPI_PLD_PANEL_UNKNOWN  6
0219 
0220 #endif              /* ACBUFFER_H */