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