xref: /freebsd/sys/contrib/dev/acpica/compiler/aslcompile.c (revision 804fe2660352e090f4481f2c1d646b508859e79a)
153289f6aSNate Lawson /******************************************************************************
253289f6aSNate Lawson  *
353289f6aSNate Lawson  * Module Name: aslcompile - top level compile module
453289f6aSNate Lawson  *
553289f6aSNate Lawson  *****************************************************************************/
653289f6aSNate Lawson 
70d84335fSJung-uk Kim /******************************************************************************
80d84335fSJung-uk Kim  *
90d84335fSJung-uk Kim  * 1. Copyright Notice
100d84335fSJung-uk Kim  *
11*804fe266SJung-uk Kim  * Some or all of this work - Copyright (c) 1999 - 2024, Intel Corp.
1253289f6aSNate Lawson  * All rights reserved.
1353289f6aSNate Lawson  *
140d84335fSJung-uk Kim  * 2. License
150d84335fSJung-uk Kim  *
160d84335fSJung-uk Kim  * 2.1. This is your license from Intel Corp. under its intellectual property
170d84335fSJung-uk Kim  * rights. You may have additional license terms from the party that provided
180d84335fSJung-uk Kim  * you this software, covering your right to use that party's intellectual
190d84335fSJung-uk Kim  * property rights.
200d84335fSJung-uk Kim  *
210d84335fSJung-uk Kim  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
220d84335fSJung-uk Kim  * copy of the source code appearing in this file ("Covered Code") an
230d84335fSJung-uk Kim  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
240d84335fSJung-uk Kim  * base code distributed originally by Intel ("Original Intel Code") to copy,
250d84335fSJung-uk Kim  * make derivatives, distribute, use and display any portion of the Covered
260d84335fSJung-uk Kim  * Code in any form, with the right to sublicense such rights; and
270d84335fSJung-uk Kim  *
280d84335fSJung-uk Kim  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
290d84335fSJung-uk Kim  * license (with the right to sublicense), under only those claims of Intel
300d84335fSJung-uk Kim  * patents that are infringed by the Original Intel Code, to make, use, sell,
310d84335fSJung-uk Kim  * offer to sell, and import the Covered Code and derivative works thereof
320d84335fSJung-uk Kim  * solely to the minimum extent necessary to exercise the above copyright
330d84335fSJung-uk Kim  * license, and in no event shall the patent license extend to any additions
340d84335fSJung-uk Kim  * to or modifications of the Original Intel Code. No other license or right
350d84335fSJung-uk Kim  * is granted directly or by implication, estoppel or otherwise;
360d84335fSJung-uk Kim  *
370d84335fSJung-uk Kim  * The above copyright and patent license is granted only if the following
380d84335fSJung-uk Kim  * conditions are met:
390d84335fSJung-uk Kim  *
400d84335fSJung-uk Kim  * 3. Conditions
410d84335fSJung-uk Kim  *
420d84335fSJung-uk Kim  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
430d84335fSJung-uk Kim  * Redistribution of source code of any substantial portion of the Covered
440d84335fSJung-uk Kim  * Code or modification with rights to further distribute source must include
450d84335fSJung-uk Kim  * the above Copyright Notice, the above License, this list of Conditions,
460d84335fSJung-uk Kim  * and the following Disclaimer and Export Compliance provision. In addition,
470d84335fSJung-uk Kim  * Licensee must cause all Covered Code to which Licensee contributes to
480d84335fSJung-uk Kim  * contain a file documenting the changes Licensee made to create that Covered
490d84335fSJung-uk Kim  * Code and the date of any change. Licensee must include in that file the
500d84335fSJung-uk Kim  * documentation of any changes made by any predecessor Licensee. Licensee
510d84335fSJung-uk Kim  * must include a prominent statement that the modification is derived,
520d84335fSJung-uk Kim  * directly or indirectly, from Original Intel Code.
530d84335fSJung-uk Kim  *
540d84335fSJung-uk Kim  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
550d84335fSJung-uk Kim  * Redistribution of source code of any substantial portion of the Covered
560d84335fSJung-uk Kim  * Code or modification without rights to further distribute source must
570d84335fSJung-uk Kim  * include the following Disclaimer and Export Compliance provision in the
580d84335fSJung-uk Kim  * documentation and/or other materials provided with distribution. In
590d84335fSJung-uk Kim  * addition, Licensee may not authorize further sublicense of source of any
600d84335fSJung-uk Kim  * portion of the Covered Code, and must include terms to the effect that the
610d84335fSJung-uk Kim  * license from Licensee to its licensee is limited to the intellectual
620d84335fSJung-uk Kim  * property embodied in the software Licensee provides to its licensee, and
630d84335fSJung-uk Kim  * not to intellectual property embodied in modifications its licensee may
640d84335fSJung-uk Kim  * make.
650d84335fSJung-uk Kim  *
660d84335fSJung-uk Kim  * 3.3. Redistribution of Executable. Redistribution in executable form of any
670d84335fSJung-uk Kim  * substantial portion of the Covered Code or modification must reproduce the
680d84335fSJung-uk Kim  * above Copyright Notice, and the following Disclaimer and Export Compliance
690d84335fSJung-uk Kim  * provision in the documentation and/or other materials provided with the
700d84335fSJung-uk Kim  * distribution.
710d84335fSJung-uk Kim  *
720d84335fSJung-uk Kim  * 3.4. Intel retains all right, title, and interest in and to the Original
730d84335fSJung-uk Kim  * Intel Code.
740d84335fSJung-uk Kim  *
750d84335fSJung-uk Kim  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
760d84335fSJung-uk Kim  * Intel shall be used in advertising or otherwise to promote the sale, use or
770d84335fSJung-uk Kim  * other dealings in products derived from or relating to the Covered Code
780d84335fSJung-uk Kim  * without prior written authorization from Intel.
790d84335fSJung-uk Kim  *
800d84335fSJung-uk Kim  * 4. Disclaimer and Export Compliance
810d84335fSJung-uk Kim  *
820d84335fSJung-uk Kim  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
830d84335fSJung-uk Kim  * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
840d84335fSJung-uk Kim  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
850d84335fSJung-uk Kim  * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
860d84335fSJung-uk Kim  * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
870d84335fSJung-uk Kim  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
880d84335fSJung-uk Kim  * PARTICULAR PURPOSE.
890d84335fSJung-uk Kim  *
900d84335fSJung-uk Kim  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
910d84335fSJung-uk Kim  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
920d84335fSJung-uk Kim  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
930d84335fSJung-uk Kim  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
940d84335fSJung-uk Kim  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
950d84335fSJung-uk Kim  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
960d84335fSJung-uk Kim  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
970d84335fSJung-uk Kim  * LIMITED REMEDY.
980d84335fSJung-uk Kim  *
990d84335fSJung-uk Kim  * 4.3. Licensee shall not export, either directly or indirectly, any of this
1000d84335fSJung-uk Kim  * software or system incorporating such software without first obtaining any
1010d84335fSJung-uk Kim  * required license or other approval from the U. S. Department of Commerce or
1020d84335fSJung-uk Kim  * any other agency or department of the United States Government. In the
1030d84335fSJung-uk Kim  * event Licensee exports any such software from the United States or
1040d84335fSJung-uk Kim  * re-exports any such software from a foreign destination, Licensee shall
1050d84335fSJung-uk Kim  * ensure that the distribution and export/re-export of the software is in
1060d84335fSJung-uk Kim  * compliance with all laws, regulations, orders, or other restrictions of the
1070d84335fSJung-uk Kim  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
1080d84335fSJung-uk Kim  * any of its subsidiaries will export/re-export any technical data, process,
1090d84335fSJung-uk Kim  * software, or service, directly or indirectly, to any country for which the
1100d84335fSJung-uk Kim  * United States government or any agency thereof requires an export license,
1110d84335fSJung-uk Kim  * other governmental approval, or letter of assurance, without first obtaining
1120d84335fSJung-uk Kim  * such license, approval or letter.
1130d84335fSJung-uk Kim  *
1140d84335fSJung-uk Kim  *****************************************************************************
1150d84335fSJung-uk Kim  *
1160d84335fSJung-uk Kim  * Alternatively, you may choose to be licensed under the terms of the
1170d84335fSJung-uk Kim  * following license:
1180d84335fSJung-uk Kim  *
119d244b227SJung-uk Kim  * Redistribution and use in source and binary forms, with or without
120d244b227SJung-uk Kim  * modification, are permitted provided that the following conditions
121d244b227SJung-uk Kim  * are met:
122d244b227SJung-uk Kim  * 1. Redistributions of source code must retain the above copyright
123d244b227SJung-uk Kim  *    notice, this list of conditions, and the following disclaimer,
124d244b227SJung-uk Kim  *    without modification.
125d244b227SJung-uk Kim  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126d244b227SJung-uk Kim  *    substantially similar to the "NO WARRANTY" disclaimer below
127d244b227SJung-uk Kim  *    ("Disclaimer") and any redistribution must be conditioned upon
128d244b227SJung-uk Kim  *    including a substantially similar Disclaimer requirement for further
129d244b227SJung-uk Kim  *    binary redistribution.
130d244b227SJung-uk Kim  * 3. Neither the names of the above-listed copyright holders nor the names
131d244b227SJung-uk Kim  *    of any contributors may be used to endorse or promote products derived
132d244b227SJung-uk Kim  *    from this software without specific prior written permission.
13353289f6aSNate Lawson  *
1340d84335fSJung-uk Kim  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1350d84335fSJung-uk Kim  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1360d84335fSJung-uk Kim  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1370d84335fSJung-uk Kim  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
1380d84335fSJung-uk Kim  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
1390d84335fSJung-uk Kim  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
1400d84335fSJung-uk Kim  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
1410d84335fSJung-uk Kim  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
1420d84335fSJung-uk Kim  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1430d84335fSJung-uk Kim  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1440d84335fSJung-uk Kim  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1450d84335fSJung-uk Kim  *
1460d84335fSJung-uk Kim  * Alternatively, you may choose to be licensed under the terms of the
147d244b227SJung-uk Kim  * GNU General Public License ("GPL") version 2 as published by the Free
148d244b227SJung-uk Kim  * Software Foundation.
14953289f6aSNate Lawson  *
1500d84335fSJung-uk Kim  *****************************************************************************/
151d244b227SJung-uk Kim 
152d244b227SJung-uk Kim #include <contrib/dev/acpica/compiler/aslcompiler.h>
153313a0c13SJung-uk Kim #include <contrib/dev/acpica/include/acnamesp.h>
15453289f6aSNate Lawson 
15553289f6aSNate Lawson #include <stdio.h>
156fba7fc7eSJung-uk Kim #include <time.h>
1573c1812acSJung-uk Kim #include <contrib/dev/acpica/include/acapps.h>
15853289f6aSNate Lawson 
15953289f6aSNate Lawson #define _COMPONENT          ACPI_COMPILER
16053289f6aSNate Lawson         ACPI_MODULE_NAME    ("aslcompile")
16153289f6aSNate Lawson 
162ed17e06eSJung-uk Kim /*
163ed17e06eSJung-uk Kim  * Main parser entry
164ed17e06eSJung-uk Kim  * External is here in case the parser emits the same external in the
165ed17e06eSJung-uk Kim  * generated header. (Newer versions of Bison)
166ed17e06eSJung-uk Kim  */
167ed17e06eSJung-uk Kim int
168ed17e06eSJung-uk Kim AslCompilerparse(
169ed17e06eSJung-uk Kim     void);
170ed17e06eSJung-uk Kim 
171fba7fc7eSJung-uk Kim /* Local prototypes */
172fba7fc7eSJung-uk Kim 
173fba7fc7eSJung-uk Kim static void
174fba7fc7eSJung-uk Kim CmFlushSourceCode (
175fba7fc7eSJung-uk Kim     void);
176fba7fc7eSJung-uk Kim 
17742fecd12SJung-uk Kim static void
178f38b0f21SJung-uk Kim CmDumpAllEvents (
179f38b0f21SJung-uk Kim     void);
180f38b0f21SJung-uk Kim 
18144b0f624SJung-uk Kim static void
18244b0f624SJung-uk Kim CmFinishFiles(
18344b0f624SJung-uk Kim     BOOLEAN                 DeleteAmlFile);
18444b0f624SJung-uk Kim 
18553289f6aSNate Lawson 
18653289f6aSNate Lawson /*******************************************************************************
18753289f6aSNate Lawson  *
188313a0c13SJung-uk Kim  * FUNCTION:    CmDoCompile
189313a0c13SJung-uk Kim  *
190313a0c13SJung-uk Kim  * PARAMETERS:  None
191313a0c13SJung-uk Kim  *
192313a0c13SJung-uk Kim  * RETURN:      Status (0 = OK)
193313a0c13SJung-uk Kim  *
194313a0c13SJung-uk Kim  * DESCRIPTION: This procedure performs the entire compile
195313a0c13SJung-uk Kim  *
196313a0c13SJung-uk Kim  ******************************************************************************/
197313a0c13SJung-uk Kim 
19844b0f624SJung-uk Kim ACPI_STATUS
CmDoCompile(void)199313a0c13SJung-uk Kim CmDoCompile (
200313a0c13SJung-uk Kim     void)
201313a0c13SJung-uk Kim {
202313a0c13SJung-uk Kim     UINT8                   FullCompile;
203313a0c13SJung-uk Kim     UINT8                   Event;
20444b0f624SJung-uk Kim     ASL_GLOBAL_FILE_NODE    *FileNode;
205313a0c13SJung-uk Kim 
206313a0c13SJung-uk Kim 
207313a0c13SJung-uk Kim     FullCompile = UtBeginEvent ("*** Total Compile time ***");
208313a0c13SJung-uk Kim     Event = UtBeginEvent ("Open input and output files");
209313a0c13SJung-uk Kim     UtEndEvent (Event);
210313a0c13SJung-uk Kim 
211313a0c13SJung-uk Kim     Event = UtBeginEvent ("Preprocess input file");
2126f1f1a63SJung-uk Kim     if (AslGbl_PreprocessFlag)
213313a0c13SJung-uk Kim     {
214fe0f0bbbSJung-uk Kim         /* Enter compiler name as a #define */
215fe0f0bbbSJung-uk Kim 
216fe0f0bbbSJung-uk Kim         PrAddDefine (ASL_DEFINE, "", FALSE);
217fe0f0bbbSJung-uk Kim 
218313a0c13SJung-uk Kim         /* Preprocessor */
219313a0c13SJung-uk Kim 
220313a0c13SJung-uk Kim         PrDoPreprocess ();
2216f1f1a63SJung-uk Kim         AslGbl_CurrentLineNumber = 1;
2226f1f1a63SJung-uk Kim         AslGbl_LogicalLineNumber = 1;
223f9a6772eSJung-uk Kim         AslGbl_CurrentLineOffset = 0;
2245ef50723SJung-uk Kim 
2256f1f1a63SJung-uk Kim         if (AslGbl_PreprocessOnly)
226313a0c13SJung-uk Kim         {
227313a0c13SJung-uk Kim             UtEndEvent (Event);
22844b0f624SJung-uk Kim             return (AE_OK);
229313a0c13SJung-uk Kim         }
230313a0c13SJung-uk Kim     }
231313a0c13SJung-uk Kim     UtEndEvent (Event);
232313a0c13SJung-uk Kim 
2335ef50723SJung-uk Kim 
234313a0c13SJung-uk Kim     /* Build the parse tree */
235313a0c13SJung-uk Kim 
236313a0c13SJung-uk Kim     Event = UtBeginEvent ("Parse source code and build parse tree");
237313a0c13SJung-uk Kim     AslCompilerparse();
238313a0c13SJung-uk Kim     UtEndEvent (Event);
239313a0c13SJung-uk Kim 
2401c0e1b6dSJung-uk Kim     /* Check for parser-detected syntax errors */
241313a0c13SJung-uk Kim 
2426f1f1a63SJung-uk Kim     if (AslGbl_SyntaxError)
243313a0c13SJung-uk Kim     {
2449a4bc520SJung-uk Kim         AslError (ASL_ERROR, ASL_MSG_SYNTAX, NULL,
245f8146b88SJung-uk Kim             "Compiler aborting due to parser-detected syntax error(s)\n");
24644b0f624SJung-uk Kim 
24744b0f624SJung-uk Kim         /* Flag this error in the FileNode for compilation summary */
24844b0f624SJung-uk Kim 
24944b0f624SJung-uk Kim         FileNode = FlGetCurrentFileNode ();
25044b0f624SJung-uk Kim         FileNode->ParserErrorDetected = TRUE;
25144b0f624SJung-uk Kim         AslGbl_ParserErrorDetected = TRUE;
252313a0c13SJung-uk Kim         LsDumpParseTree ();
2539a4bc520SJung-uk Kim         AePrintErrorLog(ASL_FILE_STDERR);
2549a4bc520SJung-uk Kim 
255313a0c13SJung-uk Kim         goto ErrorExit;
256313a0c13SJung-uk Kim     }
257313a0c13SJung-uk Kim 
258313a0c13SJung-uk Kim     /* Did the parse tree get successfully constructed? */
259313a0c13SJung-uk Kim 
2606f1f1a63SJung-uk Kim     if (!AslGbl_ParseTreeRoot)
261313a0c13SJung-uk Kim     {
262313a0c13SJung-uk Kim         /*
263313a0c13SJung-uk Kim          * If there are no errors, then we have some sort of
264313a0c13SJung-uk Kim          * internal problem.
265313a0c13SJung-uk Kim          */
266313a0c13SJung-uk Kim         AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL,
267313a0c13SJung-uk Kim             NULL, "- Could not resolve parse tree root node");
268313a0c13SJung-uk Kim 
269313a0c13SJung-uk Kim         goto ErrorExit;
270313a0c13SJung-uk Kim     }
271313a0c13SJung-uk Kim 
2729a4bc520SJung-uk Kim     AePrintErrorLog(ASL_FILE_STDERR);
2739a4bc520SJung-uk Kim 
274313a0c13SJung-uk Kim     /* Flush out any remaining source after parse tree is complete */
275313a0c13SJung-uk Kim 
276313a0c13SJung-uk Kim     Event = UtBeginEvent ("Flush source input");
277313a0c13SJung-uk Kim     CmFlushSourceCode ();
278313a0c13SJung-uk Kim 
2791c0e1b6dSJung-uk Kim     /* Prune the parse tree if requested (debug purposes only) */
2801c0e1b6dSJung-uk Kim 
2816f1f1a63SJung-uk Kim     if (AslGbl_PruneParseTree)
2821c0e1b6dSJung-uk Kim     {
2836f1f1a63SJung-uk Kim         AslPruneParseTree (AslGbl_PruneDepth, AslGbl_PruneType);
2841c0e1b6dSJung-uk Kim     }
2851c0e1b6dSJung-uk Kim 
286313a0c13SJung-uk Kim     /* Optional parse tree dump, compiler debug output only */
287313a0c13SJung-uk Kim 
288313a0c13SJung-uk Kim     LsDumpParseTree ();
289313a0c13SJung-uk Kim 
2909a4bc520SJung-uk Kim     AslGbl_ParserErrorDetected = FALSE;
2919a4bc520SJung-uk Kim     AslGbl_SyntaxError = FALSE;
2923ee58df5SJung-uk Kim     UtEndEvent (Event);
29344b0f624SJung-uk Kim     UtEndEvent (FullCompile);
29444b0f624SJung-uk Kim 
2959a4bc520SJung-uk Kim     AslGbl_ParserErrorDetected = FALSE;
2969a4bc520SJung-uk Kim     AslGbl_SyntaxError = FALSE;
29744b0f624SJung-uk Kim ErrorExit:
29844b0f624SJung-uk Kim     UtEndEvent (FullCompile);
29944b0f624SJung-uk Kim     return (AE_ERROR);
300313a0c13SJung-uk Kim }
301313a0c13SJung-uk Kim 
30244b0f624SJung-uk Kim 
30344b0f624SJung-uk Kim /*******************************************************************************
30444b0f624SJung-uk Kim  *
30544b0f624SJung-uk Kim  * FUNCTION:    CmDoAslMiddleAndBackEnd
30644b0f624SJung-uk Kim  *
30744b0f624SJung-uk Kim  * PARAMETERS:  None
30844b0f624SJung-uk Kim  *
30944b0f624SJung-uk Kim  * RETURN:      Status of middle-end and back-end
31044b0f624SJung-uk Kim  *
31144b0f624SJung-uk Kim  * DESCRIPTION: Perform compiler middle-end (type checking and semantic
31244b0f624SJung-uk Kim  *              analysis) and back-end (code generation)
31344b0f624SJung-uk Kim  *
31444b0f624SJung-uk Kim  ******************************************************************************/
31544b0f624SJung-uk Kim 
31644b0f624SJung-uk Kim int
CmDoAslMiddleAndBackEnd(void)31744b0f624SJung-uk Kim CmDoAslMiddleAndBackEnd (
31844b0f624SJung-uk Kim     void)
31944b0f624SJung-uk Kim {
32044b0f624SJung-uk Kim     UINT8                   Event;
32144b0f624SJung-uk Kim     ACPI_STATUS             Status;
32244b0f624SJung-uk Kim 
32344b0f624SJung-uk Kim 
324f9a6772eSJung-uk Kim     OpcGetIntegerWidth (AslGbl_ParseTreeRoot->Asl.Child);
325f9a6772eSJung-uk Kim 
326f9a6772eSJung-uk Kim     /* Pre-process parse tree for any operator transforms */
327f9a6772eSJung-uk Kim 
328f9a6772eSJung-uk Kim     Event = UtBeginEvent ("Parse tree transforms");
329f9a6772eSJung-uk Kim     DbgPrint (ASL_DEBUG_OUTPUT, "\nParse tree transforms\n\n");
330f9a6772eSJung-uk Kim     TrWalkParseTree (AslGbl_ParseTreeRoot, ASL_WALK_VISIT_TWICE,
331f9a6772eSJung-uk Kim         TrAmlTransformWalkBegin, TrAmlTransformWalkEnd, NULL);
332f9a6772eSJung-uk Kim     UtEndEvent (Event);
333f9a6772eSJung-uk Kim 
334f9a6772eSJung-uk Kim     /* Generate AML opcodes corresponding to the parse tokens */
335f9a6772eSJung-uk Kim 
336f9a6772eSJung-uk Kim     Event = UtBeginEvent ("Generate AML opcodes");
337f9a6772eSJung-uk Kim     DbgPrint (ASL_DEBUG_OUTPUT, "Generating AML opcodes\n\n");
338f9a6772eSJung-uk Kim     TrWalkParseTree (AslGbl_ParseTreeRoot, ASL_WALK_VISIT_UPWARD,
339f9a6772eSJung-uk Kim         NULL, OpcAmlOpcodeWalk, NULL);
340f9a6772eSJung-uk Kim     UtEndEvent (Event);
341f9a6772eSJung-uk Kim 
342f9a6772eSJung-uk Kim 
343313a0c13SJung-uk Kim     /* Interpret and generate all compile-time constants */
344313a0c13SJung-uk Kim 
345313a0c13SJung-uk Kim     Event = UtBeginEvent ("Constant folding via AML interpreter");
346313a0c13SJung-uk Kim     DbgPrint (ASL_DEBUG_OUTPUT,
347f8146b88SJung-uk Kim         "Interpreting compile-time constant expressions\n\n");
3487cf3e94aSJung-uk Kim 
3496f1f1a63SJung-uk Kim     if (AslGbl_FoldConstants)
3507cf3e94aSJung-uk Kim     {
3516f1f1a63SJung-uk Kim         TrWalkParseTree (AslGbl_ParseTreeRoot, ASL_WALK_VISIT_UPWARD,
352f8146b88SJung-uk Kim             NULL, OpcAmlConstantWalk, NULL);
3537cf3e94aSJung-uk Kim     }
3547cf3e94aSJung-uk Kim     else
3557cf3e94aSJung-uk Kim     {
3567cf3e94aSJung-uk Kim         DbgPrint (ASL_PARSE_OUTPUT, "    Optional folding disabled\n");
3577cf3e94aSJung-uk Kim     }
358313a0c13SJung-uk Kim     UtEndEvent (Event);
359313a0c13SJung-uk Kim 
360313a0c13SJung-uk Kim     /* Update AML opcodes if necessary, after constant folding */
361313a0c13SJung-uk Kim 
362313a0c13SJung-uk Kim     Event = UtBeginEvent ("Updating AML opcodes after constant folding");
363313a0c13SJung-uk Kim     DbgPrint (ASL_DEBUG_OUTPUT,
364f8146b88SJung-uk Kim         "Updating AML opcodes after constant folding\n\n");
3656f1f1a63SJung-uk Kim     TrWalkParseTree (AslGbl_ParseTreeRoot, ASL_WALK_VISIT_UPWARD,
366313a0c13SJung-uk Kim         NULL, OpcAmlOpcodeUpdateWalk, NULL);
367313a0c13SJung-uk Kim     UtEndEvent (Event);
368313a0c13SJung-uk Kim 
369313a0c13SJung-uk Kim     /* Calculate all AML package lengths */
370313a0c13SJung-uk Kim 
371313a0c13SJung-uk Kim     Event = UtBeginEvent ("Generate AML package lengths");
372f8146b88SJung-uk Kim     DbgPrint (ASL_DEBUG_OUTPUT, "Generating Package lengths\n\n");
3736f1f1a63SJung-uk Kim     TrWalkParseTree (AslGbl_ParseTreeRoot, ASL_WALK_VISIT_UPWARD, NULL,
374313a0c13SJung-uk Kim         LnPackageLengthWalk, NULL);
375313a0c13SJung-uk Kim     UtEndEvent (Event);
376313a0c13SJung-uk Kim 
3776f1f1a63SJung-uk Kim     if (AslGbl_ParseOnlyFlag)
378313a0c13SJung-uk Kim     {
379313a0c13SJung-uk Kim         AePrintErrorLog (ASL_FILE_STDERR);
380313a0c13SJung-uk Kim         UtDisplaySummary (ASL_FILE_STDERR);
3816f1f1a63SJung-uk Kim         if (AslGbl_DebugFlag)
382313a0c13SJung-uk Kim         {
383313a0c13SJung-uk Kim             /* Print error summary to the stdout also */
384313a0c13SJung-uk Kim 
385313a0c13SJung-uk Kim             AePrintErrorLog (ASL_FILE_STDOUT);
386313a0c13SJung-uk Kim             UtDisplaySummary (ASL_FILE_STDOUT);
387313a0c13SJung-uk Kim         }
388313a0c13SJung-uk Kim         return (0);
389313a0c13SJung-uk Kim     }
390313a0c13SJung-uk Kim 
391313a0c13SJung-uk Kim     /*
392313a0c13SJung-uk Kim      * Create an internal namespace and use it as a symbol table
393313a0c13SJung-uk Kim      */
394313a0c13SJung-uk Kim 
395313a0c13SJung-uk Kim     /* Namespace loading */
396313a0c13SJung-uk Kim 
397313a0c13SJung-uk Kim     Event = UtBeginEvent ("Create ACPI Namespace");
398f8146b88SJung-uk Kim     DbgPrint (ASL_DEBUG_OUTPUT, "Creating ACPI Namespace\n\n");
3996f1f1a63SJung-uk Kim     Status = LdLoadNamespace (AslGbl_ParseTreeRoot);
400313a0c13SJung-uk Kim     UtEndEvent (Event);
401313a0c13SJung-uk Kim     if (ACPI_FAILURE (Status))
402313a0c13SJung-uk Kim     {
40344b0f624SJung-uk Kim         return (-1);
404313a0c13SJung-uk Kim     }
405313a0c13SJung-uk Kim 
406313a0c13SJung-uk Kim     /* Namespace cross-reference */
407313a0c13SJung-uk Kim 
408f8146b88SJung-uk Kim     AslGbl_NamespaceEvent = UtBeginEvent (
409f8146b88SJung-uk Kim         "Cross reference parse tree and Namespace");
410f8146b88SJung-uk Kim     DbgPrint (ASL_DEBUG_OUTPUT, "Cross referencing namespace\n\n");
411313a0c13SJung-uk Kim     Status = XfCrossReferenceNamespace ();
412313a0c13SJung-uk Kim     if (ACPI_FAILURE (Status))
413313a0c13SJung-uk Kim     {
41444b0f624SJung-uk Kim         return (-1);
415313a0c13SJung-uk Kim     }
416313a0c13SJung-uk Kim 
417313a0c13SJung-uk Kim     /* Namespace - Check for non-referenced objects */
418313a0c13SJung-uk Kim 
419313a0c13SJung-uk Kim     LkFindUnreferencedObjects ();
420313a0c13SJung-uk Kim     UtEndEvent (AslGbl_NamespaceEvent);
421313a0c13SJung-uk Kim 
422f8146b88SJung-uk Kim     /* Resolve External Declarations */
423f8146b88SJung-uk Kim 
424f8146b88SJung-uk Kim     Event = UtBeginEvent ("Resolve all Externals");
425f8146b88SJung-uk Kim     DbgPrint (ASL_DEBUG_OUTPUT, "\nResolve Externals\n\n");
4260d84335fSJung-uk Kim 
4276f1f1a63SJung-uk Kim     if (AslGbl_DoExternalsInPlace)
4280d84335fSJung-uk Kim     {
4296f1f1a63SJung-uk Kim         TrWalkParseTree (AslGbl_ParseTreeRoot, ASL_WALK_VISIT_DOWNWARD,
4300d84335fSJung-uk Kim             ExAmlExternalWalkBegin, NULL, NULL);
4310d84335fSJung-uk Kim     }
4320d84335fSJung-uk Kim     else
4330d84335fSJung-uk Kim     {
4346f1f1a63SJung-uk Kim         TrWalkParseTree (AslGbl_ParseTreeRoot, ASL_WALK_VISIT_TWICE,
435f8146b88SJung-uk Kim             ExAmlExternalWalkBegin, ExAmlExternalWalkEnd, NULL);
4360d84335fSJung-uk Kim     }
437f8146b88SJung-uk Kim     UtEndEvent (Event);
438f8146b88SJung-uk Kim 
439313a0c13SJung-uk Kim     /*
440313a0c13SJung-uk Kim      * Semantic analysis. This can happen only after the
441313a0c13SJung-uk Kim      * namespace has been loaded and cross-referenced.
442313a0c13SJung-uk Kim      *
443313a0c13SJung-uk Kim      * part one - check control methods
444313a0c13SJung-uk Kim      */
445313a0c13SJung-uk Kim     Event = UtBeginEvent ("Analyze control method return types");
4466f1f1a63SJung-uk Kim     AslGbl_AnalysisWalkInfo.MethodStack = NULL;
447313a0c13SJung-uk Kim 
448f8146b88SJung-uk Kim     DbgPrint (ASL_DEBUG_OUTPUT, "Semantic analysis - Method analysis\n\n");
449f8146b88SJung-uk Kim 
4506f1f1a63SJung-uk Kim     if (AslGbl_CrossReferenceOutput)
451f8146b88SJung-uk Kim     {
452f8146b88SJung-uk Kim         OtPrintHeaders ("Part 1: Object Reference Map "
453f8146b88SJung-uk Kim             "(Object references from within each control method)");
454f8146b88SJung-uk Kim     }
455f8146b88SJung-uk Kim 
4566f1f1a63SJung-uk Kim     TrWalkParseTree (AslGbl_ParseTreeRoot, ASL_WALK_VISIT_TWICE,
457313a0c13SJung-uk Kim         MtMethodAnalysisWalkBegin,
4586f1f1a63SJung-uk Kim         MtMethodAnalysisWalkEnd, &AslGbl_AnalysisWalkInfo);
459313a0c13SJung-uk Kim     UtEndEvent (Event);
460313a0c13SJung-uk Kim 
461f8146b88SJung-uk Kim     /* Generate the object cross-reference file if requested */
462f8146b88SJung-uk Kim 
463f8146b88SJung-uk Kim     Event = UtBeginEvent ("Generate cross-reference file");
464f8146b88SJung-uk Kim     OtCreateXrefFile ();
465f8146b88SJung-uk Kim     UtEndEvent (Event);
466f8146b88SJung-uk Kim 
467313a0c13SJung-uk Kim     /* Semantic error checking part two - typing of method returns */
468313a0c13SJung-uk Kim 
469313a0c13SJung-uk Kim     Event = UtBeginEvent ("Determine object types returned by methods");
470f8146b88SJung-uk Kim     DbgPrint (ASL_DEBUG_OUTPUT, "Semantic analysis - Method typing\n\n");
4716f1f1a63SJung-uk Kim     TrWalkParseTree (AslGbl_ParseTreeRoot, ASL_WALK_VISIT_UPWARD,
472313a0c13SJung-uk Kim         NULL, AnMethodTypingWalkEnd, NULL);
473313a0c13SJung-uk Kim     UtEndEvent (Event);
474313a0c13SJung-uk Kim 
475313a0c13SJung-uk Kim     /* Semantic error checking part three - operand type checking */
476313a0c13SJung-uk Kim 
477313a0c13SJung-uk Kim     Event = UtBeginEvent ("Analyze AML operand types");
478f8146b88SJung-uk Kim     DbgPrint (ASL_DEBUG_OUTPUT,
479f8146b88SJung-uk Kim         "Semantic analysis - Operand type checking\n\n");
4806f1f1a63SJung-uk Kim     if (AslGbl_DoTypechecking)
481f8146b88SJung-uk Kim     {
4826f1f1a63SJung-uk Kim         TrWalkParseTree (AslGbl_ParseTreeRoot, ASL_WALK_VISIT_UPWARD,
4836f1f1a63SJung-uk Kim             NULL, AnOperandTypecheckWalkEnd, &AslGbl_AnalysisWalkInfo);
484f8146b88SJung-uk Kim     }
485313a0c13SJung-uk Kim     UtEndEvent (Event);
486313a0c13SJung-uk Kim 
487313a0c13SJung-uk Kim     /* Semantic error checking part four - other miscellaneous checks */
488313a0c13SJung-uk Kim 
489313a0c13SJung-uk Kim     Event = UtBeginEvent ("Miscellaneous analysis");
490f8146b88SJung-uk Kim     DbgPrint (ASL_DEBUG_OUTPUT, "Semantic analysis - miscellaneous\n\n");
4916f1f1a63SJung-uk Kim     TrWalkParseTree (AslGbl_ParseTreeRoot, ASL_WALK_VISIT_DOWNWARD,
492313a0c13SJung-uk Kim         AnOtherSemanticAnalysisWalkBegin,
4936f1f1a63SJung-uk Kim         NULL, &AslGbl_AnalysisWalkInfo);
494313a0c13SJung-uk Kim     UtEndEvent (Event);
495313a0c13SJung-uk Kim 
4960d84335fSJung-uk Kim     /*
4970d84335fSJung-uk Kim      * ASL-/ASL+ converter: Gbl_ParseTreeRoot->CommentList contains the
4980d84335fSJung-uk Kim      * very last comment of a given ASL file because it's the last constructed
4990d84335fSJung-uk Kim      * node during compilation. We take the very last comment and save it in a
5000d84335fSJung-uk Kim      * global for it to be used by the disassembler.
5010d84335fSJung-uk Kim      */
502f1db5ef7SJung-uk Kim     if (AcpiGbl_CaptureComments)
5030d84335fSJung-uk Kim     {
5046f1f1a63SJung-uk Kim         AcpiGbl_LastListHead = AslGbl_ParseTreeRoot->Asl.CommentList;
5056f1f1a63SJung-uk Kim         AslGbl_ParseTreeRoot->Asl.CommentList = NULL;
5060d84335fSJung-uk Kim     }
5070d84335fSJung-uk Kim 
508313a0c13SJung-uk Kim     /* Calculate all AML package lengths */
509313a0c13SJung-uk Kim 
510313a0c13SJung-uk Kim     Event = UtBeginEvent ("Finish AML package length generation");
511f8146b88SJung-uk Kim     DbgPrint (ASL_DEBUG_OUTPUT, "Generating Package lengths\n\n");
5126f1f1a63SJung-uk Kim     TrWalkParseTree (AslGbl_ParseTreeRoot, ASL_WALK_VISIT_UPWARD, NULL,
513313a0c13SJung-uk Kim         LnInitLengthsWalk, NULL);
5146f1f1a63SJung-uk Kim     TrWalkParseTree (AslGbl_ParseTreeRoot, ASL_WALK_VISIT_UPWARD, NULL,
515313a0c13SJung-uk Kim         LnPackageLengthWalk, NULL);
516313a0c13SJung-uk Kim     UtEndEvent (Event);
517313a0c13SJung-uk Kim 
518313a0c13SJung-uk Kim     /* Code generation - emit the AML */
519313a0c13SJung-uk Kim 
520313a0c13SJung-uk Kim     Event = UtBeginEvent ("Generate AML code and write output files");
521f8146b88SJung-uk Kim     DbgPrint (ASL_DEBUG_OUTPUT, "Writing AML byte code\n\n");
52244b0f624SJung-uk Kim 
52344b0f624SJung-uk Kim     AslGbl_CurrentDB = AslGbl_ParseTreeRoot->Asl.Child;
52444b0f624SJung-uk Kim 
52544b0f624SJung-uk Kim     while (AslGbl_CurrentDB)
52644b0f624SJung-uk Kim     {
52744b0f624SJung-uk Kim         switch  (FlSwitchFileSet(AslGbl_CurrentDB->Asl.Filename))
52844b0f624SJung-uk Kim         {
52944b0f624SJung-uk Kim             case SWITCH_TO_DIFFERENT_FILE:
53044b0f624SJung-uk Kim                 /*
53144b0f624SJung-uk Kim                  * Reset these parameters when definition blocks belong in
53244b0f624SJung-uk Kim                  * different files. If they belong in the same file, there is
53344b0f624SJung-uk Kim                  * no need to reset these parameters
53444b0f624SJung-uk Kim                  */
53544b0f624SJung-uk Kim                 FlSeekFile (ASL_FILE_SOURCE_OUTPUT, 0);
53644b0f624SJung-uk Kim                 AslGbl_SourceLine = 0;
53744b0f624SJung-uk Kim                 AslGbl_NextError = AslGbl_ErrorLog;
53844b0f624SJung-uk Kim 
53944b0f624SJung-uk Kim                 /* fall-through */
54044b0f624SJung-uk Kim 
54144b0f624SJung-uk Kim             case SWITCH_TO_SAME_FILE:
54244b0f624SJung-uk Kim 
543313a0c13SJung-uk Kim                 CgGenerateAmlOutput ();
54444b0f624SJung-uk Kim                 CmDoOutputFiles ();
54544b0f624SJung-uk Kim                 AslGbl_CurrentDB = AslGbl_CurrentDB->Asl.Next;
54644b0f624SJung-uk Kim 
54744b0f624SJung-uk Kim                 break;
54844b0f624SJung-uk Kim 
54944b0f624SJung-uk Kim             default: /* FILE_NOT_FOUND */
55044b0f624SJung-uk Kim 
55144b0f624SJung-uk Kim                 /* The requested file could not be found. Get out of here */
55244b0f624SJung-uk Kim 
55344b0f624SJung-uk Kim                 AslGbl_CurrentDB = NULL;
55444b0f624SJung-uk Kim                 break;
55544b0f624SJung-uk Kim         }
55644b0f624SJung-uk Kim     }
557313a0c13SJung-uk Kim     UtEndEvent (Event);
558313a0c13SJung-uk Kim 
559313a0c13SJung-uk Kim     Event = UtBeginEvent ("Write optional output files");
560313a0c13SJung-uk Kim     UtEndEvent (Event);
561313a0c13SJung-uk Kim 
562313a0c13SJung-uk Kim     return (0);
563313a0c13SJung-uk Kim }
564313a0c13SJung-uk Kim 
565313a0c13SJung-uk Kim 
566313a0c13SJung-uk Kim /*******************************************************************************
567313a0c13SJung-uk Kim  *
56853289f6aSNate Lawson  * FUNCTION:    AslCompilerSignon
56953289f6aSNate Lawson  *
57053289f6aSNate Lawson  * PARAMETERS:  FileId      - ID of the output file
57153289f6aSNate Lawson  *
57253289f6aSNate Lawson  * RETURN:      None
57353289f6aSNate Lawson  *
57453289f6aSNate Lawson  * DESCRIPTION: Display compiler signon
57553289f6aSNate Lawson  *
57653289f6aSNate Lawson  ******************************************************************************/
57753289f6aSNate Lawson 
57853289f6aSNate Lawson void
AslCompilerSignon(UINT32 FileId)57953289f6aSNate Lawson AslCompilerSignon (
58053289f6aSNate Lawson     UINT32                  FileId)
58153289f6aSNate Lawson {
58253289f6aSNate Lawson     char                    *Prefix = "";
5833c1812acSJung-uk Kim     char                    *UtilityName;
58453289f6aSNate Lawson 
58553289f6aSNate Lawson 
586fba7fc7eSJung-uk Kim     /* Set line prefix depending on the destination file type */
587fba7fc7eSJung-uk Kim 
58853289f6aSNate Lawson     switch (FileId)
58953289f6aSNate Lawson     {
59053289f6aSNate Lawson     case ASL_FILE_ASM_SOURCE_OUTPUT:
59153289f6aSNate Lawson     case ASL_FILE_ASM_INCLUDE_OUTPUT:
59253289f6aSNate Lawson 
59353289f6aSNate Lawson         Prefix = "; ";
59453289f6aSNate Lawson         break;
59553289f6aSNate Lawson 
59653289f6aSNate Lawson     case ASL_FILE_HEX_OUTPUT:
59753289f6aSNate Lawson 
5986f1f1a63SJung-uk Kim         if (AslGbl_HexOutputFlag == HEX_OUTPUT_ASM)
59953289f6aSNate Lawson         {
60053289f6aSNate Lawson             Prefix = "; ";
60153289f6aSNate Lawson         }
6026f1f1a63SJung-uk Kim         else if ((AslGbl_HexOutputFlag == HEX_OUTPUT_C) ||
6036f1f1a63SJung-uk Kim                  (AslGbl_HexOutputFlag == HEX_OUTPUT_ASL))
60453289f6aSNate Lawson         {
60553289f6aSNate Lawson             FlPrintFile (ASL_FILE_HEX_OUTPUT, "/*\n");
60653289f6aSNate Lawson             Prefix = " * ";
60753289f6aSNate Lawson         }
60853289f6aSNate Lawson         break;
60953289f6aSNate Lawson 
61053289f6aSNate Lawson     case ASL_FILE_C_SOURCE_OUTPUT:
6119c7c683cSJung-uk Kim     case ASL_FILE_C_OFFSET_OUTPUT:
61253289f6aSNate Lawson     case ASL_FILE_C_INCLUDE_OUTPUT:
61353289f6aSNate Lawson 
61453289f6aSNate Lawson         Prefix = " * ";
61553289f6aSNate Lawson         break;
61653289f6aSNate Lawson 
61753289f6aSNate Lawson     default:
618a9d8d09cSJung-uk Kim 
61953289f6aSNate Lawson         /* No other output types supported */
620a9d8d09cSJung-uk Kim 
62153289f6aSNate Lawson         break;
62253289f6aSNate Lawson     }
62353289f6aSNate Lawson 
624fba7fc7eSJung-uk Kim     /* Running compiler or disassembler? */
625fba7fc7eSJung-uk Kim 
626af051161SJung-uk Kim     if (AcpiGbl_DisasmFlag)
627fba7fc7eSJung-uk Kim     {
6283c1812acSJung-uk Kim         UtilityName = AML_DISASSEMBLER_NAME;
629fba7fc7eSJung-uk Kim     }
630fba7fc7eSJung-uk Kim     else
631fba7fc7eSJung-uk Kim     {
6323c1812acSJung-uk Kim         UtilityName = ASL_COMPILER_NAME;
633fba7fc7eSJung-uk Kim     }
634fba7fc7eSJung-uk Kim 
6353c1812acSJung-uk Kim     /* Compiler signon with copyright */
636fba7fc7eSJung-uk Kim 
6373c1812acSJung-uk Kim     FlPrintFile (FileId, "%s\n", Prefix);
6383c1812acSJung-uk Kim     FlPrintFile (FileId, ACPI_COMMON_HEADER (UtilityName, Prefix));
63953289f6aSNate Lawson }
64053289f6aSNate Lawson 
64153289f6aSNate Lawson 
64253289f6aSNate Lawson /*******************************************************************************
64353289f6aSNate Lawson  *
64453289f6aSNate Lawson  * FUNCTION:    AslCompilerFileHeader
64553289f6aSNate Lawson  *
64653289f6aSNate Lawson  * PARAMETERS:  FileId      - ID of the output file
64753289f6aSNate Lawson  *
64853289f6aSNate Lawson  * RETURN:      None
64953289f6aSNate Lawson  *
65053289f6aSNate Lawson  * DESCRIPTION: Header used at the beginning of output files
65153289f6aSNate Lawson  *
65253289f6aSNate Lawson  ******************************************************************************/
65353289f6aSNate Lawson 
65453289f6aSNate Lawson void
AslCompilerFileHeader(UINT32 FileId)65553289f6aSNate Lawson AslCompilerFileHeader (
65653289f6aSNate Lawson     UINT32                  FileId)
65753289f6aSNate Lawson {
658ec0234b4SJung-uk Kim     char                    *NewTime;
65953289f6aSNate Lawson     time_t                  Aclock;
66053289f6aSNate Lawson     char                    *Prefix = "";
66153289f6aSNate Lawson 
66253289f6aSNate Lawson 
663fba7fc7eSJung-uk Kim     /* Set line prefix depending on the destination file type */
664fba7fc7eSJung-uk Kim 
66553289f6aSNate Lawson     switch (FileId)
66653289f6aSNate Lawson     {
66753289f6aSNate Lawson     case ASL_FILE_ASM_SOURCE_OUTPUT:
66853289f6aSNate Lawson     case ASL_FILE_ASM_INCLUDE_OUTPUT:
66953289f6aSNate Lawson 
67053289f6aSNate Lawson         Prefix = "; ";
67153289f6aSNate Lawson         break;
67253289f6aSNate Lawson 
67353289f6aSNate Lawson     case ASL_FILE_HEX_OUTPUT:
67453289f6aSNate Lawson 
6756f1f1a63SJung-uk Kim         if (AslGbl_HexOutputFlag == HEX_OUTPUT_ASM)
67653289f6aSNate Lawson         {
67753289f6aSNate Lawson             Prefix = "; ";
67853289f6aSNate Lawson         }
6796f1f1a63SJung-uk Kim         else if ((AslGbl_HexOutputFlag == HEX_OUTPUT_C) ||
6806f1f1a63SJung-uk Kim                  (AslGbl_HexOutputFlag == HEX_OUTPUT_ASL))
68153289f6aSNate Lawson         {
68253289f6aSNate Lawson             Prefix = " * ";
68353289f6aSNate Lawson         }
68453289f6aSNate Lawson         break;
68553289f6aSNate Lawson 
68653289f6aSNate Lawson     case ASL_FILE_C_SOURCE_OUTPUT:
6879c7c683cSJung-uk Kim     case ASL_FILE_C_OFFSET_OUTPUT:
68853289f6aSNate Lawson     case ASL_FILE_C_INCLUDE_OUTPUT:
68953289f6aSNate Lawson 
69053289f6aSNate Lawson         Prefix = " * ";
69153289f6aSNate Lawson         break;
69253289f6aSNate Lawson 
69353289f6aSNate Lawson     default:
694a9d8d09cSJung-uk Kim 
69553289f6aSNate Lawson         /* No other output types supported */
696a9d8d09cSJung-uk Kim 
69753289f6aSNate Lawson         break;
69853289f6aSNate Lawson     }
69953289f6aSNate Lawson 
700*804fe266SJung-uk Kim     /* Compilation header (with timestamp) */
70153289f6aSNate Lawson 
70253289f6aSNate Lawson     FlPrintFile (FileId,
703*804fe266SJung-uk Kim         "%sCompilation of \"%s\"",
704ec0234b4SJung-uk Kim         Prefix, AslGbl_Files[ASL_FILE_INPUT].Filename);
705ec0234b4SJung-uk Kim 
706*804fe266SJung-uk Kim     if (!AslGbl_Deterministic)
707*804fe266SJung-uk Kim     {
708*804fe266SJung-uk Kim         Aclock = time (NULL);
709*804fe266SJung-uk Kim         NewTime = ctime (&Aclock);
710ec0234b4SJung-uk Kim         if (NewTime)
711ec0234b4SJung-uk Kim         {
712*804fe266SJung-uk Kim             FlPrintFile (FileId, " - %s%s\n", NewTime, Prefix);
713*804fe266SJung-uk Kim         }
714*804fe266SJung-uk Kim     }
715*804fe266SJung-uk Kim     else
716*804fe266SJung-uk Kim     {
717*804fe266SJung-uk Kim         FlPrintFile (FileId, "\n");
718ec0234b4SJung-uk Kim     }
71953289f6aSNate Lawson 
72053289f6aSNate Lawson     switch (FileId)
72153289f6aSNate Lawson     {
72253289f6aSNate Lawson     case ASL_FILE_C_SOURCE_OUTPUT:
7239c7c683cSJung-uk Kim     case ASL_FILE_C_OFFSET_OUTPUT:
72453289f6aSNate Lawson     case ASL_FILE_C_INCLUDE_OUTPUT:
725a9d8d09cSJung-uk Kim 
72653289f6aSNate Lawson         FlPrintFile (FileId, " */\n");
72753289f6aSNate Lawson         break;
72853289f6aSNate Lawson 
72953289f6aSNate Lawson     default:
730a9d8d09cSJung-uk Kim 
73153289f6aSNate Lawson         /* Nothing to do for other output types */
732a9d8d09cSJung-uk Kim 
73353289f6aSNate Lawson         break;
73453289f6aSNate Lawson     }
73553289f6aSNate Lawson }
73653289f6aSNate Lawson 
73753289f6aSNate Lawson 
73853289f6aSNate Lawson /*******************************************************************************
73953289f6aSNate Lawson  *
74053289f6aSNate Lawson  * FUNCTION:    CmFlushSourceCode
74153289f6aSNate Lawson  *
74253289f6aSNate Lawson  * PARAMETERS:  None
74353289f6aSNate Lawson  *
74453289f6aSNate Lawson  * RETURN:      None
74553289f6aSNate Lawson  *
74653289f6aSNate Lawson  * DESCRIPTION: Read in any remaining source code after the parse tree
74753289f6aSNate Lawson  *              has been constructed.
74853289f6aSNate Lawson  *
74953289f6aSNate Lawson  ******************************************************************************/
75053289f6aSNate Lawson 
751fba7fc7eSJung-uk Kim static void
CmFlushSourceCode(void)752fba7fc7eSJung-uk Kim CmFlushSourceCode (
753fba7fc7eSJung-uk Kim     void)
75453289f6aSNate Lawson {
75553289f6aSNate Lawson     char                    Buffer;
75653289f6aSNate Lawson 
75753289f6aSNate Lawson 
75853289f6aSNate Lawson     while (FlReadFile (ASL_FILE_INPUT, &Buffer, 1) != AE_ERROR)
75953289f6aSNate Lawson     {
760eef1b955SJung-uk Kim         AslInsertLineBuffer ((int) Buffer);
76153289f6aSNate Lawson     }
76253289f6aSNate Lawson 
763eef1b955SJung-uk Kim     AslResetCurrentLineBuffer ();
76453289f6aSNate Lawson }
76553289f6aSNate Lawson 
76653289f6aSNate Lawson 
76753289f6aSNate Lawson /*******************************************************************************
76853289f6aSNate Lawson  *
769fba7fc7eSJung-uk Kim  * FUNCTION:    CmDoOutputFiles
770fba7fc7eSJung-uk Kim  *
771fba7fc7eSJung-uk Kim  * PARAMETERS:  None
772fba7fc7eSJung-uk Kim  *
773fba7fc7eSJung-uk Kim  * RETURN:      None.
774fba7fc7eSJung-uk Kim  *
775fba7fc7eSJung-uk Kim  * DESCRIPTION: Create all "listing" type files
776fba7fc7eSJung-uk Kim  *
777fba7fc7eSJung-uk Kim  ******************************************************************************/
778fba7fc7eSJung-uk Kim 
77953289f6aSNate Lawson void
CmDoOutputFiles(void)780fba7fc7eSJung-uk Kim CmDoOutputFiles (
781fba7fc7eSJung-uk Kim     void)
78253289f6aSNate Lawson {
78353289f6aSNate Lawson 
78453289f6aSNate Lawson     /* Create listings and hex files */
78553289f6aSNate Lawson 
78653289f6aSNate Lawson     LsDoListings ();
787efcc2a30SJung-uk Kim     HxDoHexOutput ();
78853289f6aSNate Lawson 
78953289f6aSNate Lawson     /* Dump the namespace to the .nsp file if requested */
79053289f6aSNate Lawson 
791efcc2a30SJung-uk Kim     (void) NsDisplayNamespace ();
792313a0c13SJung-uk Kim 
793313a0c13SJung-uk Kim     /* Dump the device mapping file */
794313a0c13SJung-uk Kim 
795313a0c13SJung-uk Kim     MpEmitMappingInfo ();
796fba7fc7eSJung-uk Kim }
797fba7fc7eSJung-uk Kim 
798fba7fc7eSJung-uk Kim 
799fba7fc7eSJung-uk Kim /*******************************************************************************
800fba7fc7eSJung-uk Kim  *
801f38b0f21SJung-uk Kim  * FUNCTION:    CmDumpAllEvents
802fba7fc7eSJung-uk Kim  *
803f38b0f21SJung-uk Kim  * PARAMETERS:  None
804fba7fc7eSJung-uk Kim  *
805fba7fc7eSJung-uk Kim  * RETURN:      None.
806fba7fc7eSJung-uk Kim  *
807f38b0f21SJung-uk Kim  * DESCRIPTION: Dump all compiler events
808fba7fc7eSJung-uk Kim  *
809fba7fc7eSJung-uk Kim  ******************************************************************************/
810fba7fc7eSJung-uk Kim 
811fba7fc7eSJung-uk Kim static void
CmDumpAllEvents(void)812f38b0f21SJung-uk Kim CmDumpAllEvents (
813f38b0f21SJung-uk Kim     void)
814fba7fc7eSJung-uk Kim {
815f38b0f21SJung-uk Kim     ASL_EVENT_INFO          *Event;
816fba7fc7eSJung-uk Kim     UINT32                  Delta;
817f8146b88SJung-uk Kim     UINT32                  MicroSeconds;
818f8146b88SJung-uk Kim     UINT32                  MilliSeconds;
819f38b0f21SJung-uk Kim     UINT32                  i;
820fba7fc7eSJung-uk Kim 
821f38b0f21SJung-uk Kim 
822f38b0f21SJung-uk Kim     Event = AslGbl_Events;
823f38b0f21SJung-uk Kim 
824f38b0f21SJung-uk Kim     DbgPrint (ASL_DEBUG_OUTPUT, "\n\nElapsed time for major events\n\n");
8256f1f1a63SJung-uk Kim     if (AslGbl_CompileTimesFlag)
826fba7fc7eSJung-uk Kim     {
827f38b0f21SJung-uk Kim         printf ("\nElapsed time for major events\n\n");
828fba7fc7eSJung-uk Kim     }
829fba7fc7eSJung-uk Kim 
830f38b0f21SJung-uk Kim     for (i = 0; i < AslGbl_NextEvent; i++)
831f38b0f21SJung-uk Kim     {
832f38b0f21SJung-uk Kim         if (Event->Valid)
833f38b0f21SJung-uk Kim         {
834fba7fc7eSJung-uk Kim             /* Delta will be in 100-nanosecond units */
835fba7fc7eSJung-uk Kim 
836fba7fc7eSJung-uk Kim             Delta = (UINT32) (Event->EndTime - Event->StartTime);
837fba7fc7eSJung-uk Kim 
838f8146b88SJung-uk Kim             MicroSeconds = Delta / ACPI_100NSEC_PER_USEC;
839f8146b88SJung-uk Kim             MilliSeconds = Delta / ACPI_100NSEC_PER_MSEC;
840fba7fc7eSJung-uk Kim 
841fba7fc7eSJung-uk Kim             /* Round milliseconds up */
842fba7fc7eSJung-uk Kim 
843f8146b88SJung-uk Kim             if ((MicroSeconds - (MilliSeconds * ACPI_USEC_PER_MSEC)) >= 500)
844fba7fc7eSJung-uk Kim             {
845f8146b88SJung-uk Kim                 MilliSeconds++;
846fba7fc7eSJung-uk Kim             }
847fba7fc7eSJung-uk Kim 
848fba7fc7eSJung-uk Kim             DbgPrint (ASL_DEBUG_OUTPUT, "%8u usec %8u msec - %s\n",
849f8146b88SJung-uk Kim                 MicroSeconds, MilliSeconds, Event->EventName);
850f38b0f21SJung-uk Kim 
8516f1f1a63SJung-uk Kim             if (AslGbl_CompileTimesFlag)
852f38b0f21SJung-uk Kim             {
853f38b0f21SJung-uk Kim                 printf ("%8u usec %8u msec - %s\n",
854f8146b88SJung-uk Kim                     MicroSeconds, MilliSeconds, Event->EventName);
855f38b0f21SJung-uk Kim             }
856f38b0f21SJung-uk Kim         }
857f38b0f21SJung-uk Kim 
858f38b0f21SJung-uk Kim         Event++;
859f38b0f21SJung-uk Kim     }
86053289f6aSNate Lawson }
86153289f6aSNate Lawson 
86253289f6aSNate Lawson 
86353289f6aSNate Lawson /*******************************************************************************
86453289f6aSNate Lawson  *
86553289f6aSNate Lawson  * FUNCTION:    CmCleanupAndExit
86653289f6aSNate Lawson  *
86753289f6aSNate Lawson  * PARAMETERS:  None
86853289f6aSNate Lawson  *
86953289f6aSNate Lawson  * RETURN:      None.
87053289f6aSNate Lawson  *
87153289f6aSNate Lawson  * DESCRIPTION: Close all open files and exit the compiler
87253289f6aSNate Lawson  *
87353289f6aSNate Lawson  ******************************************************************************/
87453289f6aSNate Lawson 
875a009b7dcSJung-uk Kim int
CmCleanupAndExit(void)876fba7fc7eSJung-uk Kim CmCleanupAndExit (
877fba7fc7eSJung-uk Kim     void)
87853289f6aSNate Lawson {
879a009b7dcSJung-uk Kim     int                     Status = 0;
880042ff955SJung-uk Kim     BOOLEAN                 DeleteAmlFile = FALSE;
88144b0f624SJung-uk Kim     ASL_GLOBAL_FILE_NODE    *CurrentFileNode = AslGbl_FilesList;
88253289f6aSNate Lawson 
88353289f6aSNate Lawson 
88444b0f624SJung-uk Kim     /* Check if any errors occurred during compile */
88544b0f624SJung-uk Kim 
88644b0f624SJung-uk Kim     (void) AslCheckForErrorExit ();
88744b0f624SJung-uk Kim 
888eef1b955SJung-uk Kim     AePrintErrorLog (ASL_FILE_STDERR);
8896f1f1a63SJung-uk Kim     if (AslGbl_DebugFlag)
89053289f6aSNate Lawson     {
891eef1b955SJung-uk Kim         /* Print error summary to stdout also */
89253289f6aSNate Lawson 
893eef1b955SJung-uk Kim         AePrintErrorLog (ASL_FILE_STDOUT);
89453289f6aSNate Lawson     }
89553289f6aSNate Lawson 
896f38b0f21SJung-uk Kim     /* Emit compile times if enabled */
897f38b0f21SJung-uk Kim 
898f38b0f21SJung-uk Kim     CmDumpAllEvents ();
89953289f6aSNate Lawson 
9006f1f1a63SJung-uk Kim     if (AslGbl_CompileTimesFlag)
90153289f6aSNate Lawson     {
90253289f6aSNate Lawson         printf ("\nMiscellaneous compile statistics\n\n");
9036f1f1a63SJung-uk Kim         printf ("%11u : %s\n", AslGbl_TotalParseNodes, "Parse nodes");
9046f1f1a63SJung-uk Kim         printf ("%11u : %s\n", AslGbl_NsLookupCount, "Namespace searches");
9056f1f1a63SJung-uk Kim         printf ("%11u : %s\n", AslGbl_TotalNamedObjects, "Named objects");
9066f1f1a63SJung-uk Kim         printf ("%11u : %s\n", AslGbl_TotalMethods, "Control methods");
9076f1f1a63SJung-uk Kim         printf ("%11u : %s\n", AslGbl_TotalAllocations, "Memory Allocations");
9086f1f1a63SJung-uk Kim         printf ("%11u : %s\n", AslGbl_TotalAllocated, "Total allocated memory");
9096f1f1a63SJung-uk Kim         printf ("%11u : %s\n", AslGbl_TotalFolds, "Constant subtrees folded");
91053289f6aSNate Lawson         printf ("\n");
91153289f6aSNate Lawson     }
91253289f6aSNate Lawson 
9136f1f1a63SJung-uk Kim     if (AslGbl_NsLookupCount)
91453289f6aSNate Lawson     {
915a88e22b7SJung-uk Kim         DbgPrint (ASL_DEBUG_OUTPUT,
916a88e22b7SJung-uk Kim             "\n\nMiscellaneous compile statistics\n\n");
91753289f6aSNate Lawson 
918a88e22b7SJung-uk Kim         DbgPrint (ASL_DEBUG_OUTPUT,
919a88e22b7SJung-uk Kim             "%32s : %u\n", "Total Namespace searches",
9206f1f1a63SJung-uk Kim             AslGbl_NsLookupCount);
921a88e22b7SJung-uk Kim 
922a88e22b7SJung-uk Kim         DbgPrint (ASL_DEBUG_OUTPUT,
923a88e22b7SJung-uk Kim             "%32s : %u usec\n", "Time per search", ((UINT32)
924a88e22b7SJung-uk Kim             (AslGbl_Events[AslGbl_NamespaceEvent].EndTime -
925a88e22b7SJung-uk Kim                 AslGbl_Events[AslGbl_NamespaceEvent].StartTime) / 10) /
9266f1f1a63SJung-uk Kim                 AslGbl_NsLookupCount);
927a88e22b7SJung-uk Kim     }
92853289f6aSNate Lawson 
9296f1f1a63SJung-uk Kim     if (AslGbl_ExceptionCount[ASL_ERROR] > ASL_MAX_ERROR_COUNT)
93053289f6aSNate Lawson     {
931ab71bbb7SJung-uk Kim         printf ("\nMaximum error count (%d) exceeded (aslcompile.c)\n",
932a88e22b7SJung-uk Kim             ASL_MAX_ERROR_COUNT);
93353289f6aSNate Lawson     }
93453289f6aSNate Lawson 
93553289f6aSNate Lawson     UtDisplaySummary (ASL_FILE_STDOUT);
9362272d050SJung-uk Kim 
937042ff955SJung-uk Kim     /*
938a009b7dcSJung-uk Kim      * Delete the AML file if there are errors and the force AML output option
939a009b7dcSJung-uk Kim      * (-f) has not been used.
940a009b7dcSJung-uk Kim      *
941a009b7dcSJung-uk Kim      * Return -1 as a status of the compiler if no AML files are generated. If
942a009b7dcSJung-uk Kim      * the AML file is generated in the presence of errors, return 0. In the
943a009b7dcSJung-uk Kim      * latter case, the errors were ignored by the user so the compilation is
944a009b7dcSJung-uk Kim      * considered successful.
945042ff955SJung-uk Kim      */
946a009b7dcSJung-uk Kim     if (AslGbl_ParserErrorDetected || AslGbl_PreprocessOnly ||
947a009b7dcSJung-uk Kim         ((AslGbl_ExceptionCount[ASL_ERROR] > 0) &&
9486f1f1a63SJung-uk Kim         (!AslGbl_IgnoreErrors) &&
94944b0f624SJung-uk Kim         AslGbl_Files[ASL_FILE_AML_OUTPUT].Handle))
950042ff955SJung-uk Kim     {
951042ff955SJung-uk Kim         DeleteAmlFile = TRUE;
952a009b7dcSJung-uk Kim         Status = -1;
953042ff955SJung-uk Kim     }
954042ff955SJung-uk Kim 
9552272d050SJung-uk Kim     /* Close all open files */
9562272d050SJung-uk Kim 
95744b0f624SJung-uk Kim     while (CurrentFileNode)
95844b0f624SJung-uk Kim     {
959a009b7dcSJung-uk Kim         /*
960a009b7dcSJung-uk Kim          * Set the program return status based on file errors. If there are any
961a009b7dcSJung-uk Kim          * errors and during compilation, the command is not considered
962a009b7dcSJung-uk Kim          * successful.
963a009b7dcSJung-uk Kim          */
964a009b7dcSJung-uk Kim         if (Status != -1 && !AslGbl_IgnoreErrors &&
965a009b7dcSJung-uk Kim             CurrentFileNode->ParserErrorDetected)
966a009b7dcSJung-uk Kim         {
967a009b7dcSJung-uk Kim             Status = -1;
968a009b7dcSJung-uk Kim         }
969a009b7dcSJung-uk Kim 
97044b0f624SJung-uk Kim         switch  (FlSwitchFileSet (CurrentFileNode->Files[ASL_FILE_INPUT].Filename))
97144b0f624SJung-uk Kim         {
97244b0f624SJung-uk Kim             case SWITCH_TO_SAME_FILE:
97344b0f624SJung-uk Kim             case SWITCH_TO_DIFFERENT_FILE:
97444b0f624SJung-uk Kim 
97544b0f624SJung-uk Kim                 CmFinishFiles (DeleteAmlFile);
97644b0f624SJung-uk Kim                 CurrentFileNode = CurrentFileNode->Next;
97744b0f624SJung-uk Kim                 break;
97844b0f624SJung-uk Kim 
97944b0f624SJung-uk Kim             case FILE_NOT_FOUND:
98044b0f624SJung-uk Kim             default:
98144b0f624SJung-uk Kim 
98244b0f624SJung-uk Kim                 CurrentFileNode = NULL;
98344b0f624SJung-uk Kim                 break;
98444b0f624SJung-uk Kim         }
98544b0f624SJung-uk Kim     }
98644b0f624SJung-uk Kim 
98744b0f624SJung-uk Kim     /* Final cleanup after compiling one file */
98844b0f624SJung-uk Kim 
98944b0f624SJung-uk Kim     if (!AslGbl_DoAslConversion)
99044b0f624SJung-uk Kim     {
99144b0f624SJung-uk Kim         UtDeleteLocalCaches ();
99244b0f624SJung-uk Kim     }
993a009b7dcSJung-uk Kim 
994a009b7dcSJung-uk Kim     return (Status);
99544b0f624SJung-uk Kim }
99644b0f624SJung-uk Kim 
99744b0f624SJung-uk Kim 
99844b0f624SJung-uk Kim /*******************************************************************************
99944b0f624SJung-uk Kim  *
100044b0f624SJung-uk Kim  * FUNCTION:    CmFinishFiles
100144b0f624SJung-uk Kim  *
100244b0f624SJung-uk Kim  * PARAMETERS:  DeleteAmlFile
100344b0f624SJung-uk Kim  *
100444b0f624SJung-uk Kim  * RETURN:      None.
100544b0f624SJung-uk Kim  *
100644b0f624SJung-uk Kim  * DESCRIPTION: Close all open files, delete AML files depending on the
100744b0f624SJung-uk Kim  *              function parameter is true.
100844b0f624SJung-uk Kim  *
100944b0f624SJung-uk Kim  ******************************************************************************/
101044b0f624SJung-uk Kim 
101144b0f624SJung-uk Kim static void
CmFinishFiles(BOOLEAN DeleteAmlFile)101244b0f624SJung-uk Kim CmFinishFiles(
101344b0f624SJung-uk Kim     BOOLEAN                 DeleteAmlFile)
101444b0f624SJung-uk Kim {
101544b0f624SJung-uk Kim     UINT32                  i;
101644b0f624SJung-uk Kim 
101744b0f624SJung-uk Kim 
10188d744e47SJung-uk Kim     /*
10195ef50723SJung-uk Kim      * Take care with the preprocessor file (.pre), it might be the same
10208d744e47SJung-uk Kim      * as the "input" file, depending on where the compiler has terminated
10218d744e47SJung-uk Kim      * or aborted. Prevent attempt to close the same file twice in
10228d744e47SJung-uk Kim      * loop below.
10238d744e47SJung-uk Kim      */
10246f1f1a63SJung-uk Kim     if (AslGbl_Files[ASL_FILE_PREPROCESSOR].Handle ==
10256f1f1a63SJung-uk Kim         AslGbl_Files[ASL_FILE_INPUT].Handle)
10268d744e47SJung-uk Kim     {
10276f1f1a63SJung-uk Kim         AslGbl_Files[ASL_FILE_PREPROCESSOR].Handle = NULL;
10288d744e47SJung-uk Kim     }
10298d744e47SJung-uk Kim 
10308d744e47SJung-uk Kim     /* Close the standard I/O files */
10314c52cad2SJung-uk Kim 
10324c52cad2SJung-uk Kim     for (i = ASL_FILE_INPUT; i < ASL_MAX_FILE_TYPE; i++)
10332272d050SJung-uk Kim     {
103444b0f624SJung-uk Kim         /*
103544b0f624SJung-uk Kim          * Some files such as debug output files could be pointing to
103644b0f624SJung-uk Kim          * stderr or stdout. Leave these alone.
103744b0f624SJung-uk Kim          */
103844b0f624SJung-uk Kim         if (AslGbl_Files[i].Handle != stderr &&
103944b0f624SJung-uk Kim             AslGbl_Files[i].Handle != stdout)
104044b0f624SJung-uk Kim         {
10412272d050SJung-uk Kim             FlCloseFile (i);
10422272d050SJung-uk Kim         }
104344b0f624SJung-uk Kim     }
1044572c8255SJung-uk Kim 
1045572c8255SJung-uk Kim     /* Delete AML file if there are errors */
1046572c8255SJung-uk Kim 
1047042ff955SJung-uk Kim     if (DeleteAmlFile)
1048572c8255SJung-uk Kim     {
1049042ff955SJung-uk Kim         FlDeleteFile (ASL_FILE_AML_OUTPUT);
1050572c8255SJung-uk Kim     }
1051572c8255SJung-uk Kim 
10525ef50723SJung-uk Kim     /* Delete the preprocessor temp file unless full debug was specified */
10534c52cad2SJung-uk Kim 
10546f1f1a63SJung-uk Kim     if (AslGbl_PreprocessFlag && !AslGbl_KeepPreprocessorTempFile)
10554c52cad2SJung-uk Kim     {
1056042ff955SJung-uk Kim         FlDeleteFile (ASL_FILE_PREPROCESSOR);
10574c52cad2SJung-uk Kim     }
10584c52cad2SJung-uk Kim 
1059572c8255SJung-uk Kim     /*
1060572c8255SJung-uk Kim      * Delete intermediate ("combined") source file (if -ls flag not set)
1061a88e22b7SJung-uk Kim      * This file is created during normal ASL/AML compiles. It is not
1062a88e22b7SJung-uk Kim      * created by the data table compiler.
1063a88e22b7SJung-uk Kim      *
1064a88e22b7SJung-uk Kim      * If the -ls flag is set, then the .SRC file should not be deleted.
1065a88e22b7SJung-uk Kim      * In this case, Gbl_SourceOutputFlag is set to TRUE.
1066a88e22b7SJung-uk Kim      *
1067a88e22b7SJung-uk Kim      * Note: Handles are cleared by FlCloseFile above, so we look at the
1068a88e22b7SJung-uk Kim      * filename instead, to determine if the .SRC file was actually
1069a88e22b7SJung-uk Kim      * created.
1070572c8255SJung-uk Kim      */
10716f1f1a63SJung-uk Kim     if (!AslGbl_SourceOutputFlag)
1072572c8255SJung-uk Kim     {
1073042ff955SJung-uk Kim         FlDeleteFile (ASL_FILE_SOURCE_OUTPUT);
1074572c8255SJung-uk Kim     }
10750d84335fSJung-uk Kim }
1076