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