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