1 /******************************************************************************
3 * Module Name: aslfiles - File support functions
5 *****************************************************************************/
7 /******************************************************************************
11 * Some or all of this work - Copyright (c) 1999 - 2018, Intel Corp.
12 * All rights reserved.
16 * 2.1. This is your license from Intel Corp. under its intellectual property
17 * rights. You may have additional license terms from the party that provided
18 * you this software, covering your right to use that party's intellectual
21 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22 * copy of the source code appearing in this file ("Covered Code") an
23 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24 * base code distributed originally by Intel ("Original Intel Code") to copy,
25 * make derivatives, distribute, use and display any portion of the Covered
26 * Code in any form, with the right to sublicense such rights; and
28 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29 * license (with the right to sublicense), under only those claims of Intel
30 * patents that are infringed by the Original Intel Code, to make, use, sell,
31 * offer to sell, and import the Covered Code and derivative works thereof
32 * solely to the minimum extent necessary to exercise the above copyright
33 * license, and in no event shall the patent license extend to any additions
34 * to or modifications of the Original Intel Code. No other license or right
35 * is granted directly or by implication, estoppel or otherwise;
37 * The above copyright and patent license is granted only if the following
42 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43 * Redistribution of source code of any substantial portion of the Covered
44 * Code or modification with rights to further distribute source must include
45 * the above Copyright Notice, the above License, this list of Conditions,
46 * and the following Disclaimer and Export Compliance provision. In addition,
47 * Licensee must cause all Covered Code to which Licensee contributes to
48 * contain a file documenting the changes Licensee made to create that Covered
49 * Code and the date of any change. Licensee must include in that file the
50 * documentation of any changes made by any predecessor Licensee. Licensee
51 * must include a prominent statement that the modification is derived,
52 * directly or indirectly, from Original Intel Code.
54 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55 * Redistribution of source code of any substantial portion of the Covered
56 * Code or modification without rights to further distribute source must
57 * include the following Disclaimer and Export Compliance provision in the
58 * documentation and/or other materials provided with distribution. In
59 * addition, Licensee may not authorize further sublicense of source of any
60 * portion of the Covered Code, and must include terms to the effect that the
61 * license from Licensee to its licensee is limited to the intellectual
62 * property embodied in the software Licensee provides to its licensee, and
63 * not to intellectual property embodied in modifications its licensee may
66 * 3.3. Redistribution of Executable. Redistribution in executable form of any
67 * substantial portion of the Covered Code or modification must reproduce the
68 * above Copyright Notice, and the following Disclaimer and Export Compliance
69 * provision in the documentation and/or other materials provided with the
72 * 3.4. Intel retains all right, title, and interest in and to the Original
75 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76 * Intel shall be used in advertising or otherwise to promote the sale, use or
77 * other dealings in products derived from or relating to the Covered Code
78 * without prior written authorization from Intel.
80 * 4. Disclaimer and Export Compliance
82 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
90 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
99 * 4.3. Licensee shall not export, either directly or indirectly, any of this
100 * software or system incorporating such software without first obtaining any
101 * required license or other approval from the U. S. Department of Commerce or
102 * any other agency or department of the United States Government. In the
103 * event Licensee exports any such software from the United States or
104 * re-exports any such software from a foreign destination, Licensee shall
105 * ensure that the distribution and export/re-export of the software is in
106 * compliance with all laws, regulations, orders, or other restrictions of the
107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108 * any of its subsidiaries will export/re-export any technical data, process,
109 * software, or service, directly or indirectly, to any country for which the
110 * United States government or any agency thereof requires an export license,
111 * other governmental approval, or letter of assurance, without first obtaining
112 * such license, approval or letter.
114 *****************************************************************************
116 * Alternatively, you may choose to be licensed under the terms of the
119 * Redistribution and use in source and binary forms, with or without
120 * modification, are permitted provided that the following conditions
122 * 1. Redistributions of source code must retain the above copyright
123 * notice, this list of conditions, and the following disclaimer,
124 * without modification.
125 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126 * substantially similar to the "NO WARRANTY" disclaimer below
127 * ("Disclaimer") and any redistribution must be conditioned upon
128 * including a substantially similar Disclaimer requirement for further
129 * binary redistribution.
130 * 3. Neither the names of the above-listed copyright holders nor the names
131 * of any contributors may be used to endorse or promote products derived
132 * from this software without specific prior written permission.
134 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
135 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
136 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
137 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
138 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
139 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
140 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
141 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
142 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
144 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
146 * Alternatively, you may choose to be licensed under the terms of the
147 * GNU General Public License ("GPL") version 2 as published by the Free
148 * Software Foundation.
150 *****************************************************************************/
152 #include "aslcompiler.h"
155 #define _COMPONENT ACPI_COMPILER
156 ACPI_MODULE_NAME ("aslfiles")
158 /* Local prototypes */
161 FlOpenIncludeWithPrefix (
163 ACPI_PARSE_OBJECT *Op,
166 #ifdef ACPI_OBSOLETE_FUNCTIONS
168 FlParseInputPathname (
169 char *InputFilename);
173 /*******************************************************************************
175 * FUNCTION: FlSetLineNumber
177 * PARAMETERS: Op - Parse node for the LINE asl statement
181 * DESCRIPTION: Set the current line number
183 ******************************************************************************/
190 DbgPrint (ASL_PARSE_OUTPUT, "\n#line: New line number %u (old %u)\n",
191 LineNumber, Gbl_LogicalLineNumber);
193 Gbl_CurrentLineNumber = LineNumber;
197 /*******************************************************************************
199 * FUNCTION: FlSetFilename
201 * PARAMETERS: Op - Parse node for the LINE asl statement
205 * DESCRIPTION: Set the current filename
207 ******************************************************************************/
214 DbgPrint (ASL_PARSE_OUTPUT, "\n#line: New filename %s (old %s)\n",
215 Filename, Gbl_Files[ASL_FILE_INPUT].Filename);
217 /* No need to free any existing filename */
219 Gbl_Files[ASL_FILE_INPUT].Filename = Filename;
223 /*******************************************************************************
225 * FUNCTION: FlAddIncludeDirectory
227 * PARAMETERS: Dir - Directory pathname string
231 * DESCRIPTION: Add a directory the list of include prefix directories.
233 ******************************************************************************/
236 FlAddIncludeDirectory (
239 ASL_INCLUDE_DIR *NewDir;
240 ASL_INCLUDE_DIR *NextDir;
241 ASL_INCLUDE_DIR *PrevDir = NULL;
242 UINT32 NeedsSeparator = 0;
246 DirLength = strlen (Dir);
252 /* Make sure that the pathname ends with a path separator */
254 if ((Dir[DirLength-1] != '/') &&
255 (Dir[DirLength-1] != '\\'))
260 NewDir = ACPI_ALLOCATE_ZEROED (sizeof (ASL_INCLUDE_DIR));
261 NewDir->Dir = ACPI_ALLOCATE (DirLength + 1 + NeedsSeparator);
262 strcpy (NewDir->Dir, Dir);
265 strcat (NewDir->Dir, "/");
269 * Preserve command line ordering of -I options by adding new elements
270 * at the end of the list
272 NextDir = Gbl_IncludeDirList;
276 NextDir = NextDir->Next;
281 PrevDir->Next = NewDir;
285 Gbl_IncludeDirList = NewDir;
290 /*******************************************************************************
292 * FUNCTION: FlMergePathnames
294 * PARAMETERS: PrefixDir - Prefix directory pathname. Can be NULL or
295 * a zero length string.
296 * FilePathname - The include filename from the source ASL.
298 * RETURN: Merged pathname string
300 * DESCRIPTION: Merge two pathnames that (probably) have common elements, to
301 * arrive at a minimal length string. Merge can occur if the
302 * FilePathname is relative to the PrefixDir.
304 ******************************************************************************/
316 DbgPrint (ASL_PARSE_OUTPUT, "Include: Prefix path - \"%s\"\n"
317 "Include: FilePathname - \"%s\"\n",
318 PrefixDir, FilePathname);
321 * If there is no prefix directory or if the file pathname is absolute,
322 * just return the original file pathname
324 if (!PrefixDir || (!*PrefixDir) ||
325 (*FilePathname == '/') ||
326 (FilePathname[1] == ':'))
328 Pathname = UtLocalCacheCalloc (strlen (FilePathname) + 1);
329 strcpy (Pathname, FilePathname);
330 goto ConvertBackslashes;
333 /* Need a local copy of the prefix directory path */
335 CommonPath = UtLocalCacheCalloc (strlen (PrefixDir) + 1);
336 strcpy (CommonPath, PrefixDir);
339 * Walk forward through the file path, and simultaneously backward
340 * through the prefix directory path until there are no more
341 * relative references at the start of the file path.
343 while (*FilePathname && (!strncmp (FilePathname, "../", 3)))
345 /* Remove last element of the prefix directory path */
347 LastElement = strrchr (CommonPath, '/');
350 goto ConcatenatePaths;
353 *LastElement = 0; /* Terminate CommonPath string */
354 FilePathname += 3; /* Point to next path element */
358 * Remove the last element of the prefix directory path (it is the same as
359 * the first element of the file pathname), and build the final merged
362 LastElement = strrchr (CommonPath, '/');
368 /* Build the final merged pathname */
371 Pathname = UtLocalCacheCalloc (
372 strlen (CommonPath) + strlen (FilePathname) + 2);
373 if (LastElement && *CommonPath)
375 strcpy (Pathname, CommonPath);
376 strcat (Pathname, "/");
378 strcat (Pathname, FilePathname);
380 /* Convert all backslashes to normal slashes */
383 UtConvertBackslashes (Pathname);
385 DbgPrint (ASL_PARSE_OUTPUT, "Include: Merged Pathname - \"%s\"\n",
391 /*******************************************************************************
393 * FUNCTION: FlOpenIncludeWithPrefix
395 * PARAMETERS: PrefixDir - Prefix directory pathname. Can be a zero
397 * Filename - The include filename from the source ASL.
399 * RETURN: Valid file descriptor if successful. Null otherwise.
401 * DESCRIPTION: Open an include file and push it on the input file stack.
403 ******************************************************************************/
406 FlOpenIncludeWithPrefix (
408 ACPI_PARSE_OBJECT *Op,
413 UINT32 OriginalLineNumber;
416 /* Build the full pathname to the file */
418 Pathname = FlMergePathnames (PrefixDir, Filename);
420 DbgPrint (ASL_PARSE_OUTPUT, "Include: Opening file - \"%s\"\n\n",
423 /* Attempt to open the file, push if successful */
425 IncludeFile = fopen (Pathname, "r");
428 fprintf (stderr, "Could not open include file %s\n", Pathname);
429 ACPI_FREE (Pathname);
434 * Check the entire include file for any # preprocessor directives.
435 * This is because there may be some confusion between the #include
436 * preprocessor directive and the ASL Include statement. A file included
437 * by the ASL include cannot contain preprocessor directives because
438 * the preprocessor has already run by the time the ASL include is
439 * recognized (by the compiler, not the preprocessor.)
441 * Note: DtGetNextLine strips/ignores comments.
442 * Save current line number since DtGetNextLine modifies it.
444 Gbl_CurrentLineNumber--;
445 OriginalLineNumber = Gbl_CurrentLineNumber;
447 while (DtGetNextLine (IncludeFile, DT_ALLOW_MULTILINE_QUOTES) != ASL_EOF)
449 if (Gbl_CurrentLineBuffer[0] == '#')
451 AslError (ASL_ERROR, ASL_MSG_INCLUDE_FILE,
452 Op, "use #include instead");
456 Gbl_CurrentLineNumber = OriginalLineNumber;
458 /* Must seek back to the start of the file */
460 fseek (IncludeFile, 0, SEEK_SET);
462 /* Push the include file on the open input file stack */
464 AslPushInputFileStack (IncludeFile, Pathname);
465 return (IncludeFile);
469 /*******************************************************************************
471 * FUNCTION: FlOpenIncludeFile
473 * PARAMETERS: Op - Parse node for the INCLUDE ASL statement
477 * DESCRIPTION: Open an include file and push it on the input file stack.
479 ******************************************************************************/
483 ACPI_PARSE_OBJECT *Op)
486 ASL_INCLUDE_DIR *NextDir;
489 /* Op must be valid */
493 AslCommonError (ASL_ERROR, ASL_MSG_INCLUDE_FILE_OPEN,
494 Gbl_CurrentLineNumber, Gbl_LogicalLineNumber,
495 Gbl_InputByteCount, Gbl_CurrentColumn,
496 Gbl_Files[ASL_FILE_INPUT].Filename, " - Null parse node");
502 * Flush out the "include ()" statement on this line, start
503 * the actual include file on the next line
505 AslResetCurrentLineBuffer ();
506 FlPrintFile (ASL_FILE_SOURCE_OUTPUT, "\n");
507 Gbl_CurrentLineOffset++;
510 /* Attempt to open the include file */
512 /* If the file specifies an absolute path, just open it */
514 if ((Op->Asl.Value.String[0] == '/') ||
515 (Op->Asl.Value.String[0] == '\\') ||
516 (Op->Asl.Value.String[1] == ':'))
518 IncludeFile = FlOpenIncludeWithPrefix ("", Op, Op->Asl.Value.String);
527 * The include filename is not an absolute path.
529 * First, search for the file within the "local" directory -- meaning
530 * the same directory that contains the source file.
532 * Construct the file pathname from the global directory name.
534 IncludeFile = FlOpenIncludeWithPrefix (
535 Gbl_DirectoryPath, Op, Op->Asl.Value.String);
542 * Second, search for the file within the (possibly multiple) directories
543 * specified by the -I option on the command line.
545 NextDir = Gbl_IncludeDirList;
548 IncludeFile = FlOpenIncludeWithPrefix (
549 NextDir->Dir, Op, Op->Asl.Value.String);
555 NextDir = NextDir->Next;
558 /* We could not open the include file after trying very hard */
561 sprintf (MsgBuffer, "%s, %s", Op->Asl.Value.String, strerror (errno));
562 AslError (ASL_ERROR, ASL_MSG_INCLUDE_FILE_OPEN, Op, MsgBuffer);
566 /*******************************************************************************
568 * FUNCTION: FlOpenInputFile
570 * PARAMETERS: InputFilename - The user-specified ASL source file to be
575 * DESCRIPTION: Open the specified input file, and save the directory path to
576 * the file so that include files can be opened in
577 * the same directory.
579 ******************************************************************************/
586 /* Open the input ASL file, text mode */
588 FlOpenFile (ASL_FILE_INPUT, InputFilename, "rt");
589 AslCompilerin = Gbl_Files[ASL_FILE_INPUT].Handle;
595 /*******************************************************************************
597 * FUNCTION: FlOpenAmlOutputFile
599 * PARAMETERS: FilenamePrefix - The user-specified ASL source file
603 * DESCRIPTION: Create the output filename (*.AML) and open the file. The file
604 * is created in the same directory as the parent input file.
606 ******************************************************************************/
609 FlOpenAmlOutputFile (
610 char *FilenamePrefix)
615 /* Output filename usually comes from the ASL itself */
617 Filename = Gbl_Files[ASL_FILE_AML_OUTPUT].Filename;
620 /* Create the output AML filename */
621 if (!AcpiGbl_CaptureComments)
623 Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_AML_CODE);
627 Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_CONVERT_AML);
631 AslCommonError (ASL_ERROR, ASL_MSG_OUTPUT_FILENAME,
632 0, 0, 0, 0, NULL, NULL);
636 Gbl_Files[ASL_FILE_AML_OUTPUT].Filename = Filename;
639 /* Open the output AML file in binary mode */
641 FlOpenFile (ASL_FILE_AML_OUTPUT, Filename, "w+b");
646 /*******************************************************************************
648 * FUNCTION: FlOpenMiscOutputFiles
650 * PARAMETERS: FilenamePrefix - The user-specified ASL source file
654 * DESCRIPTION: Create and open the various output files needed, depending on
655 * the command line options
657 ******************************************************************************/
660 FlOpenMiscOutputFiles (
661 char *FilenamePrefix)
666 /* Create/Open a map file if requested */
670 Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_MAP);
673 AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
674 0, 0, 0, 0, NULL, NULL);
678 /* Open the hex file, text mode (closed at compiler exit) */
680 FlOpenFile (ASL_FILE_MAP_OUTPUT, Filename, "w+t");
682 AslCompilerSignon (ASL_FILE_MAP_OUTPUT);
683 AslCompilerFileHeader (ASL_FILE_MAP_OUTPUT);
686 /* All done for disassembler */
688 if (Gbl_FileType == ASL_INPUT_TYPE_BINARY_ACPI_TABLE)
693 /* Create/Open a hex output file if asked */
695 if (Gbl_HexOutputFlag)
697 Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_HEX_DUMP);
700 AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
701 0, 0, 0, 0, NULL, NULL);
705 /* Open the hex file, text mode */
707 FlOpenFile (ASL_FILE_HEX_OUTPUT, Filename, "w+t");
709 AslCompilerSignon (ASL_FILE_HEX_OUTPUT);
710 AslCompilerFileHeader (ASL_FILE_HEX_OUTPUT);
713 /* Create/Open a debug output file if asked */
717 Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_DEBUG);
720 AslCommonError (ASL_ERROR, ASL_MSG_DEBUG_FILENAME,
721 0, 0, 0, 0, NULL, NULL);
725 /* Open the debug file as STDERR, text mode */
727 Gbl_Files[ASL_FILE_DEBUG_OUTPUT].Filename = Filename;
728 Gbl_Files[ASL_FILE_DEBUG_OUTPUT].Handle =
729 freopen (Filename, "w+t", stderr);
731 if (!Gbl_Files[ASL_FILE_DEBUG_OUTPUT].Handle)
734 * A problem with freopen is that on error, we no longer
735 * have stderr and cannot emit normal error messages.
736 * Emit error to stdout, close files, and exit.
739 "\nCould not open debug output file: %s\n\n", Filename);
745 AslCompilerSignon (ASL_FILE_DEBUG_OUTPUT);
746 AslCompilerFileHeader (ASL_FILE_DEBUG_OUTPUT);
749 /* Create/Open a cross-reference output file if asked */
751 if (Gbl_CrossReferenceOutput)
753 Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_XREF);
756 AslCommonError (ASL_ERROR, ASL_MSG_DEBUG_FILENAME,
757 0, 0, 0, 0, NULL, NULL);
761 FlOpenFile (ASL_FILE_XREF_OUTPUT, Filename, "w+t");
763 AslCompilerSignon (ASL_FILE_XREF_OUTPUT);
764 AslCompilerFileHeader (ASL_FILE_XREF_OUTPUT);
767 /* Create/Open a listing output file if asked */
771 Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_LISTING);
774 AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
775 0, 0, 0, 0, NULL, NULL);
779 /* Open the listing file, text mode */
781 FlOpenFile (ASL_FILE_LISTING_OUTPUT, Filename, "w+t");
783 AslCompilerSignon (ASL_FILE_LISTING_OUTPUT);
784 AslCompilerFileHeader (ASL_FILE_LISTING_OUTPUT);
787 /* Create the preprocessor output temp file if preprocessor enabled */
789 if (Gbl_PreprocessFlag)
791 Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_PREPROCESSOR);
794 AslCommonError (ASL_ERROR, ASL_MSG_PREPROCESSOR_FILENAME,
795 0, 0, 0, 0, NULL, NULL);
799 FlOpenFile (ASL_FILE_PREPROCESSOR, Filename, "w+t");
803 * Create the "user" preprocessor output file if -li flag set.
804 * Note, this file contains no embedded #line directives.
806 if (Gbl_PreprocessorOutputFlag)
808 Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_PREPROC_USER);
811 AslCommonError (ASL_ERROR, ASL_MSG_PREPROCESSOR_FILENAME,
812 0, 0, 0, 0, NULL, NULL);
816 FlOpenFile (ASL_FILE_PREPROCESSOR_USER, Filename, "w+t");
819 /* All done for data table compiler */
821 if (Gbl_FileType == ASL_INPUT_TYPE_ASCII_DATA)
826 /* Create/Open a combined source output file */
828 Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_SOURCE);
831 AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
832 0, 0, 0, 0, NULL, NULL);
837 * Open the source output file, binary mode (so that LF does not get
838 * expanded to CR/LF on some systems, messing up our seek
841 FlOpenFile (ASL_FILE_SOURCE_OUTPUT, Filename, "w+b");
845 // AslCompilerin = Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Handle;
847 /* Create/Open a assembly code source output file if asked */
849 if (Gbl_AsmOutputFlag)
851 Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_ASM_SOURCE);
854 AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
855 0, 0, 0, 0, NULL, NULL);
859 /* Open the assembly code source file, text mode */
861 FlOpenFile (ASL_FILE_ASM_SOURCE_OUTPUT, Filename, "w+t");
863 AslCompilerSignon (ASL_FILE_ASM_SOURCE_OUTPUT);
864 AslCompilerFileHeader (ASL_FILE_ASM_SOURCE_OUTPUT);
867 /* Create/Open a C code source output file if asked */
869 if (Gbl_C_OutputFlag)
871 Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_C_SOURCE);
874 AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
875 0, 0, 0, 0, NULL, NULL);
879 /* Open the C code source file, text mode */
881 FlOpenFile (ASL_FILE_C_SOURCE_OUTPUT, Filename, "w+t");
883 FlPrintFile (ASL_FILE_C_SOURCE_OUTPUT, "/*\n");
884 AslCompilerSignon (ASL_FILE_C_SOURCE_OUTPUT);
885 AslCompilerFileHeader (ASL_FILE_C_SOURCE_OUTPUT);
888 /* Create/Open a C code source output file for the offset table if asked */
890 if (Gbl_C_OffsetTableFlag)
892 Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_C_OFFSET);
895 AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
896 0, 0, 0, 0, NULL, NULL);
900 /* Open the C code source file, text mode */
902 FlOpenFile (ASL_FILE_C_OFFSET_OUTPUT, Filename, "w+t");
904 FlPrintFile (ASL_FILE_C_OFFSET_OUTPUT, "/*\n");
905 AslCompilerSignon (ASL_FILE_C_OFFSET_OUTPUT);
906 AslCompilerFileHeader (ASL_FILE_C_OFFSET_OUTPUT);
909 /* Create/Open a assembly include output file if asked */
911 if (Gbl_AsmIncludeOutputFlag)
913 Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_ASM_INCLUDE);
916 AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
917 0, 0, 0, 0, NULL, NULL);
921 /* Open the assembly include file, text mode */
923 FlOpenFile (ASL_FILE_ASM_INCLUDE_OUTPUT, Filename, "w+t");
925 AslCompilerSignon (ASL_FILE_ASM_INCLUDE_OUTPUT);
926 AslCompilerFileHeader (ASL_FILE_ASM_INCLUDE_OUTPUT);
929 /* Create/Open a C include output file if asked */
931 if (Gbl_C_IncludeOutputFlag)
933 Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_C_INCLUDE);
936 AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
937 0, 0, 0, 0, NULL, NULL);
941 /* Open the C include file, text mode */
943 FlOpenFile (ASL_FILE_C_INCLUDE_OUTPUT, Filename, "w+t");
945 FlPrintFile (ASL_FILE_C_INCLUDE_OUTPUT, "/*\n");
946 AslCompilerSignon (ASL_FILE_C_INCLUDE_OUTPUT);
947 AslCompilerFileHeader (ASL_FILE_C_INCLUDE_OUTPUT);
950 /* Create a namespace output file if asked */
952 if (Gbl_NsOutputFlag)
954 Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_NAMESPACE);
957 AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
958 0, 0, 0, 0, NULL, NULL);
962 /* Open the namespace file, text mode */
964 FlOpenFile (ASL_FILE_NAMESPACE_OUTPUT, Filename, "w+t");
966 AslCompilerSignon (ASL_FILE_NAMESPACE_OUTPUT);
967 AslCompilerFileHeader (ASL_FILE_NAMESPACE_OUTPUT);
970 /* Create a debug file for the converter */
972 if (AcpiGbl_DebugAslConversion)
974 Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_CONVERT_DEBUG);
977 AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
978 0, 0, 0, 0, NULL, NULL);
982 /* Open the converter debug file, text mode */
984 FlOpenFile (ASL_FILE_CONV_DEBUG_OUTPUT, Filename, "w+t");
986 AslCompilerSignon (ASL_FILE_CONV_DEBUG_OUTPUT);
987 AslCompilerFileHeader (ASL_FILE_CONV_DEBUG_OUTPUT);
989 AcpiGbl_ConvDebugFile = Gbl_Files[ASL_FILE_CONV_DEBUG_OUTPUT].Handle;
996 #ifdef ACPI_OBSOLETE_FUNCTIONS
997 /*******************************************************************************
999 * FUNCTION: FlParseInputPathname
1001 * PARAMETERS: InputFilename - The user-specified ASL source file to be
1006 * DESCRIPTION: Split the input path into a directory and filename part
1007 * 1) Directory part used to open include files
1008 * 2) Filename part used to generate output filenames
1010 ******************************************************************************/
1013 FlParseInputPathname (
1014 char *InputFilename)
1024 /* Get the path to the input filename's directory */
1026 Gbl_DirectoryPath = strdup (InputFilename);
1027 if (!Gbl_DirectoryPath)
1029 return (AE_NO_MEMORY);
1032 Substring = strrchr (Gbl_DirectoryPath, '\\');
1035 Substring = strrchr (Gbl_DirectoryPath, '/');
1038 Substring = strrchr (Gbl_DirectoryPath, ':');
1044 Gbl_DirectoryPath[0] = 0;
1045 if (Gbl_UseDefaultAmlFilename)
1047 Gbl_OutputFilenamePrefix = strdup (InputFilename);
1052 if (Gbl_UseDefaultAmlFilename)
1054 Gbl_OutputFilenamePrefix = strdup (Substring + 1);
1059 UtConvertBackslashes (Gbl_OutputFilenamePrefix);