diff options
Diffstat (limited to 'drivers/acpi/dispatcher/dsmthdat.c')
| -rw-r--r-- | drivers/acpi/dispatcher/dsmthdat.c | 195 |
1 files changed, 115 insertions, 80 deletions
diff --git a/drivers/acpi/dispatcher/dsmthdat.c b/drivers/acpi/dispatcher/dsmthdat.c index f31d095f9833..f7998306f756 100644 --- a/drivers/acpi/dispatcher/dsmthdat.c +++ b/drivers/acpi/dispatcher/dsmthdat.c | |||
| @@ -52,6 +52,29 @@ | |||
| 52 | #define _COMPONENT ACPI_DISPATCHER | 52 | #define _COMPONENT ACPI_DISPATCHER |
| 53 | ACPI_MODULE_NAME ("dsmthdat") | 53 | ACPI_MODULE_NAME ("dsmthdat") |
| 54 | 54 | ||
| 55 | /* Local prototypes */ | ||
| 56 | |||
| 57 | static void | ||
| 58 | acpi_ds_method_data_delete_value ( | ||
| 59 | u16 opcode, | ||
| 60 | u32 index, | ||
| 61 | struct acpi_walk_state *walk_state); | ||
| 62 | |||
| 63 | static acpi_status | ||
| 64 | acpi_ds_method_data_set_value ( | ||
| 65 | u16 opcode, | ||
| 66 | u32 index, | ||
| 67 | union acpi_operand_object *object, | ||
| 68 | struct acpi_walk_state *walk_state); | ||
| 69 | |||
| 70 | #ifdef ACPI_OBSOLETE_FUNCTIONS | ||
| 71 | acpi_object_type | ||
| 72 | acpi_ds_method_data_get_type ( | ||
| 73 | u16 opcode, | ||
| 74 | u32 index, | ||
| 75 | struct acpi_walk_state *walk_state); | ||
| 76 | #endif | ||
| 77 | |||
| 55 | 78 | ||
| 56 | /******************************************************************************* | 79 | /******************************************************************************* |
| 57 | * | 80 | * |
| @@ -62,8 +85,8 @@ | |||
| 62 | * RETURN: Status | 85 | * RETURN: Status |
| 63 | * | 86 | * |
| 64 | * DESCRIPTION: Initialize the data structures that hold the method's arguments | 87 | * DESCRIPTION: Initialize the data structures that hold the method's arguments |
| 65 | * and locals. The data struct is an array of NTEs for each. | 88 | * and locals. The data struct is an array of namespace nodes for |
| 66 | * This allows ref_of and de_ref_of to work properly for these | 89 | * each - this allows ref_of and de_ref_of to work properly for these |
| 67 | * special data types. | 90 | * special data types. |
| 68 | * | 91 | * |
| 69 | * NOTES: walk_state fields are initialized to zero by the | 92 | * NOTES: walk_state fields are initialized to zero by the |
| @@ -92,7 +115,8 @@ acpi_ds_method_data_init ( | |||
| 92 | walk_state->arguments[i].name.integer |= (i << 24); | 115 | walk_state->arguments[i].name.integer |= (i << 24); |
| 93 | walk_state->arguments[i].descriptor = ACPI_DESC_TYPE_NAMED; | 116 | walk_state->arguments[i].descriptor = ACPI_DESC_TYPE_NAMED; |
| 94 | walk_state->arguments[i].type = ACPI_TYPE_ANY; | 117 | walk_state->arguments[i].type = ACPI_TYPE_ANY; |
| 95 | walk_state->arguments[i].flags = ANOBJ_END_OF_PEER_LIST | ANOBJ_METHOD_ARG; | 118 | walk_state->arguments[i].flags = ANOBJ_END_OF_PEER_LIST | |
| 119 | ANOBJ_METHOD_ARG; | ||
| 96 | } | 120 | } |
| 97 | 121 | ||
| 98 | /* Init the method locals */ | 122 | /* Init the method locals */ |
| @@ -104,7 +128,8 @@ acpi_ds_method_data_init ( | |||
| 104 | walk_state->local_variables[i].name.integer |= (i << 24); | 128 | walk_state->local_variables[i].name.integer |= (i << 24); |
| 105 | walk_state->local_variables[i].descriptor = ACPI_DESC_TYPE_NAMED; | 129 | walk_state->local_variables[i].descriptor = ACPI_DESC_TYPE_NAMED; |
| 106 | walk_state->local_variables[i].type = ACPI_TYPE_ANY; | 130 | walk_state->local_variables[i].type = ACPI_TYPE_ANY; |
| 107 | walk_state->local_variables[i].flags = ANOBJ_END_OF_PEER_LIST | ANOBJ_METHOD_LOCAL; | 131 | walk_state->local_variables[i].flags = ANOBJ_END_OF_PEER_LIST | |
| 132 | ANOBJ_METHOD_LOCAL; | ||
| 108 | } | 133 | } |
| 109 | 134 | ||
| 110 | return_VOID; | 135 | return_VOID; |
| @@ -198,15 +223,18 @@ acpi_ds_method_data_init_args ( | |||
| 198 | return_ACPI_STATUS (AE_OK); | 223 | return_ACPI_STATUS (AE_OK); |
| 199 | } | 224 | } |
| 200 | 225 | ||
| 201 | /* Copy passed parameters into the new method stack frame */ | 226 | /* Copy passed parameters into the new method stack frame */ |
| 202 | 227 | ||
| 203 | while ((index < ACPI_METHOD_NUM_ARGS) && (index < max_param_count) && params[index]) { | 228 | while ((index < ACPI_METHOD_NUM_ARGS) && |
| 229 | (index < max_param_count) && | ||
| 230 | params[index]) { | ||
| 204 | /* | 231 | /* |
| 205 | * A valid parameter. | 232 | * A valid parameter. |
| 206 | * Store the argument in the method/walk descriptor. | 233 | * Store the argument in the method/walk descriptor. |
| 207 | * Do not copy the arg in order to implement call by reference | 234 | * Do not copy the arg in order to implement call by reference |
| 208 | */ | 235 | */ |
| 209 | status = acpi_ds_method_data_set_value (AML_ARG_OP, index, params[index], walk_state); | 236 | status = acpi_ds_method_data_set_value (AML_ARG_OP, index, |
| 237 | params[index], walk_state); | ||
| 210 | if (ACPI_FAILURE (status)) { | 238 | if (ACPI_FAILURE (status)) { |
| 211 | return_ACPI_STATUS (status); | 239 | return_ACPI_STATUS (status); |
| 212 | } | 240 | } |
| @@ -224,11 +252,13 @@ acpi_ds_method_data_init_args ( | |||
| 224 | * FUNCTION: acpi_ds_method_data_get_node | 252 | * FUNCTION: acpi_ds_method_data_get_node |
| 225 | * | 253 | * |
| 226 | * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP | 254 | * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP |
| 227 | * Index - which local_var or argument whose type | 255 | * Index - Which Local or Arg whose type to get |
| 228 | * to get | ||
| 229 | * walk_state - Current walk state object | 256 | * walk_state - Current walk state object |
| 257 | * Node - Where the node is returned. | ||
| 230 | * | 258 | * |
| 231 | * RETURN: Get the Node associated with a local or arg. | 259 | * RETURN: Status and node |
| 260 | * | ||
| 261 | * DESCRIPTION: Get the Node associated with a local or arg. | ||
| 232 | * | 262 | * |
| 233 | ******************************************************************************/ | 263 | ******************************************************************************/ |
| 234 | 264 | ||
| @@ -249,7 +279,8 @@ acpi_ds_method_data_get_node ( | |||
| 249 | case AML_LOCAL_OP: | 279 | case AML_LOCAL_OP: |
| 250 | 280 | ||
| 251 | if (index > ACPI_METHOD_MAX_LOCAL) { | 281 | if (index > ACPI_METHOD_MAX_LOCAL) { |
| 252 | ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Local index %d is invalid (max %d)\n", | 282 | ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, |
| 283 | "Local index %d is invalid (max %d)\n", | ||
| 253 | index, ACPI_METHOD_MAX_LOCAL)); | 284 | index, ACPI_METHOD_MAX_LOCAL)); |
| 254 | return_ACPI_STATUS (AE_AML_INVALID_INDEX); | 285 | return_ACPI_STATUS (AE_AML_INVALID_INDEX); |
| 255 | } | 286 | } |
| @@ -262,7 +293,8 @@ acpi_ds_method_data_get_node ( | |||
| 262 | case AML_ARG_OP: | 293 | case AML_ARG_OP: |
| 263 | 294 | ||
| 264 | if (index > ACPI_METHOD_MAX_ARG) { | 295 | if (index > ACPI_METHOD_MAX_ARG) { |
| 265 | ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Arg index %d is invalid (max %d)\n", | 296 | ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, |
| 297 | "Arg index %d is invalid (max %d)\n", | ||
| 266 | index, ACPI_METHOD_MAX_ARG)); | 298 | index, ACPI_METHOD_MAX_ARG)); |
| 267 | return_ACPI_STATUS (AE_AML_INVALID_INDEX); | 299 | return_ACPI_STATUS (AE_AML_INVALID_INDEX); |
| 268 | } | 300 | } |
| @@ -286,7 +318,7 @@ acpi_ds_method_data_get_node ( | |||
| 286 | * FUNCTION: acpi_ds_method_data_set_value | 318 | * FUNCTION: acpi_ds_method_data_set_value |
| 287 | * | 319 | * |
| 288 | * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP | 320 | * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP |
| 289 | * Index - which local_var or argument to get | 321 | * Index - Which Local or Arg to get |
| 290 | * Object - Object to be inserted into the stack entry | 322 | * Object - Object to be inserted into the stack entry |
| 291 | * walk_state - Current walk state object | 323 | * walk_state - Current walk state object |
| 292 | * | 324 | * |
| @@ -297,7 +329,7 @@ acpi_ds_method_data_get_node ( | |||
| 297 | * | 329 | * |
| 298 | ******************************************************************************/ | 330 | ******************************************************************************/ |
| 299 | 331 | ||
| 300 | acpi_status | 332 | static acpi_status |
| 301 | acpi_ds_method_data_set_value ( | 333 | acpi_ds_method_data_set_value ( |
| 302 | u16 opcode, | 334 | u16 opcode, |
| 303 | u32 index, | 335 | u32 index, |
| @@ -340,68 +372,16 @@ acpi_ds_method_data_set_value ( | |||
| 340 | 372 | ||
| 341 | /******************************************************************************* | 373 | /******************************************************************************* |
| 342 | * | 374 | * |
| 343 | * FUNCTION: acpi_ds_method_data_get_type | ||
| 344 | * | ||
| 345 | * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP | ||
| 346 | * Index - which local_var or argument whose type | ||
| 347 | * to get | ||
| 348 | * walk_state - Current walk state object | ||
| 349 | * | ||
| 350 | * RETURN: Data type of current value of the selected Arg or Local | ||
| 351 | * | ||
| 352 | ******************************************************************************/ | ||
| 353 | #ifdef ACPI_FUTURE_USAGE | ||
| 354 | acpi_object_type | ||
| 355 | acpi_ds_method_data_get_type ( | ||
| 356 | u16 opcode, | ||
| 357 | u32 index, | ||
| 358 | struct acpi_walk_state *walk_state) | ||
| 359 | { | ||
| 360 | acpi_status status; | ||
| 361 | struct acpi_namespace_node *node; | ||
| 362 | union acpi_operand_object *object; | ||
| 363 | |||
| 364 | |||
| 365 | ACPI_FUNCTION_TRACE ("ds_method_data_get_type"); | ||
| 366 | |||
| 367 | |||
| 368 | /* Get the namespace node for the arg/local */ | ||
| 369 | |||
| 370 | status = acpi_ds_method_data_get_node (opcode, index, walk_state, &node); | ||
| 371 | if (ACPI_FAILURE (status)) { | ||
| 372 | return_VALUE ((ACPI_TYPE_NOT_FOUND)); | ||
| 373 | } | ||
| 374 | |||
| 375 | /* Get the object */ | ||
| 376 | |||
| 377 | object = acpi_ns_get_attached_object (node); | ||
| 378 | if (!object) { | ||
| 379 | /* Uninitialized local/arg, return TYPE_ANY */ | ||
| 380 | |||
| 381 | return_VALUE (ACPI_TYPE_ANY); | ||
| 382 | } | ||
| 383 | |||
| 384 | /* Get the object type */ | ||
| 385 | |||
| 386 | return_VALUE (ACPI_GET_OBJECT_TYPE (object)); | ||
| 387 | } | ||
| 388 | #endif /* ACPI_FUTURE_USAGE */ | ||
| 389 | |||
| 390 | |||
| 391 | /******************************************************************************* | ||
| 392 | * | ||
| 393 | * FUNCTION: acpi_ds_method_data_get_value | 375 | * FUNCTION: acpi_ds_method_data_get_value |
| 394 | * | 376 | * |
| 395 | * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP | 377 | * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP |
| 396 | * Index - which local_var or argument to get | 378 | * Index - which local_var or argument to get |
| 397 | * walk_state - Current walk state object | 379 | * walk_state - Current walk state object |
| 398 | * *dest_desc - Ptr to Descriptor into which selected Arg | 380 | * dest_desc - Where Arg or Local value is returned |
| 399 | * or Local value should be copied | ||
| 400 | * | 381 | * |
| 401 | * RETURN: Status | 382 | * RETURN: Status |
| 402 | * | 383 | * |
| 403 | * DESCRIPTION: Retrieve value of selected Arg or Local from the method frame | 384 | * DESCRIPTION: Retrieve value of selected Arg or Local for this method |
| 404 | * at the current top of the method stack. | ||
| 405 | * Used only in acpi_ex_resolve_to_value(). | 385 | * Used only in acpi_ex_resolve_to_value(). |
| 406 | * | 386 | * |
| 407 | ******************************************************************************/ | 387 | ******************************************************************************/ |
| @@ -467,14 +447,16 @@ acpi_ds_method_data_get_value ( | |||
| 467 | else switch (opcode) { | 447 | else switch (opcode) { |
| 468 | case AML_ARG_OP: | 448 | case AML_ARG_OP: |
| 469 | 449 | ||
| 470 | ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Uninitialized Arg[%d] at node %p\n", | 450 | ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, |
| 451 | "Uninitialized Arg[%d] at node %p\n", | ||
| 471 | index, node)); | 452 | index, node)); |
| 472 | 453 | ||
| 473 | return_ACPI_STATUS (AE_AML_UNINITIALIZED_ARG); | 454 | return_ACPI_STATUS (AE_AML_UNINITIALIZED_ARG); |
| 474 | 455 | ||
| 475 | case AML_LOCAL_OP: | 456 | case AML_LOCAL_OP: |
| 476 | 457 | ||
| 477 | ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Uninitialized Local[%d] at node %p\n", | 458 | ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, |
| 459 | "Uninitialized Local[%d] at node %p\n", | ||
| 478 | index, node)); | 460 | index, node)); |
| 479 | 461 | ||
| 480 | return_ACPI_STATUS (AE_AML_UNINITIALIZED_LOCAL); | 462 | return_ACPI_STATUS (AE_AML_UNINITIALIZED_LOCAL); |
| @@ -506,12 +488,12 @@ acpi_ds_method_data_get_value ( | |||
| 506 | * | 488 | * |
| 507 | * RETURN: None | 489 | * RETURN: None |
| 508 | * | 490 | * |
| 509 | * DESCRIPTION: Delete the entry at Opcode:Index on the method stack. Inserts | 491 | * DESCRIPTION: Delete the entry at Opcode:Index. Inserts |
| 510 | * a null into the stack slot after the object is deleted. | 492 | * a null into the stack slot after the object is deleted. |
| 511 | * | 493 | * |
| 512 | ******************************************************************************/ | 494 | ******************************************************************************/ |
| 513 | 495 | ||
| 514 | void | 496 | static void |
| 515 | acpi_ds_method_data_delete_value ( | 497 | acpi_ds_method_data_delete_value ( |
| 516 | u16 opcode, | 498 | u16 opcode, |
| 517 | u32 index, | 499 | u32 index, |
| @@ -562,7 +544,7 @@ acpi_ds_method_data_delete_value ( | |||
| 562 | * FUNCTION: acpi_ds_store_object_to_local | 544 | * FUNCTION: acpi_ds_store_object_to_local |
| 563 | * | 545 | * |
| 564 | * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP | 546 | * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP |
| 565 | * Index - which local_var or argument to set | 547 | * Index - Which Local or Arg to set |
| 566 | * obj_desc - Value to be stored | 548 | * obj_desc - Value to be stored |
| 567 | * walk_state - Current walk state | 549 | * walk_state - Current walk state |
| 568 | * | 550 | * |
| @@ -651,19 +633,20 @@ acpi_ds_store_object_to_local ( | |||
| 651 | */ | 633 | */ |
| 652 | if (opcode == AML_ARG_OP) { | 634 | if (opcode == AML_ARG_OP) { |
| 653 | /* | 635 | /* |
| 654 | * Make sure that the object is the correct type. This may be overkill, but | 636 | * Make sure that the object is the correct type. This may be |
| 655 | * it is here because references were NS nodes in the past. Now they are | 637 | * overkill, butit is here because references were NS nodes in |
| 656 | * operand objects of type Reference. | 638 | * the past. Now they are operand objects of type Reference. |
| 657 | */ | 639 | */ |
| 658 | if (ACPI_GET_DESCRIPTOR_TYPE (current_obj_desc) != ACPI_DESC_TYPE_OPERAND) { | 640 | if (ACPI_GET_DESCRIPTOR_TYPE (current_obj_desc) != ACPI_DESC_TYPE_OPERAND) { |
| 659 | ACPI_REPORT_ERROR (("Invalid descriptor type while storing to method arg: [%s]\n", | 641 | ACPI_REPORT_ERROR (( |
| 660 | acpi_ut_get_descriptor_name (current_obj_desc))); | 642 | "Invalid descriptor type while storing to method arg: [%s]\n", |
| 643 | acpi_ut_get_descriptor_name (current_obj_desc))); | ||
| 661 | return_ACPI_STATUS (AE_AML_INTERNAL); | 644 | return_ACPI_STATUS (AE_AML_INTERNAL); |
| 662 | } | 645 | } |
| 663 | 646 | ||
| 664 | /* | 647 | /* |
| 665 | * If we have a valid reference object that came from ref_of(), do the | 648 | * If we have a valid reference object that came from ref_of(), |
| 666 | * indirect store | 649 | * do the indirect store |
| 667 | */ | 650 | */ |
| 668 | if ((current_obj_desc->common.type == ACPI_TYPE_LOCAL_REFERENCE) && | 651 | if ((current_obj_desc->common.type == ACPI_TYPE_LOCAL_REFERENCE) && |
| 669 | (current_obj_desc->reference.opcode == AML_REF_OF_OP)) { | 652 | (current_obj_desc->reference.opcode == AML_REF_OF_OP)) { |
| @@ -713,3 +696,55 @@ acpi_ds_store_object_to_local ( | |||
| 713 | } | 696 | } |
| 714 | 697 | ||
| 715 | 698 | ||
| 699 | #ifdef ACPI_OBSOLETE_FUNCTIONS | ||
| 700 | /******************************************************************************* | ||
| 701 | * | ||
| 702 | * FUNCTION: acpi_ds_method_data_get_type | ||
| 703 | * | ||
| 704 | * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP | ||
| 705 | * Index - Which Local or Arg whose type to get | ||
| 706 | * walk_state - Current walk state object | ||
| 707 | * | ||
| 708 | * RETURN: Data type of current value of the selected Arg or Local | ||
| 709 | * | ||
| 710 | * DESCRIPTION: Get the type of the object stored in the Local or Arg | ||
| 711 | * | ||
| 712 | ******************************************************************************/ | ||
| 713 | |||
| 714 | acpi_object_type | ||
| 715 | acpi_ds_method_data_get_type ( | ||
| 716 | u16 opcode, | ||
| 717 | u32 index, | ||
| 718 | struct acpi_walk_state *walk_state) | ||
| 719 | { | ||
| 720 | acpi_status status; | ||
| 721 | struct acpi_namespace_node *node; | ||
| 722 | union acpi_operand_object *object; | ||
| 723 | |||
| 724 | |||
| 725 | ACPI_FUNCTION_TRACE ("ds_method_data_get_type"); | ||
| 726 | |||
| 727 | |||
| 728 | /* Get the namespace node for the arg/local */ | ||
| 729 | |||
| 730 | status = acpi_ds_method_data_get_node (opcode, index, walk_state, &node); | ||
| 731 | if (ACPI_FAILURE (status)) { | ||
| 732 | return_VALUE ((ACPI_TYPE_NOT_FOUND)); | ||
| 733 | } | ||
| 734 | |||
| 735 | /* Get the object */ | ||
| 736 | |||
| 737 | object = acpi_ns_get_attached_object (node); | ||
| 738 | if (!object) { | ||
| 739 | /* Uninitialized local/arg, return TYPE_ANY */ | ||
| 740 | |||
| 741 | return_VALUE (ACPI_TYPE_ANY); | ||
| 742 | } | ||
| 743 | |||
| 744 | /* Get the object type */ | ||
| 745 | |||
| 746 | return_VALUE (ACPI_GET_OBJECT_TYPE (object)); | ||
| 747 | } | ||
| 748 | #endif | ||
| 749 | |||
| 750 | |||
