acpica.library: Initial import of Intel ACPICA, v20131115
[AROS.git] / arch / all-pc / acpica / source / compiler / aslcompile.c
blob6aa8701ddc36b344c31e84291bdbcd98086230b9
1 /******************************************************************************
3 * Module Name: aslcompile - top level compile module
5 *****************************************************************************/
7 /*
8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved.
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.
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.
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.
44 #include "aslcompiler.h"
45 #include "dtcompiler.h"
47 #include <stdio.h>
48 #include <time.h>
49 #include <acapps.h>
51 #define _COMPONENT ACPI_COMPILER
52 ACPI_MODULE_NAME ("aslcompile")
55 * Main parser entry
56 * External is here in case the parser emits the same external in the
57 * generated header. (Newer versions of Bison)
59 int
60 AslCompilerparse(
61 void);
63 /* Local prototypes */
65 static void
66 CmFlushSourceCode (
67 void);
69 static void
70 FlConsumeAnsiComment (
71 FILE *Handle,
72 ASL_FILE_STATUS *Status);
74 static void
75 FlConsumeNewComment (
76 FILE *Handle,
77 ASL_FILE_STATUS *Status);
79 static void
80 CmDumpAllEvents (
81 void);
84 /*******************************************************************************
86 * FUNCTION: AslCompilerSignon
88 * PARAMETERS: FileId - ID of the output file
90 * RETURN: None
92 * DESCRIPTION: Display compiler signon
94 ******************************************************************************/
96 void
97 AslCompilerSignon (
98 UINT32 FileId)
100 char *Prefix = "";
101 char *UtilityName;
104 /* Set line prefix depending on the destination file type */
106 switch (FileId)
108 case ASL_FILE_ASM_SOURCE_OUTPUT:
109 case ASL_FILE_ASM_INCLUDE_OUTPUT:
111 Prefix = "; ";
112 break;
114 case ASL_FILE_HEX_OUTPUT:
116 if (Gbl_HexOutputFlag == HEX_OUTPUT_ASM)
118 Prefix = "; ";
120 else if ((Gbl_HexOutputFlag == HEX_OUTPUT_C) ||
121 (Gbl_HexOutputFlag == HEX_OUTPUT_ASL))
123 FlPrintFile (ASL_FILE_HEX_OUTPUT, "/*\n");
124 Prefix = " * ";
126 break;
128 case ASL_FILE_C_SOURCE_OUTPUT:
129 case ASL_FILE_C_OFFSET_OUTPUT:
130 case ASL_FILE_C_INCLUDE_OUTPUT:
132 Prefix = " * ";
133 break;
135 default:
137 /* No other output types supported */
139 break;
142 /* Running compiler or disassembler? */
144 if (Gbl_DisasmFlag)
146 UtilityName = AML_DISASSEMBLER_NAME;
148 else
150 UtilityName = ASL_COMPILER_NAME;
153 /* Compiler signon with copyright */
155 FlPrintFile (FileId, "%s\n", Prefix);
156 FlPrintFile (FileId, ACPI_COMMON_HEADER (UtilityName, Prefix));
160 /*******************************************************************************
162 * FUNCTION: AslCompilerFileHeader
164 * PARAMETERS: FileId - ID of the output file
166 * RETURN: None
168 * DESCRIPTION: Header used at the beginning of output files
170 ******************************************************************************/
172 void
173 AslCompilerFileHeader (
174 UINT32 FileId)
176 struct tm *NewTime;
177 time_t Aclock;
178 char *Prefix = "";
181 /* Set line prefix depending on the destination file type */
183 switch (FileId)
185 case ASL_FILE_ASM_SOURCE_OUTPUT:
186 case ASL_FILE_ASM_INCLUDE_OUTPUT:
188 Prefix = "; ";
189 break;
191 case ASL_FILE_HEX_OUTPUT:
193 if (Gbl_HexOutputFlag == HEX_OUTPUT_ASM)
195 Prefix = "; ";
197 else if ((Gbl_HexOutputFlag == HEX_OUTPUT_C) ||
198 (Gbl_HexOutputFlag == HEX_OUTPUT_ASL))
200 Prefix = " * ";
202 break;
204 case ASL_FILE_C_SOURCE_OUTPUT:
205 case ASL_FILE_C_OFFSET_OUTPUT:
206 case ASL_FILE_C_INCLUDE_OUTPUT:
208 Prefix = " * ";
209 break;
211 default:
213 /* No other output types supported */
215 break;
218 /* Compilation header with timestamp */
220 (void) time (&Aclock);
221 NewTime = localtime (&Aclock);
223 FlPrintFile (FileId,
224 "%sCompilation of \"%s\" - %s%s\n",
225 Prefix, Gbl_Files[ASL_FILE_INPUT].Filename, asctime (NewTime),
226 Prefix);
228 switch (FileId)
230 case ASL_FILE_C_SOURCE_OUTPUT:
231 case ASL_FILE_C_OFFSET_OUTPUT:
232 case ASL_FILE_C_INCLUDE_OUTPUT:
234 FlPrintFile (FileId, " */\n");
235 break;
237 default:
239 /* Nothing to do for other output types */
241 break;
246 /*******************************************************************************
248 * FUNCTION: CmFlushSourceCode
250 * PARAMETERS: None
252 * RETURN: None
254 * DESCRIPTION: Read in any remaining source code after the parse tree
255 * has been constructed.
257 ******************************************************************************/
259 static void
260 CmFlushSourceCode (
261 void)
263 char Buffer;
266 while (FlReadFile (ASL_FILE_INPUT, &Buffer, 1) != AE_ERROR)
268 AslInsertLineBuffer ((int) Buffer);
271 AslResetCurrentLineBuffer ();
275 /*******************************************************************************
277 * FUNCTION: FlConsume*
279 * PARAMETERS: Handle - Open input file
280 * Status - File current status struct
282 * RETURN: Number of lines consumed
284 * DESCRIPTION: Step over both types of comment during check for ascii chars
286 ******************************************************************************/
288 static void
289 FlConsumeAnsiComment (
290 FILE *Handle,
291 ASL_FILE_STATUS *Status)
293 UINT8 Byte;
294 BOOLEAN ClosingComment = FALSE;
297 while (fread (&Byte, 1, 1, Handle) == 1)
299 /* Scan until comment close is found */
301 if (ClosingComment)
303 if (Byte == '/')
305 return;
308 if (Byte != '*')
310 /* Reset */
312 ClosingComment = FALSE;
315 else if (Byte == '*')
317 ClosingComment = TRUE;
320 /* Maintain line count */
322 if (Byte == 0x0A)
324 Status->Line++;
327 Status->Offset++;
332 static void
333 FlConsumeNewComment (
334 FILE *Handle,
335 ASL_FILE_STATUS *Status)
337 UINT8 Byte;
340 while (fread (&Byte, 1, 1, Handle) == 1)
342 Status->Offset++;
344 /* Comment ends at newline */
346 if (Byte == 0x0A)
348 Status->Line++;
349 return;
355 /*******************************************************************************
357 * FUNCTION: FlCheckForAcpiTable
359 * PARAMETERS: Handle - Open input file
361 * RETURN: Status
363 * DESCRIPTION: Determine if a file seems to be a binary ACPI table, via the
364 * following checks on what would be the table header:
365 * 0) File must be at least as long as an ACPI_TABLE_HEADER
366 * 1) The header length field must match the file size
367 * 2) Signature, OemId, OemTableId, AslCompilerId must be ASCII
369 ******************************************************************************/
371 ACPI_STATUS
372 FlCheckForAcpiTable (
373 FILE *Handle)
375 ACPI_TABLE_HEADER Table;
376 UINT32 FileSize;
377 size_t Actual;
378 UINT32 i;
381 /* Read a potential table header */
383 Actual = fread (&Table, 1, sizeof (ACPI_TABLE_HEADER), Handle);
384 fseek (Handle, 0, SEEK_SET);
386 if (Actual < sizeof (ACPI_TABLE_HEADER))
388 return (AE_ERROR);
391 /* Header length field must match the file size */
393 FileSize = DtGetFileSize (Handle);
394 if (Table.Length != FileSize)
396 return (AE_ERROR);
400 * These fields must be ASCII:
401 * Signature, OemId, OemTableId, AslCompilerId.
402 * We allow a NULL terminator in OemId and OemTableId.
404 for (i = 0; i < ACPI_NAME_SIZE; i++)
406 if (!ACPI_IS_ASCII ((UINT8) Table.Signature[i]))
408 return (AE_ERROR);
411 if (!ACPI_IS_ASCII ((UINT8) Table.AslCompilerId[i]))
413 return (AE_ERROR);
417 for (i = 0; (i < ACPI_OEM_ID_SIZE) && (Table.OemId[i]); i++)
419 if (!ACPI_IS_ASCII ((UINT8) Table.OemId[i]))
421 return (AE_ERROR);
425 for (i = 0; (i < ACPI_OEM_TABLE_ID_SIZE) && (Table.OemTableId[i]); i++)
427 if (!ACPI_IS_ASCII ((UINT8) Table.OemTableId[i]))
429 return (AE_ERROR);
433 printf ("Binary file appears to be a valid ACPI table, disassembling\n");
434 return (AE_OK);
438 /*******************************************************************************
440 * FUNCTION: FlCheckForAscii
442 * PARAMETERS: Handle - Open input file
443 * Filename - Input filename
444 * DisplayErrors - TRUE if error messages desired
446 * RETURN: Status
448 * DESCRIPTION: Verify that the input file is entirely ASCII. Ignores characters
449 * within comments. Note: does not handle nested comments and does
450 * not handle comment delimiters within string literals. However,
451 * on the rare chance this happens and an invalid character is
452 * missed, the parser will catch the error by failing in some
453 * spectactular manner.
455 ******************************************************************************/
457 ACPI_STATUS
458 FlCheckForAscii (
459 FILE *Handle,
460 char *Filename,
461 BOOLEAN DisplayErrors)
463 UINT8 Byte;
464 ACPI_SIZE BadBytes = 0;
465 BOOLEAN OpeningComment = FALSE;
466 ASL_FILE_STATUS Status;
469 Status.Line = 1;
470 Status.Offset = 0;
472 /* Read the entire file */
474 while (fread (&Byte, 1, 1, Handle) == 1)
476 /* Ignore comment fields (allow non-ascii within) */
478 if (OpeningComment)
480 /* Check for second comment open delimiter */
482 if (Byte == '*')
484 FlConsumeAnsiComment (Handle, &Status);
487 if (Byte == '/')
489 FlConsumeNewComment (Handle, &Status);
492 /* Reset */
494 OpeningComment = FALSE;
496 else if (Byte == '/')
498 OpeningComment = TRUE;
501 /* Check for an ASCII character */
503 if (!ACPI_IS_ASCII (Byte))
505 if ((BadBytes < 10) && (DisplayErrors))
507 AcpiOsPrintf (
508 "Non-ASCII character [0x%2.2X] found in line %u, file offset 0x%.2X\n",
509 Byte, Status.Line, Status.Offset);
512 BadBytes++;
515 /* Update line counter */
517 else if (Byte == 0x0A)
519 Status.Line++;
522 Status.Offset++;
525 /* Seek back to the beginning of the source file */
527 fseek (Handle, 0, SEEK_SET);
529 /* Were there any non-ASCII characters in the file? */
531 if (BadBytes)
533 if (DisplayErrors)
535 AcpiOsPrintf (
536 "%u non-ASCII characters found in input source text, could be a binary file\n",
537 BadBytes);
538 AslError (ASL_ERROR, ASL_MSG_NON_ASCII, NULL, Filename);
541 return (AE_BAD_CHARACTER);
544 /* File is OK (100% ASCII) */
546 return (AE_OK);
550 /*******************************************************************************
552 * FUNCTION: CmDoCompile
554 * PARAMETERS: None
556 * RETURN: Status (0 = OK)
558 * DESCRIPTION: This procedure performs the entire compile
560 ******************************************************************************/
563 CmDoCompile (
564 void)
566 ACPI_STATUS Status;
567 UINT8 FullCompile;
568 UINT8 Event;
571 FullCompile = UtBeginEvent ("*** Total Compile time ***");
572 Event = UtBeginEvent ("Open input and output files");
573 UtEndEvent (Event);
575 Event = UtBeginEvent ("Preprocess input file");
576 if (Gbl_PreprocessFlag)
578 /* Preprocessor */
580 PrDoPreprocess ();
581 if (Gbl_PreprocessOnly)
583 UtEndEvent (Event);
584 CmCleanupAndExit ();
585 return (0);
588 UtEndEvent (Event);
590 /* Build the parse tree */
592 Event = UtBeginEvent ("Parse source code and build parse tree");
593 AslCompilerparse();
594 UtEndEvent (Event);
596 /* Check for parse errors */
598 Status = AslCheckForErrorExit ();
599 if (ACPI_FAILURE (Status))
601 fprintf (stderr, "Compiler aborting due to parser-detected syntax error(s)\n");
602 LsDumpParseTree ();
603 goto ErrorExit;
606 /* Did the parse tree get successfully constructed? */
608 if (!RootNode)
611 * If there are no errors, then we have some sort of
612 * internal problem.
614 AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL,
615 NULL, "- Could not resolve parse tree root node");
617 goto ErrorExit;
621 /* Flush out any remaining source after parse tree is complete */
623 Event = UtBeginEvent ("Flush source input");
624 CmFlushSourceCode ();
626 /* Optional parse tree dump, compiler debug output only */
628 LsDumpParseTree ();
630 OpcGetIntegerWidth (RootNode);
631 UtEndEvent (Event);
633 /* Pre-process parse tree for any operator transforms */
635 Event = UtBeginEvent ("Parse tree transforms");
636 DbgPrint (ASL_DEBUG_OUTPUT, "\nParse tree transforms\n\n");
637 TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD,
638 TrAmlTransformWalk, NULL, NULL);
639 UtEndEvent (Event);
641 /* Generate AML opcodes corresponding to the parse tokens */
643 Event = UtBeginEvent ("Generate AML opcodes");
644 DbgPrint (ASL_DEBUG_OUTPUT, "\nGenerating AML opcodes\n\n");
645 TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, NULL,
646 OpcAmlOpcodeWalk, NULL);
647 UtEndEvent (Event);
650 * Now that the input is parsed, we can open the AML output file.
651 * Note: by default, the name of this file comes from the table descriptor
652 * within the input file.
654 Event = UtBeginEvent ("Open AML output file");
655 Status = FlOpenAmlOutputFile (Gbl_OutputFilenamePrefix);
656 UtEndEvent (Event);
657 if (ACPI_FAILURE (Status))
659 AePrintErrorLog (ASL_FILE_STDERR);
660 return (-1);
663 /* Interpret and generate all compile-time constants */
665 Event = UtBeginEvent ("Constant folding via AML interpreter");
666 DbgPrint (ASL_DEBUG_OUTPUT,
667 "\nInterpreting compile-time constant expressions\n\n");
668 TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD,
669 OpcAmlConstantWalk, NULL, NULL);
670 UtEndEvent (Event);
672 /* Update AML opcodes if necessary, after constant folding */
674 Event = UtBeginEvent ("Updating AML opcodes after constant folding");
675 DbgPrint (ASL_DEBUG_OUTPUT,
676 "\nUpdating AML opcodes after constant folding\n\n");
677 TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD,
678 NULL, OpcAmlOpcodeUpdateWalk, NULL);
679 UtEndEvent (Event);
681 /* Calculate all AML package lengths */
683 Event = UtBeginEvent ("Generate AML package lengths");
684 DbgPrint (ASL_DEBUG_OUTPUT, "\nGenerating Package lengths\n\n");
685 TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, NULL,
686 LnPackageLengthWalk, NULL);
687 UtEndEvent (Event);
689 if (Gbl_ParseOnlyFlag)
691 AePrintErrorLog (ASL_FILE_STDERR);
692 UtDisplaySummary (ASL_FILE_STDERR);
693 if (Gbl_DebugFlag)
695 /* Print error summary to the stdout also */
697 AePrintErrorLog (ASL_FILE_STDOUT);
698 UtDisplaySummary (ASL_FILE_STDOUT);
700 UtEndEvent (FullCompile);
701 return (0);
705 * Create an internal namespace and use it as a symbol table
708 /* Namespace loading */
710 Event = UtBeginEvent ("Create ACPI Namespace");
711 Status = LdLoadNamespace (RootNode);
712 UtEndEvent (Event);
713 if (ACPI_FAILURE (Status))
715 goto ErrorExit;
718 /* Namespace cross-reference */
720 AslGbl_NamespaceEvent = UtBeginEvent ("Cross reference parse tree and Namespace");
721 Status = XfCrossReferenceNamespace ();
722 if (ACPI_FAILURE (Status))
724 goto ErrorExit;
727 /* Namespace - Check for non-referenced objects */
729 LkFindUnreferencedObjects ();
730 UtEndEvent (AslGbl_NamespaceEvent);
733 * Semantic analysis. This can happen only after the
734 * namespace has been loaded and cross-referenced.
736 * part one - check control methods
738 Event = UtBeginEvent ("Analyze control method return types");
739 AnalysisWalkInfo.MethodStack = NULL;
741 DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - Method analysis\n\n");
742 TrWalkParseTree (RootNode, ASL_WALK_VISIT_TWICE,
743 MtMethodAnalysisWalkBegin,
744 MtMethodAnalysisWalkEnd, &AnalysisWalkInfo);
745 UtEndEvent (Event);
747 /* Semantic error checking part two - typing of method returns */
749 Event = UtBeginEvent ("Determine object types returned by methods");
750 DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - Method typing\n\n");
751 TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD,
752 NULL, AnMethodTypingWalkEnd, NULL);
753 UtEndEvent (Event);
755 /* Semantic error checking part three - operand type checking */
757 Event = UtBeginEvent ("Analyze AML operand types");
758 DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - Operand type checking\n\n");
759 TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD,
760 NULL, AnOperandTypecheckWalkEnd, &AnalysisWalkInfo);
761 UtEndEvent (Event);
763 /* Semantic error checking part four - other miscellaneous checks */
765 Event = UtBeginEvent ("Miscellaneous analysis");
766 DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - miscellaneous\n\n");
767 TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD,
768 AnOtherSemanticAnalysisWalkBegin,
769 NULL, &AnalysisWalkInfo);
770 UtEndEvent (Event);
772 /* Calculate all AML package lengths */
774 Event = UtBeginEvent ("Finish AML package length generation");
775 DbgPrint (ASL_DEBUG_OUTPUT, "\nGenerating Package lengths\n\n");
776 TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, NULL,
777 LnInitLengthsWalk, NULL);
778 TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, NULL,
779 LnPackageLengthWalk, NULL);
780 UtEndEvent (Event);
782 /* Code generation - emit the AML */
784 Event = UtBeginEvent ("Generate AML code and write output files");
785 CgGenerateAmlOutput ();
786 UtEndEvent (Event);
788 Event = UtBeginEvent ("Write optional output files");
789 CmDoOutputFiles ();
790 UtEndEvent (Event);
792 UtEndEvent (FullCompile);
793 CmCleanupAndExit ();
794 return (0);
796 ErrorExit:
797 UtEndEvent (FullCompile);
798 CmCleanupAndExit ();
799 return (-1);
803 /*******************************************************************************
805 * FUNCTION: CmDoOutputFiles
807 * PARAMETERS: None
809 * RETURN: None.
811 * DESCRIPTION: Create all "listing" type files
813 ******************************************************************************/
815 void
816 CmDoOutputFiles (
817 void)
820 /* Create listings and hex files */
822 LsDoListings ();
823 HxDoHexOutput ();
825 /* Dump the namespace to the .nsp file if requested */
827 (void) NsDisplayNamespace ();
831 /*******************************************************************************
833 * FUNCTION: CmDumpAllEvents
835 * PARAMETERS: None
837 * RETURN: None.
839 * DESCRIPTION: Dump all compiler events
841 ******************************************************************************/
843 static void
844 CmDumpAllEvents (
845 void)
847 ASL_EVENT_INFO *Event;
848 UINT32 Delta;
849 UINT32 USec;
850 UINT32 MSec;
851 UINT32 i;
854 Event = AslGbl_Events;
856 DbgPrint (ASL_DEBUG_OUTPUT, "\n\nElapsed time for major events\n\n");
857 if (Gbl_CompileTimesFlag)
859 printf ("\nElapsed time for major events\n\n");
862 for (i = 0; i < AslGbl_NextEvent; i++)
864 if (Event->Valid)
866 /* Delta will be in 100-nanosecond units */
868 Delta = (UINT32) (Event->EndTime - Event->StartTime);
870 USec = Delta / ACPI_100NSEC_PER_USEC;
871 MSec = Delta / ACPI_100NSEC_PER_MSEC;
873 /* Round milliseconds up */
875 if ((USec - (MSec * ACPI_USEC_PER_MSEC)) >= 500)
877 MSec++;
880 DbgPrint (ASL_DEBUG_OUTPUT, "%8u usec %8u msec - %s\n",
881 USec, MSec, Event->EventName);
883 if (Gbl_CompileTimesFlag)
885 printf ("%8u usec %8u msec - %s\n",
886 USec, MSec, Event->EventName);
890 Event++;
895 /*******************************************************************************
897 * FUNCTION: CmCleanupAndExit
899 * PARAMETERS: None
901 * RETURN: None.
903 * DESCRIPTION: Close all open files and exit the compiler
905 ******************************************************************************/
907 void
908 CmCleanupAndExit (
909 void)
911 UINT32 i;
912 BOOLEAN DeleteAmlFile = FALSE;
915 AePrintErrorLog (ASL_FILE_STDERR);
916 if (Gbl_DebugFlag)
918 /* Print error summary to stdout also */
920 AePrintErrorLog (ASL_FILE_STDOUT);
923 /* Emit compile times if enabled */
925 CmDumpAllEvents ();
927 if (Gbl_CompileTimesFlag)
929 printf ("\nMiscellaneous compile statistics\n\n");
930 printf ("%11u : %s\n", TotalParseNodes, "Parse nodes");
931 printf ("%11u : %s\n", Gbl_NsLookupCount, "Namespace searches");
932 printf ("%11u : %s\n", TotalNamedObjects, "Named objects");
933 printf ("%11u : %s\n", TotalMethods, "Control methods");
934 printf ("%11u : %s\n", TotalAllocations, "Memory Allocations");
935 printf ("%11u : %s\n", TotalAllocated, "Total allocated memory");
936 printf ("%11u : %s\n", TotalFolds, "Constant subtrees folded");
937 printf ("\n");
940 if (Gbl_NsLookupCount)
942 DbgPrint (ASL_DEBUG_OUTPUT,
943 "\n\nMiscellaneous compile statistics\n\n");
945 DbgPrint (ASL_DEBUG_OUTPUT,
946 "%32s : %u\n", "Total Namespace searches",
947 Gbl_NsLookupCount);
949 DbgPrint (ASL_DEBUG_OUTPUT,
950 "%32s : %u usec\n", "Time per search", ((UINT32)
951 (AslGbl_Events[AslGbl_NamespaceEvent].EndTime -
952 AslGbl_Events[AslGbl_NamespaceEvent].StartTime) / 10) /
953 Gbl_NsLookupCount);
956 if (Gbl_ExceptionCount[ASL_ERROR] > ASL_MAX_ERROR_COUNT)
958 printf ("\nMaximum error count (%u) exceeded\n",
959 ASL_MAX_ERROR_COUNT);
962 UtDisplaySummary (ASL_FILE_STDOUT);
965 * We will delete the AML file if there are errors and the
966 * force AML output option has not been used.
968 if ((Gbl_ExceptionCount[ASL_ERROR] > 0) && (!Gbl_IgnoreErrors) &&
969 Gbl_Files[ASL_FILE_AML_OUTPUT].Handle)
971 DeleteAmlFile = TRUE;
974 /* Close all open files */
977 * Take care with the preprocessor file (.i), it might be the same
978 * as the "input" file, depending on where the compiler has terminated
979 * or aborted. Prevent attempt to close the same file twice in
980 * loop below.
982 if (Gbl_Files[ASL_FILE_PREPROCESSOR].Handle ==
983 Gbl_Files[ASL_FILE_INPUT].Handle)
985 Gbl_Files[ASL_FILE_PREPROCESSOR].Handle = NULL;
988 /* Close the standard I/O files */
990 for (i = ASL_FILE_INPUT; i < ASL_MAX_FILE_TYPE; i++)
992 FlCloseFile (i);
995 /* Delete AML file if there are errors */
997 if (DeleteAmlFile)
999 FlDeleteFile (ASL_FILE_AML_OUTPUT);
1002 /* Delete the preprocessor output file (.i) unless -li flag is set */
1004 if (!Gbl_PreprocessorOutputFlag &&
1005 Gbl_PreprocessFlag)
1007 FlDeleteFile (ASL_FILE_PREPROCESSOR);
1011 * Delete intermediate ("combined") source file (if -ls flag not set)
1012 * This file is created during normal ASL/AML compiles. It is not
1013 * created by the data table compiler.
1015 * If the -ls flag is set, then the .SRC file should not be deleted.
1016 * In this case, Gbl_SourceOutputFlag is set to TRUE.
1018 * Note: Handles are cleared by FlCloseFile above, so we look at the
1019 * filename instead, to determine if the .SRC file was actually
1020 * created.
1022 * TBD: SourceOutput should be .TMP, then rename if we want to keep it?
1024 if (!Gbl_SourceOutputFlag)
1026 FlDeleteFile (ASL_FILE_SOURCE_OUTPUT);