From 78198357cfd22c18cfffd6f74d31b9c73a12b536 Mon Sep 17 00:00:00 2001 From: aystarik Date: Wed, 29 Jun 2005 15:39:56 +0000 Subject: [PATCH] Cleanup and merge globals date 2000.11.16.17.24.00; author rmoore1; state Exp; --- source/compiler/aslanalyze.c | 140 +-------- source/compiler/aslcodegen.c | 32 ++- source/compiler/aslcompile.c | 524 ++++++++-------------------------- source/compiler/aslcompiler.h | 206 +++++++++---- 4 files changed, 290 insertions(+), 612 deletions(-) diff --git a/source/compiler/aslanalyze.c b/source/compiler/aslanalyze.c index f7c430e3b..534c13f2a 100644 --- a/source/compiler/aslanalyze.c +++ b/source/compiler/aslanalyze.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: aslanalyze.c - check for semantic errors - * $Revision: 1.9 $ + * $Revision: 1.10 $ * *****************************************************************************/ @@ -122,140 +122,6 @@ #include -#define ASL_RSVD_RETURN_VALUE 0x01 -UINT32 AslGbl_ReservedMethods = 0; - -typedef struct -{ - char *Name; - UINT8 NumArguments; - UINT8 Flags; - -} ASL_RESERVED_INFO; - - -ASL_RESERVED_INFO ReservedMethods[] = { - "_AC0", 0, ASL_RSVD_RETURN_VALUE, - "_AC1", 0, ASL_RSVD_RETURN_VALUE, - "_AC2", 0, ASL_RSVD_RETURN_VALUE, - "_AC3", 0, ASL_RSVD_RETURN_VALUE, - "_ADR", 0, ASL_RSVD_RETURN_VALUE, - "_AL0", 0, ASL_RSVD_RETURN_VALUE, - "_AL1", 0, ASL_RSVD_RETURN_VALUE, - "_AL2", 0, ASL_RSVD_RETURN_VALUE, - "_AL3", 0, ASL_RSVD_RETURN_VALUE, - "_BBN", 0, ASL_RSVD_RETURN_VALUE, - "_BCL", 0, ASL_RSVD_RETURN_VALUE, - "_BCM", 1, 0, - "_BDN", 0, ASL_RSVD_RETURN_VALUE, - "_BFS", 1, 0, - "_BIF", 0, ASL_RSVD_RETURN_VALUE, - "_BST", 0, ASL_RSVD_RETURN_VALUE, - "_BTP", 1, 0, - "_CID", 0, ASL_RSVD_RETURN_VALUE, - "_CRS", 0, ASL_RSVD_RETURN_VALUE, - "_CRT", 0, ASL_RSVD_RETURN_VALUE, - "_CST", 0, ASL_RSVD_RETURN_VALUE, - "_DCK", 1, ASL_RSVD_RETURN_VALUE, - "_DCS", 0, ASL_RSVD_RETURN_VALUE, - "_DDC", 1, ASL_RSVD_RETURN_VALUE, - "_DDN", 1, 0, /* Spec is ambiguous about this */ - "_DGS", 0, ASL_RSVD_RETURN_VALUE, - "_DIS", 0, 0, - "_DMA", 0, ASL_RSVD_RETURN_VALUE, - "_DOD", 0, ASL_RSVD_RETURN_VALUE, - "_DOS", 1, 0, - "_DSS", 1, 0, - "_EC_", 0, ASL_RSVD_RETURN_VALUE, - "_EDL", 0, ASL_RSVD_RETURN_VALUE, - "_EJ0", 1, 0, - "_EJ1", 1, 0, - "_EJ2", 1, 0, - "_EJ3", 1, 0, - "_EJ4", 1, 0, - "_EJD", 0, ASL_RSVD_RETURN_VALUE, - "_FDE", 0, ASL_RSVD_RETURN_VALUE, - "_FDI", 0, ASL_RSVD_RETURN_VALUE, - "_FDM", 1, 0, - "_FIX", 0, ASL_RSVD_RETURN_VALUE, - "_GLK", 0, ASL_RSVD_RETURN_VALUE, - "_GPD", 0, ASL_RSVD_RETURN_VALUE, - "_GPE", 0, ASL_RSVD_RETURN_VALUE, - "_GTF", 0, ASL_RSVD_RETURN_VALUE, - "_GTM", 0, ASL_RSVD_RETURN_VALUE, - "_GTS", 1, 0, - "_HID", 0, ASL_RSVD_RETURN_VALUE, - "_HOT", 0, ASL_RSVD_RETURN_VALUE, - "_HPP", 0, ASL_RSVD_RETURN_VALUE, - "_INI", 0, 0, - "_IRC", 0, 0, - "_LCK", 1, 0, - "_LID", 0, ASL_RSVD_RETURN_VALUE, - "_MAT", 0, ASL_RSVD_RETURN_VALUE, - "_MSG", 1, 0, - "_OFF", 0, 0, - "_ON_", 0, 0, - "_PCL", 0, ASL_RSVD_RETURN_VALUE, - "_PCT", 0, ASL_RSVD_RETURN_VALUE, - "_PIC", 1, 0, - "_PPC", 0, ASL_RSVD_RETURN_VALUE, - "_PR0", 0, ASL_RSVD_RETURN_VALUE, - "_PR1", 0, ASL_RSVD_RETURN_VALUE, - "_PR2", 0, ASL_RSVD_RETURN_VALUE, - "_PRS", 0, ASL_RSVD_RETURN_VALUE, - "_PRT", 0, ASL_RSVD_RETURN_VALUE, - "_PRW", 0, ASL_RSVD_RETURN_VALUE, - "_PS0", 0, 0, - "_PS1", 0, 0, - "_PS2", 0, 0, - "_PS3", 0, 0, - "_PSC", 0, ASL_RSVD_RETURN_VALUE, - "_PSL", 0, ASL_RSVD_RETURN_VALUE, - "_PSR", 0, ASL_RSVD_RETURN_VALUE, - "_PSS", 0, ASL_RSVD_RETURN_VALUE, - "_PSV", 0, ASL_RSVD_RETURN_VALUE, - "_PSW", 1, 0, - "_PTC", 0, ASL_RSVD_RETURN_VALUE, - "_PTS", 1, 0, - "_PXM", 0, ASL_RSVD_RETURN_VALUE, - "_REG", 2, 0, - "_RMV", 0, ASL_RSVD_RETURN_VALUE, - "_ROM", 2, ASL_RSVD_RETURN_VALUE, - "_S0_", 0, ASL_RSVD_RETURN_VALUE, - "_S1_", 0, ASL_RSVD_RETURN_VALUE, - "_S2_", 0, ASL_RSVD_RETURN_VALUE, - "_S3_", 0, ASL_RSVD_RETURN_VALUE, - "_S4_", 0, ASL_RSVD_RETURN_VALUE, - "_S5_", 0, ASL_RSVD_RETURN_VALUE, - "_S1D", 0, ASL_RSVD_RETURN_VALUE, - "_S2D", 0, ASL_RSVD_RETURN_VALUE, - "_S3D", 0, ASL_RSVD_RETURN_VALUE, - "_S4D", 0, ASL_RSVD_RETURN_VALUE, - "_SBS", 0, ASL_RSVD_RETURN_VALUE, - "_SCP", 1, 0, - "_SEG", 0, ASL_RSVD_RETURN_VALUE, - "_SPD", 1, ASL_RSVD_RETURN_VALUE, - "_SRS", 1, 0, - "_SST", 1, 0, - "_STA", 0, ASL_RSVD_RETURN_VALUE, - "_STM", 3, 0, - "_STR", 0, ASL_RSVD_RETURN_VALUE, - "_SUN", 0, ASL_RSVD_RETURN_VALUE, - "_TC1", 0, ASL_RSVD_RETURN_VALUE, - "_TC2", 0, ASL_RSVD_RETURN_VALUE, - "_TMP", 0, ASL_RSVD_RETURN_VALUE, - "_TSP", 0, ASL_RSVD_RETURN_VALUE, - "_TZD", 0, ASL_RSVD_RETURN_VALUE, - "_TZP", 0, ASL_RSVD_RETURN_VALUE, - "_UID", 0, ASL_RSVD_RETURN_VALUE, - "_VPO", 0, ASL_RSVD_RETURN_VALUE, - "_WAK", 1, ASL_RSVD_RETURN_VALUE, - NULL, 0, 0, -}; - -char MsgBuffer[256]; - - /******************************************************************************* * @@ -292,7 +158,7 @@ AnCheckForReservedMethod ( { if (!STRCMP (Node->ExternalName, ReservedMethods[i].Name)) { - AslGbl_ReservedMethods++; + Gbl_ReservedMethods++; /* Matched a reserved method name */ @@ -331,7 +197,7 @@ AnCheckForReservedMethod ( (Node->ExternalName[1] == 'Q')) { - AslGbl_ReservedMethods++; + Gbl_ReservedMethods++; /* The next two characters must be hex digits */ diff --git a/source/compiler/aslcodegen.c b/source/compiler/aslcodegen.c index 1be33a286..643e2d4bf 100644 --- a/source/compiler/aslcodegen.c +++ b/source/compiler/aslcodegen.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: aslcodegen - AML code generation - * $Revision: 1.15 $ + * $Revision: 1.17 $ * *****************************************************************************/ @@ -149,7 +149,8 @@ CgGenerateAmlOutput (void) } Gbl_SourceLine = 0; - AslGbl_NextError = AslGbl_ErrorLog; + LsPushNode (Gbl_InputFilename); + Gbl_NextError = Gbl_ErrorLog; TgWalkParseTree (ASL_WALK_VISIT_DOWNWARD, CgAmlWriteWalk, NULL, NULL); @@ -157,7 +158,7 @@ CgGenerateAmlOutput (void) if (Gbl_ListingFlag) { LsFinishSourceListing (); - fprintf (Gbl_ListingFile, "\n\nTable header with final checksum:\n\n"); + fprintf (Gbl_ListingOutputFile, "\n\nTable header with final checksum:\n\n"); } CgCloseTable (); @@ -242,7 +243,7 @@ CgLocalWriteAmlData ( /* Write the raw data to the AML file */ - fwrite ((char *) Buffer, Length, 1, Gbl_OutputAmlFile); + fwrite ((char *) Buffer, Length, 1, Gbl_AmlOutputFile); /* Write the hex bytes to the listing file (if requested) */ @@ -465,6 +466,11 @@ CgWriteTableHeader ( TableHeader.AslCompilerRevision = CompilerCreatorRevision; + /* Table length. Checksum zero for now, will rewrite later */ + + TableHeader.Length = Gbl_TableLength; + TableHeader.Checksum = 0; + CgLocalWriteAmlData (&TableHeader, sizeof (ACPI_TABLE_HEADER)); } @@ -488,20 +494,13 @@ CgCloseTable (void) UINT8 FileByte; - TableHeader.Length = Gbl_TableLength; - TableHeader.Checksum = 0; - - /* Write the header at the start of the file */ - - fseek (Gbl_OutputAmlFile, 0, SEEK_SET); - CgLocalWriteAmlData (&TableHeader, sizeof (ACPI_TABLE_HEADER)); /* Calculate the checksum over the entire file */ - fseek (Gbl_OutputAmlFile, 0, SEEK_SET); + fseek (Gbl_AmlOutputFile, 0, SEEK_SET); Sum = 0; - while (fread (&FileByte, 1, 1, Gbl_OutputAmlFile)) + while (fread (&FileByte, 1, 1, Gbl_AmlOutputFile)) { Sum += FileByte; } @@ -510,7 +509,7 @@ CgCloseTable (void) TableHeader.Checksum = (0 - Sum); - fseek (Gbl_OutputAmlFile, 0, SEEK_SET); + fseek (Gbl_AmlOutputFile, 0, SEEK_SET); CgLocalWriteAmlData (&TableHeader, sizeof (ACPI_TABLE_HEADER)); } @@ -537,7 +536,10 @@ CgWriteNode ( /* TEMP FIX: always check for DEFAULT_ARG */ - if (Node->ParseOpcode == DEFAULT_ARG) + if ((Node->ParseOpcode == DEFAULT_ARG) || + (Node->ParseOpcode == EXTERNAL) || + (Node->ParseOpcode == INCLUDE) || + (Node->ParseOpcode == INCLUDE_END)) { return; } diff --git a/source/compiler/aslcompile.c b/source/compiler/aslcompile.c index 7dcd5dca7..56ad79e34 100644 --- a/source/compiler/aslcompile.c +++ b/source/compiler/aslcompile.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: aslcompile - top level compile module - * $Revision: 1.67 $ + * $Revision: 1.3 $ * *****************************************************************************/ @@ -10,8 +10,8 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp. - * All rights reserved. + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. * * 2. License * @@ -115,20 +115,63 @@ * *****************************************************************************/ -#include -#include "aslcompiler.h" -#define _COMPONENT ACPI_COMPILER - ACPI_MODULE_NAME ("aslcompile") +#include "AslCompiler.h" +#include "acnamesp.h" +#include "acdebug.h" +#include + + + +/* + * Stubs + */ + +void +AcpiTbDeleteAcpiTables (void) +{ +} + + +BOOLEAN +AcpiTbSystemTablePointer ( + void *Where) +{ + return FALSE; + +} + +void +AcpiAmlDumpOperands ( + ACPI_OPERAND_OBJECT **Operands, + OPERATING_MODE InterpreterMode, + NATIVE_CHAR *Ident, + UINT32 NumLevels, + NATIVE_CHAR *Note, + NATIVE_CHAR *ModuleName, + UINT32 LineNumber) +{ +} + +ACPI_STATUS +AcpiAmlDumpOperand ( + ACPI_OPERAND_OBJECT *EntryDesc) +{ + return AE_OK; +} + + +struct tm *NewTime; +time_t Aclock; /******************************************************************************* * - * FUNCTION: AslCompilerSignon + * FUNCTION: Signon and FileHeader * - * PARAMETERS: FileId - ID of the output file - * - * RETURN: None + * PARAMETERS: None + * + * RETURN: None * * DESCRIPTION: Display compiler signon * @@ -136,475 +179,158 @@ void AslCompilerSignon ( - UINT32 FileId) + FILE *Where) { - char *Prefix = ""; + time (&Aclock); + NewTime = localtime (&Aclock); - /* - * Set line prefix depending on the destination file type - */ - switch (FileId) - { - case ASL_FILE_ASM_SOURCE_OUTPUT: + fprintf (Where, "\n%s [Version %s, %s]\n\n", CompilerId, CompilerVersion, __DATE__); - Prefix = "; "; - break; - - case ASL_FILE_HEX_OUTPUT: - - if (Gbl_HexOutputFlag == HEX_OUTPUT_ASM) - { - Prefix = "; "; - } - else if (Gbl_HexOutputFlag == HEX_OUTPUT_C) - { - FlPrintFile (ASL_FILE_HEX_OUTPUT, "/*\n"); - Prefix = " * "; - } - break; - - case ASL_FILE_C_SOURCE_OUTPUT: - - Prefix = " * "; - break; - - default: - /* No other output types supported */ - break; - } - - /* Compiler signon with copyright */ - - FlPrintFile (FileId, - "%s\n%s%s\n%s%s version %X [%s]\n%s%s\n%sSupports ACPI Specification Revision 2.0b\n%s\n", - Prefix, - Prefix, IntelAcpiCA, - Prefix, CompilerId, ACPI_CA_VERSION, __DATE__, - Prefix, CompilerCopyright, - Prefix, - Prefix); } - -/******************************************************************************* - * - * FUNCTION: AslCompilerFileHeader - * - * PARAMETERS: FileId - ID of the output file - * - * RETURN: None - * - * DESCRIPTION: Header used at the beginning of output files - * - ******************************************************************************/ - void AslCompilerFileHeader ( - UINT32 FileId) + FILE *Where) { - struct tm *NewTime; - time_t Aclock; - char *Prefix = ""; + fprintf (Where, "Compilation of \"%s\" - %s\n", Gbl_InputFilename, asctime (NewTime)); - /* - * Set line prefix depending on the destination file type - */ - switch (FileId) - { - case ASL_FILE_ASM_SOURCE_OUTPUT: - - Prefix = "; "; - break; - - case ASL_FILE_HEX_OUTPUT: - - if (Gbl_HexOutputFlag == HEX_OUTPUT_ASM) - { - Prefix = "; "; - } - else if (Gbl_HexOutputFlag == HEX_OUTPUT_C) - { - Prefix = " * "; - } - break; - - case ASL_FILE_C_SOURCE_OUTPUT: - - Prefix = " * "; - break; - - default: - /* No other output types supported */ - break; - } - - /* Compilation header with timestamp */ - - (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; - } } + /******************************************************************************* * - * FUNCTION: CmFlushSourceCode + * FUNCTION: * - * PARAMETERS: None + * PARAMETERS: * - * RETURN: None + * RETURN: * - * DESCRIPTION: Read in any remaining source code after the parse tree - * has been constructed. - * - ******************************************************************************/ - -void -CmFlushSourceCode (void) -{ - char Buffer; - - - while (FlReadFile (ASL_FILE_INPUT, &Buffer, 1) != AE_ERROR) - { - InsertLineBuffer ((int) Buffer); - } - - ResetCurrentLineBuffer (); -} - - -/******************************************************************************* - * - * FUNCTION: CmDoCompile - * - * PARAMETERS: None - * - * RETURN: Status (0 = OK) - * - * DESCRIPTION: This procedure performs the entire compile + * DESCRIPTION: * ******************************************************************************/ int CmDoCompile (void) { - ACPI_STATUS Status; - UINT32 i = 0; + ACPI_STATUS Status; - UtBeginEvent (12, "Total Compile time"); - UtBeginEvent (i, "Initialize"); - - /* Open the required input and output files */ - - Status = FlOpenInputFile (Gbl_Files[ASL_FILE_INPUT].Filename); + Status = FlOpenInputFile (Gbl_InputFilename); if (ACPI_FAILURE (Status)) { - AePrintErrorLog (ASL_FILE_STDERR); + AePrintErrorLog (stderr); + return -1; + } + Status = FlOpenMiscOutputFiles (Gbl_InputFilename); + if (ACPI_FAILURE (Status)) + { + AePrintErrorLog (stderr); return -1; } - Status = FlOpenMiscOutputFiles (Gbl_OutputFilenamePrefix); - if (ACPI_FAILURE (Status)) - { - AePrintErrorLog (ASL_FILE_STDERR); - return -1; - } - UtEndEvent (i++); + /* ACPI CA subsystem initialization */ + + AcpiCmInitGlobals (); + AcpiCmMutexInitialize (); + AcpiNsRootInitialize (); /* Build the parse tree */ - UtBeginEvent (i, "Parse source code and build parse tree"); AslCompilerparse(); - UtEndEvent (i++); - - /* Flush out any remaining source after parse tree is complete */ - - CmFlushSourceCode (); - - /* Did the parse tree get successfully constructed? */ - - if (!RootNode) - { - CmCleanupAndExit (); - return -1; - } - - OpcGetIntegerWidth (RootNode); - - /* Pre-process parse tree for any operator transforms */ - - UtBeginEvent (i, "Generate AML opcodes"); - DbgPrint (ASL_DEBUG_OUTPUT, "\nParse tree transforms\n\n"); - TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, TrAmlTransformWalk, NULL, NULL); + /* Generate AML opcodes corresponding to the parse tokens */ - DbgPrint (ASL_DEBUG_OUTPUT, "\nGenerating AML opcodes\n\n"); - TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, NULL, OpcAmlOpcodeWalk, NULL); - UtEndEvent (i++); - - /* - * Now that the input is parsed, we can open the AML output file. - * Note: by default, the name of this file comes from the table descriptor - * within the input file. - */ - Status = FlOpenAmlOutputFile (Gbl_OutputFilenamePrefix); - if (ACPI_FAILURE (Status)) - { - AePrintErrorLog (ASL_FILE_STDERR); - return -1; - } - - /* 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++); + DbgPrint ("\nGenerating AML opcodes\n\n"); + TgWalkParseTree (ASL_WALK_VISIT_UPWARD, NULL, CgAmlOpcodeWalk, NULL); /* Calculate all AML package lengths */ - UtBeginEvent (i, "Generate AML package lengths"); - DbgPrint (ASL_DEBUG_OUTPUT, "\nGenerating Package lengths\n\n"); - TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, NULL, LnPackageLengthWalk, NULL); - UtEndEvent (i++); + DbgPrint ("\nGenerating Package lengths\n\n"); + TgWalkParseTree (ASL_WALK_VISIT_UPWARD, NULL, LnPackageLengthWalk, NULL); - if (Gbl_ParseOnlyFlag) - { - AePrintErrorLog (ASL_FILE_STDOUT); - UtDisplaySummary (ASL_FILE_STDOUT); - if (Gbl_DebugFlag) - { - /* Print error summary to the debug file */ + /* Semantic error checking */ - AePrintErrorLog (ASL_FILE_STDERR); - UtDisplaySummary (ASL_FILE_STDERR); - } - return 0; - } + AnalysisWalkInfo.MethodStack = NULL; + + DbgPrint ("\nSemantic analysis\n\n"); + TgWalkParseTree (ASL_WALK_VISIT_TWICE, AnSemanticAnalysisWalkBegin, + AnSemanticAnalysisWalkEnd, &AnalysisWalkInfo); - /* - * Create an internal namespace and use it as a symbol table - */ /* Namespace loading */ - UtBeginEvent (i, "Create ACPI Namespace"); - Status = LdLoadNamespace (RootNode); - UtEndEvent (i++); - if (ACPI_FAILURE (Status)) - { - return -1; - } + LdLoadNamespace (); + /* Namespace lookup */ - UtBeginEvent (i, "Cross reference parse tree and Namespace"); - Status = LkCrossReferenceNamespace (); - UtEndEvent (i++); - UtEndEvent (i++); - if (ACPI_FAILURE (Status)) - { - return -1; - } - - /* - * Semantic analysis. This can happen only after the - * namespace has been loaded and cross-referenced. - * - * part one - check control methods - */ - UtBeginEvent (i, "Analyze control method return types"); - AnalysisWalkInfo.MethodStack = NULL; - - DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - Method analysis\n\n"); - TrWalkParseTree (RootNode, ASL_WALK_VISIT_TWICE, AnMethodAnalysisWalkBegin, - AnMethodAnalysisWalkEnd, &AnalysisWalkInfo); - UtEndEvent (i++); - - /* Semantic error checking part two - typing of method returns */ - - UtBeginEvent (i, "Determine object types returned by methods"); - DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - Method typing \n\n"); - TrWalkParseTree (RootNode, ASL_WALK_VISIT_TWICE, AnMethodTypingWalkBegin, - AnMethodTypingWalkEnd, NULL); - UtEndEvent (i++); - - /* Semantic error checking part three - operand type checking */ - - UtBeginEvent (i, "Analyze AML operand types"); - DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - Operand type checking \n\n"); - TrWalkParseTree (RootNode, ASL_WALK_VISIT_TWICE, AnOperandTypecheckWalkBegin, - AnOperandTypecheckWalkEnd, &AnalysisWalkInfo); - UtEndEvent (i++); - - /* Semantic error checking part four - other miscellaneous checks */ - - UtBeginEvent (i, "Miscellaneous analysis"); - DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - miscellaneous \n\n"); - TrWalkParseTree (RootNode, ASL_WALK_VISIT_TWICE, AnOtherSemanticAnalysisWalkBegin, - AnOtherSemanticAnalysisWalkEnd, &AnalysisWalkInfo); - UtEndEvent (i++); + LkCrossReferenceNamespace (); /* Calculate all AML package lengths */ - UtBeginEvent (i, "Finish AML package length generation"); - DbgPrint (ASL_DEBUG_OUTPUT, "\nGenerating Package lengths\n\n"); - TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, NULL, LnInitLengthsWalk, NULL); - TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, NULL, LnPackageLengthWalk, NULL); - UtEndEvent (i++); + DbgPrint ("\nGenerating Package lengths\n\n"); + TgWalkParseTree (ASL_WALK_VISIT_UPWARD, NULL, LnInitLengthsWalk, NULL); + TgWalkParseTree (ASL_WALK_VISIT_UPWARD, NULL, LnPackageLengthWalk, NULL); + + + /* + * Now that the input is parsed, we can open the AML output file. + * Note: by default, the name of this file comes from the table descriptor + * within the input file. + */ + Status = FlOpenAmlOutputFile (Gbl_InputFilename); + if (ACPI_FAILURE (Status)) + { + AePrintErrorLog (stderr); + return -1; + } /* Code generation - emit the AML */ - UtBeginEvent (i, "Generate AML code and write output files"); CgGenerateAmlOutput (); - UtEndEvent (i++); - UtBeginEvent (i, "Write optional output files"); - CmDoOutputFiles (); - UtEndEvent (i++); - UtEndEvent (13); - CmCleanupAndExit (); - return 0; -} + AePrintErrorLog (stdout); + if (Gbl_DebugFlag) + { + /* Print error summary to the debug file */ -void -CmDoOutputFiles (void) -{ + AePrintErrorLog (stderr); + } - /* Create listings and hex files */ + /* Dump the AML as hex if requested */ - LsDoListings (); LsDoHexOutput (); /* Dump the namespace to the .nsp file if requested */ LsDisplayNamespace (); -} -/******************************************************************************* - * - * FUNCTION: CmCleanupAndExit - * - * PARAMETERS: None - * - * RETURN: None. - * - * DESCRIPTION: Close all open files and exit the compiler - * - ******************************************************************************/ - -void -CmCleanupAndExit (void) -{ - UINT32 i; - - - AePrintErrorLog (ASL_FILE_STDOUT); - if (Gbl_DebugFlag) - { - /* Print error summary to the debug file */ - - AePrintErrorLog (ASL_FILE_STDERR); - } - - DbgPrint (ASL_DEBUG_OUTPUT, "\n\nElapsed time for major events\n\n"); - for (i = 0; i < 13; i++) - { - if (AslGbl_Events[i].Valid) - { - DbgPrint (ASL_DEBUG_OUTPUT, "%8lu ms - %s\n", - AslGbl_Events[i].EndTime - - AslGbl_Events[i].StartTime, - AslGbl_Events[i].EventName); - } - } - - if (Gbl_CompileTimesFlag) - { - printf ("\nElapsed time for major events\n\n"); - for (i = 0; i < 13; i++) - { - if (AslGbl_Events[i].Valid) - { - printf ("%8lu ms : %s\n", - AslGbl_Events[i].EndTime - - AslGbl_Events[i].StartTime, - AslGbl_Events[i].EventName); - } - } - printf ("\nMiscellaneous compile statistics\n\n"); - printf ("%11u : %s\n", TotalParseNodes, "Parse nodes"); - printf ("%11u : %s\n", Gbl_NsLookupCount, "Namespace searches"); - printf ("%11u : %s\n", TotalNamedObjects, "Named objects"); - 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"); - } - - if (Gbl_NsLookupCount) - { - 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", - ((UINT32) (AslGbl_Events[7].EndTime - AslGbl_Events[7].StartTime) * 1000) / - Gbl_NsLookupCount); - } - /* Close all open files */ - for (i = 2; i < ASL_MAX_FILE_TYPE; i++) - { - FlCloseFile (i); - } + FlCloseListingFile (); + FlCloseSourceOutputFile (); + FlCloseHexOutputFile (); - /* - * TBD: SourceOutput should be .TMP, then rename if we want to keep it? - */ - if (!Gbl_SourceOutputFlag) - { - unlink (Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Filename); - } - - /* Delete AML file if there are errors */ + fclose (Gbl_AmlOutputFile); if ((Gbl_ExceptionCount[ASL_ERROR] > 0) && (!Gbl_IgnoreErrors)) { - unlink (Gbl_Files[ASL_FILE_AML_OUTPUT].Filename); + unlink (Gbl_OutputFilename); } - if (Gbl_ExceptionCount[ASL_ERROR] > ASL_MAX_ERROR_COUNT) - { - printf ("\nMaximum error count (%d) exceeded.\n", ASL_MAX_ERROR_COUNT); - } + UtDisplaySummary (); - UtDisplaySummary (ASL_FILE_STDOUT); - exit (0); + + return 0; } + diff --git a/source/compiler/aslcompiler.h b/source/compiler/aslcompiler.h index 6a24ec90e..d90b5120c 100644 --- a/source/compiler/aslcompiler.h +++ b/source/compiler/aslcompiler.h @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: aslcompiler.h - common include file - * $Revision: 1.24 $ + * $Revision: 1.28 $ * *****************************************************************************/ @@ -132,6 +132,7 @@ #include "acpi.h" +#include "acdebug.h" #define CompilerVersion "X205" #define CompilerCreatorRevision 0x00020205 /* Acpi 2.0, Version# */ @@ -217,75 +218,98 @@ typedef struct asl_analysis_walk_info typedef struct asl_mapping_entry { - UINT32 Value; - UINT16 AmlOpcode; - UINT8 Flags; + UINT32 Value; + UINT16 AmlOpcode; + UINT8 Flags; } ASL_MAPPING_ENTRY; typedef union asl_node_value { - UINT64 Integer; /* Generic integer is largest integer */ - UINT64 Integer64; - UINT32 Integer32; - UINT16 Integer16; - UINT8 Integer8; - void *Pointer; - char *String; + UINT64 Integer; /* Generic integer is largest integer */ + UINT64 Integer64; + UINT32 Integer32; + UINT16 Integer16; + UINT8 Integer8; + void *Pointer; + char *String; } ASL_NODE_VALUE; typedef struct asl_parse_node { - struct asl_parse_node *Parent; - struct asl_parse_node *Peer; - struct asl_parse_node *Child; - ACPI_NAMESPACE_NODE *NsNode; - union asl_node_value Value; - char *ExternalName; - char *Namepath; - UINT32 LineNumber; - UINT32 LogicalLineNumber; - UINT32 EndLine; - UINT32 EndLogicalLine; - UINT16 AmlOpcode; - UINT16 ParseOpcode; - UINT32 AmlLength; - UINT32 AmlSubtreeLength; - UINT8 AmlOpcodeLength; - UINT8 AmlPkgLenBytes; - UINT8 Flags; - char ParseOpName[12]; - char AmlOpName[12]; + struct asl_parse_node *Parent; + struct asl_parse_node *Peer; + struct asl_parse_node *Child; + ACPI_NAMESPACE_NODE *NsNode; + union asl_node_value Value; + char *Filename; + char *ExternalName; + char *Namepath; + UINT32 LineNumber; + UINT32 LogicalLineNumber; + UINT32 EndLine; + UINT32 EndLogicalLine; + UINT16 AmlOpcode; + UINT16 ParseOpcode; + UINT32 AmlLength; + UINT32 AmlSubtreeLength; + UINT8 AmlOpcodeLength; + UINT8 AmlPkgLenBytes; + UINT8 Flags; + char ParseOpName[12]; + char AmlOpName[12]; } ASL_PARSE_NODE; typedef struct asl_walk_info { - ASL_PARSE_NODE **NodePtr; - UINT32 *LevelPtr; + ASL_PARSE_NODE **NodePtr; + UINT32 *LevelPtr; } ASL_WALK_INFO; typedef struct asl_error_msg { - UINT32 LineNumber; - UINT32 LogicalLineNumber; - UINT32 Column; - char *Message; - struct asl_error_msg *Next; - UINT8 MessageId; - UINT8 Level; + UINT32 LineNumber; + UINT32 LogicalLineNumber; + UINT32 Column; + char *Message; + struct asl_error_msg *Next; + char *Filename; + UINT8 MessageId; + UINT8 Level; } ASL_ERROR_MSG; + +typedef struct asl_listing_node +{ + char *Filename; + UINT32 LineNumber; + struct asl_listing_node *Next; + +} ASL_LISTING_NODE; + + +#define ASL_RSVD_RETURN_VALUE 0x01 + +typedef struct +{ + char *Name; + UINT8 NumArguments; + UINT8 Flags; + +} ASL_RESERVED_INFO; + + typedef void (*ASL_WALK_CALLBACK) ( - ASL_PARSE_NODE *Node, - UINT32 Level, - void *Context); + ASL_PARSE_NODE *Node, + UINT32 Level, + void *Context); @@ -311,22 +335,24 @@ extern int yydebug; extern char hex[]; +extern char MsgBuffer[]; #define ASL_LINE_BUFFER_SIZE 1024 + /* Source code buffers and pointers for error reporting */ +EXTERN char Gbl_CurrentLineBuffer[ASL_LINE_BUFFER_SIZE]; EXTERN int INIT_GLOBAL (Gbl_CurrentColumn, 0); EXTERN int INIT_GLOBAL (Gbl_CurrentLineNumber, 1); EXTERN int INIT_GLOBAL (Gbl_LogicalLineNumber, 1); -EXTERN char Gbl_CurrentLineBuffer[ASL_LINE_BUFFER_SIZE]; EXTERN char INIT_GLOBAL (*Gbl_LineBufPtr, Gbl_CurrentLineBuffer); /* Exception reporting */ -EXTERN ASL_ERROR_MSG INIT_GLOBAL (*AslGbl_ErrorLog,NULL); -EXTERN ASL_ERROR_MSG INIT_GLOBAL (*AslGbl_NextError,NULL); -UINT32 AslGbl_ExceptionCount[2]; +EXTERN ASL_ERROR_MSG INIT_GLOBAL (*Gbl_ErrorLog,NULL); +EXTERN ASL_ERROR_MSG INIT_GLOBAL (*Gbl_NextError,NULL); +extern UINT32 Gbl_ExceptionCount[]; /* Option flags */ @@ -340,21 +366,26 @@ EXTERN BOOLEAN INIT_GLOBAL (Gbl_SourceOutputFlag, FALSE); /* Files */ -EXTERN char INIT_GLOBAL (*Gbl_NsFilename, NULL); +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_ListingFilename, NULL); -EXTERN char INIT_GLOBAL (*Gbl_DebugFilename, NULL); -EXTERN char INIT_GLOBAL (*Gbl_HexFilename, 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_OutputAmlFile; -EXTERN FILE *Gbl_DebugFile; -EXTERN FILE *Gbl_ListingFile; -EXTERN FILE *Gbl_HexFile; -EXTERN FILE *Gbl_NsFile; +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 char *Gbl_CurrentInputFilename; + /* Statistics */ @@ -367,9 +398,39 @@ EXTERN UINT32 INIT_GLOBAL (TotalExecutableOpcodes, 0); EXTERN ASL_PARSE_NODE INIT_GLOBAL (*RootNode, NULL); -EXTERN ACPI_TABLE_HEADER TableHeader; EXTERN UINT32 INIT_GLOBAL (Gbl_TableLength, 0); EXTERN UINT32 INIT_GLOBAL (Gbl_SourceLine, 0); +EXTERN ASL_LISTING_NODE INIT_GLOBAL (*Gbl_ListingNode, NULL); + + + + +EXTERN UINT32 INIT_GLOBAL (Gbl_CurrentHexColumn, 0); +EXTERN UINT32 INIT_GLOBAL (Gbl_CurrentAmlOffset, 0); +EXTERN UINT32 INIT_GLOBAL (Gbl_CurrentLine, 0); +EXTERN UINT8 INIT_GLOBAL (Gbl_HexBytesWereWritten, FALSE); +EXTERN UINT32 INIT_GLOBAL (Gbl_NumNamespaceObjects, 0); +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; +EXTERN ACPI_TABLE_HEADER TableHeader; +EXTERN ASL_RESERVED_INFO ReservedMethods[]; + + +extern char hex[]; + + +/* Scratch buffers */ + +EXTERN UINT8 Gbl_AmlBuffer[16]; +EXTERN char MsgBuffer[256]; +EXTERN char StringBuffer[256]; + + @@ -447,6 +508,11 @@ getopt ( void ErrorContext (void); +/* aslcompile */ + +int +CmDoCompile (void); + /* aslerror */ @@ -463,6 +529,7 @@ AslCommonError ( UINT8 MessageId, UINT32 CurrentLineNumber, UINT32 LogicalLineNumber, + char *Filename, char *ExtraMessage); void @@ -495,6 +562,14 @@ LsFinishSourceListing (void); void LsDoHexOutput (void); +void +LsPushNode ( + char *Filename); + +ASL_LISTING_NODE * +LsPopNode (void); + + void @@ -614,6 +689,11 @@ TgLinkChildren ( UINT32 NumChildren, ...); +void +TgSetEndLineNumber ( + ASL_PARSE_NODE *Node); + + void TgWalkTree (void); @@ -632,6 +712,13 @@ TgSetNodeFlags ( ASL_PARSE_NODE *Node, UINT32 Flags); +ASL_PARSE_NODE * +TgLinkPeerNodes ( + UINT32 NumPeers, + ...); + + + /* Analyze */ void @@ -647,12 +734,9 @@ AnSemanticAnalysisWalkEnd ( void *Context); -/* aslfiles */ - -#define FlOpenIncludeFile(a) _FlOpenIncludeFile ((ASL_PARSE_NODE *)(a)) void -_FlOpenIncludeFile ( +FlOpenIncludeFile ( ASL_PARSE_NODE *Node); ACPI_STATUS