Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /******************************************************************************* |
| 2 | * |
| 3 | * Module Name: rsmem24 - Memory 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("rsmemory") |
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_memory24 |
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_memory24(union aml_resource * aml, |
| 67 | u16 aml_resource_length, struct acpi_resource * resource) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | { |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 69 | ACPI_FUNCTION_TRACE("rs_get_memory24"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 71 | /* Get the Read/Write bit */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 73 | resource->data.memory24.read_write_attribute = |
| 74 | (aml->memory24.information & 0x01); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | |
| 76 | /* |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 77 | * Get the following contiguous fields from the AML descriptor: |
| 78 | * Minimum Base Address |
| 79 | * Maximum Base Address |
| 80 | * Address Base Alignment |
| 81 | * Range Length |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | */ |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 83 | acpi_rs_move_data(&resource->data.memory24.minimum, |
| 84 | &aml->memory24.minimum, 4, ACPI_MOVE_TYPE_16_TO_32); |
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 */ |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 87 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 88 | resource->type = ACPI_RESOURCE_TYPE_MEMORY24; |
| 89 | resource->length = ACPI_SIZEOF_RESOURCE(struct acpi_resource_memory24); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 90 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | } |
| 92 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | /******************************************************************************* |
| 94 | * |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 95 | * FUNCTION: acpi_rs_set_memory24 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | * |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 97 | * PARAMETERS: Resource - Pointer to the resource descriptor |
| 98 | * Aml - Where the AML descriptor is returned |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | * |
| 100 | * RETURN: Status |
| 101 | * |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 102 | * DESCRIPTION: Convert an internal resource descriptor to the corresponding |
| 103 | * external AML resource descriptor. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | * |
| 105 | ******************************************************************************/ |
| 106 | |
| 107 | acpi_status |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 108 | acpi_rs_set_memory24(struct acpi_resource *resource, union aml_resource *aml) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | { |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 110 | ACPI_FUNCTION_TRACE("rs_set_memory24"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 111 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 112 | /* Set the Information Byte */ |
| 113 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 114 | aml->memory24.information = (u8) |
| 115 | (resource->data.memory24.read_write_attribute & 0x01); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 117 | /* |
| 118 | * Set the following contiguous fields in the AML descriptor: |
| 119 | * Minimum Base Address |
| 120 | * Maximum Base Address |
| 121 | * Address Base Alignment |
| 122 | * Range Length |
| 123 | */ |
| 124 | acpi_rs_move_data(&aml->memory24.minimum, |
| 125 | &resource->data.memory24.minimum, 4, |
| 126 | ACPI_MOVE_TYPE_32_TO_16); |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 127 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 128 | /* Complete the AML descriptor header */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 129 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 130 | acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_MEMORY24, |
| 131 | sizeof(struct aml_resource_memory24), aml); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 132 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 133 | } |
| 134 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | /******************************************************************************* |
| 136 | * |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 137 | * FUNCTION: acpi_rs_get_memory32 |
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 | * PARAMETERS: Aml - Pointer to the AML resource descriptor |
| 140 | * aml_resource_length - Length of the resource from the AML header |
| 141 | * Resource - Where the internal resource is returned |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 142 | * |
| 143 | * RETURN: Status |
| 144 | * |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 145 | * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding |
| 146 | * internal resource descriptor, simplifying bitflags and handling |
| 147 | * alignment and endian issues if necessary. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | * |
| 149 | ******************************************************************************/ |
| 150 | |
| 151 | acpi_status |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 152 | acpi_rs_get_memory32(union aml_resource *aml, |
| 153 | u16 aml_resource_length, struct acpi_resource *resource) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | { |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 155 | ACPI_FUNCTION_TRACE("rs_get_memory32"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 156 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 157 | /* Get the Read/Write bit */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 159 | resource->data.memory32.read_write_attribute = |
| 160 | (aml->memory32.information & 0x01); |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 161 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 162 | /* |
| 163 | * Get the following contiguous fields from the AML descriptor: |
| 164 | * Minimum Base Address |
| 165 | * Maximum Base Address |
| 166 | * Address Base Alignment |
| 167 | * Range Length |
| 168 | */ |
| 169 | acpi_rs_move_data(&resource->data.memory32.minimum, |
| 170 | &aml->memory32.minimum, 4, ACPI_MOVE_TYPE_32_TO_32); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 171 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 172 | /* Complete the resource header */ |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 173 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 174 | resource->type = ACPI_RESOURCE_TYPE_MEMORY32; |
| 175 | resource->length = ACPI_SIZEOF_RESOURCE(struct acpi_resource_memory32); |
| 176 | return_ACPI_STATUS(AE_OK); |
| 177 | } |
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 | /******************************************************************************* |
| 180 | * |
| 181 | * FUNCTION: acpi_rs_set_memory32 |
| 182 | * |
| 183 | * PARAMETERS: Resource - Pointer to the resource descriptor |
| 184 | * Aml - Where the AML descriptor is returned |
| 185 | * |
| 186 | * RETURN: Status |
| 187 | * |
| 188 | * DESCRIPTION: Convert an internal resource descriptor to the corresponding |
| 189 | * external AML resource descriptor. |
| 190 | * |
| 191 | ******************************************************************************/ |
| 192 | |
| 193 | acpi_status |
| 194 | acpi_rs_set_memory32(struct acpi_resource *resource, union aml_resource *aml) |
| 195 | { |
| 196 | ACPI_FUNCTION_TRACE("rs_set_memory32"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 197 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 198 | /* Set the Information Byte */ |
| 199 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 200 | aml->memory32.information = (u8) |
| 201 | (resource->data.memory32.read_write_attribute & 0x01); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 202 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 203 | /* |
| 204 | * Set the following contiguous fields in the AML descriptor: |
| 205 | * Minimum Base Address |
| 206 | * Maximum Base Address |
| 207 | * Address Base Alignment |
| 208 | * Range Length |
| 209 | */ |
| 210 | acpi_rs_move_data(&aml->memory32.minimum, |
| 211 | &resource->data.memory32.minimum, 4, |
| 212 | ACPI_MOVE_TYPE_32_TO_32); |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 213 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 214 | /* Complete the AML descriptor header */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 215 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 216 | acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_MEMORY32, |
| 217 | sizeof(struct aml_resource_memory32), aml); |
| 218 | return_ACPI_STATUS(AE_OK); |
| 219 | } |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 220 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 221 | /******************************************************************************* |
| 222 | * |
| 223 | * FUNCTION: acpi_rs_get_fixed_memory32 |
| 224 | * |
| 225 | * PARAMETERS: Aml - Pointer to the AML resource descriptor |
| 226 | * aml_resource_length - Length of the resource from the AML header |
| 227 | * Resource - Where the internal resource is returned |
| 228 | * |
| 229 | * RETURN: Status |
| 230 | * |
| 231 | * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding |
| 232 | * internal resource descriptor, simplifying bitflags and handling |
| 233 | * alignment and endian issues if necessary. |
| 234 | * |
| 235 | ******************************************************************************/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 236 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 237 | acpi_status |
| 238 | acpi_rs_get_fixed_memory32(union aml_resource *aml, |
| 239 | u16 aml_resource_length, |
| 240 | struct acpi_resource *resource) |
| 241 | { |
| 242 | ACPI_FUNCTION_TRACE("rs_get_fixed_memory32"); |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 243 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame^] | 244 | /* Get the Read/Write bit */ |
| 245 | |
| 246 | resource->data.fixed_memory32.read_write_attribute = |
| 247 | (aml->fixed_memory32.information & 0x01); |
| 248 | |
| 249 | /* |
| 250 | * Get the following contiguous fields from the AML descriptor: |
| 251 | * Base Address |
| 252 | * Range Length |
| 253 | */ |
| 254 | ACPI_MOVE_32_TO_32(&resource->data.fixed_memory32.address, |
| 255 | &aml->fixed_memory32.address); |
| 256 | ACPI_MOVE_32_TO_32(&resource->data.fixed_memory32.address_length, |
| 257 | &aml->fixed_memory32.address_length); |
| 258 | |
| 259 | /* Complete the resource header */ |
| 260 | |
| 261 | resource->type = ACPI_RESOURCE_TYPE_FIXED_MEMORY32; |
| 262 | resource->length = |
| 263 | ACPI_SIZEOF_RESOURCE(struct acpi_resource_fixed_memory32); |
| 264 | return_ACPI_STATUS(AE_OK); |
| 265 | } |
| 266 | |
| 267 | /******************************************************************************* |
| 268 | * |
| 269 | * FUNCTION: acpi_rs_set_fixed_memory32 |
| 270 | * |
| 271 | * PARAMETERS: Resource - Pointer to the resource descriptor |
| 272 | * Aml - Where the AML descriptor is returned |
| 273 | * |
| 274 | * RETURN: Status |
| 275 | * |
| 276 | * DESCRIPTION: Convert an internal resource descriptor to the corresponding |
| 277 | * external AML resource descriptor. |
| 278 | * |
| 279 | ******************************************************************************/ |
| 280 | |
| 281 | acpi_status |
| 282 | acpi_rs_set_fixed_memory32(struct acpi_resource *resource, |
| 283 | union aml_resource *aml) |
| 284 | { |
| 285 | ACPI_FUNCTION_TRACE("rs_set_fixed_memory32"); |
| 286 | |
| 287 | /* Set the Information Byte */ |
| 288 | |
| 289 | aml->fixed_memory32.information = (u8) |
| 290 | (resource->data.fixed_memory32.read_write_attribute & 0x01); |
| 291 | |
| 292 | /* |
| 293 | * Set the following contiguous fields in the AML descriptor: |
| 294 | * Base Address |
| 295 | * Range Length |
| 296 | */ |
| 297 | ACPI_MOVE_32_TO_32(&aml->fixed_memory32.address, |
| 298 | &resource->data.fixed_memory32.address); |
| 299 | ACPI_MOVE_32_TO_32(&aml->fixed_memory32.address_length, |
| 300 | &resource->data.fixed_memory32.address_length); |
| 301 | |
| 302 | /* Complete the AML descriptor header */ |
| 303 | |
| 304 | acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_FIXED_MEMORY32, |
| 305 | sizeof(struct aml_resource_fixed_memory32), |
| 306 | aml); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 307 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 308 | } |