xref: /freebsd/sys/contrib/dev/acpica/compiler/asloptions.c (revision 9a4bc5208fad4d69360dbbe769e28a37419c4e21)
1a9d8d09cSJung-uk Kim /******************************************************************************
2a9d8d09cSJung-uk Kim  *
3a9d8d09cSJung-uk Kim  * Module Name: asloptions - compiler command line processing
4a9d8d09cSJung-uk Kim  *
5a9d8d09cSJung-uk Kim  *****************************************************************************/
6a9d8d09cSJung-uk Kim 
70d84335fSJung-uk Kim /******************************************************************************
80d84335fSJung-uk Kim  *
90d84335fSJung-uk Kim  * 1. Copyright Notice
100d84335fSJung-uk Kim  *
11ab71bbb7SJung-uk Kim  * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp.
12a9d8d09cSJung-uk Kim  * All rights reserved.
13a9d8d09cSJung-uk Kim  *
140d84335fSJung-uk Kim  * 2. License
150d84335fSJung-uk Kim  *
160d84335fSJung-uk Kim  * 2.1. This is your license from Intel Corp. under its intellectual property
170d84335fSJung-uk Kim  * rights. You may have additional license terms from the party that provided
180d84335fSJung-uk Kim  * you this software, covering your right to use that party's intellectual
190d84335fSJung-uk Kim  * property rights.
200d84335fSJung-uk Kim  *
210d84335fSJung-uk Kim  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
220d84335fSJung-uk Kim  * copy of the source code appearing in this file ("Covered Code") an
230d84335fSJung-uk Kim  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
240d84335fSJung-uk Kim  * base code distributed originally by Intel ("Original Intel Code") to copy,
250d84335fSJung-uk Kim  * make derivatives, distribute, use and display any portion of the Covered
260d84335fSJung-uk Kim  * Code in any form, with the right to sublicense such rights; and
270d84335fSJung-uk Kim  *
280d84335fSJung-uk Kim  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
290d84335fSJung-uk Kim  * license (with the right to sublicense), under only those claims of Intel
300d84335fSJung-uk Kim  * patents that are infringed by the Original Intel Code, to make, use, sell,
310d84335fSJung-uk Kim  * offer to sell, and import the Covered Code and derivative works thereof
320d84335fSJung-uk Kim  * solely to the minimum extent necessary to exercise the above copyright
330d84335fSJung-uk Kim  * license, and in no event shall the patent license extend to any additions
340d84335fSJung-uk Kim  * to or modifications of the Original Intel Code. No other license or right
350d84335fSJung-uk Kim  * is granted directly or by implication, estoppel or otherwise;
360d84335fSJung-uk Kim  *
370d84335fSJung-uk Kim  * The above copyright and patent license is granted only if the following
380d84335fSJung-uk Kim  * conditions are met:
390d84335fSJung-uk Kim  *
400d84335fSJung-uk Kim  * 3. Conditions
410d84335fSJung-uk Kim  *
420d84335fSJung-uk Kim  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
430d84335fSJung-uk Kim  * Redistribution of source code of any substantial portion of the Covered
440d84335fSJung-uk Kim  * Code or modification with rights to further distribute source must include
450d84335fSJung-uk Kim  * the above Copyright Notice, the above License, this list of Conditions,
460d84335fSJung-uk Kim  * and the following Disclaimer and Export Compliance provision. In addition,
470d84335fSJung-uk Kim  * Licensee must cause all Covered Code to which Licensee contributes to
480d84335fSJung-uk Kim  * contain a file documenting the changes Licensee made to create that Covered
490d84335fSJung-uk Kim  * Code and the date of any change. Licensee must include in that file the
500d84335fSJung-uk Kim  * documentation of any changes made by any predecessor Licensee. Licensee
510d84335fSJung-uk Kim  * must include a prominent statement that the modification is derived,
520d84335fSJung-uk Kim  * directly or indirectly, from Original Intel Code.
530d84335fSJung-uk Kim  *
540d84335fSJung-uk Kim  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
550d84335fSJung-uk Kim  * Redistribution of source code of any substantial portion of the Covered
560d84335fSJung-uk Kim  * Code or modification without rights to further distribute source must
570d84335fSJung-uk Kim  * include the following Disclaimer and Export Compliance provision in the
580d84335fSJung-uk Kim  * documentation and/or other materials provided with distribution. In
590d84335fSJung-uk Kim  * addition, Licensee may not authorize further sublicense of source of any
600d84335fSJung-uk Kim  * portion of the Covered Code, and must include terms to the effect that the
610d84335fSJung-uk Kim  * license from Licensee to its licensee is limited to the intellectual
620d84335fSJung-uk Kim  * property embodied in the software Licensee provides to its licensee, and
630d84335fSJung-uk Kim  * not to intellectual property embodied in modifications its licensee may
640d84335fSJung-uk Kim  * make.
650d84335fSJung-uk Kim  *
660d84335fSJung-uk Kim  * 3.3. Redistribution of Executable. Redistribution in executable form of any
670d84335fSJung-uk Kim  * substantial portion of the Covered Code or modification must reproduce the
680d84335fSJung-uk Kim  * above Copyright Notice, and the following Disclaimer and Export Compliance
690d84335fSJung-uk Kim  * provision in the documentation and/or other materials provided with the
700d84335fSJung-uk Kim  * distribution.
710d84335fSJung-uk Kim  *
720d84335fSJung-uk Kim  * 3.4. Intel retains all right, title, and interest in and to the Original
730d84335fSJung-uk Kim  * Intel Code.
740d84335fSJung-uk Kim  *
750d84335fSJung-uk Kim  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
760d84335fSJung-uk Kim  * Intel shall be used in advertising or otherwise to promote the sale, use or
770d84335fSJung-uk Kim  * other dealings in products derived from or relating to the Covered Code
780d84335fSJung-uk Kim  * without prior written authorization from Intel.
790d84335fSJung-uk Kim  *
800d84335fSJung-uk Kim  * 4. Disclaimer and Export Compliance
810d84335fSJung-uk Kim  *
820d84335fSJung-uk Kim  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
830d84335fSJung-uk Kim  * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
840d84335fSJung-uk Kim  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
850d84335fSJung-uk Kim  * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
860d84335fSJung-uk Kim  * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
870d84335fSJung-uk Kim  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
880d84335fSJung-uk Kim  * PARTICULAR PURPOSE.
890d84335fSJung-uk Kim  *
900d84335fSJung-uk Kim  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
910d84335fSJung-uk Kim  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
920d84335fSJung-uk Kim  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
930d84335fSJung-uk Kim  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
940d84335fSJung-uk Kim  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
950d84335fSJung-uk Kim  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
960d84335fSJung-uk Kim  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
970d84335fSJung-uk Kim  * LIMITED REMEDY.
980d84335fSJung-uk Kim  *
990d84335fSJung-uk Kim  * 4.3. Licensee shall not export, either directly or indirectly, any of this
1000d84335fSJung-uk Kim  * software or system incorporating such software without first obtaining any
1010d84335fSJung-uk Kim  * required license or other approval from the U. S. Department of Commerce or
1020d84335fSJung-uk Kim  * any other agency or department of the United States Government. In the
1030d84335fSJung-uk Kim  * event Licensee exports any such software from the United States or
1040d84335fSJung-uk Kim  * re-exports any such software from a foreign destination, Licensee shall
1050d84335fSJung-uk Kim  * ensure that the distribution and export/re-export of the software is in
1060d84335fSJung-uk Kim  * compliance with all laws, regulations, orders, or other restrictions of the
1070d84335fSJung-uk Kim  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
1080d84335fSJung-uk Kim  * any of its subsidiaries will export/re-export any technical data, process,
1090d84335fSJung-uk Kim  * software, or service, directly or indirectly, to any country for which the
1100d84335fSJung-uk Kim  * United States government or any agency thereof requires an export license,
1110d84335fSJung-uk Kim  * other governmental approval, or letter of assurance, without first obtaining
1120d84335fSJung-uk Kim  * such license, approval or letter.
1130d84335fSJung-uk Kim  *
1140d84335fSJung-uk Kim  *****************************************************************************
1150d84335fSJung-uk Kim  *
1160d84335fSJung-uk Kim  * Alternatively, you may choose to be licensed under the terms of the
1170d84335fSJung-uk Kim  * following license:
1180d84335fSJung-uk Kim  *
119a9d8d09cSJung-uk Kim  * Redistribution and use in source and binary forms, with or without
120a9d8d09cSJung-uk Kim  * modification, are permitted provided that the following conditions
121a9d8d09cSJung-uk Kim  * are met:
122a9d8d09cSJung-uk Kim  * 1. Redistributions of source code must retain the above copyright
123a9d8d09cSJung-uk Kim  *    notice, this list of conditions, and the following disclaimer,
124a9d8d09cSJung-uk Kim  *    without modification.
125a9d8d09cSJung-uk Kim  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126a9d8d09cSJung-uk Kim  *    substantially similar to the "NO WARRANTY" disclaimer below
127a9d8d09cSJung-uk Kim  *    ("Disclaimer") and any redistribution must be conditioned upon
128a9d8d09cSJung-uk Kim  *    including a substantially similar Disclaimer requirement for further
129a9d8d09cSJung-uk Kim  *    binary redistribution.
130a9d8d09cSJung-uk Kim  * 3. Neither the names of the above-listed copyright holders nor the names
131a9d8d09cSJung-uk Kim  *    of any contributors may be used to endorse or promote products derived
132a9d8d09cSJung-uk Kim  *    from this software without specific prior written permission.
133a9d8d09cSJung-uk Kim  *
1340d84335fSJung-uk Kim  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1350d84335fSJung-uk Kim  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1360d84335fSJung-uk Kim  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1370d84335fSJung-uk Kim  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
1380d84335fSJung-uk Kim  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
1390d84335fSJung-uk Kim  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
1400d84335fSJung-uk Kim  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
1410d84335fSJung-uk Kim  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
1420d84335fSJung-uk Kim  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1430d84335fSJung-uk Kim  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1440d84335fSJung-uk Kim  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1450d84335fSJung-uk Kim  *
1460d84335fSJung-uk Kim  * Alternatively, you may choose to be licensed under the terms of the
147a9d8d09cSJung-uk Kim  * GNU General Public License ("GPL") version 2 as published by the Free
148a9d8d09cSJung-uk Kim  * Software Foundation.
149a9d8d09cSJung-uk Kim  *
1500d84335fSJung-uk Kim  *****************************************************************************/
151a9d8d09cSJung-uk Kim 
152a9d8d09cSJung-uk Kim #include <contrib/dev/acpica/compiler/aslcompiler.h>
153a9d8d09cSJung-uk Kim #include <contrib/dev/acpica/include/acapps.h>
154a9d8d09cSJung-uk Kim #include <contrib/dev/acpica/include/acdisasm.h>
155*9a4bc520SJung-uk Kim #include <contrib/dev/acpica/include/acglobal.h>
156a9d8d09cSJung-uk Kim 
157a9d8d09cSJung-uk Kim #define _COMPONENT          ACPI_COMPILER
158a9d8d09cSJung-uk Kim         ACPI_MODULE_NAME    ("asloption")
159a9d8d09cSJung-uk Kim 
160a9d8d09cSJung-uk Kim 
161a9d8d09cSJung-uk Kim /* Local prototypes */
162a9d8d09cSJung-uk Kim 
163a9d8d09cSJung-uk Kim static int
164a9d8d09cSJung-uk Kim AslDoOptions (
165a9d8d09cSJung-uk Kim     int                     argc,
166a9d8d09cSJung-uk Kim     char                    **argv,
167a9d8d09cSJung-uk Kim     BOOLEAN                 IsResponseFile);
168a9d8d09cSJung-uk Kim 
169a9d8d09cSJung-uk Kim static void
170a9d8d09cSJung-uk Kim AslMergeOptionTokens (
171a9d8d09cSJung-uk Kim     char                    *InBuffer,
172a9d8d09cSJung-uk Kim     char                    *OutBuffer);
173a9d8d09cSJung-uk Kim 
174a9d8d09cSJung-uk Kim static int
175a9d8d09cSJung-uk Kim AslDoResponseFile (
176a9d8d09cSJung-uk Kim     char                    *Filename);
177a9d8d09cSJung-uk Kim 
178a9d8d09cSJung-uk Kim 
179a9d8d09cSJung-uk Kim #define ASL_TOKEN_SEPARATORS    " \t\n"
180*9a4bc520SJung-uk Kim #define ASL_SUPPORTED_OPTIONS   "@:a:b|c|d^D:e:f^gh^i|I:l^m:no|p:P^q^r:s|:t|T+G^v^w|x:z"
181a9d8d09cSJung-uk Kim 
182a9d8d09cSJung-uk Kim 
183a9d8d09cSJung-uk Kim /*******************************************************************************
184a9d8d09cSJung-uk Kim  *
185a9d8d09cSJung-uk Kim  * FUNCTION:    AslCommandLine
186a9d8d09cSJung-uk Kim  *
187a9d8d09cSJung-uk Kim  * PARAMETERS:  argc/argv
188a9d8d09cSJung-uk Kim  *
189a9d8d09cSJung-uk Kim  * RETURN:      Last argv index
190a9d8d09cSJung-uk Kim  *
191a9d8d09cSJung-uk Kim  * DESCRIPTION: Command line processing
192a9d8d09cSJung-uk Kim  *
193a9d8d09cSJung-uk Kim  ******************************************************************************/
194a9d8d09cSJung-uk Kim 
195a9d8d09cSJung-uk Kim int
196a9d8d09cSJung-uk Kim AslCommandLine (
197a9d8d09cSJung-uk Kim     int                     argc,
198a9d8d09cSJung-uk Kim     char                    **argv)
199a9d8d09cSJung-uk Kim {
200a9d8d09cSJung-uk Kim     int                     BadCommandLine = 0;
201a9d8d09cSJung-uk Kim     ACPI_STATUS             Status;
202a9d8d09cSJung-uk Kim 
203a9d8d09cSJung-uk Kim 
204a9d8d09cSJung-uk Kim     /* Minimum command line contains at least the command and an input file */
205a9d8d09cSJung-uk Kim 
206a9d8d09cSJung-uk Kim     if (argc < 2)
207a9d8d09cSJung-uk Kim     {
208a9d8d09cSJung-uk Kim         Usage ();
209a9d8d09cSJung-uk Kim         exit (1);
210a9d8d09cSJung-uk Kim     }
211a9d8d09cSJung-uk Kim 
212a9d8d09cSJung-uk Kim     /* Process all command line options */
213a9d8d09cSJung-uk Kim 
214a9d8d09cSJung-uk Kim     BadCommandLine = AslDoOptions (argc, argv, FALSE);
215a9d8d09cSJung-uk Kim 
2166f1f1a63SJung-uk Kim     if (AslGbl_DoTemplates)
217a9d8d09cSJung-uk Kim     {
218f8146b88SJung-uk Kim         Status = DtCreateTemplates (argv);
219a9d8d09cSJung-uk Kim         if (ACPI_FAILURE (Status))
220a9d8d09cSJung-uk Kim         {
221a9d8d09cSJung-uk Kim             exit (-1);
222a9d8d09cSJung-uk Kim         }
223f9a6772eSJung-uk Kim         exit (0);
224a9d8d09cSJung-uk Kim     }
225a9d8d09cSJung-uk Kim 
226a9d8d09cSJung-uk Kim     /* Next parameter must be the input filename */
227a9d8d09cSJung-uk Kim 
228a9d8d09cSJung-uk Kim     if (!argv[AcpiGbl_Optind] &&
229af051161SJung-uk Kim         !AcpiGbl_DisasmFlag)
230a9d8d09cSJung-uk Kim     {
231a9d8d09cSJung-uk Kim         printf ("Missing input filename\n");
232a9d8d09cSJung-uk Kim         BadCommandLine = TRUE;
233a9d8d09cSJung-uk Kim     }
234a9d8d09cSJung-uk Kim 
2356f1f1a63SJung-uk Kim     if (AslGbl_DoSignon)
236a9d8d09cSJung-uk Kim     {
237a9d8d09cSJung-uk Kim         printf (ACPI_COMMON_SIGNON (ASL_COMPILER_NAME));
2386f1f1a63SJung-uk Kim         if (AslGbl_IgnoreErrors)
239a9d8d09cSJung-uk Kim         {
240a9d8d09cSJung-uk Kim             printf ("Ignoring all errors, forcing AML file generation\n\n");
241a9d8d09cSJung-uk Kim         }
242a9d8d09cSJung-uk Kim     }
243a9d8d09cSJung-uk Kim 
244a9d8d09cSJung-uk Kim     if (BadCommandLine)
245a9d8d09cSJung-uk Kim     {
24679c6d946SJung-uk Kim         printf ("Use -h option for help information\n");
247a9d8d09cSJung-uk Kim         exit (1);
248a9d8d09cSJung-uk Kim     }
249a9d8d09cSJung-uk Kim 
250a9d8d09cSJung-uk Kim     return (AcpiGbl_Optind);
251a9d8d09cSJung-uk Kim }
252a9d8d09cSJung-uk Kim 
253a9d8d09cSJung-uk Kim 
254a9d8d09cSJung-uk Kim /*******************************************************************************
255a9d8d09cSJung-uk Kim  *
256a9d8d09cSJung-uk Kim  * FUNCTION:    AslDoOptions
257a9d8d09cSJung-uk Kim  *
258a9d8d09cSJung-uk Kim  * PARAMETERS:  argc/argv           - Standard argc/argv
259a9d8d09cSJung-uk Kim  *              IsResponseFile      - TRUE if executing a response file.
260a9d8d09cSJung-uk Kim  *
261a9d8d09cSJung-uk Kim  * RETURN:      Status
262a9d8d09cSJung-uk Kim  *
263a9d8d09cSJung-uk Kim  * DESCRIPTION: Command line option processing
264a9d8d09cSJung-uk Kim  *
265a9d8d09cSJung-uk Kim  ******************************************************************************/
266a9d8d09cSJung-uk Kim 
267a9d8d09cSJung-uk Kim static int
268a9d8d09cSJung-uk Kim AslDoOptions (
269a9d8d09cSJung-uk Kim     int                     argc,
270a9d8d09cSJung-uk Kim     char                    **argv,
271a9d8d09cSJung-uk Kim     BOOLEAN                 IsResponseFile)
272a9d8d09cSJung-uk Kim {
273a9d8d09cSJung-uk Kim     ACPI_STATUS             Status;
274*9a4bc520SJung-uk Kim     INT32                  j;
275a9d8d09cSJung-uk Kim 
276a9d8d09cSJung-uk Kim 
277a9d8d09cSJung-uk Kim     /* Get the command line options */
278a9d8d09cSJung-uk Kim 
279313a0c13SJung-uk Kim     while ((j = AcpiGetopt (argc, argv, ASL_SUPPORTED_OPTIONS)) != ACPI_OPT_END) switch (j)
280a9d8d09cSJung-uk Kim     {
281a9d8d09cSJung-uk Kim     case '@':   /* Begin a response file */
282a9d8d09cSJung-uk Kim 
283a9d8d09cSJung-uk Kim         if (IsResponseFile)
284a9d8d09cSJung-uk Kim         {
285a9d8d09cSJung-uk Kim             printf ("Nested command files are not supported\n");
286a9d8d09cSJung-uk Kim             return (-1);
287a9d8d09cSJung-uk Kim         }
288a9d8d09cSJung-uk Kim 
289a9d8d09cSJung-uk Kim         if (AslDoResponseFile (AcpiGbl_Optarg))
290a9d8d09cSJung-uk Kim         {
291a9d8d09cSJung-uk Kim             return (-1);
292a9d8d09cSJung-uk Kim         }
293a9d8d09cSJung-uk Kim         break;
294a9d8d09cSJung-uk Kim 
295f8146b88SJung-uk Kim     case 'a':   /* Debug options */
296f8146b88SJung-uk Kim 
297f8146b88SJung-uk Kim         switch (AcpiGbl_Optarg[0])
298f8146b88SJung-uk Kim         {
299f8146b88SJung-uk Kim         case 'r':
300f8146b88SJung-uk Kim 
3016f1f1a63SJung-uk Kim             AslGbl_EnableReferenceTypechecking = TRUE;
302f8146b88SJung-uk Kim             break;
303f8146b88SJung-uk Kim 
304f8146b88SJung-uk Kim         default:
305f8146b88SJung-uk Kim 
306f8146b88SJung-uk Kim             printf ("Unknown option: -a%s\n", AcpiGbl_Optarg);
307f8146b88SJung-uk Kim             return (-1);
308f8146b88SJung-uk Kim         }
309f8146b88SJung-uk Kim 
310f8146b88SJung-uk Kim         break;
311f8146b88SJung-uk Kim 
312f8146b88SJung-uk Kim 
3131c0e1b6dSJung-uk Kim     case 'b':   /* Debug options */
314a9d8d09cSJung-uk Kim 
315a9d8d09cSJung-uk Kim         switch (AcpiGbl_Optarg[0])
316a9d8d09cSJung-uk Kim         {
3170d84335fSJung-uk Kim 
3180d84335fSJung-uk Kim         case 'c':
3190d84335fSJung-uk Kim 
3200d84335fSJung-uk Kim             printf ("Debug ASL to ASL+ conversion\n");
3210d84335fSJung-uk Kim 
3226f1f1a63SJung-uk Kim             AslGbl_DoAslConversion = TRUE;
3236f1f1a63SJung-uk Kim             AslGbl_FoldConstants = FALSE;
3246f1f1a63SJung-uk Kim             AslGbl_IntegerOptimizationFlag = FALSE;
3256f1f1a63SJung-uk Kim             AslGbl_ReferenceOptimizationFlag = FALSE;
3266f1f1a63SJung-uk Kim             AslGbl_OptimizeTrivialParseNodes = FALSE;
327f1db5ef7SJung-uk Kim             AcpiGbl_CaptureComments = TRUE;
3280d84335fSJung-uk Kim             AcpiGbl_DoDisassemblerOptimizations = FALSE;
3290d84335fSJung-uk Kim             AcpiGbl_DebugAslConversion = TRUE;
3300d84335fSJung-uk Kim             AcpiGbl_DmEmitExternalOpcodes = TRUE;
3316f1f1a63SJung-uk Kim             AslGbl_DoExternalsInPlace = TRUE;
3320d84335fSJung-uk Kim 
3330d84335fSJung-uk Kim             return (0);
3340d84335fSJung-uk Kim 
335a9d8d09cSJung-uk Kim         case 'f':
336a9d8d09cSJung-uk Kim 
337a9d8d09cSJung-uk Kim             AslCompilerdebug = 1; /* same as yydebug */
338a9d8d09cSJung-uk Kim             DtParserdebug = 1;
339a9d8d09cSJung-uk Kim             PrParserdebug = 1;
3406f1f1a63SJung-uk Kim             AslGbl_DebugFlag = TRUE;
3416f1f1a63SJung-uk Kim             AslGbl_KeepPreprocessorTempFile = TRUE;
3421c0e1b6dSJung-uk Kim             break;
3431c0e1b6dSJung-uk Kim 
3441c0e1b6dSJung-uk Kim         case 'p':   /* Prune ASL parse tree */
3451c0e1b6dSJung-uk Kim 
3461c0e1b6dSJung-uk Kim             /* Get the required argument */
3471c0e1b6dSJung-uk Kim 
3481c0e1b6dSJung-uk Kim             if (AcpiGetoptArgument (argc, argv))
3491c0e1b6dSJung-uk Kim             {
3501c0e1b6dSJung-uk Kim                 return (-1);
3511c0e1b6dSJung-uk Kim             }
3521c0e1b6dSJung-uk Kim 
3536f1f1a63SJung-uk Kim             AslGbl_PruneParseTree = TRUE;
3546f1f1a63SJung-uk Kim             AslGbl_PruneDepth = (UINT8) strtoul (AcpiGbl_Optarg, NULL, 0);
3551c0e1b6dSJung-uk Kim             break;
3561c0e1b6dSJung-uk Kim 
3571c0e1b6dSJung-uk Kim         case 's':
3581c0e1b6dSJung-uk Kim 
3596f1f1a63SJung-uk Kim             AslGbl_DebugFlag = TRUE;
360a9d8d09cSJung-uk Kim             break;
361a9d8d09cSJung-uk Kim 
362a9d8d09cSJung-uk Kim         case 't':
363a9d8d09cSJung-uk Kim 
3641c0e1b6dSJung-uk Kim             /* Get the required argument */
3651c0e1b6dSJung-uk Kim 
3661c0e1b6dSJung-uk Kim             if (AcpiGetoptArgument (argc, argv))
3671c0e1b6dSJung-uk Kim             {
3681c0e1b6dSJung-uk Kim                 return (-1);
3691c0e1b6dSJung-uk Kim             }
3706f1f1a63SJung-uk Kim             AslGbl_PruneType = (UINT8) strtoul (AcpiGbl_Optarg, NULL, 0);
371a9d8d09cSJung-uk Kim             break;
372a9d8d09cSJung-uk Kim 
373a9d8d09cSJung-uk Kim         default:
374a9d8d09cSJung-uk Kim 
375a9d8d09cSJung-uk Kim             printf ("Unknown option: -b%s\n", AcpiGbl_Optarg);
376a9d8d09cSJung-uk Kim             return (-1);
377a9d8d09cSJung-uk Kim         }
378a9d8d09cSJung-uk Kim 
379a9d8d09cSJung-uk Kim         break;
380a9d8d09cSJung-uk Kim 
381a9d8d09cSJung-uk Kim     case 'c':
382a9d8d09cSJung-uk Kim 
383a9d8d09cSJung-uk Kim         switch (AcpiGbl_Optarg[0])
384a9d8d09cSJung-uk Kim         {
3850d84335fSJung-uk Kim 
3860d84335fSJung-uk Kim         case 'a':
3870d84335fSJung-uk Kim 
3880d84335fSJung-uk Kim             printf ("Convert ASL to ASL+ with comments\n");
3896f1f1a63SJung-uk Kim             AslGbl_DoAslConversion = TRUE;
3906f1f1a63SJung-uk Kim             AslGbl_FoldConstants = FALSE;
3916f1f1a63SJung-uk Kim             AslGbl_IntegerOptimizationFlag = FALSE;
3926f1f1a63SJung-uk Kim             AslGbl_ReferenceOptimizationFlag = FALSE;
3936f1f1a63SJung-uk Kim             AslGbl_OptimizeTrivialParseNodes = FALSE;
394f1db5ef7SJung-uk Kim             AcpiGbl_CaptureComments = TRUE;
3950d84335fSJung-uk Kim             AcpiGbl_DoDisassemblerOptimizations = FALSE;
3960d84335fSJung-uk Kim             AcpiGbl_DmEmitExternalOpcodes = TRUE;
3976f1f1a63SJung-uk Kim             AslGbl_DoExternalsInPlace = TRUE;
3980d84335fSJung-uk Kim 
3990d84335fSJung-uk Kim             return (0);
4000d84335fSJung-uk Kim 
401a9d8d09cSJung-uk Kim         case 'r':
402a9d8d09cSJung-uk Kim 
4036f1f1a63SJung-uk Kim             AslGbl_NoResourceChecking = TRUE;
404a9d8d09cSJung-uk Kim             break;
405a9d8d09cSJung-uk Kim 
406a9d8d09cSJung-uk Kim         default:
407a9d8d09cSJung-uk Kim 
408a9d8d09cSJung-uk Kim             printf ("Unknown option: -c%s\n", AcpiGbl_Optarg);
409a9d8d09cSJung-uk Kim             return (-1);
410a9d8d09cSJung-uk Kim         }
411a9d8d09cSJung-uk Kim         break;
412a9d8d09cSJung-uk Kim 
413a9d8d09cSJung-uk Kim     case 'd':   /* Disassembler */
414a9d8d09cSJung-uk Kim 
415a9d8d09cSJung-uk Kim         switch (AcpiGbl_Optarg[0])
416a9d8d09cSJung-uk Kim         {
417a9d8d09cSJung-uk Kim         case '^':
418a9d8d09cSJung-uk Kim 
4196f1f1a63SJung-uk Kim             AslGbl_DoCompile = FALSE;
420a9d8d09cSJung-uk Kim             break;
421a9d8d09cSJung-uk Kim 
422a9d8d09cSJung-uk Kim         case 'a':
423a9d8d09cSJung-uk Kim 
4246f1f1a63SJung-uk Kim             AslGbl_DoCompile = FALSE;
4256f1f1a63SJung-uk Kim             AslGbl_DisassembleAll = TRUE;
426a9d8d09cSJung-uk Kim             break;
427a9d8d09cSJung-uk Kim 
428a9d8d09cSJung-uk Kim         case 'b':   /* Do not convert buffers to resource descriptors */
429a9d8d09cSJung-uk Kim 
430a9d8d09cSJung-uk Kim             AcpiGbl_NoResourceDisassembly = TRUE;
431a9d8d09cSJung-uk Kim             break;
432a9d8d09cSJung-uk Kim 
433a9d8d09cSJung-uk Kim         case 'c':
434a9d8d09cSJung-uk Kim 
435a9d8d09cSJung-uk Kim             break;
436a9d8d09cSJung-uk Kim 
4377cf3e94aSJung-uk Kim         case 'f':
4387cf3e94aSJung-uk Kim 
4397cf3e94aSJung-uk Kim             AcpiGbl_ForceAmlDisassembly = TRUE;
4407cf3e94aSJung-uk Kim             break;
4417cf3e94aSJung-uk Kim 
4421c0e1b6dSJung-uk Kim         case 'l':   /* Use legacy ASL code (not ASL+) for disassembly */
4431c0e1b6dSJung-uk Kim 
4446f1f1a63SJung-uk Kim             AslGbl_DoCompile = FALSE;
4451c0e1b6dSJung-uk Kim             AcpiGbl_CstyleDisassembly = FALSE;
4461c0e1b6dSJung-uk Kim             break;
4471c0e1b6dSJung-uk Kim 
448*9a4bc520SJung-uk Kim         case 's':   /* Specify table signature (Only supported for CDAT table) */
449*9a4bc520SJung-uk Kim 
450*9a4bc520SJung-uk Kim             /* Get the required argument */
451*9a4bc520SJung-uk Kim 
452*9a4bc520SJung-uk Kim             if (AcpiGetoptArgument (argc, argv))
453*9a4bc520SJung-uk Kim             {
454*9a4bc520SJung-uk Kim                 return (-1);
455*9a4bc520SJung-uk Kim             }
456*9a4bc520SJung-uk Kim 
457*9a4bc520SJung-uk Kim             /* Check for exact string "CDAT" (upper or lower case) */
458*9a4bc520SJung-uk Kim 
459*9a4bc520SJung-uk Kim             AcpiGbl_CDAT = ACPI_CAST_PTR (char, &AcpiGbl_Optarg);
460*9a4bc520SJung-uk Kim             if (AcpiUtStricmp (AcpiGbl_Optarg, ACPI_SIG_CDAT))
461*9a4bc520SJung-uk Kim             {
462*9a4bc520SJung-uk Kim                 printf ("\nUnknown table signature: %s\n", AcpiGbl_Optarg);
463*9a4bc520SJung-uk Kim                 return (-1);
464*9a4bc520SJung-uk Kim             }
465*9a4bc520SJung-uk Kim 
466*9a4bc520SJung-uk Kim             AcpiGbl_CDAT = malloc (5);
467*9a4bc520SJung-uk Kim             AcpiUtSafeStrncpy ((char *) AcpiGbl_CDAT, ACPI_SIG_CDAT, 5);
468*9a4bc520SJung-uk Kim             break;
469*9a4bc520SJung-uk Kim 
470a9d8d09cSJung-uk Kim         default:
471a9d8d09cSJung-uk Kim 
472a9d8d09cSJung-uk Kim             printf ("Unknown option: -d%s\n", AcpiGbl_Optarg);
473a9d8d09cSJung-uk Kim             return (-1);
474a9d8d09cSJung-uk Kim         }
475a9d8d09cSJung-uk Kim 
476af051161SJung-uk Kim         AcpiGbl_DisasmFlag = TRUE;
477a9d8d09cSJung-uk Kim         break;
478a9d8d09cSJung-uk Kim 
479a9d8d09cSJung-uk Kim     case 'D':   /* Define a symbol */
480a9d8d09cSJung-uk Kim 
481a9d8d09cSJung-uk Kim         PrAddDefine (AcpiGbl_Optarg, NULL, TRUE);
482a9d8d09cSJung-uk Kim         break;
483a9d8d09cSJung-uk Kim 
484a9d8d09cSJung-uk Kim     case 'e':   /* External files for disassembler */
485a9d8d09cSJung-uk Kim 
486313a0c13SJung-uk Kim         /* Get entire list of external files */
487313a0c13SJung-uk Kim 
488313a0c13SJung-uk Kim         AcpiGbl_Optind--;
489313a0c13SJung-uk Kim         argv[AcpiGbl_Optind] = AcpiGbl_Optarg;
490313a0c13SJung-uk Kim 
491313a0c13SJung-uk Kim         while (argv[AcpiGbl_Optind] &&
492313a0c13SJung-uk Kim               (argv[AcpiGbl_Optind][0] != '-'))
493313a0c13SJung-uk Kim         {
494313a0c13SJung-uk Kim             Status = AcpiDmAddToExternalFileList (argv[AcpiGbl_Optind]);
495a9d8d09cSJung-uk Kim             if (ACPI_FAILURE (Status))
496a9d8d09cSJung-uk Kim             {
497f8146b88SJung-uk Kim                 printf ("Could not add %s to external list\n",
498f8146b88SJung-uk Kim                     argv[AcpiGbl_Optind]);
499a9d8d09cSJung-uk Kim                 return (-1);
500a9d8d09cSJung-uk Kim             }
501313a0c13SJung-uk Kim 
502313a0c13SJung-uk Kim             AcpiGbl_Optind++;
503313a0c13SJung-uk Kim         }
504a9d8d09cSJung-uk Kim         break;
505a9d8d09cSJung-uk Kim 
50679c6d946SJung-uk Kim     case 'f':
50779c6d946SJung-uk Kim 
50879c6d946SJung-uk Kim         switch (AcpiGbl_Optarg[0])
50979c6d946SJung-uk Kim         {
51079c6d946SJung-uk Kim         case '^':   /* Ignore errors and force creation of aml file */
511a9d8d09cSJung-uk Kim 
5126f1f1a63SJung-uk Kim             AslGbl_IgnoreErrors = TRUE;
513a9d8d09cSJung-uk Kim             break;
514a9d8d09cSJung-uk Kim 
51579c6d946SJung-uk Kim         case 'e':   /* Disassembler: Get external declaration file */
51679c6d946SJung-uk Kim 
51779c6d946SJung-uk Kim             if (AcpiGetoptArgument (argc, argv))
51879c6d946SJung-uk Kim             {
51979c6d946SJung-uk Kim                 return (-1);
52079c6d946SJung-uk Kim             }
52179c6d946SJung-uk Kim 
5226f1f1a63SJung-uk Kim             AslGbl_ExternalRefFilename = AcpiGbl_Optarg;
52379c6d946SJung-uk Kim             break;
52479c6d946SJung-uk Kim 
52579c6d946SJung-uk Kim         default:
52679c6d946SJung-uk Kim 
52779c6d946SJung-uk Kim             printf ("Unknown option: -f%s\n", AcpiGbl_Optarg);
52879c6d946SJung-uk Kim             return (-1);
52979c6d946SJung-uk Kim         }
53079c6d946SJung-uk Kim         break;
53179c6d946SJung-uk Kim 
532a9d8d09cSJung-uk Kim     case 'G':
533a9d8d09cSJung-uk Kim 
5346f1f1a63SJung-uk Kim         AslGbl_CompileGeneric = TRUE;
535a9d8d09cSJung-uk Kim         break;
536a9d8d09cSJung-uk Kim 
537a9d8d09cSJung-uk Kim     case 'g':   /* Get all ACPI tables */
538a9d8d09cSJung-uk Kim 
539313a0c13SJung-uk Kim         printf ("-g option is deprecated, use acpidump utility instead\n");
540313a0c13SJung-uk Kim         exit (1);
541a9d8d09cSJung-uk Kim 
542a9d8d09cSJung-uk Kim     case 'h':
543a9d8d09cSJung-uk Kim 
544a9d8d09cSJung-uk Kim         switch (AcpiGbl_Optarg[0])
545a9d8d09cSJung-uk Kim         {
546a9d8d09cSJung-uk Kim         case '^':
547a9d8d09cSJung-uk Kim 
548a9d8d09cSJung-uk Kim             Usage ();
549a9d8d09cSJung-uk Kim             exit (0);
550a9d8d09cSJung-uk Kim 
551a9d8d09cSJung-uk Kim         case 'c':
552a9d8d09cSJung-uk Kim 
553a9d8d09cSJung-uk Kim             UtDisplayConstantOpcodes ();
554a9d8d09cSJung-uk Kim             exit (0);
555a9d8d09cSJung-uk Kim 
556493deb39SJung-uk Kim         case 'd':
557493deb39SJung-uk Kim 
558493deb39SJung-uk Kim             AslDisassemblyHelp ();
559493deb39SJung-uk Kim             exit (0);
560493deb39SJung-uk Kim 
561a9d8d09cSJung-uk Kim         case 'f':
562a9d8d09cSJung-uk Kim 
563a9d8d09cSJung-uk Kim             AslFilenameHelp ();
564a9d8d09cSJung-uk Kim             exit (0);
565a9d8d09cSJung-uk Kim 
566a9d8d09cSJung-uk Kim         case 'r':
567a9d8d09cSJung-uk Kim 
568a9d8d09cSJung-uk Kim             /* reserved names */
569a9d8d09cSJung-uk Kim 
570a9d8d09cSJung-uk Kim             ApDisplayReservedNames ();
571a9d8d09cSJung-uk Kim             exit (0);
572a9d8d09cSJung-uk Kim 
573a9d8d09cSJung-uk Kim         case 't':
574a9d8d09cSJung-uk Kim 
575a9d8d09cSJung-uk Kim             UtDisplaySupportedTables ();
576a9d8d09cSJung-uk Kim             exit (0);
577a9d8d09cSJung-uk Kim 
578a9d8d09cSJung-uk Kim         default:
579a9d8d09cSJung-uk Kim 
580a9d8d09cSJung-uk Kim             printf ("Unknown option: -h%s\n", AcpiGbl_Optarg);
581a9d8d09cSJung-uk Kim             return (-1);
582a9d8d09cSJung-uk Kim         }
583a9d8d09cSJung-uk Kim 
584a9d8d09cSJung-uk Kim     case 'I':   /* Add an include file search directory */
585a9d8d09cSJung-uk Kim 
586a9d8d09cSJung-uk Kim         FlAddIncludeDirectory (AcpiGbl_Optarg);
587a9d8d09cSJung-uk Kim         break;
588a9d8d09cSJung-uk Kim 
589a9d8d09cSJung-uk Kim     case 'i':   /* Output AML as an include file */
590a9d8d09cSJung-uk Kim 
591a9d8d09cSJung-uk Kim         switch (AcpiGbl_Optarg[0])
592a9d8d09cSJung-uk Kim         {
593a9d8d09cSJung-uk Kim         case 'a':
594a9d8d09cSJung-uk Kim 
595a9d8d09cSJung-uk Kim             /* Produce assembly code include file */
596a9d8d09cSJung-uk Kim 
5976f1f1a63SJung-uk Kim             AslGbl_AsmIncludeOutputFlag = TRUE;
598a9d8d09cSJung-uk Kim             break;
599a9d8d09cSJung-uk Kim 
600a9d8d09cSJung-uk Kim         case 'c':
601a9d8d09cSJung-uk Kim 
602a9d8d09cSJung-uk Kim             /* Produce C include file */
603a9d8d09cSJung-uk Kim 
6046f1f1a63SJung-uk Kim             AslGbl_C_IncludeOutputFlag = TRUE;
605a9d8d09cSJung-uk Kim             break;
606a9d8d09cSJung-uk Kim 
607a9d8d09cSJung-uk Kim         case 'n':
608a9d8d09cSJung-uk Kim 
609a9d8d09cSJung-uk Kim             /* Compiler/Disassembler: Ignore the NOOP operator */
610a9d8d09cSJung-uk Kim 
611a9d8d09cSJung-uk Kim             AcpiGbl_IgnoreNoopOperator = TRUE;
612a9d8d09cSJung-uk Kim             break;
613a9d8d09cSJung-uk Kim 
614a9d8d09cSJung-uk Kim         default:
615a9d8d09cSJung-uk Kim 
616a9d8d09cSJung-uk Kim             printf ("Unknown option: -i%s\n", AcpiGbl_Optarg);
617a9d8d09cSJung-uk Kim             return (-1);
618a9d8d09cSJung-uk Kim         }
619a9d8d09cSJung-uk Kim         break;
620a9d8d09cSJung-uk Kim 
621a9d8d09cSJung-uk Kim     case 'l':   /* Listing files */
622a9d8d09cSJung-uk Kim 
623a9d8d09cSJung-uk Kim         switch (AcpiGbl_Optarg[0])
624a9d8d09cSJung-uk Kim         {
625a9d8d09cSJung-uk Kim         case '^':
626a9d8d09cSJung-uk Kim 
627a9d8d09cSJung-uk Kim             /* Produce listing file (Mixed source/aml) */
628a9d8d09cSJung-uk Kim 
6296f1f1a63SJung-uk Kim             AslGbl_ListingFlag = TRUE;
63070e6ab8fSJung-uk Kim             AcpiGbl_DmOpt_Listing = TRUE;
631a9d8d09cSJung-uk Kim             break;
632a9d8d09cSJung-uk Kim 
633a9d8d09cSJung-uk Kim         case 'i':
634a9d8d09cSJung-uk Kim 
635a9d8d09cSJung-uk Kim             /* Produce preprocessor output file */
636a9d8d09cSJung-uk Kim 
6376f1f1a63SJung-uk Kim             AslGbl_PreprocessorOutputFlag = TRUE;
638a9d8d09cSJung-uk Kim             break;
639a9d8d09cSJung-uk Kim 
640313a0c13SJung-uk Kim         case 'm':
641313a0c13SJung-uk Kim 
642313a0c13SJung-uk Kim             /* Produce hardware map summary file */
643313a0c13SJung-uk Kim 
6446f1f1a63SJung-uk Kim             AslGbl_MapfileFlag = TRUE;
645313a0c13SJung-uk Kim             break;
646313a0c13SJung-uk Kim 
647a9d8d09cSJung-uk Kim         case 'n':
648a9d8d09cSJung-uk Kim 
649a9d8d09cSJung-uk Kim             /* Produce namespace file */
650a9d8d09cSJung-uk Kim 
6516f1f1a63SJung-uk Kim             AslGbl_NsOutputFlag = TRUE;
652a9d8d09cSJung-uk Kim             break;
653a9d8d09cSJung-uk Kim 
654a9d8d09cSJung-uk Kim         case 's':
655a9d8d09cSJung-uk Kim 
656a9d8d09cSJung-uk Kim             /* Produce combined source file */
657a9d8d09cSJung-uk Kim 
6586f1f1a63SJung-uk Kim             AslGbl_SourceOutputFlag = TRUE;
659a9d8d09cSJung-uk Kim             break;
660a9d8d09cSJung-uk Kim 
661f8146b88SJung-uk Kim         case 'x':
662f8146b88SJung-uk Kim 
663f8146b88SJung-uk Kim             /* Produce cross-reference file */
664f8146b88SJung-uk Kim 
6656f1f1a63SJung-uk Kim             AslGbl_CrossReferenceOutput = TRUE;
666f8146b88SJung-uk Kim             break;
667f8146b88SJung-uk Kim 
668a9d8d09cSJung-uk Kim         default:
669a9d8d09cSJung-uk Kim 
670a9d8d09cSJung-uk Kim             printf ("Unknown option: -l%s\n", AcpiGbl_Optarg);
671a9d8d09cSJung-uk Kim             return (-1);
672a9d8d09cSJung-uk Kim         }
673a9d8d09cSJung-uk Kim         break;
674a9d8d09cSJung-uk Kim 
675a9d8d09cSJung-uk Kim     case 'm':   /* Set line buffer size */
676a9d8d09cSJung-uk Kim 
6776f1f1a63SJung-uk Kim         AslGbl_LineBufferSize = (UINT32) strtoul (AcpiGbl_Optarg, NULL, 0) * 1024;
6786f1f1a63SJung-uk Kim         if (AslGbl_LineBufferSize < ASL_DEFAULT_LINE_BUFFER_SIZE)
679a9d8d09cSJung-uk Kim         {
6806f1f1a63SJung-uk Kim             AslGbl_LineBufferSize = ASL_DEFAULT_LINE_BUFFER_SIZE;
681a9d8d09cSJung-uk Kim         }
6826f1f1a63SJung-uk Kim         printf ("Line Buffer Size: %u\n", AslGbl_LineBufferSize);
683a9d8d09cSJung-uk Kim         break;
684a9d8d09cSJung-uk Kim 
685a9d8d09cSJung-uk Kim     case 'n':   /* Parse only */
686a9d8d09cSJung-uk Kim 
6876f1f1a63SJung-uk Kim         AslGbl_ParseOnlyFlag = TRUE;
688a9d8d09cSJung-uk Kim         break;
689a9d8d09cSJung-uk Kim 
690a9d8d09cSJung-uk Kim     case 'o':   /* Control compiler AML optimizations */
691a9d8d09cSJung-uk Kim 
692a9d8d09cSJung-uk Kim         switch (AcpiGbl_Optarg[0])
693a9d8d09cSJung-uk Kim         {
694a9d8d09cSJung-uk Kim         case 'a':
695a9d8d09cSJung-uk Kim 
696a9d8d09cSJung-uk Kim             /* Disable all optimizations */
697a9d8d09cSJung-uk Kim 
6986f1f1a63SJung-uk Kim             AslGbl_FoldConstants = FALSE;
6996f1f1a63SJung-uk Kim             AslGbl_IntegerOptimizationFlag = FALSE;
7006f1f1a63SJung-uk Kim             AslGbl_ReferenceOptimizationFlag = FALSE;
7016f1f1a63SJung-uk Kim             AslGbl_OptimizeTrivialParseNodes = FALSE;
7020d84335fSJung-uk Kim 
703a9d8d09cSJung-uk Kim             break;
704a9d8d09cSJung-uk Kim 
705f8146b88SJung-uk Kim         case 'c':
706f8146b88SJung-uk Kim 
707f8146b88SJung-uk Kim             /* Display compile time(s) */
708f8146b88SJung-uk Kim 
7096f1f1a63SJung-uk Kim             AslGbl_CompileTimesFlag = TRUE;
710f8146b88SJung-uk Kim             break;
711f8146b88SJung-uk Kim 
712493deb39SJung-uk Kim         case 'd':
713493deb39SJung-uk Kim 
714493deb39SJung-uk Kim             /* Disable disassembler code optimizations */
715493deb39SJung-uk Kim 
716493deb39SJung-uk Kim             AcpiGbl_DoDisassemblerOptimizations = FALSE;
717493deb39SJung-uk Kim             break;
718493deb39SJung-uk Kim 
719f8146b88SJung-uk Kim         case 'e':
720f8146b88SJung-uk Kim 
7213920312eSJung-uk Kim             /* Disassembler: Emit embedded external operators */
7223920312eSJung-uk Kim 
7233920312eSJung-uk Kim             AcpiGbl_DmEmitExternalOpcodes = TRUE;
724f8146b88SJung-uk Kim             break;
725f8146b88SJung-uk Kim 
7260d84335fSJung-uk Kim         case 'E':
7270d84335fSJung-uk Kim 
7280d84335fSJung-uk Kim             /*
7290d84335fSJung-uk Kim              * iASL: keep External opcodes in place.
7300d84335fSJung-uk Kim              * No affect if Gbl_DoExternals is false.
7310d84335fSJung-uk Kim              */
7320d84335fSJung-uk Kim 
7336f1f1a63SJung-uk Kim             AslGbl_DoExternalsInPlace = TRUE;
7340d84335fSJung-uk Kim             break;
7350d84335fSJung-uk Kim 
736a9d8d09cSJung-uk Kim         case 'f':
737a9d8d09cSJung-uk Kim 
738a9d8d09cSJung-uk Kim             /* Disable folding on "normal" expressions */
739a9d8d09cSJung-uk Kim 
7406f1f1a63SJung-uk Kim             AslGbl_FoldConstants = FALSE;
741a9d8d09cSJung-uk Kim             break;
742a9d8d09cSJung-uk Kim 
743a9d8d09cSJung-uk Kim         case 'i':
744a9d8d09cSJung-uk Kim 
745a9d8d09cSJung-uk Kim             /* Disable integer optimization to constants */
746a9d8d09cSJung-uk Kim 
7476f1f1a63SJung-uk Kim             AslGbl_IntegerOptimizationFlag = FALSE;
748a9d8d09cSJung-uk Kim             break;
749a9d8d09cSJung-uk Kim 
750a9d8d09cSJung-uk Kim         case 'n':
751a9d8d09cSJung-uk Kim 
752a9d8d09cSJung-uk Kim             /* Disable named reference optimization */
753a9d8d09cSJung-uk Kim 
7546f1f1a63SJung-uk Kim             AslGbl_ReferenceOptimizationFlag = FALSE;
755a9d8d09cSJung-uk Kim             break;
756a9d8d09cSJung-uk Kim 
757a9d8d09cSJung-uk Kim         case 't':
758a9d8d09cSJung-uk Kim 
759f8146b88SJung-uk Kim             /* Disable heavy typechecking */
760a9d8d09cSJung-uk Kim 
7616f1f1a63SJung-uk Kim             AslGbl_DoTypechecking = FALSE;
762a9d8d09cSJung-uk Kim             break;
763a9d8d09cSJung-uk Kim 
764a9d8d09cSJung-uk Kim         default:
765a9d8d09cSJung-uk Kim 
766a9d8d09cSJung-uk Kim             printf ("Unknown option: -c%s\n", AcpiGbl_Optarg);
767a9d8d09cSJung-uk Kim             return (-1);
768a9d8d09cSJung-uk Kim         }
769a9d8d09cSJung-uk Kim         break;
770a9d8d09cSJung-uk Kim 
771a9d8d09cSJung-uk Kim     case 'P':   /* Preprocessor options */
772a9d8d09cSJung-uk Kim 
773a9d8d09cSJung-uk Kim         switch (AcpiGbl_Optarg[0])
774a9d8d09cSJung-uk Kim         {
775a9d8d09cSJung-uk Kim         case '^':   /* Proprocess only, emit (.i) file */
776a9d8d09cSJung-uk Kim 
7776f1f1a63SJung-uk Kim             AslGbl_PreprocessOnly = TRUE;
7786f1f1a63SJung-uk Kim             AslGbl_PreprocessorOutputFlag = TRUE;
779a9d8d09cSJung-uk Kim             break;
780a9d8d09cSJung-uk Kim 
781a9d8d09cSJung-uk Kim         case 'n':   /* Disable preprocessor */
782a9d8d09cSJung-uk Kim 
7836f1f1a63SJung-uk Kim             AslGbl_PreprocessFlag = FALSE;
784a9d8d09cSJung-uk Kim             break;
785a9d8d09cSJung-uk Kim 
786a9d8d09cSJung-uk Kim         default:
787a9d8d09cSJung-uk Kim 
788a9d8d09cSJung-uk Kim             printf ("Unknown option: -P%s\n", AcpiGbl_Optarg);
789a9d8d09cSJung-uk Kim             return (-1);
790a9d8d09cSJung-uk Kim         }
791a9d8d09cSJung-uk Kim         break;
792a9d8d09cSJung-uk Kim 
793a9d8d09cSJung-uk Kim     case 'p':   /* Override default AML output filename */
794a9d8d09cSJung-uk Kim 
7956f1f1a63SJung-uk Kim         AslGbl_OutputFilenamePrefix = AcpiGbl_Optarg;
7966f1f1a63SJung-uk Kim         UtConvertBackslashes (AslGbl_OutputFilenamePrefix);
7976f1f1a63SJung-uk Kim         AslGbl_UseDefaultAmlFilename = FALSE;
798a9d8d09cSJung-uk Kim         break;
799a9d8d09cSJung-uk Kim 
8000d84335fSJung-uk Kim     case 'q':   /* ASL/ASl+ converter: compile only and leave badaml. */
8010d84335fSJung-uk Kim 
8020d84335fSJung-uk Kim         printf ("Convert ASL to ASL+ with comments\n");
8036f1f1a63SJung-uk Kim         AslGbl_FoldConstants = FALSE;
8046f1f1a63SJung-uk Kim         AslGbl_IntegerOptimizationFlag = FALSE;
8056f1f1a63SJung-uk Kim         AslGbl_ReferenceOptimizationFlag = FALSE;
8066f1f1a63SJung-uk Kim         AslGbl_OptimizeTrivialParseNodes = FALSE;
8076f1f1a63SJung-uk Kim         AslGbl_DoExternalsInPlace = TRUE;
808f1db5ef7SJung-uk Kim         AcpiGbl_CaptureComments = TRUE;
8090d84335fSJung-uk Kim         return (0);
8100d84335fSJung-uk Kim 
811a9d8d09cSJung-uk Kim     case 'r':   /* Override revision found in table header */
812a9d8d09cSJung-uk Kim 
8136f1f1a63SJung-uk Kim         AslGbl_RevisionOverride = (UINT8) strtoul (AcpiGbl_Optarg, NULL, 0);
814a9d8d09cSJung-uk Kim         break;
815a9d8d09cSJung-uk Kim 
816a9d8d09cSJung-uk Kim     case 's':   /* Create AML in a source code file */
817a9d8d09cSJung-uk Kim 
818a9d8d09cSJung-uk Kim         switch (AcpiGbl_Optarg[0])
819a9d8d09cSJung-uk Kim         {
820a9d8d09cSJung-uk Kim         case 'a':
821a9d8d09cSJung-uk Kim 
822a9d8d09cSJung-uk Kim             /* Produce assembly code output file */
823a9d8d09cSJung-uk Kim 
8246f1f1a63SJung-uk Kim             AslGbl_AsmOutputFlag = TRUE;
825a9d8d09cSJung-uk Kim             break;
826a9d8d09cSJung-uk Kim 
827a9d8d09cSJung-uk Kim         case 'c':
828a9d8d09cSJung-uk Kim 
829a9d8d09cSJung-uk Kim             /* Produce C hex output file */
830a9d8d09cSJung-uk Kim 
8316f1f1a63SJung-uk Kim             AslGbl_C_OutputFlag = TRUE;
832a9d8d09cSJung-uk Kim             break;
833a9d8d09cSJung-uk Kim 
834a9d8d09cSJung-uk Kim         case 'o':
835a9d8d09cSJung-uk Kim 
836a9d8d09cSJung-uk Kim             /* Produce AML offset table in C */
837a9d8d09cSJung-uk Kim 
8386f1f1a63SJung-uk Kim             AslGbl_C_OffsetTableFlag = TRUE;
839a9d8d09cSJung-uk Kim             break;
840a9d8d09cSJung-uk Kim 
841a9d8d09cSJung-uk Kim         default:
842a9d8d09cSJung-uk Kim 
843a9d8d09cSJung-uk Kim             printf ("Unknown option: -s%s\n", AcpiGbl_Optarg);
844a9d8d09cSJung-uk Kim             return (-1);
845a9d8d09cSJung-uk Kim         }
846a9d8d09cSJung-uk Kim         break;
847a9d8d09cSJung-uk Kim 
848a9d8d09cSJung-uk Kim     case 't':   /* Produce hex table output file */
849a9d8d09cSJung-uk Kim 
850a9d8d09cSJung-uk Kim         switch (AcpiGbl_Optarg[0])
851a9d8d09cSJung-uk Kim         {
852a9d8d09cSJung-uk Kim         case 'a':
853a9d8d09cSJung-uk Kim 
8546f1f1a63SJung-uk Kim             AslGbl_HexOutputFlag = HEX_OUTPUT_ASM;
855a9d8d09cSJung-uk Kim             break;
856a9d8d09cSJung-uk Kim 
857a9d8d09cSJung-uk Kim         case 'c':
858a9d8d09cSJung-uk Kim 
8596f1f1a63SJung-uk Kim             AslGbl_HexOutputFlag = HEX_OUTPUT_C;
860a9d8d09cSJung-uk Kim             break;
861a9d8d09cSJung-uk Kim 
862a009b7dcSJung-uk Kim         case 'p': /* data table flex/bison prototype */
863a009b7dcSJung-uk Kim 
864a009b7dcSJung-uk Kim             AslGbl_DtLexBisonPrototype = TRUE;
865a009b7dcSJung-uk Kim             break;
866a009b7dcSJung-uk Kim 
867a9d8d09cSJung-uk Kim         case 's':
868a9d8d09cSJung-uk Kim 
8696f1f1a63SJung-uk Kim             AslGbl_HexOutputFlag = HEX_OUTPUT_ASL;
870a9d8d09cSJung-uk Kim             break;
871a9d8d09cSJung-uk Kim 
872a9d8d09cSJung-uk Kim         default:
873a9d8d09cSJung-uk Kim 
874a9d8d09cSJung-uk Kim             printf ("Unknown option: -t%s\n", AcpiGbl_Optarg);
875a9d8d09cSJung-uk Kim             return (-1);
876a9d8d09cSJung-uk Kim         }
877a9d8d09cSJung-uk Kim         break;
878a9d8d09cSJung-uk Kim 
879a9d8d09cSJung-uk Kim     case 'T':   /* Create a ACPI table template file */
880a9d8d09cSJung-uk Kim 
8816f1f1a63SJung-uk Kim         AslGbl_DoTemplates = TRUE;
882a9d8d09cSJung-uk Kim         break;
883a9d8d09cSJung-uk Kim 
884a9d8d09cSJung-uk Kim     case 'v':   /* Version and verbosity settings */
885a9d8d09cSJung-uk Kim 
886a9d8d09cSJung-uk Kim         switch (AcpiGbl_Optarg[0])
887a9d8d09cSJung-uk Kim         {
888a9d8d09cSJung-uk Kim         case '^':
889a9d8d09cSJung-uk Kim 
890a9d8d09cSJung-uk Kim             printf (ACPI_COMMON_SIGNON (ASL_COMPILER_NAME));
891a9d8d09cSJung-uk Kim             exit (0);
892a9d8d09cSJung-uk Kim 
893a9d8d09cSJung-uk Kim         case 'a':
894a9d8d09cSJung-uk Kim 
895313a0c13SJung-uk Kim             /* Disable all error/warning/remark messages */
896a9d8d09cSJung-uk Kim 
8976f1f1a63SJung-uk Kim             AslGbl_NoErrors = TRUE;
898a9d8d09cSJung-uk Kim             break;
899a9d8d09cSJung-uk Kim 
900313a0c13SJung-uk Kim         case 'e':
901313a0c13SJung-uk Kim 
902313a0c13SJung-uk Kim             /* Disable all warning/remark messages (errors only) */
903313a0c13SJung-uk Kim 
9046f1f1a63SJung-uk Kim             AslGbl_DisplayRemarks = FALSE;
9056f1f1a63SJung-uk Kim             AslGbl_DisplayWarnings = FALSE;
906313a0c13SJung-uk Kim             break;
907313a0c13SJung-uk Kim 
908a9d8d09cSJung-uk Kim         case 'i':
909a9d8d09cSJung-uk Kim             /*
910a9d8d09cSJung-uk Kim              * Support for integrated development environment(s).
911a9d8d09cSJung-uk Kim              *
912a9d8d09cSJung-uk Kim              * 1) No compiler signon
913a9d8d09cSJung-uk Kim              * 2) Send stderr messages to stdout
914a9d8d09cSJung-uk Kim              * 3) Less verbose error messages (single line only for each)
915a9d8d09cSJung-uk Kim              * 4) Error/warning messages are formatted appropriately to
916a9d8d09cSJung-uk Kim              *    be recognized by MS Visual Studio
917a9d8d09cSJung-uk Kim              */
9186f1f1a63SJung-uk Kim             AslGbl_VerboseErrors = FALSE;
9196f1f1a63SJung-uk Kim             AslGbl_DoSignon = FALSE;
920a9d8d09cSJung-uk Kim             break;
921a9d8d09cSJung-uk Kim 
922a9d8d09cSJung-uk Kim         case 'o':
923a9d8d09cSJung-uk Kim 
9246f1f1a63SJung-uk Kim             AslGbl_DisplayOptimizations = TRUE;
925a9d8d09cSJung-uk Kim             break;
926a9d8d09cSJung-uk Kim 
927a9d8d09cSJung-uk Kim         case 'r':
928a9d8d09cSJung-uk Kim 
9296f1f1a63SJung-uk Kim             AslGbl_DisplayRemarks = FALSE;
930a9d8d09cSJung-uk Kim             break;
931a9d8d09cSJung-uk Kim 
932a9d8d09cSJung-uk Kim         case 's':
933a9d8d09cSJung-uk Kim 
9346f1f1a63SJung-uk Kim             AslGbl_DoSignon = FALSE;
935a9d8d09cSJung-uk Kim             break;
936a9d8d09cSJung-uk Kim 
937a9d8d09cSJung-uk Kim         case 't':
938a9d8d09cSJung-uk Kim 
9396f1f1a63SJung-uk Kim             AslGbl_VerboseTemplates = TRUE;
940a9d8d09cSJung-uk Kim             break;
941a9d8d09cSJung-uk Kim 
942a9d8d09cSJung-uk Kim         case 'w':
943a9d8d09cSJung-uk Kim 
944a9d8d09cSJung-uk Kim             /* Get the required argument */
945a9d8d09cSJung-uk Kim 
946a9d8d09cSJung-uk Kim             if (AcpiGetoptArgument (argc, argv))
947a9d8d09cSJung-uk Kim             {
948a9d8d09cSJung-uk Kim                 return (-1);
949a9d8d09cSJung-uk Kim             }
950a9d8d09cSJung-uk Kim 
951a9d8d09cSJung-uk Kim             Status = AslDisableException (AcpiGbl_Optarg);
952a9d8d09cSJung-uk Kim             if (ACPI_FAILURE (Status))
953a9d8d09cSJung-uk Kim             {
954a9d8d09cSJung-uk Kim                 return (-1);
955a9d8d09cSJung-uk Kim             }
956a9d8d09cSJung-uk Kim             break;
957a9d8d09cSJung-uk Kim 
9585f9b24faSJung-uk Kim         case 'x':
9595f9b24faSJung-uk Kim 
9605f9b24faSJung-uk Kim             /* Get the required argument */
9615f9b24faSJung-uk Kim 
9625f9b24faSJung-uk Kim             if (AcpiGetoptArgument (argc, argv))
9635f9b24faSJung-uk Kim             {
9645f9b24faSJung-uk Kim                 return (-1);
9655f9b24faSJung-uk Kim             }
9665f9b24faSJung-uk Kim 
9673ee58df5SJung-uk Kim             Status = AslLogExpectedException (AcpiGbl_Optarg);
9685f9b24faSJung-uk Kim             if (ACPI_FAILURE (Status))
9695f9b24faSJung-uk Kim             {
9705f9b24faSJung-uk Kim                 return (-1);
9715f9b24faSJung-uk Kim             }
9725f9b24faSJung-uk Kim             break;
9735f9b24faSJung-uk Kim 
974a9d8d09cSJung-uk Kim         default:
975a9d8d09cSJung-uk Kim 
976a9d8d09cSJung-uk Kim             printf ("Unknown option: -v%s\n", AcpiGbl_Optarg);
977a9d8d09cSJung-uk Kim             return (-1);
978a9d8d09cSJung-uk Kim         }
979a9d8d09cSJung-uk Kim         break;
980a9d8d09cSJung-uk Kim 
981a9d8d09cSJung-uk Kim     case 'w': /* Set warning levels */
982a9d8d09cSJung-uk Kim 
983a9d8d09cSJung-uk Kim         switch (AcpiGbl_Optarg[0])
984a9d8d09cSJung-uk Kim         {
985a9d8d09cSJung-uk Kim         case '1':
986a9d8d09cSJung-uk Kim 
9876f1f1a63SJung-uk Kim             AslGbl_WarningLevel = ASL_WARNING;
988a9d8d09cSJung-uk Kim             break;
989a9d8d09cSJung-uk Kim 
990a9d8d09cSJung-uk Kim         case '2':
991a9d8d09cSJung-uk Kim 
9926f1f1a63SJung-uk Kim             AslGbl_WarningLevel = ASL_WARNING2;
993a9d8d09cSJung-uk Kim             break;
994a9d8d09cSJung-uk Kim 
995a9d8d09cSJung-uk Kim         case '3':
996a9d8d09cSJung-uk Kim 
9976f1f1a63SJung-uk Kim             AslGbl_WarningLevel = ASL_WARNING3;
998a9d8d09cSJung-uk Kim             break;
999a9d8d09cSJung-uk Kim 
1000a9d8d09cSJung-uk Kim         case 'e':
1001a9d8d09cSJung-uk Kim 
10026f1f1a63SJung-uk Kim             AslGbl_WarningsAsErrors = TRUE;
1003a9d8d09cSJung-uk Kim             break;
1004a9d8d09cSJung-uk Kim 
100590b566fdSJung-uk Kim         case 'w':
100690b566fdSJung-uk Kim 
100790b566fdSJung-uk Kim             /* Get the required argument */
100890b566fdSJung-uk Kim 
100990b566fdSJung-uk Kim             if (AcpiGetoptArgument (argc, argv))
101090b566fdSJung-uk Kim             {
101190b566fdSJung-uk Kim                 return (-1);
101290b566fdSJung-uk Kim             }
101390b566fdSJung-uk Kim 
101490b566fdSJung-uk Kim             Status = AslElevateException (AcpiGbl_Optarg);
101590b566fdSJung-uk Kim             if (ACPI_FAILURE (Status))
101690b566fdSJung-uk Kim             {
101790b566fdSJung-uk Kim                 return (-1);
101890b566fdSJung-uk Kim             }
101990b566fdSJung-uk Kim             break;
102090b566fdSJung-uk Kim 
102190b566fdSJung-uk Kim 
1022a9d8d09cSJung-uk Kim         default:
1023a9d8d09cSJung-uk Kim 
1024a9d8d09cSJung-uk Kim             printf ("Unknown option: -w%s\n", AcpiGbl_Optarg);
1025a9d8d09cSJung-uk Kim             return (-1);
1026a9d8d09cSJung-uk Kim         }
1027a9d8d09cSJung-uk Kim         break;
1028a9d8d09cSJung-uk Kim 
1029a9d8d09cSJung-uk Kim     case 'x':   /* Set debug print output level */
1030a9d8d09cSJung-uk Kim 
1031a9d8d09cSJung-uk Kim         AcpiDbgLevel = strtoul (AcpiGbl_Optarg, NULL, 16);
1032a9d8d09cSJung-uk Kim         break;
1033a9d8d09cSJung-uk Kim 
1034a9d8d09cSJung-uk Kim     case 'z':
1035a9d8d09cSJung-uk Kim 
10366f1f1a63SJung-uk Kim         AslGbl_UseOriginalCompilerId = TRUE;
1037a9d8d09cSJung-uk Kim         break;
1038a9d8d09cSJung-uk Kim 
1039a9d8d09cSJung-uk Kim     default:
1040a9d8d09cSJung-uk Kim 
1041a9d8d09cSJung-uk Kim         return (-1);
1042a9d8d09cSJung-uk Kim     }
1043a9d8d09cSJung-uk Kim 
1044a9d8d09cSJung-uk Kim     return (0);
1045a9d8d09cSJung-uk Kim }
1046a9d8d09cSJung-uk Kim 
1047a9d8d09cSJung-uk Kim 
1048a9d8d09cSJung-uk Kim /*******************************************************************************
1049a9d8d09cSJung-uk Kim  *
1050a9d8d09cSJung-uk Kim  * FUNCTION:    AslMergeOptionTokens
1051a9d8d09cSJung-uk Kim  *
1052a9d8d09cSJung-uk Kim  * PARAMETERS:  InBuffer            - Input containing an option string
1053a9d8d09cSJung-uk Kim  *              OutBuffer           - Merged output buffer
1054a9d8d09cSJung-uk Kim  *
1055a9d8d09cSJung-uk Kim  * RETURN:      None
1056a9d8d09cSJung-uk Kim  *
1057a9d8d09cSJung-uk Kim  * DESCRIPTION: Remove all whitespace from an option string.
1058a9d8d09cSJung-uk Kim  *
1059a9d8d09cSJung-uk Kim  ******************************************************************************/
1060a9d8d09cSJung-uk Kim 
1061a9d8d09cSJung-uk Kim static void
1062a9d8d09cSJung-uk Kim AslMergeOptionTokens (
1063a9d8d09cSJung-uk Kim     char                    *InBuffer,
1064a9d8d09cSJung-uk Kim     char                    *OutBuffer)
1065a9d8d09cSJung-uk Kim {
1066a9d8d09cSJung-uk Kim     char                    *Token;
1067a9d8d09cSJung-uk Kim 
1068a9d8d09cSJung-uk Kim 
1069a9d8d09cSJung-uk Kim     *OutBuffer = 0;
1070a9d8d09cSJung-uk Kim 
1071a9d8d09cSJung-uk Kim     Token = strtok (InBuffer, ASL_TOKEN_SEPARATORS);
1072a9d8d09cSJung-uk Kim     while (Token)
1073a9d8d09cSJung-uk Kim     {
1074a9d8d09cSJung-uk Kim         strcat (OutBuffer, Token);
1075a9d8d09cSJung-uk Kim         Token = strtok (NULL, ASL_TOKEN_SEPARATORS);
1076a9d8d09cSJung-uk Kim     }
1077a9d8d09cSJung-uk Kim }
1078a9d8d09cSJung-uk Kim 
1079a9d8d09cSJung-uk Kim 
1080a9d8d09cSJung-uk Kim /*******************************************************************************
1081a9d8d09cSJung-uk Kim  *
1082a9d8d09cSJung-uk Kim  * FUNCTION:    AslDoResponseFile
1083a9d8d09cSJung-uk Kim  *
1084a9d8d09cSJung-uk Kim  * PARAMETERS:  Filename        - Name of the response file
1085a9d8d09cSJung-uk Kim  *
1086a9d8d09cSJung-uk Kim  * RETURN:      Status
1087a9d8d09cSJung-uk Kim  *
1088a9d8d09cSJung-uk Kim  * DESCRIPTION: Open a response file and process all options within.
1089a9d8d09cSJung-uk Kim  *
1090a9d8d09cSJung-uk Kim  ******************************************************************************/
1091a9d8d09cSJung-uk Kim 
1092a9d8d09cSJung-uk Kim static int
1093a9d8d09cSJung-uk Kim AslDoResponseFile (
1094a9d8d09cSJung-uk Kim     char                    *Filename)
1095a9d8d09cSJung-uk Kim {
10966f1f1a63SJung-uk Kim     char                    *argv = AslGbl_StringBuffer2;
1097a9d8d09cSJung-uk Kim     FILE                    *ResponseFile;
1098a9d8d09cSJung-uk Kim     int                     OptStatus = 0;
1099a9d8d09cSJung-uk Kim     int                     Opterr;
1100a9d8d09cSJung-uk Kim     int                     Optind;
1101a9d8d09cSJung-uk Kim 
1102a9d8d09cSJung-uk Kim 
1103a9d8d09cSJung-uk Kim     ResponseFile = fopen (Filename, "r");
1104a9d8d09cSJung-uk Kim     if (!ResponseFile)
1105a9d8d09cSJung-uk Kim     {
1106a9d8d09cSJung-uk Kim         printf ("Could not open command file %s, %s\n",
1107a9d8d09cSJung-uk Kim             Filename, strerror (errno));
1108a9d8d09cSJung-uk Kim         return (-1);
1109a9d8d09cSJung-uk Kim     }
1110a9d8d09cSJung-uk Kim 
1111a9d8d09cSJung-uk Kim     /* Must save the current GetOpt globals */
1112a9d8d09cSJung-uk Kim 
1113a9d8d09cSJung-uk Kim     Opterr = AcpiGbl_Opterr;
1114a9d8d09cSJung-uk Kim     Optind = AcpiGbl_Optind;
1115a9d8d09cSJung-uk Kim 
1116a9d8d09cSJung-uk Kim     /*
1117a9d8d09cSJung-uk Kim      * Process all lines in the response file. There must be one complete
1118a9d8d09cSJung-uk Kim      * option per line
1119a9d8d09cSJung-uk Kim      */
11206f1f1a63SJung-uk Kim     while (fgets (AslGbl_StringBuffer, ASL_STRING_BUFFER_SIZE, ResponseFile))
1121a9d8d09cSJung-uk Kim     {
1122a9d8d09cSJung-uk Kim         /* Compress all tokens, allowing us to use a single argv entry */
1123a9d8d09cSJung-uk Kim 
11246f1f1a63SJung-uk Kim         AslMergeOptionTokens (AslGbl_StringBuffer, AslGbl_StringBuffer2);
1125a9d8d09cSJung-uk Kim 
1126a9d8d09cSJung-uk Kim         /* Process the option */
1127a9d8d09cSJung-uk Kim 
1128a9d8d09cSJung-uk Kim         AcpiGbl_Opterr = 0;
1129a9d8d09cSJung-uk Kim         AcpiGbl_Optind = 0;
1130a9d8d09cSJung-uk Kim 
1131a9d8d09cSJung-uk Kim         OptStatus = AslDoOptions (1, &argv, TRUE);
1132a9d8d09cSJung-uk Kim         if (OptStatus)
1133a9d8d09cSJung-uk Kim         {
1134a9d8d09cSJung-uk Kim             printf ("Invalid option in command file %s: %s\n",
11356f1f1a63SJung-uk Kim                 Filename, AslGbl_StringBuffer);
1136a9d8d09cSJung-uk Kim             break;
1137a9d8d09cSJung-uk Kim         }
1138a9d8d09cSJung-uk Kim     }
1139a9d8d09cSJung-uk Kim 
1140a9d8d09cSJung-uk Kim     /* Restore the GetOpt globals */
1141a9d8d09cSJung-uk Kim 
1142a9d8d09cSJung-uk Kim     AcpiGbl_Opterr = Opterr;
1143a9d8d09cSJung-uk Kim     AcpiGbl_Optind = Optind;
1144a9d8d09cSJung-uk Kim 
1145a9d8d09cSJung-uk Kim     fclose (ResponseFile);
1146a9d8d09cSJung-uk Kim     return (OptStatus);
1147a9d8d09cSJung-uk Kim }
1148