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