Standalone disassembler now uses namespace mgr for symbol table

date	2002.07.23.20.30.00;	author rmoore1;	state Exp;
This commit is contained in:
aystarik 2005-06-29 15:38:53 +00:00
parent 54e0380bbd
commit d41eb9e2d3
3 changed files with 160 additions and 358 deletions

View File

@ -183,6 +183,41 @@ AcpiDsMethodDataInitArgs (
#define FILE_SUFFIX_DISASSEMBLY "dsl"
/*******************************************************************************
*
* FUNCTION: AdInitialize
*
* PARAMETERS: None.
*
* RETURN: Status
*
* DESCRIPTION: CA initialization
*
******************************************************************************/
ACPI_STATUS
AdInitialize (
void)
{
ACPI_STATUS Status;
/* ACPI CA subsystem initialization */
AcpiUtInitGlobals ();
Status = AcpiUtMutexInitialize ();
if (ACPI_FAILURE (Status))
{
return Status;
}
Status = AcpiNsRootInitialize ();
return Status;
}
/*******************************************************************************
*
* FUNCTION: FlGenerateFilename
@ -248,11 +283,12 @@ FlGenerateFilename (
ACPI_STATUS
AdAmlDisassemble (
char *Filename)
BOOLEAN OutToFile,
char *Filename)
{
ACPI_STATUS Status;
char *OutFilename;
FILE *File;
ACPI_STATUS Status;
char *OutFilename = NULL;
FILE *File;
@ -279,20 +315,23 @@ AdAmlDisassemble (
}
/* Create/Open a combined source output file */
OutFilename = FlGenerateFilename (Filename, FILE_SUFFIX_DISASSEMBLY);
if (!OutFilename)
if (OutToFile)
{
fprintf (stderr, "Could not generate output filename\n");
}
File = fopen (OutFilename, "w+");
if (!File)
{
fprintf (stderr, "Could not open output filen\n");
}
/* Create/Open a combined source output file */
AcpiOsRedirectOutput (File);
OutFilename = FlGenerateFilename (Filename, FILE_SUFFIX_DISASSEMBLY);
if (!OutFilename)
{
fprintf (stderr, "Could not generate output filename\n");
}
File = fopen (OutFilename, "w+");
if (!File)
{
fprintf (stderr, "Could not open output filen\n");
}
AcpiOsRedirectOutput (File);
}
/* Always parse the tables, only option is what to display */
@ -471,7 +510,7 @@ AdDoDeferredParse (
ACPI_PARSE_OBJECT *ExtraOp;
ACPI_FUNCTION_NAME ("AdDoDeferredParse");
ACPI_FUNCTION_TRACE ("AdDoDeferredParse");
fprintf (stderr, ".");
@ -499,6 +538,7 @@ AdDoDeferredParse (
/* Parse the method */
WalkState->ParseFlags &= ~ACPI_PARSE_DELETE_TREE;
Status = AcpiPsParseAml (WalkState);
/*
@ -595,7 +635,6 @@ AdSecondPassParse (
continue;
}
switch (Op->Common.AmlOpcode)
{
case AML_METHOD_OP:
@ -626,7 +665,6 @@ AdSecondPassParse (
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unhandled deferred opcode [%s]\n",
Op->Common.AmlOpName));
break;
}
Op = AcpiPsGetDepthNext (Root, Op);
@ -698,21 +736,6 @@ AdGetTables (
return Status;
}
ACPI_STATUS
AcpiDsInitCallbacks (
ACPI_WALK_STATE *WalkState,
UINT32 PassNumber)
{
WalkState->ParseFlags = 0;
WalkState->DescendingCallback = AcpiPsFindObject;
WalkState->AscendingCallback = NULL;
return (AE_OK);
}
/******************************************************************************
*
* FUNCTION: AdParseTable
@ -730,6 +753,7 @@ AdParseTables (void)
{
ACPI_STATUS Status = AE_OK;
ACPI_WALK_STATE *WalkState;
ACPI_TABLE_DESC TableDesc;
if (!AcpiGbl_DSDT)
@ -737,22 +761,23 @@ AdParseTables (void)
return AE_NOT_EXIST;
}
/* Pass 1: Parse everything except control method bodies */
fprintf (stderr, "Pass 1 parse\n");
DsdtLength = AcpiGbl_DSDT->Length;
AmlLength = DsdtLength - sizeof (ACPI_TABLE_HEADER);
AmlStart = ((UINT8 *) AcpiGbl_DSDT + sizeof (ACPI_TABLE_HEADER));
/* Create the root object */
AcpiGbl_ParsedNamespaceRoot = AcpiPsAllocOp (AML_SCOPE_OP);
AcpiGbl_ParsedNamespaceRoot = AcpiPsCreateScopeOp ();
if (!AcpiGbl_ParsedNamespaceRoot)
{
return AE_NO_MEMORY;
}
/* Initialize the root object */
AcpiGbl_ParsedNamespaceRoot->Named.Name = ACPI_ROOT_NAME;
/* Pass 1: Parse everything except control method bodies */
fprintf (stderr, "Pass 1 parse\n");
/* Create and initialize a new walk state */
WalkState = AcpiDsCreateWalkState (TABLE_ID_DSDT,
@ -762,10 +787,6 @@ AdParseTables (void)
return (AE_NO_MEMORY);
}
DsdtLength = AcpiGbl_DSDT->Length;
AmlLength = DsdtLength - sizeof (ACPI_TABLE_HEADER);
AmlStart = ((UINT8 *) AcpiGbl_DSDT + sizeof (ACPI_TABLE_HEADER));
Status = AcpiDsInitAmlWalk (WalkState, AcpiGbl_ParsedNamespaceRoot, NULL, AmlStart,
AmlLength, NULL, NULL, 1);
if (ACPI_FAILURE (Status))
@ -773,20 +794,32 @@ AdParseTables (void)
return (Status);
}
WalkState->ParseFlags &= ~ACPI_PARSE_DELETE_TREE;
Status = AcpiPsParseAml (WalkState);
if (ACPI_FAILURE (Status))
{
return Status;
}
/* Pass 2: Parse control methods and link their parse trees into the main parse tree */
/* Second pass */
TableDesc.AmlStart = AmlStart;
TableDesc.AmlLength = AmlLength;
fprintf (stderr, "Pass 2 parse\n");
Status = AcpiNsOneCompleteParse (2, &TableDesc);
if (ACPI_FAILURE (Status))
{
return (Status);
}
/* Pass 3: Parse control methods and link their parse trees into the main parse tree */
Status = AdSecondPassParse (AcpiGbl_ParsedNamespaceRoot);
fprintf (stderr, "Parsing completed\n");
return Status;
return AE_OK;
}

