]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - source/compiler/aslcompile.c
Import ACPICA 20141107.
[FreeBSD/FreeBSD.git] / source / compiler / aslcompile.c
1 /******************************************************************************
2  *
3  * Module Name: aslcompile - top level compile module
4  *
5  *****************************************************************************/
6
7 /*
8  * Copyright (C) 2000 - 2014, Intel Corp.
9  * All rights reserved.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 1. Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions, and the following disclaimer,
16  *    without modification.
17  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18  *    substantially similar to the "NO WARRANTY" disclaimer below
19  *    ("Disclaimer") and any redistribution must be conditioned upon
20  *    including a substantially similar Disclaimer requirement for further
21  *    binary redistribution.
22  * 3. Neither the names of the above-listed copyright holders nor the names
23  *    of any contributors may be used to endorse or promote products derived
24  *    from this software without specific prior written permission.
25  *
26  * Alternatively, this software may be distributed under the terms of the
27  * GNU General Public License ("GPL") version 2 as published by the Free
28  * Software Foundation.
29  *
30  * NO WARRANTY
31  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41  * POSSIBILITY OF SUCH DAMAGES.
42  */
43
44 #include "aslcompiler.h"
45 #include "dtcompiler.h"
46 #include "acnamesp.h"
47
48 #include <stdio.h>
49 #include <time.h>
50 #include <acapps.h>
51
52 #define _COMPONENT          ACPI_COMPILER
53         ACPI_MODULE_NAME    ("aslcompile")
54
55 /*
56  * Main parser entry
57  * External is here in case the parser emits the same external in the
58  * generated header. (Newer versions of Bison)
59  */
60 int
61 AslCompilerparse(
62     void);
63
64 /* Local prototypes */
65
66 static void
67 CmFlushSourceCode (
68     void);
69
70 static void
71 CmDumpAllEvents (
72     void);
73
74
75 /*******************************************************************************
76  *
77  * FUNCTION:    CmDoCompile
78  *
79  * PARAMETERS:  None
80  *
81  * RETURN:      Status (0 = OK)
82  *
83  * DESCRIPTION: This procedure performs the entire compile
84  *
85  ******************************************************************************/
86
87 int
88 CmDoCompile (
89     void)
90 {
91     ACPI_STATUS             Status;
92     UINT8                   FullCompile;
93     UINT8                   Event;
94
95
96     FullCompile = UtBeginEvent ("*** Total Compile time ***");
97     Event = UtBeginEvent ("Open input and output files");
98     UtEndEvent (Event);
99
100     Event = UtBeginEvent ("Preprocess input file");
101     if (Gbl_PreprocessFlag)
102     {
103         /* Preprocessor */
104
105         PrDoPreprocess ();
106         if (Gbl_PreprocessOnly)
107         {
108             UtEndEvent (Event);
109             CmCleanupAndExit ();
110             return (0);
111         }
112     }
113     UtEndEvent (Event);
114
115     /* Build the parse tree */
116
117     Event = UtBeginEvent ("Parse source code and build parse tree");
118     AslCompilerparse();
119     UtEndEvent (Event);
120
121     /* Check for parse errors */
122
123     Status = AslCheckForErrorExit ();
124     if (ACPI_FAILURE (Status))
125     {
126         fprintf (stderr, "Compiler aborting due to parser-detected syntax error(s)\n");
127         LsDumpParseTree ();
128         goto ErrorExit;
129     }
130
131     /* Did the parse tree get successfully constructed? */
132
133     if (!RootNode)
134     {
135         /*
136          * If there are no errors, then we have some sort of
137          * internal problem.
138          */
139         AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL,
140             NULL, "- Could not resolve parse tree root node");
141
142         goto ErrorExit;
143     }
144
145     /* Flush out any remaining source after parse tree is complete */
146
147     Event = UtBeginEvent ("Flush source input");
148     CmFlushSourceCode ();
149
150     /* Prune the parse tree if requested (debug purposes only) */
151
152     if (Gbl_PruneParseTree)
153     {
154         AslPruneParseTree (Gbl_PruneDepth, Gbl_PruneType);
155     }
156
157     /* Optional parse tree dump, compiler debug output only */
158
159     LsDumpParseTree ();
160
161     OpcGetIntegerWidth (RootNode);
162     UtEndEvent (Event);
163
164     /* Pre-process parse tree for any operator transforms */
165
166     Event = UtBeginEvent ("Parse tree transforms");
167     DbgPrint (ASL_DEBUG_OUTPUT, "\nParse tree transforms\n\n");
168     TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD,
169         TrAmlTransformWalk, NULL, NULL);
170     UtEndEvent (Event);
171
172     /* Generate AML opcodes corresponding to the parse tokens */
173
174     Event = UtBeginEvent ("Generate AML opcodes");
175     DbgPrint (ASL_DEBUG_OUTPUT, "\nGenerating AML opcodes\n\n");
176     TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, NULL,
177         OpcAmlOpcodeWalk, NULL);
178     UtEndEvent (Event);
179
180     /*
181      * Now that the input is parsed, we can open the AML output file.
182      * Note: by default, the name of this file comes from the table descriptor
183      * within the input file.
184      */
185     Event = UtBeginEvent ("Open AML output file");
186     Status = FlOpenAmlOutputFile (Gbl_OutputFilenamePrefix);
187     UtEndEvent (Event);
188     if (ACPI_FAILURE (Status))
189     {
190         AePrintErrorLog (ASL_FILE_STDERR);
191         return (-1);
192     }
193
194     /* Interpret and generate all compile-time constants */
195
196     Event = UtBeginEvent ("Constant folding via AML interpreter");
197     DbgPrint (ASL_DEBUG_OUTPUT,
198         "\nInterpreting compile-time constant expressions\n\n");
199     TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD,
200         OpcAmlConstantWalk, NULL, NULL);
201     UtEndEvent (Event);
202
203     /* Update AML opcodes if necessary, after constant folding */
204
205     Event = UtBeginEvent ("Updating AML opcodes after constant folding");
206     DbgPrint (ASL_DEBUG_OUTPUT,
207         "\nUpdating AML opcodes after constant folding\n\n");
208     TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD,
209         NULL, OpcAmlOpcodeUpdateWalk, NULL);
210     UtEndEvent (Event);
211
212     /* Calculate all AML package lengths */
213
214     Event = UtBeginEvent ("Generate AML package lengths");
215     DbgPrint (ASL_DEBUG_OUTPUT, "\nGenerating Package lengths\n\n");
216     TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, NULL,
217         LnPackageLengthWalk, NULL);
218     UtEndEvent (Event);
219
220     if (Gbl_ParseOnlyFlag)
221     {
222         AePrintErrorLog (ASL_FILE_STDERR);
223         UtDisplaySummary (ASL_FILE_STDERR);
224         if (Gbl_DebugFlag)
225         {
226             /* Print error summary to the stdout also */
227
228             AePrintErrorLog (ASL_FILE_STDOUT);
229             UtDisplaySummary (ASL_FILE_STDOUT);
230         }
231         UtEndEvent (FullCompile);
232         return (0);
233     }
234
235     /*
236      * Create an internal namespace and use it as a symbol table
237      */
238
239     /* Namespace loading */
240
241     Event = UtBeginEvent ("Create ACPI Namespace");
242     Status = LdLoadNamespace (RootNode);
243     UtEndEvent (Event);
244     if (ACPI_FAILURE (Status))
245     {
246         goto ErrorExit;
247     }
248
249     /* Namespace cross-reference */
250
251     AslGbl_NamespaceEvent = UtBeginEvent ("Cross reference parse tree and Namespace");
252     Status = XfCrossReferenceNamespace ();
253     if (ACPI_FAILURE (Status))
254     {
255         goto ErrorExit;
256     }
257
258     /* Namespace - Check for non-referenced objects */
259
260     LkFindUnreferencedObjects ();
261     UtEndEvent (AslGbl_NamespaceEvent);
262
263     /*
264      * Semantic analysis. This can happen only after the
265      * namespace has been loaded and cross-referenced.
266      *
267      * part one - check control methods
268      */
269     Event = UtBeginEvent ("Analyze control method return types");
270     AnalysisWalkInfo.MethodStack = NULL;
271
272     DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - Method analysis\n\n");
273     TrWalkParseTree (RootNode, ASL_WALK_VISIT_TWICE,
274         MtMethodAnalysisWalkBegin,
275         MtMethodAnalysisWalkEnd, &AnalysisWalkInfo);
276     UtEndEvent (Event);
277
278     /* Semantic error checking part two - typing of method returns */
279
280     Event = UtBeginEvent ("Determine object types returned by methods");
281     DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - Method typing\n\n");
282     TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD,
283         NULL, AnMethodTypingWalkEnd, NULL);
284     UtEndEvent (Event);
285
286     /* Semantic error checking part three - operand type checking */
287
288     Event = UtBeginEvent ("Analyze AML operand types");
289     DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - Operand type checking\n\n");
290     TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD,
291         NULL, AnOperandTypecheckWalkEnd, &AnalysisWalkInfo);
292     UtEndEvent (Event);
293
294     /* Semantic error checking part four - other miscellaneous checks */
295
296     Event = UtBeginEvent ("Miscellaneous analysis");
297     DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - miscellaneous\n\n");
298     TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD,
299         AnOtherSemanticAnalysisWalkBegin,
300         NULL, &AnalysisWalkInfo);
301     UtEndEvent (Event);
302
303     /* Calculate all AML package lengths */
304
305     Event = UtBeginEvent ("Finish AML package length generation");
306     DbgPrint (ASL_DEBUG_OUTPUT, "\nGenerating Package lengths\n\n");
307     TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, NULL,
308         LnInitLengthsWalk, NULL);
309     TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, NULL,
310         LnPackageLengthWalk, NULL);
311     UtEndEvent (Event);
312
313     /* Code generation - emit the AML */
314
315     Event = UtBeginEvent ("Generate AML code and write output files");
316     CgGenerateAmlOutput ();
317     UtEndEvent (Event);
318
319     Event = UtBeginEvent ("Write optional output files");
320     CmDoOutputFiles ();
321     UtEndEvent (Event);
322
323     UtEndEvent (FullCompile);
324     CmCleanupAndExit ();
325     return (0);
326
327 ErrorExit:
328     UtEndEvent (FullCompile);
329     CmCleanupAndExit ();
330     return (-1);
331 }
332
333
334 /*******************************************************************************
335  *
336  * FUNCTION:    AslCompilerSignon
337  *
338  * PARAMETERS:  FileId      - ID of the output file
339  *
340  * RETURN:      None
341  *
342  * DESCRIPTION: Display compiler signon
343  *
344  ******************************************************************************/
345
346 void
347 AslCompilerSignon (
348     UINT32                  FileId)
349 {
350     char                    *Prefix = "";
351     char                    *UtilityName;
352
353
354     /* Set line prefix depending on the destination file type */
355
356     switch (FileId)
357     {
358     case ASL_FILE_ASM_SOURCE_OUTPUT:
359     case ASL_FILE_ASM_INCLUDE_OUTPUT:
360
361         Prefix = "; ";
362         break;
363
364     case ASL_FILE_HEX_OUTPUT:
365
366         if (Gbl_HexOutputFlag == HEX_OUTPUT_ASM)
367         {
368             Prefix = "; ";
369         }
370         else if ((Gbl_HexOutputFlag == HEX_OUTPUT_C) ||
371                  (Gbl_HexOutputFlag == HEX_OUTPUT_ASL))
372         {
373             FlPrintFile (ASL_FILE_HEX_OUTPUT, "/*\n");
374             Prefix = " * ";
375         }
376         break;
377
378     case ASL_FILE_C_SOURCE_OUTPUT:
379     case ASL_FILE_C_OFFSET_OUTPUT:
380     case ASL_FILE_C_INCLUDE_OUTPUT:
381
382         Prefix = " * ";
383         break;
384
385     default:
386
387         /* No other output types supported */
388
389         break;
390     }
391
392     /* Running compiler or disassembler? */
393
394     if (Gbl_DisasmFlag)
395     {
396         UtilityName = AML_DISASSEMBLER_NAME;
397     }
398     else
399     {
400         UtilityName = ASL_COMPILER_NAME;
401     }
402
403     /* Compiler signon with copyright */
404
405     FlPrintFile (FileId, "%s\n", Prefix);
406     FlPrintFile (FileId, ACPI_COMMON_HEADER (UtilityName, Prefix));
407 }
408
409
410 /*******************************************************************************
411  *
412  * FUNCTION:    AslCompilerFileHeader
413  *
414  * PARAMETERS:  FileId      - ID of the output file
415  *
416  * RETURN:      None
417  *
418  * DESCRIPTION: Header used at the beginning of output files
419  *
420  ******************************************************************************/
421
422 void
423 AslCompilerFileHeader (
424     UINT32                  FileId)
425 {
426     struct tm               *NewTime;
427     time_t                  Aclock;
428     char                    *Prefix = "";
429
430
431     /* Set line prefix depending on the destination file type */
432
433     switch (FileId)
434     {
435     case ASL_FILE_ASM_SOURCE_OUTPUT:
436     case ASL_FILE_ASM_INCLUDE_OUTPUT:
437
438         Prefix = "; ";
439         break;
440
441     case ASL_FILE_HEX_OUTPUT:
442
443         if (Gbl_HexOutputFlag == HEX_OUTPUT_ASM)
444         {
445             Prefix = "; ";
446         }
447         else if ((Gbl_HexOutputFlag == HEX_OUTPUT_C) ||
448                  (Gbl_HexOutputFlag == HEX_OUTPUT_ASL))
449         {
450             Prefix = " * ";
451         }
452         break;
453
454     case ASL_FILE_C_SOURCE_OUTPUT:
455     case ASL_FILE_C_OFFSET_OUTPUT:
456     case ASL_FILE_C_INCLUDE_OUTPUT:
457
458         Prefix = " * ";
459         break;
460
461     default:
462
463         /* No other output types supported */
464
465         break;
466     }
467
468     /* Compilation header with timestamp */
469
470     (void) time (&Aclock);
471     NewTime = localtime (&Aclock);
472
473     FlPrintFile (FileId,
474         "%sCompilation of \"%s\" - %s%s\n",
475         Prefix, Gbl_Files[ASL_FILE_INPUT].Filename, asctime (NewTime),
476         Prefix);
477
478     switch (FileId)
479     {
480     case ASL_FILE_C_SOURCE_OUTPUT:
481     case ASL_FILE_C_OFFSET_OUTPUT:
482     case ASL_FILE_C_INCLUDE_OUTPUT:
483
484         FlPrintFile (FileId, " */\n");
485         break;
486
487     default:
488
489         /* Nothing to do for other output types */
490
491         break;
492     }
493 }
494
495
496 /*******************************************************************************
497  *
498  * FUNCTION:    CmFlushSourceCode
499  *
500  * PARAMETERS:  None
501  *
502  * RETURN:      None
503  *
504  * DESCRIPTION: Read in any remaining source code after the parse tree
505  *              has been constructed.
506  *
507  ******************************************************************************/
508
509 static void
510 CmFlushSourceCode (
511     void)
512 {
513     char                    Buffer;
514
515
516     while (FlReadFile (ASL_FILE_INPUT, &Buffer, 1) != AE_ERROR)
517     {
518         AslInsertLineBuffer ((int) Buffer);
519     }
520
521     AslResetCurrentLineBuffer ();
522 }
523
524
525 /*******************************************************************************
526  *
527  * FUNCTION:    CmDoOutputFiles
528  *
529  * PARAMETERS:  None
530  *
531  * RETURN:      None.
532  *
533  * DESCRIPTION: Create all "listing" type files
534  *
535  ******************************************************************************/
536
537 void
538 CmDoOutputFiles (
539     void)
540 {
541
542     /* Create listings and hex files */
543
544     LsDoListings ();
545     HxDoHexOutput ();
546
547     /* Dump the namespace to the .nsp file if requested */
548
549     (void) NsDisplayNamespace ();
550
551     /* Dump the device mapping file */
552
553     MpEmitMappingInfo ();
554 }
555
556
557 /*******************************************************************************
558  *
559  * FUNCTION:    CmDumpAllEvents
560  *
561  * PARAMETERS:  None
562  *
563  * RETURN:      None.
564  *
565  * DESCRIPTION: Dump all compiler events
566  *
567  ******************************************************************************/
568
569 static void
570 CmDumpAllEvents (
571     void)
572 {
573     ASL_EVENT_INFO          *Event;
574     UINT32                  Delta;
575     UINT32                  USec;
576     UINT32                  MSec;
577     UINT32                  i;
578
579
580     Event = AslGbl_Events;
581
582     DbgPrint (ASL_DEBUG_OUTPUT, "\n\nElapsed time for major events\n\n");
583     if (Gbl_CompileTimesFlag)
584     {
585         printf ("\nElapsed time for major events\n\n");
586     }
587
588     for (i = 0; i < AslGbl_NextEvent; i++)
589     {
590         if (Event->Valid)
591         {
592             /* Delta will be in 100-nanosecond units */
593
594             Delta = (UINT32) (Event->EndTime - Event->StartTime);
595
596             USec = Delta / ACPI_100NSEC_PER_USEC;
597             MSec = Delta / ACPI_100NSEC_PER_MSEC;
598
599             /* Round milliseconds up */
600
601             if ((USec - (MSec * ACPI_USEC_PER_MSEC)) >= 500)
602             {
603                 MSec++;
604             }
605
606             DbgPrint (ASL_DEBUG_OUTPUT, "%8u usec %8u msec - %s\n",
607                 USec, MSec, Event->EventName);
608
609             if (Gbl_CompileTimesFlag)
610             {
611                 printf ("%8u usec %8u msec - %s\n",
612                     USec, MSec, Event->EventName);
613             }
614         }
615
616         Event++;
617     }
618 }
619
620
621 /*******************************************************************************
622  *
623  * FUNCTION:    CmCleanupAndExit
624  *
625  * PARAMETERS:  None
626  *
627  * RETURN:      None.
628  *
629  * DESCRIPTION: Close all open files and exit the compiler
630  *
631  ******************************************************************************/
632
633 void
634 CmCleanupAndExit (
635     void)
636 {
637     UINT32                  i;
638     BOOLEAN                 DeleteAmlFile = FALSE;
639
640
641     AePrintErrorLog (ASL_FILE_STDERR);
642     if (Gbl_DebugFlag)
643     {
644         /* Print error summary to stdout also */
645
646         AePrintErrorLog (ASL_FILE_STDOUT);
647     }
648
649     /* Emit compile times if enabled */
650
651     CmDumpAllEvents ();
652
653     if (Gbl_CompileTimesFlag)
654     {
655         printf ("\nMiscellaneous compile statistics\n\n");
656         printf ("%11u : %s\n", TotalParseNodes, "Parse nodes");
657         printf ("%11u : %s\n", Gbl_NsLookupCount, "Namespace searches");
658         printf ("%11u : %s\n", TotalNamedObjects, "Named objects");
659         printf ("%11u : %s\n", TotalMethods, "Control methods");
660         printf ("%11u : %s\n", TotalAllocations, "Memory Allocations");
661         printf ("%11u : %s\n", TotalAllocated, "Total allocated memory");
662         printf ("%11u : %s\n", TotalFolds, "Constant subtrees folded");
663         printf ("\n");
664     }
665
666     if (Gbl_NsLookupCount)
667     {
668         DbgPrint (ASL_DEBUG_OUTPUT,
669             "\n\nMiscellaneous compile statistics\n\n");
670
671         DbgPrint (ASL_DEBUG_OUTPUT,
672             "%32s : %u\n", "Total Namespace searches",
673             Gbl_NsLookupCount);
674
675         DbgPrint (ASL_DEBUG_OUTPUT,
676             "%32s : %u usec\n", "Time per search", ((UINT32)
677             (AslGbl_Events[AslGbl_NamespaceEvent].EndTime -
678                 AslGbl_Events[AslGbl_NamespaceEvent].StartTime) / 10) /
679                 Gbl_NsLookupCount);
680     }
681
682     if (Gbl_ExceptionCount[ASL_ERROR] > ASL_MAX_ERROR_COUNT)
683     {
684         printf ("\nMaximum error count (%u) exceeded\n",
685             ASL_MAX_ERROR_COUNT);
686     }
687
688     UtDisplaySummary (ASL_FILE_STDOUT);
689
690     /*
691      * We will delete the AML file if there are errors and the
692      * force AML output option has not been used.
693      */
694     if ((Gbl_ExceptionCount[ASL_ERROR] > 0) &&
695         (!Gbl_IgnoreErrors) &&
696         Gbl_Files[ASL_FILE_AML_OUTPUT].Handle)
697     {
698         DeleteAmlFile = TRUE;
699     }
700
701     /* Close all open files */
702
703     /*
704      * Take care with the preprocessor file (.i), it might be the same
705      * as the "input" file, depending on where the compiler has terminated
706      * or aborted. Prevent attempt to close the same file twice in
707      * loop below.
708      */
709     if (Gbl_Files[ASL_FILE_PREPROCESSOR].Handle ==
710         Gbl_Files[ASL_FILE_INPUT].Handle)
711     {
712         Gbl_Files[ASL_FILE_PREPROCESSOR].Handle = NULL;
713     }
714
715     /* Close the standard I/O files */
716
717     for (i = ASL_FILE_INPUT; i < ASL_MAX_FILE_TYPE; i++)
718     {
719         FlCloseFile (i);
720     }
721
722     /* Delete AML file if there are errors */
723
724     if (DeleteAmlFile)
725     {
726         FlDeleteFile (ASL_FILE_AML_OUTPUT);
727     }
728
729     /* Delete the preprocessor output file (.i) unless -li flag is set */
730
731     if (!Gbl_PreprocessorOutputFlag &&
732         Gbl_PreprocessFlag)
733     {
734         FlDeleteFile (ASL_FILE_PREPROCESSOR);
735     }
736
737     /*
738      * Delete intermediate ("combined") source file (if -ls flag not set)
739      * This file is created during normal ASL/AML compiles. It is not
740      * created by the data table compiler.
741      *
742      * If the -ls flag is set, then the .SRC file should not be deleted.
743      * In this case, Gbl_SourceOutputFlag is set to TRUE.
744      *
745      * Note: Handles are cleared by FlCloseFile above, so we look at the
746      * filename instead, to determine if the .SRC file was actually
747      * created.
748      *
749      * TBD: SourceOutput should be .TMP, then rename if we want to keep it?
750      */
751     if (!Gbl_SourceOutputFlag)
752     {
753         FlDeleteFile (ASL_FILE_SOURCE_OUTPUT);
754     }
755
756     /* Final cleanup after compiling one file */
757
758     CmDeleteCaches ();
759 }
760
761
762 /*******************************************************************************
763  *
764  * FUNCTION:    CmDeleteCaches
765  *
766  * PARAMETERS:  None
767  *
768  * RETURN:      None
769  *
770  * DESCRIPTION: Delete all local cache buffer blocks
771  *
772  ******************************************************************************/
773
774 void
775 CmDeleteCaches (
776     void)
777 {
778     UINT32                  BufferCount;
779     ASL_CACHE_INFO          *Next;
780
781
782     /* Parse Op cache */
783
784     BufferCount = 0;
785     while (Gbl_ParseOpCacheList)
786     {
787         Next = Gbl_ParseOpCacheList->Next;
788         ACPI_FREE (Gbl_ParseOpCacheList);
789         Gbl_ParseOpCacheList = Next;
790         BufferCount++;
791     }
792
793     DbgPrint (ASL_DEBUG_OUTPUT,
794         "%u ParseOps, Buffer size: %u ops (%u bytes), %u Buffers\n",
795         Gbl_ParseOpCount, ASL_PARSEOP_CACHE_SIZE,
796         (sizeof (ACPI_PARSE_OBJECT) * ASL_PARSEOP_CACHE_SIZE), BufferCount);
797
798     Gbl_ParseOpCount = 0;
799     Gbl_ParseOpCacheNext = NULL;
800     Gbl_ParseOpCacheLast = NULL;
801     RootNode = NULL;
802
803     /* Generic string cache */
804
805     BufferCount = 0;
806     while (Gbl_StringCacheList)
807     {
808         Next = Gbl_StringCacheList->Next;
809         ACPI_FREE (Gbl_StringCacheList);
810         Gbl_StringCacheList = Next;
811         BufferCount++;
812     }
813
814     DbgPrint (ASL_DEBUG_OUTPUT,
815         "%u Strings (%u bytes), Buffer size: %u bytes, %u Buffers\n",
816         Gbl_StringCount, Gbl_StringSize, ASL_STRING_CACHE_SIZE, BufferCount);
817
818     Gbl_StringSize = 0;
819     Gbl_StringCount = 0;
820     Gbl_StringCacheNext = NULL;
821     Gbl_StringCacheLast = NULL;
822 }