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