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