aslfiles.c revision 1.1.1.24 1 1.1 jruoho /******************************************************************************
2 1.1 jruoho *
3 1.1.1.3 christos * Module Name: aslfiles - File support functions
4 1.1 jruoho *
5 1.1 jruoho *****************************************************************************/
6 1.1 jruoho
7 1.1.1.23 christos /******************************************************************************
8 1.1.1.23 christos *
9 1.1.1.23 christos * 1. Copyright Notice
10 1.1.1.23 christos *
11 1.1.1.24 christos * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
12 1.1 jruoho * All rights reserved.
13 1.1 jruoho *
14 1.1.1.23 christos * 2. License
15 1.1.1.23 christos *
16 1.1.1.23 christos * 2.1. This is your license from Intel Corp. under its intellectual property
17 1.1.1.23 christos * rights. You may have additional license terms from the party that provided
18 1.1.1.23 christos * you this software, covering your right to use that party's intellectual
19 1.1.1.23 christos * property rights.
20 1.1.1.23 christos *
21 1.1.1.23 christos * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22 1.1.1.23 christos * copy of the source code appearing in this file ("Covered Code") an
23 1.1.1.23 christos * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24 1.1.1.23 christos * base code distributed originally by Intel ("Original Intel Code") to copy,
25 1.1.1.23 christos * make derivatives, distribute, use and display any portion of the Covered
26 1.1.1.23 christos * Code in any form, with the right to sublicense such rights; and
27 1.1.1.23 christos *
28 1.1.1.23 christos * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29 1.1.1.23 christos * license (with the right to sublicense), under only those claims of Intel
30 1.1.1.23 christos * patents that are infringed by the Original Intel Code, to make, use, sell,
31 1.1.1.23 christos * offer to sell, and import the Covered Code and derivative works thereof
32 1.1.1.23 christos * solely to the minimum extent necessary to exercise the above copyright
33 1.1.1.23 christos * license, and in no event shall the patent license extend to any additions
34 1.1.1.23 christos * to or modifications of the Original Intel Code. No other license or right
35 1.1.1.23 christos * is granted directly or by implication, estoppel or otherwise;
36 1.1.1.23 christos *
37 1.1.1.23 christos * The above copyright and patent license is granted only if the following
38 1.1.1.23 christos * conditions are met:
39 1.1.1.23 christos *
40 1.1.1.23 christos * 3. Conditions
41 1.1.1.23 christos *
42 1.1.1.23 christos * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43 1.1.1.23 christos * Redistribution of source code of any substantial portion of the Covered
44 1.1.1.23 christos * Code or modification with rights to further distribute source must include
45 1.1.1.23 christos * the above Copyright Notice, the above License, this list of Conditions,
46 1.1.1.23 christos * and the following Disclaimer and Export Compliance provision. In addition,
47 1.1.1.23 christos * Licensee must cause all Covered Code to which Licensee contributes to
48 1.1.1.23 christos * contain a file documenting the changes Licensee made to create that Covered
49 1.1.1.23 christos * Code and the date of any change. Licensee must include in that file the
50 1.1.1.23 christos * documentation of any changes made by any predecessor Licensee. Licensee
51 1.1.1.23 christos * must include a prominent statement that the modification is derived,
52 1.1.1.23 christos * directly or indirectly, from Original Intel Code.
53 1.1.1.23 christos *
54 1.1.1.23 christos * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55 1.1.1.23 christos * Redistribution of source code of any substantial portion of the Covered
56 1.1.1.23 christos * Code or modification without rights to further distribute source must
57 1.1.1.23 christos * include the following Disclaimer and Export Compliance provision in the
58 1.1.1.23 christos * documentation and/or other materials provided with distribution. In
59 1.1.1.23 christos * addition, Licensee may not authorize further sublicense of source of any
60 1.1.1.23 christos * portion of the Covered Code, and must include terms to the effect that the
61 1.1.1.23 christos * license from Licensee to its licensee is limited to the intellectual
62 1.1.1.23 christos * property embodied in the software Licensee provides to its licensee, and
63 1.1.1.23 christos * not to intellectual property embodied in modifications its licensee may
64 1.1.1.23 christos * make.
65 1.1.1.23 christos *
66 1.1.1.23 christos * 3.3. Redistribution of Executable. Redistribution in executable form of any
67 1.1.1.23 christos * substantial portion of the Covered Code or modification must reproduce the
68 1.1.1.23 christos * above Copyright Notice, and the following Disclaimer and Export Compliance
69 1.1.1.23 christos * provision in the documentation and/or other materials provided with the
70 1.1.1.23 christos * distribution.
71 1.1.1.23 christos *
72 1.1.1.23 christos * 3.4. Intel retains all right, title, and interest in and to the Original
73 1.1.1.23 christos * Intel Code.
74 1.1.1.23 christos *
75 1.1.1.23 christos * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76 1.1.1.23 christos * Intel shall be used in advertising or otherwise to promote the sale, use or
77 1.1.1.23 christos * other dealings in products derived from or relating to the Covered Code
78 1.1.1.23 christos * without prior written authorization from Intel.
79 1.1.1.23 christos *
80 1.1.1.23 christos * 4. Disclaimer and Export Compliance
81 1.1.1.23 christos *
82 1.1.1.23 christos * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83 1.1.1.23 christos * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84 1.1.1.23 christos * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85 1.1.1.23 christos * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86 1.1.1.23 christos * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87 1.1.1.23 christos * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
88 1.1.1.23 christos * PARTICULAR PURPOSE.
89 1.1.1.23 christos *
90 1.1.1.23 christos * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91 1.1.1.23 christos * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92 1.1.1.23 christos * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93 1.1.1.23 christos * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94 1.1.1.23 christos * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95 1.1.1.23 christos * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96 1.1.1.23 christos * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
97 1.1.1.23 christos * LIMITED REMEDY.
98 1.1.1.23 christos *
99 1.1.1.23 christos * 4.3. Licensee shall not export, either directly or indirectly, any of this
100 1.1.1.23 christos * software or system incorporating such software without first obtaining any
101 1.1.1.23 christos * required license or other approval from the U. S. Department of Commerce or
102 1.1.1.23 christos * any other agency or department of the United States Government. In the
103 1.1.1.23 christos * event Licensee exports any such software from the United States or
104 1.1.1.23 christos * re-exports any such software from a foreign destination, Licensee shall
105 1.1.1.23 christos * ensure that the distribution and export/re-export of the software is in
106 1.1.1.23 christos * compliance with all laws, regulations, orders, or other restrictions of the
107 1.1.1.23 christos * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108 1.1.1.23 christos * any of its subsidiaries will export/re-export any technical data, process,
109 1.1.1.23 christos * software, or service, directly or indirectly, to any country for which the
110 1.1.1.23 christos * United States government or any agency thereof requires an export license,
111 1.1.1.23 christos * other governmental approval, or letter of assurance, without first obtaining
112 1.1.1.23 christos * such license, approval or letter.
113 1.1.1.23 christos *
114 1.1.1.23 christos *****************************************************************************
115 1.1.1.23 christos *
116 1.1.1.23 christos * Alternatively, you may choose to be licensed under the terms of the
117 1.1.1.23 christos * following license:
118 1.1.1.23 christos *
119 1.1.1.2 jruoho * Redistribution and use in source and binary forms, with or without
120 1.1.1.2 jruoho * modification, are permitted provided that the following conditions
121 1.1.1.2 jruoho * are met:
122 1.1.1.2 jruoho * 1. Redistributions of source code must retain the above copyright
123 1.1.1.2 jruoho * notice, this list of conditions, and the following disclaimer,
124 1.1.1.2 jruoho * without modification.
125 1.1.1.2 jruoho * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126 1.1.1.2 jruoho * substantially similar to the "NO WARRANTY" disclaimer below
127 1.1.1.2 jruoho * ("Disclaimer") and any redistribution must be conditioned upon
128 1.1.1.2 jruoho * including a substantially similar Disclaimer requirement for further
129 1.1.1.2 jruoho * binary redistribution.
130 1.1.1.2 jruoho * 3. Neither the names of the above-listed copyright holders nor the names
131 1.1.1.2 jruoho * of any contributors may be used to endorse or promote products derived
132 1.1.1.2 jruoho * from this software without specific prior written permission.
133 1.1.1.2 jruoho *
134 1.1.1.2 jruoho * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
135 1.1.1.2 jruoho * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
136 1.1.1.18 christos * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
137 1.1.1.2 jruoho * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
138 1.1.1.23 christos * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
139 1.1.1.23 christos * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
140 1.1.1.23 christos * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
141 1.1.1.23 christos * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
142 1.1.1.23 christos * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143 1.1.1.23 christos * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
144 1.1.1.23 christos * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
145 1.1.1.23 christos *
146 1.1.1.23 christos * Alternatively, you may choose to be licensed under the terms of the
147 1.1.1.23 christos * GNU General Public License ("GPL") version 2 as published by the Free
148 1.1.1.23 christos * Software Foundation.
149 1.1.1.23 christos *
150 1.1.1.23 christos *****************************************************************************/
151 1.1 jruoho
152 1.1 jruoho #include "aslcompiler.h"
153 1.1 jruoho #include "acapps.h"
154 1.1 jruoho
155 1.1 jruoho #define _COMPONENT ACPI_COMPILER
156 1.1 jruoho ACPI_MODULE_NAME ("aslfiles")
157 1.1 jruoho
158 1.1 jruoho /* Local prototypes */
159 1.1 jruoho
160 1.1.1.6 christos static FILE *
161 1.1 jruoho FlOpenIncludeWithPrefix (
162 1.1 jruoho char *PrefixDir,
163 1.1.1.6 christos ACPI_PARSE_OBJECT *Op,
164 1.1 jruoho char *Filename);
165 1.1 jruoho
166 1.1.1.15 christos static BOOLEAN
167 1.1.1.15 christos FlInputFileExists (
168 1.1.1.15 christos char *InputFilename);
169 1.1.1.15 christos
170 1.1 jruoho #ifdef ACPI_OBSOLETE_FUNCTIONS
171 1.1 jruoho ACPI_STATUS
172 1.1 jruoho FlParseInputPathname (
173 1.1 jruoho char *InputFilename);
174 1.1 jruoho #endif
175 1.1 jruoho
176 1.1 jruoho
177 1.1 jruoho /*******************************************************************************
178 1.1 jruoho *
179 1.1.1.14 christos * FUNCTION: FlInitOneFile
180 1.1.1.14 christos *
181 1.1.1.14 christos * PARAMETERS: InputFilename - The user-specified ASL source file to be
182 1.1.1.14 christos * compiled
183 1.1.1.14 christos *
184 1.1.1.14 christos * RETURN: Status
185 1.1.1.14 christos *
186 1.1.1.14 christos * DESCRIPTION: Initialize global file structure for one input file. This file
187 1.1.1.14 christos * structure contains references to input, output, debugging, and
188 1.1.1.14 christos * other miscellaneous files that are associated for a single
189 1.1.1.14 christos * input ASL file.
190 1.1.1.14 christos *
191 1.1.1.14 christos ******************************************************************************/
192 1.1.1.14 christos
193 1.1.1.14 christos ACPI_STATUS
194 1.1.1.14 christos FlInitOneFile (
195 1.1.1.14 christos char *InputFilename)
196 1.1.1.14 christos {
197 1.1.1.14 christos UINT32 i;
198 1.1.1.14 christos ASL_GLOBAL_FILE_NODE *NewFileNode;
199 1.1.1.14 christos
200 1.1.1.14 christos
201 1.1.1.14 christos if (FlInputFileExists (InputFilename))
202 1.1.1.14 christos {
203 1.1.1.14 christos AslError (ASL_ERROR, ASL_MSG_DUPLICATE_INPUT_FILE, NULL, InputFilename);
204 1.1.1.14 christos return (AE_ALREADY_EXISTS);
205 1.1.1.14 christos }
206 1.1.1.14 christos
207 1.1.1.14 christos NewFileNode = ACPI_CAST_PTR (ASL_GLOBAL_FILE_NODE,
208 1.1.1.14 christos UtLocalCacheCalloc (sizeof (ASL_GLOBAL_FILE_NODE)));
209 1.1.1.14 christos
210 1.1.1.14 christos NewFileNode->ParserErrorDetected = FALSE;
211 1.1.1.14 christos NewFileNode->Next = AslGbl_FilesList;
212 1.1.1.14 christos
213 1.1.1.14 christos AslGbl_FilesList = NewFileNode;
214 1.1.1.14 christos AslGbl_Files = NewFileNode->Files;
215 1.1.1.14 christos
216 1.1.1.14 christos for (i = 0; i < ASL_NUM_FILES; i++)
217 1.1.1.14 christos {
218 1.1.1.14 christos AslGbl_Files[i].Handle = NULL;
219 1.1.1.14 christos AslGbl_Files[i].Filename = NULL;
220 1.1.1.14 christos }
221 1.1.1.14 christos
222 1.1.1.14 christos AslGbl_Files[ASL_FILE_STDOUT].Handle = stdout;
223 1.1.1.14 christos AslGbl_Files[ASL_FILE_STDOUT].Filename = "STDOUT";
224 1.1.1.14 christos
225 1.1.1.14 christos if (AslGbl_VerboseErrors)
226 1.1.1.14 christos {
227 1.1.1.14 christos AslGbl_Files[ASL_FILE_STDERR].Handle = stderr;
228 1.1.1.14 christos }
229 1.1.1.14 christos else
230 1.1.1.14 christos {
231 1.1.1.14 christos AslGbl_Files[ASL_FILE_STDERR].Handle = stdout;
232 1.1.1.14 christos }
233 1.1.1.14 christos
234 1.1.1.14 christos AslGbl_Files[ASL_FILE_STDERR].Filename = "STDERR";
235 1.1.1.14 christos return (AE_OK);
236 1.1.1.14 christos }
237 1.1.1.14 christos
238 1.1.1.14 christos
239 1.1.1.14 christos /*******************************************************************************
240 1.1.1.14 christos *
241 1.1.1.14 christos * FUNCTION: FlInputFileExists
242 1.1.1.14 christos *
243 1.1.1.14 christos * PARAMETERS: Filename - File name to be searched
244 1.1.1.14 christos *
245 1.1.1.14 christos * RETURN: Status
246 1.1.1.14 christos *
247 1.1.1.14 christos * DESCRIPTION: Returns true if the file name already exists.
248 1.1.1.14 christos *
249 1.1.1.14 christos ******************************************************************************/
250 1.1.1.14 christos
251 1.1.1.15 christos static BOOLEAN
252 1.1.1.14 christos FlInputFileExists (
253 1.1.1.14 christos char *Filename)
254 1.1.1.14 christos {
255 1.1.1.14 christos ASL_GLOBAL_FILE_NODE *Current = AslGbl_FilesList;
256 1.1.1.14 christos
257 1.1.1.14 christos
258 1.1.1.14 christos while (Current)
259 1.1.1.14 christos {
260 1.1.1.14 christos if (!strcmp (Filename, Current->Files[ASL_FILE_INPUT].Filename))
261 1.1.1.14 christos {
262 1.1.1.14 christos return (TRUE);
263 1.1.1.14 christos }
264 1.1.1.14 christos
265 1.1.1.14 christos Current = Current->Next;
266 1.1.1.14 christos }
267 1.1.1.14 christos
268 1.1.1.14 christos return (FALSE);
269 1.1.1.14 christos }
270 1.1.1.14 christos
271 1.1.1.14 christos
272 1.1.1.14 christos /*******************************************************************************
273 1.1.1.14 christos *
274 1.1.1.14 christos * FUNCTION: FlSwitchFileSet
275 1.1.1.14 christos *
276 1.1.1.14 christos * PARAMETERS: Op - Parse node for the LINE asl statement
277 1.1.1.14 christos *
278 1.1.1.14 christos * RETURN: None.
279 1.1.1.14 christos *
280 1.1.1.14 christos * DESCRIPTION: Set the current line number
281 1.1.1.14 christos *
282 1.1.1.14 christos ******************************************************************************/
283 1.1.1.14 christos
284 1.1.1.14 christos ASL_FILE_SWITCH_STATUS
285 1.1.1.14 christos FlSwitchFileSet (
286 1.1.1.14 christos char *InputFilename)
287 1.1.1.14 christos {
288 1.1.1.14 christos ASL_GLOBAL_FILE_NODE *Current = AslGbl_FilesList;
289 1.1.1.14 christos char *PrevFilename = Current->Files[ASL_FILE_INPUT].Filename;
290 1.1.1.14 christos
291 1.1.1.14 christos
292 1.1.1.14 christos while (Current)
293 1.1.1.14 christos {
294 1.1.1.14 christos if (!strcmp(Current->Files[ASL_FILE_INPUT].Filename, InputFilename))
295 1.1.1.14 christos {
296 1.1.1.14 christos AslGbl_Files = Current->Files;
297 1.1.1.14 christos AslGbl_TableSignature = Current->TableSignature;
298 1.1.1.14 christos AslGbl_TableId = Current->TableId;
299 1.1.1.14 christos
300 1.1.1.14 christos if (!strcmp (InputFilename, PrevFilename))
301 1.1.1.14 christos {
302 1.1.1.14 christos return (SWITCH_TO_SAME_FILE);
303 1.1.1.14 christos }
304 1.1.1.14 christos else
305 1.1.1.14 christos {
306 1.1.1.14 christos return (SWITCH_TO_DIFFERENT_FILE);
307 1.1.1.14 christos }
308 1.1.1.14 christos }
309 1.1.1.14 christos
310 1.1.1.14 christos Current = Current->Next;
311 1.1.1.14 christos }
312 1.1.1.14 christos
313 1.1.1.14 christos return (FILE_NOT_FOUND);
314 1.1.1.14 christos }
315 1.1.1.14 christos
316 1.1.1.14 christos
317 1.1.1.14 christos /*******************************************************************************
318 1.1.1.14 christos *
319 1.1.1.14 christos * FUNCTION: FlGetFileHandle
320 1.1.1.14 christos *
321 1.1.1.14 christos * PARAMETERS: OutFileId - denotes file type of output handle
322 1.1.1.14 christos * InFileId - denotes file type of the input Filename
323 1.1.1.14 christos * Filename
324 1.1.1.14 christos *
325 1.1.1.14 christos * RETURN: File handle
326 1.1.1.14 christos *
327 1.1.1.14 christos * DESCRIPTION: Get the file handle for a particular filename/FileId. This
328 1.1.1.14 christos * function also allows the caller to specify the file Id of the
329 1.1.1.14 christos * desired type.
330 1.1.1.14 christos *
331 1.1.1.14 christos ******************************************************************************/
332 1.1.1.14 christos
333 1.1.1.14 christos FILE *
334 1.1.1.14 christos FlGetFileHandle (
335 1.1.1.14 christos UINT32 OutFileId,
336 1.1.1.14 christos UINT32 InFileId,
337 1.1.1.14 christos char *Filename)
338 1.1.1.14 christos {
339 1.1.1.14 christos ASL_GLOBAL_FILE_NODE *Current = AslGbl_FilesList;
340 1.1.1.14 christos
341 1.1.1.14 christos
342 1.1.1.14 christos if (!Filename)
343 1.1.1.14 christos {
344 1.1.1.14 christos return (NULL);
345 1.1.1.14 christos }
346 1.1.1.14 christos
347 1.1.1.14 christos while (Current)
348 1.1.1.14 christos {
349 1.1.1.22 christos if (!((Current->FileType == ASL_INPUT_TYPE_ASCII_DATA) &&
350 1.1.1.22 christos (InFileId == ASL_FILE_SOURCE_OUTPUT)) &&
351 1.1.1.22 christos !strcmp (Current->Files[InFileId].Filename, Filename))
352 1.1.1.14 christos {
353 1.1.1.14 christos return (Current->Files[OutFileId].Handle);
354 1.1.1.14 christos }
355 1.1.1.14 christos
356 1.1.1.14 christos Current = Current->Next;
357 1.1.1.14 christos }
358 1.1.1.14 christos
359 1.1.1.14 christos return (NULL);
360 1.1.1.14 christos }
361 1.1.1.14 christos
362 1.1.1.14 christos
363 1.1.1.14 christos /*******************************************************************************
364 1.1.1.14 christos *
365 1.1.1.14 christos * FUNCTION: FlGetFileNode
366 1.1.1.14 christos *
367 1.1.1.14 christos * PARAMETERS: FileId - File type (ID) of the input Filename
368 1.1.1.14 christos * Filename - File to search for
369 1.1.1.14 christos *
370 1.1.1.14 christos * RETURN: A global file node
371 1.1.1.14 christos *
372 1.1.1.14 christos * DESCRIPTION: Get the file node for a particular filename/FileId.
373 1.1.1.14 christos *
374 1.1.1.14 christos ******************************************************************************/
375 1.1.1.14 christos
376 1.1.1.14 christos ASL_GLOBAL_FILE_NODE *
377 1.1.1.14 christos FlGetFileNode (
378 1.1.1.14 christos UINT32 FileId,
379 1.1.1.14 christos char *Filename)
380 1.1.1.14 christos {
381 1.1.1.14 christos ASL_GLOBAL_FILE_NODE *Current = AslGbl_FilesList;
382 1.1.1.14 christos
383 1.1.1.14 christos
384 1.1.1.14 christos if (!Filename)
385 1.1.1.14 christos {
386 1.1.1.14 christos return (NULL);
387 1.1.1.14 christos }
388 1.1.1.14 christos
389 1.1.1.14 christos while (Current)
390 1.1.1.14 christos {
391 1.1.1.14 christos if (!strcmp (Current->Files[FileId].Filename, Filename))
392 1.1.1.14 christos {
393 1.1.1.14 christos return (Current);
394 1.1.1.14 christos }
395 1.1.1.14 christos
396 1.1.1.14 christos Current = Current->Next;
397 1.1.1.14 christos }
398 1.1.1.14 christos
399 1.1.1.14 christos return (NULL);
400 1.1.1.14 christos }
401 1.1.1.14 christos
402 1.1.1.14 christos
403 1.1.1.14 christos /*******************************************************************************
404 1.1.1.14 christos *
405 1.1.1.14 christos * FUNCTION: FlGetCurrentFileNode
406 1.1.1.14 christos *
407 1.1.1.14 christos * PARAMETERS: None
408 1.1.1.14 christos *
409 1.1.1.14 christos * RETURN: Global file node
410 1.1.1.14 christos *
411 1.1.1.14 christos * DESCRIPTION: Get the current input file node
412 1.1.1.14 christos *
413 1.1.1.14 christos ******************************************************************************/
414 1.1.1.14 christos
415 1.1.1.14 christos ASL_GLOBAL_FILE_NODE *
416 1.1.1.14 christos FlGetCurrentFileNode (
417 1.1.1.14 christos void)
418 1.1.1.14 christos {
419 1.1.1.16 christos ASL_GLOBAL_FILE_NODE *FileNode =
420 1.1.1.16 christos FlGetFileNode (ASL_FILE_INPUT,AslGbl_Files[ASL_FILE_INPUT].Filename);
421 1.1.1.16 christos
422 1.1.1.16 christos
423 1.1.1.16 christos if (!FileNode)
424 1.1.1.16 christos {
425 1.1.1.16 christos /*
426 1.1.1.16 christos * If the current file node does not exist after initializing the file
427 1.1.1.16 christos * node structures, something went wrong and this is an unrecoverable
428 1.1.1.16 christos * condition.
429 1.1.1.16 christos */
430 1.1.1.16 christos FlFileError (ASL_FILE_INPUT, ASL_MSG_COMPILER_INTERNAL);
431 1.1.1.16 christos AslAbort ();
432 1.1.1.16 christos }
433 1.1.1.16 christos
434 1.1.1.16 christos return (FileNode);
435 1.1.1.14 christos }
436 1.1.1.14 christos
437 1.1.1.14 christos
438 1.1.1.14 christos /*******************************************************************************
439 1.1.1.14 christos *
440 1.1.1.3 christos * FUNCTION: FlSetLineNumber
441 1.1 jruoho *
442 1.1.1.3 christos * PARAMETERS: Op - Parse node for the LINE asl statement
443 1.1 jruoho *
444 1.1.1.3 christos * RETURN: None.
445 1.1 jruoho *
446 1.1.1.3 christos * DESCRIPTION: Set the current line number
447 1.1 jruoho *
448 1.1 jruoho ******************************************************************************/
449 1.1 jruoho
450 1.1 jruoho void
451 1.1.1.3 christos FlSetLineNumber (
452 1.1.1.3 christos UINT32 LineNumber)
453 1.1 jruoho {
454 1.1 jruoho
455 1.1.1.3 christos DbgPrint (ASL_PARSE_OUTPUT, "\n#line: New line number %u (old %u)\n",
456 1.1.1.13 christos LineNumber, AslGbl_LogicalLineNumber);
457 1.1 jruoho
458 1.1.1.13 christos AslGbl_CurrentLineNumber = LineNumber;
459 1.1 jruoho }
460 1.1 jruoho
461 1.1 jruoho
462 1.1 jruoho /*******************************************************************************
463 1.1 jruoho *
464 1.1.1.3 christos * FUNCTION: FlSetFilename
465 1.1 jruoho *
466 1.1 jruoho * PARAMETERS: Op - Parse node for the LINE asl statement
467 1.1 jruoho *
468 1.1 jruoho * RETURN: None.
469 1.1 jruoho *
470 1.1.1.3 christos * DESCRIPTION: Set the current filename
471 1.1 jruoho *
472 1.1 jruoho ******************************************************************************/
473 1.1 jruoho
474 1.1 jruoho void
475 1.1.1.3 christos FlSetFilename (
476 1.1.1.3 christos char *Filename)
477 1.1 jruoho {
478 1.1 jruoho
479 1.1.1.3 christos DbgPrint (ASL_PARSE_OUTPUT, "\n#line: New filename %s (old %s)\n",
480 1.1.1.13 christos Filename, AslGbl_Files[ASL_FILE_INPUT].Filename);
481 1.1.1.3 christos
482 1.1.1.4 christos /* No need to free any existing filename */
483 1.1.1.4 christos
484 1.1.1.13 christos AslGbl_Files[ASL_FILE_INPUT].Filename = Filename;
485 1.1 jruoho }
486 1.1 jruoho
487 1.1 jruoho
488 1.1 jruoho /*******************************************************************************
489 1.1 jruoho *
490 1.1 jruoho * FUNCTION: FlAddIncludeDirectory
491 1.1 jruoho *
492 1.1 jruoho * PARAMETERS: Dir - Directory pathname string
493 1.1 jruoho *
494 1.1 jruoho * RETURN: None
495 1.1 jruoho *
496 1.1 jruoho * DESCRIPTION: Add a directory the list of include prefix directories.
497 1.1 jruoho *
498 1.1 jruoho ******************************************************************************/
499 1.1 jruoho
500 1.1 jruoho void
501 1.1 jruoho FlAddIncludeDirectory (
502 1.1 jruoho char *Dir)
503 1.1 jruoho {
504 1.1 jruoho ASL_INCLUDE_DIR *NewDir;
505 1.1 jruoho ASL_INCLUDE_DIR *NextDir;
506 1.1 jruoho ASL_INCLUDE_DIR *PrevDir = NULL;
507 1.1 jruoho UINT32 NeedsSeparator = 0;
508 1.1 jruoho size_t DirLength;
509 1.1 jruoho
510 1.1 jruoho
511 1.1 jruoho DirLength = strlen (Dir);
512 1.1 jruoho if (!DirLength)
513 1.1 jruoho {
514 1.1 jruoho return;
515 1.1 jruoho }
516 1.1 jruoho
517 1.1 jruoho /* Make sure that the pathname ends with a path separator */
518 1.1 jruoho
519 1.1 jruoho if ((Dir[DirLength-1] != '/') &&
520 1.1 jruoho (Dir[DirLength-1] != '\\'))
521 1.1 jruoho {
522 1.1 jruoho NeedsSeparator = 1;
523 1.1 jruoho }
524 1.1 jruoho
525 1.1.1.13 christos NewDir = ACPI_CAST_PTR (ASL_INCLUDE_DIR,
526 1.1.1.13 christos UtLocalCacheCalloc (sizeof (ASL_INCLUDE_DIR)));
527 1.1.1.13 christos NewDir->Dir = UtLocalCacheCalloc (DirLength + 1 + NeedsSeparator);
528 1.1 jruoho strcpy (NewDir->Dir, Dir);
529 1.1 jruoho if (NeedsSeparator)
530 1.1 jruoho {
531 1.1 jruoho strcat (NewDir->Dir, "/");
532 1.1 jruoho }
533 1.1 jruoho
534 1.1 jruoho /*
535 1.1 jruoho * Preserve command line ordering of -I options by adding new elements
536 1.1 jruoho * at the end of the list
537 1.1 jruoho */
538 1.1.1.13 christos NextDir = AslGbl_IncludeDirList;
539 1.1 jruoho while (NextDir)
540 1.1 jruoho {
541 1.1 jruoho PrevDir = NextDir;
542 1.1 jruoho NextDir = NextDir->Next;
543 1.1 jruoho }
544 1.1 jruoho
545 1.1 jruoho if (PrevDir)
546 1.1 jruoho {
547 1.1 jruoho PrevDir->Next = NewDir;
548 1.1 jruoho }
549 1.1 jruoho else
550 1.1 jruoho {
551 1.1.1.13 christos AslGbl_IncludeDirList = NewDir;
552 1.1 jruoho }
553 1.1 jruoho }
554 1.1 jruoho
555 1.1 jruoho
556 1.1 jruoho /*******************************************************************************
557 1.1 jruoho *
558 1.1.1.3 christos * FUNCTION: FlMergePathnames
559 1.1.1.3 christos *
560 1.1.1.3 christos * PARAMETERS: PrefixDir - Prefix directory pathname. Can be NULL or
561 1.1.1.3 christos * a zero length string.
562 1.1.1.3 christos * FilePathname - The include filename from the source ASL.
563 1.1.1.3 christos *
564 1.1.1.3 christos * RETURN: Merged pathname string
565 1.1.1.3 christos *
566 1.1.1.3 christos * DESCRIPTION: Merge two pathnames that (probably) have common elements, to
567 1.1.1.3 christos * arrive at a minimal length string. Merge can occur if the
568 1.1.1.3 christos * FilePathname is relative to the PrefixDir.
569 1.1.1.3 christos *
570 1.1.1.3 christos ******************************************************************************/
571 1.1.1.3 christos
572 1.1.1.3 christos char *
573 1.1.1.3 christos FlMergePathnames (
574 1.1.1.3 christos char *PrefixDir,
575 1.1.1.3 christos char *FilePathname)
576 1.1.1.3 christos {
577 1.1.1.3 christos char *CommonPath;
578 1.1.1.3 christos char *Pathname;
579 1.1.1.3 christos char *LastElement;
580 1.1.1.3 christos
581 1.1.1.3 christos
582 1.1.1.3 christos DbgPrint (ASL_PARSE_OUTPUT, "Include: Prefix path - \"%s\"\n"
583 1.1.1.3 christos "Include: FilePathname - \"%s\"\n",
584 1.1.1.3 christos PrefixDir, FilePathname);
585 1.1.1.3 christos
586 1.1.1.3 christos /*
587 1.1.1.3 christos * If there is no prefix directory or if the file pathname is absolute,
588 1.1.1.3 christos * just return the original file pathname
589 1.1.1.3 christos */
590 1.1.1.3 christos if (!PrefixDir || (!*PrefixDir) ||
591 1.1.1.3 christos (*FilePathname == '/') ||
592 1.1.1.3 christos (FilePathname[1] == ':'))
593 1.1.1.3 christos {
594 1.1.1.11 christos Pathname = UtLocalCacheCalloc (strlen (FilePathname) + 1);
595 1.1.1.3 christos strcpy (Pathname, FilePathname);
596 1.1.1.3 christos goto ConvertBackslashes;
597 1.1.1.3 christos }
598 1.1.1.3 christos
599 1.1.1.3 christos /* Need a local copy of the prefix directory path */
600 1.1.1.3 christos
601 1.1.1.11 christos CommonPath = UtLocalCacheCalloc (strlen (PrefixDir) + 1);
602 1.1.1.3 christos strcpy (CommonPath, PrefixDir);
603 1.1.1.3 christos
604 1.1.1.3 christos /*
605 1.1.1.3 christos * Walk forward through the file path, and simultaneously backward
606 1.1.1.3 christos * through the prefix directory path until there are no more
607 1.1.1.3 christos * relative references at the start of the file path.
608 1.1.1.3 christos */
609 1.1.1.3 christos while (*FilePathname && (!strncmp (FilePathname, "../", 3)))
610 1.1.1.3 christos {
611 1.1.1.3 christos /* Remove last element of the prefix directory path */
612 1.1.1.3 christos
613 1.1.1.3 christos LastElement = strrchr (CommonPath, '/');
614 1.1.1.3 christos if (!LastElement)
615 1.1.1.3 christos {
616 1.1.1.3 christos goto ConcatenatePaths;
617 1.1.1.3 christos }
618 1.1.1.3 christos
619 1.1.1.3 christos *LastElement = 0; /* Terminate CommonPath string */
620 1.1.1.3 christos FilePathname += 3; /* Point to next path element */
621 1.1.1.3 christos }
622 1.1.1.3 christos
623 1.1.1.3 christos /*
624 1.1.1.3 christos * Remove the last element of the prefix directory path (it is the same as
625 1.1.1.3 christos * the first element of the file pathname), and build the final merged
626 1.1.1.3 christos * pathname.
627 1.1.1.3 christos */
628 1.1.1.3 christos LastElement = strrchr (CommonPath, '/');
629 1.1.1.3 christos if (LastElement)
630 1.1.1.3 christos {
631 1.1.1.3 christos *LastElement = 0;
632 1.1.1.3 christos }
633 1.1.1.3 christos
634 1.1.1.3 christos /* Build the final merged pathname */
635 1.1.1.3 christos
636 1.1.1.3 christos ConcatenatePaths:
637 1.1.1.11 christos Pathname = UtLocalCacheCalloc (
638 1.1.1.7 christos strlen (CommonPath) + strlen (FilePathname) + 2);
639 1.1.1.3 christos if (LastElement && *CommonPath)
640 1.1.1.3 christos {
641 1.1.1.3 christos strcpy (Pathname, CommonPath);
642 1.1.1.3 christos strcat (Pathname, "/");
643 1.1.1.3 christos }
644 1.1.1.3 christos strcat (Pathname, FilePathname);
645 1.1.1.3 christos
646 1.1.1.3 christos /* Convert all backslashes to normal slashes */
647 1.1.1.3 christos
648 1.1.1.3 christos ConvertBackslashes:
649 1.1.1.3 christos UtConvertBackslashes (Pathname);
650 1.1.1.3 christos
651 1.1.1.3 christos DbgPrint (ASL_PARSE_OUTPUT, "Include: Merged Pathname - \"%s\"\n",
652 1.1.1.3 christos Pathname);
653 1.1.1.3 christos return (Pathname);
654 1.1.1.3 christos }
655 1.1.1.3 christos
656 1.1.1.3 christos
657 1.1.1.3 christos /*******************************************************************************
658 1.1.1.3 christos *
659 1.1 jruoho * FUNCTION: FlOpenIncludeWithPrefix
660 1.1 jruoho *
661 1.1 jruoho * PARAMETERS: PrefixDir - Prefix directory pathname. Can be a zero
662 1.1 jruoho * length string.
663 1.1 jruoho * Filename - The include filename from the source ASL.
664 1.1 jruoho *
665 1.1 jruoho * RETURN: Valid file descriptor if successful. Null otherwise.
666 1.1 jruoho *
667 1.1 jruoho * DESCRIPTION: Open an include file and push it on the input file stack.
668 1.1 jruoho *
669 1.1 jruoho ******************************************************************************/
670 1.1 jruoho
671 1.1.1.6 christos static FILE *
672 1.1 jruoho FlOpenIncludeWithPrefix (
673 1.1 jruoho char *PrefixDir,
674 1.1.1.6 christos ACPI_PARSE_OBJECT *Op,
675 1.1 jruoho char *Filename)
676 1.1 jruoho {
677 1.1 jruoho FILE *IncludeFile;
678 1.1 jruoho char *Pathname;
679 1.1.1.6 christos UINT32 OriginalLineNumber;
680 1.1 jruoho
681 1.1 jruoho
682 1.1 jruoho /* Build the full pathname to the file */
683 1.1 jruoho
684 1.1.1.3 christos Pathname = FlMergePathnames (PrefixDir, Filename);
685 1.1 jruoho
686 1.1.1.3 christos DbgPrint (ASL_PARSE_OUTPUT, "Include: Opening file - \"%s\"\n\n",
687 1.1 jruoho Pathname);
688 1.1 jruoho
689 1.1 jruoho /* Attempt to open the file, push if successful */
690 1.1 jruoho
691 1.1 jruoho IncludeFile = fopen (Pathname, "r");
692 1.1.1.3 christos if (!IncludeFile)
693 1.1 jruoho {
694 1.1.1.3 christos return (NULL);
695 1.1 jruoho }
696 1.1 jruoho
697 1.1.1.6 christos /*
698 1.1.1.6 christos * Check the entire include file for any # preprocessor directives.
699 1.1.1.6 christos * This is because there may be some confusion between the #include
700 1.1.1.6 christos * preprocessor directive and the ASL Include statement. A file included
701 1.1.1.6 christos * by the ASL include cannot contain preprocessor directives because
702 1.1.1.6 christos * the preprocessor has already run by the time the ASL include is
703 1.1.1.6 christos * recognized (by the compiler, not the preprocessor.)
704 1.1.1.6 christos *
705 1.1.1.6 christos * Note: DtGetNextLine strips/ignores comments.
706 1.1.1.6 christos * Save current line number since DtGetNextLine modifies it.
707 1.1.1.6 christos */
708 1.1.1.13 christos AslGbl_CurrentLineNumber--;
709 1.1.1.13 christos OriginalLineNumber = AslGbl_CurrentLineNumber;
710 1.1.1.7 christos
711 1.1.1.6 christos while (DtGetNextLine (IncludeFile, DT_ALLOW_MULTILINE_QUOTES) != ASL_EOF)
712 1.1.1.6 christos {
713 1.1.1.13 christos if (AslGbl_CurrentLineBuffer[0] == '#')
714 1.1.1.6 christos {
715 1.1.1.6 christos AslError (ASL_ERROR, ASL_MSG_INCLUDE_FILE,
716 1.1.1.6 christos Op, "use #include instead");
717 1.1.1.6 christos }
718 1.1.1.6 christos }
719 1.1.1.7 christos
720 1.1.1.13 christos AslGbl_CurrentLineNumber = OriginalLineNumber;
721 1.1.1.6 christos
722 1.1.1.6 christos /* Must seek back to the start of the file */
723 1.1.1.6 christos
724 1.1.1.6 christos fseek (IncludeFile, 0, SEEK_SET);
725 1.1.1.6 christos
726 1.1.1.3 christos /* Push the include file on the open input file stack */
727 1.1.1.3 christos
728 1.1.1.3 christos AslPushInputFileStack (IncludeFile, Pathname);
729 1.1.1.3 christos return (IncludeFile);
730 1.1 jruoho }
731 1.1 jruoho
732 1.1 jruoho
733 1.1 jruoho /*******************************************************************************
734 1.1 jruoho *
735 1.1 jruoho * FUNCTION: FlOpenIncludeFile
736 1.1 jruoho *
737 1.1 jruoho * PARAMETERS: Op - Parse node for the INCLUDE ASL statement
738 1.1 jruoho *
739 1.1 jruoho * RETURN: None.
740 1.1 jruoho *
741 1.1 jruoho * DESCRIPTION: Open an include file and push it on the input file stack.
742 1.1 jruoho *
743 1.1 jruoho ******************************************************************************/
744 1.1 jruoho
745 1.1 jruoho void
746 1.1 jruoho FlOpenIncludeFile (
747 1.1 jruoho ACPI_PARSE_OBJECT *Op)
748 1.1 jruoho {
749 1.1 jruoho FILE *IncludeFile;
750 1.1 jruoho ASL_INCLUDE_DIR *NextDir;
751 1.1 jruoho
752 1.1 jruoho
753 1.1 jruoho /* Op must be valid */
754 1.1 jruoho
755 1.1 jruoho if (!Op)
756 1.1 jruoho {
757 1.1 jruoho AslCommonError (ASL_ERROR, ASL_MSG_INCLUDE_FILE_OPEN,
758 1.1.1.13 christos AslGbl_CurrentLineNumber, AslGbl_LogicalLineNumber,
759 1.1.1.13 christos AslGbl_InputByteCount, AslGbl_CurrentColumn,
760 1.1.1.13 christos AslGbl_Files[ASL_FILE_INPUT].Filename, " - Null parse node");
761 1.1 jruoho
762 1.1 jruoho return;
763 1.1 jruoho }
764 1.1 jruoho
765 1.1 jruoho /*
766 1.1 jruoho * Flush out the "include ()" statement on this line, start
767 1.1 jruoho * the actual include file on the next line
768 1.1 jruoho */
769 1.1.1.3 christos AslResetCurrentLineBuffer ();
770 1.1 jruoho FlPrintFile (ASL_FILE_SOURCE_OUTPUT, "\n");
771 1.1.1.13 christos AslGbl_CurrentLineOffset++;
772 1.1 jruoho
773 1.1 jruoho
774 1.1 jruoho /* Attempt to open the include file */
775 1.1 jruoho
776 1.1 jruoho /* If the file specifies an absolute path, just open it */
777 1.1 jruoho
778 1.1 jruoho if ((Op->Asl.Value.String[0] == '/') ||
779 1.1 jruoho (Op->Asl.Value.String[0] == '\\') ||
780 1.1 jruoho (Op->Asl.Value.String[1] == ':'))
781 1.1 jruoho {
782 1.1.1.6 christos IncludeFile = FlOpenIncludeWithPrefix ("", Op, Op->Asl.Value.String);
783 1.1 jruoho if (!IncludeFile)
784 1.1 jruoho {
785 1.1 jruoho goto ErrorExit;
786 1.1 jruoho }
787 1.1 jruoho return;
788 1.1 jruoho }
789 1.1 jruoho
790 1.1 jruoho /*
791 1.1 jruoho * The include filename is not an absolute path.
792 1.1 jruoho *
793 1.1 jruoho * First, search for the file within the "local" directory -- meaning
794 1.1 jruoho * the same directory that contains the source file.
795 1.1 jruoho *
796 1.1 jruoho * Construct the file pathname from the global directory name.
797 1.1 jruoho */
798 1.1.1.7 christos IncludeFile = FlOpenIncludeWithPrefix (
799 1.1.1.13 christos AslGbl_DirectoryPath, Op, Op->Asl.Value.String);
800 1.1 jruoho if (IncludeFile)
801 1.1 jruoho {
802 1.1 jruoho return;
803 1.1 jruoho }
804 1.1 jruoho
805 1.1 jruoho /*
806 1.1 jruoho * Second, search for the file within the (possibly multiple) directories
807 1.1 jruoho * specified by the -I option on the command line.
808 1.1 jruoho */
809 1.1.1.13 christos NextDir = AslGbl_IncludeDirList;
810 1.1 jruoho while (NextDir)
811 1.1 jruoho {
812 1.1.1.7 christos IncludeFile = FlOpenIncludeWithPrefix (
813 1.1.1.7 christos NextDir->Dir, Op, Op->Asl.Value.String);
814 1.1 jruoho if (IncludeFile)
815 1.1 jruoho {
816 1.1 jruoho return;
817 1.1 jruoho }
818 1.1 jruoho
819 1.1 jruoho NextDir = NextDir->Next;
820 1.1 jruoho }
821 1.1 jruoho
822 1.1 jruoho /* We could not open the include file after trying very hard */
823 1.1 jruoho
824 1.1 jruoho ErrorExit:
825 1.1.1.13 christos sprintf (AslGbl_MsgBuffer, "%s, %s", Op->Asl.Value.String, strerror (errno));
826 1.1.1.13 christos AslError (ASL_ERROR, ASL_MSG_INCLUDE_FILE_OPEN, Op, AslGbl_MsgBuffer);
827 1.1 jruoho }
828 1.1 jruoho
829 1.1 jruoho
830 1.1 jruoho /*******************************************************************************
831 1.1 jruoho *
832 1.1 jruoho * FUNCTION: FlOpenInputFile
833 1.1 jruoho *
834 1.1 jruoho * PARAMETERS: InputFilename - The user-specified ASL source file to be
835 1.1 jruoho * compiled
836 1.1 jruoho *
837 1.1 jruoho * RETURN: Status
838 1.1 jruoho *
839 1.1 jruoho * DESCRIPTION: Open the specified input file, and save the directory path to
840 1.1.1.19 christos * the file so that include files can be opened in the same
841 1.1.1.19 christos * directory. NOTE: File is opened in text mode.
842 1.1 jruoho *
843 1.1 jruoho ******************************************************************************/
844 1.1 jruoho
845 1.1 jruoho ACPI_STATUS
846 1.1 jruoho FlOpenInputFile (
847 1.1 jruoho char *InputFilename)
848 1.1 jruoho {
849 1.1 jruoho
850 1.1 jruoho /* Open the input ASL file, text mode */
851 1.1 jruoho
852 1.1.1.3 christos FlOpenFile (ASL_FILE_INPUT, InputFilename, "rt");
853 1.1.1.13 christos AslCompilerin = AslGbl_Files[ASL_FILE_INPUT].Handle;
854 1.1 jruoho
855 1.1 jruoho return (AE_OK);
856 1.1 jruoho }
857 1.1 jruoho
858 1.1 jruoho
859 1.1 jruoho /*******************************************************************************
860 1.1 jruoho *
861 1.1 jruoho * FUNCTION: FlOpenAmlOutputFile
862 1.1 jruoho *
863 1.1 jruoho * PARAMETERS: FilenamePrefix - The user-specified ASL source file
864 1.1 jruoho *
865 1.1 jruoho * RETURN: Status
866 1.1 jruoho *
867 1.1.1.3 christos * DESCRIPTION: Create the output filename (*.AML) and open the file. The file
868 1.1 jruoho * is created in the same directory as the parent input file.
869 1.1 jruoho *
870 1.1 jruoho ******************************************************************************/
871 1.1 jruoho
872 1.1 jruoho ACPI_STATUS
873 1.1 jruoho FlOpenAmlOutputFile (
874 1.1 jruoho char *FilenamePrefix)
875 1.1 jruoho {
876 1.1 jruoho char *Filename;
877 1.1 jruoho
878 1.1 jruoho
879 1.1 jruoho /* Output filename usually comes from the ASL itself */
880 1.1 jruoho
881 1.1.1.13 christos Filename = AslGbl_Files[ASL_FILE_AML_OUTPUT].Filename;
882 1.1 jruoho if (!Filename)
883 1.1 jruoho {
884 1.1 jruoho /* Create the output AML filename */
885 1.1.1.12 christos if (!AcpiGbl_CaptureComments)
886 1.1.1.10 christos {
887 1.1.1.10 christos Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_AML_CODE);
888 1.1.1.10 christos }
889 1.1.1.10 christos else
890 1.1.1.10 christos {
891 1.1.1.10 christos Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_CONVERT_AML);
892 1.1.1.10 christos }
893 1.1 jruoho if (!Filename)
894 1.1 jruoho {
895 1.1 jruoho AslCommonError (ASL_ERROR, ASL_MSG_OUTPUT_FILENAME,
896 1.1 jruoho 0, 0, 0, 0, NULL, NULL);
897 1.1 jruoho return (AE_ERROR);
898 1.1 jruoho }
899 1.1.1.5 christos
900 1.1.1.13 christos AslGbl_Files[ASL_FILE_AML_OUTPUT].Filename = Filename;
901 1.1 jruoho }
902 1.1 jruoho
903 1.1 jruoho /* Open the output AML file in binary mode */
904 1.1 jruoho
905 1.1 jruoho FlOpenFile (ASL_FILE_AML_OUTPUT, Filename, "w+b");
906 1.1 jruoho return (AE_OK);
907 1.1 jruoho }
908 1.1 jruoho
909 1.1 jruoho
910 1.1 jruoho /*******************************************************************************
911 1.1 jruoho *
912 1.1 jruoho * FUNCTION: FlOpenMiscOutputFiles
913 1.1 jruoho *
914 1.1 jruoho * PARAMETERS: FilenamePrefix - The user-specified ASL source file
915 1.1 jruoho *
916 1.1 jruoho * RETURN: Status
917 1.1 jruoho *
918 1.1 jruoho * DESCRIPTION: Create and open the various output files needed, depending on
919 1.1 jruoho * the command line options
920 1.1 jruoho *
921 1.1 jruoho ******************************************************************************/
922 1.1 jruoho
923 1.1 jruoho ACPI_STATUS
924 1.1 jruoho FlOpenMiscOutputFiles (
925 1.1 jruoho char *FilenamePrefix)
926 1.1 jruoho {
927 1.1 jruoho char *Filename;
928 1.1 jruoho
929 1.1 jruoho
930 1.1.1.6 christos /* Create/Open a map file if requested */
931 1.1.1.6 christos
932 1.1.1.13 christos if (AslGbl_MapfileFlag)
933 1.1.1.6 christos {
934 1.1.1.6 christos Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_MAP);
935 1.1.1.6 christos if (!Filename)
936 1.1.1.6 christos {
937 1.1.1.6 christos AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
938 1.1.1.6 christos 0, 0, 0, 0, NULL, NULL);
939 1.1.1.6 christos return (AE_ERROR);
940 1.1.1.6 christos }
941 1.1.1.6 christos
942 1.1.1.6 christos /* Open the hex file, text mode (closed at compiler exit) */
943 1.1.1.6 christos
944 1.1.1.6 christos FlOpenFile (ASL_FILE_MAP_OUTPUT, Filename, "w+t");
945 1.1.1.6 christos
946 1.1.1.6 christos AslCompilerSignon (ASL_FILE_MAP_OUTPUT);
947 1.1.1.6 christos AslCompilerFileHeader (ASL_FILE_MAP_OUTPUT);
948 1.1.1.6 christos }
949 1.1.1.6 christos
950 1.1.1.3 christos /* All done for disassembler */
951 1.1.1.3 christos
952 1.1.1.13 christos if (AslGbl_FileType == ASL_INPUT_TYPE_BINARY_ACPI_TABLE)
953 1.1.1.3 christos {
954 1.1.1.3 christos return (AE_OK);
955 1.1.1.3 christos }
956 1.1.1.3 christos
957 1.1.1.2 jruoho /* Create/Open a hex output file if asked */
958 1.1 jruoho
959 1.1.1.13 christos if (AslGbl_HexOutputFlag)
960 1.1 jruoho {
961 1.1.1.2 jruoho Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_HEX_DUMP);
962 1.1.1.2 jruoho if (!Filename)
963 1.1.1.2 jruoho {
964 1.1.1.2 jruoho AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
965 1.1.1.2 jruoho 0, 0, 0, 0, NULL, NULL);
966 1.1.1.2 jruoho return (AE_ERROR);
967 1.1.1.2 jruoho }
968 1.1.1.2 jruoho
969 1.1.1.2 jruoho /* Open the hex file, text mode */
970 1.1.1.2 jruoho
971 1.1.1.3 christos FlOpenFile (ASL_FILE_HEX_OUTPUT, Filename, "w+t");
972 1.1.1.2 jruoho
973 1.1.1.2 jruoho AslCompilerSignon (ASL_FILE_HEX_OUTPUT);
974 1.1.1.2 jruoho AslCompilerFileHeader (ASL_FILE_HEX_OUTPUT);
975 1.1 jruoho }
976 1.1 jruoho
977 1.1.1.2 jruoho /* Create/Open a debug output file if asked */
978 1.1.1.2 jruoho
979 1.1.1.13 christos if (AslGbl_DebugFlag)
980 1.1.1.2 jruoho {
981 1.1.1.2 jruoho Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_DEBUG);
982 1.1.1.2 jruoho if (!Filename)
983 1.1.1.2 jruoho {
984 1.1.1.2 jruoho AslCommonError (ASL_ERROR, ASL_MSG_DEBUG_FILENAME,
985 1.1.1.2 jruoho 0, 0, 0, 0, NULL, NULL);
986 1.1.1.2 jruoho return (AE_ERROR);
987 1.1.1.2 jruoho }
988 1.1.1.2 jruoho
989 1.1.1.2 jruoho /* Open the debug file as STDERR, text mode */
990 1.1.1.2 jruoho
991 1.1.1.13 christos AslGbl_Files[ASL_FILE_DEBUG_OUTPUT].Filename = Filename;
992 1.1.1.13 christos AslGbl_Files[ASL_FILE_DEBUG_OUTPUT].Handle =
993 1.1.1.2 jruoho freopen (Filename, "w+t", stderr);
994 1.1.1.2 jruoho
995 1.1.1.13 christos if (!AslGbl_Files[ASL_FILE_DEBUG_OUTPUT].Handle)
996 1.1.1.3 christos {
997 1.1.1.5 christos /*
998 1.1.1.6 christos * A problem with freopen is that on error, we no longer
999 1.1.1.6 christos * have stderr and cannot emit normal error messages.
1000 1.1.1.6 christos * Emit error to stdout, close files, and exit.
1001 1.1.1.5 christos */
1002 1.1.1.6 christos fprintf (stdout,
1003 1.1.1.6 christos "\nCould not open debug output file: %s\n\n", Filename);
1004 1.1.1.6 christos
1005 1.1.1.6 christos CmCleanupAndExit ();
1006 1.1.1.6 christos exit (1);
1007 1.1.1.3 christos }
1008 1.1.1.3 christos
1009 1.1.1.2 jruoho AslCompilerSignon (ASL_FILE_DEBUG_OUTPUT);
1010 1.1.1.2 jruoho AslCompilerFileHeader (ASL_FILE_DEBUG_OUTPUT);
1011 1.1.1.2 jruoho }
1012 1.1 jruoho
1013 1.1.1.8 christos /* Create/Open a cross-reference output file if asked */
1014 1.1.1.8 christos
1015 1.1.1.13 christos if (AslGbl_CrossReferenceOutput)
1016 1.1.1.8 christos {
1017 1.1.1.8 christos Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_XREF);
1018 1.1.1.8 christos if (!Filename)
1019 1.1.1.8 christos {
1020 1.1.1.8 christos AslCommonError (ASL_ERROR, ASL_MSG_DEBUG_FILENAME,
1021 1.1.1.8 christos 0, 0, 0, 0, NULL, NULL);
1022 1.1.1.8 christos return (AE_ERROR);
1023 1.1.1.8 christos }
1024 1.1.1.8 christos
1025 1.1.1.8 christos FlOpenFile (ASL_FILE_XREF_OUTPUT, Filename, "w+t");
1026 1.1.1.8 christos
1027 1.1.1.8 christos AslCompilerSignon (ASL_FILE_XREF_OUTPUT);
1028 1.1.1.8 christos AslCompilerFileHeader (ASL_FILE_XREF_OUTPUT);
1029 1.1.1.8 christos }
1030 1.1.1.8 christos
1031 1.1 jruoho /* Create/Open a listing output file if asked */
1032 1.1 jruoho
1033 1.1.1.13 christos if (AslGbl_ListingFlag)
1034 1.1 jruoho {
1035 1.1 jruoho Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_LISTING);
1036 1.1 jruoho if (!Filename)
1037 1.1 jruoho {
1038 1.1 jruoho AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
1039 1.1 jruoho 0, 0, 0, 0, NULL, NULL);
1040 1.1 jruoho return (AE_ERROR);
1041 1.1 jruoho }
1042 1.1 jruoho
1043 1.1 jruoho /* Open the listing file, text mode */
1044 1.1 jruoho
1045 1.1.1.3 christos FlOpenFile (ASL_FILE_LISTING_OUTPUT, Filename, "w+t");
1046 1.1 jruoho
1047 1.1 jruoho AslCompilerSignon (ASL_FILE_LISTING_OUTPUT);
1048 1.1 jruoho AslCompilerFileHeader (ASL_FILE_LISTING_OUTPUT);
1049 1.1 jruoho }
1050 1.1 jruoho
1051 1.1.1.6 christos /* Create the preprocessor output temp file if preprocessor enabled */
1052 1.1.1.3 christos
1053 1.1.1.13 christos if (AslGbl_PreprocessFlag)
1054 1.1.1.3 christos {
1055 1.1.1.3 christos Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_PREPROCESSOR);
1056 1.1.1.3 christos if (!Filename)
1057 1.1.1.3 christos {
1058 1.1.1.3 christos AslCommonError (ASL_ERROR, ASL_MSG_PREPROCESSOR_FILENAME,
1059 1.1.1.3 christos 0, 0, 0, 0, NULL, NULL);
1060 1.1.1.3 christos return (AE_ERROR);
1061 1.1.1.3 christos }
1062 1.1.1.3 christos
1063 1.1.1.3 christos FlOpenFile (ASL_FILE_PREPROCESSOR, Filename, "w+t");
1064 1.1.1.3 christos }
1065 1.1.1.3 christos
1066 1.1.1.6 christos /*
1067 1.1.1.6 christos * Create the "user" preprocessor output file if -li flag set.
1068 1.1.1.6 christos * Note, this file contains no embedded #line directives.
1069 1.1.1.6 christos */
1070 1.1.1.13 christos if (AslGbl_PreprocessorOutputFlag)
1071 1.1.1.6 christos {
1072 1.1.1.6 christos Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_PREPROC_USER);
1073 1.1.1.6 christos if (!Filename)
1074 1.1.1.6 christos {
1075 1.1.1.6 christos AslCommonError (ASL_ERROR, ASL_MSG_PREPROCESSOR_FILENAME,
1076 1.1.1.6 christos 0, 0, 0, 0, NULL, NULL);
1077 1.1.1.6 christos return (AE_ERROR);
1078 1.1.1.6 christos }
1079 1.1.1.6 christos
1080 1.1.1.6 christos FlOpenFile (ASL_FILE_PREPROCESSOR_USER, Filename, "w+t");
1081 1.1.1.6 christos }
1082 1.1.1.6 christos
1083 1.1.1.3 christos /* All done for data table compiler */
1084 1.1.1.3 christos
1085 1.1.1.13 christos if (AslGbl_FileType == ASL_INPUT_TYPE_ASCII_DATA)
1086 1.1.1.2 jruoho {
1087 1.1.1.2 jruoho return (AE_OK);
1088 1.1.1.2 jruoho }
1089 1.1.1.2 jruoho
1090 1.1.1.2 jruoho /* Create/Open a combined source output file */
1091 1.1.1.2 jruoho
1092 1.1.1.2 jruoho Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_SOURCE);
1093 1.1.1.2 jruoho if (!Filename)
1094 1.1.1.2 jruoho {
1095 1.1.1.2 jruoho AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
1096 1.1.1.2 jruoho 0, 0, 0, 0, NULL, NULL);
1097 1.1.1.2 jruoho return (AE_ERROR);
1098 1.1.1.2 jruoho }
1099 1.1.1.2 jruoho
1100 1.1.1.2 jruoho /*
1101 1.1.1.2 jruoho * Open the source output file, binary mode (so that LF does not get
1102 1.1.1.2 jruoho * expanded to CR/LF on some systems, messing up our seek
1103 1.1.1.2 jruoho * calculations.)
1104 1.1.1.2 jruoho */
1105 1.1.1.2 jruoho FlOpenFile (ASL_FILE_SOURCE_OUTPUT, Filename, "w+b");
1106 1.1.1.2 jruoho
1107 1.1.1.3 christos /*
1108 1.1.1.3 christos // TBD: TEMP
1109 1.1.1.13 christos // AslCompilerin = AslGbl_Files[ASL_FILE_SOURCE_OUTPUT].Handle;
1110 1.1.1.3 christos */
1111 1.1 jruoho /* Create/Open a assembly code source output file if asked */
1112 1.1 jruoho
1113 1.1.1.13 christos if (AslGbl_AsmOutputFlag)
1114 1.1 jruoho {
1115 1.1 jruoho Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_ASM_SOURCE);
1116 1.1 jruoho if (!Filename)
1117 1.1 jruoho {
1118 1.1 jruoho AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
1119 1.1 jruoho 0, 0, 0, 0, NULL, NULL);
1120 1.1 jruoho return (AE_ERROR);
1121 1.1 jruoho }
1122 1.1 jruoho
1123 1.1 jruoho /* Open the assembly code source file, text mode */
1124 1.1 jruoho
1125 1.1.1.3 christos FlOpenFile (ASL_FILE_ASM_SOURCE_OUTPUT, Filename, "w+t");
1126 1.1 jruoho
1127 1.1 jruoho AslCompilerSignon (ASL_FILE_ASM_SOURCE_OUTPUT);
1128 1.1 jruoho AslCompilerFileHeader (ASL_FILE_ASM_SOURCE_OUTPUT);
1129 1.1 jruoho }
1130 1.1 jruoho
1131 1.1 jruoho /* Create/Open a C code source output file if asked */
1132 1.1 jruoho
1133 1.1.1.13 christos if (AslGbl_C_OutputFlag)
1134 1.1 jruoho {
1135 1.1 jruoho Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_C_SOURCE);
1136 1.1 jruoho if (!Filename)
1137 1.1 jruoho {
1138 1.1 jruoho AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
1139 1.1 jruoho 0, 0, 0, 0, NULL, NULL);
1140 1.1 jruoho return (AE_ERROR);
1141 1.1 jruoho }
1142 1.1 jruoho
1143 1.1 jruoho /* Open the C code source file, text mode */
1144 1.1 jruoho
1145 1.1.1.3 christos FlOpenFile (ASL_FILE_C_SOURCE_OUTPUT, Filename, "w+t");
1146 1.1 jruoho
1147 1.1 jruoho FlPrintFile (ASL_FILE_C_SOURCE_OUTPUT, "/*\n");
1148 1.1 jruoho AslCompilerSignon (ASL_FILE_C_SOURCE_OUTPUT);
1149 1.1 jruoho AslCompilerFileHeader (ASL_FILE_C_SOURCE_OUTPUT);
1150 1.1 jruoho }
1151 1.1 jruoho
1152 1.1.1.3 christos /* Create/Open a C code source output file for the offset table if asked */
1153 1.1.1.3 christos
1154 1.1.1.13 christos if (AslGbl_C_OffsetTableFlag)
1155 1.1.1.3 christos {
1156 1.1.1.3 christos Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_C_OFFSET);
1157 1.1.1.3 christos if (!Filename)
1158 1.1.1.3 christos {
1159 1.1.1.3 christos AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
1160 1.1.1.3 christos 0, 0, 0, 0, NULL, NULL);
1161 1.1.1.3 christos return (AE_ERROR);
1162 1.1.1.3 christos }
1163 1.1.1.3 christos
1164 1.1.1.3 christos /* Open the C code source file, text mode */
1165 1.1.1.3 christos
1166 1.1.1.3 christos FlOpenFile (ASL_FILE_C_OFFSET_OUTPUT, Filename, "w+t");
1167 1.1.1.3 christos
1168 1.1.1.3 christos FlPrintFile (ASL_FILE_C_OFFSET_OUTPUT, "/*\n");
1169 1.1.1.3 christos AslCompilerSignon (ASL_FILE_C_OFFSET_OUTPUT);
1170 1.1.1.3 christos AslCompilerFileHeader (ASL_FILE_C_OFFSET_OUTPUT);
1171 1.1.1.3 christos }
1172 1.1.1.3 christos
1173 1.1 jruoho /* Create/Open a assembly include output file if asked */
1174 1.1 jruoho
1175 1.1.1.13 christos if (AslGbl_AsmIncludeOutputFlag)
1176 1.1 jruoho {
1177 1.1 jruoho Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_ASM_INCLUDE);
1178 1.1 jruoho if (!Filename)
1179 1.1 jruoho {
1180 1.1 jruoho AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
1181 1.1 jruoho 0, 0, 0, 0, NULL, NULL);
1182 1.1 jruoho return (AE_ERROR);
1183 1.1 jruoho }
1184 1.1 jruoho
1185 1.1 jruoho /* Open the assembly include file, text mode */
1186 1.1 jruoho
1187 1.1.1.3 christos FlOpenFile (ASL_FILE_ASM_INCLUDE_OUTPUT, Filename, "w+t");
1188 1.1 jruoho
1189 1.1 jruoho AslCompilerSignon (ASL_FILE_ASM_INCLUDE_OUTPUT);
1190 1.1 jruoho AslCompilerFileHeader (ASL_FILE_ASM_INCLUDE_OUTPUT);
1191 1.1 jruoho }
1192 1.1 jruoho
1193 1.1 jruoho /* Create/Open a C include output file if asked */
1194 1.1 jruoho
1195 1.1.1.13 christos if (AslGbl_C_IncludeOutputFlag)
1196 1.1 jruoho {
1197 1.1 jruoho Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_C_INCLUDE);
1198 1.1 jruoho if (!Filename)
1199 1.1 jruoho {
1200 1.1 jruoho AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
1201 1.1 jruoho 0, 0, 0, 0, NULL, NULL);
1202 1.1 jruoho return (AE_ERROR);
1203 1.1 jruoho }
1204 1.1 jruoho
1205 1.1 jruoho /* Open the C include file, text mode */
1206 1.1 jruoho
1207 1.1.1.3 christos FlOpenFile (ASL_FILE_C_INCLUDE_OUTPUT, Filename, "w+t");
1208 1.1 jruoho
1209 1.1 jruoho FlPrintFile (ASL_FILE_C_INCLUDE_OUTPUT, "/*\n");
1210 1.1 jruoho AslCompilerSignon (ASL_FILE_C_INCLUDE_OUTPUT);
1211 1.1 jruoho AslCompilerFileHeader (ASL_FILE_C_INCLUDE_OUTPUT);
1212 1.1 jruoho }
1213 1.1 jruoho
1214 1.1 jruoho /* Create a namespace output file if asked */
1215 1.1 jruoho
1216 1.1.1.13 christos if (AslGbl_NsOutputFlag)
1217 1.1 jruoho {
1218 1.1 jruoho Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_NAMESPACE);
1219 1.1 jruoho if (!Filename)
1220 1.1 jruoho {
1221 1.1 jruoho AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
1222 1.1 jruoho 0, 0, 0, 0, NULL, NULL);
1223 1.1 jruoho return (AE_ERROR);
1224 1.1 jruoho }
1225 1.1 jruoho
1226 1.1 jruoho /* Open the namespace file, text mode */
1227 1.1 jruoho
1228 1.1.1.3 christos FlOpenFile (ASL_FILE_NAMESPACE_OUTPUT, Filename, "w+t");
1229 1.1 jruoho
1230 1.1 jruoho AslCompilerSignon (ASL_FILE_NAMESPACE_OUTPUT);
1231 1.1 jruoho AslCompilerFileHeader (ASL_FILE_NAMESPACE_OUTPUT);
1232 1.1 jruoho }
1233 1.1 jruoho
1234 1.1.1.10 christos /* Create a debug file for the converter */
1235 1.1.1.10 christos
1236 1.1.1.10 christos if (AcpiGbl_DebugAslConversion)
1237 1.1.1.10 christos {
1238 1.1.1.10 christos Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_CONVERT_DEBUG);
1239 1.1.1.10 christos if (!Filename)
1240 1.1.1.10 christos {
1241 1.1.1.10 christos AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
1242 1.1.1.10 christos 0, 0, 0, 0, NULL, NULL);
1243 1.1.1.10 christos return (AE_ERROR);
1244 1.1.1.10 christos }
1245 1.1.1.10 christos
1246 1.1.1.10 christos /* Open the converter debug file, text mode */
1247 1.1.1.10 christos
1248 1.1.1.10 christos FlOpenFile (ASL_FILE_CONV_DEBUG_OUTPUT, Filename, "w+t");
1249 1.1.1.10 christos
1250 1.1.1.10 christos AslCompilerSignon (ASL_FILE_CONV_DEBUG_OUTPUT);
1251 1.1.1.10 christos AslCompilerFileHeader (ASL_FILE_CONV_DEBUG_OUTPUT);
1252 1.1.1.10 christos
1253 1.1.1.13 christos AcpiGbl_ConvDebugFile = AslGbl_Files[ASL_FILE_CONV_DEBUG_OUTPUT].Handle;
1254 1.1.1.10 christos }
1255 1.1.1.10 christos
1256 1.1 jruoho return (AE_OK);
1257 1.1 jruoho }
1258 1.1 jruoho
1259 1.1 jruoho
1260 1.1 jruoho #ifdef ACPI_OBSOLETE_FUNCTIONS
1261 1.1 jruoho /*******************************************************************************
1262 1.1 jruoho *
1263 1.1 jruoho * FUNCTION: FlParseInputPathname
1264 1.1 jruoho *
1265 1.1 jruoho * PARAMETERS: InputFilename - The user-specified ASL source file to be
1266 1.1 jruoho * compiled
1267 1.1 jruoho *
1268 1.1 jruoho * RETURN: Status
1269 1.1 jruoho *
1270 1.1 jruoho * DESCRIPTION: Split the input path into a directory and filename part
1271 1.1 jruoho * 1) Directory part used to open include files
1272 1.1 jruoho * 2) Filename part used to generate output filenames
1273 1.1 jruoho *
1274 1.1 jruoho ******************************************************************************/
1275 1.1 jruoho
1276 1.1 jruoho ACPI_STATUS
1277 1.1 jruoho FlParseInputPathname (
1278 1.1 jruoho char *InputFilename)
1279 1.1 jruoho {
1280 1.1 jruoho char *Substring;
1281 1.1 jruoho
1282 1.1 jruoho
1283 1.1 jruoho if (!InputFilename)
1284 1.1 jruoho {
1285 1.1 jruoho return (AE_OK);
1286 1.1 jruoho }
1287 1.1 jruoho
1288 1.1 jruoho /* Get the path to the input filename's directory */
1289 1.1 jruoho
1290 1.1.1.13 christos AslGbl_DirectoryPath = strdup (InputFilename);
1291 1.1.1.13 christos if (!AslGbl_DirectoryPath)
1292 1.1 jruoho {
1293 1.1 jruoho return (AE_NO_MEMORY);
1294 1.1 jruoho }
1295 1.1 jruoho
1296 1.1.1.13 christos Substring = strrchr (AslGbl_DirectoryPath, '\\');
1297 1.1 jruoho if (!Substring)
1298 1.1 jruoho {
1299 1.1.1.13 christos Substring = strrchr (AslGbl_DirectoryPath, '/');
1300 1.1 jruoho if (!Substring)
1301 1.1 jruoho {
1302 1.1.1.13 christos Substring = strrchr (AslGbl_DirectoryPath, ':');
1303 1.1 jruoho }
1304 1.1 jruoho }
1305 1.1 jruoho
1306 1.1 jruoho if (!Substring)
1307 1.1 jruoho {
1308 1.1.1.13 christos AslGbl_DirectoryPath[0] = 0;
1309 1.1.1.13 christos if (AslGbl_UseDefaultAmlFilename)
1310 1.1 jruoho {
1311 1.1.1.13 christos AslGbl_OutputFilenamePrefix = strdup (InputFilename);
1312 1.1 jruoho }
1313 1.1 jruoho }
1314 1.1 jruoho else
1315 1.1 jruoho {
1316 1.1.1.13 christos if (AslGbl_UseDefaultAmlFilename)
1317 1.1 jruoho {
1318 1.1.1.13 christos AslGbl_OutputFilenamePrefix = strdup (Substring + 1);
1319 1.1 jruoho }
1320 1.1 jruoho *(Substring+1) = 0;
1321 1.1 jruoho }
1322 1.1 jruoho
1323 1.1.1.13 christos UtConvertBackslashes (AslGbl_OutputFilenamePrefix);
1324 1.1 jruoho return (AE_OK);
1325 1.1 jruoho }
1326 1.1 jruoho #endif
1327