Added and deployed FUNCTION_ENTRY macro. Cleaned up comments to

standardize multi-line comments.


date	2001.08.27.17.57.00;	author rmoore1;	state Exp;
This commit is contained in:
aystarik 2005-06-29 17:44:41 +00:00
parent 4157875280
commit 89380e6615
8 changed files with 1422 additions and 1759 deletions

View File

@ -2,7 +2,7 @@
/******************************************************************************
*
* Module Name: exregion - ACPI default OpRegion (address space) handlers
* $Revision: 1.54 $
* $Revision: 1.56 $
*
*****************************************************************************/
@ -183,7 +183,7 @@ AcpiExSystemMemorySpaceHandler (
break;
default:
DEBUG_PRINTP (ACPI_ERROR, ("Invalid SystemMemory width %d\n",
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid SystemMemory width %d\n",
BitWidth));
return_ACPI_STATUS (AE_AML_OPERAND_VALUE);
break;
@ -195,7 +195,6 @@ AcpiExSystemMemorySpaceHandler (
* Is 1) Address below the current mapping? OR
* 2) Address beyond the current mapping?
*/
if ((Address < MemInfo->MappedPhysicalAddress) ||
(((ACPI_INTEGER) Address + Length) >
((ACPI_INTEGER) MemInfo->MappedPhysicalAddress + MemInfo->MappedLength)))
@ -204,7 +203,6 @@ AcpiExSystemMemorySpaceHandler (
* The request cannot be resolved by the current memory mapping;
* Delete the existing mapping and create a new one.
*/
if (MemInfo->MappedLength)
{
/* Valid mapping, delete it */
@ -241,9 +239,9 @@ AcpiExSystemMemorySpaceHandler (
LogicalAddrPtr = MemInfo->MappedLogicalAddress +
((ACPI_INTEGER) Address - (ACPI_INTEGER) MemInfo->MappedPhysicalAddress);
DEBUG_PRINT ((TRACE_OPREGION | VERBOSE_INFO),
("IO %d (%d width) Address=%8.8lX%8.8lX\n", Function, BitWidth,
HIDWORD(Address), LODWORD(Address)));
ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
"IO %d (%d width) Address=%8.8lX%8.8lX\n", Function, BitWidth,
HIDWORD (Address), LODWORD (Address)));
/* Perform the memory read or write */
@ -332,9 +330,9 @@ AcpiExSystemIoSpaceHandler (
FUNCTION_TRACE ("ExSystemIoSpaceHandler");
DEBUG_PRINT ((TRACE_OPREGION | VERBOSE_INFO),
("IO %d (%d width) Address=%8.8lX%8.8lX\n", Function, BitWidth,
HIDWORD(Address), LODWORD(Address)));
ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
"IO %d (%d width) Address=%8.8lX%8.8lX\n", Function, BitWidth,
HIDWORD (Address), LODWORD (Address)));
/* Decode the function parameter */
@ -413,8 +411,8 @@ AcpiExPciConfigSpaceHandler (
PciId = (ACPI_PCI_ID *) RegionContext;
PciRegister = (UINT16) Address;
DEBUG_PRINT ((TRACE_OPREGION | VERBOSE_INFO),
("IO %d (%d) Seg(%04x) Bus(%04x) Dev(%04x) Func(%04x) Reg(%04x)\n",
ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
"IO %d (%d) Seg(%04x) Bus(%04x) Dev(%04x) Func(%04x) Reg(%04x)\n",
Function, BitWidth, PciId->Segment, PciId->Bus, PciId->Device,
PciId->Function, PciRegister));

View File

@ -1,7 +1,8 @@
/******************************************************************************
*
* Module Name: amresop - AML Interpreter operand/object resolution
* Module Name: exresop - AML Interpreter operand/object resolution
* $Revision: 1.36 $
*
*****************************************************************************/
@ -9,8 +10,8 @@
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999, Intel Corp. All rights
* reserved.
* Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp.
* All rights reserved.
*
* 2. License
*
@ -114,7 +115,7 @@
*
*****************************************************************************/
#define __AMRESOP_C__
#define __EXRESOP_C__
#include "acpi.h"
#include "amlcode.h"
@ -126,13 +127,57 @@
#include "acevents.h"
#define _COMPONENT INTERPRETER
MODULE_NAME ("amresop");
#define _COMPONENT ACPI_EXECUTER
MODULE_NAME ("exresop")
/*******************************************************************************
*
* FUNCTION: AcpiAmlResolveOperands
* FUNCTION: AcpiExCheckObjectType
*
* PARAMETERS: TypeNeeded Object type needed
* ThisType Actual object type
* Object Object pointer
*
* RETURN: Status
*
* DESCRIPTION: Check required type against actual type
*
******************************************************************************/
ACPI_STATUS
AcpiExCheckObjectType (
ACPI_OBJECT_TYPE TypeNeeded,
ACPI_OBJECT_TYPE ThisType,
void *Object)
{
PROC_NAME ("ExCheckObjectType");
if (TypeNeeded == ACPI_TYPE_ANY)
{
/* All types OK, so we don't perform any typechecks */
return (AE_OK);
}
if (TypeNeeded != ThisType)
{
ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
"Needed [%s], found [%s] %p\n",
AcpiUtGetTypeName (TypeNeeded),
AcpiUtGetTypeName (ThisType), Object));
return (AE_AML_OPERAND_TYPE);
}
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: AcpiExResolveOperands
*
* PARAMETERS: Opcode Opcode being interpreted
* StackPtr Top of operand stack
@ -150,24 +195,26 @@
******************************************************************************/
ACPI_STATUS
AcpiAmlResolveOperands (
AcpiExResolveOperands (
UINT16 Opcode,
ACPI_OBJECT_INTERNAL **StackPtr)
ACPI_OPERAND_OBJECT **StackPtr,
ACPI_WALK_STATE *WalkState)
{
ACPI_OBJECT_INTERNAL *ObjDesc;
ACPI_OPERAND_OBJECT *ObjDesc;
ACPI_STATUS Status = AE_OK;
UINT8 ObjectType;
ACPI_HANDLE TempHandle;
void *TempNode;
UINT32 ArgTypes;
ACPI_OP_INFO *OpInfo;
const ACPI_OPCODE_INFO *OpInfo;
UINT32 ThisArgType;
ACPI_OBJECT_TYPE TypeNeeded;
FUNCTION_TRACE_U32 ("AmlResolveOperands", Opcode);
FUNCTION_TRACE_U32 ("ExResolveOperands", Opcode);
OpInfo = AcpiPsGetOpcodeInfo (Opcode);
if (!OpInfo)
if (ACPI_GET_OP_TYPE (OpInfo) != ACPI_OP_TYPE_OPCODE)
{
return_ACPI_STATUS (AE_AML_BAD_OPCODE);
}
@ -176,33 +223,31 @@ AcpiAmlResolveOperands (
ArgTypes = OpInfo->RuntimeArgs;
if (ArgTypes == ARGI_INVALID_OPCODE)
{
DEBUG_PRINT (ACPI_ERROR,
("AmlResolveOperands: Internal error - %X is not a runtime opcode\n", Opcode));
Status = AE_AML_INTERNAL;
goto Cleanup;
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Internal - %X is not a valid AML opcode\n",
Opcode));
return_ACPI_STATUS (AE_AML_INTERNAL);
}
DEBUG_PRINT (TRACE_EXEC,
("AmlResolveOperands: Opcode %X OperandTypes=%X \n",
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Opcode %X OperandTypes=%X \n",
Opcode, ArgTypes));
/*
* Normal exit is with *Types == '\0' at end of string.
/*
* Normal exit is with (ArgTypes == 0) at end of argument list.
* Function will return an exception from within the loop upon
* finding an entry which is not, and cannot be converted
* to, the required type; if stack underflows; or upon
* finding a NULL stack entry (which "should never happen").
* finding an entry which is not (or cannot be converted
* to) the required type; if stack underflows; or upon
* finding a NULL stack entry (which should not happen).
*/
while (GET_CURRENT_ARG_TYPE (ArgTypes))
{
if (!StackPtr || !*StackPtr)
{
DEBUG_PRINT (ACPI_ERROR,
("AmlResolveOperands: Internal error - null stack entry at %X\n", StackPtr));
Status = AE_AML_INTERNAL;
goto Cleanup;
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Internal - null stack entry at %X\n",
StackPtr));
return_ACPI_STATUS (AE_AML_INTERNAL);
}
/* Extract useful items */
@ -213,9 +258,9 @@ AcpiAmlResolveOperands (
if (VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_NAMED))
{
/* NTE */
/* Node */
ObjectType = ((ACPI_NAMED_OBJECT*) ObjDesc)->Type;
ObjectType = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type;
}
else if (VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_INTERNAL))
@ -226,13 +271,12 @@ AcpiAmlResolveOperands (
/* Check for bad ACPI_OBJECT_TYPE */
if (!AcpiAmlValidateObjectType (ObjectType))
if (!AcpiExValidateObjectType (ObjectType))
{
DEBUG_PRINT (ACPI_ERROR,
("AmlResolveOperands: Bad operand object type [0x%x]\n",
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Bad operand object type [%X]\n",
ObjectType));
Status = AE_AML_OPERAND_TYPE;
goto Cleanup;
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
if (ObjectType == (UINT8) INTERNAL_TYPE_REFERENCE)
@ -240,15 +284,14 @@ AcpiAmlResolveOperands (
/*
* Decode the Reference
*/
OpInfo = AcpiPsGetOpcodeInfo (Opcode);
if (!OpInfo)
if (ACPI_GET_OP_TYPE (OpInfo) != ACPI_OP_TYPE_OPCODE)
{
return_ACPI_STATUS (AE_AML_BAD_OPCODE);
}
switch (ObjDesc->Reference.OpCode)
switch (ObjDesc->Reference.Opcode)
{
case AML_ZERO_OP:
case AML_ONE_OP:
@ -259,269 +302,258 @@ AcpiAmlResolveOperands (
case AML_ARG_OP:
case AML_LOCAL_OP:
DEBUG_ONLY_MEMBERS (DEBUG_PRINT (ACPI_INFO,
("Reference Opcode: %s\n", OpInfo->Name)));
DEBUG_ONLY_MEMBERS (ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
"Reference Opcode: %s\n", OpInfo->Name)));
break;
default:
DEBUG_PRINT (ACPI_INFO,
("Reference Opcode: Unknown [%02x]\n",
ObjDesc->Reference.OpCode));
ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
"Reference Opcode: Unknown [%02x]\n",
ObjDesc->Reference.Opcode));
Status = AE_AML_OPERAND_TYPE;
goto Cleanup;
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
break;
}
}
}
else
{
/* Invalid descriptor */
DEBUG_PRINT (ACPI_ERROR,
("Bad descriptor type 0x%X in Obj %p\n",
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Bad descriptor type %X in Obj %p\n",
ObjDesc->Common.DataType, ObjDesc));
Status = AE_AML_OPERAND_TYPE;
goto Cleanup;
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
/*
* Decode a character from the type string
* Get one argument type, point to the next
*/
ThisArgType = GET_CURRENT_ARG_TYPE (ArgTypes);
INCREMENT_ARG_LIST (ArgTypes);
/*
* Handle cases where the object does not need to be
* resolved to a value
*/
switch (ThisArgType)
{
case ARGI_REFERENCE: /* Reference */
case ARGI_TARGETREF:
case ARGI_REFERENCE: /* References */
case ARGI_INTEGER_REF:
case ARGI_OBJECT_REF:
case ARGI_DEVICE_REF:
case ARGI_TARGETREF: /* TBD: must implement implicit conversion rules before store */
case ARGI_FIXED_TARGET: /* No implicit conversion before store to target */
case ARGI_SIMPLE_TARGET: /* Name, Local, or Arg - no implicit conversion */
/* Need an operand of type INTERNAL_TYPE_REFERENCE */
if (VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_NAMED)) /* direct name ptr OK as-is */
{
break;
goto NextOperand;
}
if (INTERNAL_TYPE_REFERENCE != ObjectType)
Status = AcpiExCheckObjectType (INTERNAL_TYPE_REFERENCE,
ObjectType, ObjDesc);
if (ACPI_FAILURE (Status))
{
DEBUG_PRINT (ACPI_INFO,
("AmlResolveOperands: Needed Reference, found %s Obj=%p\n",
AcpiCmGetTypeName (ObjectType), *StackPtr));
Status = AE_AML_OPERAND_TYPE;
goto Cleanup;
return_ACPI_STATUS (Status);
}
if (AML_NAME_OP == ObjDesc->Reference.OpCode)
if (AML_NAME_OP == ObjDesc->Reference.Opcode)
{
/*
* Convert an indirect name ptr to direct name ptr and put
* it on the stack
*/
TempHandle = ObjDesc->Reference.Object;
AcpiCmRemoveReference (ObjDesc);
(*StackPtr) = TempHandle;
}
break;
case ARGI_NUMBER: /* Number */
/* Need an operand of type ACPI_TYPE_NUMBER */
Status = AcpiAmlResolveToValue (StackPtr);
if (ACPI_FAILURE (Status))
{
goto Cleanup;
TempNode = ObjDesc->Reference.Object;
AcpiUtRemoveReference (ObjDesc);
(*StackPtr) = TempNode;
}
if (ACPI_TYPE_NUMBER != (*StackPtr)->Common.Type)
{
DEBUG_PRINT (ACPI_INFO,
("AmlResolveOperands: Needed Number, found %s Obj=%p\n",
AcpiCmGetTypeName (ObjectType), *StackPtr));
Status = AE_AML_OPERAND_TYPE;
goto Cleanup;
}
break;
case ARGI_STRING:
/* Need an operand of type ACPI_TYPE_STRING or ACPI_TYPE_BUFFER */
Status = AcpiAmlResolveToValue (StackPtr);
if (ACPI_FAILURE (Status))
{
goto Cleanup;
}
if ((ACPI_TYPE_STRING != (*StackPtr)->Common.Type) &&
(ACPI_TYPE_BUFFER != (*StackPtr)->Common.Type))
{
DEBUG_PRINT (ACPI_INFO,
("AmlResolveOperands: Needed String or Buffer, found %s Obj=%p\n",
AcpiCmGetTypeName (ObjectType), *StackPtr));
Status = AE_AML_OPERAND_TYPE;
goto Cleanup;
}
break;
case ARGI_BUFFER:
/* Need an operand of type ACPI_TYPE_BUFFER */
Status = AcpiAmlResolveToValue (StackPtr);
if (ACPI_FAILURE (Status))
{
goto Cleanup;
}
if (ACPI_TYPE_BUFFER != (*StackPtr)->Common.Type)
{
DEBUG_PRINT (ACPI_INFO,
("AmlResolveOperands: Needed Buffer, found %s Obj=%p\n",
AcpiCmGetTypeName (ObjectType), *StackPtr));
Status = AE_AML_OPERAND_TYPE;
goto Cleanup;
}
break;
case ARGI_MUTEX:
/* Need an operand of type ACPI_TYPE_MUTEX */
Status = AcpiAmlResolveToValue (StackPtr);
if (ACPI_FAILURE (Status))
{
goto Cleanup;
}
if (ACPI_TYPE_MUTEX != (*StackPtr)->Common.Type)
{
DEBUG_PRINT (ACPI_INFO,
("AmlResolveOperands: Needed Mutex, found %s Obj=%p\n",
AcpiCmGetTypeName (ObjectType), *StackPtr));
Status = AE_AML_OPERAND_TYPE;
goto Cleanup;
}
break;
case ARGI_EVENT:
/* Need an operand of type ACPI_TYPE_EVENT */
Status = AcpiAmlResolveToValue (StackPtr);
if (ACPI_FAILURE (Status))
{
goto Cleanup;
}
if (ACPI_TYPE_EVENT != (*StackPtr)->Common.Type)
{
DEBUG_PRINT (ACPI_INFO,
("AmlResolveOperands: Needed AcpiEvent, found %s Obj=%p\n",
AcpiCmGetTypeName (ObjectType), *StackPtr));
Status = AE_AML_OPERAND_TYPE;
goto Cleanup;
}
break;
case ARGI_REGION:
/* Need an operand of type ACPI_TYPE_REGION */
Status = AcpiAmlResolveToValue (StackPtr);
if (ACPI_FAILURE (Status))
{
goto Cleanup;
}
if (ACPI_TYPE_REGION != (*StackPtr)->Common.Type)
{
DEBUG_PRINT (ACPI_INFO,
("AmlResolveOperands: Needed Region, found %s Obj=%p\n",
AcpiCmGetTypeName (ObjectType), *StackPtr));
Status = AE_AML_OPERAND_TYPE;
goto Cleanup;
}
break;
case ARGI_IF: /* If */
/* Need an operand of type INTERNAL_TYPE_IF */
if (INTERNAL_TYPE_IF != (*StackPtr)->Common.Type)
{
DEBUG_PRINT (ACPI_INFO,
("AmlResolveOperands: Needed If, found %s Obj=%p\n",
AcpiCmGetTypeName (ObjectType), *StackPtr));
Status = AE_AML_OPERAND_TYPE;
goto Cleanup;
}
break;
case ARGI_PACKAGE: /* Package */
/* Need an operand of type ACPI_TYPE_PACKAGE */
Status = AcpiAmlResolveToValue (StackPtr);
if (ACPI_FAILURE (Status))
{
goto Cleanup;
}
if (ACPI_TYPE_PACKAGE != (*StackPtr)->Common.Type)
{
DEBUG_PRINT (ACPI_INFO,
("AmlResolveOperands: Needed Package, found %s Obj=%p\n",
AcpiCmGetTypeName (ObjectType), *StackPtr));
Status = AE_AML_OPERAND_TYPE;
goto Cleanup;
}
goto NextOperand;
break;
case ARGI_ANYTYPE:
/*
* We don't want to resolve IndexOp reference objects during
* a store because this would be an implicit DeRefOf operation.
* Instead, we just want to store the reference object.
* -- All others must be resolved below.
*/
if ((Opcode == AML_STORE_OP) &&
((*StackPtr)->Common.Type == INTERNAL_TYPE_REFERENCE) &&
((*StackPtr)->Reference.OpCode == AML_INDEX_OP))
((*StackPtr)->Reference.Opcode == AML_INDEX_OP))
{
break;
goto NextOperand;
}
break;
}
/* All others must be resolved */
Status = AcpiAmlResolveToValue (StackPtr);
/*
* Resolve this object to a value
*/
Status = AcpiExResolveToValue (StackPtr, WalkState);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
/*
* Check the resulting object (value) type
*/
switch (ThisArgType)
{
/*
* For the simple cases, only one type of resolved object
* is allowed
*/
case ARGI_MUTEX:
/* Need an operand of type ACPI_TYPE_MUTEX */
TypeNeeded = ACPI_TYPE_MUTEX;
break;
case ARGI_EVENT:
/* Need an operand of type ACPI_TYPE_EVENT */
TypeNeeded = ACPI_TYPE_EVENT;
break;
case ARGI_REGION:
/* Need an operand of type ACPI_TYPE_REGION */
TypeNeeded = ACPI_TYPE_REGION;
break;
case ARGI_IF: /* If */
/* Need an operand of type INTERNAL_TYPE_IF */
TypeNeeded = INTERNAL_TYPE_IF;
break;
case ARGI_PACKAGE: /* Package */
/* Need an operand of type ACPI_TYPE_PACKAGE */
TypeNeeded = ACPI_TYPE_PACKAGE;
break;
case ARGI_ANYTYPE:
/* Any operand type will do */
TypeNeeded = ACPI_TYPE_ANY;
break;
/*
* The more complex cases allow multiple resolved object types
*/
case ARGI_INTEGER: /* Number */
/*
* Need an operand of type ACPI_TYPE_INTEGER,
* But we can implicitly convert from a STRING or BUFFER
*/
Status = AcpiExConvertToInteger (*StackPtr, StackPtr, WalkState);
if (ACPI_FAILURE (Status))
{
goto Cleanup;
if (Status == AE_TYPE)
{
ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
"Needed [Integer/String/Buffer], found [%s] %p\n",
AcpiUtGetTypeName ((*StackPtr)->Common.Type), *StackPtr));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
return_ACPI_STATUS (Status);
}
/* All types OK, so we don't perform any typechecks */
goto NextOperand;
break;
case ARGI_BUFFER:
/*
* Need an operand of type ACPI_TYPE_BUFFER,
* But we can implicitly convert from a STRING or INTEGER
*/
Status = AcpiExConvertToBuffer (*StackPtr, StackPtr, WalkState);
if (ACPI_FAILURE (Status))
{
if (Status == AE_TYPE)
{
ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
"Needed [Integer/String/Buffer], found [%s] %p\n",
AcpiUtGetTypeName ((*StackPtr)->Common.Type), *StackPtr));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
return_ACPI_STATUS (Status);
}
goto NextOperand;
break;
case ARGI_STRING:
/*
* Need an operand of type ACPI_TYPE_STRING,
* But we can implicitly convert from a BUFFER or INTEGER
*/
Status = AcpiExConvertToString (*StackPtr, StackPtr, 16, ACPI_UINT32_MAX, WalkState);
if (ACPI_FAILURE (Status))
{
if (Status == AE_TYPE)
{
ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
"Needed [Integer/String/Buffer], found [%s] %p\n",
AcpiUtGetTypeName ((*StackPtr)->Common.Type), *StackPtr));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
return_ACPI_STATUS (Status);
}
goto NextOperand;
break;
case ARGI_COMPUTEDATA:
/* Need an operand of type INTEGER, STRING or BUFFER */
if ((ACPI_TYPE_INTEGER != (*StackPtr)->Common.Type) &&
(ACPI_TYPE_STRING != (*StackPtr)->Common.Type) &&
(ACPI_TYPE_BUFFER != (*StackPtr)->Common.Type))
{
ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
"Needed [Integer/String/Buffer], found [%s] %p\n",
AcpiUtGetTypeName ((*StackPtr)->Common.Type), *StackPtr));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
goto NextOperand;
break;
@ -531,85 +563,88 @@ AcpiAmlResolveOperands (
*
* The ACPI specification allows SizeOf to return the size of
* a Buffer, String or Package. However, the MS ACPI.SYS AML
* Interpreter also allows an NTE reference to return without
* Interpreter also allows an Node reference to return without
* error with a size of 4.
*/
Status = AcpiAmlResolveToValue (StackPtr);
if (ACPI_FAILURE (Status))
{
goto Cleanup;
}
/* Need a buffer, string, package or NTE reference */
/* Need a buffer, string, package or Node reference */
if (((*StackPtr)->Common.Type != ACPI_TYPE_BUFFER) &&
((*StackPtr)->Common.Type != ACPI_TYPE_STRING) &&
((*StackPtr)->Common.Type != ACPI_TYPE_PACKAGE) &&
((*StackPtr)->Common.Type != INTERNAL_TYPE_REFERENCE))
{
DEBUG_PRINT (ACPI_INFO,
("AmlResolveOperands: Needed Buf/Str/Pkg, found %s Obj=%p\n",
AcpiCmGetTypeName (ObjectType), *StackPtr));
Status = AE_AML_OPERAND_TYPE;
goto Cleanup;
ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
"Needed [Buf/Str/Pkg/Ref], found [%s] %p\n",
AcpiUtGetTypeName ((*StackPtr)->Common.Type), *StackPtr));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
/*
* If this is a reference, only allow a reference to an NTE.
* If this is a reference, only allow a reference to an Node.
*/
if ((*StackPtr)->Common.Type == INTERNAL_TYPE_REFERENCE)
{
if (!(*StackPtr)->Reference.Nte)
if (!(*StackPtr)->Reference.Node)
{
DEBUG_PRINT (ACPI_INFO,
("AmlResolveOperands: Needed NTE reference, found %s Obj=%p\n",
AcpiCmGetTypeName (ObjectType), *StackPtr));
Status = AE_AML_OPERAND_TYPE;
goto Cleanup;
ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
"Needed [Node Reference], found [%p]\n",
*StackPtr));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
}
goto NextOperand;
break;
case ARGI_COMPLEXOBJ:
Status = AcpiAmlResolveToValue (StackPtr);
if (ACPI_FAILURE (Status))
{
goto Cleanup;
}
/* Need a buffer or package */
/* Need a buffer or package or (ACPI 2.0) String */
if (((*StackPtr)->Common.Type != ACPI_TYPE_BUFFER) &&
((*StackPtr)->Common.Type != ACPI_TYPE_STRING) &&
((*StackPtr)->Common.Type != ACPI_TYPE_PACKAGE))
{
DEBUG_PRINT (ACPI_INFO,
("AmlResolveOperands: Needed Package, Buf/Pkg %s Obj=%p\n",
AcpiCmGetTypeName (ObjectType), *StackPtr));
Status = AE_AML_OPERAND_TYPE;
goto Cleanup;
ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
"Needed [Buf/Pkg], found [%s] %p\n",
AcpiUtGetTypeName ((*StackPtr)->Common.Type), *StackPtr));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
goto NextOperand;
break;
/* Unknown abbreviation passed in */
default:
DEBUG_PRINT (ACPI_ERROR,
("AmlResolveOperands: Internal error - Unknown arg type %X\n",
ThisArgType));
Status = AE_BAD_PARAMETER;
goto Cleanup;
} /* switch (*Types++) */
/* Unknown type */
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Internal - Unknown ARGI type %X\n",
ThisArgType));
return_ACPI_STATUS (AE_BAD_PARAMETER);
}
/*
* Make sure that the original object was resolved to the
* required object type (Simple cases only).
*/
Status = AcpiExCheckObjectType (TypeNeeded,
(*StackPtr)->Common.Type, *StackPtr);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
NextOperand:
/*
* If more operands needed, decrement StackPtr to point
* to next operand on stack (after checking for underflow).
* to next operand on stack
*/
if (GET_CURRENT_ARG_TYPE (ArgTypes))
{
@ -619,9 +654,7 @@ AcpiAmlResolveOperands (
} /* while (*Types) */
Cleanup:
return_ACPI_STATUS (Status);
return_ACPI_STATUS (Status);
}

