dsmthdat.c revision 122945
138494Sobrien/******************************************************************************* 238494Sobrien * 338494Sobrien * Module Name: dsmthdat - control method arguments and local variables 438494Sobrien * $Revision: 71 $ 538494Sobrien * 638494Sobrien ******************************************************************************/ 738494Sobrien 838494Sobrien/****************************************************************************** 938494Sobrien * 1038494Sobrien * 1. Copyright Notice 1138494Sobrien * 1238494Sobrien * Some or all of this work - Copyright (c) 1999 - 2003, Intel Corp. 1338494Sobrien * All rights reserved. 1438494Sobrien * 1538494Sobrien * 2. License 1638494Sobrien * 1738494Sobrien * 2.1. This is your license from Intel Corp. under its intellectual property 1838494Sobrien * rights. You may have additional license terms from the party that provided 1938494Sobrien * you this software, covering your right to use that party's intellectual 2038494Sobrien * property rights. 2138494Sobrien * 2238494Sobrien * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 2338494Sobrien * copy of the source code appearing in this file ("Covered Code") an 2438494Sobrien * irrevocable, perpetual, worldwide license under Intel's copyrights in the 2538494Sobrien * base code distributed originally by Intel ("Original Intel Code") to copy, 2638494Sobrien * make derivatives, distribute, use and display any portion of the Covered 2738494Sobrien * Code in any form, with the right to sublicense such rights; and 2838494Sobrien * 2938494Sobrien * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 3038494Sobrien * license (with the right to sublicense), under only those claims of Intel 3138494Sobrien * patents that are infringed by the Original Intel Code, to make, use, sell, 3238494Sobrien * offer to sell, and import the Covered Code and derivative works thereof 3341142Sobrien * solely to the minimum extent necessary to exercise the above copyright 3441142Sobrien * license, and in no event shall the patent license extend to any additions 3551292Sobrien * to or modifications of the Original Intel Code. No other license or right 3651292Sobrien * is granted directly or by implication, estoppel or otherwise; 3751292Sobrien * 3851292Sobrien * The above copyright and patent license is granted only if the following 3938494Sobrien * conditions are met: 4038494Sobrien * 4138494Sobrien * 3. Conditions 4238494Sobrien * 4338494Sobrien * 3.1. Redistribution of Source with Rights to Further Distribute Source. 4438494Sobrien * Redistribution of source code of any substantial portion of the Covered 4538494Sobrien * Code or modification with rights to further distribute source must include 4638494Sobrien * the above Copyright Notice, the above License, this list of Conditions, 4738494Sobrien * and the following Disclaimer and Export Compliance provision. In addition, 4838494Sobrien * Licensee must cause all Covered Code to which Licensee contributes to 4938494Sobrien * contain a file documenting the changes Licensee made to create that Covered 5038494Sobrien * Code and the date of any change. Licensee must include in that file the 5138494Sobrien * documentation of any changes made by any predecessor Licensee. Licensee 5238494Sobrien * must include a prominent statement that the modification is derived, 5338494Sobrien * directly or indirectly, from Original Intel Code. 5438494Sobrien * 5538494Sobrien * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 5638494Sobrien * Redistribution of source code of any substantial portion of the Covered 5738494Sobrien * Code or modification without rights to further distribute source must 5838494Sobrien * include the following Disclaimer and Export Compliance provision in the 5938494Sobrien * documentation and/or other materials provided with distribution. In 6038494Sobrien * addition, Licensee may not authorize further sublicense of source of any 6138494Sobrien * portion of the Covered Code, and must include terms to the effect that the 6238494Sobrien * license from Licensee to its licensee is limited to the intellectual 6338494Sobrien * property embodied in the software Licensee provides to its licensee, and 6438494Sobrien * not to intellectual property embodied in modifications its licensee may 6538494Sobrien * make. 6638494Sobrien * 6738494Sobrien * 3.3. Redistribution of Executable. Redistribution in executable form of any 6838494Sobrien * substantial portion of the Covered Code or modification must reproduce the 6938494Sobrien * above Copyright Notice, and the following Disclaimer and Export Compliance 7038494Sobrien * provision in the documentation and/or other materials provided with the 7138494Sobrien * distribution. 7238494Sobrien * 7338494Sobrien * 3.4. Intel retains all right, title, and interest in and to the Original 7438494Sobrien * Intel Code. 7538494Sobrien * 7638494Sobrien * 3.5. Neither the name Intel nor any other trademark owned or controlled by 7738494Sobrien * Intel shall be used in advertising or otherwise to promote the sale, use or 7838494Sobrien * other dealings in products derived from or relating to the Covered Code 7938494Sobrien * without prior written authorization from Intel. 8038494Sobrien * 8138494Sobrien * 4. Disclaimer and Export Compliance 8238494Sobrien * 8338494Sobrien * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 8438494Sobrien * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 8538494Sobrien * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 8638494Sobrien * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 8738494Sobrien * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 8838494Sobrien * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 8938494Sobrien * PARTICULAR PURPOSE. 9038494Sobrien * 9138494Sobrien * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 9238494Sobrien * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 9338494Sobrien * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 9438494Sobrien * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 9538494Sobrien * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 9638494Sobrien * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 9738494Sobrien * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 9841142Sobrien * LIMITED REMEDY. 9941142Sobrien * 10041142Sobrien * 4.3. Licensee shall not export, either directly or indirectly, any of this 10138494Sobrien * software or system incorporating such software without first obtaining any 10238494Sobrien * required license or other approval from the U. S. Department of Commerce or 10338494Sobrien * any other agency or department of the United States Government. In the 10438494Sobrien * event Licensee exports any such software from the United States or 10538494Sobrien * re-exports any such software from a foreign destination, Licensee shall 10638494Sobrien * ensure that the distribution and export/re-export of the software is in 10738494Sobrien * compliance with all laws, regulations, orders, or other restrictions of the 10838494Sobrien * U.S. Export Administration Regulations. Licensee agrees that neither it nor 10938494Sobrien * any of its subsidiaries will export/re-export any technical data, process, 11038494Sobrien * software, or service, directly or indirectly, to any country for which the 11138494Sobrien * United States government or any agency thereof requires an export license, 11238494Sobrien * other governmental approval, or letter of assurance, without first obtaining 11338494Sobrien * such license, approval or letter. 11438494Sobrien * 11538494Sobrien *****************************************************************************/ 11638494Sobrien 11738494Sobrien#define __DSMTHDAT_C__ 11838494Sobrien 11951292Sobrien#include "acpi.h" 12051292Sobrien#include "acdispat.h" 12151292Sobrien#include "amlcode.h" 12251292Sobrien#include "acnamesp.h" 12351292Sobrien#include "acinterp.h" 12451292Sobrien 12551292Sobrien 12651292Sobrien#define _COMPONENT ACPI_DISPATCHER 12751292Sobrien ACPI_MODULE_NAME ("dsmthdat") 12838494Sobrien 12938494Sobrien 13038494Sobrien/******************************************************************************* 13138494Sobrien * 13238494Sobrien * FUNCTION: AcpiDsMethodDataInit 13338494Sobrien * 13438494Sobrien * PARAMETERS: WalkState - Current walk state object 13538494Sobrien * 13638494Sobrien * RETURN: Status 13738494Sobrien * 13838494Sobrien * DESCRIPTION: Initialize the data structures that hold the method's arguments 13938494Sobrien * and locals. The data struct is an array of NTEs for each. 14038494Sobrien * This allows RefOf and DeRefOf to work properly for these 14138494Sobrien * special data types. 14238494Sobrien * 14338494Sobrien * NOTES: WalkState fields are initialized to zero by the 14438494Sobrien * ACPI_MEM_CALLOCATE(). 14538494Sobrien * 14638494Sobrien * A pseudo-Namespace Node is assigned to each argument and local 14738494Sobrien * so that RefOf() can return a pointer to the Node. 14838494Sobrien * 14938494Sobrien ******************************************************************************/ 15038494Sobrien 15138494Sobrienvoid 15238494SobrienAcpiDsMethodDataInit ( 15338494Sobrien ACPI_WALK_STATE *WalkState) 15438494Sobrien{ 15538494Sobrien UINT32 i; 15638494Sobrien 15738494Sobrien 15838494Sobrien ACPI_FUNCTION_TRACE ("DsMethodDataInit"); 15938494Sobrien 16038494Sobrien 16138494Sobrien /* Init the method arguments */ 16238494Sobrien 16338494Sobrien for (i = 0; i < ACPI_METHOD_NUM_ARGS; i++) 16438494Sobrien { 16538494Sobrien ACPI_MOVE_32_TO_32 (&WalkState->Arguments[i].Name, 16638494Sobrien NAMEOF_ARG_NTE); 16738494Sobrien WalkState->Arguments[i].Name.Integer |= (i << 24); 16838494Sobrien WalkState->Arguments[i].Descriptor = ACPI_DESC_TYPE_NAMED; 16938494Sobrien WalkState->Arguments[i].Type = ACPI_TYPE_ANY; 17051292Sobrien WalkState->Arguments[i].Flags = ANOBJ_END_OF_PEER_LIST | ANOBJ_METHOD_ARG; 17151292Sobrien } 17238494Sobrien 17338494Sobrien /* Init the method locals */ 17438494Sobrien 17538494Sobrien for (i = 0; i < ACPI_METHOD_NUM_LOCALS; i++) 17638494Sobrien { 17738494Sobrien ACPI_MOVE_32_TO_32 (&WalkState->LocalVariables[i].Name, 17838494Sobrien NAMEOF_LOCAL_NTE); 17938494Sobrien 18038494Sobrien WalkState->LocalVariables[i].Name.Integer |= (i << 24); 18138494Sobrien WalkState->LocalVariables[i].Descriptor = ACPI_DESC_TYPE_NAMED; 18238494Sobrien WalkState->LocalVariables[i].Type = ACPI_TYPE_ANY; 18338494Sobrien WalkState->LocalVariables[i].Flags = ANOBJ_END_OF_PEER_LIST | ANOBJ_METHOD_LOCAL; 18438494Sobrien } 18538494Sobrien 18638494Sobrien return_VOID; 18738494Sobrien} 18838494Sobrien 18938494Sobrien 19038494Sobrien/******************************************************************************* 19138494Sobrien * 19238494Sobrien * FUNCTION: AcpiDsMethodDataDeleteAll 19338494Sobrien * 19441142Sobrien * PARAMETERS: WalkState - Current walk state object 19541142Sobrien * 19641142Sobrien * RETURN: None 19738494Sobrien * 19838494Sobrien * DESCRIPTION: Delete method locals and arguments. Arguments are only 19938494Sobrien * deleted if this method was called from another method. 20038494Sobrien * 20138494Sobrien ******************************************************************************/ 20238494Sobrien 20338494Sobrienvoid 20438494SobrienAcpiDsMethodDataDeleteAll ( 20538494Sobrien ACPI_WALK_STATE *WalkState) 20638494Sobrien{ 20738494Sobrien UINT32 Index; 20838494Sobrien 20938494Sobrien 21038494Sobrien ACPI_FUNCTION_TRACE ("DsMethodDataDeleteAll"); 21138494Sobrien 21241142Sobrien 21338494Sobrien /* Detach the locals */ 21438494Sobrien 21541142Sobrien for (Index = 0; Index < ACPI_METHOD_NUM_LOCALS; Index++) 21641142Sobrien { 21741142Sobrien if (WalkState->LocalVariables[Index].Object) 21841142Sobrien { 21941142Sobrien ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Local%d=%p\n", 22051591Sobrien Index, WalkState->LocalVariables[Index].Object)); 22151591Sobrien 22242629Sobrien /* Detach object (if present) and remove a reference */ 22341142Sobrien 22442629Sobrien AcpiNsDetachObject (&WalkState->LocalVariables[Index]); 22542629Sobrien } 22642629Sobrien } 22742629Sobrien 22842629Sobrien /* Detach the arguments */ 22942629Sobrien 23042629Sobrien for (Index = 0; Index < ACPI_METHOD_NUM_ARGS; Index++) 23142629Sobrien { 23242629Sobrien if (WalkState->Arguments[Index].Object) 23342629Sobrien { 23442629Sobrien ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Arg%d=%p\n", 23551292Sobrien Index, WalkState->Arguments[Index].Object)); 23651292Sobrien 23751292Sobrien /* Detach object (if present) and remove a reference */ 23851292Sobrien 23951292Sobrien AcpiNsDetachObject (&WalkState->Arguments[Index]); 24051292Sobrien } 24151292Sobrien } 24251292Sobrien 24351292Sobrien return_VOID; 24451292Sobrien} 24551292Sobrien 24651292Sobrien 24751292Sobrien/******************************************************************************* 24851292Sobrien * 24951292Sobrien * FUNCTION: AcpiDsMethodDataInitArgs 25051591Sobrien * 25151591Sobrien * PARAMETERS: *Params - Pointer to a parameter list for the method 25251292Sobrien * MaxParamCount - The arg count for this method 25351292Sobrien * WalkState - Current walk state object 25451292Sobrien * 25551292Sobrien * RETURN: Status 25651292Sobrien * 25751292Sobrien * DESCRIPTION: Initialize arguments for a method. The parameter list is a list 25852894Sobrien * of ACPI operand objects, either null terminated or whose length 25952894Sobrien * is defined by MaxParamCount. 26052894Sobrien * 26151292Sobrien ******************************************************************************/ 26251292Sobrien 26351292SobrienACPI_STATUS 26451292SobrienAcpiDsMethodDataInitArgs ( 26551292Sobrien ACPI_OPERAND_OBJECT **Params, 26651292Sobrien UINT32 MaxParamCount, 26751292Sobrien ACPI_WALK_STATE *WalkState) 26851292Sobrien{ 26951292Sobrien ACPI_STATUS Status; 27051292Sobrien UINT32 Index = 0; 27151292Sobrien 27251292Sobrien 27352894Sobrien ACPI_FUNCTION_TRACE_PTR ("DsMethodDataInitArgs", Params); 27452894Sobrien 27552894Sobrien 27652894Sobrien if (!Params) 277 { 278 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "No param list passed to method\n")); 279 return_ACPI_STATUS (AE_OK); 280 } 281 282 /* Copy passed parameters into the new method stack frame */ 283 284 while ((Index < ACPI_METHOD_NUM_ARGS) && (Index < MaxParamCount) && Params[Index]) 285 { 286 /* 287 * A valid parameter. 288 * Store the argument in the method/walk descriptor 289 */ 290 Status = AcpiDsStoreObjectToLocal (AML_ARG_OP, Index, Params[Index], 291 WalkState); 292 if (ACPI_FAILURE (Status)) 293 { 294 return_ACPI_STATUS (Status); 295 } 296 297 Index++; 298 } 299 300 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%d args passed to method\n", Index)); 301 return_ACPI_STATUS (AE_OK); 302} 303 304 305/******************************************************************************* 306 * 307 * FUNCTION: AcpiDsMethodDataGetNode 308 * 309 * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP 310 * Index - Which localVar or argument whose type 311 * to get 312 * WalkState - Current walk state object 313 * 314 * RETURN: Get the Node associated with a local or arg. 315 * 316 ******************************************************************************/ 317 318ACPI_STATUS 319AcpiDsMethodDataGetNode ( 320 UINT16 Opcode, 321 UINT32 Index, 322 ACPI_WALK_STATE *WalkState, 323 ACPI_NAMESPACE_NODE **Node) 324{ 325 ACPI_FUNCTION_TRACE ("DsMethodDataGetNode"); 326 327 328 /* 329 * Method Locals and Arguments are supported 330 */ 331 switch (Opcode) 332 { 333 case AML_LOCAL_OP: 334 335 if (Index > ACPI_METHOD_MAX_LOCAL) 336 { 337 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Local index %d is invalid (max %d)\n", 338 Index, ACPI_METHOD_MAX_LOCAL)); 339 return_ACPI_STATUS (AE_AML_INVALID_INDEX); 340 } 341 342 /* Return a pointer to the pseudo-node */ 343 344 *Node = &WalkState->LocalVariables[Index]; 345 break; 346 347 case AML_ARG_OP: 348 349 if (Index > ACPI_METHOD_MAX_ARG) 350 { 351 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Arg index %d is invalid (max %d)\n", 352 Index, ACPI_METHOD_MAX_ARG)); 353 return_ACPI_STATUS (AE_AML_INVALID_INDEX); 354 } 355 356 /* Return a pointer to the pseudo-node */ 357 358 *Node = &WalkState->Arguments[Index]; 359 break; 360 361 default: 362 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Opcode %d is invalid\n", Opcode)); 363 return_ACPI_STATUS (AE_AML_BAD_OPCODE); 364 } 365 366 return_ACPI_STATUS (AE_OK); 367} 368 369 370/******************************************************************************* 371 * 372 * FUNCTION: AcpiDsMethodDataSetValue 373 * 374 * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP 375 * Index - Which localVar or argument to get 376 * Object - Object to be inserted into the stack entry 377 * WalkState - Current walk state object 378 * 379 * RETURN: Status 380 * 381 * DESCRIPTION: Insert an object onto the method stack at entry Opcode:Index. 382 * Note: There is no "implicit conversion" for locals. 383 * 384 ******************************************************************************/ 385 386ACPI_STATUS 387AcpiDsMethodDataSetValue ( 388 UINT16 Opcode, 389 UINT32 Index, 390 ACPI_OPERAND_OBJECT *Object, 391 ACPI_WALK_STATE *WalkState) 392{ 393 ACPI_STATUS Status; 394 ACPI_NAMESPACE_NODE *Node; 395 396 397 ACPI_FUNCTION_TRACE ("DsMethodDataSetValue"); 398 399 400 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 401 "obj %p op %X, ref count = %d [%s]\n", Object, 402 Opcode, Object->Common.ReferenceCount, 403 AcpiUtGetTypeName (Object->Common.Type))); 404 405 /* Get the namespace node for the arg/local */ 406 407 Status = AcpiDsMethodDataGetNode (Opcode, Index, WalkState, &Node); 408 if (ACPI_FAILURE (Status)) 409 { 410 return_ACPI_STATUS (Status); 411 } 412 413 /* 414 * Increment ref count so object can't be deleted while installed. 415 * NOTE: We do not copy the object in order to preserve the call by 416 * reference semantics of ACPI Control Method invocation. 417 * (See ACPI Specification 2.0C) 418 */ 419 AcpiUtAddReference (Object); 420 421 /* Install the object */ 422 423 Node->Object = Object; 424 return_ACPI_STATUS (Status); 425} 426 427 428/******************************************************************************* 429 * 430 * FUNCTION: AcpiDsMethodDataGetType 431 * 432 * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP 433 * Index - Which localVar or argument whose type 434 * to get 435 * WalkState - Current walk state object 436 * 437 * RETURN: Data type of current value of the selected Arg or Local 438 * 439 ******************************************************************************/ 440 441ACPI_OBJECT_TYPE 442AcpiDsMethodDataGetType ( 443 UINT16 Opcode, 444 UINT32 Index, 445 ACPI_WALK_STATE *WalkState) 446{ 447 ACPI_STATUS Status; 448 ACPI_NAMESPACE_NODE *Node; 449 ACPI_OPERAND_OBJECT *Object; 450 451 452 ACPI_FUNCTION_TRACE ("DsMethodDataGetType"); 453 454 455 /* Get the namespace node for the arg/local */ 456 457 Status = AcpiDsMethodDataGetNode (Opcode, Index, WalkState, &Node); 458 if (ACPI_FAILURE (Status)) 459 { 460 return_VALUE ((ACPI_TYPE_NOT_FOUND)); 461 } 462 463 /* Get the object */ 464 465 Object = AcpiNsGetAttachedObject (Node); 466 if (!Object) 467 { 468 /* Uninitialized local/arg, return TYPE_ANY */ 469 470 return_VALUE (ACPI_TYPE_ANY); 471 } 472 473 /* Get the object type */ 474 475 return_VALUE (ACPI_GET_OBJECT_TYPE (Object)); 476} 477 478 479/******************************************************************************* 480 * 481 * FUNCTION: AcpiDsMethodDataGetValue 482 * 483 * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP 484 * Index - Which localVar or argument to get 485 * WalkState - Current walk state object 486 * *DestDesc - Ptr to Descriptor into which selected Arg 487 * or Local value should be copied 488 * 489 * RETURN: Status 490 * 491 * DESCRIPTION: Retrieve value of selected Arg or Local from the method frame 492 * at the current top of the method stack. 493 * Used only in AcpiExResolveToValue(). 494 * 495 ******************************************************************************/ 496 497ACPI_STATUS 498AcpiDsMethodDataGetValue ( 499 UINT16 Opcode, 500 UINT32 Index, 501 ACPI_WALK_STATE *WalkState, 502 ACPI_OPERAND_OBJECT **DestDesc) 503{ 504 ACPI_STATUS Status; 505 ACPI_NAMESPACE_NODE *Node; 506 ACPI_OPERAND_OBJECT *Object; 507 508 509 ACPI_FUNCTION_TRACE ("DsMethodDataGetValue"); 510 511 512 /* Validate the object descriptor */ 513 514 if (!DestDesc) 515 { 516 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null object descriptor pointer\n")); 517 return_ACPI_STATUS (AE_BAD_PARAMETER); 518 } 519 520 /* Get the namespace node for the arg/local */ 521 522 Status = AcpiDsMethodDataGetNode (Opcode, Index, WalkState, &Node); 523 if (ACPI_FAILURE (Status)) 524 { 525 return_ACPI_STATUS (Status); 526 } 527 528 /* Get the object from the node */ 529 530 Object = Node->Object; 531 532 /* Examine the returned object, it must be valid. */ 533 534 if (!Object) 535 { 536 /* 537 * Index points to uninitialized object. 538 * This means that either 1) The expected argument was 539 * not passed to the method, or 2) A local variable 540 * was referenced by the method (via the ASL) 541 * before it was initialized. Either case is an error. 542 */ 543 switch (Opcode) 544 { 545 case AML_ARG_OP: 546 547 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Uninitialized Arg[%d] at node %p\n", 548 Index, Node)); 549 550 return_ACPI_STATUS (AE_AML_UNINITIALIZED_ARG); 551 552 case AML_LOCAL_OP: 553 554 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Uninitialized Local[%d] at node %p\n", 555 Index, Node)); 556 557 return_ACPI_STATUS (AE_AML_UNINITIALIZED_LOCAL); 558 559 default: 560 return_ACPI_STATUS (AE_AML_INTERNAL); 561 } 562 } 563 564 /* 565 * The Index points to an initialized and valid object. 566 * Return an additional reference to the object 567 */ 568 *DestDesc = Object; 569 AcpiUtAddReference (Object); 570 571 return_ACPI_STATUS (AE_OK); 572} 573 574 575/******************************************************************************* 576 * 577 * FUNCTION: AcpiDsMethodDataDeleteValue 578 * 579 * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP 580 * Index - Which localVar or argument to delete 581 * WalkState - Current walk state object 582 * 583 * RETURN: None 584 * 585 * DESCRIPTION: Delete the entry at Opcode:Index on the method stack. Inserts 586 * a null into the stack slot after the object is deleted. 587 * 588 ******************************************************************************/ 589 590void 591AcpiDsMethodDataDeleteValue ( 592 UINT16 Opcode, 593 UINT32 Index, 594 ACPI_WALK_STATE *WalkState) 595{ 596 ACPI_STATUS Status; 597 ACPI_NAMESPACE_NODE *Node; 598 ACPI_OPERAND_OBJECT *Object; 599 600 601 ACPI_FUNCTION_TRACE ("DsMethodDataDeleteValue"); 602 603 604 /* Get the namespace node for the arg/local */ 605 606 Status = AcpiDsMethodDataGetNode (Opcode, Index, WalkState, &Node); 607 if (ACPI_FAILURE (Status)) 608 { 609 return_VOID; 610 } 611 612 /* Get the associated object */ 613 614 Object = AcpiNsGetAttachedObject (Node); 615 616 /* 617 * Undefine the Arg or Local by setting its descriptor 618 * pointer to NULL. Locals/Args can contain both 619 * ACPI_OPERAND_OBJECTS and ACPI_NAMESPACE_NODEs 620 */ 621 Node->Object = NULL; 622 623 if ((Object) && 624 (ACPI_GET_DESCRIPTOR_TYPE (Object) == ACPI_DESC_TYPE_OPERAND)) 625 { 626 /* 627 * There is a valid object. 628 * Decrement the reference count by one to balance the 629 * increment when the object was stored. 630 */ 631 AcpiUtRemoveReference (Object); 632 } 633 634 return_VOID; 635} 636 637 638/******************************************************************************* 639 * 640 * FUNCTION: AcpiDsStoreObjectToLocal 641 * 642 * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP 643 * Index - Which localVar or argument to set 644 * ObjDesc - Value to be stored 645 * WalkState - Current walk state 646 * 647 * RETURN: Status 648 * 649 * DESCRIPTION: Store a value in an Arg or Local. The ObjDesc is installed 650 * as the new value for the Arg or Local and the reference count 651 * for ObjDesc is incremented. 652 * 653 ******************************************************************************/ 654 655ACPI_STATUS 656AcpiDsStoreObjectToLocal ( 657 UINT16 Opcode, 658 UINT32 Index, 659 ACPI_OPERAND_OBJECT *ObjDesc, 660 ACPI_WALK_STATE *WalkState) 661{ 662 ACPI_STATUS Status; 663 ACPI_NAMESPACE_NODE *Node; 664 ACPI_OPERAND_OBJECT *CurrentObjDesc; 665 666 667 ACPI_FUNCTION_TRACE ("DsStoreObjectToLocal"); 668 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Opcode=%d Idx=%d Obj=%p\n", 669 Opcode, Index, ObjDesc)); 670 671 672 /* Parameter validation */ 673 674 if (!ObjDesc) 675 { 676 return_ACPI_STATUS (AE_BAD_PARAMETER); 677 } 678 679 /* Get the namespace node for the arg/local */ 680 681 Status = AcpiDsMethodDataGetNode (Opcode, Index, WalkState, &Node); 682 if (ACPI_FAILURE (Status)) 683 { 684 return_ACPI_STATUS (Status); 685 } 686 687 CurrentObjDesc = AcpiNsGetAttachedObject (Node); 688 if (CurrentObjDesc == ObjDesc) 689 { 690 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p already installed!\n", 691 ObjDesc)); 692 return_ACPI_STATUS (Status); 693 } 694 695 /* 696 * If there is an object already in this slot, we either 697 * have to delete it, or if this is an argument and there 698 * is an object reference stored there, we have to do 699 * an indirect store! 700 */ 701 if (CurrentObjDesc) 702 { 703 /* 704 * Check for an indirect store if an argument 705 * contains an object reference (stored as an Node). 706 * We don't allow this automatic dereferencing for 707 * locals, since a store to a local should overwrite 708 * anything there, including an object reference. 709 * 710 * If both Arg0 and Local0 contain RefOf (Local4): 711 * 712 * Store (1, Arg0) - Causes indirect store to local4 713 * Store (1, Local0) - Stores 1 in local0, overwriting 714 * the reference to local4 715 * Store (1, DeRefof (Local0)) - Causes indirect store to local4 716 * 717 * Weird, but true. 718 */ 719 if (Opcode == AML_ARG_OP) 720 { 721 /* 722 * Make sure that the object is the correct type. This may be overkill, but 723 * it is here because references were NS nodes in the past. Now they are 724 * operand objects of type Reference. 725 */ 726 if (ACPI_GET_DESCRIPTOR_TYPE (CurrentObjDesc) != ACPI_DESC_TYPE_OPERAND) 727 { 728 ACPI_REPORT_ERROR (("Invalid descriptor type while storing to method arg: %X\n", 729 CurrentObjDesc->Common.Type)); 730 return_ACPI_STATUS (AE_AML_INTERNAL); 731 } 732 733 /* 734 * If we have a valid reference object that came from RefOf(), do the 735 * indirect store 736 */ 737 if ((CurrentObjDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) && 738 (CurrentObjDesc->Reference.Opcode == AML_REF_OF_OP)) 739 { 740 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 741 "Arg (%p) is an ObjRef(Node), storing in node %p\n", 742 ObjDesc, CurrentObjDesc)); 743 744 /* 745 * Store this object to the Node 746 * (perform the indirect store) 747 */ 748 Status = AcpiExStoreObjectToNode (ObjDesc, 749 CurrentObjDesc->Reference.Object, WalkState); 750 return_ACPI_STATUS (Status); 751 } 752 } 753 754 /* 755 * Delete the existing object 756 * before storing the new one 757 */ 758 AcpiDsMethodDataDeleteValue (Opcode, Index, WalkState); 759 } 760 761 /* 762 * Install the ObjStack descriptor (*ObjDesc) into 763 * the descriptor for the Arg or Local. 764 * Install the new object in the stack entry 765 * (increments the object reference count by one) 766 */ 767 Status = AcpiDsMethodDataSetValue (Opcode, Index, ObjDesc, WalkState); 768 return_ACPI_STATUS (Status); 769} 770 771 772