Skip to content
Permalink
Browse files
Integrate package handling with module-level code
This change completes the integration of the recent changes to
package object handling with the module-level code support.

For AcpiExec, the -ep flag is removed.
  • Loading branch information
acpibob committed Feb 7, 2018
1 parent cfa92ca commit 8faf6fca445eb7219963d80543fb802302a7a8c7
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 70 deletions.
@@ -155,6 +155,7 @@
#include "amlcode.h"
#include "acdispat.h"
#include "acinterp.h"
#include "acparser.h"


#define _COMPONENT ACPI_NAMESPACE
@@ -208,6 +209,7 @@ AcpiDsBuildInternalPackageObj (
ACPI_PARSE_OBJECT *Parent;
ACPI_OPERAND_OBJECT *ObjDesc = NULL;
ACPI_STATUS Status = AE_OK;
BOOLEAN ModuleLevelCode = FALSE;
UINT16 ReferenceCount;
UINT32 Index;
UINT32 i;
@@ -216,6 +218,13 @@ AcpiDsBuildInternalPackageObj (
ACPI_FUNCTION_TRACE (DsBuildInternalPackageObj);


/* Check if we are executing module level code */

if (WalkState->ParseFlags & ACPI_PARSE_MODULE_LEVEL)
{
ModuleLevelCode = TRUE;
}

/* Find the parent of a possibly nested package */

Parent = Op->Common.Parent;
@@ -250,25 +259,43 @@ AcpiDsBuildInternalPackageObj (

/*
* Allocate the element array (array of pointers to the individual
* objects) based on the NumElements parameter. Add an extra pointer slot
* so that the list is always null terminated.
* objects) if necessary. the count is based on the NumElements
* parameter. Add an extra pointer slot so that the list is always
* null terminated.
*/
ObjDesc->Package.Elements = ACPI_ALLOCATE_ZEROED (
((ACPI_SIZE) ElementCount + 1) * sizeof (void *));

if (!ObjDesc->Package.Elements)
{
AcpiUtDeleteObjectDesc (ObjDesc);
return_ACPI_STATUS (AE_NO_MEMORY);
ObjDesc->Package.Elements = ACPI_ALLOCATE_ZEROED (
((ACPI_SIZE) ElementCount + 1) * sizeof (void *));

if (!ObjDesc->Package.Elements)
{
AcpiUtDeleteObjectDesc (ObjDesc);
return_ACPI_STATUS (AE_NO_MEMORY);
}

ObjDesc->Package.Count = ElementCount;
}

ObjDesc->Package.Count = ElementCount;
/* First arg is element count. Second arg begins the initializer list */

Arg = Op->Common.Value.Arg;
Arg = Arg->Common.Next;

if (Arg)
/*
* If we are executing module-level code, we will defer the
* full resolution of the package elements in order to support
* forward references from the elements. This provides
* compatibility with other ACPI implementations.
*/
if (ModuleLevelCode)
{
ObjDesc->Package.Flags |= AOPOBJ_DATA_VALID;
ObjDesc->Package.AmlStart = WalkState->Aml;
ObjDesc->Package.AmlLength = 0;

ACPI_DEBUG_PRINT_RAW ((ACPI_DB_PARSE,
"%s: Deferring resolution of Package elements\n",
ACPI_GET_FUNCTION_NAME));
}

/*
@@ -308,12 +335,17 @@ AcpiDsBuildInternalPackageObj (
ACPI_ERROR ((AE_INFO, "%-48s", "****DS namepath not found"));
}

/*
* Initialize this package element. This function handles the
* resolution of named references within the package.
*/
AcpiDsInitPackageElement (0, ObjDesc->Package.Elements[i],
NULL, &ObjDesc->Package.Elements[i]);
if (!ModuleLevelCode)
{
/*
* Initialize this package element. This function handles the
* resolution of named references within the package.
* Forward references from module-level code are deferred
* until all ACPI tables are loaded.
*/
AcpiDsInitPackageElement (0, ObjDesc->Package.Elements[i],
NULL, &ObjDesc->Package.Elements[i]);
}
}

if (*ObjDescPtr)
@@ -383,15 +415,21 @@ AcpiDsBuildInternalPackageObj (
* NumElements count.
*
* Note: this is not an error, the package is padded out
* with NULLs.
* with NULLs as per the ACPI specification.
*/
ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
"Package List length (%u) smaller than NumElements "
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO,
"%s: Package List length (%u) smaller than NumElements "
"count (%u), padded with null elements\n",
i, ElementCount));
ACPI_GET_FUNCTION_NAME, i, ElementCount));
}

