blob: 687aaed9655ae3a50dabc031799dc61f533d0049 [file] [log] [blame]
Erik Schmauss95857632018-03-14 16:13:07 -07001// SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*******************************************************************************
3 *
4 * Module Name: rsio - IO and DMA resource descriptors
5 *
6 ******************************************************************************/
7
Linus Torvalds1da177e2005-04-16 15:20:36 -07008#include <acpi/acpi.h>
Len Browne2f7a772009-01-09 00:30:03 -05009#include "accommon.h"
10#include "acresrc.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070011
12#define _COMPONENT ACPI_RESOURCES
Len Brown4be44fc2005-08-05 00:44:28 -040013ACPI_MODULE_NAME("rsio")
Linus Torvalds1da177e2005-04-16 15:20:36 -070014
15/*******************************************************************************
16 *
Bob Moore08978312005-10-21 00:00:00 -040017 * acpi_rs_convert_io
Linus Torvalds1da177e2005-04-16 15:20:36 -070018 *
19 ******************************************************************************/
Bob Moore08978312005-10-21 00:00:00 -040020struct acpi_rsconvert_info acpi_rs_convert_io[5] = {
21 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_IO,
22 ACPI_RS_SIZE(struct acpi_resource_io),
23 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_io)},
Linus Torvalds1da177e2005-04-16 15:20:36 -070024
Bob Moore08978312005-10-21 00:00:00 -040025 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_IO,
26 sizeof(struct aml_resource_io),
27 0},
Linus Torvalds1da177e2005-04-16 15:20:36 -070028
Bob Moore08978312005-10-21 00:00:00 -040029 /* Decode flag */
Robert Moore44f6c012005-04-18 22:49:35 -040030
Bob Moore08978312005-10-21 00:00:00 -040031 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.io.io_decode),
32 AML_OFFSET(io.flags),
33 0},
Bob Moore50eca3e2005-09-30 19:03:00 -040034 /*
Bob Moore08978312005-10-21 00:00:00 -040035 * These fields are contiguous in both the source and destination:
Bob Moore50eca3e2005-09-30 19:03:00 -040036 * Address Alignment
37 * Length
Bob Moore08978312005-10-21 00:00:00 -040038 * Minimum Base Address
39 * Maximum Base Address
Bob Moore50eca3e2005-09-30 19:03:00 -040040 */
Bob Moore08978312005-10-21 00:00:00 -040041 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.io.alignment),
42 AML_OFFSET(io.alignment),
43 2},
Linus Torvalds1da177e2005-04-16 15:20:36 -070044
Bob Moore08978312005-10-21 00:00:00 -040045 {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.io.minimum),
46 AML_OFFSET(io.minimum),
47 2}
48};
Linus Torvalds1da177e2005-04-16 15:20:36 -070049
Linus Torvalds1da177e2005-04-16 15:20:36 -070050/*******************************************************************************
51 *
Bob Moore08978312005-10-21 00:00:00 -040052 * acpi_rs_convert_fixed_io
Linus Torvalds1da177e2005-04-16 15:20:36 -070053 *
54 ******************************************************************************/
55
Bob Moore08978312005-10-21 00:00:00 -040056struct acpi_rsconvert_info acpi_rs_convert_fixed_io[4] = {
57 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_FIXED_IO,
58 ACPI_RS_SIZE(struct acpi_resource_fixed_io),
59 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_fixed_io)},
Linus Torvalds1da177e2005-04-16 15:20:36 -070060
Bob Moore08978312005-10-21 00:00:00 -040061 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_FIXED_IO,
62 sizeof(struct aml_resource_fixed_io),
63 0},
Bob Moore50eca3e2005-09-30 19:03:00 -040064 /*
Bob Moore08978312005-10-21 00:00:00 -040065 * These fields are contiguous in both the source and destination:
Bob Moore50eca3e2005-09-30 19:03:00 -040066 * Base Address
67 * Length
68 */
Bob Moore08978312005-10-21 00:00:00 -040069 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.fixed_io.address_length),
70 AML_OFFSET(fixed_io.address_length),
71 1},
Linus Torvalds1da177e2005-04-16 15:20:36 -070072
Bob Moore08978312005-10-21 00:00:00 -040073 {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.fixed_io.address),
74 AML_OFFSET(fixed_io.address),
75 1}
76};
Linus Torvalds1da177e2005-04-16 15:20:36 -070077
Linus Torvalds1da177e2005-04-16 15:20:36 -070078/*******************************************************************************
79 *
Bob Moore08978312005-10-21 00:00:00 -040080 * acpi_rs_convert_generic_reg
Linus Torvalds1da177e2005-04-16 15:20:36 -070081 *
82 ******************************************************************************/
83
Bob Moore08978312005-10-21 00:00:00 -040084struct acpi_rsconvert_info acpi_rs_convert_generic_reg[4] = {
85 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_GENERIC_REGISTER,
86 ACPI_RS_SIZE(struct acpi_resource_generic_register),
87 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_generic_reg)},
88
89 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_GENERIC_REGISTER,
90 sizeof(struct aml_resource_generic_register),
91 0},
92 /*
93 * These fields are contiguous in both the source and destination:
94 * Address Space ID
95 * Register Bit Width
96 * Register Bit Offset
97 * Access Size
98 */
99 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.generic_reg.space_id),
100 AML_OFFSET(generic_reg.address_space_id),
101 4},
102
103 /* Get the Register Address */
104
105 {ACPI_RSC_MOVE64, ACPI_RS_OFFSET(data.generic_reg.address),
106 AML_OFFSET(generic_reg.address),
107 1}
108};
109
110/*******************************************************************************
111 *
112 * acpi_rs_convert_end_dpf
113 *
114 ******************************************************************************/
115
116struct acpi_rsconvert_info acpi_rs_convert_end_dpf[2] = {
117 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_END_DEPENDENT,
118 ACPI_RS_SIZE_MIN,
119 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_end_dpf)},
120
121 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_END_DEPENDENT,
122 sizeof(struct aml_resource_end_dependent),
123 0}
124};
125
126/*******************************************************************************
127 *
128 * acpi_rs_convert_end_tag
129 *
130 ******************************************************************************/
131
132struct acpi_rsconvert_info acpi_rs_convert_end_tag[2] = {
133 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_END_TAG,
134 ACPI_RS_SIZE_MIN,
135 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_end_tag)},
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136
Bob Moore50eca3e2005-09-30 19:03:00 -0400137 /*
Bob Moore08978312005-10-21 00:00:00 -0400138 * Note: The checksum field is set to zero, meaning that the resource
139 * data is treated as if the checksum operation succeeded.
140 * (ACPI Spec 1.0b Section 6.4.2.8)
Bob Moore50eca3e2005-09-30 19:03:00 -0400141 */
Bob Moore08978312005-10-21 00:00:00 -0400142 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_END_TAG,
143 sizeof(struct aml_resource_end_tag),
144 0}
145};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147/*******************************************************************************
148 *
Bob Moore08978312005-10-21 00:00:00 -0400149 * acpi_rs_get_start_dpf
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150 *
151 ******************************************************************************/
152
Bob Moore1d5b2852008-04-10 19:06:43 +0400153struct acpi_rsconvert_info acpi_rs_get_start_dpf[6] = {
Bob Moore08978312005-10-21 00:00:00 -0400154 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_START_DEPENDENT,
155 ACPI_RS_SIZE(struct acpi_resource_start_dependent),
156 ACPI_RSC_TABLE_SIZE(acpi_rs_get_start_dpf)},
Linus Torvalds1da177e2005-04-16 15:20:36 -0700157
Bob Moore08978312005-10-21 00:00:00 -0400158 /* Defaults for Compatibility and Performance priorities */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159
Bob Moore08978312005-10-21 00:00:00 -0400160 {ACPI_RSC_SET8, ACPI_RS_OFFSET(data.start_dpf.compatibility_priority),
161 ACPI_ACCEPTABLE_CONFIGURATION,
162 2},
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163
Bob Moore1d5b2852008-04-10 19:06:43 +0400164 /* Get the descriptor length (0 or 1 for Start Dpf descriptor) */
165
166 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.start_dpf.descriptor_length),
167 AML_OFFSET(start_dpf.descriptor_type),
168 0},
169
Bob Moore08978312005-10-21 00:00:00 -0400170 /* All done if there is no flag byte present in the descriptor */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700171
Bob Moore08978312005-10-21 00:00:00 -0400172 {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_AML_LENGTH, 0, 1},
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173
Bob Moore08978312005-10-21 00:00:00 -0400174 /* Flag byte is present, get the flags */
175
176 {ACPI_RSC_2BITFLAG,
177 ACPI_RS_OFFSET(data.start_dpf.compatibility_priority),
178 AML_OFFSET(start_dpf.flags),
179 0},
180
181 {ACPI_RSC_2BITFLAG,
182 ACPI_RS_OFFSET(data.start_dpf.performance_robustness),
183 AML_OFFSET(start_dpf.flags),
184 2}
185};
186
187/*******************************************************************************
188 *
189 * acpi_rs_set_start_dpf
190 *
191 ******************************************************************************/
192
Bob Moore1d5b2852008-04-10 19:06:43 +0400193struct acpi_rsconvert_info acpi_rs_set_start_dpf[10] = {
194 /* Start with a default descriptor of length 1 */
195
Bob Moore08978312005-10-21 00:00:00 -0400196 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_START_DEPENDENT,
197 sizeof(struct aml_resource_start_dependent),
198 ACPI_RSC_TABLE_SIZE(acpi_rs_set_start_dpf)},
199
200 /* Set the default flag values */
201
202 {ACPI_RSC_2BITFLAG,
203 ACPI_RS_OFFSET(data.start_dpf.compatibility_priority),
204 AML_OFFSET(start_dpf.flags),
205 0},
206
207 {ACPI_RSC_2BITFLAG,
208 ACPI_RS_OFFSET(data.start_dpf.performance_robustness),
209 AML_OFFSET(start_dpf.flags),
210 2},
Bob Moore50eca3e2005-09-30 19:03:00 -0400211 /*
Bob Moore1d5b2852008-04-10 19:06:43 +0400212 * All done if the output descriptor length is required to be 1
213 * (i.e., optimization to 0 bytes cannot be attempted)
214 */
215 {ACPI_RSC_EXIT_EQ, ACPI_RSC_COMPARE_VALUE,
216 ACPI_RS_OFFSET(data.start_dpf.descriptor_length),
217 1},
218
219 /* Set length to 0 bytes (no flags byte) */
220
221 {ACPI_RSC_LENGTH, 0, 0,
222 sizeof(struct aml_resource_start_dependent_noprio)},
223
224 /*
225 * All done if the output descriptor length is required to be 0.
226 *
227 * TBD: Perhaps we should check for error if input flags are not
228 * compatible with a 0-byte descriptor.
229 */
230 {ACPI_RSC_EXIT_EQ, ACPI_RSC_COMPARE_VALUE,
231 ACPI_RS_OFFSET(data.start_dpf.descriptor_length),
232 0},
233
234 /* Reset length to 1 byte (descriptor with flags byte) */
235
Bob Moore66d3ca92008-04-10 19:06:44 +0400236 {ACPI_RSC_LENGTH, 0, 0, sizeof(struct aml_resource_start_dependent)},
Bob Moore1d5b2852008-04-10 19:06:43 +0400237
238 /*
Bob Moore08978312005-10-21 00:00:00 -0400239 * All done if flags byte is necessary -- if either priority value
240 * is not ACPI_ACCEPTABLE_CONFIGURATION
Bob Moore50eca3e2005-09-30 19:03:00 -0400241 */
Bob Moore08978312005-10-21 00:00:00 -0400242 {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE,
243 ACPI_RS_OFFSET(data.start_dpf.compatibility_priority),
244 ACPI_ACCEPTABLE_CONFIGURATION},
Linus Torvalds1da177e2005-04-16 15:20:36 -0700245
Bob Moore08978312005-10-21 00:00:00 -0400246 {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE,
247 ACPI_RS_OFFSET(data.start_dpf.performance_robustness),
248 ACPI_ACCEPTABLE_CONFIGURATION},
Robert Moore44f6c012005-04-18 22:49:35 -0400249
Bob Moore08978312005-10-21 00:00:00 -0400250 /* Flag byte is not necessary */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251
Bob Moore08978312005-10-21 00:00:00 -0400252 {ACPI_RSC_LENGTH, 0, 0,
253 sizeof(struct aml_resource_start_dependent_noprio)}
254};