View File

@ -1,7 +1,8 @@
/******************************************************************************
*
* Module Name: amstore - AML Interpreter object store support
* Module Name: exstore - AML Interpreter object store support
* $Revision: 1.146 $
*
*****************************************************************************/
@ -9,8 +10,8 @@
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999, Intel Corp. All rights
* reserved.
* Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp.
* All rights reserved.
*
* 2. License
*
@ -114,7 +115,7 @@
*
*****************************************************************************/
#define __AMSTORE_C__
#define __EXSTORE_C__
#include "acpi.h"
#include "acparser.h"
@ -125,17 +126,17 @@
#include "actables.h"
#define _COMPONENT INTERPRETER
MODULE_NAME ("amstore");
#define _COMPONENT ACPI_EXECUTER
MODULE_NAME ("exstore")
/*******************************************************************************
*
* FUNCTION: AcpiAmlExecStore
* FUNCTION: AcpiExStore
*
* PARAMETERS: *ValDesc - Value to be stored
* *DestDesc - Where to store it 0 Must be (ACPI_HANDLE)
* or an ACPI_OBJECT_INTERNAL of type
* *DestDesc - Where to store it. Must be an NS node
* or an ACPI_OPERAND_OBJECT of type
* Reference; if the latter the descriptor
* will be either reused or deleted.
*
@ -149,107 +150,226 @@
******************************************************************************/
ACPI_STATUS
AcpiAmlExecStore (
ACPI_OBJECT_INTERNAL *ValDesc,
ACPI_OBJECT_INTERNAL *DestDesc)
AcpiExStore (
ACPI_OPERAND_OBJECT *ValDesc,
ACPI_OPERAND_OBJECT *DestDesc,
ACPI_WALK_STATE *WalkState)
{
ACPI_STATUS Status = AE_OK;
ACPI_OBJECT_INTERNAL *DeleteDestDesc = NULL;
ACPI_OBJECT_INTERNAL *TmpDesc;
ACPI_NAMED_OBJECT *Entry = NULL;
UINT8 Value = 0;
UINT32 Length;
UINT32 i;
ACPI_OPERAND_OBJECT *RefDesc = DestDesc;
FUNCTION_TRACE ("AmlExecStore");
DEBUG_PRINT (ACPI_INFO, ("entered AcpiAmlExecStore: Val=%p, Dest=%p\n",
ValDesc, DestDesc));
FUNCTION_TRACE_PTR ("ExStore", DestDesc);
/* Validate parameters */
if (!ValDesc || !DestDesc)
{
DEBUG_PRINT (ACPI_ERROR,
("AmlExecStore: Internal error - null pointer\n"));
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Internal - null pointer\n"));
return_ACPI_STATUS (AE_AML_NO_OPERAND);
}
/* Examine the datatype of the DestDesc */
/* DestDesc can be either a namespace node or an ACPI object */
if (VALID_DESCRIPTOR_TYPE (DestDesc, ACPI_DESC_TYPE_NAMED))
{
/* Dest is an ACPI_HANDLE, create a new object */
/*
* Dest is a namespace node,
* Storing an object into a Name "container"
*/
Status = AcpiExStoreObjectToNode (ValDesc,
(ACPI_NAMESPACE_NODE *) DestDesc, WalkState);
Entry = (ACPI_NAMED_OBJECT*) DestDesc;
DestDesc = AcpiCmCreateInternalObject (INTERNAL_TYPE_REFERENCE);
if (!DestDesc)
{
/* Allocation failure */
/* All done, that's it */
return_ACPI_STATUS (AE_NO_MEMORY);
}
/* Build a new Reference wrapper around the handle */
DestDesc->Reference.OpCode = AML_NAME_OP;
DestDesc->Reference.Object = Entry;
return_ACPI_STATUS (Status);
}
else
{
DEBUG_PRINT (ACPI_INFO,
("AmlExecStore: Dest is object (not handle) - may be deleted!\n"));
}
/* Destination object must be of type Reference */
/* Destination object must be an object of type Reference */
if (DestDesc->Common.Type != INTERNAL_TYPE_REFERENCE)
{
/* Destination is not an Reference */
DEBUG_PRINT (ACPI_ERROR,
("AmlExecStore: Destination is not an Reference [%p]\n", DestDesc));
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Destination is not a ReferenceObj [%p]\n", DestDesc));
DUMP_STACK_ENTRY (ValDesc);
DUMP_STACK_ENTRY (DestDesc);
DUMP_OPERANDS (&DestDesc, IMODE_EXECUTE, "AmlExecStore",
2, "target not Reference");
DUMP_OPERANDS (&DestDesc, IMODE_EXECUTE, "ExStore",
2, "Target is not a ReferenceObj");
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
/* Examine the Reference opcode */
switch (DestDesc->Reference.OpCode)
/*
* Examine the Reference opcode. These cases are handled:
*
* 1) Store to Name (Change the object associated with a name)
* 2) Store to an indexed area of a Buffer or Package
* 3) Store to a Method Local or Arg
* 4) Store to the debug object
* 5) Store to a constant -- a noop
*/
switch (RefDesc->Reference.Opcode)
{
case AML_NAME_OP:
/*
* Storing into a Name
*/
DeleteDestDesc = DestDesc;
Status = AcpiAmlStoreObjectToNte (ValDesc, DestDesc->Reference.Object);
/* Storing an object into a Name "container" */
break; /* Case NameOp */
Status = AcpiExStoreObjectToNode (ValDesc, RefDesc->Reference.Object,
WalkState);
break;
case AML_INDEX_OP:
DeleteDestDesc = DestDesc;
/* Storing to an Index (pointer into a packager or buffer) */
Status = AcpiExStoreObjectToIndex (ValDesc, RefDesc, WalkState);
break;
case AML_LOCAL_OP:
case AML_ARG_OP:
/* Store to a method local/arg */
Status = AcpiDsStoreObjectToLocal (RefDesc->Reference.Opcode,
RefDesc->Reference.Offset, ValDesc, WalkState);
break;
case AML_DEBUG_OP:
/*
* Valid source value and destination reference pointer.
*
* ACPI Specification 1.0B section 15.2.3.4.2.13:
* Destination should point to either a buffer or a package
* Storing to the Debug object causes the value stored to be
* displayed and otherwise has no effect -- see ACPI Specification
*/
ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "**** Write to Debug Object: ****:\n\n"));
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[ACPI Debug] %s: ",
AcpiUtGetTypeName (ValDesc->Common.Type)));
switch (ValDesc->Common.Type)
{
case ACPI_TYPE_INTEGER:
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "0x%X (%d)\n",
(UINT32) ValDesc->Integer.Value, (UINT32) ValDesc->Integer.Value));
break;
case ACPI_TYPE_BUFFER:
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Length 0x%X\n",
(UINT32) ValDesc->Buffer.Length));
break;
case ACPI_TYPE_STRING:
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "%s\n", ValDesc->String.Pointer));
break;
case ACPI_TYPE_PACKAGE:
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Elements - 0x%X\n",
(UINT32) ValDesc->Package.Elements));
break;
default:
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "@0x%p\n", ValDesc));
break;
}
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, "\n"));
break;
case AML_ZERO_OP:
case AML_ONE_OP:
case AML_ONES_OP:
case AML_REVISION_OP:
/*
* Actually, storing to a package is not so simple. The source must be
* Storing to a constant is a no-op -- see ACPI Specification
* Delete the reference descriptor, however
*/
break;
default:
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Internal - Unknown Reference subtype %02x\n",
RefDesc->Reference.Opcode));
/* TBD: [Restructure] use object dump routine !! */
DUMP_BUFFER (RefDesc, sizeof (ACPI_OPERAND_OBJECT));
Status = AE_AML_INTERNAL;
break;
} /* switch (RefDesc->Reference.Opcode) */
/* Always delete the reference descriptor object */
if (RefDesc)
{
AcpiUtRemoveReference (RefDesc);
}
return_ACPI_STATUS (Status);
}
/*******************************************************************************
*
* FUNCTION: AcpiExStoreObjectToIndex
*
* PARAMETERS: *ValDesc - Value to be stored
* *Node - Named object to receive the value
*
* RETURN: Status
*
* DESCRIPTION: Store the object to the named object.
*
******************************************************************************/
ACPI_STATUS
AcpiExStoreObjectToIndex (
ACPI_OPERAND_OBJECT *ValDesc,
ACPI_OPERAND_OBJECT *DestDesc,
ACPI_WALK_STATE *WalkState)
{
ACPI_STATUS Status = AE_OK;
ACPI_OPERAND_OBJECT *ObjDesc;
UINT32 Length;
UINT32 i;
UINT8 Value = 0;
FUNCTION_TRACE ("ExStoreObjectToIndex");
/*
* Destination must be a reference pointer, and
* must point to either a buffer or a package
*/
switch (DestDesc->Reference.TargetType)
{
case ACPI_TYPE_PACKAGE:
/*
* Storing to a package element is not simple. The source must be
* evaluated and converted to the type of the destination and then the
* source is copied into the destination - we can't just point to the
* source object.
@ -260,8 +380,8 @@ AcpiAmlExecStore (
* The object at *(DestDesc->Reference.Where) is the
* element within the package that is to be modified.
*/
TmpDesc = *(DestDesc->Reference.Where);
if (TmpDesc)
ObjDesc = *(DestDesc->Reference.Where);
if (ObjDesc)
{
/*
* If the Destination element is a package, we will delete
@ -271,46 +391,43 @@ AcpiAmlExecStore (
* to be packages?
* && (ValDesc->Common.Type == ACPI_TYPE_PACKAGE)
*/
if (TmpDesc->Common.Type == ACPI_TYPE_PACKAGE)
if (ObjDesc->Common.Type == ACPI_TYPE_PACKAGE)
{
/*
* Take away the reference for being part of a package and
* delete
*/
AcpiCmRemoveReference (TmpDesc);
AcpiCmRemoveReference (TmpDesc);
AcpiUtRemoveReference (ObjDesc);
AcpiUtRemoveReference (ObjDesc);
TmpDesc = NULL;
ObjDesc = NULL;
}
}
if (!TmpDesc)
if (!ObjDesc)
{
/*
* If the TmpDesc is NULL, that means an uninitialized package
* has been used as a destination, therefore, we must create
* the destination element to match the type of the source
* element NOTE: ValDesc can be of any type.
* If the ObjDesc is NULL, it means that an uninitialized package
* element has been used as a destination (this is OK), therefore,
* we must create the destination element to match the type of the
* source element NOTE: ValDesc can be of any type.
*/
TmpDesc = AcpiCmCreateInternalObject (ValDesc->Common.Type);
if (!TmpDesc)
ObjDesc = AcpiUtCreateInternalObject (ValDesc->Common.Type);
if (!ObjDesc)
{
Status = AE_NO_MEMORY;
goto Cleanup;
return_ACPI_STATUS (AE_NO_MEMORY);
}
/*
* If the source is a package, copy the source to the new dest
*/
if (ACPI_TYPE_PACKAGE == TmpDesc->Common.Type)
if (ACPI_TYPE_PACKAGE == ObjDesc->Common.Type)
{
Status = AcpiAmlBuildCopyInternalPackageObject (
ValDesc, TmpDesc);
Status = AcpiUtCopyIpackageToIpackage (ValDesc, ObjDesc, WalkState);
if (ACPI_FAILURE (Status))
{
AcpiCmRemoveReference (TmpDesc);
TmpDesc = NULL;
goto Cleanup;
AcpiUtRemoveReference (ObjDesc);
return_ACPI_STATUS (Status);
}
}
@ -319,42 +436,38 @@ AcpiAmlExecStore (
* reference to the newly created descriptor for now being
* part of the parent package
*/
*(DestDesc->Reference.Where) = TmpDesc;
AcpiCmAddReference (TmpDesc);
*(DestDesc->Reference.Where) = ObjDesc;
AcpiUtAddReference (ObjDesc);
}
if (ACPI_TYPE_PACKAGE != TmpDesc->Common.Type)
if (ACPI_TYPE_PACKAGE != ObjDesc->Common.Type)
{
/*
* The destination element is not a package, so we need to
* convert the contents of the source (ValDesc) and copy into
* the destination (TmpDesc)
* the destination (ObjDesc)
*/
Status = AcpiAmlStoreObjectToObject(ValDesc, TmpDesc);
Status = AcpiExStoreObjectToObject (ValDesc, ObjDesc,
WalkState);
if (ACPI_FAILURE (Status))
{
/*
* An error occurrered when copying the internal object
* so delete the reference.
*/
DEBUG_PRINT (ACPI_ERROR,
("AmlExecStore/Index: Unable to copy the internal object\n"));
Status = AE_AML_OPERAND_TYPE;
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Unable to copy the internal object\n"));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
}
break;
}
break;
/*
* Check that the destination is a Buffer Field type
*/
if (DestDesc->Reference.TargetType != ACPI_TYPE_BUFFER_FIELD)
{
Status = AE_AML_OPERAND_TYPE;
break;
}
case ACPI_TYPE_BUFFER_FIELD:
/* TBD: can probably call the generic Buffer/Field routines */
/*
* Storing into a buffer at a location defined by an Index.
@ -364,164 +477,300 @@ AcpiAmlExecStore (
*/
/*
* Set the TmpDesc to the destination object and type check.
* Set the ObjDesc to the destination object and type check.
*/
TmpDesc = DestDesc->Reference.Object;
if (TmpDesc->Common.Type != ACPI_TYPE_BUFFER)
ObjDesc = DestDesc->Reference.Object;
if (ObjDesc->Common.Type != ACPI_TYPE_BUFFER)
{
Status = AE_AML_OPERAND_TYPE;
break;
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
/*
* The assignment of the individual elements will be slightly
* different for each source type.
*/
switch (ValDesc->Common.Type)
{
/*
* If the type is Integer, the Length is 4.
* This loop to assign each of the elements is somewhat
* backward because of the Big Endian-ness of IA-64
*/
case ACPI_TYPE_NUMBER:
Length = 4;
case ACPI_TYPE_INTEGER:
/*
* Type is Integer, assign bytewise
* This loop to assign each of the elements is somewhat
* backward because of the Big Endian-ness of IA-64
*/
Length = sizeof (ACPI_INTEGER);
for (i = Length; i != 0; i--)
{
Value = (UINT8)(ValDesc->Number.Value >> (MUL_8 (i - 1)));
TmpDesc->Buffer.Pointer[DestDesc->Reference.Offset] = Value;
Value = (UINT8)(ValDesc->Integer.Value >> (MUL_8 (i - 1)));
ObjDesc->Buffer.Pointer[DestDesc->Reference.Offset] = Value;
}
break;
/*
* If the type is Buffer, the Length is in the structure.
* Just loop through the elements and assign each one in turn.
*/
case ACPI_TYPE_BUFFER:
/*
* Type is Buffer, the Length is in the structure.
* Just loop through the elements and assign each one in turn.
*/
Length = ValDesc->Buffer.Length;
for (i = 0; i < Length; i++)
{
Value = *(ValDesc->Buffer.Pointer + i);
TmpDesc->Buffer.Pointer[DestDesc->Reference.Offset] = Value;
Value = ValDesc->Buffer.Pointer[i];
ObjDesc->Buffer.Pointer[DestDesc->Reference.Offset] = Value;
}
break;
/*
* If the type is String, the Length is in the structure.
* Just loop through the elements and assign each one in turn.
*/
case ACPI_TYPE_STRING:
/*
* Type is String, the Length is in the structure.
* Just loop through the elements and assign each one in turn.
*/
Length = ValDesc->String.Length;
for (i = 0; i < Length; i++)
{
Value = *(ValDesc->String.Pointer + i);
TmpDesc->Buffer.Pointer[DestDesc->Reference.Offset] = Value;
Value = ValDesc->String.Pointer[i];
ObjDesc->Buffer.Pointer[DestDesc->Reference.Offset] = Value;
}
break;
/*
* If source is not a valid type so return an error.
*/
default:
DEBUG_PRINT (ACPI_ERROR,
("AmlExecStore/Index: Source must be Number/Buffer/String type, not 0x%x\n",
/* Other types are invalid */
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Source must be Number/Buffer/String type, not %X\n",
ValDesc->Common.Type));
Status = AE_AML_OPERAND_TYPE;
break;
}
/*
* If we had an error, break out of this case statement.
*/
if (ACPI_FAILURE (Status))
{
break;
}
/*
* Set the return pointer
*/
DestDesc = TmpDesc;
break;
case AML_ZERO_OP:
case AML_ONE_OP:
case AML_ONES_OP:
/*
* Storing to a constant is a no-op -- see spec sec 15.2.3.3.1.
* Delete the result descriptor.
*/
DeleteDestDesc = DestDesc;
break;
case AML_LOCAL_OP:
Status = AcpiDsMethodDataSetValue (MTH_TYPE_LOCAL,
(DestDesc->Reference.Offset), ValDesc);
DeleteDestDesc = DestDesc;
break;
case AML_ARG_OP:
Status = AcpiDsMethodDataSetValue (MTH_TYPE_ARG,
(DestDesc->Reference.Offset), ValDesc);
DeleteDestDesc = DestDesc;
break;
case AML_DEBUG_OP:
/*
* Storing to the Debug object causes the value stored to be
* displayed and otherwise has no effect -- see sec. 15.2.3.3.3.
*/
DEBUG_PRINT (ACPI_INFO, ("**** Write to Debug Object: ****: \n"));
if (ValDesc->Common.Type == ACPI_TYPE_STRING)
{
DEBUG_PRINT (ACPI_INFO, ("%s\n", ValDesc->String.Pointer));
}
else
{
DUMP_STACK_ENTRY (ValDesc);
}
DeleteDestDesc = DestDesc;
break;
default:
DEBUG_PRINT (ACPI_ERROR,
("AmlExecStore: Internal error - Unknown Reference subtype %02x\n",
DestDesc->Reference.OpCode));
/* TBD: [Restructure] use object dump routine !! */
DUMP_BUFFER (DestDesc, sizeof (ACPI_OBJECT_INTERNAL));
DeleteDestDesc = DestDesc;
Status = AE_AML_INTERNAL;
} /* switch(DestDesc->Reference.OpCode) */
Cleanup:
/* Cleanup and exit*/
if (DeleteDestDesc)
{
AcpiCmRemoveReference (DeleteDestDesc);
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Target is not a Package or BufferField\n"));
Status = AE_AML_OPERAND_TYPE;
break;
}
return_ACPI_STATUS (Status);
}
/*******************************************************************************
*
* FUNCTION: AcpiExStoreObjectToNode
*
* PARAMETERS: *SourceDesc - Value to be stored
* *Node - Named object to receive the value
*
* RETURN: Status
*
* DESCRIPTION: Store the object to the named object.
*
* The Assignment of an object to a named object is handled here
* The val passed in will replace the current value (if any)
* with the input value.
*
* When storing into an object the data is converted to the
* target object type then stored in the object. This means
* that the target object type (for an initialized target) will
* not be changed by a store operation.
*
* NOTE: the global lock is acquired early. This will result
* in the global lock being held a bit longer. Also, if the
* function fails during set up we may get the lock when we
* don't really need it. I don't think we care.
*
******************************************************************************/
ACPI_STATUS
AcpiExStoreObjectToNode (
ACPI_OPERAND_OBJECT *SourceDesc,
ACPI_NAMESPACE_NODE *Node,
ACPI_WALK_STATE *WalkState)
{
ACPI_STATUS Status = AE_OK;
ACPI_OPERAND_OBJECT *TargetDesc;
ACPI_OBJECT_TYPE8 TargetType = ACPI_TYPE_ANY;
FUNCTION_TRACE ("ExStoreObjectToNode");
/*
* Assuming the parameters were already validated
*/
/*
* Get current type of the node, and object attached to Node
*/
TargetType = AcpiNsGetType (Node);
TargetDesc = AcpiNsGetAttachedObject (Node);
ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Storing %p(%s) into node %p(%s)\n",
Node, AcpiUtGetTypeName (SourceDesc->Common.Type),
SourceDesc, AcpiUtGetTypeName (TargetType)));
/*
* Resolve the source object to an actual value
* (If it is a reference object)
*/
Status = AcpiExResolveObject (&SourceDesc, TargetType, WalkState);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
/*
* Do the actual store operation
*/
switch (TargetType)
{
case ACPI_TYPE_BUFFER_FIELD:
case INTERNAL_TYPE_REGION_FIELD:
case INTERNAL_TYPE_BANK_FIELD:
case INTERNAL_TYPE_INDEX_FIELD:
/*
* For fields, copy the source data to the target field.
*/
Status = AcpiExWriteDataToField (SourceDesc, TargetDesc);
break;
case ACPI_TYPE_INTEGER:
case ACPI_TYPE_STRING:
case ACPI_TYPE_BUFFER:
/*
* These target types are all of type Integer/String/Buffer, and
* therefore support implicit conversion before the store.
*
* Copy and/or convert the source object to a new target object
*/
Status = AcpiExStoreObject (SourceDesc, TargetType, &TargetDesc, WalkState);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
/*
* Store the new TargetDesc as the new value of the Name, and set
* the Name's type to that of the value being stored in it.
* SourceDesc reference count is incremented by AttachObject.
*/
Status = AcpiNsAttachObject (Node, TargetDesc, TargetType);
ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
"Store %s into %s via Convert/Attach\n",
AcpiUtGetTypeName (TargetDesc->Common.Type),
AcpiUtGetTypeName (TargetType)));
break;
default:
/* No conversions for all other types. Just attach the source object */
Status = AcpiNsAttachObject (Node, SourceDesc, SourceDesc->Common.Type);
ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
"Store %s into %s via Attach only\n",
AcpiUtGetTypeName (SourceDesc->Common.Type),
AcpiUtGetTypeName (SourceDesc->Common.Type)));
break;
}
return_ACPI_STATUS (Status);
}
/*******************************************************************************
*
* FUNCTION: AcpiExStoreObjectToObject
*
* PARAMETERS: *SourceDesc - Value to be stored
* *DestDesc - Object to receive the value
*
* RETURN: Status
*
* DESCRIPTION: Store an object to another object.
*
* The Assignment of an object to another (not named) object
* is handled here.
* The val passed in will replace the current value (if any)
* with the input value.
*
* When storing into an object the data is converted to the
* target object type then stored in the object. This means
* that the target object type (for an initialized target) will
* not be changed by a store operation.
*
* This module allows destination types of Number, String,
* and Buffer.
*
******************************************************************************/
ACPI_STATUS
AcpiExStoreObjectToObject (
ACPI_OPERAND_OBJECT *SourceDesc,
ACPI_OPERAND_OBJECT *DestDesc,
ACPI_WALK_STATE *WalkState)
{
ACPI_STATUS Status = AE_OK;
ACPI_OBJECT_TYPE8 DestinationType = DestDesc->Common.Type;
FUNCTION_TRACE ("ExStoreObjectToObject");
/*
* Assuming the parameters are valid!
*/
ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Storing %p(%s) to %p(%s)\n",
SourceDesc, AcpiUtGetTypeName (SourceDesc->Common.Type),
DestDesc, AcpiUtGetTypeName (DestDesc->Common.Type)));
/*
* From this interface, we only support Integers/Strings/Buffers
*/
switch (DestinationType)
{
case ACPI_TYPE_INTEGER:
case ACPI_TYPE_STRING:
case ACPI_TYPE_BUFFER:
break;
default:
ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Store into %s not implemented\n",
AcpiUtGetTypeName (DestDesc->Common.Type)));
return_ACPI_STATUS (AE_NOT_IMPLEMENTED);
}
/*
* Resolve the source object to an actual value
* (If it is a reference object)
*/
Status = AcpiExResolveObject (&SourceDesc, DestinationType, WalkState);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
/*
* Copy and/or convert the source object to the destination object
*/
Status = AcpiExStoreObject (SourceDesc, DestinationType, &DestDesc, WalkState);
return_ACPI_STATUS (Status);
}

