excreate.c revision 316303
167754Smsmith/****************************************************************************** 267754Smsmith * 377424Smsmith * Module Name: excreate - Named object creation 467754Smsmith * 567754Smsmith *****************************************************************************/ 667754Smsmith 7316303Sjkim/****************************************************************************** 8316303Sjkim * 9316303Sjkim * 1. Copyright Notice 10316303Sjkim * 11316303Sjkim * Some or all of this work - Copyright (c) 1999 - 2017, Intel Corp. 1270243Smsmith * All rights reserved. 1367754Smsmith * 14316303Sjkim * 2. License 15316303Sjkim * 16316303Sjkim * 2.1. This is your license from Intel Corp. under its intellectual property 17316303Sjkim * rights. You may have additional license terms from the party that provided 18316303Sjkim * you this software, covering your right to use that party's intellectual 19316303Sjkim * property rights. 20316303Sjkim * 21316303Sjkim * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 22316303Sjkim * copy of the source code appearing in this file ("Covered Code") an 23316303Sjkim * irrevocable, perpetual, worldwide license under Intel's copyrights in the 24316303Sjkim * base code distributed originally by Intel ("Original Intel Code") to copy, 25316303Sjkim * make derivatives, distribute, use and display any portion of the Covered 26316303Sjkim * Code in any form, with the right to sublicense such rights; and 27316303Sjkim * 28316303Sjkim * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 29316303Sjkim * license (with the right to sublicense), under only those claims of Intel 30316303Sjkim * patents that are infringed by the Original Intel Code, to make, use, sell, 31316303Sjkim * offer to sell, and import the Covered Code and derivative works thereof 32316303Sjkim * solely to the minimum extent necessary to exercise the above copyright 33316303Sjkim * license, and in no event shall the patent license extend to any additions 34316303Sjkim * to or modifications of the Original Intel Code. No other license or right 35316303Sjkim * is granted directly or by implication, estoppel or otherwise; 36316303Sjkim * 37316303Sjkim * The above copyright and patent license is granted only if the following 38316303Sjkim * conditions are met: 39316303Sjkim * 40316303Sjkim * 3. Conditions 41316303Sjkim * 42316303Sjkim * 3.1. Redistribution of Source with Rights to Further Distribute Source. 43316303Sjkim * Redistribution of source code of any substantial portion of the Covered 44316303Sjkim * Code or modification with rights to further distribute source must include 45316303Sjkim * the above Copyright Notice, the above License, this list of Conditions, 46316303Sjkim * and the following Disclaimer and Export Compliance provision. In addition, 47316303Sjkim * Licensee must cause all Covered Code to which Licensee contributes to 48316303Sjkim * contain a file documenting the changes Licensee made to create that Covered 49316303Sjkim * Code and the date of any change. Licensee must include in that file the 50316303Sjkim * documentation of any changes made by any predecessor Licensee. Licensee 51316303Sjkim * must include a prominent statement that the modification is derived, 52316303Sjkim * directly or indirectly, from Original Intel Code. 53316303Sjkim * 54316303Sjkim * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 55316303Sjkim * Redistribution of source code of any substantial portion of the Covered 56316303Sjkim * Code or modification without rights to further distribute source must 57316303Sjkim * include the following Disclaimer and Export Compliance provision in the 58316303Sjkim * documentation and/or other materials provided with distribution. In 59316303Sjkim * addition, Licensee may not authorize further sublicense of source of any 60316303Sjkim * portion of the Covered Code, and must include terms to the effect that the 61316303Sjkim * license from Licensee to its licensee is limited to the intellectual 62316303Sjkim * property embodied in the software Licensee provides to its licensee, and 63316303Sjkim * not to intellectual property embodied in modifications its licensee may 64316303Sjkim * make. 65316303Sjkim * 66316303Sjkim * 3.3. Redistribution of Executable. Redistribution in executable form of any 67316303Sjkim * substantial portion of the Covered Code or modification must reproduce the 68316303Sjkim * above Copyright Notice, and the following Disclaimer and Export Compliance 69316303Sjkim * provision in the documentation and/or other materials provided with the 70316303Sjkim * distribution. 71316303Sjkim * 72316303Sjkim * 3.4. Intel retains all right, title, and interest in and to the Original 73316303Sjkim * Intel Code. 74316303Sjkim * 75316303Sjkim * 3.5. Neither the name Intel nor any other trademark owned or controlled by 76316303Sjkim * Intel shall be used in advertising or otherwise to promote the sale, use or 77316303Sjkim * other dealings in products derived from or relating to the Covered Code 78316303Sjkim * without prior written authorization from Intel. 79316303Sjkim * 80316303Sjkim * 4. Disclaimer and Export Compliance 81316303Sjkim * 82316303Sjkim * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 83316303Sjkim * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 84316303Sjkim * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 85316303Sjkim * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 86316303Sjkim 87316303Sjkim * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 88316303Sjkim * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 89316303Sjkim * PARTICULAR PURPOSE. 90316303Sjkim * 91316303Sjkim * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 92316303Sjkim * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 93316303Sjkim * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 94316303Sjkim * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 95316303Sjkim * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 96316303Sjkim * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 97316303Sjkim * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 98316303Sjkim * LIMITED REMEDY. 99316303Sjkim * 100316303Sjkim * 4.3. Licensee shall not export, either directly or indirectly, any of this 101316303Sjkim * software or system incorporating such software without first obtaining any 102316303Sjkim * required license or other approval from the U. S. Department of Commerce or 103316303Sjkim * any other agency or department of the United States Government. In the 104316303Sjkim * event Licensee exports any such software from the United States or 105316303Sjkim * re-exports any such software from a foreign destination, Licensee shall 106316303Sjkim * ensure that the distribution and export/re-export of the software is in 107316303Sjkim * compliance with all laws, regulations, orders, or other restrictions of the 108316303Sjkim * U.S. Export Administration Regulations. Licensee agrees that neither it nor 109316303Sjkim * any of its subsidiaries will export/re-export any technical data, process, 110316303Sjkim * software, or service, directly or indirectly, to any country for which the 111316303Sjkim * United States government or any agency thereof requires an export license, 112316303Sjkim * other governmental approval, or letter of assurance, without first obtaining 113316303Sjkim * such license, approval or letter. 114316303Sjkim * 115316303Sjkim ***************************************************************************** 116316303Sjkim * 117316303Sjkim * Alternatively, you may choose to be licensed under the terms of the 118316303Sjkim * following license: 119316303Sjkim * 120217365Sjkim * Redistribution and use in source and binary forms, with or without 121217365Sjkim * modification, are permitted provided that the following conditions 122217365Sjkim * are met: 123217365Sjkim * 1. Redistributions of source code must retain the above copyright 124217365Sjkim * notice, this list of conditions, and the following disclaimer, 125217365Sjkim * without modification. 126217365Sjkim * 2. Redistributions in binary form must reproduce at minimum a disclaimer 127217365Sjkim * substantially similar to the "NO WARRANTY" disclaimer below 128217365Sjkim * ("Disclaimer") and any redistribution must be conditioned upon 129217365Sjkim * including a substantially similar Disclaimer requirement for further 130217365Sjkim * binary redistribution. 131217365Sjkim * 3. Neither the names of the above-listed copyright holders nor the names 132217365Sjkim * of any contributors may be used to endorse or promote products derived 133217365Sjkim * from this software without specific prior written permission. 13467754Smsmith * 135316303Sjkim * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 136316303Sjkim * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 137316303Sjkim * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 138316303Sjkim * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 139316303Sjkim * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 140316303Sjkim * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 141316303Sjkim * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 142316303Sjkim * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 143316303Sjkim * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 144316303Sjkim * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 145316303Sjkim * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 146316303Sjkim * 147316303Sjkim * Alternatively, you may choose to be licensed under the terms of the 148217365Sjkim * GNU General Public License ("GPL") version 2 as published by the Free 149217365Sjkim * Software Foundation. 15067754Smsmith * 151316303Sjkim *****************************************************************************/ 15267754Smsmith 153193341Sjkim#include <contrib/dev/acpica/include/acpi.h> 154193341Sjkim#include <contrib/dev/acpica/include/accommon.h> 155193341Sjkim#include <contrib/dev/acpica/include/acinterp.h> 156193341Sjkim#include <contrib/dev/acpica/include/amlcode.h> 157193341Sjkim#include <contrib/dev/acpica/include/acnamesp.h> 15867754Smsmith 15967754Smsmith 16077424Smsmith#define _COMPONENT ACPI_EXECUTER 16191116Smsmith ACPI_MODULE_NAME ("excreate") 16267754Smsmith 16367754Smsmith 164100966Siwasaki#ifndef ACPI_NO_METHOD_EXECUTION 165151937Sjkim/******************************************************************************* 16667754Smsmith * 16777424Smsmith * FUNCTION: AcpiExCreateAlias 16867754Smsmith * 16999679Siwasaki * PARAMETERS: WalkState - Current state, contains operands 17067754Smsmith * 17167754Smsmith * RETURN: Status 17267754Smsmith * 17367754Smsmith * DESCRIPTION: Create a new named alias 17467754Smsmith * 175151937Sjkim ******************************************************************************/ 17667754Smsmith 17767754SmsmithACPI_STATUS 17877424SmsmithAcpiExCreateAlias ( 17967754Smsmith ACPI_WALK_STATE *WalkState) 18067754Smsmith{ 181104470Siwasaki ACPI_NAMESPACE_NODE *TargetNode; 182104470Siwasaki ACPI_NAMESPACE_NODE *AliasNode; 183107325Siwasaki ACPI_STATUS Status = AE_OK; 18467754Smsmith 18567754Smsmith 186167802Sjkim ACPI_FUNCTION_TRACE (ExCreateAlias); 18767754Smsmith 18867754Smsmith 18977424Smsmith /* Get the source/alias operands (both namespace nodes) */ 19067754Smsmith 191104470Siwasaki AliasNode = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0]; 192104470Siwasaki TargetNode = (ACPI_NAMESPACE_NODE *) WalkState->Operands[1]; 19367754Smsmith 194128212Snjl if ((TargetNode->Type == ACPI_TYPE_LOCAL_ALIAS) || 195128212Snjl (TargetNode->Type == ACPI_TYPE_LOCAL_METHOD_ALIAS)) 196104470Siwasaki { 197114237Snjl /* 198104470Siwasaki * Dereference an existing alias so that we don't create a chain 199241973Sjkim * of aliases. With this code, we guarantee that an alias is 200114237Snjl * always exactly one level of indirection away from the 201104470Siwasaki * actual aliased name. 202104470Siwasaki */ 203128212Snjl TargetNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, TargetNode->Object); 204104470Siwasaki } 20567754Smsmith 20667754Smsmith /* 207104470Siwasaki * For objects that can never change (i.e., the NS node will 208104470Siwasaki * permanently point to the same object), we can simply attach 209241973Sjkim * the object to the new NS node. For other objects (such as 210104470Siwasaki * Integers, buffers, etc.), we have to point the Alias node 211104470Siwasaki * to the original Node. 21267754Smsmith */ 213104470Siwasaki switch (TargetNode->Type) 214104470Siwasaki { 215193267Sjkim 216193267Sjkim /* For these types, the sub-object can change dynamically via a Store */ 217193267Sjkim 218104470Siwasaki case ACPI_TYPE_INTEGER: 219104470Siwasaki case ACPI_TYPE_STRING: 220104470Siwasaki case ACPI_TYPE_BUFFER: 221104470Siwasaki case ACPI_TYPE_PACKAGE: 222104470Siwasaki case ACPI_TYPE_BUFFER_FIELD: 223193267Sjkim /* 224193267Sjkim * These types open a new scope, so we need the NS node in order to access 225193267Sjkim * any children. 226193267Sjkim */ 227193267Sjkim case ACPI_TYPE_DEVICE: 228193267Sjkim case ACPI_TYPE_POWER: 229193267Sjkim case ACPI_TYPE_PROCESSOR: 230193267Sjkim case ACPI_TYPE_THERMAL: 231193267Sjkim case ACPI_TYPE_LOCAL_SCOPE: 232104470Siwasaki /* 233104470Siwasaki * The new alias has the type ALIAS and points to the original 234193267Sjkim * NS node, not the object itself. 235104470Siwasaki */ 236107325Siwasaki AliasNode->Type = ACPI_TYPE_LOCAL_ALIAS; 237107325Siwasaki AliasNode->Object = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, TargetNode); 238104470Siwasaki break; 239104470Siwasaki 240128212Snjl case ACPI_TYPE_METHOD: 241128212Snjl /* 242193267Sjkim * Control method aliases need to be differentiated 243128212Snjl */ 244128212Snjl AliasNode->Type = ACPI_TYPE_LOCAL_METHOD_ALIAS; 245128212Snjl AliasNode->Object = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, TargetNode); 246128212Snjl break; 247128212Snjl 248104470Siwasaki default: 249104470Siwasaki 250104470Siwasaki /* Attach the original source object to the new Alias Node */ 251104470Siwasaki 252104470Siwasaki /* 253104470Siwasaki * The new alias assumes the type of the target, and it points 254241973Sjkim * to the same object. The reference count of the object has an 255104470Siwasaki * additional reference to prevent deletion out from under either the 256104470Siwasaki * target node or the alias Node 257104470Siwasaki */ 258104470Siwasaki Status = AcpiNsAttachObject (AliasNode, 259298714Sjkim AcpiNsGetAttachedObject (TargetNode), TargetNode->Type); 260104470Siwasaki break; 261104470Siwasaki } 262104470Siwasaki 26377424Smsmith /* Since both operands are Nodes, we don't need to delete them */ 26467754Smsmith 265107325Siwasaki return_ACPI_STATUS (Status); 26667754Smsmith} 26767754Smsmith 26867754Smsmith 269151937Sjkim/******************************************************************************* 27067754Smsmith * 27177424Smsmith * FUNCTION: AcpiExCreateEvent 27267754Smsmith * 27384491Smsmith * PARAMETERS: WalkState - Current state 27467754Smsmith * 27567754Smsmith * RETURN: Status 27667754Smsmith * 27767754Smsmith * DESCRIPTION: Create a new event object 27867754Smsmith * 279151937Sjkim ******************************************************************************/ 28067754Smsmith 28167754SmsmithACPI_STATUS 28277424SmsmithAcpiExCreateEvent ( 28367754Smsmith ACPI_WALK_STATE *WalkState) 28467754Smsmith{ 28567754Smsmith ACPI_STATUS Status; 28667754Smsmith ACPI_OPERAND_OBJECT *ObjDesc; 28767754Smsmith 28867754Smsmith 289167802Sjkim ACPI_FUNCTION_TRACE (ExCreateEvent); 29067754Smsmith 29167754Smsmith 29277424Smsmith ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_EVENT); 29367754Smsmith if (!ObjDesc) 29467754Smsmith { 29567754Smsmith Status = AE_NO_MEMORY; 29667754Smsmith goto Cleanup; 29767754Smsmith } 29867754Smsmith 29991116Smsmith /* 30087031Smsmith * Create the actual OS semaphore, with zero initial units -- meaning 30187031Smsmith * that the event is created in an unsignalled state 30287031Smsmith */ 30387031Smsmith Status = AcpiOsCreateSemaphore (ACPI_NO_UNIT_LIMIT, 0, 304298714Sjkim &ObjDesc->Event.OsSemaphore); 30567754Smsmith if (ACPI_FAILURE (Status)) 30667754Smsmith { 30767754Smsmith goto Cleanup; 30867754Smsmith } 30967754Smsmith 31067754Smsmith /* Attach object to the Node */ 31167754Smsmith 312298714Sjkim Status = AcpiNsAttachObject ( 313298714Sjkim (ACPI_NAMESPACE_NODE *) WalkState->Operands[0], 314298714Sjkim ObjDesc, ACPI_TYPE_EVENT); 31567754Smsmith 31667754SmsmithCleanup: 31787031Smsmith /* 31885756Smsmith * Remove local reference to the object (on error, will cause deletion 31985756Smsmith * of both object and semaphore if present.) 32085756Smsmith */ 32185756Smsmith AcpiUtRemoveReference (ObjDesc); 32267754Smsmith return_ACPI_STATUS (Status); 32367754Smsmith} 32467754Smsmith 32567754Smsmith 326151937Sjkim/******************************************************************************* 32767754Smsmith * 32877424Smsmith * FUNCTION: AcpiExCreateMutex 32967754Smsmith * 33084491Smsmith * PARAMETERS: WalkState - Current state 33167754Smsmith * 33267754Smsmith * RETURN: Status 33367754Smsmith * 33467754Smsmith * DESCRIPTION: Create a new mutex object 33567754Smsmith * 33685756Smsmith * Mutex (Name[0], SyncLevel[1]) 33785756Smsmith * 338151937Sjkim ******************************************************************************/ 33967754Smsmith 34067754SmsmithACPI_STATUS 34177424SmsmithAcpiExCreateMutex ( 34267754Smsmith ACPI_WALK_STATE *WalkState) 34367754Smsmith{ 34467754Smsmith ACPI_STATUS Status = AE_OK; 34567754Smsmith ACPI_OPERAND_OBJECT *ObjDesc; 34667754Smsmith 34767754Smsmith 348167802Sjkim ACPI_FUNCTION_TRACE_PTR (ExCreateMutex, ACPI_WALK_OPERANDS); 34967754Smsmith 35067754Smsmith 35185756Smsmith /* Create the new mutex object */ 35267754Smsmith 35377424Smsmith ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_MUTEX); 35467754Smsmith if (!ObjDesc) 35567754Smsmith { 35667754Smsmith Status = AE_NO_MEMORY; 35767754Smsmith goto Cleanup; 35867754Smsmith } 35967754Smsmith 360167802Sjkim /* Create the actual OS Mutex */ 361167802Sjkim 362167802Sjkim Status = AcpiOsCreateMutex (&ObjDesc->Mutex.OsMutex); 36367754Smsmith if (ACPI_FAILURE (Status)) 36467754Smsmith { 36567754Smsmith goto Cleanup; 36667754Smsmith } 36767754Smsmith 36885756Smsmith /* Init object and attach to NS node */ 36967754Smsmith 37085756Smsmith ObjDesc->Mutex.SyncLevel = (UINT8) WalkState->Operands[1]->Integer.Value; 371107325Siwasaki ObjDesc->Mutex.Node = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0]; 37267754Smsmith 373298714Sjkim Status = AcpiNsAttachObject ( 374298714Sjkim ObjDesc->Mutex.Node, ObjDesc, ACPI_TYPE_MUTEX); 37567754Smsmith 37667754Smsmith 37767754SmsmithCleanup: 37887031Smsmith /* 37985756Smsmith * Remove local reference to the object (on error, will cause deletion 38085756Smsmith * of both object and semaphore if present.) 38185756Smsmith */ 38285756Smsmith AcpiUtRemoveReference (ObjDesc); 38367754Smsmith return_ACPI_STATUS (Status); 38467754Smsmith} 38567754Smsmith 38667754Smsmith 387151937Sjkim/******************************************************************************* 38867754Smsmith * 38977424Smsmith * FUNCTION: AcpiExCreateRegion 39067754Smsmith * 39184491Smsmith * PARAMETERS: AmlStart - Pointer to the region declaration AML 39267754Smsmith * AmlLength - Max length of the declaration AML 393228110Sjkim * SpaceId - Address space ID for the region 39484491Smsmith * WalkState - Current state 39567754Smsmith * 39667754Smsmith * RETURN: Status 39767754Smsmith * 39867754Smsmith * DESCRIPTION: Create a new operation region object 39967754Smsmith * 400151937Sjkim ******************************************************************************/ 40167754Smsmith 40267754SmsmithACPI_STATUS 40377424SmsmithAcpiExCreateRegion ( 40484491Smsmith UINT8 *AmlStart, 40567754Smsmith UINT32 AmlLength, 406228110Sjkim UINT8 SpaceId, 40767754Smsmith ACPI_WALK_STATE *WalkState) 40867754Smsmith{ 40967754Smsmith ACPI_STATUS Status; 41067754Smsmith ACPI_OPERAND_OBJECT *ObjDesc; 41167754Smsmith ACPI_NAMESPACE_NODE *Node; 41291116Smsmith ACPI_OPERAND_OBJECT *RegionObj2; 41367754Smsmith 41467754Smsmith 415167802Sjkim ACPI_FUNCTION_TRACE (ExCreateRegion); 41667754Smsmith 41767754Smsmith 418123315Snjl /* Get the Namespace Node */ 41985756Smsmith 42099679Siwasaki Node = WalkState->Op->Common.Node; 42185756Smsmith 42270243Smsmith /* 42385756Smsmith * If the region object is already attached to this node, 42485756Smsmith * just return 42585756Smsmith */ 42687031Smsmith if (AcpiNsGetAttachedObject (Node)) 42785756Smsmith { 42885756Smsmith return_ACPI_STATUS (AE_OK); 42985756Smsmith } 43085756Smsmith 43185756Smsmith /* 43270243Smsmith * Space ID must be one of the predefined IDs, or in the user-defined 43369746Smsmith * range 43469746Smsmith */ 435228110Sjkim if (!AcpiIsValidSpaceId (SpaceId)) 43667754Smsmith { 437228110Sjkim /* 438228110Sjkim * Print an error message, but continue. We don't want to abort 439228110Sjkim * a table load for this exception. Instead, if the region is 440228110Sjkim * actually used at runtime, abort the executing method. 441228110Sjkim */ 442298714Sjkim ACPI_ERROR ((AE_INFO, 443298714Sjkim "Invalid/unknown Address Space ID: 0x%2.2X", SpaceId)); 44467754Smsmith } 44567754Smsmith 446204773Sjkim ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Region Type - %s (0x%X)\n", 447228110Sjkim AcpiUtGetRegionName (SpaceId), SpaceId)); 44867754Smsmith 44967754Smsmith /* Create the region descriptor */ 45067754Smsmith 45177424Smsmith ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_REGION); 45267754Smsmith if (!ObjDesc) 45367754Smsmith { 45467754Smsmith Status = AE_NO_MEMORY; 45567754Smsmith goto Cleanup; 45667754Smsmith } 45767754Smsmith 45867754Smsmith /* 45967754Smsmith * Remember location in AML stream of address & length 46067754Smsmith * operands since they need to be evaluated at run time. 46167754Smsmith */ 462298714Sjkim RegionObj2 = AcpiNsGetSecondaryObject (ObjDesc); 463167802Sjkim RegionObj2->Extra.AmlStart = AmlStart; 46487031Smsmith RegionObj2->Extra.AmlLength = AmlLength; 465298714Sjkim RegionObj2->Extra.Method_REG = NULL; 466228110Sjkim if (WalkState->ScopeInfo) 467228110Sjkim { 468228110Sjkim RegionObj2->Extra.ScopeNode = WalkState->ScopeInfo->Scope.Node; 469228110Sjkim } 470228110Sjkim else 471228110Sjkim { 472228110Sjkim RegionObj2->Extra.ScopeNode = Node; 473228110Sjkim } 47467754Smsmith 47567754Smsmith /* Init the region from the operands */ 47667754Smsmith 477228110Sjkim ObjDesc->Region.SpaceId = SpaceId; 47885756Smsmith ObjDesc->Region.Address = 0; 479167802Sjkim ObjDesc->Region.Length = 0; 480167802Sjkim ObjDesc->Region.Node = Node; 481298714Sjkim ObjDesc->Region.Handler = NULL; 482298714Sjkim ObjDesc->Common.Flags &= 483298714Sjkim ~(AOPOBJ_SETUP_COMPLETE | AOPOBJ_REG_CONNECTED | 484298714Sjkim AOPOBJ_OBJECT_INITIALIZED); 48567754Smsmith 48667754Smsmith /* Install the new region object in the parent Node */ 48767754Smsmith 48891116Smsmith Status = AcpiNsAttachObject (Node, ObjDesc, ACPI_TYPE_REGION); 48967754Smsmith 49067754Smsmith 49167754SmsmithCleanup: 49267754Smsmith 49385756Smsmith /* Remove local reference to the object */ 49467754Smsmith 49585756Smsmith AcpiUtRemoveReference (ObjDesc); 49667754Smsmith return_ACPI_STATUS (Status); 49767754Smsmith} 49867754Smsmith 49967754Smsmith 500151937Sjkim/******************************************************************************* 50167754Smsmith * 50277424Smsmith * FUNCTION: AcpiExCreateProcessor 50367754Smsmith * 50499679Siwasaki * PARAMETERS: WalkState - Current state 50567754Smsmith * 50667754Smsmith * RETURN: Status 50767754Smsmith * 50867754Smsmith * DESCRIPTION: Create a new processor object and populate the fields 50967754Smsmith * 51085756Smsmith * Processor (Name[0], CpuID[1], PblockAddr[2], PblockLength[3]) 51185756Smsmith * 512151937Sjkim ******************************************************************************/ 51367754Smsmith 51467754SmsmithACPI_STATUS 51577424SmsmithAcpiExCreateProcessor ( 51685756Smsmith ACPI_WALK_STATE *WalkState) 51767754Smsmith{ 51885756Smsmith ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; 51985756Smsmith ACPI_OPERAND_OBJECT *ObjDesc; 52067754Smsmith ACPI_STATUS Status; 52167754Smsmith 52267754Smsmith 523167802Sjkim ACPI_FUNCTION_TRACE_PTR (ExCreateProcessor, WalkState); 52467754Smsmith 52567754Smsmith 52685756Smsmith /* Create the processor object */ 52785756Smsmith 52877424Smsmith ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_PROCESSOR); 52967754Smsmith if (!ObjDesc) 53067754Smsmith { 53177424Smsmith return_ACPI_STATUS (AE_NO_MEMORY); 53267754Smsmith } 53367754Smsmith 534151937Sjkim /* Initialize the processor object from the operands */ 535151937Sjkim 536167802Sjkim ObjDesc->Processor.ProcId = (UINT8) Operand[1]->Integer.Value; 537167802Sjkim ObjDesc->Processor.Length = (UINT8) Operand[3]->Integer.Value; 53885756Smsmith ObjDesc->Processor.Address = (ACPI_IO_ADDRESS) Operand[2]->Integer.Value; 53967754Smsmith 54085756Smsmith /* Install the processor object in the parent Node */ 54167754Smsmith 54287031Smsmith Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0], 543298714Sjkim ObjDesc, ACPI_TYPE_PROCESSOR); 54477424Smsmith 54585756Smsmith /* Remove local reference to the object */ 54667754Smsmith 54785756Smsmith AcpiUtRemoveReference (ObjDesc); 54885756Smsmith return_ACPI_STATUS (Status); 54967754Smsmith} 55067754Smsmith 55167754Smsmith 552151937Sjkim/******************************************************************************* 55367754Smsmith * 55477424Smsmith * FUNCTION: AcpiExCreatePowerResource 55567754Smsmith * 55699679Siwasaki * PARAMETERS: WalkState - Current state 55767754Smsmith * 55867754Smsmith * RETURN: Status 55967754Smsmith * 56067754Smsmith * DESCRIPTION: Create a new PowerResource object and populate the fields 56167754Smsmith * 56285756Smsmith * PowerResource (Name[0], SystemLevel[1], ResourceOrder[2]) 56385756Smsmith * 564151937Sjkim ******************************************************************************/ 56567754Smsmith 56667754SmsmithACPI_STATUS 56777424SmsmithAcpiExCreatePowerResource ( 56885756Smsmith ACPI_WALK_STATE *WalkState) 56967754Smsmith{ 57085756Smsmith ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; 57167754Smsmith ACPI_STATUS Status; 57267754Smsmith ACPI_OPERAND_OBJECT *ObjDesc; 57367754Smsmith 57467754Smsmith 575167802Sjkim ACPI_FUNCTION_TRACE_PTR (ExCreatePowerResource, WalkState); 57667754Smsmith 57767754Smsmith 57885756Smsmith /* Create the power resource object */ 57985756Smsmith 58077424Smsmith ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_POWER); 58167754Smsmith if (!ObjDesc) 58267754Smsmith { 58377424Smsmith return_ACPI_STATUS (AE_NO_MEMORY); 58467754Smsmith } 58567754Smsmith 58685756Smsmith /* Initialize the power object from the operands */ 58767754Smsmith 588167802Sjkim ObjDesc->PowerResource.SystemLevel = (UINT8) Operand[1]->Integer.Value; 58985756Smsmith ObjDesc->PowerResource.ResourceOrder = (UINT16) Operand[2]->Integer.Value; 59067754Smsmith 59185756Smsmith /* Install the power resource object in the parent Node */ 59267754Smsmith 59387031Smsmith Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0], 594298714Sjkim ObjDesc, ACPI_TYPE_POWER); 59567754Smsmith 59685756Smsmith /* Remove local reference to the object */ 59767754Smsmith 59885756Smsmith AcpiUtRemoveReference (ObjDesc); 59985756Smsmith return_ACPI_STATUS (Status); 60067754Smsmith} 601100966Siwasaki#endif 60267754Smsmith 603151937Sjkim 604151937Sjkim/******************************************************************************* 60567754Smsmith * 60677424Smsmith * FUNCTION: AcpiExCreateMethod 60767754Smsmith * 60884491Smsmith * PARAMETERS: AmlStart - First byte of the method's AML 60967754Smsmith * AmlLength - AML byte count for this method 61099679Siwasaki * WalkState - Current state 61167754Smsmith * 61267754Smsmith * RETURN: Status 61367754Smsmith * 61467754Smsmith * DESCRIPTION: Create a new method object 61567754Smsmith * 616151937Sjkim ******************************************************************************/ 61767754Smsmith 61867754SmsmithACPI_STATUS 61977424SmsmithAcpiExCreateMethod ( 62084491Smsmith UINT8 *AmlStart, 62167754Smsmith UINT32 AmlLength, 62285756Smsmith ACPI_WALK_STATE *WalkState) 62367754Smsmith{ 62485756Smsmith ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; 62567754Smsmith ACPI_OPERAND_OBJECT *ObjDesc; 62667754Smsmith ACPI_STATUS Status; 62785756Smsmith UINT8 MethodFlags; 62867754Smsmith 62967754Smsmith 630167802Sjkim ACPI_FUNCTION_TRACE_PTR (ExCreateMethod, WalkState); 63167754Smsmith 63267754Smsmith 63367754Smsmith /* Create a new method object */ 63467754Smsmith 63577424Smsmith ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_METHOD); 63667754Smsmith if (!ObjDesc) 63767754Smsmith { 638167802Sjkim Status = AE_NO_MEMORY; 639167802Sjkim goto Exit; 64067754Smsmith } 64167754Smsmith 64285756Smsmith /* Save the method's AML pointer and length */ 64367754Smsmith 644167802Sjkim ObjDesc->Method.AmlStart = AmlStart; 64584491Smsmith ObjDesc->Method.AmlLength = AmlLength; 646285797Sjkim ObjDesc->Method.Node = Operand[0]; 64767754Smsmith 648127175Snjl /* 649217365Sjkim * Disassemble the method flags. Split off the ArgCount, Serialized 650217365Sjkim * flag, and SyncLevel for efficiency. 651127175Snjl */ 65285756Smsmith MethodFlags = (UINT8) Operand[1]->Integer.Value; 653298714Sjkim ObjDesc->Method.ParamCount = (UINT8) 654298714Sjkim (MethodFlags & AML_METHOD_ARG_COUNT); 65585756Smsmith 65667754Smsmith /* 657167802Sjkim * Get the SyncLevel. If method is serialized, a mutex will be 65867754Smsmith * created for this method when it is parsed. 65967754Smsmith */ 660167802Sjkim if (MethodFlags & AML_METHOD_SERIALIZED) 66167754Smsmith { 662217365Sjkim ObjDesc->Method.InfoFlags = ACPI_METHOD_SERIALIZED; 663217365Sjkim 66477424Smsmith /* 665167802Sjkim * ACPI 1.0: SyncLevel = 0 666167802Sjkim * ACPI 2.0: SyncLevel = SyncLevel in method declaration 66777424Smsmith */ 668167802Sjkim ObjDesc->Method.SyncLevel = (UINT8) 669193267Sjkim ((MethodFlags & AML_METHOD_SYNC_LEVEL) >> 4); 67067754Smsmith } 67167754Smsmith 67267754Smsmith /* Attach the new object to the method Node */ 67367754Smsmith 67487031Smsmith Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0], 675298714Sjkim ObjDesc, ACPI_TYPE_METHOD); 67667754Smsmith 67785756Smsmith /* Remove local reference to the object */ 67885756Smsmith 67985756Smsmith AcpiUtRemoveReference (ObjDesc); 68085756Smsmith 681167802SjkimExit: 68285756Smsmith /* Remove a reference to the operand */ 68385756Smsmith 68485756Smsmith AcpiUtRemoveReference (Operand[1]); 68567754Smsmith return_ACPI_STATUS (Status); 68667754Smsmith} 687