blob: 610d7c2101f211a66c9470441a917afe1837b9d3 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*******************************************************************************
2 *
3 * Module Name: rsio - IO and DMA resource descriptors
4 *
5 ******************************************************************************/
6
7/*
Bob Moore6c9deb72007-02-02 19:48:24 +03008 * Copyright (C) 2000 - 2007, R. Byron Moore
Linus Torvalds1da177e2005-04-16 15:20:36 -07009 * 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
Linus Torvalds1da177e2005-04-16 15:20:36 -070044#include <acpi/acpi.h>
45#include <acpi/acresrc.h>
46
47#define _COMPONENT ACPI_RESOURCES
Len Brown4be44fc2005-08-05 00:44:28 -040048ACPI_MODULE_NAME("rsio")
Linus Torvalds1da177e2005-04-16 15:20:36 -070049
50/*******************************************************************************
51 *
Bob Moore08978312005-10-21 00:00:00 -040052 * acpi_rs_convert_io
Linus Torvalds1da177e2005-04-16 15:20:36 -070053 *
54 ******************************************************************************/
Bob Moore08978312005-10-21 00:00:00 -040055struct acpi_rsconvert_info acpi_rs_convert_io[5] = {
56 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_IO,
57 ACPI_RS_SIZE(struct acpi_resource_io),
58 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_io)},
Linus Torvalds1da177e2005-04-16 15:20:36 -070059
Bob Moore08978312005-10-21 00:00:00 -040060 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_IO,
61 sizeof(struct aml_resource_io),
62 0},
Linus Torvalds1da177e2005-04-16 15:20:36 -070063
Bob Moore08978312005-10-21 00:00:00 -040064 /* Decode flag */
Robert Moore44f6c012005-04-18 22:49:35 -040065
Bob Moore08978312005-10-21 00:00:00 -040066 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.io.io_decode),
67 AML_OFFSET(io.flags),
68 0},
Bob Moore50eca3e2005-09-30 19:03:00 -040069 /*
Bob Moore08978312005-10-21 00:00:00 -040070 * These fields are contiguous in both the source and destination:
Bob Moore50eca3e2005-09-30 19:03:00 -040071 * Address Alignment
72 * Length
Bob Moore08978312005-10-21 00:00:00 -040073 * Minimum Base Address
74 * Maximum Base Address
Bob Moore50eca3e2005-09-30 19:03:00 -040075 */
Bob Moore08978312005-10-21 00:00:00 -040076 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.io.alignment),
77 AML_OFFSET(io.alignment),
78 2},
Linus Torvalds1da177e2005-04-16 15:20:36 -070079
Bob Moore08978312005-10-21 00:00:00 -040080 {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.io.minimum),
81 AML_OFFSET(io.minimum),
82 2}
83};
Linus Torvalds1da177e2005-04-16 15:20:36 -070084
Linus Torvalds1da177e2005-04-16 15:20:36 -070085/*******************************************************************************
86 *
Bob Moore08978312005-10-21 00:00:00 -040087 * acpi_rs_convert_fixed_io
Linus Torvalds1da177e2005-04-16 15:20:36 -070088 *
89 ******************************************************************************/
90
Bob Moore08978312005-10-21 00:00:00 -040091struct acpi_rsconvert_info acpi_rs_convert_fixed_io[4] = {
92 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_FIXED_IO,
93 ACPI_RS_SIZE(struct acpi_resource_fixed_io),
94 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_fixed_io)},
Linus Torvalds1da177e2005-04-16 15:20:36 -070095
Bob Moore08978312005-10-21 00:00:00 -040096 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_FIXED_IO,
97 sizeof(struct aml_resource_fixed_io),
98 0},
Bob Moore50eca3e2005-09-30 19:03:00 -040099 /*
Bob Moore08978312005-10-21 00:00:00 -0400100 * These fields are contiguous in both the source and destination:
Bob Moore50eca3e2005-09-30 19:03:00 -0400101 * Base Address
102 * Length
103 */
Bob Moore08978312005-10-21 00:00:00 -0400104 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.fixed_io.address_length),
105 AML_OFFSET(fixed_io.address_length),
106 1},
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107
Bob Moore08978312005-10-21 00:00:00 -0400108 {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.fixed_io.address),
109 AML_OFFSET(fixed_io.address),
110 1}
111};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113/*******************************************************************************
114 *
Bob Moore08978312005-10-21 00:00:00 -0400115 * acpi_rs_convert_generic_reg
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116 *
117 ******************************************************************************/
118
Bob Moore08978312005-10-21 00:00:00 -0400119struct acpi_rsconvert_info acpi_rs_convert_generic_reg[4] = {
120 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_GENERIC_REGISTER,
121 ACPI_RS_SIZE(struct acpi_resource_generic_register),
122 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_generic_reg)},
123
124 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_GENERIC_REGISTER,
125 sizeof(struct aml_resource_generic_register),
126 0},
127 /*
128 * These fields are contiguous in both the source and destination:
129 * Address Space ID
130 * Register Bit Width
131 * Register Bit Offset
132 * Access Size
133 */
134 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.generic_reg.space_id),
135 AML_OFFSET(generic_reg.address_space_id),
136 4},
137
138 /* Get the Register Address */
139
140 {ACPI_RSC_MOVE64, ACPI_RS_OFFSET(data.generic_reg.address),
141 AML_OFFSET(generic_reg.address),
142 1}
143};
144
145/*******************************************************************************
146 *
147 * acpi_rs_convert_end_dpf
148 *
149 ******************************************************************************/
150
151struct acpi_rsconvert_info acpi_rs_convert_end_dpf[2] = {
152 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_END_DEPENDENT,
153 ACPI_RS_SIZE_MIN,
154 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_end_dpf)},
155
156 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_END_DEPENDENT,
157 sizeof(struct aml_resource_end_dependent),
158 0}
159};
160
161/*******************************************************************************
162 *
163 * acpi_rs_convert_end_tag
164 *
165 ******************************************************************************/
166
167struct acpi_rsconvert_info acpi_rs_convert_end_tag[2] = {
168 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_END_TAG,
169 ACPI_RS_SIZE_MIN,
170 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_end_tag)},
Linus Torvalds1da177e2005-04-16 15:20:36 -0700171
Bob Moore50eca3e2005-09-30 19:03:00 -0400172 /*
Bob Moore08978312005-10-21 00:00:00 -0400173 * Note: The checksum field is set to zero, meaning that the resource
174 * data is treated as if the checksum operation succeeded.
175 * (ACPI Spec 1.0b Section 6.4.2.8)
Bob Moore50eca3e2005-09-30 19:03:00 -0400176 */
Bob Moore08978312005-10-21 00:00:00 -0400177 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_END_TAG,
178 sizeof(struct aml_resource_end_tag),
179 0}
180};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700181
Linus Torvalds1da177e2005-04-16 15:20:36 -0700182/*******************************************************************************
183 *
Bob Moore08978312005-10-21 00:00:00 -0400184 * acpi_rs_get_start_dpf
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185 *
186 ******************************************************************************/
187
Bob Moore1d5b2852008-04-10 19:06:43 +0400188struct acpi_rsconvert_info acpi_rs_get_start_dpf[6] = {
Bob Moore08978312005-10-21 00:00:00 -0400189 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_START_DEPENDENT,
190 ACPI_RS_SIZE(struct acpi_resource_start_dependent),
191 ACPI_RSC_TABLE_SIZE(acpi_rs_get_start_dpf)},
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192
Bob Moore08978312005-10-21 00:00:00 -0400193 /* Defaults for Compatibility and Performance priorities */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194
Bob Moore08978312005-10-21 00:00:00 -0400195 {ACPI_RSC_SET8, ACPI_RS_OFFSET(data.start_dpf.compatibility_priority),
196 ACPI_ACCEPTABLE_CONFIGURATION,
197 2},
Linus Torvalds1da177e2005-04-16 15:20:36 -0700198
Bob Moore1d5b2852008-04-10 19:06:43 +0400199 /* Get the descriptor length (0 or 1 for Start Dpf descriptor) */
200
201 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.start_dpf.descriptor_length),
202 AML_OFFSET(start_dpf.descriptor_type),
203 0},
204
Bob Moore08978312005-10-21 00:00:00 -0400205 /* All done if there is no flag byte present in the descriptor */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700206
Bob Moore08978312005-10-21 00:00:00 -0400207 {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_AML_LENGTH, 0, 1},
Linus Torvalds1da177e2005-04-16 15:20:36 -0700208
Bob Moore08978312005-10-21 00:00:00 -0400209 /* Flag byte is present, get the flags */
210
211 {ACPI_RSC_2BITFLAG,
212 ACPI_RS_OFFSET(data.start_dpf.compatibility_priority),
213 AML_OFFSET(start_dpf.flags),
214 0},
215
216 {ACPI_RSC_2BITFLAG,
217 ACPI_RS_OFFSET(data.start_dpf.performance_robustness),
218 AML_OFFSET(start_dpf.flags),
219 2}
220};
221
222/*******************************************************************************
223 *
224 * acpi_rs_set_start_dpf
225 *
226 ******************************************************************************/
227
Bob Moore1d5b2852008-04-10 19:06:43 +0400228struct acpi_rsconvert_info acpi_rs_set_start_dpf[10] = {
229 /* Start with a default descriptor of length 1 */
230
Bob Moore08978312005-10-21 00:00:00 -0400231 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_START_DEPENDENT,
232 sizeof(struct aml_resource_start_dependent),
233 ACPI_RSC_TABLE_SIZE(acpi_rs_set_start_dpf)},
234
235 /* Set the default flag values */
236
237 {ACPI_RSC_2BITFLAG,
238 ACPI_RS_OFFSET(data.start_dpf.compatibility_priority),
239 AML_OFFSET(start_dpf.flags),
240 0},
241
242 {ACPI_RSC_2BITFLAG,
243 ACPI_RS_OFFSET(data.start_dpf.performance_robustness),
244 AML_OFFSET(start_dpf.flags),
245 2},
Bob Moore50eca3e2005-09-30 19:03:00 -0400246 /*
Bob Moore1d5b2852008-04-10 19:06:43 +0400247 * All done if the output descriptor length is required to be 1
248 * (i.e., optimization to 0 bytes cannot be attempted)
249 */
250 {ACPI_RSC_EXIT_EQ, ACPI_RSC_COMPARE_VALUE,
251 ACPI_RS_OFFSET(data.start_dpf.descriptor_length),
252 1},
253
254 /* Set length to 0 bytes (no flags byte) */
255
256 {ACPI_RSC_LENGTH, 0, 0,
257 sizeof(struct aml_resource_start_dependent_noprio)},
258
259 /*
260 * All done if the output descriptor length is required to be 0.
261 *
262 * TBD: Perhaps we should check for error if input flags are not
263 * compatible with a 0-byte descriptor.
264 */
265 {ACPI_RSC_EXIT_EQ, ACPI_RSC_COMPARE_VALUE,
266 ACPI_RS_OFFSET(data.start_dpf.descriptor_length),
267 0},
268
269 /* Reset length to 1 byte (descriptor with flags byte) */
270
Bob Moore66d3ca92008-04-10 19:06:44 +0400271 {ACPI_RSC_LENGTH, 0, 0, sizeof(struct aml_resource_start_dependent)},
Bob Moore1d5b2852008-04-10 19:06:43 +0400272
273 /*
Bob Moore08978312005-10-21 00:00:00 -0400274 * All done if flags byte is necessary -- if either priority value
275 * is not ACPI_ACCEPTABLE_CONFIGURATION
Bob Moore50eca3e2005-09-30 19:03:00 -0400276 */
Bob Moore08978312005-10-21 00:00:00 -0400277 {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE,
278 ACPI_RS_OFFSET(data.start_dpf.compatibility_priority),
279 ACPI_ACCEPTABLE_CONFIGURATION},
Linus Torvalds1da177e2005-04-16 15:20:36 -0700280
Bob Moore08978312005-10-21 00:00:00 -0400281 {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE,
282 ACPI_RS_OFFSET(data.start_dpf.performance_robustness),
283 ACPI_ACCEPTABLE_CONFIGURATION},
Robert Moore44f6c012005-04-18 22:49:35 -0400284
Bob Moore08978312005-10-21 00:00:00 -0400285 /* Flag byte is not necessary */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700286
Bob Moore08978312005-10-21 00:00:00 -0400287 {ACPI_RSC_LENGTH, 0, 0,
288 sizeof(struct aml_resource_start_dependent_noprio)}
289};