1 /******************************************************************************* 2 * 3 * Module Name: rsio - IO and DMA resource descriptors 4 * 5 ******************************************************************************/ 6 7 /* 8 * Copyright (C) 2000 - 2011, Intel Corp. 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 44 #define __RSIO_C__ 45 46 #include "acpi.h" 47 #include "accommon.h" 48 #include "acresrc.h" 49 50 #define _COMPONENT ACPI_RESOURCES 51 ACPI_MODULE_NAME ("rsio") 52 53 54 /******************************************************************************* 55 * 56 * AcpiRsConvertIo 57 * 58 ******************************************************************************/ 59 60 ACPI_RSCONVERT_INFO AcpiRsConvertIo[5] = 61 { 62 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_IO, 63 ACPI_RS_SIZE (ACPI_RESOURCE_IO), 64 ACPI_RSC_TABLE_SIZE (AcpiRsConvertIo)}, 65 66 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_IO, 67 sizeof (AML_RESOURCE_IO), 68 0}, 69 70 /* Decode flag */ 71 72 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Io.IoDecode), 73 AML_OFFSET (Io.Flags), 74 0}, 75 /* 76 * These fields are contiguous in both the source and destination: 77 * Address Alignment 78 * Length 79 * Minimum Base Address 80 * Maximum Base Address 81 */ 82 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.Io.Alignment), 83 AML_OFFSET (Io.Alignment), 84 2}, 85 86 {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.Io.Minimum), 87 AML_OFFSET (Io.Minimum), 88 2} 89 }; 90 91 92 /******************************************************************************* 93 * 94 * AcpiRsConvertFixedIo 95 * 96 ******************************************************************************/ 97 98 ACPI_RSCONVERT_INFO AcpiRsConvertFixedIo[4] = 99 { 100 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_FIXED_IO, 101 ACPI_RS_SIZE (ACPI_RESOURCE_FIXED_IO), 102 ACPI_RSC_TABLE_SIZE (AcpiRsConvertFixedIo)}, 103 104 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_FIXED_IO, 105 sizeof (AML_RESOURCE_FIXED_IO), 106 0}, 107 /* 108 * These fields are contiguous in both the source and destination: 109 * Base Address 110 * Length 111 */ 112 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.FixedIo.AddressLength), 113 AML_OFFSET (FixedIo.AddressLength), 114 1}, 115 116 {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.FixedIo.Address), 117 AML_OFFSET (FixedIo.Address), 118 1} 119 }; 120 121 122 /******************************************************************************* 123 * 124 * AcpiRsConvertGenericReg 125 * 126 ******************************************************************************/ 127 128 ACPI_RSCONVERT_INFO AcpiRsConvertGenericReg[4] = 129 { 130 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_GENERIC_REGISTER, 131 ACPI_RS_SIZE (ACPI_RESOURCE_GENERIC_REGISTER), 132 ACPI_RSC_TABLE_SIZE (AcpiRsConvertGenericReg)}, 133 134 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_GENERIC_REGISTER, 135 sizeof (AML_RESOURCE_GENERIC_REGISTER), 136 0}, 137 /* 138 * These fields are contiguous in both the source and destination: 139 * Address Space ID 140 * Register Bit Width 141 * Register Bit Offset 142 * Access Size 143 */ 144 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.GenericReg.SpaceId), 145 AML_OFFSET (GenericReg.AddressSpaceId), 146 4}, 147 148 /* Get the Register Address */ 149 150 {ACPI_RSC_MOVE64, ACPI_RS_OFFSET (Data.GenericReg.Address), 151 AML_OFFSET (GenericReg.Address), 152 1} 153 }; 154 155 156 /******************************************************************************* 157 * 158 * AcpiRsConvertEndDpf 159 * 160 ******************************************************************************/ 161 162 ACPI_RSCONVERT_INFO AcpiRsConvertEndDpf[2] = 163 { 164 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_END_DEPENDENT, 165 ACPI_RS_SIZE_MIN, 166 ACPI_RSC_TABLE_SIZE (AcpiRsConvertEndDpf)}, 167 168 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_END_DEPENDENT, 169 sizeof (AML_RESOURCE_END_DEPENDENT), 170 0} 171 }; 172 173 174 /******************************************************************************* 175 * 176 * AcpiRsConvertEndTag 177 * 178 ******************************************************************************/ 179 180 ACPI_RSCONVERT_INFO AcpiRsConvertEndTag[2] = 181 { 182 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_END_TAG, 183 ACPI_RS_SIZE_MIN, 184 ACPI_RSC_TABLE_SIZE (AcpiRsConvertEndTag)}, 185 186 /* 187 * Note: The checksum field is set to zero, meaning that the resource 188 * data is treated as if the checksum operation succeeded. 189 * (ACPI Spec 1.0b Section 6.4.2.8) 190 */ 191 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_END_TAG, 192 sizeof (AML_RESOURCE_END_TAG), 193 0} 194 }; 195 196 197 /******************************************************************************* 198 * 199 * AcpiRsGetStartDpf 200 * 201 ******************************************************************************/ 202 203 ACPI_RSCONVERT_INFO AcpiRsGetStartDpf[6] = 204 { 205 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_START_DEPENDENT, 206 ACPI_RS_SIZE (ACPI_RESOURCE_START_DEPENDENT), 207 ACPI_RSC_TABLE_SIZE (AcpiRsGetStartDpf)}, 208 209 /* Defaults for Compatibility and Performance priorities */ 210 211 {ACPI_RSC_SET8, ACPI_RS_OFFSET (Data.StartDpf.CompatibilityPriority), 212 ACPI_ACCEPTABLE_CONFIGURATION, 213 2}, 214 215 /* Get the descriptor length (0 or 1 for Start Dpf descriptor) */ 216 217 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.StartDpf.DescriptorLength), 218 AML_OFFSET (StartDpf.DescriptorType), 219 0}, 220 221 /* All done if there is no flag byte present in the descriptor */ 222 223 {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_AML_LENGTH, 0, 1}, 224 225 /* Flag byte is present, get the flags */ 226 227 {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.StartDpf.CompatibilityPriority), 228 AML_OFFSET (StartDpf.Flags), 229 0}, 230 231 {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.StartDpf.PerformanceRobustness), 232 AML_OFFSET (StartDpf.Flags), 233 2} 234 }; 235 236 237 /******************************************************************************* 238 * 239 * AcpiRsSetStartDpf 240 * 241 ******************************************************************************/ 242 243 ACPI_RSCONVERT_INFO AcpiRsSetStartDpf[10] = 244 { 245 /* Start with a default descriptor of length 1 */ 246 247 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_START_DEPENDENT, 248 sizeof (AML_RESOURCE_START_DEPENDENT), 249 ACPI_RSC_TABLE_SIZE (AcpiRsSetStartDpf)}, 250 251 /* Set the default flag values */ 252 253 {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.StartDpf.CompatibilityPriority), 254 AML_OFFSET (StartDpf.Flags), 255 0}, 256 257 {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.StartDpf.PerformanceRobustness), 258 AML_OFFSET (StartDpf.Flags), 259 2}, 260 /* 261 * All done if the output descriptor length is required to be 1 262 * (i.e., optimization to 0 bytes cannot be attempted) 263 */ 264 {ACPI_RSC_EXIT_EQ, ACPI_RSC_COMPARE_VALUE, 265 ACPI_RS_OFFSET(Data.StartDpf.DescriptorLength), 266 1}, 267 268 /* Set length to 0 bytes (no flags byte) */ 269 270 {ACPI_RSC_LENGTH, 0, 0, sizeof (AML_RESOURCE_START_DEPENDENT_NOPRIO)}, 271 272 /* 273 * All done if the output descriptor length is required to be 0. 274 * 275 * TBD: Perhaps we should check for error if input flags are not 276 * compatible with a 0-byte descriptor. 277 */ 278 {ACPI_RSC_EXIT_EQ, ACPI_RSC_COMPARE_VALUE, 279 ACPI_RS_OFFSET(Data.StartDpf.DescriptorLength), 280 0}, 281 282 /* Reset length to 1 byte (descriptor with flags byte) */ 283 284 {ACPI_RSC_LENGTH, 0, 0, sizeof (AML_RESOURCE_START_DEPENDENT)}, 285 286 287 /* 288 * All done if flags byte is necessary -- if either priority value 289 * is not ACPI_ACCEPTABLE_CONFIGURATION 290 */ 291 {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE, 292 ACPI_RS_OFFSET (Data.StartDpf.CompatibilityPriority), 293 ACPI_ACCEPTABLE_CONFIGURATION}, 294 295 {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE, 296 ACPI_RS_OFFSET (Data.StartDpf.PerformanceRobustness), 297 ACPI_ACCEPTABLE_CONFIGURATION}, 298 299 /* Flag byte is not necessary */ 300 301 {ACPI_RSC_LENGTH, 0, 0, sizeof (AML_RESOURCE_START_DEPENDENT_NOPRIO)} 302 }; 303 304