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 123 #ifdef _DEBUG 124 #include <crtdbg.h> 125 #endif 126 127 #define _COMPONENT ACPI_COMPILER 128 ACPI_MODULE_NAME ("aslmain") 129 130 /* Local prototypes */ 131 132 static void 133 Options ( 134 void); 135 136 static void 137 HelpMessage ( 138 void); 139 140 static void 141 Usage ( 142 void); 143 144 static void 145 AslInitialize ( 146 void); 147 148 static int 149 AslCommandLine ( 150 int argc, 151 char **argv); 152 153 static int 154 AslDoOptions ( 155 int argc, 156 char **argv, 157 BOOLEAN IsResponseFile); 158 159 static void 160 AslMergeOptionTokens ( 161 char *InBuffer, 162 char *OutBuffer); 163 164 static int 165 AslDoResponseFile ( 166 char *Filename); 167 168 169 #define ASL_TOKEN_SEPARATORS " \t\n" 170 #define ASL_SUPPORTED_OPTIONS "@:2b:c:d^e:fgh^i^I:l^no:p:r:s:t:v:w:x:" 171 172 173 /******************************************************************************* 174 * 175 * FUNCTION: Options 176 * 177 * PARAMETERS: None 178 * 179 * RETURN: None 180 * 181 * DESCRIPTION: Display option help message 182 * 183 ******************************************************************************/ 184 185 static void 186 Options ( 187 void) 188 { 189 190 printf ("Global:\n"); 191 printf (" -@<file> Specify command file\n"); 192 printf (" -I<dir> Specify additional include directory\n"); 193 194 printf ("\nGeneral Output:\n"); 195 printf (" -p<prefix> Specify path/filename prefix for all output files\n"); 196 printf (" -va Disable all errors and warnings (summary only)\n"); 197 printf (" -vi Less verbose errors and warnings for use with IDEs\n"); 198 printf (" -vo Enable optimization comments\n"); 199 printf (" -vr Disable remarks\n"); 200 printf (" -vs Disable signon\n"); 201 printf (" -w<1|2|3> Set warning reporting level\n"); 202 203 printf ("\nAML Output Files:\n"); 204 printf (" -s<a|c> Create AML in assembler or C source file (*.asm or *.c)\n"); 205 printf (" -i<a|c> Create assembler or C include file (*.inc or *.h)\n"); 206 printf (" -t<a|c|s> Create AML in assembler, C, or ASL hex table (*.hex)\n"); 207 208 printf ("\nAML Code Generation:\n"); 209 printf (" -oa Disable all optimizations (compatibility mode)\n"); 210 printf (" -of Disable constant folding\n"); 211 printf (" -oi Disable integer optimization to Zero/One/Ones\n"); 212 printf (" -on Disable named reference string optimization\n"); 213 printf (" -cr Disable Resource Descriptor error checking\n"); 214 printf (" -r<Revision> Override table header Revision (1-255)\n"); 215 216 printf ("\nListings:\n"); 217 printf (" -l Create mixed listing file (ASL source and AML) (*.lst)\n"); 218 printf (" -ln Create namespace file (*.nsp)\n"); 219 printf (" -ls Create combined source file (expanded includes) (*.src)\n"); 220 221 printf ("\nAML Disassembler:\n"); 222 printf (" -d [file] Disassemble or decode binary ACPI table to file (*.dsl)\n"); 223 printf (" -dc [file] Disassemble AML and immediately compile it\n"); 224 printf (" (Obtain DSDT from current system if no input file)\n"); 225 printf (" -e [f1,f2] Include ACPI table(s) for external symbol resolution\n"); 226 printf (" -2 Emit ACPI 2.0 compatible ASL code\n"); 227 printf (" -g Get ACPI tables and write to files (*.dat)\n"); 228 229 printf ("\nHelp:\n"); 230 printf (" -h Additional help and compiler debug options\n"); 231 printf (" -hc Display operators allowed in constant expressions\n"); 232 printf (" -hr Display ACPI reserved method names\n"); 233 } 234 235 236 /******************************************************************************* 237 * 238 * FUNCTION: HelpMessage 239 * 240 * PARAMETERS: None 241 * 242 * RETURN: None 243 * 244 * DESCRIPTION: Display help message 245 * 246 ******************************************************************************/ 247 248 static void 249 HelpMessage ( 250 void) 251 { 252 253 printf ("AML output filename generation:\n"); 254 printf (" Output filenames are generated by appending an extension to a common\n"); 255 printf (" filename prefix. The filename prefix is obtained via one of the\n"); 256 printf (" following methods (in priority order):\n"); 257 printf (" 1) The -p option specifies the prefix\n"); 258 printf (" 2) The prefix of the AMLFileName in the ASL Definition Block\n"); 259 printf (" 3) The prefix of the input filename\n"); 260 printf ("\n"); 261 262 Options (); 263 264 printf ("\nCompiler/Disassembler Debug Options:\n"); 265 printf (" -b<p|t|b> Create compiler debug/trace file (*.txt)\n"); 266 printf (" Types: Parse/Tree/Both\n"); 267 printf (" -f Ignore errors, force creation of AML output file(s)\n"); 268 printf (" -n Parse only, no output generation\n"); 269 printf (" -ot Display compile times\n"); 270 printf (" -x<level> Set debug level for trace output\n"); 271 } 272 273 274 /******************************************************************************* 275 * 276 * FUNCTION: Usage 277 * 278 * PARAMETERS: None 279 * 280 * RETURN: None 281 * 282 * DESCRIPTION: Display usage and option message 283 * 284 ******************************************************************************/ 285 286 static void 287 Usage ( 288 void) 289 { 290 291 printf ("Usage: %s [Options] [Files]\n\n", CompilerName); 292 Options (); 293 } 294 295 296 /******************************************************************************* 297 * 298 * FUNCTION: AslInitialize 299 * 300 * PARAMETERS: None 301 * 302 * RETURN: None 303 * 304 * DESCRIPTION: Initialize compiler globals 305 * 306 ******************************************************************************/ 307 308 static void 309 AslInitialize ( 310 void) 311 { 312 UINT32 i; 313 314 315 #ifdef _DEBUG 316 _CrtSetDbgFlag (_CRTDBG_CHECK_ALWAYS_DF | _CrtSetDbgFlag(0)); 317 #endif 318 319 AcpiDbgLevel = 0; 320 321 for (i = 0; i < ASL_NUM_FILES; i++) 322 { 323 Gbl_Files[i].Handle = NULL; 324 Gbl_Files[i].Filename = NULL; 325 } 326 327 Gbl_Files[ASL_FILE_STDOUT].Handle = stdout; 328 Gbl_Files[ASL_FILE_STDOUT].Filename = "STDOUT"; 329 330 Gbl_Files[ASL_FILE_STDERR].Handle = stderr; 331 Gbl_Files[ASL_FILE_STDERR].Filename = "STDERR"; 332 } 333 334 335 /******************************************************************************* 336 * 337 * FUNCTION: AslMergeOptionTokens 338 * 339 * PARAMETERS: InBuffer - Input containing an option string 340 * OutBuffer - Merged output buffer 341 * 342 * RETURN: None 343 * 344 * DESCRIPTION: Remove all whitespace from an option string. 345 * 346 ******************************************************************************/ 347 348 static void 349 AslMergeOptionTokens ( 350 char *InBuffer, 351 char *OutBuffer) 352 { 353 char *Token; 354 355 356 *OutBuffer = 0; 357 358 Token = strtok (InBuffer, ASL_TOKEN_SEPARATORS); 359 while (Token) 360 { 361 strcat (OutBuffer, Token); 362 Token = strtok (NULL, ASL_TOKEN_SEPARATORS); 363 } 364 } 365 366 367 /******************************************************************************* 368 * 369 * FUNCTION: AslDoResponseFile 370 * 371 * PARAMETERS: Filename - Name of the response file 372 * 373 * RETURN: Status 374 * 375 * DESCRIPTION: Open a response file and process all options within. 376 * 377 ******************************************************************************/ 378 379 static int 380 AslDoResponseFile ( 381 char *Filename) 382 { 383 char *argv = StringBuffer2; 384 FILE *ResponseFile; 385 int OptStatus = 0; 386 int Opterr; 387 int Optind; 388 389 390 ResponseFile = fopen (Filename, "r"); 391 if (!ResponseFile) 392 { 393 printf ("Could not open command file %s, %s\n", 394 Filename, strerror (errno)); 395 return -1; 396 } 397 398 /* Must save the current GetOpt globals */ 399 400 Opterr = AcpiGbl_Opterr; 401 Optind = AcpiGbl_Optind; 402 403 /* 404 * Process all lines in the response file. There must be one complete 405 * option per line 406 */ 407 while (fgets (StringBuffer, ASL_MSG_BUFFER_SIZE, ResponseFile)) 408 { 409 /* Compress all tokens, allowing us to use a single argv entry */ 410 411 AslMergeOptionTokens (StringBuffer, StringBuffer2); 412 413 /* Process the option */ 414 415 AcpiGbl_Opterr = 0; 416 AcpiGbl_Optind = 0; 417 418 OptStatus = AslDoOptions (1, &argv, TRUE); 419 if (OptStatus) 420 { 421 printf ("Invalid option in command file %s: %s\n", 422 Filename, StringBuffer); 423 break; 424 } 425 } 426 427 /* Restore the GetOpt globals */ 428 429 AcpiGbl_Opterr = Opterr; 430 AcpiGbl_Optind = Optind; 431 432 fclose (ResponseFile); 433 return (OptStatus); 434 } 435 436 437 /******************************************************************************* 438 * 439 * FUNCTION: AslDoOptions 440 * 441 * PARAMETERS: argc/argv - Standard argc/argv 442 * IsResponseFile - TRUE if executing a response file. 443 * 444 * RETURN: Status 445 * 446 * DESCRIPTION: Command line option processing 447 * 448 ******************************************************************************/ 449 450 static int 451 AslDoOptions ( 452 int argc, 453 char **argv, 454 BOOLEAN IsResponseFile) 455 { 456 int j; 457 458 459 /* Get the command line options */ 460 461 while ((j = AcpiGetopt (argc, argv, ASL_SUPPORTED_OPTIONS)) != EOF) switch (j) 462 { 463 case '@': /* Begin a response file */ 464 465 if (IsResponseFile) 466 { 467 printf ("Nested command files are not supported\n"); 468 return -1; 469 } 470 471 if (AslDoResponseFile (AcpiGbl_Optarg)) 472 { 473 return -1; 474 } 475 break; 476 477 478 case '2': 479 480 Gbl_Acpi2 = TRUE; 481 break; 482 483 484 case 'b': 485 486 switch (AcpiGbl_Optarg[0]) 487 { 488 case 'b': 489 AslCompilerdebug = 1; /* same as yydebug */ 490 break; 491 492 case 'p': 493 AslCompilerdebug = 1; /* same as yydebug */ 494 break; 495 496 case 't': 497 break; 498 499 default: 500 printf ("Unknown option: -b%s\n", AcpiGbl_Optarg); 501 return (-1); 502 } 503 504 /* Produce debug output file */ 505 506 Gbl_DebugFlag = TRUE; 507 break; 508 509 510 case 'c': 511 switch (AcpiGbl_Optarg[0]) 512 { 513 case 'r': 514 Gbl_NoResourceChecking = TRUE; 515 break; 516 517 default: 518 printf ("Unknown option: -c%s\n", AcpiGbl_Optarg); 519 return (-1); 520 } 521 break; 522 523 524 case 'd': 525 switch (AcpiGbl_Optarg[0]) 526 { 527 case '^': 528 Gbl_DoCompile = FALSE; 529 break; 530 531 case 'c': 532 break; 533 534 default: 535 printf ("Unknown option: -d%s\n", AcpiGbl_Optarg); 536 return (-1); 537 } 538 539 Gbl_DisasmFlag = TRUE; 540 break; 541 542 543 case 'e': 544 Gbl_ExternalFilename = AcpiGbl_Optarg; 545 break; 546 547 548 case 'f': 549 550 /* Ignore errors and force creation of aml file */ 551 552 Gbl_IgnoreErrors = TRUE; 553 break; 554 555 556 case 'g': 557 558 /* Get all ACPI tables */ 559 560 Gbl_GetAllTables = TRUE; 561 Gbl_DoCompile = FALSE; 562 break; 563 564 565 case 'h': 566 567 switch (AcpiGbl_Optarg[0]) 568 { 569 case '^': 570 HelpMessage (); 571 exit (0); 572 573 case 'c': 574 UtDisplayConstantOpcodes (); 575 exit (0); 576 577 case 'r': 578 /* reserved names */ 579 580 ApDisplayReservedNames (); 581 exit (0); 582 583 default: 584 printf ("Unknown option: -h%s\n", AcpiGbl_Optarg); 585 return (-1); 586 } 587 break; 588 589 590 case 'I': /* Add an include file search directory */ 591 592 FlAddIncludeDirectory (AcpiGbl_Optarg); 593 break; 594 595 596 case 'i': 597 598 switch (AcpiGbl_Optarg[0]) 599 { 600 case 'a': 601 602 /* Produce assembly code include file */ 603 604 Gbl_AsmIncludeOutputFlag = TRUE; 605 break; 606 607 case 'c': 608 609 /* Produce C include file */ 610 611 Gbl_C_IncludeOutputFlag = TRUE; 612 break; 613 614 default: 615 printf ("Unknown option: -s%s\n", AcpiGbl_Optarg); 616 return (-1); 617 } 618 break; 619 620 621 case 'l': 622 623 switch (AcpiGbl_Optarg[0]) 624 { 625 case '^': 626 /* Produce listing file (Mixed source/aml) */ 627 628 Gbl_ListingFlag = TRUE; 629 break; 630 631 case 'n': 632 /* Produce namespace file */ 633 634 Gbl_NsOutputFlag = TRUE; 635 break; 636 637 case 's': 638 /* Produce combined source file */ 639 640 Gbl_SourceOutputFlag = TRUE; 641 break; 642 643 default: 644 printf ("Unknown option: -l%s\n", AcpiGbl_Optarg); 645 return (-1); 646 } 647 break; 648 649 650 case 'o': 651 652 switch (AcpiGbl_Optarg[0]) 653 { 654 case 'a': 655 656 /* Disable all optimizations */ 657 658 Gbl_FoldConstants = FALSE; 659 Gbl_IntegerOptimizationFlag = FALSE; 660 Gbl_ReferenceOptimizationFlag = FALSE; 661 break; 662 663 case 'f': 664 665 /* Disable folding on "normal" expressions */ 666 667 Gbl_FoldConstants = FALSE; 668 break; 669 670 case 'i': 671 672 /* Disable integer optimization to constants */ 673 674 Gbl_IntegerOptimizationFlag = FALSE; 675 break; 676 677 case 'n': 678 679 /* Disable named reference optimization */ 680 681 Gbl_ReferenceOptimizationFlag = FALSE; 682 break; 683 684 case 't': 685 686 /* Display compile time(s) */ 687 688 Gbl_CompileTimesFlag = TRUE; 689 break; 690 691 default: 692 printf ("Unknown option: -c%s\n", AcpiGbl_Optarg); 693 return (-1); 694 } 695 break; 696 697 698 case 'n': 699 700 /* Parse only */ 701 702 Gbl_ParseOnlyFlag = TRUE; 703 break; 704 705 706 case 'p': 707 708 /* Override default AML output filename */ 709 710 Gbl_OutputFilenamePrefix = AcpiGbl_Optarg; 711 Gbl_UseDefaultAmlFilename = FALSE; 712 break; 713 714 715 case 'r': 716 Gbl_RevisionOverride = (UINT8) strtoul (AcpiGbl_Optarg, NULL, 0); 717 break; 718 719 720 case 's': 721 722 switch (AcpiGbl_Optarg[0]) 723 { 724 case 'a': 725 726 /* Produce assembly code output file */ 727 728 Gbl_AsmOutputFlag = TRUE; 729 break; 730 731 case 'c': 732 733 /* Produce C hex output file */ 734 735 Gbl_C_OutputFlag = TRUE; 736 break; 737 738 default: 739 printf ("Unknown option: -s%s\n", AcpiGbl_Optarg); 740 return (-1); 741 } 742 break; 743 744 745 case 't': 746 747 /* Produce hex table output file */ 748 749 switch (AcpiGbl_Optarg[0]) 750 { 751 case 'a': 752 Gbl_HexOutputFlag = HEX_OUTPUT_ASM; 753 break; 754 755 case 'c': 756 Gbl_HexOutputFlag = HEX_OUTPUT_C; 757 break; 758 759 case 's': 760 Gbl_HexOutputFlag = HEX_OUTPUT_ASL; 761 break; 762 763 default: 764 printf ("Unknown option: -t%s\n", AcpiGbl_Optarg); 765 return (-1); 766 } 767 break; 768 769 770 case 'v': 771 772 switch (AcpiGbl_Optarg[0]) 773 { 774 case 'a': 775 /* Disable All error/warning messages */ 776 777 Gbl_NoErrors = TRUE; 778 break; 779 780 case 'i': 781 /* Less verbose error messages */ 782 783 Gbl_VerboseErrors = FALSE; 784 break; 785 786 case 'o': 787 Gbl_DisplayOptimizations = TRUE; 788 break; 789 790 case 'r': 791 Gbl_DisplayRemarks = FALSE; 792 break; 793 794 case 's': 795 Gbl_DoSignon = FALSE; 796 break; 797 798 default: 799 printf ("Unknown option: -v%s\n", AcpiGbl_Optarg); 800 return (-1); 801 } 802 break; 803 804 805 case 'w': /* Set warning levels */ 806 807 switch (AcpiGbl_Optarg[0]) 808 { 809 case '1': 810 Gbl_WarningLevel = ASL_WARNING; 811 break; 812 813 case '2': 814 Gbl_WarningLevel = ASL_WARNING2; 815 break; 816 817 case '3': 818 Gbl_WarningLevel = ASL_WARNING3; 819 break; 820 821 default: 822 printf ("Unknown option: -w%s\n", AcpiGbl_Optarg); 823 return (-1); 824 } 825 break; 826 827 828 case 'x': 829 830 AcpiDbgLevel = strtoul (AcpiGbl_Optarg, NULL, 16); 831 break; 832 833 834 default: 835 836 return (-1); 837 } 838 839 return (0); 840 } 841 842 843 /******************************************************************************* 844 * 845 * FUNCTION: AslCommandLine 846 * 847 * PARAMETERS: argc/argv 848 * 849 * RETURN: Last argv index 850 * 851 * DESCRIPTION: Command line processing 852 * 853 ******************************************************************************/ 854 855 static int 856 AslCommandLine ( 857 int argc, 858 char **argv) 859 { 860 int BadCommandLine = 0; 861 862 863 /* Minimum command line contains at least the command and an input file */ 864 865 if (argc < 2) 866 { 867 AslCompilerSignon (ASL_FILE_STDOUT); 868 Usage (); 869 exit (1); 870 } 871 872 /* Process all command line options */ 873 874 BadCommandLine = AslDoOptions (argc, argv, FALSE); 875 876 /* Next parameter must be the input filename */ 877 878 if (!argv[AcpiGbl_Optind] && 879 !Gbl_DisasmFlag && 880 !Gbl_GetAllTables) 881 { 882 printf ("Missing input filename\n"); 883 BadCommandLine = TRUE; 884 } 885 886 if (Gbl_DoSignon) 887 { 888 AslCompilerSignon (ASL_FILE_STDOUT); 889 } 890 891 /* Abort if anything went wrong on the command line */ 892 893 if (BadCommandLine) 894 { 895 printf ("\n"); 896 Usage (); 897 exit (1); 898 } 899 900 return (AcpiGbl_Optind); 901 } 902 903 904 /******************************************************************************* 905 * 906 * FUNCTION: main 907 * 908 * PARAMETERS: Standard argc/argv 909 * 910 * RETURN: Program termination code 911 * 912 * DESCRIPTION: C main routine for the Asl Compiler. Handle command line 913 * options and begin the compile for each file on the command line 914 * 915 ******************************************************************************/ 916 917 int ACPI_SYSTEM_XFACE 918 main ( 919 int argc, 920 char **argv) 921 { 922 ACPI_STATUS Status; 923 int Index; 924 925 926 #ifdef _DEBUG 927 _CrtSetDbgFlag (_CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_LEAK_CHECK_DF | 928 _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG)); 929 #endif 930 931 /* Init and command line */ 932 933 AslInitialize (); 934 Index = AslCommandLine (argc, argv); 935 936 /* Options that have no additional parameters or pathnames */ 937 938 if (Gbl_GetAllTables) 939 { 940 Status = AslDoOneFile (NULL); 941 if (ACPI_FAILURE (Status)) 942 { 943 return (-1); 944 } 945 return (0); 946 } 947 948 /* Process each pathname/filename in the list, with possible wildcards */ 949 950 while (argv[Index]) 951 { 952 Status = AslDoOnePathname (argv[Index]); 953 if (ACPI_FAILURE (Status)) 954 { 955 return (-1); 956 } 957 958 Index++; 959 } 960 961 return (0); 962 } 963 964 965