View File

@ -1,7 +1,9 @@
/******************************************************************************
*
* Module Name: amstoren - AML Interpreter object store support, store to NTE
* Module Name: exstoren - AML Interpreter object store support,
* Store to Node (namespace object)
* $Revision: 1.40 $
*
*****************************************************************************/
@ -9,8 +11,8 @@
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999, Intel Corp. All rights
* reserved.
* Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp.
* All rights reserved.
*
* 2. License
*
@ -114,7 +116,7 @@
*
*****************************************************************************/
#define __AMSTOREN_C__
#define __EXSTOREN_C__
#include "acpi.h"
#include "acparser.h"
@ -125,569 +127,224 @@
#include "actables.h"
#define _COMPONENT INTERPRETER
MODULE_NAME ("amstoren");
#define _COMPONENT ACPI_EXECUTER
MODULE_NAME ("exstoren")
/*******************************************************************************
*
* FUNCTION: AcpiAmlStoreObjectToNte
* FUNCTION: AcpiExResolveObject
*
* PARAMETERS: *ValDesc - Value to be stored
* *Entry - Named object to recieve the value
* PARAMETERS: SourceDescPtr - Pointer to the source object
* TargetType - Current type of the target
* WalkState - Current walk state
*
* RETURN: Status
* RETURN: Status, resolved object in SourceDescPtr.
*
* DESCRIPTION: Store the object to the named object.
*
* The Assignment of an object to a named object is handled here
* The val passed in will replace the current value (if any)
* with the input value.
*
* When storing into an object the data is converted to the
* target object type then stored in the object. This means
* that the target object type (for an initialized target) will
* not be changed by a store operation.
*
* NOTE: the global lock is acquired early. This will result
* in the global lock being held a bit longer. Also, if the
* function fails during set up we may get the lock when we
* don't really need it. I don't think we care.
* DESCRIPTION: Resolve an object. If the object is a reference, dereference
* it and return the actual object in the SourceDescPtr.
*
******************************************************************************/
ACPI_STATUS
AcpiAmlStoreObjectToNte (
ACPI_OBJECT_INTERNAL *ValDesc,
ACPI_NAMED_OBJECT *Entry)
AcpiExResolveObject (
ACPI_OPERAND_OBJECT **SourceDescPtr,
ACPI_OBJECT_TYPE8 TargetType,
ACPI_WALK_STATE *WalkState)
{
ACPI_OPERAND_OBJECT *SourceDesc = *SourceDescPtr;
ACPI_STATUS Status = AE_OK;
UINT8 *Buffer = NULL;
UINT32 Length = 0;
UINT32 Mask;
UINT32 NewValue;
BOOLEAN Locked = FALSE;
UINT8 *Location=NULL;
ACPI_OBJECT_INTERNAL *DestDesc;
OBJECT_TYPE_INTERNAL DestinationType = ACPI_TYPE_ANY;
FUNCTION_TRACE ("AmlStoreObjectToNte");
FUNCTION_TRACE ("ExResolveObject");
DEBUG_PRINT (ACPI_INFO,
("entered AcpiAmlStoreObjectToNte: NTE=%p, Obj=%p\n",
Entry, ValDesc));
/*
* Assuming the parameters are valid!!!
* Ensure we have a Source that can be stored in the target
*/
ACPI_ASSERT((Entry) && (ValDesc));
DestinationType = AcpiNsGetType (Entry);
DEBUG_PRINT (ACPI_INFO, ("AmlStoreObjectToNte: Storing %s into %s\n",
AcpiCmGetTypeName (ValDesc->Common.Type),
AcpiCmGetTypeName (DestinationType)));
/*
* First ensure we have a value that can be stored in the target
*/
switch (DestinationType)
switch (TargetType)
{
/* Type of Name's existing value */
/* This case handles the "interchangeable" types Integer, String, and Buffer. */
/*
* These cases all require only Integers or values that
* can be converted to Integers (Strings or Buffers)
*/
case ACPI_TYPE_BUFFER_FIELD:
case INTERNAL_TYPE_REGION_FIELD:
case INTERNAL_TYPE_BANK_FIELD:
case INTERNAL_TYPE_INDEX_FIELD:
/*
* Stores into a Field/Region or into a Buffer/String
* are all essentially the same.
*/
case ACPI_TYPE_INTEGER:
case ACPI_TYPE_STRING:
case ACPI_TYPE_BUFFER:
/* TBD: FIX - check for source==REF, resolve, then check type */
/*
* If SourceDesc is not a valid type, try to resolve it to one.
*/
if ((SourceDesc->Common.Type != ACPI_TYPE_INTEGER) &&
(SourceDesc->Common.Type != ACPI_TYPE_BUFFER) &&
(SourceDesc->Common.Type != ACPI_TYPE_STRING))
{
/*
* Initially not a valid type, convert
*/
Status = AcpiExResolveToValue (SourceDescPtr, WalkState);
if (ACPI_SUCCESS (Status) &&
(SourceDesc->Common.Type != ACPI_TYPE_INTEGER) &&
(SourceDesc->Common.Type != ACPI_TYPE_BUFFER) &&
(SourceDesc->Common.Type != ACPI_TYPE_STRING))
{
/*
* Conversion successful but still not a valid type
*/
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Cannot assign type %s to %s (must be type Int/Str/Buf)\n",
AcpiUtGetTypeName ((*SourceDescPtr)->Common.Type),
AcpiUtGetTypeName (TargetType)));
Status = AE_AML_OPERAND_TYPE;
}
}
break;
case INTERNAL_TYPE_ALIAS:
/*
* Aliases are resolved by AcpiAmlPrepOperands
* Aliases are resolved by AcpiExPrepOperands
*/
DEBUG_PRINT (ACPI_WARN,
("AmlStoreObjectToNte: Store into Alias - should never happen\n"));
ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Store into Alias - should never happen\n"));
Status = AE_AML_INTERNAL;
break;
case INTERNAL_TYPE_BANK_FIELD:
case INTERNAL_TYPE_INDEX_FIELD:
case ACPI_TYPE_FIELD_UNIT:
case ACPI_TYPE_NUMBER:
/*
* These cases all require only number values or values that
* can be converted to numbers.
*
* If value is not a Number, try to resolve it to one.
*/
if (ValDesc->Common.Type != ACPI_TYPE_NUMBER)
{
/*
* Initially not a number, convert
*/
Status = AcpiAmlResolveToValue (&ValDesc);
if (ACPI_SUCCESS (Status) &&
(ValDesc->Common.Type != ACPI_TYPE_NUMBER))
{
/*
* Conversion successful but still not a number
*/
DEBUG_PRINT (ACPI_ERROR,
("AmlStoreObjectToNte: Value assigned to %s must be Number, not %s\n",
AcpiCmGetTypeName (DestinationType),
AcpiCmGetTypeName (ValDesc->Common.Type)));
Status = AE_AML_OPERAND_TYPE;
}
}
break;
case ACPI_TYPE_STRING:
case ACPI_TYPE_BUFFER:
case INTERNAL_TYPE_DEF_FIELD:
/*
* Storing into a Field in a region or into a buffer or into
* a string all is essentially the same.
*
* If value is not a valid type, try to resolve it to one.
*/
if ((ValDesc->Common.Type != ACPI_TYPE_NUMBER) &&
(ValDesc->Common.Type != ACPI_TYPE_BUFFER) &&
(ValDesc->Common.Type != ACPI_TYPE_STRING))
{
/*
* Initially not a valid type, convert
*/
Status = AcpiAmlResolveToValue (&ValDesc);
if (ACPI_SUCCESS (Status) &&
(ValDesc->Common.Type != ACPI_TYPE_NUMBER) &&
(ValDesc->Common.Type != ACPI_TYPE_BUFFER) &&
(ValDesc->Common.Type != ACPI_TYPE_STRING))
{
/*
* Conversion successful but still not a valid type
*/
DEBUG_PRINT (ACPI_ERROR,
("AmlStoreObjectToNte: Assign wrong type %s to %s (must be type Num/Str/Buf)\n",
AcpiCmGetTypeName (ValDesc->Common.Type),
AcpiCmGetTypeName (DestinationType)));
Status = AE_AML_OPERAND_TYPE;
}
}
break;
case ACPI_TYPE_PACKAGE:
/*
* TBD: [Unhandled] Not real sure what to do here
*/
Status = AE_NOT_IMPLEMENTED;
break;
default:
/*
* All other types than Alias and the various Fields come here.
* Store ValDesc as the new value of the Name, and set
* the Name's type to that of the value being stored in it.
* ValDesc reference count is incremented by AttachObject.
* All other types than Alias and the various Fields come here,
* including the untyped case - ACPI_TYPE_ANY.
*/
Status = AcpiNsAttachObject (Entry, ValDesc, ValDesc->Common.Type);
DEBUG_PRINT (ACPI_INFO,
("AmlStoreObjectToNte: Store %s into %s via Attach\n",
AcpiCmGetTypeName (ValDesc->Common.Type),
AcpiCmGetTypeName (DestinationType)));
goto CleanUpAndBailOut;
break;
}
/* Exit now if failure above */
if (ACPI_FAILURE (Status))
{
goto CleanUpAndBailOut;
}
/*
* Get descriptor for object attached to NTE
*/
DestDesc = AcpiNsGetAttachedObject (Entry);
if (!DestDesc)
{
/*
* There is no existing object attached to this NTE
*/
DEBUG_PRINT (ACPI_ERROR,
("AmlStoreObjectToNte: Internal error - no destination object for %4.4s type %d\n",
&Entry->Name, DestinationType));
Status = AE_AML_INTERNAL;
goto CleanUpAndBailOut;
}
/*
* Make sure the destination Object is the same as the NTE
*/
if (DestDesc->Common.Type != (UINT8) DestinationType)
{
DEBUG_PRINT (ACPI_ERROR,
("AmlStoreObjectToNte: Internal error - Name %4.4s type %d does not match value-type %d at %p\n",
&Entry->Name, AcpiNsGetType (Entry),
DestDesc->Common.Type, DestDesc));
Status = AE_AML_INTERNAL;
goto CleanUpAndBailOut;
}
/*
* AcpiEverything is ready to execute now, We have
* a value we can handle, just perform the update
*/
switch (DestinationType)
{
/* Type of Name's existing value */
case INTERNAL_TYPE_BANK_FIELD:
/*
* Get the global lock if needed
*/
Locked = AcpiAmlAcquireGlobalLock (DestDesc->BankField.LockRule);
/*
* Set Bank value to select proper Bank
* Perform the update (Set Bank Select)
*/
Status = AcpiAmlSetNamedFieldValue (DestDesc->BankField.BankSelect,
&DestDesc->BankField.Value,
sizeof (DestDesc->BankField.Value));
if (ACPI_SUCCESS (Status))
{
/* Set bank select successful, set data value */
Status = AcpiAmlSetNamedFieldValue (DestDesc->BankField.BankSelect,
&ValDesc->BankField.Value,
sizeof (ValDesc->BankField.Value));
}
break;
case INTERNAL_TYPE_DEF_FIELD:
/*
* Get the global lock if needed
*/
Locked = AcpiAmlAcquireGlobalLock (ValDesc->Field.LockRule);
/*
* Perform the update
*/
switch (ValDesc->Common.Type)
{
case ACPI_TYPE_NUMBER:
Buffer = (UINT8 *) &ValDesc->Number.Value;
Length = sizeof (ValDesc->Number.Value);
break;
case ACPI_TYPE_BUFFER:
Buffer = (UINT8 *) ValDesc->Buffer.Pointer;
Length = ValDesc->Buffer.Length;
break;
case ACPI_TYPE_STRING:
Buffer = (UINT8 *) ValDesc->String.Pointer;
Length = ValDesc->String.Length;
break;
}
Status = AcpiAmlSetNamedFieldValue (Entry, Buffer, Length);
break; /* Global Lock released below */
case ACPI_TYPE_STRING:
/*
* Perform the update
*/
switch (ValDesc->Common.Type)
{
case ACPI_TYPE_NUMBER:
Buffer = (UINT8 *) &ValDesc->Number.Value;
Length = sizeof (ValDesc->Number.Value);
break;
case ACPI_TYPE_BUFFER:
Buffer = (UINT8 *) ValDesc->Buffer.Pointer;
Length = ValDesc->Buffer.Length;
break;
case ACPI_TYPE_STRING:
Buffer = (UINT8 *) ValDesc->String.Pointer;
Length = ValDesc->String.Length;
break;
}
/*
* Setting a string value replaces the old string
*/
if (Length < DestDesc->String.Length)
{
/*
* Zero fill, not willing to do pointer arithmetic for
* archetecture independance. Just clear the whole thing
*/
MEMSET(DestDesc->String.Pointer, 0, DestDesc->String.Length);
MEMCPY(DestDesc->String.Pointer, Buffer, Length);
}
else
{
/*
* Free the current buffer, then allocate a buffer
* large enough to hold the value
*/
if ( DestDesc->String.Pointer &&
!AcpiTbSystemTablePointer (DestDesc->String.Pointer))
{
/*
* Only free if not a pointer into the DSDT
*/
AcpiCmFree(DestDesc->String.Pointer);
}
DestDesc->String.Pointer = AcpiCmAllocate (Length + 1);
DestDesc->String.Length = Length;
if (!DestDesc->String.Pointer)
{
Status = AE_NO_MEMORY;
goto CleanUpAndBailOut;
}
MEMCPY(DestDesc->String.Pointer, Buffer, Length);
}
break;
case ACPI_TYPE_BUFFER:
/*
* Perform the update to the buffer
*/
switch (ValDesc->Common.Type)
{
case ACPI_TYPE_NUMBER:
Buffer = (UINT8 *) &ValDesc->Number.Value;
Length = sizeof (ValDesc->Number.Value);
break;
case ACPI_TYPE_BUFFER:
Buffer = (UINT8 *) ValDesc->Buffer.Pointer;
Length = ValDesc->Buffer.Length;
break;
case ACPI_TYPE_STRING:
Buffer = (UINT8 *) ValDesc->String.Pointer;
Length = ValDesc->String.Length;
break;
}
/*
* Buffer is a static allocation,
* only place what will fit in the buffer.
*/
if (Length <= DestDesc->Buffer.Length)
{
/*
* Zero fill first, not willing to do pointer arithmetic for
* archetecture independence. Just clear the whole thing
*/
MEMSET(DestDesc->Buffer.Pointer, 0, DestDesc->Buffer.Length);
MEMCPY(DestDesc->Buffer.Pointer, Buffer, Length);
}
else
{
/*
* truncate, copy only what will fit
*/
MEMCPY(DestDesc->Buffer.Pointer, Buffer, DestDesc->Buffer.Length);
DEBUG_PRINT (ACPI_INFO,
("AmlStoreObjectToNte: Truncating src buffer from %d to %d\n",
Length, DestDesc->Buffer.Length));
}
break;
case INTERNAL_TYPE_INDEX_FIELD:
/*
* Get the global lock if needed
*/
Locked = AcpiAmlAcquireGlobalLock (DestDesc->IndexField.LockRule);
/*
* Set Index value to select proper Data register
* perform the update (Set index)
*/
Status = AcpiAmlSetNamedFieldValue (DestDesc->IndexField.Index,
&DestDesc->IndexField.Value,
sizeof (DestDesc->IndexField.Value));
DEBUG_PRINT (ACPI_INFO,
("AmlStoreObjectToNte: IndexField: set index returned %s\n",
AcpiCmFormatException (Status)));
if (ACPI_SUCCESS (Status))
{
/* set index successful, next set Data value */
Status = AcpiAmlSetNamedFieldValue (DestDesc->IndexField.Data,
&ValDesc->Number.Value,
sizeof (ValDesc->Number.Value));
DEBUG_PRINT (ACPI_INFO,
("AmlStoreObjectToNte: IndexField: set data returned %s\n",
AcpiCmFormatException (Status)));
}
break;
case ACPI_TYPE_FIELD_UNIT:
if ((!DestDesc->FieldUnit.Container ||
ACPI_TYPE_BUFFER != DestDesc->FieldUnit.Container->Common.Type ||
DestDesc->FieldUnit.Sequence !=
DestDesc->FieldUnit.Container->Buffer.Sequence))
{
DUMP_PATHNAME (Entry,
"AmlStoreObjectToNte: FieldUnit: Bad container in ",
ACPI_ERROR, _COMPONENT);
DUMP_ENTRY (Entry, ACPI_ERROR);
DEBUG_PRINT (ACPI_ERROR,
("Container: %p", DestDesc->FieldUnit.Container));
if (DestDesc->FieldUnit.Container)
{
DEBUG_PRINT_RAW (ACPI_ERROR, (" Type %d, FuSeq %x BufSeq %x",
DestDesc->FieldUnit.Container->Common.Type,
DestDesc->FieldUnit.Sequence,
DestDesc->FieldUnit.Container->Buffer.Sequence));
}
DEBUG_PRINT_RAW (ACPI_ERROR, ("\n"));
Status = AE_AML_INTERNAL;
goto CleanUpAndBailOut;
}
/*
* Get the global lock if needed
*/
Locked = AcpiAmlAcquireGlobalLock (DestDesc->FieldUnit.LockRule);
/*
* TBD: [Unhandled] REMOVE this limitation
* Make sure the operation is within the limits of our implementation
* this is not a Spec limitation!!
*/
if (DestDesc->FieldUnit.Length + DestDesc->FieldUnit.BitOffset > 32)
{
DEBUG_PRINT (ACPI_ERROR,
("AmlStoreObjectToNte: FieldUnit: Implementation limitation - Field exceeds UINT32\n"));
Status = AE_NOT_IMPLEMENTED;
goto CleanUpAndBailOut;
}
/* Field location is (base of buffer) + (byte offset) */
Location = DestDesc->FieldUnit.Container->Buffer.Pointer
+ DestDesc->FieldUnit.Offset;
/*
* Construct Mask with 1 bits where the field is,
* 0 bits elsewhere
*/
Mask = ((UINT32) 1 << DestDesc->FieldUnit.Length) - ((UINT32)1
<< DestDesc->FieldUnit.BitOffset);
DEBUG_PRINT (TRACE_EXEC,
("** Store %lx in buffer %p byte %ld bit %d width %d addr %p mask %08lx\n",
ValDesc->Number.Value,
DestDesc->FieldUnit.Container->Buffer.Pointer,
DestDesc->FieldUnit.Offset, DestDesc->FieldUnit.BitOffset,
DestDesc->FieldUnit.Length,Location, Mask));
/* Zero out the field in the buffer */
MOVE_UNALIGNED32_TO_32 (&NewValue, Location);
NewValue &= ~Mask;
/*
* Shift and mask the new value into position,
* and or it into the buffer.
*/
NewValue |= (ValDesc->Number.Value << DestDesc->FieldUnit.BitOffset) &
Mask;
/* Store back the value */
MOVE_UNALIGNED32_TO_32 (Location, &NewValue);
DEBUG_PRINT (TRACE_EXEC, ("New Field value %08lx\n", NewValue));
break;
case ACPI_TYPE_NUMBER:
DestDesc->Number.Value = ValDesc->Number.Value;
break;
case ACPI_TYPE_PACKAGE:
/*
* TBD: [Unhandled] Not real sure what to do here
*/
Status = AE_NOT_IMPLEMENTED;
break;
default:
/*
* All other types than Alias and the various Fields come here.
* Store ValDesc as the new value of the Name, and set
* the Name's type to that of the value being stored in it.
* ValDesc reference count is incremented by AttachObject.
*/
DEBUG_PRINT (ACPI_WARN,
("AmlStoreObjectToNte: Store into %s not implemented\n",
AcpiCmGetTypeName (AcpiNsGetType (Entry))));
Status = AE_NOT_IMPLEMENTED;
break;
}
CleanUpAndBailOut:
/*
* Release global lock if we acquired it earlier
*/
AcpiAmlReleaseGlobalLock (Locked);
return_ACPI_STATUS (Status);
}
/*******************************************************************************
*
* FUNCTION: AcpiExStoreObject
*
* PARAMETERS: SourceDesc - Object to store
* TargetType - Current type of the target
* TargetDescPtr - Pointer to the target
* WalkState - Current walk state
*
* RETURN: Status
*
* DESCRIPTION: "Store" an object to another object. This may include
* converting the source type to the target type (implicit
* conversion), and a copy of the value of the source to
* the target.
*
******************************************************************************/
ACPI_STATUS
AcpiExStoreObject (
ACPI_OPERAND_OBJECT *SourceDesc,
ACPI_OBJECT_TYPE8 TargetType,
ACPI_OPERAND_OBJECT **TargetDescPtr,
ACPI_WALK_STATE *WalkState)
{
ACPI_OPERAND_OBJECT *TargetDesc = *TargetDescPtr;
ACPI_STATUS Status = AE_OK;
FUNCTION_TRACE ("ExStoreObject");
/*
* Perform the "implicit conversion" of the source to the current type
* of the target - As per the ACPI specification.
*
* If no conversion performed, SourceDesc is left alone, otherwise it
* is updated with a new object.
*/
Status = AcpiExConvertToTargetType (TargetType, &SourceDesc, WalkState);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
/*
* We now have two objects of identical types, and we can perform a
* copy of the *value* of the source object.
*/
switch (TargetType)
{
case ACPI_TYPE_ANY:
case INTERNAL_TYPE_DEF_ANY:
/*
* The target namespace node is uninitialized (has no target object),
* and will take on the type of the source object
*/
*TargetDescPtr = SourceDesc;
break;
case ACPI_TYPE_INTEGER:
TargetDesc->Integer.Value = SourceDesc->Integer.Value;
/* Truncate value if we are executing from a 32-bit ACPI table */
AcpiExTruncateFor32bitTable (TargetDesc, WalkState);
break;
case ACPI_TYPE_STRING:
Status = AcpiExCopyStringToString (SourceDesc, TargetDesc);
break;
case ACPI_TYPE_BUFFER:
Status = AcpiExCopyBufferToBuffer (SourceDesc, TargetDesc);
break;
case ACPI_TYPE_PACKAGE:
/*
* TBD: [Unhandled] Not real sure what to do here
*/
Status = AE_NOT_IMPLEMENTED;
break;
default:
/*
* All other types come here.
*/
ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Store into type %s not implemented\n",
AcpiUtGetTypeName (TargetType)));
Status = AE_NOT_IMPLEMENTED;
break;
}
return_ACPI_STATUS (Status);
}

