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