acbuffer.h revision 245582
1228259Sdumbbell/******************************************************************************
2228259Sdumbbell *
3228259Sdumbbell * Name: acbuffer.h - Support for buffers returned by ACPI predefined names
4228259Sdumbbell *
5228259Sdumbbell *****************************************************************************/
6228259Sdumbbell
7228259Sdumbbell/*
8228259Sdumbbell * Copyright (C) 2000 - 2013, Intel Corp.
9228259Sdumbbell * All rights reserved.
10228259Sdumbbell *
11228259Sdumbbell * Redistribution and use in source and binary forms, with or without
12228259Sdumbbell * modification, are permitted provided that the following conditions
13228259Sdumbbell * are met:
14228259Sdumbbell * 1. Redistributions of source code must retain the above copyright
15228259Sdumbbell *    notice, this list of conditions, and the following disclaimer,
16228259Sdumbbell *    without modification.
17228259Sdumbbell * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18228259Sdumbbell *    substantially similar to the "NO WARRANTY" disclaimer below
19228259Sdumbbell *    ("Disclaimer") and any redistribution must be conditioned upon
20228259Sdumbbell *    including a substantially similar Disclaimer requirement for further
21228259Sdumbbell *    binary redistribution.
22228259Sdumbbell * 3. Neither the names of the above-listed copyright holders nor the names
23228259Sdumbbell *    of any contributors may be used to endorse or promote products derived
24228259Sdumbbell *    from this software without specific prior written permission.
25228259Sdumbbell *
26228259Sdumbbell * Alternatively, this software may be distributed under the terms of the
27228259Sdumbbell * GNU General Public License ("GPL") version 2 as published by the Free
28228259Sdumbbell * Software Foundation.
29228259Sdumbbell *
30228259Sdumbbell * NO WARRANTY
31228259Sdumbbell * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32228259Sdumbbell * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33228259Sdumbbell * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34228259Sdumbbell * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35228259Sdumbbell * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36228259Sdumbbell * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37228259Sdumbbell * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38228259Sdumbbell * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39228259Sdumbbell * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40228259Sdumbbell * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41228259Sdumbbell * POSSIBILITY OF SUCH DAMAGES.
42228259Sdumbbell */
43228259Sdumbbell
44228259Sdumbbell#ifndef __ACBUFFER_H__
45228259Sdumbbell#define __ACBUFFER_H__
46228259Sdumbbell
47228259Sdumbbell/*
48228259Sdumbbell * Contains buffer structures for these predefined names:
49228259Sdumbbell * _FDE, _GRT, _GTM, _PLD, _SRT
50228259Sdumbbell */
51228259Sdumbbell
52228259Sdumbbell/*
53228259Sdumbbell * Note: C bitfields are not used for this reason:
54228259Sdumbbell *
55228259Sdumbbell * "Bitfields are great and easy to read, but unfortunately the C language
56228259Sdumbbell * does not specify the layout of bitfields in memory, which means they are
57228259Sdumbbell * essentially useless for dealing with packed data in on-disk formats or
58228259Sdumbbell * binary wire protocols." (Or ACPI tables and buffers.) "If you ask me,
59228259Sdumbbell * this decision was a design error in C. Ritchie could have picked an order
60228259Sdumbbell * and stuck with it." Norman Ramsey.
61228259Sdumbbell * See http://stackoverflow.com/a/1053662/41661
62228259Sdumbbell */
63228259Sdumbbell
64228259Sdumbbell
65228259Sdumbbell/* _FDE return value */
66228259Sdumbbell
67228259Sdumbbelltypedef struct acpi_fde_info
68228259Sdumbbell{
69228259Sdumbbell    UINT32              Floppy0;
70228259Sdumbbell    UINT32              Floppy1;
71228259Sdumbbell    UINT32              Floppy2;
72228259Sdumbbell    UINT32              Floppy3;
73228259Sdumbbell    UINT32              Tape;
74228259Sdumbbell
75228259Sdumbbell} ACPI_FDE_INFO;
76228259Sdumbbell
77228259Sdumbbell/*
78228259Sdumbbell * _GRT return value
79228259Sdumbbell * _SRT input value
80228259Sdumbbell */
81228259Sdumbbelltypedef struct acpi_grt_info
82228259Sdumbbell{
83228259Sdumbbell    UINT16              Year;
84228259Sdumbbell    UINT8               Month;
85228259Sdumbbell    UINT8               Day;
86228259Sdumbbell    UINT8               Hour;
87228259Sdumbbell    UINT8               Minute;
88228259Sdumbbell    UINT8               Second;
89228259Sdumbbell    UINT8               Valid;
90228259Sdumbbell    UINT16              Milliseconds;
91228259Sdumbbell    UINT16              Timezone;
92228259Sdumbbell    UINT8               Daylight;
93228259Sdumbbell    UINT8               Reserved[3];
94228259Sdumbbell
95228259Sdumbbell} ACPI_GRT_INFO;
96228259Sdumbbell
97228259Sdumbbell/* _GTM return value */
98228259Sdumbbell
99228259Sdumbbelltypedef struct acpi_gtm_info
100228259Sdumbbell{
101228259Sdumbbell    UINT32              PioSpeed0;
102228259Sdumbbell    UINT32              DmaSpeed0;
103228259Sdumbbell    UINT32              PioSpeed1;
104228259Sdumbbell    UINT32              DmaSpeed1;
105228259Sdumbbell    UINT32              Flags;
106228259Sdumbbell
107228259Sdumbbell} ACPI_GTM_INFO;
108228259Sdumbbell
109228259Sdumbbell/*
110228259Sdumbbell * Formatted _PLD return value. The minimum size is a package containing
111228259Sdumbbell * one buffer.
112228259Sdumbbell * Revision 1: Buffer is 16 bytes (128 bits)
113228259Sdumbbell * Revision 2: Buffer is 20 bytes (160 bits)
114228259Sdumbbell *
115228259Sdumbbell * Note: This structure is returned from the AcpiDecodePldBuffer
116228259Sdumbbell * interface.
117228259Sdumbbell */
118228259Sdumbbelltypedef struct acpi_pld_info
119228259Sdumbbell{
120228259Sdumbbell    UINT8               Revision;
121228259Sdumbbell    UINT8               IgnoreColor;
122228259Sdumbbell    UINT32              Color;
123228259Sdumbbell    UINT16              Width;
124228259Sdumbbell    UINT16              Height;
125228259Sdumbbell    UINT8               UserVisible;
126228259Sdumbbell    UINT8               Dock;
127228259Sdumbbell    UINT8               Lid;
128228259Sdumbbell    UINT8               Panel;
129228259Sdumbbell    UINT8               VerticalPosition;
130228259Sdumbbell    UINT8               HorizontalPosition;
131228259Sdumbbell    UINT8               Shape;
132228259Sdumbbell    UINT8               GroupOrientation;
133228259Sdumbbell    UINT8               GroupToken;
134228259Sdumbbell    UINT8               GroupPosition;
135228259Sdumbbell    UINT8               Bay;
136228259Sdumbbell    UINT8               Ejectable;
137228259Sdumbbell    UINT8               OspmEjectRequired;
138228259Sdumbbell    UINT8               CabinetNumber;
139228259Sdumbbell    UINT8               CardCageNumber;
140228259Sdumbbell    UINT8               Reference;
141228259Sdumbbell    UINT8               Rotation;
142228259Sdumbbell    UINT8               Order;
143228259Sdumbbell    UINT8               Reserved;
144228259Sdumbbell    UINT16              VerticalOffset;
145228259Sdumbbell    UINT16              HorizontalOffset;
146228259Sdumbbell
147228259Sdumbbell} ACPI_PLD_INFO;
148228259Sdumbbell
149228259Sdumbbell
150228259Sdumbbell/*
151228259Sdumbbell * Macros to:
152228259Sdumbbell *     1) Convert a _PLD buffer to internal ACPI_PLD_INFO format - ACPI_PLD_GET*
153228259Sdumbbell *        (Used by AcpiDecodePldBuffer)
154228259Sdumbbell *     2) Construct a _PLD buffer - ACPI_PLD_SET*
155228259Sdumbbell *        (Intended for BIOS use only)
156228259Sdumbbell */
157228259Sdumbbell#define ACPI_PLD_REV1_BUFFER_SIZE               16 /* For Revision 1 of the buffer (From ACPI spec) */
158228259Sdumbbell#define ACPI_PLD_BUFFER_SIZE                    20 /* For Revision 2 of the buffer (From ACPI spec) */
159228259Sdumbbell
160228259Sdumbbell/* First 32-bit dword, bits 0:32 */
161228259Sdumbbell
162228259Sdumbbell#define ACPI_PLD_GET_REVISION(dword)            ACPI_GET_BITS (dword, 0, ACPI_7BIT_MASK)
163228259Sdumbbell#define ACPI_PLD_SET_REVISION(dword,value)      ACPI_SET_BITS (dword, 0, ACPI_7BIT_MASK, value)     /* Offset 0, Len 7 */
164228259Sdumbbell
165228259Sdumbbell#define ACPI_PLD_GET_IGNORE_COLOR(dword)        ACPI_GET_BITS (dword, 7, ACPI_1BIT_MASK)
166228259Sdumbbell#define ACPI_PLD_SET_IGNORE_COLOR(dword,value)  ACPI_SET_BITS (dword, 7, ACPI_1BIT_MASK, value)     /* Offset 7, Len 1 */
167228259Sdumbbell
168228259Sdumbbell#define ACPI_PLD_GET_COLOR(dword)               ACPI_GET_BITS (dword, 8, ACPI_24BIT_MASK)
169228259Sdumbbell#define ACPI_PLD_SET_COLOR(dword,value)         ACPI_SET_BITS (dword, 8, ACPI_24BIT_MASK, value)    /* Offset 8, Len 24 */
170228259Sdumbbell
171228259Sdumbbell/* Second 32-bit dword, bits 33:63 */
172228259Sdumbbell
173228259Sdumbbell#define ACPI_PLD_GET_WIDTH(dword)               ACPI_GET_BITS (dword, 0, ACPI_16BIT_MASK)
174228259Sdumbbell#define ACPI_PLD_SET_WIDTH(dword,value)         ACPI_SET_BITS (dword, 0, ACPI_16BIT_MASK, value)    /* Offset 32+0=32, Len 16 */
175228259Sdumbbell
176228259Sdumbbell#define ACPI_PLD_GET_HEIGHT(dword)              ACPI_GET_BITS (dword, 16, ACPI_16BIT_MASK)
177228259Sdumbbell#define ACPI_PLD_SET_HEIGHT(dword,value)        ACPI_SET_BITS (dword, 16, ACPI_16BIT_MASK, value)   /* Offset 32+16=48, Len 16 */
178228259Sdumbbell
179228259Sdumbbell/* Third 32-bit dword, bits 64:95 */
180228259Sdumbbell
181228259Sdumbbell#define ACPI_PLD_GET_USER_VISIBLE(dword)        ACPI_GET_BITS (dword, 0, ACPI_1BIT_MASK)
182228259Sdumbbell#define ACPI_PLD_SET_USER_VISIBLE(dword,value)  ACPI_SET_BITS (dword, 0, ACPI_1BIT_MASK, value)     /* Offset 64+0=64, Len 1 */
183228259Sdumbbell
184228259Sdumbbell#define ACPI_PLD_GET_DOCK(dword)                ACPI_GET_BITS (dword, 1, ACPI_1BIT_MASK)
185228259Sdumbbell#define ACPI_PLD_SET_DOCK(dword,value)          ACPI_SET_BITS (dword, 1, ACPI_1BIT_MASK, value)     /* Offset 64+1=65, Len 1 */
186228259Sdumbbell
187228259Sdumbbell#define ACPI_PLD_GET_LID(dword)                 ACPI_GET_BITS (dword, 2, ACPI_1BIT_MASK)
188228259Sdumbbell#define ACPI_PLD_SET_LID(dword,value)           ACPI_SET_BITS (dword, 2, ACPI_1BIT_MASK, value)     /* Offset 64+2=66, Len 1 */
189228259Sdumbbell
190228259Sdumbbell#define ACPI_PLD_GET_PANEL(dword)               ACPI_GET_BITS (dword, 3, ACPI_3BIT_MASK)
191228259Sdumbbell#define ACPI_PLD_SET_PANEL(dword,value)         ACPI_SET_BITS (dword, 3, ACPI_3BIT_MASK, value)     /* Offset 64+3=67, Len 3 */
192228259Sdumbbell
193228259Sdumbbell#define ACPI_PLD_GET_VERTICAL(dword)            ACPI_GET_BITS (dword, 6, ACPI_2BIT_MASK)
194228259Sdumbbell#define ACPI_PLD_SET_VERTICAL(dword,value)      ACPI_SET_BITS (dword, 6, ACPI_2BIT_MASK, value)     /* Offset 64+6=70, Len 2 */
195228259Sdumbbell
196228259Sdumbbell#define ACPI_PLD_GET_HORIZONTAL(dword)          ACPI_GET_BITS (dword, 8, ACPI_2BIT_MASK)
197228259Sdumbbell#define ACPI_PLD_SET_HORIZONTAL(dword,value)    ACPI_SET_BITS (dword, 8, ACPI_2BIT_MASK, value)     /* Offset 64+8=72, Len 2 */
198228259Sdumbbell
199228259Sdumbbell#define ACPI_PLD_GET_SHAPE(dword)               ACPI_GET_BITS (dword, 10, ACPI_4BIT_MASK)
200228259Sdumbbell#define ACPI_PLD_SET_SHAPE(dword,value)         ACPI_SET_BITS (dword, 10, ACPI_4BIT_MASK, value)    /* Offset 64+10=74, Len 4 */
201228259Sdumbbell
202228259Sdumbbell#define ACPI_PLD_GET_ORIENTATION(dword)         ACPI_GET_BITS (dword, 14, ACPI_1BIT_MASK)
203228259Sdumbbell#define ACPI_PLD_SET_ORIENTATION(dword,value)   ACPI_SET_BITS (dword, 14, ACPI_1BIT_MASK, value)    /* Offset 64+14=78, Len 1 */
204228259Sdumbbell
205228259Sdumbbell#define ACPI_PLD_GET_TOKEN(dword)               ACPI_GET_BITS (dword, 15, ACPI_8BIT_MASK)
206228259Sdumbbell#define ACPI_PLD_SET_TOKEN(dword,value)         ACPI_SET_BITS (dword, 15, ACPI_8BIT_MASK, value)    /* Offset 64+15=79, Len 8 */
207228259Sdumbbell
208228259Sdumbbell#define ACPI_PLD_GET_POSITION(dword)            ACPI_GET_BITS (dword, 23, ACPI_8BIT_MASK)
209228259Sdumbbell#define ACPI_PLD_SET_POSITION(dword,value)      ACPI_SET_BITS (dword, 23, ACPI_8BIT_MASK, value)    /* Offset 64+23=87, Len 8 */
210228259Sdumbbell
211228259Sdumbbell#define ACPI_PLD_GET_BAY(dword)                 ACPI_GET_BITS (dword, 31, ACPI_1BIT_MASK)
212228259Sdumbbell#define ACPI_PLD_SET_BAY(dword,value)           ACPI_SET_BITS (dword, 31, ACPI_1BIT_MASK, value)    /* Offset 64+31=95, Len 1 */
213228259Sdumbbell
214228259Sdumbbell/* Fourth 32-bit dword, bits 96:127 */
215228259Sdumbbell
216228259Sdumbbell#define ACPI_PLD_GET_EJECTABLE(dword)           ACPI_GET_BITS (dword, 0, ACPI_1BIT_MASK)
217228259Sdumbbell#define ACPI_PLD_SET_EJECTABLE(dword,value)     ACPI_SET_BITS (dword, 0, ACPI_1BIT_MASK, value)     /* Offset 96+0=96, Len 1 */
218228259Sdumbbell
219228259Sdumbbell#define ACPI_PLD_GET_OSPM_EJECT(dword)          ACPI_GET_BITS (dword, 1, ACPI_1BIT_MASK)
220228259Sdumbbell#define ACPI_PLD_SET_OSPM_EJECT(dword,value)    ACPI_SET_BITS (dword, 1, ACPI_1BIT_MASK, value)     /* Offset 96+1=97, Len 1 */
221228259Sdumbbell
222228259Sdumbbell#define ACPI_PLD_GET_CABINET(dword)             ACPI_GET_BITS (dword, 2, ACPI_8BIT_MASK)
223228259Sdumbbell#define ACPI_PLD_SET_CABINET(dword,value)       ACPI_SET_BITS (dword, 2, ACPI_8BIT_MASK, value)     /* Offset 96+2=98, Len 8 */
224228259Sdumbbell
225228259Sdumbbell#define ACPI_PLD_GET_CARD_CAGE(dword)           ACPI_GET_BITS (dword, 10, ACPI_8BIT_MASK)
226228259Sdumbbell#define ACPI_PLD_SET_CARD_CAGE(dword,value)     ACPI_SET_BITS (dword, 10, ACPI_8BIT_MASK, value)    /* Offset 96+10=106, Len 8 */
227228259Sdumbbell
228228259Sdumbbell#define ACPI_PLD_GET_REFERENCE(dword)           ACPI_GET_BITS (dword, 18, ACPI_1BIT_MASK)
229228259Sdumbbell#define ACPI_PLD_SET_REFERENCE(dword,value)     ACPI_SET_BITS (dword, 18, ACPI_1BIT_MASK, value)    /* Offset 96+18=114, Len 1 */
230228259Sdumbbell
231228259Sdumbbell#define ACPI_PLD_GET_ROTATION(dword)            ACPI_GET_BITS (dword, 19, ACPI_4BIT_MASK)
232228259Sdumbbell#define ACPI_PLD_SET_ROTATION(dword,value)      ACPI_SET_BITS (dword, 19, ACPI_4BIT_MASK, value)    /* Offset 96+19=115, Len 4 */
233228259Sdumbbell
234228259Sdumbbell#define ACPI_PLD_GET_ORDER(dword)               ACPI_GET_BITS (dword, 23, ACPI_5BIT_MASK)
235228259Sdumbbell#define ACPI_PLD_SET_ORDER(dword,value)         ACPI_SET_BITS (dword, 23, ACPI_5BIT_MASK, value)    /* Offset 96+23=119, Len 5 */
236228259Sdumbbell
237228259Sdumbbell/* Fifth 32-bit dword, bits 128:159 (Revision 2 of _PLD only) */
238228259Sdumbbell
239228259Sdumbbell#define ACPI_PLD_GET_VERT_OFFSET(dword)         ACPI_GET_BITS (dword, 0, ACPI_16BIT_MASK)
240228259Sdumbbell#define ACPI_PLD_SET_VERT_OFFSET(dword,value)   ACPI_SET_BITS (dword, 0, ACPI_16BIT_MASK, value)    /* Offset 128+0=128, Len 16 */
241228259Sdumbbell
242228259Sdumbbell#define ACPI_PLD_GET_HORIZ_OFFSET(dword)        ACPI_GET_BITS (dword, 16, ACPI_16BIT_MASK)
243228259Sdumbbell#define ACPI_PLD_SET_HORIZ_OFFSET(dword,value)  ACPI_SET_BITS (dword, 16, ACPI_16BIT_MASK, value)   /* Offset 128+16=144, Len 16 */
244228259Sdumbbell
245228259Sdumbbell
246228259Sdumbbell#endif /* ACBUFFER_H */
247228259Sdumbbell