1 /****************************************************************************** 2 * 3 * Module Name: asloptions - compiler command line processing 4 * 5 *****************************************************************************/ 6 7 /****************************************************************************** 8 * 9 * 1. Copyright Notice 10 * 11 * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. 12 * All rights reserved. 13 * 14 * 2. License 15 * 16 * 2.1. This is your license from Intel Corp. under its intellectual property 17 * rights. You may have additional license terms from the party that provided 18 * you this software, covering your right to use that party's intellectual 19 * property rights. 20 * 21 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 22 * copy of the source code appearing in this file ("Covered Code") an 23 * irrevocable, perpetual, worldwide license under Intel's copyrights in the 24 * base code distributed originally by Intel ("Original Intel Code") to copy, 25 * make derivatives, distribute, use and display any portion of the Covered 26 * Code in any form, with the right to sublicense such rights; and 27 * 28 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 29 * license (with the right to sublicense), under only those claims of Intel 30 * patents that are infringed by the Original Intel Code, to make, use, sell, 31 * offer to sell, and import the Covered Code and derivative works thereof 32 * solely to the minimum extent necessary to exercise the above copyright 33 * license, and in no event shall the patent license extend to any additions 34 * to or modifications of the Original Intel Code. No other license or right 35 * is granted directly or by implication, estoppel or otherwise; 36 * 37 * The above copyright and patent license is granted only if the following 38 * conditions are met: 39 * 40 * 3. Conditions 41 * 42 * 3.1. Redistribution of Source with Rights to Further Distribute Source. 43 * Redistribution of source code of any substantial portion of the Covered 44 * Code or modification with rights to further distribute source must include 45 * the above Copyright Notice, the above License, this list of Conditions, 46 * and the following Disclaimer and Export Compliance provision. In addition, 47 * Licensee must cause all Covered Code to which Licensee contributes to 48 * contain a file documenting the changes Licensee made to create that Covered 49 * Code and the date of any change. Licensee must include in that file the 50 * documentation of any changes made by any predecessor Licensee. Licensee 51 * must include a prominent statement that the modification is derived, 52 * directly or indirectly, from Original Intel Code. 53 * 54 * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 55 * Redistribution of source code of any substantial portion of the Covered 56 * Code or modification without rights to further distribute source must 57 * include the following Disclaimer and Export Compliance provision in the 58 * documentation and/or other materials provided with distribution. In 59 * addition, Licensee may not authorize further sublicense of source of any 60 * portion of the Covered Code, and must include terms to the effect that the 61 * license from Licensee to its licensee is limited to the intellectual 62 * property embodied in the software Licensee provides to its licensee, and 63 * not to intellectual property embodied in modifications its licensee may 64 * make. 65 * 66 * 3.3. Redistribution of Executable. Redistribution in executable form of any 67 * substantial portion of the Covered Code or modification must reproduce the 68 * above Copyright Notice, and the following Disclaimer and Export Compliance 69 * provision in the documentation and/or other materials provided with the 70 * distribution. 71 * 72 * 3.4. Intel retains all right, title, and interest in and to the Original 73 * Intel Code. 74 * 75 * 3.5. Neither the name Intel nor any other trademark owned or controlled by 76 * Intel shall be used in advertising or otherwise to promote the sale, use or 77 * other dealings in products derived from or relating to the Covered Code 78 * without prior written authorization from Intel. 79 * 80 * 4. Disclaimer and Export Compliance 81 * 82 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 83 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 84 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 85 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 86 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 87 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 88 * PARTICULAR PURPOSE. 89 * 90 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 91 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 92 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 93 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 94 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 95 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 96 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 97 * LIMITED REMEDY. 98 * 99 * 4.3. Licensee shall not export, either directly or indirectly, any of this 100 * software or system incorporating such software without first obtaining any 101 * required license or other approval from the U. S. Department of Commerce or 102 * any other agency or department of the United States Government. In the 103 * event Licensee exports any such software from the United States or 104 * re-exports any such software from a foreign destination, Licensee shall 105 * ensure that the distribution and export/re-export of the software is in 106 * compliance with all laws, regulations, orders, or other restrictions of the 107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor 108 * any of its subsidiaries will export/re-export any technical data, process, 109 * software, or service, directly or indirectly, to any country for which the 110 * United States government or any agency thereof requires an export license, 111 * other governmental approval, or letter of assurance, without first obtaining 112 * such license, approval or letter. 113 * 114 ***************************************************************************** 115 * 116 * Alternatively, you may choose to be licensed under the terms of the 117 * following license: 118 * 119 * Redistribution and use in source and binary forms, with or without 120 * modification, are permitted provided that the following conditions 121 * are met: 122 * 1. Redistributions of source code must retain the above copyright 123 * notice, this list of conditions, and the following disclaimer, 124 * without modification. 125 * 2. Redistributions in binary form must reproduce at minimum a disclaimer 126 * substantially similar to the "NO WARRANTY" disclaimer below 127 * ("Disclaimer") and any redistribution must be conditioned upon 128 * including a substantially similar Disclaimer requirement for further 129 * binary redistribution. 130 * 3. Neither the names of the above-listed copyright holders nor the names 131 * of any contributors may be used to endorse or promote products derived 132 * from this software without specific prior written permission. 133 * 134 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 135 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 136 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 137 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 138 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 139 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 140 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 141 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 142 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 143 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 144 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 145 * 146 * Alternatively, you may choose to be licensed under the terms of the 147 * GNU General Public License ("GPL") version 2 as published by the Free 148 * Software Foundation. 149 * 150 *****************************************************************************/ 151 152 #include "aslcompiler.h" 153 #include "acapps.h" 154 #include "acdisasm.h" 155 #include "acglobal.h" 156 157 #define _COMPONENT ACPI_COMPILER 158 ACPI_MODULE_NAME ("asloption") 159 160 161 /* Local prototypes */ 162 163 static int 164 AslDoOptions ( 165 int argc, 166 char **argv, 167 BOOLEAN IsResponseFile); 168 169 static void 170 AslMergeOptionTokens ( 171 char *InBuffer, 172 char *OutBuffer); 173 174 static int 175 AslDoResponseFile ( 176 char *Filename); 177 178 179 #define ASL_TOKEN_SEPARATORS " \t\n" 180 #define ASL_SUPPORTED_OPTIONS "@:a:b|c|d^D:e:f^gh^i|I:l^m:no|p:P^q^r:s|:t|T+G^v^w|x:z" 181 182 183 /******************************************************************************* 184 * 185 * FUNCTION: AslCommandLine 186 * 187 * PARAMETERS: argc/argv 188 * 189 * RETURN: Last argv index 190 * 191 * DESCRIPTION: Command line processing 192 * 193 ******************************************************************************/ 194 195 int 196 AslCommandLine ( 197 int argc, 198 char **argv) 199 { 200 int BadCommandLine = 0; 201 ACPI_STATUS Status; 202 203 204 /* Minimum command line contains at least the command and an input file */ 205 206 if (argc < 2) 207 { 208 Usage (); 209 exit (1); 210 } 211 212 /* Process all command line options */ 213 214 BadCommandLine = AslDoOptions (argc, argv, FALSE); 215 216 if (AslGbl_DoTemplates) 217 { 218 Status = DtCreateTemplates (argv); 219 if (ACPI_FAILURE (Status)) 220 { 221 exit (-1); 222 } 223 exit (0); 224 } 225 226 /* Next parameter must be the input filename */ 227 228 if (!argv[AcpiGbl_Optind] && 229 !AcpiGbl_DisasmFlag) 230 { 231 printf ("Missing input filename\n"); 232 BadCommandLine = TRUE; 233 } 234 235 if (AslGbl_DoSignon) 236 { 237 printf (ACPI_COMMON_SIGNON (ASL_COMPILER_NAME)); 238 if (AslGbl_IgnoreErrors) 239 { 240 printf ("Ignoring all errors, forcing AML file generation\n\n"); 241 } 242 } 243 244 if (BadCommandLine) 245 { 246 printf ("Use -h option for help information\n"); 247 exit (1); 248 } 249 250 return (AcpiGbl_Optind); 251 } 252 253 254 /******************************************************************************* 255 * 256 * FUNCTION: AslDoOptions 257 * 258 * PARAMETERS: argc/argv - Standard argc/argv 259 * IsResponseFile - TRUE if executing a response file. 260 * 261 * RETURN: Status 262 * 263 * DESCRIPTION: Command line option processing 264 * 265 ******************************************************************************/ 266 267 static int 268 AslDoOptions ( 269 int argc, 270 char **argv, 271 BOOLEAN IsResponseFile) 272 { 273 ACPI_STATUS Status; 274 INT32 j; 275 276 277 /* Get the command line options */ 278 279 while ((j = AcpiGetopt (argc, argv, ASL_SUPPORTED_OPTIONS)) != ACPI_OPT_END) switch (j) 280 { 281 case '@': /* Begin a response file */ 282 283 if (IsResponseFile) 284 { 285 printf ("Nested command files are not supported\n"); 286 return (-1); 287 } 288 289 if (AslDoResponseFile (AcpiGbl_Optarg)) 290 { 291 return (-1); 292 } 293 break; 294 295 case 'a': /* Debug options */ 296 297 switch (AcpiGbl_Optarg[0]) 298 { 299 case 'r': 300 301 AslGbl_EnableReferenceTypechecking = TRUE; 302 break; 303 304 default: 305 306 printf ("Unknown option: -a%s\n", AcpiGbl_Optarg); 307 return (-1); 308 } 309 310 break; 311 312 313 case 'b': /* Debug options */ 314 315 switch (AcpiGbl_Optarg[0]) 316 { 317 318 case 'c': 319 320 printf ("Debug ASL to ASL+ conversion\n"); 321 322 AslGbl_DoAslConversion = TRUE; 323 AslGbl_FoldConstants = FALSE; 324 AslGbl_IntegerOptimizationFlag = FALSE; 325 AslGbl_ReferenceOptimizationFlag = FALSE; 326 AslGbl_OptimizeTrivialParseNodes = FALSE; 327 AcpiGbl_CaptureComments = TRUE; 328 AcpiGbl_DoDisassemblerOptimizations = FALSE; 329 AcpiGbl_DebugAslConversion = TRUE; 330 AcpiGbl_DmEmitExternalOpcodes = TRUE; 331 AslGbl_DoExternalsInPlace = TRUE; 332 333 return (0); 334 335 case 'f': 336 337 AslCompilerdebug = 1; /* same as yydebug */ 338 DtParserdebug = 1; 339 PrParserdebug = 1; 340 AslGbl_DebugFlag = TRUE; 341 AslGbl_KeepPreprocessorTempFile = TRUE; 342 break; 343 344 case 'p': /* Prune ASL parse tree */ 345 346 /* Get the required argument */ 347 348 if (AcpiGetoptArgument (argc, argv)) 349 { 350 return (-1); 351 } 352 353 AslGbl_PruneParseTree = TRUE; 354 AslGbl_PruneDepth = (UINT8) strtoul (AcpiGbl_Optarg, NULL, 0); 355 break; 356 357 case 's': 358 359 AslGbl_DebugFlag = TRUE; 360 break; 361 362 case 't': 363 364 /* Get the required argument */ 365 366 if (AcpiGetoptArgument (argc, argv)) 367 { 368 return (-1); 369 } 370 AslGbl_PruneType = (UINT8) strtoul (AcpiGbl_Optarg, NULL, 0); 371 break; 372 373 default: 374 375 printf ("Unknown option: -b%s\n", AcpiGbl_Optarg); 376 return (-1); 377 } 378 379 break; 380 381 case 'c': 382 383 switch (AcpiGbl_Optarg[0]) 384 { 385 386 case 'a': 387 388 printf ("Convert ASL to ASL+ with comments\n"); 389 AslGbl_DoAslConversion = TRUE; 390 AslGbl_FoldConstants = FALSE; 391 AslGbl_IntegerOptimizationFlag = FALSE; 392 AslGbl_ReferenceOptimizationFlag = FALSE; 393 AslGbl_OptimizeTrivialParseNodes = FALSE; 394 AcpiGbl_CaptureComments = TRUE; 395 AcpiGbl_DoDisassemblerOptimizations = FALSE; 396 AcpiGbl_DmEmitExternalOpcodes = TRUE; 397 AslGbl_DoExternalsInPlace = TRUE; 398 399 return (0); 400 401 case 'r': 402 403 AslGbl_NoResourceChecking = TRUE; 404 break; 405 406 default: 407 408 printf ("Unknown option: -c%s\n", AcpiGbl_Optarg); 409 return (-1); 410 } 411 break; 412 413 case 'd': /* Disassembler */ 414 415 switch (AcpiGbl_Optarg[0]) 416 { 417 case '^': 418 419 AslGbl_DoCompile = FALSE; 420 break; 421 422 case 'a': 423 424 AslGbl_DoCompile = FALSE; 425 AslGbl_DisassembleAll = TRUE; 426 break; 427 428 case 'b': /* Do not convert buffers to resource descriptors */ 429 430 AcpiGbl_NoResourceDisassembly = TRUE; 431 break; 432 433 case 'c': 434 435 break; 436 437 case 'f': 438 439 AcpiGbl_ForceAmlDisassembly = TRUE; 440 break; 441 442 case 'l': /* Use legacy ASL code (not ASL+) for disassembly */ 443 444 AslGbl_DoCompile = FALSE; 445 AcpiGbl_CstyleDisassembly = FALSE; 446 break; 447 448 case 's': /* Specify table signature (Only supported for CDAT table) */ 449 450 /* Get the required argument */ 451 452 if (AcpiGetoptArgument (argc, argv)) 453 { 454 return (-1); 455 } 456 457 /* Check for exact string "CDAT" (upper or lower case) */ 458 459 AcpiGbl_CDAT = ACPI_CAST_PTR (char, &AcpiGbl_Optarg); 460 if (AcpiUtStricmp (AcpiGbl_Optarg, ACPI_SIG_CDAT)) 461 { 462 printf ("\nUnknown table signature: %s\n", AcpiGbl_Optarg); 463 return (-1); 464 } 465 466 AcpiGbl_CDAT = malloc (5); 467 AcpiUtSafeStrncpy ((char *) AcpiGbl_CDAT, ACPI_SIG_CDAT, 5); 468 break; 469 470 default: 471 472 printf ("Unknown option: -d%s\n", AcpiGbl_Optarg); 473 return (-1); 474 } 475 476 AcpiGbl_DisasmFlag = TRUE; 477 break; 478 479 case 'D': /* Define a symbol */ 480 481 PrAddDefine (AcpiGbl_Optarg, NULL, TRUE); 482 break; 483 484 case 'e': /* External files for disassembler */ 485 486 /* Get entire list of external files */ 487 488 AcpiGbl_Optind--; 489 argv[AcpiGbl_Optind] = AcpiGbl_Optarg; 490 491 while (argv[AcpiGbl_Optind] && 492 (argv[AcpiGbl_Optind][0] != '-')) 493 { 494 Status = AcpiDmAddToExternalFileList (argv[AcpiGbl_Optind]); 495 if (ACPI_FAILURE (Status)) 496 { 497 printf ("Could not add %s to external list\n", 498 argv[AcpiGbl_Optind]); 499 return (-1); 500 } 501 502 AcpiGbl_Optind++; 503 } 504 break; 505 506 case 'f': 507 508 switch (AcpiGbl_Optarg[0]) 509 { 510 case '^': /* Ignore errors and force creation of aml file */ 511 512 AslGbl_IgnoreErrors = TRUE; 513 break; 514 515 case 'e': /* Disassembler: Get external declaration file */ 516 517 if (AcpiGetoptArgument (argc, argv)) 518 { 519 return (-1); 520 } 521 522 AslGbl_ExternalRefFilename = AcpiGbl_Optarg; 523 break; 524 525 default: 526 527 printf ("Unknown option: -f%s\n", AcpiGbl_Optarg); 528 return (-1); 529 } 530 break; 531 532 case 'G': 533 534 AslGbl_CompileGeneric = TRUE; 535 break; 536 537 case 'g': /* Get all ACPI tables */ 538 539 printf ("-g option is deprecated, use acpidump utility instead\n"); 540 exit (1); 541 542 case 'h': 543 544 switch (AcpiGbl_Optarg[0]) 545 { 546 case '^': 547 548 Usage (); 549 exit (0); 550 551 case 'c': 552 553 UtDisplayConstantOpcodes (); 554 exit (0); 555 556 case 'd': 557 558 AslDisassemblyHelp (); 559 exit (0); 560 561 case 'f': 562 563 AslFilenameHelp (); 564 exit (0); 565 566 case 'r': 567 568 /* reserved names */ 569 570 ApDisplayReservedNames (); 571 exit (0); 572 573 case 't': 574 575 UtDisplaySupportedTables (); 576 exit (0); 577 578 default: 579 580 printf ("Unknown option: -h%s\n", AcpiGbl_Optarg); 581 return (-1); 582 } 583 584 case 'I': /* Add an include file search directory */ 585 586 FlAddIncludeDirectory (AcpiGbl_Optarg); 587 break; 588 589 case 'i': /* Output AML as an include file */ 590 591 switch (AcpiGbl_Optarg[0]) 592 { 593 case 'a': 594 595 /* Produce assembly code include file */ 596 597 AslGbl_AsmIncludeOutputFlag = TRUE; 598 break; 599 600 case 'c': 601 602 /* Produce C include file */ 603 604 AslGbl_C_IncludeOutputFlag = TRUE; 605 break; 606 607 case 'n': 608 609 /* Compiler/Disassembler: Ignore the NOOP operator */ 610 611 AcpiGbl_IgnoreNoopOperator = TRUE; 612 break; 613 614 default: 615 616 printf ("Unknown option: -i%s\n", AcpiGbl_Optarg); 617 return (-1); 618 } 619 break; 620 621 case 'l': /* Listing files */ 622 623 switch (AcpiGbl_Optarg[0]) 624 { 625 case '^': 626 627 /* Produce listing file (Mixed source/aml) */ 628 629 AslGbl_ListingFlag = TRUE; 630 AcpiGbl_DmOpt_Listing = TRUE; 631 break; 632 633 case 'd': 634 635 /* Disable deterministic output, enabling timestamp */ 636 637 AslGbl_Deterministic = FALSE; 638 break; 639 640 case 'i': 641 642 /* Produce preprocessor output file */ 643 644 AslGbl_PreprocessorOutputFlag = TRUE; 645 break; 646 647 case 'm': 648 649 /* Produce hardware map summary file */ 650 651 AslGbl_MapfileFlag = TRUE; 652 break; 653 654 case 'n': 655 656 /* Produce namespace file */ 657 658 AslGbl_NsOutputFlag = TRUE; 659 break; 660 661 case 's': 662 663 /* Produce combined source file */ 664 665 AslGbl_SourceOutputFlag = TRUE; 666 break; 667 668 case 'x': 669 670 /* Produce cross-reference file */ 671 672 AslGbl_CrossReferenceOutput = TRUE; 673 break; 674 675 default: 676 677 printf ("Unknown option: -l%s\n", AcpiGbl_Optarg); 678 return (-1); 679 } 680 break; 681 682 case 'm': /* Set line buffer size */ 683 684 AslGbl_LineBufferSize = (UINT32) strtoul (AcpiGbl_Optarg, NULL, 0) * 1024; 685 if (AslGbl_LineBufferSize < ASL_DEFAULT_LINE_BUFFER_SIZE) 686 { 687 AslGbl_LineBufferSize = ASL_DEFAULT_LINE_BUFFER_SIZE; 688 } 689 printf ("Line Buffer Size: %u\n", AslGbl_LineBufferSize); 690 break; 691 692 case 'n': /* Parse only */ 693 694 AslGbl_ParseOnlyFlag = TRUE; 695 break; 696 697 case 'o': /* Control compiler AML optimizations */ 698 699 switch (AcpiGbl_Optarg[0]) 700 { 701 case 'a': 702 703 /* Disable all optimizations */ 704 705 AslGbl_FoldConstants = FALSE; 706 AslGbl_IntegerOptimizationFlag = FALSE; 707 AslGbl_ReferenceOptimizationFlag = FALSE; 708 AslGbl_OptimizeTrivialParseNodes = FALSE; 709 710 break; 711 712 case 'c': 713 714 /* Display compile time(s) */ 715 716 AslGbl_CompileTimesFlag = TRUE; 717 break; 718 719 case 'd': 720 721 /* Disable disassembler code optimizations */ 722 723 AcpiGbl_DoDisassemblerOptimizations = FALSE; 724 break; 725 726 case 'e': 727 728 /* Disassembler: Emit embedded external operators */ 729 730 AcpiGbl_DmEmitExternalOpcodes = TRUE; 731 break; 732 733 case 'E': 734 735 /* 736 * iASL: keep External opcodes in place. 737 * No affect if Gbl_DoExternals is false. 738 */ 739 740 AslGbl_DoExternalsInPlace = TRUE; 741 break; 742 743 case 'f': 744 745 /* Disable folding on "normal" expressions */ 746 747 AslGbl_FoldConstants = FALSE; 748 break; 749 750 case 'i': 751 752 /* Disable integer optimization to constants */ 753 754 AslGbl_IntegerOptimizationFlag = FALSE; 755 break; 756 757 case 'n': 758 759 /* Disable named reference optimization */ 760 761 AslGbl_ReferenceOptimizationFlag = FALSE; 762 break; 763 764 case 't': 765 766 /* Disable heavy typechecking */ 767 768 AslGbl_DoTypechecking = FALSE; 769 break; 770 771 default: 772 773 printf ("Unknown option: -c%s\n", AcpiGbl_Optarg); 774 return (-1); 775 } 776 break; 777 778 case 'P': /* Preprocessor options */ 779 780 switch (AcpiGbl_Optarg[0]) 781 { 782 case '^': /* Proprocess only, emit (.i) file */ 783 784 AslGbl_PreprocessOnly = TRUE; 785 AslGbl_PreprocessorOutputFlag = TRUE; 786 break; 787 788 case 'n': /* Disable preprocessor */ 789 790 AslGbl_PreprocessFlag = FALSE; 791 break; 792 793 default: 794 795 printf ("Unknown option: -P%s\n", AcpiGbl_Optarg); 796 return (-1); 797 } 798 break; 799 800 case 'p': /* Override default AML output filename */ 801 802 AslGbl_OutputFilenamePrefix = AcpiGbl_Optarg; 803 UtConvertBackslashes (AslGbl_OutputFilenamePrefix); 804 AslGbl_UseDefaultAmlFilename = FALSE; 805 break; 806 807 case 'q': /* ASL/ASl+ converter: compile only and leave badaml. */ 808 809 printf ("Convert ASL to ASL+ with comments\n"); 810 AslGbl_FoldConstants = FALSE; 811 AslGbl_IntegerOptimizationFlag = FALSE; 812 AslGbl_ReferenceOptimizationFlag = FALSE; 813 AslGbl_OptimizeTrivialParseNodes = FALSE; 814 AslGbl_DoExternalsInPlace = TRUE; 815 AcpiGbl_CaptureComments = TRUE; 816 return (0); 817 818 case 'r': /* Override revision found in table header */ 819 820 AslGbl_RevisionOverride = (UINT8) strtoul (AcpiGbl_Optarg, NULL, 0); 821 break; 822 823 case 's': /* Create AML in a source code file */ 824 825 switch (AcpiGbl_Optarg[0]) 826 { 827 case 'a': 828 829 /* Produce assembly code output file */ 830 831 AslGbl_AsmOutputFlag = TRUE; 832 break; 833 834 case 'c': 835 836 /* Produce C hex output file */ 837 838 AslGbl_C_OutputFlag = TRUE; 839 break; 840 841 case 'o': 842 843 /* Produce AML offset table in C */ 844 845 AslGbl_C_OffsetTableFlag = TRUE; 846 break; 847 848 default: 849 850 printf ("Unknown option: -s%s\n", AcpiGbl_Optarg); 851 return (-1); 852 } 853 break; 854 855 case 't': /* Produce hex table output file */ 856 857 switch (AcpiGbl_Optarg[0]) 858 { 859 case 'a': 860 861 AslGbl_HexOutputFlag = HEX_OUTPUT_ASM; 862 break; 863 864 case 'c': 865 866 AslGbl_HexOutputFlag = HEX_OUTPUT_C; 867 break; 868 869 case 'p': /* data table flex/bison prototype */ 870 871 AslGbl_DtLexBisonPrototype = TRUE; 872 break; 873 874 case 's': 875 876 AslGbl_HexOutputFlag = HEX_OUTPUT_ASL; 877 break; 878 879 default: 880 881 printf ("Unknown option: -t%s\n", AcpiGbl_Optarg); 882 return (-1); 883 } 884 break; 885 886 case 'T': /* Create a ACPI table template file */ 887 888 AslGbl_DoTemplates = TRUE; 889 break; 890 891 case 'v': /* Version and verbosity settings */ 892 893 switch (AcpiGbl_Optarg[0]) 894 { 895 case '^': 896 897 printf (ACPI_COMMON_SIGNON (ASL_COMPILER_NAME)); 898 exit (0); 899 900 case 'a': 901 902 /* Disable all error/warning/remark messages */ 903 904 AslGbl_NoErrors = TRUE; 905 break; 906 907 case 'd': 908 909 printf (ACPI_COMMON_SIGNON (ASL_COMPILER_NAME)); 910 printf (ACPI_COMMON_BUILD_TIME); 911 exit (0); 912 913 case 'e': 914 915 /* Disable all warning/remark messages (errors only) */ 916 917 AslGbl_DisplayRemarks = FALSE; 918 AslGbl_DisplayWarnings = FALSE; 919 break; 920 921 case 'i': 922 /* 923 * Support for integrated development environment(s). 924 * 925 * 1) No compiler signon 926 * 2) Send stderr messages to stdout 927 * 3) Less verbose error messages (single line only for each) 928 * 4) Error/warning messages are formatted appropriately to 929 * be recognized by MS Visual Studio 930 */ 931 AslGbl_VerboseErrors = FALSE; 932 AslGbl_DoSignon = FALSE; 933 break; 934 935 case 'o': 936 937 AslGbl_DisplayOptimizations = TRUE; 938 break; 939 940 case 'r': 941 942 AslGbl_DisplayRemarks = FALSE; 943 break; 944 945 case 's': 946 947 AslGbl_DoSignon = FALSE; 948 break; 949 950 case 't': 951 952 AslGbl_VerboseTemplates = TRUE; 953 break; 954 955 case 'w': 956 957 /* Get the required argument */ 958 959 if (AcpiGetoptArgument (argc, argv)) 960 { 961 return (-1); 962 } 963 964 Status = AslDisableException (AcpiGbl_Optarg); 965 if (ACPI_FAILURE (Status)) 966 { 967 return (-1); 968 } 969 break; 970 971 case 'x': 972 973 /* Get the required argument */ 974 975 if (AcpiGetoptArgument (argc, argv)) 976 { 977 return (-1); 978 } 979 980 Status = AslLogExpectedException (AcpiGbl_Optarg); 981 if (ACPI_FAILURE (Status)) 982 { 983 return (-1); 984 } 985 break; 986 987 default: 988 989 printf ("Unknown option: -v%s\n", AcpiGbl_Optarg); 990 return (-1); 991 } 992 break; 993 994 case 'w': /* Set warning levels */ 995 996 switch (AcpiGbl_Optarg[0]) 997 { 998 case '1': 999 1000 AslGbl_WarningLevel = ASL_WARNING; 1001 break; 1002 1003 case '2': 1004 1005 AslGbl_WarningLevel = ASL_WARNING2; 1006 break; 1007 1008 case '3': 1009 1010 AslGbl_WarningLevel = ASL_WARNING3; 1011 break; 1012 1013 case 'e': 1014 1015 AslGbl_WarningsAsErrors = TRUE; 1016 break; 1017 1018 case 'w': 1019 1020 /* Get the required argument */ 1021 1022 if (AcpiGetoptArgument (argc, argv)) 1023 { 1024 return (-1); 1025 } 1026 1027 Status = AslElevateException (AcpiGbl_Optarg); 1028 if (ACPI_FAILURE (Status)) 1029 { 1030 return (-1); 1031 } 1032 break; 1033 1034 1035 default: 1036 1037 printf ("Unknown option: -w%s\n", AcpiGbl_Optarg); 1038 return (-1); 1039 } 1040 break; 1041 1042 case 'x': /* Set debug print output level */ 1043 1044 AcpiDbgLevel = strtoul (AcpiGbl_Optarg, NULL, 16); 1045 break; 1046 1047 case 'z': 1048 1049 AslGbl_UseOriginalCompilerId = TRUE; 1050 break; 1051 1052 default: 1053 1054 return (-1); 1055 } 1056 1057 return (0); 1058 } 1059 1060 1061 /******************************************************************************* 1062 * 1063 * FUNCTION: AslMergeOptionTokens 1064 * 1065 * PARAMETERS: InBuffer - Input containing an option string 1066 * OutBuffer - Merged output buffer 1067 * 1068 * RETURN: None 1069 * 1070 * DESCRIPTION: Remove all whitespace from an option string. 1071 * 1072 ******************************************************************************/ 1073 1074 static void 1075 AslMergeOptionTokens ( 1076 char *InBuffer, 1077 char *OutBuffer) 1078 { 1079 char *Token; 1080 1081 1082 *OutBuffer = 0; 1083 1084 Token = strtok (InBuffer, ASL_TOKEN_SEPARATORS); 1085 while (Token) 1086 { 1087 strcat (OutBuffer, Token); 1088 Token = strtok (NULL, ASL_TOKEN_SEPARATORS); 1089 } 1090 } 1091 1092 1093 /******************************************************************************* 1094 * 1095 * FUNCTION: AslDoResponseFile 1096 * 1097 * PARAMETERS: Filename - Name of the response file 1098 * 1099 * RETURN: Status 1100 * 1101 * DESCRIPTION: Open a response file and process all options within. 1102 * 1103 ******************************************************************************/ 1104 1105 static int 1106 AslDoResponseFile ( 1107 char *Filename) 1108 { 1109 char *argv = AslGbl_StringBuffer2; 1110 FILE *ResponseFile; 1111 int OptStatus = 0; 1112 int Opterr; 1113 int Optind; 1114 1115 1116 ResponseFile = fopen (Filename, "r"); 1117 if (!ResponseFile) 1118 { 1119 printf ("Could not open command file %s, %s\n", 1120 Filename, strerror (errno)); 1121 return (-1); 1122 } 1123 1124 /* Must save the current GetOpt globals */ 1125 1126 Opterr = AcpiGbl_Opterr; 1127 Optind = AcpiGbl_Optind; 1128 1129 /* 1130 * Process all lines in the response file. There must be one complete 1131 * option per line 1132 */ 1133 while (fgets (AslGbl_StringBuffer, ASL_STRING_BUFFER_SIZE, ResponseFile)) 1134 { 1135 /* Compress all tokens, allowing us to use a single argv entry */ 1136 1137 AslMergeOptionTokens (AslGbl_StringBuffer, AslGbl_StringBuffer2); 1138 1139 /* Process the option */ 1140 1141 AcpiGbl_Opterr = 0; 1142 AcpiGbl_Optind = 0; 1143 1144 OptStatus = AslDoOptions (1, &argv, TRUE); 1145 if (OptStatus) 1146 { 1147 printf ("Invalid option in command file %s: %s\n", 1148 Filename, AslGbl_StringBuffer); 1149 break; 1150 } 1151 } 1152 1153 /* Restore the GetOpt globals */ 1154 1155 AcpiGbl_Opterr = Opterr; 1156 AcpiGbl_Optind = Optind; 1157 1158 fclose (ResponseFile); 1159 return (OptStatus); 1160 } 1161