1a9d8d09cSJung-uk Kim /****************************************************************************** 2a9d8d09cSJung-uk Kim * 3a9d8d09cSJung-uk Kim * Module Name: asloptions - compiler command line processing 4a9d8d09cSJung-uk Kim * 5a9d8d09cSJung-uk Kim *****************************************************************************/ 6a9d8d09cSJung-uk Kim 7a9d8d09cSJung-uk Kim /* 8f8146b88SJung-uk Kim * Copyright (C) 2000 - 2016, Intel Corp. 9a9d8d09cSJung-uk Kim * All rights reserved. 10a9d8d09cSJung-uk Kim * 11a9d8d09cSJung-uk Kim * Redistribution and use in source and binary forms, with or without 12a9d8d09cSJung-uk Kim * modification, are permitted provided that the following conditions 13a9d8d09cSJung-uk Kim * are met: 14a9d8d09cSJung-uk Kim * 1. Redistributions of source code must retain the above copyright 15a9d8d09cSJung-uk Kim * notice, this list of conditions, and the following disclaimer, 16a9d8d09cSJung-uk Kim * without modification. 17a9d8d09cSJung-uk Kim * 2. Redistributions in binary form must reproduce at minimum a disclaimer 18a9d8d09cSJung-uk Kim * substantially similar to the "NO WARRANTY" disclaimer below 19a9d8d09cSJung-uk Kim * ("Disclaimer") and any redistribution must be conditioned upon 20a9d8d09cSJung-uk Kim * including a substantially similar Disclaimer requirement for further 21a9d8d09cSJung-uk Kim * binary redistribution. 22a9d8d09cSJung-uk Kim * 3. Neither the names of the above-listed copyright holders nor the names 23a9d8d09cSJung-uk Kim * of any contributors may be used to endorse or promote products derived 24a9d8d09cSJung-uk Kim * from this software without specific prior written permission. 25a9d8d09cSJung-uk Kim * 26a9d8d09cSJung-uk Kim * Alternatively, this software may be distributed under the terms of the 27a9d8d09cSJung-uk Kim * GNU General Public License ("GPL") version 2 as published by the Free 28a9d8d09cSJung-uk Kim * Software Foundation. 29a9d8d09cSJung-uk Kim * 30a9d8d09cSJung-uk Kim * NO WARRANTY 31a9d8d09cSJung-uk Kim * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 32a9d8d09cSJung-uk Kim * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 33a9d8d09cSJung-uk Kim * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 34a9d8d09cSJung-uk Kim * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 35a9d8d09cSJung-uk Kim * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 36a9d8d09cSJung-uk Kim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 37a9d8d09cSJung-uk Kim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 38a9d8d09cSJung-uk Kim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 39a9d8d09cSJung-uk Kim * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 40a9d8d09cSJung-uk Kim * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 41a9d8d09cSJung-uk Kim * POSSIBILITY OF SUCH DAMAGES. 42a9d8d09cSJung-uk Kim */ 43a9d8d09cSJung-uk Kim 44a9d8d09cSJung-uk Kim #include <contrib/dev/acpica/compiler/aslcompiler.h> 45a9d8d09cSJung-uk Kim #include <contrib/dev/acpica/include/acapps.h> 46a9d8d09cSJung-uk Kim #include <contrib/dev/acpica/include/acdisasm.h> 47a9d8d09cSJung-uk Kim 48a9d8d09cSJung-uk Kim #define _COMPONENT ACPI_COMPILER 49a9d8d09cSJung-uk Kim ACPI_MODULE_NAME ("asloption") 50a9d8d09cSJung-uk Kim 51a9d8d09cSJung-uk Kim 52a9d8d09cSJung-uk Kim /* Local prototypes */ 53a9d8d09cSJung-uk Kim 54a9d8d09cSJung-uk Kim static int 55a9d8d09cSJung-uk Kim AslDoOptions ( 56a9d8d09cSJung-uk Kim int argc, 57a9d8d09cSJung-uk Kim char **argv, 58a9d8d09cSJung-uk Kim BOOLEAN IsResponseFile); 59a9d8d09cSJung-uk Kim 60a9d8d09cSJung-uk Kim static void 61a9d8d09cSJung-uk Kim AslMergeOptionTokens ( 62a9d8d09cSJung-uk Kim char *InBuffer, 63a9d8d09cSJung-uk Kim char *OutBuffer); 64a9d8d09cSJung-uk Kim 65a9d8d09cSJung-uk Kim static int 66a9d8d09cSJung-uk Kim AslDoResponseFile ( 67a9d8d09cSJung-uk Kim char *Filename); 68a9d8d09cSJung-uk Kim 69a9d8d09cSJung-uk Kim 70a9d8d09cSJung-uk Kim #define ASL_TOKEN_SEPARATORS " \t\n" 71f8146b88SJung-uk Kim #define ASL_SUPPORTED_OPTIONS "@:a:b|c|d^D:e:f^gh^i|I:l^m:no|p:P^r:s|t|T+G^v^w|x:z" 72a9d8d09cSJung-uk Kim 73a9d8d09cSJung-uk Kim 74a9d8d09cSJung-uk Kim /******************************************************************************* 75a9d8d09cSJung-uk Kim * 76a9d8d09cSJung-uk Kim * FUNCTION: AslCommandLine 77a9d8d09cSJung-uk Kim * 78a9d8d09cSJung-uk Kim * PARAMETERS: argc/argv 79a9d8d09cSJung-uk Kim * 80a9d8d09cSJung-uk Kim * RETURN: Last argv index 81a9d8d09cSJung-uk Kim * 82a9d8d09cSJung-uk Kim * DESCRIPTION: Command line processing 83a9d8d09cSJung-uk Kim * 84a9d8d09cSJung-uk Kim ******************************************************************************/ 85a9d8d09cSJung-uk Kim 86a9d8d09cSJung-uk Kim int 87a9d8d09cSJung-uk Kim AslCommandLine ( 88a9d8d09cSJung-uk Kim int argc, 89a9d8d09cSJung-uk Kim char **argv) 90a9d8d09cSJung-uk Kim { 91a9d8d09cSJung-uk Kim int BadCommandLine = 0; 92a9d8d09cSJung-uk Kim ACPI_STATUS Status; 93a9d8d09cSJung-uk Kim 94a9d8d09cSJung-uk Kim 95a9d8d09cSJung-uk Kim /* Minimum command line contains at least the command and an input file */ 96a9d8d09cSJung-uk Kim 97a9d8d09cSJung-uk Kim if (argc < 2) 98a9d8d09cSJung-uk Kim { 99a9d8d09cSJung-uk Kim printf (ACPI_COMMON_SIGNON (ASL_COMPILER_NAME)); 100a9d8d09cSJung-uk Kim Usage (); 101a9d8d09cSJung-uk Kim exit (1); 102a9d8d09cSJung-uk Kim } 103a9d8d09cSJung-uk Kim 104a9d8d09cSJung-uk Kim /* Process all command line options */ 105a9d8d09cSJung-uk Kim 106a9d8d09cSJung-uk Kim BadCommandLine = AslDoOptions (argc, argv, FALSE); 107a9d8d09cSJung-uk Kim 108a9d8d09cSJung-uk Kim if (Gbl_DoTemplates) 109a9d8d09cSJung-uk Kim { 110f8146b88SJung-uk Kim Status = DtCreateTemplates (argv); 111a9d8d09cSJung-uk Kim if (ACPI_FAILURE (Status)) 112a9d8d09cSJung-uk Kim { 113a9d8d09cSJung-uk Kim exit (-1); 114a9d8d09cSJung-uk Kim } 115a9d8d09cSJung-uk Kim exit (1); 116a9d8d09cSJung-uk Kim } 117a9d8d09cSJung-uk Kim 118a9d8d09cSJung-uk Kim /* Next parameter must be the input filename */ 119a9d8d09cSJung-uk Kim 120a9d8d09cSJung-uk Kim if (!argv[AcpiGbl_Optind] && 121313a0c13SJung-uk Kim !Gbl_DisasmFlag) 122a9d8d09cSJung-uk Kim { 123a9d8d09cSJung-uk Kim printf ("Missing input filename\n"); 124a9d8d09cSJung-uk Kim BadCommandLine = TRUE; 125a9d8d09cSJung-uk Kim } 126a9d8d09cSJung-uk Kim 127a9d8d09cSJung-uk Kim if (Gbl_DoSignon) 128a9d8d09cSJung-uk Kim { 129a9d8d09cSJung-uk Kim printf (ACPI_COMMON_SIGNON (ASL_COMPILER_NAME)); 130a9d8d09cSJung-uk Kim if (Gbl_IgnoreErrors) 131a9d8d09cSJung-uk Kim { 132a9d8d09cSJung-uk Kim printf ("Ignoring all errors, forcing AML file generation\n\n"); 133a9d8d09cSJung-uk Kim } 134a9d8d09cSJung-uk Kim } 135a9d8d09cSJung-uk Kim 136a9d8d09cSJung-uk Kim if (BadCommandLine) 137a9d8d09cSJung-uk Kim { 13879c6d946SJung-uk Kim printf ("Use -h option for help information\n"); 139a9d8d09cSJung-uk Kim exit (1); 140a9d8d09cSJung-uk Kim } 141a9d8d09cSJung-uk Kim 142a9d8d09cSJung-uk Kim return (AcpiGbl_Optind); 143a9d8d09cSJung-uk Kim } 144a9d8d09cSJung-uk Kim 145a9d8d09cSJung-uk Kim 146a9d8d09cSJung-uk Kim /******************************************************************************* 147a9d8d09cSJung-uk Kim * 148a9d8d09cSJung-uk Kim * FUNCTION: AslDoOptions 149a9d8d09cSJung-uk Kim * 150a9d8d09cSJung-uk Kim * PARAMETERS: argc/argv - Standard argc/argv 151a9d8d09cSJung-uk Kim * IsResponseFile - TRUE if executing a response file. 152a9d8d09cSJung-uk Kim * 153a9d8d09cSJung-uk Kim * RETURN: Status 154a9d8d09cSJung-uk Kim * 155a9d8d09cSJung-uk Kim * DESCRIPTION: Command line option processing 156a9d8d09cSJung-uk Kim * 157a9d8d09cSJung-uk Kim ******************************************************************************/ 158a9d8d09cSJung-uk Kim 159a9d8d09cSJung-uk Kim static int 160a9d8d09cSJung-uk Kim AslDoOptions ( 161a9d8d09cSJung-uk Kim int argc, 162a9d8d09cSJung-uk Kim char **argv, 163a9d8d09cSJung-uk Kim BOOLEAN IsResponseFile) 164a9d8d09cSJung-uk Kim { 165a9d8d09cSJung-uk Kim ACPI_STATUS Status; 166a9d8d09cSJung-uk Kim UINT32 j; 167a9d8d09cSJung-uk Kim 168a9d8d09cSJung-uk Kim 169a9d8d09cSJung-uk Kim /* Get the command line options */ 170a9d8d09cSJung-uk Kim 171313a0c13SJung-uk Kim while ((j = AcpiGetopt (argc, argv, ASL_SUPPORTED_OPTIONS)) != ACPI_OPT_END) switch (j) 172a9d8d09cSJung-uk Kim { 173a9d8d09cSJung-uk Kim case '@': /* Begin a response file */ 174a9d8d09cSJung-uk Kim 175a9d8d09cSJung-uk Kim if (IsResponseFile) 176a9d8d09cSJung-uk Kim { 177a9d8d09cSJung-uk Kim printf ("Nested command files are not supported\n"); 178a9d8d09cSJung-uk Kim return (-1); 179a9d8d09cSJung-uk Kim } 180a9d8d09cSJung-uk Kim 181a9d8d09cSJung-uk Kim if (AslDoResponseFile (AcpiGbl_Optarg)) 182a9d8d09cSJung-uk Kim { 183a9d8d09cSJung-uk Kim return (-1); 184a9d8d09cSJung-uk Kim } 185a9d8d09cSJung-uk Kim break; 186a9d8d09cSJung-uk Kim 187f8146b88SJung-uk Kim case 'a': /* Debug options */ 188f8146b88SJung-uk Kim 189f8146b88SJung-uk Kim switch (AcpiGbl_Optarg[0]) 190f8146b88SJung-uk Kim { 191f8146b88SJung-uk Kim case 'r': 192f8146b88SJung-uk Kim 193f8146b88SJung-uk Kim Gbl_EnableReferenceTypechecking = TRUE; 194f8146b88SJung-uk Kim break; 195f8146b88SJung-uk Kim 196f8146b88SJung-uk Kim default: 197f8146b88SJung-uk Kim 198f8146b88SJung-uk Kim printf ("Unknown option: -a%s\n", AcpiGbl_Optarg); 199f8146b88SJung-uk Kim return (-1); 200f8146b88SJung-uk Kim } 201f8146b88SJung-uk Kim 202f8146b88SJung-uk Kim break; 203f8146b88SJung-uk Kim 204f8146b88SJung-uk Kim 2051c0e1b6dSJung-uk Kim case 'b': /* Debug options */ 206a9d8d09cSJung-uk Kim 207a9d8d09cSJung-uk Kim switch (AcpiGbl_Optarg[0]) 208a9d8d09cSJung-uk Kim { 209a9d8d09cSJung-uk Kim case 'f': 210a9d8d09cSJung-uk Kim 211a9d8d09cSJung-uk Kim AslCompilerdebug = 1; /* same as yydebug */ 212a9d8d09cSJung-uk Kim DtParserdebug = 1; 213a9d8d09cSJung-uk Kim PrParserdebug = 1; 2141c0e1b6dSJung-uk Kim Gbl_DebugFlag = TRUE; 2155ef50723SJung-uk Kim Gbl_KeepPreprocessorTempFile = TRUE; 2161c0e1b6dSJung-uk Kim break; 2171c0e1b6dSJung-uk Kim 2181c0e1b6dSJung-uk Kim case 'p': /* Prune ASL parse tree */ 2191c0e1b6dSJung-uk Kim 2201c0e1b6dSJung-uk Kim /* Get the required argument */ 2211c0e1b6dSJung-uk Kim 2221c0e1b6dSJung-uk Kim if (AcpiGetoptArgument (argc, argv)) 2231c0e1b6dSJung-uk Kim { 2241c0e1b6dSJung-uk Kim return (-1); 2251c0e1b6dSJung-uk Kim } 2261c0e1b6dSJung-uk Kim 2271c0e1b6dSJung-uk Kim Gbl_PruneParseTree = TRUE; 2281c0e1b6dSJung-uk Kim Gbl_PruneDepth = (UINT8) strtoul (AcpiGbl_Optarg, NULL, 0); 2291c0e1b6dSJung-uk Kim break; 2301c0e1b6dSJung-uk Kim 2311c0e1b6dSJung-uk Kim case 's': 2321c0e1b6dSJung-uk Kim 2331c0e1b6dSJung-uk Kim Gbl_DebugFlag = TRUE; 234a9d8d09cSJung-uk Kim break; 235a9d8d09cSJung-uk Kim 236a9d8d09cSJung-uk Kim case 't': 237a9d8d09cSJung-uk Kim 2381c0e1b6dSJung-uk Kim /* Get the required argument */ 2391c0e1b6dSJung-uk Kim 2401c0e1b6dSJung-uk Kim if (AcpiGetoptArgument (argc, argv)) 2411c0e1b6dSJung-uk Kim { 2421c0e1b6dSJung-uk Kim return (-1); 2431c0e1b6dSJung-uk Kim } 2441c0e1b6dSJung-uk Kim 2451c0e1b6dSJung-uk Kim Gbl_PruneType = (UINT8) strtoul (AcpiGbl_Optarg, NULL, 0); 246a9d8d09cSJung-uk Kim break; 247a9d8d09cSJung-uk Kim 248a9d8d09cSJung-uk Kim default: 249a9d8d09cSJung-uk Kim 250a9d8d09cSJung-uk Kim printf ("Unknown option: -b%s\n", AcpiGbl_Optarg); 251a9d8d09cSJung-uk Kim return (-1); 252a9d8d09cSJung-uk Kim } 253a9d8d09cSJung-uk Kim 254a9d8d09cSJung-uk Kim break; 255a9d8d09cSJung-uk Kim 256a9d8d09cSJung-uk Kim case 'c': 257a9d8d09cSJung-uk Kim 258a9d8d09cSJung-uk Kim switch (AcpiGbl_Optarg[0]) 259a9d8d09cSJung-uk Kim { 260a9d8d09cSJung-uk Kim case 'r': 261a9d8d09cSJung-uk Kim 262a9d8d09cSJung-uk Kim Gbl_NoResourceChecking = TRUE; 263a9d8d09cSJung-uk Kim break; 264a9d8d09cSJung-uk Kim 265a9d8d09cSJung-uk Kim default: 266a9d8d09cSJung-uk Kim 267a9d8d09cSJung-uk Kim printf ("Unknown option: -c%s\n", AcpiGbl_Optarg); 268a9d8d09cSJung-uk Kim return (-1); 269a9d8d09cSJung-uk Kim } 270a9d8d09cSJung-uk Kim break; 271a9d8d09cSJung-uk Kim 272a9d8d09cSJung-uk Kim case 'd': /* Disassembler */ 273a9d8d09cSJung-uk Kim 274a9d8d09cSJung-uk Kim switch (AcpiGbl_Optarg[0]) 275a9d8d09cSJung-uk Kim { 276a9d8d09cSJung-uk Kim case '^': 277a9d8d09cSJung-uk Kim 278a9d8d09cSJung-uk Kim Gbl_DoCompile = FALSE; 279a9d8d09cSJung-uk Kim break; 280a9d8d09cSJung-uk Kim 281a9d8d09cSJung-uk Kim case 'a': 282a9d8d09cSJung-uk Kim 283a9d8d09cSJung-uk Kim Gbl_DoCompile = FALSE; 284a9d8d09cSJung-uk Kim Gbl_DisassembleAll = TRUE; 285a9d8d09cSJung-uk Kim break; 286a9d8d09cSJung-uk Kim 287a9d8d09cSJung-uk Kim case 'b': /* Do not convert buffers to resource descriptors */ 288a9d8d09cSJung-uk Kim 289a9d8d09cSJung-uk Kim AcpiGbl_NoResourceDisassembly = TRUE; 290a9d8d09cSJung-uk Kim break; 291a9d8d09cSJung-uk Kim 292a9d8d09cSJung-uk Kim case 'c': 293a9d8d09cSJung-uk Kim 294a9d8d09cSJung-uk Kim break; 295a9d8d09cSJung-uk Kim 2967cf3e94aSJung-uk Kim case 'f': 2977cf3e94aSJung-uk Kim 2987cf3e94aSJung-uk Kim AcpiGbl_ForceAmlDisassembly = TRUE; 2997cf3e94aSJung-uk Kim break; 3007cf3e94aSJung-uk Kim 3011c0e1b6dSJung-uk Kim case 'l': /* Use legacy ASL code (not ASL+) for disassembly */ 3021c0e1b6dSJung-uk Kim 3031c0e1b6dSJung-uk Kim Gbl_DoCompile = FALSE; 3041c0e1b6dSJung-uk Kim AcpiGbl_CstyleDisassembly = FALSE; 3051c0e1b6dSJung-uk Kim break; 3061c0e1b6dSJung-uk Kim 307a9d8d09cSJung-uk Kim default: 308a9d8d09cSJung-uk Kim 309a9d8d09cSJung-uk Kim printf ("Unknown option: -d%s\n", AcpiGbl_Optarg); 310a9d8d09cSJung-uk Kim return (-1); 311a9d8d09cSJung-uk Kim } 312a9d8d09cSJung-uk Kim 313a9d8d09cSJung-uk Kim Gbl_DisasmFlag = TRUE; 314a9d8d09cSJung-uk Kim break; 315a9d8d09cSJung-uk Kim 316a9d8d09cSJung-uk Kim case 'D': /* Define a symbol */ 317a9d8d09cSJung-uk Kim 318a9d8d09cSJung-uk Kim PrAddDefine (AcpiGbl_Optarg, NULL, TRUE); 319a9d8d09cSJung-uk Kim break; 320a9d8d09cSJung-uk Kim 321a9d8d09cSJung-uk Kim case 'e': /* External files for disassembler */ 322a9d8d09cSJung-uk Kim 323313a0c13SJung-uk Kim /* Get entire list of external files */ 324313a0c13SJung-uk Kim 325313a0c13SJung-uk Kim AcpiGbl_Optind--; 326313a0c13SJung-uk Kim argv[AcpiGbl_Optind] = AcpiGbl_Optarg; 327313a0c13SJung-uk Kim 328313a0c13SJung-uk Kim while (argv[AcpiGbl_Optind] && 329313a0c13SJung-uk Kim (argv[AcpiGbl_Optind][0] != '-')) 330313a0c13SJung-uk Kim { 331313a0c13SJung-uk Kim Status = AcpiDmAddToExternalFileList (argv[AcpiGbl_Optind]); 332a9d8d09cSJung-uk Kim if (ACPI_FAILURE (Status)) 333a9d8d09cSJung-uk Kim { 334f8146b88SJung-uk Kim printf ("Could not add %s to external list\n", 335f8146b88SJung-uk Kim argv[AcpiGbl_Optind]); 336a9d8d09cSJung-uk Kim return (-1); 337a9d8d09cSJung-uk Kim } 338313a0c13SJung-uk Kim 339313a0c13SJung-uk Kim AcpiGbl_Optind++; 340313a0c13SJung-uk Kim } 341a9d8d09cSJung-uk Kim break; 342a9d8d09cSJung-uk Kim 34379c6d946SJung-uk Kim case 'f': 34479c6d946SJung-uk Kim 34579c6d946SJung-uk Kim switch (AcpiGbl_Optarg[0]) 34679c6d946SJung-uk Kim { 34779c6d946SJung-uk Kim case '^': /* Ignore errors and force creation of aml file */ 348a9d8d09cSJung-uk Kim 349a9d8d09cSJung-uk Kim Gbl_IgnoreErrors = TRUE; 350a9d8d09cSJung-uk Kim break; 351a9d8d09cSJung-uk Kim 35279c6d946SJung-uk Kim case 'e': /* Disassembler: Get external declaration file */ 35379c6d946SJung-uk Kim 35479c6d946SJung-uk Kim if (AcpiGetoptArgument (argc, argv)) 35579c6d946SJung-uk Kim { 35679c6d946SJung-uk Kim return (-1); 35779c6d946SJung-uk Kim } 35879c6d946SJung-uk Kim 35979c6d946SJung-uk Kim Gbl_ExternalRefFilename = AcpiGbl_Optarg; 36079c6d946SJung-uk Kim break; 36179c6d946SJung-uk Kim 36279c6d946SJung-uk Kim default: 36379c6d946SJung-uk Kim 36479c6d946SJung-uk Kim printf ("Unknown option: -f%s\n", AcpiGbl_Optarg); 36579c6d946SJung-uk Kim return (-1); 36679c6d946SJung-uk Kim } 36779c6d946SJung-uk Kim break; 36879c6d946SJung-uk Kim 369a9d8d09cSJung-uk Kim case 'G': 370a9d8d09cSJung-uk Kim 371a9d8d09cSJung-uk Kim Gbl_CompileGeneric = TRUE; 372a9d8d09cSJung-uk Kim break; 373a9d8d09cSJung-uk Kim 374a9d8d09cSJung-uk Kim case 'g': /* Get all ACPI tables */ 375a9d8d09cSJung-uk Kim 376313a0c13SJung-uk Kim printf ("-g option is deprecated, use acpidump utility instead\n"); 377313a0c13SJung-uk Kim exit (1); 378a9d8d09cSJung-uk Kim 379a9d8d09cSJung-uk Kim case 'h': 380a9d8d09cSJung-uk Kim 381a9d8d09cSJung-uk Kim switch (AcpiGbl_Optarg[0]) 382a9d8d09cSJung-uk Kim { 383a9d8d09cSJung-uk Kim case '^': 384a9d8d09cSJung-uk Kim 385a9d8d09cSJung-uk Kim Usage (); 386a9d8d09cSJung-uk Kim exit (0); 387a9d8d09cSJung-uk Kim 388a9d8d09cSJung-uk Kim case 'c': 389a9d8d09cSJung-uk Kim 390a9d8d09cSJung-uk Kim UtDisplayConstantOpcodes (); 391a9d8d09cSJung-uk Kim exit (0); 392a9d8d09cSJung-uk Kim 393a9d8d09cSJung-uk Kim case 'f': 394a9d8d09cSJung-uk Kim 395a9d8d09cSJung-uk Kim AslFilenameHelp (); 396a9d8d09cSJung-uk Kim exit (0); 397a9d8d09cSJung-uk Kim 398a9d8d09cSJung-uk Kim case 'r': 399a9d8d09cSJung-uk Kim 400a9d8d09cSJung-uk Kim /* reserved names */ 401a9d8d09cSJung-uk Kim 402a9d8d09cSJung-uk Kim ApDisplayReservedNames (); 403a9d8d09cSJung-uk Kim exit (0); 404a9d8d09cSJung-uk Kim 405a9d8d09cSJung-uk Kim case 't': 406a9d8d09cSJung-uk Kim 407a9d8d09cSJung-uk Kim UtDisplaySupportedTables (); 408a9d8d09cSJung-uk Kim exit (0); 409a9d8d09cSJung-uk Kim 410a9d8d09cSJung-uk Kim default: 411a9d8d09cSJung-uk Kim 412a9d8d09cSJung-uk Kim printf ("Unknown option: -h%s\n", AcpiGbl_Optarg); 413a9d8d09cSJung-uk Kim return (-1); 414a9d8d09cSJung-uk Kim } 415a9d8d09cSJung-uk Kim 416a9d8d09cSJung-uk Kim case 'I': /* Add an include file search directory */ 417a9d8d09cSJung-uk Kim 418a9d8d09cSJung-uk Kim FlAddIncludeDirectory (AcpiGbl_Optarg); 419a9d8d09cSJung-uk Kim break; 420a9d8d09cSJung-uk Kim 421a9d8d09cSJung-uk Kim case 'i': /* Output AML as an include file */ 422a9d8d09cSJung-uk Kim 423a9d8d09cSJung-uk Kim switch (AcpiGbl_Optarg[0]) 424a9d8d09cSJung-uk Kim { 425a9d8d09cSJung-uk Kim case 'a': 426a9d8d09cSJung-uk Kim 427a9d8d09cSJung-uk Kim /* Produce assembly code include file */ 428a9d8d09cSJung-uk Kim 429a9d8d09cSJung-uk Kim Gbl_AsmIncludeOutputFlag = TRUE; 430a9d8d09cSJung-uk Kim break; 431a9d8d09cSJung-uk Kim 432a9d8d09cSJung-uk Kim case 'c': 433a9d8d09cSJung-uk Kim 434a9d8d09cSJung-uk Kim /* Produce C include file */ 435a9d8d09cSJung-uk Kim 436a9d8d09cSJung-uk Kim Gbl_C_IncludeOutputFlag = TRUE; 437a9d8d09cSJung-uk Kim break; 438a9d8d09cSJung-uk Kim 439a9d8d09cSJung-uk Kim case 'n': 440a9d8d09cSJung-uk Kim 441a9d8d09cSJung-uk Kim /* Compiler/Disassembler: Ignore the NOOP operator */ 442a9d8d09cSJung-uk Kim 443a9d8d09cSJung-uk Kim AcpiGbl_IgnoreNoopOperator = TRUE; 444a9d8d09cSJung-uk Kim break; 445a9d8d09cSJung-uk Kim 446a9d8d09cSJung-uk Kim default: 447a9d8d09cSJung-uk Kim 448a9d8d09cSJung-uk Kim printf ("Unknown option: -i%s\n", AcpiGbl_Optarg); 449a9d8d09cSJung-uk Kim return (-1); 450a9d8d09cSJung-uk Kim } 451a9d8d09cSJung-uk Kim break; 452a9d8d09cSJung-uk Kim 453a9d8d09cSJung-uk Kim case 'l': /* Listing files */ 454a9d8d09cSJung-uk Kim 455a9d8d09cSJung-uk Kim switch (AcpiGbl_Optarg[0]) 456a9d8d09cSJung-uk Kim { 457a9d8d09cSJung-uk Kim case '^': 458a9d8d09cSJung-uk Kim 459a9d8d09cSJung-uk Kim /* Produce listing file (Mixed source/aml) */ 460a9d8d09cSJung-uk Kim 461a9d8d09cSJung-uk Kim Gbl_ListingFlag = TRUE; 46270e6ab8fSJung-uk Kim AcpiGbl_DmOpt_Listing = TRUE; 463a9d8d09cSJung-uk Kim break; 464a9d8d09cSJung-uk Kim 465a9d8d09cSJung-uk Kim case 'i': 466a9d8d09cSJung-uk Kim 467a9d8d09cSJung-uk Kim /* Produce preprocessor output file */ 468a9d8d09cSJung-uk Kim 469a9d8d09cSJung-uk Kim Gbl_PreprocessorOutputFlag = TRUE; 470a9d8d09cSJung-uk Kim break; 471a9d8d09cSJung-uk Kim 472313a0c13SJung-uk Kim case 'm': 473313a0c13SJung-uk Kim 474313a0c13SJung-uk Kim /* Produce hardware map summary file */ 475313a0c13SJung-uk Kim 476313a0c13SJung-uk Kim Gbl_MapfileFlag = TRUE; 477313a0c13SJung-uk Kim break; 478313a0c13SJung-uk Kim 479a9d8d09cSJung-uk Kim case 'n': 480a9d8d09cSJung-uk Kim 481a9d8d09cSJung-uk Kim /* Produce namespace file */ 482a9d8d09cSJung-uk Kim 483a9d8d09cSJung-uk Kim Gbl_NsOutputFlag = TRUE; 484a9d8d09cSJung-uk Kim break; 485a9d8d09cSJung-uk Kim 486a9d8d09cSJung-uk Kim case 's': 487a9d8d09cSJung-uk Kim 488a9d8d09cSJung-uk Kim /* Produce combined source file */ 489a9d8d09cSJung-uk Kim 490a9d8d09cSJung-uk Kim Gbl_SourceOutputFlag = TRUE; 491a9d8d09cSJung-uk Kim break; 492a9d8d09cSJung-uk Kim 493f8146b88SJung-uk Kim case 'x': 494f8146b88SJung-uk Kim 495f8146b88SJung-uk Kim /* Produce cross-reference file */ 496f8146b88SJung-uk Kim 497f8146b88SJung-uk Kim Gbl_CrossReferenceOutput = TRUE; 498f8146b88SJung-uk Kim break; 499f8146b88SJung-uk Kim 500a9d8d09cSJung-uk Kim default: 501a9d8d09cSJung-uk Kim 502a9d8d09cSJung-uk Kim printf ("Unknown option: -l%s\n", AcpiGbl_Optarg); 503a9d8d09cSJung-uk Kim return (-1); 504a9d8d09cSJung-uk Kim } 505a9d8d09cSJung-uk Kim break; 506a9d8d09cSJung-uk Kim 507a9d8d09cSJung-uk Kim case 'm': /* Set line buffer size */ 508a9d8d09cSJung-uk Kim 509a9d8d09cSJung-uk Kim Gbl_LineBufferSize = (UINT32) strtoul (AcpiGbl_Optarg, NULL, 0) * 1024; 510a9d8d09cSJung-uk Kim if (Gbl_LineBufferSize < ASL_DEFAULT_LINE_BUFFER_SIZE) 511a9d8d09cSJung-uk Kim { 512a9d8d09cSJung-uk Kim Gbl_LineBufferSize = ASL_DEFAULT_LINE_BUFFER_SIZE; 513a9d8d09cSJung-uk Kim } 514a9d8d09cSJung-uk Kim printf ("Line Buffer Size: %u\n", Gbl_LineBufferSize); 515a9d8d09cSJung-uk Kim break; 516a9d8d09cSJung-uk Kim 517a9d8d09cSJung-uk Kim case 'n': /* Parse only */ 518a9d8d09cSJung-uk Kim 519a9d8d09cSJung-uk Kim Gbl_ParseOnlyFlag = TRUE; 520a9d8d09cSJung-uk Kim break; 521a9d8d09cSJung-uk Kim 522a9d8d09cSJung-uk Kim case 'o': /* Control compiler AML optimizations */ 523a9d8d09cSJung-uk Kim 524a9d8d09cSJung-uk Kim switch (AcpiGbl_Optarg[0]) 525a9d8d09cSJung-uk Kim { 526a9d8d09cSJung-uk Kim case 'a': 527a9d8d09cSJung-uk Kim 528a9d8d09cSJung-uk Kim /* Disable all optimizations */ 529a9d8d09cSJung-uk Kim 530a9d8d09cSJung-uk Kim Gbl_FoldConstants = FALSE; 531a9d8d09cSJung-uk Kim Gbl_IntegerOptimizationFlag = FALSE; 532a9d8d09cSJung-uk Kim Gbl_ReferenceOptimizationFlag = FALSE; 533a9d8d09cSJung-uk Kim break; 534a9d8d09cSJung-uk Kim 535f8146b88SJung-uk Kim case 'c': 536f8146b88SJung-uk Kim 537f8146b88SJung-uk Kim /* Display compile time(s) */ 538f8146b88SJung-uk Kim 539f8146b88SJung-uk Kim Gbl_CompileTimesFlag = TRUE; 540f8146b88SJung-uk Kim break; 541f8146b88SJung-uk Kim 542f8146b88SJung-uk Kim case 'e': 543f8146b88SJung-uk Kim 544*3920312eSJung-uk Kim /* iASL: Disable External opcode generation */ 545f8146b88SJung-uk Kim 546f8146b88SJung-uk Kim Gbl_DoExternals = FALSE; 547*3920312eSJung-uk Kim 548*3920312eSJung-uk Kim /* Disassembler: Emit embedded external operators */ 549*3920312eSJung-uk Kim 550*3920312eSJung-uk Kim AcpiGbl_DmEmitExternalOpcodes = TRUE; 551f8146b88SJung-uk Kim break; 552f8146b88SJung-uk Kim 553a9d8d09cSJung-uk Kim case 'f': 554a9d8d09cSJung-uk Kim 555a9d8d09cSJung-uk Kim /* Disable folding on "normal" expressions */ 556a9d8d09cSJung-uk Kim 557a9d8d09cSJung-uk Kim Gbl_FoldConstants = FALSE; 558a9d8d09cSJung-uk Kim break; 559a9d8d09cSJung-uk Kim 560a9d8d09cSJung-uk Kim case 'i': 561a9d8d09cSJung-uk Kim 562a9d8d09cSJung-uk Kim /* Disable integer optimization to constants */ 563a9d8d09cSJung-uk Kim 564a9d8d09cSJung-uk Kim Gbl_IntegerOptimizationFlag = FALSE; 565a9d8d09cSJung-uk Kim break; 566a9d8d09cSJung-uk Kim 567a9d8d09cSJung-uk Kim case 'n': 568a9d8d09cSJung-uk Kim 569a9d8d09cSJung-uk Kim /* Disable named reference optimization */ 570a9d8d09cSJung-uk Kim 571a9d8d09cSJung-uk Kim Gbl_ReferenceOptimizationFlag = FALSE; 572a9d8d09cSJung-uk Kim break; 573a9d8d09cSJung-uk Kim 574a9d8d09cSJung-uk Kim case 't': 575a9d8d09cSJung-uk Kim 576f8146b88SJung-uk Kim /* Disable heavy typechecking */ 577a9d8d09cSJung-uk Kim 578f8146b88SJung-uk Kim Gbl_DoTypechecking = FALSE; 579a9d8d09cSJung-uk Kim break; 580a9d8d09cSJung-uk Kim 581a9d8d09cSJung-uk Kim default: 582a9d8d09cSJung-uk Kim 583a9d8d09cSJung-uk Kim printf ("Unknown option: -c%s\n", AcpiGbl_Optarg); 584a9d8d09cSJung-uk Kim return (-1); 585a9d8d09cSJung-uk Kim } 586a9d8d09cSJung-uk Kim break; 587a9d8d09cSJung-uk Kim 588a9d8d09cSJung-uk Kim case 'P': /* Preprocessor options */ 589a9d8d09cSJung-uk Kim 590a9d8d09cSJung-uk Kim switch (AcpiGbl_Optarg[0]) 591a9d8d09cSJung-uk Kim { 592a9d8d09cSJung-uk Kim case '^': /* Proprocess only, emit (.i) file */ 593a9d8d09cSJung-uk Kim 594a9d8d09cSJung-uk Kim Gbl_PreprocessOnly = TRUE; 595a9d8d09cSJung-uk Kim Gbl_PreprocessorOutputFlag = TRUE; 596a9d8d09cSJung-uk Kim break; 597a9d8d09cSJung-uk Kim 598a9d8d09cSJung-uk Kim case 'n': /* Disable preprocessor */ 599a9d8d09cSJung-uk Kim 600a9d8d09cSJung-uk Kim Gbl_PreprocessFlag = FALSE; 601a9d8d09cSJung-uk Kim break; 602a9d8d09cSJung-uk Kim 603a9d8d09cSJung-uk Kim default: 604a9d8d09cSJung-uk Kim 605a9d8d09cSJung-uk Kim printf ("Unknown option: -P%s\n", AcpiGbl_Optarg); 606a9d8d09cSJung-uk Kim return (-1); 607a9d8d09cSJung-uk Kim } 608a9d8d09cSJung-uk Kim break; 609a9d8d09cSJung-uk Kim 610a9d8d09cSJung-uk Kim case 'p': /* Override default AML output filename */ 611a9d8d09cSJung-uk Kim 612a9d8d09cSJung-uk Kim Gbl_OutputFilenamePrefix = AcpiGbl_Optarg; 613313a0c13SJung-uk Kim UtConvertBackslashes (Gbl_OutputFilenamePrefix); 614a9d8d09cSJung-uk Kim Gbl_UseDefaultAmlFilename = FALSE; 615a9d8d09cSJung-uk Kim break; 616a9d8d09cSJung-uk Kim 617a9d8d09cSJung-uk Kim case 'r': /* Override revision found in table header */ 618a9d8d09cSJung-uk Kim 619a9d8d09cSJung-uk Kim Gbl_RevisionOverride = (UINT8) strtoul (AcpiGbl_Optarg, NULL, 0); 620a9d8d09cSJung-uk Kim break; 621a9d8d09cSJung-uk Kim 622a9d8d09cSJung-uk Kim case 's': /* Create AML in a source code file */ 623a9d8d09cSJung-uk Kim 624a9d8d09cSJung-uk Kim switch (AcpiGbl_Optarg[0]) 625a9d8d09cSJung-uk Kim { 626a9d8d09cSJung-uk Kim case 'a': 627a9d8d09cSJung-uk Kim 628a9d8d09cSJung-uk Kim /* Produce assembly code output file */ 629a9d8d09cSJung-uk Kim 630a9d8d09cSJung-uk Kim Gbl_AsmOutputFlag = TRUE; 631a9d8d09cSJung-uk Kim break; 632a9d8d09cSJung-uk Kim 633a9d8d09cSJung-uk Kim case 'c': 634a9d8d09cSJung-uk Kim 635a9d8d09cSJung-uk Kim /* Produce C hex output file */ 636a9d8d09cSJung-uk Kim 637a9d8d09cSJung-uk Kim Gbl_C_OutputFlag = TRUE; 638a9d8d09cSJung-uk Kim break; 639a9d8d09cSJung-uk Kim 640a9d8d09cSJung-uk Kim case 'o': 641a9d8d09cSJung-uk Kim 642a9d8d09cSJung-uk Kim /* Produce AML offset table in C */ 643a9d8d09cSJung-uk Kim 644a9d8d09cSJung-uk Kim Gbl_C_OffsetTableFlag = TRUE; 645a9d8d09cSJung-uk Kim break; 646a9d8d09cSJung-uk Kim 647a9d8d09cSJung-uk Kim default: 648a9d8d09cSJung-uk Kim 649a9d8d09cSJung-uk Kim printf ("Unknown option: -s%s\n", AcpiGbl_Optarg); 650a9d8d09cSJung-uk Kim return (-1); 651a9d8d09cSJung-uk Kim } 652a9d8d09cSJung-uk Kim break; 653a9d8d09cSJung-uk Kim 654a9d8d09cSJung-uk Kim case 't': /* Produce hex table output file */ 655a9d8d09cSJung-uk Kim 656a9d8d09cSJung-uk Kim switch (AcpiGbl_Optarg[0]) 657a9d8d09cSJung-uk Kim { 658a9d8d09cSJung-uk Kim case 'a': 659a9d8d09cSJung-uk Kim 660a9d8d09cSJung-uk Kim Gbl_HexOutputFlag = HEX_OUTPUT_ASM; 661a9d8d09cSJung-uk Kim break; 662a9d8d09cSJung-uk Kim 663a9d8d09cSJung-uk Kim case 'c': 664a9d8d09cSJung-uk Kim 665a9d8d09cSJung-uk Kim Gbl_HexOutputFlag = HEX_OUTPUT_C; 666a9d8d09cSJung-uk Kim break; 667a9d8d09cSJung-uk Kim 668a9d8d09cSJung-uk Kim case 's': 669a9d8d09cSJung-uk Kim 670a9d8d09cSJung-uk Kim Gbl_HexOutputFlag = HEX_OUTPUT_ASL; 671a9d8d09cSJung-uk Kim break; 672a9d8d09cSJung-uk Kim 673a9d8d09cSJung-uk Kim default: 674a9d8d09cSJung-uk Kim 675a9d8d09cSJung-uk Kim printf ("Unknown option: -t%s\n", AcpiGbl_Optarg); 676a9d8d09cSJung-uk Kim return (-1); 677a9d8d09cSJung-uk Kim } 678a9d8d09cSJung-uk Kim break; 679a9d8d09cSJung-uk Kim 680a9d8d09cSJung-uk Kim case 'T': /* Create a ACPI table template file */ 681a9d8d09cSJung-uk Kim 682a9d8d09cSJung-uk Kim Gbl_DoTemplates = TRUE; 683a9d8d09cSJung-uk Kim break; 684a9d8d09cSJung-uk Kim 685a9d8d09cSJung-uk Kim case 'v': /* Version and verbosity settings */ 686a9d8d09cSJung-uk Kim 687a9d8d09cSJung-uk Kim switch (AcpiGbl_Optarg[0]) 688a9d8d09cSJung-uk Kim { 689a9d8d09cSJung-uk Kim case '^': 690a9d8d09cSJung-uk Kim 691a9d8d09cSJung-uk Kim printf (ACPI_COMMON_SIGNON (ASL_COMPILER_NAME)); 692a9d8d09cSJung-uk Kim exit (0); 693a9d8d09cSJung-uk Kim 694a9d8d09cSJung-uk Kim case 'a': 695a9d8d09cSJung-uk Kim 696313a0c13SJung-uk Kim /* Disable all error/warning/remark messages */ 697a9d8d09cSJung-uk Kim 698a9d8d09cSJung-uk Kim Gbl_NoErrors = TRUE; 699a9d8d09cSJung-uk Kim break; 700a9d8d09cSJung-uk Kim 701313a0c13SJung-uk Kim case 'e': 702313a0c13SJung-uk Kim 703313a0c13SJung-uk Kim /* Disable all warning/remark messages (errors only) */ 704313a0c13SJung-uk Kim 705313a0c13SJung-uk Kim Gbl_DisplayRemarks = FALSE; 706313a0c13SJung-uk Kim Gbl_DisplayWarnings = FALSE; 707313a0c13SJung-uk Kim break; 708313a0c13SJung-uk Kim 709a9d8d09cSJung-uk Kim case 'i': 710a9d8d09cSJung-uk Kim /* 711a9d8d09cSJung-uk Kim * Support for integrated development environment(s). 712a9d8d09cSJung-uk Kim * 713a9d8d09cSJung-uk Kim * 1) No compiler signon 714a9d8d09cSJung-uk Kim * 2) Send stderr messages to stdout 715a9d8d09cSJung-uk Kim * 3) Less verbose error messages (single line only for each) 716a9d8d09cSJung-uk Kim * 4) Error/warning messages are formatted appropriately to 717a9d8d09cSJung-uk Kim * be recognized by MS Visual Studio 718a9d8d09cSJung-uk Kim */ 719a9d8d09cSJung-uk Kim Gbl_VerboseErrors = FALSE; 720a9d8d09cSJung-uk Kim Gbl_DoSignon = FALSE; 721a9d8d09cSJung-uk Kim Gbl_Files[ASL_FILE_STDERR].Handle = stdout; 722a9d8d09cSJung-uk Kim break; 723a9d8d09cSJung-uk Kim 724a9d8d09cSJung-uk Kim case 'o': 725a9d8d09cSJung-uk Kim 726a9d8d09cSJung-uk Kim Gbl_DisplayOptimizations = TRUE; 727a9d8d09cSJung-uk Kim break; 728a9d8d09cSJung-uk Kim 729a9d8d09cSJung-uk Kim case 'r': 730a9d8d09cSJung-uk Kim 731a9d8d09cSJung-uk Kim Gbl_DisplayRemarks = FALSE; 732a9d8d09cSJung-uk Kim break; 733a9d8d09cSJung-uk Kim 734a9d8d09cSJung-uk Kim case 's': 735a9d8d09cSJung-uk Kim 736a9d8d09cSJung-uk Kim Gbl_DoSignon = FALSE; 737a9d8d09cSJung-uk Kim break; 738a9d8d09cSJung-uk Kim 739a9d8d09cSJung-uk Kim case 't': 740a9d8d09cSJung-uk Kim 741a9d8d09cSJung-uk Kim Gbl_VerboseTemplates = TRUE; 742a9d8d09cSJung-uk Kim break; 743a9d8d09cSJung-uk Kim 744a9d8d09cSJung-uk Kim case 'w': 745a9d8d09cSJung-uk Kim 746a9d8d09cSJung-uk Kim /* Get the required argument */ 747a9d8d09cSJung-uk Kim 748a9d8d09cSJung-uk Kim if (AcpiGetoptArgument (argc, argv)) 749a9d8d09cSJung-uk Kim { 750a9d8d09cSJung-uk Kim return (-1); 751a9d8d09cSJung-uk Kim } 752a9d8d09cSJung-uk Kim 753a9d8d09cSJung-uk Kim Status = AslDisableException (AcpiGbl_Optarg); 754a9d8d09cSJung-uk Kim if (ACPI_FAILURE (Status)) 755a9d8d09cSJung-uk Kim { 756a9d8d09cSJung-uk Kim return (-1); 757a9d8d09cSJung-uk Kim } 758a9d8d09cSJung-uk Kim break; 759a9d8d09cSJung-uk Kim 760a9d8d09cSJung-uk Kim default: 761a9d8d09cSJung-uk Kim 762a9d8d09cSJung-uk Kim printf ("Unknown option: -v%s\n", AcpiGbl_Optarg); 763a9d8d09cSJung-uk Kim return (-1); 764a9d8d09cSJung-uk Kim } 765a9d8d09cSJung-uk Kim break; 766a9d8d09cSJung-uk Kim 767a9d8d09cSJung-uk Kim case 'w': /* Set warning levels */ 768a9d8d09cSJung-uk Kim 769a9d8d09cSJung-uk Kim switch (AcpiGbl_Optarg[0]) 770a9d8d09cSJung-uk Kim { 771a9d8d09cSJung-uk Kim case '1': 772a9d8d09cSJung-uk Kim 773a9d8d09cSJung-uk Kim Gbl_WarningLevel = ASL_WARNING; 774a9d8d09cSJung-uk Kim break; 775a9d8d09cSJung-uk Kim 776a9d8d09cSJung-uk Kim case '2': 777a9d8d09cSJung-uk Kim 778a9d8d09cSJung-uk Kim Gbl_WarningLevel = ASL_WARNING2; 779a9d8d09cSJung-uk Kim break; 780a9d8d09cSJung-uk Kim 781a9d8d09cSJung-uk Kim case '3': 782a9d8d09cSJung-uk Kim 783a9d8d09cSJung-uk Kim Gbl_WarningLevel = ASL_WARNING3; 784a9d8d09cSJung-uk Kim break; 785a9d8d09cSJung-uk Kim 786a9d8d09cSJung-uk Kim case 'e': 787a9d8d09cSJung-uk Kim 788a9d8d09cSJung-uk Kim Gbl_WarningsAsErrors = TRUE; 789a9d8d09cSJung-uk Kim break; 790a9d8d09cSJung-uk Kim 791a9d8d09cSJung-uk Kim default: 792a9d8d09cSJung-uk Kim 793a9d8d09cSJung-uk Kim printf ("Unknown option: -w%s\n", AcpiGbl_Optarg); 794a9d8d09cSJung-uk Kim return (-1); 795a9d8d09cSJung-uk Kim } 796a9d8d09cSJung-uk Kim break; 797a9d8d09cSJung-uk Kim 798a9d8d09cSJung-uk Kim case 'x': /* Set debug print output level */ 799a9d8d09cSJung-uk Kim 800a9d8d09cSJung-uk Kim AcpiDbgLevel = strtoul (AcpiGbl_Optarg, NULL, 16); 801a9d8d09cSJung-uk Kim break; 802a9d8d09cSJung-uk Kim 803a9d8d09cSJung-uk Kim case 'z': 804a9d8d09cSJung-uk Kim 805a9d8d09cSJung-uk Kim Gbl_UseOriginalCompilerId = TRUE; 806a9d8d09cSJung-uk Kim break; 807a9d8d09cSJung-uk Kim 808a9d8d09cSJung-uk Kim default: 809a9d8d09cSJung-uk Kim 810a9d8d09cSJung-uk Kim return (-1); 811a9d8d09cSJung-uk Kim } 812a9d8d09cSJung-uk Kim 813a9d8d09cSJung-uk Kim return (0); 814a9d8d09cSJung-uk Kim } 815a9d8d09cSJung-uk Kim 816a9d8d09cSJung-uk Kim 817a9d8d09cSJung-uk Kim /******************************************************************************* 818a9d8d09cSJung-uk Kim * 819a9d8d09cSJung-uk Kim * FUNCTION: AslMergeOptionTokens 820a9d8d09cSJung-uk Kim * 821a9d8d09cSJung-uk Kim * PARAMETERS: InBuffer - Input containing an option string 822a9d8d09cSJung-uk Kim * OutBuffer - Merged output buffer 823a9d8d09cSJung-uk Kim * 824a9d8d09cSJung-uk Kim * RETURN: None 825a9d8d09cSJung-uk Kim * 826a9d8d09cSJung-uk Kim * DESCRIPTION: Remove all whitespace from an option string. 827a9d8d09cSJung-uk Kim * 828a9d8d09cSJung-uk Kim ******************************************************************************/ 829a9d8d09cSJung-uk Kim 830a9d8d09cSJung-uk Kim static void 831a9d8d09cSJung-uk Kim AslMergeOptionTokens ( 832a9d8d09cSJung-uk Kim char *InBuffer, 833a9d8d09cSJung-uk Kim char *OutBuffer) 834a9d8d09cSJung-uk Kim { 835a9d8d09cSJung-uk Kim char *Token; 836a9d8d09cSJung-uk Kim 837a9d8d09cSJung-uk Kim 838a9d8d09cSJung-uk Kim *OutBuffer = 0; 839a9d8d09cSJung-uk Kim 840a9d8d09cSJung-uk Kim Token = strtok (InBuffer, ASL_TOKEN_SEPARATORS); 841a9d8d09cSJung-uk Kim while (Token) 842a9d8d09cSJung-uk Kim { 843a9d8d09cSJung-uk Kim strcat (OutBuffer, Token); 844a9d8d09cSJung-uk Kim Token = strtok (NULL, ASL_TOKEN_SEPARATORS); 845a9d8d09cSJung-uk Kim } 846a9d8d09cSJung-uk Kim } 847a9d8d09cSJung-uk Kim 848a9d8d09cSJung-uk Kim 849a9d8d09cSJung-uk Kim /******************************************************************************* 850a9d8d09cSJung-uk Kim * 851a9d8d09cSJung-uk Kim * FUNCTION: AslDoResponseFile 852a9d8d09cSJung-uk Kim * 853a9d8d09cSJung-uk Kim * PARAMETERS: Filename - Name of the response file 854a9d8d09cSJung-uk Kim * 855a9d8d09cSJung-uk Kim * RETURN: Status 856a9d8d09cSJung-uk Kim * 857a9d8d09cSJung-uk Kim * DESCRIPTION: Open a response file and process all options within. 858a9d8d09cSJung-uk Kim * 859a9d8d09cSJung-uk Kim ******************************************************************************/ 860a9d8d09cSJung-uk Kim 861a9d8d09cSJung-uk Kim static int 862a9d8d09cSJung-uk Kim AslDoResponseFile ( 863a9d8d09cSJung-uk Kim char *Filename) 864a9d8d09cSJung-uk Kim { 865a9d8d09cSJung-uk Kim char *argv = StringBuffer2; 866a9d8d09cSJung-uk Kim FILE *ResponseFile; 867a9d8d09cSJung-uk Kim int OptStatus = 0; 868a9d8d09cSJung-uk Kim int Opterr; 869a9d8d09cSJung-uk Kim int Optind; 870a9d8d09cSJung-uk Kim 871a9d8d09cSJung-uk Kim 872a9d8d09cSJung-uk Kim ResponseFile = fopen (Filename, "r"); 873a9d8d09cSJung-uk Kim if (!ResponseFile) 874a9d8d09cSJung-uk Kim { 875a9d8d09cSJung-uk Kim printf ("Could not open command file %s, %s\n", 876a9d8d09cSJung-uk Kim Filename, strerror (errno)); 877a9d8d09cSJung-uk Kim return (-1); 878a9d8d09cSJung-uk Kim } 879a9d8d09cSJung-uk Kim 880a9d8d09cSJung-uk Kim /* Must save the current GetOpt globals */ 881a9d8d09cSJung-uk Kim 882a9d8d09cSJung-uk Kim Opterr = AcpiGbl_Opterr; 883a9d8d09cSJung-uk Kim Optind = AcpiGbl_Optind; 884a9d8d09cSJung-uk Kim 885a9d8d09cSJung-uk Kim /* 886a9d8d09cSJung-uk Kim * Process all lines in the response file. There must be one complete 887a9d8d09cSJung-uk Kim * option per line 888a9d8d09cSJung-uk Kim */ 889a9d8d09cSJung-uk Kim while (fgets (StringBuffer, ASL_MSG_BUFFER_SIZE, ResponseFile)) 890a9d8d09cSJung-uk Kim { 891a9d8d09cSJung-uk Kim /* Compress all tokens, allowing us to use a single argv entry */ 892a9d8d09cSJung-uk Kim 893a9d8d09cSJung-uk Kim AslMergeOptionTokens (StringBuffer, StringBuffer2); 894a9d8d09cSJung-uk Kim 895a9d8d09cSJung-uk Kim /* Process the option */ 896a9d8d09cSJung-uk Kim 897a9d8d09cSJung-uk Kim AcpiGbl_Opterr = 0; 898a9d8d09cSJung-uk Kim AcpiGbl_Optind = 0; 899a9d8d09cSJung-uk Kim 900a9d8d09cSJung-uk Kim OptStatus = AslDoOptions (1, &argv, TRUE); 901a9d8d09cSJung-uk Kim if (OptStatus) 902a9d8d09cSJung-uk Kim { 903a9d8d09cSJung-uk Kim printf ("Invalid option in command file %s: %s\n", 904a9d8d09cSJung-uk Kim Filename, StringBuffer); 905a9d8d09cSJung-uk Kim break; 906a9d8d09cSJung-uk Kim } 907a9d8d09cSJung-uk Kim } 908a9d8d09cSJung-uk Kim 909a9d8d09cSJung-uk Kim /* Restore the GetOpt globals */ 910a9d8d09cSJung-uk Kim 911a9d8d09cSJung-uk Kim AcpiGbl_Opterr = Opterr; 912a9d8d09cSJung-uk Kim AcpiGbl_Optind = Optind; 913a9d8d09cSJung-uk Kim 914a9d8d09cSJung-uk Kim fclose (ResponseFile); 915a9d8d09cSJung-uk Kim return (OptStatus); 916a9d8d09cSJung-uk Kim } 917