1 2 /****************************************************************************** 3 * 4 * Module Name: aslmain - compiler main and utilities 5 * 6 *****************************************************************************/ 7 8 /****************************************************************************** 9 * 10 * 1. Copyright Notice 11 * 12 * Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp. 13 * All rights reserved. 14 * 15 * 2. License 16 * 17 * 2.1. This is your license from Intel Corp. under its intellectual property 18 * rights. You may have additional license terms from the party that provided 19 * you this software, covering your right to use that party's intellectual 20 * property rights. 21 * 22 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 23 * copy of the source code appearing in this file ("Covered Code") an 24 * irrevocable, perpetual, worldwide license under Intel's copyrights in the 25 * base code distributed originally by Intel ("Original Intel Code") to copy, 26 * make derivatives, distribute, use and display any portion of the Covered 27 * Code in any form, with the right to sublicense such rights; and 28 * 29 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 30 * license (with the right to sublicense), under only those claims of Intel 31 * patents that are infringed by the Original Intel Code, to make, use, sell, 32 * offer to sell, and import the Covered Code and derivative works thereof 33 * solely to the minimum extent necessary to exercise the above copyright 34 * license, and in no event shall the patent license extend to any additions 35 * to or modifications of the Original Intel Code. No other license or right 36 * is granted directly or by implication, estoppel or otherwise; 37 * 38 * The above copyright and patent license is granted only if the following 39 * conditions are met: 40 * 41 * 3. Conditions 42 * 43 * 3.1. Redistribution of Source with Rights to Further Distribute Source. 44 * Redistribution of source code of any substantial portion of the Covered 45 * Code or modification with rights to further distribute source must include 46 * the above Copyright Notice, the above License, this list of Conditions, 47 * and the following Disclaimer and Export Compliance provision. In addition, 48 * Licensee must cause all Covered Code to which Licensee contributes to 49 * contain a file documenting the changes Licensee made to create that Covered 50 * Code and the date of any change. Licensee must include in that file the 51 * documentation of any changes made by any predecessor Licensee. Licensee 52 * must include a prominent statement that the modification is derived, 53 * directly or indirectly, from Original Intel Code. 54 * 55 * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 56 * Redistribution of source code of any substantial portion of the Covered 57 * Code or modification without rights to further distribute source must 58 * include the following Disclaimer and Export Compliance provision in the 59 * documentation and/or other materials provided with distribution. In 60 * addition, Licensee may not authorize further sublicense of source of any 61 * portion of the Covered Code, and must include terms to the effect that the 62 * license from Licensee to its licensee is limited to the intellectual 63 * property embodied in the software Licensee provides to its licensee, and 64 * not to intellectual property embodied in modifications its licensee may 65 * make. 66 * 67 * 3.3. Redistribution of Executable. Redistribution in executable form of any 68 * substantial portion of the Covered Code or modification must reproduce the 69 * above Copyright Notice, and the following Disclaimer and Export Compliance 70 * provision in the documentation and/or other materials provided with the 71 * distribution. 72 * 73 * 3.4. Intel retains all right, title, and interest in and to the Original 74 * Intel Code. 75 * 76 * 3.5. Neither the name Intel nor any other trademark owned or controlled by 77 * Intel shall be used in advertising or otherwise to promote the sale, use or 78 * other dealings in products derived from or relating to the Covered Code 79 * without prior written authorization from Intel. 80 * 81 * 4. Disclaimer and Export Compliance 82 * 83 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 84 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 85 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 86 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 87 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 88 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 89 * PARTICULAR PURPOSE. 90 * 91 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 92 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 93 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 94 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 95 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 96 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 97 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 98 * LIMITED REMEDY. 99 * 100 * 4.3. Licensee shall not export, either directly or indirectly, any of this 101 * software or system incorporating such software without first obtaining any 102 * required license or other approval from the U. S. Department of Commerce or 103 * any other agency or department of the United States Government. In the 104 * event Licensee exports any such software from the United States or 105 * re-exports any such software from a foreign destination, Licensee shall 106 * ensure that the distribution and export/re-export of the software is in 107 * compliance with all laws, regulations, orders, or other restrictions of the 108 * U.S. Export Administration Regulations. Licensee agrees that neither it nor 109 * any of its subsidiaries will export/re-export any technical data, process, 110 * software, or service, directly or indirectly, to any country for which the 111 * United States government or any agency thereof requires an export license, 112 * other governmental approval, or letter of assurance, without first obtaining 113 * such license, approval or letter. 114 * 115 *****************************************************************************/ 116 117 118 #define _DECLARE_GLOBALS 119 120 #include <contrib/dev/acpica/compiler/aslcompiler.h> 121 #include <contrib/dev/acpica/include/acapps.h> 122 #include <contrib/dev/acpica/include/acdisasm.h> 123 124 #ifdef _DEBUG 125 #include <crtdbg.h> 126 #endif 127 128 #define _COMPONENT ACPI_COMPILER 129 ACPI_MODULE_NAME ("aslmain") 130 131 /* Local prototypes */ 132 133 static void 134 Options ( 135 void); 136 137 static void 138 HelpMessage ( 139 void); 140 141 static void 142 Usage ( 143 void); 144 145 static void 146 AslInitialize ( 147 void); 148 149 static int 150 AslCommandLine ( 151 int argc, 152 char **argv); 153 154 static int 155 AslDoOptions ( 156 int argc, 157 char **argv, 158 BOOLEAN IsResponseFile); 159 160 static void 161 AslMergeOptionTokens ( 162 char *InBuffer, 163 char *OutBuffer); 164 165 static int 166 AslDoResponseFile ( 167 char *Filename); 168 169 170 #define ASL_TOKEN_SEPARATORS " \t\n" 171 #define ASL_SUPPORTED_OPTIONS "@:2b:c:d^e:fgh^i^I:l^no:p:r:s:t:T:v:w:x:z" 172 173 174 /******************************************************************************* 175 * 176 * FUNCTION: Options 177 * 178 * PARAMETERS: None 179 * 180 * RETURN: None 181 * 182 * DESCRIPTION: Display option help message 183 * 184 ******************************************************************************/ 185 186 static void 187 Options ( 188 void) 189 { 190 191 printf ("Global:\n"); 192 printf (" -@<file> Specify command file\n"); 193 printf (" -I<dir> Specify additional include directory\n"); 194 195 printf ("\nGeneral Output:\n"); 196 printf (" -p<prefix> Specify path/filename prefix for all output files\n"); 197 printf (" -va Disable all errors and warnings (summary only)\n"); 198 printf (" -vi Less verbose errors and warnings for use with IDEs\n"); 199 printf (" -vo Enable optimization comments\n"); 200 printf (" -vr Disable remarks\n"); 201 printf (" -vs Disable signon\n"); 202 printf (" -w<1|2|3> Set warning reporting level\n"); 203 204 printf ("\nAML Output Files:\n"); 205 printf (" -s<a|c> Create AML in assembler or C source file (*.asm or *.c)\n"); 206 printf (" -i<a|c> Create assembler or C include file (*.inc or *.h)\n"); 207 printf (" -t<a|c|s> Create AML in assembler, C, or ASL hex table (*.hex)\n"); 208 209 printf ("\nAML Code Generation:\n"); 210 printf (" -oa Disable all optimizations (compatibility mode)\n"); 211 printf (" -of Disable constant folding\n"); 212 printf (" -oi Disable integer optimization to Zero/One/Ones\n"); 213 printf (" -on Disable named reference string optimization\n"); 214 printf (" -cr Disable Resource Descriptor error checking\n"); 215 printf (" -r<Revision> Override table header Revision (1-255)\n"); 216 217 printf ("\nASL Listing Files:\n"); 218 printf (" -l Create mixed listing file (ASL source and AML) (*.lst)\n"); 219 printf (" -ln Create namespace file (*.nsp)\n"); 220 printf (" -ls Create combined source file (expanded includes) (*.src)\n"); 221 222 printf ("\nACPI Data Tables:\n"); 223 printf (" -T <Sig> Create table template file for <Sig> (or \"ALL\")\n"); 224 printf (" -vt Create verbose templates (full disassembly)\n"); 225 226 printf ("\nAML Disassembler:\n"); 227 printf (" -d [file] Disassemble or decode binary ACPI table to file (*.dsl)\n"); 228 printf (" -da [f1,f2] Disassemble multiple tables from single namespace\n"); 229 printf (" -dc [file] Disassemble AML and immediately compile it\n"); 230 printf (" (Obtain DSDT from current system if no input file)\n"); 231 printf (" -e [f1,f2] Include ACPI table(s) for external symbol resolution\n"); 232 printf (" -2 Emit ACPI 2.0 compatible ASL code\n"); 233 printf (" -g Get ACPI tables and write to files (*.dat)\n"); 234 235 printf ("\nHelp:\n"); 236 printf (" -h Additional help and compiler debug options\n"); 237 printf (" -hc Display operators allowed in constant expressions\n"); 238 printf (" -hr Display ACPI reserved method names\n"); 239 printf (" -ht Display currently supported ACPI table names\n"); 240 } 241 242 243 /******************************************************************************* 244 * 245 * FUNCTION: HelpMessage 246 * 247 * PARAMETERS: None 248 * 249 * RETURN: None 250 * 251 * DESCRIPTION: Display help message 252 * 253 ******************************************************************************/ 254 255 static void 256 HelpMessage ( 257 void) 258 { 259 260 printf ("AML output filename generation:\n"); 261 printf (" Output filenames are generated by appending an extension to a common\n"); 262 printf (" filename prefix. The filename prefix is obtained via one of the\n"); 263 printf (" following methods (in priority order):\n"); 264 printf (" 1) The -p option specifies the prefix\n"); 265 printf (" 2) The prefix of the AMLFileName in the ASL Definition Block\n"); 266 printf (" 3) The prefix of the input filename\n"); 267 printf ("\n"); 268 269 Options (); 270 271 printf ("\nCompiler/Disassembler Debug Options:\n"); 272 printf (" -b<p|t|b> Create compiler debug/trace file (*.txt)\n"); 273 printf (" Types: Parse/Tree/Both\n"); 274 printf (" -f Ignore errors, force creation of AML output file(s)\n"); 275 printf (" -n Parse only, no output generation\n"); 276 printf (" -ot Display compile times\n"); 277 printf (" -x<level> Set debug level for trace output\n"); 278 printf (" -z Do not insert new compiler ID for DataTables\n"); 279 } 280 281 282 /******************************************************************************* 283 * 284 * FUNCTION: Usage 285 * 286 * PARAMETERS: None 287 * 288 * RETURN: None 289 * 290 * DESCRIPTION: Display usage and option message 291 * 292 ******************************************************************************/ 293 294 static void 295 Usage ( 296 void) 297 { 298 299 printf ("%s\n", ASL_COMPLIANCE); 300 printf ("Usage: %s [Options] [Files]\n\n", ASL_INVOCATION_NAME); 301 Options (); 302 } 303 304 305 /******************************************************************************* 306 * 307 * FUNCTION: AslInitialize 308 * 309 * PARAMETERS: None 310 * 311 * RETURN: None 312 * 313 * DESCRIPTION: Initialize compiler globals 314 * 315 ******************************************************************************/ 316 317 static void 318 AslInitialize ( 319 void) 320 { 321 UINT32 i; 322 323 324 #ifdef _DEBUG 325 _CrtSetDbgFlag (_CRTDBG_CHECK_ALWAYS_DF | _CrtSetDbgFlag(0)); 326 #endif 327 328 AcpiDbgLevel = 0; 329 330 for (i = 0; i < ASL_NUM_FILES; i++) 331 { 332 Gbl_Files[i].Handle = NULL; 333 Gbl_Files[i].Filename = NULL; 334 } 335 336 Gbl_Files[ASL_FILE_STDOUT].Handle = stdout; 337 Gbl_Files[ASL_FILE_STDOUT].Filename = "STDOUT"; 338 339 Gbl_Files[ASL_FILE_STDERR].Handle = stderr; 340 Gbl_Files[ASL_FILE_STDERR].Filename = "STDERR"; 341 } 342 343 344 /******************************************************************************* 345 * 346 * FUNCTION: AslMergeOptionTokens 347 * 348 * PARAMETERS: InBuffer - Input containing an option string 349 * OutBuffer - Merged output buffer 350 * 351 * RETURN: None 352 * 353 * DESCRIPTION: Remove all whitespace from an option string. 354 * 355 ******************************************************************************/ 356 357 static void 358 AslMergeOptionTokens ( 359 char *InBuffer, 360 char *OutBuffer) 361 { 362 char *Token; 363 364 365 *OutBuffer = 0; 366 367 Token = strtok (InBuffer, ASL_TOKEN_SEPARATORS); 368 while (Token) 369 { 370 strcat (OutBuffer, Token); 371 Token = strtok (NULL, ASL_TOKEN_SEPARATORS); 372 } 373 } 374 375 376 /******************************************************************************* 377 * 378 * FUNCTION: AslDoResponseFile 379 * 380 * PARAMETERS: Filename - Name of the response file 381 * 382 * RETURN: Status 383 * 384 * DESCRIPTION: Open a response file and process all options within. 385 * 386 ******************************************************************************/ 387 388 static int 389 AslDoResponseFile ( 390 char *Filename) 391 { 392 char *argv = StringBuffer2; 393 FILE *ResponseFile; 394 int OptStatus = 0; 395 int Opterr; 396 int Optind; 397 398 399 ResponseFile = fopen (Filename, "r"); 400 if (!ResponseFile) 401 { 402 printf ("Could not open command file %s, %s\n", 403 Filename, strerror (errno)); 404 return -1; 405 } 406 407 /* Must save the current GetOpt globals */ 408 409 Opterr = AcpiGbl_Opterr; 410 Optind = AcpiGbl_Optind; 411 412 /* 413 * Process all lines in the response file. There must be one complete 414 * option per line 415 */ 416 while (fgets (StringBuffer, ASL_MSG_BUFFER_SIZE, ResponseFile)) 417 { 418 /* Compress all tokens, allowing us to use a single argv entry */ 419 420 AslMergeOptionTokens (StringBuffer, StringBuffer2); 421 422 /* Process the option */ 423 424 AcpiGbl_Opterr = 0; 425 AcpiGbl_Optind = 0; 426 427 OptStatus = AslDoOptions (1, &argv, TRUE); 428 if (OptStatus) 429 { 430 printf ("Invalid option in command file %s: %s\n", 431 Filename, StringBuffer); 432 break; 433 } 434 } 435 436 /* Restore the GetOpt globals */ 437 438 AcpiGbl_Opterr = Opterr; 439 AcpiGbl_Optind = Optind; 440 441 fclose (ResponseFile); 442 return (OptStatus); 443 } 444 445 446 /******************************************************************************* 447 * 448 * FUNCTION: AslDoOptions 449 * 450 * PARAMETERS: argc/argv - Standard argc/argv 451 * IsResponseFile - TRUE if executing a response file. 452 * 453 * RETURN: Status 454 * 455 * DESCRIPTION: Command line option processing 456 * 457 ******************************************************************************/ 458 459 static int 460 AslDoOptions ( 461 int argc, 462 char **argv, 463 BOOLEAN IsResponseFile) 464 { 465 int j; 466 ACPI_STATUS Status; 467 468 469 /* Get the command line options */ 470 471 while ((j = AcpiGetopt (argc, argv, ASL_SUPPORTED_OPTIONS)) != EOF) switch (j) 472 { 473 case '@': /* Begin a response file */ 474 475 if (IsResponseFile) 476 { 477 printf ("Nested command files are not supported\n"); 478 return -1; 479 } 480 481 if (AslDoResponseFile (AcpiGbl_Optarg)) 482 { 483 return -1; 484 } 485 break; 486 487 488 case '2': 489 490 Gbl_Acpi2 = TRUE; 491 break; 492 493 494 case 'b': 495 496 switch (AcpiGbl_Optarg[0]) 497 { 498 case 'b': 499 AslCompilerdebug = 1; /* same as yydebug */ 500 break; 501 502 case 'p': 503 AslCompilerdebug = 1; /* same as yydebug */ 504 break; 505 506 case 't': 507 break; 508 509 default: 510 printf ("Unknown option: -b%s\n", AcpiGbl_Optarg); 511 return (-1); 512 } 513 514 /* Produce debug output file */ 515 516 Gbl_DebugFlag = TRUE; 517 break; 518 519 520 case 'c': 521 switch (AcpiGbl_Optarg[0]) 522 { 523 case 'r': 524 Gbl_NoResourceChecking = TRUE; 525 break; 526 527 default: 528 printf ("Unknown option: -c%s\n", AcpiGbl_Optarg); 529 return (-1); 530 } 531 break; 532 533 534 case 'd': 535 switch (AcpiGbl_Optarg[0]) 536 { 537 case '^': 538 Gbl_DoCompile = FALSE; 539 break; 540 541 case 'a': 542 Gbl_DoCompile = FALSE; 543 Gbl_DisassembleAll = TRUE; 544 break; 545 546 case 'c': 547 break; 548 549 default: 550 printf ("Unknown option: -d%s\n", AcpiGbl_Optarg); 551 return (-1); 552 } 553 554 Gbl_DisasmFlag = TRUE; 555 break; 556 557 558 case 'e': 559 Status = AcpiDmAddToExternalFileList (AcpiGbl_Optarg); 560 if (ACPI_FAILURE (Status)) 561 { 562 printf ("Could not add %s to external list\n", AcpiGbl_Optarg); 563 return (-1); 564 } 565 break; 566 567 568 case 'f': 569 570 /* Ignore errors and force creation of aml file */ 571 572 Gbl_IgnoreErrors = TRUE; 573 break; 574 575 576 case 'g': 577 578 /* Get all ACPI tables */ 579 580 Gbl_GetAllTables = TRUE; 581 Gbl_DoCompile = FALSE; 582 break; 583 584 585 case 'h': 586 587 switch (AcpiGbl_Optarg[0]) 588 { 589 case '^': 590 HelpMessage (); 591 exit (0); 592 593 case 'c': 594 UtDisplayConstantOpcodes (); 595 exit (0); 596 597 case 'r': 598 /* reserved names */ 599 600 ApDisplayReservedNames (); 601 exit (0); 602 603 case 't': 604 UtDisplaySupportedTables (); 605 exit (0); 606 607 default: 608 printf ("Unknown option: -h%s\n", AcpiGbl_Optarg); 609 return (-1); 610 } 611 612 613 case 'I': /* Add an include file search directory */ 614 615 FlAddIncludeDirectory (AcpiGbl_Optarg); 616 break; 617 618 619 case 'i': 620 621 switch (AcpiGbl_Optarg[0]) 622 { 623 case 'a': 624 625 /* Produce assembly code include file */ 626 627 Gbl_AsmIncludeOutputFlag = TRUE; 628 break; 629 630 case 'c': 631 632 /* Produce C include file */ 633 634 Gbl_C_IncludeOutputFlag = TRUE; 635 break; 636 637 default: 638 printf ("Unknown option: -s%s\n", AcpiGbl_Optarg); 639 return (-1); 640 } 641 break; 642 643 644 case 'l': 645 646 switch (AcpiGbl_Optarg[0]) 647 { 648 case '^': 649 /* Produce listing file (Mixed source/aml) */ 650 651 Gbl_ListingFlag = TRUE; 652 break; 653 654 case 'n': 655 /* Produce namespace file */ 656 657 Gbl_NsOutputFlag = TRUE; 658 break; 659 660 case 's': 661 /* Produce combined source file */ 662 663 Gbl_SourceOutputFlag = TRUE; 664 break; 665 666 default: 667 printf ("Unknown option: -l%s\n", AcpiGbl_Optarg); 668 return (-1); 669 } 670 break; 671 672 673 case 'o': 674 675 switch (AcpiGbl_Optarg[0]) 676 { 677 case 'a': 678 679 /* Disable all optimizations */ 680 681 Gbl_FoldConstants = FALSE; 682 Gbl_IntegerOptimizationFlag = FALSE; 683 Gbl_ReferenceOptimizationFlag = FALSE; 684 break; 685 686 case 'f': 687 688 /* Disable folding on "normal" expressions */ 689 690 Gbl_FoldConstants = FALSE; 691 break; 692 693 case 'i': 694 695 /* Disable integer optimization to constants */ 696 697 Gbl_IntegerOptimizationFlag = FALSE; 698 break; 699 700 case 'n': 701 702 /* Disable named reference optimization */ 703 704 Gbl_ReferenceOptimizationFlag = FALSE; 705 break; 706 707 case 't': 708 709 /* Display compile time(s) */ 710 711 Gbl_CompileTimesFlag = TRUE; 712 break; 713 714 default: 715 printf ("Unknown option: -c%s\n", AcpiGbl_Optarg); 716 return (-1); 717 } 718 break; 719 720 721 case 'n': 722 723 /* Parse only */ 724 725 Gbl_ParseOnlyFlag = TRUE; 726 break; 727 728 729 case 'p': 730 731 /* Override default AML output filename */ 732 733 Gbl_OutputFilenamePrefix = AcpiGbl_Optarg; 734 Gbl_UseDefaultAmlFilename = FALSE; 735 break; 736 737 738 case 'r': 739 Gbl_RevisionOverride = (UINT8) strtoul (AcpiGbl_Optarg, NULL, 0); 740 break; 741 742 743 case 's': 744 745 switch (AcpiGbl_Optarg[0]) 746 { 747 case 'a': 748 749 /* Produce assembly code output file */ 750 751 Gbl_AsmOutputFlag = TRUE; 752 break; 753 754 case 'c': 755 756 /* Produce C hex output file */ 757 758 Gbl_C_OutputFlag = TRUE; 759 break; 760 761 default: 762 printf ("Unknown option: -s%s\n", AcpiGbl_Optarg); 763 return (-1); 764 } 765 break; 766 767 768 case 't': 769 770 /* Produce hex table output file */ 771 772 switch (AcpiGbl_Optarg[0]) 773 { 774 case 'a': 775 Gbl_HexOutputFlag = HEX_OUTPUT_ASM; 776 break; 777 778 case 'c': 779 Gbl_HexOutputFlag = HEX_OUTPUT_C; 780 break; 781 782 case 's': 783 Gbl_HexOutputFlag = HEX_OUTPUT_ASL; 784 break; 785 786 default: 787 printf ("Unknown option: -t%s\n", AcpiGbl_Optarg); 788 return (-1); 789 } 790 break; 791 792 793 case 'T': 794 Gbl_DoTemplates = TRUE; 795 Gbl_TemplateSignature = AcpiGbl_Optarg; 796 break; 797 798 799 case 'v': 800 801 switch (AcpiGbl_Optarg[0]) 802 { 803 case 'a': 804 /* Disable All error/warning messages */ 805 806 Gbl_NoErrors = TRUE; 807 break; 808 809 case 'i': 810 /* Less verbose error messages */ 811 812 Gbl_VerboseErrors = FALSE; 813 break; 814 815 case 'o': 816 Gbl_DisplayOptimizations = TRUE; 817 break; 818 819 case 'r': 820 Gbl_DisplayRemarks = FALSE; 821 break; 822 823 case 's': 824 Gbl_DoSignon = FALSE; 825 break; 826 827 case 't': 828 Gbl_VerboseTemplates = TRUE; 829 break; 830 831 default: 832 printf ("Unknown option: -v%s\n", AcpiGbl_Optarg); 833 return (-1); 834 } 835 break; 836 837 838 case 'w': /* Set warning levels */ 839 840 switch (AcpiGbl_Optarg[0]) 841 { 842 case '1': 843 Gbl_WarningLevel = ASL_WARNING; 844 break; 845 846 case '2': 847 Gbl_WarningLevel = ASL_WARNING2; 848 break; 849 850 case '3': 851 Gbl_WarningLevel = ASL_WARNING3; 852 break; 853 854 default: 855 printf ("Unknown option: -w%s\n", AcpiGbl_Optarg); 856 return (-1); 857 } 858 break; 859 860 861 case 'x': 862 863 AcpiDbgLevel = strtoul (AcpiGbl_Optarg, NULL, 16); 864 break; 865 866 867 case 'z': 868 869 Gbl_UseOriginalCompilerId = TRUE; 870 break; 871 872 873 default: 874 875 return (-1); 876 } 877 878 return (0); 879 } 880 881 882 /******************************************************************************* 883 * 884 * FUNCTION: AslCommandLine 885 * 886 * PARAMETERS: argc/argv 887 * 888 * RETURN: Last argv index 889 * 890 * DESCRIPTION: Command line processing 891 * 892 ******************************************************************************/ 893 894 static int 895 AslCommandLine ( 896 int argc, 897 char **argv) 898 { 899 int BadCommandLine = 0; 900 ACPI_STATUS Status; 901 902 903 /* Minimum command line contains at least the command and an input file */ 904 905 if (argc < 2) 906 { 907 printf (ACPI_COMMON_SIGNON (ASL_COMPILER_NAME)); 908 Usage (); 909 exit (1); 910 } 911 912 /* Process all command line options */ 913 914 BadCommandLine = AslDoOptions (argc, argv, FALSE); 915 916 if (Gbl_DoTemplates) 917 { 918 Status = DtCreateTemplates (Gbl_TemplateSignature); 919 if (ACPI_FAILURE (Status)) 920 { 921 exit (-1); 922 } 923 exit (1); 924 } 925 926 /* Next parameter must be the input filename */ 927 928 if (!argv[AcpiGbl_Optind] && 929 !Gbl_DisasmFlag && 930 !Gbl_GetAllTables) 931 { 932 printf ("Missing input filename\n"); 933 BadCommandLine = TRUE; 934 } 935 936 if (Gbl_DoSignon) 937 { 938 printf (ACPI_COMMON_SIGNON (ASL_COMPILER_NAME)); 939 } 940 941 /* Abort if anything went wrong on the command line */ 942 943 if (BadCommandLine) 944 { 945 printf ("\n"); 946 Usage (); 947 exit (1); 948 } 949 950 return (AcpiGbl_Optind); 951 } 952 953 954 /******************************************************************************* 955 * 956 * FUNCTION: main 957 * 958 * PARAMETERS: Standard argc/argv 959 * 960 * RETURN: Program termination code 961 * 962 * DESCRIPTION: C main routine for the Asl Compiler. Handle command line 963 * options and begin the compile for each file on the command line 964 * 965 ******************************************************************************/ 966 967 int ACPI_SYSTEM_XFACE 968 main ( 969 int argc, 970 char **argv) 971 { 972 ACPI_STATUS Status; 973 int Index1; 974 int Index2; 975 976 977 AcpiGbl_ExternalFileList = NULL; 978 979 #ifdef _DEBUG 980 _CrtSetDbgFlag (_CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_LEAK_CHECK_DF | 981 _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG)); 982 #endif 983 984 /* Init and command line */ 985 986 AslInitialize (); 987 Index1 = Index2 = AslCommandLine (argc, argv); 988 989 /* Options that have no additional parameters or pathnames */ 990 991 if (Gbl_GetAllTables) 992 { 993 Status = AslDoOneFile (NULL); 994 if (ACPI_FAILURE (Status)) 995 { 996 return (-1); 997 } 998 return (0); 999 } 1000 1001 if (Gbl_DisassembleAll) 1002 { 1003 while (argv[Index1]) 1004 { 1005 Status = AslDoOnePathname (argv[Index1], AcpiDmAddToExternalFileList); 1006 if (ACPI_FAILURE (Status)) 1007 { 1008 return (-1); 1009 } 1010 1011 Index1++; 1012 } 1013 } 1014 1015 /* Process each pathname/filename in the list, with possible wildcards */ 1016 1017 while (argv[Index2]) 1018 { 1019 Status = AslDoOnePathname (argv[Index2], AslDoOneFile); 1020 if (ACPI_FAILURE (Status)) 1021 { 1022 return (-1); 1023 } 1024 1025 Index2++; 1026 } 1027 1028 if (AcpiGbl_ExternalFileList) 1029 { 1030 AcpiDmClearExternalFileList(); 1031 } 1032 1033 return (0); 1034 } 1035 1036 1037