diff options
| author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
| commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
| tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /drivers/acpi/resources/rsxface.c | |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'drivers/acpi/resources/rsxface.c')
| -rw-r--r-- | drivers/acpi/resources/rsxface.c | 437 |
1 files changed, 437 insertions, 0 deletions
diff --git a/drivers/acpi/resources/rsxface.c b/drivers/acpi/resources/rsxface.c new file mode 100644 index 000000000000..a9cdcbeb3432 --- /dev/null +++ b/drivers/acpi/resources/rsxface.c | |||
| @@ -0,0 +1,437 @@ | |||
| 1 | /******************************************************************************* | ||
| 2 | * | ||
| 3 | * Module Name: rsxface - Public interfaces to the resource manager | ||
| 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 | |||
| 44 | #include <linux/module.h> | ||
| 45 | |||
| 46 | #include <acpi/acpi.h> | ||
| 47 | #include <acpi/acresrc.h> | ||
| 48 | |||
| 49 | #define _COMPONENT ACPI_RESOURCES | ||
| 50 | ACPI_MODULE_NAME ("rsxface") | ||
| 51 | |||
| 52 | |||
| 53 | /******************************************************************************* | ||
| 54 | * | ||
| 55 | * FUNCTION: acpi_get_irq_routing_table | ||
| 56 | * | ||
| 57 | * PARAMETERS: device_handle - a handle to the Bus device we are querying | ||
| 58 | * ret_buffer - a pointer to a buffer to receive the | ||
| 59 | * current resources for the device | ||
| 60 | * | ||
| 61 | * RETURN: Status | ||
| 62 | * | ||
| 63 | * DESCRIPTION: This function is called to get the IRQ routing table for a | ||
| 64 | * specific bus. The caller must first acquire a handle for the | ||
| 65 | * desired bus. The routine table is placed in the buffer pointed | ||
| 66 | * to by the ret_buffer variable parameter. | ||
| 67 | * | ||
| 68 | * If the function fails an appropriate status will be returned | ||
| 69 | * and the value of ret_buffer is undefined. | ||
| 70 | * | ||
| 71 | * This function attempts to execute the _PRT method contained in | ||
| 72 | * the object indicated by the passed device_handle. | ||
| 73 | * | ||
| 74 | ******************************************************************************/ | ||
| 75 | |||
| 76 | acpi_status | ||
| 77 | acpi_get_irq_routing_table ( | ||
| 78 | acpi_handle device_handle, | ||
| 79 | struct acpi_buffer *ret_buffer) | ||
| 80 | { | ||
| 81 | acpi_status status; | ||
| 82 | |||
| 83 | |||
| 84 | ACPI_FUNCTION_TRACE ("acpi_get_irq_routing_table "); | ||
| 85 | |||
| 86 | |||
| 87 | /* | ||
| 88 | * Must have a valid handle and buffer, So we have to have a handle | ||
| 89 | * and a return buffer structure, and if there is a non-zero buffer length | ||
| 90 | * we also need a valid pointer in the buffer. If it's a zero buffer length, | ||
| 91 | * we'll be returning the needed buffer size, so keep going. | ||
| 92 | */ | ||
| 93 | if (!device_handle) { | ||
| 94 | return_ACPI_STATUS (AE_BAD_PARAMETER); | ||
| 95 | } | ||
| 96 | |||
| 97 | status = acpi_ut_validate_buffer (ret_buffer); | ||
| 98 | if (ACPI_FAILURE (status)) { | ||
| 99 | return_ACPI_STATUS (status); | ||
| 100 | } | ||
| 101 | |||
| 102 | status = acpi_rs_get_prt_method_data (device_handle, ret_buffer); | ||
| 103 | return_ACPI_STATUS (status); | ||
| 104 | } | ||
| 105 | |||
| 106 | |||
| 107 | /******************************************************************************* | ||
| 108 | * | ||
| 109 | * FUNCTION: acpi_get_current_resources | ||
| 110 | * | ||
| 111 | * PARAMETERS: device_handle - a handle to the device object for the | ||
| 112 | * device we are querying | ||
| 113 | * ret_buffer - a pointer to a buffer to receive the | ||
| 114 | * current resources for the device | ||
| 115 | * | ||
| 116 | * RETURN: Status | ||
| 117 | * | ||
| 118 | * DESCRIPTION: This function is called to get the current resources for a | ||
| 119 | * specific device. The caller must first acquire a handle for | ||
| 120 | * the desired device. The resource data is placed in the buffer | ||
| 121 | * pointed to by the ret_buffer variable parameter. | ||
| 122 | * | ||
| 123 | * If the function fails an appropriate status will be returned | ||
| 124 | * and the value of ret_buffer is undefined. | ||
| 125 | * | ||
| 126 | * This function attempts to execute the _CRS method contained in | ||
| 127 | * the object indicated by the passed device_handle. | ||
| 128 | * | ||
| 129 | ******************************************************************************/ | ||
| 130 | |||
| 131 | acpi_status | ||
| 132 | acpi_get_current_resources ( | ||
| 133 | acpi_handle device_handle, | ||
| 134 | struct acpi_buffer *ret_buffer) | ||
| 135 | { | ||
| 136 | acpi_status status; | ||
| 137 | |||
| 138 | |||
| 139 | ACPI_FUNCTION_TRACE ("acpi_get_current_resources"); | ||
| 140 | |||
| 141 | |||
| 142 | /* | ||
| 143 | * Must have a valid handle and buffer, So we have to have a handle | ||
| 144 | * and a return buffer structure, and if there is a non-zero buffer length | ||
| 145 | * we also need a valid pointer in the buffer. If it's a zero buffer length, | ||
| 146 | * we'll be returning the needed buffer size, so keep going. | ||
| 147 | */ | ||
| 148 | if (!device_handle) { | ||
| 149 | return_ACPI_STATUS (AE_BAD_PARAMETER); | ||
| 150 | } | ||
| 151 | |||
| 152 | status = acpi_ut_validate_buffer (ret_buffer); | ||
| 153 | if (ACPI_FAILURE (status)) { | ||
| 154 | return_ACPI_STATUS (status); | ||
| 155 | } | ||
| 156 | |||
| 157 | status = acpi_rs_get_crs_method_data (device_handle, ret_buffer); | ||
| 158 | return_ACPI_STATUS (status); | ||
| 159 | } | ||
| 160 | EXPORT_SYMBOL(acpi_get_current_resources); | ||
| 161 | |||
| 162 | |||
| 163 | /******************************************************************************* | ||
| 164 | * | ||
| 165 | * FUNCTION: acpi_get_possible_resources | ||
| 166 | * | ||
| 167 | * PARAMETERS: device_handle - a handle to the device object for the | ||
| 168 | * device we are querying | ||
| 169 | * ret_buffer - a pointer to a buffer to receive the | ||
| 170 | * resources for the device | ||
| 171 | * | ||
| 172 | * RETURN: Status | ||
| 173 | * | ||
| 174 | * DESCRIPTION: This function is called to get a list of the possible resources | ||
| 175 | * for a specific device. The caller must first acquire a handle | ||
| 176 | * for the desired device. The resource data is placed in the | ||
| 177 | * buffer pointed to by the ret_buffer variable. | ||
| 178 | * | ||
| 179 | * If the function fails an appropriate status will be returned | ||
| 180 | * and the value of ret_buffer is undefined. | ||
| 181 | * | ||
| 182 | ******************************************************************************/ | ||
| 183 | #ifdef ACPI_FUTURE_USAGE | ||
| 184 | acpi_status | ||
| 185 | acpi_get_possible_resources ( | ||
| 186 | acpi_handle device_handle, | ||
| 187 | struct acpi_buffer *ret_buffer) | ||
| 188 | { | ||
| 189 | acpi_status status; | ||
| 190 | |||
| 191 | |||
| 192 | ACPI_FUNCTION_TRACE ("acpi_get_possible_resources"); | ||
| 193 | |||
| 194 | |||
| 195 | /* | ||
| 196 | * Must have a valid handle and buffer, So we have to have a handle | ||
| 197 | * and a return buffer structure, and if there is a non-zero buffer length | ||
| 198 | * we also need a valid pointer in the buffer. If it's a zero buffer length, | ||
| 199 | * we'll be returning the needed buffer size, so keep going. | ||
| 200 | */ | ||
| 201 | if (!device_handle) { | ||
| 202 | return_ACPI_STATUS (AE_BAD_PARAMETER); | ||
| 203 | } | ||
| 204 | |||
| 205 | status = acpi_ut_validate_buffer (ret_buffer); | ||
| 206 | if (ACPI_FAILURE (status)) { | ||
| 207 | return_ACPI_STATUS (status); | ||
| 208 | } | ||
| 209 | |||
| 210 | status = acpi_rs_get_prs_method_data (device_handle, ret_buffer); | ||
| 211 | return_ACPI_STATUS (status); | ||
| 212 | } | ||
| 213 | EXPORT_SYMBOL(acpi_get_possible_resources); | ||
| 214 | #endif /* ACPI_FUTURE_USAGE */ | ||
| 215 | |||
| 216 | |||
| 217 | /******************************************************************************* | ||
| 218 | * | ||
| 219 | * FUNCTION: acpi_walk_resources | ||
| 220 | * | ||
| 221 | * PARAMETERS: device_handle - a handle to the device object for the | ||
| 222 | * device we are querying | ||
| 223 | * Path - method name of the resources we want | ||
| 224 | * (METHOD_NAME__CRS or METHOD_NAME__PRS) | ||
| 225 | * user_function - called for each resource | ||
| 226 | * Context - passed to user_function | ||
| 227 | * | ||
| 228 | * RETURN: Status | ||
| 229 | * | ||
| 230 | * DESCRIPTION: Retrieves the current or possible resource list for the | ||
| 231 | * specified device. The user_function is called once for | ||
| 232 | * each resource in the list. | ||
| 233 | * | ||
| 234 | ******************************************************************************/ | ||
| 235 | |||
| 236 | acpi_status | ||
| 237 | acpi_walk_resources ( | ||
| 238 | acpi_handle device_handle, | ||
| 239 | char *path, | ||
| 240 | ACPI_WALK_RESOURCE_CALLBACK user_function, | ||
| 241 | void *context) | ||
| 242 | { | ||
| 243 | acpi_status status; | ||
| 244 | struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; | ||
| 245 | struct acpi_resource *resource; | ||
| 246 | struct acpi_resource *buffer_end; | ||
| 247 | |||
| 248 | |||
| 249 | ACPI_FUNCTION_TRACE ("acpi_walk_resources"); | ||
| 250 | |||
| 251 | |||
| 252 | if (!device_handle || | ||
| 253 | (ACPI_STRNCMP (path, METHOD_NAME__CRS, sizeof (METHOD_NAME__CRS)) && | ||
| 254 | ACPI_STRNCMP (path, METHOD_NAME__PRS, sizeof (METHOD_NAME__PRS)))) { | ||
| 255 | return_ACPI_STATUS (AE_BAD_PARAMETER); | ||
| 256 | } | ||
| 257 | |||
| 258 | status = acpi_rs_get_method_data (device_handle, path, &buffer); | ||
| 259 | if (ACPI_FAILURE (status)) { | ||
| 260 | return_ACPI_STATUS (status); | ||
| 261 | } | ||
| 262 | |||
| 263 | /* Setup pointers */ | ||
| 264 | |||
| 265 | resource = (struct acpi_resource *) buffer.pointer; | ||
| 266 | buffer_end = ACPI_CAST_PTR (struct acpi_resource, | ||
| 267 | ((u8 *) buffer.pointer + buffer.length)); | ||
| 268 | |||
| 269 | /* Walk the resource list */ | ||
| 270 | |||
| 271 | for (;;) { | ||
| 272 | if (!resource || resource->id == ACPI_RSTYPE_END_TAG) { | ||
| 273 | break; | ||
| 274 | } | ||
| 275 | |||
| 276 | status = user_function (resource, context); | ||
| 277 | |||
| 278 | switch (status) { | ||
| 279 | case AE_OK: | ||
| 280 | case AE_CTRL_DEPTH: | ||
| 281 | |||
| 282 | /* Just keep going */ | ||
| 283 | |||
| 284 | status = AE_OK; | ||
| 285 | break; | ||
| 286 | |||
| 287 | case AE_CTRL_TERMINATE: | ||
| 288 | |||
| 289 | /* Exit now, with OK stats */ | ||
| 290 | |||
| 291 | status = AE_OK; | ||
| 292 | goto cleanup; | ||
| 293 | |||
| 294 | default: | ||
| 295 | |||
| 296 | /* All others are valid exceptions */ | ||
| 297 | |||
| 298 | goto cleanup; | ||
| 299 | } | ||
| 300 | |||
| 301 | /* Get the next resource descriptor */ | ||
| 302 | |||
| 303 | resource = ACPI_NEXT_RESOURCE (resource); | ||
| 304 | |||
| 305 | /* Check for end-of-buffer */ | ||
| 306 | |||
| 307 | if (resource >= buffer_end) { | ||
| 308 | goto cleanup; | ||
| 309 | } | ||
| 310 | } | ||
| 311 | |||
| 312 | cleanup: | ||
| 313 | |||
| 314 | acpi_os_free (buffer.pointer); | ||
| 315 | return_ACPI_STATUS (status); | ||
| 316 | } | ||
| 317 | EXPORT_SYMBOL(acpi_walk_resources); | ||
| 318 | |||
| 319 | |||
| 320 | /******************************************************************************* | ||
| 321 | * | ||
| 322 | * FUNCTION: acpi_set_current_resources | ||
| 323 | * | ||
| 324 | * PARAMETERS: device_handle - a handle to the device object for the | ||
| 325 | * device we are changing the resources of | ||
| 326 | * in_buffer - a pointer to a buffer containing the | ||
| 327 | * resources to be set for the device | ||
| 328 | * | ||
| 329 | * RETURN: Status | ||
| 330 | * | ||
| 331 | * DESCRIPTION: This function is called to set the current resources for a | ||
| 332 | * specific device. The caller must first acquire a handle for | ||
| 333 | * the desired device. The resource data is passed to the routine | ||
| 334 | * the buffer pointed to by the in_buffer variable. | ||
| 335 | * | ||
| 336 | ******************************************************************************/ | ||
| 337 | |||
| 338 | acpi_status | ||
| 339 | acpi_set_current_resources ( | ||
| 340 | acpi_handle device_handle, | ||
| 341 | struct acpi_buffer *in_buffer) | ||
| 342 | { | ||
| 343 | acpi_status status; | ||
| 344 | |||
| 345 | |||
| 346 | ACPI_FUNCTION_TRACE ("acpi_set_current_resources"); | ||
| 347 | |||
| 348 | |||
| 349 | /* | ||
| 350 | * Must have a valid handle and buffer | ||
| 351 | */ | ||
| 352 | if ((!device_handle) || | ||
| 353 | (!in_buffer) || | ||
| 354 | (!in_buffer->pointer) || | ||
| 355 | (!in_buffer->length)) { | ||
| 356 | return_ACPI_STATUS (AE_BAD_PARAMETER); | ||
| 357 | } | ||
| 358 | |||
| 359 | status = acpi_rs_set_srs_method_data (device_handle, in_buffer); | ||
| 360 | return_ACPI_STATUS (status); | ||
| 361 | } | ||
| 362 | EXPORT_SYMBOL(acpi_set_current_resources); | ||
| 363 | |||
| 364 | |||
| 365 | #define ACPI_COPY_FIELD(out, in, field) ((out)->field = (in)->field) | ||
| 366 | #define ACPI_COPY_ADDRESS(out, in) \ | ||
| 367 | ACPI_COPY_FIELD(out, in, resource_type); \ | ||
| 368 | ACPI_COPY_FIELD(out, in, producer_consumer); \ | ||
| 369 | ACPI_COPY_FIELD(out, in, decode); \ | ||
| 370 | ACPI_COPY_FIELD(out, in, min_address_fixed); \ | ||
| 371 | ACPI_COPY_FIELD(out, in, max_address_fixed); \ | ||
| 372 | ACPI_COPY_FIELD(out, in, attribute); \ | ||
| 373 | ACPI_COPY_FIELD(out, in, granularity); \ | ||
| 374 | ACPI_COPY_FIELD(out, in, min_address_range); \ | ||
| 375 | ACPI_COPY_FIELD(out, in, max_address_range); \ | ||
| 376 | ACPI_COPY_FIELD(out, in, address_translation_offset); \ | ||
| 377 | ACPI_COPY_FIELD(out, in, address_length); \ | ||
| 378 | ACPI_COPY_FIELD(out, in, resource_source); | ||
| 379 | |||
| 380 | /****************************************************************************** | ||
| 381 | * | ||
| 382 | * FUNCTION: acpi_resource_to_address64 | ||
| 383 | * | ||
| 384 | * PARAMETERS: resource - Pointer to a resource | ||
| 385 | * out - Pointer to the users's return | ||
| 386 | * buffer (a struct | ||
| 387 | * struct acpi_resource_address64) | ||
| 388 | * | ||
| 389 | * RETURN: Status | ||
| 390 | * | ||
| 391 | * DESCRIPTION: If the resource is an address16, address32, or address64, | ||
| 392 | * copy it to the address64 return buffer. This saves the | ||
| 393 | * caller from having to duplicate code for different-sized | ||
| 394 | * addresses. | ||
| 395 | * | ||
| 396 | ******************************************************************************/ | ||
| 397 | |||
| 398 | acpi_status | ||
| 399 | acpi_resource_to_address64 ( | ||
| 400 | struct acpi_resource *resource, | ||
| 401 | struct acpi_resource_address64 *out) | ||
| 402 | { | ||
| 403 | struct acpi_resource_address16 *address16; | ||
| 404 | struct acpi_resource_address32 *address32; | ||
| 405 | |||
| 406 | |||
| 407 | switch (resource->id) { | ||
| 408 | case ACPI_RSTYPE_ADDRESS16: | ||
| 409 | |||
| 410 | address16 = (struct acpi_resource_address16 *) &resource->data; | ||
| 411 | ACPI_COPY_ADDRESS(out, address16); | ||
| 412 | break; | ||
| 413 | |||
| 414 | |||
| 415 | case ACPI_RSTYPE_ADDRESS32: | ||
| 416 | |||
| 417 | address32 = (struct acpi_resource_address32 *) &resource->data; | ||
| 418 | ACPI_COPY_ADDRESS(out, address32); | ||
| 419 | break; | ||
| 420 | |||
| 421 | |||
| 422 | case ACPI_RSTYPE_ADDRESS64: | ||
| 423 | |||
| 424 | /* Simple copy for 64 bit source */ | ||
| 425 | |||
| 426 | ACPI_MEMCPY (out, &resource->data, sizeof (struct acpi_resource_address64)); | ||
| 427 | break; | ||
| 428 | |||
| 429 | |||
| 430 | default: | ||
| 431 | return (AE_BAD_PARAMETER); | ||
| 432 | } | ||
| 433 | |||
| 434 | return (AE_OK); | ||
| 435 | } | ||
| 436 | EXPORT_SYMBOL(acpi_resource_to_address64); | ||
| 437 | |||