View File

@ -1,7 +1,8 @@
/******************************************************************************
*
* Module Name: amstorob - AML Interpreter object store support, store to object
* Module Name: exstorob - AML Interpreter object store support, store to object
* $Revision: 1.37 $
*
*****************************************************************************/
@ -9,8 +10,8 @@
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999, Intel Corp. All rights
* reserved.
* Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp.
* All rights reserved.
*
* 2. License
*
@ -114,7 +115,7 @@
*
*****************************************************************************/
#define __AMSTOROB_C__
#define __EXSTOROB_C__
#include "acpi.h"
#include "acparser.h"
@ -125,316 +126,152 @@
#include "actables.h"
#define _COMPONENT INTERPRETER
MODULE_NAME ("amstorob");
#define _COMPONENT ACPI_EXECUTER
MODULE_NAME ("exstorob")
/*******************************************************************************
*
* FUNCTION: AcpiAmlStoreObjectToObject
* FUNCTION: AcpiExCopyBufferToBuffer
*
* PARAMETERS: *ValDesc - Value to be stored
* *DestDesc - Object to receive the value
* PARAMETERS: SourceDesc - Source object to copy
* TargetDesc - Destination object of the copy
*
* RETURN: Status
*
* DESCRIPTION: Store an object to another object.
*
* The Assignment of an object to another (not named) object
* is handled here.
* The val passed in will replace the current value (if any)
* with the input value.
*
* When storing into an object the data is converted to the
* target object type then stored in the object. This means
* that the target object type (for an initialized target) will
* not be changed by a store operation.
*
* This module allows destination types of Number, String,
* and Buffer.
* DESCRIPTION: Copy a buffer object to another buffer object.
*
******************************************************************************/
ACPI_STATUS
AcpiAmlStoreObjectToObject (
ACPI_OBJECT_INTERNAL *ValDesc,
ACPI_OBJECT_INTERNAL *DestDesc)
AcpiExCopyBufferToBuffer (
ACPI_OPERAND_OBJECT *SourceDesc,
ACPI_OPERAND_OBJECT *TargetDesc)
{
ACPI_STATUS Status = AE_OK;
UINT8 *Buffer = NULL;
UINT32 Length = 0;
OBJECT_TYPE_INTERNAL DestinationType = DestDesc->Common.Type;
UINT32 Length;
UINT8 *Buffer;
FUNCTION_TRACE ("AmlStoreObjectToObject");
PROC_NAME ("ExCopyBufferToBuffer");
DEBUG_PRINT (ACPI_INFO,
("entered AcpiAmlStoreObjectToObject: Dest=%p, Val=%p\n",
DestDesc, ValDesc));
/*
* Assuming the parameters are valid!!!
* We know that SourceDesc is a buffer by now
*/
ACPI_ASSERT((DestDesc) && (ValDesc));
DEBUG_PRINT (ACPI_INFO, ("AmlStoreObjectToObject: Storing %s into %s\n",
AcpiCmGetTypeName (ValDesc->Common.Type),
AcpiCmGetTypeName (DestDesc->Common.Type)));
Buffer = (UINT8 *) SourceDesc->Buffer.Pointer;
Length = SourceDesc->Buffer.Length;
/*
* First ensure we have a value that can be stored in the target
* If target is a buffer of length zero, allocate a new
* buffer of the proper length
*/
switch (DestinationType)
if (TargetDesc->Buffer.Length == 0)
{
/* Type of Name's existing value */
case ACPI_TYPE_NUMBER:
/*
* These cases all require only number values or values that
* can be converted to numbers.
*
* If value is not a Number, try to resolve it to one.
*/
if (ValDesc->Common.Type != ACPI_TYPE_NUMBER)
TargetDesc->Buffer.Pointer = ACPI_MEM_ALLOCATE (Length);
if (!TargetDesc->Buffer.Pointer)
{
/*
* Initially not a number, convert
*/
Status = AcpiAmlResolveToValue (&ValDesc);
if (ACPI_SUCCESS (Status) &&
(ValDesc->Common.Type != ACPI_TYPE_NUMBER))
{
/*
* Conversion successful but still not a number
*/
DEBUG_PRINT (ACPI_ERROR,
("AmlStoreObjectToObject: Value assigned to %s must be Number, not %s\n",
AcpiCmGetTypeName (DestinationType),
AcpiCmGetTypeName (ValDesc->Common.Type)));
Status = AE_AML_OPERAND_TYPE;
}
return (AE_NO_MEMORY);
}
break;
case ACPI_TYPE_STRING:
case ACPI_TYPE_BUFFER:
/*
* Storing into a Field in a region or into a buffer or into
* a string all is essentially the same.
*
* If value is not a valid type, try to resolve it to one.
*/
if ((ValDesc->Common.Type != ACPI_TYPE_NUMBER) &&
(ValDesc->Common.Type != ACPI_TYPE_BUFFER) &&
(ValDesc->Common.Type != ACPI_TYPE_STRING))
{
/*
* Initially not a valid type, convert
*/
Status = AcpiAmlResolveToValue (&ValDesc);
if (ACPI_SUCCESS (Status) &&
(ValDesc->Common.Type != ACPI_TYPE_NUMBER) &&
(ValDesc->Common.Type != ACPI_TYPE_BUFFER) &&
(ValDesc->Common.Type != ACPI_TYPE_STRING))
{
/*
* Conversion successful but still not a valid type
*/
DEBUG_PRINT (ACPI_ERROR,
("AmlStoreObjectToObject: Assign wrong type %s to %s (must be type Num/Str/Buf)\n",
AcpiCmGetTypeName (ValDesc->Common.Type),
AcpiCmGetTypeName (DestinationType)));
Status = AE_AML_OPERAND_TYPE;
}
}
break;
default:
/*
* TBD: [Unhandled] What other combinations must be implemented?
*/
Status = AE_NOT_IMPLEMENTED;
break;
}
/* Exit now if failure above */
if (ACPI_FAILURE (Status))
{
goto CleanUpAndBailOut;
TargetDesc->Buffer.Length = Length;
}
/*
* AcpiEverything is ready to execute now, We have
* a value we can handle, just perform the update
* Buffer is a static allocation,
* only place what will fit in the buffer.
*/
switch (DestinationType)
if (Length <= TargetDesc->Buffer.Length)
{
/* Clear existing buffer and copy in the new one */
case ACPI_TYPE_STRING:
/*
* Perform the update
*/
switch (ValDesc->Common.Type)
{
case ACPI_TYPE_NUMBER:
Buffer = (UINT8 *) &ValDesc->Number.Value;
Length = sizeof (ValDesc->Number.Value);
break;
case ACPI_TYPE_BUFFER:
Buffer = (UINT8 *) ValDesc->Buffer.Pointer;
Length = ValDesc->Buffer.Length;
break;
case ACPI_TYPE_STRING:
Buffer = (UINT8 *) ValDesc->String.Pointer;
Length = ValDesc->String.Length;
break;
}
/*
* Setting a string value replaces the old string
*/
if (Length < DestDesc->String.Length)
{
/*
* Zero fill, not willing to do pointer arithmetic for
* architecture independence. Just clear the whole thing
*/
MEMSET(DestDesc->String.Pointer, 0, DestDesc->String.Length);
MEMCPY(DestDesc->String.Pointer, Buffer, Length);
}
else
{
/*
* Free the current buffer, then allocate a buffer
* large enough to hold the value
*/
if ( DestDesc->String.Pointer &&
!AcpiTbSystemTablePointer (DestDesc->String.Pointer))
{
/*
* Only free if not a pointer into the DSDT
*/
AcpiCmFree(DestDesc->String.Pointer);
}
DestDesc->String.Pointer = AcpiCmAllocate (Length + 1);
DestDesc->String.Length = Length;
if (!DestDesc->String.Pointer)
{
Status = AE_NO_MEMORY;
goto CleanUpAndBailOut;
}
MEMCPY(DestDesc->String.Pointer, Buffer, Length);
}
break;
case ACPI_TYPE_BUFFER:
/*
* Perform the update to the buffer
*/
switch (ValDesc->Common.Type)
{
case ACPI_TYPE_NUMBER:
Buffer = (UINT8 *) &ValDesc->Number.Value;
Length = sizeof (ValDesc->Number.Value);
break;
case ACPI_TYPE_BUFFER:
Buffer = (UINT8 *) ValDesc->Buffer.Pointer;
Length = ValDesc->Buffer.Length;
break;
case ACPI_TYPE_STRING:
Buffer = (UINT8 *) ValDesc->String.Pointer;
Length = ValDesc->String.Length;
break;
}
/*
* If the buffer is uninitialized,
* memory needs to be allocated for the copy.
*/
if(0 == DestDesc->Buffer.Length)
{
DestDesc->Buffer.Pointer = AcpiCmCallocate(Length);
DestDesc->Buffer.Length = Length;
if (!DestDesc->Buffer.Pointer)
{
Status = AE_NO_MEMORY;
goto CleanUpAndBailOut;
}
}
/*
* Buffer is a static allocation,
* only place what will fit in the buffer.
*/
if (Length <= DestDesc->Buffer.Length)
{
/*
* Zero fill first, not willing to do pointer arithmetic for
* architecture independence. Just clear the whole thing
*/
MEMSET(DestDesc->Buffer.Pointer, 0, DestDesc->Buffer.Length);
MEMCPY(DestDesc->Buffer.Pointer, Buffer, Length);
}
else
{
/*
* truncate, copy only what will fit
*/
MEMCPY(DestDesc->Buffer.Pointer, Buffer, DestDesc->Buffer.Length);
DEBUG_PRINT (ACPI_INFO,
("AmlStoreObjectToObject: Truncating src buffer from %d to %d\n",
Length, DestDesc->Buffer.Length));
}
break;
case ACPI_TYPE_NUMBER:
DestDesc->Number.Value = ValDesc->Number.Value;
break;
default:
/*
* All other types than Alias and the various Fields come here.
* Store ValDesc as the new value of the Name, and set
* the Name's type to that of the value being stored in it.
* ValDesc reference count is incremented by AttachObject.
*/
DEBUG_PRINT (ACPI_WARN,
("AmlStoreObjectToObject: Store into %s not implemented\n",
AcpiCmGetTypeName (DestDesc->Common.Type)));
Status = AE_NOT_IMPLEMENTED;
break;
MEMSET (TargetDesc->Buffer.Pointer, 0, TargetDesc->Buffer.Length);
MEMCPY (TargetDesc->Buffer.Pointer, Buffer, Length);
}
CleanUpAndBailOut:
else
{
/*
* Truncate the source, copy only what will fit
*/
MEMCPY (TargetDesc->Buffer.Pointer, Buffer, TargetDesc->Buffer.Length);
return_ACPI_STATUS (Status);
ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
"Truncating src buffer from %X to %X\n",
Length, TargetDesc->Buffer.Length));
}
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: AcpiExCopyStringToString
*
* PARAMETERS: SourceDesc - Source object to copy
* TargetDesc - Destination object of the copy
*
* RETURN: Status
*
* DESCRIPTION: Copy a String object to another String object
*
******************************************************************************/
ACPI_STATUS
AcpiExCopyStringToString (
ACPI_OPERAND_OBJECT *SourceDesc,
ACPI_OPERAND_OBJECT *TargetDesc)
{
UINT32 Length;
UINT8 *Buffer;
FUNCTION_ENTRY ();
/*
* We know that SourceDesc is a string by now.
*/
Buffer = (UINT8 *) SourceDesc->String.Pointer;
Length = SourceDesc->String.Length;
/*
* Setting a string value replaces the old string
*/
if (Length < TargetDesc->String.Length)
{
/* Clear old string and copy in the new one */
MEMSET (TargetDesc->String.Pointer, 0, TargetDesc->String.Length);
MEMCPY (TargetDesc->String.Pointer, Buffer, Length);
}
else
{
/*
* Free the current buffer, then allocate a buffer
* large enough to hold the value
*/
if (TargetDesc->String.Pointer &&
(!(TargetDesc->Common.Flags & AOPOBJ_STATIC_POINTER)))
{
/*
* Only free if not a pointer into the DSDT
*/
ACPI_MEM_FREE (TargetDesc->String.Pointer);
}
TargetDesc->String.Pointer = ACPI_MEM_ALLOCATE (Length + 1);
if (!TargetDesc->String.Pointer)
{
return (AE_NO_MEMORY);
}
TargetDesc->String.Length = Length;
MEMCPY (TargetDesc->String.Pointer, Buffer, Length);
}
return (AE_OK);
}

