153289f6aSNate Lawson /****************************************************************************** 253289f6aSNate Lawson * 353289f6aSNate Lawson * Module Name: aslmain - compiler main and utilities 453289f6aSNate Lawson * 553289f6aSNate Lawson *****************************************************************************/ 653289f6aSNate Lawson 7d244b227SJung-uk Kim /* 8ec3fc72fSJung-uk Kim * Copyright (C) 2000 - 2012, Intel Corp. 953289f6aSNate Lawson * All rights reserved. 1053289f6aSNate Lawson * 11d244b227SJung-uk Kim * Redistribution and use in source and binary forms, with or without 12d244b227SJung-uk Kim * modification, are permitted provided that the following conditions 13d244b227SJung-uk Kim * are met: 14d244b227SJung-uk Kim * 1. Redistributions of source code must retain the above copyright 15d244b227SJung-uk Kim * notice, this list of conditions, and the following disclaimer, 16d244b227SJung-uk Kim * without modification. 17d244b227SJung-uk Kim * 2. Redistributions in binary form must reproduce at minimum a disclaimer 18d244b227SJung-uk Kim * substantially similar to the "NO WARRANTY" disclaimer below 19d244b227SJung-uk Kim * ("Disclaimer") and any redistribution must be conditioned upon 20d244b227SJung-uk Kim * including a substantially similar Disclaimer requirement for further 21d244b227SJung-uk Kim * binary redistribution. 22d244b227SJung-uk Kim * 3. Neither the names of the above-listed copyright holders nor the names 23d244b227SJung-uk Kim * of any contributors may be used to endorse or promote products derived 24d244b227SJung-uk Kim * from this software without specific prior written permission. 2553289f6aSNate Lawson * 26d244b227SJung-uk Kim * Alternatively, this software may be distributed under the terms of the 27d244b227SJung-uk Kim * GNU General Public License ("GPL") version 2 as published by the Free 28d244b227SJung-uk Kim * Software Foundation. 2953289f6aSNate Lawson * 30d244b227SJung-uk Kim * NO WARRANTY 31d244b227SJung-uk Kim * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 32d244b227SJung-uk Kim * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 33d244b227SJung-uk Kim * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 34d244b227SJung-uk Kim * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 35d244b227SJung-uk Kim * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 36d244b227SJung-uk Kim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 37d244b227SJung-uk Kim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 38d244b227SJung-uk Kim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 39d244b227SJung-uk Kim * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 40d244b227SJung-uk Kim * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 41d244b227SJung-uk Kim * POSSIBILITY OF SUCH DAMAGES. 42d244b227SJung-uk Kim */ 4353289f6aSNate Lawson 4453289f6aSNate Lawson 4553289f6aSNate Lawson #define _DECLARE_GLOBALS 4653289f6aSNate Lawson 47ab6f3bf9SJung-uk Kim #include <contrib/dev/acpica/compiler/aslcompiler.h> 48ab6f3bf9SJung-uk Kim #include <contrib/dev/acpica/include/acapps.h> 49709fac06SJung-uk Kim #include <contrib/dev/acpica/include/acdisasm.h> 50042ff955SJung-uk Kim #include <signal.h> 5153289f6aSNate Lawson 5253289f6aSNate Lawson #ifdef _DEBUG 5353289f6aSNate Lawson #include <crtdbg.h> 5453289f6aSNate Lawson #endif 5553289f6aSNate Lawson 5653289f6aSNate Lawson #define _COMPONENT ACPI_COMPILER 5753289f6aSNate Lawson ACPI_MODULE_NAME ("aslmain") 5853289f6aSNate Lawson 59fba7fc7eSJung-uk Kim /* Local prototypes */ 60fba7fc7eSJung-uk Kim 61fba7fc7eSJung-uk Kim static void 62fba7fc7eSJung-uk Kim Options ( 63fba7fc7eSJung-uk Kim void); 64fba7fc7eSJung-uk Kim 65fba7fc7eSJung-uk Kim static void 66f38b0f21SJung-uk Kim FilenameHelp ( 67fba7fc7eSJung-uk Kim void); 68fba7fc7eSJung-uk Kim 69fba7fc7eSJung-uk Kim static void 70fba7fc7eSJung-uk Kim Usage ( 71fba7fc7eSJung-uk Kim void); 72fba7fc7eSJung-uk Kim 73042ff955SJung-uk Kim static void ACPI_SYSTEM_XFACE 74042ff955SJung-uk Kim AslSignalHandler ( 75042ff955SJung-uk Kim int Sig); 76042ff955SJung-uk Kim 77fba7fc7eSJung-uk Kim static void 78fba7fc7eSJung-uk Kim AslInitialize ( 79fba7fc7eSJung-uk Kim void); 80fba7fc7eSJung-uk Kim 81a9f12690SJung-uk Kim static int 82fba7fc7eSJung-uk Kim AslCommandLine ( 83fba7fc7eSJung-uk Kim int argc, 84fba7fc7eSJung-uk Kim char **argv); 85fba7fc7eSJung-uk Kim 86d6dd1baeSJung-uk Kim static int 87d6dd1baeSJung-uk Kim AslDoOptions ( 88d6dd1baeSJung-uk Kim int argc, 89d6dd1baeSJung-uk Kim char **argv, 90d6dd1baeSJung-uk Kim BOOLEAN IsResponseFile); 91d6dd1baeSJung-uk Kim 92d6dd1baeSJung-uk Kim static void 93d6dd1baeSJung-uk Kim AslMergeOptionTokens ( 94d6dd1baeSJung-uk Kim char *InBuffer, 95d6dd1baeSJung-uk Kim char *OutBuffer); 96d6dd1baeSJung-uk Kim 97d6dd1baeSJung-uk Kim static int 98d6dd1baeSJung-uk Kim AslDoResponseFile ( 99d6dd1baeSJung-uk Kim char *Filename); 100d6dd1baeSJung-uk Kim 101d6dd1baeSJung-uk Kim 102d6dd1baeSJung-uk Kim #define ASL_TOKEN_SEPARATORS " \t\n" 103042ff955SJung-uk Kim #define ASL_SUPPORTED_OPTIONS "@:2b|c|d^D:e:fgh^i|I:l^m:no|p:P^r:s|t|T:G^v^w|x:z" 104d6dd1baeSJung-uk Kim 10553289f6aSNate Lawson 10653289f6aSNate Lawson /******************************************************************************* 10753289f6aSNate Lawson * 10853289f6aSNate Lawson * FUNCTION: Options 10953289f6aSNate Lawson * 11053289f6aSNate Lawson * PARAMETERS: None 11153289f6aSNate Lawson * 11253289f6aSNate Lawson * RETURN: None 11353289f6aSNate Lawson * 11453289f6aSNate Lawson * DESCRIPTION: Display option help message 11553289f6aSNate Lawson * 11653289f6aSNate Lawson ******************************************************************************/ 11753289f6aSNate Lawson 118fba7fc7eSJung-uk Kim static void 11953289f6aSNate Lawson Options ( 12053289f6aSNate Lawson void) 12153289f6aSNate Lawson { 12253289f6aSNate Lawson 1233f0275a0SJung-uk Kim printf ("\nGlobal:\n"); 1243f0275a0SJung-uk Kim ACPI_OPTION ("-@ <file>", "Specify command file"); 1253f0275a0SJung-uk Kim ACPI_OPTION ("-I <dir>", "Specify additional include directory"); 126*8ef1a331SJung-uk Kim ACPI_OPTION ("-T <sig>|ALL|*", "Create table template file for ACPI <Sig>"); 127e8241eabSJung-uk Kim ACPI_OPTION ("-v", "Display compiler version"); 128d6dd1baeSJung-uk Kim 1294c52cad2SJung-uk Kim printf ("\nPreprocessor:\n"); 1304c52cad2SJung-uk Kim ACPI_OPTION ("-D <symbol>", "Define symbol for preprocessor use"); 1314c52cad2SJung-uk Kim ACPI_OPTION ("-li", "Create preprocessed output file (*.i)"); 1324c52cad2SJung-uk Kim ACPI_OPTION ("-P", "Preprocess only and create preprocessor output file (*.i)"); 133eef1b955SJung-uk Kim ACPI_OPTION ("-Pn", "Disable preprocessor"); 1344c52cad2SJung-uk Kim 135d6dd1baeSJung-uk Kim printf ("\nGeneral Output:\n"); 1363f0275a0SJung-uk Kim ACPI_OPTION ("-p <prefix>", "Specify path/filename prefix for all output files"); 1373f0275a0SJung-uk Kim ACPI_OPTION ("-va", "Disable all errors and warnings (summary only)"); 1383f0275a0SJung-uk Kim ACPI_OPTION ("-vi", "Less verbose errors and warnings for use with IDEs"); 1393f0275a0SJung-uk Kim ACPI_OPTION ("-vo", "Enable optimization comments"); 1403f0275a0SJung-uk Kim ACPI_OPTION ("-vr", "Disable remarks"); 1413f0275a0SJung-uk Kim ACPI_OPTION ("-vs", "Disable signon"); 1424c52cad2SJung-uk Kim ACPI_OPTION ("-w1 -w2 -w3", "Set warning reporting level"); 143eef1b955SJung-uk Kim ACPI_OPTION ("-we", "Report warnings as errors"); 14453289f6aSNate Lawson 145*8ef1a331SJung-uk Kim printf ("\nAML and Data Output Files:\n"); 146*8ef1a331SJung-uk Kim ACPI_OPTION ("-sa -sc", "Create assembler or C source file (*.asm or *.c)"); 1474c52cad2SJung-uk Kim ACPI_OPTION ("-ia -ic", "Create assembler or C include file (*.inc or *.h)"); 148*8ef1a331SJung-uk Kim ACPI_OPTION ("-ta -tc -ts", "Create assembler, C, or ASL hex table (*.hex)"); 14953289f6aSNate Lawson 150c8466860SMark Santcroos printf ("\nAML Code Generation:\n"); 1513f0275a0SJung-uk Kim ACPI_OPTION ("-oa", "Disable all optimizations (compatibility mode)"); 1523f0275a0SJung-uk Kim ACPI_OPTION ("-of", "Disable constant folding"); 1533f0275a0SJung-uk Kim ACPI_OPTION ("-oi", "Disable integer optimization to Zero/One/Ones"); 1543f0275a0SJung-uk Kim ACPI_OPTION ("-on", "Disable named reference string optimization"); 1553f0275a0SJung-uk Kim ACPI_OPTION ("-cr", "Disable Resource Descriptor error checking"); 1563f0275a0SJung-uk Kim ACPI_OPTION ("-r <revision>", "Override table header Revision (1-255)"); 15753289f6aSNate Lawson 15842fecd12SJung-uk Kim printf ("\nASL Listing Files:\n"); 1593f0275a0SJung-uk Kim ACPI_OPTION ("-l", "Create mixed listing file (ASL source and AML) (*.lst)"); 1603f0275a0SJung-uk Kim ACPI_OPTION ("-ln", "Create namespace file (*.nsp)"); 1613f0275a0SJung-uk Kim ACPI_OPTION ("-ls", "Create combined source file (expanded includes) (*.src)"); 16253289f6aSNate Lawson 163a88e22b7SJung-uk Kim printf ("\nACPI Data Tables:\n"); 1643f0275a0SJung-uk Kim ACPI_OPTION ("-G", "Compile custom table containing generic operators"); 1653f0275a0SJung-uk Kim ACPI_OPTION ("-vt", "Create verbose templates (full disassembly)"); 166a88e22b7SJung-uk Kim 16753289f6aSNate Lawson printf ("\nAML Disassembler:\n"); 1683f0275a0SJung-uk Kim ACPI_OPTION ("-d [file]", "Disassemble or decode binary ACPI table to file (*.dsl)"); 1693f0275a0SJung-uk Kim ACPI_OPTION ("-da [f1,f2]", "Disassemble multiple tables from single namespace"); 170042ff955SJung-uk Kim ACPI_OPTION ("-db", "Do not translate Buffers to Resource Templates"); 1713f0275a0SJung-uk Kim ACPI_OPTION ("-dc [file]", "Disassemble AML and immediately compile it"); 1723f0275a0SJung-uk Kim ACPI_OPTION ("", "(Obtain DSDT from current system if no input file)"); 1733f0275a0SJung-uk Kim ACPI_OPTION ("-e [f1,f2]", "Include ACPI table(s) for external symbol resolution"); 1743f0275a0SJung-uk Kim ACPI_OPTION ("-2", "Emit ACPI 2.0 compatible ASL code"); 1753f0275a0SJung-uk Kim ACPI_OPTION ("-g", "Get ACPI tables and write to files (*.dat)"); 176*8ef1a331SJung-uk Kim ACPI_OPTION ("-vt", "Dump binary table data in hex format within output file"); 17753289f6aSNate Lawson 17853289f6aSNate Lawson printf ("\nHelp:\n"); 179f38b0f21SJung-uk Kim ACPI_OPTION ("-h", "This message"); 1803f0275a0SJung-uk Kim ACPI_OPTION ("-hc", "Display operators allowed in constant expressions"); 181f38b0f21SJung-uk Kim ACPI_OPTION ("-hf", "Display help for output filename generation"); 1823f0275a0SJung-uk Kim ACPI_OPTION ("-hr", "Display ACPI reserved method names"); 1833f0275a0SJung-uk Kim ACPI_OPTION ("-ht", "Display currently supported ACPI table names"); 184f38b0f21SJung-uk Kim 185f38b0f21SJung-uk Kim printf ("\nDebug Options:\n"); 186f38b0f21SJung-uk Kim ACPI_OPTION ("-bf -bt", "Create debug file (full or parse tree only) (*.txt)"); 187f38b0f21SJung-uk Kim ACPI_OPTION ("-f", "Ignore errors, force creation of AML output file(s)"); 188f38b0f21SJung-uk Kim ACPI_OPTION ("-n", "Parse only, no output generation"); 189f38b0f21SJung-uk Kim ACPI_OPTION ("-ot", "Display compile times and statistics"); 190f38b0f21SJung-uk Kim ACPI_OPTION ("-x <level>", "Set debug level for trace output"); 191f38b0f21SJung-uk Kim ACPI_OPTION ("-z", "Do not insert new compiler ID for DataTables"); 19253289f6aSNate Lawson } 19353289f6aSNate Lawson 19453289f6aSNate Lawson 19553289f6aSNate Lawson /******************************************************************************* 19653289f6aSNate Lawson * 197f38b0f21SJung-uk Kim * FUNCTION: FilenameHelp 19853289f6aSNate Lawson * 19953289f6aSNate Lawson * PARAMETERS: None 20053289f6aSNate Lawson * 20153289f6aSNate Lawson * RETURN: None 20253289f6aSNate Lawson * 203f38b0f21SJung-uk Kim * DESCRIPTION: Display help message for output filename generation 20453289f6aSNate Lawson * 20553289f6aSNate Lawson ******************************************************************************/ 20653289f6aSNate Lawson 207fba7fc7eSJung-uk Kim static void 208f38b0f21SJung-uk Kim FilenameHelp ( 20953289f6aSNate Lawson void) 21053289f6aSNate Lawson { 21153289f6aSNate Lawson 2123f0275a0SJung-uk Kim printf ("\nAML output filename generation:\n"); 21353289f6aSNate Lawson printf (" Output filenames are generated by appending an extension to a common\n"); 21453289f6aSNate Lawson printf (" filename prefix. The filename prefix is obtained via one of the\n"); 21553289f6aSNate Lawson printf (" following methods (in priority order):\n"); 21653289f6aSNate Lawson printf (" 1) The -p option specifies the prefix\n"); 21753289f6aSNate Lawson printf (" 2) The prefix of the AMLFileName in the ASL Definition Block\n"); 21853289f6aSNate Lawson printf (" 3) The prefix of the input filename\n"); 21953289f6aSNate Lawson printf ("\n"); 22053289f6aSNate Lawson } 22153289f6aSNate Lawson 22253289f6aSNate Lawson 22353289f6aSNate Lawson /******************************************************************************* 22453289f6aSNate Lawson * 22553289f6aSNate Lawson * FUNCTION: Usage 22653289f6aSNate Lawson * 22753289f6aSNate Lawson * PARAMETERS: None 22853289f6aSNate Lawson * 22953289f6aSNate Lawson * RETURN: None 23053289f6aSNate Lawson * 23153289f6aSNate Lawson * DESCRIPTION: Display usage and option message 23253289f6aSNate Lawson * 23353289f6aSNate Lawson ******************************************************************************/ 23453289f6aSNate Lawson 235fba7fc7eSJung-uk Kim static void 23653289f6aSNate Lawson Usage ( 23753289f6aSNate Lawson void) 23853289f6aSNate Lawson { 23953289f6aSNate Lawson 2403f0275a0SJung-uk Kim printf ("%s\n\n", ASL_COMPLIANCE); 2413f0275a0SJung-uk Kim ACPI_USAGE_HEADER ("iasl [Options] [Files]"); 24253289f6aSNate Lawson Options (); 24353289f6aSNate Lawson } 24453289f6aSNate Lawson 24553289f6aSNate Lawson 246042ff955SJung-uk Kim /****************************************************************************** 247042ff955SJung-uk Kim * 248042ff955SJung-uk Kim * FUNCTION: AslSignalHandler 249042ff955SJung-uk Kim * 250042ff955SJung-uk Kim * PARAMETERS: Sig - Signal that invoked this handler 251042ff955SJung-uk Kim * 252042ff955SJung-uk Kim * RETURN: None 253042ff955SJung-uk Kim * 254042ff955SJung-uk Kim * DESCRIPTION: Control-C handler. Delete any intermediate files and any 255042ff955SJung-uk Kim * output files that may be left in an indeterminate state. 256042ff955SJung-uk Kim * 257042ff955SJung-uk Kim *****************************************************************************/ 258042ff955SJung-uk Kim 259042ff955SJung-uk Kim static void ACPI_SYSTEM_XFACE 260042ff955SJung-uk Kim AslSignalHandler ( 261042ff955SJung-uk Kim int Sig) 262042ff955SJung-uk Kim { 263042ff955SJung-uk Kim UINT32 i; 264042ff955SJung-uk Kim 265042ff955SJung-uk Kim 266042ff955SJung-uk Kim signal (Sig, SIG_IGN); 267042ff955SJung-uk Kim printf ("Aborting\n\n"); 268042ff955SJung-uk Kim 269042ff955SJung-uk Kim /* Close all open files */ 270042ff955SJung-uk Kim 271042ff955SJung-uk Kim Gbl_Files[ASL_FILE_PREPROCESSOR].Handle = NULL; /* the .i file is same as source file */ 272042ff955SJung-uk Kim 273042ff955SJung-uk Kim for (i = ASL_FILE_INPUT; i < ASL_MAX_FILE_TYPE; i++) 274042ff955SJung-uk Kim { 275042ff955SJung-uk Kim FlCloseFile (i); 276042ff955SJung-uk Kim } 277042ff955SJung-uk Kim 278042ff955SJung-uk Kim /* Delete any output files */ 279042ff955SJung-uk Kim 280042ff955SJung-uk Kim for (i = ASL_FILE_AML_OUTPUT; i < ASL_MAX_FILE_TYPE; i++) 281042ff955SJung-uk Kim { 282042ff955SJung-uk Kim FlDeleteFile (i); 283042ff955SJung-uk Kim } 284042ff955SJung-uk Kim 285042ff955SJung-uk Kim exit (0); 286042ff955SJung-uk Kim } 287042ff955SJung-uk Kim 288042ff955SJung-uk Kim 28953289f6aSNate Lawson /******************************************************************************* 29053289f6aSNate Lawson * 29153289f6aSNate Lawson * FUNCTION: AslInitialize 29253289f6aSNate Lawson * 29353289f6aSNate Lawson * PARAMETERS: None 29453289f6aSNate Lawson * 29553289f6aSNate Lawson * RETURN: None 29653289f6aSNate Lawson * 29753289f6aSNate Lawson * DESCRIPTION: Initialize compiler globals 29853289f6aSNate Lawson * 29953289f6aSNate Lawson ******************************************************************************/ 30053289f6aSNate Lawson 301fba7fc7eSJung-uk Kim static void 302fba7fc7eSJung-uk Kim AslInitialize ( 303fba7fc7eSJung-uk Kim void) 30453289f6aSNate Lawson { 30553289f6aSNate Lawson UINT32 i; 30653289f6aSNate Lawson 30753289f6aSNate Lawson 30853289f6aSNate Lawson #ifdef _DEBUG 30953289f6aSNate Lawson _CrtSetDbgFlag (_CRTDBG_CHECK_ALWAYS_DF | _CrtSetDbgFlag(0)); 31053289f6aSNate Lawson #endif 31153289f6aSNate Lawson 31253289f6aSNate Lawson 31353289f6aSNate Lawson for (i = 0; i < ASL_NUM_FILES; i++) 31453289f6aSNate Lawson { 31553289f6aSNate Lawson Gbl_Files[i].Handle = NULL; 31653289f6aSNate Lawson Gbl_Files[i].Filename = NULL; 31753289f6aSNate Lawson } 31853289f6aSNate Lawson 31953289f6aSNate Lawson Gbl_Files[ASL_FILE_STDOUT].Handle = stdout; 32053289f6aSNate Lawson Gbl_Files[ASL_FILE_STDOUT].Filename = "STDOUT"; 32153289f6aSNate Lawson 32253289f6aSNate Lawson Gbl_Files[ASL_FILE_STDERR].Handle = stderr; 32353289f6aSNate Lawson Gbl_Files[ASL_FILE_STDERR].Filename = "STDERR"; 324042ff955SJung-uk Kim 325042ff955SJung-uk Kim /* Allocate the line buffer(s) */ 326042ff955SJung-uk Kim 327042ff955SJung-uk Kim Gbl_LineBufferSize /= 2; 328042ff955SJung-uk Kim UtExpandLineBuffers (); 32953289f6aSNate Lawson } 33053289f6aSNate Lawson 33153289f6aSNate Lawson 33253289f6aSNate Lawson /******************************************************************************* 33353289f6aSNate Lawson * 334d6dd1baeSJung-uk Kim * FUNCTION: AslMergeOptionTokens 33553289f6aSNate Lawson * 336d6dd1baeSJung-uk Kim * PARAMETERS: InBuffer - Input containing an option string 337d6dd1baeSJung-uk Kim * OutBuffer - Merged output buffer 33853289f6aSNate Lawson * 33953289f6aSNate Lawson * RETURN: None 34053289f6aSNate Lawson * 341d6dd1baeSJung-uk Kim * DESCRIPTION: Remove all whitespace from an option string. 342d6dd1baeSJung-uk Kim * 343d6dd1baeSJung-uk Kim ******************************************************************************/ 344d6dd1baeSJung-uk Kim 345d6dd1baeSJung-uk Kim static void 346d6dd1baeSJung-uk Kim AslMergeOptionTokens ( 347d6dd1baeSJung-uk Kim char *InBuffer, 348d6dd1baeSJung-uk Kim char *OutBuffer) 349d6dd1baeSJung-uk Kim { 350d6dd1baeSJung-uk Kim char *Token; 351d6dd1baeSJung-uk Kim 352d6dd1baeSJung-uk Kim 353d6dd1baeSJung-uk Kim *OutBuffer = 0; 354d6dd1baeSJung-uk Kim 355d6dd1baeSJung-uk Kim Token = strtok (InBuffer, ASL_TOKEN_SEPARATORS); 356d6dd1baeSJung-uk Kim while (Token) 357d6dd1baeSJung-uk Kim { 358d6dd1baeSJung-uk Kim strcat (OutBuffer, Token); 359d6dd1baeSJung-uk Kim Token = strtok (NULL, ASL_TOKEN_SEPARATORS); 360d6dd1baeSJung-uk Kim } 361d6dd1baeSJung-uk Kim } 362d6dd1baeSJung-uk Kim 363d6dd1baeSJung-uk Kim 364d6dd1baeSJung-uk Kim /******************************************************************************* 365d6dd1baeSJung-uk Kim * 366d6dd1baeSJung-uk Kim * FUNCTION: AslDoResponseFile 367d6dd1baeSJung-uk Kim * 368d6dd1baeSJung-uk Kim * PARAMETERS: Filename - Name of the response file 369d6dd1baeSJung-uk Kim * 370d6dd1baeSJung-uk Kim * RETURN: Status 371d6dd1baeSJung-uk Kim * 372d6dd1baeSJung-uk Kim * DESCRIPTION: Open a response file and process all options within. 37353289f6aSNate Lawson * 37453289f6aSNate Lawson ******************************************************************************/ 37553289f6aSNate Lawson 376a9f12690SJung-uk Kim static int 377d6dd1baeSJung-uk Kim AslDoResponseFile ( 378d6dd1baeSJung-uk Kim char *Filename) 37953289f6aSNate Lawson { 380d6dd1baeSJung-uk Kim char *argv = StringBuffer2; 381d6dd1baeSJung-uk Kim FILE *ResponseFile; 382d6dd1baeSJung-uk Kim int OptStatus = 0; 383d6dd1baeSJung-uk Kim int Opterr; 384d6dd1baeSJung-uk Kim int Optind; 385d6dd1baeSJung-uk Kim 386d6dd1baeSJung-uk Kim 387d6dd1baeSJung-uk Kim ResponseFile = fopen (Filename, "r"); 388d6dd1baeSJung-uk Kim if (!ResponseFile) 389d6dd1baeSJung-uk Kim { 390d6dd1baeSJung-uk Kim printf ("Could not open command file %s, %s\n", 391d6dd1baeSJung-uk Kim Filename, strerror (errno)); 392*8ef1a331SJung-uk Kim return (-1); 393d6dd1baeSJung-uk Kim } 394d6dd1baeSJung-uk Kim 395d6dd1baeSJung-uk Kim /* Must save the current GetOpt globals */ 396d6dd1baeSJung-uk Kim 397d6dd1baeSJung-uk Kim Opterr = AcpiGbl_Opterr; 398d6dd1baeSJung-uk Kim Optind = AcpiGbl_Optind; 399d6dd1baeSJung-uk Kim 400d6dd1baeSJung-uk Kim /* 401d6dd1baeSJung-uk Kim * Process all lines in the response file. There must be one complete 402d6dd1baeSJung-uk Kim * option per line 403d6dd1baeSJung-uk Kim */ 404d6dd1baeSJung-uk Kim while (fgets (StringBuffer, ASL_MSG_BUFFER_SIZE, ResponseFile)) 405d6dd1baeSJung-uk Kim { 406d6dd1baeSJung-uk Kim /* Compress all tokens, allowing us to use a single argv entry */ 407d6dd1baeSJung-uk Kim 408d6dd1baeSJung-uk Kim AslMergeOptionTokens (StringBuffer, StringBuffer2); 409d6dd1baeSJung-uk Kim 410d6dd1baeSJung-uk Kim /* Process the option */ 411d6dd1baeSJung-uk Kim 412d6dd1baeSJung-uk Kim AcpiGbl_Opterr = 0; 413d6dd1baeSJung-uk Kim AcpiGbl_Optind = 0; 414d6dd1baeSJung-uk Kim 415d6dd1baeSJung-uk Kim OptStatus = AslDoOptions (1, &argv, TRUE); 416d6dd1baeSJung-uk Kim if (OptStatus) 417d6dd1baeSJung-uk Kim { 418d6dd1baeSJung-uk Kim printf ("Invalid option in command file %s: %s\n", 419d6dd1baeSJung-uk Kim Filename, StringBuffer); 420d6dd1baeSJung-uk Kim break; 421d6dd1baeSJung-uk Kim } 422d6dd1baeSJung-uk Kim } 423d6dd1baeSJung-uk Kim 424d6dd1baeSJung-uk Kim /* Restore the GetOpt globals */ 425d6dd1baeSJung-uk Kim 426d6dd1baeSJung-uk Kim AcpiGbl_Opterr = Opterr; 427d6dd1baeSJung-uk Kim AcpiGbl_Optind = Optind; 428d6dd1baeSJung-uk Kim 429d6dd1baeSJung-uk Kim fclose (ResponseFile); 430d6dd1baeSJung-uk Kim return (OptStatus); 431d6dd1baeSJung-uk Kim } 432d6dd1baeSJung-uk Kim 433d6dd1baeSJung-uk Kim 434d6dd1baeSJung-uk Kim /******************************************************************************* 435d6dd1baeSJung-uk Kim * 436d6dd1baeSJung-uk Kim * FUNCTION: AslDoOptions 437d6dd1baeSJung-uk Kim * 438d6dd1baeSJung-uk Kim * PARAMETERS: argc/argv - Standard argc/argv 439d6dd1baeSJung-uk Kim * IsResponseFile - TRUE if executing a response file. 440d6dd1baeSJung-uk Kim * 441d6dd1baeSJung-uk Kim * RETURN: Status 442d6dd1baeSJung-uk Kim * 443d6dd1baeSJung-uk Kim * DESCRIPTION: Command line option processing 444d6dd1baeSJung-uk Kim * 445d6dd1baeSJung-uk Kim ******************************************************************************/ 446d6dd1baeSJung-uk Kim 447d6dd1baeSJung-uk Kim static int 448d6dd1baeSJung-uk Kim AslDoOptions ( 449d6dd1baeSJung-uk Kim int argc, 450d6dd1baeSJung-uk Kim char **argv, 451d6dd1baeSJung-uk Kim BOOLEAN IsResponseFile) 452d6dd1baeSJung-uk Kim { 453a9f12690SJung-uk Kim int j; 45442fecd12SJung-uk Kim ACPI_STATUS Status; 45553289f6aSNate Lawson 45653289f6aSNate Lawson 45753289f6aSNate Lawson /* Get the command line options */ 45853289f6aSNate Lawson 459d6dd1baeSJung-uk Kim while ((j = AcpiGetopt (argc, argv, ASL_SUPPORTED_OPTIONS)) != EOF) switch (j) 46053289f6aSNate Lawson { 461d6dd1baeSJung-uk Kim case '@': /* Begin a response file */ 462d6dd1baeSJung-uk Kim 463d6dd1baeSJung-uk Kim if (IsResponseFile) 464d6dd1baeSJung-uk Kim { 465d6dd1baeSJung-uk Kim printf ("Nested command files are not supported\n"); 4664c52cad2SJung-uk Kim return (-1); 467d6dd1baeSJung-uk Kim } 468d6dd1baeSJung-uk Kim 469d6dd1baeSJung-uk Kim if (AslDoResponseFile (AcpiGbl_Optarg)) 470d6dd1baeSJung-uk Kim { 4714c52cad2SJung-uk Kim return (-1); 472d6dd1baeSJung-uk Kim } 473d6dd1baeSJung-uk Kim break; 474d6dd1baeSJung-uk Kim 475d6dd1baeSJung-uk Kim 4764c52cad2SJung-uk Kim case '2': /* ACPI 2.0 compatibility mode */ 477fba7fc7eSJung-uk Kim Gbl_Acpi2 = TRUE; 478fba7fc7eSJung-uk Kim break; 479fba7fc7eSJung-uk Kim 480fba7fc7eSJung-uk Kim 4814c52cad2SJung-uk Kim case 'b': /* Debug output options */ 48253289f6aSNate Lawson switch (AcpiGbl_Optarg[0]) 48353289f6aSNate Lawson { 484f38b0f21SJung-uk Kim case 'f': 48553289f6aSNate Lawson AslCompilerdebug = 1; /* same as yydebug */ 486d052a1ccSJung-uk Kim DtParserdebug = 1; 4874c52cad2SJung-uk Kim PrParserdebug = 1; 48853289f6aSNate Lawson break; 48953289f6aSNate Lawson 49053289f6aSNate Lawson case 't': 49153289f6aSNate Lawson break; 49253289f6aSNate Lawson 49353289f6aSNate Lawson default: 49453289f6aSNate Lawson printf ("Unknown option: -b%s\n", AcpiGbl_Optarg); 495d6dd1baeSJung-uk Kim return (-1); 49653289f6aSNate Lawson } 49753289f6aSNate Lawson 49853289f6aSNate Lawson /* Produce debug output file */ 49953289f6aSNate Lawson 50053289f6aSNate Lawson Gbl_DebugFlag = TRUE; 50153289f6aSNate Lawson break; 50253289f6aSNate Lawson 50353289f6aSNate Lawson 50453289f6aSNate Lawson case 'c': 5053f5e024cSJung-uk Kim switch (AcpiGbl_Optarg[0]) 5063f5e024cSJung-uk Kim { 5073f5e024cSJung-uk Kim case 'r': 5083f5e024cSJung-uk Kim Gbl_NoResourceChecking = TRUE; 5093f5e024cSJung-uk Kim break; 51053289f6aSNate Lawson 5113f5e024cSJung-uk Kim default: 5123f5e024cSJung-uk Kim printf ("Unknown option: -c%s\n", AcpiGbl_Optarg); 5133f5e024cSJung-uk Kim return (-1); 5143f5e024cSJung-uk Kim } 51553289f6aSNate Lawson break; 51653289f6aSNate Lawson 51753289f6aSNate Lawson 5184c52cad2SJung-uk Kim case 'd': /* Disassembler */ 51953289f6aSNate Lawson switch (AcpiGbl_Optarg[0]) 52053289f6aSNate Lawson { 52153289f6aSNate Lawson case '^': 522a9f12690SJung-uk Kim Gbl_DoCompile = FALSE; 52353289f6aSNate Lawson break; 52453289f6aSNate Lawson 525709fac06SJung-uk Kim case 'a': 526709fac06SJung-uk Kim Gbl_DoCompile = FALSE; 527709fac06SJung-uk Kim Gbl_DisassembleAll = TRUE; 528709fac06SJung-uk Kim break; 529709fac06SJung-uk Kim 530042ff955SJung-uk Kim case 'b': /* Do not convert buffers to resource descriptors */ 531042ff955SJung-uk Kim AcpiGbl_NoResourceDisassembly = TRUE; 532042ff955SJung-uk Kim break; 533042ff955SJung-uk Kim 53453289f6aSNate Lawson case 'c': 53553289f6aSNate Lawson break; 53653289f6aSNate Lawson 53753289f6aSNate Lawson default: 53853289f6aSNate Lawson printf ("Unknown option: -d%s\n", AcpiGbl_Optarg); 539d6dd1baeSJung-uk Kim return (-1); 54053289f6aSNate Lawson } 54153289f6aSNate Lawson 54253289f6aSNate Lawson Gbl_DisasmFlag = TRUE; 54353289f6aSNate Lawson break; 54453289f6aSNate Lawson 54553289f6aSNate Lawson 5464c52cad2SJung-uk Kim case 'D': /* Define a symbol */ 5474c52cad2SJung-uk Kim PrAddDefine (AcpiGbl_Optarg, NULL, TRUE); 5484c52cad2SJung-uk Kim break; 5494c52cad2SJung-uk Kim 5504c52cad2SJung-uk Kim 5514c52cad2SJung-uk Kim case 'e': /* External files for disassembler */ 55242fecd12SJung-uk Kim Status = AcpiDmAddToExternalFileList (AcpiGbl_Optarg); 55342fecd12SJung-uk Kim if (ACPI_FAILURE (Status)) 55442fecd12SJung-uk Kim { 55542fecd12SJung-uk Kim printf ("Could not add %s to external list\n", AcpiGbl_Optarg); 55642fecd12SJung-uk Kim return (-1); 55742fecd12SJung-uk Kim } 55853289f6aSNate Lawson break; 55953289f6aSNate Lawson 56053289f6aSNate Lawson 5614c52cad2SJung-uk Kim case 'f': /* Ignore errors and force creation of aml file */ 56253289f6aSNate Lawson Gbl_IgnoreErrors = TRUE; 56353289f6aSNate Lawson break; 56453289f6aSNate Lawson 56553289f6aSNate Lawson 5664c52cad2SJung-uk Kim case 'G': 5674c52cad2SJung-uk Kim Gbl_CompileGeneric = TRUE; 5684c52cad2SJung-uk Kim break; 56953289f6aSNate Lawson 5704c52cad2SJung-uk Kim 5714c52cad2SJung-uk Kim case 'g': /* Get all ACPI tables */ 57253289f6aSNate Lawson 57353289f6aSNate Lawson Gbl_GetAllTables = TRUE; 574a9f12690SJung-uk Kim Gbl_DoCompile = FALSE; 57553289f6aSNate Lawson break; 57653289f6aSNate Lawson 57753289f6aSNate Lawson 57853289f6aSNate Lawson case 'h': 57953289f6aSNate Lawson switch (AcpiGbl_Optarg[0]) 58053289f6aSNate Lawson { 58153289f6aSNate Lawson case '^': 582f38b0f21SJung-uk Kim Usage (); 58353289f6aSNate Lawson exit (0); 58453289f6aSNate Lawson 58553289f6aSNate Lawson case 'c': 58653289f6aSNate Lawson UtDisplayConstantOpcodes (); 58753289f6aSNate Lawson exit (0); 58853289f6aSNate Lawson 589f38b0f21SJung-uk Kim case 'f': 590f38b0f21SJung-uk Kim FilenameHelp (); 591f38b0f21SJung-uk Kim exit (0); 592f38b0f21SJung-uk Kim 59353289f6aSNate Lawson case 'r': 59453289f6aSNate Lawson /* reserved names */ 59553289f6aSNate Lawson 596ca3cf4faSJung-uk Kim ApDisplayReservedNames (); 59753289f6aSNate Lawson exit (0); 59853289f6aSNate Lawson 599a88e22b7SJung-uk Kim case 't': 600a88e22b7SJung-uk Kim UtDisplaySupportedTables (); 601a88e22b7SJung-uk Kim exit (0); 602a88e22b7SJung-uk Kim 60353289f6aSNate Lawson default: 60453289f6aSNate Lawson printf ("Unknown option: -h%s\n", AcpiGbl_Optarg); 605d6dd1baeSJung-uk Kim return (-1); 60653289f6aSNate Lawson } 60753289f6aSNate Lawson 60853289f6aSNate Lawson 609d6dd1baeSJung-uk Kim case 'I': /* Add an include file search directory */ 610d6dd1baeSJung-uk Kim FlAddIncludeDirectory (AcpiGbl_Optarg); 611d6dd1baeSJung-uk Kim break; 612d6dd1baeSJung-uk Kim 613d6dd1baeSJung-uk Kim 6144c52cad2SJung-uk Kim case 'i': /* Output AML as an include file */ 61553289f6aSNate Lawson switch (AcpiGbl_Optarg[0]) 61653289f6aSNate Lawson { 61753289f6aSNate Lawson case 'a': 61853289f6aSNate Lawson 61953289f6aSNate Lawson /* Produce assembly code include file */ 62053289f6aSNate Lawson 62153289f6aSNate Lawson Gbl_AsmIncludeOutputFlag = TRUE; 62253289f6aSNate Lawson break; 62353289f6aSNate Lawson 62453289f6aSNate Lawson case 'c': 62553289f6aSNate Lawson 62653289f6aSNate Lawson /* Produce C include file */ 62753289f6aSNate Lawson 62853289f6aSNate Lawson Gbl_C_IncludeOutputFlag = TRUE; 62953289f6aSNate Lawson break; 63053289f6aSNate Lawson 63153289f6aSNate Lawson default: 6324c52cad2SJung-uk Kim printf ("Unknown option: -i%s\n", AcpiGbl_Optarg); 633d6dd1baeSJung-uk Kim return (-1); 63453289f6aSNate Lawson } 63553289f6aSNate Lawson break; 63653289f6aSNate Lawson 63753289f6aSNate Lawson 6384c52cad2SJung-uk Kim case 'l': /* Listing files */ 63953289f6aSNate Lawson switch (AcpiGbl_Optarg[0]) 64053289f6aSNate Lawson { 64153289f6aSNate Lawson case '^': 64253289f6aSNate Lawson /* Produce listing file (Mixed source/aml) */ 64353289f6aSNate Lawson 64453289f6aSNate Lawson Gbl_ListingFlag = TRUE; 64553289f6aSNate Lawson break; 64653289f6aSNate Lawson 6474c52cad2SJung-uk Kim case 'i': 6484c52cad2SJung-uk Kim /* Produce preprocessor output file */ 6494c52cad2SJung-uk Kim 6504c52cad2SJung-uk Kim Gbl_PreprocessorOutputFlag = TRUE; 6514c52cad2SJung-uk Kim break; 6524c52cad2SJung-uk Kim 65353289f6aSNate Lawson case 'n': 65453289f6aSNate Lawson /* Produce namespace file */ 65553289f6aSNate Lawson 65653289f6aSNate Lawson Gbl_NsOutputFlag = TRUE; 65753289f6aSNate Lawson break; 65853289f6aSNate Lawson 65953289f6aSNate Lawson case 's': 66053289f6aSNate Lawson /* Produce combined source file */ 66153289f6aSNate Lawson 66253289f6aSNate Lawson Gbl_SourceOutputFlag = TRUE; 66353289f6aSNate Lawson break; 66453289f6aSNate Lawson 66553289f6aSNate Lawson default: 66653289f6aSNate Lawson printf ("Unknown option: -l%s\n", AcpiGbl_Optarg); 667d6dd1baeSJung-uk Kim return (-1); 66853289f6aSNate Lawson } 66953289f6aSNate Lawson break; 67053289f6aSNate Lawson 67153289f6aSNate Lawson 672042ff955SJung-uk Kim case 'm': /* Set line buffer size */ 673042ff955SJung-uk Kim Gbl_LineBufferSize = (UINT32) strtoul (AcpiGbl_Optarg, NULL, 0) * 1024; 674042ff955SJung-uk Kim if (Gbl_LineBufferSize < ASL_DEFAULT_LINE_BUFFER_SIZE) 675042ff955SJung-uk Kim { 676042ff955SJung-uk Kim Gbl_LineBufferSize = ASL_DEFAULT_LINE_BUFFER_SIZE; 677042ff955SJung-uk Kim } 678042ff955SJung-uk Kim printf ("Line Buffer Size: %u\n", Gbl_LineBufferSize); 6793f0275a0SJung-uk Kim break; 6803f0275a0SJung-uk Kim 6813f0275a0SJung-uk Kim 6824c52cad2SJung-uk Kim case 'n': /* Parse only */ 6833f0275a0SJung-uk Kim Gbl_ParseOnlyFlag = TRUE; 6843f0275a0SJung-uk Kim break; 6853f0275a0SJung-uk Kim 6863f0275a0SJung-uk Kim 6874c52cad2SJung-uk Kim case 'o': /* Control compiler AML optimizations */ 68853289f6aSNate Lawson switch (AcpiGbl_Optarg[0]) 68953289f6aSNate Lawson { 69053289f6aSNate Lawson case 'a': 69153289f6aSNate Lawson 69253289f6aSNate Lawson /* Disable all optimizations */ 69353289f6aSNate Lawson 69453289f6aSNate Lawson Gbl_FoldConstants = FALSE; 69553289f6aSNate Lawson Gbl_IntegerOptimizationFlag = FALSE; 69653289f6aSNate Lawson Gbl_ReferenceOptimizationFlag = FALSE; 69753289f6aSNate Lawson break; 69853289f6aSNate Lawson 69953289f6aSNate Lawson case 'f': 70053289f6aSNate Lawson 70153289f6aSNate Lawson /* Disable folding on "normal" expressions */ 70253289f6aSNate Lawson 70353289f6aSNate Lawson Gbl_FoldConstants = FALSE; 70453289f6aSNate Lawson break; 70553289f6aSNate Lawson 70653289f6aSNate Lawson case 'i': 70753289f6aSNate Lawson 70853289f6aSNate Lawson /* Disable integer optimization to constants */ 70953289f6aSNate Lawson 71053289f6aSNate Lawson Gbl_IntegerOptimizationFlag = FALSE; 71153289f6aSNate Lawson break; 71253289f6aSNate Lawson 71353289f6aSNate Lawson case 'n': 71453289f6aSNate Lawson 71553289f6aSNate Lawson /* Disable named reference optimization */ 71653289f6aSNate Lawson 71753289f6aSNate Lawson Gbl_ReferenceOptimizationFlag = FALSE; 71853289f6aSNate Lawson break; 71953289f6aSNate Lawson 72053289f6aSNate Lawson case 't': 72153289f6aSNate Lawson 72253289f6aSNate Lawson /* Display compile time(s) */ 72353289f6aSNate Lawson 72453289f6aSNate Lawson Gbl_CompileTimesFlag = TRUE; 72553289f6aSNate Lawson break; 72653289f6aSNate Lawson 72753289f6aSNate Lawson default: 72853289f6aSNate Lawson printf ("Unknown option: -c%s\n", AcpiGbl_Optarg); 729d6dd1baeSJung-uk Kim return (-1); 73053289f6aSNate Lawson } 73153289f6aSNate Lawson break; 73253289f6aSNate Lawson 73353289f6aSNate Lawson 734eef1b955SJung-uk Kim case 'P': /* Preprocessor options */ 735eef1b955SJung-uk Kim switch (AcpiGbl_Optarg[0]) 736eef1b955SJung-uk Kim { 737eef1b955SJung-uk Kim case '^': /* Proprocess only, emit (.i) file */ 7384c52cad2SJung-uk Kim Gbl_PreprocessOnly = TRUE; 7394c52cad2SJung-uk Kim Gbl_PreprocessorOutputFlag = TRUE; 7404c52cad2SJung-uk Kim break; 74153289f6aSNate Lawson 742eef1b955SJung-uk Kim case 'n': /* Disable preprocessor */ 743eef1b955SJung-uk Kim Gbl_PreprocessFlag = FALSE; 744eef1b955SJung-uk Kim break; 745eef1b955SJung-uk Kim 746eef1b955SJung-uk Kim default: 747eef1b955SJung-uk Kim printf ("Unknown option: -P%s\n", AcpiGbl_Optarg); 748eef1b955SJung-uk Kim return (-1); 749eef1b955SJung-uk Kim } 750eef1b955SJung-uk Kim break; 751eef1b955SJung-uk Kim 75253289f6aSNate Lawson 7534c52cad2SJung-uk Kim case 'p': /* Override default AML output filename */ 75453289f6aSNate Lawson Gbl_OutputFilenamePrefix = AcpiGbl_Optarg; 75553289f6aSNate Lawson Gbl_UseDefaultAmlFilename = FALSE; 75653289f6aSNate Lawson break; 75753289f6aSNate Lawson 75853289f6aSNate Lawson 7594c52cad2SJung-uk Kim case 'r': /* Override revision found in table header */ 760c8466860SMark Santcroos Gbl_RevisionOverride = (UINT8) strtoul (AcpiGbl_Optarg, NULL, 0); 76153289f6aSNate Lawson break; 76253289f6aSNate Lawson 76353289f6aSNate Lawson 7644c52cad2SJung-uk Kim case 's': /* Create AML in a source code file */ 76553289f6aSNate Lawson switch (AcpiGbl_Optarg[0]) 76653289f6aSNate Lawson { 76753289f6aSNate Lawson case 'a': 76853289f6aSNate Lawson 76953289f6aSNate Lawson /* Produce assembly code output file */ 77053289f6aSNate Lawson 77153289f6aSNate Lawson Gbl_AsmOutputFlag = TRUE; 77253289f6aSNate Lawson break; 77353289f6aSNate Lawson 77453289f6aSNate Lawson case 'c': 77553289f6aSNate Lawson 77653289f6aSNate Lawson /* Produce C hex output file */ 77753289f6aSNate Lawson 77853289f6aSNate Lawson Gbl_C_OutputFlag = TRUE; 77953289f6aSNate Lawson break; 78053289f6aSNate Lawson 78153289f6aSNate Lawson default: 78253289f6aSNate Lawson printf ("Unknown option: -s%s\n", AcpiGbl_Optarg); 783d6dd1baeSJung-uk Kim return (-1); 78453289f6aSNate Lawson } 78553289f6aSNate Lawson break; 78653289f6aSNate Lawson 78753289f6aSNate Lawson 7884c52cad2SJung-uk Kim case 't': /* Produce hex table output file */ 78953289f6aSNate Lawson switch (AcpiGbl_Optarg[0]) 79053289f6aSNate Lawson { 79153289f6aSNate Lawson case 'a': 79253289f6aSNate Lawson Gbl_HexOutputFlag = HEX_OUTPUT_ASM; 79353289f6aSNate Lawson break; 79453289f6aSNate Lawson 79553289f6aSNate Lawson case 'c': 79653289f6aSNate Lawson Gbl_HexOutputFlag = HEX_OUTPUT_C; 79753289f6aSNate Lawson break; 79853289f6aSNate Lawson 7993f5e024cSJung-uk Kim case 's': 8003f5e024cSJung-uk Kim Gbl_HexOutputFlag = HEX_OUTPUT_ASL; 8013f5e024cSJung-uk Kim break; 8023f5e024cSJung-uk Kim 80353289f6aSNate Lawson default: 80453289f6aSNate Lawson printf ("Unknown option: -t%s\n", AcpiGbl_Optarg); 805d6dd1baeSJung-uk Kim return (-1); 80653289f6aSNate Lawson } 80753289f6aSNate Lawson break; 80853289f6aSNate Lawson 80953289f6aSNate Lawson 8104c52cad2SJung-uk Kim case 'T': /* Create a ACPI table template file */ 811a88e22b7SJung-uk Kim Gbl_DoTemplates = TRUE; 812a88e22b7SJung-uk Kim Gbl_TemplateSignature = AcpiGbl_Optarg; 813a88e22b7SJung-uk Kim break; 814a88e22b7SJung-uk Kim 815a88e22b7SJung-uk Kim 816e8241eabSJung-uk Kim case 'v': /* Version and verbosity settings */ 81753289f6aSNate Lawson switch (AcpiGbl_Optarg[0]) 81853289f6aSNate Lawson { 819e8241eabSJung-uk Kim case '^': 820e8241eabSJung-uk Kim printf (ACPI_COMMON_SIGNON (ASL_COMPILER_NAME)); 821e8241eabSJung-uk Kim exit (0); 822e8241eabSJung-uk Kim 823a9f12690SJung-uk Kim case 'a': 824a9f12690SJung-uk Kim /* Disable All error/warning messages */ 825a9f12690SJung-uk Kim 826a9f12690SJung-uk Kim Gbl_NoErrors = TRUE; 827a9f12690SJung-uk Kim break; 828a9f12690SJung-uk Kim 82953289f6aSNate Lawson case 'i': 830a7a3b383SJung-uk Kim /* 831a7a3b383SJung-uk Kim * Support for integrated development environment(s). 832a7a3b383SJung-uk Kim * 833a7a3b383SJung-uk Kim * 1) No compiler signon 834a7a3b383SJung-uk Kim * 2) Send stderr messages to stdout 835a7a3b383SJung-uk Kim * 3) Less verbose error messages (single line only for each) 836a7a3b383SJung-uk Kim * 4) Error/warning messages are formatted appropriately to 837a7a3b383SJung-uk Kim * be recognized by MS Visual Studio 838a7a3b383SJung-uk Kim */ 83953289f6aSNate Lawson Gbl_VerboseErrors = FALSE; 840a7a3b383SJung-uk Kim Gbl_DoSignon = FALSE; 841a7a3b383SJung-uk Kim Gbl_Files[ASL_FILE_STDERR].Handle = stdout; 84253289f6aSNate Lawson break; 84353289f6aSNate Lawson 84453289f6aSNate Lawson case 'o': 84553289f6aSNate Lawson Gbl_DisplayOptimizations = TRUE; 84653289f6aSNate Lawson break; 84753289f6aSNate Lawson 84853289f6aSNate Lawson case 'r': 84953289f6aSNate Lawson Gbl_DisplayRemarks = FALSE; 85053289f6aSNate Lawson break; 85153289f6aSNate Lawson 85253289f6aSNate Lawson case 's': 853a9f12690SJung-uk Kim Gbl_DoSignon = FALSE; 85453289f6aSNate Lawson break; 85553289f6aSNate Lawson 856a88e22b7SJung-uk Kim case 't': 857a88e22b7SJung-uk Kim Gbl_VerboseTemplates = TRUE; 858a88e22b7SJung-uk Kim break; 859a88e22b7SJung-uk Kim 86053289f6aSNate Lawson default: 86153289f6aSNate Lawson printf ("Unknown option: -v%s\n", AcpiGbl_Optarg); 862d6dd1baeSJung-uk Kim return (-1); 86353289f6aSNate Lawson } 86453289f6aSNate Lawson break; 86553289f6aSNate Lawson 86653289f6aSNate Lawson 8671a39cfb0SJung-uk Kim case 'w': /* Set warning levels */ 8681a39cfb0SJung-uk Kim switch (AcpiGbl_Optarg[0]) 8691a39cfb0SJung-uk Kim { 8701a39cfb0SJung-uk Kim case '1': 8711a39cfb0SJung-uk Kim Gbl_WarningLevel = ASL_WARNING; 8721a39cfb0SJung-uk Kim break; 8731a39cfb0SJung-uk Kim 8741a39cfb0SJung-uk Kim case '2': 8751a39cfb0SJung-uk Kim Gbl_WarningLevel = ASL_WARNING2; 8761a39cfb0SJung-uk Kim break; 8771a39cfb0SJung-uk Kim 8781a39cfb0SJung-uk Kim case '3': 8791a39cfb0SJung-uk Kim Gbl_WarningLevel = ASL_WARNING3; 8801a39cfb0SJung-uk Kim break; 8811a39cfb0SJung-uk Kim 882eef1b955SJung-uk Kim case 'e': 883eef1b955SJung-uk Kim Gbl_WarningsAsErrors = TRUE; 884eef1b955SJung-uk Kim break; 885eef1b955SJung-uk Kim 8861a39cfb0SJung-uk Kim default: 8871a39cfb0SJung-uk Kim printf ("Unknown option: -w%s\n", AcpiGbl_Optarg); 888d6dd1baeSJung-uk Kim return (-1); 8891a39cfb0SJung-uk Kim } 8901a39cfb0SJung-uk Kim break; 8911a39cfb0SJung-uk Kim 8921a39cfb0SJung-uk Kim 8934c52cad2SJung-uk Kim case 'x': /* Set debug print output level */ 89453289f6aSNate Lawson AcpiDbgLevel = strtoul (AcpiGbl_Optarg, NULL, 16); 89553289f6aSNate Lawson break; 89653289f6aSNate Lawson 89753289f6aSNate Lawson 898a88e22b7SJung-uk Kim case 'z': 899a88e22b7SJung-uk Kim Gbl_UseOriginalCompilerId = TRUE; 900a88e22b7SJung-uk Kim break; 901a88e22b7SJung-uk Kim 902a88e22b7SJung-uk Kim 90353289f6aSNate Lawson default: 904d6dd1baeSJung-uk Kim return (-1); 90553289f6aSNate Lawson } 90653289f6aSNate Lawson 907d6dd1baeSJung-uk Kim return (0); 908d6dd1baeSJung-uk Kim } 909d6dd1baeSJung-uk Kim 910d6dd1baeSJung-uk Kim 911d6dd1baeSJung-uk Kim /******************************************************************************* 912d6dd1baeSJung-uk Kim * 913d6dd1baeSJung-uk Kim * FUNCTION: AslCommandLine 914d6dd1baeSJung-uk Kim * 915d6dd1baeSJung-uk Kim * PARAMETERS: argc/argv 916d6dd1baeSJung-uk Kim * 917d6dd1baeSJung-uk Kim * RETURN: Last argv index 918d6dd1baeSJung-uk Kim * 919d6dd1baeSJung-uk Kim * DESCRIPTION: Command line processing 920d6dd1baeSJung-uk Kim * 921d6dd1baeSJung-uk Kim ******************************************************************************/ 922d6dd1baeSJung-uk Kim 923d6dd1baeSJung-uk Kim static int 924d6dd1baeSJung-uk Kim AslCommandLine ( 925d6dd1baeSJung-uk Kim int argc, 926d6dd1baeSJung-uk Kim char **argv) 927d6dd1baeSJung-uk Kim { 928d6dd1baeSJung-uk Kim int BadCommandLine = 0; 92942fecd12SJung-uk Kim ACPI_STATUS Status; 930d6dd1baeSJung-uk Kim 931d6dd1baeSJung-uk Kim 932d6dd1baeSJung-uk Kim /* Minimum command line contains at least the command and an input file */ 933d6dd1baeSJung-uk Kim 934d6dd1baeSJung-uk Kim if (argc < 2) 935d6dd1baeSJung-uk Kim { 9363c1812acSJung-uk Kim printf (ACPI_COMMON_SIGNON (ASL_COMPILER_NAME)); 937d6dd1baeSJung-uk Kim Usage (); 938d6dd1baeSJung-uk Kim exit (1); 939d6dd1baeSJung-uk Kim } 940d6dd1baeSJung-uk Kim 941d6dd1baeSJung-uk Kim /* Process all command line options */ 942d6dd1baeSJung-uk Kim 943d6dd1baeSJung-uk Kim BadCommandLine = AslDoOptions (argc, argv, FALSE); 944d6dd1baeSJung-uk Kim 945a88e22b7SJung-uk Kim if (Gbl_DoTemplates) 946a88e22b7SJung-uk Kim { 94742fecd12SJung-uk Kim Status = DtCreateTemplates (Gbl_TemplateSignature); 94842fecd12SJung-uk Kim if (ACPI_FAILURE (Status)) 94942fecd12SJung-uk Kim { 95042fecd12SJung-uk Kim exit (-1); 95142fecd12SJung-uk Kim } 952a88e22b7SJung-uk Kim exit (1); 953a88e22b7SJung-uk Kim } 954a88e22b7SJung-uk Kim 95553289f6aSNate Lawson /* Next parameter must be the input filename */ 95653289f6aSNate Lawson 957a9f12690SJung-uk Kim if (!argv[AcpiGbl_Optind] && 958fba7fc7eSJung-uk Kim !Gbl_DisasmFlag && 959fba7fc7eSJung-uk Kim !Gbl_GetAllTables) 96053289f6aSNate Lawson { 96153289f6aSNate Lawson printf ("Missing input filename\n"); 96253289f6aSNate Lawson BadCommandLine = TRUE; 96353289f6aSNate Lawson } 96453289f6aSNate Lawson 965a9f12690SJung-uk Kim if (Gbl_DoSignon) 96653289f6aSNate Lawson { 9673c1812acSJung-uk Kim printf (ACPI_COMMON_SIGNON (ASL_COMPILER_NAME)); 968ec3fc72fSJung-uk Kim if (Gbl_IgnoreErrors) 969ec3fc72fSJung-uk Kim { 970ec3fc72fSJung-uk Kim printf ("Ignoring all errors, forcing AML file generation\n\n"); 971ec3fc72fSJung-uk Kim } 97253289f6aSNate Lawson } 97353289f6aSNate Lawson 97453289f6aSNate Lawson /* Abort if anything went wrong on the command line */ 97553289f6aSNate Lawson 97653289f6aSNate Lawson if (BadCommandLine) 97753289f6aSNate Lawson { 97853289f6aSNate Lawson printf ("\n"); 97953289f6aSNate Lawson Usage (); 98053289f6aSNate Lawson exit (1); 98153289f6aSNate Lawson } 98253289f6aSNate Lawson 983a9f12690SJung-uk Kim return (AcpiGbl_Optind); 98453289f6aSNate Lawson } 98553289f6aSNate Lawson 98653289f6aSNate Lawson 98753289f6aSNate Lawson /******************************************************************************* 98853289f6aSNate Lawson * 98953289f6aSNate Lawson * FUNCTION: main 99053289f6aSNate Lawson * 99153289f6aSNate Lawson * PARAMETERS: Standard argc/argv 99253289f6aSNate Lawson * 99353289f6aSNate Lawson * RETURN: Program termination code 99453289f6aSNate Lawson * 99553289f6aSNate Lawson * DESCRIPTION: C main routine for the Asl Compiler. Handle command line 996a9f12690SJung-uk Kim * options and begin the compile for each file on the command line 99753289f6aSNate Lawson * 99853289f6aSNate Lawson ******************************************************************************/ 99953289f6aSNate Lawson 100053289f6aSNate Lawson int ACPI_SYSTEM_XFACE 100153289f6aSNate Lawson main ( 100253289f6aSNate Lawson int argc, 100353289f6aSNate Lawson char **argv) 100453289f6aSNate Lawson { 100553289f6aSNate Lawson ACPI_STATUS Status; 1006709fac06SJung-uk Kim int Index1; 1007709fac06SJung-uk Kim int Index2; 100853289f6aSNate Lawson 100953289f6aSNate Lawson 1010042ff955SJung-uk Kim signal (SIGINT, AslSignalHandler); 1011042ff955SJung-uk Kim 1012709fac06SJung-uk Kim AcpiGbl_ExternalFileList = NULL; 1013042ff955SJung-uk Kim AcpiDbgLevel = 0; 1014709fac06SJung-uk Kim 1015fba7fc7eSJung-uk Kim #ifdef _DEBUG 1016fba7fc7eSJung-uk Kim _CrtSetDbgFlag (_CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_LEAK_CHECK_DF | 1017fba7fc7eSJung-uk Kim _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG)); 1018fba7fc7eSJung-uk Kim #endif 1019fba7fc7eSJung-uk Kim 102053289f6aSNate Lawson /* Init and command line */ 102153289f6aSNate Lawson 1022042ff955SJung-uk Kim Index1 = Index2 = AslCommandLine (argc, argv); 1023042ff955SJung-uk Kim 102453289f6aSNate Lawson AslInitialize (); 10254c52cad2SJung-uk Kim PrInitializePreprocessor (); 102653289f6aSNate Lawson 1027a9f12690SJung-uk Kim /* Options that have no additional parameters or pathnames */ 1028a9f12690SJung-uk Kim 1029a9f12690SJung-uk Kim if (Gbl_GetAllTables) 1030a9f12690SJung-uk Kim { 1031a9f12690SJung-uk Kim Status = AslDoOneFile (NULL); 1032fba7fc7eSJung-uk Kim if (ACPI_FAILURE (Status)) 1033fba7fc7eSJung-uk Kim { 1034a9f12690SJung-uk Kim return (-1); 1035a9f12690SJung-uk Kim } 1036a9f12690SJung-uk Kim return (0); 1037fba7fc7eSJung-uk Kim } 103853289f6aSNate Lawson 1039709fac06SJung-uk Kim if (Gbl_DisassembleAll) 104053289f6aSNate Lawson { 1041709fac06SJung-uk Kim while (argv[Index1]) 1042709fac06SJung-uk Kim { 1043709fac06SJung-uk Kim Status = AslDoOnePathname (argv[Index1], AcpiDmAddToExternalFileList); 104453289f6aSNate Lawson if (ACPI_FAILURE (Status)) 104553289f6aSNate Lawson { 1046a9f12690SJung-uk Kim return (-1); 104753289f6aSNate Lawson } 104853289f6aSNate Lawson 1049709fac06SJung-uk Kim Index1++; 1050709fac06SJung-uk Kim } 1051709fac06SJung-uk Kim } 1052709fac06SJung-uk Kim 1053709fac06SJung-uk Kim /* Process each pathname/filename in the list, with possible wildcards */ 1054709fac06SJung-uk Kim 1055709fac06SJung-uk Kim while (argv[Index2]) 1056709fac06SJung-uk Kim { 1057709fac06SJung-uk Kim Status = AslDoOnePathname (argv[Index2], AslDoOneFile); 1058709fac06SJung-uk Kim if (ACPI_FAILURE (Status)) 1059709fac06SJung-uk Kim { 1060709fac06SJung-uk Kim return (-1); 1061709fac06SJung-uk Kim } 1062709fac06SJung-uk Kim 1063709fac06SJung-uk Kim Index2++; 1064709fac06SJung-uk Kim } 1065709fac06SJung-uk Kim 1066709fac06SJung-uk Kim if (AcpiGbl_ExternalFileList) 1067709fac06SJung-uk Kim { 1068709fac06SJung-uk Kim AcpiDmClearExternalFileList(); 106953289f6aSNate Lawson } 107053289f6aSNate Lawson 107153289f6aSNate Lawson return (0); 107253289f6aSNate Lawson } 1073