Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * Module Name: evregion - ACPI address_space (op_region) handler dispatch |
| 4 | * |
| 5 | *****************************************************************************/ |
| 6 | |
| 7 | /* |
Bob Moore | 4a90c7e | 2006-01-13 16:22:00 -0500 | [diff] [blame] | 8 | * Copyright (C) 2000 - 2006, R. Byron Moore |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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/acevents.h> |
| 46 | #include <acpi/acnamesp.h> |
| 47 | #include <acpi/acinterp.h> |
| 48 | |
| 49 | #define _COMPONENT ACPI_EVENTS |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 50 | ACPI_MODULE_NAME("evregion") |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | #define ACPI_NUM_DEFAULT_SPACES 4 |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 52 | static u8 acpi_gbl_default_address_spaces[ACPI_NUM_DEFAULT_SPACES] = { |
| 53 | ACPI_ADR_SPACE_SYSTEM_MEMORY, |
| 54 | ACPI_ADR_SPACE_SYSTEM_IO, |
| 55 | ACPI_ADR_SPACE_PCI_CONFIG, |
| 56 | ACPI_ADR_SPACE_DATA_TABLE |
| 57 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 59 | /* Local prototypes */ |
| 60 | |
| 61 | static acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 62 | acpi_ev_reg_run(acpi_handle obj_handle, |
| 63 | u32 level, void *context, void **return_value); |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 64 | |
| 65 | static acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 66 | acpi_ev_install_handler(acpi_handle obj_handle, |
| 67 | u32 level, void *context, void **return_value); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | |
| 69 | /******************************************************************************* |
| 70 | * |
| 71 | * FUNCTION: acpi_ev_install_region_handlers |
| 72 | * |
| 73 | * PARAMETERS: None |
| 74 | * |
| 75 | * RETURN: Status |
| 76 | * |
| 77 | * DESCRIPTION: Installs the core subsystem default address space handlers. |
| 78 | * |
| 79 | ******************************************************************************/ |
| 80 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 81 | acpi_status acpi_ev_install_region_handlers(void) |
| 82 | { |
| 83 | acpi_status status; |
| 84 | acpi_native_uint i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 86 | ACPI_FUNCTION_TRACE(ev_install_region_handlers); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 88 | status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); |
| 89 | if (ACPI_FAILURE(status)) { |
| 90 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | } |
| 92 | |
| 93 | /* |
| 94 | * All address spaces (PCI Config, EC, SMBus) are scope dependent |
| 95 | * and registration must occur for a specific device. |
| 96 | * |
| 97 | * In the case of the system memory and IO address spaces there is currently |
| 98 | * no device associated with the address space. For these we use the root. |
| 99 | * |
| 100 | * We install the default PCI config space handler at the root so |
| 101 | * that this space is immediately available even though the we have |
| 102 | * not enumerated all the PCI Root Buses yet. This is to conform |
| 103 | * to the ACPI specification which states that the PCI config |
| 104 | * space must be always available -- even though we are nowhere |
| 105 | * near ready to find the PCI root buses at this point. |
| 106 | * |
| 107 | * NOTE: We ignore AE_ALREADY_EXISTS because this means that a handler |
| 108 | * has already been installed (via acpi_install_address_space_handler). |
| 109 | * Similar for AE_SAME_HANDLER. |
| 110 | */ |
| 111 | for (i = 0; i < ACPI_NUM_DEFAULT_SPACES; i++) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 112 | status = acpi_ev_install_space_handler(acpi_gbl_root_node, |
| 113 | acpi_gbl_default_address_spaces |
| 114 | [i], |
| 115 | ACPI_DEFAULT_HANDLER, |
| 116 | NULL, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | switch (status) { |
| 118 | case AE_OK: |
| 119 | case AE_SAME_HANDLER: |
| 120 | case AE_ALREADY_EXISTS: |
| 121 | |
| 122 | /* These exceptions are all OK */ |
| 123 | |
| 124 | status = AE_OK; |
| 125 | break; |
| 126 | |
| 127 | default: |
| 128 | |
| 129 | goto unlock_and_exit; |
| 130 | } |
| 131 | } |
| 132 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 133 | unlock_and_exit: |
| 134 | (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); |
| 135 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | } |
| 137 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | /******************************************************************************* |
| 139 | * |
| 140 | * FUNCTION: acpi_ev_initialize_op_regions |
| 141 | * |
| 142 | * PARAMETERS: None |
| 143 | * |
| 144 | * RETURN: Status |
| 145 | * |
| 146 | * DESCRIPTION: Execute _REG methods for all Operation Regions that have |
| 147 | * an installed default region handler. |
| 148 | * |
| 149 | ******************************************************************************/ |
| 150 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 151 | acpi_status acpi_ev_initialize_op_regions(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 153 | acpi_status status; |
| 154 | acpi_native_uint i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 155 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 156 | ACPI_FUNCTION_TRACE(ev_initialize_op_regions); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 157 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 158 | status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); |
| 159 | if (ACPI_FAILURE(status)) { |
| 160 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 161 | } |
| 162 | |
| 163 | /* |
| 164 | * Run the _REG methods for op_regions in each default address space |
| 165 | */ |
| 166 | for (i = 0; i < ACPI_NUM_DEFAULT_SPACES; i++) { |
Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 167 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 168 | /* TBD: Make sure handler is the DEFAULT handler, otherwise |
| 169 | * _REG will have already been run. |
| 170 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 171 | status = acpi_ev_execute_reg_methods(acpi_gbl_root_node, |
| 172 | acpi_gbl_default_address_spaces |
| 173 | [i]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 174 | } |
| 175 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 176 | (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); |
| 177 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 178 | } |
| 179 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 180 | /******************************************************************************* |
| 181 | * |
| 182 | * FUNCTION: acpi_ev_execute_reg_method |
| 183 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 184 | * PARAMETERS: region_obj - Region object |
| 185 | * Function - Passed to _REG: On (1) or Off (0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 186 | * |
| 187 | * RETURN: Status |
| 188 | * |
| 189 | * DESCRIPTION: Execute _REG method for a region |
| 190 | * |
| 191 | ******************************************************************************/ |
| 192 | |
| 193 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 194 | acpi_ev_execute_reg_method(union acpi_operand_object *region_obj, u32 function) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 195 | { |
Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 196 | struct acpi_evaluate_info *info; |
| 197 | union acpi_operand_object *args[3]; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 198 | union acpi_operand_object *region_obj2; |
| 199 | acpi_status status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 200 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 201 | ACPI_FUNCTION_TRACE(ev_execute_reg_method); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 202 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 203 | region_obj2 = acpi_ns_get_secondary_object(region_obj); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 204 | if (!region_obj2) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 205 | return_ACPI_STATUS(AE_NOT_EXIST); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 206 | } |
| 207 | |
| 208 | if (region_obj2->extra.method_REG == NULL) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 209 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 210 | } |
| 211 | |
Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 212 | /* Allocate and initialize the evaluation information block */ |
| 213 | |
| 214 | info = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_evaluate_info)); |
| 215 | if (!info) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 216 | return_ACPI_STATUS(AE_NO_MEMORY); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 217 | } |
| 218 | |
Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 219 | info->prefix_node = region_obj2->extra.method_REG; |
| 220 | info->pathname = NULL; |
| 221 | info->parameters = args; |
| 222 | info->parameter_type = ACPI_PARAM_ARGS; |
| 223 | info->flags = ACPI_IGNORE_RETURN_VALUE; |
| 224 | |
| 225 | /* |
| 226 | * The _REG method has two arguments: |
| 227 | * |
| 228 | * Arg0 - Integer: |
| 229 | * Operation region space ID Same value as region_obj->Region.space_id |
| 230 | * |
| 231 | * Arg1 - Integer: |
| 232 | * connection status 1 for connecting the handler, 0 for disconnecting |
| 233 | * the handler (Passed as a parameter) |
| 234 | */ |
| 235 | args[0] = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER); |
| 236 | if (!args[0]) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 237 | status = AE_NO_MEMORY; |
Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 238 | goto cleanup1; |
| 239 | } |
| 240 | |
| 241 | args[1] = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER); |
| 242 | if (!args[1]) { |
| 243 | status = AE_NO_MEMORY; |
| 244 | goto cleanup2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 245 | } |
| 246 | |
| 247 | /* Setup the parameter objects */ |
| 248 | |
Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 249 | args[0]->integer.value = region_obj->region.space_id; |
| 250 | args[1]->integer.value = function; |
| 251 | args[2] = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 252 | |
| 253 | /* Execute the method, no return value */ |
| 254 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 255 | ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname |
Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 256 | (ACPI_TYPE_METHOD, info->prefix_node, NULL)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 257 | |
Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 258 | status = acpi_ns_evaluate(info); |
| 259 | acpi_ut_remove_reference(args[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 260 | |
Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 261 | cleanup2: |
| 262 | acpi_ut_remove_reference(args[0]); |
| 263 | |
| 264 | cleanup1: |
| 265 | ACPI_FREE(info); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 266 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 267 | } |
| 268 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 269 | /******************************************************************************* |
| 270 | * |
| 271 | * FUNCTION: acpi_ev_address_space_dispatch |
| 272 | * |
| 273 | * PARAMETERS: region_obj - Internal region object |
| 274 | * Function - Read or Write operation |
| 275 | * Address - Where in the space to read or write |
| 276 | * bit_width - Field width in bits (8, 16, 32, or 64) |
Bob Moore | 958dd24 | 2006-05-12 17:12:00 -0400 | [diff] [blame] | 277 | * Value - Pointer to in or out value, must be |
| 278 | * full 64-bit acpi_integer |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 279 | * |
| 280 | * RETURN: Status |
| 281 | * |
| 282 | * DESCRIPTION: Dispatch an address space or operation region access to |
| 283 | * a previously installed handler. |
| 284 | * |
| 285 | ******************************************************************************/ |
| 286 | |
| 287 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 288 | acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj, |
| 289 | u32 function, |
| 290 | acpi_physical_address address, |
Bob Moore | 958dd24 | 2006-05-12 17:12:00 -0400 | [diff] [blame] | 291 | u32 bit_width, acpi_integer * value) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 292 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 293 | acpi_status status; |
| 294 | acpi_status status2; |
| 295 | acpi_adr_space_handler handler; |
| 296 | acpi_adr_space_setup region_setup; |
| 297 | union acpi_operand_object *handler_desc; |
| 298 | union acpi_operand_object *region_obj2; |
| 299 | void *region_context = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 300 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 301 | ACPI_FUNCTION_TRACE(ev_address_space_dispatch); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 302 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 303 | region_obj2 = acpi_ns_get_secondary_object(region_obj); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 304 | if (!region_obj2) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 305 | return_ACPI_STATUS(AE_NOT_EXIST); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 306 | } |
| 307 | |
| 308 | /* Ensure that there is a handler associated with this region */ |
| 309 | |
| 310 | handler_desc = region_obj->region.handler; |
| 311 | if (!handler_desc) { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 312 | ACPI_ERROR((AE_INFO, |
| 313 | "No handler for Region [%4.4s] (%p) [%s]", |
| 314 | acpi_ut_get_node_name(region_obj->region.node), |
| 315 | region_obj, |
| 316 | acpi_ut_get_region_name(region_obj->region. |
| 317 | space_id))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 318 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 319 | return_ACPI_STATUS(AE_NOT_EXIST); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 320 | } |
| 321 | |
| 322 | /* |
| 323 | * It may be the case that the region has never been initialized |
| 324 | * Some types of regions require special init code |
| 325 | */ |
| 326 | if (!(region_obj->region.flags & AOPOBJ_SETUP_COMPLETE)) { |
| 327 | /* |
| 328 | * This region has not been initialized yet, do it |
| 329 | */ |
| 330 | region_setup = handler_desc->address_space.setup; |
| 331 | if (!region_setup) { |
Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 332 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 333 | /* No initialization routine, exit with error */ |
| 334 | |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 335 | ACPI_ERROR((AE_INFO, |
| 336 | "No init routine for region(%p) [%s]", |
| 337 | region_obj, |
| 338 | acpi_ut_get_region_name(region_obj->region. |
| 339 | space_id))); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 340 | return_ACPI_STATUS(AE_NOT_EXIST); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 341 | } |
| 342 | |
| 343 | /* |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 344 | * We must exit the interpreter because the region |
| 345 | * setup will potentially execute control methods |
| 346 | * (e.g., _REG method for this region) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 347 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 348 | acpi_ex_exit_interpreter(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 349 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 350 | status = region_setup(region_obj, ACPI_REGION_ACTIVATE, |
| 351 | handler_desc->address_space.context, |
| 352 | ®ion_context); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 353 | |
| 354 | /* Re-enter the interpreter */ |
| 355 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 356 | status2 = acpi_ex_enter_interpreter(); |
| 357 | if (ACPI_FAILURE(status2)) { |
| 358 | return_ACPI_STATUS(status2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 359 | } |
| 360 | |
| 361 | /* Check for failure of the Region Setup */ |
| 362 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 363 | if (ACPI_FAILURE(status)) { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 364 | ACPI_EXCEPTION((AE_INFO, status, |
| 365 | "During region initialization: [%s]", |
| 366 | acpi_ut_get_region_name(region_obj-> |
| 367 | region. |
| 368 | space_id))); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 369 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 370 | } |
| 371 | |
| 372 | /* |
| 373 | * Region initialization may have been completed by region_setup |
| 374 | */ |
| 375 | if (!(region_obj->region.flags & AOPOBJ_SETUP_COMPLETE)) { |
| 376 | region_obj->region.flags |= AOPOBJ_SETUP_COMPLETE; |
| 377 | |
| 378 | if (region_obj2->extra.region_context) { |
Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 379 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 380 | /* The handler for this region was already installed */ |
| 381 | |
Bob Moore | 8313524 | 2006-10-03 00:00:00 -0400 | [diff] [blame] | 382 | ACPI_FREE(region_context); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 383 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 384 | /* |
| 385 | * Save the returned context for use in all accesses to |
| 386 | * this particular region |
| 387 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 388 | region_obj2->extra.region_context = |
| 389 | region_context; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 390 | } |
| 391 | } |
| 392 | } |
| 393 | |
| 394 | /* We have everything we need, we can invoke the address space handler */ |
| 395 | |
| 396 | handler = handler_desc->address_space.handler; |
| 397 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 398 | ACPI_DEBUG_PRINT((ACPI_DB_OPREGION, |
| 399 | "Handler %p (@%p) Address %8.8X%8.8X [%s]\n", |
| 400 | ®ion_obj->region.handler->address_space, handler, |
| 401 | ACPI_FORMAT_UINT64(address), |
| 402 | acpi_ut_get_region_name(region_obj->region. |
| 403 | space_id))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 404 | |
Bob Moore | 6168612 | 2006-03-17 16:44:00 -0500 | [diff] [blame] | 405 | if (!(handler_desc->address_space.handler_flags & |
| 406 | ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 407 | /* |
| 408 | * For handlers other than the default (supplied) handlers, we must |
| 409 | * exit the interpreter because the handler *might* block -- we don't |
| 410 | * know what it will do, so we can't hold the lock on the intepreter. |
| 411 | */ |
| 412 | acpi_ex_exit_interpreter(); |
| 413 | } |
| 414 | |
| 415 | /* Call the handler */ |
| 416 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 417 | status = handler(function, address, bit_width, value, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 418 | handler_desc->address_space.context, |
| 419 | region_obj2->extra.region_context); |
| 420 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 421 | if (ACPI_FAILURE(status)) { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 422 | ACPI_EXCEPTION((AE_INFO, status, "Returned by Handler for [%s]", |
| 423 | acpi_ut_get_region_name(region_obj->region. |
| 424 | space_id))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 425 | } |
| 426 | |
Bob Moore | 6168612 | 2006-03-17 16:44:00 -0500 | [diff] [blame] | 427 | if (!(handler_desc->address_space.handler_flags & |
| 428 | ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 429 | /* |
| 430 | * We just returned from a non-default handler, we must re-enter the |
| 431 | * interpreter |
| 432 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 433 | status2 = acpi_ex_enter_interpreter(); |
| 434 | if (ACPI_FAILURE(status2)) { |
| 435 | return_ACPI_STATUS(status2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 436 | } |
| 437 | } |
| 438 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 439 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 440 | } |
| 441 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 442 | /******************************************************************************* |
| 443 | * |
| 444 | * FUNCTION: acpi_ev_detach_region |
| 445 | * |
| 446 | * PARAMETERS: region_obj - Region Object |
| 447 | * acpi_ns_is_locked - Namespace Region Already Locked? |
| 448 | * |
| 449 | * RETURN: None |
| 450 | * |
| 451 | * DESCRIPTION: Break the association between the handler and the region |
| 452 | * this is a two way association. |
| 453 | * |
| 454 | ******************************************************************************/ |
| 455 | |
| 456 | void |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 457 | acpi_ev_detach_region(union acpi_operand_object *region_obj, |
| 458 | u8 acpi_ns_is_locked) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 459 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 460 | union acpi_operand_object *handler_obj; |
| 461 | union acpi_operand_object *obj_desc; |
| 462 | union acpi_operand_object **last_obj_ptr; |
| 463 | acpi_adr_space_setup region_setup; |
| 464 | void **region_context; |
| 465 | union acpi_operand_object *region_obj2; |
| 466 | acpi_status status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 467 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 468 | ACPI_FUNCTION_TRACE(ev_detach_region); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 469 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 470 | region_obj2 = acpi_ns_get_secondary_object(region_obj); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 471 | if (!region_obj2) { |
| 472 | return_VOID; |
| 473 | } |
| 474 | region_context = ®ion_obj2->extra.region_context; |
| 475 | |
| 476 | /* Get the address handler from the region object */ |
| 477 | |
| 478 | handler_obj = region_obj->region.handler; |
| 479 | if (!handler_obj) { |
Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 480 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 481 | /* This region has no handler, all done */ |
| 482 | |
| 483 | return_VOID; |
| 484 | } |
| 485 | |
| 486 | /* Find this region in the handler's list */ |
| 487 | |
| 488 | obj_desc = handler_obj->address_space.region_list; |
| 489 | last_obj_ptr = &handler_obj->address_space.region_list; |
| 490 | |
| 491 | while (obj_desc) { |
Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 492 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 493 | /* Is this the correct Region? */ |
| 494 | |
| 495 | if (obj_desc == region_obj) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 496 | ACPI_DEBUG_PRINT((ACPI_DB_OPREGION, |
| 497 | "Removing Region %p from address handler %p\n", |
| 498 | region_obj, handler_obj)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 499 | |
| 500 | /* This is it, remove it from the handler's list */ |
| 501 | |
| 502 | *last_obj_ptr = obj_desc->region.next; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 503 | obj_desc->region.next = NULL; /* Must clear field */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 504 | |
| 505 | if (acpi_ns_is_locked) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 506 | status = |
| 507 | acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); |
| 508 | if (ACPI_FAILURE(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 509 | return_VOID; |
| 510 | } |
| 511 | } |
| 512 | |
| 513 | /* Now stop region accesses by executing the _REG method */ |
| 514 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 515 | status = acpi_ev_execute_reg_method(region_obj, 0); |
| 516 | if (ACPI_FAILURE(status)) { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 517 | ACPI_EXCEPTION((AE_INFO, status, |
| 518 | "from region _REG, [%s]", |
| 519 | acpi_ut_get_region_name |
| 520 | (region_obj->region.space_id))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 521 | } |
| 522 | |
| 523 | if (acpi_ns_is_locked) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 524 | status = |
| 525 | acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); |
| 526 | if (ACPI_FAILURE(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 527 | return_VOID; |
| 528 | } |
| 529 | } |
| 530 | |
Bob Moore | f6dd922 | 2006-07-07 20:44:38 -0400 | [diff] [blame] | 531 | /* |
| 532 | * If the region has been activated, call the setup handler |
| 533 | * with the deactivate notification |
| 534 | */ |
| 535 | if (region_obj->region.flags & AOPOBJ_SETUP_COMPLETE) { |
| 536 | region_setup = handler_obj->address_space.setup; |
| 537 | status = |
| 538 | region_setup(region_obj, |
| 539 | ACPI_REGION_DEACTIVATE, |
| 540 | handler_obj->address_space. |
| 541 | context, region_context); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 542 | |
Bob Moore | f6dd922 | 2006-07-07 20:44:38 -0400 | [diff] [blame] | 543 | /* Init routine may fail, Just ignore errors */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 544 | |
Bob Moore | f6dd922 | 2006-07-07 20:44:38 -0400 | [diff] [blame] | 545 | if (ACPI_FAILURE(status)) { |
| 546 | ACPI_EXCEPTION((AE_INFO, status, |
| 547 | "from region handler - deactivate, [%s]", |
| 548 | acpi_ut_get_region_name |
| 549 | (region_obj->region. |
| 550 | space_id))); |
| 551 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 552 | |
Bob Moore | f6dd922 | 2006-07-07 20:44:38 -0400 | [diff] [blame] | 553 | region_obj->region.flags &= |
| 554 | ~(AOPOBJ_SETUP_COMPLETE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 555 | } |
| 556 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 557 | /* |
| 558 | * Remove handler reference in the region |
| 559 | * |
Bob Moore | f6dd922 | 2006-07-07 20:44:38 -0400 | [diff] [blame] | 560 | * NOTE: this doesn't mean that the region goes away, the region |
| 561 | * is just inaccessible as indicated to the _REG method |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 562 | * |
Bob Moore | f6dd922 | 2006-07-07 20:44:38 -0400 | [diff] [blame] | 563 | * If the region is on the handler's list, this must be the |
| 564 | * region's handler |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 565 | */ |
| 566 | region_obj->region.handler = NULL; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 567 | acpi_ut_remove_reference(handler_obj); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 568 | |
| 569 | return_VOID; |
| 570 | } |
| 571 | |
| 572 | /* Walk the linked list of handlers */ |
| 573 | |
| 574 | last_obj_ptr = &obj_desc->region.next; |
| 575 | obj_desc = obj_desc->region.next; |
| 576 | } |
| 577 | |
| 578 | /* If we get here, the region was not in the handler's region list */ |
| 579 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 580 | ACPI_DEBUG_PRINT((ACPI_DB_OPREGION, |
| 581 | "Cannot remove region %p from address handler %p\n", |
| 582 | region_obj, handler_obj)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 583 | |
| 584 | return_VOID; |
| 585 | } |
| 586 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 587 | /******************************************************************************* |
| 588 | * |
| 589 | * FUNCTION: acpi_ev_attach_region |
| 590 | * |
| 591 | * PARAMETERS: handler_obj - Handler Object |
| 592 | * region_obj - Region Object |
| 593 | * acpi_ns_is_locked - Namespace Region Already Locked? |
| 594 | * |
| 595 | * RETURN: None |
| 596 | * |
| 597 | * DESCRIPTION: Create the association between the handler and the region |
| 598 | * this is a two way association. |
| 599 | * |
| 600 | ******************************************************************************/ |
| 601 | |
| 602 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 603 | acpi_ev_attach_region(union acpi_operand_object *handler_obj, |
| 604 | union acpi_operand_object *region_obj, |
| 605 | u8 acpi_ns_is_locked) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 606 | { |
| 607 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 608 | ACPI_FUNCTION_TRACE(ev_attach_region); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 609 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 610 | ACPI_DEBUG_PRINT((ACPI_DB_OPREGION, |
| 611 | "Adding Region [%4.4s] %p to address handler %p [%s]\n", |
| 612 | acpi_ut_get_node_name(region_obj->region.node), |
| 613 | region_obj, handler_obj, |
| 614 | acpi_ut_get_region_name(region_obj->region. |
| 615 | space_id))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 616 | |
| 617 | /* Link this region to the front of the handler's list */ |
| 618 | |
| 619 | region_obj->region.next = handler_obj->address_space.region_list; |
| 620 | handler_obj->address_space.region_list = region_obj; |
| 621 | |
| 622 | /* Install the region's handler */ |
| 623 | |
| 624 | if (region_obj->region.handler) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 625 | return_ACPI_STATUS(AE_ALREADY_EXISTS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 626 | } |
| 627 | |
| 628 | region_obj->region.handler = handler_obj; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 629 | acpi_ut_add_reference(handler_obj); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 630 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 631 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 632 | } |
| 633 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 634 | /******************************************************************************* |
| 635 | * |
| 636 | * FUNCTION: acpi_ev_install_handler |
| 637 | * |
| 638 | * PARAMETERS: walk_namespace callback |
| 639 | * |
| 640 | * DESCRIPTION: This routine installs an address handler into objects that are |
| 641 | * of type Region or Device. |
| 642 | * |
| 643 | * If the Object is a Device, and the device has a handler of |
| 644 | * the same type then the search is terminated in that branch. |
| 645 | * |
| 646 | * This is because the existing handler is closer in proximity |
| 647 | * to any more regions than the one we are trying to install. |
| 648 | * |
| 649 | ******************************************************************************/ |
| 650 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 651 | static acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 652 | acpi_ev_install_handler(acpi_handle obj_handle, |
| 653 | u32 level, void *context, void **return_value) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 654 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 655 | union acpi_operand_object *handler_obj; |
| 656 | union acpi_operand_object *next_handler_obj; |
| 657 | union acpi_operand_object *obj_desc; |
| 658 | struct acpi_namespace_node *node; |
| 659 | acpi_status status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 660 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 661 | ACPI_FUNCTION_NAME(ev_install_handler); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 662 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 663 | handler_obj = (union acpi_operand_object *)context; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 664 | |
| 665 | /* Parameter validation */ |
| 666 | |
| 667 | if (!handler_obj) { |
| 668 | return (AE_OK); |
| 669 | } |
| 670 | |
| 671 | /* Convert and validate the device handle */ |
| 672 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 673 | node = acpi_ns_map_handle_to_node(obj_handle); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 674 | if (!node) { |
| 675 | return (AE_BAD_PARAMETER); |
| 676 | } |
| 677 | |
| 678 | /* |
| 679 | * We only care about regions.and objects |
| 680 | * that are allowed to have address space handlers |
| 681 | */ |
| 682 | if ((node->type != ACPI_TYPE_DEVICE) && |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 683 | (node->type != ACPI_TYPE_REGION) && (node != acpi_gbl_root_node)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 684 | return (AE_OK); |
| 685 | } |
| 686 | |
| 687 | /* Check for an existing internal object */ |
| 688 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 689 | obj_desc = acpi_ns_get_attached_object(node); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 690 | if (!obj_desc) { |
Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 691 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 692 | /* No object, just exit */ |
| 693 | |
| 694 | return (AE_OK); |
| 695 | } |
| 696 | |
| 697 | /* Devices are handled different than regions */ |
| 698 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 699 | if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_DEVICE) { |
Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 700 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 701 | /* Check if this Device already has a handler for this address space */ |
| 702 | |
| 703 | next_handler_obj = obj_desc->device.handler; |
| 704 | while (next_handler_obj) { |
Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 705 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 706 | /* Found a handler, is it for the same address space? */ |
| 707 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 708 | if (next_handler_obj->address_space.space_id == |
| 709 | handler_obj->address_space.space_id) { |
| 710 | ACPI_DEBUG_PRINT((ACPI_DB_OPREGION, |
| 711 | "Found handler for region [%s] in device %p(%p) handler %p\n", |
| 712 | acpi_ut_get_region_name |
| 713 | (handler_obj->address_space. |
| 714 | space_id), obj_desc, |
| 715 | next_handler_obj, |
| 716 | handler_obj)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 717 | |
| 718 | /* |
| 719 | * Since the object we found it on was a device, then it |
| 720 | * means that someone has already installed a handler for |
| 721 | * the branch of the namespace from this device on. Just |
| 722 | * bail out telling the walk routine to not traverse this |
| 723 | * branch. This preserves the scoping rule for handlers. |
| 724 | */ |
| 725 | return (AE_CTRL_DEPTH); |
| 726 | } |
| 727 | |
| 728 | /* Walk the linked list of handlers attached to this device */ |
| 729 | |
| 730 | next_handler_obj = next_handler_obj->address_space.next; |
| 731 | } |
| 732 | |
| 733 | /* |
| 734 | * As long as the device didn't have a handler for this |
| 735 | * space we don't care about it. We just ignore it and |
| 736 | * proceed. |
| 737 | */ |
| 738 | return (AE_OK); |
| 739 | } |
| 740 | |
| 741 | /* Object is a Region */ |
| 742 | |
| 743 | if (obj_desc->region.space_id != handler_obj->address_space.space_id) { |
| 744 | /* |
| 745 | * This region is for a different address space |
| 746 | * -- just ignore it |
| 747 | */ |
| 748 | return (AE_OK); |
| 749 | } |
| 750 | |
| 751 | /* |
| 752 | * Now we have a region and it is for the handler's address |
| 753 | * space type. |
| 754 | * |
| 755 | * First disconnect region for any previous handler (if any) |
| 756 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 757 | acpi_ev_detach_region(obj_desc, FALSE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 758 | |
| 759 | /* Connect the region to the new handler */ |
| 760 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 761 | status = acpi_ev_attach_region(handler_obj, obj_desc, FALSE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 762 | return (status); |
| 763 | } |
| 764 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 765 | /******************************************************************************* |
| 766 | * |
| 767 | * FUNCTION: acpi_ev_install_space_handler |
| 768 | * |
| 769 | * PARAMETERS: Node - Namespace node for the device |
| 770 | * space_id - The address space ID |
| 771 | * Handler - Address of the handler |
| 772 | * Setup - Address of the setup function |
| 773 | * Context - Value passed to the handler on each access |
| 774 | * |
| 775 | * RETURN: Status |
| 776 | * |
| 777 | * DESCRIPTION: Install a handler for all op_regions of a given space_id. |
| 778 | * Assumes namespace is locked |
| 779 | * |
| 780 | ******************************************************************************/ |
| 781 | |
| 782 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 783 | acpi_ev_install_space_handler(struct acpi_namespace_node * node, |
| 784 | acpi_adr_space_type space_id, |
| 785 | acpi_adr_space_handler handler, |
| 786 | acpi_adr_space_setup setup, void *context) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 787 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 788 | union acpi_operand_object *obj_desc; |
| 789 | union acpi_operand_object *handler_obj; |
| 790 | acpi_status status; |
| 791 | acpi_object_type type; |
Bob Moore | 6168612 | 2006-03-17 16:44:00 -0500 | [diff] [blame] | 792 | u8 flags = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 793 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 794 | ACPI_FUNCTION_TRACE(ev_install_space_handler); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 795 | |
| 796 | /* |
| 797 | * This registration is valid for only the types below |
| 798 | * and the root. This is where the default handlers |
| 799 | * get placed. |
| 800 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 801 | if ((node->type != ACPI_TYPE_DEVICE) && |
| 802 | (node->type != ACPI_TYPE_PROCESSOR) && |
| 803 | (node->type != ACPI_TYPE_THERMAL) && (node != acpi_gbl_root_node)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 804 | status = AE_BAD_PARAMETER; |
| 805 | goto unlock_and_exit; |
| 806 | } |
| 807 | |
| 808 | if (handler == ACPI_DEFAULT_HANDLER) { |
| 809 | flags = ACPI_ADDR_HANDLER_DEFAULT_INSTALLED; |
| 810 | |
| 811 | switch (space_id) { |
| 812 | case ACPI_ADR_SPACE_SYSTEM_MEMORY: |
| 813 | handler = acpi_ex_system_memory_space_handler; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 814 | setup = acpi_ev_system_memory_region_setup; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 815 | break; |
| 816 | |
| 817 | case ACPI_ADR_SPACE_SYSTEM_IO: |
| 818 | handler = acpi_ex_system_io_space_handler; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 819 | setup = acpi_ev_io_space_region_setup; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 820 | break; |
| 821 | |
| 822 | case ACPI_ADR_SPACE_PCI_CONFIG: |
| 823 | handler = acpi_ex_pci_config_space_handler; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 824 | setup = acpi_ev_pci_config_region_setup; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 825 | break; |
| 826 | |
| 827 | case ACPI_ADR_SPACE_CMOS: |
| 828 | handler = acpi_ex_cmos_space_handler; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 829 | setup = acpi_ev_cmos_region_setup; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 830 | break; |
| 831 | |
| 832 | case ACPI_ADR_SPACE_PCI_BAR_TARGET: |
| 833 | handler = acpi_ex_pci_bar_space_handler; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 834 | setup = acpi_ev_pci_bar_region_setup; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 835 | break; |
| 836 | |
| 837 | case ACPI_ADR_SPACE_DATA_TABLE: |
| 838 | handler = acpi_ex_data_table_space_handler; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 839 | setup = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 840 | break; |
| 841 | |
| 842 | default: |
| 843 | status = AE_BAD_PARAMETER; |
| 844 | goto unlock_and_exit; |
| 845 | } |
| 846 | } |
| 847 | |
| 848 | /* If the caller hasn't specified a setup routine, use the default */ |
| 849 | |
| 850 | if (!setup) { |
| 851 | setup = acpi_ev_default_region_setup; |
| 852 | } |
| 853 | |
| 854 | /* Check for an existing internal object */ |
| 855 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 856 | obj_desc = acpi_ns_get_attached_object(node); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 857 | if (obj_desc) { |
| 858 | /* |
| 859 | * The attached device object already exists. |
| 860 | * Make sure the handler is not already installed. |
| 861 | */ |
| 862 | handler_obj = obj_desc->device.handler; |
| 863 | |
| 864 | /* Walk the handler list for this device */ |
| 865 | |
| 866 | while (handler_obj) { |
Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 867 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 868 | /* Same space_id indicates a handler already installed */ |
| 869 | |
| 870 | if (handler_obj->address_space.space_id == space_id) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 871 | if (handler_obj->address_space.handler == |
| 872 | handler) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 873 | /* |
| 874 | * It is (relatively) OK to attempt to install the SAME |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 875 | * handler twice. This can easily happen |
| 876 | * with PCI_Config space. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 877 | */ |
| 878 | status = AE_SAME_HANDLER; |
| 879 | goto unlock_and_exit; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 880 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 881 | /* A handler is already installed */ |
| 882 | |
| 883 | status = AE_ALREADY_EXISTS; |
| 884 | } |
| 885 | goto unlock_and_exit; |
| 886 | } |
| 887 | |
| 888 | /* Walk the linked list of handlers */ |
| 889 | |
| 890 | handler_obj = handler_obj->address_space.next; |
| 891 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 892 | } else { |
| 893 | ACPI_DEBUG_PRINT((ACPI_DB_OPREGION, |
| 894 | "Creating object on Device %p while installing handler\n", |
| 895 | node)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 896 | |
| 897 | /* obj_desc does not exist, create one */ |
| 898 | |
| 899 | if (node->type == ACPI_TYPE_ANY) { |
| 900 | type = ACPI_TYPE_DEVICE; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 901 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 902 | type = node->type; |
| 903 | } |
| 904 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 905 | obj_desc = acpi_ut_create_internal_object(type); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 906 | if (!obj_desc) { |
| 907 | status = AE_NO_MEMORY; |
| 908 | goto unlock_and_exit; |
| 909 | } |
| 910 | |
| 911 | /* Init new descriptor */ |
| 912 | |
| 913 | obj_desc->common.type = (u8) type; |
| 914 | |
| 915 | /* Attach the new object to the Node */ |
| 916 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 917 | status = acpi_ns_attach_object(node, obj_desc, type); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 918 | |
| 919 | /* Remove local reference to the object */ |
| 920 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 921 | acpi_ut_remove_reference(obj_desc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 922 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 923 | if (ACPI_FAILURE(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 924 | goto unlock_and_exit; |
| 925 | } |
| 926 | } |
| 927 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 928 | ACPI_DEBUG_PRINT((ACPI_DB_OPREGION, |
| 929 | "Installing address handler for region %s(%X) on Device %4.4s %p(%p)\n", |
| 930 | acpi_ut_get_region_name(space_id), space_id, |
| 931 | acpi_ut_get_node_name(node), node, obj_desc)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 932 | |
| 933 | /* |
| 934 | * Install the handler |
| 935 | * |
| 936 | * At this point there is no existing handler. |
| 937 | * Just allocate the object for the handler and link it |
| 938 | * into the list. |
| 939 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 940 | handler_obj = |
| 941 | acpi_ut_create_internal_object(ACPI_TYPE_LOCAL_ADDRESS_HANDLER); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 942 | if (!handler_obj) { |
| 943 | status = AE_NO_MEMORY; |
| 944 | goto unlock_and_exit; |
| 945 | } |
| 946 | |
| 947 | /* Init handler obj */ |
| 948 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 949 | handler_obj->address_space.space_id = (u8) space_id; |
Bob Moore | 6168612 | 2006-03-17 16:44:00 -0500 | [diff] [blame] | 950 | handler_obj->address_space.handler_flags = flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 951 | handler_obj->address_space.region_list = NULL; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 952 | handler_obj->address_space.node = node; |
| 953 | handler_obj->address_space.handler = handler; |
| 954 | handler_obj->address_space.context = context; |
| 955 | handler_obj->address_space.setup = setup; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 956 | |
| 957 | /* Install at head of Device.address_space list */ |
| 958 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 959 | handler_obj->address_space.next = obj_desc->device.handler; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 960 | |
| 961 | /* |
| 962 | * The Device object is the first reference on the handler_obj. |
| 963 | * Each region that uses the handler adds a reference. |
| 964 | */ |
| 965 | obj_desc->device.handler = handler_obj; |
| 966 | |
| 967 | /* |
| 968 | * Walk the namespace finding all of the regions this |
| 969 | * handler will manage. |
| 970 | * |
| 971 | * Start at the device and search the branch toward |
| 972 | * the leaf nodes until either the leaf is encountered or |
| 973 | * a device is detected that has an address handler of the |
| 974 | * same type. |
| 975 | * |
| 976 | * In either case, back up and search down the remainder |
| 977 | * of the branch |
| 978 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 979 | status = acpi_ns_walk_namespace(ACPI_TYPE_ANY, node, ACPI_UINT32_MAX, |
| 980 | ACPI_NS_WALK_UNLOCK, |
| 981 | acpi_ev_install_handler, handler_obj, |
| 982 | NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 983 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 984 | unlock_and_exit: |
| 985 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 986 | } |
| 987 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 988 | /******************************************************************************* |
| 989 | * |
| 990 | * FUNCTION: acpi_ev_execute_reg_methods |
| 991 | * |
| 992 | * PARAMETERS: Node - Namespace node for the device |
| 993 | * space_id - The address space ID |
| 994 | * |
| 995 | * RETURN: Status |
| 996 | * |
| 997 | * DESCRIPTION: Run all _REG methods for the input Space ID; |
| 998 | * Note: assumes namespace is locked, or system init time. |
| 999 | * |
| 1000 | ******************************************************************************/ |
| 1001 | |
| 1002 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1003 | acpi_ev_execute_reg_methods(struct acpi_namespace_node *node, |
| 1004 | acpi_adr_space_type space_id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1005 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1006 | acpi_status status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1007 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 1008 | ACPI_FUNCTION_TRACE(ev_execute_reg_methods); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1009 | |
| 1010 | /* |
| 1011 | * Run all _REG methods for all Operation Regions for this |
| 1012 | * space ID. This is a separate walk in order to handle any |
| 1013 | * interdependencies between regions and _REG methods. (i.e. handlers |
| 1014 | * must be installed for all regions of this Space ID before we |
| 1015 | * can run any _REG methods) |
| 1016 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1017 | status = acpi_ns_walk_namespace(ACPI_TYPE_ANY, node, ACPI_UINT32_MAX, |
| 1018 | ACPI_NS_WALK_UNLOCK, acpi_ev_reg_run, |
| 1019 | &space_id, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1020 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1021 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1022 | } |
| 1023 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1024 | /******************************************************************************* |
| 1025 | * |
| 1026 | * FUNCTION: acpi_ev_reg_run |
| 1027 | * |
| 1028 | * PARAMETERS: walk_namespace callback |
| 1029 | * |
Bob Moore | 958dd24 | 2006-05-12 17:12:00 -0400 | [diff] [blame] | 1030 | * DESCRIPTION: Run _REG method for region objects of the requested space_iD |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1031 | * |
| 1032 | ******************************************************************************/ |
| 1033 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 1034 | static acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1035 | acpi_ev_reg_run(acpi_handle obj_handle, |
| 1036 | u32 level, void *context, void **return_value) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1037 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1038 | union acpi_operand_object *obj_desc; |
| 1039 | struct acpi_namespace_node *node; |
| 1040 | acpi_adr_space_type space_id; |
| 1041 | acpi_status status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1042 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1043 | space_id = *ACPI_CAST_PTR(acpi_adr_space_type, context); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1044 | |
| 1045 | /* Convert and validate the device handle */ |
| 1046 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1047 | node = acpi_ns_map_handle_to_node(obj_handle); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1048 | if (!node) { |
| 1049 | return (AE_BAD_PARAMETER); |
| 1050 | } |
| 1051 | |
| 1052 | /* |
| 1053 | * We only care about regions.and objects |
| 1054 | * that are allowed to have address space handlers |
| 1055 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1056 | if ((node->type != ACPI_TYPE_REGION) && (node != acpi_gbl_root_node)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1057 | return (AE_OK); |
| 1058 | } |
| 1059 | |
| 1060 | /* Check for an existing internal object */ |
| 1061 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1062 | obj_desc = acpi_ns_get_attached_object(node); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1063 | if (!obj_desc) { |
Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 1064 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1065 | /* No object, just exit */ |
| 1066 | |
| 1067 | return (AE_OK); |
| 1068 | } |
| 1069 | |
| 1070 | /* Object is a Region */ |
| 1071 | |
| 1072 | if (obj_desc->region.space_id != space_id) { |
| 1073 | /* |
| 1074 | * This region is for a different address space |
| 1075 | * -- just ignore it |
| 1076 | */ |
| 1077 | return (AE_OK); |
| 1078 | } |
| 1079 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1080 | status = acpi_ev_execute_reg_method(obj_desc, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1081 | return (status); |
| 1082 | } |