excreate.c revision 83174
1/****************************************************************************** 2 * 3 * Module Name: excreate - Named object creation 4 * $Revision: 65 $ 5 * 6 *****************************************************************************/ 7 8/****************************************************************************** 9 * 10 * 1. Copyright Notice 11 * 12 * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. 13 * All rights reserved. 14 * 15 * 2. License 16 * 17 * 2.1. This is your license from Intel Corp. under its intellectual property 18 * rights. You may have additional license terms from the party that provided 19 * you this software, covering your right to use that party's intellectual 20 * property rights. 21 * 22 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 23 * copy of the source code appearing in this file ("Covered Code") an 24 * irrevocable, perpetual, worldwide license under Intel's copyrights in the 25 * base code distributed originally by Intel ("Original Intel Code") to copy, 26 * make derivatives, distribute, use and display any portion of the Covered 27 * Code in any form, with the right to sublicense such rights; and 28 * 29 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 30 * license (with the right to sublicense), under only those claims of Intel 31 * patents that are infringed by the Original Intel Code, to make, use, sell, 32 * offer to sell, and import the Covered Code and derivative works thereof 33 * solely to the minimum extent necessary to exercise the above copyright 34 * license, and in no event shall the patent license extend to any additions 35 * to or modifications of the Original Intel Code. No other license or right 36 * is granted directly or by implication, estoppel or otherwise; 37 * 38 * The above copyright and patent license is granted only if the following 39 * conditions are met: 40 * 41 * 3. Conditions 42 * 43 * 3.1. Redistribution of Source with Rights to Further Distribute Source. 44 * Redistribution of source code of any substantial portion of the Covered 45 * Code or modification with rights to further distribute source must include 46 * the above Copyright Notice, the above License, this list of Conditions, 47 * and the following Disclaimer and Export Compliance provision. In addition, 48 * Licensee must cause all Covered Code to which Licensee contributes to 49 * contain a file documenting the changes Licensee made to create that Covered 50 * Code and the date of any change. Licensee must include in that file the 51 * documentation of any changes made by any predecessor Licensee. Licensee 52 * must include a prominent statement that the modification is derived, 53 * directly or indirectly, from Original Intel Code. 54 * 55 * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 56 * Redistribution of source code of any substantial portion of the Covered 57 * Code or modification without rights to further distribute source must 58 * include the following Disclaimer and Export Compliance provision in the 59 * documentation and/or other materials provided with distribution. In 60 * addition, Licensee may not authorize further sublicense of source of any 61 * portion of the Covered Code, and must include terms to the effect that the 62 * license from Licensee to its licensee is limited to the intellectual 63 * property embodied in the software Licensee provides to its licensee, and 64 * not to intellectual property embodied in modifications its licensee may 65 * make. 66 * 67 * 3.3. Redistribution of Executable. Redistribution in executable form of any 68 * substantial portion of the Covered Code or modification must reproduce the 69 * above Copyright Notice, and the following Disclaimer and Export Compliance 70 * provision in the documentation and/or other materials provided with the 71 * distribution. 72 * 73 * 3.4. Intel retains all right, title, and interest in and to the Original 74 * Intel Code. 75 * 76 * 3.5. Neither the name Intel nor any other trademark owned or controlled by 77 * Intel shall be used in advertising or otherwise to promote the sale, use or 78 * other dealings in products derived from or relating to the Covered Code 79 * without prior written authorization from Intel. 80 * 81 * 4. Disclaimer and Export Compliance 82 * 83 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 84 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 85 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 86 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 87 88 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 89 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 90 * PARTICULAR PURPOSE. 91 * 92 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 93 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 94 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 95 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 96 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 97 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 98 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 99 * LIMITED REMEDY. 100 * 101 * 4.3. Licensee shall not export, either directly or indirectly, any of this 102 * software or system incorporating such software without first obtaining any 103 * required license or other approval from the U. S. Department of Commerce or 104 * any other agency or department of the United States Government. In the 105 * event Licensee exports any such software from the United States or 106 * re-exports any such software from a foreign destination, Licensee shall 107 * ensure that the distribution and export/re-export of the software is in 108 * compliance with all laws, regulations, orders, or other restrictions of the 109 * U.S. Export Administration Regulations. Licensee agrees that neither it nor 110 * any of its subsidiaries will export/re-export any technical data, process, 111 * software, or service, directly or indirectly, to any country for which the 112 * United States government or any agency thereof requires an export license, 113 * other governmental approval, or letter of assurance, without first obtaining 114 * such license, approval or letter. 115 * 116 *****************************************************************************/ 117 118#define __EXCREATE_C__ 119 120#include "acpi.h" 121#include "acparser.h" 122#include "acinterp.h" 123#include "amlcode.h" 124#include "acnamesp.h" 125#include "acevents.h" 126#include "acdispat.h" 127 128 129#define _COMPONENT ACPI_EXECUTER 130 MODULE_NAME ("excreate") 131 132 133/******************************************************************************* 134 * 135 * FUNCTION: AcpiExCreateBufferField 136 * 137 * PARAMETERS: Opcode - The opcode to be executed 138 * Operands - List of operands for the opcode 139 * 140 * RETURN: Status 141 * 142 * DESCRIPTION: Execute CreateField operators: CreateBitFieldOp, 143 * CreateByteFieldOp, CreateWordFieldOp, CreateDWordFieldOp, 144 * CreateFieldOp (which define fields in buffers) 145 * 146 * ALLOCATION: Deletes CreateFieldOp's count operand descriptor 147 * 148 * 149 * ACPI SPECIFICATION REFERENCES: 150 * DefCreateBitField := CreateBitFieldOp SrcBuf BitIdx NameString 151 * DefCreateByteField := CreateByteFieldOp SrcBuf ByteIdx NameString 152 * DefCreateDWordField := CreateDWordFieldOp SrcBuf ByteIdx NameString 153 * DefCreateField := CreateFieldOp SrcBuf BitIdx NumBits NameString 154 * DefCreateWordField := CreateWordFieldOp SrcBuf ByteIdx NameString 155 * BitIndex := TermArg=>Integer 156 * ByteIndex := TermArg=>Integer 157 * NumBits := TermArg=>Integer 158 * SourceBuff := TermArg=>Buffer 159 * 160 ******************************************************************************/ 161 162ACPI_STATUS 163AcpiExCreateBufferField ( 164 UINT8 *AmlPtr, 165 UINT32 AmlLength, 166 ACPI_NAMESPACE_NODE *Node, 167 ACPI_WALK_STATE *WalkState) 168{ 169 ACPI_STATUS Status; 170 ACPI_OPERAND_OBJECT *ObjDesc; 171 ACPI_OPERAND_OBJECT *TmpDesc; 172 173 174 FUNCTION_TRACE ("ExCreateBufferField"); 175 176 177 /* Create the descriptor */ 178 179 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER_FIELD); 180 if (!ObjDesc) 181 { 182 Status = AE_NO_MEMORY; 183 goto Cleanup; 184 } 185 186 187 /* 188 * Allocate a method object for this field unit 189 */ 190 ObjDesc->BufferField.Extra = AcpiUtCreateInternalObject ( 191 INTERNAL_TYPE_EXTRA); 192 if (!ObjDesc->BufferField.Extra) 193 { 194 Status = AE_NO_MEMORY; 195 goto Cleanup; 196 } 197 198 /* 199 * Remember location in AML stream of the field unit 200 * opcode and operands -- since the buffer and index 201 * operands must be evaluated. 202 */ 203 ObjDesc->BufferField.Extra->Extra.Pcode = AmlPtr; 204 ObjDesc->BufferField.Extra->Extra.PcodeLength = AmlLength; 205 ObjDesc->BufferField.Node = Node; 206 207 208 /* 209 * This operation is supposed to cause the destination Name to refer 210 * to the defined BufferField -- it must not store the constructed 211 * BufferField object (or its current value) in some location that the 212 * Name may already be pointing to. So, if the Name currently contains 213 * a reference which would cause AcpiExStore() to perform an indirect 214 * store rather than setting the value of the Name itself, clobber that 215 * reference before calling AcpiExStore(). 216 */ 217 218 /* Type of Name's existing value */ 219 220 switch (AcpiNsGetType (Node)) 221 { 222 223 case ACPI_TYPE_BUFFER_FIELD: 224 case INTERNAL_TYPE_ALIAS: 225 case INTERNAL_TYPE_REGION_FIELD: 226 case INTERNAL_TYPE_BANK_FIELD: 227 case INTERNAL_TYPE_INDEX_FIELD: 228 229 TmpDesc = AcpiNsGetAttachedObject (Node); 230 if (TmpDesc) 231 { 232 /* 233 * There is an existing object here; delete it and zero out the 234 * object field within the Node 235 */ 236 DUMP_PATHNAME (Node, 237 "ExCreateBufferField: Removing Current Reference", 238 ACPI_LV_BFIELD, _COMPONENT); 239 240 DUMP_ENTRY (Node, ACPI_LV_BFIELD); 241 DUMP_STACK_ENTRY (TmpDesc); 242 243 AcpiUtRemoveReference (TmpDesc); 244 AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Node, NULL, 245 ACPI_TYPE_ANY); 246 } 247 248 /* Set the type to ANY (or the store below will fail) */ 249 250 ((ACPI_NAMESPACE_NODE *) Node)->Type = ACPI_TYPE_ANY; 251 252 break; 253 254 255 default: 256 257 break; 258 } 259 260 261 /* Store constructed field descriptor in result location */ 262 263 Status = AcpiExStore (ObjDesc, (ACPI_OPERAND_OBJECT *) Node, 264 WalkState); 265 266 /* 267 * If the field descriptor was not physically stored (or if a failure 268 * above), we must delete it 269 */ 270 if (ObjDesc->Common.ReferenceCount <= 1) 271 { 272 AcpiUtRemoveReference (ObjDesc); 273 } 274 275 276 return_ACPI_STATUS (AE_OK); 277 278 279Cleanup: 280 281 /* Delete region object and method subobject */ 282 283 if (ObjDesc) 284 { 285 /* Remove deletes both objects! */ 286 287 AcpiUtRemoveReference (ObjDesc); 288 ObjDesc = NULL; 289 } 290 291 return_ACPI_STATUS (Status); 292} 293 294 295/***************************************************************************** 296 * 297 * FUNCTION: AcpiExCreateAlias 298 * 299 * PARAMETERS: WalkState - Current state, contains List of 300 * operands for the opcode 301 * 302 * RETURN: Status 303 * 304 * DESCRIPTION: Create a new named alias 305 * 306 ****************************************************************************/ 307 308ACPI_STATUS 309AcpiExCreateAlias ( 310 ACPI_WALK_STATE *WalkState) 311{ 312 ACPI_NAMESPACE_NODE *SourceNode; 313 ACPI_NAMESPACE_NODE *AliasNode; 314 ACPI_STATUS Status; 315 316 317 FUNCTION_TRACE ("ExCreateAlias"); 318 319 320 /* Get the source/alias operands (both namespace nodes) */ 321 322 Status = AcpiDsObjStackPopObject ((ACPI_OPERAND_OBJECT **) &SourceNode, 323 WalkState); 324 if (ACPI_FAILURE (Status)) 325 { 326 return_ACPI_STATUS (Status); 327 } 328 329 /* 330 * Don't pop it, it gets removed in the calling routine 331 */ 332 AliasNode = AcpiDsObjStackGetValue (0, WalkState); 333 334 /* Add an additional reference to the object */ 335 336 AcpiUtAddReference (SourceNode->Object); 337 338 /* 339 * Attach the original source Node to the new Alias Node. 340 */ 341 Status = AcpiNsAttachObject (AliasNode, SourceNode->Object, 342 SourceNode->Type); 343 344 345 /* 346 * The new alias assumes the type of the source, but it points 347 * to the same object. The reference count of the object has two 348 * additional references to prevent deletion out from under either the 349 * source or the alias Node 350 */ 351 352 /* Since both operands are Nodes, we don't need to delete them */ 353 354 return_ACPI_STATUS (Status); 355} 356 357 358/***************************************************************************** 359 * 360 * FUNCTION: AcpiExCreateEvent 361 * 362 * PARAMETERS: None 363 * 364 * RETURN: Status 365 * 366 * DESCRIPTION: Create a new event object 367 * 368 ****************************************************************************/ 369 370ACPI_STATUS 371AcpiExCreateEvent ( 372 ACPI_WALK_STATE *WalkState) 373{ 374 ACPI_STATUS Status; 375 ACPI_OPERAND_OBJECT *ObjDesc; 376 377 378 FUNCTION_TRACE ("ExCreateEvent"); 379 380 381 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_EVENT); 382 if (!ObjDesc) 383 { 384 Status = AE_NO_MEMORY; 385 goto Cleanup; 386 } 387 388 /* Create the actual OS semaphore */ 389 390 /* TBD: [Investigate] should be created with 0 or 1 units? */ 391 392 Status = AcpiOsCreateSemaphore (ACPI_NO_UNIT_LIMIT, 1, 393 &ObjDesc->Event.Semaphore); 394 if (ACPI_FAILURE (Status)) 395 { 396 AcpiUtRemoveReference (ObjDesc); 397 goto Cleanup; 398 } 399 400 /* Attach object to the Node */ 401 402 Status = AcpiNsAttachObject (AcpiDsObjStackGetValue (0, WalkState), 403 ObjDesc, (UINT8) ACPI_TYPE_EVENT); 404 if (ACPI_FAILURE (Status)) 405 { 406 AcpiOsDeleteSemaphore (ObjDesc->Event.Semaphore); 407 AcpiUtRemoveReference (ObjDesc); 408 goto Cleanup; 409 } 410 411 412Cleanup: 413 414 return_ACPI_STATUS (Status); 415} 416 417 418/***************************************************************************** 419 * 420 * FUNCTION: AcpiExCreateMutex 421 * 422 * PARAMETERS: InterpreterMode - Current running mode (load1/Load2/Exec) 423 * Operands - List of operands for the opcode 424 * 425 * RETURN: Status 426 * 427 * DESCRIPTION: Create a new mutex object 428 * 429 ****************************************************************************/ 430 431ACPI_STATUS 432AcpiExCreateMutex ( 433 ACPI_WALK_STATE *WalkState) 434{ 435 ACPI_STATUS Status = AE_OK; 436 ACPI_OPERAND_OBJECT *SyncDesc; 437 ACPI_OPERAND_OBJECT *ObjDesc; 438 439 440 FUNCTION_TRACE_PTR ("ExCreateMutex", WALK_OPERANDS); 441 442 443 /* Get the operand */ 444 445 Status = AcpiDsObjStackPopObject (&SyncDesc, WalkState); 446 if (ACPI_FAILURE (Status)) 447 { 448 return_ACPI_STATUS (Status); 449 } 450 451 /* Attempt to allocate a new object */ 452 453 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_MUTEX); 454 if (!ObjDesc) 455 { 456 Status = AE_NO_MEMORY; 457 goto Cleanup; 458 } 459 460 /* Create the actual OS semaphore */ 461 462 Status = AcpiOsCreateSemaphore (1, 1, &ObjDesc->Mutex.Semaphore); 463 if (ACPI_FAILURE (Status)) 464 { 465 AcpiUtRemoveReference (ObjDesc); 466 goto Cleanup; 467 } 468 469 ObjDesc->Mutex.SyncLevel = (UINT8) SyncDesc->Integer.Value; 470 471 /* ObjDesc was on the stack top, and the name is below it */ 472 473 Status = AcpiNsAttachObject (AcpiDsObjStackGetValue (0, WalkState), 474 ObjDesc, (UINT8) ACPI_TYPE_MUTEX); 475 if (ACPI_FAILURE (Status)) 476 { 477 AcpiOsDeleteSemaphore (ObjDesc->Mutex.Semaphore); 478 AcpiUtRemoveReference (ObjDesc); 479 goto Cleanup; 480 } 481 482 483Cleanup: 484 485 /* Always delete the operand */ 486 487 AcpiUtRemoveReference (SyncDesc); 488 489 return_ACPI_STATUS (Status); 490} 491 492 493/***************************************************************************** 494 * 495 * FUNCTION: AcpiExCreateRegion 496 * 497 * PARAMETERS: AmlPtr - Pointer to the region declaration AML 498 * AmlLength - Max length of the declaration AML 499 * Operands - List of operands for the opcode 500 * InterpreterMode - Load1/Load2/Execute 501 * 502 * RETURN: Status 503 * 504 * DESCRIPTION: Create a new operation region object 505 * 506 ****************************************************************************/ 507 508ACPI_STATUS 509AcpiExCreateRegion ( 510 UINT8 *AmlPtr, 511 UINT32 AmlLength, 512 UINT8 RegionSpace, 513 ACPI_WALK_STATE *WalkState) 514{ 515 ACPI_STATUS Status; 516 ACPI_OPERAND_OBJECT *ObjDesc; 517 ACPI_NAMESPACE_NODE *Node; 518 519 520 FUNCTION_TRACE ("ExCreateRegion"); 521 522 523 /* 524 * Space ID must be one of the predefined IDs, or in the user-defined 525 * range 526 */ 527 if ((RegionSpace >= NUM_REGION_TYPES) && 528 (RegionSpace < USER_REGION_BEGIN)) 529 { 530 REPORT_ERROR (("Invalid AddressSpace type %X\n", RegionSpace)); 531 return_ACPI_STATUS (AE_AML_INVALID_SPACE_ID); 532 } 533 534 ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Region Type - %s (%X)\n", 535 AcpiUtGetRegionName (RegionSpace), RegionSpace)); 536 537 538 /* Get the Node from the object stack */ 539 540 Node = (ACPI_NAMESPACE_NODE *) AcpiDsObjStackGetValue (0, WalkState); 541 542 /* Create the region descriptor */ 543 544 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_REGION); 545 if (!ObjDesc) 546 { 547 Status = AE_NO_MEMORY; 548 goto Cleanup; 549 } 550 551 /* 552 * Allocate a method object for this region. 553 */ 554 ObjDesc->Region.Extra = AcpiUtCreateInternalObject ( 555 INTERNAL_TYPE_EXTRA); 556 if (!ObjDesc->Region.Extra) 557 { 558 Status = AE_NO_MEMORY; 559 goto Cleanup; 560 } 561 562 /* 563 * Remember location in AML stream of address & length 564 * operands since they need to be evaluated at run time. 565 */ 566 ObjDesc->Region.Extra->Extra.Pcode = AmlPtr; 567 ObjDesc->Region.Extra->Extra.PcodeLength = AmlLength; 568 569 /* Init the region from the operands */ 570 571 ObjDesc->Region.SpaceId = RegionSpace; 572 ObjDesc->Region.Address = 0; 573 ObjDesc->Region.Length = 0; 574 575 576 /* Install the new region object in the parent Node */ 577 578 ObjDesc->Region.Node = Node; 579 580 Status = AcpiNsAttachObject (Node, ObjDesc, 581 (UINT8) ACPI_TYPE_REGION); 582 583 if (ACPI_FAILURE (Status)) 584 { 585 goto Cleanup; 586 } 587 588 /* 589 * If we have a valid region, initialize it 590 * Namespace is NOT locked at this point. 591 */ 592 Status = AcpiEvInitializeRegion (ObjDesc, FALSE); 593 594 if (ACPI_FAILURE (Status)) 595 { 596 /* 597 * If AE_NOT_EXIST is returned, it is not fatal 598 * because many regions get created before a handler 599 * is installed for said region. 600 */ 601 if (AE_NOT_EXIST == Status) 602 { 603 Status = AE_OK; 604 } 605 } 606 607Cleanup: 608 609 if (ACPI_FAILURE (Status)) 610 { 611 /* Delete region object and method subobject */ 612 613 if (ObjDesc) 614 { 615 /* Remove deletes both objects! */ 616 617 AcpiUtRemoveReference (ObjDesc); 618 ObjDesc = NULL; 619 } 620 } 621 622 return_ACPI_STATUS (Status); 623} 624 625 626/***************************************************************************** 627 * 628 * FUNCTION: AcpiExCreateProcessor 629 * 630 * PARAMETERS: Op - Op containing the Processor definition and 631 * args 632 * ProcessorNode - Parent Node for the processor object 633 * 634 * RETURN: Status 635 * 636 * DESCRIPTION: Create a new processor object and populate the fields 637 * 638 ****************************************************************************/ 639 640ACPI_STATUS 641AcpiExCreateProcessor ( 642 ACPI_PARSE_OBJECT *Op, 643 ACPI_NAMESPACE_NODE *ProcessorNode) 644{ 645 ACPI_STATUS Status; 646 ACPI_PARSE_OBJECT *Arg; 647 ACPI_OPERAND_OBJECT *ObjDesc; 648 649 650 FUNCTION_TRACE_PTR ("ExCreateProcessor", Op); 651 652 653 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_PROCESSOR); 654 if (!ObjDesc) 655 { 656 return_ACPI_STATUS (AE_NO_MEMORY); 657 } 658 659 /* Install the new processor object in the parent Node */ 660 661 Status = AcpiNsAttachObject (ProcessorNode, ObjDesc, 662 (UINT8) ACPI_TYPE_PROCESSOR); 663 if (ACPI_FAILURE (Status)) 664 { 665 AcpiUtDeleteObjectDesc (ObjDesc); 666 return_ACPI_STATUS (Status); 667 } 668 669 /* Get first arg and verify existence */ 670 671 Arg = Op->Value.Arg; 672 if (!Arg) 673 { 674 return_ACPI_STATUS (AE_AML_NO_OPERAND); 675 } 676 677 /* First arg is the Processor ID */ 678 679 ObjDesc->Processor.ProcId = (UINT8) Arg->Value.Integer; 680 681 /* Get second arg and verify existence */ 682 683 Arg = Arg->Next; 684 if (!Arg) 685 { 686 return_ACPI_STATUS (AE_AML_NO_OPERAND); 687 } 688 689 /* Second arg is the PBlock Address */ 690 691 ObjDesc->Processor.Address = (ACPI_IO_ADDRESS) Arg->Value.Integer; 692 693 /* Get third arg and verify existence */ 694 695 Arg = Arg->Next; 696 if (!Arg) 697 { 698 return_ACPI_STATUS (AE_AML_NO_OPERAND); 699 } 700 701 /* Third arg is the PBlock Length */ 702 703 ObjDesc->Processor.Length = (UINT8) Arg->Value.Integer; 704 return_ACPI_STATUS (AE_OK); 705} 706 707 708/***************************************************************************** 709 * 710 * FUNCTION: AcpiExCreatePowerResource 711 * 712 * PARAMETERS: Op - Op containing the PowerResource definition 713 * and args 714 * PowerNode - Parent Node for the power object 715 * 716 * RETURN: Status 717 * 718 * DESCRIPTION: Create a new PowerResource object and populate the fields 719 * 720 ****************************************************************************/ 721 722ACPI_STATUS 723AcpiExCreatePowerResource ( 724 ACPI_PARSE_OBJECT *Op, 725 ACPI_NAMESPACE_NODE *PowerNode) 726{ 727 ACPI_STATUS Status; 728 ACPI_PARSE_OBJECT *Arg; 729 ACPI_OPERAND_OBJECT *ObjDesc; 730 731 732 FUNCTION_TRACE_PTR ("ExCreatePowerResource", Op); 733 734 735 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_POWER); 736 if (!ObjDesc) 737 { 738 return_ACPI_STATUS (AE_NO_MEMORY); 739 } 740 741 /* Install the new power resource object in the parent Node */ 742 743 Status = AcpiNsAttachObject (PowerNode, ObjDesc, 744 (UINT8) ACPI_TYPE_POWER); 745 if (ACPI_FAILURE (Status)) 746 { 747 return_ACPI_STATUS(Status); 748 } 749 750 751 /* Get first arg and verify existence */ 752 753 Arg = Op->Value.Arg; 754 if (!Arg) 755 { 756 return_ACPI_STATUS (AE_AML_NO_OPERAND); 757 } 758 759 /* First arg is the SystemLevel */ 760 761 ObjDesc->PowerResource.SystemLevel = (UINT8) Arg->Value.Integer; 762 763 /* Get second arg and check existence */ 764 765 Arg = Arg->Next; 766 if (!Arg) 767 { 768 return_ACPI_STATUS (AE_AML_NO_OPERAND); 769 } 770 771 /* Second arg is the PBlock Address */ 772 773 ObjDesc->PowerResource.ResourceOrder = (UINT16) Arg->Value.Integer; 774 775 return_ACPI_STATUS (AE_OK); 776} 777 778 779/***************************************************************************** 780 * 781 * FUNCTION: AcpiExCreateMethod 782 * 783 * PARAMETERS: AmlPtr - First byte of the method's AML 784 * AmlLength - AML byte count for this method 785 * MethodFlags - AML method flag byte 786 * Method - Method Node 787 * 788 * RETURN: Status 789 * 790 * DESCRIPTION: Create a new method object 791 * 792 ****************************************************************************/ 793 794ACPI_STATUS 795AcpiExCreateMethod ( 796 UINT8 *AmlPtr, 797 UINT32 AmlLength, 798 UINT32 MethodFlags, 799 ACPI_NAMESPACE_NODE *Method) 800{ 801 ACPI_OPERAND_OBJECT *ObjDesc; 802 ACPI_STATUS Status; 803 804 805 FUNCTION_TRACE_PTR ("ExCreateMethod", Method); 806 807 808 /* Create a new method object */ 809 810 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_METHOD); 811 if (!ObjDesc) 812 { 813 return_ACPI_STATUS (AE_NO_MEMORY); 814 } 815 816 /* Get the method's AML pointer/length from the Op */ 817 818 ObjDesc->Method.Pcode = AmlPtr; 819 ObjDesc->Method.PcodeLength = AmlLength; 820 821 /* 822 * First argument is the Method Flags (contains parameter count for the 823 * method) 824 */ 825 ObjDesc->Method.MethodFlags = (UINT8) MethodFlags; 826 ObjDesc->Method.ParamCount = (UINT8) (MethodFlags & 827 METHOD_FLAGS_ARG_COUNT); 828 829 /* 830 * Get the concurrency count. If required, a semaphore will be 831 * created for this method when it is parsed. 832 */ 833 if (MethodFlags & METHOD_FLAGS_SERIALIZED) 834 { 835 /* 836 * ACPI 1.0: Concurrency = 1 837 * ACPI 2.0: Concurrency = (SyncLevel (in method declaration) + 1) 838 */ 839 ObjDesc->Method.Concurrency = (UINT8) 840 (((MethodFlags & METHOD_FLAGS_SYNCH_LEVEL) >> 4) + 1); 841 } 842 843 else 844 { 845 ObjDesc->Method.Concurrency = INFINITE_CONCURRENCY; 846 } 847 848 /* Attach the new object to the method Node */ 849 850 Status = AcpiNsAttachObject (Method, ObjDesc, (UINT8) ACPI_TYPE_METHOD); 851 if (ACPI_FAILURE (Status)) 852 { 853 AcpiUtDeleteObjectDesc (ObjDesc); 854 } 855 856 return_ACPI_STATUS (Status); 857} 858 859 860