ACPICA: update Intel copyright
[deliverable/linux.git] / drivers / acpi / resources / rsaddr.c
CommitLineData
1da177e4
LT
1/*******************************************************************************
2 *
3 * Module Name: rsaddr - Address resource descriptors (16/32/64)
4 *
5 ******************************************************************************/
6
7/*
75a44ce0 8 * Copyright (C) 2000 - 2008, Intel Corp.
1da177e4
LT
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
1da177e4
LT
44#include <acpi/acpi.h>
45#include <acpi/acresrc.h>
46
47#define _COMPONENT ACPI_RESOURCES
4be44fcd 48ACPI_MODULE_NAME("rsaddr")
1da177e4 49
aff8c277
RM
50/*******************************************************************************
51 *
0897831b 52 * acpi_rs_convert_address16 - All WORD (16-bit) address resources
aff8c277
RM
53 *
54 ******************************************************************************/
0897831b
BM
55struct acpi_rsconvert_info acpi_rs_convert_address16[5] = {
56 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_ADDRESS16,
57 ACPI_RS_SIZE(struct acpi_resource_address16),
58 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_address16)},
aff8c277 59
0897831b
BM
60 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_ADDRESS16,
61 sizeof(struct aml_resource_address16),
62 0},
aff8c277 63
0897831b 64 /* Resource Type, General Flags, and Type-Specific Flags */
aff8c277 65
0897831b 66 {ACPI_RSC_ADDRESS, 0, 0, 0},
1da177e4
LT
67
68 /*
0897831b 69 * These fields are contiguous in both the source and destination:
50eca3eb
BM
70 * Address Granularity
71 * Address Range Minimum
72 * Address Range Maximum
73 * Address Translation Offset
74 * Address Length
1da177e4 75 */
0897831b
BM
76 {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.address16.granularity),
77 AML_OFFSET(address16.granularity),
78 5},
1da177e4 79
0897831b 80 /* Optional resource_source (Index and String) */
1da177e4 81
0897831b
BM
82 {ACPI_RSC_SOURCE, ACPI_RS_OFFSET(data.address16.resource_source),
83 0,
84 sizeof(struct aml_resource_address16)}
85};
1da177e4 86
1da177e4
LT
87/*******************************************************************************
88 *
0897831b 89 * acpi_rs_convert_address32 - All DWORD (32-bit) address resources
1da177e4
LT
90 *
91 ******************************************************************************/
92
0897831b
BM
93struct acpi_rsconvert_info acpi_rs_convert_address32[5] = {
94 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_ADDRESS32,
95 ACPI_RS_SIZE(struct acpi_resource_address32),
96 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_address32)},
44f6c012 97
0897831b
BM
98 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_ADDRESS32,
99 sizeof(struct aml_resource_address32),
100 0},
1da177e4 101
0897831b 102 /* Resource Type, General Flags, and Type-Specific Flags */
44f6c012 103
0897831b 104 {ACPI_RSC_ADDRESS, 0, 0, 0},
44f6c012 105
50eca3eb 106 /*
0897831b 107 * These fields are contiguous in both the source and destination:
50eca3eb
BM
108 * Address Granularity
109 * Address Range Minimum
110 * Address Range Maximum
111 * Address Translation Offset
112 * Address Length
113 */
0897831b
BM
114 {ACPI_RSC_MOVE32, ACPI_RS_OFFSET(data.address32.granularity),
115 AML_OFFSET(address32.granularity),
116 5},
44f6c012 117
0897831b 118 /* Optional resource_source (Index and String) */
1da177e4 119
0897831b
BM
120 {ACPI_RSC_SOURCE, ACPI_RS_OFFSET(data.address32.resource_source),
121 0,
122 sizeof(struct aml_resource_address32)}
123};
1da177e4 124
1da177e4
LT
125/*******************************************************************************
126 *
0897831b 127 * acpi_rs_convert_address64 - All QWORD (64-bit) address resources
1da177e4
LT
128 *
129 ******************************************************************************/
130
0897831b
BM
131struct acpi_rsconvert_info acpi_rs_convert_address64[5] = {
132 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_ADDRESS64,
133 ACPI_RS_SIZE(struct acpi_resource_address64),
134 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_address64)},
1da177e4 135
0897831b
BM
136 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_ADDRESS64,
137 sizeof(struct aml_resource_address64),
138 0},
1da177e4 139
0897831b 140 /* Resource Type, General Flags, and Type-Specific Flags */
1da177e4 141
0897831b 142 {ACPI_RSC_ADDRESS, 0, 0, 0},
1da177e4 143
1da177e4 144 /*
0897831b 145 * These fields are contiguous in both the source and destination:
50eca3eb
BM
146 * Address Granularity
147 * Address Range Minimum
148 * Address Range Maximum
149 * Address Translation Offset
150 * Address Length
1da177e4 151 */
0897831b
BM
152 {ACPI_RSC_MOVE64, ACPI_RS_OFFSET(data.address64.granularity),
153 AML_OFFSET(address64.granularity),
154 5},
1da177e4 155
0897831b 156 /* Optional resource_source (Index and String) */
1da177e4 157
0897831b
BM
158 {ACPI_RSC_SOURCE, ACPI_RS_OFFSET(data.address64.resource_source),
159 0,
160 sizeof(struct aml_resource_address64)}
161};
1da177e4 162
1da177e4
LT
163/*******************************************************************************
164 *
0897831b 165 * acpi_rs_convert_ext_address64 - All Extended (64-bit) address resources
1da177e4
LT
166 *
167 ******************************************************************************/
168
0897831b
BM
169struct acpi_rsconvert_info acpi_rs_convert_ext_address64[5] = {
170 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64,
171 ACPI_RS_SIZE(struct acpi_resource_extended_address64),
172 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_ext_address64)},
173
174 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64,
175 sizeof(struct aml_resource_extended_address64),
176 0},
1da177e4 177
0897831b 178 /* Resource Type, General Flags, and Type-Specific Flags */
44f6c012 179
0897831b 180 {ACPI_RSC_ADDRESS, 0, 0, 0},
1da177e4 181
0897831b 182 /* Revision ID */
44f6c012 183
0897831b
BM
184 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.ext_address64.revision_iD),
185 AML_OFFSET(ext_address64.revision_iD),
186 1},
50eca3eb 187 /*
0897831b 188 * These fields are contiguous in both the source and destination:
50eca3eb
BM
189 * Address Granularity
190 * Address Range Minimum
191 * Address Range Maximum
192 * Address Translation Offset
193 * Address Length
0897831b 194 * Type-Specific Attribute
50eca3eb 195 */
0897831b
BM
196 {ACPI_RSC_MOVE64, ACPI_RS_OFFSET(data.ext_address64.granularity),
197 AML_OFFSET(ext_address64.granularity),
198 6}
199};
1da177e4 200
1da177e4
LT
201/*******************************************************************************
202 *
0897831b 203 * acpi_rs_convert_general_flags - Flags common to all address descriptors
1da177e4
LT
204 *
205 ******************************************************************************/
206
0897831b
BM
207static struct acpi_rsconvert_info acpi_rs_convert_general_flags[6] = {
208 {ACPI_RSC_FLAGINIT, 0, AML_OFFSET(address.flags),
209 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_general_flags)},
44f6c012 210
0897831b 211 /* Resource Type (Memory, Io, bus_number, etc.) */
1da177e4 212
0897831b
BM
213 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.address.resource_type),
214 AML_OFFSET(address.resource_type),
215 1},
1da177e4 216
0897831b 217 /* General Flags - Consume, Decode, min_fixed, max_fixed */
44f6c012 218
0897831b
BM
219 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.address.producer_consumer),
220 AML_OFFSET(address.flags),
221 0},
1da177e4 222
0897831b
BM
223 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.address.decode),
224 AML_OFFSET(address.flags),
225 1},
1da177e4 226
0897831b
BM
227 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.address.min_address_fixed),
228 AML_OFFSET(address.flags),
229 2},
1da177e4 230
0897831b
BM
231 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.address.max_address_fixed),
232 AML_OFFSET(address.flags),
233 3}
234};
1da177e4 235
50eca3eb
BM
236/*******************************************************************************
237 *
0897831b 238 * acpi_rs_convert_mem_flags - Flags common to Memory address descriptors
50eca3eb
BM
239 *
240 ******************************************************************************/
1da177e4 241
0897831b
BM
242static struct acpi_rsconvert_info acpi_rs_convert_mem_flags[5] = {
243 {ACPI_RSC_FLAGINIT, 0, AML_OFFSET(address.specific_flags),
244 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_mem_flags)},
44f6c012 245
0897831b 246 /* Memory-specific flags */
1da177e4 247
0897831b
BM
248 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.address.info.mem.write_protect),
249 AML_OFFSET(address.specific_flags),
250 0},
1da177e4 251
0897831b
BM
252 {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.address.info.mem.caching),
253 AML_OFFSET(address.specific_flags),
254 1},
1da177e4 255
0897831b
BM
256 {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.address.info.mem.range_type),
257 AML_OFFSET(address.specific_flags),
258 3},
259
260 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.address.info.mem.translation),
261 AML_OFFSET(address.specific_flags),
262 5}
263};
264
265/*******************************************************************************
266 *
267 * acpi_rs_convert_io_flags - Flags common to I/O address descriptors
268 *
269 ******************************************************************************/
1da177e4 270
0897831b
BM
271static struct acpi_rsconvert_info acpi_rs_convert_io_flags[4] = {
272 {ACPI_RSC_FLAGINIT, 0, AML_OFFSET(address.specific_flags),
273 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_io_flags)},
1da177e4 274
0897831b 275 /* I/O-specific flags */
1da177e4 276
0897831b
BM
277 {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.address.info.io.range_type),
278 AML_OFFSET(address.specific_flags),
279 0},
1da177e4 280
0897831b
BM
281 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.address.info.io.translation),
282 AML_OFFSET(address.specific_flags),
283 4},
284
285 {ACPI_RSC_1BITFLAG,
286 ACPI_RS_OFFSET(data.address.info.io.translation_type),
287 AML_OFFSET(address.specific_flags),
288 5}
289};
1da177e4 290
50eca3eb
BM
291/*******************************************************************************
292 *
0897831b 293 * FUNCTION: acpi_rs_get_address_common
50eca3eb 294 *
0897831b
BM
295 * PARAMETERS: Resource - Pointer to the internal resource struct
296 * Aml - Pointer to the AML resource descriptor
50eca3eb 297 *
0897831b 298 * RETURN: TRUE if the resource_type field is OK, FALSE otherwise
50eca3eb 299 *
0897831b
BM
300 * DESCRIPTION: Convert common flag fields from a raw AML resource descriptor
301 * to an internal resource descriptor
50eca3eb
BM
302 *
303 ******************************************************************************/
1da177e4 304
0897831b
BM
305u8
306acpi_rs_get_address_common(struct acpi_resource *resource,
307 union aml_resource *aml)
50eca3eb 308{
0897831b 309 ACPI_FUNCTION_ENTRY();
1da177e4 310
0897831b 311 /* Validate the Resource Type */
1da177e4 312
0897831b
BM
313 if ((aml->address.resource_type > 2)
314 && (aml->address.resource_type < 0xC0)) {
315 return (FALSE);
1da177e4
LT
316 }
317
0897831b 318 /* Get the Resource Type and General Flags */
44f6c012 319
0897831b
BM
320 (void)acpi_rs_convert_aml_to_resource(resource, aml,
321 acpi_rs_convert_general_flags);
322
323 /* Get the Type-Specific Flags (Memory and I/O descriptors only) */
1da177e4 324
0897831b
BM
325 if (resource->data.address.resource_type == ACPI_MEMORY_RANGE) {
326 (void)acpi_rs_convert_aml_to_resource(resource, aml,
327 acpi_rs_convert_mem_flags);
328 } else if (resource->data.address.resource_type == ACPI_IO_RANGE) {
329 (void)acpi_rs_convert_aml_to_resource(resource, aml,
330 acpi_rs_convert_io_flags);
331 } else {
332 /* Generic resource type, just grab the type_specific byte */
44f6c012 333
0897831b
BM
334 resource->data.address.info.type_specific =
335 aml->address.specific_flags;
336 }
337
338 return (TRUE);
1da177e4
LT
339}
340
1da177e4
LT
341/*******************************************************************************
342 *
0897831b 343 * FUNCTION: acpi_rs_set_address_common
1da177e4 344 *
0897831b
BM
345 * PARAMETERS: Aml - Pointer to the AML resource descriptor
346 * Resource - Pointer to the internal resource struct
1da177e4 347 *
0897831b 348 * RETURN: None
1da177e4 349 *
0897831b
BM
350 * DESCRIPTION: Convert common flag fields from a resource descriptor to an
351 * AML descriptor
1da177e4
LT
352 *
353 ******************************************************************************/
354
0897831b
BM
355void
356acpi_rs_set_address_common(union aml_resource *aml,
357 struct acpi_resource *resource)
1da177e4 358{
0897831b 359 ACPI_FUNCTION_ENTRY();
44f6c012 360
0897831b 361 /* Set the Resource Type and General Flags */
1da177e4 362
0897831b
BM
363 (void)acpi_rs_convert_resource_to_aml(resource, aml,
364 acpi_rs_convert_general_flags);
44f6c012 365
0897831b 366 /* Set the Type-Specific Flags (Memory and I/O descriptors only) */
1da177e4 367
0897831b
BM
368 if (resource->data.address.resource_type == ACPI_MEMORY_RANGE) {
369 (void)acpi_rs_convert_resource_to_aml(resource, aml,
370 acpi_rs_convert_mem_flags);
371 } else if (resource->data.address.resource_type == ACPI_IO_RANGE) {
372 (void)acpi_rs_convert_resource_to_aml(resource, aml,
373 acpi_rs_convert_io_flags);
374 } else {
375 /* Generic resource type, just copy the type_specific byte */
1da177e4 376
0897831b
BM
377 aml->address.specific_flags =
378 resource->data.address.info.type_specific;
379 }
1da177e4 380}
This page took 0.277083 seconds and 5 git commands to generate.