1 /******************************************************************************
3 * Module Name: aslcompile - top level compile module
5 *****************************************************************************/
7 /******************************************************************************
11 * Some or all of this work - Copyright (c) 1999 - 2019, Intel Corp.
12 * All rights reserved.
16 * 2.1. This is your license from Intel Corp. under its intellectual property
17 * rights. You may have additional license terms from the party that provided
18 * you this software, covering your right to use that party's intellectual
21 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22 * copy of the source code appearing in this file ("Covered Code") an
23 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24 * base code distributed originally by Intel ("Original Intel Code") to copy,
25 * make derivatives, distribute, use and display any portion of the Covered
26 * Code in any form, with the right to sublicense such rights; and
28 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29 * license (with the right to sublicense), under only those claims of Intel
30 * patents that are infringed by the Original Intel Code, to make, use, sell,
31 * offer to sell, and import the Covered Code and derivative works thereof
32 * solely to the minimum extent necessary to exercise the above copyright
33 * license, and in no event shall the patent license extend to any additions
34 * to or modifications of the Original Intel Code. No other license or right
35 * is granted directly or by implication, estoppel or otherwise;
37 * The above copyright and patent license is granted only if the following
42 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43 * Redistribution of source code of any substantial portion of the Covered
44 * Code or modification with rights to further distribute source must include
45 * the above Copyright Notice, the above License, this list of Conditions,
46 * and the following Disclaimer and Export Compliance provision. In addition,
47 * Licensee must cause all Covered Code to which Licensee contributes to
48 * contain a file documenting the changes Licensee made to create that Covered
49 * Code and the date of any change. Licensee must include in that file the
50 * documentation of any changes made by any predecessor Licensee. Licensee
51 * must include a prominent statement that the modification is derived,
52 * directly or indirectly, from Original Intel Code.
54 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55 * Redistribution of source code of any substantial portion of the Covered
56 * Code or modification without rights to further distribute source must
57 * include the following Disclaimer and Export Compliance provision in the
58 * documentation and/or other materials provided with distribution. In
59 * addition, Licensee may not authorize further sublicense of source of any
60 * portion of the Covered Code, and must include terms to the effect that the
61 * license from Licensee to its licensee is limited to the intellectual
62 * property embodied in the software Licensee provides to its licensee, and
63 * not to intellectual property embodied in modifications its licensee may
66 * 3.3. Redistribution of Executable. Redistribution in executable form of any
67 * substantial portion of the Covered Code or modification must reproduce the
68 * above Copyright Notice, and the following Disclaimer and Export Compliance
69 * provision in the documentation and/or other materials provided with the
72 * 3.4. Intel retains all right, title, and interest in and to the Original
75 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76 * Intel shall be used in advertising or otherwise to promote the sale, use or
77 * other dealings in products derived from or relating to the Covered Code
78 * without prior written authorization from Intel.
80 * 4. Disclaimer and Export Compliance
82 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
90 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
99 * 4.3. Licensee shall not export, either directly or indirectly, any of this
100 * software or system incorporating such software without first obtaining any
101 * required license or other approval from the U. S. Department of Commerce or
102 * any other agency or department of the United States Government. In the
103 * event Licensee exports any such software from the United States or
104 * re-exports any such software from a foreign destination, Licensee shall
105 * ensure that the distribution and export/re-export of the software is in
106 * compliance with all laws, regulations, orders, or other restrictions of the
107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108 * any of its subsidiaries will export/re-export any technical data, process,
109 * software, or service, directly or indirectly, to any country for which the
110 * United States government or any agency thereof requires an export license,
111 * other governmental approval, or letter of assurance, without first obtaining
112 * such license, approval or letter.
114 *****************************************************************************
116 * Alternatively, you may choose to be licensed under the terms of the
119 * Redistribution and use in source and binary forms, with or without
120 * modification, are permitted provided that the following conditions
122 * 1. Redistributions of source code must retain the above copyright
123 * notice, this list of conditions, and the following disclaimer,
124 * without modification.
125 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126 * substantially similar to the "NO WARRANTY" disclaimer below
127 * ("Disclaimer") and any redistribution must be conditioned upon
128 * including a substantially similar Disclaimer requirement for further
129 * binary redistribution.
130 * 3. Neither the names of the above-listed copyright holders nor the names
131 * of any contributors may be used to endorse or promote products derived
132 * from this software without specific prior written permission.
134 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
135 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
136 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
137 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
138 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
139 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
140 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
141 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
142 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
144 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
146 * Alternatively, you may choose to be licensed under the terms of the
147 * GNU General Public License ("GPL") version 2 as published by the Free
148 * Software Foundation.
150 *****************************************************************************/
152 #include "aslcompiler.h"
153 #include "acnamesp.h"
159 #define _COMPONENT ACPI_COMPILER
160 ACPI_MODULE_NAME ("aslcompile")
164 * External is here in case the parser emits the same external in the
165 * generated header. (Newer versions of Bison)
171 /* Local prototypes */
183 BOOLEAN DeleteAmlFile);
186 /*******************************************************************************
188 * FUNCTION: CmDoCompile
192 * RETURN: Status (0 = OK)
194 * DESCRIPTION: This procedure performs the entire compile
196 ******************************************************************************/
204 ASL_GLOBAL_FILE_NODE *FileNode;
207 FullCompile = UtBeginEvent ("*** Total Compile time ***");
208 Event = UtBeginEvent ("Open input and output files");
211 Event = UtBeginEvent ("Preprocess input file");
212 if (AslGbl_PreprocessFlag)
214 /* Enter compiler name as a #define */
216 PrAddDefine (ASL_DEFINE, "", FALSE);
221 AslGbl_CurrentLineNumber = 1;
222 AslGbl_LogicalLineNumber = 1;
224 if (AslGbl_PreprocessOnly)
233 /* Build the parse tree */
235 Event = UtBeginEvent ("Parse source code and build parse tree");
239 /* Check for parser-detected syntax errors */
241 if (AslGbl_SyntaxError)
244 "Compiler aborting due to parser-detected syntax error(s)\n");
246 /* Flag this error in the FileNode for compilation summary */
248 FileNode = FlGetCurrentFileNode ();
249 FileNode->ParserErrorDetected = TRUE;
250 AslGbl_ParserErrorDetected = TRUE;
255 /* Did the parse tree get successfully constructed? */
257 if (!AslGbl_ParseTreeRoot)
260 * If there are no errors, then we have some sort of
263 AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL,
264 NULL, "- Could not resolve parse tree root node");
269 /* Flush out any remaining source after parse tree is complete */
271 Event = UtBeginEvent ("Flush source input");
272 CmFlushSourceCode ();
274 /* Prune the parse tree if requested (debug purposes only) */
276 if (AslGbl_PruneParseTree)
278 AslPruneParseTree (AslGbl_PruneDepth, AslGbl_PruneType);
281 /* Optional parse tree dump, compiler debug output only */
285 OpcGetIntegerWidth (AslGbl_ParseTreeRoot->Asl.Child);
288 /* Pre-process parse tree for any operator transforms */
290 Event = UtBeginEvent ("Parse tree transforms");
291 DbgPrint (ASL_DEBUG_OUTPUT, "\nParse tree transforms\n\n");
292 TrWalkParseTree (AslGbl_ParseTreeRoot, ASL_WALK_VISIT_TWICE,
293 TrAmlTransformWalkBegin, TrAmlTransformWalkEnd, NULL);
296 /* Generate AML opcodes corresponding to the parse tokens */
298 Event = UtBeginEvent ("Generate AML opcodes");
299 DbgPrint (ASL_DEBUG_OUTPUT, "Generating AML opcodes\n\n");
300 TrWalkParseTree (AslGbl_ParseTreeRoot, ASL_WALK_VISIT_UPWARD, NULL,
301 OpcAmlOpcodeWalk, NULL);
304 UtEndEvent (FullCompile);
308 UtEndEvent (FullCompile);
313 /*******************************************************************************
315 * FUNCTION: CmDoAslMiddleAndBackEnd
319 * RETURN: Status of middle-end and back-end
321 * DESCRIPTION: Perform compiler middle-end (type checking and semantic
322 * analysis) and back-end (code generation)
324 ******************************************************************************/
327 CmDoAslMiddleAndBackEnd (
334 /* Interpret and generate all compile-time constants */
336 Event = UtBeginEvent ("Constant folding via AML interpreter");
337 DbgPrint (ASL_DEBUG_OUTPUT,
338 "Interpreting compile-time constant expressions\n\n");
340 if (AslGbl_FoldConstants)
342 TrWalkParseTree (AslGbl_ParseTreeRoot, ASL_WALK_VISIT_UPWARD,
343 NULL, OpcAmlConstantWalk, NULL);
347 DbgPrint (ASL_PARSE_OUTPUT, " Optional folding disabled\n");
351 /* Update AML opcodes if necessary, after constant folding */
353 Event = UtBeginEvent ("Updating AML opcodes after constant folding");
354 DbgPrint (ASL_DEBUG_OUTPUT,
355 "Updating AML opcodes after constant folding\n\n");
356 TrWalkParseTree (AslGbl_ParseTreeRoot, ASL_WALK_VISIT_UPWARD,
357 NULL, OpcAmlOpcodeUpdateWalk, NULL);
360 /* Calculate all AML package lengths */
362 Event = UtBeginEvent ("Generate AML package lengths");
363 DbgPrint (ASL_DEBUG_OUTPUT, "Generating Package lengths\n\n");
364 TrWalkParseTree (AslGbl_ParseTreeRoot, ASL_WALK_VISIT_UPWARD, NULL,
365 LnPackageLengthWalk, NULL);
368 if (AslGbl_ParseOnlyFlag)
370 AePrintErrorLog (ASL_FILE_STDERR);
371 UtDisplaySummary (ASL_FILE_STDERR);
372 if (AslGbl_DebugFlag)
374 /* Print error summary to the stdout also */
376 AePrintErrorLog (ASL_FILE_STDOUT);
377 UtDisplaySummary (ASL_FILE_STDOUT);
383 * Create an internal namespace and use it as a symbol table
386 /* Namespace loading */
388 Event = UtBeginEvent ("Create ACPI Namespace");
389 DbgPrint (ASL_DEBUG_OUTPUT, "Creating ACPI Namespace\n\n");
390 Status = LdLoadNamespace (AslGbl_ParseTreeRoot);
392 if (ACPI_FAILURE (Status))
397 /* Namespace cross-reference */
399 AslGbl_NamespaceEvent = UtBeginEvent (
400 "Cross reference parse tree and Namespace");
401 DbgPrint (ASL_DEBUG_OUTPUT, "Cross referencing namespace\n\n");
402 Status = XfCrossReferenceNamespace ();
403 if (ACPI_FAILURE (Status))
408 /* Namespace - Check for non-referenced objects */
410 LkFindUnreferencedObjects ();
411 UtEndEvent (AslGbl_NamespaceEvent);
413 /* Resolve External Declarations */
415 Event = UtBeginEvent ("Resolve all Externals");
416 DbgPrint (ASL_DEBUG_OUTPUT, "\nResolve Externals\n\n");
418 if (AslGbl_DoExternalsInPlace)
420 TrWalkParseTree (AslGbl_ParseTreeRoot, ASL_WALK_VISIT_DOWNWARD,
421 ExAmlExternalWalkBegin, NULL, NULL);
425 TrWalkParseTree (AslGbl_ParseTreeRoot, ASL_WALK_VISIT_TWICE,
426 ExAmlExternalWalkBegin, ExAmlExternalWalkEnd, NULL);
431 * Semantic analysis. This can happen only after the
432 * namespace has been loaded and cross-referenced.
434 * part one - check control methods
436 Event = UtBeginEvent ("Analyze control method return types");
437 AslGbl_AnalysisWalkInfo.MethodStack = NULL;
439 DbgPrint (ASL_DEBUG_OUTPUT, "Semantic analysis - Method analysis\n\n");
441 if (AslGbl_CrossReferenceOutput)
443 OtPrintHeaders ("Part 1: Object Reference Map "
444 "(Object references from within each control method)");
447 TrWalkParseTree (AslGbl_ParseTreeRoot, ASL_WALK_VISIT_TWICE,
448 MtMethodAnalysisWalkBegin,
449 MtMethodAnalysisWalkEnd, &AslGbl_AnalysisWalkInfo);
452 /* Generate the object cross-reference file if requested */
454 Event = UtBeginEvent ("Generate cross-reference file");
458 /* Semantic error checking part two - typing of method returns */
460 Event = UtBeginEvent ("Determine object types returned by methods");
461 DbgPrint (ASL_DEBUG_OUTPUT, "Semantic analysis - Method typing\n\n");
462 TrWalkParseTree (AslGbl_ParseTreeRoot, ASL_WALK_VISIT_UPWARD,
463 NULL, AnMethodTypingWalkEnd, NULL);
466 /* Semantic error checking part three - operand type checking */
468 Event = UtBeginEvent ("Analyze AML operand types");
469 DbgPrint (ASL_DEBUG_OUTPUT,
470 "Semantic analysis - Operand type checking\n\n");
471 if (AslGbl_DoTypechecking)
473 TrWalkParseTree (AslGbl_ParseTreeRoot, ASL_WALK_VISIT_UPWARD,
474 NULL, AnOperandTypecheckWalkEnd, &AslGbl_AnalysisWalkInfo);
478 /* Semantic error checking part four - other miscellaneous checks */
480 Event = UtBeginEvent ("Miscellaneous analysis");
481 DbgPrint (ASL_DEBUG_OUTPUT, "Semantic analysis - miscellaneous\n\n");
482 TrWalkParseTree (AslGbl_ParseTreeRoot, ASL_WALK_VISIT_DOWNWARD,
483 AnOtherSemanticAnalysisWalkBegin,
484 NULL, &AslGbl_AnalysisWalkInfo);
488 * ASL-/ASL+ converter: Gbl_ParseTreeRoot->CommentList contains the
489 * very last comment of a given ASL file because it's the last constructed
490 * node during compilation. We take the very last comment and save it in a
491 * global for it to be used by the disassembler.
493 if (AcpiGbl_CaptureComments)
495 AcpiGbl_LastListHead = AslGbl_ParseTreeRoot->Asl.CommentList;
496 AslGbl_ParseTreeRoot->Asl.CommentList = NULL;
499 /* Calculate all AML package lengths */
501 Event = UtBeginEvent ("Finish AML package length generation");
502 DbgPrint (ASL_DEBUG_OUTPUT, "Generating Package lengths\n\n");
503 TrWalkParseTree (AslGbl_ParseTreeRoot, ASL_WALK_VISIT_UPWARD, NULL,
504 LnInitLengthsWalk, NULL);
505 TrWalkParseTree (AslGbl_ParseTreeRoot, ASL_WALK_VISIT_UPWARD, NULL,
506 LnPackageLengthWalk, NULL);
509 /* Code generation - emit the AML */
511 Event = UtBeginEvent ("Generate AML code and write output files");
512 DbgPrint (ASL_DEBUG_OUTPUT, "Writing AML byte code\n\n");
514 AslGbl_CurrentDB = AslGbl_ParseTreeRoot->Asl.Child;
516 while (AslGbl_CurrentDB)
518 switch (FlSwitchFileSet(AslGbl_CurrentDB->Asl.Filename))
520 case SWITCH_TO_DIFFERENT_FILE:
522 * Reset these parameters when definition blocks belong in
523 * different files. If they belong in the same file, there is
524 * no need to reset these parameters
526 FlSeekFile (ASL_FILE_SOURCE_OUTPUT, 0);
527 AslGbl_SourceLine = 0;
528 AslGbl_NextError = AslGbl_ErrorLog;
532 case SWITCH_TO_SAME_FILE:
534 CgGenerateAmlOutput ();
536 AslGbl_CurrentDB = AslGbl_CurrentDB->Asl.Next;
540 default: /* FILE_NOT_FOUND */
542 /* The requested file could not be found. Get out of here */
544 AslGbl_CurrentDB = NULL;
550 Event = UtBeginEvent ("Write optional output files");
557 /*******************************************************************************
559 * FUNCTION: AslCompilerSignon
561 * PARAMETERS: FileId - ID of the output file
565 * DESCRIPTION: Display compiler signon
567 ******************************************************************************/
577 /* Set line prefix depending on the destination file type */
581 case ASL_FILE_ASM_SOURCE_OUTPUT:
582 case ASL_FILE_ASM_INCLUDE_OUTPUT:
587 case ASL_FILE_HEX_OUTPUT:
589 if (AslGbl_HexOutputFlag == HEX_OUTPUT_ASM)
593 else if ((AslGbl_HexOutputFlag == HEX_OUTPUT_C) ||
594 (AslGbl_HexOutputFlag == HEX_OUTPUT_ASL))
596 FlPrintFile (ASL_FILE_HEX_OUTPUT, "/*\n");
601 case ASL_FILE_C_SOURCE_OUTPUT:
602 case ASL_FILE_C_OFFSET_OUTPUT:
603 case ASL_FILE_C_INCLUDE_OUTPUT:
610 /* No other output types supported */
615 /* Running compiler or disassembler? */
617 if (AcpiGbl_DisasmFlag)
619 UtilityName = AML_DISASSEMBLER_NAME;
623 UtilityName = ASL_COMPILER_NAME;
626 /* Compiler signon with copyright */
628 FlPrintFile (FileId, "%s\n", Prefix);
629 FlPrintFile (FileId, ACPI_COMMON_HEADER (UtilityName, Prefix));
633 /*******************************************************************************
635 * FUNCTION: AslCompilerFileHeader
637 * PARAMETERS: FileId - ID of the output file
641 * DESCRIPTION: Header used at the beginning of output files
643 ******************************************************************************/
646 AslCompilerFileHeader (
654 /* Set line prefix depending on the destination file type */
658 case ASL_FILE_ASM_SOURCE_OUTPUT:
659 case ASL_FILE_ASM_INCLUDE_OUTPUT:
664 case ASL_FILE_HEX_OUTPUT:
666 if (AslGbl_HexOutputFlag == HEX_OUTPUT_ASM)
670 else if ((AslGbl_HexOutputFlag == HEX_OUTPUT_C) ||
671 (AslGbl_HexOutputFlag == HEX_OUTPUT_ASL))
677 case ASL_FILE_C_SOURCE_OUTPUT:
678 case ASL_FILE_C_OFFSET_OUTPUT:
679 case ASL_FILE_C_INCLUDE_OUTPUT:
686 /* No other output types supported */
691 /* Compilation header with timestamp */
693 (void) time (&Aclock);
694 NewTime = localtime (&Aclock);
697 "%sCompilation of \"%s\" - %s%s\n",
698 Prefix, AslGbl_Files[ASL_FILE_INPUT].Filename, asctime (NewTime),
703 case ASL_FILE_C_SOURCE_OUTPUT:
704 case ASL_FILE_C_OFFSET_OUTPUT:
705 case ASL_FILE_C_INCLUDE_OUTPUT:
707 FlPrintFile (FileId, " */\n");
712 /* Nothing to do for other output types */
719 /*******************************************************************************
721 * FUNCTION: CmFlushSourceCode
727 * DESCRIPTION: Read in any remaining source code after the parse tree
728 * has been constructed.
730 ******************************************************************************/
739 while (FlReadFile (ASL_FILE_INPUT, &Buffer, 1) != AE_ERROR)
741 AslInsertLineBuffer ((int) Buffer);
744 AslResetCurrentLineBuffer ();
748 /*******************************************************************************
750 * FUNCTION: CmDoOutputFiles
756 * DESCRIPTION: Create all "listing" type files
758 ******************************************************************************/
765 /* Create listings and hex files */
770 /* Dump the namespace to the .nsp file if requested */
772 (void) NsDisplayNamespace ();
774 /* Dump the device mapping file */
776 MpEmitMappingInfo ();
780 /*******************************************************************************
782 * FUNCTION: CmDumpAllEvents
788 * DESCRIPTION: Dump all compiler events
790 ******************************************************************************/
796 ASL_EVENT_INFO *Event;
803 Event = AslGbl_Events;
805 DbgPrint (ASL_DEBUG_OUTPUT, "\n\nElapsed time for major events\n\n");
806 if (AslGbl_CompileTimesFlag)
808 printf ("\nElapsed time for major events\n\n");
811 for (i = 0; i < AslGbl_NextEvent; i++)
815 /* Delta will be in 100-nanosecond units */
817 Delta = (UINT32) (Event->EndTime - Event->StartTime);
819 MicroSeconds = Delta / ACPI_100NSEC_PER_USEC;
820 MilliSeconds = Delta / ACPI_100NSEC_PER_MSEC;
822 /* Round milliseconds up */
824 if ((MicroSeconds - (MilliSeconds * ACPI_USEC_PER_MSEC)) >= 500)
829 DbgPrint (ASL_DEBUG_OUTPUT, "%8u usec %8u msec - %s\n",
830 MicroSeconds, MilliSeconds, Event->EventName);
832 if (AslGbl_CompileTimesFlag)
834 printf ("%8u usec %8u msec - %s\n",
835 MicroSeconds, MilliSeconds, Event->EventName);
844 /*******************************************************************************
846 * FUNCTION: CmCleanupAndExit
852 * DESCRIPTION: Close all open files and exit the compiler
854 ******************************************************************************/
860 BOOLEAN DeleteAmlFile = FALSE;
861 ASL_GLOBAL_FILE_NODE *CurrentFileNode = AslGbl_FilesList;
864 /* Check if any errors occurred during compile */
866 (void) AslCheckForErrorExit ();
868 AePrintErrorLog (ASL_FILE_STDERR);
869 if (AslGbl_DebugFlag)
871 /* Print error summary to stdout also */
873 AePrintErrorLog (ASL_FILE_STDOUT);
876 /* Emit compile times if enabled */
880 if (AslGbl_CompileTimesFlag)
882 printf ("\nMiscellaneous compile statistics\n\n");
883 printf ("%11u : %s\n", AslGbl_TotalParseNodes, "Parse nodes");
884 printf ("%11u : %s\n", AslGbl_NsLookupCount, "Namespace searches");
885 printf ("%11u : %s\n", AslGbl_TotalNamedObjects, "Named objects");
886 printf ("%11u : %s\n", AslGbl_TotalMethods, "Control methods");
887 printf ("%11u : %s\n", AslGbl_TotalAllocations, "Memory Allocations");
888 printf ("%11u : %s\n", AslGbl_TotalAllocated, "Total allocated memory");
889 printf ("%11u : %s\n", AslGbl_TotalFolds, "Constant subtrees folded");
893 if (AslGbl_NsLookupCount)
895 DbgPrint (ASL_DEBUG_OUTPUT,
896 "\n\nMiscellaneous compile statistics\n\n");
898 DbgPrint (ASL_DEBUG_OUTPUT,
899 "%32s : %u\n", "Total Namespace searches",
900 AslGbl_NsLookupCount);
902 DbgPrint (ASL_DEBUG_OUTPUT,
903 "%32s : %u usec\n", "Time per search", ((UINT32)
904 (AslGbl_Events[AslGbl_NamespaceEvent].EndTime -
905 AslGbl_Events[AslGbl_NamespaceEvent].StartTime) / 10) /
906 AslGbl_NsLookupCount);
909 if (AslGbl_ExceptionCount[ASL_ERROR] > ASL_MAX_ERROR_COUNT)
911 printf ("\nMaximum error count (%d) exceeded\n",
912 ASL_MAX_ERROR_COUNT);
915 UtDisplaySummary (ASL_FILE_STDOUT);
918 * We will delete the AML file if there are errors and the
919 * force AML output option has not been used.
921 if (AslGbl_ParserErrorDetected || AslGbl_PreprocessOnly || ((AslGbl_ExceptionCount[ASL_ERROR] > 0) &&
922 (!AslGbl_IgnoreErrors) &&
923 AslGbl_Files[ASL_FILE_AML_OUTPUT].Handle))
925 DeleteAmlFile = TRUE;
928 /* Close all open files */
930 while (CurrentFileNode)
932 switch (FlSwitchFileSet (CurrentFileNode->Files[ASL_FILE_INPUT].Filename))
934 case SWITCH_TO_SAME_FILE:
935 case SWITCH_TO_DIFFERENT_FILE:
937 CmFinishFiles (DeleteAmlFile);
938 CurrentFileNode = CurrentFileNode->Next;
944 CurrentFileNode = NULL;
949 /* Final cleanup after compiling one file */
951 if (!AslGbl_DoAslConversion)
953 UtDeleteLocalCaches ();
958 /*******************************************************************************
960 * FUNCTION: CmFinishFiles
962 * PARAMETERS: DeleteAmlFile
966 * DESCRIPTION: Close all open files, delete AML files depending on the
967 * function parameter is true.
969 ******************************************************************************/
973 BOOLEAN DeleteAmlFile)
979 * Take care with the preprocessor file (.pre), it might be the same
980 * as the "input" file, depending on where the compiler has terminated
981 * or aborted. Prevent attempt to close the same file twice in
984 if (AslGbl_Files[ASL_FILE_PREPROCESSOR].Handle ==
985 AslGbl_Files[ASL_FILE_INPUT].Handle)
987 AslGbl_Files[ASL_FILE_PREPROCESSOR].Handle = NULL;
990 /* Close the standard I/O files */
992 for (i = ASL_FILE_INPUT; i < ASL_MAX_FILE_TYPE; i++)
995 * Some files such as debug output files could be pointing to
996 * stderr or stdout. Leave these alone.
998 if (AslGbl_Files[i].Handle != stderr &&
999 AslGbl_Files[i].Handle != stdout)
1005 /* Delete AML file if there are errors */
1009 FlDeleteFile (ASL_FILE_AML_OUTPUT);
1012 /* Delete the preprocessor temp file unless full debug was specified */
1014 if (AslGbl_PreprocessFlag && !AslGbl_KeepPreprocessorTempFile)
1016 FlDeleteFile (ASL_FILE_PREPROCESSOR);
1020 * Delete intermediate ("combined") source file (if -ls flag not set)
1021 * This file is created during normal ASL/AML compiles. It is not
1022 * created by the data table compiler.
1024 * If the -ls flag is set, then the .SRC file should not be deleted.
1025 * In this case, Gbl_SourceOutputFlag is set to TRUE.
1027 * Note: Handles are cleared by FlCloseFile above, so we look at the
1028 * filename instead, to determine if the .SRC file was actually
1031 if (!AslGbl_SourceOutputFlag)
1033 FlDeleteFile (ASL_FILE_SOURCE_OUTPUT);