167754Smsmith/****************************************************************************** 267754Smsmith * 377424Smsmith * Module Name: excreate - Named object creation 467754Smsmith * 567754Smsmith *****************************************************************************/ 667754Smsmith 7217365Sjkim/* 8306536Sjkim * Copyright (C) 2000 - 2016, Intel Corp. 970243Smsmith * All rights reserved. 1067754Smsmith * 11217365Sjkim * Redistribution and use in source and binary forms, with or without 12217365Sjkim * modification, are permitted provided that the following conditions 13217365Sjkim * are met: 14217365Sjkim * 1. Redistributions of source code must retain the above copyright 15217365Sjkim * notice, this list of conditions, and the following disclaimer, 16217365Sjkim * without modification. 17217365Sjkim * 2. Redistributions in binary form must reproduce at minimum a disclaimer 18217365Sjkim * substantially similar to the "NO WARRANTY" disclaimer below 19217365Sjkim * ("Disclaimer") and any redistribution must be conditioned upon 20217365Sjkim * including a substantially similar Disclaimer requirement for further 21217365Sjkim * binary redistribution. 22217365Sjkim * 3. Neither the names of the above-listed copyright holders nor the names 23217365Sjkim * of any contributors may be used to endorse or promote products derived 24217365Sjkim * from this software without specific prior written permission. 2567754Smsmith * 26217365Sjkim * Alternatively, this software may be distributed under the terms of the 27217365Sjkim * GNU General Public License ("GPL") version 2 as published by the Free 28217365Sjkim * Software Foundation. 2967754Smsmith * 30217365Sjkim * NO WARRANTY 31217365Sjkim * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 32217365Sjkim * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 33217365Sjkim * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 34217365Sjkim * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 35217365Sjkim * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 36217365Sjkim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 37217365Sjkim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 38217365Sjkim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 39217365Sjkim * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 40217365Sjkim * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 41217365Sjkim * POSSIBILITY OF SUCH DAMAGES. 42217365Sjkim */ 4367754Smsmith 44193341Sjkim#include <contrib/dev/acpica/include/acpi.h> 45193341Sjkim#include <contrib/dev/acpica/include/accommon.h> 46193341Sjkim#include <contrib/dev/acpica/include/acinterp.h> 47193341Sjkim#include <contrib/dev/acpica/include/amlcode.h> 48193341Sjkim#include <contrib/dev/acpica/include/acnamesp.h> 4967754Smsmith 5067754Smsmith 5177424Smsmith#define _COMPONENT ACPI_EXECUTER 5291116Smsmith ACPI_MODULE_NAME ("excreate") 5367754Smsmith 5467754Smsmith 55100966Siwasaki#ifndef ACPI_NO_METHOD_EXECUTION 56151937Sjkim/******************************************************************************* 5767754Smsmith * 5877424Smsmith * FUNCTION: AcpiExCreateAlias 5967754Smsmith * 6099679Siwasaki * PARAMETERS: WalkState - Current state, contains operands 6167754Smsmith * 6267754Smsmith * RETURN: Status 6367754Smsmith * 6467754Smsmith * DESCRIPTION: Create a new named alias 6567754Smsmith * 66151937Sjkim ******************************************************************************/ 6767754Smsmith 6867754SmsmithACPI_STATUS 6977424SmsmithAcpiExCreateAlias ( 7067754Smsmith ACPI_WALK_STATE *WalkState) 7167754Smsmith{ 72104470Siwasaki ACPI_NAMESPACE_NODE *TargetNode; 73104470Siwasaki ACPI_NAMESPACE_NODE *AliasNode; 74107325Siwasaki ACPI_STATUS Status = AE_OK; 7567754Smsmith 7667754Smsmith 77167802Sjkim ACPI_FUNCTION_TRACE (ExCreateAlias); 7867754Smsmith 7967754Smsmith 8077424Smsmith /* Get the source/alias operands (both namespace nodes) */ 8167754Smsmith 82104470Siwasaki AliasNode = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0]; 83104470Siwasaki TargetNode = (ACPI_NAMESPACE_NODE *) WalkState->Operands[1]; 8467754Smsmith 85128212Snjl if ((TargetNode->Type == ACPI_TYPE_LOCAL_ALIAS) || 86128212Snjl (TargetNode->Type == ACPI_TYPE_LOCAL_METHOD_ALIAS)) 87104470Siwasaki { 88114237Snjl /* 89104470Siwasaki * Dereference an existing alias so that we don't create a chain 90241973Sjkim * of aliases. With this code, we guarantee that an alias is 91114237Snjl * always exactly one level of indirection away from the 92104470Siwasaki * actual aliased name. 93104470Siwasaki */ 94128212Snjl TargetNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, TargetNode->Object); 95104470Siwasaki } 9667754Smsmith 9767754Smsmith /* 98104470Siwasaki * For objects that can never change (i.e., the NS node will 99104470Siwasaki * permanently point to the same object), we can simply attach 100241973Sjkim * the object to the new NS node. For other objects (such as 101104470Siwasaki * Integers, buffers, etc.), we have to point the Alias node 102104470Siwasaki * to the original Node. 10367754Smsmith */ 104104470Siwasaki switch (TargetNode->Type) 105104470Siwasaki { 106193267Sjkim 107193267Sjkim /* For these types, the sub-object can change dynamically via a Store */ 108193267Sjkim 109104470Siwasaki case ACPI_TYPE_INTEGER: 110104470Siwasaki case ACPI_TYPE_STRING: 111104470Siwasaki case ACPI_TYPE_BUFFER: 112104470Siwasaki case ACPI_TYPE_PACKAGE: 113104470Siwasaki case ACPI_TYPE_BUFFER_FIELD: 114193267Sjkim /* 115193267Sjkim * These types open a new scope, so we need the NS node in order to access 116193267Sjkim * any children. 117193267Sjkim */ 118193267Sjkim case ACPI_TYPE_DEVICE: 119193267Sjkim case ACPI_TYPE_POWER: 120193267Sjkim case ACPI_TYPE_PROCESSOR: 121193267Sjkim case ACPI_TYPE_THERMAL: 122193267Sjkim case ACPI_TYPE_LOCAL_SCOPE: 123104470Siwasaki /* 124104470Siwasaki * The new alias has the type ALIAS and points to the original 125193267Sjkim * NS node, not the object itself. 126104470Siwasaki */ 127107325Siwasaki AliasNode->Type = ACPI_TYPE_LOCAL_ALIAS; 128107325Siwasaki AliasNode->Object = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, TargetNode); 129104470Siwasaki break; 130104470Siwasaki 131128212Snjl case ACPI_TYPE_METHOD: 132128212Snjl /* 133193267Sjkim * Control method aliases need to be differentiated 134128212Snjl */ 135128212Snjl AliasNode->Type = ACPI_TYPE_LOCAL_METHOD_ALIAS; 136128212Snjl AliasNode->Object = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, TargetNode); 137128212Snjl break; 138128212Snjl 139104470Siwasaki default: 140104470Siwasaki 141104470Siwasaki /* Attach the original source object to the new Alias Node */ 142104470Siwasaki 143104470Siwasaki /* 144104470Siwasaki * The new alias assumes the type of the target, and it points 145241973Sjkim * to the same object. The reference count of the object has an 146104470Siwasaki * additional reference to prevent deletion out from under either the 147104470Siwasaki * target node or the alias Node 148104470Siwasaki */ 149104470Siwasaki Status = AcpiNsAttachObject (AliasNode, 150306536Sjkim AcpiNsGetAttachedObject (TargetNode), TargetNode->Type); 151104470Siwasaki break; 152104470Siwasaki } 153104470Siwasaki 15477424Smsmith /* Since both operands are Nodes, we don't need to delete them */ 15567754Smsmith 156107325Siwasaki return_ACPI_STATUS (Status); 15767754Smsmith} 15867754Smsmith 15967754Smsmith 160151937Sjkim/******************************************************************************* 16167754Smsmith * 16277424Smsmith * FUNCTION: AcpiExCreateEvent 16367754Smsmith * 16484491Smsmith * PARAMETERS: WalkState - Current state 16567754Smsmith * 16667754Smsmith * RETURN: Status 16767754Smsmith * 16867754Smsmith * DESCRIPTION: Create a new event object 16967754Smsmith * 170151937Sjkim ******************************************************************************/ 17167754Smsmith 17267754SmsmithACPI_STATUS 17377424SmsmithAcpiExCreateEvent ( 17467754Smsmith ACPI_WALK_STATE *WalkState) 17567754Smsmith{ 17667754Smsmith ACPI_STATUS Status; 17767754Smsmith ACPI_OPERAND_OBJECT *ObjDesc; 17867754Smsmith 17967754Smsmith 180167802Sjkim ACPI_FUNCTION_TRACE (ExCreateEvent); 18167754Smsmith 18267754Smsmith 18377424Smsmith ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_EVENT); 18467754Smsmith if (!ObjDesc) 18567754Smsmith { 18667754Smsmith Status = AE_NO_MEMORY; 18767754Smsmith goto Cleanup; 18867754Smsmith } 18967754Smsmith 19091116Smsmith /* 19187031Smsmith * Create the actual OS semaphore, with zero initial units -- meaning 19287031Smsmith * that the event is created in an unsignalled state 19387031Smsmith */ 19487031Smsmith Status = AcpiOsCreateSemaphore (ACPI_NO_UNIT_LIMIT, 0, 195306536Sjkim &ObjDesc->Event.OsSemaphore); 19667754Smsmith if (ACPI_FAILURE (Status)) 19767754Smsmith { 19867754Smsmith goto Cleanup; 19967754Smsmith } 20067754Smsmith 20167754Smsmith /* Attach object to the Node */ 20267754Smsmith 203306536Sjkim Status = AcpiNsAttachObject ( 204306536Sjkim (ACPI_NAMESPACE_NODE *) WalkState->Operands[0], 205306536Sjkim ObjDesc, ACPI_TYPE_EVENT); 20667754Smsmith 20767754SmsmithCleanup: 20887031Smsmith /* 20985756Smsmith * Remove local reference to the object (on error, will cause deletion 21085756Smsmith * of both object and semaphore if present.) 21185756Smsmith */ 21285756Smsmith AcpiUtRemoveReference (ObjDesc); 21367754Smsmith return_ACPI_STATUS (Status); 21467754Smsmith} 21567754Smsmith 21667754Smsmith 217151937Sjkim/******************************************************************************* 21867754Smsmith * 21977424Smsmith * FUNCTION: AcpiExCreateMutex 22067754Smsmith * 22184491Smsmith * PARAMETERS: WalkState - Current state 22267754Smsmith * 22367754Smsmith * RETURN: Status 22467754Smsmith * 22567754Smsmith * DESCRIPTION: Create a new mutex object 22667754Smsmith * 22785756Smsmith * Mutex (Name[0], SyncLevel[1]) 22885756Smsmith * 229151937Sjkim ******************************************************************************/ 23067754Smsmith 23167754SmsmithACPI_STATUS 23277424SmsmithAcpiExCreateMutex ( 23367754Smsmith ACPI_WALK_STATE *WalkState) 23467754Smsmith{ 23567754Smsmith ACPI_STATUS Status = AE_OK; 23667754Smsmith ACPI_OPERAND_OBJECT *ObjDesc; 23767754Smsmith 23867754Smsmith 239167802Sjkim ACPI_FUNCTION_TRACE_PTR (ExCreateMutex, ACPI_WALK_OPERANDS); 24067754Smsmith 24167754Smsmith 24285756Smsmith /* Create the new mutex object */ 24367754Smsmith 24477424Smsmith ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_MUTEX); 24567754Smsmith if (!ObjDesc) 24667754Smsmith { 24767754Smsmith Status = AE_NO_MEMORY; 24867754Smsmith goto Cleanup; 24967754Smsmith } 25067754Smsmith 251167802Sjkim /* Create the actual OS Mutex */ 252167802Sjkim 253167802Sjkim Status = AcpiOsCreateMutex (&ObjDesc->Mutex.OsMutex); 25467754Smsmith if (ACPI_FAILURE (Status)) 25567754Smsmith { 25667754Smsmith goto Cleanup; 25767754Smsmith } 25867754Smsmith 25985756Smsmith /* Init object and attach to NS node */ 26067754Smsmith 26185756Smsmith ObjDesc->Mutex.SyncLevel = (UINT8) WalkState->Operands[1]->Integer.Value; 262107325Siwasaki ObjDesc->Mutex.Node = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0]; 26367754Smsmith 264306536Sjkim Status = AcpiNsAttachObject ( 265306536Sjkim ObjDesc->Mutex.Node, ObjDesc, ACPI_TYPE_MUTEX); 26667754Smsmith 26767754Smsmith 26867754SmsmithCleanup: 26987031Smsmith /* 27085756Smsmith * Remove local reference to the object (on error, will cause deletion 27185756Smsmith * of both object and semaphore if present.) 27285756Smsmith */ 27385756Smsmith AcpiUtRemoveReference (ObjDesc); 27467754Smsmith return_ACPI_STATUS (Status); 27567754Smsmith} 27667754Smsmith 27767754Smsmith 278151937Sjkim/******************************************************************************* 27967754Smsmith * 28077424Smsmith * FUNCTION: AcpiExCreateRegion 28167754Smsmith * 28284491Smsmith * PARAMETERS: AmlStart - Pointer to the region declaration AML 28367754Smsmith * AmlLength - Max length of the declaration AML 284228110Sjkim * SpaceId - Address space ID for the region 28584491Smsmith * WalkState - Current state 28667754Smsmith * 28767754Smsmith * RETURN: Status 28867754Smsmith * 28967754Smsmith * DESCRIPTION: Create a new operation region object 29067754Smsmith * 291151937Sjkim ******************************************************************************/ 29267754Smsmith 29367754SmsmithACPI_STATUS 29477424SmsmithAcpiExCreateRegion ( 29584491Smsmith UINT8 *AmlStart, 29667754Smsmith UINT32 AmlLength, 297228110Sjkim UINT8 SpaceId, 29867754Smsmith ACPI_WALK_STATE *WalkState) 29967754Smsmith{ 30067754Smsmith ACPI_STATUS Status; 30167754Smsmith ACPI_OPERAND_OBJECT *ObjDesc; 30267754Smsmith ACPI_NAMESPACE_NODE *Node; 30391116Smsmith ACPI_OPERAND_OBJECT *RegionObj2; 30467754Smsmith 30567754Smsmith 306167802Sjkim ACPI_FUNCTION_TRACE (ExCreateRegion); 30767754Smsmith 30867754Smsmith 309123315Snjl /* Get the Namespace Node */ 31085756Smsmith 31199679Siwasaki Node = WalkState->Op->Common.Node; 31285756Smsmith 31370243Smsmith /* 31485756Smsmith * If the region object is already attached to this node, 31585756Smsmith * just return 31685756Smsmith */ 31787031Smsmith if (AcpiNsGetAttachedObject (Node)) 31885756Smsmith { 31985756Smsmith return_ACPI_STATUS (AE_OK); 32085756Smsmith } 32185756Smsmith 32285756Smsmith /* 32370243Smsmith * Space ID must be one of the predefined IDs, or in the user-defined 32469746Smsmith * range 32569746Smsmith */ 326228110Sjkim if (!AcpiIsValidSpaceId (SpaceId)) 32767754Smsmith { 328228110Sjkim /* 329228110Sjkim * Print an error message, but continue. We don't want to abort 330228110Sjkim * a table load for this exception. Instead, if the region is 331228110Sjkim * actually used at runtime, abort the executing method. 332228110Sjkim */ 333306536Sjkim ACPI_ERROR ((AE_INFO, 334306536Sjkim "Invalid/unknown Address Space ID: 0x%2.2X", SpaceId)); 33567754Smsmith } 33667754Smsmith 337204773Sjkim ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Region Type - %s (0x%X)\n", 338228110Sjkim AcpiUtGetRegionName (SpaceId), SpaceId)); 33967754Smsmith 34067754Smsmith /* Create the region descriptor */ 34167754Smsmith 34277424Smsmith ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_REGION); 34367754Smsmith if (!ObjDesc) 34467754Smsmith { 34567754Smsmith Status = AE_NO_MEMORY; 34667754Smsmith goto Cleanup; 34767754Smsmith } 34867754Smsmith 34967754Smsmith /* 35067754Smsmith * Remember location in AML stream of address & length 35167754Smsmith * operands since they need to be evaluated at run time. 35267754Smsmith */ 353306536Sjkim RegionObj2 = AcpiNsGetSecondaryObject (ObjDesc); 354167802Sjkim RegionObj2->Extra.AmlStart = AmlStart; 35587031Smsmith RegionObj2->Extra.AmlLength = AmlLength; 356306536Sjkim RegionObj2->Extra.Method_REG = NULL; 357228110Sjkim if (WalkState->ScopeInfo) 358228110Sjkim { 359228110Sjkim RegionObj2->Extra.ScopeNode = WalkState->ScopeInfo->Scope.Node; 360228110Sjkim } 361228110Sjkim else 362228110Sjkim { 363228110Sjkim RegionObj2->Extra.ScopeNode = Node; 364228110Sjkim } 36567754Smsmith 36667754Smsmith /* Init the region from the operands */ 36767754Smsmith 368228110Sjkim ObjDesc->Region.SpaceId = SpaceId; 36985756Smsmith ObjDesc->Region.Address = 0; 370167802Sjkim ObjDesc->Region.Length = 0; 371167802Sjkim ObjDesc->Region.Node = Node; 372306536Sjkim ObjDesc->Region.Handler = NULL; 373306536Sjkim ObjDesc->Common.Flags &= 374306536Sjkim ~(AOPOBJ_SETUP_COMPLETE | AOPOBJ_REG_CONNECTED | 375306536Sjkim AOPOBJ_OBJECT_INITIALIZED); 37667754Smsmith 37767754Smsmith /* Install the new region object in the parent Node */ 37867754Smsmith 37991116Smsmith Status = AcpiNsAttachObject (Node, ObjDesc, ACPI_TYPE_REGION); 38067754Smsmith 38167754Smsmith 38267754SmsmithCleanup: 38367754Smsmith 38485756Smsmith /* Remove local reference to the object */ 38567754Smsmith 38685756Smsmith AcpiUtRemoveReference (ObjDesc); 38767754Smsmith return_ACPI_STATUS (Status); 38867754Smsmith} 38967754Smsmith 39067754Smsmith 391151937Sjkim/******************************************************************************* 39267754Smsmith * 39377424Smsmith * FUNCTION: AcpiExCreateProcessor 39467754Smsmith * 39599679Siwasaki * PARAMETERS: WalkState - Current state 39667754Smsmith * 39767754Smsmith * RETURN: Status 39867754Smsmith * 39967754Smsmith * DESCRIPTION: Create a new processor object and populate the fields 40067754Smsmith * 40185756Smsmith * Processor (Name[0], CpuID[1], PblockAddr[2], PblockLength[3]) 40285756Smsmith * 403151937Sjkim ******************************************************************************/ 40467754Smsmith 40567754SmsmithACPI_STATUS 40677424SmsmithAcpiExCreateProcessor ( 40785756Smsmith ACPI_WALK_STATE *WalkState) 40867754Smsmith{ 40985756Smsmith ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; 41085756Smsmith ACPI_OPERAND_OBJECT *ObjDesc; 41167754Smsmith ACPI_STATUS Status; 41267754Smsmith 41367754Smsmith 414167802Sjkim ACPI_FUNCTION_TRACE_PTR (ExCreateProcessor, WalkState); 41567754Smsmith 41667754Smsmith 41785756Smsmith /* Create the processor object */ 41885756Smsmith 41977424Smsmith ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_PROCESSOR); 42067754Smsmith if (!ObjDesc) 42167754Smsmith { 42277424Smsmith return_ACPI_STATUS (AE_NO_MEMORY); 42367754Smsmith } 42467754Smsmith 425151937Sjkim /* Initialize the processor object from the operands */ 426151937Sjkim 427167802Sjkim ObjDesc->Processor.ProcId = (UINT8) Operand[1]->Integer.Value; 428167802Sjkim ObjDesc->Processor.Length = (UINT8) Operand[3]->Integer.Value; 42985756Smsmith ObjDesc->Processor.Address = (ACPI_IO_ADDRESS) Operand[2]->Integer.Value; 43067754Smsmith 43185756Smsmith /* Install the processor object in the parent Node */ 43267754Smsmith 43387031Smsmith Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0], 434306536Sjkim ObjDesc, ACPI_TYPE_PROCESSOR); 43577424Smsmith 43685756Smsmith /* Remove local reference to the object */ 43767754Smsmith 43885756Smsmith AcpiUtRemoveReference (ObjDesc); 43985756Smsmith return_ACPI_STATUS (Status); 44067754Smsmith} 44167754Smsmith 44267754Smsmith 443151937Sjkim/******************************************************************************* 44467754Smsmith * 44577424Smsmith * FUNCTION: AcpiExCreatePowerResource 44667754Smsmith * 44799679Siwasaki * PARAMETERS: WalkState - Current state 44867754Smsmith * 44967754Smsmith * RETURN: Status 45067754Smsmith * 45167754Smsmith * DESCRIPTION: Create a new PowerResource object and populate the fields 45267754Smsmith * 45385756Smsmith * PowerResource (Name[0], SystemLevel[1], ResourceOrder[2]) 45485756Smsmith * 455151937Sjkim ******************************************************************************/ 45667754Smsmith 45767754SmsmithACPI_STATUS 45877424SmsmithAcpiExCreatePowerResource ( 45985756Smsmith ACPI_WALK_STATE *WalkState) 46067754Smsmith{ 46185756Smsmith ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; 46267754Smsmith ACPI_STATUS Status; 46367754Smsmith ACPI_OPERAND_OBJECT *ObjDesc; 46467754Smsmith 46567754Smsmith 466167802Sjkim ACPI_FUNCTION_TRACE_PTR (ExCreatePowerResource, WalkState); 46767754Smsmith 46867754Smsmith 46985756Smsmith /* Create the power resource object */ 47085756Smsmith 47177424Smsmith ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_POWER); 47267754Smsmith if (!ObjDesc) 47367754Smsmith { 47477424Smsmith return_ACPI_STATUS (AE_NO_MEMORY); 47567754Smsmith } 47667754Smsmith 47785756Smsmith /* Initialize the power object from the operands */ 47867754Smsmith 479167802Sjkim ObjDesc->PowerResource.SystemLevel = (UINT8) Operand[1]->Integer.Value; 48085756Smsmith ObjDesc->PowerResource.ResourceOrder = (UINT16) Operand[2]->Integer.Value; 48167754Smsmith 48285756Smsmith /* Install the power resource object in the parent Node */ 48367754Smsmith 48487031Smsmith Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0], 485306536Sjkim ObjDesc, ACPI_TYPE_POWER); 48667754Smsmith 48785756Smsmith /* Remove local reference to the object */ 48867754Smsmith 48985756Smsmith AcpiUtRemoveReference (ObjDesc); 49085756Smsmith return_ACPI_STATUS (Status); 49167754Smsmith} 492100966Siwasaki#endif 49367754Smsmith 494151937Sjkim 495151937Sjkim/******************************************************************************* 49667754Smsmith * 49777424Smsmith * FUNCTION: AcpiExCreateMethod 49867754Smsmith * 49984491Smsmith * PARAMETERS: AmlStart - First byte of the method's AML 50067754Smsmith * AmlLength - AML byte count for this method 50199679Siwasaki * WalkState - Current state 50267754Smsmith * 50367754Smsmith * RETURN: Status 50467754Smsmith * 50567754Smsmith * DESCRIPTION: Create a new method object 50667754Smsmith * 507151937Sjkim ******************************************************************************/ 50867754Smsmith 50967754SmsmithACPI_STATUS 51077424SmsmithAcpiExCreateMethod ( 51184491Smsmith UINT8 *AmlStart, 51267754Smsmith UINT32 AmlLength, 51385756Smsmith ACPI_WALK_STATE *WalkState) 51467754Smsmith{ 51585756Smsmith ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; 51667754Smsmith ACPI_OPERAND_OBJECT *ObjDesc; 51767754Smsmith ACPI_STATUS Status; 51885756Smsmith UINT8 MethodFlags; 51967754Smsmith 52067754Smsmith 521167802Sjkim ACPI_FUNCTION_TRACE_PTR (ExCreateMethod, WalkState); 52267754Smsmith 52367754Smsmith 52467754Smsmith /* Create a new method object */ 52567754Smsmith 52677424Smsmith ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_METHOD); 52767754Smsmith if (!ObjDesc) 52867754Smsmith { 529167802Sjkim Status = AE_NO_MEMORY; 530167802Sjkim goto Exit; 53167754Smsmith } 53267754Smsmith 53385756Smsmith /* Save the method's AML pointer and length */ 53467754Smsmith 535167802Sjkim ObjDesc->Method.AmlStart = AmlStart; 53684491Smsmith ObjDesc->Method.AmlLength = AmlLength; 537306536Sjkim ObjDesc->Method.Node = Operand[0]; 53867754Smsmith 539127175Snjl /* 540217365Sjkim * Disassemble the method flags. Split off the ArgCount, Serialized 541217365Sjkim * flag, and SyncLevel for efficiency. 542127175Snjl */ 54385756Smsmith MethodFlags = (UINT8) Operand[1]->Integer.Value; 544306536Sjkim ObjDesc->Method.ParamCount = (UINT8) 545306536Sjkim (MethodFlags & AML_METHOD_ARG_COUNT); 54685756Smsmith 54767754Smsmith /* 548167802Sjkim * Get the SyncLevel. If method is serialized, a mutex will be 54967754Smsmith * created for this method when it is parsed. 55067754Smsmith */ 551167802Sjkim if (MethodFlags & AML_METHOD_SERIALIZED) 55267754Smsmith { 553217365Sjkim ObjDesc->Method.InfoFlags = ACPI_METHOD_SERIALIZED; 554217365Sjkim 55577424Smsmith /* 556167802Sjkim * ACPI 1.0: SyncLevel = 0 557167802Sjkim * ACPI 2.0: SyncLevel = SyncLevel in method declaration 55877424Smsmith */ 559167802Sjkim ObjDesc->Method.SyncLevel = (UINT8) 560193267Sjkim ((MethodFlags & AML_METHOD_SYNC_LEVEL) >> 4); 56167754Smsmith } 56267754Smsmith 56367754Smsmith /* Attach the new object to the method Node */ 56467754Smsmith 56587031Smsmith Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0], 566306536Sjkim ObjDesc, ACPI_TYPE_METHOD); 56767754Smsmith 56885756Smsmith /* Remove local reference to the object */ 56985756Smsmith 57085756Smsmith AcpiUtRemoveReference (ObjDesc); 57185756Smsmith 572167802SjkimExit: 57385756Smsmith /* Remove a reference to the operand */ 57485756Smsmith 57585756Smsmith AcpiUtRemoveReference (Operand[1]); 57667754Smsmith return_ACPI_STATUS (Status); 57767754Smsmith} 578