]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - sys/contrib/dev/acpica/compiler/aslfiles.c
- Copy stable/10@285827 to releng/10.2 in preparation for 10.2-RC1
[FreeBSD/releng/10.2.git] / sys / contrib / dev / acpica / compiler / aslfiles.c
1 /******************************************************************************
2  *
3  * Module Name: aslfiles - File support functions
4  *
5  *****************************************************************************/
6
7 /*
8  * Copyright (C) 2000 - 2015, 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 MERCHANTIBILITY 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 <contrib/dev/acpica/compiler/aslcompiler.h>
45 #include <contrib/dev/acpica/include/acapps.h>
46
47 #define _COMPONENT          ACPI_COMPILER
48         ACPI_MODULE_NAME    ("aslfiles")
49
50 /* Local prototypes */
51
52 static FILE *
53 FlOpenIncludeWithPrefix (
54     char                    *PrefixDir,
55     ACPI_PARSE_OBJECT       *Op,
56     char                    *Filename);
57
58
59 #ifdef ACPI_OBSOLETE_FUNCTIONS
60 ACPI_STATUS
61 FlParseInputPathname (
62     char                    *InputFilename);
63 #endif
64
65
66 /*******************************************************************************
67  *
68  * FUNCTION:    FlSetLineNumber
69  *
70  * PARAMETERS:  Op        - Parse node for the LINE asl statement
71  *
72  * RETURN:      None.
73  *
74  * DESCRIPTION: Set the current line number
75  *
76  ******************************************************************************/
77
78 void
79 FlSetLineNumber (
80     UINT32                  LineNumber)
81 {
82
83     DbgPrint (ASL_PARSE_OUTPUT, "\n#line: New line number %u (old %u)\n",
84          LineNumber, Gbl_LogicalLineNumber);
85
86     Gbl_CurrentLineNumber = LineNumber;
87     Gbl_LogicalLineNumber = LineNumber;
88 }
89
90
91 /*******************************************************************************
92  *
93  * FUNCTION:    FlSetFilename
94  *
95  * PARAMETERS:  Op        - Parse node for the LINE asl statement
96  *
97  * RETURN:      None.
98  *
99  * DESCRIPTION: Set the current filename
100  *
101  ******************************************************************************/
102
103 void
104 FlSetFilename (
105     char                    *Filename)
106 {
107
108     DbgPrint (ASL_PARSE_OUTPUT, "\n#line: New filename %s (old %s)\n",
109          Filename, Gbl_Files[ASL_FILE_INPUT].Filename);
110
111     /* No need to free any existing filename */
112
113     Gbl_Files[ASL_FILE_INPUT].Filename = Filename;
114 }
115
116
117 /*******************************************************************************
118  *
119  * FUNCTION:    FlAddIncludeDirectory
120  *
121  * PARAMETERS:  Dir             - Directory pathname string
122  *
123  * RETURN:      None
124  *
125  * DESCRIPTION: Add a directory the list of include prefix directories.
126  *
127  ******************************************************************************/
128
129 void
130 FlAddIncludeDirectory (
131     char                    *Dir)
132 {
133     ASL_INCLUDE_DIR         *NewDir;
134     ASL_INCLUDE_DIR         *NextDir;
135     ASL_INCLUDE_DIR         *PrevDir = NULL;
136     UINT32                  NeedsSeparator = 0;
137     size_t                  DirLength;
138
139
140     DirLength = strlen (Dir);
141     if (!DirLength)
142     {
143         return;
144     }
145
146     /* Make sure that the pathname ends with a path separator */
147
148     if ((Dir[DirLength-1] != '/') &&
149         (Dir[DirLength-1] != '\\'))
150     {
151         NeedsSeparator = 1;
152     }
153
154     NewDir = ACPI_ALLOCATE_ZEROED (sizeof (ASL_INCLUDE_DIR));
155     NewDir->Dir = ACPI_ALLOCATE (DirLength + 1 + NeedsSeparator);
156     strcpy (NewDir->Dir, Dir);
157     if (NeedsSeparator)
158     {
159         strcat (NewDir->Dir, "/");
160     }
161
162     /*
163      * Preserve command line ordering of -I options by adding new elements
164      * at the end of the list
165      */
166     NextDir = Gbl_IncludeDirList;
167     while (NextDir)
168     {
169         PrevDir = NextDir;
170         NextDir = NextDir->Next;
171     }
172
173     if (PrevDir)
174     {
175         PrevDir->Next = NewDir;
176     }
177     else
178     {
179         Gbl_IncludeDirList = NewDir;
180     }
181 }
182
183
184 /*******************************************************************************
185  *
186  * FUNCTION:    FlMergePathnames
187  *
188  * PARAMETERS:  PrefixDir       - Prefix directory pathname. Can be NULL or
189  *                                a zero length string.
190  *              FilePathname    - The include filename from the source ASL.
191  *
192  * RETURN:      Merged pathname string
193  *
194  * DESCRIPTION: Merge two pathnames that (probably) have common elements, to
195  *              arrive at a minimal length string. Merge can occur if the
196  *              FilePathname is relative to the PrefixDir.
197  *
198  ******************************************************************************/
199
200 char *
201 FlMergePathnames (
202     char                    *PrefixDir,
203     char                    *FilePathname)
204 {
205     char                    *CommonPath;
206     char                    *Pathname;
207     char                    *LastElement;
208
209
210     DbgPrint (ASL_PARSE_OUTPUT, "Include: Prefix path - \"%s\"\n"
211         "Include: FilePathname - \"%s\"\n",
212          PrefixDir, FilePathname);
213
214     /*
215      * If there is no prefix directory or if the file pathname is absolute,
216      * just return the original file pathname
217      */
218     if (!PrefixDir || (!*PrefixDir) ||
219         (*FilePathname == '/') ||
220          (FilePathname[1] == ':'))
221     {
222         Pathname = UtStringCacheCalloc (strlen (FilePathname) + 1);
223         strcpy (Pathname, FilePathname);
224         goto ConvertBackslashes;
225     }
226
227     /* Need a local copy of the prefix directory path */
228
229     CommonPath = UtStringCacheCalloc (strlen (PrefixDir) + 1);
230     strcpy (CommonPath, PrefixDir);
231
232     /*
233      * Walk forward through the file path, and simultaneously backward
234      * through the prefix directory path until there are no more
235      * relative references at the start of the file path.
236      */
237     while (*FilePathname && (!strncmp (FilePathname, "../", 3)))
238     {
239         /* Remove last element of the prefix directory path */
240
241         LastElement = strrchr (CommonPath, '/');
242         if (!LastElement)
243         {
244             goto ConcatenatePaths;
245         }
246
247         *LastElement = 0;   /* Terminate CommonPath string */
248         FilePathname += 3;  /* Point to next path element */
249     }
250
251     /*
252      * Remove the last element of the prefix directory path (it is the same as
253      * the first element of the file pathname), and build the final merged
254      * pathname.
255      */
256     LastElement = strrchr (CommonPath, '/');
257     if (LastElement)
258     {
259         *LastElement = 0;
260     }
261
262     /* Build the final merged pathname */
263
264 ConcatenatePaths:
265     Pathname = UtStringCacheCalloc (strlen (CommonPath) + strlen (FilePathname) + 2);
266     if (LastElement && *CommonPath)
267     {
268         strcpy (Pathname, CommonPath);
269         strcat (Pathname, "/");
270     }
271     strcat (Pathname, FilePathname);
272
273     /* Convert all backslashes to normal slashes */
274
275 ConvertBackslashes:
276     UtConvertBackslashes (Pathname);
277
278     DbgPrint (ASL_PARSE_OUTPUT, "Include: Merged Pathname - \"%s\"\n",
279          Pathname);
280     return (Pathname);
281 }
282
283
284 /*******************************************************************************
285  *
286  * FUNCTION:    FlOpenIncludeWithPrefix
287  *
288  * PARAMETERS:  PrefixDir       - Prefix directory pathname. Can be a zero
289  *                                length string.
290  *              Filename        - The include filename from the source ASL.
291  *
292  * RETURN:      Valid file descriptor if successful. Null otherwise.
293  *
294  * DESCRIPTION: Open an include file and push it on the input file stack.
295  *
296  ******************************************************************************/
297
298 static FILE *
299 FlOpenIncludeWithPrefix (
300     char                    *PrefixDir,
301     ACPI_PARSE_OBJECT       *Op,
302     char                    *Filename)
303 {
304     FILE                    *IncludeFile;
305     char                    *Pathname;
306
307
308     /* Build the full pathname to the file */
309
310     Pathname = FlMergePathnames (PrefixDir, Filename);
311
312     DbgPrint (ASL_PARSE_OUTPUT, "Include: Opening file - \"%s\"\n\n",
313         Pathname);
314
315     /* Attempt to open the file, push if successful */
316
317     IncludeFile = fopen (Pathname, "r");
318     if (!IncludeFile)
319     {
320         fprintf (stderr, "Could not open include file %s\n", Pathname);
321         ACPI_FREE (Pathname);
322         return (NULL);
323     }
324
325 #ifdef _MUST_HANDLE_COMMENTS
326     /*
327      * Check entire include file for any # preprocessor directives.
328      * This is because there may be some confusion between the #include
329      * preprocessor directive and the ASL Include statement.
330      */
331     while (fgets (Gbl_CurrentLineBuffer, Gbl_LineBufferSize, IncludeFile))
332     {
333         if (Gbl_CurrentLineBuffer[0] == '#')
334         {
335             AslError (ASL_ERROR, ASL_MSG_INCLUDE_FILE,
336                 Op, "use #include instead");
337         }
338     }
339 #endif
340
341     /* Must seek back to the start of the file */
342
343     fseek (IncludeFile, 0, SEEK_SET);
344
345     /* Push the include file on the open input file stack */
346
347     AslPushInputFileStack (IncludeFile, Pathname);
348     return (IncludeFile);
349 }
350
351
352 /*******************************************************************************
353  *
354  * FUNCTION:    FlOpenIncludeFile
355  *
356  * PARAMETERS:  Op        - Parse node for the INCLUDE ASL statement
357  *
358  * RETURN:      None.
359  *
360  * DESCRIPTION: Open an include file and push it on the input file stack.
361  *
362  ******************************************************************************/
363
364 void
365 FlOpenIncludeFile (
366     ACPI_PARSE_OBJECT       *Op)
367 {
368     FILE                    *IncludeFile;
369     ASL_INCLUDE_DIR         *NextDir;
370
371
372     /* Op must be valid */
373
374     if (!Op)
375     {
376         AslCommonError (ASL_ERROR, ASL_MSG_INCLUDE_FILE_OPEN,
377             Gbl_CurrentLineNumber, Gbl_LogicalLineNumber,
378             Gbl_InputByteCount, Gbl_CurrentColumn,
379             Gbl_Files[ASL_FILE_INPUT].Filename, " - Null parse node");
380
381         return;
382     }
383
384     /*
385      * Flush out the "include ()" statement on this line, start
386      * the actual include file on the next line
387      */
388     AslResetCurrentLineBuffer ();
389     FlPrintFile (ASL_FILE_SOURCE_OUTPUT, "\n");
390     Gbl_CurrentLineOffset++;
391
392
393     /* Attempt to open the include file */
394
395     /* If the file specifies an absolute path, just open it */
396
397     if ((Op->Asl.Value.String[0] == '/')  ||
398         (Op->Asl.Value.String[0] == '\\') ||
399         (Op->Asl.Value.String[1] == ':'))
400     {
401         IncludeFile = FlOpenIncludeWithPrefix ("", Op, Op->Asl.Value.String);
402         if (!IncludeFile)
403         {
404             goto ErrorExit;
405         }
406         return;
407     }
408
409     /*
410      * The include filename is not an absolute path.
411      *
412      * First, search for the file within the "local" directory -- meaning
413      * the same directory that contains the source file.
414      *
415      * Construct the file pathname from the global directory name.
416      */
417     IncludeFile = FlOpenIncludeWithPrefix (Gbl_DirectoryPath, Op, Op->Asl.Value.String);
418     if (IncludeFile)
419     {
420         return;
421     }
422
423     /*
424      * Second, search for the file within the (possibly multiple) directories
425      * specified by the -I option on the command line.
426      */
427     NextDir = Gbl_IncludeDirList;
428     while (NextDir)
429     {
430         IncludeFile = FlOpenIncludeWithPrefix (NextDir->Dir, Op, Op->Asl.Value.String);
431         if (IncludeFile)
432         {
433             return;
434         }
435
436         NextDir = NextDir->Next;
437     }
438
439     /* We could not open the include file after trying very hard */
440
441 ErrorExit:
442     sprintf (MsgBuffer, "%s, %s", Op->Asl.Value.String, strerror (errno));
443     AslError (ASL_ERROR, ASL_MSG_INCLUDE_FILE_OPEN, Op, MsgBuffer);
444 }
445
446
447 /*******************************************************************************
448  *
449  * FUNCTION:    FlOpenInputFile
450  *
451  * PARAMETERS:  InputFilename       - The user-specified ASL source file to be
452  *                                    compiled
453  *
454  * RETURN:      Status
455  *
456  * DESCRIPTION: Open the specified input file, and save the directory path to
457  *              the file so that include files can be opened in
458  *              the same directory.
459  *
460  ******************************************************************************/
461
462 ACPI_STATUS
463 FlOpenInputFile (
464     char                    *InputFilename)
465 {
466
467     /* Open the input ASL file, text mode */
468
469     FlOpenFile (ASL_FILE_INPUT, InputFilename, "rt");
470     AslCompilerin = Gbl_Files[ASL_FILE_INPUT].Handle;
471
472     return (AE_OK);
473 }
474
475
476 /*******************************************************************************
477  *
478  * FUNCTION:    FlOpenAmlOutputFile
479  *
480  * PARAMETERS:  FilenamePrefix       - The user-specified ASL source file
481  *
482  * RETURN:      Status
483  *
484  * DESCRIPTION: Create the output filename (*.AML) and open the file. The file
485  *              is created in the same directory as the parent input file.
486  *
487  ******************************************************************************/
488
489 ACPI_STATUS
490 FlOpenAmlOutputFile (
491     char                    *FilenamePrefix)
492 {
493     char                    *Filename;
494
495
496     /* Output filename usually comes from the ASL itself */
497
498     Filename = Gbl_Files[ASL_FILE_AML_OUTPUT].Filename;
499     if (!Filename)
500     {
501         /* Create the output AML filename */
502
503         Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_AML_CODE);
504         if (!Filename)
505         {
506             AslCommonError (ASL_ERROR, ASL_MSG_OUTPUT_FILENAME,
507                 0, 0, 0, 0, NULL, NULL);
508             return (AE_ERROR);
509         }
510
511         Gbl_Files[ASL_FILE_AML_OUTPUT].Filename = Filename;
512     }
513
514     /* Open the output AML file in binary mode */
515
516     FlOpenFile (ASL_FILE_AML_OUTPUT, Filename, "w+b");
517     return (AE_OK);
518 }
519
520
521 /*******************************************************************************
522  *
523  * FUNCTION:    FlOpenMiscOutputFiles
524  *
525  * PARAMETERS:  FilenamePrefix       - The user-specified ASL source file
526  *
527  * RETURN:      Status
528  *
529  * DESCRIPTION: Create and open the various output files needed, depending on
530  *              the command line options
531  *
532  ******************************************************************************/
533
534 ACPI_STATUS
535 FlOpenMiscOutputFiles (
536     char                    *FilenamePrefix)
537 {
538     char                    *Filename;
539
540
541     /* All done for disassembler */
542
543     if (Gbl_FileType == ASL_INPUT_TYPE_ACPI_TABLE)
544     {
545         return (AE_OK);
546     }
547
548     /* Create/Open a hex output file if asked */
549
550     if (Gbl_HexOutputFlag)
551     {
552         Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_HEX_DUMP);
553         if (!Filename)
554         {
555             AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
556                 0, 0, 0, 0, NULL, NULL);
557             return (AE_ERROR);
558         }
559
560         /* Open the hex file, text mode */
561
562         FlOpenFile (ASL_FILE_HEX_OUTPUT, Filename, "w+t");
563
564         AslCompilerSignon (ASL_FILE_HEX_OUTPUT);
565         AslCompilerFileHeader (ASL_FILE_HEX_OUTPUT);
566     }
567
568     /* Create/Open a debug output file if asked */
569
570     if (Gbl_DebugFlag)
571     {
572         Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_DEBUG);
573         if (!Filename)
574         {
575             AslCommonError (ASL_ERROR, ASL_MSG_DEBUG_FILENAME,
576                 0, 0, 0, 0, NULL, NULL);
577             return (AE_ERROR);
578         }
579
580         /* Open the debug file as STDERR, text mode */
581
582         /* TBD: hide this behind a FlReopenFile function */
583
584         Gbl_Files[ASL_FILE_DEBUG_OUTPUT].Filename = Filename;
585         Gbl_Files[ASL_FILE_DEBUG_OUTPUT].Handle =
586             freopen (Filename, "w+t", stderr);
587
588         if (!Gbl_Files[ASL_FILE_DEBUG_OUTPUT].Handle)
589         {
590             /*
591              * A problem with freopen is that on error,
592              * we no longer have stderr.
593              */
594             Gbl_DebugFlag = FALSE;
595             memcpy (stderr, stdout, sizeof (FILE));
596             FlFileError (ASL_FILE_DEBUG_OUTPUT, ASL_MSG_DEBUG_FILENAME);
597             AslAbort ();
598         }
599
600         AslCompilerSignon (ASL_FILE_DEBUG_OUTPUT);
601         AslCompilerFileHeader (ASL_FILE_DEBUG_OUTPUT);
602     }
603
604     /* Create/Open a listing output file if asked */
605
606     if (Gbl_ListingFlag)
607     {
608         Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_LISTING);
609         if (!Filename)
610         {
611             AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
612                 0, 0, 0, 0, NULL, NULL);
613             return (AE_ERROR);
614         }
615
616         /* Open the listing file, text mode */
617
618         FlOpenFile (ASL_FILE_LISTING_OUTPUT, Filename, "w+t");
619
620         AslCompilerSignon (ASL_FILE_LISTING_OUTPUT);
621         AslCompilerFileHeader (ASL_FILE_LISTING_OUTPUT);
622     }
623
624     /* Create the preprocessor output file if preprocessor enabled */
625
626     if (Gbl_PreprocessFlag)
627     {
628         Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_PREPROCESSOR);
629         if (!Filename)
630         {
631             AslCommonError (ASL_ERROR, ASL_MSG_PREPROCESSOR_FILENAME,
632                 0, 0, 0, 0, NULL, NULL);
633             return (AE_ERROR);
634         }
635
636         FlOpenFile (ASL_FILE_PREPROCESSOR, Filename, "w+t");
637     }
638
639     /* All done for data table compiler */
640
641     if (Gbl_FileType == ASL_INPUT_TYPE_ASCII_DATA)
642     {
643         return (AE_OK);
644     }
645
646     /* Create/Open a combined source output file */
647
648     Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_SOURCE);
649     if (!Filename)
650     {
651         AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
652             0, 0, 0, 0, NULL, NULL);
653         return (AE_ERROR);
654     }
655
656     /*
657      * Open the source output file, binary mode (so that LF does not get
658      * expanded to CR/LF on some systems, messing up our seek
659      * calculations.)
660      */
661     FlOpenFile (ASL_FILE_SOURCE_OUTPUT, Filename, "w+b");
662
663 /*
664 // TBD: TEMP
665 //    AslCompilerin = Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Handle;
666 */
667     /* Create/Open a assembly code source output file if asked */
668
669     if (Gbl_AsmOutputFlag)
670     {
671         Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_ASM_SOURCE);
672         if (!Filename)
673         {
674             AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
675                 0, 0, 0, 0, NULL, NULL);
676             return (AE_ERROR);
677         }
678
679         /* Open the assembly code source file, text mode */
680
681         FlOpenFile (ASL_FILE_ASM_SOURCE_OUTPUT, Filename, "w+t");
682
683         AslCompilerSignon (ASL_FILE_ASM_SOURCE_OUTPUT);
684         AslCompilerFileHeader (ASL_FILE_ASM_SOURCE_OUTPUT);
685     }
686
687     /* Create/Open a C code source output file if asked */
688
689     if (Gbl_C_OutputFlag)
690     {
691         Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_C_SOURCE);
692         if (!Filename)
693         {
694             AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
695                 0, 0, 0, 0, NULL, NULL);
696             return (AE_ERROR);
697         }
698
699         /* Open the C code source file, text mode */
700
701         FlOpenFile (ASL_FILE_C_SOURCE_OUTPUT, Filename, "w+t");
702
703         FlPrintFile (ASL_FILE_C_SOURCE_OUTPUT, "/*\n");
704         AslCompilerSignon (ASL_FILE_C_SOURCE_OUTPUT);
705         AslCompilerFileHeader (ASL_FILE_C_SOURCE_OUTPUT);
706     }
707
708     /* Create/Open a C code source output file for the offset table if asked */
709
710     if (Gbl_C_OffsetTableFlag)
711     {
712         Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_C_OFFSET);
713         if (!Filename)
714         {
715             AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
716                 0, 0, 0, 0, NULL, NULL);
717             return (AE_ERROR);
718         }
719
720         /* Open the C code source file, text mode */
721
722         FlOpenFile (ASL_FILE_C_OFFSET_OUTPUT, Filename, "w+t");
723
724         FlPrintFile (ASL_FILE_C_OFFSET_OUTPUT, "/*\n");
725         AslCompilerSignon (ASL_FILE_C_OFFSET_OUTPUT);
726         AslCompilerFileHeader (ASL_FILE_C_OFFSET_OUTPUT);
727     }
728
729     /* Create/Open a assembly include output file if asked */
730
731     if (Gbl_AsmIncludeOutputFlag)
732     {
733         Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_ASM_INCLUDE);
734         if (!Filename)
735         {
736             AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
737                 0, 0, 0, 0, NULL, NULL);
738             return (AE_ERROR);
739         }
740
741         /* Open the assembly include file, text mode */
742
743         FlOpenFile (ASL_FILE_ASM_INCLUDE_OUTPUT, Filename, "w+t");
744
745         AslCompilerSignon (ASL_FILE_ASM_INCLUDE_OUTPUT);
746         AslCompilerFileHeader (ASL_FILE_ASM_INCLUDE_OUTPUT);
747     }
748
749     /* Create/Open a C include output file if asked */
750
751     if (Gbl_C_IncludeOutputFlag)
752     {
753         Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_C_INCLUDE);
754         if (!Filename)
755         {
756             AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
757                 0, 0, 0, 0, NULL, NULL);
758             return (AE_ERROR);
759         }
760
761         /* Open the C include file, text mode */
762
763         FlOpenFile (ASL_FILE_C_INCLUDE_OUTPUT, Filename, "w+t");
764
765         FlPrintFile (ASL_FILE_C_INCLUDE_OUTPUT, "/*\n");
766         AslCompilerSignon (ASL_FILE_C_INCLUDE_OUTPUT);
767         AslCompilerFileHeader (ASL_FILE_C_INCLUDE_OUTPUT);
768     }
769
770     /* Create a namespace output file if asked */
771
772     if (Gbl_NsOutputFlag)
773     {
774         Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_NAMESPACE);
775         if (!Filename)
776         {
777             AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
778                 0, 0, 0, 0, NULL, NULL);
779             return (AE_ERROR);
780         }
781
782         /* Open the namespace file, text mode */
783
784         FlOpenFile (ASL_FILE_NAMESPACE_OUTPUT, Filename, "w+t");
785
786         AslCompilerSignon (ASL_FILE_NAMESPACE_OUTPUT);
787         AslCompilerFileHeader (ASL_FILE_NAMESPACE_OUTPUT);
788     }
789
790     /* Create/Open a map file if requested */
791
792     if (Gbl_MapfileFlag)
793     {
794         Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_MAP);
795         if (!Filename)
796         {
797             AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
798                 0, 0, 0, 0, NULL, NULL);
799             return (AE_ERROR);
800         }
801
802         /* Open the hex file, text mode (closed at compiler exit) */
803
804         FlOpenFile (ASL_FILE_MAP_OUTPUT, Filename, "w+t");
805
806         AslCompilerSignon (ASL_FILE_MAP_OUTPUT);
807         AslCompilerFileHeader (ASL_FILE_MAP_OUTPUT);
808     }
809
810     return (AE_OK);
811 }
812
813
814 #ifdef ACPI_OBSOLETE_FUNCTIONS
815 /*******************************************************************************
816  *
817  * FUNCTION:    FlParseInputPathname
818  *
819  * PARAMETERS:  InputFilename       - The user-specified ASL source file to be
820  *                                    compiled
821  *
822  * RETURN:      Status
823  *
824  * DESCRIPTION: Split the input path into a directory and filename part
825  *              1) Directory part used to open include files
826  *              2) Filename part used to generate output filenames
827  *
828  ******************************************************************************/
829
830 ACPI_STATUS
831 FlParseInputPathname (
832     char                    *InputFilename)
833 {
834     char                    *Substring;
835
836
837     if (!InputFilename)
838     {
839         return (AE_OK);
840     }
841
842     /* Get the path to the input filename's directory */
843
844     Gbl_DirectoryPath = strdup (InputFilename);
845     if (!Gbl_DirectoryPath)
846     {
847         return (AE_NO_MEMORY);
848     }
849
850     Substring = strrchr (Gbl_DirectoryPath, '\\');
851     if (!Substring)
852     {
853         Substring = strrchr (Gbl_DirectoryPath, '/');
854         if (!Substring)
855         {
856             Substring = strrchr (Gbl_DirectoryPath, ':');
857         }
858     }
859
860     if (!Substring)
861     {
862         Gbl_DirectoryPath[0] = 0;
863         if (Gbl_UseDefaultAmlFilename)
864         {
865             Gbl_OutputFilenamePrefix = strdup (InputFilename);
866         }
867     }
868     else
869     {
870         if (Gbl_UseDefaultAmlFilename)
871         {
872             Gbl_OutputFilenamePrefix = strdup (Substring + 1);
873         }
874         *(Substring+1) = 0;
875     }
876
877     UtConvertBackslashes (Gbl_OutputFilenamePrefix);
878     return (AE_OK);
879 }
880 #endif