/* Module-level packages will be resolved later */

if (!ModuleLevelCode)
{
ObjDesc->Package.Flags |= AOPOBJ_DATA_VALID;
}

ObjDesc->Package.Flags |= AOPOBJ_DATA_VALID;
Op->Common.Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjDesc);
return_ACPI_STATUS (Status);
}
@@ -496,6 +534,10 @@ AcpiDsResolvePackageElement (

if (Element->Reference.Resolved)
{
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_PARSE,
"%s: Package element is already resolved\n",
ACPI_GET_FUNCTION_NAME));

return_VOID;
}

@@ -511,13 +553,16 @@ AcpiDsResolvePackageElement (
if (ACPI_FAILURE (Status))
{
Status = AcpiNsExternalizeName (ACPI_UINT32_MAX,
(char *) Element->Reference.Aml,
NULL, &ExternalPath);
(char *) Element->Reference.Aml, NULL, &ExternalPath);

ACPI_EXCEPTION ((AE_INFO, Status,
"Could not find/resolve named package element: %s", ExternalPath));
"Could not find/resolve named package element: %s",
ExternalPath));

/* Not found, set the element to NULL */

ACPI_FREE (ExternalPath);
AcpiUtRemoveReference (*ElementPtr);
*ElementPtr = NULL;
return_VOID;
}
@@ -531,24 +576,6 @@ AcpiDsResolvePackageElement (
*ElementPtr = NULL;
return_VOID;
}
#if 0
else if (ResolvedNode->Flags & ANOBJ_TEMPORARY)
{
/*
* A temporary node found here indicates that the reference is
* to a node that was created within this method. We are not
* going to allow it (especially if the package is returned
* from the method) -- the temporary node will be deleted out
* from under the method. (05/2017).
*/
ACPI_ERROR ((AE_INFO,
"Package element refers to a temporary name [%4.4s], "
"inserting a NULL element",
ResolvedNode->Name.Ascii));
*ElementPtr = NULL;
return_VOID;
}
#endif

/*
* Special handling for Alias objects. We need ResolvedNode to point
@@ -587,22 +614,6 @@ AcpiDsResolvePackageElement (
return_VOID;
}

#if 0
/* TBD - alias support */
/*
* Special handling for Alias objects. We need to setup the type
* and the Op->Common.Node to point to the Alias target. Note,
* Alias has at most one level of indirection internally.
*/
Type = Op->Common.Node->Type;
if (Type == ACPI_TYPE_LOCAL_ALIAS)
{
Type = ObjDesc->Common.Type;
Op->Common.Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE,
Op->Common.Node->Object);
}
#endif

