asloptions.c revision 1.20 1 1.1 christos /******************************************************************************
2 1.1 christos *
3 1.1 christos * Module Name: asloptions - compiler command line processing
4 1.1 christos *
5 1.1 christos *****************************************************************************/
6 1.1 christos
7 1.19 christos /******************************************************************************
8 1.19 christos *
9 1.19 christos * 1. Copyright Notice
10 1.19 christos *
11 1.20 christos * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
12 1.1 christos * All rights reserved.
13 1.1 christos *
14 1.19 christos * 2. License
15 1.19 christos *
16 1.19 christos * 2.1. This is your license from Intel Corp. under its intellectual property
17 1.19 christos * rights. You may have additional license terms from the party that provided
18 1.19 christos * you this software, covering your right to use that party's intellectual
19 1.19 christos * property rights.
20 1.19 christos *
21 1.19 christos * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22 1.19 christos * copy of the source code appearing in this file ("Covered Code") an
23 1.19 christos * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24 1.19 christos * base code distributed originally by Intel ("Original Intel Code") to copy,
25 1.19 christos * make derivatives, distribute, use and display any portion of the Covered
26 1.19 christos * Code in any form, with the right to sublicense such rights; and
27 1.19 christos *
28 1.19 christos * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29 1.19 christos * license (with the right to sublicense), under only those claims of Intel
30 1.19 christos * patents that are infringed by the Original Intel Code, to make, use, sell,
31 1.19 christos * offer to sell, and import the Covered Code and derivative works thereof
32 1.19 christos * solely to the minimum extent necessary to exercise the above copyright
33 1.19 christos * license, and in no event shall the patent license extend to any additions
34 1.19 christos * to or modifications of the Original Intel Code. No other license or right
35 1.19 christos * is granted directly or by implication, estoppel or otherwise;
36 1.19 christos *
37 1.19 christos * The above copyright and patent license is granted only if the following
38 1.19 christos * conditions are met:
39 1.19 christos *
40 1.19 christos * 3. Conditions
41 1.19 christos *
42 1.19 christos * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43 1.19 christos * Redistribution of source code of any substantial portion of the Covered
44 1.19 christos * Code or modification with rights to further distribute source must include
45 1.19 christos * the above Copyright Notice, the above License, this list of Conditions,
46 1.19 christos * and the following Disclaimer and Export Compliance provision. In addition,
47 1.19 christos * Licensee must cause all Covered Code to which Licensee contributes to
48 1.19 christos * contain a file documenting the changes Licensee made to create that Covered
49 1.19 christos * Code and the date of any change. Licensee must include in that file the
50 1.19 christos * documentation of any changes made by any predecessor Licensee. Licensee
51 1.19 christos * must include a prominent statement that the modification is derived,
52 1.19 christos * directly or indirectly, from Original Intel Code.
53 1.19 christos *
54 1.19 christos * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55 1.19 christos * Redistribution of source code of any substantial portion of the Covered
56 1.19 christos * Code or modification without rights to further distribute source must
57 1.19 christos * include the following Disclaimer and Export Compliance provision in the
58 1.19 christos * documentation and/or other materials provided with distribution. In
59 1.19 christos * addition, Licensee may not authorize further sublicense of source of any
60 1.19 christos * portion of the Covered Code, and must include terms to the effect that the
61 1.19 christos * license from Licensee to its licensee is limited to the intellectual
62 1.19 christos * property embodied in the software Licensee provides to its licensee, and
63 1.19 christos * not to intellectual property embodied in modifications its licensee may
64 1.19 christos * make.
65 1.19 christos *
66 1.19 christos * 3.3. Redistribution of Executable. Redistribution in executable form of any
67 1.19 christos * substantial portion of the Covered Code or modification must reproduce the
68 1.19 christos * above Copyright Notice, and the following Disclaimer and Export Compliance
69 1.19 christos * provision in the documentation and/or other materials provided with the
70 1.19 christos * distribution.
71 1.19 christos *
72 1.19 christos * 3.4. Intel retains all right, title, and interest in and to the Original
73 1.19 christos * Intel Code.
74 1.19 christos *
75 1.19 christos * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76 1.19 christos * Intel shall be used in advertising or otherwise to promote the sale, use or
77 1.19 christos * other dealings in products derived from or relating to the Covered Code
78 1.19 christos * without prior written authorization from Intel.
79 1.19 christos *
80 1.19 christos * 4. Disclaimer and Export Compliance
81 1.19 christos *
82 1.19 christos * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83 1.19 christos * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84 1.19 christos * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85 1.19 christos * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86 1.19 christos * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87 1.19 christos * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
88 1.19 christos * PARTICULAR PURPOSE.
89 1.19 christos *
90 1.19 christos * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91 1.19 christos * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92 1.19 christos * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93 1.19 christos * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94 1.19 christos * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95 1.19 christos * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96 1.19 christos * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
97 1.19 christos * LIMITED REMEDY.
98 1.19 christos *
99 1.19 christos * 4.3. Licensee shall not export, either directly or indirectly, any of this
100 1.19 christos * software or system incorporating such software without first obtaining any
101 1.19 christos * required license or other approval from the U. S. Department of Commerce or
102 1.19 christos * any other agency or department of the United States Government. In the
103 1.19 christos * event Licensee exports any such software from the United States or
104 1.19 christos * re-exports any such software from a foreign destination, Licensee shall
105 1.19 christos * ensure that the distribution and export/re-export of the software is in
106 1.19 christos * compliance with all laws, regulations, orders, or other restrictions of the
107 1.19 christos * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108 1.19 christos * any of its subsidiaries will export/re-export any technical data, process,
109 1.19 christos * software, or service, directly or indirectly, to any country for which the
110 1.19 christos * United States government or any agency thereof requires an export license,
111 1.19 christos * other governmental approval, or letter of assurance, without first obtaining
112 1.19 christos * such license, approval or letter.
113 1.19 christos *
114 1.19 christos *****************************************************************************
115 1.19 christos *
116 1.19 christos * Alternatively, you may choose to be licensed under the terms of the
117 1.19 christos * following license:
118 1.19 christos *
119 1.1 christos * Redistribution and use in source and binary forms, with or without
120 1.1 christos * modification, are permitted provided that the following conditions
121 1.1 christos * are met:
122 1.1 christos * 1. Redistributions of source code must retain the above copyright
123 1.1 christos * notice, this list of conditions, and the following disclaimer,
124 1.1 christos * without modification.
125 1.1 christos * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126 1.1 christos * substantially similar to the "NO WARRANTY" disclaimer below
127 1.1 christos * ("Disclaimer") and any redistribution must be conditioned upon
128 1.1 christos * including a substantially similar Disclaimer requirement for further
129 1.1 christos * binary redistribution.
130 1.1 christos * 3. Neither the names of the above-listed copyright holders nor the names
131 1.1 christos * of any contributors may be used to endorse or promote products derived
132 1.1 christos * from this software without specific prior written permission.
133 1.1 christos *
134 1.1 christos * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
135 1.1 christos * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
136 1.14 christos * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
137 1.1 christos * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
138 1.19 christos * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
139 1.19 christos * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
140 1.19 christos * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
141 1.19 christos * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
142 1.19 christos * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143 1.19 christos * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
144 1.19 christos * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
145 1.19 christos *
146 1.19 christos * Alternatively, you may choose to be licensed under the terms of the
147 1.19 christos * GNU General Public License ("GPL") version 2 as published by the Free
148 1.19 christos * Software Foundation.
149 1.19 christos *
150 1.19 christos *****************************************************************************/
151 1.1 christos
152 1.1 christos #include "aslcompiler.h"
153 1.1 christos #include "acapps.h"
154 1.1 christos #include "acdisasm.h"
155 1.16 christos #include "acglobal.h"
156 1.1 christos
157 1.1 christos #define _COMPONENT ACPI_COMPILER
158 1.1 christos ACPI_MODULE_NAME ("asloption")
159 1.1 christos
160 1.1 christos
161 1.1 christos /* Local prototypes */
162 1.1 christos
163 1.1 christos static int
164 1.1 christos AslDoOptions (
165 1.1 christos int argc,
166 1.1 christos char **argv,
167 1.1 christos BOOLEAN IsResponseFile);
168 1.1 christos
169 1.1 christos static void
170 1.1 christos AslMergeOptionTokens (
171 1.1 christos char *InBuffer,
172 1.1 christos char *OutBuffer);
173 1.1 christos
174 1.1 christos static int
175 1.1 christos AslDoResponseFile (
176 1.1 christos char *Filename);
177 1.1 christos
178 1.1 christos
179 1.1 christos #define ASL_TOKEN_SEPARATORS " \t\n"
180 1.16 christos #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"
181 1.2 christos
182 1.1 christos
183 1.1 christos /*******************************************************************************
184 1.1 christos *
185 1.1 christos * FUNCTION: AslCommandLine
186 1.1 christos *
187 1.1 christos * PARAMETERS: argc/argv
188 1.1 christos *
189 1.1 christos * RETURN: Last argv index
190 1.1 christos *
191 1.1 christos * DESCRIPTION: Command line processing
192 1.1 christos *
193 1.1 christos ******************************************************************************/
194 1.1 christos
195 1.1 christos int
196 1.1 christos AslCommandLine (
197 1.1 christos int argc,
198 1.1 christos char **argv)
199 1.1 christos {
200 1.1 christos int BadCommandLine = 0;
201 1.1 christos ACPI_STATUS Status;
202 1.1 christos
203 1.1 christos
204 1.1 christos /* Minimum command line contains at least the command and an input file */
205 1.1 christos
206 1.1 christos if (argc < 2)
207 1.1 christos {
208 1.1 christos Usage ();
209 1.1 christos exit (1);
210 1.1 christos }
211 1.1 christos
212 1.1 christos /* Process all command line options */
213 1.1 christos
214 1.1 christos BadCommandLine = AslDoOptions (argc, argv, FALSE);
215 1.1 christos
216 1.9 christos if (AslGbl_DoTemplates)
217 1.1 christos {
218 1.2 christos Status = DtCreateTemplates (argv);
219 1.1 christos if (ACPI_FAILURE (Status))
220 1.1 christos {
221 1.1 christos exit (-1);
222 1.1 christos }
223 1.12 christos exit (0);
224 1.1 christos }
225 1.1 christos
226 1.1 christos /* Next parameter must be the input filename */
227 1.1 christos
228 1.1 christos if (!argv[AcpiGbl_Optind] &&
229 1.5 christos !AcpiGbl_DisasmFlag)
230 1.1 christos {
231 1.1 christos printf ("Missing input filename\n");
232 1.1 christos BadCommandLine = TRUE;
233 1.1 christos }
234 1.1 christos
235 1.9 christos if (AslGbl_DoSignon)
236 1.1 christos {
237 1.1 christos printf (ACPI_COMMON_SIGNON (ASL_COMPILER_NAME));
238 1.9 christos if (AslGbl_IgnoreErrors)
239 1.1 christos {
240 1.1 christos printf ("Ignoring all errors, forcing AML file generation\n\n");
241 1.1 christos }
242 1.1 christos }
243 1.1 christos
244 1.1 christos if (BadCommandLine)
245 1.1 christos {
246 1.1 christos printf ("Use -h option for help information\n");
247 1.1 christos exit (1);
248 1.1 christos }
249 1.1 christos
250 1.1 christos return (AcpiGbl_Optind);
251 1.1 christos }
252 1.1 christos
253 1.1 christos
254 1.1 christos /*******************************************************************************
255 1.1 christos *
256 1.1 christos * FUNCTION: AslDoOptions
257 1.1 christos *
258 1.1 christos * PARAMETERS: argc/argv - Standard argc/argv
259 1.1 christos * IsResponseFile - TRUE if executing a response file.
260 1.1 christos *
261 1.1 christos * RETURN: Status
262 1.1 christos *
263 1.1 christos * DESCRIPTION: Command line option processing
264 1.1 christos *
265 1.1 christos ******************************************************************************/
266 1.1 christos
267 1.1 christos static int
268 1.1 christos AslDoOptions (
269 1.1 christos int argc,
270 1.1 christos char **argv,
271 1.1 christos BOOLEAN IsResponseFile)
272 1.1 christos {
273 1.1 christos ACPI_STATUS Status;
274 1.16 christos INT32 j;
275 1.1 christos
276 1.1 christos
277 1.1 christos /* Get the command line options */
278 1.1 christos
279 1.2 christos while ((j = AcpiGetopt (argc, argv, ASL_SUPPORTED_OPTIONS)) != ACPI_OPT_END) switch (j)
280 1.1 christos {
281 1.1 christos case '@': /* Begin a response file */
282 1.1 christos
283 1.1 christos if (IsResponseFile)
284 1.1 christos {
285 1.1 christos printf ("Nested command files are not supported\n");
286 1.1 christos return (-1);
287 1.1 christos }
288 1.1 christos
289 1.1 christos if (AslDoResponseFile (AcpiGbl_Optarg))
290 1.1 christos {
291 1.1 christos return (-1);
292 1.1 christos }
293 1.1 christos break;
294 1.1 christos
295 1.2 christos case 'a': /* Debug options */
296 1.2 christos
297 1.2 christos switch (AcpiGbl_Optarg[0])
298 1.2 christos {
299 1.2 christos case 'r':
300 1.2 christos
301 1.9 christos AslGbl_EnableReferenceTypechecking = TRUE;
302 1.2 christos break;
303 1.2 christos
304 1.2 christos default:
305 1.2 christos
306 1.2 christos printf ("Unknown option: -a%s\n", AcpiGbl_Optarg);
307 1.2 christos return (-1);
308 1.2 christos }
309 1.2 christos
310 1.2 christos break;
311 1.2 christos
312 1.2 christos
313 1.2 christos case 'b': /* Debug options */
314 1.1 christos
315 1.1 christos switch (AcpiGbl_Optarg[0])
316 1.1 christos {
317 1.4 christos
318 1.4 christos case 'c':
319 1.4 christos
320 1.4 christos printf ("Debug ASL to ASL+ conversion\n");
321 1.4 christos
322 1.9 christos AslGbl_DoAslConversion = TRUE;
323 1.9 christos AslGbl_FoldConstants = FALSE;
324 1.9 christos AslGbl_IntegerOptimizationFlag = FALSE;
325 1.9 christos AslGbl_ReferenceOptimizationFlag = FALSE;
326 1.9 christos AslGbl_OptimizeTrivialParseNodes = FALSE;
327 1.7 christos AcpiGbl_CaptureComments = TRUE;
328 1.4 christos AcpiGbl_DoDisassemblerOptimizations = FALSE;
329 1.4 christos AcpiGbl_DebugAslConversion = TRUE;
330 1.4 christos AcpiGbl_DmEmitExternalOpcodes = TRUE;
331 1.9 christos AslGbl_DoExternalsInPlace = TRUE;
332 1.4 christos
333 1.4 christos return (0);
334 1.4 christos
335 1.1 christos case 'f':
336 1.1 christos
337 1.1 christos AslCompilerdebug = 1; /* same as yydebug */
338 1.1 christos DtParserdebug = 1;
339 1.1 christos PrParserdebug = 1;
340 1.9 christos AslGbl_DebugFlag = TRUE;
341 1.9 christos AslGbl_KeepPreprocessorTempFile = TRUE;
342 1.2 christos break;
343 1.2 christos
344 1.2 christos case 'p': /* Prune ASL parse tree */
345 1.2 christos
346 1.2 christos /* Get the required argument */
347 1.2 christos
348 1.2 christos if (AcpiGetoptArgument (argc, argv))
349 1.2 christos {
350 1.2 christos return (-1);
351 1.2 christos }
352 1.2 christos
353 1.9 christos AslGbl_PruneParseTree = TRUE;
354 1.9 christos AslGbl_PruneDepth = (UINT8) strtoul (AcpiGbl_Optarg, NULL, 0);
355 1.2 christos break;
356 1.2 christos
357 1.2 christos case 's':
358 1.2 christos
359 1.9 christos AslGbl_DebugFlag = TRUE;
360 1.1 christos break;
361 1.1 christos
362 1.1 christos case 't':
363 1.1 christos
364 1.2 christos /* Get the required argument */
365 1.2 christos
366 1.2 christos if (AcpiGetoptArgument (argc, argv))
367 1.2 christos {
368 1.2 christos return (-1);
369 1.2 christos }
370 1.9 christos AslGbl_PruneType = (UINT8) strtoul (AcpiGbl_Optarg, NULL, 0);
371 1.1 christos break;
372 1.1 christos
373 1.1 christos default:
374 1.1 christos
375 1.1 christos printf ("Unknown option: -b%s\n", AcpiGbl_Optarg);
376 1.1 christos return (-1);
377 1.1 christos }
378 1.1 christos
379 1.1 christos break;
380 1.1 christos
381 1.1 christos case 'c':
382 1.1 christos
383 1.1 christos switch (AcpiGbl_Optarg[0])
384 1.1 christos {
385 1.4 christos
386 1.4 christos case 'a':
387 1.4 christos
388 1.4 christos printf ("Convert ASL to ASL+ with comments\n");
389 1.9 christos AslGbl_DoAslConversion = TRUE;
390 1.9 christos AslGbl_FoldConstants = FALSE;
391 1.9 christos AslGbl_IntegerOptimizationFlag = FALSE;
392 1.9 christos AslGbl_ReferenceOptimizationFlag = FALSE;
393 1.9 christos AslGbl_OptimizeTrivialParseNodes = FALSE;
394 1.7 christos AcpiGbl_CaptureComments = TRUE;
395 1.4 christos AcpiGbl_DoDisassemblerOptimizations = FALSE;
396 1.4 christos AcpiGbl_DmEmitExternalOpcodes = TRUE;
397 1.9 christos AslGbl_DoExternalsInPlace = TRUE;
398 1.4 christos
399 1.4 christos return (0);
400 1.4 christos
401 1.1 christos case 'r':
402 1.1 christos
403 1.9 christos AslGbl_NoResourceChecking = TRUE;
404 1.1 christos break;
405 1.1 christos
406 1.1 christos default:
407 1.1 christos
408 1.1 christos printf ("Unknown option: -c%s\n", AcpiGbl_Optarg);
409 1.1 christos return (-1);
410 1.1 christos }
411 1.1 christos break;
412 1.1 christos
413 1.1 christos case 'd': /* Disassembler */
414 1.1 christos
415 1.1 christos switch (AcpiGbl_Optarg[0])
416 1.1 christos {
417 1.1 christos case '^':
418 1.1 christos
419 1.9 christos AslGbl_DoCompile = FALSE;
420 1.1 christos break;
421 1.1 christos
422 1.1 christos case 'a':
423 1.1 christos
424 1.9 christos AslGbl_DoCompile = FALSE;
425 1.9 christos AslGbl_DisassembleAll = TRUE;
426 1.1 christos break;
427 1.1 christos
428 1.1 christos case 'b': /* Do not convert buffers to resource descriptors */
429 1.1 christos
430 1.1 christos AcpiGbl_NoResourceDisassembly = TRUE;
431 1.1 christos break;
432 1.1 christos
433 1.1 christos case 'c':
434 1.1 christos
435 1.1 christos break;
436 1.1 christos
437 1.2 christos case 'f':
438 1.2 christos
439 1.2 christos AcpiGbl_ForceAmlDisassembly = TRUE;
440 1.2 christos break;
441 1.2 christos
442 1.2 christos case 'l': /* Use legacy ASL code (not ASL+) for disassembly */
443 1.2 christos
444 1.9 christos AslGbl_DoCompile = FALSE;
445 1.2 christos AcpiGbl_CstyleDisassembly = FALSE;
446 1.2 christos break;
447 1.2 christos
448 1.16 christos case 's': /* Specify table signature (Only supported for CDAT table) */
449 1.16 christos
450 1.16 christos /* Get the required argument */
451 1.16 christos
452 1.16 christos if (AcpiGetoptArgument (argc, argv))
453 1.16 christos {
454 1.16 christos return (-1);
455 1.16 christos }
456 1.16 christos
457 1.16 christos /* Check for exact string "CDAT" (upper or lower case) */
458 1.16 christos
459 1.16 christos AcpiGbl_CDAT = ACPI_CAST_PTR (char, &AcpiGbl_Optarg);
460 1.16 christos if (AcpiUtStricmp (AcpiGbl_Optarg, ACPI_SIG_CDAT))
461 1.16 christos {
462 1.16 christos printf ("\nUnknown table signature: %s\n", AcpiGbl_Optarg);
463 1.16 christos return (-1);
464 1.16 christos }
465 1.16 christos
466 1.16 christos AcpiGbl_CDAT = malloc (5);
467 1.16 christos AcpiUtSafeStrncpy ((char *) AcpiGbl_CDAT, ACPI_SIG_CDAT, 5);
468 1.16 christos break;
469 1.16 christos
470 1.1 christos default:
471 1.1 christos
472 1.1 christos printf ("Unknown option: -d%s\n", AcpiGbl_Optarg);
473 1.1 christos return (-1);
474 1.1 christos }
475 1.1 christos
476 1.5 christos AcpiGbl_DisasmFlag = TRUE;
477 1.1 christos break;
478 1.1 christos
479 1.1 christos case 'D': /* Define a symbol */
480 1.1 christos
481 1.1 christos PrAddDefine (AcpiGbl_Optarg, NULL, TRUE);
482 1.1 christos break;
483 1.1 christos
484 1.1 christos case 'e': /* External files for disassembler */
485 1.1 christos
486 1.1 christos /* Get entire list of external files */
487 1.1 christos
488 1.1 christos AcpiGbl_Optind--;
489 1.2 christos argv[AcpiGbl_Optind] = AcpiGbl_Optarg;
490 1.1 christos
491 1.1 christos while (argv[AcpiGbl_Optind] &&
492 1.1 christos (argv[AcpiGbl_Optind][0] != '-'))
493 1.1 christos {
494 1.1 christos Status = AcpiDmAddToExternalFileList (argv[AcpiGbl_Optind]);
495 1.1 christos if (ACPI_FAILURE (Status))
496 1.1 christos {
497 1.2 christos printf ("Could not add %s to external list\n",
498 1.2 christos argv[AcpiGbl_Optind]);
499 1.1 christos return (-1);
500 1.1 christos }
501 1.1 christos
502 1.1 christos AcpiGbl_Optind++;
503 1.1 christos }
504 1.1 christos break;
505 1.1 christos
506 1.1 christos case 'f':
507 1.1 christos
508 1.1 christos switch (AcpiGbl_Optarg[0])
509 1.1 christos {
510 1.1 christos case '^': /* Ignore errors and force creation of aml file */
511 1.1 christos
512 1.9 christos AslGbl_IgnoreErrors = TRUE;
513 1.1 christos break;
514 1.1 christos
515 1.1 christos case 'e': /* Disassembler: Get external declaration file */
516 1.1 christos
517 1.1 christos if (AcpiGetoptArgument (argc, argv))
518 1.1 christos {
519 1.1 christos return (-1);
520 1.1 christos }
521 1.1 christos
522 1.9 christos AslGbl_ExternalRefFilename = AcpiGbl_Optarg;
523 1.1 christos break;
524 1.1 christos
525 1.1 christos default:
526 1.1 christos
527 1.1 christos printf ("Unknown option: -f%s\n", AcpiGbl_Optarg);
528 1.1 christos return (-1);
529 1.1 christos }
530 1.1 christos break;
531 1.1 christos
532 1.1 christos case 'G':
533 1.1 christos
534 1.9 christos AslGbl_CompileGeneric = TRUE;
535 1.1 christos break;
536 1.1 christos
537 1.1 christos case 'g': /* Get all ACPI tables */
538 1.1 christos
539 1.2 christos printf ("-g option is deprecated, use acpidump utility instead\n");
540 1.2 christos exit (1);
541 1.1 christos
542 1.1 christos case 'h':
543 1.1 christos
544 1.1 christos switch (AcpiGbl_Optarg[0])
545 1.1 christos {
546 1.1 christos case '^':
547 1.1 christos
548 1.1 christos Usage ();
549 1.1 christos exit (0);
550 1.1 christos
551 1.1 christos case 'c':
552 1.1 christos
553 1.1 christos UtDisplayConstantOpcodes ();
554 1.1 christos exit (0);
555 1.1 christos
556 1.2 christos case 'd':
557 1.2 christos
558 1.2 christos AslDisassemblyHelp ();
559 1.2 christos exit (0);
560 1.2 christos
561 1.1 christos case 'f':
562 1.1 christos
563 1.1 christos AslFilenameHelp ();
564 1.1 christos exit (0);
565 1.1 christos
566 1.1 christos case 'r':
567 1.1 christos
568 1.1 christos /* reserved names */
569 1.1 christos
570 1.1 christos ApDisplayReservedNames ();
571 1.1 christos exit (0);
572 1.1 christos
573 1.1 christos case 't':
574 1.1 christos
575 1.1 christos UtDisplaySupportedTables ();
576 1.1 christos exit (0);
577 1.1 christos
578 1.1 christos default:
579 1.1 christos
580 1.1 christos printf ("Unknown option: -h%s\n", AcpiGbl_Optarg);
581 1.1 christos return (-1);
582 1.1 christos }
583 1.1 christos
584 1.1 christos case 'I': /* Add an include file search directory */
585 1.1 christos
586 1.1 christos FlAddIncludeDirectory (AcpiGbl_Optarg);
587 1.1 christos break;
588 1.1 christos
589 1.1 christos case 'i': /* Output AML as an include file */
590 1.1 christos
591 1.1 christos switch (AcpiGbl_Optarg[0])
592 1.1 christos {
593 1.1 christos case 'a':
594 1.1 christos
595 1.1 christos /* Produce assembly code include file */
596 1.1 christos
597 1.9 christos AslGbl_AsmIncludeOutputFlag = TRUE;
598 1.1 christos break;
599 1.1 christos
600 1.1 christos case 'c':
601 1.1 christos
602 1.1 christos /* Produce C include file */
603 1.1 christos
604 1.9 christos AslGbl_C_IncludeOutputFlag = TRUE;
605 1.1 christos break;
606 1.1 christos
607 1.1 christos case 'n':
608 1.1 christos
609 1.1 christos /* Compiler/Disassembler: Ignore the NOOP operator */
610 1.1 christos
611 1.1 christos AcpiGbl_IgnoreNoopOperator = TRUE;
612 1.1 christos break;
613 1.1 christos
614 1.1 christos default:
615 1.1 christos
616 1.1 christos printf ("Unknown option: -i%s\n", AcpiGbl_Optarg);
617 1.1 christos return (-1);
618 1.1 christos }
619 1.1 christos break;
620 1.1 christos
621 1.1 christos case 'l': /* Listing files */
622 1.1 christos
623 1.1 christos switch (AcpiGbl_Optarg[0])
624 1.1 christos {
625 1.1 christos case '^':
626 1.1 christos
627 1.1 christos /* Produce listing file (Mixed source/aml) */
628 1.1 christos
629 1.9 christos AslGbl_ListingFlag = TRUE;
630 1.2 christos AcpiGbl_DmOpt_Listing = TRUE;
631 1.1 christos break;
632 1.1 christos
633 1.18 christos case 'd':
634 1.18 christos
635 1.18 christos /* Disable deterministic output, enabling timestamp */
636 1.18 christos
637 1.18 christos AslGbl_Deterministic = FALSE;
638 1.18 christos break;
639 1.18 christos
640 1.1 christos case 'i':
641 1.1 christos
642 1.1 christos /* Produce preprocessor output file */
643 1.1 christos
644 1.9 christos AslGbl_PreprocessorOutputFlag = TRUE;
645 1.1 christos break;
646 1.1 christos
647 1.2 christos case 'm':
648 1.2 christos
649 1.2 christos /* Produce hardware map summary file */
650 1.2 christos
651 1.9 christos AslGbl_MapfileFlag = TRUE;
652 1.2 christos break;
653 1.2 christos
654 1.1 christos case 'n':
655 1.1 christos
656 1.1 christos /* Produce namespace file */
657 1.1 christos
658 1.9 christos AslGbl_NsOutputFlag = TRUE;
659 1.1 christos break;
660 1.1 christos
661 1.1 christos case 's':
662 1.1 christos
663 1.1 christos /* Produce combined source file */
664 1.1 christos
665 1.9 christos AslGbl_SourceOutputFlag = TRUE;
666 1.1 christos break;
667 1.1 christos
668 1.2 christos case 'x':
669 1.2 christos
670 1.2 christos /* Produce cross-reference file */
671 1.2 christos
672 1.9 christos AslGbl_CrossReferenceOutput = TRUE;
673 1.2 christos break;
674 1.2 christos
675 1.1 christos default:
676 1.1 christos
677 1.1 christos printf ("Unknown option: -l%s\n", AcpiGbl_Optarg);
678 1.1 christos return (-1);
679 1.1 christos }
680 1.1 christos break;
681 1.1 christos
682 1.1 christos case 'm': /* Set line buffer size */
683 1.1 christos
684 1.9 christos AslGbl_LineBufferSize = (UINT32) strtoul (AcpiGbl_Optarg, NULL, 0) * 1024;
685 1.9 christos if (AslGbl_LineBufferSize < ASL_DEFAULT_LINE_BUFFER_SIZE)
686 1.1 christos {
687 1.9 christos AslGbl_LineBufferSize = ASL_DEFAULT_LINE_BUFFER_SIZE;
688 1.1 christos }
689 1.9 christos printf ("Line Buffer Size: %u\n", AslGbl_LineBufferSize);
690 1.1 christos break;
691 1.1 christos
692 1.1 christos case 'n': /* Parse only */
693 1.1 christos
694 1.9 christos AslGbl_ParseOnlyFlag = TRUE;
695 1.1 christos break;
696 1.1 christos
697 1.1 christos case 'o': /* Control compiler AML optimizations */
698 1.1 christos
699 1.1 christos switch (AcpiGbl_Optarg[0])
700 1.1 christos {
701 1.1 christos case 'a':
702 1.1 christos
703 1.1 christos /* Disable all optimizations */
704 1.1 christos
705 1.9 christos AslGbl_FoldConstants = FALSE;
706 1.9 christos AslGbl_IntegerOptimizationFlag = FALSE;
707 1.9 christos AslGbl_ReferenceOptimizationFlag = FALSE;
708 1.9 christos AslGbl_OptimizeTrivialParseNodes = FALSE;
709 1.4 christos
710 1.1 christos break;
711 1.1 christos
712 1.2 christos case 'c':
713 1.2 christos
714 1.2 christos /* Display compile time(s) */
715 1.2 christos
716 1.9 christos AslGbl_CompileTimesFlag = TRUE;
717 1.2 christos break;
718 1.2 christos
719 1.2 christos case 'd':
720 1.2 christos
721 1.2 christos /* Disable disassembler code optimizations */
722 1.2 christos
723 1.2 christos AcpiGbl_DoDisassemblerOptimizations = FALSE;
724 1.2 christos break;
725 1.2 christos
726 1.2 christos case 'e':
727 1.2 christos
728 1.4 christos /* Disassembler: Emit embedded external operators */
729 1.4 christos
730 1.4 christos AcpiGbl_DmEmitExternalOpcodes = TRUE;
731 1.4 christos break;
732 1.2 christos
733 1.4 christos case 'E':
734 1.2 christos
735 1.4 christos /*
736 1.4 christos * iASL: keep External opcodes in place.
737 1.4 christos * No affect if Gbl_DoExternals is false.
738 1.4 christos */
739 1.2 christos
740 1.9 christos AslGbl_DoExternalsInPlace = TRUE;
741 1.2 christos break;
742 1.2 christos
743 1.1 christos case 'f':
744 1.1 christos
745 1.1 christos /* Disable folding on "normal" expressions */
746 1.1 christos
747 1.9 christos AslGbl_FoldConstants = FALSE;
748 1.1 christos break;
749 1.1 christos
750 1.1 christos case 'i':
751 1.1 christos
752 1.1 christos /* Disable integer optimization to constants */
753 1.1 christos
754 1.9 christos AslGbl_IntegerOptimizationFlag = FALSE;
755 1.1 christos break;
756 1.1 christos
757 1.1 christos case 'n':
758 1.1 christos
759 1.1 christos /* Disable named reference optimization */
760 1.1 christos
761 1.9 christos AslGbl_ReferenceOptimizationFlag = FALSE;
762 1.1 christos break;
763 1.1 christos
764 1.1 christos case 't':
765 1.1 christos
766 1.2 christos /* Disable heavy typechecking */
767 1.1 christos
768 1.9 christos AslGbl_DoTypechecking = FALSE;
769 1.1 christos break;
770 1.1 christos
771 1.1 christos default:
772 1.1 christos
773 1.1 christos printf ("Unknown option: -c%s\n", AcpiGbl_Optarg);
774 1.1 christos return (-1);
775 1.1 christos }
776 1.1 christos break;
777 1.1 christos
778 1.1 christos case 'P': /* Preprocessor options */
779 1.1 christos
780 1.1 christos switch (AcpiGbl_Optarg[0])
781 1.1 christos {
782 1.1 christos case '^': /* Proprocess only, emit (.i) file */
783 1.1 christos
784 1.9 christos AslGbl_PreprocessOnly = TRUE;
785 1.9 christos AslGbl_PreprocessorOutputFlag = TRUE;
786 1.1 christos break;
787 1.1 christos
788 1.1 christos case 'n': /* Disable preprocessor */
789 1.1 christos
790 1.9 christos AslGbl_PreprocessFlag = FALSE;
791 1.1 christos break;
792 1.1 christos
793 1.1 christos default:
794 1.1 christos
795 1.1 christos printf ("Unknown option: -P%s\n", AcpiGbl_Optarg);
796 1.1 christos return (-1);
797 1.1 christos }
798 1.1 christos break;
799 1.1 christos
800 1.1 christos case 'p': /* Override default AML output filename */
801 1.1 christos
802 1.9 christos AslGbl_OutputFilenamePrefix = AcpiGbl_Optarg;
803 1.9 christos UtConvertBackslashes (AslGbl_OutputFilenamePrefix);
804 1.9 christos AslGbl_UseDefaultAmlFilename = FALSE;
805 1.1 christos break;
806 1.1 christos
807 1.4 christos case 'q': /* ASL/ASl+ converter: compile only and leave badaml. */
808 1.4 christos
809 1.4 christos printf ("Convert ASL to ASL+ with comments\n");
810 1.9 christos AslGbl_FoldConstants = FALSE;
811 1.9 christos AslGbl_IntegerOptimizationFlag = FALSE;
812 1.9 christos AslGbl_ReferenceOptimizationFlag = FALSE;
813 1.9 christos AslGbl_OptimizeTrivialParseNodes = FALSE;
814 1.9 christos AslGbl_DoExternalsInPlace = TRUE;
815 1.7 christos AcpiGbl_CaptureComments = TRUE;
816 1.4 christos return (0);
817 1.4 christos
818 1.1 christos case 'r': /* Override revision found in table header */
819 1.1 christos
820 1.9 christos AslGbl_RevisionOverride = (UINT8) strtoul (AcpiGbl_Optarg, NULL, 0);
821 1.1 christos break;
822 1.1 christos
823 1.1 christos case 's': /* Create AML in a source code file */
824 1.1 christos
825 1.1 christos switch (AcpiGbl_Optarg[0])
826 1.1 christos {
827 1.1 christos case 'a':
828 1.1 christos
829 1.1 christos /* Produce assembly code output file */
830 1.1 christos
831 1.9 christos AslGbl_AsmOutputFlag = TRUE;
832 1.1 christos break;
833 1.1 christos
834 1.1 christos case 'c':
835 1.1 christos
836 1.1 christos /* Produce C hex output file */
837 1.1 christos
838 1.9 christos AslGbl_C_OutputFlag = TRUE;
839 1.1 christos break;
840 1.1 christos
841 1.1 christos case 'o':
842 1.1 christos
843 1.1 christos /* Produce AML offset table in C */
844 1.1 christos
845 1.9 christos AslGbl_C_OffsetTableFlag = TRUE;
846 1.1 christos break;
847 1.1 christos
848 1.1 christos default:
849 1.1 christos
850 1.1 christos printf ("Unknown option: -s%s\n", AcpiGbl_Optarg);
851 1.1 christos return (-1);
852 1.1 christos }
853 1.1 christos break;
854 1.1 christos
855 1.1 christos case 't': /* Produce hex table output file */
856 1.1 christos
857 1.1 christos switch (AcpiGbl_Optarg[0])
858 1.1 christos {
859 1.1 christos case 'a':
860 1.1 christos
861 1.9 christos AslGbl_HexOutputFlag = HEX_OUTPUT_ASM;
862 1.1 christos break;
863 1.1 christos
864 1.1 christos case 'c':
865 1.1 christos
866 1.9 christos AslGbl_HexOutputFlag = HEX_OUTPUT_C;
867 1.1 christos break;
868 1.1 christos
869 1.16 christos case 'p': /* data table flex/bison prototype */
870 1.11 christos
871 1.11 christos AslGbl_DtLexBisonPrototype = TRUE;
872 1.11 christos break;
873 1.11 christos
874 1.1 christos case 's':
875 1.1 christos
876 1.9 christos AslGbl_HexOutputFlag = HEX_OUTPUT_ASL;
877 1.1 christos break;
878 1.1 christos
879 1.1 christos default:
880 1.1 christos
881 1.1 christos printf ("Unknown option: -t%s\n", AcpiGbl_Optarg);
882 1.1 christos return (-1);
883 1.1 christos }
884 1.1 christos break;
885 1.1 christos
886 1.1 christos case 'T': /* Create a ACPI table template file */
887 1.1 christos
888 1.9 christos AslGbl_DoTemplates = TRUE;
889 1.1 christos break;
890 1.1 christos
891 1.1 christos case 'v': /* Version and verbosity settings */
892 1.1 christos
893 1.1 christos switch (AcpiGbl_Optarg[0])
894 1.1 christos {
895 1.1 christos case '^':
896 1.1 christos
897 1.1 christos printf (ACPI_COMMON_SIGNON (ASL_COMPILER_NAME));
898 1.1 christos exit (0);
899 1.1 christos
900 1.1 christos case 'a':
901 1.1 christos
902 1.1 christos /* Disable all error/warning/remark messages */
903 1.1 christos
904 1.9 christos AslGbl_NoErrors = TRUE;
905 1.1 christos break;
906 1.1 christos
907 1.2 christos case 'd':
908 1.2 christos
909 1.6 christos printf (ACPI_COMMON_SIGNON (ASL_COMPILER_NAME));
910 1.6 christos printf (ACPI_COMMON_BUILD_TIME);
911 1.2 christos exit (0);
912 1.2 christos
913 1.1 christos case 'e':
914 1.1 christos
915 1.1 christos /* Disable all warning/remark messages (errors only) */
916 1.1 christos
917 1.9 christos AslGbl_DisplayRemarks = FALSE;
918 1.9 christos AslGbl_DisplayWarnings = FALSE;
919 1.1 christos break;
920 1.1 christos
921 1.1 christos case 'i':
922 1.1 christos /*
923 1.1 christos * Support for integrated development environment(s).
924 1.1 christos *
925 1.1 christos * 1) No compiler signon
926 1.1 christos * 2) Send stderr messages to stdout
927 1.1 christos * 3) Less verbose error messages (single line only for each)
928 1.1 christos * 4) Error/warning messages are formatted appropriately to
929 1.1 christos * be recognized by MS Visual Studio
930 1.1 christos */
931 1.9 christos AslGbl_VerboseErrors = FALSE;
932 1.9 christos AslGbl_DoSignon = FALSE;
933 1.1 christos break;
934 1.1 christos
935 1.1 christos case 'o':
936 1.1 christos
937 1.9 christos AslGbl_DisplayOptimizations = TRUE;
938 1.1 christos break;
939 1.1 christos
940 1.1 christos case 'r':
941 1.1 christos
942 1.9 christos AslGbl_DisplayRemarks = FALSE;
943 1.1 christos break;
944 1.1 christos
945 1.1 christos case 's':
946 1.1 christos
947 1.9 christos AslGbl_DoSignon = FALSE;
948 1.1 christos break;
949 1.1 christos
950 1.1 christos case 't':
951 1.1 christos
952 1.9 christos AslGbl_VerboseTemplates = TRUE;
953 1.1 christos break;
954 1.1 christos
955 1.1 christos case 'w':
956 1.1 christos
957 1.1 christos /* Get the required argument */
958 1.1 christos
959 1.1 christos if (AcpiGetoptArgument (argc, argv))
960 1.1 christos {
961 1.1 christos return (-1);
962 1.1 christos }
963 1.1 christos
964 1.1 christos Status = AslDisableException (AcpiGbl_Optarg);
965 1.1 christos if (ACPI_FAILURE (Status))
966 1.1 christos {
967 1.1 christos return (-1);
968 1.1 christos }
969 1.1 christos break;
970 1.1 christos
971 1.5 christos case 'x':
972 1.5 christos
973 1.5 christos /* Get the required argument */
974 1.5 christos
975 1.5 christos if (AcpiGetoptArgument (argc, argv))
976 1.5 christos {
977 1.5 christos return (-1);
978 1.5 christos }
979 1.5 christos
980 1.13 christos Status = AslLogExpectedException (AcpiGbl_Optarg);
981 1.5 christos if (ACPI_FAILURE (Status))
982 1.5 christos {
983 1.5 christos return (-1);
984 1.5 christos }
985 1.5 christos break;
986 1.5 christos
987 1.1 christos default:
988 1.1 christos
989 1.1 christos printf ("Unknown option: -v%s\n", AcpiGbl_Optarg);
990 1.1 christos return (-1);
991 1.1 christos }
992 1.1 christos break;
993 1.1 christos
994 1.1 christos case 'w': /* Set warning levels */
995 1.1 christos
996 1.1 christos switch (AcpiGbl_Optarg[0])
997 1.1 christos {
998 1.1 christos case '1':
999 1.1 christos
1000 1.9 christos AslGbl_WarningLevel = ASL_WARNING;
1001 1.1 christos break;
1002 1.1 christos
1003 1.1 christos case '2':
1004 1.1 christos
1005 1.9 christos AslGbl_WarningLevel = ASL_WARNING2;
1006 1.1 christos break;
1007 1.1 christos
1008 1.1 christos case '3':
1009 1.1 christos
1010 1.9 christos AslGbl_WarningLevel = ASL_WARNING3;
1011 1.1 christos break;
1012 1.1 christos
1013 1.1 christos case 'e':
1014 1.1 christos
1015 1.9 christos AslGbl_WarningsAsErrors = TRUE;
1016 1.1 christos break;
1017 1.1 christos
1018 1.9 christos case 'w':
1019 1.9 christos
1020 1.9 christos /* Get the required argument */
1021 1.9 christos
1022 1.9 christos if (AcpiGetoptArgument (argc, argv))
1023 1.9 christos {
1024 1.9 christos return (-1);
1025 1.9 christos }
1026 1.9 christos
1027 1.9 christos Status = AslElevateException (AcpiGbl_Optarg);
1028 1.9 christos if (ACPI_FAILURE (Status))
1029 1.9 christos {
1030 1.9 christos return (-1);
1031 1.9 christos }
1032 1.9 christos break;
1033 1.9 christos
1034 1.9 christos
1035 1.1 christos default:
1036 1.1 christos
1037 1.1 christos printf ("Unknown option: -w%s\n", AcpiGbl_Optarg);
1038 1.1 christos return (-1);
1039 1.1 christos }
1040 1.1 christos break;
1041 1.1 christos
1042 1.1 christos case 'x': /* Set debug print output level */
1043 1.1 christos
1044 1.1 christos AcpiDbgLevel = strtoul (AcpiGbl_Optarg, NULL, 16);
1045 1.1 christos break;
1046 1.1 christos
1047 1.1 christos case 'z':
1048 1.1 christos
1049 1.9 christos AslGbl_UseOriginalCompilerId = TRUE;
1050 1.1 christos break;
1051 1.1 christos
1052 1.1 christos default:
1053 1.1 christos
1054 1.1 christos return (-1);
1055 1.1 christos }
1056 1.1 christos
1057 1.1 christos return (0);
1058 1.1 christos }
1059 1.1 christos
1060 1.1 christos
1061 1.1 christos /*******************************************************************************
1062 1.1 christos *
1063 1.1 christos * FUNCTION: AslMergeOptionTokens
1064 1.1 christos *
1065 1.1 christos * PARAMETERS: InBuffer - Input containing an option string
1066 1.1 christos * OutBuffer - Merged output buffer
1067 1.1 christos *
1068 1.1 christos * RETURN: None
1069 1.1 christos *
1070 1.1 christos * DESCRIPTION: Remove all whitespace from an option string.
1071 1.1 christos *
1072 1.1 christos ******************************************************************************/
1073 1.1 christos
1074 1.1 christos static void
1075 1.1 christos AslMergeOptionTokens (
1076 1.1 christos char *InBuffer,
1077 1.1 christos char *OutBuffer)
1078 1.1 christos {
1079 1.1 christos char *Token;
1080 1.1 christos
1081 1.1 christos
1082 1.1 christos *OutBuffer = 0;
1083 1.1 christos
1084 1.1 christos Token = strtok (InBuffer, ASL_TOKEN_SEPARATORS);
1085 1.1 christos while (Token)
1086 1.1 christos {
1087 1.1 christos strcat (OutBuffer, Token);
1088 1.1 christos Token = strtok (NULL, ASL_TOKEN_SEPARATORS);
1089 1.1 christos }
1090 1.1 christos }
1091 1.1 christos
1092 1.1 christos
1093 1.1 christos /*******************************************************************************
1094 1.1 christos *
1095 1.1 christos * FUNCTION: AslDoResponseFile
1096 1.1 christos *
1097 1.1 christos * PARAMETERS: Filename - Name of the response file
1098 1.1 christos *
1099 1.1 christos * RETURN: Status
1100 1.1 christos *
1101 1.1 christos * DESCRIPTION: Open a response file and process all options within.
1102 1.1 christos *
1103 1.1 christos ******************************************************************************/
1104 1.1 christos
1105 1.1 christos static int
1106 1.1 christos AslDoResponseFile (
1107 1.1 christos char *Filename)
1108 1.1 christos {
1109 1.9 christos char *argv = AslGbl_StringBuffer2;
1110 1.1 christos FILE *ResponseFile;
1111 1.1 christos int OptStatus = 0;
1112 1.1 christos int Opterr;
1113 1.1 christos int Optind;
1114 1.1 christos
1115 1.1 christos
1116 1.1 christos ResponseFile = fopen (Filename, "r");
1117 1.1 christos if (!ResponseFile)
1118 1.1 christos {
1119 1.1 christos printf ("Could not open command file %s, %s\n",
1120 1.1 christos Filename, strerror (errno));
1121 1.1 christos return (-1);
1122 1.1 christos }
1123 1.1 christos
1124 1.1 christos /* Must save the current GetOpt globals */
1125 1.1 christos
1126 1.1 christos Opterr = AcpiGbl_Opterr;
1127 1.1 christos Optind = AcpiGbl_Optind;
1128 1.1 christos
1129 1.1 christos /*
1130 1.1 christos * Process all lines in the response file. There must be one complete
1131 1.1 christos * option per line
1132 1.1 christos */
1133 1.9 christos while (fgets (AslGbl_StringBuffer, ASL_STRING_BUFFER_SIZE, ResponseFile))
1134 1.1 christos {
1135 1.1 christos /* Compress all tokens, allowing us to use a single argv entry */
1136 1.1 christos
1137 1.9 christos AslMergeOptionTokens (AslGbl_StringBuffer, AslGbl_StringBuffer2);
1138 1.1 christos
1139 1.1 christos /* Process the option */
1140 1.1 christos
1141 1.1 christos AcpiGbl_Opterr = 0;
1142 1.1 christos AcpiGbl_Optind = 0;
1143 1.1 christos
1144 1.1 christos OptStatus = AslDoOptions (1, &argv, TRUE);
1145 1.1 christos if (OptStatus)
1146 1.1 christos {
1147 1.1 christos printf ("Invalid option in command file %s: %s\n",
1148 1.9 christos Filename, AslGbl_StringBuffer);
1149 1.1 christos break;
1150 1.1 christos }
1151 1.1 christos }
1152 1.1 christos
1153 1.1 christos /* Restore the GetOpt globals */
1154 1.1 christos
1155 1.1 christos AcpiGbl_Opterr = Opterr;
1156 1.1 christos AcpiGbl_Optind = Optind;
1157 1.1 christos
1158 1.1 christos fclose (ResponseFile);
1159 1.1 christos return (OptStatus);
1160 1.1 christos }
1161