Skip to content

Commit

Permalink
acpinames: Add new options and wildcard support.
Browse files Browse the repository at this point in the history
- Add wilcard support for input filenames.
- Add -l option to load tables and exit, no display. This is
useful for validation of the namespace during BIOS generation.
- Add -x option for specifying debug level.
  • Loading branch information
acpibob committed Aug 5, 2015
1 parent 614cf18 commit 0ecf5b5
Show file tree
Hide file tree
Showing 8 changed files with 136 additions and 50 deletions.
10 changes: 10 additions & 0 deletions generate/msvc9/AcpiNames.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="setargv.obj"
OutputFile=".\AcpiNamesDebug\AcpiNames.exe"
LinkIncremental="1"
SuppressStartupBanner="true"
Expand Down Expand Up @@ -181,6 +182,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="setargv.obj"
OutputFile=".\AcpiNames\AcpiNames.exe"
LinkIncremental="1"
SuppressStartupBanner="true"
Expand Down Expand Up @@ -1374,6 +1376,10 @@
/>
</FileConfiguration>
</File>
<File
RelativePath="..\..\source\components\dispatcher\dsinit.c"
>
</File>
<File
RelativePath="..\..\source\components\dispatcher\dsmthdat.c"
>
Expand Down Expand Up @@ -1584,6 +1590,10 @@
/>
</FileConfiguration>
</File>
<File
RelativePath="..\..\source\components\executer\exprep.c"
>
</File>
<File
RelativePath="..\..\source\components\executer\exresnte.c"
>
Expand Down
2 changes: 2 additions & 0 deletions generate/unix/acpinames/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ OBJECTS = \
$(OBJDIR)/antables.o\
$(OBJDIR)/cmfsize.o\
$(OBJDIR)/dsfield.o\
$(OBJDIR)/dsinit.o\
$(OBJDIR)/dsmthdat.o\
$(OBJDIR)/dsobject.o\
$(OBJDIR)/dsutils.o\
Expand All @@ -50,6 +51,7 @@ OBJECTS = \
$(OBJDIR)/exdump.o\
$(OBJDIR)/exmutex.o\
$(OBJDIR)/exnames.o\
$(OBJDIR)/exprep.o\
$(OBJDIR)/exresnte.o\
$(OBJDIR)/exresolv.o\
$(OBJDIR)/exsystem.o\
Expand Down
2 changes: 1 addition & 1 deletion source/components/dispatcher/dsinit.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ AcpiDsInitializeObjects (
return_ACPI_STATUS (Status);
}

/* DSDT is always the first table */
/* DSDT is always the first AML table */

if (ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_DSDT))
{
Expand Down
2 changes: 1 addition & 1 deletion source/components/utilities/utmisc.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ AcpiUtIsPciRootBridge (
}


#if (defined ACPI_ASL_COMPILER || defined ACPI_EXEC_APP)
#if (defined ACPI_ASL_COMPILER || defined ACPI_EXEC_APP || defined ACPI_NAMES_APP)
/*******************************************************************************
*
* FUNCTION: AcpiUtIsAmlTable
Expand Down
2 changes: 1 addition & 1 deletion source/include/acutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,7 @@ BOOLEAN
AcpiUtIsPciRootBridge (
char *Id);

#if (defined ACPI_ASL_COMPILER || defined ACPI_EXEC_APP)
#if (defined ACPI_ASL_COMPILER || defined ACPI_EXEC_APP || defined ACPI_NAMES_APP)
BOOLEAN
AcpiUtIsAmlTable (
ACPI_TABLE_HEADER *Table);
Expand Down
2 changes: 2 additions & 0 deletions source/tools/acpinames/acpinames.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,12 @@
#include "acpi.h"
#include "accommon.h"
#include "acapps.h"
#include "acutils.h"
#include "../acpiexec/aecommon.h"

#include <stdio.h>

#define ACPI_MAX_INIT_TABLES (32)

extern BOOLEAN AcpiGbl_NsLoadOnly;
#endif
124 changes: 87 additions & 37 deletions source/tools/acpinames/anmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,31 @@
ACPI_MODULE_NAME ("anmain")


extern ACPI_TABLE_DESC Tables[];
/* Local prototypes */

static int
NsDumpEntireNamespace (
UINT32 TableCount);


/*
* Main routine for the ACPI user-space namespace utility.
*
* Portability note: The utility depends upon the host for command-line
* wildcard support - it is not implemented locally. For example:
*
* Linux/Unix systems: Shell expands wildcards automatically.
*
* Windows: The setargv.obj module must be linked in to automatically
* expand wildcards.
*/
extern ACPI_TABLE_DESC Tables[];
static AE_TABLE_DESC *AeTableListHead = NULL;
BOOLEAN AcpiGbl_NsLoadOnly = FALSE;


#define AN_UTILITY_NAME "ACPI Namespace Dump Utility"
#define AN_SUPPORTED_OPTIONS "?hv"
#define AN_SUPPORTED_OPTIONS "?hlvx:"


/******************************************************************************
Expand All @@ -147,7 +165,9 @@ usage (

ACPI_USAGE_HEADER ("AcpiNames [options] AMLfile");
ACPI_OPTION ("-?", "Display this message");
ACPI_OPTION ("-l", "Load namespace only, no display");
ACPI_OPTION ("-v", "Display version information");
ACPI_OPTION ("-x <DebugLevel>", "Debug output level");
}


Expand All @@ -166,45 +186,12 @@ usage (

static int
NsDumpEntireNamespace (
char *AmlFilename)
UINT32 TableCount)
{
ACPI_STATUS Status;
ACPI_TABLE_HEADER *Table = NULL;
UINT32 TableCount = 0;
AE_TABLE_DESC *TableDesc;
ACPI_HANDLE Handle;


/* Open the binary AML file and read the entire table */

Status = AcpiUtReadTableFromFile (AmlFilename, &Table);
if (ACPI_FAILURE (Status))
{
printf ("**** Could not get input table %s, %s\n", AmlFilename,
AcpiFormatException (Status));
return (-1);
}

/* Table must be a DSDT. SSDTs are not currently supported */

if (!ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_DSDT))
{
printf ("**** Input table signature is [%4.4s], must be [DSDT]\n",
Table->Signature);
return (-1);
}

