]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/contrib/dev/acpica/compiler/aslcompile.c
This commit was generated by cvs2svn to compensate for changes in r158782,
[FreeBSD/FreeBSD.git] / sys / contrib / dev / acpica / compiler / aslcompile.c
1
2 /******************************************************************************
3  *
4  * Module Name: aslcompile - top level compile module
5  *              $Revision: 1.88 $
6  *
7  *****************************************************************************/
8
9 /******************************************************************************
10  *
11  * 1. Copyright Notice
12  *
13  * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp.
14  * All rights reserved.
15  *
16  * 2. License
17  *
18  * 2.1. This is your license from Intel Corp. under its intellectual property
19  * rights.  You may have additional license terms from the party that provided
20  * you this software, covering your right to use that party's intellectual
21  * property rights.
22  *
23  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
24  * copy of the source code appearing in this file ("Covered Code") an
25  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
26  * base code distributed originally by Intel ("Original Intel Code") to copy,
27  * make derivatives, distribute, use and display any portion of the Covered
28  * Code in any form, with the right to sublicense such rights; and
29  *
30  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
31  * license (with the right to sublicense), under only those claims of Intel
32  * patents that are infringed by the Original Intel Code, to make, use, sell,
33  * offer to sell, and import the Covered Code and derivative works thereof
34  * solely to the minimum extent necessary to exercise the above copyright
35  * license, and in no event shall the patent license extend to any additions
36  * to or modifications of the Original Intel Code.  No other license or right
37  * is granted directly or by implication, estoppel or otherwise;
38  *
39  * The above copyright and patent license is granted only if the following
40  * conditions are met:
41  *
42  * 3. Conditions
43  *
44  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
45  * Redistribution of source code of any substantial portion of the Covered
46  * Code or modification with rights to further distribute source must include
47  * the above Copyright Notice, the above License, this list of Conditions,
48  * and the following Disclaimer and Export Compliance provision.  In addition,
49  * Licensee must cause all Covered Code to which Licensee contributes to
50  * contain a file documenting the changes Licensee made to create that Covered
51  * Code and the date of any change.  Licensee must include in that file the
52  * documentation of any changes made by any predecessor Licensee.  Licensee
53  * must include a prominent statement that the modification is derived,
54  * directly or indirectly, from Original Intel Code.
55  *
56  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
57  * Redistribution of source code of any substantial portion of the Covered
58  * Code or modification without rights to further distribute source must
59  * include the following Disclaimer and Export Compliance provision in the
60  * documentation and/or other materials provided with distribution.  In
61  * addition, Licensee may not authorize further sublicense of source of any
62  * portion of the Covered Code, and must include terms to the effect that the
63  * license from Licensee to its licensee is limited to the intellectual
64  * property embodied in the software Licensee provides to its licensee, and
65  * not to intellectual property embodied in modifications its licensee may
66  * make.
67  *
68  * 3.3. Redistribution of Executable. Redistribution in executable form of any
69  * substantial portion of the Covered Code or modification must reproduce the
70  * above Copyright Notice, and the following Disclaimer and Export Compliance
71  * provision in the documentation and/or other materials provided with the
72  * distribution.
73  *
74  * 3.4. Intel retains all right, title, and interest in and to the Original
75  * Intel Code.
76  *
77  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
78  * Intel shall be used in advertising or otherwise to promote the sale, use or
79  * other dealings in products derived from or relating to the Covered Code
80  * without prior written authorization from Intel.
81  *
82  * 4. Disclaimer and Export Compliance
83  *
84  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
85  * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
86  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
87  * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
88  * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
89  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
90  * PARTICULAR PURPOSE.
91  *
92  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
93  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
94  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
95  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
96  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
97  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
98  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
99  * LIMITED REMEDY.
100  *
101  * 4.3. Licensee shall not export, either directly or indirectly, any of this
102  * software or system incorporating such software without first obtaining any
103  * required license or other approval from the U. S. Department of Commerce or
104  * any other agency or department of the United States Government.  In the
105  * event Licensee exports any such software from the United States or
106  * re-exports any such software from a foreign destination, Licensee shall
107  * ensure that the distribution and export/re-export of the software is in
108  * compliance with all laws, regulations, orders, or other restrictions of the
109  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
110  * any of its subsidiaries will export/re-export any technical data, process,
111  * software, or service, directly or indirectly, to any country for which the
112  * United States government or any agency thereof requires an export license,
113  * other governmental approval, or letter of assurance, without first obtaining
114  * such license, approval or letter.
115  *
116  *****************************************************************************/
117
118 #include <stdio.h>
119 #include <time.h>
120 #include <contrib/dev/acpica/compiler/aslcompiler.h>
121
122 #define _COMPONENT          ACPI_COMPILER
123         ACPI_MODULE_NAME    ("aslcompile")
124
125 /* Local prototypes */
126
127 static void
128 CmFlushSourceCode (
129     void);
130
131 static ACPI_STATUS
132 FlCheckForAscii (
133     ASL_FILE_INFO           *FileInfo);
134
135
136 /*******************************************************************************
137  *
138  * FUNCTION:    AslCompilerSignon
139  *
140  * PARAMETERS:  FileId      - ID of the output file
141  *
142  * RETURN:      None
143  *
144  * DESCRIPTION: Display compiler signon
145  *
146  ******************************************************************************/
147
148 void
149 AslCompilerSignon (
150     UINT32                  FileId)
151 {
152     char                    *Prefix = "";
153
154
155     /* Set line prefix depending on the destination file type */
156
157     switch (FileId)
158     {
159     case ASL_FILE_ASM_SOURCE_OUTPUT:
160     case ASL_FILE_ASM_INCLUDE_OUTPUT:
161
162         Prefix = "; ";
163         break;
164
165     case ASL_FILE_HEX_OUTPUT:
166
167         if (Gbl_HexOutputFlag == HEX_OUTPUT_ASM)
168         {
169             Prefix = "; ";
170         }
171         else if (Gbl_HexOutputFlag == HEX_OUTPUT_C)
172         {
173             FlPrintFile (ASL_FILE_HEX_OUTPUT, "/*\n");
174             Prefix = " * ";
175         }
176         break;
177
178     case ASL_FILE_C_SOURCE_OUTPUT:
179     case ASL_FILE_C_INCLUDE_OUTPUT:
180
181         Prefix = " * ";
182         break;
183
184     default:
185         /* No other output types supported */
186         break;
187     }
188
189     /*
190      * Compiler signon with copyright
191      */
192     FlPrintFile (FileId,
193         "%s\n%s%s\n%s",
194         Prefix,
195         Prefix, IntelAcpiCA,
196         Prefix);
197
198     /* Running compiler or disassembler? */
199
200     if (Gbl_DisasmFlag)
201     {
202         FlPrintFile (FileId,
203             "%s", DisassemblerId);
204     }
205     else
206     {
207         FlPrintFile (FileId,
208             "%s", CompilerId);
209     }
210
211     /* Version, build date, copyright, compliance */
212
213     FlPrintFile (FileId,
214         " version %X [%s]\n%s%s\n%s%s\n%s\n",
215         (UINT32) ACPI_CA_VERSION, __DATE__,
216         Prefix, CompilerCopyright,
217         Prefix, CompilerCompliance,
218         Prefix);
219 }
220
221
222 /*******************************************************************************
223  *
224  * FUNCTION:    AslCompilerFileHeader
225  *
226  * PARAMETERS:  FileId      - ID of the output file
227  *
228  * RETURN:      None
229  *
230  * DESCRIPTION: Header used at the beginning of output files
231  *
232  ******************************************************************************/
233
234 void
235 AslCompilerFileHeader (
236     UINT32                  FileId)
237 {
238     struct tm               *NewTime;
239     time_t                  Aclock;
240     char                    *Prefix = "";
241
242
243     /* Set line prefix depending on the destination file type */
244
245     switch (FileId)
246     {
247     case ASL_FILE_ASM_SOURCE_OUTPUT:
248     case ASL_FILE_ASM_INCLUDE_OUTPUT:
249
250         Prefix = "; ";
251         break;
252
253     case ASL_FILE_HEX_OUTPUT:
254
255         if (Gbl_HexOutputFlag == HEX_OUTPUT_ASM)
256         {
257             Prefix = "; ";
258         }
259         else if (Gbl_HexOutputFlag == HEX_OUTPUT_C)
260         {
261             Prefix = " * ";
262         }
263         break;
264
265     case ASL_FILE_C_SOURCE_OUTPUT:
266     case ASL_FILE_C_INCLUDE_OUTPUT:
267
268         Prefix = " * ";
269         break;
270
271     default:
272         /* No other output types supported */
273         break;
274     }
275
276     /* Compilation header with timestamp */
277
278     (void) time (&Aclock);
279     NewTime = localtime (&Aclock);
280
281     FlPrintFile (FileId,
282         "%sCompilation of \"%s\" - %s%s\n",
283         Prefix, Gbl_Files[ASL_FILE_INPUT].Filename, asctime (NewTime),
284         Prefix);
285
286     switch (FileId)
287     {
288     case ASL_FILE_C_SOURCE_OUTPUT:
289     case ASL_FILE_C_INCLUDE_OUTPUT:
290         FlPrintFile (FileId, " */\n");
291         break;
292
293     default:
294         /* Nothing to do for other output types */
295         break;
296     }
297 }
298
299
300 /*******************************************************************************
301  *
302  * FUNCTION:    CmFlushSourceCode
303  *
304  * PARAMETERS:  None
305  *
306  * RETURN:      None
307  *
308  * DESCRIPTION: Read in any remaining source code after the parse tree
309  *              has been constructed.
310  *
311  ******************************************************************************/
312
313 static void
314 CmFlushSourceCode (
315     void)
316 {
317     char                    Buffer;
318
319
320     while (FlReadFile (ASL_FILE_INPUT, &Buffer, 1) != AE_ERROR)
321     {
322         InsertLineBuffer ((int) Buffer);
323     }
324
325     ResetCurrentLineBuffer ();
326 }
327
328
329 /*******************************************************************************
330  *
331  * FUNCTION:    FlCheckForAscii
332  *
333  * PARAMETERS:  FileInfo        - Points to an open input file
334  *
335  * RETURN:      Status
336  *
337  * DESCRIPTION: Verify that the input file is entirely ASCII.
338  *
339  ******************************************************************************/
340
341 static ACPI_STATUS
342 FlCheckForAscii (
343     ASL_FILE_INFO           *FileInfo)
344 {
345     UINT8                   Byte;
346     ACPI_SIZE               BadBytes = 0;
347     ACPI_SIZE               Offset = 0;
348
349
350     /* Read the entire file */
351
352     while (fread (&Byte, 1, 1, FileInfo->Handle))
353     {
354         /* Check for an ASCII character */
355
356         if (!isascii (Byte))
357         {
358             if (BadBytes < 10)
359             {
360                 AcpiOsPrintf (
361                     "Non-ASCII character [0x%2.2X] found at file offset 0x%8.8X\n",
362                     Byte, Offset);
363             }
364             BadBytes++;
365         }
366         Offset++;
367     }
368
369     /* Seek back to the beginning of the source file */
370
371     fseek (FileInfo->Handle, 0, SEEK_SET);
372
373     /* Were there any non-ASCII characters in the file? */
374
375     if (BadBytes)
376     {
377         AcpiOsPrintf (
378             "%d non-ASCII characters found in input file, could be a binary file\n",
379             BadBytes);
380         AslError (ASL_WARNING, ASL_MSG_NON_ASCII, NULL, FileInfo->Filename);
381         return (AE_BAD_CHARACTER);
382     }
383
384     /* File is OK */
385
386     return (AE_OK);
387 }
388
389
390 /*******************************************************************************
391  *
392  * FUNCTION:    CmDoCompile
393  *
394  * PARAMETERS:  None
395  *
396  * RETURN:      Status (0 = OK)
397  *
398  * DESCRIPTION: This procedure performs the entire compile
399  *
400  ******************************************************************************/
401
402 int
403 CmDoCompile (
404     void)
405 {
406     ACPI_STATUS             Status;
407     UINT8                   FullCompile;
408     UINT8                   Event;
409
410
411     FullCompile = UtBeginEvent ("*** Total Compile time ***");
412     Event = UtBeginEvent ("Open input and output files");
413
414     /* Open the required input and output files */
415
416     Status = FlOpenInputFile (Gbl_Files[ASL_FILE_INPUT].Filename);
417     if (ACPI_FAILURE (Status))
418     {
419         AePrintErrorLog (ASL_FILE_STDERR);
420         return -1;
421     }
422
423     /* Optional check for 100% ASCII source file */
424
425     if (Gbl_CheckForAscii)
426     {
427         /*
428          * NOTE: This code is optional because there can be "special" characters
429          * embedded in comments (such as the "copyright" symbol, 0xA9).
430          * Just emit a warning if there are non-ascii characters present.
431          */
432
433         /* Check if the input file is 100% ASCII text */
434
435         Status = FlCheckForAscii (&Gbl_Files[ASL_FILE_INPUT]);
436     }
437
438     Status = FlOpenMiscOutputFiles (Gbl_OutputFilenamePrefix);
439     if (ACPI_FAILURE (Status))
440     {
441         AePrintErrorLog (ASL_FILE_STDERR);
442         return -1;
443     }
444     UtEndEvent (Event);
445
446     /* Build the parse tree */
447
448     Event = UtBeginEvent ("Parse source code and build parse tree");
449     AslCompilerparse();
450     UtEndEvent (Event);
451
452     /* Flush out any remaining source after parse tree is complete */
453
454     Event = UtBeginEvent ("Flush source input");
455     CmFlushSourceCode ();
456
457     /* Did the parse tree get successfully constructed? */
458
459     if (!RootNode)
460     {
461         CmCleanupAndExit ();
462         return -1;
463     }
464
465     OpcGetIntegerWidth (RootNode);
466     UtEndEvent (Event);
467
468     /* Pre-process parse tree for any operator transforms */
469
470     Event = UtBeginEvent ("Parse tree transforms");
471     DbgPrint (ASL_DEBUG_OUTPUT, "\nParse tree transforms\n\n");
472     TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD,
473         TrAmlTransformWalk, NULL, NULL);
474     UtEndEvent (Event);
475
476     /* Generate AML opcodes corresponding to the parse tokens */
477
478     Event = UtBeginEvent ("Generate AML opcodes");
479     DbgPrint (ASL_DEBUG_OUTPUT, "\nGenerating AML opcodes\n\n");
480     TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, NULL,
481         OpcAmlOpcodeWalk, NULL);
482     UtEndEvent (Event);
483
484     /*
485      * Now that the input is parsed, we can open the AML output file.
486      * Note: by default, the name of this file comes from the table descriptor
487      * within the input file.
488      */
489     Event = UtBeginEvent ("Open AML output file");
490     Status = FlOpenAmlOutputFile (Gbl_OutputFilenamePrefix);
491     if (ACPI_FAILURE (Status))
492     {
493         AePrintErrorLog (ASL_FILE_STDERR);
494         return -1;
495     }
496     UtEndEvent (Event);
497
498     /* Interpret and generate all compile-time constants */
499
500     Event = UtBeginEvent ("Constant folding via AML interpreter");
501     DbgPrint (ASL_DEBUG_OUTPUT,
502         "\nInterpreting compile-time constant expressions\n\n");
503     TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD,
504         OpcAmlConstantWalk, NULL, NULL);
505     UtEndEvent (Event);
506
507     /* Update AML opcodes if necessary, after constant folding */
508
509     Event = UtBeginEvent ("Updating AML opcodes after constant folding");
510     DbgPrint (ASL_DEBUG_OUTPUT,
511         "\nUpdating AML opcodes after constant folding\n\n");
512     TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD,
513         NULL, OpcAmlOpcodeUpdateWalk, NULL);
514     UtEndEvent (Event);
515
516     /* Calculate all AML package lengths */
517
518     Event = UtBeginEvent ("Generate AML package lengths");
519     DbgPrint (ASL_DEBUG_OUTPUT, "\nGenerating Package lengths\n\n");
520     TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, NULL,
521         LnPackageLengthWalk, NULL);
522     UtEndEvent (Event);
523
524     if (Gbl_ParseOnlyFlag)
525     {
526         AePrintErrorLog (ASL_FILE_STDOUT);
527         UtDisplaySummary (ASL_FILE_STDOUT);
528         if (Gbl_DebugFlag)
529         {
530             /* Print error summary to the debug file */
531
532             AePrintErrorLog (ASL_FILE_STDERR);
533             UtDisplaySummary (ASL_FILE_STDERR);
534         }
535         return 0;
536     }
537
538     /*
539      * Create an internal namespace and use it as a symbol table
540      */
541
542     /* Namespace loading */
543
544     Event = UtBeginEvent ("Create ACPI Namespace");
545     Status = LdLoadNamespace (RootNode);
546     UtEndEvent (Event);
547     if (ACPI_FAILURE (Status))
548     {
549         return -1;
550     }
551
552     /* Namespace lookup */
553
554     AslGbl_NamespaceEvent = UtBeginEvent ("Cross reference parse tree and Namespace");
555     Status = LkCrossReferenceNamespace ();
556     UtEndEvent (AslGbl_NamespaceEvent);
557     if (ACPI_FAILURE (Status))
558     {
559         return -1;
560     }
561
562     /*
563      * Semantic analysis.  This can happen only after the
564      * namespace has been loaded and cross-referenced.
565      *
566      * part one - check control methods
567      */
568     Event = UtBeginEvent ("Analyze control method return types");
569     AnalysisWalkInfo.MethodStack = NULL;
570
571     DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - Method analysis\n\n");
572     TrWalkParseTree (RootNode, ASL_WALK_VISIT_TWICE,
573         AnMethodAnalysisWalkBegin,
574         AnMethodAnalysisWalkEnd, &AnalysisWalkInfo);
575     UtEndEvent (Event);
576
577     /* Semantic error checking part two - typing of method returns */
578
579     Event = UtBeginEvent ("Determine object types returned by methods");
580     DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - Method typing\n\n");
581     TrWalkParseTree (RootNode, ASL_WALK_VISIT_TWICE,
582         AnMethodTypingWalkBegin,
583         AnMethodTypingWalkEnd, NULL);
584     UtEndEvent (Event);
585
586     /* Semantic error checking part three - operand type checking */
587
588     Event = UtBeginEvent ("Analyze AML operand types");
589     DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - Operand type checking\n\n");
590     TrWalkParseTree (RootNode, ASL_WALK_VISIT_TWICE,
591         AnOperandTypecheckWalkBegin,
592         AnOperandTypecheckWalkEnd, &AnalysisWalkInfo);
593     UtEndEvent (Event);
594
595     /* Semantic error checking part four - other miscellaneous checks */
596
597     Event = UtBeginEvent ("Miscellaneous analysis");
598     DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - miscellaneous\n\n");
599     TrWalkParseTree (RootNode, ASL_WALK_VISIT_TWICE,
600         AnOtherSemanticAnalysisWalkBegin,
601         AnOtherSemanticAnalysisWalkEnd, &AnalysisWalkInfo);
602     UtEndEvent (Event);
603
604     /* Calculate all AML package lengths */
605
606     Event = UtBeginEvent ("Finish AML package length generation");
607     DbgPrint (ASL_DEBUG_OUTPUT, "\nGenerating Package lengths\n\n");
608     TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, NULL,
609         LnInitLengthsWalk, NULL);
610     TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, NULL,
611         LnPackageLengthWalk, NULL);
612     UtEndEvent (Event);
613
614     /* Code generation - emit the AML */
615
616     Event = UtBeginEvent ("Generate AML code and write output files");
617     CgGenerateAmlOutput ();
618     UtEndEvent (Event);
619
620     Event = UtBeginEvent ("Write optional output files");
621     CmDoOutputFiles ();
622     UtEndEvent (Event);
623
624     UtEndEvent (FullCompile);
625     CmCleanupAndExit ();
626     return 0;
627 }
628
629
630 /*******************************************************************************
631  *
632  * FUNCTION:    CmDoOutputFiles
633  *
634  * PARAMETERS:  None
635  *
636  * RETURN:      None.
637  *
638  * DESCRIPTION: Create all "listing" type files
639  *
640  ******************************************************************************/
641
642 void
643 CmDoOutputFiles (
644     void)
645 {
646
647     /* Create listings and hex files */
648
649     LsDoListings ();
650     LsDoHexOutput ();
651
652     /* Dump the namespace to the .nsp file if requested */
653
654     (void) LsDisplayNamespace ();
655 }
656
657
658 /*******************************************************************************
659  *
660  * FUNCTION:    CmDumpEvent
661  *
662  * PARAMETERS:  Event           - A compiler event struct
663  *
664  * RETURN:      None.
665  *
666  * DESCRIPTION: Dump a compiler event struct
667  *
668  ******************************************************************************/
669
670 static void
671 CmDumpEvent (
672     ASL_EVENT_INFO          *Event)
673 {
674     UINT32                  Delta;
675     UINT32                  USec;
676     UINT32                  MSec;
677
678     if (!Event->Valid)
679     {
680         return;
681     }
682
683     /* Delta will be in 100-nanosecond units */
684
685     Delta = (UINT32) (Event->EndTime - Event->StartTime);
686
687     USec = Delta / 10;
688     MSec = Delta / 10000;
689
690     /* Round milliseconds up */
691
692     if ((USec - (MSec * 1000)) >= 500)
693     {
694         MSec++;
695     }
696
697     DbgPrint (ASL_DEBUG_OUTPUT, "%8u usec %8u msec - %s\n",
698         USec, MSec, Event->EventName);
699 }
700
701
702 /*******************************************************************************
703  *
704  * FUNCTION:    CmCleanupAndExit
705  *
706  * PARAMETERS:  None
707  *
708  * RETURN:      None.
709  *
710  * DESCRIPTION: Close all open files and exit the compiler
711  *
712  ******************************************************************************/
713
714 void
715 CmCleanupAndExit (
716     void)
717 {
718     UINT32                  i;
719
720
721     AePrintErrorLog (ASL_FILE_STDOUT);
722     if (Gbl_DebugFlag)
723     {
724         /* Print error summary to the debug file */
725
726         AePrintErrorLog (ASL_FILE_STDERR);
727     }
728
729     DbgPrint (ASL_DEBUG_OUTPUT, "\n\nElapsed time for major events\n\n");
730     for (i = 0; i < AslGbl_NextEvent; i++)
731     {
732         CmDumpEvent (&AslGbl_Events[i]);
733     }
734
735     if (Gbl_CompileTimesFlag)
736     {
737         printf ("\nElapsed time for major events\n\n");
738         for (i = 0; i < AslGbl_NextEvent; i++)
739         {
740             CmDumpEvent (&AslGbl_Events[i]);
741         }
742
743         printf ("\nMiscellaneous compile statistics\n\n");
744         printf ("%11u : %s\n", TotalParseNodes, "Parse nodes");
745         printf ("%11u : %s\n", Gbl_NsLookupCount, "Namespace searches");
746         printf ("%11u : %s\n", TotalNamedObjects, "Named objects");
747         printf ("%11u : %s\n", TotalMethods, "Control methods");
748         printf ("%11u : %s\n", TotalAllocations, "Memory Allocations");
749         printf ("%11u : %s\n", TotalAllocated, "Total allocated memory");
750         printf ("%11u : %s\n", TotalFolds, "Constant subtrees folded");
751         printf ("\n");
752     }
753
754     if (Gbl_NsLookupCount)
755     {
756         DbgPrint (ASL_DEBUG_OUTPUT, "\n\nMiscellaneous compile statistics\n\n");
757         DbgPrint (ASL_DEBUG_OUTPUT, "%32s : %d\n", "Total Namespace searches",
758             Gbl_NsLookupCount);
759         DbgPrint (ASL_DEBUG_OUTPUT, "%32s : %d usec\n", "Time per search",
760             ((UINT32) (AslGbl_Events[AslGbl_NamespaceEvent].EndTime -
761                         AslGbl_Events[AslGbl_NamespaceEvent].StartTime) /
762                         10) / Gbl_NsLookupCount);
763     }
764
765     /* Close all open files */
766
767     for (i = 2; i < ASL_MAX_FILE_TYPE; i++)
768     {
769         FlCloseFile (i);
770     }
771
772     /*
773      * TBD: SourceOutput should be .TMP, then rename if we want to keep it?
774      */
775     if (!Gbl_SourceOutputFlag)
776     {
777         unlink (Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Filename);
778     }
779
780     /* Delete AML file if there are errors */
781
782     if ((Gbl_ExceptionCount[ASL_ERROR] > 0) && (!Gbl_IgnoreErrors))
783     {
784         unlink (Gbl_Files[ASL_FILE_AML_OUTPUT].Filename);
785     }
786
787     if (Gbl_ExceptionCount[ASL_ERROR] > ASL_MAX_ERROR_COUNT)
788     {
789         printf ("\nMaximum error count (%d) exceeded.\n", ASL_MAX_ERROR_COUNT);
790     }
791
792     UtDisplaySummary (ASL_FILE_STDOUT);
793
794     if (Gbl_ExceptionCount[ASL_ERROR] > 0)
795     {
796         exit (1);
797     }
798     exit (0);
799 }
800
801