View File

@ -2,7 +2,7 @@
/******************************************************************************
*
* Module Name: aslcompile - top level compile module
* $Revision: 1.48 $
* $Revision: 1.57 $
*
*****************************************************************************/
@ -118,56 +118,11 @@
#include <stdio.h>
#include "aslcompiler.h"
#include "acnamesp.h"
#include "acdebug.h"
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslcompile")
/*
* Stubs to simplify linkage to the
* ACPI Namespace Manager (Unused functions).
* TBD: These functions should be split out so
* that these stubs are no longer needed.
*/
void
AcpiExUnlinkMutex (
ACPI_OPERAND_OBJECT *ObjDesc)
{
}
void
AcpiTbDeleteAcpiTables (void)
{
}
ACPI_STATUS
AeLocalGetRootPointer (
UINT32 Flags,
ACPI_PHYSICAL_ADDRESS *RsdpPhysicalAddress)
{
return AE_ERROR;
}
void
AcpiExDumpOperands (
ACPI_OPERAND_OBJECT **Operands,
ACPI_INTERPRETER_MODE InterpreterMode,
NATIVE_CHAR *Ident,
UINT32 NumLevels,
NATIVE_CHAR *Note,
NATIVE_CHAR *ModuleName,
UINT32 LineNumber)
{
}
ACPI_STATUS
AcpiExDumpOperand (
ACPI_OPERAND_OBJECT *EntryDesc)
{
return AE_OK;
}
/*******************************************************************************
*
@ -215,12 +170,16 @@ AslCompilerSignon (
Prefix = " * ";
break;
default:
/* No other output types supported */
break;
}
/* Compiler signon with copyright */
FlPrintFile (FileId,
"%s\n%s%s %s [%s]\n%sIncludes ACPI CA Subsystem version %X\n%s%s\n%sSupports ACPI Specification Revision 2.0\n%s\n",
"%s\n%s%s %s [%s]\n%sIncludes ACPI CA Subsystem version %X\n%s%s\n%sSupports ACPI Specification Revision 2.0a\n%s\n",
Prefix,
Prefix, CompilerId, CompilerVersion, __DATE__,
Prefix, ACPI_CA_VERSION,
@ -277,17 +236,32 @@ AslCompilerFileHeader (
Prefix = " * ";
break;
default:
/* No other output types supported */
break;
}
/* Compilation header with timestamp */
time (&Aclock);
(void) time (&Aclock);
NewTime = localtime (&Aclock);
FlPrintFile (FileId,
"%sCompilation of \"%s\" - %s%s\n",
Prefix, Gbl_Files[ASL_FILE_INPUT].Filename, asctime (NewTime),
Prefix);
switch (FileId)
{
case ASL_FILE_C_SOURCE_OUTPUT:
FlPrintFile (FileId, " */\n");
break;
default:
/* Nothing to do for other output types */
break;
}
}
@ -329,11 +303,6 @@ CmDoCompile (void)
return -1;
}
/* ACPI CA subsystem initialization */
AcpiUtInitGlobals ();
AcpiUtMutexInitialize ();
AcpiNsRootInitialize ();
UtEndEvent (i++);
/* Build the parse tree */
@ -342,6 +311,8 @@ CmDoCompile (void)
AslCompilerparse();
UtEndEvent (i++);
OpcGetIntegerWidth (RootNode);
/* Pre-process parse tree for any operator transforms */
UtBeginEvent (i, "Generate AML opcodes");
@ -354,6 +325,13 @@ CmDoCompile (void)
TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, NULL, OpcAmlOpcodeWalk, NULL);
UtEndEvent (i++);
/* Interpret and generate all compile-time constants */
UtBeginEvent (i, "Constant folding via AML interpreter");
DbgPrint (ASL_DEBUG_OUTPUT, "\nInterpreting compile-time constant expressions\n\n");
TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, OpcAmlConstantWalk, NULL, NULL);
UtEndEvent (i++);
/* Calculate all AML package lengths */
UtBeginEvent (i, "Generate AML package lengths");
@ -382,14 +360,23 @@ CmDoCompile (void)
/* Namespace loading */
UtBeginEvent (i, "Create ACPI Namespace");
LdLoadNamespace ();
Status = LdLoadNamespace (RootNode);
UtEndEvent (i++);
if (ACPI_FAILURE (Status))
{
return -1;
}
/* Namespace lookup */
UtBeginEvent (i, "Cross reference parse tree and Namespace");
LkCrossReferenceNamespace ();
Status = LkCrossReferenceNamespace ();
UtEndEvent (i++);
UtEndEvent (i++);
if (ACPI_FAILURE (Status))
{
return -1;
}
/*
* Semantic analysis. This can happen only after the
@ -531,6 +518,7 @@ CmCleanupAndExit (void)
printf ("%11u : %s\n", TotalMethods, "Control methods");
printf ("%11u : %s\n", TotalAllocations, "Memory Allocations");
printf ("%11u : %s\n", TotalAllocated, "Total allocated memory");
printf ("%11u : %s\n", TotalFolds, "Constant subtrees folded");
printf ("\n");
}
@ -539,7 +527,7 @@ CmCleanupAndExit (void)
DbgPrint (ASL_DEBUG_OUTPUT, "\n\nMiscellaneous compile statistics\n\n");
DbgPrint (ASL_DEBUG_OUTPUT, "%32s : %d\n", "Total Namespace searches", Gbl_NsLookupCount);
DbgPrint (ASL_DEBUG_OUTPUT, "%32s : %d\n", "Time per search",
((AslGbl_Events[7].EndTime - AslGbl_Events[7].StartTime) * 1000) /
((UINT32) (AslGbl_Events[7].EndTime - AslGbl_Events[7].StartTime) * 1000) /
Gbl_NsLookupCount);
}

View File

@ -2,7 +2,7 @@
/******************************************************************************
*
* Module Name: aslcompiler.h - common include file
* $Revision: 1.132 $
* $Revision: 1.108 $
*
*****************************************************************************/
@ -10,7 +10,7 @@
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp.
* Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp.
* All rights reserved.
*
* 2. License
@ -129,6 +129,21 @@
/* warn : named type definition in parentheses */
#pragma warning(disable:4115)
/* MS doesn't have getopt, but we implement it */
int
getopt (
int argc,
char **argv,
char *opts);
#endif
#ifdef _LINUX
/* includes native getopt definition */
#include <unistd.h>
#endif
#include <stdio.h>
@ -140,7 +155,6 @@
#include "acpi.h"
#include "amlresrc.h"
#include "acdebug.h"
#include "asltypes.h"
#include "aslglobal.h"
@ -150,12 +164,12 @@
* Compiler versions and names
*/
#define CompilerCreatorRevision ACPI_CA_VERSION
#define CompilerVersion "X2047"
#define CompilerCreatorRevision 0x02012047 /* Acpi 2.0a, Version # */
#define IntelAcpiCA "Intel ACPI Component Architecture"
#define CompilerId "ASL Optimizing Compiler / AML Disassembler"
#define CompilerCopyright "Copyright (C) 2000 - 2004 Intel Corporation"
#define CompilerCompliance "ACPI 2.0c"
#define CompilerId "Intel ACPI Component Architecture ASL Compiler"
#define CompilerCopyright "Copyright (C) 2000 - 2002 Intel Corporation"
#define CompilerCompliance "ACPI 2.0a"
#define CompilerName "iasl"
#define CompilerCreatorId "INTL"
@ -207,17 +221,11 @@
#define FILE_SUFFIX_NAMESPACE "nsp"
#define FILE_SUFFIX_ASM_SOURCE "asm"
#define FILE_SUFFIX_C_SOURCE "c"
#define FILE_SUFFIX_DISASSEMBLY "dsl"
#define FILE_SUFFIX_ASM_INCLUDE "inc"
#define FILE_SUFFIX_C_INCLUDE "h"
/* Misc */
#define ASL_EXTERNAL_METHOD 255
#define ASL_ABORT TRUE
#define ASL_NO_ABORT FALSE
/*******************************************************************************
*
@ -252,10 +260,6 @@ void
ResetCurrentLineBuffer (
void);
void
InsertLineBuffer (
int SourceChar);
int
AslPopInputFileStack (
void);
@ -298,9 +302,6 @@ ErrorContext (void);
int
CmDoCompile (void);
void
CmDoOutputFiles (void);
void
CmCleanupAndExit (void);
@ -314,13 +315,6 @@ AslError (
ACPI_PARSE_OBJECT *Op,
char *ExtraMessage);
void
AslCoreSubsystemError (
ACPI_PARSE_OBJECT *Op,
ACPI_STATUS Status,
char *ExtraMessage,
BOOLEAN Abort);
void
AslCommonError (
UINT8 Level,
@ -335,8 +329,7 @@ AslCommonError (
void
AePrintException (
UINT32 FileId,
ASL_ERROR_MSG *Enode,
char *Header);
ASL_ERROR_MSG *Enode);
void
AePrintErrorLog (
@ -476,17 +469,6 @@ void
OpnDoRegion (
ACPI_PARSE_OBJECT *Op);
/*
* aslopt - optmization
*/
void
OptOptimizeNamePath (
ACPI_PARSE_OBJECT *Op,
UINT32 Flags,
ACPI_WALK_STATE *WalkState,
char *AmlNameString,
ACPI_NAMESPACE_NODE *TargetNode);
/*
@ -581,6 +563,11 @@ void
TrDoDefinitionBlock (
ACPI_PARSE_OBJECT *Op);
void
TrDoElseif (
ACPI_PARSE_OBJECT *Op);
/*
* asltree - parse tree support
*/
@ -775,10 +762,6 @@ void
FlSetLineNumber (
ACPI_PARSE_OBJECT *Op);
ACPI_STATUS
FlParseInputPathname (
char *InputFilename);
ACPI_STATUS
FlOpenInputFile (
char *InputFilename);
@ -900,14 +883,14 @@ UtGetArg (
ACPI_PARSE_OBJECT *Op,
UINT32 Argn);
char *
NATIVE_CHAR *
UtGetStringBuffer (
UINT32 Length);
ACPI_STATUS
UtInternalizeName (
char *ExternalName,
char **ConvertedName);
NATIVE_CHAR *ExternalName,
NATIVE_CHAR **ConvertedName);
void
UtAttachNamepathToOwner (
@ -922,13 +905,13 @@ UtCheckIntegerRange (
ACPI_STATUS
UtStrtoul64 (
char *String,
NATIVE_CHAR *String,
UINT32 Base,
ACPI_INTEGER *RetInteger);
ACPI_INTEGER
UtDoConstant (
char *String);
NATIVE_CHAR *String);
/* Find */
@ -939,207 +922,5 @@ LnAdjustLengthToRoot (
UINT32 LengthDelta);
#define NEXT_RESOURCE_DESC(a,b) (ASL_RESOURCE_DESC *) (((char *) (a)) + sizeof(b))
#define DEFAULT_RESOURCE_DESC_SIZE (sizeof (ASL_RESOURCE_DESC) + sizeof (ASL_END_TAG_DESC))
/*
* Resource utilities
*/
ASL_RESOURCE_NODE *
RsAllocateResourceNode (
UINT32 Size);
void
RsCreateBitField (
ACPI_PARSE_OBJECT *Op,
char *Name,
UINT32 ByteOffset,
UINT32 BitOffset);
void
RsCreateByteField (
ACPI_PARSE_OBJECT *Op,
char *Name,
UINT32 ByteOffset);
void
RsSetFlagBits (
UINT8 *Flags,
ACPI_PARSE_OBJECT *Op,
UINT8 Position,
UINT8 DefaultBit);
ACPI_PARSE_OBJECT *
RsCompleteNodeAndGetNext (
ACPI_PARSE_OBJECT *Op);
ASL_RESOURCE_NODE *
RsDoOneResourceDescriptor (
ACPI_PARSE_OBJECT *DescriptorTypeOp,
UINT32 CurrentByteOffset,
UINT8 *State);
#define ACPI_RSTATE_NORMAL 0
#define ACPI_RSTATE_START_DEPENDENT 1
#define ACPI_RSTATE_DEPENDENT_LIST 2
UINT32
RsLinkDescriptorChain (
ASL_RESOURCE_NODE **PreviousRnode,
ASL_RESOURCE_NODE *Rnode);
/*
* Small descriptors
*/
ASL_RESOURCE_NODE *
RsDoDmaDescriptor (
ACPI_PARSE_OBJECT *Op,
UINT32 CurrentByteOffset);
ASL_RESOURCE_NODE *
RsDoEndDependentDescriptor (
ACPI_PARSE_OBJECT *Op,
UINT32 CurrentByteOffset);
ASL_RESOURCE_NODE *
RsDoFixedIoDescriptor (
ACPI_PARSE_OBJECT *Op,
UINT32 CurrentByteOffset);
ASL_RESOURCE_NODE *
RsDoInterruptDescriptor (
ACPI_PARSE_OBJECT *Op,
UINT32 CurrentByteOffset);
ASL_RESOURCE_NODE *
RsDoIoDescriptor (
ACPI_PARSE_OBJECT *Op,
UINT32 CurrentByteOffset);
ASL_RESOURCE_NODE *
RsDoIrqDescriptor (
ACPI_PARSE_OBJECT *Op,
UINT32 CurrentByteOffset);
ASL_RESOURCE_NODE *
RsDoIrqNoFlagsDescriptor (
ACPI_PARSE_OBJECT *Op,
UINT32 CurrentByteOffset);
ASL_RESOURCE_NODE *
RsDoMemory24Descriptor (
ACPI_PARSE_OBJECT *Op,
UINT32 CurrentByteOffset);
ASL_RESOURCE_NODE *
RsDoMemory32Descriptor (
ACPI_PARSE_OBJECT *Op,
UINT32 CurrentByteOffset);
ASL_RESOURCE_NODE *
RsDoMemory32FixedDescriptor (
ACPI_PARSE_OBJECT *Op,
UINT32 CurrentByteOffset);
ASL_RESOURCE_NODE *
RsDoStartDependentDescriptor (
ACPI_PARSE_OBJECT *Op,
UINT32 CurrentByteOffset);
ASL_RESOURCE_NODE *
RsDoStartDependentNoPriDescriptor (
ACPI_PARSE_OBJECT *Op,
UINT32 CurrentByteOffset);
ASL_RESOURCE_NODE *
RsDoVendorSmallDescriptor (
ACPI_PARSE_OBJECT *Op,
UINT32 CurrentByteOffset);
/*
* Large descriptors
*/
UINT32
RsGetStringDataLength (
ACPI_PARSE_OBJECT *InitializerOp);
ASL_RESOURCE_NODE *
RsDoDwordIoDescriptor (
ACPI_PARSE_OBJECT *Op,
UINT32 CurrentByteOffset);
ASL_RESOURCE_NODE *
RsDoDwordMemoryDescriptor (
ACPI_PARSE_OBJECT *Op,
UINT32 CurrentByteOffset);
ASL_RESOURCE_NODE *
RsDoDwordSpaceDescriptor (
ACPI_PARSE_OBJECT *Op,
UINT32 CurrentByteOffset);
ASL_RESOURCE_NODE *
RsDoExtendedIoDescriptor (
ACPI_PARSE_OBJECT *Op,
UINT32 CurrentByteOffset);
ASL_RESOURCE_NODE *
RsDoExtendedMemoryDescriptor (
ACPI_PARSE_OBJECT *Op,
UINT32 CurrentByteOffset);
ASL_RESOURCE_NODE *
RsDoExtendedSpaceDescriptor (
ACPI_PARSE_OBJECT *Op,
UINT32 CurrentByteOffset);
ASL_RESOURCE_NODE *
RsDoQwordIoDescriptor (
ACPI_PARSE_OBJECT *Op,
UINT32 CurrentByteOffset);
ASL_RESOURCE_NODE *
RsDoQwordMemoryDescriptor (
ACPI_PARSE_OBJECT *Op,
UINT32 CurrentByteOffset);
ASL_RESOURCE_NODE *
RsDoQwordSpaceDescriptor (
ACPI_PARSE_OBJECT *Op,
UINT32 CurrentByteOffset);
ASL_RESOURCE_NODE *
RsDoWordIoDescriptor (
ACPI_PARSE_OBJECT *Op,
UINT32 CurrentByteOffset);
ASL_RESOURCE_NODE *
RsDoWordSpaceDescriptor (
ACPI_PARSE_OBJECT *Op,
UINT32 CurrentByteOffset);
ASL_RESOURCE_NODE *
RsDoWordBusNumberDescriptor (
ACPI_PARSE_OBJECT *Op,
UINT32 CurrentByteOffset);
ASL_RESOURCE_NODE *
RsDoVendorLargeDescriptor (
ACPI_PARSE_OBJECT *Op,
UINT32 CurrentByteOffset);
ASL_RESOURCE_NODE *
RsDoGeneralRegisterDescriptor (
ACPI_PARSE_OBJECT *Op,
UINT32 CurrentByteOffset);
#endif /* __ASLCOMPILER_H */