/*
* Allocate and link a table descriptor (allows for future expansion to
* multiple input files)
*/
TableDesc = AcpiOsAllocate (sizeof (AE_TABLE_DESC));
TableDesc->Table = Table;
TableDesc->Next = AeTableListHead;
AeTableListHead = TableDesc;

TableCount++;

/*
* Build a local XSDT with all tables. Normally, here is where the
* RSDP search is performed to find the ACPI tables
Expand Down Expand Up @@ -245,6 +232,12 @@ NsDumpEntireNamespace (
return (-1);
}

if (AcpiGbl_NsLoadOnly)
{
printf ("**** Namespace successfully loaded\n");
return (0);
}

/*
* Enable ACPICA. These calls don't do much for this
* utility, since we only dump the namespace. There is no
Expand Down Expand Up @@ -308,7 +301,10 @@ main (
int argc,
char **argv)
{
AE_TABLE_DESC *TableDesc;
ACPI_TABLE_HEADER *Table = NULL;
ACPI_STATUS Status;
UINT32 TableCount;
int j;


Expand Down Expand Up @@ -337,10 +333,21 @@ main (

while ((j = AcpiGetopt (argc, argv, AN_SUPPORTED_OPTIONS)) != ACPI_OPT_END) switch(j)
{
case 'l':

AcpiGbl_NsLoadOnly = TRUE;
break;

case 'v': /* -v: (Version): signon already emitted, just exit */

return (0);

case 'x':

AcpiDbgLevel = strtoul (AcpiGbl_Optarg, NULL, 0);
printf ("Debug Level: 0x%8.8X\n", AcpiDbgLevel);
break;

case '?':
case 'h':
default:
Expand All @@ -349,9 +356,52 @@ main (
return (0);
}

TableCount = 0;

/* Get each of the ACPI table files on the command line */

while (argv[AcpiGbl_Optind])
{
/* Get one entire table */

Status = AcpiUtReadTableFromFile (argv[AcpiGbl_Optind], &Table);
if (ACPI_FAILURE (Status))
{
fprintf (stderr, "**** Could not get table from file %s, %s\n",
argv[AcpiGbl_Optind], AcpiFormatException (Status));
return (-1);
}

/* Ignore non-AML tables, we can't use them. Except for an FADT */

if (!ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_FADT) &&
!AcpiUtIsAmlTable (Table))
{
fprintf (stderr, " %s: [%4.4s] is not an AML table - ignoring\n",
argv[AcpiGbl_Optind], Table->Signature);

AcpiOsFree (Table);
}
else
{
/* Allocate and link a table descriptor */

TableDesc = AcpiOsAllocate (sizeof (AE_TABLE_DESC));
TableDesc->Table = Table;
TableDesc->Next = AeTableListHead;
AeTableListHead = TableDesc;

TableCount++;
}

AcpiGbl_Optind++;
}

printf ("\n");

/*
* The next argument is the filename for the DSDT or SSDT.
* Open the file, build namespace and dump it.
*/
return (NsDumpEntireNamespace (argv[AcpiGbl_Optind]));
return (NsDumpEntireNamespace (TableCount));
}
42 changes: 32 additions & 10 deletions source/tools/acpinames/anstubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,14 @@ AcpiUtCopyIobjectToIobject (
return (AE_NOT_IMPLEMENTED);
}

/* Hardware */

UINT32
AcpiHwGetMode (
void)
{
return (0);
}

/* Event manager */

Expand All @@ -182,6 +190,20 @@ AcpiEvInitializeRegion (
return (AE_OK);
}

ACPI_STATUS
AcpiEvInstallXruptHandlers (
void)
{
return (AE_OK);
}

ACPI_STATUS
AcpiEvInitializeEvents (
void)
{
return (AE_OK);
}


/* AML Interpreter */

Expand All @@ -203,13 +225,6 @@ AcpiExWriteDataToField (
return (AE_NOT_IMPLEMENTED);
}

ACPI_STATUS
AcpiExPrepFieldValue (
ACPI_CREATE_FIELD_INFO *Info)
{
return (AE_OK);
}

ACPI_STATUS
AcpiExStoreObjectToNode (
ACPI_OPERAND_OBJECT *SourceDesc,
Expand Down Expand Up @@ -294,9 +309,16 @@ AcpiExTracePoint (
/* Dispatcher */

ACPI_STATUS
AcpiDsInitializeObjects (
UINT32 TableIndex,
ACPI_NAMESPACE_NODE *StartNode)
AcpiDsAutoSerializeMethod (
ACPI_NAMESPACE_NODE *Node,
ACPI_OPERAND_OBJECT *ObjDesc)
{
return (AE_OK);
}

ACPI_STATUS
AcpiDsInitializeRegion (
ACPI_HANDLE ObjHandle)
{
return (AE_OK);
}
Expand Down

0 comments on commit 0ecf5b5

Please sign in to comment.