asloptions.c revision 296373
119370Spst/******************************************************************************
219370Spst *
319370Spst * Module Name: asloptions - compiler command line processing
419370Spst *
519370Spst *****************************************************************************/
619370Spst
719370Spst/*
819370Spst * Copyright (C) 2000 - 2015, Intel Corp.
919370Spst * All rights reserved.
1019370Spst *
1119370Spst * Redistribution and use in source and binary forms, with or without
1219370Spst * modification, are permitted provided that the following conditions
1319370Spst * are met:
1419370Spst * 1. Redistributions of source code must retain the above copyright
1519370Spst *    notice, this list of conditions, and the following disclaimer,
1619370Spst *    without modification.
1719370Spst * 2. Redistributions in binary form must reproduce at minimum a disclaimer
1819370Spst *    substantially similar to the "NO WARRANTY" disclaimer below
1919370Spst *    ("Disclaimer") and any redistribution must be conditioned upon
2019370Spst *    including a substantially similar Disclaimer requirement for further
2119370Spst *    binary redistribution.
2219370Spst * 3. Neither the names of the above-listed copyright holders nor the names
2319370Spst *    of any contributors may be used to endorse or promote products derived
2419370Spst *    from this software without specific prior written permission.
2519370Spst *
2619370Spst * Alternatively, this software may be distributed under the terms of the
2719370Spst * GNU General Public License ("GPL") version 2 as published by the Free
2819370Spst * Software Foundation.
2919370Spst *
3019370Spst * NO WARRANTY
3119370Spst * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
3219370Spst * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
3319370Spst * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
3419370Spst * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
3519370Spst * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3619370Spst * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3719370Spst * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3819370Spst * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
3919370Spst * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
4019370Spst * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
4119370Spst * POSSIBILITY OF SUCH DAMAGES.
4219370Spst */
4319370Spst
4419370Spst#include <contrib/dev/acpica/compiler/aslcompiler.h>
4519370Spst#include <contrib/dev/acpica/include/acapps.h>
4619370Spst#include <contrib/dev/acpica/include/acdisasm.h>
4719370Spst
4819370Spst#define _COMPONENT          ACPI_COMPILER
4919370Spst        ACPI_MODULE_NAME    ("asloption")
5019370Spst
5119370Spst
5219370Spst/* Local prototypes */
5319370Spst
5419370Spststatic int
5519370SpstAslDoOptions (
5619370Spst    int                     argc,
5719370Spst    char                    **argv,
5819370Spst    BOOLEAN                 IsResponseFile);
5919370Spst
6019370Spststatic void
6119370SpstAslMergeOptionTokens (
6219370Spst    char                    *InBuffer,
6319370Spst    char                    *OutBuffer);
6419370Spst
6519370Spststatic int
6619370SpstAslDoResponseFile (
6719370Spst    char                    *Filename);
6819370Spst
6919370Spst
7019370Spst#define ASL_TOKEN_SEPARATORS    " \t\n"
7119370Spst#define ASL_SUPPORTED_OPTIONS   "@:b|c|d^D:e:f^gh^i|I:l^m:no|p:P^r:s|t|T+G^v^w|x:z"
7219370Spst
7319370Spst
7419370Spst/*******************************************************************************
7519370Spst *
7619370Spst * FUNCTION:    AslCommandLine
7719370Spst *
7819370Spst * PARAMETERS:  argc/argv
7919370Spst *
8019370Spst * RETURN:      Last argv index
8119370Spst *
8219370Spst * DESCRIPTION: Command line processing
8319370Spst *
8419370Spst ******************************************************************************/
8519370Spst
8619370Spstint
8719370SpstAslCommandLine (
8819370Spst    int                     argc,
8919370Spst    char                    **argv)
9019370Spst{
9119370Spst    int                     BadCommandLine = 0;
9219370Spst    ACPI_STATUS             Status;
9319370Spst
9419370Spst
9519370Spst    /* Minimum command line contains at least the command and an input file */
9619370Spst
9719370Spst    if (argc < 2)
9819370Spst    {
9919370Spst        printf (ACPI_COMMON_SIGNON (ASL_COMPILER_NAME));
10019370Spst        Usage ();
10119370Spst        exit (1);
10219370Spst    }
10319370Spst
10419370Spst    /* Process all command line options */
10519370Spst
10619370Spst    BadCommandLine = AslDoOptions (argc, argv, FALSE);
10719370Spst
10819370Spst    if (Gbl_DoTemplates)
10919370Spst    {
11019370Spst        Status = DtCreateTemplates (Gbl_TemplateSignature);
11119370Spst        if (ACPI_FAILURE (Status))
11219370Spst        {
11319370Spst            exit (-1);
11419370Spst        }
11519370Spst        exit (1);
11619370Spst    }
11719370Spst
11819370Spst    /* Next parameter must be the input filename */
11919370Spst
12019370Spst    if (!argv[AcpiGbl_Optind] &&
12119370Spst        !Gbl_DisasmFlag)
12219370Spst    {
12319370Spst        printf ("Missing input filename\n");
12419370Spst        BadCommandLine = TRUE;
12519370Spst    }
12619370Spst
12719370Spst    if (Gbl_DoSignon)
12819370Spst    {
12919370Spst        printf (ACPI_COMMON_SIGNON (ASL_COMPILER_NAME));
13019370Spst        if (Gbl_IgnoreErrors)
13119370Spst        {
13219370Spst            printf ("Ignoring all errors, forcing AML file generation\n\n");
13319370Spst        }
13419370Spst    }
13519370Spst
13619370Spst    if (BadCommandLine)
13719370Spst    {
13819370Spst        printf ("Use -h option for help information\n");
13919370Spst        exit (1);
14019370Spst    }
14119370Spst
14219370Spst    return (AcpiGbl_Optind);
14319370Spst}
14419370Spst
14519370Spst
14619370Spst/*******************************************************************************
14719370Spst *
14819370Spst * FUNCTION:    AslDoOptions
14919370Spst *
15019370Spst * PARAMETERS:  argc/argv           - Standard argc/argv
15119370Spst *              IsResponseFile      - TRUE if executing a response file.
15219370Spst *
15319370Spst * RETURN:      Status
15419370Spst *
15519370Spst * DESCRIPTION: Command line option processing
15619370Spst *
15719370Spst ******************************************************************************/
15819370Spst
15919370Spststatic int
16019370SpstAslDoOptions (
16119370Spst    int                     argc,
16219370Spst    char                    **argv,
16319370Spst    BOOLEAN                 IsResponseFile)
16419370Spst{
16519370Spst    ACPI_STATUS             Status;
16619370Spst    UINT32                  j;
16719370Spst
16819370Spst
16919370Spst    /* Get the command line options */
17019370Spst
17119370Spst    while ((j = AcpiGetopt (argc, argv, ASL_SUPPORTED_OPTIONS)) != ACPI_OPT_END) switch (j)
17219370Spst    {
17319370Spst    case '@':   /* Begin a response file */
17419370Spst
17519370Spst        if (IsResponseFile)
17619370Spst        {
17719370Spst            printf ("Nested command files are not supported\n");
17819370Spst            return (-1);
17919370Spst        }
18019370Spst
18119370Spst        if (AslDoResponseFile (AcpiGbl_Optarg))
18219370Spst        {
18319370Spst            return (-1);
18419370Spst        }
18519370Spst        break;
18619370Spst
18719370Spst    case 'b':   /* Debug options */
18819370Spst
18919370Spst        switch (AcpiGbl_Optarg[0])
19019370Spst        {
19119370Spst        case 'f':
19219370Spst
19319370Spst            AslCompilerdebug = 1; /* same as yydebug */
19419370Spst            DtParserdebug = 1;
19519370Spst            PrParserdebug = 1;
19619370Spst            Gbl_DebugFlag = TRUE;
19719370Spst            break;
19819370Spst
19919370Spst        case 'p':   /* Prune ASL parse tree */
20019370Spst
20119370Spst            /* Get the required argument */
20219370Spst
20319370Spst            if (AcpiGetoptArgument (argc, argv))
20419370Spst            {
20519370Spst                return (-1);
20619370Spst            }
20719370Spst
20819370Spst            Gbl_PruneParseTree = TRUE;
20919370Spst            Gbl_PruneDepth = (UINT8) strtoul (AcpiGbl_Optarg, NULL, 0);
21019370Spst            break;
21119370Spst
21219370Spst        case 's':
21319370Spst
21419370Spst            Gbl_DebugFlag = TRUE;
21519370Spst            break;
21619370Spst
21719370Spst        case 't':
21819370Spst
21919370Spst            /* Get the required argument */
22019370Spst
22119370Spst            if (AcpiGetoptArgument (argc, argv))
22219370Spst            {
22319370Spst                return (-1);
22419370Spst            }
22519370Spst
22619370Spst            Gbl_PruneType = (UINT8) strtoul (AcpiGbl_Optarg, NULL, 0);
22719370Spst            break;
22819370Spst
22919370Spst        default:
23019370Spst
23119370Spst            printf ("Unknown option: -b%s\n", AcpiGbl_Optarg);
23219370Spst            return (-1);
23319370Spst        }
23419370Spst
23519370Spst        break;
23619370Spst
23719370Spst    case 'c':
23819370Spst
23919370Spst        switch (AcpiGbl_Optarg[0])
24019370Spst        {
24119370Spst        case 'r':
24219370Spst
24319370Spst            Gbl_NoResourceChecking = TRUE;
24419370Spst            break;
24519370Spst
24619370Spst        default:
24719370Spst
24819370Spst            printf ("Unknown option: -c%s\n", AcpiGbl_Optarg);
24919370Spst            return (-1);
25019370Spst        }
25119370Spst        break;
25219370Spst
25319370Spst    case 'd':   /* Disassembler */
25419370Spst
25519370Spst        switch (AcpiGbl_Optarg[0])
25619370Spst        {
25719370Spst        case '^':
25819370Spst
25919370Spst            Gbl_DoCompile = FALSE;
26019370Spst            break;
26119370Spst
26219370Spst        case 'a':
26319370Spst
26419370Spst            Gbl_DoCompile = FALSE;
26519370Spst            Gbl_DisassembleAll = TRUE;
26619370Spst            break;
26719370Spst
26819370Spst        case 'b':   /* Do not convert buffers to resource descriptors */
26919370Spst
27019370Spst            AcpiGbl_NoResourceDisassembly = TRUE;
27119370Spst            break;
27219370Spst
27319370Spst        case 'c':
27419370Spst
27519370Spst            break;
27619370Spst
27719370Spst        case 'f':
27819370Spst
27919370Spst            AcpiGbl_ForceAmlDisassembly = TRUE;
28019370Spst            break;
28119370Spst
28219370Spst        case 'l':   /* Use legacy ASL code (not ASL+) for disassembly */
28319370Spst
28419370Spst            Gbl_DoCompile = FALSE;
28519370Spst            AcpiGbl_CstyleDisassembly = FALSE;
28619370Spst            break;
28719370Spst
28819370Spst        default:
28919370Spst
29019370Spst            printf ("Unknown option: -d%s\n", AcpiGbl_Optarg);
29119370Spst            return (-1);
29219370Spst        }
29319370Spst
29419370Spst        Gbl_DisasmFlag = TRUE;
29519370Spst        break;
29619370Spst
29719370Spst    case 'D':   /* Define a symbol */
29819370Spst
29919370Spst        PrAddDefine (AcpiGbl_Optarg, NULL, TRUE);
30019370Spst        break;
30119370Spst
30219370Spst    case 'e':   /* External files for disassembler */
30319370Spst
30419370Spst        /* Get entire list of external files */
30519370Spst
30619370Spst        AcpiGbl_Optind--;
30719370Spst        argv[AcpiGbl_Optind] = AcpiGbl_Optarg;
30819370Spst
30919370Spst        while (argv[AcpiGbl_Optind] &&
31019370Spst              (argv[AcpiGbl_Optind][0] != '-'))
31119370Spst        {
31219370Spst            Status = AcpiDmAddToExternalFileList (argv[AcpiGbl_Optind]);
31319370Spst            if (ACPI_FAILURE (Status))
31419370Spst            {
31519370Spst                printf ("Could not add %s to external list\n", argv[AcpiGbl_Optind]);
31619370Spst                return (-1);
31719370Spst            }
31819370Spst
31919370Spst            AcpiGbl_Optind++;
32019370Spst        }
32119370Spst        break;
32219370Spst
32319370Spst    case 'f':
32419370Spst
32519370Spst        switch (AcpiGbl_Optarg[0])
32619370Spst        {
32719370Spst        case '^':   /* Ignore errors and force creation of aml file */
32819370Spst
32919370Spst            Gbl_IgnoreErrors = TRUE;
33019370Spst            break;
33119370Spst
33219370Spst        case 'e':   /* Disassembler: Get external declaration file */
33319370Spst
33419370Spst            if (AcpiGetoptArgument (argc, argv))
33519370Spst            {
33619370Spst                return (-1);
33719370Spst            }
33819370Spst
33919370Spst            Gbl_ExternalRefFilename = AcpiGbl_Optarg;
34019370Spst            break;
34119370Spst
34219370Spst        default:
34319370Spst
34419370Spst            printf ("Unknown option: -f%s\n", AcpiGbl_Optarg);
34519370Spst            return (-1);
34619370Spst        }
34719370Spst        break;
34819370Spst
34919370Spst    case 'G':
35019370Spst
35119370Spst        Gbl_CompileGeneric = TRUE;
35219370Spst        break;
35319370Spst
35419370Spst    case 'g':   /* Get all ACPI tables */
35519370Spst
35619370Spst        printf ("-g option is deprecated, use acpidump utility instead\n");
35719370Spst        exit (1);
35819370Spst
35919370Spst    case 'h':
36019370Spst
36119370Spst        switch (AcpiGbl_Optarg[0])
36219370Spst        {
36319370Spst        case '^':
36419370Spst
36519370Spst            Usage ();
36619370Spst            exit (0);
36719370Spst
36819370Spst        case 'c':
36919370Spst
37019370Spst            UtDisplayConstantOpcodes ();
37119370Spst            exit (0);
37219370Spst
37319370Spst        case 'f':
37419370Spst
37519370Spst            AslFilenameHelp ();
37619370Spst            exit (0);
37719370Spst
37819370Spst        case 'r':
37919370Spst
38019370Spst            /* reserved names */
38119370Spst
38219370Spst            ApDisplayReservedNames ();
38319370Spst            exit (0);
38419370Spst
38519370Spst        case 't':
38619370Spst
38719370Spst            UtDisplaySupportedTables ();
38819370Spst            exit (0);
38919370Spst
39019370Spst        default:
39119370Spst
39219370Spst            printf ("Unknown option: -h%s\n", AcpiGbl_Optarg);
39319370Spst            return (-1);
39419370Spst        }
39519370Spst
39619370Spst    case 'I':   /* Add an include file search directory */
39719370Spst
39819370Spst        FlAddIncludeDirectory (AcpiGbl_Optarg);
39919370Spst        break;
40019370Spst
40119370Spst    case 'i':   /* Output AML as an include file */
40219370Spst
40319370Spst        switch (AcpiGbl_Optarg[0])
40419370Spst        {
40519370Spst        case 'a':
40619370Spst
40719370Spst            /* Produce assembly code include file */
40819370Spst
40919370Spst            Gbl_AsmIncludeOutputFlag = TRUE;
41019370Spst            break;
41119370Spst
41219370Spst        case 'c':
41319370Spst
41419370Spst            /* Produce C include file */
41519370Spst
41619370Spst            Gbl_C_IncludeOutputFlag = TRUE;
41719370Spst            break;
41819370Spst
41919370Spst        case 'n':
42019370Spst
42119370Spst            /* Compiler/Disassembler: Ignore the NOOP operator */
42219370Spst
42319370Spst            AcpiGbl_IgnoreNoopOperator = TRUE;
42419370Spst            break;
42519370Spst
42619370Spst        default:
42719370Spst
42819370Spst            printf ("Unknown option: -i%s\n", AcpiGbl_Optarg);
42919370Spst            return (-1);
43019370Spst        }
43119370Spst        break;
43219370Spst
43319370Spst    case 'l':   /* Listing files */
43419370Spst
43519370Spst        switch (AcpiGbl_Optarg[0])
43619370Spst        {
43719370Spst        case '^':
43819370Spst
43919370Spst            /* Produce listing file (Mixed source/aml) */
44019370Spst
44119370Spst            Gbl_ListingFlag = TRUE;
44219370Spst            break;
44319370Spst
44419370Spst        case 'i':
44519370Spst
44619370Spst            /* Produce preprocessor output file */
44719370Spst
44819370Spst            Gbl_PreprocessorOutputFlag = TRUE;
44919370Spst            break;
45019370Spst
45119370Spst        case 'm':
45219370Spst
45319370Spst            /* Produce hardware map summary file */
45419370Spst
45519370Spst            Gbl_MapfileFlag = TRUE;
45619370Spst            break;
45719370Spst
45819370Spst        case 'n':
45919370Spst
46019370Spst            /* Produce namespace file */
46119370Spst
46219370Spst            Gbl_NsOutputFlag = TRUE;
46319370Spst            break;
46419370Spst
46519370Spst        case 's':
46619370Spst
46719370Spst            /* Produce combined source file */
46819370Spst
46919370Spst            Gbl_SourceOutputFlag = TRUE;
47019370Spst            break;
47119370Spst
47219370Spst        default:
47319370Spst
47419370Spst            printf ("Unknown option: -l%s\n", AcpiGbl_Optarg);
47519370Spst            return (-1);
47619370Spst        }
47719370Spst        break;
47819370Spst
47919370Spst    case 'm':   /* Set line buffer size */
48019370Spst
48119370Spst        Gbl_LineBufferSize = (UINT32) strtoul (AcpiGbl_Optarg, NULL, 0) * 1024;
48219370Spst        if (Gbl_LineBufferSize < ASL_DEFAULT_LINE_BUFFER_SIZE)
48319370Spst        {
48419370Spst            Gbl_LineBufferSize = ASL_DEFAULT_LINE_BUFFER_SIZE;
48519370Spst        }
48619370Spst        printf ("Line Buffer Size: %u\n", Gbl_LineBufferSize);
48719370Spst        break;
48819370Spst
48919370Spst    case 'n':   /* Parse only */
49019370Spst
49119370Spst        Gbl_ParseOnlyFlag = TRUE;
49219370Spst        break;
49319370Spst
49419370Spst    case 'o':   /* Control compiler AML optimizations */
49519370Spst
49619370Spst        switch (AcpiGbl_Optarg[0])
49719370Spst        {
49819370Spst        case 'a':
49919370Spst
50019370Spst            /* Disable all optimizations */
50119370Spst
50219370Spst            Gbl_FoldConstants = FALSE;
50319370Spst            Gbl_IntegerOptimizationFlag = FALSE;
50419370Spst            Gbl_ReferenceOptimizationFlag = FALSE;
50519370Spst            break;
50619370Spst
50719370Spst        case 'f':
50819370Spst
50919370Spst            /* Disable folding on "normal" expressions */
51019370Spst
51119370Spst            Gbl_FoldConstants = FALSE;
51219370Spst            break;
51319370Spst
51419370Spst        case 'i':
51519370Spst
51619370Spst            /* Disable integer optimization to constants */
51719370Spst
51819370Spst            Gbl_IntegerOptimizationFlag = FALSE;
51919370Spst            break;
52019370Spst
52119370Spst        case 'n':
52219370Spst
52319370Spst            /* Disable named reference optimization */
52419370Spst
52519370Spst            Gbl_ReferenceOptimizationFlag = FALSE;
52619370Spst            break;
52719370Spst
52819370Spst        case 't':
52919370Spst
53019370Spst            /* Display compile time(s) */
53119370Spst
53219370Spst            Gbl_CompileTimesFlag = TRUE;
53319370Spst            break;
53419370Spst
53519370Spst        default:
53619370Spst
53719370Spst            printf ("Unknown option: -c%s\n", AcpiGbl_Optarg);
53819370Spst            return (-1);
53919370Spst        }
54019370Spst        break;
54119370Spst
54219370Spst    case 'P':   /* Preprocessor options */
54319370Spst
54419370Spst        switch (AcpiGbl_Optarg[0])
54519370Spst        {
54619370Spst        case '^':   /* Proprocess only, emit (.i) file */
54719370Spst
54819370Spst            Gbl_PreprocessOnly = TRUE;
54919370Spst            Gbl_PreprocessorOutputFlag = TRUE;
55019370Spst            break;
55119370Spst
55219370Spst        case 'n':   /* Disable preprocessor */
55319370Spst
55419370Spst            Gbl_PreprocessFlag = FALSE;
55519370Spst            break;
55619370Spst
55719370Spst        default:
55819370Spst
55919370Spst            printf ("Unknown option: -P%s\n", AcpiGbl_Optarg);
56019370Spst            return (-1);
56119370Spst        }
56219370Spst        break;
56319370Spst
56419370Spst    case 'p':   /* Override default AML output filename */
56519370Spst
56619370Spst        Gbl_OutputFilenamePrefix = AcpiGbl_Optarg;
56719370Spst        UtConvertBackslashes (Gbl_OutputFilenamePrefix);
56819370Spst        Gbl_UseDefaultAmlFilename = FALSE;
56919370Spst        break;
57019370Spst
57119370Spst    case 'r':   /* Override revision found in table header */
57219370Spst
57319370Spst        Gbl_RevisionOverride = (UINT8) strtoul (AcpiGbl_Optarg, NULL, 0);
57419370Spst        break;
57519370Spst
57619370Spst    case 's':   /* Create AML in a source code file */
57719370Spst
57819370Spst        switch (AcpiGbl_Optarg[0])
57919370Spst        {
58019370Spst        case 'a':
58119370Spst
58219370Spst            /* Produce assembly code output file */
58319370Spst
58419370Spst            Gbl_AsmOutputFlag = TRUE;
58519370Spst            break;
58619370Spst
58719370Spst        case 'c':
58819370Spst
58919370Spst            /* Produce C hex output file */
59019370Spst
59119370Spst            Gbl_C_OutputFlag = TRUE;
59219370Spst            break;
59319370Spst
59419370Spst        case 'o':
59519370Spst
59619370Spst            /* Produce AML offset table in C */
59719370Spst
59819370Spst            Gbl_C_OffsetTableFlag = TRUE;
59919370Spst            break;
60019370Spst
60119370Spst        default:
60219370Spst
60319370Spst            printf ("Unknown option: -s%s\n", AcpiGbl_Optarg);
60419370Spst            return (-1);
60519370Spst        }
60619370Spst        break;
60719370Spst
60819370Spst    case 't':   /* Produce hex table output file */
60919370Spst
61019370Spst        switch (AcpiGbl_Optarg[0])
61119370Spst        {
61219370Spst        case 'a':
61319370Spst
61419370Spst            Gbl_HexOutputFlag = HEX_OUTPUT_ASM;
61519370Spst            break;
61619370Spst
61719370Spst        case 'c':
61819370Spst
61919370Spst            Gbl_HexOutputFlag = HEX_OUTPUT_C;
62019370Spst            break;
62119370Spst
62219370Spst        case 's':
62319370Spst
62419370Spst            Gbl_HexOutputFlag = HEX_OUTPUT_ASL;
62519370Spst            break;
62619370Spst
62719370Spst        default:
62819370Spst
62919370Spst            printf ("Unknown option: -t%s\n", AcpiGbl_Optarg);
63019370Spst            return (-1);
63119370Spst        }
63219370Spst        break;
63319370Spst
63419370Spst    case 'T':   /* Create a ACPI table template file */
63519370Spst
63619370Spst        Gbl_DoTemplates = TRUE;
63719370Spst        Gbl_TemplateSignature = AcpiGbl_Optarg;
63819370Spst        break;
63919370Spst
64019370Spst    case 'v':   /* Version and verbosity settings */
64119370Spst
64219370Spst        switch (AcpiGbl_Optarg[0])
64319370Spst        {
64419370Spst        case '^':
64519370Spst
64619370Spst            printf (ACPI_COMMON_SIGNON (ASL_COMPILER_NAME));
64719370Spst            exit (0);
64819370Spst
64919370Spst        case 'a':
65019370Spst
65119370Spst            /* Disable all error/warning/remark messages */
65219370Spst
65319370Spst            Gbl_NoErrors = TRUE;
65419370Spst            break;
65519370Spst
65619370Spst        case 'e':
65719370Spst
65819370Spst            /* Disable all warning/remark messages (errors only) */
65919370Spst
66019370Spst            Gbl_DisplayRemarks = FALSE;
66119370Spst            Gbl_DisplayWarnings = FALSE;
66219370Spst            break;
66319370Spst
66419370Spst        case 'i':
66519370Spst            /*
66619370Spst             * Support for integrated development environment(s).
66719370Spst             *
66819370Spst             * 1) No compiler signon
66919370Spst             * 2) Send stderr messages to stdout
67019370Spst             * 3) Less verbose error messages (single line only for each)
67119370Spst             * 4) Error/warning messages are formatted appropriately to
67219370Spst             *    be recognized by MS Visual Studio
67319370Spst             */
67419370Spst            Gbl_VerboseErrors = FALSE;
67519370Spst            Gbl_DoSignon = FALSE;
67619370Spst            Gbl_Files[ASL_FILE_STDERR].Handle = stdout;
67719370Spst            break;
67819370Spst
67919370Spst        case 'o':
68019370Spst
68119370Spst            Gbl_DisplayOptimizations = TRUE;
68219370Spst            break;
68319370Spst
68419370Spst        case 'r':
68519370Spst
68619370Spst            Gbl_DisplayRemarks = FALSE;
68719370Spst            break;
68819370Spst
68919370Spst        case 's':
69019370Spst
69119370Spst            Gbl_DoSignon = FALSE;
69219370Spst            break;
69319370Spst
69419370Spst        case 't':
69519370Spst
69619370Spst            Gbl_VerboseTemplates = TRUE;
69719370Spst            break;
69819370Spst
69919370Spst        case 'w':
70019370Spst
70119370Spst            /* Get the required argument */
70219370Spst
70319370Spst            if (AcpiGetoptArgument (argc, argv))
70419370Spst            {
70519370Spst                return (-1);
70619370Spst            }
70719370Spst
70819370Spst            Status = AslDisableException (AcpiGbl_Optarg);
70919370Spst            if (ACPI_FAILURE (Status))
71019370Spst            {
71119370Spst                return (-1);
71219370Spst            }
71319370Spst            break;
71419370Spst
71519370Spst        default:
71619370Spst
71719370Spst            printf ("Unknown option: -v%s\n", AcpiGbl_Optarg);
71819370Spst            return (-1);
71919370Spst        }
72019370Spst        break;
72119370Spst
72219370Spst    case 'w': /* Set warning levels */
72319370Spst
72419370Spst        switch (AcpiGbl_Optarg[0])
72519370Spst        {
72619370Spst        case '1':
72719370Spst
72819370Spst            Gbl_WarningLevel = ASL_WARNING;
72919370Spst            break;
73019370Spst
73119370Spst        case '2':
73219370Spst
73319370Spst            Gbl_WarningLevel = ASL_WARNING2;
73419370Spst            break;
73519370Spst
73619370Spst        case '3':
73719370Spst
73819370Spst            Gbl_WarningLevel = ASL_WARNING3;
73919370Spst            break;
74019370Spst
74119370Spst        case 'e':
74219370Spst
74319370Spst            Gbl_WarningsAsErrors = TRUE;
74419370Spst            break;
74519370Spst
74619370Spst        default:
74719370Spst
74819370Spst            printf ("Unknown option: -w%s\n", AcpiGbl_Optarg);
74919370Spst            return (-1);
75019370Spst        }
75119370Spst        break;
75219370Spst
75319370Spst    case 'x':   /* Set debug print output level */
75419370Spst
75519370Spst        AcpiDbgLevel = strtoul (AcpiGbl_Optarg, NULL, 16);
75619370Spst        break;
75719370Spst
75819370Spst    case 'z':
75919370Spst
76019370Spst        Gbl_UseOriginalCompilerId = TRUE;
76119370Spst        break;
76219370Spst
76319370Spst    default:
76419370Spst
76519370Spst        return (-1);
76619370Spst    }
76719370Spst
76819370Spst    return (0);
76919370Spst}
77019370Spst
77119370Spst
77219370Spst/*******************************************************************************
77319370Spst *
77419370Spst * FUNCTION:    AslMergeOptionTokens
77519370Spst *
77619370Spst * PARAMETERS:  InBuffer            - Input containing an option string
77719370Spst *              OutBuffer           - Merged output buffer
77819370Spst *
77919370Spst * RETURN:      None
78019370Spst *
78119370Spst * DESCRIPTION: Remove all whitespace from an option string.
78219370Spst *
78319370Spst ******************************************************************************/
78419370Spst
78519370Spststatic void
78619370SpstAslMergeOptionTokens (
78719370Spst    char                    *InBuffer,
78819370Spst    char                    *OutBuffer)
78919370Spst{
79019370Spst    char                    *Token;
79119370Spst
79219370Spst
79319370Spst    *OutBuffer = 0;
79419370Spst
79519370Spst    Token = strtok (InBuffer, ASL_TOKEN_SEPARATORS);
79619370Spst    while (Token)
79719370Spst    {
79819370Spst        strcat (OutBuffer, Token);
79919370Spst        Token = strtok (NULL, ASL_TOKEN_SEPARATORS);
80019370Spst    }
80119370Spst}
80219370Spst
80319370Spst
80419370Spst/*******************************************************************************
80519370Spst *
80619370Spst * FUNCTION:    AslDoResponseFile
80719370Spst *
80819370Spst * PARAMETERS:  Filename        - Name of the response file
80919370Spst *
81019370Spst * RETURN:      Status
81119370Spst *
81219370Spst * DESCRIPTION: Open a response file and process all options within.
81319370Spst *
81419370Spst ******************************************************************************/
81519370Spst
81619370Spststatic int
81719370SpstAslDoResponseFile (
81819370Spst    char                    *Filename)
81919370Spst{
82019370Spst    char                    *argv = StringBuffer2;
82119370Spst    FILE                    *ResponseFile;
82219370Spst    int                     OptStatus = 0;
82319370Spst    int                     Opterr;
82419370Spst    int                     Optind;
82519370Spst
82619370Spst
82719370Spst    ResponseFile = fopen (Filename, "r");
82819370Spst    if (!ResponseFile)
82919370Spst    {
83019370Spst        printf ("Could not open command file %s, %s\n",
83119370Spst            Filename, strerror (errno));
83219370Spst        return (-1);
83319370Spst    }
83419370Spst
83519370Spst    /* Must save the current GetOpt globals */
83619370Spst
83719370Spst    Opterr = AcpiGbl_Opterr;
83819370Spst    Optind = AcpiGbl_Optind;
83919370Spst
84019370Spst    /*
84119370Spst     * Process all lines in the response file. There must be one complete
84219370Spst     * option per line
84319370Spst     */
84419370Spst    while (fgets (StringBuffer, ASL_MSG_BUFFER_SIZE, ResponseFile))
84519370Spst    {
84619370Spst        /* Compress all tokens, allowing us to use a single argv entry */
84719370Spst
84819370Spst        AslMergeOptionTokens (StringBuffer, StringBuffer2);
84919370Spst
85019370Spst        /* Process the option */
85119370Spst
85219370Spst        AcpiGbl_Opterr = 0;
85319370Spst        AcpiGbl_Optind = 0;
85419370Spst
85519370Spst        OptStatus = AslDoOptions (1, &argv, TRUE);
85619370Spst        if (OptStatus)
85719370Spst        {
85819370Spst            printf ("Invalid option in command file %s: %s\n",
85919370Spst                Filename, StringBuffer);
86019370Spst            break;
86119370Spst        }
86219370Spst    }
86319370Spst
86419370Spst    /* Restore the GetOpt globals */
86519370Spst
86619370Spst    AcpiGbl_Opterr = Opterr;
86719370Spst    AcpiGbl_Optind = Optind;
86819370Spst
86919370Spst    fclose (ResponseFile);
87019370Spst    return (OptStatus);
87119370Spst}
87219370Spst