Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /******************************************************************************* |
| 2 | * |
| 3 | * Module Name: rsio - IO and DMA resource descriptors |
| 4 | * |
| 5 | ******************************************************************************/ |
| 6 | |
| 7 | /* |
Bob Moore | 25f044e | 2013-01-25 05:38:56 +0000 | [diff] [blame] | 8 | * Copyright (C) 2000 - 2013, Intel Corp. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | #include <acpi/acpi.h> |
Len Brown | e2f7a77 | 2009-01-09 00:30:03 -0500 | [diff] [blame] | 45 | #include "accommon.h" |
| 46 | #include "acresrc.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | |
| 48 | #define _COMPONENT ACPI_RESOURCES |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 49 | ACPI_MODULE_NAME("rsio") |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | |
| 51 | /******************************************************************************* |
| 52 | * |
Bob Moore | 0897831 | 2005-10-21 00:00:00 -0400 | [diff] [blame] | 53 | * acpi_rs_convert_io |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | * |
| 55 | ******************************************************************************/ |
Bob Moore | 0897831 | 2005-10-21 00:00:00 -0400 | [diff] [blame] | 56 | struct acpi_rsconvert_info acpi_rs_convert_io[5] = { |
| 57 | {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_IO, |
| 58 | ACPI_RS_SIZE(struct acpi_resource_io), |
| 59 | ACPI_RSC_TABLE_SIZE(acpi_rs_convert_io)}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | |
Bob Moore | 0897831 | 2005-10-21 00:00:00 -0400 | [diff] [blame] | 61 | {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_IO, |
| 62 | sizeof(struct aml_resource_io), |
| 63 | 0}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | |
Bob Moore | 0897831 | 2005-10-21 00:00:00 -0400 | [diff] [blame] | 65 | /* Decode flag */ |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 66 | |
Bob Moore | 0897831 | 2005-10-21 00:00:00 -0400 | [diff] [blame] | 67 | {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.io.io_decode), |
| 68 | AML_OFFSET(io.flags), |
| 69 | 0}, |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 70 | /* |
Bob Moore | 0897831 | 2005-10-21 00:00:00 -0400 | [diff] [blame] | 71 | * These fields are contiguous in both the source and destination: |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 72 | * Address Alignment |
| 73 | * Length |
Bob Moore | 0897831 | 2005-10-21 00:00:00 -0400 | [diff] [blame] | 74 | * Minimum Base Address |
| 75 | * Maximum Base Address |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 76 | */ |
Bob Moore | 0897831 | 2005-10-21 00:00:00 -0400 | [diff] [blame] | 77 | {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.io.alignment), |
| 78 | AML_OFFSET(io.alignment), |
| 79 | 2}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | |
Bob Moore | 0897831 | 2005-10-21 00:00:00 -0400 | [diff] [blame] | 81 | {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.io.minimum), |
| 82 | AML_OFFSET(io.minimum), |
| 83 | 2} |
| 84 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | /******************************************************************************* |
| 87 | * |
Bob Moore | 0897831 | 2005-10-21 00:00:00 -0400 | [diff] [blame] | 88 | * acpi_rs_convert_fixed_io |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | * |
| 90 | ******************************************************************************/ |
| 91 | |
Bob Moore | 0897831 | 2005-10-21 00:00:00 -0400 | [diff] [blame] | 92 | struct acpi_rsconvert_info acpi_rs_convert_fixed_io[4] = { |
| 93 | {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_FIXED_IO, |
| 94 | ACPI_RS_SIZE(struct acpi_resource_fixed_io), |
| 95 | ACPI_RSC_TABLE_SIZE(acpi_rs_convert_fixed_io)}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | |
Bob Moore | 0897831 | 2005-10-21 00:00:00 -0400 | [diff] [blame] | 97 | {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_FIXED_IO, |
| 98 | sizeof(struct aml_resource_fixed_io), |
| 99 | 0}, |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 100 | /* |
Bob Moore | 0897831 | 2005-10-21 00:00:00 -0400 | [diff] [blame] | 101 | * These fields are contiguous in both the source and destination: |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 102 | * Base Address |
| 103 | * Length |
| 104 | */ |
Bob Moore | 0897831 | 2005-10-21 00:00:00 -0400 | [diff] [blame] | 105 | {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.fixed_io.address_length), |
| 106 | AML_OFFSET(fixed_io.address_length), |
| 107 | 1}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | |
Bob Moore | 0897831 | 2005-10-21 00:00:00 -0400 | [diff] [blame] | 109 | {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.fixed_io.address), |
| 110 | AML_OFFSET(fixed_io.address), |
| 111 | 1} |
| 112 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 113 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | /******************************************************************************* |
| 115 | * |
Bob Moore | 0897831 | 2005-10-21 00:00:00 -0400 | [diff] [blame] | 116 | * acpi_rs_convert_generic_reg |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | * |
| 118 | ******************************************************************************/ |
| 119 | |
Bob Moore | 0897831 | 2005-10-21 00:00:00 -0400 | [diff] [blame] | 120 | struct acpi_rsconvert_info acpi_rs_convert_generic_reg[4] = { |
| 121 | {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_GENERIC_REGISTER, |
| 122 | ACPI_RS_SIZE(struct acpi_resource_generic_register), |
| 123 | ACPI_RSC_TABLE_SIZE(acpi_rs_convert_generic_reg)}, |
| 124 | |
| 125 | {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_GENERIC_REGISTER, |
| 126 | sizeof(struct aml_resource_generic_register), |
| 127 | 0}, |
| 128 | /* |
| 129 | * These fields are contiguous in both the source and destination: |
| 130 | * Address Space ID |
| 131 | * Register Bit Width |
| 132 | * Register Bit Offset |
| 133 | * Access Size |
| 134 | */ |
| 135 | {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.generic_reg.space_id), |
| 136 | AML_OFFSET(generic_reg.address_space_id), |
| 137 | 4}, |
| 138 | |
| 139 | /* Get the Register Address */ |
| 140 | |
| 141 | {ACPI_RSC_MOVE64, ACPI_RS_OFFSET(data.generic_reg.address), |
| 142 | AML_OFFSET(generic_reg.address), |
| 143 | 1} |
| 144 | }; |
| 145 | |
| 146 | /******************************************************************************* |
| 147 | * |
| 148 | * acpi_rs_convert_end_dpf |
| 149 | * |
| 150 | ******************************************************************************/ |
| 151 | |
| 152 | struct acpi_rsconvert_info acpi_rs_convert_end_dpf[2] = { |
| 153 | {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_END_DEPENDENT, |
| 154 | ACPI_RS_SIZE_MIN, |
| 155 | ACPI_RSC_TABLE_SIZE(acpi_rs_convert_end_dpf)}, |
| 156 | |
| 157 | {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_END_DEPENDENT, |
| 158 | sizeof(struct aml_resource_end_dependent), |
| 159 | 0} |
| 160 | }; |
| 161 | |
| 162 | /******************************************************************************* |
| 163 | * |
| 164 | * acpi_rs_convert_end_tag |
| 165 | * |
| 166 | ******************************************************************************/ |
| 167 | |
| 168 | struct acpi_rsconvert_info acpi_rs_convert_end_tag[2] = { |
| 169 | {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_END_TAG, |
| 170 | ACPI_RS_SIZE_MIN, |
| 171 | ACPI_RSC_TABLE_SIZE(acpi_rs_convert_end_tag)}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 173 | /* |
Bob Moore | 0897831 | 2005-10-21 00:00:00 -0400 | [diff] [blame] | 174 | * Note: The checksum field is set to zero, meaning that the resource |
| 175 | * data is treated as if the checksum operation succeeded. |
| 176 | * (ACPI Spec 1.0b Section 6.4.2.8) |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 177 | */ |
Bob Moore | 0897831 | 2005-10-21 00:00:00 -0400 | [diff] [blame] | 178 | {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_END_TAG, |
| 179 | sizeof(struct aml_resource_end_tag), |
| 180 | 0} |
| 181 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 182 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 | /******************************************************************************* |
| 184 | * |
Bob Moore | 0897831 | 2005-10-21 00:00:00 -0400 | [diff] [blame] | 185 | * acpi_rs_get_start_dpf |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 186 | * |
| 187 | ******************************************************************************/ |
| 188 | |
Bob Moore | 1d5b285 | 2008-04-10 19:06:43 +0400 | [diff] [blame] | 189 | struct acpi_rsconvert_info acpi_rs_get_start_dpf[6] = { |
Bob Moore | 0897831 | 2005-10-21 00:00:00 -0400 | [diff] [blame] | 190 | {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_START_DEPENDENT, |
| 191 | ACPI_RS_SIZE(struct acpi_resource_start_dependent), |
| 192 | ACPI_RSC_TABLE_SIZE(acpi_rs_get_start_dpf)}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 193 | |
Bob Moore | 0897831 | 2005-10-21 00:00:00 -0400 | [diff] [blame] | 194 | /* Defaults for Compatibility and Performance priorities */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 195 | |
Bob Moore | 0897831 | 2005-10-21 00:00:00 -0400 | [diff] [blame] | 196 | {ACPI_RSC_SET8, ACPI_RS_OFFSET(data.start_dpf.compatibility_priority), |
| 197 | ACPI_ACCEPTABLE_CONFIGURATION, |
| 198 | 2}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 199 | |
Bob Moore | 1d5b285 | 2008-04-10 19:06:43 +0400 | [diff] [blame] | 200 | /* Get the descriptor length (0 or 1 for Start Dpf descriptor) */ |
| 201 | |
| 202 | {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.start_dpf.descriptor_length), |
| 203 | AML_OFFSET(start_dpf.descriptor_type), |
| 204 | 0}, |
| 205 | |
Bob Moore | 0897831 | 2005-10-21 00:00:00 -0400 | [diff] [blame] | 206 | /* All done if there is no flag byte present in the descriptor */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 207 | |
Bob Moore | 0897831 | 2005-10-21 00:00:00 -0400 | [diff] [blame] | 208 | {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_AML_LENGTH, 0, 1}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 209 | |
Bob Moore | 0897831 | 2005-10-21 00:00:00 -0400 | [diff] [blame] | 210 | /* Flag byte is present, get the flags */ |
| 211 | |
| 212 | {ACPI_RSC_2BITFLAG, |
| 213 | ACPI_RS_OFFSET(data.start_dpf.compatibility_priority), |
| 214 | AML_OFFSET(start_dpf.flags), |
| 215 | 0}, |
| 216 | |
| 217 | {ACPI_RSC_2BITFLAG, |
| 218 | ACPI_RS_OFFSET(data.start_dpf.performance_robustness), |
| 219 | AML_OFFSET(start_dpf.flags), |
| 220 | 2} |
| 221 | }; |
| 222 | |
| 223 | /******************************************************************************* |
| 224 | * |
| 225 | * acpi_rs_set_start_dpf |
| 226 | * |
| 227 | ******************************************************************************/ |
| 228 | |
Bob Moore | 1d5b285 | 2008-04-10 19:06:43 +0400 | [diff] [blame] | 229 | struct acpi_rsconvert_info acpi_rs_set_start_dpf[10] = { |
| 230 | /* Start with a default descriptor of length 1 */ |
| 231 | |
Bob Moore | 0897831 | 2005-10-21 00:00:00 -0400 | [diff] [blame] | 232 | {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_START_DEPENDENT, |
| 233 | sizeof(struct aml_resource_start_dependent), |
| 234 | ACPI_RSC_TABLE_SIZE(acpi_rs_set_start_dpf)}, |
| 235 | |
| 236 | /* Set the default flag values */ |
| 237 | |
| 238 | {ACPI_RSC_2BITFLAG, |
| 239 | ACPI_RS_OFFSET(data.start_dpf.compatibility_priority), |
| 240 | AML_OFFSET(start_dpf.flags), |
| 241 | 0}, |
| 242 | |
| 243 | {ACPI_RSC_2BITFLAG, |
| 244 | ACPI_RS_OFFSET(data.start_dpf.performance_robustness), |
| 245 | AML_OFFSET(start_dpf.flags), |
| 246 | 2}, |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 247 | /* |
Bob Moore | 1d5b285 | 2008-04-10 19:06:43 +0400 | [diff] [blame] | 248 | * All done if the output descriptor length is required to be 1 |
| 249 | * (i.e., optimization to 0 bytes cannot be attempted) |
| 250 | */ |
| 251 | {ACPI_RSC_EXIT_EQ, ACPI_RSC_COMPARE_VALUE, |
| 252 | ACPI_RS_OFFSET(data.start_dpf.descriptor_length), |
| 253 | 1}, |
| 254 | |
| 255 | /* Set length to 0 bytes (no flags byte) */ |
| 256 | |
| 257 | {ACPI_RSC_LENGTH, 0, 0, |
| 258 | sizeof(struct aml_resource_start_dependent_noprio)}, |
| 259 | |
| 260 | /* |
| 261 | * All done if the output descriptor length is required to be 0. |
| 262 | * |
| 263 | * TBD: Perhaps we should check for error if input flags are not |
| 264 | * compatible with a 0-byte descriptor. |
| 265 | */ |
| 266 | {ACPI_RSC_EXIT_EQ, ACPI_RSC_COMPARE_VALUE, |
| 267 | ACPI_RS_OFFSET(data.start_dpf.descriptor_length), |
| 268 | 0}, |
| 269 | |
| 270 | /* Reset length to 1 byte (descriptor with flags byte) */ |
| 271 | |
Bob Moore | 66d3ca9 | 2008-04-10 19:06:44 +0400 | [diff] [blame] | 272 | {ACPI_RSC_LENGTH, 0, 0, sizeof(struct aml_resource_start_dependent)}, |
Bob Moore | 1d5b285 | 2008-04-10 19:06:43 +0400 | [diff] [blame] | 273 | |
| 274 | /* |
Bob Moore | 0897831 | 2005-10-21 00:00:00 -0400 | [diff] [blame] | 275 | * All done if flags byte is necessary -- if either priority value |
| 276 | * is not ACPI_ACCEPTABLE_CONFIGURATION |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 277 | */ |
Bob Moore | 0897831 | 2005-10-21 00:00:00 -0400 | [diff] [blame] | 278 | {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE, |
| 279 | ACPI_RS_OFFSET(data.start_dpf.compatibility_priority), |
| 280 | ACPI_ACCEPTABLE_CONFIGURATION}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 281 | |
Bob Moore | 0897831 | 2005-10-21 00:00:00 -0400 | [diff] [blame] | 282 | {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE, |
| 283 | ACPI_RS_OFFSET(data.start_dpf.performance_robustness), |
| 284 | ACPI_ACCEPTABLE_CONFIGURATION}, |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 285 | |
Bob Moore | 0897831 | 2005-10-21 00:00:00 -0400 | [diff] [blame] | 286 | /* Flag byte is not necessary */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 287 | |
Bob Moore | 0897831 | 2005-10-21 00:00:00 -0400 | [diff] [blame] | 288 | {ACPI_RSC_LENGTH, 0, 0, |
| 289 | sizeof(struct aml_resource_start_dependent_noprio)} |
| 290 | }; |