xref: /titanic_44/usr/src/uts/intel/io/acpica/resources/rsio.c (revision 48a4016cae8aa2b8b3d8b258eb22e0c781912bed)
1 /*******************************************************************************
2  *
3  * Module Name: rsio - IO and DMA resource descriptors
4  *
5  ******************************************************************************/
6 
7 /*
8  * Copyright (C) 2000 - 2016, Intel Corp.
9  * All rights reserved.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 1. Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions, and the following disclaimer,
16  *    without modification.
17  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18  *    substantially similar to the "NO WARRANTY" disclaimer below
19  *    ("Disclaimer") and any redistribution must be conditioned upon
20  *    including a substantially similar Disclaimer requirement for further
21  *    binary redistribution.
22  * 3. Neither the names of the above-listed copyright holders nor the names
23  *    of any contributors may be used to endorse or promote products derived
24  *    from this software without specific prior written permission.
25  *
26  * Alternatively, this software may be distributed under the terms of the
27  * GNU General Public License ("GPL") version 2 as published by the Free
28  * Software Foundation.
29  *
30  * NO WARRANTY
31  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41  * POSSIBILITY OF SUCH DAMAGES.
42  */
43 
44 #include "acpi.h"
45 #include "accommon.h"
46 #include "acresrc.h"
47 
48 #define _COMPONENT          ACPI_RESOURCES
49         ACPI_MODULE_NAME    ("rsio")
50 
51 
52 /*******************************************************************************
53  *
54  * AcpiRsConvertIo
55  *
56  ******************************************************************************/
57 
58 ACPI_RSCONVERT_INFO     AcpiRsConvertIo[5] =
59 {
60     {ACPI_RSC_INITGET,  ACPI_RESOURCE_TYPE_IO,
61                         ACPI_RS_SIZE (ACPI_RESOURCE_IO),
62                         ACPI_RSC_TABLE_SIZE (AcpiRsConvertIo)},
63 
64     {ACPI_RSC_INITSET,  ACPI_RESOURCE_NAME_IO,
65                         sizeof (AML_RESOURCE_IO),
66                         0},
67 
68     /* Decode flag */
69 
70     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Io.IoDecode),
71                         AML_OFFSET (Io.Flags),
72                         0},
73     /*
74      * These fields are contiguous in both the source and destination:
75      * Address Alignment
76      * Length
77      * Minimum Base Address
78      * Maximum Base Address
79      */
80     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.Io.Alignment),
81                         AML_OFFSET (Io.Alignment),
82                         2},
83 
84     {ACPI_RSC_MOVE16,   ACPI_RS_OFFSET (Data.Io.Minimum),
85                         AML_OFFSET (Io.Minimum),
86                         2}
87 };
88 
89 
90 /*******************************************************************************
91  *
92  * AcpiRsConvertFixedIo
93  *
94  ******************************************************************************/
95 
96 ACPI_RSCONVERT_INFO     AcpiRsConvertFixedIo[4] =
97 {
98     {ACPI_RSC_INITGET,  ACPI_RESOURCE_TYPE_FIXED_IO,
99                         ACPI_RS_SIZE (ACPI_RESOURCE_FIXED_IO),
100                         ACPI_RSC_TABLE_SIZE (AcpiRsConvertFixedIo)},
101 
102     {ACPI_RSC_INITSET,  ACPI_RESOURCE_NAME_FIXED_IO,
103                         sizeof (AML_RESOURCE_FIXED_IO),
104                         0},
105     /*
106      * These fields are contiguous in both the source and destination:
107      * Base Address
108      * Length
109      */
110     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.FixedIo.AddressLength),
111                         AML_OFFSET (FixedIo.AddressLength),
112                         1},
113 
114     {ACPI_RSC_MOVE16,   ACPI_RS_OFFSET (Data.FixedIo.Address),
115                         AML_OFFSET (FixedIo.Address),
116                         1}
117 };
118 
119 
120 /*******************************************************************************
121  *
122  * AcpiRsConvertGenericReg
123  *
124  ******************************************************************************/
125 
126 ACPI_RSCONVERT_INFO     AcpiRsConvertGenericReg[4] =
127 {
128     {ACPI_RSC_INITGET,  ACPI_RESOURCE_TYPE_GENERIC_REGISTER,
129                         ACPI_RS_SIZE (ACPI_RESOURCE_GENERIC_REGISTER),
130                         ACPI_RSC_TABLE_SIZE (AcpiRsConvertGenericReg)},
131 
132     {ACPI_RSC_INITSET,  ACPI_RESOURCE_NAME_GENERIC_REGISTER,
133                         sizeof (AML_RESOURCE_GENERIC_REGISTER),
134                         0},
135     /*
136      * These fields are contiguous in both the source and destination:
137      * Address Space ID
138      * Register Bit Width
139      * Register Bit Offset
140      * Access Size
141      */
142     {ACPI_RSC_MOVE8,    ACPI_RS_OFFSET (Data.GenericReg.SpaceId),
143                         AML_OFFSET (GenericReg.AddressSpaceId),
144                         4},
145 
146     /* Get the Register Address */
147 
148     {ACPI_RSC_MOVE64,   ACPI_RS_OFFSET (Data.GenericReg.Address),
149                         AML_OFFSET (GenericReg.Address),
150                         1}
151 };
152 
153 
154 /*******************************************************************************
155  *
156  * AcpiRsConvertEndDpf
157  *
158  ******************************************************************************/
159 
160 ACPI_RSCONVERT_INFO   AcpiRsConvertEndDpf[2] =
161 {
162     {ACPI_RSC_INITGET,  ACPI_RESOURCE_TYPE_END_DEPENDENT,
163                         ACPI_RS_SIZE_MIN,
164                         ACPI_RSC_TABLE_SIZE (AcpiRsConvertEndDpf)},
165 
166     {ACPI_RSC_INITSET,  ACPI_RESOURCE_NAME_END_DEPENDENT,
167                         sizeof (AML_RESOURCE_END_DEPENDENT),
168                         0}
169 };
170 
171 
172 /*******************************************************************************
173  *
174  * AcpiRsConvertEndTag
175  *
176  ******************************************************************************/
177 
178 ACPI_RSCONVERT_INFO   AcpiRsConvertEndTag[2] =
179 {
180     {ACPI_RSC_INITGET,  ACPI_RESOURCE_TYPE_END_TAG,
181                         ACPI_RS_SIZE_MIN,
182                         ACPI_RSC_TABLE_SIZE (AcpiRsConvertEndTag)},
183 
184     /*
185      * Note: The checksum field is set to zero, meaning that the resource
186      * data is treated as if the checksum operation succeeded.
187      * (ACPI Spec 1.0b Section 6.4.2.8)
188      */
189     {ACPI_RSC_INITSET,  ACPI_RESOURCE_NAME_END_TAG,
190                         sizeof (AML_RESOURCE_END_TAG),
191                         0}
192 };
193 
194 
195 /*******************************************************************************
196  *
197  * AcpiRsGetStartDpf
198  *
199  ******************************************************************************/
200 
201 ACPI_RSCONVERT_INFO   AcpiRsGetStartDpf[6] =
202 {
203     {ACPI_RSC_INITGET,  ACPI_RESOURCE_TYPE_START_DEPENDENT,
204                         ACPI_RS_SIZE (ACPI_RESOURCE_START_DEPENDENT),
205                         ACPI_RSC_TABLE_SIZE (AcpiRsGetStartDpf)},
206 
207     /* Defaults for Compatibility and Performance priorities */
208 
209     {ACPI_RSC_SET8,     ACPI_RS_OFFSET (Data.StartDpf.CompatibilityPriority),
210                         ACPI_ACCEPTABLE_CONFIGURATION,
211                         2},
212 
213     /* Get the descriptor length (0 or 1 for Start Dpf descriptor) */
214 
215     {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.StartDpf.DescriptorLength),
216                         AML_OFFSET (StartDpf.DescriptorType),
217                         0},
218 
219     /* All done if there is no flag byte present in the descriptor */
220 
221     {ACPI_RSC_EXIT_NE,  ACPI_RSC_COMPARE_AML_LENGTH, 0, 1},
222 
223     /* Flag byte is present, get the flags */
224 
225     {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.StartDpf.CompatibilityPriority),
226                         AML_OFFSET (StartDpf.Flags),
227                         0},
228 
229     {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.StartDpf.PerformanceRobustness),
230                         AML_OFFSET (StartDpf.Flags),
231                         2}
232 };
233 
234 
235 /*******************************************************************************
236  *
237  * AcpiRsSetStartDpf
238  *
239  ******************************************************************************/
240 
241 ACPI_RSCONVERT_INFO   AcpiRsSetStartDpf[10] =
242 {
243     /* Start with a default descriptor of length 1 */
244 
245     {ACPI_RSC_INITSET,  ACPI_RESOURCE_NAME_START_DEPENDENT,
246                         sizeof (AML_RESOURCE_START_DEPENDENT),
247                         ACPI_RSC_TABLE_SIZE (AcpiRsSetStartDpf)},
248 
249     /* Set the default flag values */
250 
251     {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.StartDpf.CompatibilityPriority),
252                         AML_OFFSET (StartDpf.Flags),
253                         0},
254 
255     {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.StartDpf.PerformanceRobustness),
256                         AML_OFFSET (StartDpf.Flags),
257                         2},
258     /*
259      * All done if the output descriptor length is required to be 1
260      * (i.e., optimization to 0 bytes cannot be attempted)
261      */
262     {ACPI_RSC_EXIT_EQ,  ACPI_RSC_COMPARE_VALUE,
263                         ACPI_RS_OFFSET(Data.StartDpf.DescriptorLength),
264                         1},
265 
266     /* Set length to 0 bytes (no flags byte) */
267 
268     {ACPI_RSC_LENGTH,   0, 0, sizeof (AML_RESOURCE_START_DEPENDENT_NOPRIO)},
269 
270     /*
271      * All done if the output descriptor length is required to be 0.
272      *
273      * TBD: Perhaps we should check for error if input flags are not
274      * compatible with a 0-byte descriptor.
275      */
276     {ACPI_RSC_EXIT_EQ,  ACPI_RSC_COMPARE_VALUE,
277                         ACPI_RS_OFFSET(Data.StartDpf.DescriptorLength),
278                         0},
279 
280     /* Reset length to 1 byte (descriptor with flags byte) */
281 
282     {ACPI_RSC_LENGTH,   0, 0, sizeof (AML_RESOURCE_START_DEPENDENT)},
283 
284 
285     /*
286      * All done if flags byte is necessary -- if either priority value
287      * is not ACPI_ACCEPTABLE_CONFIGURATION
288      */
289     {ACPI_RSC_EXIT_NE,  ACPI_RSC_COMPARE_VALUE,
290                         ACPI_RS_OFFSET (Data.StartDpf.CompatibilityPriority),
291                         ACPI_ACCEPTABLE_CONFIGURATION},
292 
293     {ACPI_RSC_EXIT_NE,  ACPI_RSC_COMPARE_VALUE,
294                         ACPI_RS_OFFSET (Data.StartDpf.PerformanceRobustness),
295                         ACPI_ACCEPTABLE_CONFIGURATION},
296 
297     /* Flag byte is not necessary */
298 
299     {ACPI_RSC_LENGTH,   0, 0, sizeof (AML_RESOURCE_START_DEPENDENT_NOPRIO)}
300 };
301