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 /* 8*313a0c13SJung-uk Kim * Copyright (C) 2000 - 2014, 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" 7179c6d946SJung-uk Kim #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" 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 { 110a9d8d09cSJung-uk Kim Status = DtCreateTemplates (Gbl_TemplateSignature); 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] && 121*313a0c13SJung-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 171*313a0c13SJung-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 187a9d8d09cSJung-uk Kim case 'b': /* Debug output options */ 188a9d8d09cSJung-uk Kim 189a9d8d09cSJung-uk Kim switch (AcpiGbl_Optarg[0]) 190a9d8d09cSJung-uk Kim { 191a9d8d09cSJung-uk Kim case 'f': 192a9d8d09cSJung-uk Kim 193a9d8d09cSJung-uk Kim AslCompilerdebug = 1; /* same as yydebug */ 194a9d8d09cSJung-uk Kim DtParserdebug = 1; 195a9d8d09cSJung-uk Kim PrParserdebug = 1; 196a9d8d09cSJung-uk Kim break; 197a9d8d09cSJung-uk Kim 198a9d8d09cSJung-uk Kim case 't': 199a9d8d09cSJung-uk Kim 200a9d8d09cSJung-uk Kim break; 201a9d8d09cSJung-uk Kim 202a9d8d09cSJung-uk Kim default: 203a9d8d09cSJung-uk Kim 204a9d8d09cSJung-uk Kim printf ("Unknown option: -b%s\n", AcpiGbl_Optarg); 205a9d8d09cSJung-uk Kim return (-1); 206a9d8d09cSJung-uk Kim } 207a9d8d09cSJung-uk Kim 208a9d8d09cSJung-uk Kim /* Produce debug output file */ 209a9d8d09cSJung-uk Kim 210a9d8d09cSJung-uk Kim Gbl_DebugFlag = TRUE; 211a9d8d09cSJung-uk Kim break; 212a9d8d09cSJung-uk Kim 213a9d8d09cSJung-uk Kim case 'c': 214a9d8d09cSJung-uk Kim 215a9d8d09cSJung-uk Kim switch (AcpiGbl_Optarg[0]) 216a9d8d09cSJung-uk Kim { 217a9d8d09cSJung-uk Kim case 'r': 218a9d8d09cSJung-uk Kim 219a9d8d09cSJung-uk Kim Gbl_NoResourceChecking = TRUE; 220a9d8d09cSJung-uk Kim break; 221a9d8d09cSJung-uk Kim 222a9d8d09cSJung-uk Kim default: 223a9d8d09cSJung-uk Kim 224a9d8d09cSJung-uk Kim printf ("Unknown option: -c%s\n", AcpiGbl_Optarg); 225a9d8d09cSJung-uk Kim return (-1); 226a9d8d09cSJung-uk Kim } 227a9d8d09cSJung-uk Kim break; 228a9d8d09cSJung-uk Kim 229a9d8d09cSJung-uk Kim case 'd': /* Disassembler */ 230a9d8d09cSJung-uk Kim 231a9d8d09cSJung-uk Kim switch (AcpiGbl_Optarg[0]) 232a9d8d09cSJung-uk Kim { 233a9d8d09cSJung-uk Kim case '^': 234a9d8d09cSJung-uk Kim 235a9d8d09cSJung-uk Kim Gbl_DoCompile = FALSE; 236a9d8d09cSJung-uk Kim break; 237a9d8d09cSJung-uk Kim 238a9d8d09cSJung-uk Kim case 'a': 239a9d8d09cSJung-uk Kim 240a9d8d09cSJung-uk Kim Gbl_DoCompile = FALSE; 241a9d8d09cSJung-uk Kim Gbl_DisassembleAll = TRUE; 242a9d8d09cSJung-uk Kim break; 243a9d8d09cSJung-uk Kim 244a9d8d09cSJung-uk Kim case 'b': /* Do not convert buffers to resource descriptors */ 245a9d8d09cSJung-uk Kim 246a9d8d09cSJung-uk Kim AcpiGbl_NoResourceDisassembly = TRUE; 247a9d8d09cSJung-uk Kim break; 248a9d8d09cSJung-uk Kim 249a9d8d09cSJung-uk Kim case 'c': 250a9d8d09cSJung-uk Kim 251a9d8d09cSJung-uk Kim break; 252a9d8d09cSJung-uk Kim 253a9d8d09cSJung-uk Kim default: 254a9d8d09cSJung-uk Kim 255a9d8d09cSJung-uk Kim printf ("Unknown option: -d%s\n", AcpiGbl_Optarg); 256a9d8d09cSJung-uk Kim return (-1); 257a9d8d09cSJung-uk Kim } 258a9d8d09cSJung-uk Kim 259a9d8d09cSJung-uk Kim Gbl_DisasmFlag = TRUE; 260a9d8d09cSJung-uk Kim break; 261a9d8d09cSJung-uk Kim 262a9d8d09cSJung-uk Kim case 'D': /* Define a symbol */ 263a9d8d09cSJung-uk Kim 264a9d8d09cSJung-uk Kim PrAddDefine (AcpiGbl_Optarg, NULL, TRUE); 265a9d8d09cSJung-uk Kim break; 266a9d8d09cSJung-uk Kim 267a9d8d09cSJung-uk Kim case 'e': /* External files for disassembler */ 268a9d8d09cSJung-uk Kim 269*313a0c13SJung-uk Kim /* Get entire list of external files */ 270*313a0c13SJung-uk Kim 271*313a0c13SJung-uk Kim AcpiGbl_Optind--; 272*313a0c13SJung-uk Kim argv[AcpiGbl_Optind] = AcpiGbl_Optarg; 273*313a0c13SJung-uk Kim 274*313a0c13SJung-uk Kim while (argv[AcpiGbl_Optind] && 275*313a0c13SJung-uk Kim (argv[AcpiGbl_Optind][0] != '-')) 276*313a0c13SJung-uk Kim { 277*313a0c13SJung-uk Kim Status = AcpiDmAddToExternalFileList (argv[AcpiGbl_Optind]); 278a9d8d09cSJung-uk Kim if (ACPI_FAILURE (Status)) 279a9d8d09cSJung-uk Kim { 280*313a0c13SJung-uk Kim printf ("Could not add %s to external list\n", argv[AcpiGbl_Optind]); 281a9d8d09cSJung-uk Kim return (-1); 282a9d8d09cSJung-uk Kim } 283*313a0c13SJung-uk Kim 284*313a0c13SJung-uk Kim AcpiGbl_Optind++; 285*313a0c13SJung-uk Kim } 286a9d8d09cSJung-uk Kim break; 287a9d8d09cSJung-uk Kim 28879c6d946SJung-uk Kim case 'f': 28979c6d946SJung-uk Kim 29079c6d946SJung-uk Kim switch (AcpiGbl_Optarg[0]) 29179c6d946SJung-uk Kim { 29279c6d946SJung-uk Kim case '^': /* Ignore errors and force creation of aml file */ 293a9d8d09cSJung-uk Kim 294a9d8d09cSJung-uk Kim Gbl_IgnoreErrors = TRUE; 295a9d8d09cSJung-uk Kim break; 296a9d8d09cSJung-uk Kim 29779c6d946SJung-uk Kim case 'e': /* Disassembler: Get external declaration file */ 29879c6d946SJung-uk Kim 29979c6d946SJung-uk Kim if (AcpiGetoptArgument (argc, argv)) 30079c6d946SJung-uk Kim { 30179c6d946SJung-uk Kim return (-1); 30279c6d946SJung-uk Kim } 30379c6d946SJung-uk Kim 30479c6d946SJung-uk Kim Gbl_ExternalRefFilename = AcpiGbl_Optarg; 30579c6d946SJung-uk Kim break; 30679c6d946SJung-uk Kim 30779c6d946SJung-uk Kim default: 30879c6d946SJung-uk Kim 30979c6d946SJung-uk Kim printf ("Unknown option: -f%s\n", AcpiGbl_Optarg); 31079c6d946SJung-uk Kim return (-1); 31179c6d946SJung-uk Kim } 31279c6d946SJung-uk Kim break; 31379c6d946SJung-uk Kim 314a9d8d09cSJung-uk Kim case 'G': 315a9d8d09cSJung-uk Kim 316a9d8d09cSJung-uk Kim Gbl_CompileGeneric = TRUE; 317a9d8d09cSJung-uk Kim break; 318a9d8d09cSJung-uk Kim 319a9d8d09cSJung-uk Kim case 'g': /* Get all ACPI tables */ 320a9d8d09cSJung-uk Kim 321*313a0c13SJung-uk Kim printf ("-g option is deprecated, use acpidump utility instead\n"); 322*313a0c13SJung-uk Kim exit (1); 323a9d8d09cSJung-uk Kim 324a9d8d09cSJung-uk Kim case 'h': 325a9d8d09cSJung-uk Kim 326a9d8d09cSJung-uk Kim switch (AcpiGbl_Optarg[0]) 327a9d8d09cSJung-uk Kim { 328a9d8d09cSJung-uk Kim case '^': 329a9d8d09cSJung-uk Kim 330a9d8d09cSJung-uk Kim Usage (); 331a9d8d09cSJung-uk Kim exit (0); 332a9d8d09cSJung-uk Kim 333a9d8d09cSJung-uk Kim case 'c': 334a9d8d09cSJung-uk Kim 335a9d8d09cSJung-uk Kim UtDisplayConstantOpcodes (); 336a9d8d09cSJung-uk Kim exit (0); 337a9d8d09cSJung-uk Kim 338a9d8d09cSJung-uk Kim case 'f': 339a9d8d09cSJung-uk Kim 340a9d8d09cSJung-uk Kim AslFilenameHelp (); 341a9d8d09cSJung-uk Kim exit (0); 342a9d8d09cSJung-uk Kim 343a9d8d09cSJung-uk Kim case 'r': 344a9d8d09cSJung-uk Kim 345a9d8d09cSJung-uk Kim /* reserved names */ 346a9d8d09cSJung-uk Kim 347a9d8d09cSJung-uk Kim ApDisplayReservedNames (); 348a9d8d09cSJung-uk Kim exit (0); 349a9d8d09cSJung-uk Kim 350a9d8d09cSJung-uk Kim case 't': 351a9d8d09cSJung-uk Kim 352a9d8d09cSJung-uk Kim UtDisplaySupportedTables (); 353a9d8d09cSJung-uk Kim exit (0); 354a9d8d09cSJung-uk Kim 355a9d8d09cSJung-uk Kim default: 356a9d8d09cSJung-uk Kim 357a9d8d09cSJung-uk Kim printf ("Unknown option: -h%s\n", AcpiGbl_Optarg); 358a9d8d09cSJung-uk Kim return (-1); 359a9d8d09cSJung-uk Kim } 360a9d8d09cSJung-uk Kim 361a9d8d09cSJung-uk Kim case 'I': /* Add an include file search directory */ 362a9d8d09cSJung-uk Kim 363a9d8d09cSJung-uk Kim FlAddIncludeDirectory (AcpiGbl_Optarg); 364a9d8d09cSJung-uk Kim break; 365a9d8d09cSJung-uk Kim 366a9d8d09cSJung-uk Kim case 'i': /* Output AML as an include file */ 367a9d8d09cSJung-uk Kim 368a9d8d09cSJung-uk Kim switch (AcpiGbl_Optarg[0]) 369a9d8d09cSJung-uk Kim { 370a9d8d09cSJung-uk Kim case 'a': 371a9d8d09cSJung-uk Kim 372a9d8d09cSJung-uk Kim /* Produce assembly code include file */ 373a9d8d09cSJung-uk Kim 374a9d8d09cSJung-uk Kim Gbl_AsmIncludeOutputFlag = TRUE; 375a9d8d09cSJung-uk Kim break; 376a9d8d09cSJung-uk Kim 377a9d8d09cSJung-uk Kim case 'c': 378a9d8d09cSJung-uk Kim 379a9d8d09cSJung-uk Kim /* Produce C include file */ 380a9d8d09cSJung-uk Kim 381a9d8d09cSJung-uk Kim Gbl_C_IncludeOutputFlag = TRUE; 382a9d8d09cSJung-uk Kim break; 383a9d8d09cSJung-uk Kim 384a9d8d09cSJung-uk Kim case 'n': 385a9d8d09cSJung-uk Kim 386a9d8d09cSJung-uk Kim /* Compiler/Disassembler: Ignore the NOOP operator */ 387a9d8d09cSJung-uk Kim 388a9d8d09cSJung-uk Kim AcpiGbl_IgnoreNoopOperator = TRUE; 389a9d8d09cSJung-uk Kim break; 390a9d8d09cSJung-uk Kim 391a9d8d09cSJung-uk Kim default: 392a9d8d09cSJung-uk Kim 393a9d8d09cSJung-uk Kim printf ("Unknown option: -i%s\n", AcpiGbl_Optarg); 394a9d8d09cSJung-uk Kim return (-1); 395a9d8d09cSJung-uk Kim } 396a9d8d09cSJung-uk Kim break; 397a9d8d09cSJung-uk Kim 398a9d8d09cSJung-uk Kim case 'l': /* Listing files */ 399a9d8d09cSJung-uk Kim 400a9d8d09cSJung-uk Kim switch (AcpiGbl_Optarg[0]) 401a9d8d09cSJung-uk Kim { 402a9d8d09cSJung-uk Kim case '^': 403a9d8d09cSJung-uk Kim 404a9d8d09cSJung-uk Kim /* Produce listing file (Mixed source/aml) */ 405a9d8d09cSJung-uk Kim 406a9d8d09cSJung-uk Kim Gbl_ListingFlag = TRUE; 407a9d8d09cSJung-uk Kim break; 408a9d8d09cSJung-uk Kim 409a9d8d09cSJung-uk Kim case 'i': 410a9d8d09cSJung-uk Kim 411a9d8d09cSJung-uk Kim /* Produce preprocessor output file */ 412a9d8d09cSJung-uk Kim 413a9d8d09cSJung-uk Kim Gbl_PreprocessorOutputFlag = TRUE; 414a9d8d09cSJung-uk Kim break; 415a9d8d09cSJung-uk Kim 416*313a0c13SJung-uk Kim case 'm': 417*313a0c13SJung-uk Kim 418*313a0c13SJung-uk Kim /* Produce hardware map summary file */ 419*313a0c13SJung-uk Kim 420*313a0c13SJung-uk Kim Gbl_MapfileFlag = TRUE; 421*313a0c13SJung-uk Kim break; 422*313a0c13SJung-uk Kim 423a9d8d09cSJung-uk Kim case 'n': 424a9d8d09cSJung-uk Kim 425a9d8d09cSJung-uk Kim /* Produce namespace file */ 426a9d8d09cSJung-uk Kim 427a9d8d09cSJung-uk Kim Gbl_NsOutputFlag = TRUE; 428a9d8d09cSJung-uk Kim break; 429a9d8d09cSJung-uk Kim 430a9d8d09cSJung-uk Kim case 's': 431a9d8d09cSJung-uk Kim 432a9d8d09cSJung-uk Kim /* Produce combined source file */ 433a9d8d09cSJung-uk Kim 434a9d8d09cSJung-uk Kim Gbl_SourceOutputFlag = TRUE; 435a9d8d09cSJung-uk Kim break; 436a9d8d09cSJung-uk Kim 437a9d8d09cSJung-uk Kim default: 438a9d8d09cSJung-uk Kim 439a9d8d09cSJung-uk Kim printf ("Unknown option: -l%s\n", AcpiGbl_Optarg); 440a9d8d09cSJung-uk Kim return (-1); 441a9d8d09cSJung-uk Kim } 442a9d8d09cSJung-uk Kim break; 443a9d8d09cSJung-uk Kim 444a9d8d09cSJung-uk Kim case 'm': /* Set line buffer size */ 445a9d8d09cSJung-uk Kim 446a9d8d09cSJung-uk Kim Gbl_LineBufferSize = (UINT32) strtoul (AcpiGbl_Optarg, NULL, 0) * 1024; 447a9d8d09cSJung-uk Kim if (Gbl_LineBufferSize < ASL_DEFAULT_LINE_BUFFER_SIZE) 448a9d8d09cSJung-uk Kim { 449a9d8d09cSJung-uk Kim Gbl_LineBufferSize = ASL_DEFAULT_LINE_BUFFER_SIZE; 450a9d8d09cSJung-uk Kim } 451a9d8d09cSJung-uk Kim printf ("Line Buffer Size: %u\n", Gbl_LineBufferSize); 452a9d8d09cSJung-uk Kim break; 453a9d8d09cSJung-uk Kim 454a9d8d09cSJung-uk Kim case 'n': /* Parse only */ 455a9d8d09cSJung-uk Kim 456a9d8d09cSJung-uk Kim Gbl_ParseOnlyFlag = TRUE; 457a9d8d09cSJung-uk Kim break; 458a9d8d09cSJung-uk Kim 459a9d8d09cSJung-uk Kim case 'o': /* Control compiler AML optimizations */ 460a9d8d09cSJung-uk Kim 461a9d8d09cSJung-uk Kim switch (AcpiGbl_Optarg[0]) 462a9d8d09cSJung-uk Kim { 463a9d8d09cSJung-uk Kim case 'a': 464a9d8d09cSJung-uk Kim 465a9d8d09cSJung-uk Kim /* Disable all optimizations */ 466a9d8d09cSJung-uk Kim 467a9d8d09cSJung-uk Kim Gbl_FoldConstants = FALSE; 468a9d8d09cSJung-uk Kim Gbl_IntegerOptimizationFlag = FALSE; 469a9d8d09cSJung-uk Kim Gbl_ReferenceOptimizationFlag = FALSE; 470a9d8d09cSJung-uk Kim break; 471a9d8d09cSJung-uk Kim 472a9d8d09cSJung-uk Kim case 'f': 473a9d8d09cSJung-uk Kim 474a9d8d09cSJung-uk Kim /* Disable folding on "normal" expressions */ 475a9d8d09cSJung-uk Kim 476a9d8d09cSJung-uk Kim Gbl_FoldConstants = FALSE; 477a9d8d09cSJung-uk Kim break; 478a9d8d09cSJung-uk Kim 479a9d8d09cSJung-uk Kim case 'i': 480a9d8d09cSJung-uk Kim 481a9d8d09cSJung-uk Kim /* Disable integer optimization to constants */ 482a9d8d09cSJung-uk Kim 483a9d8d09cSJung-uk Kim Gbl_IntegerOptimizationFlag = FALSE; 484a9d8d09cSJung-uk Kim break; 485a9d8d09cSJung-uk Kim 486a9d8d09cSJung-uk Kim case 'n': 487a9d8d09cSJung-uk Kim 488a9d8d09cSJung-uk Kim /* Disable named reference optimization */ 489a9d8d09cSJung-uk Kim 490a9d8d09cSJung-uk Kim Gbl_ReferenceOptimizationFlag = FALSE; 491a9d8d09cSJung-uk Kim break; 492a9d8d09cSJung-uk Kim 493a9d8d09cSJung-uk Kim case 't': 494a9d8d09cSJung-uk Kim 495a9d8d09cSJung-uk Kim /* Display compile time(s) */ 496a9d8d09cSJung-uk Kim 497a9d8d09cSJung-uk Kim Gbl_CompileTimesFlag = TRUE; 498a9d8d09cSJung-uk Kim break; 499a9d8d09cSJung-uk Kim 500a9d8d09cSJung-uk Kim default: 501a9d8d09cSJung-uk Kim 502a9d8d09cSJung-uk Kim printf ("Unknown option: -c%s\n", AcpiGbl_Optarg); 503a9d8d09cSJung-uk Kim return (-1); 504a9d8d09cSJung-uk Kim } 505a9d8d09cSJung-uk Kim break; 506a9d8d09cSJung-uk Kim 507a9d8d09cSJung-uk Kim case 'P': /* Preprocessor options */ 508a9d8d09cSJung-uk Kim 509a9d8d09cSJung-uk Kim switch (AcpiGbl_Optarg[0]) 510a9d8d09cSJung-uk Kim { 511a9d8d09cSJung-uk Kim case '^': /* Proprocess only, emit (.i) file */ 512a9d8d09cSJung-uk Kim 513a9d8d09cSJung-uk Kim Gbl_PreprocessOnly = TRUE; 514a9d8d09cSJung-uk Kim Gbl_PreprocessorOutputFlag = TRUE; 515a9d8d09cSJung-uk Kim break; 516a9d8d09cSJung-uk Kim 517a9d8d09cSJung-uk Kim case 'n': /* Disable preprocessor */ 518a9d8d09cSJung-uk Kim 519a9d8d09cSJung-uk Kim Gbl_PreprocessFlag = FALSE; 520a9d8d09cSJung-uk Kim break; 521a9d8d09cSJung-uk Kim 522a9d8d09cSJung-uk Kim default: 523a9d8d09cSJung-uk Kim 524a9d8d09cSJung-uk Kim printf ("Unknown option: -P%s\n", AcpiGbl_Optarg); 525a9d8d09cSJung-uk Kim return (-1); 526a9d8d09cSJung-uk Kim } 527a9d8d09cSJung-uk Kim break; 528a9d8d09cSJung-uk Kim 529a9d8d09cSJung-uk Kim case 'p': /* Override default AML output filename */ 530a9d8d09cSJung-uk Kim 531a9d8d09cSJung-uk Kim Gbl_OutputFilenamePrefix = AcpiGbl_Optarg; 532*313a0c13SJung-uk Kim UtConvertBackslashes (Gbl_OutputFilenamePrefix); 533*313a0c13SJung-uk Kim 534a9d8d09cSJung-uk Kim Gbl_UseDefaultAmlFilename = FALSE; 535a9d8d09cSJung-uk Kim break; 536a9d8d09cSJung-uk Kim 537a9d8d09cSJung-uk Kim case 'r': /* Override revision found in table header */ 538a9d8d09cSJung-uk Kim 539a9d8d09cSJung-uk Kim Gbl_RevisionOverride = (UINT8) strtoul (AcpiGbl_Optarg, NULL, 0); 540a9d8d09cSJung-uk Kim break; 541a9d8d09cSJung-uk Kim 542a9d8d09cSJung-uk Kim case 's': /* Create AML in a source code file */ 543a9d8d09cSJung-uk Kim 544a9d8d09cSJung-uk Kim switch (AcpiGbl_Optarg[0]) 545a9d8d09cSJung-uk Kim { 546a9d8d09cSJung-uk Kim case 'a': 547a9d8d09cSJung-uk Kim 548a9d8d09cSJung-uk Kim /* Produce assembly code output file */ 549a9d8d09cSJung-uk Kim 550a9d8d09cSJung-uk Kim Gbl_AsmOutputFlag = TRUE; 551a9d8d09cSJung-uk Kim break; 552a9d8d09cSJung-uk Kim 553a9d8d09cSJung-uk Kim case 'c': 554a9d8d09cSJung-uk Kim 555a9d8d09cSJung-uk Kim /* Produce C hex output file */ 556a9d8d09cSJung-uk Kim 557a9d8d09cSJung-uk Kim Gbl_C_OutputFlag = TRUE; 558a9d8d09cSJung-uk Kim break; 559a9d8d09cSJung-uk Kim 560a9d8d09cSJung-uk Kim case 'o': 561a9d8d09cSJung-uk Kim 562a9d8d09cSJung-uk Kim /* Produce AML offset table in C */ 563a9d8d09cSJung-uk Kim 564a9d8d09cSJung-uk Kim Gbl_C_OffsetTableFlag = TRUE; 565a9d8d09cSJung-uk Kim break; 566a9d8d09cSJung-uk Kim 567a9d8d09cSJung-uk Kim default: 568a9d8d09cSJung-uk Kim 569a9d8d09cSJung-uk Kim printf ("Unknown option: -s%s\n", AcpiGbl_Optarg); 570a9d8d09cSJung-uk Kim return (-1); 571a9d8d09cSJung-uk Kim } 572a9d8d09cSJung-uk Kim break; 573a9d8d09cSJung-uk Kim 574a9d8d09cSJung-uk Kim case 't': /* Produce hex table output file */ 575a9d8d09cSJung-uk Kim 576a9d8d09cSJung-uk Kim switch (AcpiGbl_Optarg[0]) 577a9d8d09cSJung-uk Kim { 578a9d8d09cSJung-uk Kim case 'a': 579a9d8d09cSJung-uk Kim 580a9d8d09cSJung-uk Kim Gbl_HexOutputFlag = HEX_OUTPUT_ASM; 581a9d8d09cSJung-uk Kim break; 582a9d8d09cSJung-uk Kim 583a9d8d09cSJung-uk Kim case 'c': 584a9d8d09cSJung-uk Kim 585a9d8d09cSJung-uk Kim Gbl_HexOutputFlag = HEX_OUTPUT_C; 586a9d8d09cSJung-uk Kim break; 587a9d8d09cSJung-uk Kim 588a9d8d09cSJung-uk Kim case 's': 589a9d8d09cSJung-uk Kim 590a9d8d09cSJung-uk Kim Gbl_HexOutputFlag = HEX_OUTPUT_ASL; 591a9d8d09cSJung-uk Kim break; 592a9d8d09cSJung-uk Kim 593a9d8d09cSJung-uk Kim default: 594a9d8d09cSJung-uk Kim 595a9d8d09cSJung-uk Kim printf ("Unknown option: -t%s\n", AcpiGbl_Optarg); 596a9d8d09cSJung-uk Kim return (-1); 597a9d8d09cSJung-uk Kim } 598a9d8d09cSJung-uk Kim break; 599a9d8d09cSJung-uk Kim 600a9d8d09cSJung-uk Kim case 'T': /* Create a ACPI table template file */ 601a9d8d09cSJung-uk Kim 602a9d8d09cSJung-uk Kim Gbl_DoTemplates = TRUE; 603a9d8d09cSJung-uk Kim Gbl_TemplateSignature = AcpiGbl_Optarg; 604a9d8d09cSJung-uk Kim break; 605a9d8d09cSJung-uk Kim 606a9d8d09cSJung-uk Kim case 'v': /* Version and verbosity settings */ 607a9d8d09cSJung-uk Kim 608a9d8d09cSJung-uk Kim switch (AcpiGbl_Optarg[0]) 609a9d8d09cSJung-uk Kim { 610a9d8d09cSJung-uk Kim case '^': 611a9d8d09cSJung-uk Kim 612a9d8d09cSJung-uk Kim printf (ACPI_COMMON_SIGNON (ASL_COMPILER_NAME)); 613a9d8d09cSJung-uk Kim exit (0); 614a9d8d09cSJung-uk Kim 615a9d8d09cSJung-uk Kim case 'a': 616a9d8d09cSJung-uk Kim 617*313a0c13SJung-uk Kim /* Disable all error/warning/remark messages */ 618a9d8d09cSJung-uk Kim 619a9d8d09cSJung-uk Kim Gbl_NoErrors = TRUE; 620a9d8d09cSJung-uk Kim break; 621a9d8d09cSJung-uk Kim 622*313a0c13SJung-uk Kim case 'e': 623*313a0c13SJung-uk Kim 624*313a0c13SJung-uk Kim /* Disable all warning/remark messages (errors only) */ 625*313a0c13SJung-uk Kim 626*313a0c13SJung-uk Kim Gbl_DisplayRemarks = FALSE; 627*313a0c13SJung-uk Kim Gbl_DisplayWarnings = FALSE; 628*313a0c13SJung-uk Kim break; 629*313a0c13SJung-uk Kim 630a9d8d09cSJung-uk Kim case 'i': 631a9d8d09cSJung-uk Kim /* 632a9d8d09cSJung-uk Kim * Support for integrated development environment(s). 633a9d8d09cSJung-uk Kim * 634a9d8d09cSJung-uk Kim * 1) No compiler signon 635a9d8d09cSJung-uk Kim * 2) Send stderr messages to stdout 636a9d8d09cSJung-uk Kim * 3) Less verbose error messages (single line only for each) 637a9d8d09cSJung-uk Kim * 4) Error/warning messages are formatted appropriately to 638a9d8d09cSJung-uk Kim * be recognized by MS Visual Studio 639a9d8d09cSJung-uk Kim */ 640a9d8d09cSJung-uk Kim Gbl_VerboseErrors = FALSE; 641a9d8d09cSJung-uk Kim Gbl_DoSignon = FALSE; 642a9d8d09cSJung-uk Kim Gbl_Files[ASL_FILE_STDERR].Handle = stdout; 643a9d8d09cSJung-uk Kim break; 644a9d8d09cSJung-uk Kim 645a9d8d09cSJung-uk Kim case 'o': 646a9d8d09cSJung-uk Kim 647a9d8d09cSJung-uk Kim Gbl_DisplayOptimizations = TRUE; 648a9d8d09cSJung-uk Kim break; 649a9d8d09cSJung-uk Kim 650a9d8d09cSJung-uk Kim case 'r': 651a9d8d09cSJung-uk Kim 652a9d8d09cSJung-uk Kim Gbl_DisplayRemarks = FALSE; 653a9d8d09cSJung-uk Kim break; 654a9d8d09cSJung-uk Kim 655a9d8d09cSJung-uk Kim case 's': 656a9d8d09cSJung-uk Kim 657a9d8d09cSJung-uk Kim Gbl_DoSignon = FALSE; 658a9d8d09cSJung-uk Kim break; 659a9d8d09cSJung-uk Kim 660a9d8d09cSJung-uk Kim case 't': 661a9d8d09cSJung-uk Kim 662a9d8d09cSJung-uk Kim Gbl_VerboseTemplates = TRUE; 663a9d8d09cSJung-uk Kim break; 664a9d8d09cSJung-uk Kim 665a9d8d09cSJung-uk Kim case 'w': 666a9d8d09cSJung-uk Kim 667a9d8d09cSJung-uk Kim /* Get the required argument */ 668a9d8d09cSJung-uk Kim 669a9d8d09cSJung-uk Kim if (AcpiGetoptArgument (argc, argv)) 670a9d8d09cSJung-uk Kim { 671a9d8d09cSJung-uk Kim return (-1); 672a9d8d09cSJung-uk Kim } 673a9d8d09cSJung-uk Kim 674a9d8d09cSJung-uk Kim Status = AslDisableException (AcpiGbl_Optarg); 675a9d8d09cSJung-uk Kim if (ACPI_FAILURE (Status)) 676a9d8d09cSJung-uk Kim { 677a9d8d09cSJung-uk Kim return (-1); 678a9d8d09cSJung-uk Kim } 679a9d8d09cSJung-uk Kim break; 680a9d8d09cSJung-uk Kim 681a9d8d09cSJung-uk Kim default: 682a9d8d09cSJung-uk Kim 683a9d8d09cSJung-uk Kim printf ("Unknown option: -v%s\n", AcpiGbl_Optarg); 684a9d8d09cSJung-uk Kim return (-1); 685a9d8d09cSJung-uk Kim } 686a9d8d09cSJung-uk Kim break; 687a9d8d09cSJung-uk Kim 688a9d8d09cSJung-uk Kim case 'w': /* Set warning levels */ 689a9d8d09cSJung-uk Kim 690a9d8d09cSJung-uk Kim switch (AcpiGbl_Optarg[0]) 691a9d8d09cSJung-uk Kim { 692a9d8d09cSJung-uk Kim case '1': 693a9d8d09cSJung-uk Kim 694a9d8d09cSJung-uk Kim Gbl_WarningLevel = ASL_WARNING; 695a9d8d09cSJung-uk Kim break; 696a9d8d09cSJung-uk Kim 697a9d8d09cSJung-uk Kim case '2': 698a9d8d09cSJung-uk Kim 699a9d8d09cSJung-uk Kim Gbl_WarningLevel = ASL_WARNING2; 700a9d8d09cSJung-uk Kim break; 701a9d8d09cSJung-uk Kim 702a9d8d09cSJung-uk Kim case '3': 703a9d8d09cSJung-uk Kim 704a9d8d09cSJung-uk Kim Gbl_WarningLevel = ASL_WARNING3; 705a9d8d09cSJung-uk Kim break; 706a9d8d09cSJung-uk Kim 707a9d8d09cSJung-uk Kim case 'e': 708a9d8d09cSJung-uk Kim 709a9d8d09cSJung-uk Kim Gbl_WarningsAsErrors = TRUE; 710a9d8d09cSJung-uk Kim break; 711a9d8d09cSJung-uk Kim 712a9d8d09cSJung-uk Kim default: 713a9d8d09cSJung-uk Kim 714a9d8d09cSJung-uk Kim printf ("Unknown option: -w%s\n", AcpiGbl_Optarg); 715a9d8d09cSJung-uk Kim return (-1); 716a9d8d09cSJung-uk Kim } 717a9d8d09cSJung-uk Kim break; 718a9d8d09cSJung-uk Kim 719a9d8d09cSJung-uk Kim case 'x': /* Set debug print output level */ 720a9d8d09cSJung-uk Kim 721a9d8d09cSJung-uk Kim AcpiDbgLevel = strtoul (AcpiGbl_Optarg, NULL, 16); 722a9d8d09cSJung-uk Kim break; 723a9d8d09cSJung-uk Kim 724a9d8d09cSJung-uk Kim case 'z': 725a9d8d09cSJung-uk Kim 726a9d8d09cSJung-uk Kim Gbl_UseOriginalCompilerId = TRUE; 727a9d8d09cSJung-uk Kim break; 728a9d8d09cSJung-uk Kim 729a9d8d09cSJung-uk Kim default: 730a9d8d09cSJung-uk Kim 731a9d8d09cSJung-uk Kim return (-1); 732a9d8d09cSJung-uk Kim } 733a9d8d09cSJung-uk Kim 734a9d8d09cSJung-uk Kim return (0); 735a9d8d09cSJung-uk Kim } 736a9d8d09cSJung-uk Kim 737a9d8d09cSJung-uk Kim 738a9d8d09cSJung-uk Kim /******************************************************************************* 739a9d8d09cSJung-uk Kim * 740a9d8d09cSJung-uk Kim * FUNCTION: AslMergeOptionTokens 741a9d8d09cSJung-uk Kim * 742a9d8d09cSJung-uk Kim * PARAMETERS: InBuffer - Input containing an option string 743a9d8d09cSJung-uk Kim * OutBuffer - Merged output buffer 744a9d8d09cSJung-uk Kim * 745a9d8d09cSJung-uk Kim * RETURN: None 746a9d8d09cSJung-uk Kim * 747a9d8d09cSJung-uk Kim * DESCRIPTION: Remove all whitespace from an option string. 748a9d8d09cSJung-uk Kim * 749a9d8d09cSJung-uk Kim ******************************************************************************/ 750a9d8d09cSJung-uk Kim 751a9d8d09cSJung-uk Kim static void 752a9d8d09cSJung-uk Kim AslMergeOptionTokens ( 753a9d8d09cSJung-uk Kim char *InBuffer, 754a9d8d09cSJung-uk Kim char *OutBuffer) 755a9d8d09cSJung-uk Kim { 756a9d8d09cSJung-uk Kim char *Token; 757a9d8d09cSJung-uk Kim 758a9d8d09cSJung-uk Kim 759a9d8d09cSJung-uk Kim *OutBuffer = 0; 760a9d8d09cSJung-uk Kim 761a9d8d09cSJung-uk Kim Token = strtok (InBuffer, ASL_TOKEN_SEPARATORS); 762a9d8d09cSJung-uk Kim while (Token) 763a9d8d09cSJung-uk Kim { 764a9d8d09cSJung-uk Kim strcat (OutBuffer, Token); 765a9d8d09cSJung-uk Kim Token = strtok (NULL, ASL_TOKEN_SEPARATORS); 766a9d8d09cSJung-uk Kim } 767a9d8d09cSJung-uk Kim } 768a9d8d09cSJung-uk Kim 769a9d8d09cSJung-uk Kim 770a9d8d09cSJung-uk Kim /******************************************************************************* 771a9d8d09cSJung-uk Kim * 772a9d8d09cSJung-uk Kim * FUNCTION: AslDoResponseFile 773a9d8d09cSJung-uk Kim * 774a9d8d09cSJung-uk Kim * PARAMETERS: Filename - Name of the response file 775a9d8d09cSJung-uk Kim * 776a9d8d09cSJung-uk Kim * RETURN: Status 777a9d8d09cSJung-uk Kim * 778a9d8d09cSJung-uk Kim * DESCRIPTION: Open a response file and process all options within. 779a9d8d09cSJung-uk Kim * 780a9d8d09cSJung-uk Kim ******************************************************************************/ 781a9d8d09cSJung-uk Kim 782a9d8d09cSJung-uk Kim static int 783a9d8d09cSJung-uk Kim AslDoResponseFile ( 784a9d8d09cSJung-uk Kim char *Filename) 785a9d8d09cSJung-uk Kim { 786a9d8d09cSJung-uk Kim char *argv = StringBuffer2; 787a9d8d09cSJung-uk Kim FILE *ResponseFile; 788a9d8d09cSJung-uk Kim int OptStatus = 0; 789a9d8d09cSJung-uk Kim int Opterr; 790a9d8d09cSJung-uk Kim int Optind; 791a9d8d09cSJung-uk Kim 792a9d8d09cSJung-uk Kim 793a9d8d09cSJung-uk Kim ResponseFile = fopen (Filename, "r"); 794a9d8d09cSJung-uk Kim if (!ResponseFile) 795a9d8d09cSJung-uk Kim { 796a9d8d09cSJung-uk Kim printf ("Could not open command file %s, %s\n", 797a9d8d09cSJung-uk Kim Filename, strerror (errno)); 798a9d8d09cSJung-uk Kim return (-1); 799a9d8d09cSJung-uk Kim } 800a9d8d09cSJung-uk Kim 801a9d8d09cSJung-uk Kim /* Must save the current GetOpt globals */ 802a9d8d09cSJung-uk Kim 803a9d8d09cSJung-uk Kim Opterr = AcpiGbl_Opterr; 804a9d8d09cSJung-uk Kim Optind = AcpiGbl_Optind; 805a9d8d09cSJung-uk Kim 806a9d8d09cSJung-uk Kim /* 807a9d8d09cSJung-uk Kim * Process all lines in the response file. There must be one complete 808a9d8d09cSJung-uk Kim * option per line 809a9d8d09cSJung-uk Kim */ 810a9d8d09cSJung-uk Kim while (fgets (StringBuffer, ASL_MSG_BUFFER_SIZE, ResponseFile)) 811a9d8d09cSJung-uk Kim { 812a9d8d09cSJung-uk Kim /* Compress all tokens, allowing us to use a single argv entry */ 813a9d8d09cSJung-uk Kim 814a9d8d09cSJung-uk Kim AslMergeOptionTokens (StringBuffer, StringBuffer2); 815a9d8d09cSJung-uk Kim 816a9d8d09cSJung-uk Kim /* Process the option */ 817a9d8d09cSJung-uk Kim 818a9d8d09cSJung-uk Kim AcpiGbl_Opterr = 0; 819a9d8d09cSJung-uk Kim AcpiGbl_Optind = 0; 820a9d8d09cSJung-uk Kim 821a9d8d09cSJung-uk Kim OptStatus = AslDoOptions (1, &argv, TRUE); 822a9d8d09cSJung-uk Kim if (OptStatus) 823a9d8d09cSJung-uk Kim { 824a9d8d09cSJung-uk Kim printf ("Invalid option in command file %s: %s\n", 825a9d8d09cSJung-uk Kim Filename, StringBuffer); 826a9d8d09cSJung-uk Kim break; 827a9d8d09cSJung-uk Kim } 828a9d8d09cSJung-uk Kim } 829a9d8d09cSJung-uk Kim 830a9d8d09cSJung-uk Kim /* Restore the GetOpt globals */ 831a9d8d09cSJung-uk Kim 832a9d8d09cSJung-uk Kim AcpiGbl_Opterr = Opterr; 833a9d8d09cSJung-uk Kim AcpiGbl_Optind = Optind; 834a9d8d09cSJung-uk Kim 835a9d8d09cSJung-uk Kim fclose (ResponseFile); 836a9d8d09cSJung-uk Kim return (OptStatus); 837a9d8d09cSJung-uk Kim } 838