summaryrefslogtreecommitdiffstats
path: root/sys/contrib/dev/acpica/psparse.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/contrib/dev/acpica/psparse.c')
-rw-r--r--sys/contrib/dev/acpica/psparse.c150
1 files changed, 83 insertions, 67 deletions
diff --git a/sys/contrib/dev/acpica/psparse.c b/sys/contrib/dev/acpica/psparse.c
index fc68ef4..1d44bd8 100644
--- a/sys/contrib/dev/acpica/psparse.c
+++ b/sys/contrib/dev/acpica/psparse.c
@@ -1,7 +1,7 @@
/******************************************************************************
*
* Module Name: psparse - Parser top level AML parse routines
- * $Revision: 85 $
+ * $Revision: 74 $
*
*****************************************************************************/
@@ -130,9 +130,8 @@
#include "amlcode.h"
#include "acnamesp.h"
#include "acdebug.h"
-#include "acinterp.h"
-#define _COMPONENT ACPI_PARSER
+#define _COMPONENT PARSER
MODULE_NAME ("psparse")
@@ -204,9 +203,9 @@ AcpiPsPeekOpcode (
*
* if (Opcode == AML_EXTOP
* || (Opcode == AML_LNOT
- * && (GET8 (Aml) == AML_LEQUAL
- * || GET8 (Aml) == AML_LGREATER
- * || GET8 (Aml) == AML_LLESS)))
+ * && (GET8 (AcpiAml) == AML_LEQUAL
+ * || GET8 (AcpiAml) == AML_LGREATER
+ * || GET8 (AcpiAml) == AML_LLESS)))
*
* extended Opcode, !=, <=, or >=
*/
@@ -229,8 +228,8 @@ AcpiPsPeekOpcode (
*
* FUNCTION: AcpiPsCreateState
*
- * PARAMETERS: Aml - Aml code pointer
- * AmlSize - Length of AML code
+ * PARAMETERS: AcpiAml - AcpiAml code pointer
+ * AcpiAmlSize - Length of AML code
*
* RETURN: A new parser state object
*
@@ -249,10 +248,10 @@ AcpiPsCreateState (
FUNCTION_TRACE ("PsCreateState");
- ParserState = AcpiUtCallocate (sizeof (ACPI_PARSE_STATE));
+ ParserState = AcpiCmCallocate (sizeof (ACPI_PARSE_STATE));
if (!ParserState)
{
- return_PTR (NULL);
+ return_VALUE (NULL);
}
ParserState->Aml = Aml;
@@ -363,7 +362,7 @@ AcpiPsCompleteThisOp (
(OpcodeClass != OPTYPE_LOCAL_VARIABLE) &&
(OpcodeClass != OPTYPE_METHOD_ARGUMENT) &&
(OpcodeClass != OPTYPE_DATA_TERM) &&
- (Op->Opcode != AML_INT_NAMEPATH_OP))
+ (Op->Opcode != AML_NAMEPATH_OP))
{
/* Make sure that we only delete this subtree */
@@ -388,15 +387,15 @@ AcpiPsCompleteThisOp (
* op must be replace by a placeholder return op
*/
- if ((Op->Parent->Opcode == AML_REGION_OP) ||
- (Op->Parent->Opcode == AML_CREATE_FIELD_OP) ||
- (Op->Parent->Opcode == AML_CREATE_BIT_FIELD_OP) ||
- (Op->Parent->Opcode == AML_CREATE_BYTE_FIELD_OP) ||
- (Op->Parent->Opcode == AML_CREATE_WORD_FIELD_OP) ||
- (Op->Parent->Opcode == AML_CREATE_DWORD_FIELD_OP) ||
- (Op->Parent->Opcode == AML_CREATE_QWORD_FIELD_OP))
+ if ((Op->Parent->Opcode == AML_REGION_OP) ||
+ (Op->Parent->Opcode == AML_CREATE_FIELD_OP) ||
+ (Op->Parent->Opcode == AML_BIT_FIELD_OP) ||
+ (Op->Parent->Opcode == AML_BYTE_FIELD_OP) ||
+ (Op->Parent->Opcode == AML_WORD_FIELD_OP) ||
+ (Op->Parent->Opcode == AML_DWORD_FIELD_OP) ||
+ (Op->Parent->Opcode == AML_QWORD_FIELD_OP))
{
- ReplacementOp = AcpiPsAllocOp (AML_INT_RETURN_VALUE_OP);
+ ReplacementOp = AcpiPsAllocOp (AML_RETURN_VALUE_OP);
if (!ReplacementOp)
{
return_VALUE (FALSE);
@@ -406,7 +405,7 @@ AcpiPsCompleteThisOp (
break;
default:
- ReplacementOp = AcpiPsAllocOp (AML_INT_RETURN_VALUE_OP);
+ ReplacementOp = AcpiPsAllocOp (AML_RETURN_VALUE_OP);
if (!ReplacementOp)
{
return_VALUE (FALSE);
@@ -622,7 +621,7 @@ AcpiPsParseLoop (
ACPI_PARSE2_OBJECT *DeferredOp;
UINT32 ArgCount; /* push for fixed or var args */
UINT32 ArgTypes = 0;
- UINT32 AmlOffset;
+ ACPI_PTRDIFF AmlOffset;
UINT16 Opcode;
ACPI_PARSE_OBJECT PreOp;
ACPI_PARSE_STATE *ParserState;
@@ -664,13 +663,14 @@ AcpiPsParseLoop (
{
if (Status == AE_AML_NO_RETURN_VALUE)
{
- DEBUG_PRINTP (ACPI_ERROR,
- ("Invoked method did not return a value, %s\n",
- AcpiUtFormatException (Status)));
+ DEBUG_PRINT (ACPI_ERROR,
+ ("PsParseLoop: Invoked method did not return a value, %s\n",
+ AcpiCmFormatException (Status)));
}
- DEBUG_PRINTP (ACPI_ERROR, ("GetPredicate Failed, %s\n",
- AcpiUtFormatException (Status)));
+ DEBUG_PRINT (ACPI_ERROR,
+ ("PsParseLoop: GetPredicate Failed, %s\n",
+ AcpiCmFormatException (Status)));
return_ACPI_STATUS (Status);
}
@@ -678,7 +678,7 @@ AcpiPsParseLoop (
}
AcpiPsPopScope (ParserState, &Op, &ArgTypes, &ArgCount);
- DEBUG_PRINTP (TRACE_PARSE, ("Popped scope, Op=%p\n", Op));
+ DEBUG_PRINT (TRACE_PARSE, ("ParseLoop: Popped scope, Op=%p\n", Op));
}
else if (WalkState->PrevOp)
@@ -729,7 +729,7 @@ AcpiPsParseLoop (
* string. Convert the bare name string to a namepath.
*/
- Opcode = AML_INT_NAMEPATH_OP;
+ Opcode = AML_NAMEPATH_OP;
ArgTypes = ARGP_NAMESTRING;
break;
@@ -737,8 +737,8 @@ AcpiPsParseLoop (
/* The opcode is unrecognized. Just skip unknown opcodes */
- DEBUG_PRINTP (ACPI_ERROR,
- ("Found unknown opcode %lX at AML offset %X, ignoring\n",
+ DEBUG_PRINT (ACPI_ERROR,
+ ("ParseLoop: Found unknown opcode %lX at AML offset %X, ignoring\n",
Opcode, AmlOffset));
DUMP_BUFFER (ParserState->Aml, 128);
@@ -835,12 +835,11 @@ AcpiPsParseLoop (
}
- if ((Op->Opcode == AML_CREATE_FIELD_OP) ||
- (Op->Opcode == AML_CREATE_BIT_FIELD_OP) ||
- (Op->Opcode == AML_CREATE_BYTE_FIELD_OP) ||
- (Op->Opcode == AML_CREATE_WORD_FIELD_OP) ||
- (Op->Opcode == AML_CREATE_DWORD_FIELD_OP) ||
- (Op->Opcode == AML_CREATE_QWORD_FIELD_OP))
+ if ((Op->Opcode == AML_CREATE_FIELD_OP) ||
+ (Op->Opcode == AML_BIT_FIELD_OP) ||
+ (Op->Opcode == AML_BYTE_FIELD_OP) ||
+ (Op->Opcode == AML_WORD_FIELD_OP) ||
+ (Op->Opcode == AML_DWORD_FIELD_OP))
{
/*
* Backup to beginning of CreateXXXfield declaration
@@ -879,8 +878,8 @@ AcpiPsParseLoop (
if (OpInfo)
{
- DEBUG_PRINTP (TRACE_PARSE,
- ("Op=%p Opcode=%4.4lX Aml %p Oft=%5.5lX\n",
+ DEBUG_PRINT (TRACE_PARSE,
+ ("ParseLoop: Op=%p Opcode=%4.4lX Aml %p Oft=%5.5lX\n",
Op, Op->Opcode, ParserState->Aml, Op->AmlOffset));
}
}
@@ -908,7 +907,7 @@ AcpiPsParseLoop (
GET_CURRENT_ARG_TYPE (ArgTypes), Op);
break;
- case AML_INT_NAMEPATH_OP: /* AML_NAMESTRING_ARG */
+ case AML_NAMEPATH_OP: /* AML_NAMESTRING_ARG */
AcpiPsGetNextNamepath (ParserState, Op, &ArgCount, 1);
ArgTypes = 0;
@@ -949,8 +948,8 @@ AcpiPsParseLoop (
*/
DeferredOp->Data = ParserState->Aml;
- DeferredOp->Length = (UINT32) (ParserState->PkgEnd -
- ParserState->Aml);
+ DeferredOp->Length = ParserState->PkgEnd -
+ ParserState->Aml;
/*
* Skip body of method. For OpRegions, we must continue
@@ -995,18 +994,18 @@ AcpiPsParseLoop (
* know the length.
*/
- DeferredOp->Length = (UINT32) (ParserState->Aml -
- DeferredOp->Data);
+ DeferredOp->Length = ParserState->Aml -
+ DeferredOp->Data;
}
}
}
- if ((Op->Opcode == AML_CREATE_FIELD_OP) ||
- (Op->Opcode == AML_CREATE_BIT_FIELD_OP) ||
- (Op->Opcode == AML_CREATE_BYTE_FIELD_OP) ||
- (Op->Opcode == AML_CREATE_WORD_FIELD_OP) ||
- (Op->Opcode == AML_CREATE_DWORD_FIELD_OP) ||
- (Op->Opcode == AML_CREATE_QWORD_FIELD_OP))
+ if ((Op->Opcode == AML_CREATE_FIELD_OP) ||
+ (Op->Opcode == AML_BIT_FIELD_OP) ||
+ (Op->Opcode == AML_BYTE_FIELD_OP) ||
+ (Op->Opcode == AML_WORD_FIELD_OP) ||
+ (Op->Opcode == AML_DWORD_FIELD_OP) ||
+ (Op->Opcode == AML_QWORD_FIELD_OP))
{
/*
* Backup to beginning of CreateXXXfield declaration (1 for
@@ -1015,8 +1014,7 @@ AcpiPsParseLoop (
* BodyLength is unknown until we parse the body
*/
DeferredOp = (ACPI_PARSE2_OBJECT *) Op;
- DeferredOp->Length = (UINT32) (ParserState->Aml -
- DeferredOp->Data);
+ DeferredOp->Length = ParserState->Aml - DeferredOp->Data;
}
/* This op complete, notify the dispatcher */
@@ -1120,7 +1118,7 @@ CloseThisOp:
if (AcpiPsHasCompletedScope (ParserState))
{
AcpiPsPopScope (ParserState, &Op, &ArgTypes, &ArgCount);
- DEBUG_PRINTP (TRACE_PARSE, ("Popped scope, Op=%p\n", Op));
+ DEBUG_PRINT (TRACE_PARSE, ("ParseLoop: Popped scope, Op=%p\n", Op));
}
else
@@ -1151,7 +1149,7 @@ CloseThisOp:
* sequential closing braces). We want to terminate each one cleanly.
*/
- DEBUG_PRINTP (TRACE_PARSE, ("Package complete at Op %p\n", Op));
+ DEBUG_PRINT (TRACE_PARSE, ("PsParseLoop: Package complete at Op %p\n", Op));
do
{
if (Op)
@@ -1237,12 +1235,14 @@ AcpiPsParseAml (
ACPI_NAMESPACE_NODE *Node = NULL;
ACPI_WALK_LIST *PrevWalkList = AcpiGbl_CurrentWalkList;
ACPI_OPERAND_OBJECT *ReturnDesc;
+ ACPI_OPERAND_OBJECT *EffectiveReturnDesc = NULL;
ACPI_OPERAND_OBJECT *MthDesc = NULL;
FUNCTION_TRACE ("PsParseAml");
- DEBUG_PRINTP (TRACE_PARSE, ("Entered with Scope=%p Aml=%p size=%lX\n",
+ DEBUG_PRINT (TRACE_PARSE,
+ ("PsParseAml: Entered with Scope=%p Aml=%p size=%lX\n",
StartScope, Aml, AmlSize));
@@ -1264,11 +1264,8 @@ AcpiPsParseAml (
/* Create and initialize a new walk list */
WalkList.WalkState = NULL;
- WalkList.AcquiredMutexList.Prev = NULL;
- WalkList.AcquiredMutexList.Next = NULL;
- WalkState = AcpiDsCreateWalkState (TABLE_ID_DSDT, ParserState->StartOp,
- MthDesc, &WalkList);
+ WalkState = AcpiDsCreateWalkState (TABLE_ID_DSDT, ParserState->StartOp, MthDesc, &WalkList);
if (!WalkState)
{
Status = AE_NO_MEMORY;
@@ -1334,7 +1331,8 @@ AcpiPsParseAml (
* handles nested control method invocations without recursion.
*/
- DEBUG_PRINTP (TRACE_PARSE, ("State=%p\n", WalkState));
+ DEBUG_PRINT (TRACE_PARSE, ("PsParseAml: State=%p\n",
+ WalkState));
while (WalkState)
{
@@ -1343,8 +1341,9 @@ AcpiPsParseAml (
Status = AcpiPsParseLoop (WalkState);
}
- DEBUG_PRINTP (TRACE_PARSE,
- ("Completed one call to walk loop, State=%p\n", WalkState));
+ DEBUG_PRINT (TRACE_PARSE,
+ ("PsParseAml: Completed one call to walk loop, State=%p\n",
+ WalkState));
if (Status == AE_CTRL_TRANSFER)
{
@@ -1378,7 +1377,16 @@ AcpiPsParseAml (
ReturnDesc = WalkState->ReturnDesc;
- DEBUG_PRINTP (TRACE_PARSE, ("ReturnValue=%p, State=%p\n",
+ /* Save the last effective return value */
+
+ if (CallerReturnDesc && ReturnDesc)
+ {
+ EffectiveReturnDesc = ReturnDesc;
+ AcpiCmAddReference (EffectiveReturnDesc);
+ }
+
+ DEBUG_PRINT (TRACE_PARSE,
+ ("PsParseAml: ReturnValue=%p, State=%p\n",
WalkState->ReturnDesc, WalkState));
/* Reset the current scope to the beginning of scope stack */
@@ -1398,7 +1406,7 @@ AcpiPsParseAml (
/* Delete this walk state and all linked control states */
AcpiPsCleanupScope (WalkState->ParserState);
- AcpiUtFree (WalkState->ParserState);
+ AcpiCmFree (WalkState->ParserState);
AcpiDsDeleteWalkState (WalkState);
/* Check if we have restarted a preempted walk */
@@ -1425,6 +1433,16 @@ AcpiPsParseAml (
else if (CallerReturnDesc)
{
+ /*
+ * Some AML code expects return value w/o ReturnOp.
+ * Return the saved effective return value instead.
+ */
+
+ if (ReturnDesc == NULL && EffectiveReturnDesc != NULL)
+ {
+ AcpiCmRemoveReference (ReturnDesc);
+ ReturnDesc = EffectiveReturnDesc;
+ }
*CallerReturnDesc = ReturnDesc; /* NULL if no return value */
}
@@ -1432,14 +1450,13 @@ AcpiPsParseAml (
{
/* Caller doesn't want it, must delete it */
- AcpiUtRemoveReference (ReturnDesc);
+ AcpiCmRemoveReference (ReturnDesc);
}
}
/* Normal exit */
- AcpiExReleaseAllMutexes ((ACPI_OPERAND_OBJECT *) &WalkList.AcquiredMutexList);
AcpiGbl_CurrentWalkList = PrevWalkList;
return_ACPI_STATUS (Status);
@@ -1450,9 +1467,8 @@ Cleanup:
AcpiDsDeleteWalkState (WalkState);
AcpiPsCleanupScope (ParserState);
- AcpiUtFree (ParserState);
+ AcpiCmFree (ParserState);
- AcpiExReleaseAllMutexes ((ACPI_OPERAND_OBJECT *)&WalkList.AcquiredMutexList);
AcpiGbl_CurrentWalkList = PrevWalkList;
return_ACPI_STATUS (Status);
OpenPOWER on IntegriCloud