asloptions.c revision 250838
1315633Smm/****************************************************************************** 2315633Smm * 3315633Smm * Module Name: asloptions - compiler command line processing 4316083Smm * 5315633Smm *****************************************************************************/ 6315633Smm 7315633Smm/* 8315633Smm * Copyright (C) 2000 - 2013, Intel Corp. 9315633Smm * All rights reserved. 10315633Smm * 11315633Smm * Redistribution and use in source and binary forms, with or without 12315633Smm * modification, are permitted provided that the following conditions 13315633Smm * are met: 14315633Smm * 1. Redistributions of source code must retain the above copyright 15315633Smm * notice, this list of conditions, and the following disclaimer, 16315633Smm * without modification. 17315633Smm * 2. Redistributions in binary form must reproduce at minimum a disclaimer 18315633Smm * substantially similar to the "NO WARRANTY" disclaimer below 19315633Smm * ("Disclaimer") and any redistribution must be conditioned upon 20315633Smm * including a substantially similar Disclaimer requirement for further 21315633Smm * binary redistribution. 22315633Smm * 3. Neither the names of the above-listed copyright holders nor the names 23315633Smm * of any contributors may be used to endorse or promote products derived 24315633Smm * from this software without specific prior written permission. 25315633Smm * 26315633Smm * Alternatively, this software may be distributed under the terms of the 27315633Smm * GNU General Public License ("GPL") version 2 as published by the Free 28315633Smm * Software Foundation. 29315633Smm * 30316095Smm * NO WARRANTY 31316095Smm * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 32315633Smm * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 33315633Smm * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 34315633Smm * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 35315633Smm * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 36315633Smm * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 37315633Smm * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 38315633Smm * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 39315633Smm * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 40315633Smm * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 41315633Smm * POSSIBILITY OF SUCH DAMAGES. 42315633Smm */ 43315633Smm 44315633Smm#include <contrib/dev/acpica/compiler/aslcompiler.h> 45315633Smm#include <contrib/dev/acpica/include/acapps.h> 46315633Smm#include <contrib/dev/acpica/include/acdisasm.h> 47315633Smm 48315633Smm#define _COMPONENT ACPI_COMPILER 49316083Smm ACPI_MODULE_NAME ("asloption") 50315633Smm 51316083Smm 52316083Smm/* Local prototypes */ 53316083Smm 54316083Smmstatic int 55316083SmmAslDoOptions ( 56316083Smm int argc, 57316083Smm char **argv, 58316083Smm BOOLEAN IsResponseFile); 59316083Smm 60316083Smmstatic void 61316083SmmAslMergeOptionTokens ( 62316083Smm char *InBuffer, 63316083Smm char *OutBuffer); 64316083Smm 65316083Smmstatic int 66316083SmmAslDoResponseFile ( 67316083Smm char *Filename); 68316083Smm 69316083Smm 70316083Smm#define ASL_TOKEN_SEPARATORS " \t\n" 71316083Smm#define ASL_SUPPORTED_OPTIONS "@:b|c|d^D:e:fgh^i|I:l^m:no|p:P^r:s|t|T:G^v^w|x:z" 72316083Smm 73316083Smm 74316083Smm/******************************************************************************* 75316083Smm * 76316083Smm * FUNCTION: AslCommandLine 77316083Smm * 78316083Smm * PARAMETERS: argc/argv 79316083Smm * 80316083Smm * RETURN: Last argv index 81316083Smm * 82316083Smm * DESCRIPTION: Command line processing 83316083Smm * 84316083Smm ******************************************************************************/ 85316083Smm 86316083Smmint 87316083SmmAslCommandLine ( 88316083Smm int argc, 89316083Smm char **argv) 90316083Smm{ 91316083Smm int BadCommandLine = 0; 92316083Smm ACPI_STATUS Status; 93316083Smm 94316083Smm 95316083Smm /* Minimum command line contains at least the command and an input file */ 96328828Smm 97316083Smm if (argc < 2) 98328828Smm { 99316083Smm printf (ACPI_COMMON_SIGNON (ASL_COMPILER_NAME)); 100316083Smm Usage (); 101316083Smm exit (1); 102316083Smm } 103316083Smm 104316083Smm /* Process all command line options */ 105315633Smm 106315633Smm BadCommandLine = AslDoOptions (argc, argv, FALSE); 107315633Smm 108315633Smm if (Gbl_DoTemplates) 109315633Smm { 110315633Smm Status = DtCreateTemplates (Gbl_TemplateSignature); 111315633Smm if (ACPI_FAILURE (Status)) 112316083Smm { 113315633Smm exit (-1); 114315633Smm } 115315633Smm exit (1); 116315633Smm } 117315633Smm 118315633Smm /* Next parameter must be the input filename */ 119315633Smm 120315633Smm if (!argv[AcpiGbl_Optind] && 121315633Smm !Gbl_DisasmFlag && 122315633Smm !Gbl_GetAllTables) 123315633Smm { 124315633Smm printf ("Missing input filename\n"); 125315633Smm BadCommandLine = TRUE; 126315633Smm } 127315633Smm 128315633Smm if (Gbl_DoSignon) 129315633Smm { 130315633Smm printf (ACPI_COMMON_SIGNON (ASL_COMPILER_NAME)); 131315633Smm if (Gbl_IgnoreErrors) 132315633Smm { 133315633Smm printf ("Ignoring all errors, forcing AML file generation\n\n"); 134315633Smm } 135315633Smm } 136315633Smm 137315633Smm if (BadCommandLine) 138315633Smm { 139315633Smm printf ("\n"); 140315633Smm Usage (); 141315633Smm exit (1); 142315633Smm } 143315633Smm 144315633Smm return (AcpiGbl_Optind); 145315633Smm} 146315633Smm 147315633Smm 148315633Smm/******************************************************************************* 149315633Smm * 150315633Smm * FUNCTION: AslDoOptions 151315633Smm * 152315633Smm * PARAMETERS: argc/argv - Standard argc/argv 153315633Smm * IsResponseFile - TRUE if executing a response file. 154315633Smm * 155315633Smm * RETURN: Status 156315633Smm * 157315633Smm * DESCRIPTION: Command line option processing 158315633Smm * 159315633Smm ******************************************************************************/ 160315633Smm 161315633Smmstatic int 162315633SmmAslDoOptions ( 163315633Smm int argc, 164315633Smm char **argv, 165315633Smm BOOLEAN IsResponseFile) 166315633Smm{ 167315633Smm ACPI_STATUS Status; 168315633Smm UINT32 j; 169315633Smm 170315633Smm 171315633Smm /* Get the command line options */ 172315633Smm 173315633Smm while ((j = AcpiGetopt (argc, argv, ASL_SUPPORTED_OPTIONS)) != EOF) switch (j) 174315633Smm { 175315633Smm case '@': /* Begin a response file */ 176315633Smm 177315633Smm if (IsResponseFile) 178315633Smm { 179315633Smm printf ("Nested command files are not supported\n"); 180315633Smm return (-1); 181315633Smm } 182315633Smm 183315633Smm if (AslDoResponseFile (AcpiGbl_Optarg)) 184315633Smm { 185315633Smm return (-1); 186315633Smm } 187315633Smm break; 188315633Smm 189315633Smm case 'b': /* Debug output options */ 190315633Smm 191315633Smm switch (AcpiGbl_Optarg[0]) 192315633Smm { 193315633Smm case 'f': 194315633Smm 195315633Smm AslCompilerdebug = 1; /* same as yydebug */ 196315633Smm DtParserdebug = 1; 197315633Smm PrParserdebug = 1; 198315633Smm break; 199315633Smm 200315633Smm case 't': 201315633Smm 202315633Smm break; 203315633Smm 204315633Smm default: 205315633Smm 206315633Smm printf ("Unknown option: -b%s\n", AcpiGbl_Optarg); 207315633Smm return (-1); 208315633Smm } 209315633Smm 210315633Smm /* Produce debug output file */ 211315633Smm 212315633Smm Gbl_DebugFlag = TRUE; 213315633Smm break; 214315633Smm 215315633Smm case 'c': 216315633Smm 217315633Smm switch (AcpiGbl_Optarg[0]) 218315633Smm { 219315633Smm case 'r': 220315633Smm 221315633Smm Gbl_NoResourceChecking = TRUE; 222315633Smm break; 223315633Smm 224315633Smm default: 225315633Smm 226315633Smm printf ("Unknown option: -c%s\n", AcpiGbl_Optarg); 227315633Smm return (-1); 228315633Smm } 229315633Smm break; 230315633Smm 231315633Smm case 'd': /* Disassembler */ 232315633Smm 233315633Smm switch (AcpiGbl_Optarg[0]) 234315633Smm { 235315633Smm case '^': 236315633Smm 237315633Smm Gbl_DoCompile = FALSE; 238315633Smm break; 239315633Smm 240315633Smm case 'a': 241315633Smm 242315633Smm Gbl_DoCompile = FALSE; 243315633Smm Gbl_DisassembleAll = TRUE; 244315633Smm break; 245315633Smm 246315633Smm case 'b': /* Do not convert buffers to resource descriptors */ 247315633Smm 248315633Smm AcpiGbl_NoResourceDisassembly = TRUE; 249315633Smm break; 250315633Smm 251315633Smm case 'c': 252315633Smm 253315633Smm break; 254315633Smm 255315633Smm default: 256315633Smm 257315633Smm printf ("Unknown option: -d%s\n", AcpiGbl_Optarg); 258315633Smm return (-1); 259315633Smm } 260315633Smm 261315633Smm Gbl_DisasmFlag = TRUE; 262315633Smm break; 263315633Smm 264315633Smm case 'D': /* Define a symbol */ 265315633Smm 266315633Smm PrAddDefine (AcpiGbl_Optarg, NULL, TRUE); 267315633Smm break; 268315633Smm 269315633Smm case 'e': /* External files for disassembler */ 270315633Smm 271315633Smm Status = AcpiDmAddToExternalFileList (AcpiGbl_Optarg); 272315633Smm if (ACPI_FAILURE (Status)) 273315633Smm { 274315633Smm printf ("Could not add %s to external list\n", AcpiGbl_Optarg); 275315633Smm return (-1); 276315633Smm } 277315633Smm break; 278315633Smm 279315633Smm case 'f': /* Ignore errors and force creation of aml file */ 280315633Smm 281315633Smm Gbl_IgnoreErrors = TRUE; 282315633Smm break; 283315633Smm 284315633Smm case 'G': 285315633Smm 286315633Smm Gbl_CompileGeneric = TRUE; 287315633Smm break; 288315633Smm 289315633Smm case 'g': /* Get all ACPI tables */ 290315633Smm 291315633Smm Gbl_GetAllTables = TRUE; 292315633Smm Gbl_DoCompile = FALSE; 293315633Smm break; 294315633Smm 295315633Smm case 'h': 296315633Smm 297315633Smm switch (AcpiGbl_Optarg[0]) 298315633Smm { 299315633Smm case '^': 300315633Smm 301315633Smm Usage (); 302315633Smm exit (0); 303315633Smm 304315633Smm case 'c': 305315633Smm 306315633Smm UtDisplayConstantOpcodes (); 307315633Smm exit (0); 308315633Smm 309315633Smm case 'f': 310315633Smm 311315633Smm AslFilenameHelp (); 312315633Smm exit (0); 313315633Smm 314315633Smm case 'r': 315315633Smm 316315633Smm /* reserved names */ 317315633Smm 318315633Smm ApDisplayReservedNames (); 319315633Smm exit (0); 320316083Smm 321316083Smm case 't': 322316083Smm 323316083Smm UtDisplaySupportedTables (); 324316083Smm exit (0); 325316083Smm 326316083Smm default: 327316083Smm 328316083Smm printf ("Unknown option: -h%s\n", AcpiGbl_Optarg); 329316083Smm return (-1); 330316083Smm } 331316083Smm 332316083Smm case 'I': /* Add an include file search directory */ 333316083Smm 334316083Smm FlAddIncludeDirectory (AcpiGbl_Optarg); 335316083Smm break; 336316083Smm 337316083Smm case 'i': /* Output AML as an include file */ 338316083Smm 339316083Smm switch (AcpiGbl_Optarg[0]) 340316083Smm { 341316083Smm case 'a': 342316083Smm 343316083Smm /* Produce assembly code include file */ 344316083Smm 345316083Smm Gbl_AsmIncludeOutputFlag = TRUE; 346316083Smm break; 347316083Smm 348316083Smm case 'c': 349316083Smm 350316083Smm /* Produce C include file */ 351316083Smm 352316083Smm Gbl_C_IncludeOutputFlag = TRUE; 353316083Smm break; 354316083Smm 355316083Smm case 'n': 356316083Smm 357316083Smm /* Compiler/Disassembler: Ignore the NOOP operator */ 358316083Smm 359316083Smm AcpiGbl_IgnoreNoopOperator = TRUE; 360316083Smm break; 361316083Smm 362316083Smm default: 363316083Smm 364316083Smm printf ("Unknown option: -i%s\n", AcpiGbl_Optarg); 365316083Smm return (-1); 366316083Smm } 367316083Smm break; 368316083Smm 369316083Smm case 'l': /* Listing files */ 370316083Smm 371316083Smm switch (AcpiGbl_Optarg[0]) 372316083Smm { 373316083Smm case '^': 374316083Smm 375316083Smm /* Produce listing file (Mixed source/aml) */ 376316083Smm 377316083Smm Gbl_ListingFlag = TRUE; 378316083Smm break; 379316083Smm 380316083Smm case 'i': 381316083Smm 382316083Smm /* Produce preprocessor output file */ 383316083Smm 384316083Smm Gbl_PreprocessorOutputFlag = TRUE; 385316083Smm break; 386316083Smm 387316083Smm case 'n': 388316083Smm 389316083Smm /* Produce namespace file */ 390316083Smm 391316083Smm Gbl_NsOutputFlag = TRUE; 392316083Smm break; 393316083Smm 394316083Smm case 's': 395316083Smm 396316083Smm /* Produce combined source file */ 397316083Smm 398316083Smm Gbl_SourceOutputFlag = TRUE; 399316083Smm break; 400316083Smm 401316083Smm default: 402316083Smm 403316083Smm printf ("Unknown option: -l%s\n", AcpiGbl_Optarg); 404316083Smm return (-1); 405316083Smm } 406316083Smm break; 407316083Smm 408316083Smm case 'm': /* Set line buffer size */ 409316083Smm 410316083Smm Gbl_LineBufferSize = (UINT32) strtoul (AcpiGbl_Optarg, NULL, 0) * 1024; 411316083Smm if (Gbl_LineBufferSize < ASL_DEFAULT_LINE_BUFFER_SIZE) 412316083Smm { 413316083Smm Gbl_LineBufferSize = ASL_DEFAULT_LINE_BUFFER_SIZE; 414316083Smm } 415316083Smm printf ("Line Buffer Size: %u\n", Gbl_LineBufferSize); 416316083Smm break; 417316083Smm 418316083Smm case 'n': /* Parse only */ 419316083Smm 420316083Smm Gbl_ParseOnlyFlag = TRUE; 421316083Smm break; 422316083Smm 423316083Smm case 'o': /* Control compiler AML optimizations */ 424316083Smm 425316083Smm switch (AcpiGbl_Optarg[0]) 426316083Smm { 427316083Smm case 'a': 428316083Smm 429316083Smm /* Disable all optimizations */ 430316083Smm 431316083Smm Gbl_FoldConstants = FALSE; 432316083Smm Gbl_IntegerOptimizationFlag = FALSE; 433316083Smm Gbl_ReferenceOptimizationFlag = FALSE; 434316083Smm break; 435316083Smm 436316083Smm case 'f': 437316083Smm 438316083Smm /* Disable folding on "normal" expressions */ 439316083Smm 440316083Smm Gbl_FoldConstants = FALSE; 441316083Smm break; 442316083Smm 443316083Smm case 'i': 444316083Smm 445316083Smm /* Disable integer optimization to constants */ 446316083Smm 447316083Smm Gbl_IntegerOptimizationFlag = FALSE; 448316083Smm break; 449316083Smm 450316083Smm case 'n': 451316083Smm 452316083Smm /* Disable named reference optimization */ 453316083Smm 454316083Smm Gbl_ReferenceOptimizationFlag = FALSE; 455316083Smm break; 456316083Smm 457316083Smm case 't': 458316083Smm 459316083Smm /* Display compile time(s) */ 460316083Smm 461316083Smm Gbl_CompileTimesFlag = TRUE; 462316083Smm break; 463316083Smm 464316083Smm default: 465316083Smm 466316083Smm printf ("Unknown option: -c%s\n", AcpiGbl_Optarg); 467316083Smm return (-1); 468316083Smm } 469316083Smm break; 470316083Smm 471316083Smm case 'P': /* Preprocessor options */ 472316083Smm 473316083Smm switch (AcpiGbl_Optarg[0]) 474316083Smm { 475316083Smm case '^': /* Proprocess only, emit (.i) file */ 476316083Smm 477316083Smm Gbl_PreprocessOnly = TRUE; 478316083Smm Gbl_PreprocessorOutputFlag = TRUE; 479316083Smm break; 480316083Smm 481316083Smm case 'n': /* Disable preprocessor */ 482316083Smm 483316083Smm Gbl_PreprocessFlag = FALSE; 484316083Smm break; 485316083Smm 486316083Smm default: 487316083Smm 488316083Smm printf ("Unknown option: -P%s\n", AcpiGbl_Optarg); 489316083Smm return (-1); 490316083Smm } 491316083Smm break; 492316083Smm 493316083Smm case 'p': /* Override default AML output filename */ 494316083Smm 495316083Smm Gbl_OutputFilenamePrefix = AcpiGbl_Optarg; 496316083Smm Gbl_UseDefaultAmlFilename = FALSE; 497316083Smm break; 498316083Smm 499316083Smm case 'r': /* Override revision found in table header */ 500316083Smm 501316083Smm Gbl_RevisionOverride = (UINT8) strtoul (AcpiGbl_Optarg, NULL, 0); 502316083Smm break; 503316083Smm 504316083Smm case 's': /* Create AML in a source code file */ 505316083Smm 506316083Smm switch (AcpiGbl_Optarg[0]) 507316083Smm { 508316083Smm case 'a': 509316083Smm 510316083Smm /* Produce assembly code output file */ 511316083Smm 512316083Smm Gbl_AsmOutputFlag = TRUE; 513316083Smm break; 514316083Smm 515316083Smm case 'c': 516316083Smm 517316083Smm /* Produce C hex output file */ 518316083Smm 519316083Smm Gbl_C_OutputFlag = TRUE; 520316083Smm break; 521316083Smm 522316083Smm case 'o': 523316083Smm 524316083Smm /* Produce AML offset table in C */ 525316083Smm 526316083Smm Gbl_C_OffsetTableFlag = TRUE; 527316083Smm break; 528316083Smm 529316083Smm default: 530316083Smm 531316083Smm printf ("Unknown option: -s%s\n", AcpiGbl_Optarg); 532316083Smm return (-1); 533316083Smm } 534316083Smm break; 535316083Smm 536316083Smm case 't': /* Produce hex table output file */ 537316083Smm 538316083Smm switch (AcpiGbl_Optarg[0]) 539316083Smm { 540316083Smm case 'a': 541316083Smm 542316083Smm Gbl_HexOutputFlag = HEX_OUTPUT_ASM; 543316083Smm break; 544316083Smm 545316083Smm case 'c': 546316083Smm 547316083Smm Gbl_HexOutputFlag = HEX_OUTPUT_C; 548316083Smm break; 549316083Smm 550316083Smm case 's': 551316083Smm 552316083Smm Gbl_HexOutputFlag = HEX_OUTPUT_ASL; 553316083Smm break; 554316083Smm 555316083Smm default: 556316083Smm 557316083Smm printf ("Unknown option: -t%s\n", AcpiGbl_Optarg); 558316083Smm return (-1); 559316083Smm } 560316083Smm break; 561316083Smm 562315633Smm case 'T': /* Create a ACPI table template file */ 563315633Smm 564315633Smm Gbl_DoTemplates = TRUE; 565315633Smm Gbl_TemplateSignature = AcpiGbl_Optarg; 566315633Smm break; 567315633Smm 568315633Smm case 'v': /* Version and verbosity settings */ 569315633Smm 570315633Smm switch (AcpiGbl_Optarg[0]) 571315633Smm { 572315633Smm case '^': 573315633Smm 574315633Smm printf (ACPI_COMMON_SIGNON (ASL_COMPILER_NAME)); 575315633Smm exit (0); 576315633Smm 577315633Smm case 'a': 578315633Smm 579315633Smm /* Disable All error/warning messages */ 580315633Smm 581315633Smm Gbl_NoErrors = TRUE; 582315633Smm break; 583315633Smm 584315633Smm case 'i': 585315633Smm /* 586315633Smm * Support for integrated development environment(s). 587315633Smm * 588315633Smm * 1) No compiler signon 589315633Smm * 2) Send stderr messages to stdout 590315633Smm * 3) Less verbose error messages (single line only for each) 591315633Smm * 4) Error/warning messages are formatted appropriately to 592315633Smm * be recognized by MS Visual Studio 593315633Smm */ 594315633Smm Gbl_VerboseErrors = FALSE; 595315633Smm Gbl_DoSignon = FALSE; 596315633Smm Gbl_Files[ASL_FILE_STDERR].Handle = stdout; 597315633Smm break; 598315633Smm 599315633Smm case 'o': 600315633Smm 601315633Smm Gbl_DisplayOptimizations = TRUE; 602315633Smm break; 603315633Smm 604315633Smm case 'r': 605315633Smm 606315633Smm Gbl_DisplayRemarks = FALSE; 607315633Smm break; 608315633Smm 609315633Smm case 's': 610315633Smm 611315633Smm Gbl_DoSignon = FALSE; 612315633Smm break; 613315633Smm 614315633Smm case 't': 615315633Smm 616315633Smm Gbl_VerboseTemplates = TRUE; 617315633Smm break; 618315633Smm 619315633Smm case 'w': 620315633Smm 621315633Smm /* Get the required argument */ 622315633Smm 623315633Smm if (AcpiGetoptArgument (argc, argv)) 624315633Smm { 625315633Smm return (-1); 626315633Smm } 627315633Smm 628315633Smm Status = AslDisableException (AcpiGbl_Optarg); 629315633Smm if (ACPI_FAILURE (Status)) 630315633Smm { 631315633Smm return (-1); 632315633Smm } 633315633Smm break; 634315633Smm 635315633Smm default: 636315633Smm 637315633Smm printf ("Unknown option: -v%s\n", AcpiGbl_Optarg); 638315633Smm return (-1); 639315633Smm } 640315633Smm break; 641315633Smm 642315633Smm case 'w': /* Set warning levels */ 643315633Smm 644315633Smm switch (AcpiGbl_Optarg[0]) 645315633Smm { 646315633Smm case '1': 647315633Smm 648315633Smm Gbl_WarningLevel = ASL_WARNING; 649315633Smm break; 650315633Smm 651315633Smm case '2': 652315633Smm 653315633Smm Gbl_WarningLevel = ASL_WARNING2; 654315633Smm break; 655315633Smm 656315633Smm case '3': 657315633Smm 658315633Smm Gbl_WarningLevel = ASL_WARNING3; 659315633Smm break; 660315633Smm 661315633Smm case 'e': 662315633Smm 663315633Smm Gbl_WarningsAsErrors = TRUE; 664315633Smm break; 665315633Smm 666315633Smm default: 667316083Smm 668316083Smm printf ("Unknown option: -w%s\n", AcpiGbl_Optarg); 669316083Smm return (-1); 670316083Smm } 671316083Smm break; 672316083Smm 673316083Smm case 'x': /* Set debug print output level */ 674316083Smm 675316083Smm AcpiDbgLevel = strtoul (AcpiGbl_Optarg, NULL, 16); 676316083Smm break; 677316083Smm 678316083Smm case 'z': 679316083Smm 680316083Smm Gbl_UseOriginalCompilerId = TRUE; 681316083Smm break; 682316083Smm 683316083Smm default: 684316083Smm 685316083Smm return (-1); 686316083Smm } 687316083Smm 688316083Smm return (0); 689316083Smm} 690316083Smm 691316083Smm 692316083Smm/******************************************************************************* 693316083Smm * 694316083Smm * FUNCTION: AslMergeOptionTokens 695316083Smm * 696316083Smm * PARAMETERS: InBuffer - Input containing an option string 697316083Smm * OutBuffer - Merged output buffer 698316083Smm * 699316083Smm * RETURN: None 700316083Smm * 701316083Smm * DESCRIPTION: Remove all whitespace from an option string. 702316095Smm * 703 ******************************************************************************/ 704 705static void 706AslMergeOptionTokens ( 707 char *InBuffer, 708 char *OutBuffer) 709{ 710 char *Token; 711 712 713 *OutBuffer = 0; 714 715 Token = strtok (InBuffer, ASL_TOKEN_SEPARATORS); 716 while (Token) 717 { 718 strcat (OutBuffer, Token); 719 Token = strtok (NULL, ASL_TOKEN_SEPARATORS); 720 } 721} 722 723 724/******************************************************************************* 725 * 726 * FUNCTION: AslDoResponseFile 727 * 728 * PARAMETERS: Filename - Name of the response file 729 * 730 * RETURN: Status 731 * 732 * DESCRIPTION: Open a response file and process all options within. 733 * 734 ******************************************************************************/ 735 736static int 737AslDoResponseFile ( 738 char *Filename) 739{ 740 char *argv = StringBuffer2; 741 FILE *ResponseFile; 742 int OptStatus = 0; 743 int Opterr; 744 int Optind; 745 746 747 ResponseFile = fopen (Filename, "r"); 748 if (!ResponseFile) 749 { 750 printf ("Could not open command file %s, %s\n", 751 Filename, strerror (errno)); 752 return (-1); 753 } 754 755 /* Must save the current GetOpt globals */ 756 757 Opterr = AcpiGbl_Opterr; 758 Optind = AcpiGbl_Optind; 759 760 /* 761 * Process all lines in the response file. There must be one complete 762 * option per line 763 */ 764 while (fgets (StringBuffer, ASL_MSG_BUFFER_SIZE, ResponseFile)) 765 { 766 /* Compress all tokens, allowing us to use a single argv entry */ 767 768 AslMergeOptionTokens (StringBuffer, StringBuffer2); 769 770 /* Process the option */ 771 772 AcpiGbl_Opterr = 0; 773 AcpiGbl_Optind = 0; 774 775 OptStatus = AslDoOptions (1, &argv, TRUE); 776 if (OptStatus) 777 { 778 printf ("Invalid option in command file %s: %s\n", 779 Filename, StringBuffer); 780 break; 781 } 782 } 783 784 /* Restore the GetOpt globals */ 785 786 AcpiGbl_Opterr = Opterr; 787 AcpiGbl_Optind = Optind; 788 789 fclose (ResponseFile); 790 return (OptStatus); 791} 792