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