1 /******************************************************************************
3 * Module Name: aslfiles - file I/O suppoert
5 *****************************************************************************/
7 /******************************************************************************
11 * Some or all of this work - Copyright (c) 1999 - 2012, 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 #include "aslcompiler.h"
119 #define _COMPONENT ACPI_COMPILER
120 ACPI_MODULE_NAME ("aslfiles")
122 /* Local prototypes */
125 FlOpenIncludeWithPrefix (
130 #ifdef ACPI_OBSOLETE_FUNCTIONS
132 FlParseInputPathname (
133 char *InputFilename);
137 /*******************************************************************************
145 * DESCRIPTION: Dump the error log and abort the compiler. Used for serious
148 ******************************************************************************/
155 AePrintErrorLog (ASL_FILE_STDERR);
158 /* Print error summary to stdout also */
160 AePrintErrorLog (ASL_FILE_STDOUT);
167 /*******************************************************************************
169 * FUNCTION: FlFileError
171 * PARAMETERS: FileId - Index into file info array
172 * ErrorId - Index into error message array
176 * DESCRIPTION: Decode errno to an error message and add the entire error
179 ******************************************************************************/
187 sprintf (MsgBuffer, "\"%s\" (%s)", Gbl_Files[FileId].Filename,
189 AslCommonError (ASL_ERROR, ErrorId, 0, 0, 0, 0, NULL, MsgBuffer);
193 /*******************************************************************************
195 * FUNCTION: FlOpenFile
197 * PARAMETERS: FileId - Index into file info array
198 * Filename - file pathname to open
199 * Mode - Open mode for fopen
203 * DESCRIPTION: Open a file.
204 * NOTE: Aborts compiler on any error.
206 ******************************************************************************/
217 File = fopen (Filename, Mode);
219 Gbl_Files[FileId].Filename = Filename;
220 Gbl_Files[FileId].Handle = File;
224 FlFileError (FileId, ASL_MSG_OPEN);
230 /*******************************************************************************
232 * FUNCTION: FlGetFileSize
234 * PARAMETERS: FileId - Index into file info array
238 * DESCRIPTION: Get current file size. Uses seek-to-EOF. File must be open.
240 ******************************************************************************/
251 fp = Gbl_Files[FileId].Handle;
254 fseek (fp, 0, SEEK_END);
255 FileSize = (UINT32) ftell (fp);
257 /* Restore file pointer */
259 fseek (fp, Offset, SEEK_SET);
264 /*******************************************************************************
266 * FUNCTION: FlReadFile
268 * PARAMETERS: FileId - Index into file info array
269 * Buffer - Where to place the data
270 * Length - Amount to read
272 * RETURN: Status. AE_ERROR indicates EOF.
274 * DESCRIPTION: Read data from an open file.
275 * NOTE: Aborts compiler on any error.
277 ******************************************************************************/
288 /* Read and check for error */
290 Actual = fread (Buffer, 1, Length, Gbl_Files[FileId].Handle);
291 if (Actual != Length)
293 if (feof (Gbl_Files[FileId].Handle))
295 /* End-of-file, just return error */
300 FlFileError (FileId, ASL_MSG_READ);
308 /*******************************************************************************
310 * FUNCTION: FlWriteFile
312 * PARAMETERS: FileId - Index into file info array
313 * Buffer - Data to write
314 * Length - Amount of data to write
318 * DESCRIPTION: Write data to an open file.
319 * NOTE: Aborts compiler on any error.
321 ******************************************************************************/
332 /* Write and check for error */
334 Actual = fwrite ((char *) Buffer, 1, Length, Gbl_Files[FileId].Handle);
335 if (Actual != Length)
337 FlFileError (FileId, ASL_MSG_WRITE);
343 /*******************************************************************************
345 * FUNCTION: FlPrintFile
347 * PARAMETERS: FileId - Index into file info array
348 * Format - Printf format string
349 * ... - Printf arguments
353 * DESCRIPTION: Formatted write to an open file.
354 * NOTE: Aborts compiler on any error.
356 ******************************************************************************/
368 va_start (Args, Format);
370 Actual = vfprintf (Gbl_Files[FileId].Handle, Format, Args);
375 FlFileError (FileId, ASL_MSG_WRITE);
381 /*******************************************************************************
383 * FUNCTION: FlSeekFile
385 * PARAMETERS: FileId - Index into file info array
386 * Offset - Absolute byte offset in file
390 * DESCRIPTION: Seek to absolute offset
391 * NOTE: Aborts compiler on any error.
393 ******************************************************************************/
403 Error = fseek (Gbl_Files[FileId].Handle, Offset, SEEK_SET);
406 FlFileError (FileId, ASL_MSG_SEEK);
412 /*******************************************************************************
414 * FUNCTION: FlCloseFile
416 * PARAMETERS: FileId - Index into file info array
420 * DESCRIPTION: Close an open file. Aborts compiler on error
422 ******************************************************************************/
431 if (!Gbl_Files[FileId].Handle)
436 Error = fclose (Gbl_Files[FileId].Handle);
439 FlFileError (FileId, ASL_MSG_CLOSE);
443 Gbl_Files[FileId].Handle = NULL;
448 /*******************************************************************************
450 * FUNCTION: FlDeleteFile
452 * PARAMETERS: FileId - Index into file info array
456 * DESCRIPTION: Delete a file.
458 ******************************************************************************/
464 ASL_FILE_INFO *Info = &Gbl_Files[FileId];
472 if (remove (Info->Filename))
474 printf ("%s (%s file) ",
475 Info->Filename, Info->Description);
476 perror ("Could not delete");
479 Info->Filename = NULL;
484 /*******************************************************************************
486 * FUNCTION: FlSetLineNumber
488 * PARAMETERS: Op - Parse node for the LINE asl statement
492 * DESCRIPTION: Set the current line number
494 ******************************************************************************/
501 DbgPrint (ASL_PARSE_OUTPUT, "\n#line: New line number %u (old %u)\n",
502 LineNumber, Gbl_LogicalLineNumber);
504 Gbl_CurrentLineNumber = LineNumber;
505 Gbl_LogicalLineNumber = LineNumber;
509 /*******************************************************************************
511 * FUNCTION: FlSetFilename
513 * PARAMETERS: Op - Parse node for the LINE asl statement
517 * DESCRIPTION: Set the current filename
519 ******************************************************************************/
526 DbgPrint (ASL_PARSE_OUTPUT, "\n#line: New filename %s (old %s)\n",
527 Filename, Gbl_Files[ASL_FILE_INPUT].Filename);
529 Gbl_Files[ASL_FILE_INPUT].Filename = Filename;
533 /*******************************************************************************
535 * FUNCTION: FlAddIncludeDirectory
537 * PARAMETERS: Dir - Directory pathname string
541 * DESCRIPTION: Add a directory the list of include prefix directories.
543 ******************************************************************************/
546 FlAddIncludeDirectory (
549 ASL_INCLUDE_DIR *NewDir;
550 ASL_INCLUDE_DIR *NextDir;
551 ASL_INCLUDE_DIR *PrevDir = NULL;
552 UINT32 NeedsSeparator = 0;
556 DirLength = strlen (Dir);
562 /* Make sure that the pathname ends with a path separator */
564 if ((Dir[DirLength-1] != '/') &&
565 (Dir[DirLength-1] != '\\'))
570 NewDir = ACPI_ALLOCATE_ZEROED (sizeof (ASL_INCLUDE_DIR));
571 NewDir->Dir = ACPI_ALLOCATE (DirLength + 1 + NeedsSeparator);
572 strcpy (NewDir->Dir, Dir);
575 strcat (NewDir->Dir, "/");
579 * Preserve command line ordering of -I options by adding new elements
580 * at the end of the list
582 NextDir = Gbl_IncludeDirList;
586 NextDir = NextDir->Next;
591 PrevDir->Next = NewDir;
595 Gbl_IncludeDirList = NewDir;
600 /*******************************************************************************
602 * FUNCTION: FlMergePathnames
604 * PARAMETERS: PrefixDir - Prefix directory pathname. Can be NULL or
605 * a zero length string.
606 * FilePathname - The include filename from the source ASL.
608 * RETURN: Merged pathname string
610 * DESCRIPTION: Merge two pathnames that (probably) have common elements, to
611 * arrive at a minimal length string. Merge can occur if the
612 * FilePathname is relative to the PrefixDir.
614 ******************************************************************************/
626 DbgPrint (ASL_PARSE_OUTPUT, "Include: Prefix path - \"%s\"\n"
627 "Include: FilePathname - \"%s\"\n",
628 PrefixDir, FilePathname);
631 * If there is no prefix directory or if the file pathname is absolute,
632 * just return the original file pathname
634 if (!PrefixDir || (!*PrefixDir) ||
635 (*FilePathname == '/') ||
636 (FilePathname[1] == ':'))
638 Pathname = ACPI_ALLOCATE (strlen (FilePathname) + 1);
639 strcpy (Pathname, FilePathname);
640 goto ConvertBackslashes;
643 /* Need a local copy of the prefix directory path */
645 CommonPath = ACPI_ALLOCATE (strlen (PrefixDir) + 1);
646 strcpy (CommonPath, PrefixDir);
649 * Walk forward through the file path, and simultaneously backward
650 * through the prefix directory path until there are no more
651 * relative references at the start of the file path.
653 while (*FilePathname && (!strncmp (FilePathname, "../", 3)))
655 /* Remove last element of the prefix directory path */
657 LastElement = strrchr (CommonPath, '/');
660 goto ConcatenatePaths;
663 *LastElement = 0; /* Terminate CommonPath string */
664 FilePathname += 3; /* Point to next path element */
668 * Remove the last element of the prefix directory path (it is the same as
669 * the first element of the file pathname), and build the final merged
672 LastElement = strrchr (CommonPath, '/');
678 /* Build the final merged pathname */
681 Pathname = ACPI_ALLOCATE_ZEROED (strlen (CommonPath) + strlen (FilePathname) + 2);
682 if (LastElement && *CommonPath)
684 strcpy (Pathname, CommonPath);
685 strcat (Pathname, "/");
687 strcat (Pathname, FilePathname);
688 ACPI_FREE (CommonPath);
690 /* Convert all backslashes to normal slashes */
693 UtConvertBackslashes (Pathname);
695 DbgPrint (ASL_PARSE_OUTPUT, "Include: Merged Pathname - \"%s\"\n",
701 /*******************************************************************************
703 * FUNCTION: FlOpenIncludeWithPrefix
705 * PARAMETERS: PrefixDir - Prefix directory pathname. Can be a zero
707 * Filename - The include filename from the source ASL.
709 * RETURN: Valid file descriptor if successful. Null otherwise.
711 * DESCRIPTION: Open an include file and push it on the input file stack.
713 ******************************************************************************/
716 FlOpenIncludeWithPrefix (
724 /* Build the full pathname to the file */
726 Pathname = FlMergePathnames (PrefixDir, Filename);
728 DbgPrint (ASL_PARSE_OUTPUT, "Include: Opening file - \"%s\"\n\n",
731 /* Attempt to open the file, push if successful */
733 IncludeFile = fopen (Pathname, "r");
736 /* Push the include file on the open input file stack */
738 AslPushInputFileStack (IncludeFile, Pathname);
739 return (IncludeFile);
742 ACPI_FREE (Pathname);
747 /*******************************************************************************
749 * FUNCTION: FlOpenIncludeFile
751 * PARAMETERS: Op - Parse node for the INCLUDE ASL statement
755 * DESCRIPTION: Open an include file and push it on the input file stack.
757 ******************************************************************************/
761 ACPI_PARSE_OBJECT *Op)
764 ASL_INCLUDE_DIR *NextDir;
767 /* Op must be valid */
771 AslCommonError (ASL_ERROR, ASL_MSG_INCLUDE_FILE_OPEN,
772 Gbl_CurrentLineNumber, Gbl_LogicalLineNumber,
773 Gbl_InputByteCount, Gbl_CurrentColumn,
774 Gbl_Files[ASL_FILE_INPUT].Filename, " - Null parse node");
780 * Flush out the "include ()" statement on this line, start
781 * the actual include file on the next line
783 AslResetCurrentLineBuffer ();
784 FlPrintFile (ASL_FILE_SOURCE_OUTPUT, "\n");
785 Gbl_CurrentLineOffset++;
788 /* Attempt to open the include file */
790 /* If the file specifies an absolute path, just open it */
792 if ((Op->Asl.Value.String[0] == '/') ||
793 (Op->Asl.Value.String[0] == '\\') ||
794 (Op->Asl.Value.String[1] == ':'))
796 IncludeFile = FlOpenIncludeWithPrefix ("", Op->Asl.Value.String);
805 * The include filename is not an absolute path.
807 * First, search for the file within the "local" directory -- meaning
808 * the same directory that contains the source file.
810 * Construct the file pathname from the global directory name.
812 IncludeFile = FlOpenIncludeWithPrefix (Gbl_DirectoryPath, Op->Asl.Value.String);
819 * Second, search for the file within the (possibly multiple) directories
820 * specified by the -I option on the command line.
822 NextDir = Gbl_IncludeDirList;
825 IncludeFile = FlOpenIncludeWithPrefix (NextDir->Dir, Op->Asl.Value.String);
831 NextDir = NextDir->Next;
834 /* We could not open the include file after trying very hard */
837 sprintf (MsgBuffer, "%s, %s", Op->Asl.Value.String, strerror (errno));
838 AslError (ASL_ERROR, ASL_MSG_INCLUDE_FILE_OPEN, Op, MsgBuffer);
842 /*******************************************************************************
844 * FUNCTION: FlOpenInputFile
846 * PARAMETERS: InputFilename - The user-specified ASL source file to be
851 * DESCRIPTION: Open the specified input file, and save the directory path to
852 * the file so that include files can be opened in
853 * the same directory.
855 ******************************************************************************/
862 /* Open the input ASL file, text mode */
864 FlOpenFile (ASL_FILE_INPUT, InputFilename, "rt");
865 AslCompilerin = Gbl_Files[ASL_FILE_INPUT].Handle;
871 /*******************************************************************************
873 * FUNCTION: FlOpenAmlOutputFile
875 * PARAMETERS: FilenamePrefix - The user-specified ASL source file
879 * DESCRIPTION: Create the output filename (*.AML) and open the file. The file
880 * is created in the same directory as the parent input file.
882 ******************************************************************************/
885 FlOpenAmlOutputFile (
886 char *FilenamePrefix)
891 /* Output filename usually comes from the ASL itself */
893 Filename = Gbl_Files[ASL_FILE_AML_OUTPUT].Filename;
896 /* Create the output AML filename */
898 Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_AML_CODE);
901 AslCommonError (ASL_ERROR, ASL_MSG_OUTPUT_FILENAME,
902 0, 0, 0, 0, NULL, NULL);
907 /* Open the output AML file in binary mode */
909 FlOpenFile (ASL_FILE_AML_OUTPUT, Filename, "w+b");
914 /*******************************************************************************
916 * FUNCTION: FlOpenMiscOutputFiles
918 * PARAMETERS: FilenamePrefix - The user-specified ASL source file
922 * DESCRIPTION: Create and open the various output files needed, depending on
923 * the command line options
925 ******************************************************************************/
928 FlOpenMiscOutputFiles (
929 char *FilenamePrefix)
934 /* Create/Open a hex output file if asked */
936 if (Gbl_HexOutputFlag)
938 Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_HEX_DUMP);
941 AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
942 0, 0, 0, 0, NULL, NULL);
946 /* Open the hex file, text mode */
948 FlOpenFile (ASL_FILE_HEX_OUTPUT, Filename, "w+t");
950 AslCompilerSignon (ASL_FILE_HEX_OUTPUT);
951 AslCompilerFileHeader (ASL_FILE_HEX_OUTPUT);
954 /* Create/Open a debug output file if asked */
958 Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_DEBUG);
961 AslCommonError (ASL_ERROR, ASL_MSG_DEBUG_FILENAME,
962 0, 0, 0, 0, NULL, NULL);
966 /* Open the debug file as STDERR, text mode */
968 /* TBD: hide this behind a FlReopenFile function */
970 Gbl_Files[ASL_FILE_DEBUG_OUTPUT].Filename = Filename;
971 Gbl_Files[ASL_FILE_DEBUG_OUTPUT].Handle =
972 freopen (Filename, "w+t", stderr);
974 if (!Gbl_Files[ASL_FILE_DEBUG_OUTPUT].Handle)
976 AslCommonError (ASL_ERROR, ASL_MSG_DEBUG_FILENAME,
977 0, 0, 0, 0, NULL, NULL);
981 AslCompilerSignon (ASL_FILE_DEBUG_OUTPUT);
982 AslCompilerFileHeader (ASL_FILE_DEBUG_OUTPUT);
985 /* Create/Open a listing output file if asked */
989 Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_LISTING);
992 AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
993 0, 0, 0, 0, NULL, NULL);
997 /* Open the listing file, text mode */
999 FlOpenFile (ASL_FILE_LISTING_OUTPUT, Filename, "w+t");
1001 AslCompilerSignon (ASL_FILE_LISTING_OUTPUT);
1002 AslCompilerFileHeader (ASL_FILE_LISTING_OUTPUT);
1005 /* Create the preprocessor output file if preprocessor enabled */
1007 if (Gbl_PreprocessFlag)
1009 Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_PREPROCESSOR);
1012 AslCommonError (ASL_ERROR, ASL_MSG_PREPROCESSOR_FILENAME,
1013 0, 0, 0, 0, NULL, NULL);
1017 FlOpenFile (ASL_FILE_PREPROCESSOR, Filename, "w+t");
1020 /* All done for data table compiler */
1022 if (Gbl_FileType == ASL_INPUT_TYPE_ASCII_DATA)
1027 /* Create/Open a combined source output file */
1029 Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_SOURCE);
1032 AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
1033 0, 0, 0, 0, NULL, NULL);
1038 * Open the source output file, binary mode (so that LF does not get
1039 * expanded to CR/LF on some systems, messing up our seek
1042 FlOpenFile (ASL_FILE_SOURCE_OUTPUT, Filename, "w+b");
1046 // AslCompilerin = Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Handle;
1048 /* Create/Open a assembly code source output file if asked */
1050 if (Gbl_AsmOutputFlag)
1052 Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_ASM_SOURCE);
1055 AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
1056 0, 0, 0, 0, NULL, NULL);
1060 /* Open the assembly code source file, text mode */
1062 FlOpenFile (ASL_FILE_ASM_SOURCE_OUTPUT, Filename, "w+t");
1064 AslCompilerSignon (ASL_FILE_ASM_SOURCE_OUTPUT);
1065 AslCompilerFileHeader (ASL_FILE_ASM_SOURCE_OUTPUT);
1068 /* Create/Open a C code source output file if asked */
1070 if (Gbl_C_OutputFlag)
1072 Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_C_SOURCE);
1075 AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
1076 0, 0, 0, 0, NULL, NULL);
1080 /* Open the C code source file, text mode */
1082 FlOpenFile (ASL_FILE_C_SOURCE_OUTPUT, Filename, "w+t");
1084 FlPrintFile (ASL_FILE_C_SOURCE_OUTPUT, "/*\n");
1085 AslCompilerSignon (ASL_FILE_C_SOURCE_OUTPUT);
1086 AslCompilerFileHeader (ASL_FILE_C_SOURCE_OUTPUT);
1089 /* Create/Open a assembly include output file if asked */
1091 if (Gbl_AsmIncludeOutputFlag)
1093 Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_ASM_INCLUDE);
1096 AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
1097 0, 0, 0, 0, NULL, NULL);
1101 /* Open the assembly include file, text mode */
1103 FlOpenFile (ASL_FILE_ASM_INCLUDE_OUTPUT, Filename, "w+t");
1105 AslCompilerSignon (ASL_FILE_ASM_INCLUDE_OUTPUT);
1106 AslCompilerFileHeader (ASL_FILE_ASM_INCLUDE_OUTPUT);
1109 /* Create/Open a C include output file if asked */
1111 if (Gbl_C_IncludeOutputFlag)
1113 Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_C_INCLUDE);
1116 AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
1117 0, 0, 0, 0, NULL, NULL);
1121 /* Open the C include file, text mode */
1123 FlOpenFile (ASL_FILE_C_INCLUDE_OUTPUT, Filename, "w+t");
1125 FlPrintFile (ASL_FILE_C_INCLUDE_OUTPUT, "/*\n");
1126 AslCompilerSignon (ASL_FILE_C_INCLUDE_OUTPUT);
1127 AslCompilerFileHeader (ASL_FILE_C_INCLUDE_OUTPUT);
1130 /* Create a namespace output file if asked */
1132 if (Gbl_NsOutputFlag)
1134 Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_NAMESPACE);
1137 AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
1138 0, 0, 0, 0, NULL, NULL);
1142 /* Open the namespace file, text mode */
1144 FlOpenFile (ASL_FILE_NAMESPACE_OUTPUT, Filename, "w+t");
1146 AslCompilerSignon (ASL_FILE_NAMESPACE_OUTPUT);
1147 AslCompilerFileHeader (ASL_FILE_NAMESPACE_OUTPUT);
1154 #ifdef ACPI_OBSOLETE_FUNCTIONS
1155 /*******************************************************************************
1157 * FUNCTION: FlParseInputPathname
1159 * PARAMETERS: InputFilename - The user-specified ASL source file to be
1164 * DESCRIPTION: Split the input path into a directory and filename part
1165 * 1) Directory part used to open include files
1166 * 2) Filename part used to generate output filenames
1168 ******************************************************************************/
1171 FlParseInputPathname (
1172 char *InputFilename)
1182 /* Get the path to the input filename's directory */
1184 Gbl_DirectoryPath = strdup (InputFilename);
1185 if (!Gbl_DirectoryPath)
1187 return (AE_NO_MEMORY);
1190 Substring = strrchr (Gbl_DirectoryPath, '\\');
1193 Substring = strrchr (Gbl_DirectoryPath, '/');
1196 Substring = strrchr (Gbl_DirectoryPath, ':');
1202 Gbl_DirectoryPath[0] = 0;
1203 if (Gbl_UseDefaultAmlFilename)
1205 Gbl_OutputFilenamePrefix = strdup (InputFilename);
1210 if (Gbl_UseDefaultAmlFilename)
1212 Gbl_OutputFilenamePrefix = strdup (Substring + 1);