diff --git a/source/components/executer/excreate.c b/source/components/executer/excreate.c index b3910ec70..5571699ec 100644 --- a/source/components/executer/excreate.c +++ b/source/components/executer/excreate.c @@ -1,7 +1,7 @@ + /****************************************************************************** - * - * Module Name: excreate - Named object creation - * $Revision: 1.97 $ + * + * Module Name: iecreate - Named object creation * *****************************************************************************/ @@ -9,8 +9,8 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp. - * All rights reserved. + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. * * 2. License * @@ -38,9 +38,9 @@ * The above copyright and patent license is granted only if the following * conditions are met: * - * 3. Conditions + * 3. Conditions * - * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * 3.1. Redistribution of Source with Rights to Further Distribute Source. * Redistribution of source code of any substantial portion of the Covered * Code or modification with rights to further distribute source must include * the above Copyright Notice, the above License, this list of Conditions, @@ -48,11 +48,11 @@ * Licensee must cause all Covered Code to which Licensee contributes to * contain a file documenting the changes Licensee made to create that Covered * Code and the date of any change. Licensee must include in that file the - * documentation of any changes made by any predecessor Licensee. Licensee + * documentation of any changes made by any predecessor Licensee. Licensee * must include a prominent statement that the modification is derived, * directly or indirectly, from Original Intel Code. * - * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. * Redistribution of source code of any substantial portion of the Covered * Code or modification without rights to further distribute source must * include the following Disclaimer and Export Compliance provision in the @@ -87,7 +87,7 @@ * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A - * PARTICULAR PURPOSE. + * PARTICULAR PURPOSE. * * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR @@ -115,26 +115,342 @@ * *****************************************************************************/ -#define __EXCREATE_C__ +#define __IECREATE_C__ -#include "acpi.h" -#include "acinterp.h" -#include "amlcode.h" -#include "acnamesp.h" -#include "acevents.h" -#include "actables.h" +#include +#include +#include +#include +#include +#include -#define _COMPONENT ACPI_EXECUTER - ACPI_MODULE_NAME ("excreate") +#define _COMPONENT INTERPRETER + MODULE_NAME ("iecreate"); + + + /***************************************************************************** + * + * FUNCTION: AmlExecCreateField + * + * PARAMETERS: Opcode - The opcode to be executed + * + * RETURN: Status + * + * DESCRIPTION: Execute CreateField operators: CreateBitFieldOp, + * CreateByteFieldOp, CreateWordFieldOp, CreateDWordFieldOp, + * CreateFieldOp (which define fields in buffers) + * + * ALLOCATION: Deletes CreateFieldOp's count operand descriptor + * + * + * ACPI SPECIFICATION REFERENCES: + * 16.2.4.2 DefCreateBitField := CreateBitFieldOp SourceBuff BitIndex NameString + * 16.2.4.2 DefCreateByteField := CreateByteFieldOp SourceBuff ByteIndex NameString + * 16.2.4.2 DefCreateDWordField := CreateDWordFieldOp SourceBuff ByteIndex NameString + * 16.2.4.2 DefCreateField := CreateFieldOp SourceBuff BitIndex NumBits NameString + * 16.2.4.2 DefCreateWordField := CreateWordFieldOp SourceBuff ByteIndex NameString + * 16.2.4.2 BitIndex := TermArg=>Integer + * 16.2.4.2 ByteIndex := TermArg=>Integer + * 16.2.4.2 NumBits := TermArg=>Integer + * 16.2.4.2 SourceBuff := TermArg=>Buffer + * + ****************************************************************************/ + +ACPI_STATUS +AmlExecCreateField ( + UINT16 Opcode, + ACPI_OBJECT_INTERNAL **Operands) +{ + ACPI_OBJECT_INTERNAL *ResDesc = NULL; + ACPI_OBJECT_INTERNAL *CntDesc = NULL; + ACPI_OBJECT_INTERNAL *OffDesc = NULL; + ACPI_OBJECT_INTERNAL *SrcDesc = NULL; + ACPI_OBJECT_INTERNAL *FieldDesc; + ACPI_OBJECT_TYPE ResType; + ACPI_STATUS Status; + char *OpName = NULL; + UINT32 NumOperands; + UINT32 Offset; + UINT32 BitOffset; + UINT16 BitCount; + UINT8 TypeFound; + + + + FUNCTION_TRACE ("AmlExecCreateField"); + + + /* DefCreateField := CreateFieldOp SourceBuff BitIndex NumBits NameString */ + + if (AML_CreateFieldOp == Opcode) + { + Status = AmlPrepOperands ("lnnb", Operands); + NumOperands = 4; + } + + /* + * Create[Bit|Byte|DWord|Word]Field + * DefCreate*Field := Create*FieldOp SourceBuff [Bit|Byte]Index NameString + */ + else + { + Status = AmlPrepOperands ("lnb", Operands); + NumOperands = 3; + } + + if (Status != AE_OK) + { + /* Invalid parameters on object stack */ + + AmlAppendOperandDiag (_THIS_MODULE, __LINE__, Opcode, Operands, NumOperands); + return_ACPI_STATUS (Status); + } + + OpName = PsGetOpcodeName (Opcode); + DUMP_OPERANDS (Operands, IMODE_Execute, OpName, NumOperands, "after AmlPrepOperands"); + + + /* Get the operands */ + + if (AML_CreateFieldOp == Opcode) + { + ResDesc = Operands[0]; + CntDesc = Operands[-1]; + OffDesc = Operands[-2]; + SrcDesc = Operands[-3]; + } + + else + { + ResDesc = Operands[0]; + OffDesc = Operands[-1]; + SrcDesc = Operands[-2]; + } + + Offset = OffDesc->Number.Value; + + + + /* If ResDesc is a Name, it will be a direct name pointer after AmlPrepOperands() */ + + if (!VALID_DESCRIPTOR_TYPE (ResDesc, DESC_TYPE_NTE)) + { + DEBUG_PRINT (ACPI_ERROR, ("AmlExecCreateField (%s): destination must be a Name(NTE)\n", OpName)); + return_ACPI_STATUS (AE_AML_ERROR); + } + + + /* + * Setup the Bit offsets and counts, according to the opcode + */ + + switch (Opcode) + { + + /* DefCreateBitField := CreateBitFieldOp SourceBuff BitIndex NameString */ + + case AML_BitFieldOp: + + BitOffset = Offset; /* offset is in bits */ + BitCount = 1; /* field is a bit */ + break; + + + /* DefCreateByteField := CreateByteFieldOp SourceBuff ByteIndex NameString */ + + case AML_ByteFieldOp: + + BitOffset = 8 * Offset; /* offset is in bytes */ + BitCount = 8; /* field is a Byte */ + break; + + + /* DefCreateWordField := CreateWordFieldOp SourceBuff ByteIndex NameString */ + + case AML_WordFieldOp: + + BitOffset = 8 * Offset; /* offset is in bytes */ + BitCount = 16; /* field is a Word */ + break; + + + /* DefCreateDWordField := CreateDWordFieldOp SourceBuff ByteIndex NameString */ + + case AML_DWordFieldOp: + + BitOffset = 8 * Offset; /* offset is in bytes */ + BitCount = 32; /* field is a DWord */ + break; + + + /* DefCreateField := CreateFieldOp SourceBuff BitIndex NumBits NameString */ + + case AML_CreateFieldOp: + + BitOffset = Offset; /* offset is in bits */ + BitCount = (UINT16) CntDesc->Number.Value; /* as is count */ + break; + + + default: + + DEBUG_PRINT (ACPI_ERROR, ( + "AmlExecCreateField: Internal error - unknown field creation opcode %02x\n", + Opcode)); + return_ACPI_STATUS (AE_AML_ERROR); + + } /* switch */ + + + + /* + * Setup field according to the object type + */ + + switch (SrcDesc->Common.Type) + { + + /* SourceBuff := TermArg=>Buffer */ + + case ACPI_TYPE_Buffer: + + if (BitOffset + (UINT32) BitCount > 8 * (UINT32) SrcDesc->Buffer.Length) + { + DEBUG_PRINT (ACPI_ERROR, ("AmlExecCreateField: Field exceeds Buffer %d > %d\n", + BitOffset + (UINT32) BitCount, + 8 * (UINT32) SrcDesc->Buffer.Length)); + return_ACPI_STATUS (AE_AML_ERROR); + } + + + /* Allocate a temporary object for the field */ + + FieldDesc = CmCreateInternalObject (ACPI_TYPE_FieldUnit); + if (!FieldDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Construct the field object */ + + FieldDesc->FieldUnit.Access = (UINT16) ACCESS_AnyAcc; + FieldDesc->FieldUnit.LockRule = (UINT16) GLOCK_NeverLock; + FieldDesc->FieldUnit.UpdateRule = (UINT16) UPDATE_Preserve; + FieldDesc->FieldUnit.Length = BitCount; + FieldDesc->FieldUnit.BitOffset = (UINT16) BitOffset % 8; + FieldDesc->FieldUnit.Offset = BitOffset / 8; + FieldDesc->FieldUnit.Container = SrcDesc; + FieldDesc->FieldUnit.Sequence = SrcDesc->Buffer.Sequence; + + /* An additional reference for SrcDesc */ + + CmUpdateObjectReference (SrcDesc, REF_INCREMENT); + + break; + + + /* Improper object type */ + + default: + + TypeFound = SrcDesc->Common.Type; + + if ((TypeFound > (UINT8) INTERNAL_TYPE_Lvalue) || + (Gbl_BadType == Gbl_NsTypeNames[TypeFound])) + { + DEBUG_PRINT (ACPI_ERROR, ( + "AmlExecCreateField: Tried to create field in improper object type - encoding %d\n", + TypeFound)); + } + + else + { + DEBUG_PRINT (ACPI_ERROR, ( + "AmlExecCreateField: Tried to create field in improper object type - %s\n", + Gbl_NsTypeNames[TypeFound])); + } + + return_ACPI_STATUS (AE_AML_ERROR); + + } /* switch */ + + + if (AML_CreateFieldOp == Opcode) + { + /* Delete object descriptor unique to CreateField */ + + CmDeleteInternalObject (CntDesc); + CntDesc = NULL; + } + + /* + * This operation is supposed to cause the destination Name to refer + * to the defined FieldUnit -- it must not store the constructed + * FieldUnit object (or its current value) in some location that the + * Name may already be pointing to. So, if the Name currently contains + * a reference which would cause AmlExecStore() to perform an indirect + * store rather than setting the value of the Name itself, clobber that + * reference before calling AmlExecStore(). + */ + + ResType = NsGetType (ResDesc); + switch (ResType) /* Type of Name's existing value */ + { + + case ACPI_TYPE_FieldUnit: + + case INTERNAL_TYPE_Alias: + case INTERNAL_TYPE_BankField: + case INTERNAL_TYPE_DefField: + case INTERNAL_TYPE_IndexField: + + DUMP_PATHNAME (ResDesc, "AmlExecCreateField: clobber ", TRACE_BFIELD, _COMPONENT); + + DUMP_ENTRY (ResDesc, TRACE_BFIELD); + DUMP_STACK_ENTRY (NsGetAttachedObject (ResDesc)); + + NsAttachObject (ResDesc, NULL, ACPI_TYPE_Any); + break; + + + default: + + break; + } + + + /* Store constructed field descriptor in result location */ + + Status = AmlExecStore (FieldDesc, ResDesc); + + + /* All done with the temp field descriptor */ + + CmDeleteInternalObject (FieldDesc); + + + /* Delete the parameters */ + + CmDeleteInternalObject (SrcDesc); + CmDeleteInternalObject (OffDesc); + + /* + * Pop off everything from the stack except the result, + * which we want to leave sitting at the stack top. + */ + + + + return_ACPI_STATUS (Status); +} -#ifndef ACPI_NO_METHOD_EXECUTION /***************************************************************************** * - * FUNCTION: AcpiExCreateAlias + * FUNCTION: AmlExecCreateAlias * - * PARAMETERS: WalkState - Current state, contains operands + * PARAMETERS: None * * RETURN: Status * @@ -143,84 +459,28 @@ ****************************************************************************/ ACPI_STATUS -AcpiExCreateAlias ( - ACPI_WALK_STATE *WalkState) +AmlExecCreateAlias ( + ACPI_OBJECT_INTERNAL **Operands) { - ACPI_NAMESPACE_NODE *TargetNode; - ACPI_NAMESPACE_NODE *AliasNode; - ACPI_STATUS Status = AE_OK; + ACPI_STATUS Status = AE_NOT_IMPLEMENTED; +/* ACPI_OBJECT_INTERNAL *ObjDesc; */ - ACPI_FUNCTION_TRACE ("ExCreateAlias"); + FUNCTION_TRACE ("AmlExecCreateAlias"); - /* Get the source/alias operands (both namespace nodes) */ - - AliasNode = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0]; - TargetNode = (ACPI_NAMESPACE_NODE *) WalkState->Operands[1]; - - if (TargetNode->Type == ACPI_TYPE_LOCAL_ALIAS) - { - /* - * Dereference an existing alias so that we don't create a chain - * of aliases. With this code, we guarantee that an alias is - * always exactly one level of indirection away from the - * actual aliased name. - */ - TargetNode = (ACPI_NAMESPACE_NODE *) TargetNode->Object; - } - - /* - * For objects that can never change (i.e., the NS node will - * permanently point to the same object), we can simply attach - * the object to the new NS node. For other objects (such as - * Integers, buffers, etc.), we have to point the Alias node - * to the original Node. - */ - switch (TargetNode->Type) - { - case ACPI_TYPE_INTEGER: - case ACPI_TYPE_STRING: - case ACPI_TYPE_BUFFER: - case ACPI_TYPE_PACKAGE: - case ACPI_TYPE_BUFFER_FIELD: - - /* - * The new alias has the type ALIAS and points to the original - * NS node, not the object itself. This is because for these - * types, the object can change dynamically via a Store. - */ - AliasNode->Type = ACPI_TYPE_LOCAL_ALIAS; - AliasNode->Object = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, TargetNode); - break; - - default: - - /* Attach the original source object to the new Alias Node */ - - /* - * The new alias assumes the type of the target, and it points - * to the same object. The reference count of the object has an - * additional reference to prevent deletion out from under either the - * target node or the alias Node - */ - Status = AcpiNsAttachObject (AliasNode, - AcpiNsGetAttachedObject (TargetNode), - TargetNode->Type); - break; - } - - /* Since both operands are Nodes, we don't need to delete them */ + BREAKPOINT3; return_ACPI_STATUS (Status); + } /***************************************************************************** * - * FUNCTION: AcpiExCreateEvent + * FUNCTION: AmlExecCreateEvent * - * PARAMETERS: WalkState - Current state + * PARAMETERS: None * * RETURN: Status * @@ -229,121 +489,141 @@ AcpiExCreateAlias ( ****************************************************************************/ ACPI_STATUS -AcpiExCreateEvent ( - ACPI_WALK_STATE *WalkState) +AmlExecCreateEvent ( + ACPI_OBJECT_INTERNAL **Operands) { ACPI_STATUS Status; - ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OBJECT_INTERNAL *ObjDesc; - ACPI_FUNCTION_TRACE ("ExCreateEvent"); + FUNCTION_TRACE ("AmlExecCreateEvent"); - ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_EVENT); + BREAKPOINT3; + + ObjDesc = CmCreateInternalObject (ACPI_TYPE_Event); if (!ObjDesc) { Status = AE_NO_MEMORY; goto Cleanup; } - /* - * Create the actual OS semaphore, with zero initial units -- meaning - * that the event is created in an unsignalled state - */ - Status = AcpiOsCreateSemaphore (ACPI_NO_UNIT_LIMIT, 0, - &ObjDesc->Event.Semaphore); + /* Create the actual OS semaphore */ + + Status = OsdCreateSemaphore (1, &ObjDesc->Event.Semaphore); if (ACPI_FAILURE (Status)) { + CmDeleteInternalObject (ObjDesc); + goto Cleanup; + } + + /* Attach object to the NTE */ + + Status = NsAttachObject (Operands[0], ObjDesc, (UINT8) ACPI_TYPE_Event); + if (ACPI_FAILURE (Status)) + { + OsdDeleteSemaphore (ObjDesc->Event.Semaphore); + CmDeleteInternalObject (ObjDesc); goto Cleanup; } - /* Attach object to the Node */ - Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) WalkState->Operands[0], - ObjDesc, ACPI_TYPE_EVENT); Cleanup: - /* - * Remove local reference to the object (on error, will cause deletion - * of both object and semaphore if present.) - */ - AcpiUtRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); } /***************************************************************************** * - * FUNCTION: AcpiExCreateMutex + * FUNCTION: AmlExecCreateMutex * - * PARAMETERS: WalkState - Current state + * PARAMETERS: InterpreterMode - Current running mode (load1/Load2/Exec) * * RETURN: Status * * DESCRIPTION: Create a new mutex object * - * Mutex (Name[0], SyncLevel[1]) - * ****************************************************************************/ ACPI_STATUS -AcpiExCreateMutex ( - ACPI_WALK_STATE *WalkState) +AmlExecCreateMutex ( + OPERATING_MODE InterpreterMode, + ACPI_OBJECT_INTERNAL **Operands) { ACPI_STATUS Status = AE_OK; - ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OBJECT_INTERNAL *SyncDesc; + ACPI_OBJECT_INTERNAL *ObjDesc; - ACPI_FUNCTION_TRACE_PTR ("ExCreateMutex", ACPI_WALK_OPERANDS); + + FUNCTION_TRACE_PTR ("AmlExecCreateMutex", Operands); - /* Create the new mutex object */ + if (IMODE_LoadPass2 == InterpreterMode) + { + /* + * Successful execution + * Convert the Number from AmlDoByteConst() into a Mutex + */ - ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_MUTEX); - if (!ObjDesc) - { - Status = AE_NO_MEMORY; - goto Cleanup; + SyncDesc = Operands[0]; + if (!SyncDesc) + { + return_ACPI_STATUS (AE_AML_ERROR); + } + + /* Attempt to allocate a new object */ + + ObjDesc = CmCreateInternalObject (ACPI_TYPE_Mutex); + if (!ObjDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* Create the actual OS semaphore */ + + Status = OsdCreateSemaphore (1, &ObjDesc->Mutex.Semaphore); + if (ACPI_FAILURE (Status)) + { + CmDeleteInternalObject (ObjDesc); + goto Cleanup; + } + + ObjDesc->Mutex.SyncLevel = (UINT8) SyncDesc->Number.Value; + + /* ObjDesc was on the stack top, and the name is below it */ + + Status = NsAttachObject (Operands [-1], /* Name */ + ObjDesc, (UINT8) ACPI_TYPE_Mutex); + if (ACPI_FAILURE (Status)) + { + OsdDeleteSemaphore (ObjDesc->Mutex.Semaphore); + CmDeleteInternalObject (ObjDesc); + goto Cleanup; + } } - /* - * Create the actual OS semaphore. - * One unit max to make it a mutex, with one initial unit to allow - * the mutex to be acquired. - */ - Status = AcpiOsCreateSemaphore (1, 1, &ObjDesc->Mutex.Semaphore); - if (ACPI_FAILURE (Status)) - { - goto Cleanup; - } - - /* Init object and attach to NS node */ - - ObjDesc->Mutex.SyncLevel = (UINT8) WalkState->Operands[1]->Integer.Value; - ObjDesc->Mutex.Node = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0]; - - Status = AcpiNsAttachObject (ObjDesc->Mutex.Node, - ObjDesc, ACPI_TYPE_MUTEX); - Cleanup: - /* - * Remove local reference to the object (on error, will cause deletion - * of both object and semaphore if present.) - */ - AcpiUtRemoveReference (ObjDesc); + + /* Always delete the operand */ + + CmDeleteOperand (&Operands[0]); + return_ACPI_STATUS (Status); } /***************************************************************************** * - * FUNCTION: AcpiExCreateRegion + * FUNCTION: AmlExecCreateRegion * - * PARAMETERS: AmlStart - Pointer to the region declaration AML + * PARAMETERS: AmlPtr - Pointer to the region declaration AML * AmlLength - Max length of the declaration AML - * Operands - List of operands for the opcode - * WalkState - Current state + * InterpreterMode - Load1/Load2/Execute * * RETURN: Status * @@ -352,377 +632,341 @@ Cleanup: ****************************************************************************/ ACPI_STATUS -AcpiExCreateRegion ( - UINT8 *AmlStart, +AmlExecCreateRegion ( + UINT8 *AmlPtr, UINT32 AmlLength, - UINT8 RegionSpace, - ACPI_WALK_STATE *WalkState) + ACPI_OBJECT_INTERNAL **Operands, + OPERATING_MODE InterpreterMode) { ACPI_STATUS Status; - ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_NAMESPACE_NODE *Node; - ACPI_OPERAND_OBJECT *RegionObj2; + ACPI_OBJECT_INTERNAL *SpaceIdDesc; + ACPI_OBJECT_INTERNAL *AddressDesc; + ACPI_OBJECT_INTERNAL *LengthDesc; + ACPI_OBJECT_INTERNAL *ObjDescRegion; + ACPI_HANDLE *Entry; + UINT32 RegionSpace; - ACPI_FUNCTION_TRACE ("ExCreateRegion"); + FUNCTION_TRACE ("AmlExecCreateRegion"); - /* Get the Node from the object stack */ + /* Get operands */ - Node = WalkState->Op->Common.Node; - - /* - * If the region object is already attached to this node, - * just return - */ - if (AcpiNsGetAttachedObject (Node)) - { - return_ACPI_STATUS (AE_OK); - } - - /* - * Space ID must be one of the predefined IDs, or in the user-defined - * range - */ - if ((RegionSpace >= ACPI_NUM_PREDEFINED_REGIONS) && - (RegionSpace < ACPI_USER_REGION_BEGIN)) - { - ACPI_REPORT_ERROR (("Invalid AddressSpace type %X\n", RegionSpace)); - return_ACPI_STATUS (AE_AML_INVALID_SPACE_ID); - } - - ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Region Type - %s (%X)\n", - AcpiUtGetRegionName (RegionSpace), RegionSpace)); + LengthDesc = Operands [0]; + AddressDesc = Operands [-1]; + SpaceIdDesc = Operands [-2]; + Entry = (ACPI_HANDLE *) Operands [-3]; /* Create the region descriptor */ - ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_REGION); - if (!ObjDesc) + ObjDescRegion = CmCreateInternalObject (ACPI_TYPE_Region); + if (!ObjDescRegion) { Status = AE_NO_MEMORY; goto Cleanup; } - /* - * Remember location in AML stream of address & length - * operands since they need to be evaluated at run time. - */ - RegionObj2 = ObjDesc->Common.NextObject; - RegionObj2->Extra.AmlStart = AmlStart; - RegionObj2->Extra.AmlLength = AmlLength; - /* Init the region from the operands */ - ObjDesc->Region.SpaceId = RegionSpace; - ObjDesc->Region.Address = 0; - ObjDesc->Region.Length = 0; - ObjDesc->Region.Node = Node; + RegionSpace = SpaceIdDesc->Number.Value; - /* Install the new region object in the parent Node */ + ObjDescRegion->Region.SpaceId = RegionSpace; + ObjDescRegion->Region.Address = 0; + ObjDescRegion->Region.Length = 0; + ObjDescRegion->Region.DataValid = 0; - Status = AcpiNsAttachObject (Node, ObjDesc, ACPI_TYPE_REGION); + /* Decode the RegionSpace */ - -Cleanup: - - /* Remove local reference to the object */ - - AcpiUtRemoveReference (ObjDesc); - return_ACPI_STATUS (Status); -} - - -/***************************************************************************** - * - * FUNCTION: AcpiExCreateTableRegion - * - * PARAMETERS: WalkState - Current state - * - * RETURN: Status - * - * DESCRIPTION: Create a new DataTableRegion object - * - ****************************************************************************/ - -ACPI_STATUS -AcpiExCreateTableRegion ( - ACPI_WALK_STATE *WalkState) -{ - ACPI_STATUS Status; - ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; - ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_NAMESPACE_NODE *Node; - ACPI_TABLE_HEADER *Table; - ACPI_OPERAND_OBJECT *RegionObj2; - - - ACPI_FUNCTION_TRACE ("ExCreateTableRegion"); - - /* Get the Node from the object stack */ - - Node = WalkState->Op->Common.Node; - - /* - * If the region object is already attached to this node, - * just return - */ - if (AcpiNsGetAttachedObject (Node)) + if (RegionSpace >= NUM_REGION_TYPES) { - return_ACPI_STATUS (AE_OK); + DEBUG_PRINT (TRACE_LOAD, ("AmlDoNamedObject: Type out of range [*???*]\n")); + REPORT_WARNING ("Unable to decode the RegionSpace"); } - /* Find the ACPI table */ - - Status = AcpiTbFindTable (Operand[1]->String.Pointer, - Operand[2]->String.Pointer, - Operand[3]->String.Pointer, &Table); - - if (ACPI_FAILURE (Status)) + else { - return_ACPI_STATUS (Status); + DEBUG_PRINT (TRACE_LOAD, ("AmlDoNamedObject: Region Type [%s]\n", + Gbl_RegionTypes[RegionSpace])); } - /* Create the region descriptor */ - - ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_REGION); - if (!ObjDesc) + if ((IMODE_LoadPass1 == InterpreterMode) || + (IMODE_LoadPass2 == InterpreterMode)) { - return_ACPI_STATUS (AE_NO_MEMORY); + /* + * If not done already, we must allocate a method object + * for this region. + */ + if (!ObjDescRegion->Region.Method) + { + ObjDescRegion->Region.Method = + CmCreateInternalObject (ACPI_TYPE_Method); + + if (!ObjDescRegion->Region.Method) + { + Status = AE_NO_MEMORY; + /* Delete ObjDescRegion */ + goto Cleanup; + } + } + + /* + * Remember location in AML stream of address & length + * operands since they need to be evaluated at run time. + */ + ObjDescRegion->Region.Method->Method.Pcode = AmlPtr; + ObjDescRegion->Region.Method->Method.PcodeLength = AmlLength; } - RegionObj2 = ObjDesc->Common.NextObject; - RegionObj2->Extra.RegionContext = NULL; + + if (IMODE_Execute == InterpreterMode) + { + /* + * Record value computed for the "region base address" expression + */ + + if (VALID_DESCRIPTOR_TYPE (AddressDesc, DESC_TYPE_ACPI_OBJ)) + { + if (AddressDesc->Common.Type != (UINT8) ACPI_TYPE_Number) + { + /* Object is not of type Number */ - /* Init the region from the operands */ + DEBUG_PRINT (ACPI_ERROR, + ("AmlDoNamedObject/RegionOp: Malformed Region/Address\n")); - ObjDesc->Region.SpaceId = REGION_DATA_TABLE; - ObjDesc->Region.Address = (ACPI_PHYSICAL_ADDRESS) ACPI_TO_INTEGER (Table); - ObjDesc->Region.Length = Table->Length; - ObjDesc->Region.Node = Node; - ObjDesc->Region.Flags = AOPOBJ_DATA_VALID; + Status = AE_AML_ERROR; + goto Cleanup; + } - /* Install the new region object in the parent Node */ + ObjDescRegion->Region.Address = AddressDesc->Number.Value; + } - Status = AcpiNsAttachObject (Node, ObjDesc, ACPI_TYPE_REGION); + + + /* + * Record value computed for the "region length" expression + */ + + if (VALID_DESCRIPTOR_TYPE (LengthDesc, DESC_TYPE_ACPI_OBJ)) + { + if (LengthDesc->Common.Type != (UINT8) ACPI_TYPE_Number) + { + /* Object is not of type Number */ + + DEBUG_PRINT (ACPI_ERROR, + ("AmlDoNamedObject/RegionOp: Malformed Region/Length\n")); + + Status = AE_AML_ERROR; + goto Cleanup; + } + + ObjDescRegion->Region.Length = LengthDesc->Number.Value; + ObjDescRegion->Region.DataValid = 1; + } + } + + + /* Install the new region object in the parent NTE */ + + ObjDescRegion->Region.Nte = (NAME_TABLE_ENTRY *) Entry; + + Status = NsAttachObject (Entry, ObjDescRegion, (UINT8) ACPI_TYPE_Region); if (ACPI_FAILURE (Status)) { goto Cleanup; } - Status = AcpiEvInitializeRegion (ObjDesc, FALSE); - if (ACPI_FAILURE (Status)) - { - if (Status == AE_NOT_EXIST) - { - Status = AE_OK; - } - else - { - goto Cleanup; - } - } - ObjDesc->Region.Flags |= AOPOBJ_SETUP_COMPLETE; Cleanup: - /* Remove local reference to the object */ + if (Status != AE_OK) + { + /* Delete region object and method subobject */ + + if (ObjDescRegion) + { + CmDeleteInternalObject (ObjDescRegion); /* Deletes both objects! */ + ObjDescRegion = NULL; + } + } + + /* Delete operands */ + + CmDeleteOperand (&Operands[0]); + CmDeleteOperand (&Operands[-1]); + CmDeleteOperand (&Operands[-2]); + + /* + * If we have a valid region and we are in load pass two, + * now is the time to initialize the region. + * (The object stack is completely cleared. Not executing, no nested methods) + */ + if (ObjDescRegion) + { + if (IMODE_LoadPass2 == InterpreterMode) + { + /* + * TBD: Is there anything we can or could do when this fails? + * We need to do something useful with a failure. + */ + (void *) EvInitializeRegion (ObjDescRegion); + } + + } - AcpiUtRemoveReference (ObjDesc); return_ACPI_STATUS (Status); } /***************************************************************************** * - * FUNCTION: AcpiExCreateProcessor + * FUNCTION: AmlExecCreateProcessor * - * PARAMETERS: WalkState - Current state + * PARAMETERS: Op - Op containing the Processor definition and args + * ProcessorNTE - NTE for the containing NTE * * RETURN: Status * * DESCRIPTION: Create a new processor object and populate the fields * - * Processor (Name[0], CpuID[1], PblockAddr[2], PblockLength[3]) - * ****************************************************************************/ ACPI_STATUS -AcpiExCreateProcessor ( - ACPI_WALK_STATE *WalkState) +AmlExecCreateProcessor ( + ACPI_GENERIC_OP *Op, + ACPI_HANDLE ProcessorNTE) { - ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; - ACPI_OPERAND_OBJECT *ObjDesc; ACPI_STATUS Status; + ACPI_GENERIC_OP *Arg; + ACPI_OBJECT_INTERNAL *ObjDesc; - ACPI_FUNCTION_TRACE_PTR ("ExCreateProcessor", WalkState); + FUNCTION_TRACE_PTR ("AmlExecCreateProcessor", Op); - /* Create the processor object */ - - ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_PROCESSOR); + ObjDesc = CmCreateInternalObject (ACPI_TYPE_Processor); if (!ObjDesc) { - return_ACPI_STATUS (AE_NO_MEMORY); + Status = AE_NO_MEMORY; + return_ACPI_STATUS (Status); } - /* - * Initialize the processor object from the operands - */ - ObjDesc->Processor.ProcId = (UINT8) Operand[1]->Integer.Value; - ObjDesc->Processor.Address = (ACPI_IO_ADDRESS) Operand[2]->Integer.Value; - ObjDesc->Processor.Length = (UINT8) Operand[3]->Integer.Value; + /* Install the new processor object in the parent NTE */ - /* Install the processor object in the parent Node */ + Status = NsAttachObject (ProcessorNTE, ObjDesc, (UINT8) ACPI_TYPE_Processor); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS(Status); + } - Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0], - ObjDesc, ACPI_TYPE_PROCESSOR); + Arg = Op->Value.Arg; + /* check existence */ - /* Remove local reference to the object */ + if (!Arg) + { + Status = AE_AML_ERROR; + return_ACPI_STATUS (Status); + } - AcpiUtRemoveReference (ObjDesc); - return_ACPI_STATUS (Status); + /* First arg is the Processor ID */ + ObjDesc->Processor.ProcId = (UINT8) Arg->Value.Integer; + + /* Move to next arg and check existence */ + Arg = Arg->Next; + if (!Arg) + { + Status = AE_AML_ERROR; + return_ACPI_STATUS (Status); + } + + /* Second arg is the PBlock Address */ + ObjDesc->Processor.PBLKAddress = (UINT32) Arg->Value.Integer; + + /* Move to next arg and check existence */ + Arg = Arg->Next; + if (!Arg) + { + Status = AE_AML_ERROR; + return_ACPI_STATUS (Status); + } + + /* Third arg is the PBlock Length */ + ObjDesc->Processor.PBLKLength = (UINT8) Arg->Value.Integer; + + return_ACPI_STATUS (AE_OK); } + /***************************************************************************** * - * FUNCTION: AcpiExCreatePowerResource + * FUNCTION: AmlExecCreateMethod * - * PARAMETERS: WalkState - Current state + * PARAMETERS: InterpreterMode - Current running mode (load1/Load2/Exec) * * RETURN: Status * - * DESCRIPTION: Create a new PowerResource object and populate the fields - * - * PowerResource (Name[0], SystemLevel[1], ResourceOrder[2]) + * DESCRIPTION: Create a new mutex object * ****************************************************************************/ ACPI_STATUS -AcpiExCreatePowerResource ( - ACPI_WALK_STATE *WalkState) -{ - ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; - ACPI_STATUS Status; - ACPI_OPERAND_OBJECT *ObjDesc; - - - ACPI_FUNCTION_TRACE_PTR ("ExCreatePowerResource", WalkState); - - - /* Create the power resource object */ - - ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_POWER); - if (!ObjDesc) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } - - /* Initialize the power object from the operands */ - - ObjDesc->PowerResource.SystemLevel = (UINT8) Operand[1]->Integer.Value; - ObjDesc->PowerResource.ResourceOrder = (UINT16) Operand[2]->Integer.Value; - - /* Install the power resource object in the parent Node */ - - Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0], - ObjDesc, ACPI_TYPE_POWER); - - - /* Remove local reference to the object */ - - AcpiUtRemoveReference (ObjDesc); - return_ACPI_STATUS (Status); -} - -#endif - -/***************************************************************************** - * - * FUNCTION: AcpiExCreateMethod - * - * PARAMETERS: AmlStart - First byte of the method's AML - * AmlLength - AML byte count for this method - * WalkState - Current state - * - * RETURN: Status - * - * DESCRIPTION: Create a new method object - * - ****************************************************************************/ - -ACPI_STATUS -AcpiExCreateMethod ( - UINT8 *AmlStart, +AmlExecCreateMethod ( + UINT8 *AmlPtr, UINT32 AmlLength, - ACPI_WALK_STATE *WalkState) + UINT32 MethodFlags, + ACPI_HANDLE Method) { - ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; - ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OBJECT_INTERNAL *ObjDesc; ACPI_STATUS Status; - UINT8 MethodFlags; - ACPI_FUNCTION_TRACE_PTR ("ExCreateMethod", WalkState); + FUNCTION_TRACE_PTR ("AmlExecCreateMethod", Method); /* Create a new method object */ - ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_METHOD); + ObjDesc = CmCreateInternalObject (ACPI_TYPE_Method); if (!ObjDesc) { return_ACPI_STATUS (AE_NO_MEMORY); } - /* Save the method's AML pointer and length */ + /* Get the method's AML pointer/length from the Op */ - ObjDesc->Method.AmlStart = AmlStart; - ObjDesc->Method.AmlLength = AmlLength; + ObjDesc->Method.Pcode = AmlPtr; + ObjDesc->Method.PcodeLength = AmlLength; - /* disassemble the method flags */ - - MethodFlags = (UINT8) Operand[1]->Integer.Value; + /* First argument is the Method Flags (contains parameter count for the method) */ ObjDesc->Method.MethodFlags = MethodFlags; - ObjDesc->Method.ParamCount = (UINT8) (MethodFlags & METHOD_FLAGS_ARG_COUNT); + ObjDesc->Method.ParamCount = MethodFlags & ACPI_METHOD_ARG_MASK; + + /* Method is not parsed yet */ - /* - * Get the concurrency count. If required, a semaphore will be - * created for this method when it is parsed. - */ - if (MethodFlags & METHOD_FLAGS_SERIALIZED) + ObjDesc->Method.ParserOp = NULL; + + /* Another +1 gets added when PsxExecute is called, no need for: ObjDesc->Method.Pcode++; */ + + ObjDesc->Method.AcpiTable = NULL; /* TBD: was (UINT8 *) PcodeAddr; */ + ObjDesc->Method.TableLength = 0; /* TBD: needed? (UINT32) (WalkState->amlEnd - PcodeAddr); */ + + /* Attach the new object to the method NTE */ + + Status = NsAttachObject (Method, ObjDesc, (UINT8) ACPI_TYPE_Method); + if (ACPI_FAILURE (Status)) { - /* - * ACPI 1.0: Concurrency = 1 - * ACPI 2.0: Concurrency = (SyncLevel (in method declaration) + 1) - */ - ObjDesc->Method.Concurrency = (UINT8) - (((MethodFlags & METHOD_FLAGS_SYNCH_LEVEL) >> 4) + 1); + CmFree (ObjDesc); } - else - { - ObjDesc->Method.Concurrency = INFINITE_CONCURRENCY; - } - - /* Attach the new object to the method Node */ - - Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0], - ObjDesc, ACPI_TYPE_METHOD); - - /* Remove local reference to the object */ - - AcpiUtRemoveReference (ObjDesc); - - /* Remove a reference to the operand */ - - AcpiUtRemoveReference (Operand[1]); return_ACPI_STATUS (Status); } + + + +