xref: /freebsd/sys/contrib/dev/acpica/compiler/aslmain.c (revision 1669d8afc64812c8d2d1d147ae1fd42ff441e1b1)
1 
2 /******************************************************************************
3  *
4  * Module Name: aslmain - compiler main and utilities
5  *              $Revision: 1.96 $
6  *
7  *****************************************************************************/
8 
9 /******************************************************************************
10  *
11  * 1. Copyright Notice
12  *
13  * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp.
14  * All rights reserved.
15  *
16  * 2. License
17  *
18  * 2.1. This is your license from Intel Corp. under its intellectual property
19  * rights.  You may have additional license terms from the party that provided
20  * you this software, covering your right to use that party's intellectual
21  * property rights.
22  *
23  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
24  * copy of the source code appearing in this file ("Covered Code") an
25  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
26  * base code distributed originally by Intel ("Original Intel Code") to copy,
27  * make derivatives, distribute, use and display any portion of the Covered
28  * Code in any form, with the right to sublicense such rights; and
29  *
30  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
31  * license (with the right to sublicense), under only those claims of Intel
32  * patents that are infringed by the Original Intel Code, to make, use, sell,
33  * offer to sell, and import the Covered Code and derivative works thereof
34  * solely to the minimum extent necessary to exercise the above copyright
35  * license, and in no event shall the patent license extend to any additions
36  * to or modifications of the Original Intel Code.  No other license or right
37  * is granted directly or by implication, estoppel or otherwise;
38  *
39  * The above copyright and patent license is granted only if the following
40  * conditions are met:
41  *
42  * 3. Conditions
43  *
44  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
45  * Redistribution of source code of any substantial portion of the Covered
46  * Code or modification with rights to further distribute source must include
47  * the above Copyright Notice, the above License, this list of Conditions,
48  * and the following Disclaimer and Export Compliance provision.  In addition,
49  * Licensee must cause all Covered Code to which Licensee contributes to
50  * contain a file documenting the changes Licensee made to create that Covered
51  * Code and the date of any change.  Licensee must include in that file the
52  * documentation of any changes made by any predecessor Licensee.  Licensee
53  * must include a prominent statement that the modification is derived,
54  * directly or indirectly, from Original Intel Code.
55  *
56  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
57  * Redistribution of source code of any substantial portion of the Covered
58  * Code or modification without rights to further distribute source must
59  * include the following Disclaimer and Export Compliance provision in the
60  * documentation and/or other materials provided with distribution.  In
61  * addition, Licensee may not authorize further sublicense of source of any
62  * portion of the Covered Code, and must include terms to the effect that the
63  * license from Licensee to its licensee is limited to the intellectual
64  * property embodied in the software Licensee provides to its licensee, and
65  * not to intellectual property embodied in modifications its licensee may
66  * make.
67  *
68  * 3.3. Redistribution of Executable. Redistribution in executable form of any
69  * substantial portion of the Covered Code or modification must reproduce the
70  * above Copyright Notice, and the following Disclaimer and Export Compliance
71  * provision in the documentation and/or other materials provided with the
72  * distribution.
73  *
74  * 3.4. Intel retains all right, title, and interest in and to the Original
75  * Intel Code.
76  *
77  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
78  * Intel shall be used in advertising or otherwise to promote the sale, use or
79  * other dealings in products derived from or relating to the Covered Code
80  * without prior written authorization from Intel.
81  *
82  * 4. Disclaimer and Export Compliance
83  *
84  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
85  * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
86  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
87  * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
88  * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
89  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
90  * PARTICULAR PURPOSE.
91  *
92  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
93  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
94  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
95  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
96  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
97  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
98  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
99  * LIMITED REMEDY.
100  *
101  * 4.3. Licensee shall not export, either directly or indirectly, any of this
102  * software or system incorporating such software without first obtaining any
103  * required license or other approval from the U. S. Department of Commerce or
104  * any other agency or department of the United States Government.  In the
105  * event Licensee exports any such software from the United States or
106  * re-exports any such software from a foreign destination, Licensee shall
107  * ensure that the distribution and export/re-export of the software is in
108  * compliance with all laws, regulations, orders, or other restrictions of the
109  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
110  * any of its subsidiaries will export/re-export any technical data, process,
111  * software, or service, directly or indirectly, to any country for which the
112  * United States government or any agency thereof requires an export license,
113  * other governmental approval, or letter of assurance, without first obtaining
114  * such license, approval or letter.
115  *
116  *****************************************************************************/
117 
118 
119 #define _DECLARE_GLOBALS
120 
121 #include <contrib/dev/acpica/compiler/aslcompiler.h>
122 #include <contrib/dev/acpica/acnamesp.h>
123 #include <contrib/dev/acpica/actables.h>
124 #include <contrib/dev/acpica/acapps.h>
125 
126 #ifdef _DEBUG
127 #include <crtdbg.h>
128 #endif
129 
130 #define _COMPONENT          ACPI_COMPILER
131         ACPI_MODULE_NAME    ("aslmain")
132 
133 BOOLEAN                 AslToFile = TRUE;
134 BOOLEAN                 DoCompile = TRUE;
135 BOOLEAN                 DoSignon = TRUE;
136 
137 char                    hex[] =
138 {
139     '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'
140 };
141 
142 /* Local prototypes */
143 
144 static void
145 Options (
146     void);
147 
148 static void
149 HelpMessage (
150     void);
151 
152 static void
153 Usage (
154     void);
155 
156 static void
157 AslInitialize (
158     void);
159 
160 static void
161 AslCommandLine (
162     int                     argc,
163     char                    **argv);
164 
165 #ifdef _DEBUG
166 #include <crtdbg.h>
167 #endif
168 
169 /*******************************************************************************
170  *
171  * FUNCTION:    Options
172  *
173  * PARAMETERS:  None
174  *
175  * RETURN:      None
176  *
177  * DESCRIPTION: Display option help message
178  *
179  ******************************************************************************/
180 
181 static void
182 Options (
183     void)
184 {
185 
186     printf ("General Output:\n");
187     printf ("  -p <prefix>    Specify filename prefix for all output files (including .aml)\n");
188     printf ("  -vi            Less verbose errors and warnings for use with IDEs\n");
189     printf ("  -vo            Enable optimization comments\n");
190     printf ("  -vr            Disable remarks\n");
191     printf ("  -vs            Disable signon\n");
192     printf ("  -w<1|2|3>      Set warning reporting level\n");
193 
194     printf ("\nAML Output Files:\n");
195     printf ("  -s<a|c>        Create AML in assembler or C source file (*.asm or *.c)\n");
196     printf ("  -i<a|c>        Create assembler or C include file (*.inc or *.h)\n");
197     printf ("  -t<a|c>        Create AML in assembler or C hex table (*.hex)\n");
198 
199     printf ("\nAML Code Generation:\n");
200     printf ("  -oa            Disable all optimizations (compatibility mode)\n");
201     printf ("  -of            Disable constant folding\n");
202     printf ("  -oi            Disable integer optimization to Zero/One/Ones\n");
203     printf ("  -on            Disable named reference string optimization\n");
204     printf ("  -r<Revision>   Override table header Revision (1-255)\n");
205 
206     printf ("\nListings:\n");
207     printf ("  -l             Create mixed listing file (ASL source and AML) (*.lst)\n");
208     printf ("  -ln            Create namespace file (*.nsp)\n");
209     printf ("  -ls            Create combined source file (expanded includes) (*.src)\n");
210 
211     printf ("\nAML Disassembler:\n");
212     printf ("  -d  [file]     Disassemble or decode binary ACPI table to file (*.dsl)\n");
213     printf ("  -dc [file]     Disassemble AML and immediately compile it\n");
214     printf ("                 (Obtain DSDT from current system if no input file)\n");
215     printf ("  -e  [file]     Include ACPI table for external symbol resolution\n");
216     printf ("  -2             Emit ACPI 2.0 compatible ASL code\n");
217     printf ("  -g             Get ACPI tables and write to files (*.dat)\n");
218 
219     printf ("\nHelp:\n");
220     printf ("  -h             Additional help and compiler debug options\n");
221     printf ("  -hc            Display operators allowed in constant expressions\n");
222     printf ("  -hr            Display ACPI reserved method names\n");
223 }
224 
225 
226 /*******************************************************************************
227  *
228  * FUNCTION:    HelpMessage
229  *
230  * PARAMETERS:  None
231  *
232  * RETURN:      None
233  *
234  * DESCRIPTION: Display help message
235  *
236  ******************************************************************************/
237 
238 static void
239 HelpMessage (
240     void)
241 {
242 
243     printf ("AML output filename generation:\n");
244     printf ("  Output filenames are generated by appending an extension to a common\n");
245     printf ("  filename prefix.  The filename prefix is obtained via one of the\n");
246     printf ("  following methods (in priority order):\n");
247     printf ("    1) The -p option specifies the prefix\n");
248     printf ("    2) The prefix of the AMLFileName in the ASL Definition Block\n");
249     printf ("    3) The prefix of the input filename\n");
250     printf ("\n");
251 
252     Options ();
253 
254     printf ("\nCompiler/Disassembler Debug Options:\n");
255     printf ("  -b<p|t|b>      Create compiler debug/trace file (*.txt)\n");
256     printf ("                   Types: Parse/Tree/Both\n");
257     printf ("  -f             Ignore errors, force creation of AML output file(s)\n");
258     printf ("  -c             Parse only, no output generation\n");
259     printf ("  -ot            Display compile times\n");
260     printf ("  -x<level>      Set debug level for trace output\n");
261 }
262 
263 
264 /*******************************************************************************
265  *
266  * FUNCTION:    Usage
267  *
268  * PARAMETERS:  None
269  *
270  * RETURN:      None
271  *
272  * DESCRIPTION: Display usage and option message
273  *
274  ******************************************************************************/
275 
276 static void
277 Usage (
278     void)
279 {
280 
281     printf ("Usage:    %s [Options] [InputFile]\n\n", CompilerName);
282     Options ();
283 }
284 
285 
286 /*******************************************************************************
287  *
288  * FUNCTION:    AslInitialize
289  *
290  * PARAMETERS:  None
291  *
292  * RETURN:      None
293  *
294  * DESCRIPTION: Initialize compiler globals
295  *
296  ******************************************************************************/
297 
298 static void
299 AslInitialize (
300     void)
301 {
302     UINT32                  i;
303 
304 
305 #ifdef _DEBUG
306     _CrtSetDbgFlag (_CRTDBG_CHECK_ALWAYS_DF | _CrtSetDbgFlag(0));
307 #endif
308 
309     AcpiDbgLevel = 0;
310 
311     for (i = 0; i < ASL_NUM_FILES; i++)
312     {
313         Gbl_Files[i].Handle = NULL;
314         Gbl_Files[i].Filename = NULL;
315     }
316 
317     Gbl_Files[ASL_FILE_STDOUT].Handle   = stdout;
318     Gbl_Files[ASL_FILE_STDOUT].Filename = "STDOUT";
319 
320     Gbl_Files[ASL_FILE_STDERR].Handle   = stderr;
321     Gbl_Files[ASL_FILE_STDERR].Filename = "STDERR";
322 }
323 
324 
325 /*******************************************************************************
326  *
327  * FUNCTION:    AslCommandLine
328  *
329  * PARAMETERS:  argc/argv
330  *
331  * RETURN:      None
332  *
333  * DESCRIPTION: Command line processing
334  *
335  ******************************************************************************/
336 
337 static void
338 AslCommandLine (
339     int                     argc,
340     char                    **argv)
341 {
342     BOOLEAN                 BadCommandLine = FALSE;
343     ACPI_NATIVE_INT         j;
344 
345 
346     /* Minimum command line contains at least one option or an input file */
347 
348     if (argc < 2)
349     {
350         AslCompilerSignon (ASL_FILE_STDOUT);
351         Usage ();
352         exit (1);
353     }
354 
355     /* Get the command line options */
356 
357     while ((j = AcpiGetopt (argc, argv, "2b:cd^e:fgh^i^l^o:p:r:s:t:v:w:x:")) != EOF) switch (j)
358     {
359     case '2':
360         Gbl_Acpi2 = TRUE;
361         break;
362 
363 
364     case 'b':
365 
366         switch (AcpiGbl_Optarg[0])
367         {
368         case 'b':
369             AslCompilerdebug = 1; /* same as yydebug */
370             break;
371 
372         case 'p':
373             AslCompilerdebug = 1; /* same as yydebug */
374             break;
375 
376         case 't':
377             break;
378 
379         default:
380             printf ("Unknown option: -b%s\n", AcpiGbl_Optarg);
381             BadCommandLine = TRUE;
382             break;
383         }
384 
385         /* Produce debug output file */
386 
387         Gbl_DebugFlag = TRUE;
388         break;
389 
390 
391     case 'c':
392 
393         /* Parse only */
394 
395         Gbl_ParseOnlyFlag = TRUE;
396         break;
397 
398 
399     case 'd':
400         switch (AcpiGbl_Optarg[0])
401         {
402         case '^':
403             DoCompile = FALSE;
404             break;
405 
406         case 'c':
407             break;
408 
409         default:
410             printf ("Unknown option: -d%s\n", AcpiGbl_Optarg);
411             BadCommandLine = TRUE;
412             break;
413         }
414 
415         Gbl_DisasmFlag = TRUE;
416         break;
417 
418 
419     case 'e':
420         Gbl_ExternalFilename = AcpiGbl_Optarg;
421         break;
422 
423 
424     case 'f':
425 
426         /* Ignore errors and force creation of aml file */
427 
428         Gbl_IgnoreErrors = TRUE;
429         break;
430 
431 
432     case 'g':
433 
434         /* Get all ACPI tables */
435 
436         Gbl_GetAllTables = TRUE;
437         DoCompile = FALSE;
438         break;
439 
440 
441     case 'h':
442 
443         switch (AcpiGbl_Optarg[0])
444         {
445         case '^':
446             HelpMessage ();
447             exit (0);
448 
449         case 'c':
450             UtDisplayConstantOpcodes ();
451             exit (0);
452 
453         case 'r':
454             /* reserved names */
455 
456             MpDisplayReservedNames ();
457             exit (0);
458 
459         default:
460             printf ("Unknown option: -h%s\n", AcpiGbl_Optarg);
461             BadCommandLine = TRUE;
462             break;
463         }
464         break;
465 
466 
467     case 'i':
468 
469         switch (AcpiGbl_Optarg[0])
470         {
471         case 'a':
472 
473             /* Produce assembly code include file */
474 
475             Gbl_AsmIncludeOutputFlag = TRUE;
476             break;
477 
478         case 'c':
479 
480             /* Produce C include file */
481 
482             Gbl_C_IncludeOutputFlag = TRUE;
483             break;
484 
485         default:
486             printf ("Unknown option: -s%s\n", AcpiGbl_Optarg);
487             BadCommandLine = TRUE;
488             break;
489         }
490         break;
491 
492 
493     case 'l':
494 
495         switch (AcpiGbl_Optarg[0])
496         {
497         case '^':
498             /* Produce listing file (Mixed source/aml) */
499 
500             Gbl_ListingFlag = TRUE;
501             break;
502 
503         case 'n':
504             /* Produce namespace file */
505 
506             Gbl_NsOutputFlag = TRUE;
507             break;
508 
509         case 's':
510             /* Produce combined source file */
511 
512             Gbl_SourceOutputFlag = TRUE;
513             break;
514 
515         default:
516             printf ("Unknown option: -l%s\n", AcpiGbl_Optarg);
517             BadCommandLine = TRUE;
518             break;
519         }
520         break;
521 
522 
523     case 'o':
524 
525         switch (AcpiGbl_Optarg[0])
526         {
527         case 'a':
528 
529             /* Disable all optimizations */
530 
531             Gbl_FoldConstants = FALSE;
532             Gbl_IntegerOptimizationFlag = FALSE;
533             Gbl_ReferenceOptimizationFlag = FALSE;
534             break;
535 
536         case 'f':
537 
538             /* Disable folding on "normal" expressions */
539 
540             Gbl_FoldConstants = FALSE;
541             break;
542 
543         case 'i':
544 
545             /* Disable integer optimization to constants */
546 
547             Gbl_IntegerOptimizationFlag = FALSE;
548             break;
549 
550         case 'n':
551 
552             /* Disable named reference optimization */
553 
554             Gbl_ReferenceOptimizationFlag = FALSE;
555             break;
556 
557         case 't':
558 
559             /* Display compile time(s) */
560 
561             Gbl_CompileTimesFlag = TRUE;
562             break;
563 
564         default:
565             printf ("Unknown option: -c%s\n", AcpiGbl_Optarg);
566             BadCommandLine = TRUE;
567             break;
568         }
569         break;
570 
571 
572     case 'p':
573 
574         /* Override default AML output filename */
575 
576         Gbl_OutputFilenamePrefix = AcpiGbl_Optarg;
577         Gbl_UseDefaultAmlFilename = FALSE;
578         break;
579 
580 
581     case 'r':
582         Gbl_RevisionOverride = (UINT8) strtoul (AcpiGbl_Optarg, NULL, 0);
583         break;
584 
585 
586     case 's':
587 
588         switch (AcpiGbl_Optarg[0])
589         {
590         case 'a':
591 
592             /* Produce assembly code output file */
593 
594             Gbl_AsmOutputFlag = TRUE;
595             break;
596 
597         case 'c':
598 
599             /* Produce C hex output file */
600 
601             Gbl_C_OutputFlag = TRUE;
602             break;
603 
604         default:
605             printf ("Unknown option: -s%s\n", AcpiGbl_Optarg);
606             BadCommandLine = TRUE;
607             break;
608         }
609         break;
610 
611 
612     case 't':
613 
614         /* Produce hex table output file */
615 
616         switch (AcpiGbl_Optarg[0])
617         {
618         case 'a':
619             Gbl_HexOutputFlag = HEX_OUTPUT_ASM;
620             break;
621 
622         case 'c':
623             Gbl_HexOutputFlag = HEX_OUTPUT_C;
624             break;
625 
626         default:
627             printf ("Unknown option: -t%s\n", AcpiGbl_Optarg);
628             BadCommandLine = TRUE;
629             break;
630         }
631         break;
632 
633 
634     case 'v':
635 
636         switch (AcpiGbl_Optarg[0])
637         {
638         case 'i':
639             /* Less verbose error messages */
640 
641             Gbl_VerboseErrors = FALSE;
642             break;
643 
644         case 'o':
645             Gbl_DisplayOptimizations = TRUE;
646             break;
647 
648         case 'r':
649             Gbl_DisplayRemarks = FALSE;
650             break;
651 
652         case 's':
653             DoSignon = FALSE;
654             break;
655 
656         default:
657             printf ("Unknown option: -v%s\n", AcpiGbl_Optarg);
658             BadCommandLine = TRUE;
659             break;
660         }
661         break;
662 
663 
664     case 'w': /* Set warning levels */
665 
666         switch (AcpiGbl_Optarg[0])
667         {
668         case '1':
669             Gbl_WarningLevel = ASL_WARNING;
670             break;
671 
672         case '2':
673             Gbl_WarningLevel = ASL_WARNING2;
674             break;
675 
676         case '3':
677             Gbl_WarningLevel = ASL_WARNING3;
678             break;
679 
680         default:
681             printf ("Unknown option: -w%s\n", AcpiGbl_Optarg);
682             BadCommandLine = TRUE;
683             break;
684         }
685         break;
686 
687 
688     case 'x':
689 
690         AcpiDbgLevel = strtoul (AcpiGbl_Optarg, NULL, 16);
691         break;
692 
693 
694     default:
695 
696         BadCommandLine = TRUE;
697         break;
698     }
699 
700     /* Next parameter must be the input filename */
701 
702     Gbl_Files[ASL_FILE_INPUT].Filename = argv[AcpiGbl_Optind];
703 
704     if (!Gbl_Files[ASL_FILE_INPUT].Filename &&
705         !Gbl_DisasmFlag &&
706         !Gbl_GetAllTables)
707     {
708         printf ("Missing input filename\n");
709         BadCommandLine = TRUE;
710     }
711 
712     if (DoSignon)
713     {
714         AslCompilerSignon (ASL_FILE_STDOUT);
715     }
716 
717     /* Abort if anything went wrong on the command line */
718 
719     if (BadCommandLine)
720     {
721         printf ("\n");
722         Usage ();
723         exit (1);
724     }
725 
726     if ((AcpiGbl_Optind + 1) < argc)
727     {
728         printf ("Warning: extra arguments (%d) after input filename are ignored\n\n",
729             argc - AcpiGbl_Optind - 1);
730     }
731 }
732 
733 
734 /*******************************************************************************
735  *
736  * FUNCTION:    main
737  *
738  * PARAMETERS:  Standard argc/argv
739  *
740  * RETURN:      Program termination code
741  *
742  * DESCRIPTION: C main routine for the Asl Compiler.  Handle command line
743  *              options and begin the compile.
744  *
745  ******************************************************************************/
746 
747 int ACPI_SYSTEM_XFACE
748 main (
749     int                     argc,
750     char                    **argv)
751 {
752     ACPI_STATUS             Status;
753     char                    *Prefix;
754 
755 
756 #ifdef _DEBUG
757     _CrtSetDbgFlag (_CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_LEAK_CHECK_DF |
758                     _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG));
759 #endif
760 
761     /* Init and command line */
762 
763     AslInitialize ();
764     AslCommandLine (argc, argv);
765 
766     /*
767      * If -p not specified, we will use the input filename as the
768      * output filename prefix
769      */
770     Status = FlSplitInputPathname (Gbl_Files[ASL_FILE_INPUT].Filename,
771         &Gbl_DirectoryPath, &Prefix);
772     if (ACPI_FAILURE (Status))
773     {
774         return -1;
775     }
776 
777     if (Gbl_UseDefaultAmlFilename)
778     {
779         Gbl_OutputFilenamePrefix = Prefix;
780     }
781 
782     /* AML Disassembly (Optional) */
783 
784     if (Gbl_DisasmFlag || Gbl_GetAllTables)
785     {
786         /* ACPI CA subsystem initialization */
787 
788         Status = AdInitialize ();
789         if (ACPI_FAILURE (Status))
790         {
791             return -1;
792         }
793 
794         Status = AcpiAllocateRootTable (4);
795         if (ACPI_FAILURE (Status))
796         {
797             AcpiOsPrintf ("Could not initialize ACPI Table Manager, %s\n",
798                 AcpiFormatException (Status));
799             return -1;
800         }
801 
802         /* This is where the disassembly happens */
803 
804         AcpiGbl_DbOpt_disasm = TRUE;
805         Status = AdAmlDisassemble (AslToFile,
806                         Gbl_Files[ASL_FILE_INPUT].Filename,
807                         Gbl_OutputFilenamePrefix,
808                         &Gbl_Files[ASL_FILE_INPUT].Filename,
809                         Gbl_GetAllTables);
810         if (ACPI_FAILURE (Status))
811         {
812             return -1;
813         }
814 
815         /*
816          * Gbl_Files[ASL_FILE_INPUT].Filename was replaced with the
817          * .DSL disassembly file, which can now be compiled if requested
818          */
819         if (DoCompile)
820         {
821             AcpiOsPrintf ("\nCompiling \"%s\"\n",
822                 Gbl_Files[ASL_FILE_INPUT].Filename);
823         }
824     }
825 
826     /*
827      * ASL Compilation (Optional)
828      */
829     if (DoCompile)
830     {
831         /*
832          * If -p not specified, we will use the input filename as the
833          * output filename prefix
834          */
835         Status = FlSplitInputPathname (Gbl_Files[ASL_FILE_INPUT].Filename,
836             &Gbl_DirectoryPath, &Prefix);
837         if (ACPI_FAILURE (Status))
838         {
839             return -1;
840         }
841 
842         if (Gbl_UseDefaultAmlFilename)
843         {
844             Gbl_OutputFilenamePrefix = Prefix;
845         }
846 
847         /* ACPI CA subsystem initialization (Must be re-initialized) */
848 
849         Status = AcpiOsInitialize ();
850         AcpiUtInitGlobals ();
851         Status = AcpiUtMutexInitialize ();
852         if (ACPI_FAILURE (Status))
853         {
854             return -1;
855         }
856 
857         Status = AcpiNsRootInitialize ();
858         if (ACPI_FAILURE (Status))
859         {
860             return -1;
861         }
862         Status = CmDoCompile ();
863     }
864 
865     return (0);
866 }
867 
868 
869