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
, AslGbl_LogicalLineNumber
);
193 AslGbl_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
, AslGbl_Files
[ASL_FILE_INPUT
].Filename
);
217 /* No need to free any existing filename */
219 AslGbl_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_CAST_PTR (ASL_INCLUDE_DIR
,
261 UtLocalCacheCalloc (sizeof (ASL_INCLUDE_DIR
)));
262 NewDir
->Dir
= UtLocalCacheCalloc (DirLength
+ 1 + NeedsSeparator
);
263 strcpy (NewDir
->Dir
, Dir
);
266 strcat (NewDir
->Dir
, "/");
270 * Preserve command line ordering of -I options by adding new elements
271 * at the end of the list
273 NextDir
= AslGbl_IncludeDirList
;
277 NextDir
= NextDir
->Next
;
282 PrevDir
->Next
= NewDir
;
286 AslGbl_IncludeDirList
= NewDir
;
291 /*******************************************************************************
293 * FUNCTION: FlMergePathnames
295 * PARAMETERS: PrefixDir - Prefix directory pathname. Can be NULL or
296 * a zero length string.
297 * FilePathname - The include filename from the source ASL.
299 * RETURN: Merged pathname string
301 * DESCRIPTION: Merge two pathnames that (probably) have common elements, to
302 * arrive at a minimal length string. Merge can occur if the
303 * FilePathname is relative to the PrefixDir.
305 ******************************************************************************/
317 DbgPrint (ASL_PARSE_OUTPUT
, "Include: Prefix path - \"%s\"\n"
318 "Include: FilePathname - \"%s\"\n",
319 PrefixDir
, FilePathname
);
322 * If there is no prefix directory or if the file pathname is absolute,
323 * just return the original file pathname
325 if (!PrefixDir
|| (!*PrefixDir
) ||
326 (*FilePathname
== '/') ||
327 (FilePathname
[1] == ':'))
329 Pathname
= UtLocalCacheCalloc (strlen (FilePathname
) + 1);
330 strcpy (Pathname
, FilePathname
);
331 goto ConvertBackslashes
;
334 /* Need a local copy of the prefix directory path */
336 CommonPath
= UtLocalCacheCalloc (strlen (PrefixDir
) + 1);
337 strcpy (CommonPath
, PrefixDir
);
340 * Walk forward through the file path, and simultaneously backward
341 * through the prefix directory path until there are no more
342 * relative references at the start of the file path.
344 while (*FilePathname
&& (!strncmp (FilePathname
, "../", 3)))
346 /* Remove last element of the prefix directory path */
348 LastElement
= strrchr (CommonPath
, '/');
351 goto ConcatenatePaths
;
354 *LastElement
= 0; /* Terminate CommonPath string */
355 FilePathname
+= 3; /* Point to next path element */
359 * Remove the last element of the prefix directory path (it is the same as
360 * the first element of the file pathname), and build the final merged
363 LastElement
= strrchr (CommonPath
, '/');
369 /* Build the final merged pathname */
372 Pathname
= UtLocalCacheCalloc (
373 strlen (CommonPath
) + strlen (FilePathname
) + 2);
374 if (LastElement
&& *CommonPath
)
376 strcpy (Pathname
, CommonPath
);
377 strcat (Pathname
, "/");
379 strcat (Pathname
, FilePathname
);
381 /* Convert all backslashes to normal slashes */
384 UtConvertBackslashes (Pathname
);
386 DbgPrint (ASL_PARSE_OUTPUT
, "Include: Merged Pathname - \"%s\"\n",
392 /*******************************************************************************
394 * FUNCTION: FlOpenIncludeWithPrefix
396 * PARAMETERS: PrefixDir - Prefix directory pathname. Can be a zero
398 * Filename - The include filename from the source ASL.
400 * RETURN: Valid file descriptor if successful. Null otherwise.
402 * DESCRIPTION: Open an include file and push it on the input file stack.
404 ******************************************************************************/
407 FlOpenIncludeWithPrefix (
409 ACPI_PARSE_OBJECT
*Op
,
414 UINT32 OriginalLineNumber
;
417 /* Build the full pathname to the file */
419 Pathname
= FlMergePathnames (PrefixDir
, Filename
);
421 DbgPrint (ASL_PARSE_OUTPUT
, "Include: Opening file - \"%s\"\n\n",
424 /* Attempt to open the file, push if successful */
426 IncludeFile
= fopen (Pathname
, "r");
429 fprintf (stderr
, "Could not open include file %s\n", Pathname
);
430 ACPI_FREE (Pathname
);
435 * Check the entire include file for any # preprocessor directives.
436 * This is because there may be some confusion between the #include
437 * preprocessor directive and the ASL Include statement. A file included
438 * by the ASL include cannot contain preprocessor directives because
439 * the preprocessor has already run by the time the ASL include is
440 * recognized (by the compiler, not the preprocessor.)
442 * Note: DtGetNextLine strips/ignores comments.
443 * Save current line number since DtGetNextLine modifies it.
445 AslGbl_CurrentLineNumber
--;
446 OriginalLineNumber
= AslGbl_CurrentLineNumber
;
448 while (DtGetNextLine (IncludeFile
, DT_ALLOW_MULTILINE_QUOTES
) != ASL_EOF
)
450 if (AslGbl_CurrentLineBuffer
[0] == '#')
452 AslError (ASL_ERROR
, ASL_MSG_INCLUDE_FILE
,
453 Op
, "use #include instead");
457 AslGbl_CurrentLineNumber
= OriginalLineNumber
;
459 /* Must seek back to the start of the file */
461 fseek (IncludeFile
, 0, SEEK_SET
);
463 /* Push the include file on the open input file stack */
465 AslPushInputFileStack (IncludeFile
, Pathname
);
466 return (IncludeFile
);
470 /*******************************************************************************
472 * FUNCTION: FlOpenIncludeFile
474 * PARAMETERS: Op - Parse node for the INCLUDE ASL statement
478 * DESCRIPTION: Open an include file and push it on the input file stack.
480 ******************************************************************************/
484 ACPI_PARSE_OBJECT
*Op
)
487 ASL_INCLUDE_DIR
*NextDir
;
490 /* Op must be valid */
494 AslCommonError (ASL_ERROR
, ASL_MSG_INCLUDE_FILE_OPEN
,
495 AslGbl_CurrentLineNumber
, AslGbl_LogicalLineNumber
,
496 AslGbl_InputByteCount
, AslGbl_CurrentColumn
,
497 AslGbl_Files
[ASL_FILE_INPUT
].Filename
, " - Null parse node");
503 * Flush out the "include ()" statement on this line, start
504 * the actual include file on the next line
506 AslResetCurrentLineBuffer ();
507 FlPrintFile (ASL_FILE_SOURCE_OUTPUT
, "\n");
508 AslGbl_CurrentLineOffset
++;
511 /* Attempt to open the include file */
513 /* If the file specifies an absolute path, just open it */
515 if ((Op
->Asl
.Value
.String
[0] == '/') ||
516 (Op
->Asl
.Value
.String
[0] == '\\') ||
517 (Op
->Asl
.Value
.String
[1] == ':'))
519 IncludeFile
= FlOpenIncludeWithPrefix ("", Op
, Op
->Asl
.Value
.String
);
528 * The include filename is not an absolute path.
530 * First, search for the file within the "local" directory -- meaning
531 * the same directory that contains the source file.
533 * Construct the file pathname from the global directory name.
535 IncludeFile
= FlOpenIncludeWithPrefix (
536 AslGbl_DirectoryPath
, Op
, Op
->Asl
.Value
.String
);
543 * Second, search for the file within the (possibly multiple) directories
544 * specified by the -I option on the command line.
546 NextDir
= AslGbl_IncludeDirList
;
549 IncludeFile
= FlOpenIncludeWithPrefix (
550 NextDir
->Dir
, Op
, Op
->Asl
.Value
.String
);
556 NextDir
= NextDir
->Next
;
559 /* We could not open the include file after trying very hard */
562 sprintf (AslGbl_MsgBuffer
, "%s, %s", Op
->Asl
.Value
.String
, strerror (errno
));
563 AslError (ASL_ERROR
, ASL_MSG_INCLUDE_FILE_OPEN
, Op
, AslGbl_MsgBuffer
);
567 /*******************************************************************************
569 * FUNCTION: FlOpenInputFile
571 * PARAMETERS: InputFilename - The user-specified ASL source file to be
576 * DESCRIPTION: Open the specified input file, and save the directory path to
577 * the file so that include files can be opened in
578 * the same directory.
580 ******************************************************************************/
587 /* Open the input ASL file, text mode */
589 FlOpenFile (ASL_FILE_INPUT
, InputFilename
, "rt");
590 AslCompilerin
= AslGbl_Files
[ASL_FILE_INPUT
].Handle
;
596 /*******************************************************************************
598 * FUNCTION: FlOpenAmlOutputFile
600 * PARAMETERS: FilenamePrefix - The user-specified ASL source file
604 * DESCRIPTION: Create the output filename (*.AML) and open the file. The file
605 * is created in the same directory as the parent input file.
607 ******************************************************************************/
610 FlOpenAmlOutputFile (
611 char *FilenamePrefix
)
616 /* Output filename usually comes from the ASL itself */
618 Filename
= AslGbl_Files
[ASL_FILE_AML_OUTPUT
].Filename
;
621 /* Create the output AML filename */
622 if (!AcpiGbl_CaptureComments
)
624 Filename
= FlGenerateFilename (FilenamePrefix
, FILE_SUFFIX_AML_CODE
);
628 Filename
= FlGenerateFilename (FilenamePrefix
, FILE_SUFFIX_CONVERT_AML
);
632 AslCommonError (ASL_ERROR
, ASL_MSG_OUTPUT_FILENAME
,
633 0, 0, 0, 0, NULL
, NULL
);
637 AslGbl_Files
[ASL_FILE_AML_OUTPUT
].Filename
= Filename
;
640 /* Open the output AML file in binary mode */
642 FlOpenFile (ASL_FILE_AML_OUTPUT
, Filename
, "w+b");
647 /*******************************************************************************
649 * FUNCTION: FlOpenMiscOutputFiles
651 * PARAMETERS: FilenamePrefix - The user-specified ASL source file
655 * DESCRIPTION: Create and open the various output files needed, depending on
656 * the command line options
658 ******************************************************************************/
661 FlOpenMiscOutputFiles (
662 char *FilenamePrefix
)
667 /* Create/Open a map file if requested */
669 if (AslGbl_MapfileFlag
)
671 Filename
= FlGenerateFilename (FilenamePrefix
, FILE_SUFFIX_MAP
);
674 AslCommonError (ASL_ERROR
, ASL_MSG_LISTING_FILENAME
,
675 0, 0, 0, 0, NULL
, NULL
);
679 /* Open the hex file, text mode (closed at compiler exit) */
681 FlOpenFile (ASL_FILE_MAP_OUTPUT
, Filename
, "w+t");
683 AslCompilerSignon (ASL_FILE_MAP_OUTPUT
);
684 AslCompilerFileHeader (ASL_FILE_MAP_OUTPUT
);
687 /* All done for disassembler */
689 if (AslGbl_FileType
== ASL_INPUT_TYPE_BINARY_ACPI_TABLE
)
694 /* Create/Open a hex output file if asked */
696 if (AslGbl_HexOutputFlag
)
698 Filename
= FlGenerateFilename (FilenamePrefix
, FILE_SUFFIX_HEX_DUMP
);
701 AslCommonError (ASL_ERROR
, ASL_MSG_LISTING_FILENAME
,
702 0, 0, 0, 0, NULL
, NULL
);
706 /* Open the hex file, text mode */
708 FlOpenFile (ASL_FILE_HEX_OUTPUT
, Filename
, "w+t");
710 AslCompilerSignon (ASL_FILE_HEX_OUTPUT
);
711 AslCompilerFileHeader (ASL_FILE_HEX_OUTPUT
);
714 /* Create/Open a debug output file if asked */
716 if (AslGbl_DebugFlag
)
718 Filename
= FlGenerateFilename (FilenamePrefix
, FILE_SUFFIX_DEBUG
);
721 AslCommonError (ASL_ERROR
, ASL_MSG_DEBUG_FILENAME
,
722 0, 0, 0, 0, NULL
, NULL
);
726 /* Open the debug file as STDERR, text mode */
728 AslGbl_Files
[ASL_FILE_DEBUG_OUTPUT
].Filename
= Filename
;
729 AslGbl_Files
[ASL_FILE_DEBUG_OUTPUT
].Handle
=
730 freopen (Filename
, "w+t", stderr
);
732 if (!AslGbl_Files
[ASL_FILE_DEBUG_OUTPUT
].Handle
)
735 * A problem with freopen is that on error, we no longer
736 * have stderr and cannot emit normal error messages.
737 * Emit error to stdout, close files, and exit.
740 "\nCould not open debug output file: %s\n\n", Filename
);
746 AslCompilerSignon (ASL_FILE_DEBUG_OUTPUT
);
747 AslCompilerFileHeader (ASL_FILE_DEBUG_OUTPUT
);
750 /* Create/Open a cross-reference output file if asked */
752 if (AslGbl_CrossReferenceOutput
)
754 Filename
= FlGenerateFilename (FilenamePrefix
, FILE_SUFFIX_XREF
);
757 AslCommonError (ASL_ERROR
, ASL_MSG_DEBUG_FILENAME
,
758 0, 0, 0, 0, NULL
, NULL
);
762 FlOpenFile (ASL_FILE_XREF_OUTPUT
, Filename
, "w+t");
764 AslCompilerSignon (ASL_FILE_XREF_OUTPUT
);
765 AslCompilerFileHeader (ASL_FILE_XREF_OUTPUT
);
768 /* Create/Open a listing output file if asked */
770 if (AslGbl_ListingFlag
)
772 Filename
= FlGenerateFilename (FilenamePrefix
, FILE_SUFFIX_LISTING
);
775 AslCommonError (ASL_ERROR
, ASL_MSG_LISTING_FILENAME
,
776 0, 0, 0, 0, NULL
, NULL
);
780 /* Open the listing file, text mode */
782 FlOpenFile (ASL_FILE_LISTING_OUTPUT
, Filename
, "w+t");
784 AslCompilerSignon (ASL_FILE_LISTING_OUTPUT
);
785 AslCompilerFileHeader (ASL_FILE_LISTING_OUTPUT
);
788 /* Create the preprocessor output temp file if preprocessor enabled */
790 if (AslGbl_PreprocessFlag
)
792 Filename
= FlGenerateFilename (FilenamePrefix
, FILE_SUFFIX_PREPROCESSOR
);
795 AslCommonError (ASL_ERROR
, ASL_MSG_PREPROCESSOR_FILENAME
,
796 0, 0, 0, 0, NULL
, NULL
);
800 FlOpenFile (ASL_FILE_PREPROCESSOR
, Filename
, "w+t");
804 * Create the "user" preprocessor output file if -li flag set.
805 * Note, this file contains no embedded #line directives.
807 if (AslGbl_PreprocessorOutputFlag
)
809 Filename
= FlGenerateFilename (FilenamePrefix
, FILE_SUFFIX_PREPROC_USER
);
812 AslCommonError (ASL_ERROR
, ASL_MSG_PREPROCESSOR_FILENAME
,
813 0, 0, 0, 0, NULL
, NULL
);
817 FlOpenFile (ASL_FILE_PREPROCESSOR_USER
, Filename
, "w+t");
820 /* All done for data table compiler */
822 if (AslGbl_FileType
== ASL_INPUT_TYPE_ASCII_DATA
)
827 /* Create/Open a combined source output file */
829 Filename
= FlGenerateFilename (FilenamePrefix
, FILE_SUFFIX_SOURCE
);
832 AslCommonError (ASL_ERROR
, ASL_MSG_LISTING_FILENAME
,
833 0, 0, 0, 0, NULL
, NULL
);
838 * Open the source output file, binary mode (so that LF does not get
839 * expanded to CR/LF on some systems, messing up our seek
842 FlOpenFile (ASL_FILE_SOURCE_OUTPUT
, Filename
, "w+b");
846 // AslCompilerin = AslGbl_Files[ASL_FILE_SOURCE_OUTPUT].Handle;
848 /* Create/Open a assembly code source output file if asked */
850 if (AslGbl_AsmOutputFlag
)
852 Filename
= FlGenerateFilename (FilenamePrefix
, FILE_SUFFIX_ASM_SOURCE
);
855 AslCommonError (ASL_ERROR
, ASL_MSG_LISTING_FILENAME
,
856 0, 0, 0, 0, NULL
, NULL
);
860 /* Open the assembly code source file, text mode */
862 FlOpenFile (ASL_FILE_ASM_SOURCE_OUTPUT
, Filename
, "w+t");
864 AslCompilerSignon (ASL_FILE_ASM_SOURCE_OUTPUT
);
865 AslCompilerFileHeader (ASL_FILE_ASM_SOURCE_OUTPUT
);
868 /* Create/Open a C code source output file if asked */
870 if (AslGbl_C_OutputFlag
)
872 Filename
= FlGenerateFilename (FilenamePrefix
, FILE_SUFFIX_C_SOURCE
);
875 AslCommonError (ASL_ERROR
, ASL_MSG_LISTING_FILENAME
,
876 0, 0, 0, 0, NULL
, NULL
);
880 /* Open the C code source file, text mode */
882 FlOpenFile (ASL_FILE_C_SOURCE_OUTPUT
, Filename
, "w+t");
884 FlPrintFile (ASL_FILE_C_SOURCE_OUTPUT
, "/*\n");
885 AslCompilerSignon (ASL_FILE_C_SOURCE_OUTPUT
);
886 AslCompilerFileHeader (ASL_FILE_C_SOURCE_OUTPUT
);
889 /* Create/Open a C code source output file for the offset table if asked */
891 if (AslGbl_C_OffsetTableFlag
)
893 Filename
= FlGenerateFilename (FilenamePrefix
, FILE_SUFFIX_C_OFFSET
);
896 AslCommonError (ASL_ERROR
, ASL_MSG_LISTING_FILENAME
,
897 0, 0, 0, 0, NULL
, NULL
);
901 /* Open the C code source file, text mode */
903 FlOpenFile (ASL_FILE_C_OFFSET_OUTPUT
, Filename
, "w+t");
905 FlPrintFile (ASL_FILE_C_OFFSET_OUTPUT
, "/*\n");
906 AslCompilerSignon (ASL_FILE_C_OFFSET_OUTPUT
);
907 AslCompilerFileHeader (ASL_FILE_C_OFFSET_OUTPUT
);
910 /* Create/Open a assembly include output file if asked */
912 if (AslGbl_AsmIncludeOutputFlag
)
914 Filename
= FlGenerateFilename (FilenamePrefix
, FILE_SUFFIX_ASM_INCLUDE
);
917 AslCommonError (ASL_ERROR
, ASL_MSG_LISTING_FILENAME
,
918 0, 0, 0, 0, NULL
, NULL
);
922 /* Open the assembly include file, text mode */
924 FlOpenFile (ASL_FILE_ASM_INCLUDE_OUTPUT
, Filename
, "w+t");
926 AslCompilerSignon (ASL_FILE_ASM_INCLUDE_OUTPUT
);
927 AslCompilerFileHeader (ASL_FILE_ASM_INCLUDE_OUTPUT
);
930 /* Create/Open a C include output file if asked */
932 if (AslGbl_C_IncludeOutputFlag
)
934 Filename
= FlGenerateFilename (FilenamePrefix
, FILE_SUFFIX_C_INCLUDE
);
937 AslCommonError (ASL_ERROR
, ASL_MSG_LISTING_FILENAME
,
938 0, 0, 0, 0, NULL
, NULL
);
942 /* Open the C include file, text mode */
944 FlOpenFile (ASL_FILE_C_INCLUDE_OUTPUT
, Filename
, "w+t");
946 FlPrintFile (ASL_FILE_C_INCLUDE_OUTPUT
, "/*\n");
947 AslCompilerSignon (ASL_FILE_C_INCLUDE_OUTPUT
);
948 AslCompilerFileHeader (ASL_FILE_C_INCLUDE_OUTPUT
);
951 /* Create a namespace output file if asked */
953 if (AslGbl_NsOutputFlag
)
955 Filename
= FlGenerateFilename (FilenamePrefix
, FILE_SUFFIX_NAMESPACE
);
958 AslCommonError (ASL_ERROR
, ASL_MSG_LISTING_FILENAME
,
959 0, 0, 0, 0, NULL
, NULL
);
963 /* Open the namespace file, text mode */
965 FlOpenFile (ASL_FILE_NAMESPACE_OUTPUT
, Filename
, "w+t");
967 AslCompilerSignon (ASL_FILE_NAMESPACE_OUTPUT
);
968 AslCompilerFileHeader (ASL_FILE_NAMESPACE_OUTPUT
);
971 /* Create a debug file for the converter */
973 if (AcpiGbl_DebugAslConversion
)
975 Filename
= FlGenerateFilename (FilenamePrefix
, FILE_SUFFIX_CONVERT_DEBUG
);
978 AslCommonError (ASL_ERROR
, ASL_MSG_LISTING_FILENAME
,
979 0, 0, 0, 0, NULL
, NULL
);
983 /* Open the converter debug file, text mode */
985 FlOpenFile (ASL_FILE_CONV_DEBUG_OUTPUT
, Filename
, "w+t");
987 AslCompilerSignon (ASL_FILE_CONV_DEBUG_OUTPUT
);
988 AslCompilerFileHeader (ASL_FILE_CONV_DEBUG_OUTPUT
);
990 AcpiGbl_ConvDebugFile
= AslGbl_Files
[ASL_FILE_CONV_DEBUG_OUTPUT
].Handle
;
997 #ifdef ACPI_OBSOLETE_FUNCTIONS
998 /*******************************************************************************
1000 * FUNCTION: FlParseInputPathname
1002 * PARAMETERS: InputFilename - The user-specified ASL source file to be
1007 * DESCRIPTION: Split the input path into a directory and filename part
1008 * 1) Directory part used to open include files
1009 * 2) Filename part used to generate output filenames
1011 ******************************************************************************/
1014 FlParseInputPathname (
1015 char *InputFilename
)
1025 /* Get the path to the input filename's directory */
1027 AslGbl_DirectoryPath
= strdup (InputFilename
);
1028 if (!AslGbl_DirectoryPath
)
1030 return (AE_NO_MEMORY
);
1033 Substring
= strrchr (AslGbl_DirectoryPath
, '\\');
1036 Substring
= strrchr (AslGbl_DirectoryPath
, '/');
1039 Substring
= strrchr (AslGbl_DirectoryPath
, ':');
1045 AslGbl_DirectoryPath
[0] = 0;
1046 if (AslGbl_UseDefaultAmlFilename
)
1048 AslGbl_OutputFilenamePrefix
= strdup (InputFilename
);
1053 if (AslGbl_UseDefaultAmlFilename
)
1055 AslGbl_OutputFilenamePrefix
= strdup (Substring
+ 1);
1060 UtConvertBackslashes (AslGbl_OutputFilenamePrefix
);