153289f6aSNate Lawson /****************************************************************************** 253289f6aSNate Lawson * 353289f6aSNate Lawson * Module Name: aslmain - compiler main and utilities 453289f6aSNate Lawson * 553289f6aSNate Lawson *****************************************************************************/ 653289f6aSNate Lawson 7d244b227SJung-uk Kim /* 8efcc2a30SJung-uk Kim * Copyright (C) 2000 - 2013, 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" 103ed17e06eSJung-uk Kim #define ASL_SUPPORTED_OPTIONS "@:b|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 * 114*9c48c75eSJung-uk Kim * DESCRIPTION: Display option help message. 115*9c48c75eSJung-uk Kim * Optional items in square brackets. 11653289f6aSNate Lawson * 11753289f6aSNate Lawson ******************************************************************************/ 11853289f6aSNate Lawson 119fba7fc7eSJung-uk Kim static void 12053289f6aSNate Lawson Options ( 12153289f6aSNate Lawson void) 12253289f6aSNate Lawson { 12353289f6aSNate Lawson 1243f0275a0SJung-uk Kim printf ("\nGlobal:\n"); 1253f0275a0SJung-uk Kim ACPI_OPTION ("-@ <file>", "Specify command file"); 1263f0275a0SJung-uk Kim ACPI_OPTION ("-I <dir>", "Specify additional include directory"); 1278ef1a331SJung-uk Kim ACPI_OPTION ("-T <sig>|ALL|*", "Create table template file for ACPI <Sig>"); 128e8241eabSJung-uk Kim ACPI_OPTION ("-v", "Display compiler version"); 129d6dd1baeSJung-uk Kim 1304c52cad2SJung-uk Kim printf ("\nPreprocessor:\n"); 1314c52cad2SJung-uk Kim ACPI_OPTION ("-D <symbol>", "Define symbol for preprocessor use"); 1324c52cad2SJung-uk Kim ACPI_OPTION ("-li", "Create preprocessed output file (*.i)"); 1334c52cad2SJung-uk Kim ACPI_OPTION ("-P", "Preprocess only and create preprocessor output file (*.i)"); 134eef1b955SJung-uk Kim ACPI_OPTION ("-Pn", "Disable preprocessor"); 1354c52cad2SJung-uk Kim 136*9c48c75eSJung-uk Kim printf ("\nGeneral Processing:\n"); 1373f0275a0SJung-uk Kim ACPI_OPTION ("-p <prefix>", "Specify path/filename prefix for all output files"); 1383f0275a0SJung-uk Kim ACPI_OPTION ("-va", "Disable all errors and warnings (summary only)"); 1393f0275a0SJung-uk Kim ACPI_OPTION ("-vi", "Less verbose errors and warnings for use with IDEs"); 1403f0275a0SJung-uk Kim ACPI_OPTION ("-vo", "Enable optimization comments"); 1413f0275a0SJung-uk Kim ACPI_OPTION ("-vr", "Disable remarks"); 1423f0275a0SJung-uk Kim ACPI_OPTION ("-vs", "Disable signon"); 1434c52cad2SJung-uk Kim ACPI_OPTION ("-w1 -w2 -w3", "Set warning reporting level"); 144eef1b955SJung-uk Kim ACPI_OPTION ("-we", "Report warnings as errors"); 14553289f6aSNate Lawson 146*9c48c75eSJung-uk Kim printf ("\nAML Code Generation (*.aml):\n"); 1473f0275a0SJung-uk Kim ACPI_OPTION ("-oa", "Disable all optimizations (compatibility mode)"); 1483f0275a0SJung-uk Kim ACPI_OPTION ("-of", "Disable constant folding"); 1493f0275a0SJung-uk Kim ACPI_OPTION ("-oi", "Disable integer optimization to Zero/One/Ones"); 1503f0275a0SJung-uk Kim ACPI_OPTION ("-on", "Disable named reference string optimization"); 1513f0275a0SJung-uk Kim ACPI_OPTION ("-cr", "Disable Resource Descriptor error checking"); 152efcc2a30SJung-uk Kim ACPI_OPTION ("-in", "Ignore NoOp operators"); 1533f0275a0SJung-uk Kim ACPI_OPTION ("-r <revision>", "Override table header Revision (1-255)"); 15453289f6aSNate Lawson 155*9c48c75eSJung-uk Kim printf ("\nOptional Source Code Output Files:\n"); 156*9c48c75eSJung-uk Kim ACPI_OPTION ("-sc -sa", "Create source file in C or assembler (*.c or *.asm)"); 157*9c48c75eSJung-uk Kim ACPI_OPTION ("-ic -ia", "Create include file in C or assembler (*.h or *.inc)"); 158*9c48c75eSJung-uk Kim ACPI_OPTION ("-tc -ta -ts", "Create hex AML table in C, assembler, or ASL (*.hex)"); 159*9c48c75eSJung-uk Kim 160*9c48c75eSJung-uk Kim printf ("\nOptional Listing Files:\n"); 1613f0275a0SJung-uk Kim ACPI_OPTION ("-l", "Create mixed listing file (ASL source and AML) (*.lst)"); 1623f0275a0SJung-uk Kim ACPI_OPTION ("-ln", "Create namespace file (*.nsp)"); 1633f0275a0SJung-uk Kim ACPI_OPTION ("-ls", "Create combined source file (expanded includes) (*.src)"); 16453289f6aSNate Lawson 165*9c48c75eSJung-uk Kim printf ("\nData Table Compiler:\n"); 166*9c48c75eSJung-uk Kim ACPI_OPTION ("-G", "Compile custom table that contains generic operators"); 167*9c48c75eSJung-uk Kim ACPI_OPTION ("-vt", "Create verbose template files (full disassembly)"); 168a88e22b7SJung-uk Kim 16953289f6aSNate Lawson printf ("\nAML Disassembler:\n"); 170*9c48c75eSJung-uk Kim ACPI_OPTION ("-d <f1,f2>", "Disassemble or decode binary ACPI tables to file (*.dsl)"); 171*9c48c75eSJung-uk Kim ACPI_OPTION ("", " (Optional, file type is automatically detected)"); 172*9c48c75eSJung-uk Kim ACPI_OPTION ("-da <f1,f2>", "Disassemble multiple tables from single namespace"); 173042ff955SJung-uk Kim ACPI_OPTION ("-db", "Do not translate Buffers to Resource Templates"); 174*9c48c75eSJung-uk Kim ACPI_OPTION ("-dc <f1,f2>", "Disassemble AML and immediately compile it"); 1753f0275a0SJung-uk Kim ACPI_OPTION ("", " (Obtain DSDT from current system if no input file)"); 176*9c48c75eSJung-uk Kim ACPI_OPTION ("-e <f1,f2>", "Include ACPI table(s) for external symbol resolution"); 1773f0275a0SJung-uk Kim ACPI_OPTION ("-g", "Get ACPI tables and write to files (*.dat)"); 178efcc2a30SJung-uk Kim ACPI_OPTION ("-in", "Ignore NoOp opcodes"); 1798ef1a331SJung-uk Kim ACPI_OPTION ("-vt", "Dump binary table data in hex format within output file"); 18053289f6aSNate Lawson 18153289f6aSNate Lawson printf ("\nHelp:\n"); 182f38b0f21SJung-uk Kim ACPI_OPTION ("-h", "This message"); 1833f0275a0SJung-uk Kim ACPI_OPTION ("-hc", "Display operators allowed in constant expressions"); 184f38b0f21SJung-uk Kim ACPI_OPTION ("-hf", "Display help for output filename generation"); 1853f0275a0SJung-uk Kim ACPI_OPTION ("-hr", "Display ACPI reserved method names"); 1863f0275a0SJung-uk Kim ACPI_OPTION ("-ht", "Display currently supported ACPI table names"); 187f38b0f21SJung-uk Kim 188f38b0f21SJung-uk Kim printf ("\nDebug Options:\n"); 189f38b0f21SJung-uk Kim ACPI_OPTION ("-bf -bt", "Create debug file (full or parse tree only) (*.txt)"); 190f38b0f21SJung-uk Kim ACPI_OPTION ("-f", "Ignore errors, force creation of AML output file(s)"); 191*9c48c75eSJung-uk Kim ACPI_OPTION ("-m <size>", "Set internal line buffer size (in Kbytes)"); 192f38b0f21SJung-uk Kim ACPI_OPTION ("-n", "Parse only, no output generation"); 193f38b0f21SJung-uk Kim ACPI_OPTION ("-ot", "Display compile times and statistics"); 194f38b0f21SJung-uk Kim ACPI_OPTION ("-x <level>", "Set debug level for trace output"); 195f38b0f21SJung-uk Kim ACPI_OPTION ("-z", "Do not insert new compiler ID for DataTables"); 19653289f6aSNate Lawson } 19753289f6aSNate Lawson 19853289f6aSNate Lawson 19953289f6aSNate Lawson /******************************************************************************* 20053289f6aSNate Lawson * 201f38b0f21SJung-uk Kim * FUNCTION: FilenameHelp 20253289f6aSNate Lawson * 20353289f6aSNate Lawson * PARAMETERS: None 20453289f6aSNate Lawson * 20553289f6aSNate Lawson * RETURN: None 20653289f6aSNate Lawson * 207f38b0f21SJung-uk Kim * DESCRIPTION: Display help message for output filename generation 20853289f6aSNate Lawson * 20953289f6aSNate Lawson ******************************************************************************/ 21053289f6aSNate Lawson 211fba7fc7eSJung-uk Kim static void 212f38b0f21SJung-uk Kim FilenameHelp ( 21353289f6aSNate Lawson void) 21453289f6aSNate Lawson { 21553289f6aSNate Lawson 2163f0275a0SJung-uk Kim printf ("\nAML output filename generation:\n"); 21753289f6aSNate Lawson printf (" Output filenames are generated by appending an extension to a common\n"); 21853289f6aSNate Lawson printf (" filename prefix. The filename prefix is obtained via one of the\n"); 21953289f6aSNate Lawson printf (" following methods (in priority order):\n"); 22053289f6aSNate Lawson printf (" 1) The -p option specifies the prefix\n"); 22153289f6aSNate Lawson printf (" 2) The prefix of the AMLFileName in the ASL Definition Block\n"); 22253289f6aSNate Lawson printf (" 3) The prefix of the input filename\n"); 22353289f6aSNate Lawson printf ("\n"); 22453289f6aSNate Lawson } 22553289f6aSNate Lawson 22653289f6aSNate Lawson 22753289f6aSNate Lawson /******************************************************************************* 22853289f6aSNate Lawson * 22953289f6aSNate Lawson * FUNCTION: Usage 23053289f6aSNate Lawson * 23153289f6aSNate Lawson * PARAMETERS: None 23253289f6aSNate Lawson * 23353289f6aSNate Lawson * RETURN: None 23453289f6aSNate Lawson * 23553289f6aSNate Lawson * DESCRIPTION: Display usage and option message 23653289f6aSNate Lawson * 23753289f6aSNate Lawson ******************************************************************************/ 23853289f6aSNate Lawson 239fba7fc7eSJung-uk Kim static void 24053289f6aSNate Lawson Usage ( 24153289f6aSNate Lawson void) 24253289f6aSNate Lawson { 24353289f6aSNate Lawson 2443f0275a0SJung-uk Kim printf ("%s\n\n", ASL_COMPLIANCE); 2453f0275a0SJung-uk Kim ACPI_USAGE_HEADER ("iasl [Options] [Files]"); 24653289f6aSNate Lawson Options (); 24753289f6aSNate Lawson } 24853289f6aSNate Lawson 24953289f6aSNate Lawson 250042ff955SJung-uk Kim /****************************************************************************** 251042ff955SJung-uk Kim * 252042ff955SJung-uk Kim * FUNCTION: AslSignalHandler 253042ff955SJung-uk Kim * 254042ff955SJung-uk Kim * PARAMETERS: Sig - Signal that invoked this handler 255042ff955SJung-uk Kim * 256042ff955SJung-uk Kim * RETURN: None 257042ff955SJung-uk Kim * 258042ff955SJung-uk Kim * DESCRIPTION: Control-C handler. Delete any intermediate files and any 259042ff955SJung-uk Kim * output files that may be left in an indeterminate state. 260042ff955SJung-uk Kim * 261042ff955SJung-uk Kim *****************************************************************************/ 262042ff955SJung-uk Kim 263042ff955SJung-uk Kim static void ACPI_SYSTEM_XFACE 264042ff955SJung-uk Kim AslSignalHandler ( 265042ff955SJung-uk Kim int Sig) 266042ff955SJung-uk Kim { 267042ff955SJung-uk Kim UINT32 i; 268042ff955SJung-uk Kim 269042ff955SJung-uk Kim 270042ff955SJung-uk Kim signal (Sig, SIG_IGN); 271042ff955SJung-uk Kim printf ("Aborting\n\n"); 272042ff955SJung-uk Kim 273042ff955SJung-uk Kim /* Close all open files */ 274042ff955SJung-uk Kim 275042ff955SJung-uk Kim Gbl_Files[ASL_FILE_PREPROCESSOR].Handle = NULL; /* the .i file is same as source file */ 276042ff955SJung-uk Kim 277042ff955SJung-uk Kim for (i = ASL_FILE_INPUT; i < ASL_MAX_FILE_TYPE; i++) 278042ff955SJung-uk Kim { 279042ff955SJung-uk Kim FlCloseFile (i); 280042ff955SJung-uk Kim } 281042ff955SJung-uk Kim 282042ff955SJung-uk Kim /* Delete any output files */ 283042ff955SJung-uk Kim 284042ff955SJung-uk Kim for (i = ASL_FILE_AML_OUTPUT; i < ASL_MAX_FILE_TYPE; i++) 285042ff955SJung-uk Kim { 286042ff955SJung-uk Kim FlDeleteFile (i); 287042ff955SJung-uk Kim } 288042ff955SJung-uk Kim 289042ff955SJung-uk Kim exit (0); 290042ff955SJung-uk Kim } 291042ff955SJung-uk Kim 292042ff955SJung-uk Kim 29353289f6aSNate Lawson /******************************************************************************* 29453289f6aSNate Lawson * 29553289f6aSNate Lawson * FUNCTION: AslInitialize 29653289f6aSNate Lawson * 29753289f6aSNate Lawson * PARAMETERS: None 29853289f6aSNate Lawson * 29953289f6aSNate Lawson * RETURN: None 30053289f6aSNate Lawson * 30153289f6aSNate Lawson * DESCRIPTION: Initialize compiler globals 30253289f6aSNate Lawson * 30353289f6aSNate Lawson ******************************************************************************/ 30453289f6aSNate Lawson 305fba7fc7eSJung-uk Kim static void 306fba7fc7eSJung-uk Kim AslInitialize ( 307fba7fc7eSJung-uk Kim void) 30853289f6aSNate Lawson { 30953289f6aSNate Lawson UINT32 i; 31053289f6aSNate Lawson 31153289f6aSNate Lawson 31253289f6aSNate Lawson #ifdef _DEBUG 31353289f6aSNate Lawson _CrtSetDbgFlag (_CRTDBG_CHECK_ALWAYS_DF | _CrtSetDbgFlag(0)); 31453289f6aSNate Lawson #endif 31553289f6aSNate Lawson 31653289f6aSNate Lawson 31753289f6aSNate Lawson for (i = 0; i < ASL_NUM_FILES; i++) 31853289f6aSNate Lawson { 31953289f6aSNate Lawson Gbl_Files[i].Handle = NULL; 32053289f6aSNate Lawson Gbl_Files[i].Filename = NULL; 32153289f6aSNate Lawson } 32253289f6aSNate Lawson 32353289f6aSNate Lawson Gbl_Files[ASL_FILE_STDOUT].Handle = stdout; 32453289f6aSNate Lawson Gbl_Files[ASL_FILE_STDOUT].Filename = "STDOUT"; 32553289f6aSNate Lawson 32653289f6aSNate Lawson Gbl_Files[ASL_FILE_STDERR].Handle = stderr; 32753289f6aSNate Lawson Gbl_Files[ASL_FILE_STDERR].Filename = "STDERR"; 328042ff955SJung-uk Kim 329042ff955SJung-uk Kim /* Allocate the line buffer(s) */ 330042ff955SJung-uk Kim 331042ff955SJung-uk Kim Gbl_LineBufferSize /= 2; 332042ff955SJung-uk Kim UtExpandLineBuffers (); 33353289f6aSNate Lawson } 33453289f6aSNate Lawson 33553289f6aSNate Lawson 33653289f6aSNate Lawson /******************************************************************************* 33753289f6aSNate Lawson * 338d6dd1baeSJung-uk Kim * FUNCTION: AslMergeOptionTokens 33953289f6aSNate Lawson * 340d6dd1baeSJung-uk Kim * PARAMETERS: InBuffer - Input containing an option string 341d6dd1baeSJung-uk Kim * OutBuffer - Merged output buffer 34253289f6aSNate Lawson * 34353289f6aSNate Lawson * RETURN: None 34453289f6aSNate Lawson * 345d6dd1baeSJung-uk Kim * DESCRIPTION: Remove all whitespace from an option string. 346d6dd1baeSJung-uk Kim * 347d6dd1baeSJung-uk Kim ******************************************************************************/ 348d6dd1baeSJung-uk Kim 349d6dd1baeSJung-uk Kim static void 350d6dd1baeSJung-uk Kim AslMergeOptionTokens ( 351d6dd1baeSJung-uk Kim char *InBuffer, 352d6dd1baeSJung-uk Kim char *OutBuffer) 353d6dd1baeSJung-uk Kim { 354d6dd1baeSJung-uk Kim char *Token; 355d6dd1baeSJung-uk Kim 356d6dd1baeSJung-uk Kim 357d6dd1baeSJung-uk Kim *OutBuffer = 0; 358d6dd1baeSJung-uk Kim 359d6dd1baeSJung-uk Kim Token = strtok (InBuffer, ASL_TOKEN_SEPARATORS); 360d6dd1baeSJung-uk Kim while (Token) 361d6dd1baeSJung-uk Kim { 362d6dd1baeSJung-uk Kim strcat (OutBuffer, Token); 363d6dd1baeSJung-uk Kim Token = strtok (NULL, ASL_TOKEN_SEPARATORS); 364d6dd1baeSJung-uk Kim } 365d6dd1baeSJung-uk Kim } 366d6dd1baeSJung-uk Kim 367d6dd1baeSJung-uk Kim 368d6dd1baeSJung-uk Kim /******************************************************************************* 369d6dd1baeSJung-uk Kim * 370d6dd1baeSJung-uk Kim * FUNCTION: AslDoResponseFile 371d6dd1baeSJung-uk Kim * 372d6dd1baeSJung-uk Kim * PARAMETERS: Filename - Name of the response file 373d6dd1baeSJung-uk Kim * 374d6dd1baeSJung-uk Kim * RETURN: Status 375d6dd1baeSJung-uk Kim * 376d6dd1baeSJung-uk Kim * DESCRIPTION: Open a response file and process all options within. 37753289f6aSNate Lawson * 37853289f6aSNate Lawson ******************************************************************************/ 37953289f6aSNate Lawson 380a9f12690SJung-uk Kim static int 381d6dd1baeSJung-uk Kim AslDoResponseFile ( 382d6dd1baeSJung-uk Kim char *Filename) 38353289f6aSNate Lawson { 384d6dd1baeSJung-uk Kim char *argv = StringBuffer2; 385d6dd1baeSJung-uk Kim FILE *ResponseFile; 386d6dd1baeSJung-uk Kim int OptStatus = 0; 387d6dd1baeSJung-uk Kim int Opterr; 388d6dd1baeSJung-uk Kim int Optind; 389d6dd1baeSJung-uk Kim 390d6dd1baeSJung-uk Kim 391d6dd1baeSJung-uk Kim ResponseFile = fopen (Filename, "r"); 392d6dd1baeSJung-uk Kim if (!ResponseFile) 393d6dd1baeSJung-uk Kim { 394d6dd1baeSJung-uk Kim printf ("Could not open command file %s, %s\n", 395d6dd1baeSJung-uk Kim Filename, strerror (errno)); 3968ef1a331SJung-uk Kim return (-1); 397d6dd1baeSJung-uk Kim } 398d6dd1baeSJung-uk Kim 399d6dd1baeSJung-uk Kim /* Must save the current GetOpt globals */ 400d6dd1baeSJung-uk Kim 401d6dd1baeSJung-uk Kim Opterr = AcpiGbl_Opterr; 402d6dd1baeSJung-uk Kim Optind = AcpiGbl_Optind; 403d6dd1baeSJung-uk Kim 404d6dd1baeSJung-uk Kim /* 405d6dd1baeSJung-uk Kim * Process all lines in the response file. There must be one complete 406d6dd1baeSJung-uk Kim * option per line 407d6dd1baeSJung-uk Kim */ 408d6dd1baeSJung-uk Kim while (fgets (StringBuffer, ASL_MSG_BUFFER_SIZE, ResponseFile)) 409d6dd1baeSJung-uk Kim { 410d6dd1baeSJung-uk Kim /* Compress all tokens, allowing us to use a single argv entry */ 411d6dd1baeSJung-uk Kim 412d6dd1baeSJung-uk Kim AslMergeOptionTokens (StringBuffer, StringBuffer2); 413d6dd1baeSJung-uk Kim 414d6dd1baeSJung-uk Kim /* Process the option */ 415d6dd1baeSJung-uk Kim 416d6dd1baeSJung-uk Kim AcpiGbl_Opterr = 0; 417d6dd1baeSJung-uk Kim AcpiGbl_Optind = 0; 418d6dd1baeSJung-uk Kim 419d6dd1baeSJung-uk Kim OptStatus = AslDoOptions (1, &argv, TRUE); 420d6dd1baeSJung-uk Kim if (OptStatus) 421d6dd1baeSJung-uk Kim { 422d6dd1baeSJung-uk Kim printf ("Invalid option in command file %s: %s\n", 423d6dd1baeSJung-uk Kim Filename, StringBuffer); 424d6dd1baeSJung-uk Kim break; 425d6dd1baeSJung-uk Kim } 426d6dd1baeSJung-uk Kim } 427d6dd1baeSJung-uk Kim 428d6dd1baeSJung-uk Kim /* Restore the GetOpt globals */ 429d6dd1baeSJung-uk Kim 430d6dd1baeSJung-uk Kim AcpiGbl_Opterr = Opterr; 431d6dd1baeSJung-uk Kim AcpiGbl_Optind = Optind; 432d6dd1baeSJung-uk Kim 433d6dd1baeSJung-uk Kim fclose (ResponseFile); 434d6dd1baeSJung-uk Kim return (OptStatus); 435d6dd1baeSJung-uk Kim } 436d6dd1baeSJung-uk Kim 437d6dd1baeSJung-uk Kim 438d6dd1baeSJung-uk Kim /******************************************************************************* 439d6dd1baeSJung-uk Kim * 440d6dd1baeSJung-uk Kim * FUNCTION: AslDoOptions 441d6dd1baeSJung-uk Kim * 442d6dd1baeSJung-uk Kim * PARAMETERS: argc/argv - Standard argc/argv 443d6dd1baeSJung-uk Kim * IsResponseFile - TRUE if executing a response file. 444d6dd1baeSJung-uk Kim * 445d6dd1baeSJung-uk Kim * RETURN: Status 446d6dd1baeSJung-uk Kim * 447d6dd1baeSJung-uk Kim * DESCRIPTION: Command line option processing 448d6dd1baeSJung-uk Kim * 449d6dd1baeSJung-uk Kim ******************************************************************************/ 450d6dd1baeSJung-uk Kim 451d6dd1baeSJung-uk Kim static int 452d6dd1baeSJung-uk Kim AslDoOptions ( 453d6dd1baeSJung-uk Kim int argc, 454d6dd1baeSJung-uk Kim char **argv, 455d6dd1baeSJung-uk Kim BOOLEAN IsResponseFile) 456d6dd1baeSJung-uk Kim { 457a9f12690SJung-uk Kim int j; 45842fecd12SJung-uk Kim ACPI_STATUS Status; 45953289f6aSNate Lawson 46053289f6aSNate Lawson 46153289f6aSNate Lawson /* Get the command line options */ 46253289f6aSNate Lawson 463d6dd1baeSJung-uk Kim while ((j = AcpiGetopt (argc, argv, ASL_SUPPORTED_OPTIONS)) != EOF) switch (j) 46453289f6aSNate Lawson { 465d6dd1baeSJung-uk Kim case '@': /* Begin a response file */ 466d6dd1baeSJung-uk Kim 467d6dd1baeSJung-uk Kim if (IsResponseFile) 468d6dd1baeSJung-uk Kim { 469d6dd1baeSJung-uk Kim printf ("Nested command files are not supported\n"); 4704c52cad2SJung-uk Kim return (-1); 471d6dd1baeSJung-uk Kim } 472d6dd1baeSJung-uk Kim 473d6dd1baeSJung-uk Kim if (AslDoResponseFile (AcpiGbl_Optarg)) 474d6dd1baeSJung-uk Kim { 4754c52cad2SJung-uk Kim return (-1); 476d6dd1baeSJung-uk Kim } 477d6dd1baeSJung-uk Kim break; 478d6dd1baeSJung-uk Kim 479d6dd1baeSJung-uk Kim 4804c52cad2SJung-uk Kim case 'b': /* Debug output options */ 48153289f6aSNate Lawson switch (AcpiGbl_Optarg[0]) 48253289f6aSNate Lawson { 483f38b0f21SJung-uk Kim case 'f': 48453289f6aSNate Lawson AslCompilerdebug = 1; /* same as yydebug */ 485d052a1ccSJung-uk Kim DtParserdebug = 1; 4864c52cad2SJung-uk Kim PrParserdebug = 1; 48753289f6aSNate Lawson break; 48853289f6aSNate Lawson 48953289f6aSNate Lawson case 't': 49053289f6aSNate Lawson break; 49153289f6aSNate Lawson 49253289f6aSNate Lawson default: 49353289f6aSNate Lawson printf ("Unknown option: -b%s\n", AcpiGbl_Optarg); 494d6dd1baeSJung-uk Kim return (-1); 49553289f6aSNate Lawson } 49653289f6aSNate Lawson 49753289f6aSNate Lawson /* Produce debug output file */ 49853289f6aSNate Lawson 49953289f6aSNate Lawson Gbl_DebugFlag = TRUE; 50053289f6aSNate Lawson break; 50153289f6aSNate Lawson 50253289f6aSNate Lawson 50353289f6aSNate Lawson case 'c': 5043f5e024cSJung-uk Kim switch (AcpiGbl_Optarg[0]) 5053f5e024cSJung-uk Kim { 5063f5e024cSJung-uk Kim case 'r': 5073f5e024cSJung-uk Kim Gbl_NoResourceChecking = TRUE; 5083f5e024cSJung-uk Kim break; 50953289f6aSNate Lawson 5103f5e024cSJung-uk Kim default: 5113f5e024cSJung-uk Kim printf ("Unknown option: -c%s\n", AcpiGbl_Optarg); 5123f5e024cSJung-uk Kim return (-1); 5133f5e024cSJung-uk Kim } 51453289f6aSNate Lawson break; 51553289f6aSNate Lawson 51653289f6aSNate Lawson 5174c52cad2SJung-uk Kim case 'd': /* Disassembler */ 51853289f6aSNate Lawson switch (AcpiGbl_Optarg[0]) 51953289f6aSNate Lawson { 52053289f6aSNate Lawson case '^': 521a9f12690SJung-uk Kim Gbl_DoCompile = FALSE; 52253289f6aSNate Lawson break; 52353289f6aSNate Lawson 524709fac06SJung-uk Kim case 'a': 525709fac06SJung-uk Kim Gbl_DoCompile = FALSE; 526709fac06SJung-uk Kim Gbl_DisassembleAll = TRUE; 527709fac06SJung-uk Kim break; 528709fac06SJung-uk Kim 529042ff955SJung-uk Kim case 'b': /* Do not convert buffers to resource descriptors */ 530042ff955SJung-uk Kim AcpiGbl_NoResourceDisassembly = TRUE; 531042ff955SJung-uk Kim break; 532042ff955SJung-uk Kim 53353289f6aSNate Lawson case 'c': 53453289f6aSNate Lawson break; 53553289f6aSNate Lawson 53653289f6aSNate Lawson default: 53753289f6aSNate Lawson printf ("Unknown option: -d%s\n", AcpiGbl_Optarg); 538d6dd1baeSJung-uk Kim return (-1); 53953289f6aSNate Lawson } 54053289f6aSNate Lawson 54153289f6aSNate Lawson Gbl_DisasmFlag = TRUE; 54253289f6aSNate Lawson break; 54353289f6aSNate Lawson 54453289f6aSNate Lawson 5454c52cad2SJung-uk Kim case 'D': /* Define a symbol */ 5464c52cad2SJung-uk Kim PrAddDefine (AcpiGbl_Optarg, NULL, TRUE); 5474c52cad2SJung-uk Kim break; 5484c52cad2SJung-uk Kim 5494c52cad2SJung-uk Kim 5504c52cad2SJung-uk Kim case 'e': /* External files for disassembler */ 55142fecd12SJung-uk Kim Status = AcpiDmAddToExternalFileList (AcpiGbl_Optarg); 55242fecd12SJung-uk Kim if (ACPI_FAILURE (Status)) 55342fecd12SJung-uk Kim { 55442fecd12SJung-uk Kim printf ("Could not add %s to external list\n", AcpiGbl_Optarg); 55542fecd12SJung-uk Kim return (-1); 55642fecd12SJung-uk Kim } 55753289f6aSNate Lawson break; 55853289f6aSNate Lawson 55953289f6aSNate Lawson 5604c52cad2SJung-uk Kim case 'f': /* Ignore errors and force creation of aml file */ 56153289f6aSNate Lawson Gbl_IgnoreErrors = TRUE; 56253289f6aSNate Lawson break; 56353289f6aSNate Lawson 56453289f6aSNate Lawson 5654c52cad2SJung-uk Kim case 'G': 5664c52cad2SJung-uk Kim Gbl_CompileGeneric = TRUE; 5674c52cad2SJung-uk Kim break; 56853289f6aSNate Lawson 5694c52cad2SJung-uk Kim 5704c52cad2SJung-uk Kim case 'g': /* Get all ACPI tables */ 57153289f6aSNate Lawson 57253289f6aSNate Lawson Gbl_GetAllTables = TRUE; 573a9f12690SJung-uk Kim Gbl_DoCompile = FALSE; 57453289f6aSNate Lawson break; 57553289f6aSNate Lawson 57653289f6aSNate Lawson 57753289f6aSNate Lawson case 'h': 57853289f6aSNate Lawson switch (AcpiGbl_Optarg[0]) 57953289f6aSNate Lawson { 58053289f6aSNate Lawson case '^': 581f38b0f21SJung-uk Kim Usage (); 58253289f6aSNate Lawson exit (0); 58353289f6aSNate Lawson 58453289f6aSNate Lawson case 'c': 58553289f6aSNate Lawson UtDisplayConstantOpcodes (); 58653289f6aSNate Lawson exit (0); 58753289f6aSNate Lawson 588f38b0f21SJung-uk Kim case 'f': 589f38b0f21SJung-uk Kim FilenameHelp (); 590f38b0f21SJung-uk Kim exit (0); 591f38b0f21SJung-uk Kim 59253289f6aSNate Lawson case 'r': 59353289f6aSNate Lawson /* reserved names */ 59453289f6aSNate Lawson 595ca3cf4faSJung-uk Kim ApDisplayReservedNames (); 59653289f6aSNate Lawson exit (0); 59753289f6aSNate Lawson 598a88e22b7SJung-uk Kim case 't': 599a88e22b7SJung-uk Kim UtDisplaySupportedTables (); 600a88e22b7SJung-uk Kim exit (0); 601a88e22b7SJung-uk Kim 60253289f6aSNate Lawson default: 60353289f6aSNate Lawson printf ("Unknown option: -h%s\n", AcpiGbl_Optarg); 604d6dd1baeSJung-uk Kim return (-1); 60553289f6aSNate Lawson } 60653289f6aSNate Lawson 60753289f6aSNate Lawson 608d6dd1baeSJung-uk Kim case 'I': /* Add an include file search directory */ 609d6dd1baeSJung-uk Kim FlAddIncludeDirectory (AcpiGbl_Optarg); 610d6dd1baeSJung-uk Kim break; 611d6dd1baeSJung-uk Kim 612d6dd1baeSJung-uk Kim 6134c52cad2SJung-uk Kim case 'i': /* Output AML as an include file */ 61453289f6aSNate Lawson switch (AcpiGbl_Optarg[0]) 61553289f6aSNate Lawson { 61653289f6aSNate Lawson case 'a': 61753289f6aSNate Lawson 61853289f6aSNate Lawson /* Produce assembly code include file */ 61953289f6aSNate Lawson 62053289f6aSNate Lawson Gbl_AsmIncludeOutputFlag = TRUE; 62153289f6aSNate Lawson break; 62253289f6aSNate Lawson 62353289f6aSNate Lawson case 'c': 62453289f6aSNate Lawson 62553289f6aSNate Lawson /* Produce C include file */ 62653289f6aSNate Lawson 62753289f6aSNate Lawson Gbl_C_IncludeOutputFlag = TRUE; 62853289f6aSNate Lawson break; 62953289f6aSNate Lawson 630efcc2a30SJung-uk Kim case 'n': 631efcc2a30SJung-uk Kim 632efcc2a30SJung-uk Kim /* Compiler/Disassembler: Ignore the NOOP operator */ 633efcc2a30SJung-uk Kim 634efcc2a30SJung-uk Kim AcpiGbl_IgnoreNoopOperator = TRUE; 635efcc2a30SJung-uk Kim break; 636efcc2a30SJung-uk Kim 63753289f6aSNate Lawson default: 6384c52cad2SJung-uk Kim printf ("Unknown option: -i%s\n", AcpiGbl_Optarg); 639d6dd1baeSJung-uk Kim return (-1); 64053289f6aSNate Lawson } 64153289f6aSNate Lawson break; 64253289f6aSNate Lawson 64353289f6aSNate Lawson 6444c52cad2SJung-uk Kim case 'l': /* Listing files */ 64553289f6aSNate Lawson switch (AcpiGbl_Optarg[0]) 64653289f6aSNate Lawson { 64753289f6aSNate Lawson case '^': 64853289f6aSNate Lawson /* Produce listing file (Mixed source/aml) */ 64953289f6aSNate Lawson 65053289f6aSNate Lawson Gbl_ListingFlag = TRUE; 65153289f6aSNate Lawson break; 65253289f6aSNate Lawson 6534c52cad2SJung-uk Kim case 'i': 6544c52cad2SJung-uk Kim /* Produce preprocessor output file */ 6554c52cad2SJung-uk Kim 6564c52cad2SJung-uk Kim Gbl_PreprocessorOutputFlag = TRUE; 6574c52cad2SJung-uk Kim break; 6584c52cad2SJung-uk Kim 65953289f6aSNate Lawson case 'n': 66053289f6aSNate Lawson /* Produce namespace file */ 66153289f6aSNate Lawson 66253289f6aSNate Lawson Gbl_NsOutputFlag = TRUE; 66353289f6aSNate Lawson break; 66453289f6aSNate Lawson 66553289f6aSNate Lawson case 's': 66653289f6aSNate Lawson /* Produce combined source file */ 66753289f6aSNate Lawson 66853289f6aSNate Lawson Gbl_SourceOutputFlag = TRUE; 66953289f6aSNate Lawson break; 67053289f6aSNate Lawson 67153289f6aSNate Lawson default: 67253289f6aSNate Lawson printf ("Unknown option: -l%s\n", AcpiGbl_Optarg); 673d6dd1baeSJung-uk Kim return (-1); 67453289f6aSNate Lawson } 67553289f6aSNate Lawson break; 67653289f6aSNate Lawson 67753289f6aSNate Lawson 678042ff955SJung-uk Kim case 'm': /* Set line buffer size */ 679042ff955SJung-uk Kim Gbl_LineBufferSize = (UINT32) strtoul (AcpiGbl_Optarg, NULL, 0) * 1024; 680042ff955SJung-uk Kim if (Gbl_LineBufferSize < ASL_DEFAULT_LINE_BUFFER_SIZE) 681042ff955SJung-uk Kim { 682042ff955SJung-uk Kim Gbl_LineBufferSize = ASL_DEFAULT_LINE_BUFFER_SIZE; 683042ff955SJung-uk Kim } 684042ff955SJung-uk Kim printf ("Line Buffer Size: %u\n", Gbl_LineBufferSize); 6853f0275a0SJung-uk Kim break; 6863f0275a0SJung-uk Kim 6873f0275a0SJung-uk Kim 6884c52cad2SJung-uk Kim case 'n': /* Parse only */ 6893f0275a0SJung-uk Kim Gbl_ParseOnlyFlag = TRUE; 6903f0275a0SJung-uk Kim break; 6913f0275a0SJung-uk Kim 6923f0275a0SJung-uk Kim 6934c52cad2SJung-uk Kim case 'o': /* Control compiler AML optimizations */ 69453289f6aSNate Lawson switch (AcpiGbl_Optarg[0]) 69553289f6aSNate Lawson { 69653289f6aSNate Lawson case 'a': 69753289f6aSNate Lawson 69853289f6aSNate Lawson /* Disable all optimizations */ 69953289f6aSNate Lawson 70053289f6aSNate Lawson Gbl_FoldConstants = FALSE; 70153289f6aSNate Lawson Gbl_IntegerOptimizationFlag = FALSE; 70253289f6aSNate Lawson Gbl_ReferenceOptimizationFlag = FALSE; 70353289f6aSNate Lawson break; 70453289f6aSNate Lawson 70553289f6aSNate Lawson case 'f': 70653289f6aSNate Lawson 70753289f6aSNate Lawson /* Disable folding on "normal" expressions */ 70853289f6aSNate Lawson 70953289f6aSNate Lawson Gbl_FoldConstants = FALSE; 71053289f6aSNate Lawson break; 71153289f6aSNate Lawson 71253289f6aSNate Lawson case 'i': 71353289f6aSNate Lawson 71453289f6aSNate Lawson /* Disable integer optimization to constants */ 71553289f6aSNate Lawson 71653289f6aSNate Lawson Gbl_IntegerOptimizationFlag = FALSE; 71753289f6aSNate Lawson break; 71853289f6aSNate Lawson 71953289f6aSNate Lawson case 'n': 72053289f6aSNate Lawson 72153289f6aSNate Lawson /* Disable named reference optimization */ 72253289f6aSNate Lawson 72353289f6aSNate Lawson Gbl_ReferenceOptimizationFlag = FALSE; 72453289f6aSNate Lawson break; 72553289f6aSNate Lawson 72653289f6aSNate Lawson case 't': 72753289f6aSNate Lawson 72853289f6aSNate Lawson /* Display compile time(s) */ 72953289f6aSNate Lawson 73053289f6aSNate Lawson Gbl_CompileTimesFlag = TRUE; 73153289f6aSNate Lawson break; 73253289f6aSNate Lawson 73353289f6aSNate Lawson default: 73453289f6aSNate Lawson printf ("Unknown option: -c%s\n", AcpiGbl_Optarg); 735d6dd1baeSJung-uk Kim return (-1); 73653289f6aSNate Lawson } 73753289f6aSNate Lawson break; 73853289f6aSNate Lawson 73953289f6aSNate Lawson 740eef1b955SJung-uk Kim case 'P': /* Preprocessor options */ 741eef1b955SJung-uk Kim switch (AcpiGbl_Optarg[0]) 742eef1b955SJung-uk Kim { 743eef1b955SJung-uk Kim case '^': /* Proprocess only, emit (.i) file */ 7444c52cad2SJung-uk Kim Gbl_PreprocessOnly = TRUE; 7454c52cad2SJung-uk Kim Gbl_PreprocessorOutputFlag = TRUE; 7464c52cad2SJung-uk Kim break; 74753289f6aSNate Lawson 748eef1b955SJung-uk Kim case 'n': /* Disable preprocessor */ 749eef1b955SJung-uk Kim Gbl_PreprocessFlag = FALSE; 750eef1b955SJung-uk Kim break; 751eef1b955SJung-uk Kim 752eef1b955SJung-uk Kim default: 753eef1b955SJung-uk Kim printf ("Unknown option: -P%s\n", AcpiGbl_Optarg); 754eef1b955SJung-uk Kim return (-1); 755eef1b955SJung-uk Kim } 756eef1b955SJung-uk Kim break; 757eef1b955SJung-uk Kim 75853289f6aSNate Lawson 7594c52cad2SJung-uk Kim case 'p': /* Override default AML output filename */ 76053289f6aSNate Lawson Gbl_OutputFilenamePrefix = AcpiGbl_Optarg; 76153289f6aSNate Lawson Gbl_UseDefaultAmlFilename = FALSE; 76253289f6aSNate Lawson break; 76353289f6aSNate Lawson 76453289f6aSNate Lawson 7654c52cad2SJung-uk Kim case 'r': /* Override revision found in table header */ 766c8466860SMark Santcroos Gbl_RevisionOverride = (UINT8) strtoul (AcpiGbl_Optarg, NULL, 0); 76753289f6aSNate Lawson break; 76853289f6aSNate Lawson 76953289f6aSNate Lawson 7704c52cad2SJung-uk Kim case 's': /* Create AML in a source code file */ 77153289f6aSNate Lawson switch (AcpiGbl_Optarg[0]) 77253289f6aSNate Lawson { 77353289f6aSNate Lawson case 'a': 77453289f6aSNate Lawson 77553289f6aSNate Lawson /* Produce assembly code output file */ 77653289f6aSNate Lawson 77753289f6aSNate Lawson Gbl_AsmOutputFlag = TRUE; 77853289f6aSNate Lawson break; 77953289f6aSNate Lawson 78053289f6aSNate Lawson case 'c': 78153289f6aSNate Lawson 78253289f6aSNate Lawson /* Produce C hex output file */ 78353289f6aSNate Lawson 78453289f6aSNate Lawson Gbl_C_OutputFlag = TRUE; 78553289f6aSNate Lawson break; 78653289f6aSNate Lawson 78753289f6aSNate Lawson default: 78853289f6aSNate Lawson printf ("Unknown option: -s%s\n", AcpiGbl_Optarg); 789d6dd1baeSJung-uk Kim return (-1); 79053289f6aSNate Lawson } 79153289f6aSNate Lawson break; 79253289f6aSNate Lawson 79353289f6aSNate Lawson 7944c52cad2SJung-uk Kim case 't': /* Produce hex table output file */ 79553289f6aSNate Lawson switch (AcpiGbl_Optarg[0]) 79653289f6aSNate Lawson { 79753289f6aSNate Lawson case 'a': 79853289f6aSNate Lawson Gbl_HexOutputFlag = HEX_OUTPUT_ASM; 79953289f6aSNate Lawson break; 80053289f6aSNate Lawson 80153289f6aSNate Lawson case 'c': 80253289f6aSNate Lawson Gbl_HexOutputFlag = HEX_OUTPUT_C; 80353289f6aSNate Lawson break; 80453289f6aSNate Lawson 8053f5e024cSJung-uk Kim case 's': 8063f5e024cSJung-uk Kim Gbl_HexOutputFlag = HEX_OUTPUT_ASL; 8073f5e024cSJung-uk Kim break; 8083f5e024cSJung-uk Kim 80953289f6aSNate Lawson default: 81053289f6aSNate Lawson printf ("Unknown option: -t%s\n", AcpiGbl_Optarg); 811d6dd1baeSJung-uk Kim return (-1); 81253289f6aSNate Lawson } 81353289f6aSNate Lawson break; 81453289f6aSNate Lawson 81553289f6aSNate Lawson 8164c52cad2SJung-uk Kim case 'T': /* Create a ACPI table template file */ 817a88e22b7SJung-uk Kim Gbl_DoTemplates = TRUE; 818a88e22b7SJung-uk Kim Gbl_TemplateSignature = AcpiGbl_Optarg; 819a88e22b7SJung-uk Kim break; 820a88e22b7SJung-uk Kim 821a88e22b7SJung-uk Kim 822e8241eabSJung-uk Kim case 'v': /* Version and verbosity settings */ 82353289f6aSNate Lawson switch (AcpiGbl_Optarg[0]) 82453289f6aSNate Lawson { 825e8241eabSJung-uk Kim case '^': 826e8241eabSJung-uk Kim printf (ACPI_COMMON_SIGNON (ASL_COMPILER_NAME)); 827e8241eabSJung-uk Kim exit (0); 828e8241eabSJung-uk Kim 829a9f12690SJung-uk Kim case 'a': 830a9f12690SJung-uk Kim /* Disable All error/warning messages */ 831a9f12690SJung-uk Kim 832a9f12690SJung-uk Kim Gbl_NoErrors = TRUE; 833a9f12690SJung-uk Kim break; 834a9f12690SJung-uk Kim 83553289f6aSNate Lawson case 'i': 836a7a3b383SJung-uk Kim /* 837a7a3b383SJung-uk Kim * Support for integrated development environment(s). 838a7a3b383SJung-uk Kim * 839a7a3b383SJung-uk Kim * 1) No compiler signon 840a7a3b383SJung-uk Kim * 2) Send stderr messages to stdout 841a7a3b383SJung-uk Kim * 3) Less verbose error messages (single line only for each) 842a7a3b383SJung-uk Kim * 4) Error/warning messages are formatted appropriately to 843a7a3b383SJung-uk Kim * be recognized by MS Visual Studio 844a7a3b383SJung-uk Kim */ 84553289f6aSNate Lawson Gbl_VerboseErrors = FALSE; 846a7a3b383SJung-uk Kim Gbl_DoSignon = FALSE; 847a7a3b383SJung-uk Kim Gbl_Files[ASL_FILE_STDERR].Handle = stdout; 84853289f6aSNate Lawson break; 84953289f6aSNate Lawson 85053289f6aSNate Lawson case 'o': 85153289f6aSNate Lawson Gbl_DisplayOptimizations = TRUE; 85253289f6aSNate Lawson break; 85353289f6aSNate Lawson 85453289f6aSNate Lawson case 'r': 85553289f6aSNate Lawson Gbl_DisplayRemarks = FALSE; 85653289f6aSNate Lawson break; 85753289f6aSNate Lawson 85853289f6aSNate Lawson case 's': 859a9f12690SJung-uk Kim Gbl_DoSignon = FALSE; 86053289f6aSNate Lawson break; 86153289f6aSNate Lawson 862a88e22b7SJung-uk Kim case 't': 863a88e22b7SJung-uk Kim Gbl_VerboseTemplates = TRUE; 864a88e22b7SJung-uk Kim break; 865a88e22b7SJung-uk Kim 86653289f6aSNate Lawson default: 86753289f6aSNate Lawson printf ("Unknown option: -v%s\n", AcpiGbl_Optarg); 868d6dd1baeSJung-uk Kim return (-1); 86953289f6aSNate Lawson } 87053289f6aSNate Lawson break; 87153289f6aSNate Lawson 87253289f6aSNate Lawson 8731a39cfb0SJung-uk Kim case 'w': /* Set warning levels */ 8741a39cfb0SJung-uk Kim switch (AcpiGbl_Optarg[0]) 8751a39cfb0SJung-uk Kim { 8761a39cfb0SJung-uk Kim case '1': 8771a39cfb0SJung-uk Kim Gbl_WarningLevel = ASL_WARNING; 8781a39cfb0SJung-uk Kim break; 8791a39cfb0SJung-uk Kim 8801a39cfb0SJung-uk Kim case '2': 8811a39cfb0SJung-uk Kim Gbl_WarningLevel = ASL_WARNING2; 8821a39cfb0SJung-uk Kim break; 8831a39cfb0SJung-uk Kim 8841a39cfb0SJung-uk Kim case '3': 8851a39cfb0SJung-uk Kim Gbl_WarningLevel = ASL_WARNING3; 8861a39cfb0SJung-uk Kim break; 8871a39cfb0SJung-uk Kim 888eef1b955SJung-uk Kim case 'e': 889eef1b955SJung-uk Kim Gbl_WarningsAsErrors = TRUE; 890eef1b955SJung-uk Kim break; 891eef1b955SJung-uk Kim 8921a39cfb0SJung-uk Kim default: 8931a39cfb0SJung-uk Kim printf ("Unknown option: -w%s\n", AcpiGbl_Optarg); 894d6dd1baeSJung-uk Kim return (-1); 8951a39cfb0SJung-uk Kim } 8961a39cfb0SJung-uk Kim break; 8971a39cfb0SJung-uk Kim 8981a39cfb0SJung-uk Kim 8994c52cad2SJung-uk Kim case 'x': /* Set debug print output level */ 90053289f6aSNate Lawson AcpiDbgLevel = strtoul (AcpiGbl_Optarg, NULL, 16); 90153289f6aSNate Lawson break; 90253289f6aSNate Lawson 90353289f6aSNate Lawson 904a88e22b7SJung-uk Kim case 'z': 905a88e22b7SJung-uk Kim Gbl_UseOriginalCompilerId = TRUE; 906a88e22b7SJung-uk Kim break; 907a88e22b7SJung-uk Kim 908a88e22b7SJung-uk Kim 90953289f6aSNate Lawson default: 910d6dd1baeSJung-uk Kim return (-1); 91153289f6aSNate Lawson } 91253289f6aSNate Lawson 913d6dd1baeSJung-uk Kim return (0); 914d6dd1baeSJung-uk Kim } 915d6dd1baeSJung-uk Kim 916d6dd1baeSJung-uk Kim 917d6dd1baeSJung-uk Kim /******************************************************************************* 918d6dd1baeSJung-uk Kim * 919d6dd1baeSJung-uk Kim * FUNCTION: AslCommandLine 920d6dd1baeSJung-uk Kim * 921d6dd1baeSJung-uk Kim * PARAMETERS: argc/argv 922d6dd1baeSJung-uk Kim * 923d6dd1baeSJung-uk Kim * RETURN: Last argv index 924d6dd1baeSJung-uk Kim * 925d6dd1baeSJung-uk Kim * DESCRIPTION: Command line processing 926d6dd1baeSJung-uk Kim * 927d6dd1baeSJung-uk Kim ******************************************************************************/ 928d6dd1baeSJung-uk Kim 929d6dd1baeSJung-uk Kim static int 930d6dd1baeSJung-uk Kim AslCommandLine ( 931d6dd1baeSJung-uk Kim int argc, 932d6dd1baeSJung-uk Kim char **argv) 933d6dd1baeSJung-uk Kim { 934d6dd1baeSJung-uk Kim int BadCommandLine = 0; 93542fecd12SJung-uk Kim ACPI_STATUS Status; 936d6dd1baeSJung-uk Kim 937d6dd1baeSJung-uk Kim 938d6dd1baeSJung-uk Kim /* Minimum command line contains at least the command and an input file */ 939d6dd1baeSJung-uk Kim 940d6dd1baeSJung-uk Kim if (argc < 2) 941d6dd1baeSJung-uk Kim { 9423c1812acSJung-uk Kim printf (ACPI_COMMON_SIGNON (ASL_COMPILER_NAME)); 943d6dd1baeSJung-uk Kim Usage (); 944d6dd1baeSJung-uk Kim exit (1); 945d6dd1baeSJung-uk Kim } 946d6dd1baeSJung-uk Kim 947d6dd1baeSJung-uk Kim /* Process all command line options */ 948d6dd1baeSJung-uk Kim 949d6dd1baeSJung-uk Kim BadCommandLine = AslDoOptions (argc, argv, FALSE); 950d6dd1baeSJung-uk Kim 951a88e22b7SJung-uk Kim if (Gbl_DoTemplates) 952a88e22b7SJung-uk Kim { 95342fecd12SJung-uk Kim Status = DtCreateTemplates (Gbl_TemplateSignature); 95442fecd12SJung-uk Kim if (ACPI_FAILURE (Status)) 95542fecd12SJung-uk Kim { 95642fecd12SJung-uk Kim exit (-1); 95742fecd12SJung-uk Kim } 958a88e22b7SJung-uk Kim exit (1); 959a88e22b7SJung-uk Kim } 960a88e22b7SJung-uk Kim 96153289f6aSNate Lawson /* Next parameter must be the input filename */ 96253289f6aSNate Lawson 963a9f12690SJung-uk Kim if (!argv[AcpiGbl_Optind] && 964fba7fc7eSJung-uk Kim !Gbl_DisasmFlag && 965fba7fc7eSJung-uk Kim !Gbl_GetAllTables) 96653289f6aSNate Lawson { 96753289f6aSNate Lawson printf ("Missing input filename\n"); 96853289f6aSNate Lawson BadCommandLine = TRUE; 96953289f6aSNate Lawson } 97053289f6aSNate Lawson 971a9f12690SJung-uk Kim if (Gbl_DoSignon) 97253289f6aSNate Lawson { 9733c1812acSJung-uk Kim printf (ACPI_COMMON_SIGNON (ASL_COMPILER_NAME)); 974ec3fc72fSJung-uk Kim if (Gbl_IgnoreErrors) 975ec3fc72fSJung-uk Kim { 976ec3fc72fSJung-uk Kim printf ("Ignoring all errors, forcing AML file generation\n\n"); 977ec3fc72fSJung-uk Kim } 97853289f6aSNate Lawson } 97953289f6aSNate Lawson 98053289f6aSNate Lawson /* Abort if anything went wrong on the command line */ 98153289f6aSNate Lawson 98253289f6aSNate Lawson if (BadCommandLine) 98353289f6aSNate Lawson { 98453289f6aSNate Lawson printf ("\n"); 98553289f6aSNate Lawson Usage (); 98653289f6aSNate Lawson exit (1); 98753289f6aSNate Lawson } 98853289f6aSNate Lawson 989a9f12690SJung-uk Kim return (AcpiGbl_Optind); 99053289f6aSNate Lawson } 99153289f6aSNate Lawson 99253289f6aSNate Lawson 99353289f6aSNate Lawson /******************************************************************************* 99453289f6aSNate Lawson * 99553289f6aSNate Lawson * FUNCTION: main 99653289f6aSNate Lawson * 99753289f6aSNate Lawson * PARAMETERS: Standard argc/argv 99853289f6aSNate Lawson * 99953289f6aSNate Lawson * RETURN: Program termination code 100053289f6aSNate Lawson * 100153289f6aSNate Lawson * DESCRIPTION: C main routine for the Asl Compiler. Handle command line 1002a9f12690SJung-uk Kim * options and begin the compile for each file on the command line 100353289f6aSNate Lawson * 100453289f6aSNate Lawson ******************************************************************************/ 100553289f6aSNate Lawson 100653289f6aSNate Lawson int ACPI_SYSTEM_XFACE 100753289f6aSNate Lawson main ( 100853289f6aSNate Lawson int argc, 100953289f6aSNate Lawson char **argv) 101053289f6aSNate Lawson { 101153289f6aSNate Lawson ACPI_STATUS Status; 1012709fac06SJung-uk Kim int Index1; 1013709fac06SJung-uk Kim int Index2; 101453289f6aSNate Lawson 101553289f6aSNate Lawson 1016042ff955SJung-uk Kim signal (SIGINT, AslSignalHandler); 1017042ff955SJung-uk Kim 1018709fac06SJung-uk Kim AcpiGbl_ExternalFileList = NULL; 1019042ff955SJung-uk Kim AcpiDbgLevel = 0; 1020709fac06SJung-uk Kim 1021fba7fc7eSJung-uk Kim #ifdef _DEBUG 1022fba7fc7eSJung-uk Kim _CrtSetDbgFlag (_CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_LEAK_CHECK_DF | 1023fba7fc7eSJung-uk Kim _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG)); 1024fba7fc7eSJung-uk Kim #endif 1025fba7fc7eSJung-uk Kim 102653289f6aSNate Lawson /* Init and command line */ 102753289f6aSNate Lawson 1028042ff955SJung-uk Kim Index1 = Index2 = AslCommandLine (argc, argv); 1029042ff955SJung-uk Kim 103053289f6aSNate Lawson AslInitialize (); 10314c52cad2SJung-uk Kim PrInitializePreprocessor (); 103253289f6aSNate Lawson 1033a9f12690SJung-uk Kim /* Options that have no additional parameters or pathnames */ 1034a9f12690SJung-uk Kim 1035a9f12690SJung-uk Kim if (Gbl_GetAllTables) 1036a9f12690SJung-uk Kim { 1037a9f12690SJung-uk Kim Status = AslDoOneFile (NULL); 1038fba7fc7eSJung-uk Kim if (ACPI_FAILURE (Status)) 1039fba7fc7eSJung-uk Kim { 1040a9f12690SJung-uk Kim return (-1); 1041a9f12690SJung-uk Kim } 1042a9f12690SJung-uk Kim return (0); 1043fba7fc7eSJung-uk Kim } 104453289f6aSNate Lawson 1045709fac06SJung-uk Kim if (Gbl_DisassembleAll) 104653289f6aSNate Lawson { 1047709fac06SJung-uk Kim while (argv[Index1]) 1048709fac06SJung-uk Kim { 1049709fac06SJung-uk Kim Status = AslDoOnePathname (argv[Index1], AcpiDmAddToExternalFileList); 105053289f6aSNate Lawson if (ACPI_FAILURE (Status)) 105153289f6aSNate Lawson { 1052a9f12690SJung-uk Kim return (-1); 105353289f6aSNate Lawson } 105453289f6aSNate Lawson 1055709fac06SJung-uk Kim Index1++; 1056709fac06SJung-uk Kim } 1057709fac06SJung-uk Kim } 1058709fac06SJung-uk Kim 1059709fac06SJung-uk Kim /* Process each pathname/filename in the list, with possible wildcards */ 1060709fac06SJung-uk Kim 1061709fac06SJung-uk Kim while (argv[Index2]) 1062709fac06SJung-uk Kim { 1063709fac06SJung-uk Kim Status = AslDoOnePathname (argv[Index2], AslDoOneFile); 1064709fac06SJung-uk Kim if (ACPI_FAILURE (Status)) 1065709fac06SJung-uk Kim { 1066709fac06SJung-uk Kim return (-1); 1067709fac06SJung-uk Kim } 1068709fac06SJung-uk Kim 1069709fac06SJung-uk Kim Index2++; 1070709fac06SJung-uk Kim } 1071709fac06SJung-uk Kim 1072709fac06SJung-uk Kim if (AcpiGbl_ExternalFileList) 1073709fac06SJung-uk Kim { 1074709fac06SJung-uk Kim AcpiDmClearExternalFileList(); 107553289f6aSNate Lawson } 107653289f6aSNate Lawson 107753289f6aSNate Lawson return (0); 107853289f6aSNate Lawson } 1079