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 70d84335fSJung-uk Kim /****************************************************************************** 80d84335fSJung-uk Kim * 90d84335fSJung-uk Kim * 1. Copyright Notice 100d84335fSJung-uk Kim * 11e5e1f58aSJung-uk Kim * Some or all of this work - Copyright (c) 1999 - 2019, Intel Corp. 12a9d8d09cSJung-uk Kim * All rights reserved. 13a9d8d09cSJung-uk Kim * 140d84335fSJung-uk Kim * 2. License 150d84335fSJung-uk Kim * 160d84335fSJung-uk Kim * 2.1. This is your license from Intel Corp. under its intellectual property 170d84335fSJung-uk Kim * rights. You may have additional license terms from the party that provided 180d84335fSJung-uk Kim * you this software, covering your right to use that party's intellectual 190d84335fSJung-uk Kim * property rights. 200d84335fSJung-uk Kim * 210d84335fSJung-uk Kim * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 220d84335fSJung-uk Kim * copy of the source code appearing in this file ("Covered Code") an 230d84335fSJung-uk Kim * irrevocable, perpetual, worldwide license under Intel's copyrights in the 240d84335fSJung-uk Kim * base code distributed originally by Intel ("Original Intel Code") to copy, 250d84335fSJung-uk Kim * make derivatives, distribute, use and display any portion of the Covered 260d84335fSJung-uk Kim * Code in any form, with the right to sublicense such rights; and 270d84335fSJung-uk Kim * 280d84335fSJung-uk Kim * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 290d84335fSJung-uk Kim * license (with the right to sublicense), under only those claims of Intel 300d84335fSJung-uk Kim * patents that are infringed by the Original Intel Code, to make, use, sell, 310d84335fSJung-uk Kim * offer to sell, and import the Covered Code and derivative works thereof 320d84335fSJung-uk Kim * solely to the minimum extent necessary to exercise the above copyright 330d84335fSJung-uk Kim * license, and in no event shall the patent license extend to any additions 340d84335fSJung-uk Kim * to or modifications of the Original Intel Code. No other license or right 350d84335fSJung-uk Kim * is granted directly or by implication, estoppel or otherwise; 360d84335fSJung-uk Kim * 370d84335fSJung-uk Kim * The above copyright and patent license is granted only if the following 380d84335fSJung-uk Kim * conditions are met: 390d84335fSJung-uk Kim * 400d84335fSJung-uk Kim * 3. Conditions 410d84335fSJung-uk Kim * 420d84335fSJung-uk Kim * 3.1. Redistribution of Source with Rights to Further Distribute Source. 430d84335fSJung-uk Kim * Redistribution of source code of any substantial portion of the Covered 440d84335fSJung-uk Kim * Code or modification with rights to further distribute source must include 450d84335fSJung-uk Kim * the above Copyright Notice, the above License, this list of Conditions, 460d84335fSJung-uk Kim * and the following Disclaimer and Export Compliance provision. In addition, 470d84335fSJung-uk Kim * Licensee must cause all Covered Code to which Licensee contributes to 480d84335fSJung-uk Kim * contain a file documenting the changes Licensee made to create that Covered 490d84335fSJung-uk Kim * Code and the date of any change. Licensee must include in that file the 500d84335fSJung-uk Kim * documentation of any changes made by any predecessor Licensee. Licensee 510d84335fSJung-uk Kim * must include a prominent statement that the modification is derived, 520d84335fSJung-uk Kim * directly or indirectly, from Original Intel Code. 530d84335fSJung-uk Kim * 540d84335fSJung-uk Kim * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 550d84335fSJung-uk Kim * Redistribution of source code of any substantial portion of the Covered 560d84335fSJung-uk Kim * Code or modification without rights to further distribute source must 570d84335fSJung-uk Kim * include the following Disclaimer and Export Compliance provision in the 580d84335fSJung-uk Kim * documentation and/or other materials provided with distribution. In 590d84335fSJung-uk Kim * addition, Licensee may not authorize further sublicense of source of any 600d84335fSJung-uk Kim * portion of the Covered Code, and must include terms to the effect that the 610d84335fSJung-uk Kim * license from Licensee to its licensee is limited to the intellectual 620d84335fSJung-uk Kim * property embodied in the software Licensee provides to its licensee, and 630d84335fSJung-uk Kim * not to intellectual property embodied in modifications its licensee may 640d84335fSJung-uk Kim * make. 650d84335fSJung-uk Kim * 660d84335fSJung-uk Kim * 3.3. Redistribution of Executable. Redistribution in executable form of any 670d84335fSJung-uk Kim * substantial portion of the Covered Code or modification must reproduce the 680d84335fSJung-uk Kim * above Copyright Notice, and the following Disclaimer and Export Compliance 690d84335fSJung-uk Kim * provision in the documentation and/or other materials provided with the 700d84335fSJung-uk Kim * distribution. 710d84335fSJung-uk Kim * 720d84335fSJung-uk Kim * 3.4. Intel retains all right, title, and interest in and to the Original 730d84335fSJung-uk Kim * Intel Code. 740d84335fSJung-uk Kim * 750d84335fSJung-uk Kim * 3.5. Neither the name Intel nor any other trademark owned or controlled by 760d84335fSJung-uk Kim * Intel shall be used in advertising or otherwise to promote the sale, use or 770d84335fSJung-uk Kim * other dealings in products derived from or relating to the Covered Code 780d84335fSJung-uk Kim * without prior written authorization from Intel. 790d84335fSJung-uk Kim * 800d84335fSJung-uk Kim * 4. Disclaimer and Export Compliance 810d84335fSJung-uk Kim * 820d84335fSJung-uk Kim * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 830d84335fSJung-uk Kim * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 840d84335fSJung-uk Kim * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 850d84335fSJung-uk Kim * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 860d84335fSJung-uk Kim * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 870d84335fSJung-uk Kim * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 880d84335fSJung-uk Kim * PARTICULAR PURPOSE. 890d84335fSJung-uk Kim * 900d84335fSJung-uk Kim * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 910d84335fSJung-uk Kim * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 920d84335fSJung-uk Kim * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 930d84335fSJung-uk Kim * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 940d84335fSJung-uk Kim * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 950d84335fSJung-uk Kim * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 960d84335fSJung-uk Kim * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 970d84335fSJung-uk Kim * LIMITED REMEDY. 980d84335fSJung-uk Kim * 990d84335fSJung-uk Kim * 4.3. Licensee shall not export, either directly or indirectly, any of this 1000d84335fSJung-uk Kim * software or system incorporating such software without first obtaining any 1010d84335fSJung-uk Kim * required license or other approval from the U. S. Department of Commerce or 1020d84335fSJung-uk Kim * any other agency or department of the United States Government. In the 1030d84335fSJung-uk Kim * event Licensee exports any such software from the United States or 1040d84335fSJung-uk Kim * re-exports any such software from a foreign destination, Licensee shall 1050d84335fSJung-uk Kim * ensure that the distribution and export/re-export of the software is in 1060d84335fSJung-uk Kim * compliance with all laws, regulations, orders, or other restrictions of the 1070d84335fSJung-uk Kim * U.S. Export Administration Regulations. Licensee agrees that neither it nor 1080d84335fSJung-uk Kim * any of its subsidiaries will export/re-export any technical data, process, 1090d84335fSJung-uk Kim * software, or service, directly or indirectly, to any country for which the 1100d84335fSJung-uk Kim * United States government or any agency thereof requires an export license, 1110d84335fSJung-uk Kim * other governmental approval, or letter of assurance, without first obtaining 1120d84335fSJung-uk Kim * such license, approval or letter. 1130d84335fSJung-uk Kim * 1140d84335fSJung-uk Kim ***************************************************************************** 1150d84335fSJung-uk Kim * 1160d84335fSJung-uk Kim * Alternatively, you may choose to be licensed under the terms of the 1170d84335fSJung-uk Kim * following license: 1180d84335fSJung-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 * 1340d84335fSJung-uk Kim * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1350d84335fSJung-uk Kim * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1360d84335fSJung-uk Kim * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1370d84335fSJung-uk Kim * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 1380d84335fSJung-uk Kim * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 1390d84335fSJung-uk Kim * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 1400d84335fSJung-uk Kim * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 1410d84335fSJung-uk Kim * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 1420d84335fSJung-uk Kim * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 1430d84335fSJung-uk Kim * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 1440d84335fSJung-uk Kim * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 1450d84335fSJung-uk Kim * 1460d84335fSJung-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 * 1500d84335fSJung-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" 1790d84335fSJung-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 Usage (); 208a9d8d09cSJung-uk Kim exit (1); 209a9d8d09cSJung-uk Kim } 210a9d8d09cSJung-uk Kim 211a9d8d09cSJung-uk Kim /* Process all command line options */ 212a9d8d09cSJung-uk Kim 213a9d8d09cSJung-uk Kim BadCommandLine = AslDoOptions (argc, argv, FALSE); 214a9d8d09cSJung-uk Kim 2156f1f1a63SJung-uk Kim if (AslGbl_DoTemplates) 216a9d8d09cSJung-uk Kim { 217f8146b88SJung-uk Kim Status = DtCreateTemplates (argv); 218a9d8d09cSJung-uk Kim if (ACPI_FAILURE (Status)) 219a9d8d09cSJung-uk Kim { 220a9d8d09cSJung-uk Kim exit (-1); 221a9d8d09cSJung-uk Kim } 222a9d8d09cSJung-uk Kim exit (1); 223a9d8d09cSJung-uk Kim } 224a9d8d09cSJung-uk Kim 225a9d8d09cSJung-uk Kim /* Next parameter must be the input filename */ 226a9d8d09cSJung-uk Kim 227a9d8d09cSJung-uk Kim if (!argv[AcpiGbl_Optind] && 228af051161SJung-uk Kim !AcpiGbl_DisasmFlag) 229a9d8d09cSJung-uk Kim { 230a9d8d09cSJung-uk Kim printf ("Missing input filename\n"); 231a9d8d09cSJung-uk Kim BadCommandLine = TRUE; 232a9d8d09cSJung-uk Kim } 233a9d8d09cSJung-uk Kim 2346f1f1a63SJung-uk Kim if (AslGbl_DoSignon) 235a9d8d09cSJung-uk Kim { 236a9d8d09cSJung-uk Kim printf (ACPI_COMMON_SIGNON (ASL_COMPILER_NAME)); 2376f1f1a63SJung-uk Kim if (AslGbl_IgnoreErrors) 238a9d8d09cSJung-uk Kim { 239a9d8d09cSJung-uk Kim printf ("Ignoring all errors, forcing AML file generation\n\n"); 240a9d8d09cSJung-uk Kim } 241a9d8d09cSJung-uk Kim } 242a9d8d09cSJung-uk Kim 243a9d8d09cSJung-uk Kim if (BadCommandLine) 244a9d8d09cSJung-uk Kim { 24579c6d946SJung-uk Kim printf ("Use -h option for help information\n"); 246a9d8d09cSJung-uk Kim exit (1); 247a9d8d09cSJung-uk Kim } 248a9d8d09cSJung-uk Kim 249a9d8d09cSJung-uk Kim return (AcpiGbl_Optind); 250a9d8d09cSJung-uk Kim } 251a9d8d09cSJung-uk Kim 252a9d8d09cSJung-uk Kim 253a9d8d09cSJung-uk Kim /******************************************************************************* 254a9d8d09cSJung-uk Kim * 255a9d8d09cSJung-uk Kim * FUNCTION: AslDoOptions 256a9d8d09cSJung-uk Kim * 257a9d8d09cSJung-uk Kim * PARAMETERS: argc/argv - Standard argc/argv 258a9d8d09cSJung-uk Kim * IsResponseFile - TRUE if executing a response file. 259a9d8d09cSJung-uk Kim * 260a9d8d09cSJung-uk Kim * RETURN: Status 261a9d8d09cSJung-uk Kim * 262a9d8d09cSJung-uk Kim * DESCRIPTION: Command line option processing 263a9d8d09cSJung-uk Kim * 264a9d8d09cSJung-uk Kim ******************************************************************************/ 265a9d8d09cSJung-uk Kim 266a9d8d09cSJung-uk Kim static int 267a9d8d09cSJung-uk Kim AslDoOptions ( 268a9d8d09cSJung-uk Kim int argc, 269a9d8d09cSJung-uk Kim char **argv, 270a9d8d09cSJung-uk Kim BOOLEAN IsResponseFile) 271a9d8d09cSJung-uk Kim { 272a9d8d09cSJung-uk Kim ACPI_STATUS Status; 273a9d8d09cSJung-uk Kim UINT32 j; 274a9d8d09cSJung-uk Kim 275a9d8d09cSJung-uk Kim 276a9d8d09cSJung-uk Kim /* Get the command line options */ 277a9d8d09cSJung-uk Kim 278313a0c13SJung-uk Kim while ((j = AcpiGetopt (argc, argv, ASL_SUPPORTED_OPTIONS)) != ACPI_OPT_END) switch (j) 279a9d8d09cSJung-uk Kim { 280a9d8d09cSJung-uk Kim case '@': /* Begin a response file */ 281a9d8d09cSJung-uk Kim 282a9d8d09cSJung-uk Kim if (IsResponseFile) 283a9d8d09cSJung-uk Kim { 284a9d8d09cSJung-uk Kim printf ("Nested command files are not supported\n"); 285a9d8d09cSJung-uk Kim return (-1); 286a9d8d09cSJung-uk Kim } 287a9d8d09cSJung-uk Kim 288a9d8d09cSJung-uk Kim if (AslDoResponseFile (AcpiGbl_Optarg)) 289a9d8d09cSJung-uk Kim { 290a9d8d09cSJung-uk Kim return (-1); 291a9d8d09cSJung-uk Kim } 292a9d8d09cSJung-uk Kim break; 293a9d8d09cSJung-uk Kim 294f8146b88SJung-uk Kim case 'a': /* Debug options */ 295f8146b88SJung-uk Kim 296f8146b88SJung-uk Kim switch (AcpiGbl_Optarg[0]) 297f8146b88SJung-uk Kim { 298f8146b88SJung-uk Kim case 'r': 299f8146b88SJung-uk Kim 3006f1f1a63SJung-uk Kim AslGbl_EnableReferenceTypechecking = TRUE; 301f8146b88SJung-uk Kim break; 302f8146b88SJung-uk Kim 303f8146b88SJung-uk Kim default: 304f8146b88SJung-uk Kim 305f8146b88SJung-uk Kim printf ("Unknown option: -a%s\n", AcpiGbl_Optarg); 306f8146b88SJung-uk Kim return (-1); 307f8146b88SJung-uk Kim } 308f8146b88SJung-uk Kim 309f8146b88SJung-uk Kim break; 310f8146b88SJung-uk Kim 311f8146b88SJung-uk Kim 3121c0e1b6dSJung-uk Kim case 'b': /* Debug options */ 313a9d8d09cSJung-uk Kim 314a9d8d09cSJung-uk Kim switch (AcpiGbl_Optarg[0]) 315a9d8d09cSJung-uk Kim { 3160d84335fSJung-uk Kim 3170d84335fSJung-uk Kim case 'c': 3180d84335fSJung-uk Kim 3190d84335fSJung-uk Kim printf ("Debug ASL to ASL+ conversion\n"); 3200d84335fSJung-uk Kim 3216f1f1a63SJung-uk Kim AslGbl_DoAslConversion = TRUE; 3226f1f1a63SJung-uk Kim AslGbl_FoldConstants = FALSE; 3236f1f1a63SJung-uk Kim AslGbl_IntegerOptimizationFlag = FALSE; 3246f1f1a63SJung-uk Kim AslGbl_ReferenceOptimizationFlag = FALSE; 3256f1f1a63SJung-uk Kim AslGbl_OptimizeTrivialParseNodes = FALSE; 326f1db5ef7SJung-uk Kim AcpiGbl_CaptureComments = TRUE; 3270d84335fSJung-uk Kim AcpiGbl_DoDisassemblerOptimizations = FALSE; 3280d84335fSJung-uk Kim AcpiGbl_DebugAslConversion = TRUE; 3290d84335fSJung-uk Kim AcpiGbl_DmEmitExternalOpcodes = TRUE; 3306f1f1a63SJung-uk Kim AslGbl_DoExternalsInPlace = TRUE; 3310d84335fSJung-uk Kim 3320d84335fSJung-uk Kim return (0); 3330d84335fSJung-uk Kim 334a9d8d09cSJung-uk Kim case 'f': 335a9d8d09cSJung-uk Kim 336a9d8d09cSJung-uk Kim AslCompilerdebug = 1; /* same as yydebug */ 337a9d8d09cSJung-uk Kim DtParserdebug = 1; 338a9d8d09cSJung-uk Kim PrParserdebug = 1; 3396f1f1a63SJung-uk Kim AslGbl_DebugFlag = TRUE; 3406f1f1a63SJung-uk Kim AslGbl_KeepPreprocessorTempFile = TRUE; 3411c0e1b6dSJung-uk Kim break; 3421c0e1b6dSJung-uk Kim 3431c0e1b6dSJung-uk Kim case 'p': /* Prune ASL parse tree */ 3441c0e1b6dSJung-uk Kim 3451c0e1b6dSJung-uk Kim /* Get the required argument */ 3461c0e1b6dSJung-uk Kim 3471c0e1b6dSJung-uk Kim if (AcpiGetoptArgument (argc, argv)) 3481c0e1b6dSJung-uk Kim { 3491c0e1b6dSJung-uk Kim return (-1); 3501c0e1b6dSJung-uk Kim } 3511c0e1b6dSJung-uk Kim 3526f1f1a63SJung-uk Kim AslGbl_PruneParseTree = TRUE; 3536f1f1a63SJung-uk Kim AslGbl_PruneDepth = (UINT8) strtoul (AcpiGbl_Optarg, NULL, 0); 3541c0e1b6dSJung-uk Kim break; 3551c0e1b6dSJung-uk Kim 3561c0e1b6dSJung-uk Kim case 's': 3571c0e1b6dSJung-uk Kim 3586f1f1a63SJung-uk Kim AslGbl_DebugFlag = TRUE; 359a9d8d09cSJung-uk Kim break; 360a9d8d09cSJung-uk Kim 361a9d8d09cSJung-uk Kim case 't': 362a9d8d09cSJung-uk Kim 3631c0e1b6dSJung-uk Kim /* Get the required argument */ 3641c0e1b6dSJung-uk Kim 3651c0e1b6dSJung-uk Kim if (AcpiGetoptArgument (argc, argv)) 3661c0e1b6dSJung-uk Kim { 3671c0e1b6dSJung-uk Kim return (-1); 3681c0e1b6dSJung-uk Kim } 3691c0e1b6dSJung-uk Kim 3706f1f1a63SJung-uk Kim AslGbl_PruneType = (UINT8) strtoul (AcpiGbl_Optarg, NULL, 0); 371a9d8d09cSJung-uk Kim break; 372a9d8d09cSJung-uk Kim 373a9d8d09cSJung-uk Kim default: 374a9d8d09cSJung-uk Kim 375a9d8d09cSJung-uk Kim printf ("Unknown option: -b%s\n", AcpiGbl_Optarg); 376a9d8d09cSJung-uk Kim return (-1); 377a9d8d09cSJung-uk Kim } 378a9d8d09cSJung-uk Kim 379a9d8d09cSJung-uk Kim break; 380a9d8d09cSJung-uk Kim 381a9d8d09cSJung-uk Kim case 'c': 382a9d8d09cSJung-uk Kim 383a9d8d09cSJung-uk Kim switch (AcpiGbl_Optarg[0]) 384a9d8d09cSJung-uk Kim { 3850d84335fSJung-uk Kim 3860d84335fSJung-uk Kim case 'a': 3870d84335fSJung-uk Kim 3880d84335fSJung-uk Kim printf ("Convert ASL to ASL+ with comments\n"); 3896f1f1a63SJung-uk Kim AslGbl_DoAslConversion = TRUE; 3906f1f1a63SJung-uk Kim AslGbl_FoldConstants = FALSE; 3916f1f1a63SJung-uk Kim AslGbl_IntegerOptimizationFlag = FALSE; 3926f1f1a63SJung-uk Kim AslGbl_ReferenceOptimizationFlag = FALSE; 3936f1f1a63SJung-uk Kim AslGbl_OptimizeTrivialParseNodes = FALSE; 394f1db5ef7SJung-uk Kim AcpiGbl_CaptureComments = TRUE; 3950d84335fSJung-uk Kim AcpiGbl_DoDisassemblerOptimizations = FALSE; 3960d84335fSJung-uk Kim AcpiGbl_DmEmitExternalOpcodes = TRUE; 3976f1f1a63SJung-uk Kim AslGbl_DoExternalsInPlace = TRUE; 3980d84335fSJung-uk Kim 3990d84335fSJung-uk Kim return (0); 4000d84335fSJung-uk Kim 401a9d8d09cSJung-uk Kim case 'r': 402a9d8d09cSJung-uk Kim 4036f1f1a63SJung-uk Kim AslGbl_NoResourceChecking = TRUE; 404a9d8d09cSJung-uk Kim break; 405a9d8d09cSJung-uk Kim 406a9d8d09cSJung-uk Kim default: 407a9d8d09cSJung-uk Kim 408a9d8d09cSJung-uk Kim printf ("Unknown option: -c%s\n", AcpiGbl_Optarg); 409a9d8d09cSJung-uk Kim return (-1); 410a9d8d09cSJung-uk Kim } 411a9d8d09cSJung-uk Kim break; 412a9d8d09cSJung-uk Kim 413a9d8d09cSJung-uk Kim case 'd': /* Disassembler */ 414a9d8d09cSJung-uk Kim 415a9d8d09cSJung-uk Kim switch (AcpiGbl_Optarg[0]) 416a9d8d09cSJung-uk Kim { 417a9d8d09cSJung-uk Kim case '^': 418a9d8d09cSJung-uk Kim 4196f1f1a63SJung-uk Kim AslGbl_DoCompile = FALSE; 420a9d8d09cSJung-uk Kim break; 421a9d8d09cSJung-uk Kim 422a9d8d09cSJung-uk Kim case 'a': 423a9d8d09cSJung-uk Kim 4246f1f1a63SJung-uk Kim AslGbl_DoCompile = FALSE; 4256f1f1a63SJung-uk Kim AslGbl_DisassembleAll = TRUE; 426a9d8d09cSJung-uk Kim break; 427a9d8d09cSJung-uk Kim 428a9d8d09cSJung-uk Kim case 'b': /* Do not convert buffers to resource descriptors */ 429a9d8d09cSJung-uk Kim 430a9d8d09cSJung-uk Kim AcpiGbl_NoResourceDisassembly = TRUE; 431a9d8d09cSJung-uk Kim break; 432a9d8d09cSJung-uk Kim 433a9d8d09cSJung-uk Kim case 'c': 434a9d8d09cSJung-uk Kim 435a9d8d09cSJung-uk Kim break; 436a9d8d09cSJung-uk Kim 4377cf3e94aSJung-uk Kim case 'f': 4387cf3e94aSJung-uk Kim 4397cf3e94aSJung-uk Kim AcpiGbl_ForceAmlDisassembly = TRUE; 4407cf3e94aSJung-uk Kim break; 4417cf3e94aSJung-uk Kim 4421c0e1b6dSJung-uk Kim case 'l': /* Use legacy ASL code (not ASL+) for disassembly */ 4431c0e1b6dSJung-uk Kim 4446f1f1a63SJung-uk Kim AslGbl_DoCompile = FALSE; 4451c0e1b6dSJung-uk Kim AcpiGbl_CstyleDisassembly = FALSE; 4461c0e1b6dSJung-uk Kim break; 4471c0e1b6dSJung-uk Kim 448a9d8d09cSJung-uk Kim default: 449a9d8d09cSJung-uk Kim 450a9d8d09cSJung-uk Kim printf ("Unknown option: -d%s\n", AcpiGbl_Optarg); 451a9d8d09cSJung-uk Kim return (-1); 452a9d8d09cSJung-uk Kim } 453a9d8d09cSJung-uk Kim 454af051161SJung-uk Kim AcpiGbl_DisasmFlag = TRUE; 455a9d8d09cSJung-uk Kim break; 456a9d8d09cSJung-uk Kim 457a9d8d09cSJung-uk Kim case 'D': /* Define a symbol */ 458a9d8d09cSJung-uk Kim 459a9d8d09cSJung-uk Kim PrAddDefine (AcpiGbl_Optarg, NULL, TRUE); 460a9d8d09cSJung-uk Kim break; 461a9d8d09cSJung-uk Kim 462a9d8d09cSJung-uk Kim case 'e': /* External files for disassembler */ 463a9d8d09cSJung-uk Kim 464313a0c13SJung-uk Kim /* Get entire list of external files */ 465313a0c13SJung-uk Kim 466313a0c13SJung-uk Kim AcpiGbl_Optind--; 467313a0c13SJung-uk Kim argv[AcpiGbl_Optind] = AcpiGbl_Optarg; 468313a0c13SJung-uk Kim 469313a0c13SJung-uk Kim while (argv[AcpiGbl_Optind] && 470313a0c13SJung-uk Kim (argv[AcpiGbl_Optind][0] != '-')) 471313a0c13SJung-uk Kim { 472313a0c13SJung-uk Kim Status = AcpiDmAddToExternalFileList (argv[AcpiGbl_Optind]); 473a9d8d09cSJung-uk Kim if (ACPI_FAILURE (Status)) 474a9d8d09cSJung-uk Kim { 475f8146b88SJung-uk Kim printf ("Could not add %s to external list\n", 476f8146b88SJung-uk Kim argv[AcpiGbl_Optind]); 477a9d8d09cSJung-uk Kim return (-1); 478a9d8d09cSJung-uk Kim } 479313a0c13SJung-uk Kim 480313a0c13SJung-uk Kim AcpiGbl_Optind++; 481313a0c13SJung-uk Kim } 482a9d8d09cSJung-uk Kim break; 483a9d8d09cSJung-uk Kim 48479c6d946SJung-uk Kim case 'f': 48579c6d946SJung-uk Kim 48679c6d946SJung-uk Kim switch (AcpiGbl_Optarg[0]) 48779c6d946SJung-uk Kim { 48879c6d946SJung-uk Kim case '^': /* Ignore errors and force creation of aml file */ 489a9d8d09cSJung-uk Kim 4906f1f1a63SJung-uk Kim AslGbl_IgnoreErrors = TRUE; 491a9d8d09cSJung-uk Kim break; 492a9d8d09cSJung-uk Kim 49379c6d946SJung-uk Kim case 'e': /* Disassembler: Get external declaration file */ 49479c6d946SJung-uk Kim 49579c6d946SJung-uk Kim if (AcpiGetoptArgument (argc, argv)) 49679c6d946SJung-uk Kim { 49779c6d946SJung-uk Kim return (-1); 49879c6d946SJung-uk Kim } 49979c6d946SJung-uk Kim 5006f1f1a63SJung-uk Kim AslGbl_ExternalRefFilename = AcpiGbl_Optarg; 50179c6d946SJung-uk Kim break; 50279c6d946SJung-uk Kim 50379c6d946SJung-uk Kim default: 50479c6d946SJung-uk Kim 50579c6d946SJung-uk Kim printf ("Unknown option: -f%s\n", AcpiGbl_Optarg); 50679c6d946SJung-uk Kim return (-1); 50779c6d946SJung-uk Kim } 50879c6d946SJung-uk Kim break; 50979c6d946SJung-uk Kim 510a9d8d09cSJung-uk Kim case 'G': 511a9d8d09cSJung-uk Kim 5126f1f1a63SJung-uk Kim AslGbl_CompileGeneric = TRUE; 513a9d8d09cSJung-uk Kim break; 514a9d8d09cSJung-uk Kim 515a9d8d09cSJung-uk Kim case 'g': /* Get all ACPI tables */ 516a9d8d09cSJung-uk Kim 517313a0c13SJung-uk Kim printf ("-g option is deprecated, use acpidump utility instead\n"); 518313a0c13SJung-uk Kim exit (1); 519a9d8d09cSJung-uk Kim 520a9d8d09cSJung-uk Kim case 'h': 521a9d8d09cSJung-uk Kim 522a9d8d09cSJung-uk Kim switch (AcpiGbl_Optarg[0]) 523a9d8d09cSJung-uk Kim { 524a9d8d09cSJung-uk Kim case '^': 525a9d8d09cSJung-uk Kim 526a9d8d09cSJung-uk Kim Usage (); 527a9d8d09cSJung-uk Kim exit (0); 528a9d8d09cSJung-uk Kim 529a9d8d09cSJung-uk Kim case 'c': 530a9d8d09cSJung-uk Kim 531a9d8d09cSJung-uk Kim UtDisplayConstantOpcodes (); 532a9d8d09cSJung-uk Kim exit (0); 533a9d8d09cSJung-uk Kim 534493deb39SJung-uk Kim case 'd': 535493deb39SJung-uk Kim 536493deb39SJung-uk Kim AslDisassemblyHelp (); 537493deb39SJung-uk Kim exit (0); 538493deb39SJung-uk Kim 539a9d8d09cSJung-uk Kim case 'f': 540a9d8d09cSJung-uk Kim 541a9d8d09cSJung-uk Kim AslFilenameHelp (); 542a9d8d09cSJung-uk Kim exit (0); 543a9d8d09cSJung-uk Kim 544a9d8d09cSJung-uk Kim case 'r': 545a9d8d09cSJung-uk Kim 546a9d8d09cSJung-uk Kim /* reserved names */ 547a9d8d09cSJung-uk Kim 548a9d8d09cSJung-uk Kim ApDisplayReservedNames (); 549a9d8d09cSJung-uk Kim exit (0); 550a9d8d09cSJung-uk Kim 551a9d8d09cSJung-uk Kim case 't': 552a9d8d09cSJung-uk Kim 553a9d8d09cSJung-uk Kim UtDisplaySupportedTables (); 554a9d8d09cSJung-uk Kim exit (0); 555a9d8d09cSJung-uk Kim 556a9d8d09cSJung-uk Kim default: 557a9d8d09cSJung-uk Kim 558a9d8d09cSJung-uk Kim printf ("Unknown option: -h%s\n", AcpiGbl_Optarg); 559a9d8d09cSJung-uk Kim return (-1); 560a9d8d09cSJung-uk Kim } 561a9d8d09cSJung-uk Kim 562a9d8d09cSJung-uk Kim case 'I': /* Add an include file search directory */ 563a9d8d09cSJung-uk Kim 564a9d8d09cSJung-uk Kim FlAddIncludeDirectory (AcpiGbl_Optarg); 565a9d8d09cSJung-uk Kim break; 566a9d8d09cSJung-uk Kim 567a9d8d09cSJung-uk Kim case 'i': /* Output AML as an include file */ 568a9d8d09cSJung-uk Kim 569a9d8d09cSJung-uk Kim switch (AcpiGbl_Optarg[0]) 570a9d8d09cSJung-uk Kim { 571a9d8d09cSJung-uk Kim case 'a': 572a9d8d09cSJung-uk Kim 573a9d8d09cSJung-uk Kim /* Produce assembly code include file */ 574a9d8d09cSJung-uk Kim 5756f1f1a63SJung-uk Kim AslGbl_AsmIncludeOutputFlag = TRUE; 576a9d8d09cSJung-uk Kim break; 577a9d8d09cSJung-uk Kim 578a9d8d09cSJung-uk Kim case 'c': 579a9d8d09cSJung-uk Kim 580a9d8d09cSJung-uk Kim /* Produce C include file */ 581a9d8d09cSJung-uk Kim 5826f1f1a63SJung-uk Kim AslGbl_C_IncludeOutputFlag = TRUE; 583a9d8d09cSJung-uk Kim break; 584a9d8d09cSJung-uk Kim 585a9d8d09cSJung-uk Kim case 'n': 586a9d8d09cSJung-uk Kim 587a9d8d09cSJung-uk Kim /* Compiler/Disassembler: Ignore the NOOP operator */ 588a9d8d09cSJung-uk Kim 589a9d8d09cSJung-uk Kim AcpiGbl_IgnoreNoopOperator = TRUE; 590a9d8d09cSJung-uk Kim break; 591a9d8d09cSJung-uk Kim 592a9d8d09cSJung-uk Kim default: 593a9d8d09cSJung-uk Kim 594a9d8d09cSJung-uk Kim printf ("Unknown option: -i%s\n", AcpiGbl_Optarg); 595a9d8d09cSJung-uk Kim return (-1); 596a9d8d09cSJung-uk Kim } 597a9d8d09cSJung-uk Kim break; 598a9d8d09cSJung-uk Kim 599a9d8d09cSJung-uk Kim case 'l': /* Listing files */ 600a9d8d09cSJung-uk Kim 601a9d8d09cSJung-uk Kim switch (AcpiGbl_Optarg[0]) 602a9d8d09cSJung-uk Kim { 603a9d8d09cSJung-uk Kim case '^': 604a9d8d09cSJung-uk Kim 605a9d8d09cSJung-uk Kim /* Produce listing file (Mixed source/aml) */ 606a9d8d09cSJung-uk Kim 6076f1f1a63SJung-uk Kim AslGbl_ListingFlag = TRUE; 60870e6ab8fSJung-uk Kim AcpiGbl_DmOpt_Listing = TRUE; 609a9d8d09cSJung-uk Kim break; 610a9d8d09cSJung-uk Kim 611a9d8d09cSJung-uk Kim case 'i': 612a9d8d09cSJung-uk Kim 613a9d8d09cSJung-uk Kim /* Produce preprocessor output file */ 614a9d8d09cSJung-uk Kim 6156f1f1a63SJung-uk Kim AslGbl_PreprocessorOutputFlag = TRUE; 616a9d8d09cSJung-uk Kim break; 617a9d8d09cSJung-uk Kim 618313a0c13SJung-uk Kim case 'm': 619313a0c13SJung-uk Kim 620313a0c13SJung-uk Kim /* Produce hardware map summary file */ 621313a0c13SJung-uk Kim 6226f1f1a63SJung-uk Kim AslGbl_MapfileFlag = TRUE; 623313a0c13SJung-uk Kim break; 624313a0c13SJung-uk Kim 625a9d8d09cSJung-uk Kim case 'n': 626a9d8d09cSJung-uk Kim 627a9d8d09cSJung-uk Kim /* Produce namespace file */ 628a9d8d09cSJung-uk Kim 6296f1f1a63SJung-uk Kim AslGbl_NsOutputFlag = TRUE; 630a9d8d09cSJung-uk Kim break; 631a9d8d09cSJung-uk Kim 632a9d8d09cSJung-uk Kim case 's': 633a9d8d09cSJung-uk Kim 634a9d8d09cSJung-uk Kim /* Produce combined source file */ 635a9d8d09cSJung-uk Kim 6366f1f1a63SJung-uk Kim AslGbl_SourceOutputFlag = TRUE; 637a9d8d09cSJung-uk Kim break; 638a9d8d09cSJung-uk Kim 639f8146b88SJung-uk Kim case 'x': 640f8146b88SJung-uk Kim 641f8146b88SJung-uk Kim /* Produce cross-reference file */ 642f8146b88SJung-uk Kim 6436f1f1a63SJung-uk Kim AslGbl_CrossReferenceOutput = TRUE; 644f8146b88SJung-uk Kim break; 645f8146b88SJung-uk Kim 646a9d8d09cSJung-uk Kim default: 647a9d8d09cSJung-uk Kim 648a9d8d09cSJung-uk Kim printf ("Unknown option: -l%s\n", AcpiGbl_Optarg); 649a9d8d09cSJung-uk Kim return (-1); 650a9d8d09cSJung-uk Kim } 651a9d8d09cSJung-uk Kim break; 652a9d8d09cSJung-uk Kim 653a9d8d09cSJung-uk Kim case 'm': /* Set line buffer size */ 654a9d8d09cSJung-uk Kim 6556f1f1a63SJung-uk Kim AslGbl_LineBufferSize = (UINT32) strtoul (AcpiGbl_Optarg, NULL, 0) * 1024; 6566f1f1a63SJung-uk Kim if (AslGbl_LineBufferSize < ASL_DEFAULT_LINE_BUFFER_SIZE) 657a9d8d09cSJung-uk Kim { 6586f1f1a63SJung-uk Kim AslGbl_LineBufferSize = ASL_DEFAULT_LINE_BUFFER_SIZE; 659a9d8d09cSJung-uk Kim } 6606f1f1a63SJung-uk Kim printf ("Line Buffer Size: %u\n", AslGbl_LineBufferSize); 661a9d8d09cSJung-uk Kim break; 662a9d8d09cSJung-uk Kim 663a9d8d09cSJung-uk Kim case 'n': /* Parse only */ 664a9d8d09cSJung-uk Kim 6656f1f1a63SJung-uk Kim AslGbl_ParseOnlyFlag = TRUE; 666a9d8d09cSJung-uk Kim break; 667a9d8d09cSJung-uk Kim 668a9d8d09cSJung-uk Kim case 'o': /* Control compiler AML optimizations */ 669a9d8d09cSJung-uk Kim 670a9d8d09cSJung-uk Kim switch (AcpiGbl_Optarg[0]) 671a9d8d09cSJung-uk Kim { 672a9d8d09cSJung-uk Kim case 'a': 673a9d8d09cSJung-uk Kim 674a9d8d09cSJung-uk Kim /* Disable all optimizations */ 675a9d8d09cSJung-uk Kim 6766f1f1a63SJung-uk Kim AslGbl_FoldConstants = FALSE; 6776f1f1a63SJung-uk Kim AslGbl_IntegerOptimizationFlag = FALSE; 6786f1f1a63SJung-uk Kim AslGbl_ReferenceOptimizationFlag = FALSE; 6796f1f1a63SJung-uk Kim AslGbl_OptimizeTrivialParseNodes = FALSE; 6800d84335fSJung-uk Kim 681a9d8d09cSJung-uk Kim break; 682a9d8d09cSJung-uk Kim 683f8146b88SJung-uk Kim case 'c': 684f8146b88SJung-uk Kim 685f8146b88SJung-uk Kim /* Display compile time(s) */ 686f8146b88SJung-uk Kim 6876f1f1a63SJung-uk Kim AslGbl_CompileTimesFlag = TRUE; 688f8146b88SJung-uk Kim break; 689f8146b88SJung-uk Kim 690493deb39SJung-uk Kim case 'd': 691493deb39SJung-uk Kim 692493deb39SJung-uk Kim /* Disable disassembler code optimizations */ 693493deb39SJung-uk Kim 694493deb39SJung-uk Kim AcpiGbl_DoDisassemblerOptimizations = FALSE; 695493deb39SJung-uk Kim break; 696493deb39SJung-uk Kim 697f8146b88SJung-uk Kim case 'e': 698f8146b88SJung-uk Kim 6993920312eSJung-uk Kim /* Disassembler: Emit embedded external operators */ 7003920312eSJung-uk Kim 7013920312eSJung-uk Kim AcpiGbl_DmEmitExternalOpcodes = TRUE; 702f8146b88SJung-uk Kim break; 703f8146b88SJung-uk Kim 7040d84335fSJung-uk Kim case 'E': 7050d84335fSJung-uk Kim 7060d84335fSJung-uk Kim /* 7070d84335fSJung-uk Kim * iASL: keep External opcodes in place. 7080d84335fSJung-uk Kim * No affect if Gbl_DoExternals is false. 7090d84335fSJung-uk Kim */ 7100d84335fSJung-uk Kim 7116f1f1a63SJung-uk Kim AslGbl_DoExternalsInPlace = TRUE; 7120d84335fSJung-uk Kim break; 7130d84335fSJung-uk Kim 714a9d8d09cSJung-uk Kim case 'f': 715a9d8d09cSJung-uk Kim 716a9d8d09cSJung-uk Kim /* Disable folding on "normal" expressions */ 717a9d8d09cSJung-uk Kim 7186f1f1a63SJung-uk Kim AslGbl_FoldConstants = FALSE; 719a9d8d09cSJung-uk Kim break; 720a9d8d09cSJung-uk Kim 721a9d8d09cSJung-uk Kim case 'i': 722a9d8d09cSJung-uk Kim 723a9d8d09cSJung-uk Kim /* Disable integer optimization to constants */ 724a9d8d09cSJung-uk Kim 7256f1f1a63SJung-uk Kim AslGbl_IntegerOptimizationFlag = FALSE; 726a9d8d09cSJung-uk Kim break; 727a9d8d09cSJung-uk Kim 728a9d8d09cSJung-uk Kim case 'n': 729a9d8d09cSJung-uk Kim 730a9d8d09cSJung-uk Kim /* Disable named reference optimization */ 731a9d8d09cSJung-uk Kim 7326f1f1a63SJung-uk Kim AslGbl_ReferenceOptimizationFlag = FALSE; 733a9d8d09cSJung-uk Kim break; 734a9d8d09cSJung-uk Kim 735a9d8d09cSJung-uk Kim case 't': 736a9d8d09cSJung-uk Kim 737f8146b88SJung-uk Kim /* Disable heavy typechecking */ 738a9d8d09cSJung-uk Kim 7396f1f1a63SJung-uk Kim AslGbl_DoTypechecking = FALSE; 740a9d8d09cSJung-uk Kim break; 741a9d8d09cSJung-uk Kim 742a9d8d09cSJung-uk Kim default: 743a9d8d09cSJung-uk Kim 744a9d8d09cSJung-uk Kim printf ("Unknown option: -c%s\n", AcpiGbl_Optarg); 745a9d8d09cSJung-uk Kim return (-1); 746a9d8d09cSJung-uk Kim } 747a9d8d09cSJung-uk Kim break; 748a9d8d09cSJung-uk Kim 749a9d8d09cSJung-uk Kim case 'P': /* Preprocessor options */ 750a9d8d09cSJung-uk Kim 751a9d8d09cSJung-uk Kim switch (AcpiGbl_Optarg[0]) 752a9d8d09cSJung-uk Kim { 753a9d8d09cSJung-uk Kim case '^': /* Proprocess only, emit (.i) file */ 754a9d8d09cSJung-uk Kim 7556f1f1a63SJung-uk Kim AslGbl_PreprocessOnly = TRUE; 7566f1f1a63SJung-uk Kim AslGbl_PreprocessorOutputFlag = TRUE; 757a9d8d09cSJung-uk Kim break; 758a9d8d09cSJung-uk Kim 759a9d8d09cSJung-uk Kim case 'n': /* Disable preprocessor */ 760a9d8d09cSJung-uk Kim 7616f1f1a63SJung-uk Kim AslGbl_PreprocessFlag = FALSE; 762a9d8d09cSJung-uk Kim break; 763a9d8d09cSJung-uk Kim 764a9d8d09cSJung-uk Kim default: 765a9d8d09cSJung-uk Kim 766a9d8d09cSJung-uk Kim printf ("Unknown option: -P%s\n", AcpiGbl_Optarg); 767a9d8d09cSJung-uk Kim return (-1); 768a9d8d09cSJung-uk Kim } 769a9d8d09cSJung-uk Kim break; 770a9d8d09cSJung-uk Kim 771a9d8d09cSJung-uk Kim case 'p': /* Override default AML output filename */ 772a9d8d09cSJung-uk Kim 7736f1f1a63SJung-uk Kim AslGbl_OutputFilenamePrefix = AcpiGbl_Optarg; 7746f1f1a63SJung-uk Kim UtConvertBackslashes (AslGbl_OutputFilenamePrefix); 7756f1f1a63SJung-uk Kim AslGbl_UseDefaultAmlFilename = FALSE; 776a9d8d09cSJung-uk Kim break; 777a9d8d09cSJung-uk Kim 7780d84335fSJung-uk Kim case 'q': /* ASL/ASl+ converter: compile only and leave badaml. */ 7790d84335fSJung-uk Kim 7800d84335fSJung-uk Kim printf ("Convert ASL to ASL+ with comments\n"); 7816f1f1a63SJung-uk Kim AslGbl_FoldConstants = FALSE; 7826f1f1a63SJung-uk Kim AslGbl_IntegerOptimizationFlag = FALSE; 7836f1f1a63SJung-uk Kim AslGbl_ReferenceOptimizationFlag = FALSE; 7846f1f1a63SJung-uk Kim AslGbl_OptimizeTrivialParseNodes = FALSE; 7856f1f1a63SJung-uk Kim AslGbl_DoExternalsInPlace = TRUE; 786f1db5ef7SJung-uk Kim AcpiGbl_CaptureComments = TRUE; 7870d84335fSJung-uk Kim return (0); 7880d84335fSJung-uk Kim 789a9d8d09cSJung-uk Kim case 'r': /* Override revision found in table header */ 790a9d8d09cSJung-uk Kim 7916f1f1a63SJung-uk Kim AslGbl_RevisionOverride = (UINT8) strtoul (AcpiGbl_Optarg, NULL, 0); 792a9d8d09cSJung-uk Kim break; 793a9d8d09cSJung-uk Kim 794a9d8d09cSJung-uk Kim case 's': /* Create AML in a source code file */ 795a9d8d09cSJung-uk Kim 796a9d8d09cSJung-uk Kim switch (AcpiGbl_Optarg[0]) 797a9d8d09cSJung-uk Kim { 798a9d8d09cSJung-uk Kim case 'a': 799a9d8d09cSJung-uk Kim 800a9d8d09cSJung-uk Kim /* Produce assembly code output file */ 801a9d8d09cSJung-uk Kim 8026f1f1a63SJung-uk Kim AslGbl_AsmOutputFlag = TRUE; 803a9d8d09cSJung-uk Kim break; 804a9d8d09cSJung-uk Kim 805a9d8d09cSJung-uk Kim case 'c': 806a9d8d09cSJung-uk Kim 807a9d8d09cSJung-uk Kim /* Produce C hex output file */ 808a9d8d09cSJung-uk Kim 8096f1f1a63SJung-uk Kim AslGbl_C_OutputFlag = TRUE; 810a9d8d09cSJung-uk Kim break; 811a9d8d09cSJung-uk Kim 812a9d8d09cSJung-uk Kim case 'o': 813a9d8d09cSJung-uk Kim 814a9d8d09cSJung-uk Kim /* Produce AML offset table in C */ 815a9d8d09cSJung-uk Kim 8166f1f1a63SJung-uk Kim AslGbl_C_OffsetTableFlag = TRUE; 817a9d8d09cSJung-uk Kim break; 818a9d8d09cSJung-uk Kim 819a9d8d09cSJung-uk Kim default: 820a9d8d09cSJung-uk Kim 821a9d8d09cSJung-uk Kim printf ("Unknown option: -s%s\n", AcpiGbl_Optarg); 822a9d8d09cSJung-uk Kim return (-1); 823a9d8d09cSJung-uk Kim } 824a9d8d09cSJung-uk Kim break; 825a9d8d09cSJung-uk Kim 826a9d8d09cSJung-uk Kim case 't': /* Produce hex table output file */ 827a9d8d09cSJung-uk Kim 828a9d8d09cSJung-uk Kim switch (AcpiGbl_Optarg[0]) 829a9d8d09cSJung-uk Kim { 830a9d8d09cSJung-uk Kim case 'a': 831a9d8d09cSJung-uk Kim 8326f1f1a63SJung-uk Kim AslGbl_HexOutputFlag = HEX_OUTPUT_ASM; 833a9d8d09cSJung-uk Kim break; 834a9d8d09cSJung-uk Kim 835a9d8d09cSJung-uk Kim case 'c': 836a9d8d09cSJung-uk Kim 8376f1f1a63SJung-uk Kim AslGbl_HexOutputFlag = HEX_OUTPUT_C; 838a9d8d09cSJung-uk Kim break; 839a9d8d09cSJung-uk Kim 840*a009b7dcSJung-uk Kim case 'p': /* data table flex/bison prototype */ 841*a009b7dcSJung-uk Kim 842*a009b7dcSJung-uk Kim AslGbl_DtLexBisonPrototype = TRUE; 843*a009b7dcSJung-uk Kim break; 844*a009b7dcSJung-uk Kim 845a9d8d09cSJung-uk Kim case 's': 846a9d8d09cSJung-uk Kim 8476f1f1a63SJung-uk Kim AslGbl_HexOutputFlag = HEX_OUTPUT_ASL; 848a9d8d09cSJung-uk Kim break; 849a9d8d09cSJung-uk Kim 850a9d8d09cSJung-uk Kim default: 851a9d8d09cSJung-uk Kim 852a9d8d09cSJung-uk Kim printf ("Unknown option: -t%s\n", AcpiGbl_Optarg); 853a9d8d09cSJung-uk Kim return (-1); 854a9d8d09cSJung-uk Kim } 855a9d8d09cSJung-uk Kim break; 856a9d8d09cSJung-uk Kim 857a9d8d09cSJung-uk Kim case 'T': /* Create a ACPI table template file */ 858a9d8d09cSJung-uk Kim 8596f1f1a63SJung-uk Kim AslGbl_DoTemplates = TRUE; 860a9d8d09cSJung-uk Kim break; 861a9d8d09cSJung-uk Kim 862a9d8d09cSJung-uk Kim case 'v': /* Version and verbosity settings */ 863a9d8d09cSJung-uk Kim 864a9d8d09cSJung-uk Kim switch (AcpiGbl_Optarg[0]) 865a9d8d09cSJung-uk Kim { 866a9d8d09cSJung-uk Kim case '^': 867a9d8d09cSJung-uk Kim 868a9d8d09cSJung-uk Kim printf (ACPI_COMMON_SIGNON (ASL_COMPILER_NAME)); 869a9d8d09cSJung-uk Kim exit (0); 870a9d8d09cSJung-uk Kim 871a9d8d09cSJung-uk Kim case 'a': 872a9d8d09cSJung-uk Kim 873313a0c13SJung-uk Kim /* Disable all error/warning/remark messages */ 874a9d8d09cSJung-uk Kim 8756f1f1a63SJung-uk Kim AslGbl_NoErrors = TRUE; 876a9d8d09cSJung-uk Kim break; 877a9d8d09cSJung-uk Kim 878313a0c13SJung-uk Kim case 'e': 879313a0c13SJung-uk Kim 880313a0c13SJung-uk Kim /* Disable all warning/remark messages (errors only) */ 881313a0c13SJung-uk Kim 8826f1f1a63SJung-uk Kim AslGbl_DisplayRemarks = FALSE; 8836f1f1a63SJung-uk Kim AslGbl_DisplayWarnings = FALSE; 884313a0c13SJung-uk Kim break; 885313a0c13SJung-uk Kim 886a9d8d09cSJung-uk Kim case 'i': 887a9d8d09cSJung-uk Kim /* 888a9d8d09cSJung-uk Kim * Support for integrated development environment(s). 889a9d8d09cSJung-uk Kim * 890a9d8d09cSJung-uk Kim * 1) No compiler signon 891a9d8d09cSJung-uk Kim * 2) Send stderr messages to stdout 892a9d8d09cSJung-uk Kim * 3) Less verbose error messages (single line only for each) 893a9d8d09cSJung-uk Kim * 4) Error/warning messages are formatted appropriately to 894a9d8d09cSJung-uk Kim * be recognized by MS Visual Studio 895a9d8d09cSJung-uk Kim */ 8966f1f1a63SJung-uk Kim AslGbl_VerboseErrors = FALSE; 8976f1f1a63SJung-uk Kim AslGbl_DoSignon = FALSE; 898a9d8d09cSJung-uk Kim break; 899a9d8d09cSJung-uk Kim 900a9d8d09cSJung-uk Kim case 'o': 901a9d8d09cSJung-uk Kim 9026f1f1a63SJung-uk Kim AslGbl_DisplayOptimizations = TRUE; 903a9d8d09cSJung-uk Kim break; 904a9d8d09cSJung-uk Kim 905a9d8d09cSJung-uk Kim case 'r': 906a9d8d09cSJung-uk Kim 9076f1f1a63SJung-uk Kim AslGbl_DisplayRemarks = FALSE; 908a9d8d09cSJung-uk Kim break; 909a9d8d09cSJung-uk Kim 910a9d8d09cSJung-uk Kim case 's': 911a9d8d09cSJung-uk Kim 9126f1f1a63SJung-uk Kim AslGbl_DoSignon = FALSE; 913a9d8d09cSJung-uk Kim break; 914a9d8d09cSJung-uk Kim 915a9d8d09cSJung-uk Kim case 't': 916a9d8d09cSJung-uk Kim 9176f1f1a63SJung-uk Kim AslGbl_VerboseTemplates = TRUE; 918a9d8d09cSJung-uk Kim break; 919a9d8d09cSJung-uk Kim 920a9d8d09cSJung-uk Kim case 'w': 921a9d8d09cSJung-uk Kim 922a9d8d09cSJung-uk Kim /* Get the required argument */ 923a9d8d09cSJung-uk Kim 924a9d8d09cSJung-uk Kim if (AcpiGetoptArgument (argc, argv)) 925a9d8d09cSJung-uk Kim { 926a9d8d09cSJung-uk Kim return (-1); 927a9d8d09cSJung-uk Kim } 928a9d8d09cSJung-uk Kim 929a9d8d09cSJung-uk Kim Status = AslDisableException (AcpiGbl_Optarg); 930a9d8d09cSJung-uk Kim if (ACPI_FAILURE (Status)) 931a9d8d09cSJung-uk Kim { 932a9d8d09cSJung-uk Kim return (-1); 933a9d8d09cSJung-uk Kim } 934a9d8d09cSJung-uk Kim break; 935a9d8d09cSJung-uk Kim 9365f9b24faSJung-uk Kim case 'x': 9375f9b24faSJung-uk Kim 9385f9b24faSJung-uk Kim /* Get the required argument */ 9395f9b24faSJung-uk Kim 9405f9b24faSJung-uk Kim if (AcpiGetoptArgument (argc, argv)) 9415f9b24faSJung-uk Kim { 9425f9b24faSJung-uk Kim return (-1); 9435f9b24faSJung-uk Kim } 9445f9b24faSJung-uk Kim 9455f9b24faSJung-uk Kim Status = AslExpectException (AcpiGbl_Optarg); 9465f9b24faSJung-uk Kim if (ACPI_FAILURE (Status)) 9475f9b24faSJung-uk Kim { 9485f9b24faSJung-uk Kim return (-1); 9495f9b24faSJung-uk Kim } 9505f9b24faSJung-uk Kim break; 9515f9b24faSJung-uk Kim 952a9d8d09cSJung-uk Kim default: 953a9d8d09cSJung-uk Kim 954a9d8d09cSJung-uk Kim printf ("Unknown option: -v%s\n", AcpiGbl_Optarg); 955a9d8d09cSJung-uk Kim return (-1); 956a9d8d09cSJung-uk Kim } 957a9d8d09cSJung-uk Kim break; 958a9d8d09cSJung-uk Kim 959a9d8d09cSJung-uk Kim case 'w': /* Set warning levels */ 960a9d8d09cSJung-uk Kim 961a9d8d09cSJung-uk Kim switch (AcpiGbl_Optarg[0]) 962a9d8d09cSJung-uk Kim { 963a9d8d09cSJung-uk Kim case '1': 964a9d8d09cSJung-uk Kim 9656f1f1a63SJung-uk Kim AslGbl_WarningLevel = ASL_WARNING; 966a9d8d09cSJung-uk Kim break; 967a9d8d09cSJung-uk Kim 968a9d8d09cSJung-uk Kim case '2': 969a9d8d09cSJung-uk Kim 9706f1f1a63SJung-uk Kim AslGbl_WarningLevel = ASL_WARNING2; 971a9d8d09cSJung-uk Kim break; 972a9d8d09cSJung-uk Kim 973a9d8d09cSJung-uk Kim case '3': 974a9d8d09cSJung-uk Kim 9756f1f1a63SJung-uk Kim AslGbl_WarningLevel = ASL_WARNING3; 976a9d8d09cSJung-uk Kim break; 977a9d8d09cSJung-uk Kim 978a9d8d09cSJung-uk Kim case 'e': 979a9d8d09cSJung-uk Kim 9806f1f1a63SJung-uk Kim AslGbl_WarningsAsErrors = TRUE; 981a9d8d09cSJung-uk Kim break; 982a9d8d09cSJung-uk Kim 98390b566fdSJung-uk Kim case 'w': 98490b566fdSJung-uk Kim 98590b566fdSJung-uk Kim /* Get the required argument */ 98690b566fdSJung-uk Kim 98790b566fdSJung-uk Kim if (AcpiGetoptArgument (argc, argv)) 98890b566fdSJung-uk Kim { 98990b566fdSJung-uk Kim return (-1); 99090b566fdSJung-uk Kim } 99190b566fdSJung-uk Kim 99290b566fdSJung-uk Kim Status = AslElevateException (AcpiGbl_Optarg); 99390b566fdSJung-uk Kim if (ACPI_FAILURE (Status)) 99490b566fdSJung-uk Kim { 99590b566fdSJung-uk Kim return (-1); 99690b566fdSJung-uk Kim } 99790b566fdSJung-uk Kim break; 99890b566fdSJung-uk Kim 99990b566fdSJung-uk Kim 1000a9d8d09cSJung-uk Kim default: 1001a9d8d09cSJung-uk Kim 1002a9d8d09cSJung-uk Kim printf ("Unknown option: -w%s\n", AcpiGbl_Optarg); 1003a9d8d09cSJung-uk Kim return (-1); 1004a9d8d09cSJung-uk Kim } 1005a9d8d09cSJung-uk Kim break; 1006a9d8d09cSJung-uk Kim 1007a9d8d09cSJung-uk Kim case 'x': /* Set debug print output level */ 1008a9d8d09cSJung-uk Kim 1009a9d8d09cSJung-uk Kim AcpiDbgLevel = strtoul (AcpiGbl_Optarg, NULL, 16); 1010a9d8d09cSJung-uk Kim break; 1011a9d8d09cSJung-uk Kim 1012a9d8d09cSJung-uk Kim case 'z': 1013a9d8d09cSJung-uk Kim 10146f1f1a63SJung-uk Kim AslGbl_UseOriginalCompilerId = TRUE; 1015a9d8d09cSJung-uk Kim break; 1016a9d8d09cSJung-uk Kim 1017a9d8d09cSJung-uk Kim default: 1018a9d8d09cSJung-uk Kim 1019a9d8d09cSJung-uk Kim return (-1); 1020a9d8d09cSJung-uk Kim } 1021a9d8d09cSJung-uk Kim 1022a9d8d09cSJung-uk Kim return (0); 1023a9d8d09cSJung-uk Kim } 1024a9d8d09cSJung-uk Kim 1025a9d8d09cSJung-uk Kim 1026a9d8d09cSJung-uk Kim /******************************************************************************* 1027a9d8d09cSJung-uk Kim * 1028a9d8d09cSJung-uk Kim * FUNCTION: AslMergeOptionTokens 1029a9d8d09cSJung-uk Kim * 1030a9d8d09cSJung-uk Kim * PARAMETERS: InBuffer - Input containing an option string 1031a9d8d09cSJung-uk Kim * OutBuffer - Merged output buffer 1032a9d8d09cSJung-uk Kim * 1033a9d8d09cSJung-uk Kim * RETURN: None 1034a9d8d09cSJung-uk Kim * 1035a9d8d09cSJung-uk Kim * DESCRIPTION: Remove all whitespace from an option string. 1036a9d8d09cSJung-uk Kim * 1037a9d8d09cSJung-uk Kim ******************************************************************************/ 1038a9d8d09cSJung-uk Kim 1039a9d8d09cSJung-uk Kim static void 1040a9d8d09cSJung-uk Kim AslMergeOptionTokens ( 1041a9d8d09cSJung-uk Kim char *InBuffer, 1042a9d8d09cSJung-uk Kim char *OutBuffer) 1043a9d8d09cSJung-uk Kim { 1044a9d8d09cSJung-uk Kim char *Token; 1045a9d8d09cSJung-uk Kim 1046a9d8d09cSJung-uk Kim 1047a9d8d09cSJung-uk Kim *OutBuffer = 0; 1048a9d8d09cSJung-uk Kim 1049a9d8d09cSJung-uk Kim Token = strtok (InBuffer, ASL_TOKEN_SEPARATORS); 1050a9d8d09cSJung-uk Kim while (Token) 1051a9d8d09cSJung-uk Kim { 1052a9d8d09cSJung-uk Kim strcat (OutBuffer, Token); 1053a9d8d09cSJung-uk Kim Token = strtok (NULL, ASL_TOKEN_SEPARATORS); 1054a9d8d09cSJung-uk Kim } 1055a9d8d09cSJung-uk Kim } 1056a9d8d09cSJung-uk Kim 1057a9d8d09cSJung-uk Kim 1058a9d8d09cSJung-uk Kim /******************************************************************************* 1059a9d8d09cSJung-uk Kim * 1060a9d8d09cSJung-uk Kim * FUNCTION: AslDoResponseFile 1061a9d8d09cSJung-uk Kim * 1062a9d8d09cSJung-uk Kim * PARAMETERS: Filename - Name of the response file 1063a9d8d09cSJung-uk Kim * 1064a9d8d09cSJung-uk Kim * RETURN: Status 1065a9d8d09cSJung-uk Kim * 1066a9d8d09cSJung-uk Kim * DESCRIPTION: Open a response file and process all options within. 1067a9d8d09cSJung-uk Kim * 1068a9d8d09cSJung-uk Kim ******************************************************************************/ 1069a9d8d09cSJung-uk Kim 1070a9d8d09cSJung-uk Kim static int 1071a9d8d09cSJung-uk Kim AslDoResponseFile ( 1072a9d8d09cSJung-uk Kim char *Filename) 1073a9d8d09cSJung-uk Kim { 10746f1f1a63SJung-uk Kim char *argv = AslGbl_StringBuffer2; 1075a9d8d09cSJung-uk Kim FILE *ResponseFile; 1076a9d8d09cSJung-uk Kim int OptStatus = 0; 1077a9d8d09cSJung-uk Kim int Opterr; 1078a9d8d09cSJung-uk Kim int Optind; 1079a9d8d09cSJung-uk Kim 1080a9d8d09cSJung-uk Kim 1081a9d8d09cSJung-uk Kim ResponseFile = fopen (Filename, "r"); 1082a9d8d09cSJung-uk Kim if (!ResponseFile) 1083a9d8d09cSJung-uk Kim { 1084a9d8d09cSJung-uk Kim printf ("Could not open command file %s, %s\n", 1085a9d8d09cSJung-uk Kim Filename, strerror (errno)); 1086a9d8d09cSJung-uk Kim return (-1); 1087a9d8d09cSJung-uk Kim } 1088a9d8d09cSJung-uk Kim 1089a9d8d09cSJung-uk Kim /* Must save the current GetOpt globals */ 1090a9d8d09cSJung-uk Kim 1091a9d8d09cSJung-uk Kim Opterr = AcpiGbl_Opterr; 1092a9d8d09cSJung-uk Kim Optind = AcpiGbl_Optind; 1093a9d8d09cSJung-uk Kim 1094a9d8d09cSJung-uk Kim /* 1095a9d8d09cSJung-uk Kim * Process all lines in the response file. There must be one complete 1096a9d8d09cSJung-uk Kim * option per line 1097a9d8d09cSJung-uk Kim */ 10986f1f1a63SJung-uk Kim while (fgets (AslGbl_StringBuffer, ASL_STRING_BUFFER_SIZE, ResponseFile)) 1099a9d8d09cSJung-uk Kim { 1100a9d8d09cSJung-uk Kim /* Compress all tokens, allowing us to use a single argv entry */ 1101a9d8d09cSJung-uk Kim 11026f1f1a63SJung-uk Kim AslMergeOptionTokens (AslGbl_StringBuffer, AslGbl_StringBuffer2); 1103a9d8d09cSJung-uk Kim 1104a9d8d09cSJung-uk Kim /* Process the option */ 1105a9d8d09cSJung-uk Kim 1106a9d8d09cSJung-uk Kim AcpiGbl_Opterr = 0; 1107a9d8d09cSJung-uk Kim AcpiGbl_Optind = 0; 1108a9d8d09cSJung-uk Kim 1109a9d8d09cSJung-uk Kim OptStatus = AslDoOptions (1, &argv, TRUE); 1110a9d8d09cSJung-uk Kim if (OptStatus) 1111a9d8d09cSJung-uk Kim { 1112a9d8d09cSJung-uk Kim printf ("Invalid option in command file %s: %s\n", 11136f1f1a63SJung-uk Kim Filename, AslGbl_StringBuffer); 1114a9d8d09cSJung-uk Kim break; 1115a9d8d09cSJung-uk Kim } 1116a9d8d09cSJung-uk Kim } 1117a9d8d09cSJung-uk Kim 1118a9d8d09cSJung-uk Kim /* Restore the GetOpt globals */ 1119a9d8d09cSJung-uk Kim 1120a9d8d09cSJung-uk Kim AcpiGbl_Opterr = Opterr; 1121a9d8d09cSJung-uk Kim AcpiGbl_Optind = Optind; 1122a9d8d09cSJung-uk Kim 1123a9d8d09cSJung-uk Kim fclose (ResponseFile); 1124a9d8d09cSJung-uk Kim return (OptStatus); 1125a9d8d09cSJung-uk Kim } 1126