Skip to content

Commit

Permalink
Fixes for AcpiExec namespace init file
Browse files Browse the repository at this point in the history
This change fixes several problems with the support for the
AcpiExec namespace init file (-fi option). Specifically, it
fixes AE_ALREADY_EXISTS errors, as well as various seg faults.
  • Loading branch information
acpibob committed Mar 25, 2020
1 parent 992c0a6 commit 6803997
Show file tree
Hide file tree
Showing 11 changed files with 252 additions and 117 deletions.
1 change: 1 addition & 0 deletions source/compiler/aslcompile.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ CmDoCompile (

LsDumpParseTree ();

UtEndEvent (Event);
UtEndEvent (FullCompile);
return (AE_OK);

Expand Down
19 changes: 8 additions & 11 deletions source/components/debugger/dbinput.c
Original file line number Diff line number Diff line change
Expand Up @@ -637,19 +637,16 @@ AcpiDbGetNextToken (
return (NULL);
}

/* Remove any spaces at the beginning */
/* Remove any spaces at the beginning, ignore blank lines */

if (*String == ' ')
while (*String && isspace (*String))
{
while (*String && (*String == ' '))
{
String++;
}
String++;
}

if (!(*String))
{
return (NULL);
}
if (!(*String))
{
return (NULL);
}

switch (*String)
Expand Down Expand Up @@ -754,7 +751,7 @@ AcpiDbGetNextToken (

/* Find end of token */

while (*String && (*String != ' '))
while (*String && !isspace (*String))
{
String++;
}
Expand Down
27 changes: 25 additions & 2 deletions source/components/dispatcher/dswexec.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,9 @@
#include "acinterp.h"
#include "acnamesp.h"
#include "acdebug.h"

#ifdef ACPI_EXEC_APP
#include "aecommon.h"
#endif

#define _COMPONENT ACPI_DISPATCHER
ACPI_MODULE_NAME ("dswexec")
Expand Down Expand Up @@ -504,7 +506,10 @@ AcpiDsExecEndOp (
UINT32 OpClass;
ACPI_PARSE_OBJECT *NextOp;
ACPI_PARSE_OBJECT *FirstArg;

#ifdef ACPI_EXEC_APP
char *Namepath;
ACPI_OPERAND_OBJECT *ObjDesc;
#endif

ACPI_FUNCTION_TRACE_PTR (DsExecEndOp, WalkState);

Expand Down Expand Up @@ -717,6 +722,24 @@ AcpiDsExecEndOp (
}

Status = AcpiDsEvalBufferFieldOperands (WalkState, Op);
#ifdef ACPI_EXEC_APP
/*
* AcpiExec support for namespace initialization file (initialize
* BufferFields in this code.)
*/
Namepath = AcpiNsGetExternalPathname (Op->Common.Node);
Status = AeLookupInitFileEntry (Namepath, &ObjDesc);
if (ACPI_SUCCESS (Status))
{
Status = AcpiExWriteDataToField (ObjDesc, Op->Common.Node->Object, NULL);
if ACPI_FAILURE (Status)
{
ACPI_EXCEPTION ((AE_INFO, Status, "While writing to buffer field"));
}
}
ACPI_FREE (Namepath);
Status = AE_OK;
#endif
break;


Expand Down
2 changes: 0 additions & 2 deletions source/components/dispatcher/dswload.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@
#include "acdispat.h"
#include "acinterp.h"
#include "acnamesp.h"

#ifdef ACPI_ASL_COMPILER
#include "acdisasm.h"
#endif
Expand Down Expand Up @@ -555,7 +554,6 @@ AcpiDsLoad1EndOp (
ACPI_PARSE_OBJECT *Op;
ACPI_OBJECT_TYPE ObjectType;
ACPI_STATUS Status = AE_OK;

#ifdef ACPI_ASL_COMPILER
UINT8 ParamCount;
#endif
Expand Down
37 changes: 37 additions & 0 deletions source/components/dispatcher/dswload2.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@
#include "acinterp.h"
#include "acnamesp.h"
#include "acevents.h"
#ifdef ACPI_EXEC_APP
#include "aecommon.h"
#endif

#define _COMPONENT ACPI_DISPATCHER
ACPI_MODULE_NAME ("dswload2")
Expand Down Expand Up @@ -531,6 +534,10 @@ AcpiDsLoad2EndOp (
ACPI_NAMESPACE_NODE *NewNode;
UINT32 i;
UINT8 RegionSpace;
#ifdef ACPI_EXEC_APP
ACPI_OPERAND_OBJECT *ObjDesc;
char *Namepath;
#endif


ACPI_FUNCTION_TRACE (DsLoad2EndOp);
Expand Down Expand Up @@ -627,6 +634,11 @@ AcpiDsLoad2EndOp (
* be evaluated later during the execution phase
*/
Status = AcpiDsCreateBufferField (Op, WalkState);
if ACPI_FAILURE (Status)
{
ACPI_EXCEPTION ((AE_INFO, Status, "CreateBufferField failure"));
goto Cleanup;
}
break;

case AML_TYPE_NAMED_FIELD:
Expand Down Expand Up @@ -766,6 +778,31 @@ AcpiDsLoad2EndOp (
case AML_NAME_OP:

Status = AcpiDsCreateNode (WalkState, Node, Op);
if (ACPI_FAILURE (Status))
{
goto Cleanup;
}

#ifdef ACPI_EXEC_APP
/*
* AcpiExec support for namespace initialization file (initialize
* Name opcodes in this code.)
*/
Namepath = AcpiNsGetExternalPathname (Node);
Status = AeLookupInitFileEntry (Namepath, &ObjDesc);
if (ACPI_SUCCESS (Status))
{
/* Detach any existing object, attach new object */

if (Node->Object)
{
AcpiNsDetachObject (Node);
}
AcpiNsAttachObject (Node, ObjDesc, ObjDesc->Common.Type);
}
ACPI_FREE (Namepath);
Status = AE_OK;
#endif
break;

case AML_METHOD_OP:
Expand Down
8 changes: 1 addition & 7 deletions source/components/namespace/nsnames.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,6 @@
#define _COMPONENT ACPI_NAMESPACE
ACPI_MODULE_NAME ("nsnames")

/* Local Prototypes */

static void
AcpiNsNormalizePathname (
char *OriginalPath);


/*******************************************************************************
*
Expand Down Expand Up @@ -616,7 +610,7 @@ AcpiNsBuildPrefixedPathname (
*
******************************************************************************/

static void
void
AcpiNsNormalizePathname (
char *OriginalPath)
{
Expand Down
9 changes: 5 additions & 4 deletions source/components/utilities/utdelete.c
Original file line number Diff line number Diff line change
Expand Up @@ -626,13 +626,13 @@ AcpiUtUpdateRefCount (
*
* FUNCTION: AcpiUtUpdateObjectReference
*
* PARAMETERS: Object - Increment ref count for this object
* and all sub-objects
* PARAMETERS: Object - Increment or decrement the ref count for
* this object and all sub-objects
* Action - Either REF_INCREMENT or REF_DECREMENT
*
* RETURN: Status
*
* DESCRIPTION: Increment the object reference count
* DESCRIPTION: Increment or decrement the object reference count
*
* Object references are incremented when:
* 1) An object is attached to a Node (namespace object)
Expand Down Expand Up @@ -671,7 +671,7 @@ AcpiUtUpdateObjectReference (
}

/*
* All sub-objects must have their reference count incremented
* All sub-objects must have their reference count updated
* also. Different object types have different subobjects.
*/
switch (Object->Common.Type)
Expand Down Expand Up @@ -740,6 +740,7 @@ AcpiUtUpdateObjectReference (
break;
}
}

NextObject = NULL;
break;

Expand Down
4 changes: 4 additions & 0 deletions source/include/acnamesp.h
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,10 @@ AcpiNsBuildNormalizedPath (
UINT32 PathSize,
BOOLEAN NoTrailing);

void
AcpiNsNormalizePathname (
char *OriginalPath);

char *
AcpiNsGetNormalizedPathname (
ACPI_NAMESPACE_NODE *Node,
Expand Down
20 changes: 15 additions & 5 deletions source/tools/acpiexec/aecommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,9 @@ typedef struct ae_debug_regions
typedef struct init_file_entry
{
char *Name;
char *Value;
ACPI_OPERAND_OBJECT *ObjDesc;
BOOLEAN IsUsed;

} INIT_FILE_ENTRY;

Expand Down Expand Up @@ -346,19 +348,23 @@ int
AeOpenInitializationFile (
char *Filename);

void
ACPI_STATUS
AeProcessInitFile (
void);

ACPI_STATUS
AeSetupConfiguration (
void *RegionAddr);

ACPI_STATUS
AeLookupInitFileEntry (
char *Pathname,
ACPI_OPERAND_OBJECT **ObjDesc);

void
AeDisplayUnusedInitFileItems (
void);

void
AeDeleteInitFileList (
void);

/* aeexec */

void
Expand All @@ -376,6 +382,10 @@ AeGetDevices (
void *Context,
void **ReturnValue);

ACPI_STATUS
AeSetupConfiguration (
void *RegionAddr);

ACPI_STATUS
ExecuteOSI (
char *OsiString,
Expand Down

0 comments on commit 6803997

Please sign in to comment.