switch (Type)
{
/*
@@ -723,8 +723,8 @@ AcpiDsExecEndOp (
case AML_TYPE_CREATE_OBJECT:

ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
"Executing CreateObject (Buffer/Package) Op=%p AMLPtr=%p\n",
Op, Op->Named.Data));
"Executing CreateObject (Buffer/Package) Op=%p Child=%p ParentOpcode=%4.4X\n",
Op, Op->Named.Value.Arg, Op->Common.Parent->Common.AmlOpcode));

switch (Op->Common.Parent->Common.AmlOpcode)
{
@@ -405,7 +405,8 @@ AcpiNsParseTable (

if (AcpiGbl_ParseTableAsTermList)
{
ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "**** Start table execution pass\n"));
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_PARSE,
"%s: **** Start table execution pass\n", ACPI_GET_FUNCTION_NAME));

Status = AcpiNsExecuteTable (TableIndex, StartNode);
if (ACPI_FAILURE (Status))
@@ -438,6 +438,7 @@ AcpiPsGetChild (

case AML_BUFFER_OP:
case AML_PACKAGE_OP:
case AML_VARIABLE_PACKAGE_OP:
case AML_METHOD_OP:
case AML_IF_OP:
case AML_WHILE_OP:
@@ -302,15 +302,19 @@ ACPI_INIT_GLOBAL (UINT8, AcpiGbl_DoNotUseXsdt, FALSE);

/*
* Optionally support group module level code.
* NOTE, this is essentially obsolete and will be removed soon
* (01/2018).
*/
ACPI_INIT_GLOBAL (UINT8, AcpiGbl_GroupModuleLevelCode, FALSE);

/*
* Optionally support module level code by parsing the entire table as
* a TermList. Default is FALSE, do not execute entire table until some
* lock order issues are fixed.
* NOTE, this is essentially obsolete and will be removed soon
* (01/2018).
*/
ACPI_INIT_GLOBAL (UINT8, AcpiGbl_ParseTableAsTermList, FALSE);
ACPI_INIT_GLOBAL (UINT8, AcpiGbl_ParseTableAsTermList, TRUE);

/*
* Optionally use 32-bit FADT addresses if and when there is a conflict
@@ -250,6 +250,7 @@ usage (
ACPI_OPTION ("-da", "Disable method abort on error");
ACPI_OPTION ("-di", "Disable execution of STA/INI methods during init");
ACPI_OPTION ("-do", "Disable Operation Region address simulation");
ACPI_OPTION ("-dp", "Disable TermList parsing for scope objects");
ACPI_OPTION ("-dr", "Disable repair of method return values");
ACPI_OPTION ("-ds", "Disable method auto-serialization");
ACPI_OPTION ("-dt", "Disable allocation tracking (performance)");
@@ -259,8 +260,7 @@ usage (
ACPI_OPTION ("-ef", "Enable display of final memory statistics");
ACPI_OPTION ("-ei", "Enable additional tests for ACPICA interfaces");
ACPI_OPTION ("-el", "Enable loading of additional test tables");
ACPI_OPTION ("-em", "Enable grouping of module-level code");
ACPI_OPTION ("-ep", "Enable TermList parsing for scope objects");
ACPI_OPTION ("-em", "Enable (legacy) grouping of module-level code");
ACPI_OPTION ("-es", "Enable Interpreter Slack Mode");
ACPI_OPTION ("-et", "Enable debug semaphore timeout");
printf ("\n");
@@ -340,6 +340,11 @@ AeDoOptions (
AcpiGbl_DbOpt_NoRegionSupport = TRUE;
break;

case 'p':

AcpiGbl_ParseTableAsTermList = FALSE;
break;

case 'r':

AcpiGbl_DisableAutoRepair = TRUE;
@@ -395,11 +400,6 @@ AeDoOptions (
AcpiGbl_GroupModuleLevelCode = TRUE;
break;

case 'p':

AcpiGbl_ParseTableAsTermList = TRUE;
break;

case 's':

AcpiGbl_EnableInterpreterSlack = TRUE;
@@ -172,7 +172,7 @@ run_test_case()
AML_DONT_EXIST=$[ $AML_DONT_EXIST + 1 ]
TEST_RET=1
else
options="-ef -ep -el -to 60"
options="-ef -el -to 60"
method=MN00

if [ "$DO_MEMSTAT" == "yes" ]; then

0 comments on commit 8faf6fc

Please sign in to comment.