View File

@ -1,7 +1,8 @@
/******************************************************************************
*
* Module Name: amsystem - Interface to OS services
* Module Name: exsystem - Interface to OS services
* $Revision: 1.67 $
*
*****************************************************************************/
@ -9,8 +10,8 @@
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999, Intel Corp. All rights
* reserved.
* Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp.
* All rights reserved.
*
* 2. License
*
@ -114,42 +115,21 @@
*
*****************************************************************************/
#define __AMSYSTEM_C__
#define __EXSYSTEM_C__
#include "acpi.h"
#include "interp.h"
#include "namesp.h"
#include "hardware.h"
#include "events.h"
#include "acinterp.h"
#include "acnamesp.h"
#include "achware.h"
#include "acevents.h"
#define _COMPONENT INTERPRETER
MODULE_NAME ("amsystem");
#define _COMPONENT ACPI_EXECUTER
MODULE_NAME ("exsystem")
/******************************************************************************
/*******************************************************************************
*
* FUNCTION: OsThreadId
*
* PARAMETERS: None
*
* RETURN: Current Thread ID (for this implementation a 1 is returned)
*
* DESCRIPTION: An invocation is identified by its Thread ID. In a single
* threaded OS the Thread ID is undefined so a 1 will be
* returned.
*
******************************************************************************/
UINT16
OsThreadId (void)
{
return (1);
}
/******************************************************************************
*
* FUNCTION: OsLocalWaitSemaphore
* FUNCTION: AcpiExSystemWaitSemaphore
*
* PARAMETERS: Semaphore - OSD semaphore to wait on
* Timeout - Max time to wait
@ -163,16 +143,17 @@ OsThreadId (void)
******************************************************************************/
ACPI_STATUS
OsLocalWaitSemaphore (
AcpiExSystemWaitSemaphore (
ACPI_HANDLE Semaphore,
UINT32 Timeout)
{
ACPI_STATUS Status;
FUNCTION_TRACE ("OsLocalWaitSemaphore");
FUNCTION_TRACE ("ExSystemWaitSemaphore");
Status = AcpiOsdWaitSemaphore (Semaphore, 1, 0);
Status = AcpiOsWaitSemaphore (Semaphore, 1, 0);
if (ACPI_SUCCESS (Status))
{
return_ACPI_STATUS (Status);
@ -182,24 +163,31 @@ OsLocalWaitSemaphore (
{
/* We must wait, so unlock the interpreter */
AcpiAmlExitInterpreter ();
AcpiExExitInterpreter ();
Status = AcpiOsdWaitSemaphore (Semaphore, 1, Timeout);
Status = AcpiOsWaitSemaphore (Semaphore, 1, Timeout);
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "*** Thread awake after blocking, %s\n",
AcpiFormatException (Status)));
/* Reacquire the interpreter */
AcpiAmlEnterInterpreter ();
Status = AcpiExEnterInterpreter ();
if (ACPI_SUCCESS (Status))
{
/* Restore the timeout exception */
DEBUG_PRINT (TRACE_EXEC, ("*** Thread awake and inside interpreter after blocking, %s\n", AcpiCmFormatException (Status)));
Status = AE_TIME;
}
}
return_ACPI_STATUS (Status);
}
/******************************************************************************
/*******************************************************************************
*
* FUNCTION: OsDoStall
* FUNCTION: AcpiExSystemDoStall
*
* PARAMETERS: HowLong - The amount of time to stall
*
@ -210,33 +198,35 @@ OsLocalWaitSemaphore (
******************************************************************************/
void
OsDoStall (
AcpiExSystemDoStall (
UINT32 HowLong)
{
FUNCTION_ENTRY ();
if (HowLong > 1000) /* 1 millisecond */
{
/* Since this thread will sleep, we must release the interpreter */
AcpiAmlExitInterpreter ();
AcpiExExitInterpreter ();
AcpiOsdSleepUsec (HowLong);
AcpiOsStall (HowLong);
/* And now we must get the interpreter again */
AcpiAmlEnterInterpreter ();
AcpiExEnterInterpreter ();
}
else
{
AcpiOsdSleepUsec (HowLong);
AcpiOsSleep (0, (HowLong / 1000) + 1);
}
}
/******************************************************************************
/*******************************************************************************
*
* FUNCTION: OsDoSuspend
* FUNCTION: AcpiExSystemDoSuspend
*
* PARAMETERS: HowLong - The amount of time to suspend
*
@ -247,24 +237,29 @@ OsDoStall (
******************************************************************************/
void
OsDoSuspend (
AcpiExSystemDoSuspend (
UINT32 HowLong)
{
FUNCTION_ENTRY ();
/* Since this thread will sleep, we must release the interpreter */
AcpiAmlExitInterpreter ();
AcpiExExitInterpreter ();
AcpiOsdSleep ((UINT16) (HowLong / (UINT32) 1000), (UINT16) (HowLong % (UINT32) 1000));
AcpiOsSleep ((UINT16) (HowLong / (UINT32) 1000),
(UINT16) (HowLong % (UINT32) 1000));
/* And now we must get the interpreter again */
AcpiAmlEnterInterpreter ();
AcpiExEnterInterpreter ();
}
/******************************************************************************
/*******************************************************************************
*
* FUNCTION: OsAcquireMutex
* FUNCTION: AcpiExSystemAcquireMutex
*
* PARAMETERS: *TimeDesc - The 'time to delay' object descriptor
* *ObjDesc - The object descriptor for this op
@ -278,14 +273,15 @@ OsDoSuspend (
******************************************************************************/
ACPI_STATUS
OsAcquireMutex (
ACPI_OBJECT_INTERNAL *TimeDesc,
ACPI_OBJECT_INTERNAL *ObjDesc)
AcpiExSystemAcquireMutex (
ACPI_OPERAND_OBJECT *TimeDesc,
ACPI_OPERAND_OBJECT *ObjDesc)
{
ACPI_STATUS Status = AE_OK;
FUNCTION_TRACE_PTR ("OsAcquireMutex", ObjDesc);
FUNCTION_TRACE_PTR ("ExSystemAcquireMutex", ObjDesc);
if (!ObjDesc)
{
@ -295,41 +291,41 @@ OsAcquireMutex (
/*
* Support for the _GL_ Mutex object -- go get the global lock
*/
if (ObjDesc->Mutex.Semaphore == AcpiGbl_GlobalLockSemaphore)
{
Status = AcpiEvAcquireGlobalLock ();
return_ACPI_STATUS (Status);
}
Status = OsLocalWaitSemaphore (ObjDesc->Mutex.Semaphore, TimeDesc->Number.Value);
Status = AcpiExSystemWaitSemaphore (ObjDesc->Mutex.Semaphore,
(UINT32) TimeDesc->Integer.Value);
return_ACPI_STATUS (Status);
}
/******************************************************************************
/*******************************************************************************
*
* FUNCTION: OsReleaseMutex
* FUNCTION: AcpiExSystemReleaseMutex
*
* PARAMETERS: *ObjDesc - The object descriptor for this op
*
* RETURN: Status
*
* DESCRIPTION: Provides an access point to perform synchronization operations
* within the AML. This operation is a request to release a previously
* acquired Mutex. If the Mutex variable is set then it will be
* decremented.
* within the AML. This operation is a request to release a
* previously acquired Mutex. If the Mutex variable is set then
* it will be decremented.
*
******************************************************************************/
ACPI_STATUS
OsReleaseMutex (
ACPI_OBJECT_INTERNAL *ObjDesc)
AcpiExSystemReleaseMutex (
ACPI_OPERAND_OBJECT *ObjDesc)
{
ACPI_STATUS Status = AE_OK;
FUNCTION_TRACE ("OsReleaseMutex");
FUNCTION_TRACE ("ExSystemReleaseMutex");
if (!ObjDesc)
@ -346,14 +342,14 @@ OsReleaseMutex (
return_ACPI_STATUS (AE_OK);
}
Status = AcpiOsdSignalSemaphore (ObjDesc->Mutex.Semaphore, 1);
Status = AcpiOsSignalSemaphore (ObjDesc->Mutex.Semaphore, 1);
return_ACPI_STATUS (Status);
}
/******************************************************************************
/*******************************************************************************
*
* FUNCTION: OsSignalEvent
* FUNCTION: AcpiExSystemSignalEvent
*
* PARAMETERS: *ObjDesc - The object descriptor for this op
*
@ -365,27 +361,27 @@ OsReleaseMutex (
******************************************************************************/
ACPI_STATUS
OsSignalEvent (
ACPI_OBJECT_INTERNAL *ObjDesc)
AcpiExSystemSignalEvent (
ACPI_OPERAND_OBJECT *ObjDesc)
{
ACPI_STATUS Status = AE_OK;
FUNCTION_TRACE ("OsSignalEvent");
FUNCTION_TRACE ("ExSystemSignalEvent");
if (ObjDesc)
{
Status = AcpiOsdSignalSemaphore (ObjDesc->Event.Semaphore, 1);
Status = AcpiOsSignalSemaphore (ObjDesc->Event.Semaphore, 1);
}
return_ACPI_STATUS (Status);
}
/******************************************************************************
/*******************************************************************************
*
* FUNCTION: OsWaitEvent
* FUNCTION: AcpiExSystemWaitEvent
*
* PARAMETERS: *TimeDesc - The 'time to delay' object descriptor
* *ObjDesc - The object descriptor for this op
@ -393,24 +389,26 @@ OsSignalEvent (
* RETURN: Status
*
* DESCRIPTION: Provides an access point to perform synchronization operations
* within the AML. This operation is a request to wait for an event.
* within the AML. This operation is a request to wait for an
* event.
*
******************************************************************************/
ACPI_STATUS
OsWaitEvent (
ACPI_OBJECT_INTERNAL *TimeDesc,
ACPI_OBJECT_INTERNAL *ObjDesc)
AcpiExSystemWaitEvent (
ACPI_OPERAND_OBJECT *TimeDesc,
ACPI_OPERAND_OBJECT *ObjDesc)
{
ACPI_STATUS Status = AE_OK;
FUNCTION_TRACE ("OsWaitEvent");
FUNCTION_TRACE ("ExSystemWaitEvent");
if (ObjDesc)
{
Status = OsLocalWaitSemaphore (ObjDesc->Event.Semaphore, TimeDesc->Number.Value);
Status = AcpiExSystemWaitSemaphore (ObjDesc->Event.Semaphore,
(UINT32) TimeDesc->Integer.Value);
}
@ -418,34 +416,38 @@ OsWaitEvent (
}
/******************************************************************************
/*******************************************************************************
*
* FUNCTION: OsResetEvent
* FUNCTION: AcpiExSystemResetEvent
*
* PARAMETERS: *ObjDesc - The object descriptor for this op
*
* RETURN: Status
*
* DESCRIPTION: Provides an access point to perform synchronization operations
* within the AML.
* DESCRIPTION: Reset an event to a known state.
*
******************************************************************************/
ACPI_STATUS
OsResetEvent (
ACPI_OBJECT_INTERNAL *ObjDesc)
AcpiExSystemResetEvent (
ACPI_OPERAND_OBJECT *ObjDesc)
{
ACPI_STATUS Status = AE_OK;
void *TempSemaphore;
/* We are going to simply delete the existing semaphore and create a new one! */
FUNCTION_ENTRY ();
Status = AcpiOsdCreateSemaphore (0, &TempSemaphore);
/*
* We are going to simply delete the existing semaphore and
* create a new one!
*/
Status = AcpiOsCreateSemaphore (ACPI_NO_UNIT_LIMIT, 0, &TempSemaphore);
if (ACPI_SUCCESS (Status))
{
AcpiOsdDeleteSemaphore (ObjDesc->Mutex.Semaphore);
ObjDesc->Mutex.Semaphore = TempSemaphore;
AcpiOsDeleteSemaphore (ObjDesc->Event.Semaphore);
ObjDesc->Event.Semaphore = TempSemaphore;
}
return (Status);

View File

@ -1,7 +1,8 @@
/******************************************************************************
*
* Module Name: amutils - interpreter/scanner utilities
* Module Name: exutils - interpreter/scanner utilities
* $Revision: 1.83 $
*
*****************************************************************************/
@ -9,8 +10,8 @@
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999, Intel Corp. All rights
* reserved.
* Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp.
* All rights reserved.
*
* 2. License
*
@ -114,7 +115,7 @@
*
*****************************************************************************/
#define __AMUTILS_C__
#define __EXUTILS_C__
#include "acpi.h"
#include "acparser.h"
@ -123,53 +124,37 @@
#include "acnamesp.h"
#include "acevents.h"
#define _COMPONENT INTERPRETER
MODULE_NAME ("amutils");
typedef struct Internal_Search_st
{
ACPI_OBJECT_INTERNAL *DestObj;
UINT32 Index;
ACPI_OBJECT_INTERNAL *SourceObj;
} INTERNAL_PKG_SEARCH_INFO;
/* Used to traverse nested packages when copying*/
INTERNAL_PKG_SEARCH_INFO CopyLevel[MAX_PACKAGE_DEPTH];
static INT8 hex[] =
{'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
#define _COMPONENT ACPI_EXECUTER
MODULE_NAME ("exutils")
/*******************************************************************************
*
* FUNCTION: AcpiAmlEnterInterpreter
* FUNCTION: AcpiExEnterInterpreter
*
* PARAMETERS: None
*
* DESCRIPTION: Enter the interpreter execution region
* TBD: should be a macro
*
******************************************************************************/
void
AcpiAmlEnterInterpreter (void)
ACPI_STATUS
AcpiExEnterInterpreter (void)
{
FUNCTION_TRACE ("AmlEnterInterpreter");
ACPI_STATUS Status;
FUNCTION_TRACE ("ExEnterInterpreter");
AcpiCmAcquireMutex (ACPI_MTX_EXECUTE);
return_VOID;
Status = AcpiUtAcquireMutex (ACPI_MTX_EXECUTE);
return_ACPI_STATUS (Status);
}
/*******************************************************************************
*
* FUNCTION: AcpiAmlExitInterpreter
* FUNCTION: AcpiExExitInterpreter
*
* PARAMETERS: None
*
@ -185,15 +170,17 @@ AcpiAmlEnterInterpreter (void)
* already executing
* 7) About to invoke a user-installed opregion handler
*
* TBD: should be a macro
*
******************************************************************************/
void
AcpiAmlExitInterpreter (void)
AcpiExExitInterpreter (void)
{
FUNCTION_TRACE ("AmlExitInterpreter");
FUNCTION_TRACE ("ExExitInterpreter");
AcpiCmReleaseMutex (ACPI_MTX_EXECUTE);
AcpiUtReleaseMutex (ACPI_MTX_EXECUTE);
return_VOID;
}
@ -201,7 +188,7 @@ AcpiAmlExitInterpreter (void)
/*******************************************************************************
*
* FUNCTION: AcpiAmlValidateObjectType
* FUNCTION: AcpiExValidateObjectType
*
* PARAMETERS: Type Object type to validate
*
@ -210,46 +197,72 @@ AcpiAmlExitInterpreter (void)
******************************************************************************/
BOOLEAN
AcpiAmlValidateObjectType (
AcpiExValidateObjectType (
ACPI_OBJECT_TYPE Type)
{
FUNCTION_ENTRY ();
if ((Type > ACPI_TYPE_MAX && Type < INTERNAL_TYPE_BEGIN) ||
(Type > INTERNAL_TYPE_MAX))
{
return FALSE;
return (FALSE);
}
return TRUE;
return (TRUE);
}
/*******************************************************************************
*
* FUNCTION: AcpiAmlBufSeq
* FUNCTION: AcpiExTruncateFor32bitTable
*
* RETURN: The next buffer descriptor sequence number
* PARAMETERS: ObjDesc - Object to be truncated
* WalkState - Current walk state
* (A method must be executing)
*
* DESCRIPTION: Provide a unique sequence number for each Buffer descriptor
* allocated during the interpreter's existence. These numbers
* are used to relate FieldUnit descriptors to the Buffers
* within which the fields are defined.
* RETURN: none
*
* Just increment the global counter and return it.
* DESCRIPTION: Truncate a number to 32-bits if the currently executing method
* belongs to a 32-bit ACPI table.
*
******************************************************************************/
UINT32
AcpiAmlBufSeq (void)
void
AcpiExTruncateFor32bitTable (
ACPI_OPERAND_OBJECT *ObjDesc,
ACPI_WALK_STATE *WalkState)
{
return ++AcpiGbl_BufSeq;
FUNCTION_ENTRY ();
/*
* Object must be a valid number and we must be executing
* a control method
*/
if ((!ObjDesc) ||
(ObjDesc->Common.Type != ACPI_TYPE_INTEGER) ||
(!WalkState->MethodNode))
{
return;
}
if (WalkState->MethodNode->Flags & ANOBJ_DATA_WIDTH_32)
{
/*
* We are running a method that exists in a 32-bit ACPI table.
* Truncate the value to 32 bits by zeroing out the upper 32-bit field
*/
ObjDesc->Integer.Value &= (ACPI_INTEGER) ACPI_UINT32_MAX;
}
}
/*******************************************************************************
*
* FUNCTION: AcpiAmlAcquireGlobalLock
* FUNCTION: AcpiExAcquireGlobalLock
*
* PARAMETERS: Rule - Lock rule: AlwaysLock, NeverLock
*
@ -262,33 +275,33 @@ AcpiAmlBufSeq (void)
******************************************************************************/
BOOLEAN
AcpiAmlAcquireGlobalLock (
AcpiExAcquireGlobalLock (
UINT32 Rule)
{
BOOLEAN Locked = FALSE;
ACPI_STATUS Status;
FUNCTION_TRACE ("AmlAcquireGlobalLock");
FUNCTION_TRACE ("ExAcquireGlobalLock");
/* Only attempt lock if the Rule says so */
/* Only attempt lock if the Rule says so */
if (Rule == (UINT32) GLOCK_ALWAYS_LOCK)
{
/* OK to get the lock */
/* We should attempt to get the lock */
Status = AcpiEvAcquireGlobalLock ();
if (ACPI_FAILURE (Status))
{
DEBUG_PRINT (ACPI_ERROR, ("Get Global Lock Failed!!\n"));
}
if (ACPI_SUCCESS (Status))
{
AcpiGbl_GlobalLockSet = TRUE;
Locked = TRUE;
}
else
{
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not acquire Global Lock, %s\n",
AcpiFormatException (Status)));
}
}
return_VALUE (Locked);
@ -297,7 +310,7 @@ AcpiAmlAcquireGlobalLock (
/*******************************************************************************
*
* FUNCTION: AcpiAmlReleaseGlobalLock
* FUNCTION: AcpiExReleaseGlobalLock
*
* PARAMETERS: LockedByMe - Return value from corresponding call to
* AcquireGlobalLock.
@ -309,31 +322,20 @@ AcpiAmlAcquireGlobalLock (
******************************************************************************/
ACPI_STATUS
AcpiAmlReleaseGlobalLock (
AcpiExReleaseGlobalLock (
BOOLEAN LockedByMe)
{
FUNCTION_TRACE ("AmlReleaseGlobalLock");
FUNCTION_TRACE ("ExReleaseGlobalLock");
/* Only attempt unlock if the caller locked it */
if (LockedByMe)
{
/* Double check against the global flag */
/* OK, now release the lock */
if (AcpiGbl_GlobalLockSet)
{
/* OK, now release the lock */
AcpiEvReleaseGlobalLock ();
AcpiGbl_GlobalLockSet = FALSE;
}
else
{
DEBUG_PRINT (ACPI_ERROR, ("Global lock was not set\n"));
}
AcpiEvReleaseGlobalLock ();
}
@ -343,7 +345,7 @@ AcpiAmlReleaseGlobalLock (
/*******************************************************************************
*
* FUNCTION: AcpiAmlDigitsNeeded
* FUNCTION: AcpiExDigitsNeeded
*
* PARAMETERS: val - Value to be represented
* base - Base of representation
@ -352,27 +354,28 @@ AcpiAmlReleaseGlobalLock (
*
******************************************************************************/
INT32
AcpiAmlDigitsNeeded (
INT32 val,
INT32 base)
UINT32
AcpiExDigitsNeeded (
ACPI_INTEGER val,
UINT32 base)
{
INT32 NumDigits = 0;
UINT32 NumDigits = 0;
FUNCTION_TRACE ("AmlDigitsNeeded");
FUNCTION_TRACE ("ExDigitsNeeded");
if (base < 1)
{
/* impossible base */
REPORT_ERROR ("AmlDigitsNeeded: Impossible base");
REPORT_ERROR (("ExDigitsNeeded: Internal error - Invalid base\n"));
}
else
{
for (NumDigits = 1 + (val < 0) ; val /= base ; ++NumDigits)
/*
* ACPI_INTEGER is unsigned, which is why we don't worry about the '-'
*/
for (NumDigits = 1; (val = ACPI_DIVIDE (val,base)); ++NumDigits)
{ ; }
}
@ -386,27 +389,30 @@ AcpiAmlDigitsNeeded (
*
* PARAMETERS: Value - Value to be converted
*
* RETURN: Convert a 32-bit value to big-endian (swap the bytes)
* DESCRIPTION: Convert a 32-bit value to big-endian (swap the bytes)
*
******************************************************************************/
UINT32
static UINT32
_ntohl (
UINT32 Value)
{
union
{
UINT32 Value;
INT8 Bytes[4];
UINT8 Bytes[4];
} Out;
union
{
UINT32 Value;
INT8 Bytes[4];
UINT8 Bytes[4];
} In;
FUNCTION_ENTRY ();
In.Value = Value;
Out.Bytes[0] = In.Bytes[3];
@ -414,28 +420,32 @@ _ntohl (
Out.Bytes[2] = In.Bytes[1];
Out.Bytes[3] = In.Bytes[0];
return Out.Value;
return (Out.Value);
}
/*******************************************************************************
*
* FUNCTION: AcpiAmlEisaIdToString
* FUNCTION: AcpiExEisaIdToString
*
* PARAMETERS: NumericId - EISA ID to be converted
* OutString - Where to put the converted string (8 bytes)
*
* RETURN: Convert a numeric EISA ID to string representation
* DESCRIPTION: Convert a numeric EISA ID to string representation
*
******************************************************************************/
ACPI_STATUS
AcpiAmlEisaIdToString (
AcpiExEisaIdToString (
UINT32 NumericId,
INT8 *OutString)
NATIVE_CHAR *OutString)
{
UINT32 id;
FUNCTION_ENTRY ();
/* swap to big-endian to get contiguous bits */
id = _ntohl (NumericId);
@ -443,182 +453,49 @@ AcpiAmlEisaIdToString (
OutString[0] = (char) ('@' + ((id >> 26) & 0x1f));
OutString[1] = (char) ('@' + ((id >> 21) & 0x1f));
OutString[2] = (char) ('@' + ((id >> 16) & 0x1f));
OutString[3] = hex[(id >> 12) & 0xf];
OutString[4] = hex[(id >> 8) & 0xf];
OutString[5] = hex[(id >> 4) & 0xf];
OutString[6] = hex[id & 0xf];
OutString[3] = AcpiUtHexToAsciiChar (id, 12);
OutString[4] = AcpiUtHexToAsciiChar (id, 8);
OutString[5] = AcpiUtHexToAsciiChar (id, 4);
OutString[6] = AcpiUtHexToAsciiChar (id, 0);
OutString[7] = 0;
return AE_OK;
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: AcpiAmlBuildCopyInternalPackageObject
* FUNCTION: AcpiExUnsignedIntegerToString
*
* PARAMETERS: *SourceObj - Pointer to the source package object
* *DestObj - Where the internal object is returned
* PARAMETERS: Value - Value to be converted
* OutString - Where to put the converted string (8 bytes)
*
* RETURN: Status - the status of the call
*
* DESCRIPTION: This function is called to copy an internal package object
* into another internal package object.
* RETURN: Convert a number to string representation
*
******************************************************************************/
ACPI_STATUS
AcpiAmlBuildCopyInternalPackageObject (
ACPI_OBJECT_INTERNAL *SourceObj,
ACPI_OBJECT_INTERNAL *DestObj)
AcpiExUnsignedIntegerToString (
ACPI_INTEGER Value,
NATIVE_CHAR *OutString)
{
UINT32 CurrentDepth = 0;
ACPI_STATUS Status = AE_OK;
UINT32 Length = 0;
UINT32 ThisIndex;
UINT32 ObjectSpace = 0;
ACPI_OBJECT_INTERNAL *ThisDestObj;
ACPI_OBJECT_INTERNAL *ThisSourceObj;
INTERNAL_PKG_SEARCH_INFO *LevelPtr;
UINT32 Count;
UINT32 DigitsNeeded;
FUNCTION_TRACE ("AmlBuildCopyInternalPackageObject");
FUNCTION_ENTRY ();
/*
* Initialize the working variables
*/
DigitsNeeded = AcpiExDigitsNeeded (Value, 10);
OutString[DigitsNeeded] = '\0';
MEMSET ((void *) CopyLevel, 0, sizeof(CopyLevel));
CopyLevel[0].DestObj = DestObj;
CopyLevel[0].SourceObj = SourceObj;
LevelPtr = &CopyLevel[0];
CurrentDepth = 0;
DestObj->Common.Type = SourceObj->Common.Type;
DestObj->Package.Count = SourceObj->Package.Count;
/*
* Build an array of ACPI_OBJECTS in the buffer
* and move the free space past it
*/
DestObj->Package.Elements = AcpiCmCallocate (
(DestObj->Package.Count + 1) *
sizeof (void *));
if (!DestObj->Package.Elements)
for (Count = DigitsNeeded; Count > 0; Count--)
{
/* Package vector allocation failure */
REPORT_ERROR ("AmlBuildCopyInternalPackageObject: Package vector allocation failure");
return_ACPI_STATUS (AE_NO_MEMORY);
OutString[Count-1] = (NATIVE_CHAR) ('0' + (ACPI_MODULO (Value, 10)));
Value = ACPI_DIVIDE (Value, 10);
}
DestObj->Package.NextElement = DestObj->Package.Elements;
while (1)
{
ThisIndex = LevelPtr->Index;
ThisDestObj = (ACPI_OBJECT_INTERNAL *) LevelPtr->DestObj->Package.Elements[ThisIndex];
ThisSourceObj = (ACPI_OBJECT_INTERNAL *) LevelPtr->SourceObj->Package.Elements[ThisIndex];
if (IS_THIS_OBJECT_TYPE (ThisSourceObj, ACPI_TYPE_PACKAGE))
{
/*
* If this object is a package then we go one deeper
*/
if (CurrentDepth >= MAX_PACKAGE_DEPTH-1)
{
/*
* Too many nested levels of packages for us to handle
*/
DEBUG_PRINT (ACPI_ERROR,
("AmlBuildCopyInternalPackageObject: Pkg nested too deep (max %d)\n",
MAX_PACKAGE_DEPTH));
return_ACPI_STATUS (AE_LIMIT);
}
/*
* Build the package object
*/
ThisDestObj = AcpiCmCreateInternalObject (ACPI_TYPE_PACKAGE);
LevelPtr->DestObj->Package.Elements[ThisIndex] = ThisDestObj;
ThisDestObj->Common.Type = ACPI_TYPE_PACKAGE;
ThisDestObj->Package.Count = ThisDestObj->Package.Count;
/*
* Save space for the array of objects (Package elements)
* update the buffer length counter
*/
ObjectSpace = ThisDestObj->Package.Count *
sizeof (ACPI_OBJECT_INTERNAL);
Length += ObjectSpace;
CurrentDepth++;
LevelPtr = &CopyLevel[CurrentDepth];
LevelPtr->DestObj = ThisDestObj;
LevelPtr->SourceObj = ThisSourceObj;
LevelPtr->Index = 0;
} /* if object is a package */
else
{
ThisDestObj = AcpiCmCreateInternalObject (
ThisSourceObj->Common.Type);
LevelPtr->DestObj->Package.Elements[ThisIndex] = ThisDestObj;
Status = AcpiAmlStoreObjectToObject(ThisSourceObj, ThisDestObj);
if (ACPI_FAILURE (Status))
{
/*
* Failure get out
*/
return_ACPI_STATUS (Status);
}
Length +=ObjectSpace;
LevelPtr->Index++;
while (LevelPtr->Index >= LevelPtr->DestObj->Package.Count)
{
/*
* We've handled all of the objects at this level, This means
* that we have just completed a package. That package may
* have contained one or more packages itself
*/
if (CurrentDepth == 0)
{
/*
* We have handled all of the objects in the top level
* package just add the length of the package objects
* and exit
*/
return_ACPI_STATUS (AE_OK);
}
/*
* Go back up a level and move the index past the just
* completed package object.
*/
CurrentDepth--;
LevelPtr = &CopyLevel[CurrentDepth];
LevelPtr->Index++;
}
} /* else object is NOT a package */
} /* while (1) */
/*
* We'll never get here, but the compiler whines about return value
*/
return_ACPI_STATUS (AE_OK);
return (AE_OK);
}

View File

@ -1,6 +1,7 @@
/******************************************************************************
*
* Module Name: psargs - Parse AML opcode arguments
* $Revision: 1.51 $
*
*****************************************************************************/
@ -8,8 +9,8 @@
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999, Intel Corp. All rights
* reserved.
* Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp.
* All rights reserved.
*
* 2. License
*
@ -120,8 +121,8 @@
#include "amlcode.h"
#include "acnamesp.h"
#define _COMPONENT PARSER
MODULE_NAME ("psargs");
#define _COMPONENT ACPI_PARSER
MODULE_NAME ("psargs")
/*******************************************************************************
@ -141,14 +142,14 @@ UINT32
AcpiPsGetNextPackageLength (
ACPI_PARSE_STATE *ParserState)
{
INT32 EncodedLength;
INT32 Length = 0;
UINT32 EncodedLength;
UINT32 Length = 0;
FUNCTION_TRACE ("PsGetNextPackageLength");
EncodedLength = (INT32) GET8 (ParserState->Aml);
EncodedLength = (UINT32) GET8 (ParserState->Aml);
ParserState->Aml++;
@ -156,32 +157,33 @@ AcpiPsGetNextPackageLength (
{
case 0: /* 1-byte encoding (bits 0-5) */
Length = (EncodedLength & 0x3f);
Length = (EncodedLength & 0x3F);
break;
case 1: /* 2-byte encoding (next byte + bits 0-3) */
Length = (GET8 (ParserState->Aml) << 4) | (EncodedLength & 0xf);
Length = ((GET8 (ParserState->Aml) << 04) |
(EncodedLength & 0x0F));
ParserState->Aml++;
break;
case 2: /* 3-byte encoding (next 2 bytes + bits 0-3) */
Length = ( (GET8 (ParserState->Aml + 1) << 12)
| (GET8 (ParserState->Aml) << 4)
| (EncodedLength & 0xf));
Length = ((GET8 (ParserState->Aml + 1) << 12) |
(GET8 (ParserState->Aml) << 04) |
(EncodedLength & 0x0F));
ParserState->Aml += 2;
break;
case 3: /* 4-byte encoding (next 3 bytes + bits 0-3) */
Length = ( (GET8 (ParserState->Aml + 2) << 20)
| (GET8 (ParserState->Aml + 1) << 12)
| (GET8 (ParserState->Aml) << 4)
| (EncodedLength & 0xf));
Length = ((GET8 (ParserState->Aml + 2) << 20) |
(GET8 (ParserState->Aml + 1) << 12) |
(GET8 (ParserState->Aml) << 04) |
(EncodedLength & 0x0F));
ParserState->Aml += 3;
break;
}
@ -235,13 +237,13 @@ AcpiPsGetNextPackageEnd (
*
******************************************************************************/
INT8 *
NATIVE_CHAR *
AcpiPsGetNextNamestring (
ACPI_PARSE_STATE *ParserState)
{
INT8 *Start = (INT8 *) ParserState->Aml;
INT8 *End = (INT8 *) ParserState->Aml;
INT32 Length;
UINT8 *Start = ParserState->Aml;
UINT8 *End = ParserState->Aml;
UINT32 Length;
FUNCTION_TRACE ("PsGetNextNamestring");
@ -284,7 +286,7 @@ AcpiPsGetNextNamestring (
/* multiple name segments */
Length = (INT32) GET8 (End + 1) * 4;
Length = (UINT32) GET8 (End + 1) * 4;
End += 2 + Length;
break;
@ -300,7 +302,7 @@ AcpiPsGetNextNamestring (
ParserState->Aml = (UINT8*) End;
return_PTR (Start);
return_PTR ((NATIVE_CHAR *) Start);
}
@ -331,14 +333,14 @@ AcpiPsGetNextNamestring (
void
AcpiPsGetNextNamepath (
ACPI_PARSE_STATE *ParserState,
ACPI_GENERIC_OP *Arg,
ACPI_PARSE_OBJECT *Arg,
UINT32 *ArgCount,
BOOLEAN MethodCall)
{
INT8 *Path;
ACPI_GENERIC_OP *Name;
ACPI_GENERIC_OP *Op;
ACPI_GENERIC_OP *Count;
NATIVE_CHAR *Path;
ACPI_PARSE_OBJECT *NameOp;
ACPI_PARSE_OBJECT *Op;
ACPI_PARSE_OBJECT *Count;
FUNCTION_TRACE ("PsGetNextNamepath");
@ -349,7 +351,7 @@ AcpiPsGetNextNamepath (
{
/* Null name case, create a null namepath object */
AcpiPsInitOp (Arg, AML_NAMEPATH_OP);
AcpiPsInitOp (Arg, AML_INT_NAMEPATH_OP);
Arg->Value.Name = Path;
return_VOID;
}
@ -360,7 +362,6 @@ AcpiPsGetNextNamepath (
/*
* Lookup the name in the parsed namespace
*/
Op = NULL;
if (MethodCall)
{
@ -378,25 +379,24 @@ AcpiPsGetNextNamepath (
* associated with this method, and 2) Change the NAMEPATH
* object into a METHODCALL object.
*/
Count = AcpiPsGetArg (Op, 0);
if (Count && Count->Opcode == AML_BYTE_OP)
{
Name = AcpiPsAllocOp (AML_NAMEPATH_OP);
if (Name)
NameOp = AcpiPsAllocOp (AML_INT_NAMEPATH_OP);
if (NameOp)
{
/* Change arg into a METHOD CALL and attach the name */
AcpiPsInitOp (Arg, AML_METHODCALL_OP);
AcpiPsInitOp (Arg, AML_INT_METHODCALL_OP);
Name->Value.Name = Path;
NameOp->Value.Name = Path;
/* Point METHODCALL/NAME to the METHOD NTE */
/* Point METHODCALL/NAME to the METHOD Node */
Name->AcpiNamedObject = Op;
AcpiPsAppendArg (Arg, Name);
NameOp->Node = (ACPI_NAMESPACE_NODE *) Op;
AcpiPsAppendArg (Arg, NameOp);
*ArgCount = Count->Value.Integer &
*ArgCount = (UINT32) Count->Value.Integer &
METHOD_FLAGS_ARG_COUNT;
}
}
@ -412,14 +412,12 @@ AcpiPsGetNextNamepath (
}
}
/*
* Either we didn't find the object in the namespace, or the object is
* something other than a control method. Just initialize the Op with the
* pathname
*/
AcpiPsInitOp (Arg, AML_NAMEPATH_OP);
AcpiPsInitOp (Arg, AML_INT_NAMEPATH_OP);
Arg->Value.Name = Path;
@ -433,15 +431,15 @@ AcpiPsGetNextNamepath (
void
AcpiPsGetNextNamepath (
ACPI_PARSE_STATE *ParserState,
ACPI_GENERIC_OP *Arg,
ACPI_PARSE_OBJECT *Arg,
UINT32 *ArgCount,
BOOLEAN MethodCall)
{
INT8 *Path;
ACPI_GENERIC_OP *Name;
NATIVE_CHAR *Path;
ACPI_PARSE_OBJECT *NameOp;
ACPI_STATUS Status;
ACPI_NAMED_OBJECT *Method = NULL;
ACPI_NAMED_OBJECT *Entry;
ACPI_NAMESPACE_NODE *MethodNode = NULL;
ACPI_NAMESPACE_NODE *Node;
ACPI_GENERIC_STATE ScopeInfo;
@ -453,7 +451,7 @@ AcpiPsGetNextNamepath (
{
/* Null name case, create a null namepath object */
AcpiPsInitOp (Arg, AML_NAMEPATH_OP);
AcpiPsInitOp (Arg, AML_INT_NAMEPATH_OP);
Arg->Value.Name = Path;
return_VOID;
}
@ -464,11 +462,11 @@ AcpiPsGetNextNamepath (
/*
* Lookup the name in the internal namespace
*/
ScopeInfo.Scope.NameTable = NULL;
Entry = ParserState->StartOp->AcpiNamedObject;
if (Entry)
ScopeInfo.Scope.Node = NULL;
Node = ParserState->StartNode;
if (Node)
{
ScopeInfo.Scope.NameTable = Entry->ChildTable;
ScopeInfo.Scope.Node = Node;
}
/*
@ -477,34 +475,37 @@ AcpiPsGetNextNamepath (
* parent tree, but don't open a new scope -- we just want to lookup the
* object (MUST BE mode EXECUTE to perform upsearch)
*/
Status = AcpiNsLookup (&ScopeInfo, Path, ACPI_TYPE_ANY, IMODE_EXECUTE,
NS_SEARCH_PARENT | NS_DONT_OPEN_SCOPE, NULL,
&Entry);
&Node);
if (ACPI_SUCCESS (Status))
{
if (Entry->Type == ACPI_TYPE_METHOD)
if (Node->Type == ACPI_TYPE_METHOD)
{
Method = Entry;
DEBUG_PRINT (TRACE_PARSE,
("PsGetNextNamepath: method - %p Path=%p\n",
Method, Path));
MethodNode = Node;
ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "method - %p Path=%p\n",
MethodNode, Path));
Name = AcpiPsAllocOp (AML_NAMEPATH_OP);
if (Name)
NameOp = AcpiPsAllocOp (AML_INT_NAMEPATH_OP);
if (NameOp)
{
/* Change arg into a METHOD CALL and attach name to it */
AcpiPsInitOp (Arg, AML_METHODCALL_OP);
AcpiPsInitOp (Arg, AML_INT_METHODCALL_OP);
Name->Value.Name = Path;
NameOp->Value.Name = Path;
/* Point METHODCALL/NAME to the METHOD NTE */
/* Point METHODCALL/NAME to the METHOD Node */
Name->AcpiNamedObject = Method;
AcpiPsAppendArg (Arg, Name);
NameOp->Node = MethodNode;
AcpiPsAppendArg (Arg, NameOp);
*ArgCount = ((ACPI_OBJECT_INTERNAL *) Method->Object)->Method.ParamCount;
if (!(ACPI_OPERAND_OBJECT *) MethodNode->Object)
{
return_VOID;
}
*ArgCount = ((ACPI_OPERAND_OBJECT *) MethodNode->Object)->Method.ParamCount;
}
return_VOID;
@ -521,10 +522,9 @@ AcpiPsGetNextNamepath (
/*
* Either we didn't find the object in the namespace, or the object is
* something other than a control method. Just initialize the Op with the
* pathname
* pathname.
*/
AcpiPsInitOp (Arg, AML_NAMEPATH_OP);
AcpiPsInitOp (Arg, AML_INT_NAMEPATH_OP);
Arg->Value.Name = Path;
@ -550,11 +550,10 @@ AcpiPsGetNextNamepath (
void
AcpiPsGetNextSimpleArg (
ACPI_PARSE_STATE *ParserState,
INT32 ArgType,
ACPI_GENERIC_OP *Arg)
UINT32 ArgType,
ACPI_PARSE_OBJECT *Arg)
{
FUNCTION_TRACE_U32 ("PsGetNextSimpleArg", ArgType);
@ -591,6 +590,17 @@ AcpiPsGetNextSimpleArg (
break;
case ARGP_QWORDDATA:
AcpiPsInitOp (Arg, AML_QWORD_OP);
/* Get 8 bytes from the AML stream */
MOVE_UNALIGNED64_TO_64 (&Arg->Value.Integer, ParserState->Aml);
ParserState->Aml += 8;
break;
case ARGP_CHARLIST:
AcpiPsInitOp (Arg, AML_STRING_OP);
@ -607,7 +617,7 @@ AcpiPsGetNextSimpleArg (
case ARGP_NAME:
case ARGP_NAMESTRING:
AcpiPsInitOp (Arg, AML_NAMEPATH_OP);
AcpiPsInitOp (Arg, AML_INT_NAMEPATH_OP);
Arg->Value.Name = AcpiPsGetNextNamestring (ParserState);
break;
}
@ -628,13 +638,13 @@ AcpiPsGetNextSimpleArg (
*
******************************************************************************/
ACPI_GENERIC_OP *
ACPI_PARSE_OBJECT *
AcpiPsGetNextField (
ACPI_PARSE_STATE *ParserState)
{
ACPI_PTRDIFF AmlOffset = ParserState->Aml -
UINT32 AmlOffset = ParserState->Aml -
ParserState->AmlStart;
ACPI_GENERIC_OP *Field;
ACPI_PARSE_OBJECT *Field;
UINT16 Opcode;
UINT32 Name;
@ -649,20 +659,20 @@ AcpiPsGetNextField (
default:
Opcode = AML_NAMEDFIELD_OP;
Opcode = AML_INT_NAMEDFIELD_OP;
break;
case 0x00:
Opcode = AML_RESERVEDFIELD_OP;
Opcode = AML_INT_RESERVEDFIELD_OP;
ParserState->Aml++;
break;
case 0x01:
Opcode = AML_ACCESSFIELD_OP;
Opcode = AML_INT_ACCESSFIELD_OP;
ParserState->Aml++;
break;
}
@ -679,7 +689,7 @@ AcpiPsGetNextField (
switch (Opcode)
{
case AML_NAMEDFIELD_OP:
case AML_INT_NAMEDFIELD_OP:
/* Get the 4-character name */
@ -693,7 +703,7 @@ AcpiPsGetNextField (
break;
case AML_RESERVEDFIELD_OP:
case AML_INT_RESERVEDFIELD_OP:
/* Get the length which is encoded as a package length */
@ -701,7 +711,7 @@ AcpiPsGetNextField (
break;
case AML_ACCESSFIELD_OP:
case AML_INT_ACCESSFIELD_OP:
/* Get AccessType and AccessAtrib and merge into the field Op */
@ -732,16 +742,16 @@ AcpiPsGetNextField (
*
******************************************************************************/
ACPI_GENERIC_OP *
ACPI_PARSE_OBJECT *
AcpiPsGetNextArg (
ACPI_PARSE_STATE *ParserState,
INT32 ArgType,
UINT32 ArgType,
UINT32 *ArgCount)
{
ACPI_GENERIC_OP *Arg = NULL;
ACPI_GENERIC_OP *Prev = NULL;
ACPI_GENERIC_OP *Field;
INT32 Subop;
ACPI_PARSE_OBJECT *Arg = NULL;
ACPI_PARSE_OBJECT *Prev = NULL;
ACPI_PARSE_OBJECT *Field;
UINT32 Subop;
FUNCTION_TRACE_PTR ("PsGetNextArg", ParserState);
@ -814,13 +824,13 @@ AcpiPsGetNextArg (
{
/* non-empty list */
Arg = AcpiPsAllocOp (AML_BYTELIST_OP);
Arg = AcpiPsAllocOp (AML_INT_BYTELIST_OP);
if (Arg)
{
/* fill in bytelist data */
Arg->Value.Size = (ParserState->PkgEnd - ParserState->Aml);
AcpiPsToBytelistOp (Arg)->Data = ParserState->Aml;
((ACPI_PARSE2_OBJECT *) Arg)->Data = ParserState->Aml;
}
/* skip to End of byte data */
@ -840,7 +850,7 @@ AcpiPsGetNextArg (
{
/* NullName or NameString */
Arg = AcpiPsAllocOp (AML_NAMEPATH_OP);
Arg = AcpiPsAllocOp (AML_INT_NAMEPATH_OP);
if (Arg)
{
AcpiPsGetNextNamepath (ParserState, Arg, ArgCount, 0);