Added option to display compile times

date	2001.05.10.21.25.00;	author rmoore1;	state Exp;
This commit is contained in:
aystarik 2005-06-29 15:57:15 +00:00
parent 99b38d3410
commit 25d29c6948
3 changed files with 420 additions and 1232 deletions

View File

@ -3,7 +3,7 @@
/******************************************************************************
*
* Module Name: aslglobal.h - Global variable definitions
* $Revision: 1.9 $
* $Revision: 1.12 $
*
*****************************************************************************/
@ -145,10 +145,7 @@ extern char *AslCompilertext;
extern FILE *AslCompilerin;
extern int optind;
extern char *optarg;
extern char hex[];
extern char MsgBuffer[];
#define ASL_LINE_BUFFER_SIZE 512
#define ASL_MSG_BUFFER_SIZE (ASL_LINE_BUFFER_SIZE * 2)
@ -163,12 +160,14 @@ EXTERN int INIT_GLOBAL (Gbl_LogicalLineNumber, 1);
EXTERN int INIT_GLOBAL (Gbl_CurrentLineOffset, 0);
EXTERN char INIT_GLOBAL (*Gbl_LineBufPtr, Gbl_CurrentLineBuffer);
/* Exception reporting */
EXTERN ASL_ERROR_MSG INIT_GLOBAL (*Gbl_ErrorLog,NULL);
EXTERN ASL_ERROR_MSG INIT_GLOBAL (*Gbl_NextError,NULL);
extern UINT32 Gbl_ExceptionCount[];
/* Option flags */
EXTERN BOOLEAN INIT_GLOBAL (Gbl_UseDefaultAmlFilename, TRUE);
@ -179,30 +178,20 @@ EXTERN BOOLEAN INIT_GLOBAL (Gbl_ListingFlag, FALSE);
EXTERN BOOLEAN INIT_GLOBAL (Gbl_IgnoreErrors, FALSE);
EXTERN BOOLEAN INIT_GLOBAL (Gbl_SourceOutputFlag, FALSE);
EXTERN BOOLEAN INIT_GLOBAL (Gbl_ParseOnlyFlag, FALSE);
EXTERN BOOLEAN INIT_GLOBAL (Gbl_CompileTimesFlag, FALSE);
/* Files */
EXTERN char *Gbl_DirectoryPath;
EXTERN char INIT_GLOBAL (*Gbl_NamespaceOutputFilename, NULL);
EXTERN char INIT_GLOBAL (*Gbl_InputFilename, NULL);
EXTERN char INIT_GLOBAL (*Gbl_IncludeFilename, NULL);
EXTERN char INIT_GLOBAL (*Gbl_SourceOutputFilename, NULL);
EXTERN char INIT_GLOBAL (*Gbl_OutputFilename, NULL);
EXTERN char INIT_GLOBAL (*Gbl_OutputFilenamePrefix, NULL);
EXTERN char INIT_GLOBAL (*Gbl_ListingOutputFilename, NULL);
EXTERN char INIT_GLOBAL (*Gbl_DebugOutputFilename, NULL);
EXTERN char INIT_GLOBAL (*Gbl_HexOutputFilename, NULL);
EXTERN FILE *Gbl_AslInputFile;
EXTERN FILE *Gbl_AmlOutputFile;
EXTERN FILE *Gbl_DebugOutputFile;
EXTERN FILE *Gbl_ListingOutputFile;
EXTERN FILE *Gbl_HexOutputFile;
EXTERN FILE *Gbl_NamespaceOutputFile;
EXTERN FILE *Gbl_SourceOutputFile;
EXTERN BOOLEAN INIT_GLOBAL (Gbl_HasIncludeFiles, FALSE);
EXTERN ASL_FILE_INFO Gbl_Files [ASL_NUM_FILES];
EXTERN char *Gbl_DirectoryPath;
EXTERN char INIT_GLOBAL (*Gbl_IncludeFilename, NULL);
EXTERN char INIT_GLOBAL (*Gbl_OutputFilenamePrefix, NULL);
EXTERN char *Gbl_CurrentInputFilename;
EXTERN BOOLEAN INIT_GLOBAL (Gbl_HasIncludeFiles, FALSE);
/* Statistics */
@ -212,8 +201,8 @@ EXTERN UINT32 INIT_GLOBAL (TotalKeywords, 0);
EXTERN UINT32 INIT_GLOBAL (TotalNamedObjects, 0);
EXTERN UINT32 INIT_GLOBAL (TotalExecutableOpcodes, 0);
/* Misc */
/* Misc */
EXTERN ASL_PARSE_NODE INIT_GLOBAL (*RootNode, NULL);
EXTERN UINT32 INIT_GLOBAL (Gbl_TableLength, 0);
@ -230,6 +219,7 @@ EXTERN UINT32 INIT_GLOBAL (Gbl_ReservedMethods, 0);
EXTERN UINT8 INIT_GLOBAL (AcpiGbl_DbOutputFlags, DB_CONSOLE_OUTPUT);
EXTERN FILE *DebugFile; /* Placeholder for oswinxf only */
/* Static structures */
EXTERN ASL_ANALYSIS_WALK_INFO AnalysisWalkInfo;

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,7 @@
/******************************************************************************
*
* Module Name: aslmain - compiler main and utilities
* $Revision: 1.82 $
* $Revision: 1.34 $
*
*****************************************************************************/
@ -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, 2000, 2001, Intel Corp.
* All rights reserved.
*
* 2. License
@ -119,120 +119,14 @@
#define _DECLARE_GLOBALS
#include "aslcompiler.h"
#include "acnamesp.h"
#include "acapps.h"
#ifdef _DEBUG
#include <crtdbg.h>
#endif
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslmain")
BOOLEAN AslToFile = TRUE;
BOOLEAN DoCompile = TRUE;
BOOLEAN DoSignon = TRUE;
char hex[] =
{
'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'
};
MODULE_NAME ("aslmain")
/*******************************************************************************
*
* FUNCTION: Options
*
* PARAMETERS: None
*
* RETURN: None
*
* DESCRIPTION: Display option help message
*
******************************************************************************/
static void
Options (
void)
{
printf ("General Output:\n");
printf (" -p <prefix> Specify filename prefix for all output files (including .aml)\n");
printf (" -vi Less verbose errors and warnings for use with IDEs\n");
printf (" -vo Enable optimization comments\n");
printf (" -vr Disable remarks\n");
printf (" -vs Disable signon\n");
printf ("\nAML Output Files:\n");
printf (" -s<a|c> Create AML in assembler or C source file (*.asm or *.c)\n");
printf (" -i<a|c> Create assembler or C include file (*.inc or *.h)\n");
printf (" -t<a|c> Create AML in assembler or C hex table (*.hex)\n");
printf ("\nAML Code Generation:\n");
printf (" -oa Disable all optimizations (compatibility mode)\n");
printf (" -of Disable constant folding\n");
printf (" -oi Disable integer optimization to Zero/One/Ones\n");
printf (" -on Disable named reference string optimization\n");
printf (" -r<Revision> Override table header Revision (1-255)\n");
printf ("\nListings:\n");
printf (" -l Create mixed listing file (ASL source and AML) (*.lst)\n");
printf (" -ln Create namespace file (*.nsp)\n");
printf (" -ls Create combined source file (expanded includes) (*.src)\n");
printf ("\nAML Disassembler:\n");
printf (" -d [file] Disassemble AML to ASL source code file (*.dsl)\n");
printf (" -dc [file] Disassemble AML and immediately compile it\n");
printf (" (Obtain DSDT from current system if no input file)\n");
printf (" -e Generate External() statements for unresolved symbols\n");
printf (" -g Get ACPI tables and write to files (*.dat)\n");
printf ("\nMiscellaneous:\n");
printf (" -a Verify source file is entirely ASCII text (0x00-0x7F)\n");
printf ("\nHelp:\n");
printf (" -h Additional help and compiler debug options\n");
printf (" -hc Display operators allowed in constant expressions\n");
printf (" -hr Display ACPI reserved method names\n");
}
/*******************************************************************************
*
* FUNCTION: HelpMessage
*
* PARAMETERS: None
*
* RETURN: None
*
* DESCRIPTION: Display help message
*
******************************************************************************/
static void
HelpMessage (
void)
{
printf ("AML output filename generation:\n");
printf (" Output filenames are generated by appending an extension to a common\n");
printf (" filename prefix. The filename prefix is obtained via one of the\n");
printf (" following methods (in priority order):\n");
printf (" 1) The -p option specifies the prefix\n");
printf (" 2) The prefix of the AMLFileName in the ASL Definition Block\n");
printf (" 3) The prefix of the input filename\n");
printf ("\n");
Options ();
printf ("\nCompiler Debug Options:\n");
printf (" -b<p|t|b> Create compiler debug/trace file (*.txt)\n");
printf (" Types: Parse/Tree/Both\n");
printf (" -f Ignore errors, force creation of AML output file(s)\n");
printf (" -c Parse only, no output generation\n");
printf (" -ot Display compile times\n");
printf (" -x<level> Set debug level for trace output\n");
}
UINT32 Gbl_ExceptionCount[2] = {0,0};
char hex[] = {'0','1','2','3','4','5','6','7',
'8','9','A','B','C','D','E','F'};
/*******************************************************************************
@ -243,17 +137,26 @@ HelpMessage (
*
* RETURN: None
*
* DESCRIPTION: Display usage and option message
* DESCRIPTION: Display help message
*
******************************************************************************/
static void
void
Usage (
void)
{
printf ("Usage: %s [Options] [InputFile]\n\n", CompilerName);
Options ();
printf ("Usage: %s <Options> <InputFile>\n\n", CompilerName);
printf ("Options: -d <p|t|b> Create compiler debug/trace file (*.txt)\n");
printf (" Types: Parse/Tree/Both\n");
printf (" -h Create ascii hex file (*.hex)\n");
printf (" -i Ignore errors, always create AML file\n");
printf (" -l Create listing (mixed source/AML) file (*.lst)\n");
printf (" -n Create namespace file (*.nsp)\n");
printf (" -o <name> Specify filename prefix for all output files\n");
printf (" (including the .aml file)\n");
printf (" -p Parse only, no output generation\n");
printf (" -s Create combined (w/includes) ASL file (*.src)\n");
printf (" -t Display compile times\n");
}
@ -269,17 +172,12 @@ Usage (
*
******************************************************************************/
static void
AslInitialize (
void)
void
AslInitialize (void)
{
UINT32 i;
UINT32 i;
#ifdef _DEBUG
_CrtSetDbgFlag (_CRTDBG_CHECK_ALWAYS_DF | _CrtSetDbgFlag(0));
#endif
AcpiDbgLevel = 0;
for (i = 0; i < ASL_NUM_FILES; i++)
@ -296,394 +194,6 @@ AslInitialize (
}
/*******************************************************************************
*
* FUNCTION: AslCommandLine
*
* PARAMETERS: argc/argv
*
* RETURN: None
*
* DESCRIPTION: Command line processing
*
******************************************************************************/
static void
AslCommandLine (
int argc,
char **argv)
{
BOOLEAN BadCommandLine = FALSE;
ACPI_NATIVE_UINT j;
/* Minimum command line contains at least one option or an input file */
if (argc < 2)
{
AslCompilerSignon (ASL_FILE_STDOUT);
Usage ();
exit (1);
}
/* Get the command line options */
while ((j = AcpiGetopt (argc, argv, "ab:cd^efgh^i^l^o:p:r:s:t:v:x:")) != EOF) switch (j)
{
case 'a':
Gbl_CheckForAscii = TRUE;
break;
case 'b':
switch (AcpiGbl_Optarg[0])
{
case 'b':
AslCompilerdebug = 1; /* same as yydebug */
break;
case 'p':
AslCompilerdebug = 1; /* same as yydebug */
break;
case 't':
break;
default:
printf ("Unknown option: -b%s\n", AcpiGbl_Optarg);
BadCommandLine = TRUE;
break;
}
/* Produce debug output file */
Gbl_DebugFlag = TRUE;
break;
case 'c':
/* Parse only */
Gbl_ParseOnlyFlag = TRUE;
break;
case 'd':
switch (AcpiGbl_Optarg[0])
{
case '^':
DoCompile = FALSE;
break;
case 'c':
break;
default:
printf ("Unknown option: -d%s\n", AcpiGbl_Optarg);
BadCommandLine = TRUE;
break;
}
Gbl_DisasmFlag = TRUE;
break;
case 'e':
/* Generate external statements for unresolved symbols */
Gbl_GenerateExternals = TRUE;
break;
case 'f':
/* Ignore errors and force creation of aml file */
Gbl_IgnoreErrors = TRUE;
break;
case 'g':
/* Get all ACPI tables */
Gbl_GetAllTables = TRUE;
DoCompile = FALSE;
break;
case 'h':
switch (AcpiGbl_Optarg[0])
{
case '^':
HelpMessage ();
exit (0);
case 'c':
UtDisplayConstantOpcodes ();
exit (0);
case 'r':
/* reserved names */
MpDisplayReservedNames ();
exit (0);
default:
printf ("Unknown option: -h%s\n", AcpiGbl_Optarg);
BadCommandLine = TRUE;
break;
}
break;
case 'i':
switch (AcpiGbl_Optarg[0])
{
case 'a':
/* Produce assembly code include file */
Gbl_AsmIncludeOutputFlag = TRUE;
break;
case 'c':
/* Produce C include file */
Gbl_C_IncludeOutputFlag = TRUE;
break;
default:
printf ("Unknown option: -s%s\n", AcpiGbl_Optarg);
BadCommandLine = TRUE;
break;
}
break;
case 'l':
switch (AcpiGbl_Optarg[0])
{
case '^':
/* Produce listing file (Mixed source/aml) */
Gbl_ListingFlag = TRUE;
break;
case 'n':
/* Produce namespace file */
Gbl_NsOutputFlag = TRUE;
break;
case 's':
/* Produce combined source file */
Gbl_SourceOutputFlag = TRUE;
break;
default:
printf ("Unknown option: -l%s\n", AcpiGbl_Optarg);
BadCommandLine = TRUE;
break;
}
break;
case 'o':
switch (AcpiGbl_Optarg[0])
{
case 'a':
/* Disable all optimizations */
Gbl_FoldConstants = FALSE;
Gbl_IntegerOptimizationFlag = FALSE;
Gbl_ReferenceOptimizationFlag = FALSE;
break;
case 'f':
/* Disable folding on "normal" expressions */
Gbl_FoldConstants = FALSE;
break;
case 'i':
/* Disable integer optimization to constants */
Gbl_IntegerOptimizationFlag = FALSE;
break;
case 'n':
/* Disable named reference optimization */
Gbl_ReferenceOptimizationFlag = FALSE;
break;
case 't':
/* Display compile time(s) */
Gbl_CompileTimesFlag = TRUE;
break;
default:
printf ("Unknown option: -c%s\n", AcpiGbl_Optarg);
BadCommandLine = TRUE;
break;
}
break;
case 'p':
/* Override default AML output filename */
Gbl_OutputFilenamePrefix = AcpiGbl_Optarg;
Gbl_UseDefaultAmlFilename = FALSE;
break;
case 'r':
Gbl_RevisionOverride = (UINT8) strtoul (AcpiGbl_Optarg, NULL, 0);
break;
case 's':
switch (AcpiGbl_Optarg[0])
{
case 'a':
/* Produce assembly code output file */
Gbl_AsmOutputFlag = TRUE;
break;
case 'c':
/* Produce C hex output file */
Gbl_C_OutputFlag = TRUE;
break;
default:
printf ("Unknown option: -s%s\n", AcpiGbl_Optarg);
BadCommandLine = TRUE;
break;
}
break;
case 't':
/* Produce hex table output file */
switch (AcpiGbl_Optarg[0])
{
case 'a':
Gbl_HexOutputFlag = HEX_OUTPUT_ASM;
break;
case 'c':
Gbl_HexOutputFlag = HEX_OUTPUT_C;
break;
default:
printf ("Unknown option: -t%s\n", AcpiGbl_Optarg);
BadCommandLine = TRUE;
break;
}
break;
case 'v':
switch (AcpiGbl_Optarg[0])
{
case 'i':
/* Less verbose error messages */
Gbl_VerboseErrors = FALSE;
break;
case 'o':
Gbl_DisplayOptimizations = TRUE;
break;
case 'r':
Gbl_DisplayRemarks = FALSE;
break;
case 's':
DoSignon = FALSE;
break;
default:
printf ("Unknown option: -v%s\n", AcpiGbl_Optarg);
BadCommandLine = TRUE;
break;
}
break;
case 'x':
AcpiDbgLevel = strtoul (AcpiGbl_Optarg, NULL, 16);
break;
default:
BadCommandLine = TRUE;
break;
}
/* Next parameter must be the input filename */
Gbl_Files[ASL_FILE_INPUT].Filename = argv[AcpiGbl_Optind];
if (!Gbl_Files[ASL_FILE_INPUT].Filename &&
!Gbl_DisasmFlag &&
!Gbl_GetAllTables)
{
printf ("Missing input filename\n");
BadCommandLine = TRUE;
}
if (DoSignon)
{
AslCompilerSignon (ASL_FILE_STDOUT);
}
/* Abort if anything went wrong on the command line */
if (BadCommandLine)
{
printf ("\n");
Usage ();
exit (1);
}
if ((AcpiGbl_Optind + 1) < argc)
{
printf ("Warning: extra arguments (%d) after input filename are ignored\n\n",
argc - AcpiGbl_Optind - 1);
}
}
/*******************************************************************************
*
* FUNCTION: main
@ -697,112 +207,147 @@ AslCommandLine (
*
******************************************************************************/
int ACPI_SYSTEM_XFACE
int
main (
int argc,
char **argv)
int argc,
char **argv)
{
ACPI_STATUS Status;
char *Prefix;
UINT32 j;
BOOLEAN BadCommandLine = FALSE;
int Status;
/* Init and command line */
AslInitialize ();
AslCommandLine (argc, argv);
AslCompilerSignon (ASL_FILE_STDOUT);
/* Minimum command line contains at least the input file */
if (argc < 2)
{
Usage ();
return 0;
}
/* Get the command line options */
while ((j = getopt (argc, argv, "a:d:hilno:pst")) != EOF) switch (j)
{
case 'a':
AcpiDbgLevel = strtoul (optarg, NULL, 16);
break;
case 'd':
switch (optarg[0])
{
case 'b':
AslCompilerdebug = 1; /* same as yydebug */
break;
case 'p':
AslCompilerdebug = 1; /* same as yydebug */
break;
case 't':
break;
}
/* Produce debug output file */
Gbl_DebugFlag = TRUE;
break;
case 'h':
/* Produce hex output file */
Gbl_HexOutputFlag = TRUE;
break;
case 'i':
/* Ignore errors and always attempt to create aml file */
Gbl_IgnoreErrors = TRUE;
break;
case 'l':
/* Produce listing file (Mixed source/aml) */
Gbl_ListingFlag = TRUE;
break;
case 'n':
/* Produce namespace file */
Gbl_NsOutputFlag = TRUE;
break;
case 'o':
/* Override default AML output filename */
Gbl_OutputFilenamePrefix = optarg;
Gbl_UseDefaultAmlFilename = FALSE;
break;
case 'p':
/* Parse only */
Gbl_ParseOnlyFlag = TRUE;
break;
case 's':
/* Produce combined source file */
Gbl_SourceOutputFlag = TRUE;
break;
case 't':
/* Display compile time(s) */
Gbl_CompileTimesFlag = TRUE;
break;
default:
BadCommandLine = TRUE;
break;
}
/* Next parameter must be the input filename */
Gbl_Files[ASL_FILE_INPUT].Filename = argv[optind];
if (!Gbl_Files[ASL_FILE_INPUT].Filename)
{
printf ("Missing input filename\n");
BadCommandLine = TRUE;
}
/* Abort if anything went wrong on the command line */
if (BadCommandLine)
{
printf ("\n");
Usage ();
return -1;
}
if ((optind + 1) < argc)
{
printf ("Warning: extra arguments (%d) after input filename are ignored\n\n", argc - optind - 1);
}
/*
* If -p not specified, we will use the input filename as the
* If -o not specified, we will use the input filename as the
* output filename prefix
*/
FlSplitInputPathname (Gbl_Files[ASL_FILE_INPUT].Filename,
&Gbl_DirectoryPath, &Prefix);
if (Gbl_UseDefaultAmlFilename)
{
Gbl_OutputFilenamePrefix = Prefix;
Gbl_OutputFilenamePrefix = Gbl_Files[ASL_FILE_INPUT].Filename;
}
/* AML Disassembly (Optional) */
if (Gbl_DisasmFlag || Gbl_GetAllTables)
{
/* ACPI CA subsystem initialization */
Status = CmDoCompile ();
Status = AcpiOsInitialize ();
AcpiUtInitGlobals ();
Status = AcpiUtMutexInitialize ();
if (ACPI_FAILURE (Status))
{
return -1;
}
Status = AcpiNsRootInitialize ();
if (ACPI_FAILURE (Status))
{
return -1;
}
/* This is where the disassembly happens */
AcpiGbl_DbOpt_disasm = TRUE;
Status = AdAmlDisassemble (AslToFile,
Gbl_Files[ASL_FILE_INPUT].Filename,
Gbl_OutputFilenamePrefix,
&Gbl_Files[ASL_FILE_INPUT].Filename,
Gbl_GetAllTables);
if (ACPI_FAILURE (Status))
{
return -1;
}
/*
* Gbl_Files[ASL_FILE_INPUT].Filename was replaced with the
* .DSL disassembly file, which can now be compiled if requested
*/
if (DoCompile)
{
AcpiOsPrintf ("\nCompiling \"%s\"\n",
Gbl_Files[ASL_FILE_INPUT].Filename);
}
}
/*
* ASL Compilation (Optional)
*/
if (DoCompile)
{
/*
* If -p not specified, we will use the input filename as the
* output filename prefix
*/
FlSplitInputPathname (Gbl_Files[ASL_FILE_INPUT].Filename,
&Gbl_DirectoryPath, &Prefix);
if (Gbl_UseDefaultAmlFilename)
{
Gbl_OutputFilenamePrefix = Prefix;
}
/* ACPI CA subsystem initialization (Must be re-initialized) */
Status = AcpiOsInitialize ();
AcpiUtInitGlobals ();
Status = AcpiUtMutexInitialize ();
if (ACPI_FAILURE (Status))
{
return -1;
}
Status = AcpiNsRootInitialize ();
if (ACPI_FAILURE (Status))
{
return -1;
}
Status = CmDoCompile ();
}
return (0);
return (Status);
}