1 2 /****************************************************************************** 3 * 4 * Module Name: aslmain - compiler main and utilities 5 * 6 *****************************************************************************/ 7 8 /* 9 * Copyright (C) 2000 - 2012, Intel Corp. 10 * All rights reserved. 11 * 12 * Redistribution and use in source and binary forms, with or without 13 * modification, are permitted provided that the following conditions 14 * are met: 15 * 1. Redistributions of source code must retain the above copyright 16 * notice, this list of conditions, and the following disclaimer, 17 * without modification. 18 * 2. Redistributions in binary form must reproduce at minimum a disclaimer 19 * substantially similar to the "NO WARRANTY" disclaimer below 20 * ("Disclaimer") and any redistribution must be conditioned upon 21 * including a substantially similar Disclaimer requirement for further 22 * binary redistribution. 23 * 3. Neither the names of the above-listed copyright holders nor the names 24 * of any contributors may be used to endorse or promote products derived 25 * from this software without specific prior written permission. 26 * 27 * Alternatively, this software may be distributed under the terms of the 28 * GNU General Public License ("GPL") version 2 as published by the Free 29 * Software Foundation. 30 * 31 * NO WARRANTY 32 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 33 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 34 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 35 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 36 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 37 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 38 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 39 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 40 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 41 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 42 * POSSIBILITY OF SUCH DAMAGES. 43 */ 44 45 46 #define _DECLARE_GLOBALS 47 48 #include <contrib/dev/acpica/compiler/aslcompiler.h> 49 #include <contrib/dev/acpica/include/acapps.h> 50 #include <contrib/dev/acpica/include/acdisasm.h> 51 52 #ifdef _DEBUG 53 #include <crtdbg.h> 54 #endif 55 56 #define _COMPONENT ACPI_COMPILER 57 ACPI_MODULE_NAME ("aslmain") 58 59 /* Local prototypes */ 60 61 static void 62 Options ( 63 void); 64 65 static void 66 HelpMessage ( 67 void); 68 69 static void 70 Usage ( 71 void); 72 73 static void 74 AslInitialize ( 75 void); 76 77 static int 78 AslCommandLine ( 79 int argc, 80 char **argv); 81 82 static int 83 AslDoOptions ( 84 int argc, 85 char **argv, 86 BOOLEAN IsResponseFile); 87 88 static void 89 AslMergeOptionTokens ( 90 char *InBuffer, 91 char *OutBuffer); 92 93 static int 94 AslDoResponseFile ( 95 char *Filename); 96 97 98 #define ASL_TOKEN_SEPARATORS " \t\n" 99 #define ASL_SUPPORTED_OPTIONS "@:2b|c|d^D:e:fgh^i|I:l^mno|p:Pr:s|t|T:G^v|w|x:z" 100 101 102 /******************************************************************************* 103 * 104 * FUNCTION: Options 105 * 106 * PARAMETERS: None 107 * 108 * RETURN: None 109 * 110 * DESCRIPTION: Display option help message 111 * 112 ******************************************************************************/ 113 114 static void 115 Options ( 116 void) 117 { 118 119 printf ("\nGlobal:\n"); 120 ACPI_OPTION ("-@ <file>", "Specify command file"); 121 ACPI_OPTION ("-I <dir>", "Specify additional include directory"); 122 123 printf ("\nPreprocessor:\n"); 124 ACPI_OPTION ("-D <symbol>", "Define symbol for preprocessor use"); 125 ACPI_OPTION ("-li", "Create preprocessed output file (*.i)"); 126 ACPI_OPTION ("-P", "Preprocess only and create preprocessor output file (*.i)"); 127 128 printf ("\nGeneral Output:\n"); 129 ACPI_OPTION ("-p <prefix>", "Specify path/filename prefix for all output files"); 130 ACPI_OPTION ("-va", "Disable all errors and warnings (summary only)"); 131 ACPI_OPTION ("-vi", "Less verbose errors and warnings for use with IDEs"); 132 ACPI_OPTION ("-vo", "Enable optimization comments"); 133 ACPI_OPTION ("-vr", "Disable remarks"); 134 ACPI_OPTION ("-vs", "Disable signon"); 135 ACPI_OPTION ("-w1 -w2 -w3", "Set warning reporting level"); 136 137 printf ("\nAML Output Files:\n"); 138 ACPI_OPTION ("-sa -sc", "Create AML in assembler or C source file (*.asm or *.c)"); 139 ACPI_OPTION ("-ia -ic", "Create assembler or C include file (*.inc or *.h)"); 140 ACPI_OPTION ("-ta -tc -ts", "Create AML in assembler, C, or ASL hex table (*.hex)"); 141 142 printf ("\nAML Code Generation:\n"); 143 ACPI_OPTION ("-oa", "Disable all optimizations (compatibility mode)"); 144 ACPI_OPTION ("-of", "Disable constant folding"); 145 ACPI_OPTION ("-oi", "Disable integer optimization to Zero/One/Ones"); 146 ACPI_OPTION ("-on", "Disable named reference string optimization"); 147 ACPI_OPTION ("-cr", "Disable Resource Descriptor error checking"); 148 ACPI_OPTION ("-r <revision>", "Override table header Revision (1-255)"); 149 150 printf ("\nASL Listing Files:\n"); 151 ACPI_OPTION ("-l", "Create mixed listing file (ASL source and AML) (*.lst)"); 152 ACPI_OPTION ("-ln", "Create namespace file (*.nsp)"); 153 ACPI_OPTION ("-ls", "Create combined source file (expanded includes) (*.src)"); 154 155 printf ("\nACPI Data Tables:\n"); 156 ACPI_OPTION ("-G", "Compile custom table containing generic operators"); 157 ACPI_OPTION ("-T <sig>|ALL|*", "Create table template file(s) for <Sig>"); 158 ACPI_OPTION ("-vt", "Create verbose templates (full disassembly)"); 159 160 printf ("\nAML Disassembler:\n"); 161 ACPI_OPTION ("-d [file]", "Disassemble or decode binary ACPI table to file (*.dsl)"); 162 ACPI_OPTION ("-da [f1,f2]", "Disassemble multiple tables from single namespace"); 163 ACPI_OPTION ("-dc [file]", "Disassemble AML and immediately compile it"); 164 ACPI_OPTION ("", "(Obtain DSDT from current system if no input file)"); 165 ACPI_OPTION ("-e [f1,f2]", "Include ACPI table(s) for external symbol resolution"); 166 ACPI_OPTION ("-m", "Do not translate Buffers to Resource Templates"); 167 ACPI_OPTION ("-2", "Emit ACPI 2.0 compatible ASL code"); 168 ACPI_OPTION ("-g", "Get ACPI tables and write to files (*.dat)"); 169 170 printf ("\nHelp:\n"); 171 ACPI_OPTION ("-h", "Additional help and compiler debug options"); 172 ACPI_OPTION ("-hc", "Display operators allowed in constant expressions"); 173 ACPI_OPTION ("-hr", "Display ACPI reserved method names"); 174 ACPI_OPTION ("-ht", "Display currently supported ACPI table names"); 175 } 176 177 178 /******************************************************************************* 179 * 180 * FUNCTION: HelpMessage 181 * 182 * PARAMETERS: None 183 * 184 * RETURN: None 185 * 186 * DESCRIPTION: Display help message 187 * 188 ******************************************************************************/ 189 190 static void 191 HelpMessage ( 192 void) 193 { 194 195 printf ("\nAML output filename generation:\n"); 196 printf (" Output filenames are generated by appending an extension to a common\n"); 197 printf (" filename prefix. The filename prefix is obtained via one of the\n"); 198 printf (" following methods (in priority order):\n"); 199 printf (" 1) The -p option specifies the prefix\n"); 200 printf (" 2) The prefix of the AMLFileName in the ASL Definition Block\n"); 201 printf (" 3) The prefix of the input filename\n"); 202 printf ("\n"); 203 204 Options (); 205 206 printf ("\nCompiler/Disassembler Debug Options:\n"); 207 ACPI_OPTION ("-bb -bp -bt", "Create compiler debug/trace file (*.txt)"); 208 ACPI_OPTION ("", "Types: Parse/Tree/Both"); 209 ACPI_OPTION ("-f", "Ignore errors, force creation of AML output file(s)"); 210 ACPI_OPTION ("-n", "Parse only, no output generation"); 211 ACPI_OPTION ("-ot", "Display compile times"); 212 ACPI_OPTION ("-x <level>", "Set debug level for trace output"); 213 ACPI_OPTION ("-z", "Do not insert new compiler ID for DataTables"); 214 } 215 216 217 /******************************************************************************* 218 * 219 * FUNCTION: Usage 220 * 221 * PARAMETERS: None 222 * 223 * RETURN: None 224 * 225 * DESCRIPTION: Display usage and option message 226 * 227 ******************************************************************************/ 228 229 static void 230 Usage ( 231 void) 232 { 233 234 printf ("%s\n\n", ASL_COMPLIANCE); 235 ACPI_USAGE_HEADER ("iasl [Options] [Files]"); 236 Options (); 237 } 238 239 240 /******************************************************************************* 241 * 242 * FUNCTION: AslInitialize 243 * 244 * PARAMETERS: None 245 * 246 * RETURN: None 247 * 248 * DESCRIPTION: Initialize compiler globals 249 * 250 ******************************************************************************/ 251 252 static void 253 AslInitialize ( 254 void) 255 { 256 UINT32 i; 257 258 259 #ifdef _DEBUG 260 _CrtSetDbgFlag (_CRTDBG_CHECK_ALWAYS_DF | _CrtSetDbgFlag(0)); 261 #endif 262 263 AcpiDbgLevel = 0; 264 265 for (i = 0; i < ASL_NUM_FILES; i++) 266 { 267 Gbl_Files[i].Handle = NULL; 268 Gbl_Files[i].Filename = NULL; 269 } 270 271 Gbl_Files[ASL_FILE_STDOUT].Handle = stdout; 272 Gbl_Files[ASL_FILE_STDOUT].Filename = "STDOUT"; 273 274 Gbl_Files[ASL_FILE_STDERR].Handle = stderr; 275 Gbl_Files[ASL_FILE_STDERR].Filename = "STDERR"; 276 } 277 278 279 /******************************************************************************* 280 * 281 * FUNCTION: AslMergeOptionTokens 282 * 283 * PARAMETERS: InBuffer - Input containing an option string 284 * OutBuffer - Merged output buffer 285 * 286 * RETURN: None 287 * 288 * DESCRIPTION: Remove all whitespace from an option string. 289 * 290 ******************************************************************************/ 291 292 static void 293 AslMergeOptionTokens ( 294 char *InBuffer, 295 char *OutBuffer) 296 { 297 char *Token; 298 299 300 *OutBuffer = 0; 301 302 Token = strtok (InBuffer, ASL_TOKEN_SEPARATORS); 303 while (Token) 304 { 305 strcat (OutBuffer, Token); 306 Token = strtok (NULL, ASL_TOKEN_SEPARATORS); 307 } 308 } 309 310 311 /******************************************************************************* 312 * 313 * FUNCTION: AslDoResponseFile 314 * 315 * PARAMETERS: Filename - Name of the response file 316 * 317 * RETURN: Status 318 * 319 * DESCRIPTION: Open a response file and process all options within. 320 * 321 ******************************************************************************/ 322 323 static int 324 AslDoResponseFile ( 325 char *Filename) 326 { 327 char *argv = StringBuffer2; 328 FILE *ResponseFile; 329 int OptStatus = 0; 330 int Opterr; 331 int Optind; 332 333 334 ResponseFile = fopen (Filename, "r"); 335 if (!ResponseFile) 336 { 337 printf ("Could not open command file %s, %s\n", 338 Filename, strerror (errno)); 339 return -1; 340 } 341 342 /* Must save the current GetOpt globals */ 343 344 Opterr = AcpiGbl_Opterr; 345 Optind = AcpiGbl_Optind; 346 347 /* 348 * Process all lines in the response file. There must be one complete 349 * option per line 350 */ 351 while (fgets (StringBuffer, ASL_MSG_BUFFER_SIZE, ResponseFile)) 352 { 353 /* Compress all tokens, allowing us to use a single argv entry */ 354 355 AslMergeOptionTokens (StringBuffer, StringBuffer2); 356 357 /* Process the option */ 358 359 AcpiGbl_Opterr = 0; 360 AcpiGbl_Optind = 0; 361 362 OptStatus = AslDoOptions (1, &argv, TRUE); 363 if (OptStatus) 364 { 365 printf ("Invalid option in command file %s: %s\n", 366 Filename, StringBuffer); 367 break; 368 } 369 } 370 371 /* Restore the GetOpt globals */ 372 373 AcpiGbl_Opterr = Opterr; 374 AcpiGbl_Optind = Optind; 375 376 fclose (ResponseFile); 377 return (OptStatus); 378 } 379 380 381 /******************************************************************************* 382 * 383 * FUNCTION: AslDoOptions 384 * 385 * PARAMETERS: argc/argv - Standard argc/argv 386 * IsResponseFile - TRUE if executing a response file. 387 * 388 * RETURN: Status 389 * 390 * DESCRIPTION: Command line option processing 391 * 392 ******************************************************************************/ 393 394 static int 395 AslDoOptions ( 396 int argc, 397 char **argv, 398 BOOLEAN IsResponseFile) 399 { 400 int j; 401 ACPI_STATUS Status; 402 403 404 /* Get the command line options */ 405 406 while ((j = AcpiGetopt (argc, argv, ASL_SUPPORTED_OPTIONS)) != EOF) switch (j) 407 { 408 case '@': /* Begin a response file */ 409 410 if (IsResponseFile) 411 { 412 printf ("Nested command files are not supported\n"); 413 return (-1); 414 } 415 416 if (AslDoResponseFile (AcpiGbl_Optarg)) 417 { 418 return (-1); 419 } 420 break; 421 422 423 case '2': /* ACPI 2.0 compatibility mode */ 424 Gbl_Acpi2 = TRUE; 425 break; 426 427 428 case 'b': /* Debug output options */ 429 switch (AcpiGbl_Optarg[0]) 430 { 431 case 'b': 432 AslCompilerdebug = 1; /* same as yydebug */ 433 DtParserdebug = 1; 434 PrParserdebug = 1; 435 break; 436 437 case 'p': 438 AslCompilerdebug = 1; /* same as yydebug */ 439 DtParserdebug = 1; 440 PrParserdebug = 1; 441 break; 442 443 case 't': 444 break; 445 446 default: 447 printf ("Unknown option: -b%s\n", AcpiGbl_Optarg); 448 return (-1); 449 } 450 451 /* Produce debug output file */ 452 453 Gbl_DebugFlag = TRUE; 454 break; 455 456 457 case 'c': 458 switch (AcpiGbl_Optarg[0]) 459 { 460 case 'r': 461 Gbl_NoResourceChecking = TRUE; 462 break; 463 464 default: 465 printf ("Unknown option: -c%s\n", AcpiGbl_Optarg); 466 return (-1); 467 } 468 break; 469 470 471 case 'd': /* Disassembler */ 472 switch (AcpiGbl_Optarg[0]) 473 { 474 case '^': 475 Gbl_DoCompile = FALSE; 476 break; 477 478 case 'a': 479 Gbl_DoCompile = FALSE; 480 Gbl_DisassembleAll = TRUE; 481 break; 482 483 case 'c': 484 break; 485 486 default: 487 printf ("Unknown option: -d%s\n", AcpiGbl_Optarg); 488 return (-1); 489 } 490 491 Gbl_DisasmFlag = TRUE; 492 break; 493 494 495 case 'D': /* Define a symbol */ 496 PrAddDefine (AcpiGbl_Optarg, NULL, TRUE); 497 break; 498 499 500 case 'e': /* External files for disassembler */ 501 Status = AcpiDmAddToExternalFileList (AcpiGbl_Optarg); 502 if (ACPI_FAILURE (Status)) 503 { 504 printf ("Could not add %s to external list\n", AcpiGbl_Optarg); 505 return (-1); 506 } 507 break; 508 509 510 case 'f': /* Ignore errors and force creation of aml file */ 511 Gbl_IgnoreErrors = TRUE; 512 break; 513 514 515 case 'G': 516 Gbl_CompileGeneric = TRUE; 517 break; 518 519 520 case 'g': /* Get all ACPI tables */ 521 522 Gbl_GetAllTables = TRUE; 523 Gbl_DoCompile = FALSE; 524 break; 525 526 527 case 'h': 528 switch (AcpiGbl_Optarg[0]) 529 { 530 case '^': 531 HelpMessage (); 532 exit (0); 533 534 case 'c': 535 UtDisplayConstantOpcodes (); 536 exit (0); 537 538 case 'r': 539 /* reserved names */ 540 541 ApDisplayReservedNames (); 542 exit (0); 543 544 case 't': 545 UtDisplaySupportedTables (); 546 exit (0); 547 548 default: 549 printf ("Unknown option: -h%s\n", AcpiGbl_Optarg); 550 return (-1); 551 } 552 553 554 case 'I': /* Add an include file search directory */ 555 FlAddIncludeDirectory (AcpiGbl_Optarg); 556 break; 557 558 559 case 'i': /* Output AML as an include file */ 560 switch (AcpiGbl_Optarg[0]) 561 { 562 case 'a': 563 564 /* Produce assembly code include file */ 565 566 Gbl_AsmIncludeOutputFlag = TRUE; 567 break; 568 569 case 'c': 570 571 /* Produce C include file */ 572 573 Gbl_C_IncludeOutputFlag = TRUE; 574 break; 575 576 default: 577 printf ("Unknown option: -i%s\n", AcpiGbl_Optarg); 578 return (-1); 579 } 580 break; 581 582 583 case 'l': /* Listing files */ 584 switch (AcpiGbl_Optarg[0]) 585 { 586 case '^': 587 /* Produce listing file (Mixed source/aml) */ 588 589 Gbl_ListingFlag = TRUE; 590 break; 591 592 case 'i': 593 /* Produce preprocessor output file */ 594 595 Gbl_PreprocessorOutputFlag = TRUE; 596 break; 597 598 case 'n': 599 /* Produce namespace file */ 600 601 Gbl_NsOutputFlag = TRUE; 602 break; 603 604 case 's': 605 /* Produce combined source file */ 606 607 Gbl_SourceOutputFlag = TRUE; 608 break; 609 610 default: 611 printf ("Unknown option: -l%s\n", AcpiGbl_Optarg); 612 return (-1); 613 } 614 break; 615 616 617 case 'm': /* Do not convert buffers to resource descriptors */ 618 AcpiGbl_NoResourceDisassembly = TRUE; 619 break; 620 621 622 case 'n': /* Parse only */ 623 Gbl_ParseOnlyFlag = TRUE; 624 break; 625 626 627 case 'o': /* Control compiler AML optimizations */ 628 switch (AcpiGbl_Optarg[0]) 629 { 630 case 'a': 631 632 /* Disable all optimizations */ 633 634 Gbl_FoldConstants = FALSE; 635 Gbl_IntegerOptimizationFlag = FALSE; 636 Gbl_ReferenceOptimizationFlag = FALSE; 637 break; 638 639 case 'f': 640 641 /* Disable folding on "normal" expressions */ 642 643 Gbl_FoldConstants = FALSE; 644 break; 645 646 case 'i': 647 648 /* Disable integer optimization to constants */ 649 650 Gbl_IntegerOptimizationFlag = FALSE; 651 break; 652 653 case 'n': 654 655 /* Disable named reference optimization */ 656 657 Gbl_ReferenceOptimizationFlag = FALSE; 658 break; 659 660 case 't': 661 662 /* Display compile time(s) */ 663 664 Gbl_CompileTimesFlag = TRUE; 665 break; 666 667 default: 668 printf ("Unknown option: -c%s\n", AcpiGbl_Optarg); 669 return (-1); 670 } 671 break; 672 673 674 case 'P': /* Preprocess (plus .i file) only */ 675 Gbl_PreprocessOnly = TRUE; 676 Gbl_PreprocessorOutputFlag = TRUE; 677 break; 678 679 680 case 'p': /* Override default AML output filename */ 681 Gbl_OutputFilenamePrefix = AcpiGbl_Optarg; 682 Gbl_UseDefaultAmlFilename = FALSE; 683 break; 684 685 686 case 'r': /* Override revision found in table header */ 687 Gbl_RevisionOverride = (UINT8) strtoul (AcpiGbl_Optarg, NULL, 0); 688 break; 689 690 691 case 's': /* Create AML in a source code file */ 692 switch (AcpiGbl_Optarg[0]) 693 { 694 case 'a': 695 696 /* Produce assembly code output file */ 697 698 Gbl_AsmOutputFlag = TRUE; 699 break; 700 701 case 'c': 702 703 /* Produce C hex output file */ 704 705 Gbl_C_OutputFlag = TRUE; 706 break; 707 708 default: 709 printf ("Unknown option: -s%s\n", AcpiGbl_Optarg); 710 return (-1); 711 } 712 break; 713 714 715 case 't': /* Produce hex table output file */ 716 switch (AcpiGbl_Optarg[0]) 717 { 718 case 'a': 719 Gbl_HexOutputFlag = HEX_OUTPUT_ASM; 720 break; 721 722 case 'c': 723 Gbl_HexOutputFlag = HEX_OUTPUT_C; 724 break; 725 726 case 's': 727 Gbl_HexOutputFlag = HEX_OUTPUT_ASL; 728 break; 729 730 default: 731 printf ("Unknown option: -t%s\n", AcpiGbl_Optarg); 732 return (-1); 733 } 734 break; 735 736 737 case 'T': /* Create a ACPI table template file */ 738 Gbl_DoTemplates = TRUE; 739 Gbl_TemplateSignature = AcpiGbl_Optarg; 740 break; 741 742 743 case 'v': /* Verbosity settings */ 744 switch (AcpiGbl_Optarg[0]) 745 { 746 case 'a': 747 /* Disable All error/warning messages */ 748 749 Gbl_NoErrors = TRUE; 750 break; 751 752 case 'i': 753 /* Less verbose error messages */ 754 755 Gbl_VerboseErrors = FALSE; 756 break; 757 758 case 'o': 759 Gbl_DisplayOptimizations = TRUE; 760 break; 761 762 case 'r': 763 Gbl_DisplayRemarks = FALSE; 764 break; 765 766 case 's': 767 Gbl_DoSignon = FALSE; 768 break; 769 770 case 't': 771 Gbl_VerboseTemplates = TRUE; 772 break; 773 774 default: 775 printf ("Unknown option: -v%s\n", AcpiGbl_Optarg); 776 return (-1); 777 } 778 break; 779 780 781 case 'w': /* Set warning levels */ 782 switch (AcpiGbl_Optarg[0]) 783 { 784 case '1': 785 Gbl_WarningLevel = ASL_WARNING; 786 break; 787 788 case '2': 789 Gbl_WarningLevel = ASL_WARNING2; 790 break; 791 792 case '3': 793 Gbl_WarningLevel = ASL_WARNING3; 794 break; 795 796 default: 797 printf ("Unknown option: -w%s\n", AcpiGbl_Optarg); 798 return (-1); 799 } 800 break; 801 802 803 case 'x': /* Set debug print output level */ 804 AcpiDbgLevel = strtoul (AcpiGbl_Optarg, NULL, 16); 805 break; 806 807 808 case 'z': 809 Gbl_UseOriginalCompilerId = TRUE; 810 break; 811 812 813 default: 814 return (-1); 815 } 816 817 return (0); 818 } 819 820 821 /******************************************************************************* 822 * 823 * FUNCTION: AslCommandLine 824 * 825 * PARAMETERS: argc/argv 826 * 827 * RETURN: Last argv index 828 * 829 * DESCRIPTION: Command line processing 830 * 831 ******************************************************************************/ 832 833 static int 834 AslCommandLine ( 835 int argc, 836 char **argv) 837 { 838 int BadCommandLine = 0; 839 ACPI_STATUS Status; 840 841 842 /* Minimum command line contains at least the command and an input file */ 843 844 if (argc < 2) 845 { 846 printf (ACPI_COMMON_SIGNON (ASL_COMPILER_NAME)); 847 Usage (); 848 exit (1); 849 } 850 851 /* Process all command line options */ 852 853 BadCommandLine = AslDoOptions (argc, argv, FALSE); 854 855 if (Gbl_DoTemplates) 856 { 857 Status = DtCreateTemplates (Gbl_TemplateSignature); 858 if (ACPI_FAILURE (Status)) 859 { 860 exit (-1); 861 } 862 exit (1); 863 } 864 865 /* Next parameter must be the input filename */ 866 867 if (!argv[AcpiGbl_Optind] && 868 !Gbl_DisasmFlag && 869 !Gbl_GetAllTables) 870 { 871 printf ("Missing input filename\n"); 872 BadCommandLine = TRUE; 873 } 874 875 if (Gbl_DoSignon) 876 { 877 printf (ACPI_COMMON_SIGNON (ASL_COMPILER_NAME)); 878 if (Gbl_IgnoreErrors) 879 { 880 printf ("Ignoring all errors, forcing AML file generation\n\n"); 881 } 882 } 883 884 /* Abort if anything went wrong on the command line */ 885 886 if (BadCommandLine) 887 { 888 printf ("\n"); 889 Usage (); 890 exit (1); 891 } 892 893 return (AcpiGbl_Optind); 894 } 895 896 897 /******************************************************************************* 898 * 899 * FUNCTION: main 900 * 901 * PARAMETERS: Standard argc/argv 902 * 903 * RETURN: Program termination code 904 * 905 * DESCRIPTION: C main routine for the Asl Compiler. Handle command line 906 * options and begin the compile for each file on the command line 907 * 908 ******************************************************************************/ 909 910 int ACPI_SYSTEM_XFACE 911 main ( 912 int argc, 913 char **argv) 914 { 915 ACPI_STATUS Status; 916 int Index1; 917 int Index2; 918 919 920 AcpiGbl_ExternalFileList = NULL; 921 922 #ifdef _DEBUG 923 _CrtSetDbgFlag (_CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_LEAK_CHECK_DF | 924 _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG)); 925 #endif 926 927 /* Init and command line */ 928 929 AslInitialize (); 930 PrInitializePreprocessor (); 931 Index1 = Index2 = AslCommandLine (argc, argv); 932 933 /* Options that have no additional parameters or pathnames */ 934 935 if (Gbl_GetAllTables) 936 { 937 Status = AslDoOneFile (NULL); 938 if (ACPI_FAILURE (Status)) 939 { 940 return (-1); 941 } 942 return (0); 943 } 944 945 if (Gbl_DisassembleAll) 946 { 947 while (argv[Index1]) 948 { 949 Status = AslDoOnePathname (argv[Index1], AcpiDmAddToExternalFileList); 950 if (ACPI_FAILURE (Status)) 951 { 952 return (-1); 953 } 954 955 Index1++; 956 } 957 } 958 959 /* Process each pathname/filename in the list, with possible wildcards */ 960 961 while (argv[Index2]) 962 { 963 Status = AslDoOnePathname (argv[Index2], AslDoOneFile); 964 if (ACPI_FAILURE (Status)) 965 { 966 return (-1); 967 } 968 969 Index2++; 970 } 971 972 if (AcpiGbl_ExternalFileList) 973 { 974 AcpiDmClearExternalFileList(); 975 } 976 977 return (0); 978 } 979 980 981