Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | |
| 2 | /****************************************************************************** |
| 3 | * |
| 4 | * Module Name: exregion - ACPI default op_region (address space) handlers |
| 5 | * |
| 6 | *****************************************************************************/ |
| 7 | |
| 8 | /* |
Bob Moore | 4a90c7e | 2006-01-13 16:22:00 -0500 | [diff] [blame] | 9 | * Copyright (C) 2000 - 2006, R. Byron Moore |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | * All rights reserved. |
| 11 | * |
| 12 | * Redistribution and use in source and binary forms, with or without |
| 13 | * modification, are permitted provided that the following conditions |
| 14 | * are met: |
| 15 | * 1. Redistributions of source code must retain the above copyright |
| 16 | * notice, this list of conditions, and the following disclaimer, |
| 17 | * without modification. |
| 18 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer |
| 19 | * substantially similar to the "NO WARRANTY" disclaimer below |
| 20 | * ("Disclaimer") and any redistribution must be conditioned upon |
| 21 | * including a substantially similar Disclaimer requirement for further |
| 22 | * binary redistribution. |
| 23 | * 3. Neither the names of the above-listed copyright holders nor the names |
| 24 | * of any contributors may be used to endorse or promote products derived |
| 25 | * from this software without specific prior written permission. |
| 26 | * |
| 27 | * Alternatively, this software may be distributed under the terms of the |
| 28 | * GNU General Public License ("GPL") version 2 as published by the Free |
| 29 | * Software Foundation. |
| 30 | * |
| 31 | * NO WARRANTY |
| 32 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 33 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 34 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR |
| 35 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 36 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 37 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 38 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 39 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| 40 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
| 41 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 42 | * POSSIBILITY OF SUCH DAMAGES. |
| 43 | */ |
| 44 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | #include <acpi/acpi.h> |
| 46 | #include <acpi/acinterp.h> |
| 47 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | #define _COMPONENT ACPI_EXECUTER |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 49 | ACPI_MODULE_NAME("exregion") |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | |
| 51 | /******************************************************************************* |
| 52 | * |
| 53 | * FUNCTION: acpi_ex_system_memory_space_handler |
| 54 | * |
| 55 | * PARAMETERS: Function - Read or Write operation |
| 56 | * Address - Where in the space to read or write |
| 57 | * bit_width - Field width in bits (8, 16, or 32) |
| 58 | * Value - Pointer to in or out value |
| 59 | * handler_context - Pointer to Handler's context |
| 60 | * region_context - Pointer to context specific to the |
| 61 | * accessed region |
| 62 | * |
| 63 | * RETURN: Status |
| 64 | * |
| 65 | * DESCRIPTION: Handler for the System Memory address space (Op Region) |
| 66 | * |
| 67 | ******************************************************************************/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 69 | acpi_ex_system_memory_space_handler(u32 function, |
| 70 | acpi_physical_address address, |
| 71 | u32 bit_width, |
| 72 | acpi_integer * value, |
| 73 | void *handler_context, void *region_context) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 75 | acpi_status status = AE_OK; |
| 76 | void *logical_addr_ptr = NULL; |
| 77 | struct acpi_mem_space_context *mem_info = region_context; |
| 78 | u32 length; |
| 79 | acpi_size window_size; |
Bob Moore | 0897831 | 2005-10-21 00:00:00 -0400 | [diff] [blame] | 80 | #ifdef ACPI_MISALIGNMENT_NOT_SUPPORTED |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 81 | u32 remainder; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | #endif |
| 83 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 84 | ACPI_FUNCTION_TRACE("ex_system_memory_space_handler"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | |
| 86 | /* Validate and translate the bit width */ |
| 87 | |
| 88 | switch (bit_width) { |
| 89 | case 8: |
| 90 | length = 1; |
| 91 | break; |
| 92 | |
| 93 | case 16: |
| 94 | length = 2; |
| 95 | break; |
| 96 | |
| 97 | case 32: |
| 98 | length = 4; |
| 99 | break; |
| 100 | |
| 101 | case 64: |
| 102 | length = 8; |
| 103 | break; |
| 104 | |
| 105 | default: |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 106 | ACPI_ERROR((AE_INFO, "Invalid system_memory width %d", |
| 107 | bit_width)); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 108 | return_ACPI_STATUS(AE_AML_OPERAND_VALUE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | } |
| 110 | |
Bob Moore | 0897831 | 2005-10-21 00:00:00 -0400 | [diff] [blame] | 111 | #ifdef ACPI_MISALIGNMENT_NOT_SUPPORTED |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | /* |
| 113 | * Hardware does not support non-aligned data transfers, we must verify |
| 114 | * the request. |
| 115 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 116 | (void)acpi_ut_short_divide((acpi_integer) address, length, NULL, |
| 117 | &remainder); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 | if (remainder != 0) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 119 | return_ACPI_STATUS(AE_AML_ALIGNMENT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | } |
| 121 | #endif |
| 122 | |
| 123 | /* |
| 124 | * Does the request fit into the cached memory mapping? |
| 125 | * Is 1) Address below the current mapping? OR |
| 126 | * 2) Address beyond the current mapping? |
| 127 | */ |
| 128 | if ((address < mem_info->mapped_physical_address) || |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 129 | (((acpi_integer) address + length) > ((acpi_integer) |
| 130 | mem_info-> |
| 131 | mapped_physical_address + |
| 132 | mem_info->mapped_length))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 133 | /* |
| 134 | * The request cannot be resolved by the current memory mapping; |
| 135 | * Delete the existing mapping and create a new one. |
| 136 | */ |
| 137 | if (mem_info->mapped_length) { |
| 138 | /* Valid mapping, delete it */ |
| 139 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 140 | acpi_os_unmap_memory(mem_info->mapped_logical_address, |
| 141 | mem_info->mapped_length); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 142 | } |
| 143 | |
| 144 | /* |
| 145 | * Don't attempt to map memory beyond the end of the region, and |
| 146 | * constrain the maximum mapping size to something reasonable. |
| 147 | */ |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 148 | window_size = (acpi_size) |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 149 | ((mem_info->address + mem_info->length) - address); |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 150 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 151 | if (window_size > ACPI_SYSMEM_REGION_WINDOW_SIZE) { |
| 152 | window_size = ACPI_SYSMEM_REGION_WINDOW_SIZE; |
| 153 | } |
| 154 | |
| 155 | /* Create a new mapping starting at the address given */ |
| 156 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 157 | status = acpi_os_map_memory(address, window_size, |
| 158 | (void **)&mem_info-> |
| 159 | mapped_logical_address); |
| 160 | if (ACPI_FAILURE(status)) { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 161 | ACPI_ERROR((AE_INFO, |
| 162 | "Could not map memory at %8.8X%8.8X, size %X", |
| 163 | ACPI_FORMAT_UINT64(address), |
| 164 | (u32) window_size)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 165 | mem_info->mapped_length = 0; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 166 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | } |
| 168 | |
| 169 | /* Save the physical address and mapping size */ |
| 170 | |
| 171 | mem_info->mapped_physical_address = address; |
| 172 | mem_info->mapped_length = window_size; |
| 173 | } |
| 174 | |
| 175 | /* |
| 176 | * Generate a logical pointer corresponding to the address we want to |
| 177 | * access |
| 178 | */ |
| 179 | logical_addr_ptr = mem_info->mapped_logical_address + |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 180 | ((acpi_integer) address - |
| 181 | (acpi_integer) mem_info->mapped_physical_address); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 182 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 183 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
| 184 | "system_memory %d (%d width) Address=%8.8X%8.8X\n", |
| 185 | function, bit_width, ACPI_FORMAT_UINT64(address))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 186 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 187 | /* |
| 188 | * Perform the memory read or write |
| 189 | * |
| 190 | * Note: For machines that do not support non-aligned transfers, the target |
| 191 | * address was checked for alignment above. We do not attempt to break the |
| 192 | * transfer up into smaller (byte-size) chunks because the AML specifically |
| 193 | * asked for a transfer width that the hardware may require. |
| 194 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 195 | switch (function) { |
| 196 | case ACPI_READ: |
| 197 | |
| 198 | *value = 0; |
| 199 | switch (bit_width) { |
| 200 | case 8: |
Bob Moore | c51a4de | 2005-11-17 13:07:00 -0500 | [diff] [blame] | 201 | *value = (acpi_integer) ACPI_GET8(logical_addr_ptr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 202 | break; |
| 203 | |
| 204 | case 16: |
Bob Moore | c51a4de | 2005-11-17 13:07:00 -0500 | [diff] [blame] | 205 | *value = (acpi_integer) ACPI_GET16(logical_addr_ptr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 206 | break; |
| 207 | |
| 208 | case 32: |
Bob Moore | c51a4de | 2005-11-17 13:07:00 -0500 | [diff] [blame] | 209 | *value = (acpi_integer) ACPI_GET32(logical_addr_ptr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 210 | break; |
| 211 | |
| 212 | #if ACPI_MACHINE_WIDTH != 16 |
| 213 | case 64: |
Bob Moore | c51a4de | 2005-11-17 13:07:00 -0500 | [diff] [blame] | 214 | *value = (acpi_integer) ACPI_GET64(logical_addr_ptr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 215 | break; |
| 216 | #endif |
| 217 | default: |
| 218 | /* bit_width was already validated */ |
| 219 | break; |
| 220 | } |
| 221 | break; |
| 222 | |
| 223 | case ACPI_WRITE: |
| 224 | |
| 225 | switch (bit_width) { |
| 226 | case 8: |
Bob Moore | c51a4de | 2005-11-17 13:07:00 -0500 | [diff] [blame] | 227 | ACPI_SET8(logical_addr_ptr) = (u8) * value; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 228 | break; |
| 229 | |
| 230 | case 16: |
Bob Moore | c51a4de | 2005-11-17 13:07:00 -0500 | [diff] [blame] | 231 | ACPI_SET16(logical_addr_ptr) = (u16) * value; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 232 | break; |
| 233 | |
| 234 | case 32: |
Bob Moore | c51a4de | 2005-11-17 13:07:00 -0500 | [diff] [blame] | 235 | ACPI_SET32(logical_addr_ptr) = (u32) * value; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 236 | break; |
| 237 | |
| 238 | #if ACPI_MACHINE_WIDTH != 16 |
| 239 | case 64: |
Bob Moore | c51a4de | 2005-11-17 13:07:00 -0500 | [diff] [blame] | 240 | ACPI_SET64(logical_addr_ptr) = (u64) * value; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 241 | break; |
| 242 | #endif |
| 243 | |
| 244 | default: |
| 245 | /* bit_width was already validated */ |
| 246 | break; |
| 247 | } |
| 248 | break; |
| 249 | |
| 250 | default: |
| 251 | status = AE_BAD_PARAMETER; |
| 252 | break; |
| 253 | } |
| 254 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 255 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 256 | } |
| 257 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 258 | /******************************************************************************* |
| 259 | * |
| 260 | * FUNCTION: acpi_ex_system_io_space_handler |
| 261 | * |
| 262 | * PARAMETERS: Function - Read or Write operation |
| 263 | * Address - Where in the space to read or write |
| 264 | * bit_width - Field width in bits (8, 16, or 32) |
| 265 | * Value - Pointer to in or out value |
| 266 | * handler_context - Pointer to Handler's context |
| 267 | * region_context - Pointer to context specific to the |
| 268 | * accessed region |
| 269 | * |
| 270 | * RETURN: Status |
| 271 | * |
| 272 | * DESCRIPTION: Handler for the System IO address space (Op Region) |
| 273 | * |
| 274 | ******************************************************************************/ |
| 275 | |
| 276 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 277 | acpi_ex_system_io_space_handler(u32 function, |
| 278 | acpi_physical_address address, |
| 279 | u32 bit_width, |
| 280 | acpi_integer * value, |
| 281 | void *handler_context, void *region_context) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 282 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 283 | acpi_status status = AE_OK; |
| 284 | u32 value32; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 285 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 286 | ACPI_FUNCTION_TRACE("ex_system_io_space_handler"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 287 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 288 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
| 289 | "system_iO %d (%d width) Address=%8.8X%8.8X\n", |
| 290 | function, bit_width, ACPI_FORMAT_UINT64(address))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 291 | |
| 292 | /* Decode the function parameter */ |
| 293 | |
| 294 | switch (function) { |
| 295 | case ACPI_READ: |
| 296 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 297 | status = acpi_os_read_port((acpi_io_address) address, |
| 298 | &value32, bit_width); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 299 | *value = value32; |
| 300 | break; |
| 301 | |
| 302 | case ACPI_WRITE: |
| 303 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 304 | status = acpi_os_write_port((acpi_io_address) address, |
| 305 | (u32) * value, bit_width); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 306 | break; |
| 307 | |
| 308 | default: |
| 309 | status = AE_BAD_PARAMETER; |
| 310 | break; |
| 311 | } |
| 312 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 313 | return_ACPI_STATUS(status); |
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 | * |
| 318 | * FUNCTION: acpi_ex_pci_config_space_handler |
| 319 | * |
| 320 | * PARAMETERS: Function - Read or Write operation |
| 321 | * Address - Where in the space to read or write |
| 322 | * bit_width - Field width in bits (8, 16, or 32) |
| 323 | * Value - Pointer to in or out value |
| 324 | * handler_context - Pointer to Handler's context |
| 325 | * region_context - Pointer to context specific to the |
| 326 | * accessed region |
| 327 | * |
| 328 | * RETURN: Status |
| 329 | * |
| 330 | * DESCRIPTION: Handler for the PCI Config address space (Op Region) |
| 331 | * |
| 332 | ******************************************************************************/ |
| 333 | |
| 334 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 335 | acpi_ex_pci_config_space_handler(u32 function, |
| 336 | acpi_physical_address address, |
| 337 | u32 bit_width, |
| 338 | acpi_integer * value, |
| 339 | void *handler_context, void *region_context) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 340 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 341 | acpi_status status = AE_OK; |
| 342 | struct acpi_pci_id *pci_id; |
| 343 | u16 pci_register; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 344 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 345 | ACPI_FUNCTION_TRACE("ex_pci_config_space_handler"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 346 | |
| 347 | /* |
| 348 | * The arguments to acpi_os(Read|Write)pci_configuration are: |
| 349 | * |
| 350 | * pci_segment is the PCI bus segment range 0-31 |
| 351 | * pci_bus is the PCI bus number range 0-255 |
| 352 | * pci_device is the PCI device number range 0-31 |
| 353 | * pci_function is the PCI device function number |
| 354 | * pci_register is the Config space register range 0-255 bytes |
| 355 | * |
| 356 | * Value - input value for write, output address for read |
| 357 | * |
| 358 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 359 | pci_id = (struct acpi_pci_id *)region_context; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 360 | pci_register = (u16) (u32) address; |
| 361 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 362 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
| 363 | "pci_config %d (%d) Seg(%04x) Bus(%04x) Dev(%04x) Func(%04x) Reg(%04x)\n", |
| 364 | function, bit_width, pci_id->segment, pci_id->bus, |
| 365 | pci_id->device, pci_id->function, pci_register)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 366 | |
| 367 | switch (function) { |
| 368 | case ACPI_READ: |
| 369 | |
| 370 | *value = 0; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 371 | status = acpi_os_read_pci_configuration(pci_id, pci_register, |
| 372 | value, bit_width); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 373 | break; |
| 374 | |
| 375 | case ACPI_WRITE: |
| 376 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 377 | status = acpi_os_write_pci_configuration(pci_id, pci_register, |
| 378 | *value, bit_width); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 379 | break; |
| 380 | |
| 381 | default: |
| 382 | |
| 383 | status = AE_BAD_PARAMETER; |
| 384 | break; |
| 385 | } |
| 386 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 387 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 388 | } |
| 389 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 390 | /******************************************************************************* |
| 391 | * |
| 392 | * FUNCTION: acpi_ex_cmos_space_handler |
| 393 | * |
| 394 | * PARAMETERS: Function - Read or Write operation |
| 395 | * Address - Where in the space to read or write |
| 396 | * bit_width - Field width in bits (8, 16, or 32) |
| 397 | * Value - Pointer to in or out value |
| 398 | * handler_context - Pointer to Handler's context |
| 399 | * region_context - Pointer to context specific to the |
| 400 | * accessed region |
| 401 | * |
| 402 | * RETURN: Status |
| 403 | * |
| 404 | * DESCRIPTION: Handler for the CMOS address space (Op Region) |
| 405 | * |
| 406 | ******************************************************************************/ |
| 407 | |
| 408 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 409 | acpi_ex_cmos_space_handler(u32 function, |
| 410 | acpi_physical_address address, |
| 411 | u32 bit_width, |
| 412 | acpi_integer * value, |
| 413 | void *handler_context, void *region_context) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 414 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 415 | acpi_status status = AE_OK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 416 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 417 | ACPI_FUNCTION_TRACE("ex_cmos_space_handler"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 418 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 419 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 420 | } |
| 421 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 422 | /******************************************************************************* |
| 423 | * |
| 424 | * FUNCTION: acpi_ex_pci_bar_space_handler |
| 425 | * |
| 426 | * PARAMETERS: Function - Read or Write operation |
| 427 | * Address - Where in the space to read or write |
| 428 | * bit_width - Field width in bits (8, 16, or 32) |
| 429 | * Value - Pointer to in or out value |
| 430 | * handler_context - Pointer to Handler's context |
| 431 | * region_context - Pointer to context specific to the |
| 432 | * accessed region |
| 433 | * |
| 434 | * RETURN: Status |
| 435 | * |
| 436 | * DESCRIPTION: Handler for the PCI bar_target address space (Op Region) |
| 437 | * |
| 438 | ******************************************************************************/ |
| 439 | |
| 440 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 441 | acpi_ex_pci_bar_space_handler(u32 function, |
| 442 | acpi_physical_address address, |
| 443 | u32 bit_width, |
| 444 | acpi_integer * value, |
| 445 | void *handler_context, void *region_context) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 446 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 447 | acpi_status status = AE_OK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 448 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 449 | ACPI_FUNCTION_TRACE("ex_pci_bar_space_handler"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 450 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 451 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 452 | } |
| 453 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 454 | /******************************************************************************* |
| 455 | * |
| 456 | * FUNCTION: acpi_ex_data_table_space_handler |
| 457 | * |
| 458 | * PARAMETERS: Function - Read or Write operation |
| 459 | * Address - Where in the space to read or write |
| 460 | * bit_width - Field width in bits (8, 16, or 32) |
| 461 | * Value - Pointer to in or out value |
| 462 | * handler_context - Pointer to Handler's context |
| 463 | * region_context - Pointer to context specific to the |
| 464 | * accessed region |
| 465 | * |
| 466 | * RETURN: Status |
| 467 | * |
| 468 | * DESCRIPTION: Handler for the Data Table address space (Op Region) |
| 469 | * |
| 470 | ******************************************************************************/ |
| 471 | |
| 472 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 473 | acpi_ex_data_table_space_handler(u32 function, |
| 474 | acpi_physical_address address, |
| 475 | u32 bit_width, |
| 476 | acpi_integer * value, |
| 477 | void *handler_context, void *region_context) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 478 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 479 | acpi_status status = AE_OK; |
| 480 | u32 byte_width = ACPI_DIV_8(bit_width); |
| 481 | u32 i; |
| 482 | char *logical_addr_ptr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 483 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 484 | ACPI_FUNCTION_TRACE("ex_data_table_space_handler"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 485 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 486 | logical_addr_ptr = ACPI_PHYSADDR_TO_PTR(address); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 487 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 488 | /* Perform the memory read or write */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 489 | |
| 490 | switch (function) { |
| 491 | case ACPI_READ: |
| 492 | |
| 493 | for (i = 0; i < byte_width; i++) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 494 | ((char *)value)[i] = logical_addr_ptr[i]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 495 | } |
| 496 | break; |
| 497 | |
| 498 | case ACPI_WRITE: |
| 499 | default: |
| 500 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 501 | return_ACPI_STATUS(AE_SUPPORT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 502 | } |
| 503 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 504 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 505 | } |