asloptions.c revision 199767f8919635c4928607450d9e0abb932109ce
/******************************************************************************
*
* Module Name: asloptions - compiler command line processing
*
*****************************************************************************/
/*
* Copyright (C) 2000 - 2015, Intel Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* Alternatively, this software may be distributed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
* NO WARRANTY
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES.
*/
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("asloption")
/* Local prototypes */
static int
int argc,
char **argv,
static void
char *InBuffer,
char *OutBuffer);
static int
char *Filename);
#define ASL_TOKEN_SEPARATORS " \t\n"
#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"
/*******************************************************************************
*
* FUNCTION: AslCommandLine
*
*
* RETURN: Last argv index
*
* DESCRIPTION: Command line processing
*
******************************************************************************/
int
int argc,
char **argv)
{
int BadCommandLine = 0;
/* Minimum command line contains at least the command and an input file */
if (argc < 2)
{
Usage ();
exit (1);
}
/* Process all command line options */
if (Gbl_DoTemplates)
{
if (ACPI_FAILURE (Status))
{
exit (-1);
}
exit (1);
}
/* Next parameter must be the input filename */
if (!argv[AcpiGbl_Optind] &&
{
printf ("Missing input filename\n");
}
if (Gbl_DoSignon)
{
if (Gbl_IgnoreErrors)
{
printf ("Ignoring all errors, forcing AML file generation\n\n");
}
}
if (BadCommandLine)
{
printf ("Use -h option for help information\n");
exit (1);
}
return (AcpiGbl_Optind);
}
/*******************************************************************************
*
* FUNCTION: AslDoOptions
*
* IsResponseFile - TRUE if executing a response file.
*
* RETURN: Status
*
* DESCRIPTION: Command line option processing
*
******************************************************************************/
static int
int argc,
char **argv,
{
UINT32 j;
/* Get the command line options */
{
case '@': /* Begin a response file */
if (IsResponseFile)
{
printf ("Nested command files are not supported\n");
return (-1);
}
if (AslDoResponseFile (AcpiGbl_Optarg))
{
return (-1);
}
break;
case 'b': /* Debug options */
switch (AcpiGbl_Optarg[0])
{
case 'f':
DtParserdebug = 1;
PrParserdebug = 1;
break;
case 'p': /* Prune ASL parse tree */
/* Get the required argument */
{
return (-1);
}
break;
case 's':
break;
case 't':
/* Get the required argument */
{
return (-1);
}
break;
default:
return (-1);
}
break;
case 'c':
switch (AcpiGbl_Optarg[0])
{
case 'r':
break;
default:
return (-1);
}
break;
case 'd': /* Disassembler */
switch (AcpiGbl_Optarg[0])
{
case '^':
break;
case 'a':
break;
case 'b': /* Do not convert buffers to resource descriptors */
break;
case 'c':
break;
case 'f':
break;
case 'l': /* Use legacy ASL code (not ASL+) for disassembly */
break;
default:
return (-1);
}
break;
case 'D': /* Define a symbol */
break;
case 'e': /* External files for disassembler */
/* Get entire list of external files */
while (argv[AcpiGbl_Optind] &&
{
if (ACPI_FAILURE (Status))
{
return (-1);
}
}
break;
case 'f':
switch (AcpiGbl_Optarg[0])
{
case '^': /* Ignore errors and force creation of aml file */
break;
case 'e': /* Disassembler: Get external declaration file */
{
return (-1);
}
break;
default:
return (-1);
}
break;
case 'G':
break;
case 'g': /* Get all ACPI tables */
printf ("-g option is deprecated, use acpidump utility instead\n");
exit (1);
case 'h':
switch (AcpiGbl_Optarg[0])
{
case '^':
Usage ();
exit (0);
case 'c':
exit (0);
case 'f':
AslFilenameHelp ();
exit (0);
case 'r':
/* reserved names */
exit (0);
case 't':
exit (0);
default:
return (-1);
}
case 'I': /* Add an include file search directory */
break;
case 'i': /* Output AML as an include file */
switch (AcpiGbl_Optarg[0])
{
case 'a':
/* Produce assembly code include file */
break;
case 'c':
/* Produce C include file */
break;
case 'n':
/* Compiler/Disassembler: Ignore the NOOP operator */
break;
default:
return (-1);
}
break;
case 'l': /* Listing files */
switch (AcpiGbl_Optarg[0])
{
case '^':
break;
case 'i':
/* Produce preprocessor output file */
break;
case 'm':
/* Produce hardware map summary file */
break;
case 'n':
/* Produce namespace file */
break;
case 's':
/* Produce combined source file */
break;
default:
return (-1);
}
break;
case 'm': /* Set line buffer size */
{
}
break;
case 'n': /* Parse only */
break;
case 'o': /* Control compiler AML optimizations */
switch (AcpiGbl_Optarg[0])
{
case 'a':
/* Disable all optimizations */
break;
case 'f':
/* Disable folding on "normal" expressions */
break;
case 'i':
/* Disable integer optimization to constants */
break;
case 'n':
/* Disable named reference optimization */
break;
case 't':
/* Display compile time(s) */
break;
default:
return (-1);
}
break;
case 'P': /* Preprocessor options */
switch (AcpiGbl_Optarg[0])
{
case '^': /* Proprocess only, emit (.i) file */
break;
case 'n': /* Disable preprocessor */
break;
default:
return (-1);
}
break;
case 'p': /* Override default AML output filename */
break;
case 'r': /* Override revision found in table header */
break;
case 's': /* Create AML in a source code file */
switch (AcpiGbl_Optarg[0])
{
case 'a':
/* Produce assembly code output file */
break;
case 'c':
/* Produce C hex output file */
break;
case 'o':
/* Produce AML offset table in C */
break;
default:
return (-1);
}
break;
case 't': /* Produce hex table output file */
switch (AcpiGbl_Optarg[0])
{
case 'a':
break;
case 'c':
break;
case 's':
break;
default:
return (-1);
}
break;
case 'T': /* Create a ACPI table template file */
break;
case 'v': /* Version and verbosity settings */
switch (AcpiGbl_Optarg[0])
{
case '^':
exit (0);
case 'a':
Gbl_NoErrors = TRUE;
break;
case 'e':
break;
case 'i':
/*
* Support for integrated development environment(s).
*
* 1) No compiler signon
* 2) Send stderr messages to stdout
* 3) Less verbose error messages (single line only for each)
* be recognized by MS Visual Studio
*/
break;
case 'o':
break;
case 'r':
break;
case 's':
break;
case 't':
break;
case 'w':
/* Get the required argument */
{
return (-1);
}
if (ACPI_FAILURE (Status))
{
return (-1);
}
break;
default:
return (-1);
}
break;
case 'w': /* Set warning levels */
switch (AcpiGbl_Optarg[0])
{
case '1':
break;
case '2':
break;
case '3':
break;
case 'e':
break;
default:
return (-1);
}
break;
case 'x': /* Set debug print output level */
break;
case 'z':
break;
default:
return (-1);
}
return (0);
}
/*******************************************************************************
*
* FUNCTION: AslMergeOptionTokens
*
* PARAMETERS: InBuffer - Input containing an option string
* OutBuffer - Merged output buffer
*
* RETURN: None
*
* DESCRIPTION: Remove all whitespace from an option string.
*
******************************************************************************/
static void
char *InBuffer,
char *OutBuffer)
{
char *Token;
*OutBuffer = 0;
while (Token)
{
}
}
/*******************************************************************************
*
* FUNCTION: AslDoResponseFile
*
* PARAMETERS: Filename - Name of the response file
*
* RETURN: Status
*
* DESCRIPTION: Open a response file and process all options within.
*
******************************************************************************/
static int
char *Filename)
{
char *argv = StringBuffer2;
int OptStatus = 0;
int Opterr;
int Optind;
if (!ResponseFile)
{
printf ("Could not open command file %s, %s\n",
return (-1);
}
/* Must save the current GetOpt globals */
/*
* Process all lines in the response file. There must be one complete
* option per line
*/
{
/* Compress all tokens, allowing us to use a single argv entry */
/* Process the option */
AcpiGbl_Opterr = 0;
AcpiGbl_Optind = 0;
if (OptStatus)
{
printf ("Invalid option in command file %s: %s\n",
break;
}
}
/* Restore the GetOpt globals */
return (OptStatus);
}