summaryrefslogtreecommitdiffstats
path: root/sys/contrib/dev/acpica/exresop.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/contrib/dev/acpica/exresop.c')
-rw-r--r--sys/contrib/dev/acpica/exresop.c196
1 files changed, 114 insertions, 82 deletions
diff --git a/sys/contrib/dev/acpica/exresop.c b/sys/contrib/dev/acpica/exresop.c
index a9283f2..f513053 100644
--- a/sys/contrib/dev/acpica/exresop.c
+++ b/sys/contrib/dev/acpica/exresop.c
@@ -2,7 +2,7 @@
/******************************************************************************
*
* Module Name: exresop - AML Interpreter operand/object resolution
- * $Revision: 41 $
+ * $Revision: 47 $
*
*****************************************************************************/
@@ -10,7 +10,7 @@
*
* 1. Copyright Notice
*
- * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp.
+ * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp.
* All rights reserved.
*
* 2. License
@@ -128,7 +128,7 @@
#define _COMPONENT ACPI_EXECUTER
- MODULE_NAME ("exresop")
+ ACPI_MODULE_NAME ("exresop")
/*******************************************************************************
@@ -151,7 +151,7 @@ AcpiExCheckObjectType (
ACPI_OBJECT_TYPE ThisType,
void *Object)
{
- PROC_NAME ("ExCheckObjectType");
+ ACPI_FUNCTION_NAME ("ExCheckObjectType");
if (TypeNeeded == ACPI_TYPE_ANY)
@@ -179,18 +179,21 @@ AcpiExCheckObjectType (
*
* FUNCTION: AcpiExResolveOperands
*
- * PARAMETERS: Opcode Opcode being interpreted
- * StackPtr Top of operand stack
+ * PARAMETERS: Opcode - Opcode being interpreted
+ * StackPtr - Pointer to the operand stack to be
+ * resolved
+ * WalkState - Current stateu
*
* RETURN: Status
*
- * DESCRIPTION: Convert stack entries to required types
+ * DESCRIPTION: Convert multiple input operands to the types required by the
+ * target operator.
*
- * Each nibble in ArgTypes represents one required operand
- * and indicates the required Type:
+ * Each nibble (actually 5 bits) in ArgTypes represents one required
+ * operand and indicates the required Type:
*
- * The corresponding stack entry will be converted to the
- * required type if possible, else return an exception
+ * The corresponding operand will be converted to the required type if
+ * possible, otherwise we abort with an exception.
*
******************************************************************************/
@@ -210,7 +213,7 @@ AcpiExResolveOperands (
ACPI_OBJECT_TYPE TypeNeeded;
- FUNCTION_TRACE_U32 ("ExResolveOperands", Opcode);
+ ACPI_FUNCTION_TRACE_U32 ("ExResolveOperands", Opcode);
OpInfo = AcpiPsGetOpcodeInfo (Opcode);
@@ -219,7 +222,6 @@ AcpiExResolveOperands (
return_ACPI_STATUS (AE_AML_BAD_OPCODE);
}
-
ArgTypes = OpInfo->RuntimeArgs;
if (ArgTypes == ARGI_INVALID_OPCODE)
{
@@ -232,7 +234,6 @@ AcpiExResolveOperands (
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Opcode %X OperandTypes=%X \n",
Opcode, ArgTypes));
-
/*
* Normal exit is with (ArgTypes == 0) at end of argument list.
* Function will return an exception from within the loop upon
@@ -256,15 +257,18 @@ AcpiExResolveOperands (
/* Decode the descriptor type */
- if (VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_NAMED))
+ switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc))
{
+ case ACPI_DESC_TYPE_NAMED:
+
/* Node */
ObjectType = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type;
- }
+ break;
+
+
+ case ACPI_DESC_TYPE_INTERNAL:
- else if (VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_INTERNAL))
- {
/* ACPI internal object */
ObjectType = ObjDesc->Common.Type;
@@ -290,7 +294,6 @@ AcpiExResolveOperands (
return_ACPI_STATUS (AE_AML_BAD_OPCODE);
}
-
switch (ObjDesc->Reference.Opcode)
{
case AML_ZERO_OP:
@@ -303,28 +306,28 @@ AcpiExResolveOperands (
case AML_LOCAL_OP:
case AML_REVISION_OP:
- DEBUG_ONLY_MEMBERS (ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+ ACPI_DEBUG_ONLY_MEMBERS (ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
"Reference Opcode: %s\n", OpInfo->Name)));
break;
default:
- ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Reference Opcode: Unknown [%02x]\n",
ObjDesc->Reference.Opcode));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
- break;
}
}
- }
+ break;
+
+
+ default:
- else
- {
/* Invalid descriptor */
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Bad descriptor type %X in Obj %p\n",
- ObjDesc->Common.DataType, ObjDesc));
+ ACPI_GET_DESCRIPTOR_TYPE (ObjDesc), ObjDesc));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
@@ -336,25 +339,37 @@ AcpiExResolveOperands (
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_REF_OR_STRING: /* Can be a String or Reference */
- case ARGI_REFERENCE: /* References */
+ if ((ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_INTERNAL) &&
+ (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_STRING))
+ {
+ /*
+ * String found - the string references a named object and must be
+ * resolved to a node
+ */
+ goto NextOperand;
+ }
+
+ /* Else not a string - fall through to the normal Reference case below */
+
+ 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_TARGETREF: /* Allows 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 */
+ 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 */
+ if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_NAMED) /* Node (name) ptr OK as-is */
{
goto NextOperand;
}
@@ -366,7 +381,6 @@ AcpiExResolveOperands (
return_ACPI_STATUS (Status);
}
-
if (AML_NAME_OP == ObjDesc->Reference.Opcode)
{
/*
@@ -377,9 +391,7 @@ AcpiExResolveOperands (
AcpiUtRemoveReference (ObjDesc);
(*StackPtr) = TempNode;
}
-
goto NextOperand;
- break;
case ARGI_ANYTYPE:
@@ -409,7 +421,6 @@ AcpiExResolveOperands (
return_ACPI_STATUS (Status);
}
-
/*
* Check the resulting object (value) type
*/
@@ -476,7 +487,7 @@ AcpiExResolveOperands (
{
if (Status == AE_TYPE)
{
- ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Needed [Integer/String/Buffer], found [%s] %p\n",
AcpiUtGetTypeName ((*StackPtr)->Common.Type), *StackPtr));
@@ -485,9 +496,7 @@ AcpiExResolveOperands (
return_ACPI_STATUS (Status);
}
-
goto NextOperand;
- break;
case ARGI_BUFFER:
@@ -501,7 +510,7 @@ AcpiExResolveOperands (
{
if (Status == AE_TYPE)
{
- ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Needed [Integer/String/Buffer], found [%s] %p\n",
AcpiUtGetTypeName ((*StackPtr)->Common.Type), *StackPtr));
@@ -510,9 +519,7 @@ AcpiExResolveOperands (
return_ACPI_STATUS (Status);
}
-
goto NextOperand;
- break;
case ARGI_STRING:
@@ -526,7 +533,7 @@ AcpiExResolveOperands (
{
if (Status == AE_TYPE)
{
- ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Needed [Integer/String/Buffer], found [%s] %p\n",
AcpiUtGetTypeName ((*StackPtr)->Common.Type), *StackPtr));
@@ -535,87 +542,115 @@ AcpiExResolveOperands (
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))
+ switch ((*StackPtr)->Common.Type)
{
- ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+ case ACPI_TYPE_INTEGER:
+ case ACPI_TYPE_STRING:
+ case ACPI_TYPE_BUFFER:
+
+ /* Valid operand */
+ break;
+
+ default:
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Needed [Integer/String/Buffer], found [%s] %p\n",
AcpiUtGetTypeName ((*StackPtr)->Common.Type), *StackPtr));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
goto NextOperand;
- break;
case ARGI_DATAOBJECT:
/*
* ARGI_DATAOBJECT is only used by the SizeOf operator.
+ * Need a buffer, string, package, or Node reference.
*
- * 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 Node reference to return without
- * error with a size of 4.
- */
-
- /* 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))
- {
- 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 Node.
+ * The only reference allowed here is a direct reference to
+ * a namespace node.
*/
if ((*StackPtr)->Common.Type == INTERNAL_TYPE_REFERENCE)
{
if (!(*StackPtr)->Reference.Node)
{
- ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Needed [Node Reference], found [%p]\n",
*StackPtr));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
+
+ /* Get the object attached to the node */
+
+ TempNode = AcpiNsGetAttachedObject ((*StackPtr)->Reference.Node);
+ if (!TempNode)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Node [%p] has no attached object\n",
+ (*StackPtr)->Reference.Node));
+
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+
+ /*
+ * Swap the reference object with the node's object. Must add
+ * a reference to the node object, and remove a reference from
+ * the original reference object.
+ */
+ AcpiUtAddReference (TempNode);
+ AcpiUtRemoveReference (*StackPtr);
+ (*StackPtr) = TempNode;
+ }
+
+ /* Need a buffer, string, package */
+
+ switch ((*StackPtr)->Common.Type)
+ {
+ case ACPI_TYPE_PACKAGE:
+ case ACPI_TYPE_STRING:
+ case ACPI_TYPE_BUFFER:
+
+ /* Valid operand */
+ break;
+
+ default:
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Needed [Buf/Str/Pkg], found [%s] %p\n",
+ AcpiUtGetTypeName ((*StackPtr)->Common.Type), *StackPtr));
+
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
goto NextOperand;
- break;
case ARGI_COMPLEXOBJ:
/* 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))
+ switch ((*StackPtr)->Common.Type)
{
- ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
- "Needed [Buf/Pkg], found [%s] %p\n",
+ case ACPI_TYPE_PACKAGE:
+ case ACPI_TYPE_STRING:
+ case ACPI_TYPE_BUFFER:
+
+ /* Valid operand */
+ break;
+
+ default:
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Needed [Buf/Str/Pkg], found [%s] %p\n",
AcpiUtGetTypeName ((*StackPtr)->Common.Type), *StackPtr));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
goto NextOperand;
- break;
default:
@@ -629,7 +664,6 @@ AcpiExResolveOperands (
return_ACPI_STATUS (AE_BAD_PARAMETER);
}
-
/*
* Make sure that the original object was resolved to the
* required object type (Simple cases only).
@@ -641,7 +675,6 @@ AcpiExResolveOperands (
return_ACPI_STATUS (Status);
}
-
NextOperand:
/*
* If more operands needed, decrement StackPtr to point
@@ -654,7 +687,6 @@ NextOperand:
} /* while (*Types) */
-
return_ACPI_STATUS (Status);
}
OpenPOWER on IntegriCloud