excreate.c revision 77424
1/****************************************************************************** 2 * 3 * Module Name: excreate - Named object creation 4 * $Revision: 63 $ 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 191 ObjDesc->BufferField.Extra = AcpiUtCreateInternalObject ( 192 INTERNAL_TYPE_EXTRA); 193 if (!ObjDesc->BufferField.Extra) 194 { 195 Status = AE_NO_MEMORY; 196 goto Cleanup; 197 } 198 199 /* 200 * Remember location in AML stream of the field unit 201 * opcode and operands -- since the buffer and index 202 * operands must be evaluated. 203 */ 204 205 ObjDesc->BufferField.Extra->Extra.Pcode = AmlPtr; 206 ObjDesc->BufferField.Extra->Extra.PcodeLength = AmlLength; 207 ObjDesc->BufferField.Node = Node; 208 209 210 /* 211 * This operation is supposed to cause the destination Name to refer 212 * to the defined BufferField -- it must not store the constructed 213 * BufferField object (or its current value) in some location that the 214 * Name may already be pointing to. So, if the Name currently contains 215 * a reference which would cause AcpiExStore() to perform an indirect 216 * store rather than setting the value of the Name itself, clobber that 217 * reference before calling AcpiExStore(). 218 */ 219 220 /* Type of Name's existing value */ 221 222 switch (AcpiNsGetType (Node)) 223 { 224 225 case ACPI_TYPE_BUFFER_FIELD: 226 case INTERNAL_TYPE_ALIAS: 227 case INTERNAL_TYPE_REGION_FIELD: 228 case INTERNAL_TYPE_BANK_FIELD: 229 case INTERNAL_TYPE_INDEX_FIELD: 230 231 TmpDesc = AcpiNsGetAttachedObject (Node); 232 if (TmpDesc) 233 { 234 /* 235 * There is an existing object here; delete it and zero out the 236 * object field within the Node 237 */ 238 239 DUMP_PATHNAME (Node, 240 "ExCreateBufferField: Removing Current Reference", 241 TRACE_BFIELD, _COMPONENT); 242 243 DUMP_ENTRY (Node, TRACE_BFIELD); 244 DUMP_STACK_ENTRY (TmpDesc); 245 246 AcpiUtRemoveReference (TmpDesc); 247 AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Node, NULL, 248 ACPI_TYPE_ANY); 249 } 250 251 /* Set the type to ANY (or the store below will fail) */ 252 253 ((ACPI_NAMESPACE_NODE *) Node)->Type = ACPI_TYPE_ANY; 254 255 break; 256 257 258 default: 259 260 break; 261 } 262 263 264 /* Store constructed field descriptor in result location */ 265 266 Status = AcpiExStore (ObjDesc, (ACPI_OPERAND_OBJECT *) Node, 267 WalkState); 268 269 /* 270 * If the field descriptor was not physically stored (or if a failure 271 * above), we must delete it 272 */ 273 if (ObjDesc->Common.ReferenceCount <= 1) 274 { 275 AcpiUtRemoveReference (ObjDesc); 276 } 277 278 279 return_ACPI_STATUS (AE_OK); 280 281 282Cleanup: 283 284 /* Delete region object and method subobject */ 285 286 if (ObjDesc) 287 { 288 /* Remove deletes both objects! */ 289 290 AcpiUtRemoveReference (ObjDesc); 291 ObjDesc = NULL; 292 } 293 294 return_ACPI_STATUS (Status); 295} 296 297 298/***************************************************************************** 299 * 300 * FUNCTION: AcpiExCreateAlias 301 * 302 * PARAMETERS: WalkState - Current state, contains List of 303 * operands for the opcode 304 * 305 * RETURN: Status 306 * 307 * DESCRIPTION: Create a new named alias 308 * 309 ****************************************************************************/ 310 311ACPI_STATUS 312AcpiExCreateAlias ( 313 ACPI_WALK_STATE *WalkState) 314{ 315 ACPI_NAMESPACE_NODE *SourceNode; 316 ACPI_NAMESPACE_NODE *AliasNode; 317 ACPI_STATUS Status; 318 319 320 FUNCTION_TRACE ("ExCreateAlias"); 321 322 323 /* Get the source/alias operands (both namespace nodes) */ 324 325 Status = AcpiDsObjStackPopObject ((ACPI_OPERAND_OBJECT **) &SourceNode, 326 WalkState); 327 if (ACPI_FAILURE (Status)) 328 { 329 return_ACPI_STATUS (Status); 330 } 331 332 /* 333 * Don't pop it, it gets removed in the calling routine 334 */ 335 AliasNode = AcpiDsObjStackGetValue (0, WalkState); 336 337 /* Add an additional reference to the object */ 338 339 AcpiUtAddReference (SourceNode->Object); 340 341 /* 342 * Attach the original source Node to the new Alias Node. 343 */ 344 Status = AcpiNsAttachObject (AliasNode, SourceNode->Object, 345 SourceNode->Type); 346 347 348 /* 349 * The new alias assumes the type of the source, but it points 350 * to the same object. The reference count of the object has two 351 * additional references to prevent deletion out from under either the 352 * source or the alias Node 353 */ 354 355 /* Since both operands are Nodes, we don't need to delete them */ 356 357 return_ACPI_STATUS (Status); 358} 359 360 361/***************************************************************************** 362 * 363 * FUNCTION: AcpiExCreateEvent 364 * 365 * PARAMETERS: None 366 * 367 * RETURN: Status 368 * 369 * DESCRIPTION: Create a new event object 370 * 371 ****************************************************************************/ 372 373ACPI_STATUS 374AcpiExCreateEvent ( 375 ACPI_WALK_STATE *WalkState) 376{ 377 ACPI_STATUS Status; 378 ACPI_OPERAND_OBJECT *ObjDesc; 379 380 381 FUNCTION_TRACE ("ExCreateEvent"); 382 383 384 BREAKPOINT3; 385 386 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_EVENT); 387 if (!ObjDesc) 388 { 389 Status = AE_NO_MEMORY; 390 goto Cleanup; 391 } 392 393 /* Create the actual OS semaphore */ 394 395 /* TBD: [Investigate] should be created with 0 or 1 units? */ 396 397 Status = AcpiOsCreateSemaphore (ACPI_NO_UNIT_LIMIT, 1, 398 &ObjDesc->Event.Semaphore); 399 if (ACPI_FAILURE (Status)) 400 { 401 AcpiUtRemoveReference (ObjDesc); 402 goto Cleanup; 403 } 404 405 /* Attach object to the Node */ 406 407 Status = AcpiNsAttachObject (AcpiDsObjStackGetValue (0, WalkState), 408 ObjDesc, (UINT8) ACPI_TYPE_EVENT); 409 if (ACPI_FAILURE (Status)) 410 { 411 AcpiOsDeleteSemaphore (ObjDesc->Event.Semaphore); 412 AcpiUtRemoveReference (ObjDesc); 413 goto Cleanup; 414 } 415 416 417Cleanup: 418 419 return_ACPI_STATUS (Status); 420} 421 422 423/***************************************************************************** 424 * 425 * FUNCTION: AcpiExCreateMutex 426 * 427 * PARAMETERS: InterpreterMode - Current running mode (load1/Load2/Exec) 428 * Operands - List of operands for the opcode 429 * 430 * RETURN: Status 431 * 432 * DESCRIPTION: Create a new mutex object 433 * 434 ****************************************************************************/ 435 436ACPI_STATUS 437AcpiExCreateMutex ( 438 ACPI_WALK_STATE *WalkState) 439{ 440 ACPI_STATUS Status = AE_OK; 441 ACPI_OPERAND_OBJECT *SyncDesc; 442 ACPI_OPERAND_OBJECT *ObjDesc; 443 444 445 FUNCTION_TRACE_PTR ("ExCreateMutex", WALK_OPERANDS); 446 447 448 /* Get the operand */ 449 450 Status = AcpiDsObjStackPopObject (&SyncDesc, WalkState); 451 if (ACPI_FAILURE (Status)) 452 { 453 return_ACPI_STATUS (Status); 454 } 455 456 /* Attempt to allocate a new object */ 457 458 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_MUTEX); 459 if (!ObjDesc) 460 { 461 Status = AE_NO_MEMORY; 462 goto Cleanup; 463 } 464 465 /* Create the actual OS semaphore */ 466 467 Status = AcpiOsCreateSemaphore (1, 1, &ObjDesc->Mutex.Semaphore); 468 if (ACPI_FAILURE (Status)) 469 { 470 AcpiUtRemoveReference (ObjDesc); 471 goto Cleanup; 472 } 473 474 ObjDesc->Mutex.SyncLevel = (UINT8) SyncDesc->Integer.Value; 475 476 /* ObjDesc was on the stack top, and the name is below it */ 477 478 Status = AcpiNsAttachObject (AcpiDsObjStackGetValue (0, WalkState), 479 ObjDesc, (UINT8) ACPI_TYPE_MUTEX); 480 if (ACPI_FAILURE (Status)) 481 { 482 AcpiOsDeleteSemaphore (ObjDesc->Mutex.Semaphore); 483 AcpiUtRemoveReference (ObjDesc); 484 goto Cleanup; 485 } 486 487 488Cleanup: 489 490 /* Always delete the operand */ 491 492 AcpiUtRemoveReference (SyncDesc); 493 494 return_ACPI_STATUS (Status); 495} 496 497 498/***************************************************************************** 499 * 500 * FUNCTION: AcpiExCreateRegion 501 * 502 * PARAMETERS: AmlPtr - Pointer to the region declaration AML 503 * AmlLength - Max length of the declaration AML 504 * Operands - List of operands for the opcode 505 * InterpreterMode - Load1/Load2/Execute 506 * 507 * RETURN: Status 508 * 509 * DESCRIPTION: Create a new operation region object 510 * 511 ****************************************************************************/ 512 513ACPI_STATUS 514AcpiExCreateRegion ( 515 UINT8 *AmlPtr, 516 UINT32 AmlLength, 517 UINT8 RegionSpace, 518 ACPI_WALK_STATE *WalkState) 519{ 520 ACPI_STATUS Status; 521 ACPI_OPERAND_OBJECT *ObjDesc; 522 ACPI_NAMESPACE_NODE *Node; 523 524 525 FUNCTION_TRACE ("ExCreateRegion"); 526 527 528 /* 529 * Space ID must be one of the predefined IDs, or in the user-defined 530 * range 531 */ 532 if ((RegionSpace >= NUM_REGION_TYPES) && 533 (RegionSpace < USER_REGION_BEGIN)) 534 { 535 REPORT_ERROR (("Invalid AddressSpace type %X\n", RegionSpace)); 536 return_ACPI_STATUS (AE_AML_INVALID_SPACE_ID); 537 } 538 539 DEBUG_PRINTP (TRACE_LOAD, ("Region Type - %s (%X)\n", 540 AcpiUtGetRegionName (RegionSpace), RegionSpace)); 541 542 543 /* Get the Node from the object stack */ 544 545 Node = (ACPI_NAMESPACE_NODE *) AcpiDsObjStackGetValue (0, WalkState); 546 547 /* Create the region descriptor */ 548 549 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_REGION); 550 if (!ObjDesc) 551 { 552 Status = AE_NO_MEMORY; 553 goto Cleanup; 554 } 555 556 /* 557 * Allocate a method object for this region. 558 */ 559 560 ObjDesc->Region.Extra = AcpiUtCreateInternalObject ( 561 INTERNAL_TYPE_EXTRA); 562 if (!ObjDesc->Region.Extra) 563 { 564 Status = AE_NO_MEMORY; 565 goto Cleanup; 566 } 567 568 /* 569 * Remember location in AML stream of address & length 570 * operands since they need to be evaluated at run time. 571 */ 572 573 ObjDesc->Region.Extra->Extra.Pcode = AmlPtr; 574 ObjDesc->Region.Extra->Extra.PcodeLength = AmlLength; 575 576 /* Init the region from the operands */ 577 578 ObjDesc->Region.SpaceId = RegionSpace; 579 ObjDesc->Region.Address = 0; 580 ObjDesc->Region.Length = 0; 581 582 583 /* Install the new region object in the parent Node */ 584 585 ObjDesc->Region.Node = Node; 586 587 Status = AcpiNsAttachObject (Node, ObjDesc, 588 (UINT8) ACPI_TYPE_REGION); 589 590 if (ACPI_FAILURE (Status)) 591 { 592 goto Cleanup; 593 } 594 595 /* 596 * If we have a valid region, initialize it 597 * Namespace is NOT locked at this point. 598 */ 599 600 Status = AcpiEvInitializeRegion (ObjDesc, FALSE); 601 602 if (ACPI_FAILURE (Status)) 603 { 604 /* 605 * If AE_NOT_EXIST is returned, it is not fatal 606 * because many regions get created before a handler 607 * is installed for said region. 608 */ 609 if (AE_NOT_EXIST == Status) 610 { 611 Status = AE_OK; 612 } 613 } 614 615Cleanup: 616 617 if (ACPI_FAILURE (Status)) 618 { 619 /* Delete region object and method subobject */ 620 621 if (ObjDesc) 622 { 623 /* Remove deletes both objects! */ 624 625 AcpiUtRemoveReference (ObjDesc); 626 ObjDesc = NULL; 627 } 628 } 629 630 return_ACPI_STATUS (Status); 631} 632 633 634/***************************************************************************** 635 * 636 * FUNCTION: AcpiExCreateProcessor 637 * 638 * PARAMETERS: Op - Op containing the Processor definition and 639 * args 640 * ProcessorNode - Parent Node for the processor object 641 * 642 * RETURN: Status 643 * 644 * DESCRIPTION: Create a new processor object and populate the fields 645 * 646 ****************************************************************************/ 647 648ACPI_STATUS 649AcpiExCreateProcessor ( 650 ACPI_PARSE_OBJECT *Op, 651 ACPI_NAMESPACE_NODE *ProcessorNode) 652{ 653 ACPI_STATUS Status; 654 ACPI_PARSE_OBJECT *Arg; 655 ACPI_OPERAND_OBJECT *ObjDesc; 656 657 658 FUNCTION_TRACE_PTR ("ExCreateProcessor", Op); 659 660 661 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_PROCESSOR); 662 if (!ObjDesc) 663 { 664 return_ACPI_STATUS (AE_NO_MEMORY); 665 } 666 667 /* Install the new processor object in the parent Node */ 668 669 Status = AcpiNsAttachObject (ProcessorNode, ObjDesc, 670 (UINT8) ACPI_TYPE_PROCESSOR); 671 if (ACPI_FAILURE (Status)) 672 { 673 AcpiUtDeleteObjectDesc (ObjDesc); 674 return_ACPI_STATUS (Status); 675 } 676 677 /* Get first arg and verify existence */ 678 679 Arg = Op->Value.Arg; 680 if (!Arg) 681 { 682 return_ACPI_STATUS (AE_AML_NO_OPERAND); 683 } 684 685 /* First arg is the Processor ID */ 686 687 ObjDesc->Processor.ProcId = (UINT8) Arg->Value.Integer; 688 689 /* Get second arg and verify existence */ 690 691 Arg = Arg->Next; 692 if (!Arg) 693 { 694 return_ACPI_STATUS (AE_AML_NO_OPERAND); 695 } 696 697 /* Second arg is the PBlock Address */ 698 699 ObjDesc->Processor.Address = (ACPI_IO_ADDRESS) Arg->Value.Integer; 700 701 /* Get third arg and verify existence */ 702 703 Arg = Arg->Next; 704 if (!Arg) 705 { 706 return_ACPI_STATUS (AE_AML_NO_OPERAND); 707 } 708 709 /* Third arg is the PBlock Length */ 710 711 ObjDesc->Processor.Length = (UINT8) Arg->Value.Integer; 712 return_ACPI_STATUS (AE_OK); 713} 714 715 716/***************************************************************************** 717 * 718 * FUNCTION: AcpiExCreatePowerResource 719 * 720 * PARAMETERS: Op - Op containing the PowerResource definition 721 * and args 722 * PowerNode - Parent Node for the power object 723 * 724 * RETURN: Status 725 * 726 * DESCRIPTION: Create a new PowerResource object and populate the fields 727 * 728 ****************************************************************************/ 729 730ACPI_STATUS 731AcpiExCreatePowerResource ( 732 ACPI_PARSE_OBJECT *Op, 733 ACPI_NAMESPACE_NODE *PowerNode) 734{ 735 ACPI_STATUS Status; 736 ACPI_PARSE_OBJECT *Arg; 737 ACPI_OPERAND_OBJECT *ObjDesc; 738 739 740 FUNCTION_TRACE_PTR ("ExCreatePowerResource", Op); 741 742 743 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_POWER); 744 if (!ObjDesc) 745 { 746 return_ACPI_STATUS (AE_NO_MEMORY); 747 } 748 749 /* Install the new power resource object in the parent Node */ 750 751 Status = AcpiNsAttachObject (PowerNode, ObjDesc, 752 (UINT8) ACPI_TYPE_POWER); 753 if (ACPI_FAILURE (Status)) 754 { 755 return_ACPI_STATUS(Status); 756 } 757 758 759 /* Get first arg and verify existence */ 760 761 Arg = Op->Value.Arg; 762 if (!Arg) 763 { 764 return_ACPI_STATUS (AE_AML_NO_OPERAND); 765 } 766 767 /* First arg is the SystemLevel */ 768 769 ObjDesc->PowerResource.SystemLevel = (UINT8) Arg->Value.Integer; 770 771 /* Get second arg and check existence */ 772 773 Arg = Arg->Next; 774 if (!Arg) 775 { 776 return_ACPI_STATUS (AE_AML_NO_OPERAND); 777 } 778 779 /* Second arg is the PBlock Address */ 780 781 ObjDesc->PowerResource.ResourceOrder = (UINT16) Arg->Value.Integer; 782 783 return_ACPI_STATUS (AE_OK); 784} 785 786 787/***************************************************************************** 788 * 789 * FUNCTION: AcpiExCreateMethod 790 * 791 * PARAMETERS: AmlPtr - First byte of the method's AML 792 * AmlLength - AML byte count for this method 793 * MethodFlags - AML method flag byte 794 * Method - Method Node 795 * 796 * RETURN: Status 797 * 798 * DESCRIPTION: Create a new method object 799 * 800 ****************************************************************************/ 801 802ACPI_STATUS 803AcpiExCreateMethod ( 804 UINT8 *AmlPtr, 805 UINT32 AmlLength, 806 UINT32 MethodFlags, 807 ACPI_NAMESPACE_NODE *Method) 808{ 809 ACPI_OPERAND_OBJECT *ObjDesc; 810 ACPI_STATUS Status; 811 812 813 FUNCTION_TRACE_PTR ("ExCreateMethod", Method); 814 815 816 /* Create a new method object */ 817 818 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_METHOD); 819 if (!ObjDesc) 820 { 821 return_ACPI_STATUS (AE_NO_MEMORY); 822 } 823 824 /* Get the method's AML pointer/length from the Op */ 825 826 ObjDesc->Method.Pcode = AmlPtr; 827 ObjDesc->Method.PcodeLength = AmlLength; 828 829 /* 830 * First argument is the Method Flags (contains parameter count for the 831 * method) 832 */ 833 834 ObjDesc->Method.MethodFlags = (UINT8) MethodFlags; 835 ObjDesc->Method.ParamCount = (UINT8) (MethodFlags & 836 METHOD_FLAGS_ARG_COUNT); 837 838 /* 839 * Get the concurrency count. If required, a semaphore will be 840 * created for this method when it is parsed. 841 */ 842 if (MethodFlags & METHOD_FLAGS_SERIALIZED) 843 { 844 /* 845 * ACPI 1.0: Concurrency = 1 846 * ACPI 2.0: Concurrency = (SyncLevel (in method declaration) + 1) 847 */ 848 ObjDesc->Method.Concurrency = (UINT8) 849 (((MethodFlags & METHOD_FLAGS_SYNCH_LEVEL) >> 4) + 1); 850 } 851 852 else 853 { 854 ObjDesc->Method.Concurrency = INFINITE_CONCURRENCY; 855 } 856 857 /* Attach the new object to the method Node */ 858 859 Status = AcpiNsAttachObject (Method, ObjDesc, (UINT8) ACPI_TYPE_METHOD); 860 if (ACPI_FAILURE (Status)) 861 { 862 AcpiUtDeleteObjectDesc (ObjDesc); 863 } 864 865 return_ACPI_STATUS (Status); 866} 867 868 869