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 7*0d84335fSJung-uk Kim /****************************************************************************** 8*0d84335fSJung-uk Kim * 9*0d84335fSJung-uk Kim * 1. Copyright Notice 10*0d84335fSJung-uk Kim * 11*0d84335fSJung-uk Kim * Some or all of this work - Copyright (c) 1999 - 2017, Intel Corp. 12a9d8d09cSJung-uk Kim * All rights reserved. 13a9d8d09cSJung-uk Kim * 14*0d84335fSJung-uk Kim * 2. License 15*0d84335fSJung-uk Kim * 16*0d84335fSJung-uk Kim * 2.1. This is your license from Intel Corp. under its intellectual property 17*0d84335fSJung-uk Kim * rights. You may have additional license terms from the party that provided 18*0d84335fSJung-uk Kim * you this software, covering your right to use that party's intellectual 19*0d84335fSJung-uk Kim * property rights. 20*0d84335fSJung-uk Kim * 21*0d84335fSJung-uk Kim * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 22*0d84335fSJung-uk Kim * copy of the source code appearing in this file ("Covered Code") an 23*0d84335fSJung-uk Kim * irrevocable, perpetual, worldwide license under Intel's copyrights in the 24*0d84335fSJung-uk Kim * base code distributed originally by Intel ("Original Intel Code") to copy, 25*0d84335fSJung-uk Kim * make derivatives, distribute, use and display any portion of the Covered 26*0d84335fSJung-uk Kim * Code in any form, with the right to sublicense such rights; and 27*0d84335fSJung-uk Kim * 28*0d84335fSJung-uk Kim * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 29*0d84335fSJung-uk Kim * license (with the right to sublicense), under only those claims of Intel 30*0d84335fSJung-uk Kim * patents that are infringed by the Original Intel Code, to make, use, sell, 31*0d84335fSJung-uk Kim * offer to sell, and import the Covered Code and derivative works thereof 32*0d84335fSJung-uk Kim * solely to the minimum extent necessary to exercise the above copyright 33*0d84335fSJung-uk Kim * license, and in no event shall the patent license extend to any additions 34*0d84335fSJung-uk Kim * to or modifications of the Original Intel Code. No other license or right 35*0d84335fSJung-uk Kim * is granted directly or by implication, estoppel or otherwise; 36*0d84335fSJung-uk Kim * 37*0d84335fSJung-uk Kim * The above copyright and patent license is granted only if the following 38*0d84335fSJung-uk Kim * conditions are met: 39*0d84335fSJung-uk Kim * 40*0d84335fSJung-uk Kim * 3. Conditions 41*0d84335fSJung-uk Kim * 42*0d84335fSJung-uk Kim * 3.1. Redistribution of Source with Rights to Further Distribute Source. 43*0d84335fSJung-uk Kim * Redistribution of source code of any substantial portion of the Covered 44*0d84335fSJung-uk Kim * Code or modification with rights to further distribute source must include 45*0d84335fSJung-uk Kim * the above Copyright Notice, the above License, this list of Conditions, 46*0d84335fSJung-uk Kim * and the following Disclaimer and Export Compliance provision. In addition, 47*0d84335fSJung-uk Kim * Licensee must cause all Covered Code to which Licensee contributes to 48*0d84335fSJung-uk Kim * contain a file documenting the changes Licensee made to create that Covered 49*0d84335fSJung-uk Kim * Code and the date of any change. Licensee must include in that file the 50*0d84335fSJung-uk Kim * documentation of any changes made by any predecessor Licensee. Licensee 51*0d84335fSJung-uk Kim * must include a prominent statement that the modification is derived, 52*0d84335fSJung-uk Kim * directly or indirectly, from Original Intel Code. 53*0d84335fSJung-uk Kim * 54*0d84335fSJung-uk Kim * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 55*0d84335fSJung-uk Kim * Redistribution of source code of any substantial portion of the Covered 56*0d84335fSJung-uk Kim * Code or modification without rights to further distribute source must 57*0d84335fSJung-uk Kim * include the following Disclaimer and Export Compliance provision in the 58*0d84335fSJung-uk Kim * documentation and/or other materials provided with distribution. In 59*0d84335fSJung-uk Kim * addition, Licensee may not authorize further sublicense of source of any 60*0d84335fSJung-uk Kim * portion of the Covered Code, and must include terms to the effect that the 61*0d84335fSJung-uk Kim * license from Licensee to its licensee is limited to the intellectual 62*0d84335fSJung-uk Kim * property embodied in the software Licensee provides to its licensee, and 63*0d84335fSJung-uk Kim * not to intellectual property embodied in modifications its licensee may 64*0d84335fSJung-uk Kim * make. 65*0d84335fSJung-uk Kim * 66*0d84335fSJung-uk Kim * 3.3. Redistribution of Executable. Redistribution in executable form of any 67*0d84335fSJung-uk Kim * substantial portion of the Covered Code or modification must reproduce the 68*0d84335fSJung-uk Kim * above Copyright Notice, and the following Disclaimer and Export Compliance 69*0d84335fSJung-uk Kim * provision in the documentation and/or other materials provided with the 70*0d84335fSJung-uk Kim * distribution. 71*0d84335fSJung-uk Kim * 72*0d84335fSJung-uk Kim * 3.4. Intel retains all right, title, and interest in and to the Original 73*0d84335fSJung-uk Kim * Intel Code. 74*0d84335fSJung-uk Kim * 75*0d84335fSJung-uk Kim * 3.5. Neither the name Intel nor any other trademark owned or controlled by 76*0d84335fSJung-uk Kim * Intel shall be used in advertising or otherwise to promote the sale, use or 77*0d84335fSJung-uk Kim * other dealings in products derived from or relating to the Covered Code 78*0d84335fSJung-uk Kim * without prior written authorization from Intel. 79*0d84335fSJung-uk Kim * 80*0d84335fSJung-uk Kim * 4. Disclaimer and Export Compliance 81*0d84335fSJung-uk Kim * 82*0d84335fSJung-uk Kim * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 83*0d84335fSJung-uk Kim * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 84*0d84335fSJung-uk Kim * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 85*0d84335fSJung-uk Kim * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 86*0d84335fSJung-uk Kim * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 87*0d84335fSJung-uk Kim * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 88*0d84335fSJung-uk Kim * PARTICULAR PURPOSE. 89*0d84335fSJung-uk Kim * 90*0d84335fSJung-uk Kim * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 91*0d84335fSJung-uk Kim * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 92*0d84335fSJung-uk Kim * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 93*0d84335fSJung-uk Kim * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 94*0d84335fSJung-uk Kim * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 95*0d84335fSJung-uk Kim * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 96*0d84335fSJung-uk Kim * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 97*0d84335fSJung-uk Kim * LIMITED REMEDY. 98*0d84335fSJung-uk Kim * 99*0d84335fSJung-uk Kim * 4.3. Licensee shall not export, either directly or indirectly, any of this 100*0d84335fSJung-uk Kim * software or system incorporating such software without first obtaining any 101*0d84335fSJung-uk Kim * required license or other approval from the U. S. Department of Commerce or 102*0d84335fSJung-uk Kim * any other agency or department of the United States Government. In the 103*0d84335fSJung-uk Kim * event Licensee exports any such software from the United States or 104*0d84335fSJung-uk Kim * re-exports any such software from a foreign destination, Licensee shall 105*0d84335fSJung-uk Kim * ensure that the distribution and export/re-export of the software is in 106*0d84335fSJung-uk Kim * compliance with all laws, regulations, orders, or other restrictions of the 107*0d84335fSJung-uk Kim * U.S. Export Administration Regulations. Licensee agrees that neither it nor 108*0d84335fSJung-uk Kim * any of its subsidiaries will export/re-export any technical data, process, 109*0d84335fSJung-uk Kim * software, or service, directly or indirectly, to any country for which the 110*0d84335fSJung-uk Kim * United States government or any agency thereof requires an export license, 111*0d84335fSJung-uk Kim * other governmental approval, or letter of assurance, without first obtaining 112*0d84335fSJung-uk Kim * such license, approval or letter. 113*0d84335fSJung-uk Kim * 114*0d84335fSJung-uk Kim ***************************************************************************** 115*0d84335fSJung-uk Kim * 116*0d84335fSJung-uk Kim * Alternatively, you may choose to be licensed under the terms of the 117*0d84335fSJung-uk Kim * following license: 118*0d84335fSJung-uk Kim * 119a9d8d09cSJung-uk Kim * Redistribution and use in source and binary forms, with or without 120a9d8d09cSJung-uk Kim * modification, are permitted provided that the following conditions 121a9d8d09cSJung-uk Kim * are met: 122a9d8d09cSJung-uk Kim * 1. Redistributions of source code must retain the above copyright 123a9d8d09cSJung-uk Kim * notice, this list of conditions, and the following disclaimer, 124a9d8d09cSJung-uk Kim * without modification. 125a9d8d09cSJung-uk Kim * 2. Redistributions in binary form must reproduce at minimum a disclaimer 126a9d8d09cSJung-uk Kim * substantially similar to the "NO WARRANTY" disclaimer below 127a9d8d09cSJung-uk Kim * ("Disclaimer") and any redistribution must be conditioned upon 128a9d8d09cSJung-uk Kim * including a substantially similar Disclaimer requirement for further 129a9d8d09cSJung-uk Kim * binary redistribution. 130a9d8d09cSJung-uk Kim * 3. Neither the names of the above-listed copyright holders nor the names 131a9d8d09cSJung-uk Kim * of any contributors may be used to endorse or promote products derived 132a9d8d09cSJung-uk Kim * from this software without specific prior written permission. 133a9d8d09cSJung-uk Kim * 134*0d84335fSJung-uk Kim * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 135*0d84335fSJung-uk Kim * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 136*0d84335fSJung-uk Kim * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 137*0d84335fSJung-uk Kim * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 138*0d84335fSJung-uk Kim * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 139*0d84335fSJung-uk Kim * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 140*0d84335fSJung-uk Kim * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 141*0d84335fSJung-uk Kim * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 142*0d84335fSJung-uk Kim * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 143*0d84335fSJung-uk Kim * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 144*0d84335fSJung-uk Kim * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 145*0d84335fSJung-uk Kim * 146*0d84335fSJung-uk Kim * Alternatively, you may choose to be licensed under the terms of the 147a9d8d09cSJung-uk Kim * GNU General Public License ("GPL") version 2 as published by the Free 148a9d8d09cSJung-uk Kim * Software Foundation. 149a9d8d09cSJung-uk Kim * 150*0d84335fSJung-uk Kim *****************************************************************************/ 151a9d8d09cSJung-uk Kim 152a9d8d09cSJung-uk Kim #include <contrib/dev/acpica/compiler/aslcompiler.h> 153a9d8d09cSJung-uk Kim #include <contrib/dev/acpica/include/acapps.h> 154a9d8d09cSJung-uk Kim #include <contrib/dev/acpica/include/acdisasm.h> 155a9d8d09cSJung-uk Kim 156a9d8d09cSJung-uk Kim #define _COMPONENT ACPI_COMPILER 157a9d8d09cSJung-uk Kim ACPI_MODULE_NAME ("asloption") 158a9d8d09cSJung-uk Kim 159a9d8d09cSJung-uk Kim 160a9d8d09cSJung-uk Kim /* Local prototypes */ 161a9d8d09cSJung-uk Kim 162a9d8d09cSJung-uk Kim static int 163a9d8d09cSJung-uk Kim AslDoOptions ( 164a9d8d09cSJung-uk Kim int argc, 165a9d8d09cSJung-uk Kim char **argv, 166a9d8d09cSJung-uk Kim BOOLEAN IsResponseFile); 167a9d8d09cSJung-uk Kim 168a9d8d09cSJung-uk Kim static void 169a9d8d09cSJung-uk Kim AslMergeOptionTokens ( 170a9d8d09cSJung-uk Kim char *InBuffer, 171a9d8d09cSJung-uk Kim char *OutBuffer); 172a9d8d09cSJung-uk Kim 173a9d8d09cSJung-uk Kim static int 174a9d8d09cSJung-uk Kim AslDoResponseFile ( 175a9d8d09cSJung-uk Kim char *Filename); 176a9d8d09cSJung-uk Kim 177a9d8d09cSJung-uk Kim 178a9d8d09cSJung-uk Kim #define ASL_TOKEN_SEPARATORS " \t\n" 179*0d84335fSJung-uk Kim #define ASL_SUPPORTED_OPTIONS "@:a:b|c|d^D:e:f^gh^i|I:l^m:no|p:P^q^r:s|t|T+G^v^w|x:z" 180a9d8d09cSJung-uk Kim 181a9d8d09cSJung-uk Kim 182a9d8d09cSJung-uk Kim /******************************************************************************* 183a9d8d09cSJung-uk Kim * 184a9d8d09cSJung-uk Kim * FUNCTION: AslCommandLine 185a9d8d09cSJung-uk Kim * 186a9d8d09cSJung-uk Kim * PARAMETERS: argc/argv 187a9d8d09cSJung-uk Kim * 188a9d8d09cSJung-uk Kim * RETURN: Last argv index 189a9d8d09cSJung-uk Kim * 190a9d8d09cSJung-uk Kim * DESCRIPTION: Command line processing 191a9d8d09cSJung-uk Kim * 192a9d8d09cSJung-uk Kim ******************************************************************************/ 193a9d8d09cSJung-uk Kim 194a9d8d09cSJung-uk Kim int 195a9d8d09cSJung-uk Kim AslCommandLine ( 196a9d8d09cSJung-uk Kim int argc, 197a9d8d09cSJung-uk Kim char **argv) 198a9d8d09cSJung-uk Kim { 199a9d8d09cSJung-uk Kim int BadCommandLine = 0; 200a9d8d09cSJung-uk Kim ACPI_STATUS Status; 201a9d8d09cSJung-uk Kim 202a9d8d09cSJung-uk Kim 203a9d8d09cSJung-uk Kim /* Minimum command line contains at least the command and an input file */ 204a9d8d09cSJung-uk Kim 205a9d8d09cSJung-uk Kim if (argc < 2) 206a9d8d09cSJung-uk Kim { 207a9d8d09cSJung-uk Kim printf (ACPI_COMMON_SIGNON (ASL_COMPILER_NAME)); 208a9d8d09cSJung-uk Kim Usage (); 209a9d8d09cSJung-uk Kim exit (1); 210a9d8d09cSJung-uk Kim } 211a9d8d09cSJung-uk Kim 212a9d8d09cSJung-uk Kim /* Process all command line options */ 213a9d8d09cSJung-uk Kim 214a9d8d09cSJung-uk Kim BadCommandLine = AslDoOptions (argc, argv, FALSE); 215a9d8d09cSJung-uk Kim 216a9d8d09cSJung-uk Kim if (Gbl_DoTemplates) 217a9d8d09cSJung-uk Kim { 218f8146b88SJung-uk Kim Status = DtCreateTemplates (argv); 219a9d8d09cSJung-uk Kim if (ACPI_FAILURE (Status)) 220a9d8d09cSJung-uk Kim { 221a9d8d09cSJung-uk Kim exit (-1); 222a9d8d09cSJung-uk Kim } 223a9d8d09cSJung-uk Kim exit (1); 224a9d8d09cSJung-uk Kim } 225a9d8d09cSJung-uk Kim 226a9d8d09cSJung-uk Kim /* Next parameter must be the input filename */ 227a9d8d09cSJung-uk Kim 228a9d8d09cSJung-uk Kim if (!argv[AcpiGbl_Optind] && 229313a0c13SJung-uk Kim !Gbl_DisasmFlag) 230a9d8d09cSJung-uk Kim { 231a9d8d09cSJung-uk Kim printf ("Missing input filename\n"); 232a9d8d09cSJung-uk Kim BadCommandLine = TRUE; 233a9d8d09cSJung-uk Kim } 234a9d8d09cSJung-uk Kim 235a9d8d09cSJung-uk Kim if (Gbl_DoSignon) 236a9d8d09cSJung-uk Kim { 237a9d8d09cSJung-uk Kim printf (ACPI_COMMON_SIGNON (ASL_COMPILER_NAME)); 238a9d8d09cSJung-uk Kim if (Gbl_IgnoreErrors) 239a9d8d09cSJung-uk Kim { 240a9d8d09cSJung-uk Kim printf ("Ignoring all errors, forcing AML file generation\n\n"); 241a9d8d09cSJung-uk Kim } 242a9d8d09cSJung-uk Kim } 243a9d8d09cSJung-uk Kim 244a9d8d09cSJung-uk Kim if (BadCommandLine) 245a9d8d09cSJung-uk Kim { 24679c6d946SJung-uk Kim printf ("Use -h option for help information\n"); 247a9d8d09cSJung-uk Kim exit (1); 248a9d8d09cSJung-uk Kim } 249a9d8d09cSJung-uk Kim 250a9d8d09cSJung-uk Kim return (AcpiGbl_Optind); 251a9d8d09cSJung-uk Kim } 252a9d8d09cSJung-uk Kim 253a9d8d09cSJung-uk Kim 254a9d8d09cSJung-uk Kim /******************************************************************************* 255a9d8d09cSJung-uk Kim * 256a9d8d09cSJung-uk Kim * FUNCTION: AslDoOptions 257a9d8d09cSJung-uk Kim * 258a9d8d09cSJung-uk Kim * PARAMETERS: argc/argv - Standard argc/argv 259a9d8d09cSJung-uk Kim * IsResponseFile - TRUE if executing a response file. 260a9d8d09cSJung-uk Kim * 261a9d8d09cSJung-uk Kim * RETURN: Status 262a9d8d09cSJung-uk Kim * 263a9d8d09cSJung-uk Kim * DESCRIPTION: Command line option processing 264a9d8d09cSJung-uk Kim * 265a9d8d09cSJung-uk Kim ******************************************************************************/ 266a9d8d09cSJung-uk Kim 267a9d8d09cSJung-uk Kim static int 268a9d8d09cSJung-uk Kim AslDoOptions ( 269a9d8d09cSJung-uk Kim int argc, 270a9d8d09cSJung-uk Kim char **argv, 271a9d8d09cSJung-uk Kim BOOLEAN IsResponseFile) 272a9d8d09cSJung-uk Kim { 273a9d8d09cSJung-uk Kim ACPI_STATUS Status; 274a9d8d09cSJung-uk Kim UINT32 j; 275a9d8d09cSJung-uk Kim 276a9d8d09cSJung-uk Kim 277a9d8d09cSJung-uk Kim /* Get the command line options */ 278a9d8d09cSJung-uk Kim 279313a0c13SJung-uk Kim while ((j = AcpiGetopt (argc, argv, ASL_SUPPORTED_OPTIONS)) != ACPI_OPT_END) switch (j) 280a9d8d09cSJung-uk Kim { 281a9d8d09cSJung-uk Kim case '@': /* Begin a response file */ 282a9d8d09cSJung-uk Kim 283a9d8d09cSJung-uk Kim if (IsResponseFile) 284a9d8d09cSJung-uk Kim { 285a9d8d09cSJung-uk Kim printf ("Nested command files are not supported\n"); 286a9d8d09cSJung-uk Kim return (-1); 287a9d8d09cSJung-uk Kim } 288a9d8d09cSJung-uk Kim 289a9d8d09cSJung-uk Kim if (AslDoResponseFile (AcpiGbl_Optarg)) 290a9d8d09cSJung-uk Kim { 291a9d8d09cSJung-uk Kim return (-1); 292a9d8d09cSJung-uk Kim } 293a9d8d09cSJung-uk Kim break; 294a9d8d09cSJung-uk Kim 295f8146b88SJung-uk Kim case 'a': /* Debug options */ 296f8146b88SJung-uk Kim 297f8146b88SJung-uk Kim switch (AcpiGbl_Optarg[0]) 298f8146b88SJung-uk Kim { 299f8146b88SJung-uk Kim case 'r': 300f8146b88SJung-uk Kim 301f8146b88SJung-uk Kim Gbl_EnableReferenceTypechecking = TRUE; 302f8146b88SJung-uk Kim break; 303f8146b88SJung-uk Kim 304f8146b88SJung-uk Kim default: 305f8146b88SJung-uk Kim 306f8146b88SJung-uk Kim printf ("Unknown option: -a%s\n", AcpiGbl_Optarg); 307f8146b88SJung-uk Kim return (-1); 308f8146b88SJung-uk Kim } 309f8146b88SJung-uk Kim 310f8146b88SJung-uk Kim break; 311f8146b88SJung-uk Kim 312f8146b88SJung-uk Kim 3131c0e1b6dSJung-uk Kim case 'b': /* Debug options */ 314a9d8d09cSJung-uk Kim 315a9d8d09cSJung-uk Kim switch (AcpiGbl_Optarg[0]) 316a9d8d09cSJung-uk Kim { 317*0d84335fSJung-uk Kim 318*0d84335fSJung-uk Kim case 'c': 319*0d84335fSJung-uk Kim 320*0d84335fSJung-uk Kim printf ("Debug ASL to ASL+ conversion\n"); 321*0d84335fSJung-uk Kim 322*0d84335fSJung-uk Kim Gbl_DoAslConversion = TRUE; 323*0d84335fSJung-uk Kim Gbl_FoldConstants = FALSE; 324*0d84335fSJung-uk Kim Gbl_IntegerOptimizationFlag = FALSE; 325*0d84335fSJung-uk Kim Gbl_ReferenceOptimizationFlag = FALSE; 326*0d84335fSJung-uk Kim Gbl_OptimizeTrivialParseNodes = FALSE; 327*0d84335fSJung-uk Kim Gbl_CaptureComments = TRUE; 328*0d84335fSJung-uk Kim AcpiGbl_DoDisassemblerOptimizations = FALSE; 329*0d84335fSJung-uk Kim AcpiGbl_DebugAslConversion = TRUE; 330*0d84335fSJung-uk Kim AcpiGbl_DmEmitExternalOpcodes = TRUE; 331*0d84335fSJung-uk Kim Gbl_DoExternalsInPlace = TRUE; 332*0d84335fSJung-uk Kim 333*0d84335fSJung-uk Kim return (0); 334*0d84335fSJung-uk Kim 335a9d8d09cSJung-uk Kim case 'f': 336a9d8d09cSJung-uk Kim 337a9d8d09cSJung-uk Kim AslCompilerdebug = 1; /* same as yydebug */ 338a9d8d09cSJung-uk Kim DtParserdebug = 1; 339a9d8d09cSJung-uk Kim PrParserdebug = 1; 3401c0e1b6dSJung-uk Kim Gbl_DebugFlag = TRUE; 3415ef50723SJung-uk Kim Gbl_KeepPreprocessorTempFile = TRUE; 3421c0e1b6dSJung-uk Kim break; 3431c0e1b6dSJung-uk Kim 3441c0e1b6dSJung-uk Kim case 'p': /* Prune ASL parse tree */ 3451c0e1b6dSJung-uk Kim 3461c0e1b6dSJung-uk Kim /* Get the required argument */ 3471c0e1b6dSJung-uk Kim 3481c0e1b6dSJung-uk Kim if (AcpiGetoptArgument (argc, argv)) 3491c0e1b6dSJung-uk Kim { 3501c0e1b6dSJung-uk Kim return (-1); 3511c0e1b6dSJung-uk Kim } 3521c0e1b6dSJung-uk Kim 3531c0e1b6dSJung-uk Kim Gbl_PruneParseTree = TRUE; 3541c0e1b6dSJung-uk Kim Gbl_PruneDepth = (UINT8) strtoul (AcpiGbl_Optarg, NULL, 0); 3551c0e1b6dSJung-uk Kim break; 3561c0e1b6dSJung-uk Kim 3571c0e1b6dSJung-uk Kim case 's': 3581c0e1b6dSJung-uk Kim 3591c0e1b6dSJung-uk Kim Gbl_DebugFlag = TRUE; 360a9d8d09cSJung-uk Kim break; 361a9d8d09cSJung-uk Kim 362a9d8d09cSJung-uk Kim case 't': 363a9d8d09cSJung-uk Kim 3641c0e1b6dSJung-uk Kim /* Get the required argument */ 3651c0e1b6dSJung-uk Kim 3661c0e1b6dSJung-uk Kim if (AcpiGetoptArgument (argc, argv)) 3671c0e1b6dSJung-uk Kim { 3681c0e1b6dSJung-uk Kim return (-1); 3691c0e1b6dSJung-uk Kim } 3701c0e1b6dSJung-uk Kim 3711c0e1b6dSJung-uk Kim Gbl_PruneType = (UINT8) strtoul (AcpiGbl_Optarg, NULL, 0); 372a9d8d09cSJung-uk Kim break; 373a9d8d09cSJung-uk Kim 374a9d8d09cSJung-uk Kim default: 375a9d8d09cSJung-uk Kim 376a9d8d09cSJung-uk Kim printf ("Unknown option: -b%s\n", AcpiGbl_Optarg); 377a9d8d09cSJung-uk Kim return (-1); 378a9d8d09cSJung-uk Kim } 379a9d8d09cSJung-uk Kim 380a9d8d09cSJung-uk Kim break; 381a9d8d09cSJung-uk Kim 382a9d8d09cSJung-uk Kim case 'c': 383a9d8d09cSJung-uk Kim 384a9d8d09cSJung-uk Kim switch (AcpiGbl_Optarg[0]) 385a9d8d09cSJung-uk Kim { 386*0d84335fSJung-uk Kim 387*0d84335fSJung-uk Kim case 'a': 388*0d84335fSJung-uk Kim 389*0d84335fSJung-uk Kim printf ("Convert ASL to ASL+ with comments\n"); 390*0d84335fSJung-uk Kim Gbl_DoAslConversion = TRUE; 391*0d84335fSJung-uk Kim Gbl_FoldConstants = FALSE; 392*0d84335fSJung-uk Kim Gbl_IntegerOptimizationFlag = FALSE; 393*0d84335fSJung-uk Kim Gbl_ReferenceOptimizationFlag = FALSE; 394*0d84335fSJung-uk Kim Gbl_OptimizeTrivialParseNodes = FALSE; 395*0d84335fSJung-uk Kim Gbl_CaptureComments = TRUE; 396*0d84335fSJung-uk Kim AcpiGbl_DoDisassemblerOptimizations = FALSE; 397*0d84335fSJung-uk Kim AcpiGbl_DmEmitExternalOpcodes = TRUE; 398*0d84335fSJung-uk Kim Gbl_DoExternalsInPlace = TRUE; 399*0d84335fSJung-uk Kim 400*0d84335fSJung-uk Kim return (0); 401*0d84335fSJung-uk Kim 402a9d8d09cSJung-uk Kim case 'r': 403a9d8d09cSJung-uk Kim 404a9d8d09cSJung-uk Kim Gbl_NoResourceChecking = TRUE; 405a9d8d09cSJung-uk Kim break; 406a9d8d09cSJung-uk Kim 407a9d8d09cSJung-uk Kim default: 408a9d8d09cSJung-uk Kim 409a9d8d09cSJung-uk Kim printf ("Unknown option: -c%s\n", AcpiGbl_Optarg); 410a9d8d09cSJung-uk Kim return (-1); 411a9d8d09cSJung-uk Kim } 412a9d8d09cSJung-uk Kim break; 413a9d8d09cSJung-uk Kim 414a9d8d09cSJung-uk Kim case 'd': /* Disassembler */ 415a9d8d09cSJung-uk Kim 416a9d8d09cSJung-uk Kim switch (AcpiGbl_Optarg[0]) 417a9d8d09cSJung-uk Kim { 418a9d8d09cSJung-uk Kim case '^': 419a9d8d09cSJung-uk Kim 420493deb39SJung-uk Kim /* Get the required argument */ 421493deb39SJung-uk Kim 422493deb39SJung-uk Kim if (AcpiGetoptArgument (argc, argv)) 423493deb39SJung-uk Kim { 424493deb39SJung-uk Kim return (-1); 425493deb39SJung-uk Kim } 426493deb39SJung-uk Kim 427a9d8d09cSJung-uk Kim Gbl_DoCompile = FALSE; 428a9d8d09cSJung-uk Kim break; 429a9d8d09cSJung-uk Kim 430a9d8d09cSJung-uk Kim case 'a': 431a9d8d09cSJung-uk Kim 432493deb39SJung-uk Kim /* Get the required argument */ 433493deb39SJung-uk Kim 434493deb39SJung-uk Kim if (AcpiGetoptArgument (argc, argv)) 435493deb39SJung-uk Kim { 436493deb39SJung-uk Kim return (-1); 437493deb39SJung-uk Kim } 438493deb39SJung-uk Kim 439a9d8d09cSJung-uk Kim Gbl_DoCompile = FALSE; 440a9d8d09cSJung-uk Kim Gbl_DisassembleAll = TRUE; 441a9d8d09cSJung-uk Kim break; 442a9d8d09cSJung-uk Kim 443a9d8d09cSJung-uk Kim case 'b': /* Do not convert buffers to resource descriptors */ 444a9d8d09cSJung-uk Kim 445a9d8d09cSJung-uk Kim AcpiGbl_NoResourceDisassembly = TRUE; 446a9d8d09cSJung-uk Kim break; 447a9d8d09cSJung-uk Kim 448a9d8d09cSJung-uk Kim case 'c': 449a9d8d09cSJung-uk Kim 450a9d8d09cSJung-uk Kim break; 451a9d8d09cSJung-uk Kim 4527cf3e94aSJung-uk Kim case 'f': 4537cf3e94aSJung-uk Kim 4547cf3e94aSJung-uk Kim AcpiGbl_ForceAmlDisassembly = TRUE; 4557cf3e94aSJung-uk Kim break; 4567cf3e94aSJung-uk Kim 4571c0e1b6dSJung-uk Kim case 'l': /* Use legacy ASL code (not ASL+) for disassembly */ 4581c0e1b6dSJung-uk Kim 4591c0e1b6dSJung-uk Kim Gbl_DoCompile = FALSE; 4601c0e1b6dSJung-uk Kim AcpiGbl_CstyleDisassembly = FALSE; 4611c0e1b6dSJung-uk Kim break; 4621c0e1b6dSJung-uk Kim 463a9d8d09cSJung-uk Kim default: 464a9d8d09cSJung-uk Kim 465a9d8d09cSJung-uk Kim printf ("Unknown option: -d%s\n", AcpiGbl_Optarg); 466a9d8d09cSJung-uk Kim return (-1); 467a9d8d09cSJung-uk Kim } 468a9d8d09cSJung-uk Kim 469a9d8d09cSJung-uk Kim Gbl_DisasmFlag = TRUE; 470a9d8d09cSJung-uk Kim break; 471a9d8d09cSJung-uk Kim 472a9d8d09cSJung-uk Kim case 'D': /* Define a symbol */ 473a9d8d09cSJung-uk Kim 474a9d8d09cSJung-uk Kim PrAddDefine (AcpiGbl_Optarg, NULL, TRUE); 475a9d8d09cSJung-uk Kim break; 476a9d8d09cSJung-uk Kim 477a9d8d09cSJung-uk Kim case 'e': /* External files for disassembler */ 478a9d8d09cSJung-uk Kim 479313a0c13SJung-uk Kim /* Get entire list of external files */ 480313a0c13SJung-uk Kim 481313a0c13SJung-uk Kim AcpiGbl_Optind--; 482313a0c13SJung-uk Kim argv[AcpiGbl_Optind] = AcpiGbl_Optarg; 483313a0c13SJung-uk Kim 484313a0c13SJung-uk Kim while (argv[AcpiGbl_Optind] && 485313a0c13SJung-uk Kim (argv[AcpiGbl_Optind][0] != '-')) 486313a0c13SJung-uk Kim { 487313a0c13SJung-uk Kim Status = AcpiDmAddToExternalFileList (argv[AcpiGbl_Optind]); 488a9d8d09cSJung-uk Kim if (ACPI_FAILURE (Status)) 489a9d8d09cSJung-uk Kim { 490f8146b88SJung-uk Kim printf ("Could not add %s to external list\n", 491f8146b88SJung-uk Kim argv[AcpiGbl_Optind]); 492a9d8d09cSJung-uk Kim return (-1); 493a9d8d09cSJung-uk Kim } 494313a0c13SJung-uk Kim 495313a0c13SJung-uk Kim AcpiGbl_Optind++; 496313a0c13SJung-uk Kim } 497a9d8d09cSJung-uk Kim break; 498a9d8d09cSJung-uk Kim 49979c6d946SJung-uk Kim case 'f': 50079c6d946SJung-uk Kim 50179c6d946SJung-uk Kim switch (AcpiGbl_Optarg[0]) 50279c6d946SJung-uk Kim { 50379c6d946SJung-uk Kim case '^': /* Ignore errors and force creation of aml file */ 504a9d8d09cSJung-uk Kim 505a9d8d09cSJung-uk Kim Gbl_IgnoreErrors = TRUE; 506a9d8d09cSJung-uk Kim break; 507a9d8d09cSJung-uk Kim 50879c6d946SJung-uk Kim case 'e': /* Disassembler: Get external declaration file */ 50979c6d946SJung-uk Kim 51079c6d946SJung-uk Kim if (AcpiGetoptArgument (argc, argv)) 51179c6d946SJung-uk Kim { 51279c6d946SJung-uk Kim return (-1); 51379c6d946SJung-uk Kim } 51479c6d946SJung-uk Kim 51579c6d946SJung-uk Kim Gbl_ExternalRefFilename = AcpiGbl_Optarg; 51679c6d946SJung-uk Kim break; 51779c6d946SJung-uk Kim 51879c6d946SJung-uk Kim default: 51979c6d946SJung-uk Kim 52079c6d946SJung-uk Kim printf ("Unknown option: -f%s\n", AcpiGbl_Optarg); 52179c6d946SJung-uk Kim return (-1); 52279c6d946SJung-uk Kim } 52379c6d946SJung-uk Kim break; 52479c6d946SJung-uk Kim 525a9d8d09cSJung-uk Kim case 'G': 526a9d8d09cSJung-uk Kim 527a9d8d09cSJung-uk Kim Gbl_CompileGeneric = TRUE; 528a9d8d09cSJung-uk Kim break; 529a9d8d09cSJung-uk Kim 530a9d8d09cSJung-uk Kim case 'g': /* Get all ACPI tables */ 531a9d8d09cSJung-uk Kim 532313a0c13SJung-uk Kim printf ("-g option is deprecated, use acpidump utility instead\n"); 533313a0c13SJung-uk Kim exit (1); 534a9d8d09cSJung-uk Kim 535a9d8d09cSJung-uk Kim case 'h': 536a9d8d09cSJung-uk Kim 537a9d8d09cSJung-uk Kim switch (AcpiGbl_Optarg[0]) 538a9d8d09cSJung-uk Kim { 539a9d8d09cSJung-uk Kim case '^': 540a9d8d09cSJung-uk Kim 541a9d8d09cSJung-uk Kim Usage (); 542a9d8d09cSJung-uk Kim exit (0); 543a9d8d09cSJung-uk Kim 544a9d8d09cSJung-uk Kim case 'c': 545a9d8d09cSJung-uk Kim 546a9d8d09cSJung-uk Kim UtDisplayConstantOpcodes (); 547a9d8d09cSJung-uk Kim exit (0); 548a9d8d09cSJung-uk Kim 549493deb39SJung-uk Kim case 'd': 550493deb39SJung-uk Kim 551493deb39SJung-uk Kim AslDisassemblyHelp (); 552493deb39SJung-uk Kim exit (0); 553493deb39SJung-uk Kim 554a9d8d09cSJung-uk Kim case 'f': 555a9d8d09cSJung-uk Kim 556a9d8d09cSJung-uk Kim AslFilenameHelp (); 557a9d8d09cSJung-uk Kim exit (0); 558a9d8d09cSJung-uk Kim 559a9d8d09cSJung-uk Kim case 'r': 560a9d8d09cSJung-uk Kim 561a9d8d09cSJung-uk Kim /* reserved names */ 562a9d8d09cSJung-uk Kim 563a9d8d09cSJung-uk Kim ApDisplayReservedNames (); 564a9d8d09cSJung-uk Kim exit (0); 565a9d8d09cSJung-uk Kim 566a9d8d09cSJung-uk Kim case 't': 567a9d8d09cSJung-uk Kim 568a9d8d09cSJung-uk Kim UtDisplaySupportedTables (); 569a9d8d09cSJung-uk Kim exit (0); 570a9d8d09cSJung-uk Kim 571a9d8d09cSJung-uk Kim default: 572a9d8d09cSJung-uk Kim 573a9d8d09cSJung-uk Kim printf ("Unknown option: -h%s\n", AcpiGbl_Optarg); 574a9d8d09cSJung-uk Kim return (-1); 575a9d8d09cSJung-uk Kim } 576a9d8d09cSJung-uk Kim 577a9d8d09cSJung-uk Kim case 'I': /* Add an include file search directory */ 578a9d8d09cSJung-uk Kim 579a9d8d09cSJung-uk Kim FlAddIncludeDirectory (AcpiGbl_Optarg); 580a9d8d09cSJung-uk Kim break; 581a9d8d09cSJung-uk Kim 582a9d8d09cSJung-uk Kim case 'i': /* Output AML as an include file */ 583a9d8d09cSJung-uk Kim 584a9d8d09cSJung-uk Kim switch (AcpiGbl_Optarg[0]) 585a9d8d09cSJung-uk Kim { 586a9d8d09cSJung-uk Kim case 'a': 587a9d8d09cSJung-uk Kim 588a9d8d09cSJung-uk Kim /* Produce assembly code include file */ 589a9d8d09cSJung-uk Kim 590a9d8d09cSJung-uk Kim Gbl_AsmIncludeOutputFlag = TRUE; 591a9d8d09cSJung-uk Kim break; 592a9d8d09cSJung-uk Kim 593a9d8d09cSJung-uk Kim case 'c': 594a9d8d09cSJung-uk Kim 595a9d8d09cSJung-uk Kim /* Produce C include file */ 596a9d8d09cSJung-uk Kim 597a9d8d09cSJung-uk Kim Gbl_C_IncludeOutputFlag = TRUE; 598a9d8d09cSJung-uk Kim break; 599a9d8d09cSJung-uk Kim 600a9d8d09cSJung-uk Kim case 'n': 601a9d8d09cSJung-uk Kim 602a9d8d09cSJung-uk Kim /* Compiler/Disassembler: Ignore the NOOP operator */ 603a9d8d09cSJung-uk Kim 604a9d8d09cSJung-uk Kim AcpiGbl_IgnoreNoopOperator = TRUE; 605a9d8d09cSJung-uk Kim break; 606a9d8d09cSJung-uk Kim 607a9d8d09cSJung-uk Kim default: 608a9d8d09cSJung-uk Kim 609a9d8d09cSJung-uk Kim printf ("Unknown option: -i%s\n", AcpiGbl_Optarg); 610a9d8d09cSJung-uk Kim return (-1); 611a9d8d09cSJung-uk Kim } 612a9d8d09cSJung-uk Kim break; 613a9d8d09cSJung-uk Kim 614a9d8d09cSJung-uk Kim case 'l': /* Listing files */ 615a9d8d09cSJung-uk Kim 616a9d8d09cSJung-uk Kim switch (AcpiGbl_Optarg[0]) 617a9d8d09cSJung-uk Kim { 618a9d8d09cSJung-uk Kim case '^': 619a9d8d09cSJung-uk Kim 620a9d8d09cSJung-uk Kim /* Produce listing file (Mixed source/aml) */ 621a9d8d09cSJung-uk Kim 622a9d8d09cSJung-uk Kim Gbl_ListingFlag = TRUE; 62370e6ab8fSJung-uk Kim AcpiGbl_DmOpt_Listing = TRUE; 624a9d8d09cSJung-uk Kim break; 625a9d8d09cSJung-uk Kim 626a9d8d09cSJung-uk Kim case 'i': 627a9d8d09cSJung-uk Kim 628a9d8d09cSJung-uk Kim /* Produce preprocessor output file */ 629a9d8d09cSJung-uk Kim 630a9d8d09cSJung-uk Kim Gbl_PreprocessorOutputFlag = TRUE; 631a9d8d09cSJung-uk Kim break; 632a9d8d09cSJung-uk Kim 633313a0c13SJung-uk Kim case 'm': 634313a0c13SJung-uk Kim 635313a0c13SJung-uk Kim /* Produce hardware map summary file */ 636313a0c13SJung-uk Kim 637313a0c13SJung-uk Kim Gbl_MapfileFlag = TRUE; 638313a0c13SJung-uk Kim break; 639313a0c13SJung-uk Kim 640a9d8d09cSJung-uk Kim case 'n': 641a9d8d09cSJung-uk Kim 642a9d8d09cSJung-uk Kim /* Produce namespace file */ 643a9d8d09cSJung-uk Kim 644a9d8d09cSJung-uk Kim Gbl_NsOutputFlag = TRUE; 645a9d8d09cSJung-uk Kim break; 646a9d8d09cSJung-uk Kim 647a9d8d09cSJung-uk Kim case 's': 648a9d8d09cSJung-uk Kim 649a9d8d09cSJung-uk Kim /* Produce combined source file */ 650a9d8d09cSJung-uk Kim 651a9d8d09cSJung-uk Kim Gbl_SourceOutputFlag = TRUE; 652a9d8d09cSJung-uk Kim break; 653a9d8d09cSJung-uk Kim 654f8146b88SJung-uk Kim case 'x': 655f8146b88SJung-uk Kim 656f8146b88SJung-uk Kim /* Produce cross-reference file */ 657f8146b88SJung-uk Kim 658f8146b88SJung-uk Kim Gbl_CrossReferenceOutput = TRUE; 659f8146b88SJung-uk Kim break; 660f8146b88SJung-uk Kim 661a9d8d09cSJung-uk Kim default: 662a9d8d09cSJung-uk Kim 663a9d8d09cSJung-uk Kim printf ("Unknown option: -l%s\n", AcpiGbl_Optarg); 664a9d8d09cSJung-uk Kim return (-1); 665a9d8d09cSJung-uk Kim } 666a9d8d09cSJung-uk Kim break; 667a9d8d09cSJung-uk Kim 668a9d8d09cSJung-uk Kim case 'm': /* Set line buffer size */ 669a9d8d09cSJung-uk Kim 670a9d8d09cSJung-uk Kim Gbl_LineBufferSize = (UINT32) strtoul (AcpiGbl_Optarg, NULL, 0) * 1024; 671a9d8d09cSJung-uk Kim if (Gbl_LineBufferSize < ASL_DEFAULT_LINE_BUFFER_SIZE) 672a9d8d09cSJung-uk Kim { 673a9d8d09cSJung-uk Kim Gbl_LineBufferSize = ASL_DEFAULT_LINE_BUFFER_SIZE; 674a9d8d09cSJung-uk Kim } 675a9d8d09cSJung-uk Kim printf ("Line Buffer Size: %u\n", Gbl_LineBufferSize); 676a9d8d09cSJung-uk Kim break; 677a9d8d09cSJung-uk Kim 678a9d8d09cSJung-uk Kim case 'n': /* Parse only */ 679a9d8d09cSJung-uk Kim 680a9d8d09cSJung-uk Kim Gbl_ParseOnlyFlag = TRUE; 681a9d8d09cSJung-uk Kim break; 682a9d8d09cSJung-uk Kim 683a9d8d09cSJung-uk Kim case 'o': /* Control compiler AML optimizations */ 684a9d8d09cSJung-uk Kim 685a9d8d09cSJung-uk Kim switch (AcpiGbl_Optarg[0]) 686a9d8d09cSJung-uk Kim { 687a9d8d09cSJung-uk Kim case 'a': 688a9d8d09cSJung-uk Kim 689a9d8d09cSJung-uk Kim /* Disable all optimizations */ 690a9d8d09cSJung-uk Kim 691a9d8d09cSJung-uk Kim Gbl_FoldConstants = FALSE; 692a9d8d09cSJung-uk Kim Gbl_IntegerOptimizationFlag = FALSE; 693a9d8d09cSJung-uk Kim Gbl_ReferenceOptimizationFlag = FALSE; 694*0d84335fSJung-uk Kim Gbl_OptimizeTrivialParseNodes = FALSE; 695*0d84335fSJung-uk Kim 696a9d8d09cSJung-uk Kim break; 697a9d8d09cSJung-uk Kim 698f8146b88SJung-uk Kim case 'c': 699f8146b88SJung-uk Kim 700f8146b88SJung-uk Kim /* Display compile time(s) */ 701f8146b88SJung-uk Kim 702f8146b88SJung-uk Kim Gbl_CompileTimesFlag = TRUE; 703f8146b88SJung-uk Kim break; 704f8146b88SJung-uk Kim 705493deb39SJung-uk Kim case 'd': 706493deb39SJung-uk Kim 707493deb39SJung-uk Kim /* Disable disassembler code optimizations */ 708493deb39SJung-uk Kim 709493deb39SJung-uk Kim AcpiGbl_DoDisassemblerOptimizations = FALSE; 710493deb39SJung-uk Kim break; 711493deb39SJung-uk Kim 712f8146b88SJung-uk Kim case 'e': 713f8146b88SJung-uk Kim 7143920312eSJung-uk Kim /* Disassembler: Emit embedded external operators */ 7153920312eSJung-uk Kim 7163920312eSJung-uk Kim AcpiGbl_DmEmitExternalOpcodes = TRUE; 717f8146b88SJung-uk Kim break; 718f8146b88SJung-uk Kim 719*0d84335fSJung-uk Kim case 'E': 720*0d84335fSJung-uk Kim 721*0d84335fSJung-uk Kim /* 722*0d84335fSJung-uk Kim * iASL: keep External opcodes in place. 723*0d84335fSJung-uk Kim * No affect if Gbl_DoExternals is false. 724*0d84335fSJung-uk Kim */ 725*0d84335fSJung-uk Kim 726*0d84335fSJung-uk Kim Gbl_DoExternalsInPlace = TRUE; 727*0d84335fSJung-uk Kim break; 728*0d84335fSJung-uk Kim 729a9d8d09cSJung-uk Kim case 'f': 730a9d8d09cSJung-uk Kim 731a9d8d09cSJung-uk Kim /* Disable folding on "normal" expressions */ 732a9d8d09cSJung-uk Kim 733a9d8d09cSJung-uk Kim Gbl_FoldConstants = FALSE; 734a9d8d09cSJung-uk Kim break; 735a9d8d09cSJung-uk Kim 736a9d8d09cSJung-uk Kim case 'i': 737a9d8d09cSJung-uk Kim 738a9d8d09cSJung-uk Kim /* Disable integer optimization to constants */ 739a9d8d09cSJung-uk Kim 740a9d8d09cSJung-uk Kim Gbl_IntegerOptimizationFlag = FALSE; 741a9d8d09cSJung-uk Kim break; 742a9d8d09cSJung-uk Kim 743a9d8d09cSJung-uk Kim case 'n': 744a9d8d09cSJung-uk Kim 745a9d8d09cSJung-uk Kim /* Disable named reference optimization */ 746a9d8d09cSJung-uk Kim 747a9d8d09cSJung-uk Kim Gbl_ReferenceOptimizationFlag = FALSE; 748a9d8d09cSJung-uk Kim break; 749a9d8d09cSJung-uk Kim 750a9d8d09cSJung-uk Kim case 't': 751a9d8d09cSJung-uk Kim 752f8146b88SJung-uk Kim /* Disable heavy typechecking */ 753a9d8d09cSJung-uk Kim 754f8146b88SJung-uk Kim Gbl_DoTypechecking = FALSE; 755a9d8d09cSJung-uk Kim break; 756a9d8d09cSJung-uk Kim 757a9d8d09cSJung-uk Kim default: 758a9d8d09cSJung-uk Kim 759a9d8d09cSJung-uk Kim printf ("Unknown option: -c%s\n", AcpiGbl_Optarg); 760a9d8d09cSJung-uk Kim return (-1); 761a9d8d09cSJung-uk Kim } 762a9d8d09cSJung-uk Kim break; 763a9d8d09cSJung-uk Kim 764a9d8d09cSJung-uk Kim case 'P': /* Preprocessor options */ 765a9d8d09cSJung-uk Kim 766a9d8d09cSJung-uk Kim switch (AcpiGbl_Optarg[0]) 767a9d8d09cSJung-uk Kim { 768a9d8d09cSJung-uk Kim case '^': /* Proprocess only, emit (.i) file */ 769a9d8d09cSJung-uk Kim 770a9d8d09cSJung-uk Kim Gbl_PreprocessOnly = TRUE; 771a9d8d09cSJung-uk Kim Gbl_PreprocessorOutputFlag = TRUE; 772a9d8d09cSJung-uk Kim break; 773a9d8d09cSJung-uk Kim 774a9d8d09cSJung-uk Kim case 'n': /* Disable preprocessor */ 775a9d8d09cSJung-uk Kim 776a9d8d09cSJung-uk Kim Gbl_PreprocessFlag = FALSE; 777a9d8d09cSJung-uk Kim break; 778a9d8d09cSJung-uk Kim 779a9d8d09cSJung-uk Kim default: 780a9d8d09cSJung-uk Kim 781a9d8d09cSJung-uk Kim printf ("Unknown option: -P%s\n", AcpiGbl_Optarg); 782a9d8d09cSJung-uk Kim return (-1); 783a9d8d09cSJung-uk Kim } 784a9d8d09cSJung-uk Kim break; 785a9d8d09cSJung-uk Kim 786a9d8d09cSJung-uk Kim case 'p': /* Override default AML output filename */ 787a9d8d09cSJung-uk Kim 788a9d8d09cSJung-uk Kim Gbl_OutputFilenamePrefix = AcpiGbl_Optarg; 789313a0c13SJung-uk Kim UtConvertBackslashes (Gbl_OutputFilenamePrefix); 790a9d8d09cSJung-uk Kim Gbl_UseDefaultAmlFilename = FALSE; 791a9d8d09cSJung-uk Kim break; 792a9d8d09cSJung-uk Kim 793*0d84335fSJung-uk Kim case 'q': /* ASL/ASl+ converter: compile only and leave badaml. */ 794*0d84335fSJung-uk Kim 795*0d84335fSJung-uk Kim printf ("Convert ASL to ASL+ with comments\n"); 796*0d84335fSJung-uk Kim Gbl_FoldConstants = FALSE; 797*0d84335fSJung-uk Kim Gbl_IntegerOptimizationFlag = FALSE; 798*0d84335fSJung-uk Kim Gbl_ReferenceOptimizationFlag = FALSE; 799*0d84335fSJung-uk Kim Gbl_OptimizeTrivialParseNodes = FALSE; 800*0d84335fSJung-uk Kim Gbl_CaptureComments = TRUE; 801*0d84335fSJung-uk Kim Gbl_DoExternalsInPlace = TRUE; 802*0d84335fSJung-uk Kim return (0); 803*0d84335fSJung-uk Kim 804a9d8d09cSJung-uk Kim case 'r': /* Override revision found in table header */ 805a9d8d09cSJung-uk Kim 806a9d8d09cSJung-uk Kim Gbl_RevisionOverride = (UINT8) strtoul (AcpiGbl_Optarg, NULL, 0); 807a9d8d09cSJung-uk Kim break; 808a9d8d09cSJung-uk Kim 809a9d8d09cSJung-uk Kim case 's': /* Create AML in a source code file */ 810a9d8d09cSJung-uk Kim 811a9d8d09cSJung-uk Kim switch (AcpiGbl_Optarg[0]) 812a9d8d09cSJung-uk Kim { 813a9d8d09cSJung-uk Kim case 'a': 814a9d8d09cSJung-uk Kim 815a9d8d09cSJung-uk Kim /* Produce assembly code output file */ 816a9d8d09cSJung-uk Kim 817a9d8d09cSJung-uk Kim Gbl_AsmOutputFlag = TRUE; 818a9d8d09cSJung-uk Kim break; 819a9d8d09cSJung-uk Kim 820a9d8d09cSJung-uk Kim case 'c': 821a9d8d09cSJung-uk Kim 822a9d8d09cSJung-uk Kim /* Produce C hex output file */ 823a9d8d09cSJung-uk Kim 824a9d8d09cSJung-uk Kim Gbl_C_OutputFlag = TRUE; 825a9d8d09cSJung-uk Kim break; 826a9d8d09cSJung-uk Kim 827a9d8d09cSJung-uk Kim case 'o': 828a9d8d09cSJung-uk Kim 829a9d8d09cSJung-uk Kim /* Produce AML offset table in C */ 830a9d8d09cSJung-uk Kim 831a9d8d09cSJung-uk Kim Gbl_C_OffsetTableFlag = TRUE; 832a9d8d09cSJung-uk Kim break; 833a9d8d09cSJung-uk Kim 834a9d8d09cSJung-uk Kim default: 835a9d8d09cSJung-uk Kim 836a9d8d09cSJung-uk Kim printf ("Unknown option: -s%s\n", AcpiGbl_Optarg); 837a9d8d09cSJung-uk Kim return (-1); 838a9d8d09cSJung-uk Kim } 839a9d8d09cSJung-uk Kim break; 840a9d8d09cSJung-uk Kim 841a9d8d09cSJung-uk Kim case 't': /* Produce hex table output file */ 842a9d8d09cSJung-uk Kim 843a9d8d09cSJung-uk Kim switch (AcpiGbl_Optarg[0]) 844a9d8d09cSJung-uk Kim { 845a9d8d09cSJung-uk Kim case 'a': 846a9d8d09cSJung-uk Kim 847a9d8d09cSJung-uk Kim Gbl_HexOutputFlag = HEX_OUTPUT_ASM; 848a9d8d09cSJung-uk Kim break; 849a9d8d09cSJung-uk Kim 850a9d8d09cSJung-uk Kim case 'c': 851a9d8d09cSJung-uk Kim 852a9d8d09cSJung-uk Kim Gbl_HexOutputFlag = HEX_OUTPUT_C; 853a9d8d09cSJung-uk Kim break; 854a9d8d09cSJung-uk Kim 855a9d8d09cSJung-uk Kim case 's': 856a9d8d09cSJung-uk Kim 857a9d8d09cSJung-uk Kim Gbl_HexOutputFlag = HEX_OUTPUT_ASL; 858a9d8d09cSJung-uk Kim break; 859a9d8d09cSJung-uk Kim 860a9d8d09cSJung-uk Kim default: 861a9d8d09cSJung-uk Kim 862a9d8d09cSJung-uk Kim printf ("Unknown option: -t%s\n", AcpiGbl_Optarg); 863a9d8d09cSJung-uk Kim return (-1); 864a9d8d09cSJung-uk Kim } 865a9d8d09cSJung-uk Kim break; 866a9d8d09cSJung-uk Kim 867a9d8d09cSJung-uk Kim case 'T': /* Create a ACPI table template file */ 868a9d8d09cSJung-uk Kim 869a9d8d09cSJung-uk Kim Gbl_DoTemplates = TRUE; 870a9d8d09cSJung-uk Kim break; 871a9d8d09cSJung-uk Kim 872a9d8d09cSJung-uk Kim case 'v': /* Version and verbosity settings */ 873a9d8d09cSJung-uk Kim 874a9d8d09cSJung-uk Kim switch (AcpiGbl_Optarg[0]) 875a9d8d09cSJung-uk Kim { 876a9d8d09cSJung-uk Kim case '^': 877a9d8d09cSJung-uk Kim 878a9d8d09cSJung-uk Kim printf (ACPI_COMMON_SIGNON (ASL_COMPILER_NAME)); 879a9d8d09cSJung-uk Kim exit (0); 880a9d8d09cSJung-uk Kim 881a9d8d09cSJung-uk Kim case 'a': 882a9d8d09cSJung-uk Kim 883313a0c13SJung-uk Kim /* Disable all error/warning/remark messages */ 884a9d8d09cSJung-uk Kim 885a9d8d09cSJung-uk Kim Gbl_NoErrors = TRUE; 886a9d8d09cSJung-uk Kim break; 887a9d8d09cSJung-uk Kim 888313a0c13SJung-uk Kim case 'e': 889313a0c13SJung-uk Kim 890313a0c13SJung-uk Kim /* Disable all warning/remark messages (errors only) */ 891313a0c13SJung-uk Kim 892313a0c13SJung-uk Kim Gbl_DisplayRemarks = FALSE; 893313a0c13SJung-uk Kim Gbl_DisplayWarnings = FALSE; 894313a0c13SJung-uk Kim break; 895313a0c13SJung-uk Kim 896a9d8d09cSJung-uk Kim case 'i': 897a9d8d09cSJung-uk Kim /* 898a9d8d09cSJung-uk Kim * Support for integrated development environment(s). 899a9d8d09cSJung-uk Kim * 900a9d8d09cSJung-uk Kim * 1) No compiler signon 901a9d8d09cSJung-uk Kim * 2) Send stderr messages to stdout 902a9d8d09cSJung-uk Kim * 3) Less verbose error messages (single line only for each) 903a9d8d09cSJung-uk Kim * 4) Error/warning messages are formatted appropriately to 904a9d8d09cSJung-uk Kim * be recognized by MS Visual Studio 905a9d8d09cSJung-uk Kim */ 906a9d8d09cSJung-uk Kim Gbl_VerboseErrors = FALSE; 907a9d8d09cSJung-uk Kim Gbl_DoSignon = FALSE; 908a9d8d09cSJung-uk Kim Gbl_Files[ASL_FILE_STDERR].Handle = stdout; 909a9d8d09cSJung-uk Kim break; 910a9d8d09cSJung-uk Kim 911a9d8d09cSJung-uk Kim case 'o': 912a9d8d09cSJung-uk Kim 913a9d8d09cSJung-uk Kim Gbl_DisplayOptimizations = TRUE; 914a9d8d09cSJung-uk Kim break; 915a9d8d09cSJung-uk Kim 916a9d8d09cSJung-uk Kim case 'r': 917a9d8d09cSJung-uk Kim 918a9d8d09cSJung-uk Kim Gbl_DisplayRemarks = FALSE; 919a9d8d09cSJung-uk Kim break; 920a9d8d09cSJung-uk Kim 921a9d8d09cSJung-uk Kim case 's': 922a9d8d09cSJung-uk Kim 923a9d8d09cSJung-uk Kim Gbl_DoSignon = FALSE; 924a9d8d09cSJung-uk Kim break; 925a9d8d09cSJung-uk Kim 926a9d8d09cSJung-uk Kim case 't': 927a9d8d09cSJung-uk Kim 928a9d8d09cSJung-uk Kim Gbl_VerboseTemplates = TRUE; 929a9d8d09cSJung-uk Kim break; 930a9d8d09cSJung-uk Kim 931a9d8d09cSJung-uk Kim case 'w': 932a9d8d09cSJung-uk Kim 933a9d8d09cSJung-uk Kim /* Get the required argument */ 934a9d8d09cSJung-uk Kim 935a9d8d09cSJung-uk Kim if (AcpiGetoptArgument (argc, argv)) 936a9d8d09cSJung-uk Kim { 937a9d8d09cSJung-uk Kim return (-1); 938a9d8d09cSJung-uk Kim } 939a9d8d09cSJung-uk Kim 940a9d8d09cSJung-uk Kim Status = AslDisableException (AcpiGbl_Optarg); 941a9d8d09cSJung-uk Kim if (ACPI_FAILURE (Status)) 942a9d8d09cSJung-uk Kim { 943a9d8d09cSJung-uk Kim return (-1); 944a9d8d09cSJung-uk Kim } 945a9d8d09cSJung-uk Kim break; 946a9d8d09cSJung-uk Kim 947a9d8d09cSJung-uk Kim default: 948a9d8d09cSJung-uk Kim 949a9d8d09cSJung-uk Kim printf ("Unknown option: -v%s\n", AcpiGbl_Optarg); 950a9d8d09cSJung-uk Kim return (-1); 951a9d8d09cSJung-uk Kim } 952a9d8d09cSJung-uk Kim break; 953a9d8d09cSJung-uk Kim 954a9d8d09cSJung-uk Kim case 'w': /* Set warning levels */ 955a9d8d09cSJung-uk Kim 956a9d8d09cSJung-uk Kim switch (AcpiGbl_Optarg[0]) 957a9d8d09cSJung-uk Kim { 958a9d8d09cSJung-uk Kim case '1': 959a9d8d09cSJung-uk Kim 960a9d8d09cSJung-uk Kim Gbl_WarningLevel = ASL_WARNING; 961a9d8d09cSJung-uk Kim break; 962a9d8d09cSJung-uk Kim 963a9d8d09cSJung-uk Kim case '2': 964a9d8d09cSJung-uk Kim 965a9d8d09cSJung-uk Kim Gbl_WarningLevel = ASL_WARNING2; 966a9d8d09cSJung-uk Kim break; 967a9d8d09cSJung-uk Kim 968a9d8d09cSJung-uk Kim case '3': 969a9d8d09cSJung-uk Kim 970a9d8d09cSJung-uk Kim Gbl_WarningLevel = ASL_WARNING3; 971a9d8d09cSJung-uk Kim break; 972a9d8d09cSJung-uk Kim 973a9d8d09cSJung-uk Kim case 'e': 974a9d8d09cSJung-uk Kim 975a9d8d09cSJung-uk Kim Gbl_WarningsAsErrors = TRUE; 976a9d8d09cSJung-uk Kim break; 977a9d8d09cSJung-uk Kim 978a9d8d09cSJung-uk Kim default: 979a9d8d09cSJung-uk Kim 980a9d8d09cSJung-uk Kim printf ("Unknown option: -w%s\n", AcpiGbl_Optarg); 981a9d8d09cSJung-uk Kim return (-1); 982a9d8d09cSJung-uk Kim } 983a9d8d09cSJung-uk Kim break; 984a9d8d09cSJung-uk Kim 985a9d8d09cSJung-uk Kim case 'x': /* Set debug print output level */ 986a9d8d09cSJung-uk Kim 987a9d8d09cSJung-uk Kim AcpiDbgLevel = strtoul (AcpiGbl_Optarg, NULL, 16); 988a9d8d09cSJung-uk Kim break; 989a9d8d09cSJung-uk Kim 990a9d8d09cSJung-uk Kim case 'z': 991a9d8d09cSJung-uk Kim 992a9d8d09cSJung-uk Kim Gbl_UseOriginalCompilerId = TRUE; 993a9d8d09cSJung-uk Kim break; 994a9d8d09cSJung-uk Kim 995a9d8d09cSJung-uk Kim default: 996a9d8d09cSJung-uk Kim 997a9d8d09cSJung-uk Kim return (-1); 998a9d8d09cSJung-uk Kim } 999a9d8d09cSJung-uk Kim 1000a9d8d09cSJung-uk Kim return (0); 1001a9d8d09cSJung-uk Kim } 1002a9d8d09cSJung-uk Kim 1003a9d8d09cSJung-uk Kim 1004a9d8d09cSJung-uk Kim /******************************************************************************* 1005a9d8d09cSJung-uk Kim * 1006a9d8d09cSJung-uk Kim * FUNCTION: AslMergeOptionTokens 1007a9d8d09cSJung-uk Kim * 1008a9d8d09cSJung-uk Kim * PARAMETERS: InBuffer - Input containing an option string 1009a9d8d09cSJung-uk Kim * OutBuffer - Merged output buffer 1010a9d8d09cSJung-uk Kim * 1011a9d8d09cSJung-uk Kim * RETURN: None 1012a9d8d09cSJung-uk Kim * 1013a9d8d09cSJung-uk Kim * DESCRIPTION: Remove all whitespace from an option string. 1014a9d8d09cSJung-uk Kim * 1015a9d8d09cSJung-uk Kim ******************************************************************************/ 1016a9d8d09cSJung-uk Kim 1017a9d8d09cSJung-uk Kim static void 1018a9d8d09cSJung-uk Kim AslMergeOptionTokens ( 1019a9d8d09cSJung-uk Kim char *InBuffer, 1020a9d8d09cSJung-uk Kim char *OutBuffer) 1021a9d8d09cSJung-uk Kim { 1022a9d8d09cSJung-uk Kim char *Token; 1023a9d8d09cSJung-uk Kim 1024a9d8d09cSJung-uk Kim 1025a9d8d09cSJung-uk Kim *OutBuffer = 0; 1026a9d8d09cSJung-uk Kim 1027a9d8d09cSJung-uk Kim Token = strtok (InBuffer, ASL_TOKEN_SEPARATORS); 1028a9d8d09cSJung-uk Kim while (Token) 1029a9d8d09cSJung-uk Kim { 1030a9d8d09cSJung-uk Kim strcat (OutBuffer, Token); 1031a9d8d09cSJung-uk Kim Token = strtok (NULL, ASL_TOKEN_SEPARATORS); 1032a9d8d09cSJung-uk Kim } 1033a9d8d09cSJung-uk Kim } 1034a9d8d09cSJung-uk Kim 1035a9d8d09cSJung-uk Kim 1036a9d8d09cSJung-uk Kim /******************************************************************************* 1037a9d8d09cSJung-uk Kim * 1038a9d8d09cSJung-uk Kim * FUNCTION: AslDoResponseFile 1039a9d8d09cSJung-uk Kim * 1040a9d8d09cSJung-uk Kim * PARAMETERS: Filename - Name of the response file 1041a9d8d09cSJung-uk Kim * 1042a9d8d09cSJung-uk Kim * RETURN: Status 1043a9d8d09cSJung-uk Kim * 1044a9d8d09cSJung-uk Kim * DESCRIPTION: Open a response file and process all options within. 1045a9d8d09cSJung-uk Kim * 1046a9d8d09cSJung-uk Kim ******************************************************************************/ 1047a9d8d09cSJung-uk Kim 1048a9d8d09cSJung-uk Kim static int 1049a9d8d09cSJung-uk Kim AslDoResponseFile ( 1050a9d8d09cSJung-uk Kim char *Filename) 1051a9d8d09cSJung-uk Kim { 1052a9d8d09cSJung-uk Kim char *argv = StringBuffer2; 1053a9d8d09cSJung-uk Kim FILE *ResponseFile; 1054a9d8d09cSJung-uk Kim int OptStatus = 0; 1055a9d8d09cSJung-uk Kim int Opterr; 1056a9d8d09cSJung-uk Kim int Optind; 1057a9d8d09cSJung-uk Kim 1058a9d8d09cSJung-uk Kim 1059a9d8d09cSJung-uk Kim ResponseFile = fopen (Filename, "r"); 1060a9d8d09cSJung-uk Kim if (!ResponseFile) 1061a9d8d09cSJung-uk Kim { 1062a9d8d09cSJung-uk Kim printf ("Could not open command file %s, %s\n", 1063a9d8d09cSJung-uk Kim Filename, strerror (errno)); 1064a9d8d09cSJung-uk Kim return (-1); 1065a9d8d09cSJung-uk Kim } 1066a9d8d09cSJung-uk Kim 1067a9d8d09cSJung-uk Kim /* Must save the current GetOpt globals */ 1068a9d8d09cSJung-uk Kim 1069a9d8d09cSJung-uk Kim Opterr = AcpiGbl_Opterr; 1070a9d8d09cSJung-uk Kim Optind = AcpiGbl_Optind; 1071a9d8d09cSJung-uk Kim 1072a9d8d09cSJung-uk Kim /* 1073a9d8d09cSJung-uk Kim * Process all lines in the response file. There must be one complete 1074a9d8d09cSJung-uk Kim * option per line 1075a9d8d09cSJung-uk Kim */ 1076a9d8d09cSJung-uk Kim while (fgets (StringBuffer, ASL_MSG_BUFFER_SIZE, ResponseFile)) 1077a9d8d09cSJung-uk Kim { 1078a9d8d09cSJung-uk Kim /* Compress all tokens, allowing us to use a single argv entry */ 1079a9d8d09cSJung-uk Kim 1080a9d8d09cSJung-uk Kim AslMergeOptionTokens (StringBuffer, StringBuffer2); 1081a9d8d09cSJung-uk Kim 1082a9d8d09cSJung-uk Kim /* Process the option */ 1083a9d8d09cSJung-uk Kim 1084a9d8d09cSJung-uk Kim AcpiGbl_Opterr = 0; 1085a9d8d09cSJung-uk Kim AcpiGbl_Optind = 0; 1086a9d8d09cSJung-uk Kim 1087a9d8d09cSJung-uk Kim OptStatus = AslDoOptions (1, &argv, TRUE); 1088a9d8d09cSJung-uk Kim if (OptStatus) 1089a9d8d09cSJung-uk Kim { 1090a9d8d09cSJung-uk Kim printf ("Invalid option in command file %s: %s\n", 1091a9d8d09cSJung-uk Kim Filename, StringBuffer); 1092a9d8d09cSJung-uk Kim break; 1093a9d8d09cSJung-uk Kim } 1094a9d8d09cSJung-uk Kim } 1095a9d8d09cSJung-uk Kim 1096a9d8d09cSJung-uk Kim /* Restore the GetOpt globals */ 1097a9d8d09cSJung-uk Kim 1098a9d8d09cSJung-uk Kim AcpiGbl_Opterr = Opterr; 1099a9d8d09cSJung-uk Kim AcpiGbl_Optind = Optind; 1100a9d8d09cSJung-uk Kim 1101a9d8d09cSJung-uk Kim fclose (ResponseFile); 1102a9d8d09cSJung-uk Kim return (OptStatus); 1103a9d8d09cSJung-uk Kim } 1104