Path: blob/main/sys/contrib/dev/acpica/compiler/asloptions.c
48371 views
/******************************************************************************1*2* Module Name: asloptions - compiler command line processing3*4*****************************************************************************/56/******************************************************************************7*8* 1. Copyright Notice9*10* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.11* All rights reserved.12*13* 2. License14*15* 2.1. This is your license from Intel Corp. under its intellectual property16* rights. You may have additional license terms from the party that provided17* you this software, covering your right to use that party's intellectual18* property rights.19*20* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a21* copy of the source code appearing in this file ("Covered Code") an22* irrevocable, perpetual, worldwide license under Intel's copyrights in the23* base code distributed originally by Intel ("Original Intel Code") to copy,24* make derivatives, distribute, use and display any portion of the Covered25* Code in any form, with the right to sublicense such rights; and26*27* 2.3. Intel grants Licensee a non-exclusive and non-transferable patent28* license (with the right to sublicense), under only those claims of Intel29* patents that are infringed by the Original Intel Code, to make, use, sell,30* offer to sell, and import the Covered Code and derivative works thereof31* solely to the minimum extent necessary to exercise the above copyright32* license, and in no event shall the patent license extend to any additions33* to or modifications of the Original Intel Code. No other license or right34* is granted directly or by implication, estoppel or otherwise;35*36* The above copyright and patent license is granted only if the following37* conditions are met:38*39* 3. Conditions40*41* 3.1. Redistribution of Source with Rights to Further Distribute Source.42* Redistribution of source code of any substantial portion of the Covered43* Code or modification with rights to further distribute source must include44* the above Copyright Notice, the above License, this list of Conditions,45* and the following Disclaimer and Export Compliance provision. In addition,46* Licensee must cause all Covered Code to which Licensee contributes to47* contain a file documenting the changes Licensee made to create that Covered48* Code and the date of any change. Licensee must include in that file the49* documentation of any changes made by any predecessor Licensee. Licensee50* must include a prominent statement that the modification is derived,51* directly or indirectly, from Original Intel Code.52*53* 3.2. Redistribution of Source with no Rights to Further Distribute Source.54* Redistribution of source code of any substantial portion of the Covered55* Code or modification without rights to further distribute source must56* include the following Disclaimer and Export Compliance provision in the57* documentation and/or other materials provided with distribution. In58* addition, Licensee may not authorize further sublicense of source of any59* portion of the Covered Code, and must include terms to the effect that the60* license from Licensee to its licensee is limited to the intellectual61* property embodied in the software Licensee provides to its licensee, and62* not to intellectual property embodied in modifications its licensee may63* make.64*65* 3.3. Redistribution of Executable. Redistribution in executable form of any66* substantial portion of the Covered Code or modification must reproduce the67* above Copyright Notice, and the following Disclaimer and Export Compliance68* provision in the documentation and/or other materials provided with the69* distribution.70*71* 3.4. Intel retains all right, title, and interest in and to the Original72* Intel Code.73*74* 3.5. Neither the name Intel nor any other trademark owned or controlled by75* Intel shall be used in advertising or otherwise to promote the sale, use or76* other dealings in products derived from or relating to the Covered Code77* without prior written authorization from Intel.78*79* 4. Disclaimer and Export Compliance80*81* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED82* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE83* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,84* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY85* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY86* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A87* PARTICULAR PURPOSE.88*89* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES90* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR91* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,92* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY93* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL94* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS95* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY96* LIMITED REMEDY.97*98* 4.3. Licensee shall not export, either directly or indirectly, any of this99* software or system incorporating such software without first obtaining any100* required license or other approval from the U. S. Department of Commerce or101* any other agency or department of the United States Government. In the102* event Licensee exports any such software from the United States or103* re-exports any such software from a foreign destination, Licensee shall104* ensure that the distribution and export/re-export of the software is in105* compliance with all laws, regulations, orders, or other restrictions of the106* U.S. Export Administration Regulations. Licensee agrees that neither it nor107* any of its subsidiaries will export/re-export any technical data, process,108* software, or service, directly or indirectly, to any country for which the109* United States government or any agency thereof requires an export license,110* other governmental approval, or letter of assurance, without first obtaining111* such license, approval or letter.112*113*****************************************************************************114*115* Alternatively, you may choose to be licensed under the terms of the116* following license:117*118* Redistribution and use in source and binary forms, with or without119* modification, are permitted provided that the following conditions120* are met:121* 1. Redistributions of source code must retain the above copyright122* notice, this list of conditions, and the following disclaimer,123* without modification.124* 2. Redistributions in binary form must reproduce at minimum a disclaimer125* substantially similar to the "NO WARRANTY" disclaimer below126* ("Disclaimer") and any redistribution must be conditioned upon127* including a substantially similar Disclaimer requirement for further128* binary redistribution.129* 3. Neither the names of the above-listed copyright holders nor the names130* of any contributors may be used to endorse or promote products derived131* from this software without specific prior written permission.132*133* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS134* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT135* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR136* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT137* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,138* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT139* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,140* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY141* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT142* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE143* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.144*145* Alternatively, you may choose to be licensed under the terms of the146* GNU General Public License ("GPL") version 2 as published by the Free147* Software Foundation.148*149*****************************************************************************/150151#include <contrib/dev/acpica/compiler/aslcompiler.h>152#include <contrib/dev/acpica/include/acapps.h>153#include <contrib/dev/acpica/include/acdisasm.h>154#include <contrib/dev/acpica/include/acglobal.h>155156#define _COMPONENT ACPI_COMPILER157ACPI_MODULE_NAME ("asloption")158159160/* Local prototypes */161162static int163AslDoOptions (164int argc,165char **argv,166BOOLEAN IsResponseFile);167168static void169AslMergeOptionTokens (170char *InBuffer,171char *OutBuffer);172173static int174AslDoResponseFile (175char *Filename);176177178#define ASL_TOKEN_SEPARATORS " \t\n"179#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"180181182/*******************************************************************************183*184* FUNCTION: AslCommandLine185*186* PARAMETERS: argc/argv187*188* RETURN: Last argv index189*190* DESCRIPTION: Command line processing191*192******************************************************************************/193194int195AslCommandLine (196int argc,197char **argv)198{199int BadCommandLine = 0;200ACPI_STATUS Status;201202203/* Minimum command line contains at least the command and an input file */204205if (argc < 2)206{207Usage ();208exit (1);209}210211/* Process all command line options */212213BadCommandLine = AslDoOptions (argc, argv, FALSE);214215if (AslGbl_DoTemplates)216{217Status = DtCreateTemplates (argv);218if (ACPI_FAILURE (Status))219{220exit (-1);221}222exit (0);223}224225/* Next parameter must be the input filename */226227if (!argv[AcpiGbl_Optind] &&228!AcpiGbl_DisasmFlag)229{230printf ("Missing input filename\n");231BadCommandLine = TRUE;232}233234if (AslGbl_DoSignon)235{236printf (ACPI_COMMON_SIGNON (ASL_COMPILER_NAME));237if (AslGbl_IgnoreErrors)238{239printf ("Ignoring all errors, forcing AML file generation\n\n");240}241}242243if (BadCommandLine)244{245printf ("Use -h option for help information\n");246exit (1);247}248249return (AcpiGbl_Optind);250}251252253/*******************************************************************************254*255* FUNCTION: AslDoOptions256*257* PARAMETERS: argc/argv - Standard argc/argv258* IsResponseFile - TRUE if executing a response file.259*260* RETURN: Status261*262* DESCRIPTION: Command line option processing263*264******************************************************************************/265266static int267AslDoOptions (268int argc,269char **argv,270BOOLEAN IsResponseFile)271{272ACPI_STATUS Status;273INT32 j;274275276/* Get the command line options */277278while ((j = AcpiGetopt (argc, argv, ASL_SUPPORTED_OPTIONS)) != ACPI_OPT_END) switch (j)279{280case '@': /* Begin a response file */281282if (IsResponseFile)283{284printf ("Nested command files are not supported\n");285return (-1);286}287288if (AslDoResponseFile (AcpiGbl_Optarg))289{290return (-1);291}292break;293294case 'a': /* Debug options */295296switch (AcpiGbl_Optarg[0])297{298case 'r':299300AslGbl_EnableReferenceTypechecking = TRUE;301break;302303default:304305printf ("Unknown option: -a%s\n", AcpiGbl_Optarg);306return (-1);307}308309break;310311312case 'b': /* Debug options */313314switch (AcpiGbl_Optarg[0])315{316317case 'c':318319printf ("Debug ASL to ASL+ conversion\n");320321AslGbl_DoAslConversion = TRUE;322AslGbl_FoldConstants = FALSE;323AslGbl_IntegerOptimizationFlag = FALSE;324AslGbl_ReferenceOptimizationFlag = FALSE;325AslGbl_OptimizeTrivialParseNodes = FALSE;326AcpiGbl_CaptureComments = TRUE;327AcpiGbl_DoDisassemblerOptimizations = FALSE;328AcpiGbl_DebugAslConversion = TRUE;329AcpiGbl_DmEmitExternalOpcodes = TRUE;330AslGbl_DoExternalsInPlace = TRUE;331332return (0);333334case 'f':335336AslCompilerdebug = 1; /* same as yydebug */337DtParserdebug = 1;338PrParserdebug = 1;339AslGbl_DebugFlag = TRUE;340AslGbl_KeepPreprocessorTempFile = TRUE;341break;342343case 'p': /* Prune ASL parse tree */344345/* Get the required argument */346347if (AcpiGetoptArgument (argc, argv))348{349return (-1);350}351352AslGbl_PruneParseTree = TRUE;353AslGbl_PruneDepth = (UINT8) strtoul (AcpiGbl_Optarg, NULL, 0);354break;355356case 's':357358AslGbl_DebugFlag = TRUE;359break;360361case 't':362363/* Get the required argument */364365if (AcpiGetoptArgument (argc, argv))366{367return (-1);368}369AslGbl_PruneType = (UINT8) strtoul (AcpiGbl_Optarg, NULL, 0);370break;371372default:373374printf ("Unknown option: -b%s\n", AcpiGbl_Optarg);375return (-1);376}377378break;379380case 'c':381382switch (AcpiGbl_Optarg[0])383{384385case 'a':386387printf ("Convert ASL to ASL+ with comments\n");388AslGbl_DoAslConversion = TRUE;389AslGbl_FoldConstants = FALSE;390AslGbl_IntegerOptimizationFlag = FALSE;391AslGbl_ReferenceOptimizationFlag = FALSE;392AslGbl_OptimizeTrivialParseNodes = FALSE;393AcpiGbl_CaptureComments = TRUE;394AcpiGbl_DoDisassemblerOptimizations = FALSE;395AcpiGbl_DmEmitExternalOpcodes = TRUE;396AslGbl_DoExternalsInPlace = TRUE;397398return (0);399400case 'r':401402AslGbl_NoResourceChecking = TRUE;403break;404405default:406407printf ("Unknown option: -c%s\n", AcpiGbl_Optarg);408return (-1);409}410break;411412case 'd': /* Disassembler */413414switch (AcpiGbl_Optarg[0])415{416case '^':417418AslGbl_DoCompile = FALSE;419break;420421case 'a':422423AslGbl_DoCompile = FALSE;424AslGbl_DisassembleAll = TRUE;425break;426427case 'b': /* Do not convert buffers to resource descriptors */428429AcpiGbl_NoResourceDisassembly = TRUE;430break;431432case 'c':433434break;435436case 'f':437438AcpiGbl_ForceAmlDisassembly = TRUE;439break;440441case 'l': /* Use legacy ASL code (not ASL+) for disassembly */442443AslGbl_DoCompile = FALSE;444AcpiGbl_CstyleDisassembly = FALSE;445break;446447case 's': /* Specify table signature (Only supported for CDAT table) */448449/* Get the required argument */450451if (AcpiGetoptArgument (argc, argv))452{453return (-1);454}455456/* Check for exact string "CDAT" (upper or lower case) */457458AcpiGbl_CDAT = ACPI_CAST_PTR (char, &AcpiGbl_Optarg);459if (AcpiUtStricmp (AcpiGbl_Optarg, ACPI_SIG_CDAT))460{461printf ("\nUnknown table signature: %s\n", AcpiGbl_Optarg);462return (-1);463}464465AcpiGbl_CDAT = malloc (5);466AcpiUtSafeStrncpy ((char *) AcpiGbl_CDAT, ACPI_SIG_CDAT, 5);467break;468469default:470471printf ("Unknown option: -d%s\n", AcpiGbl_Optarg);472return (-1);473}474475AcpiGbl_DisasmFlag = TRUE;476break;477478case 'D': /* Define a symbol */479480PrAddDefine (AcpiGbl_Optarg, NULL, TRUE);481break;482483case 'e': /* External files for disassembler */484485/* Get entire list of external files */486487AcpiGbl_Optind--;488argv[AcpiGbl_Optind] = AcpiGbl_Optarg;489490while (argv[AcpiGbl_Optind] &&491(argv[AcpiGbl_Optind][0] != '-'))492{493Status = AcpiDmAddToExternalFileList (argv[AcpiGbl_Optind]);494if (ACPI_FAILURE (Status))495{496printf ("Could not add %s to external list\n",497argv[AcpiGbl_Optind]);498return (-1);499}500501AcpiGbl_Optind++;502}503break;504505case 'f':506507switch (AcpiGbl_Optarg[0])508{509case '^': /* Ignore errors and force creation of aml file */510511AslGbl_IgnoreErrors = TRUE;512break;513514case 'e': /* Disassembler: Get external declaration file */515516if (AcpiGetoptArgument (argc, argv))517{518return (-1);519}520521AslGbl_ExternalRefFilename = AcpiGbl_Optarg;522break;523524default:525526printf ("Unknown option: -f%s\n", AcpiGbl_Optarg);527return (-1);528}529break;530531case 'G':532533AslGbl_CompileGeneric = TRUE;534break;535536case 'g': /* Get all ACPI tables */537538printf ("-g option is deprecated, use acpidump utility instead\n");539exit (1);540541case 'h':542543switch (AcpiGbl_Optarg[0])544{545case '^':546547Usage ();548exit (0);549550case 'c':551552UtDisplayConstantOpcodes ();553exit (0);554555case 'd':556557AslDisassemblyHelp ();558exit (0);559560case 'f':561562AslFilenameHelp ();563exit (0);564565case 'r':566567/* reserved names */568569ApDisplayReservedNames ();570exit (0);571572case 't':573574UtDisplaySupportedTables ();575exit (0);576577default:578579printf ("Unknown option: -h%s\n", AcpiGbl_Optarg);580return (-1);581}582583case 'I': /* Add an include file search directory */584585FlAddIncludeDirectory (AcpiGbl_Optarg);586break;587588case 'i': /* Output AML as an include file */589590switch (AcpiGbl_Optarg[0])591{592case 'a':593594/* Produce assembly code include file */595596AslGbl_AsmIncludeOutputFlag = TRUE;597break;598599case 'c':600601/* Produce C include file */602603AslGbl_C_IncludeOutputFlag = TRUE;604break;605606case 'n':607608/* Compiler/Disassembler: Ignore the NOOP operator */609610AcpiGbl_IgnoreNoopOperator = TRUE;611break;612613default:614615printf ("Unknown option: -i%s\n", AcpiGbl_Optarg);616return (-1);617}618break;619620case 'l': /* Listing files */621622switch (AcpiGbl_Optarg[0])623{624case '^':625626/* Produce listing file (Mixed source/aml) */627628AslGbl_ListingFlag = TRUE;629AcpiGbl_DmOpt_Listing = TRUE;630break;631632case 'd':633634/* Disable deterministic output, enabling timestamp */635636AslGbl_Deterministic = FALSE;637break;638639case 'i':640641/* Produce preprocessor output file */642643AslGbl_PreprocessorOutputFlag = TRUE;644break;645646case 'm':647648/* Produce hardware map summary file */649650AslGbl_MapfileFlag = TRUE;651break;652653case 'n':654655/* Produce namespace file */656657AslGbl_NsOutputFlag = TRUE;658break;659660case 's':661662/* Produce combined source file */663664AslGbl_SourceOutputFlag = TRUE;665break;666667case 'x':668669/* Produce cross-reference file */670671AslGbl_CrossReferenceOutput = TRUE;672break;673674default:675676printf ("Unknown option: -l%s\n", AcpiGbl_Optarg);677return (-1);678}679break;680681case 'm': /* Set line buffer size */682683AslGbl_LineBufferSize = (UINT32) strtoul (AcpiGbl_Optarg, NULL, 0) * 1024;684if (AslGbl_LineBufferSize < ASL_DEFAULT_LINE_BUFFER_SIZE)685{686AslGbl_LineBufferSize = ASL_DEFAULT_LINE_BUFFER_SIZE;687}688printf ("Line Buffer Size: %u\n", AslGbl_LineBufferSize);689break;690691case 'n': /* Parse only */692693AslGbl_ParseOnlyFlag = TRUE;694break;695696case 'o': /* Control compiler AML optimizations */697698switch (AcpiGbl_Optarg[0])699{700case 'a':701702/* Disable all optimizations */703704AslGbl_FoldConstants = FALSE;705AslGbl_IntegerOptimizationFlag = FALSE;706AslGbl_ReferenceOptimizationFlag = FALSE;707AslGbl_OptimizeTrivialParseNodes = FALSE;708709break;710711case 'c':712713/* Display compile time(s) */714715AslGbl_CompileTimesFlag = TRUE;716break;717718case 'd':719720/* Disable disassembler code optimizations */721722AcpiGbl_DoDisassemblerOptimizations = FALSE;723break;724725case 'e':726727/* Disassembler: Emit embedded external operators */728729AcpiGbl_DmEmitExternalOpcodes = TRUE;730break;731732case 'E':733734/*735* iASL: keep External opcodes in place.736* No affect if Gbl_DoExternals is false.737*/738739AslGbl_DoExternalsInPlace = TRUE;740break;741742case 'f':743744/* Disable folding on "normal" expressions */745746AslGbl_FoldConstants = FALSE;747break;748749case 'i':750751/* Disable integer optimization to constants */752753AslGbl_IntegerOptimizationFlag = FALSE;754break;755756case 'n':757758/* Disable named reference optimization */759760AslGbl_ReferenceOptimizationFlag = FALSE;761break;762763case 't':764765/* Disable heavy typechecking */766767AslGbl_DoTypechecking = FALSE;768break;769770default:771772printf ("Unknown option: -c%s\n", AcpiGbl_Optarg);773return (-1);774}775break;776777case 'P': /* Preprocessor options */778779switch (AcpiGbl_Optarg[0])780{781case '^': /* Proprocess only, emit (.i) file */782783AslGbl_PreprocessOnly = TRUE;784AslGbl_PreprocessorOutputFlag = TRUE;785break;786787case 'n': /* Disable preprocessor */788789AslGbl_PreprocessFlag = FALSE;790break;791792default:793794printf ("Unknown option: -P%s\n", AcpiGbl_Optarg);795return (-1);796}797break;798799case 'p': /* Override default AML output filename */800801AslGbl_OutputFilenamePrefix = AcpiGbl_Optarg;802UtConvertBackslashes (AslGbl_OutputFilenamePrefix);803AslGbl_UseDefaultAmlFilename = FALSE;804break;805806case 'q': /* ASL/ASl+ converter: compile only and leave badaml. */807808printf ("Convert ASL to ASL+ with comments\n");809AslGbl_FoldConstants = FALSE;810AslGbl_IntegerOptimizationFlag = FALSE;811AslGbl_ReferenceOptimizationFlag = FALSE;812AslGbl_OptimizeTrivialParseNodes = FALSE;813AslGbl_DoExternalsInPlace = TRUE;814AcpiGbl_CaptureComments = TRUE;815return (0);816817case 'r': /* Override revision found in table header */818819AslGbl_RevisionOverride = (UINT8) strtoul (AcpiGbl_Optarg, NULL, 0);820break;821822case 's': /* Create AML in a source code file */823824switch (AcpiGbl_Optarg[0])825{826case 'a':827828/* Produce assembly code output file */829830AslGbl_AsmOutputFlag = TRUE;831break;832833case 'c':834835/* Produce C hex output file */836837AslGbl_C_OutputFlag = TRUE;838break;839840case 'o':841842/* Produce AML offset table in C */843844AslGbl_C_OffsetTableFlag = TRUE;845break;846847default:848849printf ("Unknown option: -s%s\n", AcpiGbl_Optarg);850return (-1);851}852break;853854case 't': /* Produce hex table output file */855856switch (AcpiGbl_Optarg[0])857{858case 'a':859860AslGbl_HexOutputFlag = HEX_OUTPUT_ASM;861break;862863case 'c':864865AslGbl_HexOutputFlag = HEX_OUTPUT_C;866break;867868case 'p': /* data table flex/bison prototype */869870AslGbl_DtLexBisonPrototype = TRUE;871break;872873case 's':874875AslGbl_HexOutputFlag = HEX_OUTPUT_ASL;876break;877878default:879880printf ("Unknown option: -t%s\n", AcpiGbl_Optarg);881return (-1);882}883break;884885case 'T': /* Create a ACPI table template file */886887AslGbl_DoTemplates = TRUE;888break;889890case 'v': /* Version and verbosity settings */891892switch (AcpiGbl_Optarg[0])893{894case '^':895896printf (ACPI_COMMON_SIGNON (ASL_COMPILER_NAME));897exit (0);898899case 'a':900901/* Disable all error/warning/remark messages */902903AslGbl_NoErrors = TRUE;904break;905906case 'e':907908/* Disable all warning/remark messages (errors only) */909910AslGbl_DisplayRemarks = FALSE;911AslGbl_DisplayWarnings = FALSE;912break;913914case 'i':915/*916* Support for integrated development environment(s).917*918* 1) No compiler signon919* 2) Send stderr messages to stdout920* 3) Less verbose error messages (single line only for each)921* 4) Error/warning messages are formatted appropriately to922* be recognized by MS Visual Studio923*/924AslGbl_VerboseErrors = FALSE;925AslGbl_DoSignon = FALSE;926break;927928case 'o':929930AslGbl_DisplayOptimizations = TRUE;931break;932933case 'r':934935AslGbl_DisplayRemarks = FALSE;936break;937938case 's':939940AslGbl_DoSignon = FALSE;941break;942943case 't':944945AslGbl_VerboseTemplates = TRUE;946break;947948case 'w':949950/* Get the required argument */951952if (AcpiGetoptArgument (argc, argv))953{954return (-1);955}956957Status = AslDisableException (AcpiGbl_Optarg);958if (ACPI_FAILURE (Status))959{960return (-1);961}962break;963964case 'x':965966/* Get the required argument */967968if (AcpiGetoptArgument (argc, argv))969{970return (-1);971}972973Status = AslLogExpectedException (AcpiGbl_Optarg);974if (ACPI_FAILURE (Status))975{976return (-1);977}978break;979980default:981982printf ("Unknown option: -v%s\n", AcpiGbl_Optarg);983return (-1);984}985break;986987case 'w': /* Set warning levels */988989switch (AcpiGbl_Optarg[0])990{991case '1':992993AslGbl_WarningLevel = ASL_WARNING;994break;995996case '2':997998AslGbl_WarningLevel = ASL_WARNING2;999break;10001001case '3':10021003AslGbl_WarningLevel = ASL_WARNING3;1004break;10051006case 'e':10071008AslGbl_WarningsAsErrors = TRUE;1009break;10101011case 'w':10121013/* Get the required argument */10141015if (AcpiGetoptArgument (argc, argv))1016{1017return (-1);1018}10191020Status = AslElevateException (AcpiGbl_Optarg);1021if (ACPI_FAILURE (Status))1022{1023return (-1);1024}1025break;102610271028default:10291030printf ("Unknown option: -w%s\n", AcpiGbl_Optarg);1031return (-1);1032}1033break;10341035case 'x': /* Set debug print output level */10361037AcpiDbgLevel = strtoul (AcpiGbl_Optarg, NULL, 16);1038break;10391040case 'z':10411042AslGbl_UseOriginalCompilerId = TRUE;1043break;10441045default:10461047return (-1);1048}10491050return (0);1051}105210531054/*******************************************************************************1055*1056* FUNCTION: AslMergeOptionTokens1057*1058* PARAMETERS: InBuffer - Input containing an option string1059* OutBuffer - Merged output buffer1060*1061* RETURN: None1062*1063* DESCRIPTION: Remove all whitespace from an option string.1064*1065******************************************************************************/10661067static void1068AslMergeOptionTokens (1069char *InBuffer,1070char *OutBuffer)1071{1072char *Token;107310741075*OutBuffer = 0;10761077Token = strtok (InBuffer, ASL_TOKEN_SEPARATORS);1078while (Token)1079{1080strcat (OutBuffer, Token);1081Token = strtok (NULL, ASL_TOKEN_SEPARATORS);1082}1083}108410851086/*******************************************************************************1087*1088* FUNCTION: AslDoResponseFile1089*1090* PARAMETERS: Filename - Name of the response file1091*1092* RETURN: Status1093*1094* DESCRIPTION: Open a response file and process all options within.1095*1096******************************************************************************/10971098static int1099AslDoResponseFile (1100char *Filename)1101{1102char *argv = AslGbl_StringBuffer2;1103FILE *ResponseFile;1104int OptStatus = 0;1105int Opterr;1106int Optind;110711081109ResponseFile = fopen (Filename, "r");1110if (!ResponseFile)1111{1112printf ("Could not open command file %s, %s\n",1113Filename, strerror (errno));1114return (-1);1115}11161117/* Must save the current GetOpt globals */11181119Opterr = AcpiGbl_Opterr;1120Optind = AcpiGbl_Optind;11211122/*1123* Process all lines in the response file. There must be one complete1124* option per line1125*/1126while (fgets (AslGbl_StringBuffer, ASL_STRING_BUFFER_SIZE, ResponseFile))1127{1128/* Compress all tokens, allowing us to use a single argv entry */11291130AslMergeOptionTokens (AslGbl_StringBuffer, AslGbl_StringBuffer2);11311132/* Process the option */11331134AcpiGbl_Opterr = 0;1135AcpiGbl_Optind = 0;11361137OptStatus = AslDoOptions (1, &argv, TRUE);1138if (OptStatus)1139{1140printf ("Invalid option in command file %s: %s\n",1141Filename, AslGbl_StringBuffer);1142break;1143}1144}11451146/* Restore the GetOpt globals */11471148AcpiGbl_Opterr = Opterr;1149AcpiGbl_Optind = Optind;11501151fclose (ResponseFile);1152return (OptStatus);1153}115411551156