Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /******************************************************************************* |
| 2 | * |
| 3 | * Module Name: rsmisc - Miscellaneous resource descriptors |
| 4 | * |
| 5 | ******************************************************************************/ |
| 6 | |
| 7 | /* |
| 8 | * Copyright (C) 2000 - 2005, R. Byron Moore |
| 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> |
| 45 | #include <acpi/acresrc.h> |
| 46 | |
| 47 | #define _COMPONENT ACPI_RESOURCES |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 48 | ACPI_MODULE_NAME("rsmisc") |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | |
| 50 | /******************************************************************************* |
| 51 | * |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 52 | * FUNCTION: acpi_rs_get_generic_reg |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | * |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 54 | * PARAMETERS: Aml - Pointer to the AML resource descriptor |
| 55 | * aml_resource_length - Length of the resource from the AML header |
| 56 | * Resource - Where the internal resource is returned |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | * |
| 58 | * RETURN: Status |
| 59 | * |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 60 | * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding |
| 61 | * internal resource descriptor, simplifying bitflags and handling |
| 62 | * alignment and endian issues if necessary. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | * |
| 64 | ******************************************************************************/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | acpi_status |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 66 | acpi_rs_get_generic_reg(union aml_resource *aml, |
| 67 | u16 aml_resource_length, struct acpi_resource *resource) |
Robert Moore | bda663d | 2005-09-16 16:51:15 -0400 | [diff] [blame] | 68 | { |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 69 | ACPI_FUNCTION_TRACE("rs_get_generic_reg"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | |
| 71 | /* |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 72 | * Get the following fields from the AML descriptor: |
| 73 | * Address Space ID |
| 74 | * Register Bit Width |
| 75 | * Register Bit Offset |
| 76 | * Access Size |
| 77 | * Register Address |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | */ |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 79 | resource->data.generic_reg.space_id = aml->generic_reg.address_space_id; |
| 80 | resource->data.generic_reg.bit_width = aml->generic_reg.bit_width; |
| 81 | resource->data.generic_reg.bit_offset = aml->generic_reg.bit_offset; |
| 82 | resource->data.generic_reg.access_size = aml->generic_reg.access_size; |
| 83 | ACPI_MOVE_64_TO_64(&resource->data.generic_reg.address, |
| 84 | &aml->generic_reg.address); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 86 | /* Complete the resource header */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 88 | resource->type = ACPI_RESOURCE_TYPE_GENERIC_REGISTER; |
| 89 | resource->length = |
| 90 | ACPI_SIZEOF_RESOURCE(struct acpi_resource_generic_register); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 91 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 92 | } |
| 93 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | /******************************************************************************* |
| 95 | * |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 96 | * FUNCTION: acpi_rs_set_generic_reg |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | * |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 98 | * PARAMETERS: Resource - Pointer to the resource descriptor |
| 99 | * Aml - Where the AML descriptor is returned |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | * |
| 101 | * RETURN: Status |
| 102 | * |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 103 | * DESCRIPTION: Convert an internal resource descriptor to the corresponding |
| 104 | * external AML resource descriptor. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | * |
| 106 | ******************************************************************************/ |
| 107 | |
| 108 | acpi_status |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 109 | acpi_rs_set_generic_reg(struct acpi_resource *resource, union aml_resource *aml) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | { |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 111 | ACPI_FUNCTION_TRACE("rs_set_generic_reg"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 113 | /* |
| 114 | * Set the following fields in the AML descriptor: |
| 115 | * Address Space ID |
| 116 | * Register Bit Width |
| 117 | * Register Bit Offset |
| 118 | * Access Size |
| 119 | * Register Address |
| 120 | */ |
| 121 | aml->generic_reg.address_space_id = |
| 122 | (u8) resource->data.generic_reg.space_id; |
| 123 | aml->generic_reg.bit_width = (u8) resource->data.generic_reg.bit_width; |
| 124 | aml->generic_reg.bit_offset = |
| 125 | (u8) resource->data.generic_reg.bit_offset; |
| 126 | aml->generic_reg.access_size = |
| 127 | (u8) resource->data.generic_reg.access_size; |
| 128 | ACPI_MOVE_64_TO_64(&aml->generic_reg.address, |
| 129 | &resource->data.generic_reg.address); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 130 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 131 | /* Complete the AML descriptor header */ |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 132 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 133 | acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_GENERIC_REGISTER, |
| 134 | sizeof(struct |
| 135 | aml_resource_generic_register), aml); |
| 136 | return_ACPI_STATUS(AE_OK); |
| 137 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 139 | /******************************************************************************* |
| 140 | * |
| 141 | * FUNCTION: acpi_rs_get_vendor |
| 142 | * |
| 143 | * PARAMETERS: Aml - Pointer to the AML resource descriptor |
| 144 | * aml_resource_length - Length of the resource from the AML header |
| 145 | * Resource - Where the internal resource is returned |
| 146 | * |
| 147 | * RETURN: Status |
| 148 | * |
| 149 | * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding |
| 150 | * internal resource descriptor, simplifying bitflags and handling |
| 151 | * alignment and endian issues if necessary. |
| 152 | * |
| 153 | ******************************************************************************/ |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 154 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 155 | acpi_status |
| 156 | acpi_rs_get_vendor(union aml_resource *aml, |
| 157 | u16 aml_resource_length, struct acpi_resource *resource) |
| 158 | { |
| 159 | u8 *aml_byte_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 160 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 161 | ACPI_FUNCTION_TRACE("rs_get_vendor"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 162 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 163 | /* Determine if this is a large or small vendor specific item */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 164 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 165 | if (aml->large_header.descriptor_type & ACPI_RESOURCE_NAME_LARGE) { |
| 166 | /* Large item, Point to the first vendor byte */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 168 | aml_byte_data = |
| 169 | ((u8 *) aml) + sizeof(struct aml_resource_large_header); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 170 | } else { |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 171 | /* Small item, Point to the first vendor byte */ |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 172 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 173 | aml_byte_data = |
| 174 | ((u8 *) aml) + sizeof(struct aml_resource_small_header); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 175 | } |
| 176 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 177 | /* Copy the vendor-specific bytes */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 178 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 179 | ACPI_MEMCPY(resource->data.vendor.byte_data, |
| 180 | aml_byte_data, aml_resource_length); |
| 181 | resource->data.vendor.byte_length = aml_resource_length; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 182 | |
| 183 | /* |
| 184 | * In order for the struct_size to fall on a 32-bit boundary, |
| 185 | * calculate the length of the vendor string and expand the |
| 186 | * struct_size to the next 32-bit boundary. |
| 187 | */ |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 188 | resource->type = ACPI_RESOURCE_TYPE_VENDOR; |
| 189 | resource->length = ACPI_SIZEOF_RESOURCE(struct acpi_resource_vendor) + |
| 190 | ACPI_ROUND_UP_to_32_bITS(aml_resource_length); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 191 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 192 | } |
| 193 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 194 | /******************************************************************************* |
| 195 | * |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 196 | * FUNCTION: acpi_rs_set_vendor |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 197 | * |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 198 | * PARAMETERS: Resource - Pointer to the resource descriptor |
| 199 | * Aml - Where the AML descriptor is returned |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 200 | * |
| 201 | * RETURN: Status |
| 202 | * |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 203 | * DESCRIPTION: Convert an internal resource descriptor to the corresponding |
| 204 | * external AML resource descriptor. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 205 | * |
| 206 | ******************************************************************************/ |
| 207 | |
| 208 | acpi_status |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 209 | acpi_rs_set_vendor(struct acpi_resource *resource, union aml_resource *aml) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 210 | { |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 211 | u32 resource_length; |
| 212 | u8 *source; |
| 213 | u8 *destination; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 214 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 215 | ACPI_FUNCTION_TRACE("rs_set_vendor"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 216 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 217 | resource_length = resource->data.vendor.byte_length; |
| 218 | source = ACPI_CAST_PTR(u8, resource->data.vendor.byte_data); |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 219 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 220 | /* Length determines if this is a large or small resource */ |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 221 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 222 | if (resource_length > 7) { |
| 223 | /* Large item, get pointer to the data part of the descriptor */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 224 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 225 | destination = |
| 226 | ((u8 *) aml) + sizeof(struct aml_resource_large_header); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 227 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 228 | /* Complete the AML descriptor header */ |
| 229 | |
| 230 | acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_VENDOR_LARGE, |
| 231 | (u32) (resource_length + |
| 232 | sizeof(struct |
| 233 | aml_resource_large_header)), |
| 234 | aml); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 235 | } else { |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 236 | /* Small item, get pointer to the data part of the descriptor */ |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 237 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 238 | destination = |
| 239 | ((u8 *) aml) + sizeof(struct aml_resource_small_header); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 240 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 241 | /* Complete the AML descriptor header */ |
| 242 | |
| 243 | acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_VENDOR_SMALL, |
| 244 | (u32) (resource_length + |
| 245 | sizeof(struct |
| 246 | aml_resource_small_header)), |
| 247 | aml); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 248 | } |
| 249 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 250 | /* Copy the vendor-specific bytes */ |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 251 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 252 | ACPI_MEMCPY(destination, source, resource_length); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 253 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 254 | } |
| 255 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 256 | /******************************************************************************* |
| 257 | * |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 258 | * FUNCTION: acpi_rs_get_start_dpf |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 259 | * |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 260 | * PARAMETERS: Aml - Pointer to the AML resource descriptor |
| 261 | * aml_resource_length - Length of the resource from the AML header |
| 262 | * Resource - Where the internal resource is returned |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 263 | * |
| 264 | * RETURN: Status |
| 265 | * |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 266 | * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding |
| 267 | * internal resource descriptor, simplifying bitflags and handling |
| 268 | * alignment and endian issues if necessary. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 269 | * |
| 270 | ******************************************************************************/ |
| 271 | |
| 272 | acpi_status |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 273 | acpi_rs_get_start_dpf(union aml_resource *aml, |
| 274 | u16 aml_resource_length, struct acpi_resource *resource) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 275 | { |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 276 | ACPI_FUNCTION_TRACE("rs_get_start_dpf"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 277 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 278 | /* Get the flags byte if present */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 279 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 280 | if (aml_resource_length == 1) { |
| 281 | /* Get the Compatibility priority */ |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 282 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 283 | resource->data.start_dpf.compatibility_priority = |
| 284 | (aml->start_dpf.flags & 0x03); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 285 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 286 | if (resource->data.start_dpf.compatibility_priority >= 3) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 287 | return_ACPI_STATUS(AE_AML_BAD_RESOURCE_VALUE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 288 | } |
| 289 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 290 | /* Get the Performance/Robustness preference */ |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 291 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 292 | resource->data.start_dpf.performance_robustness = |
| 293 | ((aml->start_dpf.flags >> 2) & 0x03); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 294 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 295 | if (resource->data.start_dpf.performance_robustness >= 3) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 296 | return_ACPI_STATUS(AE_AML_BAD_RESOURCE_VALUE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 297 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 298 | } else { |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 299 | /* start_dependent_no_pri(), no flags byte, set defaults */ |
| 300 | |
| 301 | resource->data.start_dpf.compatibility_priority = |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 302 | ACPI_ACCEPTABLE_CONFIGURATION; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 303 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 304 | resource->data.start_dpf.performance_robustness = |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 305 | ACPI_ACCEPTABLE_CONFIGURATION; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 306 | } |
| 307 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 308 | /* Complete the resource header */ |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 309 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 310 | resource->type = ACPI_RESOURCE_TYPE_START_DEPENDENT; |
| 311 | resource->length = |
| 312 | ACPI_SIZEOF_RESOURCE(struct acpi_resource_start_dependent); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 313 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 314 | } |
| 315 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 316 | /******************************************************************************* |
| 317 | * |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 318 | * FUNCTION: acpi_rs_set_start_dpf |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 319 | * |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 320 | * PARAMETERS: Resource - Pointer to the resource descriptor |
| 321 | * Aml - Where the AML descriptor is returned |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 322 | * |
| 323 | * RETURN: Status |
| 324 | * |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 325 | * DESCRIPTION: Convert an internal resource descriptor to the corresponding |
| 326 | * external AML resource descriptor. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 327 | * |
| 328 | ******************************************************************************/ |
| 329 | |
| 330 | acpi_status |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 331 | acpi_rs_set_start_dpf(struct acpi_resource *resource, union aml_resource *aml) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 332 | { |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 333 | ACPI_FUNCTION_TRACE("rs_set_start_dpf"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 334 | |
| 335 | /* |
Robert Moore | bda663d | 2005-09-16 16:51:15 -0400 | [diff] [blame] | 336 | * The descriptor type field is set based upon whether a byte is needed |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 337 | * to contain Priority data. |
| 338 | */ |
| 339 | if (ACPI_ACCEPTABLE_CONFIGURATION == |
Robert Moore | bda663d | 2005-09-16 16:51:15 -0400 | [diff] [blame] | 340 | resource->data.start_dpf.compatibility_priority && |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 341 | ACPI_ACCEPTABLE_CONFIGURATION == |
Robert Moore | bda663d | 2005-09-16 16:51:15 -0400 | [diff] [blame] | 342 | resource->data.start_dpf.performance_robustness) { |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 343 | acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_START_DEPENDENT, |
| 344 | sizeof(struct |
| 345 | aml_resource_start_dependent_noprio), |
| 346 | aml); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 347 | } else { |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 348 | acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_START_DEPENDENT, |
| 349 | sizeof(struct |
| 350 | aml_resource_start_dependent), |
| 351 | aml); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 352 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 353 | /* Set the Flags byte */ |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 354 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 355 | aml->start_dpf.flags = (u8) |
| 356 | (((resource->data.start_dpf. |
| 357 | performance_robustness & 0x03) << 2) | (resource->data. |
| 358 | start_dpf. |
| 359 | compatibility_priority |
| 360 | & 0x03)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 361 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 362 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 363 | } |
| 364 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 365 | /******************************************************************************* |
| 366 | * |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 367 | * FUNCTION: acpi_rs_get_end_dpf |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 368 | * |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 369 | * PARAMETERS: Aml - Pointer to the AML resource descriptor |
| 370 | * aml_resource_length - Length of the resource from the AML header |
| 371 | * Resource - Where the internal resource is returned |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 372 | * |
| 373 | * RETURN: Status |
| 374 | * |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 375 | * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding |
| 376 | * internal resource descriptor, simplifying bitflags and handling |
| 377 | * alignment and endian issues if necessary. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 378 | * |
| 379 | ******************************************************************************/ |
| 380 | |
| 381 | acpi_status |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 382 | acpi_rs_get_end_dpf(union aml_resource *aml, |
| 383 | u16 aml_resource_length, struct acpi_resource *resource) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 384 | { |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 385 | ACPI_FUNCTION_TRACE("rs_get_end_dpf"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 386 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 387 | /* Complete the resource header */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 388 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 389 | resource->type = ACPI_RESOURCE_TYPE_END_DEPENDENT; |
| 390 | resource->length = (u32) ACPI_RESOURCE_LENGTH; |
| 391 | return_ACPI_STATUS(AE_OK); |
| 392 | } |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 393 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 394 | /******************************************************************************* |
| 395 | * |
| 396 | * FUNCTION: acpi_rs_set_end_dpf |
| 397 | * |
| 398 | * PARAMETERS: Resource - Pointer to the resource descriptor |
| 399 | * Aml - Where the AML descriptor is returned |
| 400 | * |
| 401 | * RETURN: Status |
| 402 | * |
| 403 | * DESCRIPTION: Convert an internal resource descriptor to the corresponding |
| 404 | * external AML resource descriptor. |
| 405 | * |
| 406 | ******************************************************************************/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 407 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 408 | acpi_status |
| 409 | acpi_rs_set_end_dpf(struct acpi_resource *resource, union aml_resource *aml) |
| 410 | { |
| 411 | ACPI_FUNCTION_TRACE("rs_set_end_dpf"); |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 412 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 413 | /* Complete the AML descriptor header */ |
| 414 | |
| 415 | acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_END_DEPENDENT, |
| 416 | sizeof(struct aml_resource_end_dependent), |
| 417 | aml); |
| 418 | return_ACPI_STATUS(AE_OK); |
| 419 | } |
| 420 | |
| 421 | /******************************************************************************* |
| 422 | * |
| 423 | * FUNCTION: acpi_rs_get_end_tag |
| 424 | * |
| 425 | * PARAMETERS: Aml - Pointer to the AML resource descriptor |
| 426 | * aml_resource_length - Length of the resource from the AML header |
| 427 | * Resource - Where the internal resource is returned |
| 428 | * |
| 429 | * RETURN: Status |
| 430 | * |
| 431 | * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding |
| 432 | * internal resource descriptor, simplifying bitflags and handling |
| 433 | * alignment and endian issues if necessary. |
| 434 | * |
| 435 | ******************************************************************************/ |
| 436 | |
| 437 | acpi_status |
| 438 | acpi_rs_get_end_tag(union aml_resource *aml, |
| 439 | u16 aml_resource_length, struct acpi_resource *resource) |
| 440 | { |
| 441 | ACPI_FUNCTION_TRACE("rs_get_end_tag"); |
| 442 | |
| 443 | /* Complete the resource header */ |
| 444 | |
| 445 | resource->type = ACPI_RESOURCE_TYPE_END_TAG; |
| 446 | resource->length = ACPI_RESOURCE_LENGTH; |
| 447 | return_ACPI_STATUS(AE_OK); |
| 448 | } |
| 449 | |
| 450 | /******************************************************************************* |
| 451 | * |
| 452 | * FUNCTION: acpi_rs_set_end_tag |
| 453 | * |
| 454 | * PARAMETERS: Resource - Pointer to the resource descriptor |
| 455 | * Aml - Where the AML descriptor is returned |
| 456 | * |
| 457 | * RETURN: Status |
| 458 | * |
| 459 | * DESCRIPTION: Convert an internal resource descriptor to the corresponding |
| 460 | * external AML resource descriptor. |
| 461 | * |
| 462 | ******************************************************************************/ |
| 463 | |
| 464 | acpi_status |
| 465 | acpi_rs_set_end_tag(struct acpi_resource *resource, union aml_resource *aml) |
| 466 | { |
| 467 | ACPI_FUNCTION_TRACE("rs_set_end_tag"); |
| 468 | |
| 469 | /* |
| 470 | * Set the Checksum - zero means that the resource data is treated as if |
| 471 | * the checksum operation succeeded (ACPI Spec 1.0b Section 6.4.2.8) |
| 472 | */ |
| 473 | aml->end_tag.checksum = 0; |
| 474 | |
| 475 | /* Complete the AML descriptor header */ |
| 476 | |
| 477 | acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_END_TAG, |
| 478 | sizeof(struct aml_resource_end_tag), aml); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 479 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 480 | } |