Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | |
| 2 | /****************************************************************************** |
| 3 | * |
| 4 | * Module Name: exresolv - AML Interpreter object resolution |
| 5 | * |
| 6 | *****************************************************************************/ |
| 7 | |
| 8 | /* |
| 9 | * Copyright (C) 2000 - 2005, R. Byron Moore |
| 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 | |
| 45 | |
| 46 | #include <acpi/acpi.h> |
| 47 | #include <acpi/amlcode.h> |
| 48 | #include <acpi/acdispat.h> |
| 49 | #include <acpi/acinterp.h> |
| 50 | #include <acpi/acnamesp.h> |
| 51 | #include <acpi/acparser.h> |
| 52 | |
| 53 | |
| 54 | #define _COMPONENT ACPI_EXECUTER |
| 55 | ACPI_MODULE_NAME ("exresolv") |
| 56 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame^] | 57 | /* Local prototypes */ |
| 58 | |
| 59 | static acpi_status |
| 60 | acpi_ex_resolve_object_to_value ( |
| 61 | union acpi_operand_object **stack_ptr, |
| 62 | struct acpi_walk_state *walk_state); |
| 63 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | |
| 65 | /******************************************************************************* |
| 66 | * |
| 67 | * FUNCTION: acpi_ex_resolve_to_value |
| 68 | * |
| 69 | * PARAMETERS: **stack_ptr - Points to entry on obj_stack, which can |
| 70 | * be either an (union acpi_operand_object *) |
| 71 | * or an acpi_handle. |
| 72 | * walk_state - Current method state |
| 73 | * |
| 74 | * RETURN: Status |
| 75 | * |
| 76 | * DESCRIPTION: Convert Reference objects to values |
| 77 | * |
| 78 | ******************************************************************************/ |
| 79 | |
| 80 | acpi_status |
| 81 | acpi_ex_resolve_to_value ( |
| 82 | union acpi_operand_object **stack_ptr, |
| 83 | struct acpi_walk_state *walk_state) |
| 84 | { |
| 85 | acpi_status status; |
| 86 | |
| 87 | |
| 88 | ACPI_FUNCTION_TRACE_PTR ("ex_resolve_to_value", stack_ptr); |
| 89 | |
| 90 | |
| 91 | if (!stack_ptr || !*stack_ptr) { |
| 92 | ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Internal - null pointer\n")); |
| 93 | return_ACPI_STATUS (AE_AML_NO_OPERAND); |
| 94 | } |
| 95 | |
| 96 | /* |
| 97 | * The entity pointed to by the stack_ptr can be either |
| 98 | * 1) A valid union acpi_operand_object, or |
| 99 | * 2) A struct acpi_namespace_node (named_obj) |
| 100 | */ |
| 101 | if (ACPI_GET_DESCRIPTOR_TYPE (*stack_ptr) == ACPI_DESC_TYPE_OPERAND) { |
| 102 | status = acpi_ex_resolve_object_to_value (stack_ptr, walk_state); |
| 103 | if (ACPI_FAILURE (status)) { |
| 104 | return_ACPI_STATUS (status); |
| 105 | } |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame^] | 106 | |
| 107 | if (!*stack_ptr) { |
| 108 | ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Internal - null pointer\n")); |
| 109 | return_ACPI_STATUS (AE_AML_NO_OPERAND); |
| 110 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 111 | } |
| 112 | |
| 113 | /* |
| 114 | * Object on the stack may have changed if acpi_ex_resolve_object_to_value() |
| 115 | * was called (i.e., we can't use an _else_ here.) |
| 116 | */ |
| 117 | if (ACPI_GET_DESCRIPTOR_TYPE (*stack_ptr) == ACPI_DESC_TYPE_NAMED) { |
| 118 | status = acpi_ex_resolve_node_to_value ( |
| 119 | ACPI_CAST_INDIRECT_PTR (struct acpi_namespace_node, stack_ptr), |
| 120 | walk_state); |
| 121 | if (ACPI_FAILURE (status)) { |
| 122 | return_ACPI_STATUS (status); |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Resolved object %p\n", *stack_ptr)); |
| 127 | return_ACPI_STATUS (AE_OK); |
| 128 | } |
| 129 | |
| 130 | |
| 131 | /******************************************************************************* |
| 132 | * |
| 133 | * FUNCTION: acpi_ex_resolve_object_to_value |
| 134 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame^] | 135 | * PARAMETERS: stack_ptr - Pointer to an internal object |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | * walk_state - Current method state |
| 137 | * |
| 138 | * RETURN: Status |
| 139 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame^] | 140 | * DESCRIPTION: Retrieve the value from an internal object. The Reference type |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 141 | * uses the associated AML opcode to determine the value. |
| 142 | * |
| 143 | ******************************************************************************/ |
| 144 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame^] | 145 | static acpi_status |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | acpi_ex_resolve_object_to_value ( |
| 147 | union acpi_operand_object **stack_ptr, |
| 148 | struct acpi_walk_state *walk_state) |
| 149 | { |
| 150 | acpi_status status = AE_OK; |
| 151 | union acpi_operand_object *stack_desc; |
| 152 | void *temp_node; |
| 153 | union acpi_operand_object *obj_desc; |
| 154 | u16 opcode; |
| 155 | |
| 156 | |
| 157 | ACPI_FUNCTION_TRACE ("ex_resolve_object_to_value"); |
| 158 | |
| 159 | |
| 160 | stack_desc = *stack_ptr; |
| 161 | |
| 162 | /* This is an union acpi_operand_object */ |
| 163 | |
| 164 | switch (ACPI_GET_OBJECT_TYPE (stack_desc)) { |
| 165 | case ACPI_TYPE_LOCAL_REFERENCE: |
| 166 | |
| 167 | opcode = stack_desc->reference.opcode; |
| 168 | |
| 169 | switch (opcode) { |
| 170 | case AML_NAME_OP: |
| 171 | |
| 172 | /* |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame^] | 173 | * Convert name reference to a namespace node |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 174 | * Then, acpi_ex_resolve_node_to_value can be used to get the value |
| 175 | */ |
| 176 | temp_node = stack_desc->reference.object; |
| 177 | |
| 178 | /* Delete the Reference Object */ |
| 179 | |
| 180 | acpi_ut_remove_reference (stack_desc); |
| 181 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame^] | 182 | /* Return the namespace node */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 | |
| 184 | (*stack_ptr) = temp_node; |
| 185 | break; |
| 186 | |
| 187 | |
| 188 | case AML_LOCAL_OP: |
| 189 | case AML_ARG_OP: |
| 190 | |
| 191 | /* |
| 192 | * Get the local from the method's state info |
| 193 | * Note: this increments the local's object reference count |
| 194 | */ |
| 195 | status = acpi_ds_method_data_get_value (opcode, |
| 196 | stack_desc->reference.offset, walk_state, &obj_desc); |
| 197 | if (ACPI_FAILURE (status)) { |
| 198 | return_ACPI_STATUS (status); |
| 199 | } |
| 200 | |
| 201 | ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Arg/Local %X] value_obj is %p\n", |
| 202 | stack_desc->reference.offset, obj_desc)); |
| 203 | |
| 204 | /* |
| 205 | * Now we can delete the original Reference Object and |
| 206 | * replace it with the resolved value |
| 207 | */ |
| 208 | acpi_ut_remove_reference (stack_desc); |
| 209 | *stack_ptr = obj_desc; |
| 210 | break; |
| 211 | |
| 212 | |
| 213 | case AML_INDEX_OP: |
| 214 | |
| 215 | switch (stack_desc->reference.target_type) { |
| 216 | case ACPI_TYPE_BUFFER_FIELD: |
| 217 | |
| 218 | /* Just return - leave the Reference on the stack */ |
| 219 | break; |
| 220 | |
| 221 | |
| 222 | case ACPI_TYPE_PACKAGE: |
| 223 | |
| 224 | obj_desc = *stack_desc->reference.where; |
| 225 | if (obj_desc) { |
| 226 | /* |
| 227 | * Valid obj descriptor, copy pointer to return value |
| 228 | * (i.e., dereference the package index) |
| 229 | * Delete the ref object, increment the returned object |
| 230 | */ |
| 231 | acpi_ut_remove_reference (stack_desc); |
| 232 | acpi_ut_add_reference (obj_desc); |
| 233 | *stack_ptr = obj_desc; |
| 234 | } |
| 235 | else { |
| 236 | /* |
| 237 | * A NULL object descriptor means an unitialized element of |
| 238 | * the package, can't dereference it |
| 239 | */ |
| 240 | ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, |
| 241 | "Attempt to deref an Index to NULL pkg element Idx=%p\n", |
| 242 | stack_desc)); |
| 243 | status = AE_AML_UNINITIALIZED_ELEMENT; |
| 244 | } |
| 245 | break; |
| 246 | |
| 247 | |
| 248 | default: |
| 249 | |
| 250 | /* Invalid reference object */ |
| 251 | |
| 252 | ACPI_REPORT_ERROR (( |
| 253 | "During resolve, Unknown target_type %X in Index/Reference obj %p\n", |
| 254 | stack_desc->reference.target_type, stack_desc)); |
| 255 | status = AE_AML_INTERNAL; |
| 256 | break; |
| 257 | } |
| 258 | break; |
| 259 | |
| 260 | |
| 261 | case AML_REF_OF_OP: |
| 262 | case AML_DEBUG_OP: |
| 263 | case AML_LOAD_OP: |
| 264 | |
| 265 | /* Just leave the object as-is */ |
| 266 | |
| 267 | break; |
| 268 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame^] | 269 | case AML_INT_NAMEPATH_OP: /* Reference to a named object */ |
| 270 | |
| 271 | /* Get the object pointed to by the namespace node */ |
| 272 | |
| 273 | *stack_ptr = (stack_desc->reference.node)->object; |
| 274 | acpi_ut_add_reference (*stack_ptr); |
| 275 | acpi_ut_remove_reference (stack_desc); |
| 276 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 277 | |
| 278 | default: |
| 279 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame^] | 280 | ACPI_REPORT_ERROR (( |
| 281 | "During resolve, Unknown Reference opcode %X (%s) in %p\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 282 | opcode, acpi_ps_get_opcode_name (opcode), stack_desc)); |
| 283 | status = AE_AML_INTERNAL; |
| 284 | break; |
| 285 | } |
| 286 | break; |
| 287 | |
| 288 | |
| 289 | case ACPI_TYPE_BUFFER: |
| 290 | |
| 291 | status = acpi_ds_get_buffer_arguments (stack_desc); |
| 292 | break; |
| 293 | |
| 294 | |
| 295 | case ACPI_TYPE_PACKAGE: |
| 296 | |
| 297 | status = acpi_ds_get_package_arguments (stack_desc); |
| 298 | break; |
| 299 | |
| 300 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame^] | 301 | /* These cases may never happen here, but just in case.. */ |
| 302 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 303 | case ACPI_TYPE_BUFFER_FIELD: |
| 304 | case ACPI_TYPE_LOCAL_REGION_FIELD: |
| 305 | case ACPI_TYPE_LOCAL_BANK_FIELD: |
| 306 | case ACPI_TYPE_LOCAL_INDEX_FIELD: |
| 307 | |
| 308 | ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "field_read source_desc=%p Type=%X\n", |
| 309 | stack_desc, ACPI_GET_OBJECT_TYPE (stack_desc))); |
| 310 | |
| 311 | status = acpi_ex_read_data_from_field (walk_state, stack_desc, &obj_desc); |
| 312 | *stack_ptr = (void *) obj_desc; |
| 313 | break; |
| 314 | |
| 315 | default: |
| 316 | break; |
| 317 | } |
| 318 | |
| 319 | return_ACPI_STATUS (status); |
| 320 | } |
| 321 | |
| 322 | |
| 323 | /******************************************************************************* |
| 324 | * |
| 325 | * FUNCTION: acpi_ex_resolve_multiple |
| 326 | * |
| 327 | * PARAMETERS: walk_state - Current state (contains AML opcode) |
| 328 | * Operand - Starting point for resolution |
| 329 | * return_type - Where the object type is returned |
| 330 | * return_desc - Where the resolved object is returned |
| 331 | * |
| 332 | * RETURN: Status |
| 333 | * |
| 334 | * DESCRIPTION: Return the base object and type. Traverse a reference list if |
| 335 | * necessary to get to the base object. |
| 336 | * |
| 337 | ******************************************************************************/ |
| 338 | |
| 339 | acpi_status |
| 340 | acpi_ex_resolve_multiple ( |
| 341 | struct acpi_walk_state *walk_state, |
| 342 | union acpi_operand_object *operand, |
| 343 | acpi_object_type *return_type, |
| 344 | union acpi_operand_object **return_desc) |
| 345 | { |
| 346 | union acpi_operand_object *obj_desc = (void *) operand; |
| 347 | struct acpi_namespace_node *node; |
| 348 | acpi_object_type type; |
| 349 | acpi_status status; |
| 350 | |
| 351 | |
| 352 | ACPI_FUNCTION_TRACE ("acpi_ex_resolve_multiple"); |
| 353 | |
| 354 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame^] | 355 | /* Operand can be either a namespace node or an operand descriptor */ |
| 356 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 357 | switch (ACPI_GET_DESCRIPTOR_TYPE (obj_desc)) { |
| 358 | case ACPI_DESC_TYPE_OPERAND: |
| 359 | type = obj_desc->common.type; |
| 360 | break; |
| 361 | |
| 362 | case ACPI_DESC_TYPE_NAMED: |
| 363 | type = ((struct acpi_namespace_node *) obj_desc)->type; |
| 364 | obj_desc = acpi_ns_get_attached_object ((struct acpi_namespace_node *) obj_desc); |
| 365 | |
| 366 | /* If we had an Alias node, use the attached object for type info */ |
| 367 | |
| 368 | if (type == ACPI_TYPE_LOCAL_ALIAS) { |
| 369 | type = ((struct acpi_namespace_node *) obj_desc)->type; |
| 370 | obj_desc = acpi_ns_get_attached_object ((struct acpi_namespace_node *) obj_desc); |
| 371 | } |
| 372 | break; |
| 373 | |
| 374 | default: |
| 375 | return_ACPI_STATUS (AE_AML_OPERAND_TYPE); |
| 376 | } |
| 377 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame^] | 378 | /* If type is anything other than a reference, we are done */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 379 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 380 | if (type != ACPI_TYPE_LOCAL_REFERENCE) { |
| 381 | goto exit; |
| 382 | } |
| 383 | |
| 384 | /* |
| 385 | * For reference objects created via the ref_of or Index operators, |
| 386 | * we need to get to the base object (as per the ACPI specification |
| 387 | * of the object_type and size_of operators). This means traversing |
| 388 | * the list of possibly many nested references. |
| 389 | */ |
| 390 | while (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_LOCAL_REFERENCE) { |
| 391 | switch (obj_desc->reference.opcode) { |
| 392 | case AML_REF_OF_OP: |
| 393 | |
| 394 | /* Dereference the reference pointer */ |
| 395 | |
| 396 | node = obj_desc->reference.object; |
| 397 | |
| 398 | /* All "References" point to a NS node */ |
| 399 | |
| 400 | if (ACPI_GET_DESCRIPTOR_TYPE (node) != ACPI_DESC_TYPE_NAMED) { |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame^] | 401 | ACPI_REPORT_ERROR (( |
| 402 | "acpi_ex_resolve_multiple: Not a NS node %p [%s]\n", |
| 403 | node, acpi_ut_get_descriptor_name (node))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 404 | return_ACPI_STATUS (AE_AML_INTERNAL); |
| 405 | } |
| 406 | |
| 407 | /* Get the attached object */ |
| 408 | |
| 409 | obj_desc = acpi_ns_get_attached_object (node); |
| 410 | if (!obj_desc) { |
| 411 | /* No object, use the NS node type */ |
| 412 | |
| 413 | type = acpi_ns_get_type (node); |
| 414 | goto exit; |
| 415 | } |
| 416 | |
| 417 | /* Check for circular references */ |
| 418 | |
| 419 | if (obj_desc == operand) { |
| 420 | return_ACPI_STATUS (AE_AML_CIRCULAR_REFERENCE); |
| 421 | } |
| 422 | break; |
| 423 | |
| 424 | |
| 425 | case AML_INDEX_OP: |
| 426 | |
| 427 | /* Get the type of this reference (index into another object) */ |
| 428 | |
| 429 | type = obj_desc->reference.target_type; |
| 430 | if (type != ACPI_TYPE_PACKAGE) { |
| 431 | goto exit; |
| 432 | } |
| 433 | |
| 434 | /* |
| 435 | * The main object is a package, we want to get the type |
| 436 | * of the individual package element that is referenced by |
| 437 | * the index. |
| 438 | * |
| 439 | * This could of course in turn be another reference object. |
| 440 | */ |
| 441 | obj_desc = *(obj_desc->reference.where); |
| 442 | if (!obj_desc) { |
| 443 | /* NULL package elements are allowed */ |
| 444 | |
| 445 | type = 0; /* Uninitialized */ |
| 446 | goto exit; |
| 447 | } |
| 448 | break; |
| 449 | |
| 450 | |
| 451 | case AML_INT_NAMEPATH_OP: |
| 452 | |
| 453 | /* Dereference the reference pointer */ |
| 454 | |
| 455 | node = obj_desc->reference.node; |
| 456 | |
| 457 | /* All "References" point to a NS node */ |
| 458 | |
| 459 | if (ACPI_GET_DESCRIPTOR_TYPE (node) != ACPI_DESC_TYPE_NAMED) { |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame^] | 460 | ACPI_REPORT_ERROR (( |
| 461 | "acpi_ex_resolve_multiple: Not a NS node %p [%s]\n", |
| 462 | node, acpi_ut_get_descriptor_name (node))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 463 | return_ACPI_STATUS (AE_AML_INTERNAL); |
| 464 | } |
| 465 | |
| 466 | /* Get the attached object */ |
| 467 | |
| 468 | obj_desc = acpi_ns_get_attached_object (node); |
| 469 | if (!obj_desc) { |
| 470 | /* No object, use the NS node type */ |
| 471 | |
| 472 | type = acpi_ns_get_type (node); |
| 473 | goto exit; |
| 474 | } |
| 475 | |
| 476 | /* Check for circular references */ |
| 477 | |
| 478 | if (obj_desc == operand) { |
| 479 | return_ACPI_STATUS (AE_AML_CIRCULAR_REFERENCE); |
| 480 | } |
| 481 | break; |
| 482 | |
| 483 | |
| 484 | case AML_LOCAL_OP: |
| 485 | case AML_ARG_OP: |
| 486 | |
| 487 | if (return_desc) { |
| 488 | status = acpi_ds_method_data_get_value (obj_desc->reference.opcode, |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame^] | 489 | obj_desc->reference.offset, walk_state, &obj_desc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 490 | if (ACPI_FAILURE (status)) { |
| 491 | return_ACPI_STATUS (status); |
| 492 | } |
| 493 | acpi_ut_remove_reference (obj_desc); |
| 494 | } |
| 495 | else { |
| 496 | status = acpi_ds_method_data_get_node (obj_desc->reference.opcode, |
| 497 | obj_desc->reference.offset, walk_state, &node); |
| 498 | if (ACPI_FAILURE (status)) { |
| 499 | return_ACPI_STATUS (status); |
| 500 | } |
| 501 | |
| 502 | obj_desc = acpi_ns_get_attached_object (node); |
| 503 | if (!obj_desc) { |
| 504 | type = ACPI_TYPE_ANY; |
| 505 | goto exit; |
| 506 | } |
| 507 | } |
| 508 | break; |
| 509 | |
| 510 | |
| 511 | case AML_DEBUG_OP: |
| 512 | |
| 513 | /* The Debug Object is of type "debug_object" */ |
| 514 | |
| 515 | type = ACPI_TYPE_DEBUG_OBJECT; |
| 516 | goto exit; |
| 517 | |
| 518 | |
| 519 | default: |
| 520 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame^] | 521 | ACPI_REPORT_ERROR (( |
| 522 | "acpi_ex_resolve_multiple: Unknown Reference subtype %X\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 523 | obj_desc->reference.opcode)); |
| 524 | return_ACPI_STATUS (AE_AML_INTERNAL); |
| 525 | } |
| 526 | } |
| 527 | |
| 528 | /* |
| 529 | * Now we are guaranteed to have an object that has not been created |
| 530 | * via the ref_of or Index operators. |
| 531 | */ |
| 532 | type = ACPI_GET_OBJECT_TYPE (obj_desc); |
| 533 | |
| 534 | |
| 535 | exit: |
| 536 | /* Convert internal types to external types */ |
| 537 | |
| 538 | switch (type) { |
| 539 | case ACPI_TYPE_LOCAL_REGION_FIELD: |
| 540 | case ACPI_TYPE_LOCAL_BANK_FIELD: |
| 541 | case ACPI_TYPE_LOCAL_INDEX_FIELD: |
| 542 | |
| 543 | type = ACPI_TYPE_FIELD_UNIT; |
| 544 | break; |
| 545 | |
| 546 | case ACPI_TYPE_LOCAL_SCOPE: |
| 547 | |
| 548 | /* Per ACPI Specification, Scope is untyped */ |
| 549 | |
| 550 | type = ACPI_TYPE_ANY; |
| 551 | break; |
| 552 | |
| 553 | default: |
| 554 | /* No change to Type required */ |
| 555 | break; |
| 556 | } |
| 557 | |
| 558 | *return_type = type; |
| 559 | if (return_desc) { |
| 560 | *return_desc = obj_desc; |
| 561 | } |
| 562 | return_ACPI_STATUS (AE_OK); |
| 563 | } |
| 564 | |
| 565 | |