excreate.c revision 100966
1219019Sgabor/****************************************************************************** 2219019Sgabor * 3219019Sgabor * Module Name: excreate - Named object creation 4219019Sgabor * $Revision: 93 $ 5219019Sgabor * 6219019Sgabor *****************************************************************************/ 7219019Sgabor 8219019Sgabor/****************************************************************************** 9219019Sgabor * 10219019Sgabor * 1. Copyright Notice 11219019Sgabor * 12219019Sgabor * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp. 13219019Sgabor * All rights reserved. 14219019Sgabor * 15219019Sgabor * 2. License 16219019Sgabor * 17219019Sgabor * 2.1. This is your license from Intel Corp. under its intellectual property 18219019Sgabor * rights. You may have additional license terms from the party that provided 19219019Sgabor * you this software, covering your right to use that party's intellectual 20219019Sgabor * property rights. 21219019Sgabor * 22219019Sgabor * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 23219019Sgabor * copy of the source code appearing in this file ("Covered Code") an 24219019Sgabor * irrevocable, perpetual, worldwide license under Intel's copyrights in the 25219019Sgabor * base code distributed originally by Intel ("Original Intel Code") to copy, 26219019Sgabor * make derivatives, distribute, use and display any portion of the Covered 27219019Sgabor * Code in any form, with the right to sublicense such rights; and 28219019Sgabor * 29219019Sgabor * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 30219019Sgabor * license (with the right to sublicense), under only those claims of Intel 31219019Sgabor * patents that are infringed by the Original Intel Code, to make, use, sell, 32219019Sgabor * offer to sell, and import the Covered Code and derivative works thereof 33219019Sgabor * solely to the minimum extent necessary to exercise the above copyright 34219019Sgabor * license, and in no event shall the patent license extend to any additions 35219019Sgabor * to or modifications of the Original Intel Code. No other license or right 36219019Sgabor * is granted directly or by implication, estoppel or otherwise; 37219019Sgabor * 38219019Sgabor * The above copyright and patent license is granted only if the following 39219019Sgabor * conditions are met: 40219019Sgabor * 41219019Sgabor * 3. Conditions 42219019Sgabor * 43219019Sgabor * 3.1. Redistribution of Source with Rights to Further Distribute Source. 44219019Sgabor * Redistribution of source code of any substantial portion of the Covered 45219019Sgabor * Code or modification with rights to further distribute source must include 46219019Sgabor * the above Copyright Notice, the above License, this list of Conditions, 47219019Sgabor * and the following Disclaimer and Export Compliance provision. In addition, 48219019Sgabor * Licensee must cause all Covered Code to which Licensee contributes to 49219019Sgabor * contain a file documenting the changes Licensee made to create that Covered 50219019Sgabor * Code and the date of any change. Licensee must include in that file the 51219019Sgabor * documentation of any changes made by any predecessor Licensee. Licensee 52219019Sgabor * must include a prominent statement that the modification is derived, 53219019Sgabor * directly or indirectly, from Original Intel Code. 54219019Sgabor * 55219019Sgabor * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 56219019Sgabor * Redistribution of source code of any substantial portion of the Covered 57219019Sgabor * Code or modification without rights to further distribute source must 58219019Sgabor * include the following Disclaimer and Export Compliance provision in the 59219019Sgabor * documentation and/or other materials provided with distribution. In 60219019Sgabor * addition, Licensee may not authorize further sublicense of source of any 61219019Sgabor * portion of the Covered Code, and must include terms to the effect that the 62219019Sgabor * license from Licensee to its licensee is limited to the intellectual 63219019Sgabor * property embodied in the software Licensee provides to its licensee, and 64219019Sgabor * not to intellectual property embodied in modifications its licensee may 65219019Sgabor * make. 66219019Sgabor * 67219019Sgabor * 3.3. Redistribution of Executable. Redistribution in executable form of any 68219019Sgabor * substantial portion of the Covered Code or modification must reproduce the 69219019Sgabor * above Copyright Notice, and the following Disclaimer and Export Compliance 70219019Sgabor * provision in the documentation and/or other materials provided with the 71219019Sgabor * distribution. 72219019Sgabor * 73219019Sgabor * 3.4. Intel retains all right, title, and interest in and to the Original 74219019Sgabor * Intel Code. 75219019Sgabor * 76219019Sgabor * 3.5. Neither the name Intel nor any other trademark owned or controlled by 77219019Sgabor * Intel shall be used in advertising or otherwise to promote the sale, use or 78219019Sgabor * other dealings in products derived from or relating to the Covered Code 79219019Sgabor * without prior written authorization from Intel. 80219019Sgabor * 81219019Sgabor * 4. Disclaimer and Export Compliance 82219019Sgabor * 83219019Sgabor * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 84219019Sgabor * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 85219019Sgabor * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 86219019Sgabor * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 87219019Sgabor 88219019Sgabor * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 89219019Sgabor * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 90219019Sgabor * PARTICULAR PURPOSE. 91219019Sgabor * 92219019Sgabor * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 93219019Sgabor * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 94219019Sgabor * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 95219019Sgabor * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 96219019Sgabor * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 97219019Sgabor * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 98219019Sgabor * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 99219019Sgabor * LIMITED REMEDY. 100219019Sgabor * 101219019Sgabor * 4.3. Licensee shall not export, either directly or indirectly, any of this 102219019Sgabor * software or system incorporating such software without first obtaining any 103219019Sgabor * required license or other approval from the U. S. Department of Commerce or 104219019Sgabor * any other agency or department of the United States Government. In the 105219019Sgabor * event Licensee exports any such software from the United States or 106219019Sgabor * re-exports any such software from a foreign destination, Licensee shall 107219019Sgabor * ensure that the distribution and export/re-export of the software is in 108219019Sgabor * compliance with all laws, regulations, orders, or other restrictions of the 109219019Sgabor * U.S. Export Administration Regulations. Licensee agrees that neither it nor 110219019Sgabor * any of its subsidiaries will export/re-export any technical data, process, 111219019Sgabor * software, or service, directly or indirectly, to any country for which the 112228843Scperciva * United States government or any agency thereof requires an export license, 113219019Sgabor * other governmental approval, or letter of assurance, without first obtaining 114219019Sgabor * such license, approval or letter. 115219019Sgabor * 116219019Sgabor *****************************************************************************/ 117219019Sgabor 118219019Sgabor#define __EXCREATE_C__ 119219019Sgabor 120219019Sgabor#include "acpi.h" 121219019Sgabor#include "acinterp.h" 122219019Sgabor#include "amlcode.h" 123219019Sgabor#include "acnamesp.h" 124219019Sgabor#include "acevents.h" 125219019Sgabor#include "actables.h" 126219019Sgabor 127219019Sgabor 128219019Sgabor#define _COMPONENT ACPI_EXECUTER 129219019Sgabor ACPI_MODULE_NAME ("excreate") 130219019Sgabor 131219019Sgabor 132219019Sgabor#ifndef ACPI_NO_METHOD_EXECUTION 133219019Sgabor/***************************************************************************** 134219019Sgabor * 135219019Sgabor * FUNCTION: AcpiExCreateAlias 136219019Sgabor * 137219019Sgabor * PARAMETERS: WalkState - Current state, contains operands 138219019Sgabor * 139219019Sgabor * RETURN: Status 140219019Sgabor * 141219019Sgabor * DESCRIPTION: Create a new named alias 142219019Sgabor * 143219019Sgabor ****************************************************************************/ 144219019Sgabor 145219019SgaborACPI_STATUS 146219019SgaborAcpiExCreateAlias ( 147219019Sgabor ACPI_WALK_STATE *WalkState) 148219019Sgabor{ 149219019Sgabor ACPI_NAMESPACE_NODE *SourceNode; 150219019Sgabor ACPI_STATUS Status; 151219019Sgabor 152219019Sgabor 153219019Sgabor ACPI_FUNCTION_TRACE ("ExCreateAlias"); 154219019Sgabor 155219019Sgabor 156219019Sgabor /* Get the source/alias operands (both namespace nodes) */ 157219019Sgabor 158219019Sgabor SourceNode = (ACPI_NAMESPACE_NODE *) WalkState->Operands[1]; 159219019Sgabor 160219019Sgabor 161219019Sgabor /* Attach the original source object to the new Alias Node */ 162219019Sgabor 163219019Sgabor Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) WalkState->Operands[0], 164219019Sgabor AcpiNsGetAttachedObject (SourceNode), 165219019Sgabor SourceNode->Type); 166219019Sgabor 167219019Sgabor /* 168219019Sgabor * The new alias assumes the type of the source, but it points 169219019Sgabor * to the same object. The reference count of the object has an 170219019Sgabor * additional reference to prevent deletion out from under either the 171219019Sgabor * source or the alias Node 172219019Sgabor */ 173219019Sgabor 174219019Sgabor /* Since both operands are Nodes, we don't need to delete them */ 175219019Sgabor 176219019Sgabor return_ACPI_STATUS (Status); 177219019Sgabor} 178219019Sgabor 179219019Sgabor 180219019Sgabor/***************************************************************************** 181219019Sgabor * 182219019Sgabor * FUNCTION: AcpiExCreateEvent 183219019Sgabor * 184219019Sgabor * PARAMETERS: WalkState - Current state 185219019Sgabor * 186219019Sgabor * RETURN: Status 187219019Sgabor * 188219019Sgabor * DESCRIPTION: Create a new event object 189219019Sgabor * 190219019Sgabor ****************************************************************************/ 191219019Sgabor 192219019SgaborACPI_STATUS 193219019SgaborAcpiExCreateEvent ( 194219019Sgabor ACPI_WALK_STATE *WalkState) 195219019Sgabor{ 196219019Sgabor ACPI_STATUS Status; 197219019Sgabor ACPI_OPERAND_OBJECT *ObjDesc; 198219019Sgabor 199219019Sgabor 200219019Sgabor ACPI_FUNCTION_TRACE ("ExCreateEvent"); 201219019Sgabor 202219019Sgabor 203219019Sgabor ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_EVENT); 204219019Sgabor if (!ObjDesc) 205219019Sgabor { 206219019Sgabor Status = AE_NO_MEMORY; 207219019Sgabor goto Cleanup; 208219019Sgabor } 209219019Sgabor 210219019Sgabor /* 211219019Sgabor * Create the actual OS semaphore, with zero initial units -- meaning 212219019Sgabor * that the event is created in an unsignalled state 213219019Sgabor */ 214219019Sgabor Status = AcpiOsCreateSemaphore (ACPI_NO_UNIT_LIMIT, 0, 215219019Sgabor &ObjDesc->Event.Semaphore); 216219019Sgabor if (ACPI_FAILURE (Status)) 217219019Sgabor { 218219019Sgabor goto Cleanup; 219219019Sgabor } 220219019Sgabor 221219019Sgabor /* Attach object to the Node */ 222219019Sgabor 223219019Sgabor Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) WalkState->Operands[0], 224219019Sgabor ObjDesc, ACPI_TYPE_EVENT); 225219019Sgabor 226219019SgaborCleanup: 227219019Sgabor /* 228219019Sgabor * Remove local reference to the object (on error, will cause deletion 229219019Sgabor * of both object and semaphore if present.) 230219019Sgabor */ 231219019Sgabor AcpiUtRemoveReference (ObjDesc); 232219019Sgabor return_ACPI_STATUS (Status); 233219019Sgabor} 234219019Sgabor 235219019Sgabor 236219019Sgabor/***************************************************************************** 237219019Sgabor * 238219019Sgabor * FUNCTION: AcpiExCreateMutex 239219019Sgabor * 240219019Sgabor * PARAMETERS: WalkState - Current state 241219019Sgabor * 242219019Sgabor * RETURN: Status 243219019Sgabor * 244219019Sgabor * DESCRIPTION: Create a new mutex object 245219019Sgabor * 246219019Sgabor * Mutex (Name[0], SyncLevel[1]) 247219019Sgabor * 248219019Sgabor ****************************************************************************/ 249219019Sgabor 250219019SgaborACPI_STATUS 251219019SgaborAcpiExCreateMutex ( 252219019Sgabor ACPI_WALK_STATE *WalkState) 253219019Sgabor{ 254219019Sgabor ACPI_STATUS Status = AE_OK; 255219019Sgabor ACPI_OPERAND_OBJECT *ObjDesc; 256219019Sgabor 257219019Sgabor 258219019Sgabor ACPI_FUNCTION_TRACE_PTR ("ExCreateMutex", ACPI_WALK_OPERANDS); 259219019Sgabor 260219019Sgabor 261219019Sgabor /* Create the new mutex object */ 262219019Sgabor 263219019Sgabor ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_MUTEX); 264219019Sgabor if (!ObjDesc) 265219019Sgabor { 266219019Sgabor Status = AE_NO_MEMORY; 267219019Sgabor goto Cleanup; 268219019Sgabor } 269219019Sgabor 270219019Sgabor /* 271219019Sgabor * Create the actual OS semaphore. 272219019Sgabor * One unit max to make it a mutex, with one initial unit to allow 273219019Sgabor * the mutex to be acquired. 274219019Sgabor */ 275219019Sgabor Status = AcpiOsCreateSemaphore (1, 1, &ObjDesc->Mutex.Semaphore); 276219019Sgabor if (ACPI_FAILURE (Status)) 277219019Sgabor { 278219019Sgabor goto Cleanup; 279219019Sgabor } 280219019Sgabor 281219019Sgabor /* Init object and attach to NS node */ 282219019Sgabor 283219019Sgabor ObjDesc->Mutex.SyncLevel = (UINT8) WalkState->Operands[1]->Integer.Value; 284219019Sgabor 285219019Sgabor Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) WalkState->Operands[0], 286219019Sgabor ObjDesc, ACPI_TYPE_MUTEX); 287219019Sgabor 288219019Sgabor 289219019SgaborCleanup: 290219019Sgabor /* 291219019Sgabor * Remove local reference to the object (on error, will cause deletion 292219019Sgabor * of both object and semaphore if present.) 293219019Sgabor */ 294219019Sgabor AcpiUtRemoveReference (ObjDesc); 295219019Sgabor return_ACPI_STATUS (Status); 296219019Sgabor} 297219019Sgabor 298228843Scperciva 299219019Sgabor/***************************************************************************** 300219019Sgabor * 301219019Sgabor * FUNCTION: AcpiExCreateRegion 302219019Sgabor * 303219019Sgabor * PARAMETERS: AmlStart - Pointer to the region declaration AML 304219019Sgabor * AmlLength - Max length of the declaration AML 305219019Sgabor * Operands - List of operands for the opcode 306219019Sgabor * WalkState - Current state 307219019Sgabor * 308219019Sgabor * RETURN: Status 309219019Sgabor * 310219019Sgabor * DESCRIPTION: Create a new operation region object 311219019Sgabor * 312219019Sgabor ****************************************************************************/ 313219019Sgabor 314219019SgaborACPI_STATUS 315219019SgaborAcpiExCreateRegion ( 316 UINT8 *AmlStart, 317 UINT32 AmlLength, 318 UINT8 RegionSpace, 319 ACPI_WALK_STATE *WalkState) 320{ 321 ACPI_STATUS Status; 322 ACPI_OPERAND_OBJECT *ObjDesc; 323 ACPI_NAMESPACE_NODE *Node; 324 ACPI_OPERAND_OBJECT *RegionObj2; 325 326 327 ACPI_FUNCTION_TRACE ("ExCreateRegion"); 328 329 330 /* Get the Node from the object stack */ 331 332 Node = WalkState->Op->Common.Node; 333 334 /* 335 * If the region object is already attached to this node, 336 * just return 337 */ 338 if (AcpiNsGetAttachedObject (Node)) 339 { 340 return_ACPI_STATUS (AE_OK); 341 } 342 343 /* 344 * Space ID must be one of the predefined IDs, or in the user-defined 345 * range 346 */ 347 if ((RegionSpace >= ACPI_NUM_PREDEFINED_REGIONS) && 348 (RegionSpace < ACPI_USER_REGION_BEGIN)) 349 { 350 ACPI_REPORT_ERROR (("Invalid AddressSpace type %X\n", RegionSpace)); 351 return_ACPI_STATUS (AE_AML_INVALID_SPACE_ID); 352 } 353 354 ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Region Type - %s (%X)\n", 355 AcpiUtGetRegionName (RegionSpace), RegionSpace)); 356 357 358 /* Create the region descriptor */ 359 360 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_REGION); 361 if (!ObjDesc) 362 { 363 Status = AE_NO_MEMORY; 364 goto Cleanup; 365 } 366 367 /* 368 * Remember location in AML stream of address & length 369 * operands since they need to be evaluated at run time. 370 */ 371 RegionObj2 = ObjDesc->Common.NextObject; 372 RegionObj2->Extra.AmlStart = AmlStart; 373 RegionObj2->Extra.AmlLength = AmlLength; 374 375 /* Init the region from the operands */ 376 377 ObjDesc->Region.SpaceId = RegionSpace; 378 ObjDesc->Region.Address = 0; 379 ObjDesc->Region.Length = 0; 380 ObjDesc->Region.Node = Node; 381 382 /* Install the new region object in the parent Node */ 383 384 Status = AcpiNsAttachObject (Node, ObjDesc, ACPI_TYPE_REGION); 385 386 387Cleanup: 388 389 /* Remove local reference to the object */ 390 391 AcpiUtRemoveReference (ObjDesc); 392 return_ACPI_STATUS (Status); 393} 394 395 396/***************************************************************************** 397 * 398 * FUNCTION: AcpiExCreateTableRegion 399 * 400 * PARAMETERS: WalkState - Current state 401 * 402 * RETURN: Status 403 * 404 * DESCRIPTION: Create a new DataTableRegion object 405 * 406 ****************************************************************************/ 407 408ACPI_STATUS 409AcpiExCreateTableRegion ( 410 ACPI_WALK_STATE *WalkState) 411{ 412 ACPI_STATUS Status; 413 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; 414 ACPI_OPERAND_OBJECT *ObjDesc; 415 ACPI_NAMESPACE_NODE *Node; 416 ACPI_TABLE_HEADER *Table; 417 ACPI_OPERAND_OBJECT *RegionObj2; 418 419 420 ACPI_FUNCTION_TRACE ("ExCreateTableRegion"); 421 422 /* Get the Node from the object stack */ 423 424 Node = WalkState->Op->Common.Node; 425 426 /* 427 * If the region object is already attached to this node, 428 * just return 429 */ 430 if (AcpiNsGetAttachedObject (Node)) 431 { 432 return_ACPI_STATUS (AE_OK); 433 } 434 435 /* Find the ACPI table */ 436 437 Status = AcpiTbFindTable (Operand[1]->String.Pointer, 438 Operand[2]->String.Pointer, 439 Operand[3]->String.Pointer, &Table); 440 441 if (ACPI_FAILURE (Status)) 442 { 443 return_ACPI_STATUS (Status); 444 } 445 446 /* Create the region descriptor */ 447 448 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_REGION); 449 if (!ObjDesc) 450 { 451 return_ACPI_STATUS (AE_NO_MEMORY); 452 } 453 454 RegionObj2 = ObjDesc->Common.NextObject; 455 RegionObj2->Extra.RegionContext = NULL; 456 457 /* Init the region from the operands */ 458 459 ObjDesc->Region.SpaceId = REGION_DATA_TABLE; 460 ObjDesc->Region.Address = (ACPI_PHYSICAL_ADDRESS) ACPI_TO_INTEGER (Table); 461 ObjDesc->Region.Length = Table->Length; 462 ObjDesc->Region.Node = Node; 463 ObjDesc->Region.Flags = AOPOBJ_DATA_VALID; 464 465 /* Install the new region object in the parent Node */ 466 467 Status = AcpiNsAttachObject (Node, ObjDesc, ACPI_TYPE_REGION); 468 if (ACPI_FAILURE (Status)) 469 { 470 goto Cleanup; 471 } 472 473 Status = AcpiEvInitializeRegion (ObjDesc, FALSE); 474 if (ACPI_FAILURE (Status)) 475 { 476 if (Status == AE_NOT_EXIST) 477 { 478 Status = AE_OK; 479 } 480 else 481 { 482 goto Cleanup; 483 } 484 } 485 486 ObjDesc->Region.Flags |= AOPOBJ_SETUP_COMPLETE; 487 488 489Cleanup: 490 491 /* Remove local reference to the object */ 492 493 AcpiUtRemoveReference (ObjDesc); 494 return_ACPI_STATUS (Status); 495} 496 497 498/***************************************************************************** 499 * 500 * FUNCTION: AcpiExCreateProcessor 501 * 502 * PARAMETERS: WalkState - Current state 503 * 504 * RETURN: Status 505 * 506 * DESCRIPTION: Create a new processor object and populate the fields 507 * 508 * Processor (Name[0], CpuID[1], PblockAddr[2], PblockLength[3]) 509 * 510 ****************************************************************************/ 511 512ACPI_STATUS 513AcpiExCreateProcessor ( 514 ACPI_WALK_STATE *WalkState) 515{ 516 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; 517 ACPI_OPERAND_OBJECT *ObjDesc; 518 ACPI_STATUS Status; 519 520 521 ACPI_FUNCTION_TRACE_PTR ("ExCreateProcessor", WalkState); 522 523 524 /* Create the processor object */ 525 526 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_PROCESSOR); 527 if (!ObjDesc) 528 { 529 return_ACPI_STATUS (AE_NO_MEMORY); 530 } 531 532 /* 533 * Initialize the processor object from the operands 534 */ 535 ObjDesc->Processor.ProcId = (UINT8) Operand[1]->Integer.Value; 536 ObjDesc->Processor.Address = (ACPI_IO_ADDRESS) Operand[2]->Integer.Value; 537 ObjDesc->Processor.Length = (UINT8) Operand[3]->Integer.Value; 538 539 /* Install the processor object in the parent Node */ 540 541 Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0], 542 ObjDesc, ACPI_TYPE_PROCESSOR); 543 544 545 /* Remove local reference to the object */ 546 547 AcpiUtRemoveReference (ObjDesc); 548 return_ACPI_STATUS (Status); 549} 550 551 552/***************************************************************************** 553 * 554 * FUNCTION: AcpiExCreatePowerResource 555 * 556 * PARAMETERS: WalkState - Current state 557 * 558 * RETURN: Status 559 * 560 * DESCRIPTION: Create a new PowerResource object and populate the fields 561 * 562 * PowerResource (Name[0], SystemLevel[1], ResourceOrder[2]) 563 * 564 ****************************************************************************/ 565 566ACPI_STATUS 567AcpiExCreatePowerResource ( 568 ACPI_WALK_STATE *WalkState) 569{ 570 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; 571 ACPI_STATUS Status; 572 ACPI_OPERAND_OBJECT *ObjDesc; 573 574 575 ACPI_FUNCTION_TRACE_PTR ("ExCreatePowerResource", WalkState); 576 577 578 /* Create the power resource object */ 579 580 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_POWER); 581 if (!ObjDesc) 582 { 583 return_ACPI_STATUS (AE_NO_MEMORY); 584 } 585 586 /* Initialize the power object from the operands */ 587 588 ObjDesc->PowerResource.SystemLevel = (UINT8) Operand[1]->Integer.Value; 589 ObjDesc->PowerResource.ResourceOrder = (UINT16) Operand[2]->Integer.Value; 590 591 /* Install the power resource object in the parent Node */ 592 593 Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0], 594 ObjDesc, ACPI_TYPE_POWER); 595 596 597 /* Remove local reference to the object */ 598 599 AcpiUtRemoveReference (ObjDesc); 600 return_ACPI_STATUS (Status); 601} 602 603#endif 604 605/***************************************************************************** 606 * 607 * FUNCTION: AcpiExCreateMethod 608 * 609 * PARAMETERS: AmlStart - First byte of the method's AML 610 * AmlLength - AML byte count for this method 611 * WalkState - Current state 612 * 613 * RETURN: Status 614 * 615 * DESCRIPTION: Create a new method object 616 * 617 ****************************************************************************/ 618 619ACPI_STATUS 620AcpiExCreateMethod ( 621 UINT8 *AmlStart, 622 UINT32 AmlLength, 623 ACPI_WALK_STATE *WalkState) 624{ 625 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; 626 ACPI_OPERAND_OBJECT *ObjDesc; 627 ACPI_STATUS Status; 628 UINT8 MethodFlags; 629 630 631 ACPI_FUNCTION_TRACE_PTR ("ExCreateMethod", WalkState); 632 633 634 /* Create a new method object */ 635 636 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_METHOD); 637 if (!ObjDesc) 638 { 639 return_ACPI_STATUS (AE_NO_MEMORY); 640 } 641 642 /* Save the method's AML pointer and length */ 643 644 ObjDesc->Method.AmlStart = AmlStart; 645 ObjDesc->Method.AmlLength = AmlLength; 646 647 /* disassemble the method flags */ 648 649 MethodFlags = (UINT8) Operand[1]->Integer.Value; 650 651 ObjDesc->Method.MethodFlags = MethodFlags; 652 ObjDesc->Method.ParamCount = (UINT8) (MethodFlags & METHOD_FLAGS_ARG_COUNT); 653 654 /* 655 * Get the concurrency count. If required, a semaphore will be 656 * created for this method when it is parsed. 657 */ 658 if (MethodFlags & METHOD_FLAGS_SERIALIZED) 659 { 660 /* 661 * ACPI 1.0: Concurrency = 1 662 * ACPI 2.0: Concurrency = (SyncLevel (in method declaration) + 1) 663 */ 664 ObjDesc->Method.Concurrency = (UINT8) 665 (((MethodFlags & METHOD_FLAGS_SYNCH_LEVEL) >> 4) + 1); 666 } 667 668 else 669 { 670 ObjDesc->Method.Concurrency = INFINITE_CONCURRENCY; 671 } 672 673 /* Attach the new object to the method Node */ 674 675 Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0], 676 ObjDesc, ACPI_TYPE_METHOD); 677 678 /* Remove local reference to the object */ 679 680 AcpiUtRemoveReference (ObjDesc); 681 682 /* Remove a reference to the operand */ 683 684 AcpiUtRemoveReference (Operand[1]); 685 return_ACPI_STATUS (Status); 686} 687 688 689