excreate.c revision 193259
1/****************************************************************************** 2 * 3 * Module Name: excreate - Named object creation 4 * $Revision: 1.114 $ 5 * 6 *****************************************************************************/ 7 8/****************************************************************************** 9 * 10 * 1. Copyright Notice 11 * 12 * Some or all of this work - Copyright (c) 1999 - 2007, 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 "acinterp.h" 122#include "amlcode.h" 123#include "acnamesp.h" 124#include "acevents.h" 125#include "actables.h" 126 127 128#define _COMPONENT ACPI_EXECUTER 129 ACPI_MODULE_NAME ("excreate") 130 131 132#ifndef ACPI_NO_METHOD_EXECUTION 133/******************************************************************************* 134 * 135 * FUNCTION: AcpiExCreateAlias 136 * 137 * PARAMETERS: WalkState - Current state, contains operands 138 * 139 * RETURN: Status 140 * 141 * DESCRIPTION: Create a new named alias 142 * 143 ******************************************************************************/ 144 145ACPI_STATUS 146AcpiExCreateAlias ( 147 ACPI_WALK_STATE *WalkState) 148{ 149 ACPI_NAMESPACE_NODE *TargetNode; 150 ACPI_NAMESPACE_NODE *AliasNode; 151 ACPI_STATUS Status = AE_OK; 152 153 154 ACPI_FUNCTION_TRACE (ExCreateAlias); 155 156 157 /* Get the source/alias operands (both namespace nodes) */ 158 159 AliasNode = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0]; 160 TargetNode = (ACPI_NAMESPACE_NODE *) WalkState->Operands[1]; 161 162 if ((TargetNode->Type == ACPI_TYPE_LOCAL_ALIAS) || 163 (TargetNode->Type == ACPI_TYPE_LOCAL_METHOD_ALIAS)) 164 { 165 /* 166 * Dereference an existing alias so that we don't create a chain 167 * of aliases. With this code, we guarantee that an alias is 168 * always exactly one level of indirection away from the 169 * actual aliased name. 170 */ 171 TargetNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, TargetNode->Object); 172 } 173 174 /* 175 * For objects that can never change (i.e., the NS node will 176 * permanently point to the same object), we can simply attach 177 * the object to the new NS node. For other objects (such as 178 * Integers, buffers, etc.), we have to point the Alias node 179 * to the original Node. 180 */ 181 switch (TargetNode->Type) 182 { 183 case ACPI_TYPE_INTEGER: 184 case ACPI_TYPE_STRING: 185 case ACPI_TYPE_BUFFER: 186 case ACPI_TYPE_PACKAGE: 187 case ACPI_TYPE_BUFFER_FIELD: 188 189 /* 190 * The new alias has the type ALIAS and points to the original 191 * NS node, not the object itself. This is because for these 192 * types, the object can change dynamically via a Store. 193 */ 194 AliasNode->Type = ACPI_TYPE_LOCAL_ALIAS; 195 AliasNode->Object = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, TargetNode); 196 break; 197 198 case ACPI_TYPE_METHOD: 199 200 /* 201 * The new alias has the type ALIAS and points to the original 202 * NS node, not the object itself. This is because for these 203 * types, the object can change dynamically via a Store. 204 */ 205 AliasNode->Type = ACPI_TYPE_LOCAL_METHOD_ALIAS; 206 AliasNode->Object = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, TargetNode); 207 break; 208 209 default: 210 211 /* Attach the original source object to the new Alias Node */ 212 213 /* 214 * The new alias assumes the type of the target, and it points 215 * to the same object. The reference count of the object has an 216 * additional reference to prevent deletion out from under either the 217 * target node or the alias Node 218 */ 219 Status = AcpiNsAttachObject (AliasNode, 220 AcpiNsGetAttachedObject (TargetNode), TargetNode->Type); 221 break; 222 } 223 224 /* Since both operands are Nodes, we don't need to delete them */ 225 226 return_ACPI_STATUS (Status); 227} 228 229 230/******************************************************************************* 231 * 232 * FUNCTION: AcpiExCreateEvent 233 * 234 * PARAMETERS: WalkState - Current state 235 * 236 * RETURN: Status 237 * 238 * DESCRIPTION: Create a new event object 239 * 240 ******************************************************************************/ 241 242ACPI_STATUS 243AcpiExCreateEvent ( 244 ACPI_WALK_STATE *WalkState) 245{ 246 ACPI_STATUS Status; 247 ACPI_OPERAND_OBJECT *ObjDesc; 248 249 250 ACPI_FUNCTION_TRACE (ExCreateEvent); 251 252 253 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_EVENT); 254 if (!ObjDesc) 255 { 256 Status = AE_NO_MEMORY; 257 goto Cleanup; 258 } 259 260 /* 261 * Create the actual OS semaphore, with zero initial units -- meaning 262 * that the event is created in an unsignalled state 263 */ 264 Status = AcpiOsCreateSemaphore (ACPI_NO_UNIT_LIMIT, 0, 265 &ObjDesc->Event.OsSemaphore); 266 if (ACPI_FAILURE (Status)) 267 { 268 goto Cleanup; 269 } 270 271 /* Attach object to the Node */ 272 273 Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) WalkState->Operands[0], 274 ObjDesc, ACPI_TYPE_EVENT); 275 276Cleanup: 277 /* 278 * Remove local reference to the object (on error, will cause deletion 279 * of both object and semaphore if present.) 280 */ 281 AcpiUtRemoveReference (ObjDesc); 282 return_ACPI_STATUS (Status); 283} 284 285 286/******************************************************************************* 287 * 288 * FUNCTION: AcpiExCreateMutex 289 * 290 * PARAMETERS: WalkState - Current state 291 * 292 * RETURN: Status 293 * 294 * DESCRIPTION: Create a new mutex object 295 * 296 * Mutex (Name[0], SyncLevel[1]) 297 * 298 ******************************************************************************/ 299 300ACPI_STATUS 301AcpiExCreateMutex ( 302 ACPI_WALK_STATE *WalkState) 303{ 304 ACPI_STATUS Status = AE_OK; 305 ACPI_OPERAND_OBJECT *ObjDesc; 306 307 308 ACPI_FUNCTION_TRACE_PTR (ExCreateMutex, ACPI_WALK_OPERANDS); 309 310 311 /* Create the new mutex object */ 312 313 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_MUTEX); 314 if (!ObjDesc) 315 { 316 Status = AE_NO_MEMORY; 317 goto Cleanup; 318 } 319 320 /* Create the actual OS Mutex */ 321 322 Status = AcpiOsCreateMutex (&ObjDesc->Mutex.OsMutex); 323 if (ACPI_FAILURE (Status)) 324 { 325 goto Cleanup; 326 } 327 328 /* Init object and attach to NS node */ 329 330 ObjDesc->Mutex.SyncLevel = (UINT8) WalkState->Operands[1]->Integer.Value; 331 ObjDesc->Mutex.Node = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0]; 332 333 Status = AcpiNsAttachObject (ObjDesc->Mutex.Node, ObjDesc, ACPI_TYPE_MUTEX); 334 335 336Cleanup: 337 /* 338 * Remove local reference to the object (on error, will cause deletion 339 * of both object and semaphore if present.) 340 */ 341 AcpiUtRemoveReference (ObjDesc); 342 return_ACPI_STATUS (Status); 343} 344 345 346/******************************************************************************* 347 * 348 * FUNCTION: AcpiExCreateRegion 349 * 350 * PARAMETERS: AmlStart - Pointer to the region declaration AML 351 * AmlLength - Max length of the declaration AML 352 * RegionSpace - SpaceID for the region 353 * WalkState - Current state 354 * 355 * RETURN: Status 356 * 357 * DESCRIPTION: Create a new operation region object 358 * 359 ******************************************************************************/ 360 361ACPI_STATUS 362AcpiExCreateRegion ( 363 UINT8 *AmlStart, 364 UINT32 AmlLength, 365 UINT8 RegionSpace, 366 ACPI_WALK_STATE *WalkState) 367{ 368 ACPI_STATUS Status; 369 ACPI_OPERAND_OBJECT *ObjDesc; 370 ACPI_NAMESPACE_NODE *Node; 371 ACPI_OPERAND_OBJECT *RegionObj2; 372 373 374 ACPI_FUNCTION_TRACE (ExCreateRegion); 375 376 377 /* Get the Namespace Node */ 378 379 Node = WalkState->Op->Common.Node; 380 381 /* 382 * If the region object is already attached to this node, 383 * just return 384 */ 385 if (AcpiNsGetAttachedObject (Node)) 386 { 387 return_ACPI_STATUS (AE_OK); 388 } 389 390 /* 391 * Space ID must be one of the predefined IDs, or in the user-defined 392 * range 393 */ 394 if ((RegionSpace >= ACPI_NUM_PREDEFINED_REGIONS) && 395 (RegionSpace < ACPI_USER_REGION_BEGIN)) 396 { 397 ACPI_ERROR ((AE_INFO, "Invalid AddressSpace type %X", RegionSpace)); 398 return_ACPI_STATUS (AE_AML_INVALID_SPACE_ID); 399 } 400 401 ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Region Type - %s (%X)\n", 402 AcpiUtGetRegionName (RegionSpace), RegionSpace)); 403 404 /* Create the region descriptor */ 405 406 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_REGION); 407 if (!ObjDesc) 408 { 409 Status = AE_NO_MEMORY; 410 goto Cleanup; 411 } 412 413 /* 414 * Remember location in AML stream of address & length 415 * operands since they need to be evaluated at run time. 416 */ 417 RegionObj2 = ObjDesc->Common.NextObject; 418 RegionObj2->Extra.AmlStart = AmlStart; 419 RegionObj2->Extra.AmlLength = AmlLength; 420 421 /* Init the region from the operands */ 422 423 ObjDesc->Region.SpaceId = RegionSpace; 424 ObjDesc->Region.Address = 0; 425 ObjDesc->Region.Length = 0; 426 ObjDesc->Region.Node = Node; 427 428 /* Install the new region object in the parent Node */ 429 430 Status = AcpiNsAttachObject (Node, ObjDesc, ACPI_TYPE_REGION); 431 432 433Cleanup: 434 435 /* Remove local reference to the object */ 436 437 AcpiUtRemoveReference (ObjDesc); 438 return_ACPI_STATUS (Status); 439} 440 441 442/******************************************************************************* 443 * 444 * FUNCTION: AcpiExCreateTableRegion 445 * 446 * PARAMETERS: WalkState - Current state 447 * 448 * RETURN: Status 449 * 450 * DESCRIPTION: Create a new DataTableRegion object 451 * 452 ******************************************************************************/ 453 454ACPI_STATUS 455AcpiExCreateTableRegion ( 456 ACPI_WALK_STATE *WalkState) 457{ 458 ACPI_STATUS Status; 459 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; 460 ACPI_OPERAND_OBJECT *ObjDesc; 461 ACPI_NAMESPACE_NODE *Node; 462 ACPI_OPERAND_OBJECT *RegionObj2; 463 ACPI_NATIVE_UINT TableIndex; 464 ACPI_TABLE_HEADER *Table; 465 466 467 ACPI_FUNCTION_TRACE (ExCreateTableRegion); 468 469 470 /* Get the Node from the object stack */ 471 472 Node = WalkState->Op->Common.Node; 473 474 /* 475 * If the region object is already attached to this node, 476 * just return 477 */ 478 if (AcpiNsGetAttachedObject (Node)) 479 { 480 return_ACPI_STATUS (AE_OK); 481 } 482 483 /* Find the ACPI table */ 484 485 Status = AcpiTbFindTable (Operand[1]->String.Pointer, 486 Operand[2]->String.Pointer, Operand[3]->String.Pointer, 487 &TableIndex); 488 if (ACPI_FAILURE (Status)) 489 { 490 return_ACPI_STATUS (Status); 491 } 492 493 /* Create the region descriptor */ 494 495 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_REGION); 496 if (!ObjDesc) 497 { 498 return_ACPI_STATUS (AE_NO_MEMORY); 499 } 500 501 RegionObj2 = ObjDesc->Common.NextObject; 502 RegionObj2->Extra.RegionContext = NULL; 503 504 Status = AcpiGetTableByIndex (TableIndex, &Table); 505 if (ACPI_FAILURE (Status)) 506 { 507 return_ACPI_STATUS (Status); 508 } 509 510 /* Init the region from the operands */ 511 512 ObjDesc->Region.SpaceId = REGION_DATA_TABLE; 513 ObjDesc->Region.Address = (ACPI_PHYSICAL_ADDRESS) ACPI_TO_INTEGER (Table); 514 ObjDesc->Region.Length = Table->Length; 515 ObjDesc->Region.Node = Node; 516 ObjDesc->Region.Flags = AOPOBJ_DATA_VALID; 517 518 /* Install the new region object in the parent Node */ 519 520 Status = AcpiNsAttachObject (Node, ObjDesc, ACPI_TYPE_REGION); 521 if (ACPI_FAILURE (Status)) 522 { 523 goto Cleanup; 524 } 525 526 Status = AcpiEvInitializeRegion (ObjDesc, FALSE); 527 if (ACPI_FAILURE (Status)) 528 { 529 if (Status == AE_NOT_EXIST) 530 { 531 Status = AE_OK; 532 } 533 else 534 { 535 goto Cleanup; 536 } 537 } 538 539 ObjDesc->Region.Flags |= AOPOBJ_SETUP_COMPLETE; 540 541 542Cleanup: 543 544 /* Remove local reference to the object */ 545 546 AcpiUtRemoveReference (ObjDesc); 547 return_ACPI_STATUS (Status); 548} 549 550 551/******************************************************************************* 552 * 553 * FUNCTION: AcpiExCreateProcessor 554 * 555 * PARAMETERS: WalkState - Current state 556 * 557 * RETURN: Status 558 * 559 * DESCRIPTION: Create a new processor object and populate the fields 560 * 561 * Processor (Name[0], CpuID[1], PblockAddr[2], PblockLength[3]) 562 * 563 ******************************************************************************/ 564 565ACPI_STATUS 566AcpiExCreateProcessor ( 567 ACPI_WALK_STATE *WalkState) 568{ 569 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; 570 ACPI_OPERAND_OBJECT *ObjDesc; 571 ACPI_STATUS Status; 572 573 574 ACPI_FUNCTION_TRACE_PTR (ExCreateProcessor, WalkState); 575 576 577 /* Create the processor object */ 578 579 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_PROCESSOR); 580 if (!ObjDesc) 581 { 582 return_ACPI_STATUS (AE_NO_MEMORY); 583 } 584 585 /* Initialize the processor object from the operands */ 586 587 ObjDesc->Processor.ProcId = (UINT8) Operand[1]->Integer.Value; 588 ObjDesc->Processor.Length = (UINT8) Operand[3]->Integer.Value; 589 ObjDesc->Processor.Address = (ACPI_IO_ADDRESS) Operand[2]->Integer.Value; 590 591 /* Install the processor object in the parent Node */ 592 593 Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0], 594 ObjDesc, ACPI_TYPE_PROCESSOR); 595 596 /* Remove local reference to the object */ 597 598 AcpiUtRemoveReference (ObjDesc); 599 return_ACPI_STATUS (Status); 600} 601 602 603/******************************************************************************* 604 * 605 * FUNCTION: AcpiExCreatePowerResource 606 * 607 * PARAMETERS: WalkState - Current state 608 * 609 * RETURN: Status 610 * 611 * DESCRIPTION: Create a new PowerResource object and populate the fields 612 * 613 * PowerResource (Name[0], SystemLevel[1], ResourceOrder[2]) 614 * 615 ******************************************************************************/ 616 617ACPI_STATUS 618AcpiExCreatePowerResource ( 619 ACPI_WALK_STATE *WalkState) 620{ 621 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; 622 ACPI_STATUS Status; 623 ACPI_OPERAND_OBJECT *ObjDesc; 624 625 626 ACPI_FUNCTION_TRACE_PTR (ExCreatePowerResource, WalkState); 627 628 629 /* Create the power resource object */ 630 631 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_POWER); 632 if (!ObjDesc) 633 { 634 return_ACPI_STATUS (AE_NO_MEMORY); 635 } 636 637 /* Initialize the power object from the operands */ 638 639 ObjDesc->PowerResource.SystemLevel = (UINT8) Operand[1]->Integer.Value; 640 ObjDesc->PowerResource.ResourceOrder = (UINT16) Operand[2]->Integer.Value; 641 642 /* Install the power resource object in the parent Node */ 643 644 Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0], 645 ObjDesc, ACPI_TYPE_POWER); 646 647 /* Remove local reference to the object */ 648 649 AcpiUtRemoveReference (ObjDesc); 650 return_ACPI_STATUS (Status); 651} 652#endif 653 654 655/******************************************************************************* 656 * 657 * FUNCTION: AcpiExCreateMethod 658 * 659 * PARAMETERS: AmlStart - First byte of the method's AML 660 * AmlLength - AML byte count for this method 661 * WalkState - Current state 662 * 663 * RETURN: Status 664 * 665 * DESCRIPTION: Create a new method object 666 * 667 ******************************************************************************/ 668 669ACPI_STATUS 670AcpiExCreateMethod ( 671 UINT8 *AmlStart, 672 UINT32 AmlLength, 673 ACPI_WALK_STATE *WalkState) 674{ 675 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; 676 ACPI_OPERAND_OBJECT *ObjDesc; 677 ACPI_STATUS Status; 678 UINT8 MethodFlags; 679 680 681 ACPI_FUNCTION_TRACE_PTR (ExCreateMethod, WalkState); 682 683 684 /* Create a new method object */ 685 686 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_METHOD); 687 if (!ObjDesc) 688 { 689 Status = AE_NO_MEMORY; 690 goto Exit; 691 } 692 693 /* Save the method's AML pointer and length */ 694 695 ObjDesc->Method.AmlStart = AmlStart; 696 ObjDesc->Method.AmlLength = AmlLength; 697 698 /* 699 * Disassemble the method flags. Split off the Arg Count 700 * for efficiency 701 */ 702 MethodFlags = (UINT8) Operand[1]->Integer.Value; 703 704 ObjDesc->Method.MethodFlags = (UINT8) (MethodFlags & ~AML_METHOD_ARG_COUNT); 705 ObjDesc->Method.ParamCount = (UINT8) (MethodFlags & AML_METHOD_ARG_COUNT); 706 707 /* 708 * Get the SyncLevel. If method is serialized, a mutex will be 709 * created for this method when it is parsed. 710 */ 711 if (MethodFlags & AML_METHOD_SERIALIZED) 712 { 713 /* 714 * ACPI 1.0: SyncLevel = 0 715 * ACPI 2.0: SyncLevel = SyncLevel in method declaration 716 */ 717 ObjDesc->Method.SyncLevel = (UINT8) 718 ((MethodFlags & AML_METHOD_SYNCH_LEVEL) >> 4); 719 } 720 721 /* Attach the new object to the method Node */ 722 723 Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0], 724 ObjDesc, ACPI_TYPE_METHOD); 725 726 /* Remove local reference to the object */ 727 728 AcpiUtRemoveReference (ObjDesc); 729 730Exit: 731 /* Remove a reference to the operand */ 732 733 AcpiUtRemoveReference (Operand[1]); 734 return_ACPI_STATUS (Status); 735} 736 737 738