1 /****************************************************************************** 2 * 3 * Module Name: aslcompile - top level compile module 4 * 5 *****************************************************************************/ 6 7 /* 8 * Copyright (C) 2000 - 2015, 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 /* Enter compiler name as a #define */ 104 105 PrAddDefine (ASL_DEFINE, "", FALSE); 106 107 /* Preprocessor */ 108 109 PrDoPreprocess (); 110 Gbl_CurrentLineNumber = 1; 111 Gbl_LogicalLineNumber = 1; 112 113 if (Gbl_PreprocessOnly) 114 { 115 UtEndEvent (Event); 116 CmCleanupAndExit (); 117 return (0); 118 } 119 } 120 UtEndEvent (Event); 121 122 123 /* Build the parse tree */ 124 125 Event = UtBeginEvent ("Parse source code and build parse tree"); 126 AslCompilerparse(); 127 UtEndEvent (Event); 128 129 /* Check for parser-detected syntax errors */ 130 131 if (Gbl_SyntaxError) 132 { 133 fprintf (stderr, 134 "Compiler aborting due to parser-detected syntax error(s)\n"); 135 LsDumpParseTree (); 136 goto ErrorExit; 137 } 138 139 /* Did the parse tree get successfully constructed? */ 140 141 if (!RootNode) 142 { 143 /* 144 * If there are no errors, then we have some sort of 145 * internal problem. 146 */ 147 AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, 148 NULL, "- Could not resolve parse tree root node"); 149 150 goto ErrorExit; 151 } 152 153 /* Flush out any remaining source after parse tree is complete */ 154 155 Event = UtBeginEvent ("Flush source input"); 156 CmFlushSourceCode (); 157 158 /* Prune the parse tree if requested (debug purposes only) */ 159 160 if (Gbl_PruneParseTree) 161 { 162 AslPruneParseTree (Gbl_PruneDepth, Gbl_PruneType); 163 } 164 165 /* Optional parse tree dump, compiler debug output only */ 166 167 LsDumpParseTree (); 168 169 OpcGetIntegerWidth (RootNode->Asl.Child); 170 UtEndEvent (Event); 171 172 /* Pre-process parse tree for any operator transforms */ 173 174 Event = UtBeginEvent ("Parse tree transforms"); 175 DbgPrint (ASL_DEBUG_OUTPUT, "\nParse tree transforms\n\n"); 176 TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, 177 TrAmlTransformWalk, NULL, NULL); 178 UtEndEvent (Event); 179 180 /* Generate AML opcodes corresponding to the parse tokens */ 181 182 Event = UtBeginEvent ("Generate AML opcodes"); 183 DbgPrint (ASL_DEBUG_OUTPUT, "\nGenerating AML opcodes\n\n"); 184 TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, NULL, 185 OpcAmlOpcodeWalk, NULL); 186 UtEndEvent (Event); 187 188 /* 189 * Now that the input is parsed, we can open the AML output file. 190 * Note: by default, the name of this file comes from the table 191 * descriptor within the input file. 192 */ 193 Event = UtBeginEvent ("Open AML output file"); 194 Status = FlOpenAmlOutputFile (Gbl_OutputFilenamePrefix); 195 UtEndEvent (Event); 196 if (ACPI_FAILURE (Status)) 197 { 198 AePrintErrorLog (ASL_FILE_STDERR); 199 return (-1); 200 } 201 202 /* Interpret and generate all compile-time constants */ 203 204 Event = UtBeginEvent ("Constant folding via AML interpreter"); 205 DbgPrint (ASL_DEBUG_OUTPUT, 206 "\nInterpreting compile-time constant expressions\n\n"); 207 208 if (Gbl_FoldConstants) 209 { 210 TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, 211 OpcAmlConstantWalk, NULL, NULL); 212 } 213 else 214 { 215 DbgPrint (ASL_PARSE_OUTPUT, " Optional folding disabled\n"); 216 } 217 UtEndEvent (Event); 218 219 /* Update AML opcodes if necessary, after constant folding */ 220 221 Event = UtBeginEvent ("Updating AML opcodes after constant folding"); 222 DbgPrint (ASL_DEBUG_OUTPUT, 223 "\nUpdating AML opcodes after constant folding\n\n"); 224 TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, 225 NULL, OpcAmlOpcodeUpdateWalk, NULL); 226 UtEndEvent (Event); 227 228 /* Calculate all AML package lengths */ 229 230 Event = UtBeginEvent ("Generate AML package lengths"); 231 DbgPrint (ASL_DEBUG_OUTPUT, "\nGenerating Package lengths\n\n"); 232 TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, NULL, 233 LnPackageLengthWalk, NULL); 234 UtEndEvent (Event); 235 236 if (Gbl_ParseOnlyFlag) 237 { 238 AePrintErrorLog (ASL_FILE_STDERR); 239 UtDisplaySummary (ASL_FILE_STDERR); 240 if (Gbl_DebugFlag) 241 { 242 /* Print error summary to the stdout also */ 243 244 AePrintErrorLog (ASL_FILE_STDOUT); 245 UtDisplaySummary (ASL_FILE_STDOUT); 246 } 247 UtEndEvent (FullCompile); 248 return (0); 249 } 250 251 /* 252 * Create an internal namespace and use it as a symbol table 253 */ 254 255 /* Namespace loading */ 256 257 Event = UtBeginEvent ("Create ACPI Namespace"); 258 Status = LdLoadNamespace (RootNode); 259 UtEndEvent (Event); 260 if (ACPI_FAILURE (Status)) 261 { 262 goto ErrorExit; 263 } 264 265 /* Namespace cross-reference */ 266 267 AslGbl_NamespaceEvent = UtBeginEvent ( 268 "Cross reference parse tree and Namespace"); 269 Status = XfCrossReferenceNamespace (); 270 if (ACPI_FAILURE (Status)) 271 { 272 goto ErrorExit; 273 } 274 275 /* Namespace - Check for non-referenced objects */ 276 277 LkFindUnreferencedObjects (); 278 UtEndEvent (AslGbl_NamespaceEvent); 279 280 /* 281 * Semantic analysis. This can happen only after the 282 * namespace has been loaded and cross-referenced. 283 * 284 * part one - check control methods 285 */ 286 Event = UtBeginEvent ("Analyze control method return types"); 287 AnalysisWalkInfo.MethodStack = NULL; 288 289 DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - Method analysis\n\n"); 290 TrWalkParseTree (RootNode, ASL_WALK_VISIT_TWICE, 291 MtMethodAnalysisWalkBegin, 292 MtMethodAnalysisWalkEnd, &AnalysisWalkInfo); 293 UtEndEvent (Event); 294 295 /* Semantic error checking part two - typing of method returns */ 296 297 Event = UtBeginEvent ("Determine object types returned by methods"); 298 DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - Method typing\n\n"); 299 TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, 300 NULL, AnMethodTypingWalkEnd, NULL); 301 UtEndEvent (Event); 302 303 /* Semantic error checking part three - operand type checking */ 304 305 Event = UtBeginEvent ("Analyze AML operand types"); 306 DbgPrint (ASL_DEBUG_OUTPUT, 307 "\nSemantic analysis - Operand type checking\n\n"); 308 if (Gbl_DoTypechecking) 309 { 310 TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, 311 NULL, AnOperandTypecheckWalkEnd, &AnalysisWalkInfo); 312 } 313 UtEndEvent (Event); 314 315 /* Semantic error checking part four - other miscellaneous checks */ 316 317 Event = UtBeginEvent ("Miscellaneous analysis"); 318 DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - miscellaneous\n\n"); 319 TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, 320 AnOtherSemanticAnalysisWalkBegin, 321 NULL, &AnalysisWalkInfo); 322 UtEndEvent (Event); 323 324 /* Calculate all AML package lengths */ 325 326 Event = UtBeginEvent ("Finish AML package length generation"); 327 DbgPrint (ASL_DEBUG_OUTPUT, "\nGenerating Package lengths\n\n"); 328 TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, NULL, 329 LnInitLengthsWalk, NULL); 330 TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, NULL, 331 LnPackageLengthWalk, NULL); 332 UtEndEvent (Event); 333 334 /* Code generation - emit the AML */ 335 336 Event = UtBeginEvent ("Generate AML code and write output files"); 337 CgGenerateAmlOutput (); 338 UtEndEvent (Event); 339 340 Event = UtBeginEvent ("Write optional output files"); 341 CmDoOutputFiles (); 342 UtEndEvent (Event); 343 344 UtEndEvent (FullCompile); 345 CmCleanupAndExit (); 346 return (0); 347 348 ErrorExit: 349 UtEndEvent (FullCompile); 350 CmCleanupAndExit (); 351 return (-1); 352 } 353 354 355 /******************************************************************************* 356 * 357 * FUNCTION: AslCompilerSignon 358 * 359 * PARAMETERS: FileId - ID of the output file 360 * 361 * RETURN: None 362 * 363 * DESCRIPTION: Display compiler signon 364 * 365 ******************************************************************************/ 366 367 void 368 AslCompilerSignon ( 369 UINT32 FileId) 370 { 371 char *Prefix = ""; 372 char *UtilityName; 373 374 375 /* Set line prefix depending on the destination file type */ 376 377 switch (FileId) 378 { 379 case ASL_FILE_ASM_SOURCE_OUTPUT: 380 case ASL_FILE_ASM_INCLUDE_OUTPUT: 381 382 Prefix = "; "; 383 break; 384 385 case ASL_FILE_HEX_OUTPUT: 386 387 if (Gbl_HexOutputFlag == HEX_OUTPUT_ASM) 388 { 389 Prefix = "; "; 390 } 391 else if ((Gbl_HexOutputFlag == HEX_OUTPUT_C) || 392 (Gbl_HexOutputFlag == HEX_OUTPUT_ASL)) 393 { 394 FlPrintFile (ASL_FILE_HEX_OUTPUT, "/*\n"); 395 Prefix = " * "; 396 } 397 break; 398 399 case ASL_FILE_C_SOURCE_OUTPUT: 400 case ASL_FILE_C_OFFSET_OUTPUT: 401 case ASL_FILE_C_INCLUDE_OUTPUT: 402 403 Prefix = " * "; 404 break; 405 406 default: 407 408 /* No other output types supported */ 409 410 break; 411 } 412 413 /* Running compiler or disassembler? */ 414 415 if (Gbl_DisasmFlag) 416 { 417 UtilityName = AML_DISASSEMBLER_NAME; 418 } 419 else 420 { 421 UtilityName = ASL_COMPILER_NAME; 422 } 423 424 /* Compiler signon with copyright */ 425 426 FlPrintFile (FileId, "%s\n", Prefix); 427 FlPrintFile (FileId, ACPI_COMMON_HEADER (UtilityName, Prefix)); 428 } 429 430 431 /******************************************************************************* 432 * 433 * FUNCTION: AslCompilerFileHeader 434 * 435 * PARAMETERS: FileId - ID of the output file 436 * 437 * RETURN: None 438 * 439 * DESCRIPTION: Header used at the beginning of output files 440 * 441 ******************************************************************************/ 442 443 void 444 AslCompilerFileHeader ( 445 UINT32 FileId) 446 { 447 struct tm *NewTime; 448 time_t Aclock; 449 char *Prefix = ""; 450 451 452 /* Set line prefix depending on the destination file type */ 453 454 switch (FileId) 455 { 456 case ASL_FILE_ASM_SOURCE_OUTPUT: 457 case ASL_FILE_ASM_INCLUDE_OUTPUT: 458 459 Prefix = "; "; 460 break; 461 462 case ASL_FILE_HEX_OUTPUT: 463 464 if (Gbl_HexOutputFlag == HEX_OUTPUT_ASM) 465 { 466 Prefix = "; "; 467 } 468 else if ((Gbl_HexOutputFlag == HEX_OUTPUT_C) || 469 (Gbl_HexOutputFlag == HEX_OUTPUT_ASL)) 470 { 471 Prefix = " * "; 472 } 473 break; 474 475 case ASL_FILE_C_SOURCE_OUTPUT: 476 case ASL_FILE_C_OFFSET_OUTPUT: 477 case ASL_FILE_C_INCLUDE_OUTPUT: 478 479 Prefix = " * "; 480 break; 481 482 default: 483 484 /* No other output types supported */ 485 486 break; 487 } 488 489 /* Compilation header with timestamp */ 490 491 (void) time (&Aclock); 492 NewTime = localtime (&Aclock); 493 494 FlPrintFile (FileId, 495 "%sCompilation of \"%s\" - %s%s\n", 496 Prefix, Gbl_Files[ASL_FILE_INPUT].Filename, asctime (NewTime), 497 Prefix); 498 499 switch (FileId) 500 { 501 case ASL_FILE_C_SOURCE_OUTPUT: 502 case ASL_FILE_C_OFFSET_OUTPUT: 503 case ASL_FILE_C_INCLUDE_OUTPUT: 504 505 FlPrintFile (FileId, " */\n"); 506 break; 507 508 default: 509 510 /* Nothing to do for other output types */ 511 512 break; 513 } 514 } 515 516 517 /******************************************************************************* 518 * 519 * FUNCTION: CmFlushSourceCode 520 * 521 * PARAMETERS: None 522 * 523 * RETURN: None 524 * 525 * DESCRIPTION: Read in any remaining source code after the parse tree 526 * has been constructed. 527 * 528 ******************************************************************************/ 529 530 static void 531 CmFlushSourceCode ( 532 void) 533 { 534 char Buffer; 535 536 537 while (FlReadFile (ASL_FILE_INPUT, &Buffer, 1) != AE_ERROR) 538 { 539 AslInsertLineBuffer ((int) Buffer); 540 } 541 542 AslResetCurrentLineBuffer (); 543 } 544 545 546 /******************************************************************************* 547 * 548 * FUNCTION: CmDoOutputFiles 549 * 550 * PARAMETERS: None 551 * 552 * RETURN: None. 553 * 554 * DESCRIPTION: Create all "listing" type files 555 * 556 ******************************************************************************/ 557 558 void 559 CmDoOutputFiles ( 560 void) 561 { 562 563 /* Create listings and hex files */ 564 565 LsDoListings (); 566 HxDoHexOutput (); 567 568 /* Dump the namespace to the .nsp file if requested */ 569 570 (void) NsDisplayNamespace (); 571 572 /* Dump the device mapping file */ 573 574 MpEmitMappingInfo (); 575 } 576 577 578 /******************************************************************************* 579 * 580 * FUNCTION: CmDumpAllEvents 581 * 582 * PARAMETERS: None 583 * 584 * RETURN: None. 585 * 586 * DESCRIPTION: Dump all compiler events 587 * 588 ******************************************************************************/ 589 590 static void 591 CmDumpAllEvents ( 592 void) 593 { 594 ASL_EVENT_INFO *Event; 595 UINT32 Delta; 596 UINT32 MicroSeconds; 597 UINT32 MilliSeconds; 598 UINT32 i; 599 600 601 Event = AslGbl_Events; 602 603 DbgPrint (ASL_DEBUG_OUTPUT, "\n\nElapsed time for major events\n\n"); 604 if (Gbl_CompileTimesFlag) 605 { 606 printf ("\nElapsed time for major events\n\n"); 607 } 608 609 for (i = 0; i < AslGbl_NextEvent; i++) 610 { 611 if (Event->Valid) 612 { 613 /* Delta will be in 100-nanosecond units */ 614 615 Delta = (UINT32) (Event->EndTime - Event->StartTime); 616 617 MicroSeconds = Delta / ACPI_100NSEC_PER_USEC; 618 MilliSeconds = Delta / ACPI_100NSEC_PER_MSEC; 619 620 /* Round milliseconds up */ 621 622 if ((MicroSeconds - (MilliSeconds * ACPI_USEC_PER_MSEC)) >= 500) 623 { 624 MilliSeconds++; 625 } 626 627 DbgPrint (ASL_DEBUG_OUTPUT, "%8u usec %8u msec - %s\n", 628 MicroSeconds, MilliSeconds, Event->EventName); 629 630 if (Gbl_CompileTimesFlag) 631 { 632 printf ("%8u usec %8u msec - %s\n", 633 MicroSeconds, MilliSeconds, Event->EventName); 634 } 635 } 636 637 Event++; 638 } 639 } 640 641 642 /******************************************************************************* 643 * 644 * FUNCTION: CmCleanupAndExit 645 * 646 * PARAMETERS: None 647 * 648 * RETURN: None. 649 * 650 * DESCRIPTION: Close all open files and exit the compiler 651 * 652 ******************************************************************************/ 653 654 void 655 CmCleanupAndExit ( 656 void) 657 { 658 UINT32 i; 659 BOOLEAN DeleteAmlFile = FALSE; 660 661 662 AePrintErrorLog (ASL_FILE_STDERR); 663 if (Gbl_DebugFlag) 664 { 665 /* Print error summary to stdout also */ 666 667 AePrintErrorLog (ASL_FILE_STDOUT); 668 } 669 670 /* Emit compile times if enabled */ 671 672 CmDumpAllEvents (); 673 674 if (Gbl_CompileTimesFlag) 675 { 676 printf ("\nMiscellaneous compile statistics\n\n"); 677 printf ("%11u : %s\n", TotalParseNodes, "Parse nodes"); 678 printf ("%11u : %s\n", Gbl_NsLookupCount, "Namespace searches"); 679 printf ("%11u : %s\n", TotalNamedObjects, "Named objects"); 680 printf ("%11u : %s\n", TotalMethods, "Control methods"); 681 printf ("%11u : %s\n", TotalAllocations, "Memory Allocations"); 682 printf ("%11u : %s\n", TotalAllocated, "Total allocated memory"); 683 printf ("%11u : %s\n", TotalFolds, "Constant subtrees folded"); 684 printf ("\n"); 685 } 686 687 if (Gbl_NsLookupCount) 688 { 689 DbgPrint (ASL_DEBUG_OUTPUT, 690 "\n\nMiscellaneous compile statistics\n\n"); 691 692 DbgPrint (ASL_DEBUG_OUTPUT, 693 "%32s : %u\n", "Total Namespace searches", 694 Gbl_NsLookupCount); 695 696 DbgPrint (ASL_DEBUG_OUTPUT, 697 "%32s : %u usec\n", "Time per search", ((UINT32) 698 (AslGbl_Events[AslGbl_NamespaceEvent].EndTime - 699 AslGbl_Events[AslGbl_NamespaceEvent].StartTime) / 10) / 700 Gbl_NsLookupCount); 701 } 702 703 if (Gbl_ExceptionCount[ASL_ERROR] > ASL_MAX_ERROR_COUNT) 704 { 705 printf ("\nMaximum error count (%u) exceeded\n", 706 ASL_MAX_ERROR_COUNT); 707 } 708 709 UtDisplaySummary (ASL_FILE_STDOUT); 710 711 /* 712 * We will delete the AML file if there are errors and the 713 * force AML output option has not been used. 714 */ 715 if ((Gbl_ExceptionCount[ASL_ERROR] > 0) && 716 (!Gbl_IgnoreErrors) && 717 Gbl_Files[ASL_FILE_AML_OUTPUT].Handle) 718 { 719 DeleteAmlFile = TRUE; 720 } 721 722 /* Close all open files */ 723 724 /* 725 * Take care with the preprocessor file (.pre), it might be the same 726 * as the "input" file, depending on where the compiler has terminated 727 * or aborted. Prevent attempt to close the same file twice in 728 * loop below. 729 */ 730 if (Gbl_Files[ASL_FILE_PREPROCESSOR].Handle == 731 Gbl_Files[ASL_FILE_INPUT].Handle) 732 { 733 Gbl_Files[ASL_FILE_PREPROCESSOR].Handle = NULL; 734 } 735 736 /* Close the standard I/O files */ 737 738 for (i = ASL_FILE_INPUT; i < ASL_MAX_FILE_TYPE; i++) 739 { 740 FlCloseFile (i); 741 } 742 743 /* Delete AML file if there are errors */ 744 745 if (DeleteAmlFile) 746 { 747 FlDeleteFile (ASL_FILE_AML_OUTPUT); 748 } 749 750 /* Delete the preprocessor temp file unless full debug was specified */ 751 752 if (Gbl_PreprocessFlag && !Gbl_KeepPreprocessorTempFile) 753 { 754 FlDeleteFile (ASL_FILE_PREPROCESSOR); 755 } 756 757 /* 758 * Delete intermediate ("combined") source file (if -ls flag not set) 759 * This file is created during normal ASL/AML compiles. It is not 760 * created by the data table compiler. 761 * 762 * If the -ls flag is set, then the .SRC file should not be deleted. 763 * In this case, Gbl_SourceOutputFlag is set to TRUE. 764 * 765 * Note: Handles are cleared by FlCloseFile above, so we look at the 766 * filename instead, to determine if the .SRC file was actually 767 * created. 768 */ 769 if (!Gbl_SourceOutputFlag) 770 { 771 FlDeleteFile (ASL_FILE_SOURCE_OUTPUT); 772 } 773 774 /* Final cleanup after compiling one file */ 775 776 CmDeleteCaches (); 777 } 778 779 780 /******************************************************************************* 781 * 782 * FUNCTION: CmDeleteCaches 783 * 784 * PARAMETERS: None 785 * 786 * RETURN: None 787 * 788 * DESCRIPTION: Delete all local cache buffer blocks 789 * 790 ******************************************************************************/ 791 792 void 793 CmDeleteCaches ( 794 void) 795 { 796 UINT32 BufferCount; 797 ASL_CACHE_INFO *Next; 798 799 800 /* Parse Op cache */ 801 802 BufferCount = 0; 803 while (Gbl_ParseOpCacheList) 804 { 805 Next = Gbl_ParseOpCacheList->Next; 806 ACPI_FREE (Gbl_ParseOpCacheList); 807 Gbl_ParseOpCacheList = Next; 808 BufferCount++; 809 } 810 811 DbgPrint (ASL_DEBUG_OUTPUT, 812 "%u ParseOps, Buffer size: %u ops (%u bytes), %u Buffers\n", 813 Gbl_ParseOpCount, ASL_PARSEOP_CACHE_SIZE, 814 (sizeof (ACPI_PARSE_OBJECT) * ASL_PARSEOP_CACHE_SIZE), BufferCount); 815 816 Gbl_ParseOpCount = 0; 817 Gbl_ParseOpCacheNext = NULL; 818 Gbl_ParseOpCacheLast = NULL; 819 RootNode = NULL; 820 821 /* Generic string cache */ 822 823 BufferCount = 0; 824 while (Gbl_StringCacheList) 825 { 826 Next = Gbl_StringCacheList->Next; 827 ACPI_FREE (Gbl_StringCacheList); 828 Gbl_StringCacheList = Next; 829 BufferCount++; 830 } 831 832 DbgPrint (ASL_DEBUG_OUTPUT, 833 "%u Strings (%u bytes), Buffer size: %u bytes, %u Buffers\n", 834 Gbl_StringCount, Gbl_StringSize, ASL_STRING_CACHE_SIZE, BufferCount); 835 836 Gbl_StringSize = 0; 837 Gbl_StringCount = 0; 838 Gbl_StringCacheNext = NULL; 839 Gbl_StringCacheLast = NULL; 840 } 841