aslfiles.c revision 1.1 1 1.1 jruoho
2 1.1 jruoho /******************************************************************************
3 1.1 jruoho *
4 1.1 jruoho * Module Name: aslfiles - file I/O suppoert
5 1.1 jruoho *
6 1.1 jruoho *****************************************************************************/
7 1.1 jruoho
8 1.1 jruoho /******************************************************************************
9 1.1 jruoho *
10 1.1 jruoho * 1. Copyright Notice
11 1.1 jruoho *
12 1.1 jruoho * Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp.
13 1.1 jruoho * All rights reserved.
14 1.1 jruoho *
15 1.1 jruoho * 2. License
16 1.1 jruoho *
17 1.1 jruoho * 2.1. This is your license from Intel Corp. under its intellectual property
18 1.1 jruoho * rights. You may have additional license terms from the party that provided
19 1.1 jruoho * you this software, covering your right to use that party's intellectual
20 1.1 jruoho * property rights.
21 1.1 jruoho *
22 1.1 jruoho * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23 1.1 jruoho * copy of the source code appearing in this file ("Covered Code") an
24 1.1 jruoho * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25 1.1 jruoho * base code distributed originally by Intel ("Original Intel Code") to copy,
26 1.1 jruoho * make derivatives, distribute, use and display any portion of the Covered
27 1.1 jruoho * Code in any form, with the right to sublicense such rights; and
28 1.1 jruoho *
29 1.1 jruoho * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30 1.1 jruoho * license (with the right to sublicense), under only those claims of Intel
31 1.1 jruoho * patents that are infringed by the Original Intel Code, to make, use, sell,
32 1.1 jruoho * offer to sell, and import the Covered Code and derivative works thereof
33 1.1 jruoho * solely to the minimum extent necessary to exercise the above copyright
34 1.1 jruoho * license, and in no event shall the patent license extend to any additions
35 1.1 jruoho * to or modifications of the Original Intel Code. No other license or right
36 1.1 jruoho * is granted directly or by implication, estoppel or otherwise;
37 1.1 jruoho *
38 1.1 jruoho * The above copyright and patent license is granted only if the following
39 1.1 jruoho * conditions are met:
40 1.1 jruoho *
41 1.1 jruoho * 3. Conditions
42 1.1 jruoho *
43 1.1 jruoho * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44 1.1 jruoho * Redistribution of source code of any substantial portion of the Covered
45 1.1 jruoho * Code or modification with rights to further distribute source must include
46 1.1 jruoho * the above Copyright Notice, the above License, this list of Conditions,
47 1.1 jruoho * and the following Disclaimer and Export Compliance provision. In addition,
48 1.1 jruoho * Licensee must cause all Covered Code to which Licensee contributes to
49 1.1 jruoho * contain a file documenting the changes Licensee made to create that Covered
50 1.1 jruoho * Code and the date of any change. Licensee must include in that file the
51 1.1 jruoho * documentation of any changes made by any predecessor Licensee. Licensee
52 1.1 jruoho * must include a prominent statement that the modification is derived,
53 1.1 jruoho * directly or indirectly, from Original Intel Code.
54 1.1 jruoho *
55 1.1 jruoho * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56 1.1 jruoho * Redistribution of source code of any substantial portion of the Covered
57 1.1 jruoho * Code or modification without rights to further distribute source must
58 1.1 jruoho * include the following Disclaimer and Export Compliance provision in the
59 1.1 jruoho * documentation and/or other materials provided with distribution. In
60 1.1 jruoho * addition, Licensee may not authorize further sublicense of source of any
61 1.1 jruoho * portion of the Covered Code, and must include terms to the effect that the
62 1.1 jruoho * license from Licensee to its licensee is limited to the intellectual
63 1.1 jruoho * property embodied in the software Licensee provides to its licensee, and
64 1.1 jruoho * not to intellectual property embodied in modifications its licensee may
65 1.1 jruoho * make.
66 1.1 jruoho *
67 1.1 jruoho * 3.3. Redistribution of Executable. Redistribution in executable form of any
68 1.1 jruoho * substantial portion of the Covered Code or modification must reproduce the
69 1.1 jruoho * above Copyright Notice, and the following Disclaimer and Export Compliance
70 1.1 jruoho * provision in the documentation and/or other materials provided with the
71 1.1 jruoho * distribution.
72 1.1 jruoho *
73 1.1 jruoho * 3.4. Intel retains all right, title, and interest in and to the Original
74 1.1 jruoho * Intel Code.
75 1.1 jruoho *
76 1.1 jruoho * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77 1.1 jruoho * Intel shall be used in advertising or otherwise to promote the sale, use or
78 1.1 jruoho * other dealings in products derived from or relating to the Covered Code
79 1.1 jruoho * without prior written authorization from Intel.
80 1.1 jruoho *
81 1.1 jruoho * 4. Disclaimer and Export Compliance
82 1.1 jruoho *
83 1.1 jruoho * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84 1.1 jruoho * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85 1.1 jruoho * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
86 1.1 jruoho * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
87 1.1 jruoho * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
88 1.1 jruoho * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
89 1.1 jruoho * PARTICULAR PURPOSE.
90 1.1 jruoho *
91 1.1 jruoho * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92 1.1 jruoho * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93 1.1 jruoho * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94 1.1 jruoho * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95 1.1 jruoho * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96 1.1 jruoho * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
97 1.1 jruoho * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
98 1.1 jruoho * LIMITED REMEDY.
99 1.1 jruoho *
100 1.1 jruoho * 4.3. Licensee shall not export, either directly or indirectly, any of this
101 1.1 jruoho * software or system incorporating such software without first obtaining any
102 1.1 jruoho * required license or other approval from the U. S. Department of Commerce or
103 1.1 jruoho * any other agency or department of the United States Government. In the
104 1.1 jruoho * event Licensee exports any such software from the United States or
105 1.1 jruoho * re-exports any such software from a foreign destination, Licensee shall
106 1.1 jruoho * ensure that the distribution and export/re-export of the software is in
107 1.1 jruoho * compliance with all laws, regulations, orders, or other restrictions of the
108 1.1 jruoho * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109 1.1 jruoho * any of its subsidiaries will export/re-export any technical data, process,
110 1.1 jruoho * software, or service, directly or indirectly, to any country for which the
111 1.1 jruoho * United States government or any agency thereof requires an export license,
112 1.1 jruoho * other governmental approval, or letter of assurance, without first obtaining
113 1.1 jruoho * such license, approval or letter.
114 1.1 jruoho *
115 1.1 jruoho *****************************************************************************/
116 1.1 jruoho
117 1.1 jruoho #include "aslcompiler.h"
118 1.1 jruoho #include "acapps.h"
119 1.1 jruoho
120 1.1 jruoho #define _COMPONENT ACPI_COMPILER
121 1.1 jruoho ACPI_MODULE_NAME ("aslfiles")
122 1.1 jruoho
123 1.1 jruoho /* Local prototypes */
124 1.1 jruoho
125 1.1 jruoho FILE *
126 1.1 jruoho FlOpenIncludeWithPrefix (
127 1.1 jruoho char *PrefixDir,
128 1.1 jruoho char *Filename);
129 1.1 jruoho
130 1.1 jruoho
131 1.1 jruoho #ifdef ACPI_OBSOLETE_FUNCTIONS
132 1.1 jruoho ACPI_STATUS
133 1.1 jruoho FlParseInputPathname (
134 1.1 jruoho char *InputFilename);
135 1.1 jruoho #endif
136 1.1 jruoho
137 1.1 jruoho
138 1.1 jruoho /*******************************************************************************
139 1.1 jruoho *
140 1.1 jruoho * FUNCTION: AslAbort
141 1.1 jruoho *
142 1.1 jruoho * PARAMETERS: None
143 1.1 jruoho *
144 1.1 jruoho * RETURN: None
145 1.1 jruoho *
146 1.1 jruoho * DESCRIPTION: Dump the error log and abort the compiler. Used for serious
147 1.1 jruoho * I/O errors
148 1.1 jruoho *
149 1.1 jruoho ******************************************************************************/
150 1.1 jruoho
151 1.1 jruoho void
152 1.1 jruoho AslAbort (
153 1.1 jruoho void)
154 1.1 jruoho {
155 1.1 jruoho
156 1.1 jruoho AePrintErrorLog (ASL_FILE_STDOUT);
157 1.1 jruoho if (Gbl_DebugFlag)
158 1.1 jruoho {
159 1.1 jruoho /* Print error summary to the debug file */
160 1.1 jruoho
161 1.1 jruoho AePrintErrorLog (ASL_FILE_STDERR);
162 1.1 jruoho }
163 1.1 jruoho
164 1.1 jruoho exit (1);
165 1.1 jruoho }
166 1.1 jruoho
167 1.1 jruoho
168 1.1 jruoho /*******************************************************************************
169 1.1 jruoho *
170 1.1 jruoho * FUNCTION: FlFileError
171 1.1 jruoho *
172 1.1 jruoho * PARAMETERS: FileId - Index into file info array
173 1.1 jruoho * ErrorId - Index into error message array
174 1.1 jruoho *
175 1.1 jruoho * RETURN: None
176 1.1 jruoho *
177 1.1 jruoho * DESCRIPTION: Decode errno to an error message and add the entire error
178 1.1 jruoho * to the error log.
179 1.1 jruoho *
180 1.1 jruoho ******************************************************************************/
181 1.1 jruoho
182 1.1 jruoho void
183 1.1 jruoho FlFileError (
184 1.1 jruoho UINT32 FileId,
185 1.1 jruoho UINT8 ErrorId)
186 1.1 jruoho {
187 1.1 jruoho
188 1.1 jruoho sprintf (MsgBuffer, "\"%s\" (%s)", Gbl_Files[FileId].Filename,
189 1.1 jruoho strerror (errno));
190 1.1 jruoho AslCommonError (ASL_ERROR, ErrorId, 0, 0, 0, 0, NULL, MsgBuffer);
191 1.1 jruoho }
192 1.1 jruoho
193 1.1 jruoho
194 1.1 jruoho /*******************************************************************************
195 1.1 jruoho *
196 1.1 jruoho * FUNCTION: FlOpenFile
197 1.1 jruoho *
198 1.1 jruoho * PARAMETERS: FileId - Index into file info array
199 1.1 jruoho * Filename - file pathname to open
200 1.1 jruoho * Mode - Open mode for fopen
201 1.1 jruoho *
202 1.1 jruoho * RETURN: None
203 1.1 jruoho *
204 1.1 jruoho * DESCRIPTION: Open a file.
205 1.1 jruoho * NOTE: Aborts compiler on any error.
206 1.1 jruoho *
207 1.1 jruoho ******************************************************************************/
208 1.1 jruoho
209 1.1 jruoho void
210 1.1 jruoho FlOpenFile (
211 1.1 jruoho UINT32 FileId,
212 1.1 jruoho char *Filename,
213 1.1 jruoho char *Mode)
214 1.1 jruoho {
215 1.1 jruoho FILE *File;
216 1.1 jruoho
217 1.1 jruoho
218 1.1 jruoho File = fopen (Filename, Mode);
219 1.1 jruoho
220 1.1 jruoho Gbl_Files[FileId].Filename = Filename;
221 1.1 jruoho Gbl_Files[FileId].Handle = File;
222 1.1 jruoho
223 1.1 jruoho if (!File)
224 1.1 jruoho {
225 1.1 jruoho FlFileError (FileId, ASL_MSG_OPEN);
226 1.1 jruoho AslAbort ();
227 1.1 jruoho }
228 1.1 jruoho }
229 1.1 jruoho
230 1.1 jruoho
231 1.1 jruoho /*******************************************************************************
232 1.1 jruoho *
233 1.1 jruoho * FUNCTION: FlGetFileSize
234 1.1 jruoho *
235 1.1 jruoho * PARAMETERS: FileId - Index into file info array
236 1.1 jruoho *
237 1.1 jruoho * RETURN: File Size
238 1.1 jruoho *
239 1.1 jruoho * DESCRIPTION: Get current file size. Uses seek-to-EOF. File must be open.
240 1.1 jruoho *
241 1.1 jruoho ******************************************************************************/
242 1.1 jruoho
243 1.1 jruoho UINT32
244 1.1 jruoho FlGetFileSize (
245 1.1 jruoho UINT32 FileId)
246 1.1 jruoho {
247 1.1 jruoho FILE *fp;
248 1.1 jruoho UINT32 FileSize;
249 1.1 jruoho
250 1.1 jruoho
251 1.1 jruoho fp = Gbl_Files[FileId].Handle;
252 1.1 jruoho
253 1.1 jruoho fseek (fp, 0, SEEK_END);
254 1.1 jruoho FileSize = (UINT32) ftell (fp);
255 1.1 jruoho fseek (fp, 0, SEEK_SET);
256 1.1 jruoho
257 1.1 jruoho return (FileSize);
258 1.1 jruoho }
259 1.1 jruoho
260 1.1 jruoho
261 1.1 jruoho /*******************************************************************************
262 1.1 jruoho *
263 1.1 jruoho * FUNCTION: FlReadFile
264 1.1 jruoho *
265 1.1 jruoho * PARAMETERS: FileId - Index into file info array
266 1.1 jruoho * Buffer - Where to place the data
267 1.1 jruoho * Length - Amount to read
268 1.1 jruoho *
269 1.1 jruoho * RETURN: Status. AE_ERROR indicates EOF.
270 1.1 jruoho *
271 1.1 jruoho * DESCRIPTION: Read data from an open file.
272 1.1 jruoho * NOTE: Aborts compiler on any error.
273 1.1 jruoho *
274 1.1 jruoho ******************************************************************************/
275 1.1 jruoho
276 1.1 jruoho ACPI_STATUS
277 1.1 jruoho FlReadFile (
278 1.1 jruoho UINT32 FileId,
279 1.1 jruoho void *Buffer,
280 1.1 jruoho UINT32 Length)
281 1.1 jruoho {
282 1.1 jruoho UINT32 Actual;
283 1.1 jruoho
284 1.1 jruoho
285 1.1 jruoho /* Read and check for error */
286 1.1 jruoho
287 1.1 jruoho Actual = fread (Buffer, 1, Length, Gbl_Files[FileId].Handle);
288 1.1 jruoho if (Actual != Length)
289 1.1 jruoho {
290 1.1 jruoho if (feof (Gbl_Files[FileId].Handle))
291 1.1 jruoho {
292 1.1 jruoho /* End-of-file, just return error */
293 1.1 jruoho
294 1.1 jruoho return (AE_ERROR);
295 1.1 jruoho }
296 1.1 jruoho
297 1.1 jruoho FlFileError (FileId, ASL_MSG_READ);
298 1.1 jruoho AslAbort ();
299 1.1 jruoho }
300 1.1 jruoho
301 1.1 jruoho return (AE_OK);
302 1.1 jruoho }
303 1.1 jruoho
304 1.1 jruoho
305 1.1 jruoho /*******************************************************************************
306 1.1 jruoho *
307 1.1 jruoho * FUNCTION: FlWriteFile
308 1.1 jruoho *
309 1.1 jruoho * PARAMETERS: FileId - Index into file info array
310 1.1 jruoho * Buffer - Data to write
311 1.1 jruoho * Length - Amount of data to write
312 1.1 jruoho *
313 1.1 jruoho * RETURN: None
314 1.1 jruoho *
315 1.1 jruoho * DESCRIPTION: Write data to an open file.
316 1.1 jruoho * NOTE: Aborts compiler on any error.
317 1.1 jruoho *
318 1.1 jruoho ******************************************************************************/
319 1.1 jruoho
320 1.1 jruoho void
321 1.1 jruoho FlWriteFile (
322 1.1 jruoho UINT32 FileId,
323 1.1 jruoho void *Buffer,
324 1.1 jruoho UINT32 Length)
325 1.1 jruoho {
326 1.1 jruoho UINT32 Actual;
327 1.1 jruoho
328 1.1 jruoho
329 1.1 jruoho /* Write and check for error */
330 1.1 jruoho
331 1.1 jruoho Actual = fwrite ((char *) Buffer, 1, Length, Gbl_Files[FileId].Handle);
332 1.1 jruoho if (Actual != Length)
333 1.1 jruoho {
334 1.1 jruoho FlFileError (FileId, ASL_MSG_WRITE);
335 1.1 jruoho AslAbort ();
336 1.1 jruoho }
337 1.1 jruoho }
338 1.1 jruoho
339 1.1 jruoho
340 1.1 jruoho /*******************************************************************************
341 1.1 jruoho *
342 1.1 jruoho * FUNCTION: FlPrintFile
343 1.1 jruoho *
344 1.1 jruoho * PARAMETERS: FileId - Index into file info array
345 1.1 jruoho * Format - Printf format string
346 1.1 jruoho * ... - Printf arguments
347 1.1 jruoho *
348 1.1 jruoho * RETURN: None
349 1.1 jruoho *
350 1.1 jruoho * DESCRIPTION: Formatted write to an open file.
351 1.1 jruoho * NOTE: Aborts compiler on any error.
352 1.1 jruoho *
353 1.1 jruoho ******************************************************************************/
354 1.1 jruoho
355 1.1 jruoho void
356 1.1 jruoho FlPrintFile (
357 1.1 jruoho UINT32 FileId,
358 1.1 jruoho char *Format,
359 1.1 jruoho ...)
360 1.1 jruoho {
361 1.1 jruoho INT32 Actual;
362 1.1 jruoho va_list Args;
363 1.1 jruoho
364 1.1 jruoho
365 1.1 jruoho va_start (Args, Format);
366 1.1 jruoho
367 1.1 jruoho Actual = vfprintf (Gbl_Files[FileId].Handle, Format, Args);
368 1.1 jruoho va_end (Args);
369 1.1 jruoho
370 1.1 jruoho if (Actual == -1)
371 1.1 jruoho {
372 1.1 jruoho FlFileError (FileId, ASL_MSG_WRITE);
373 1.1 jruoho AslAbort ();
374 1.1 jruoho }
375 1.1 jruoho }
376 1.1 jruoho
377 1.1 jruoho
378 1.1 jruoho /*******************************************************************************
379 1.1 jruoho *
380 1.1 jruoho * FUNCTION: FlSeekFile
381 1.1 jruoho *
382 1.1 jruoho * PARAMETERS: FileId - Index into file info array
383 1.1 jruoho * Offset - Absolute byte offset in file
384 1.1 jruoho *
385 1.1 jruoho * RETURN: None
386 1.1 jruoho *
387 1.1 jruoho * DESCRIPTION: Seek to absolute offset
388 1.1 jruoho * NOTE: Aborts compiler on any error.
389 1.1 jruoho *
390 1.1 jruoho ******************************************************************************/
391 1.1 jruoho
392 1.1 jruoho void
393 1.1 jruoho FlSeekFile (
394 1.1 jruoho UINT32 FileId,
395 1.1 jruoho long Offset)
396 1.1 jruoho {
397 1.1 jruoho int Error;
398 1.1 jruoho
399 1.1 jruoho
400 1.1 jruoho Error = fseek (Gbl_Files[FileId].Handle, Offset, SEEK_SET);
401 1.1 jruoho if (Error)
402 1.1 jruoho {
403 1.1 jruoho FlFileError (FileId, ASL_MSG_SEEK);
404 1.1 jruoho AslAbort ();
405 1.1 jruoho }
406 1.1 jruoho }
407 1.1 jruoho
408 1.1 jruoho
409 1.1 jruoho /*******************************************************************************
410 1.1 jruoho *
411 1.1 jruoho * FUNCTION: FlCloseFile
412 1.1 jruoho *
413 1.1 jruoho * PARAMETERS: FileId - Index into file info array
414 1.1 jruoho *
415 1.1 jruoho * RETURN: None
416 1.1 jruoho *
417 1.1 jruoho * DESCRIPTION: Close an open file. Aborts compiler on error
418 1.1 jruoho *
419 1.1 jruoho ******************************************************************************/
420 1.1 jruoho
421 1.1 jruoho void
422 1.1 jruoho FlCloseFile (
423 1.1 jruoho UINT32 FileId)
424 1.1 jruoho {
425 1.1 jruoho int Error;
426 1.1 jruoho
427 1.1 jruoho
428 1.1 jruoho if (!Gbl_Files[FileId].Handle)
429 1.1 jruoho {
430 1.1 jruoho return;
431 1.1 jruoho }
432 1.1 jruoho
433 1.1 jruoho Error = fclose (Gbl_Files[FileId].Handle);
434 1.1 jruoho Gbl_Files[FileId].Handle = NULL;
435 1.1 jruoho
436 1.1 jruoho if (Error)
437 1.1 jruoho {
438 1.1 jruoho FlFileError (FileId, ASL_MSG_CLOSE);
439 1.1 jruoho AslAbort ();
440 1.1 jruoho }
441 1.1 jruoho
442 1.1 jruoho return;
443 1.1 jruoho }
444 1.1 jruoho
445 1.1 jruoho
446 1.1 jruoho /*******************************************************************************
447 1.1 jruoho *
448 1.1 jruoho * FUNCTION: FlSetLineNumber
449 1.1 jruoho *
450 1.1 jruoho * PARAMETERS: Op - Parse node for the LINE asl statement
451 1.1 jruoho *
452 1.1 jruoho * RETURN: None.
453 1.1 jruoho *
454 1.1 jruoho * DESCRIPTION: Set the current line number
455 1.1 jruoho *
456 1.1 jruoho ******************************************************************************/
457 1.1 jruoho
458 1.1 jruoho void
459 1.1 jruoho FlSetLineNumber (
460 1.1 jruoho ACPI_PARSE_OBJECT *Op)
461 1.1 jruoho {
462 1.1 jruoho
463 1.1 jruoho Gbl_CurrentLineNumber = (UINT32) Op->Asl.Value.Integer;
464 1.1 jruoho Gbl_LogicalLineNumber = (UINT32) Op->Asl.Value.Integer;
465 1.1 jruoho }
466 1.1 jruoho
467 1.1 jruoho
468 1.1 jruoho /*******************************************************************************
469 1.1 jruoho *
470 1.1 jruoho * FUNCTION: FlAddIncludeDirectory
471 1.1 jruoho *
472 1.1 jruoho * PARAMETERS: Dir - Directory pathname string
473 1.1 jruoho *
474 1.1 jruoho * RETURN: None
475 1.1 jruoho *
476 1.1 jruoho * DESCRIPTION: Add a directory the list of include prefix directories.
477 1.1 jruoho *
478 1.1 jruoho ******************************************************************************/
479 1.1 jruoho
480 1.1 jruoho void
481 1.1 jruoho FlAddIncludeDirectory (
482 1.1 jruoho char *Dir)
483 1.1 jruoho {
484 1.1 jruoho ASL_INCLUDE_DIR *NewDir;
485 1.1 jruoho ASL_INCLUDE_DIR *NextDir;
486 1.1 jruoho ASL_INCLUDE_DIR *PrevDir = NULL;
487 1.1 jruoho UINT32 NeedsSeparator = 0;
488 1.1 jruoho size_t DirLength;
489 1.1 jruoho
490 1.1 jruoho
491 1.1 jruoho DirLength = strlen (Dir);
492 1.1 jruoho if (!DirLength)
493 1.1 jruoho {
494 1.1 jruoho return;
495 1.1 jruoho }
496 1.1 jruoho
497 1.1 jruoho /* Make sure that the pathname ends with a path separator */
498 1.1 jruoho
499 1.1 jruoho if ((Dir[DirLength-1] != '/') &&
500 1.1 jruoho (Dir[DirLength-1] != '\\'))
501 1.1 jruoho {
502 1.1 jruoho NeedsSeparator = 1;
503 1.1 jruoho }
504 1.1 jruoho
505 1.1 jruoho NewDir = ACPI_ALLOCATE_ZEROED (sizeof (ASL_INCLUDE_DIR));
506 1.1 jruoho NewDir->Dir = ACPI_ALLOCATE (DirLength + 1 + NeedsSeparator);
507 1.1 jruoho strcpy (NewDir->Dir, Dir);
508 1.1 jruoho if (NeedsSeparator)
509 1.1 jruoho {
510 1.1 jruoho strcat (NewDir->Dir, "/");
511 1.1 jruoho }
512 1.1 jruoho
513 1.1 jruoho /*
514 1.1 jruoho * Preserve command line ordering of -I options by adding new elements
515 1.1 jruoho * at the end of the list
516 1.1 jruoho */
517 1.1 jruoho NextDir = Gbl_IncludeDirList;
518 1.1 jruoho while (NextDir)
519 1.1 jruoho {
520 1.1 jruoho PrevDir = NextDir;
521 1.1 jruoho NextDir = NextDir->Next;
522 1.1 jruoho }
523 1.1 jruoho
524 1.1 jruoho if (PrevDir)
525 1.1 jruoho {
526 1.1 jruoho PrevDir->Next = NewDir;
527 1.1 jruoho }
528 1.1 jruoho else
529 1.1 jruoho {
530 1.1 jruoho Gbl_IncludeDirList = NewDir;
531 1.1 jruoho }
532 1.1 jruoho }
533 1.1 jruoho
534 1.1 jruoho
535 1.1 jruoho /*******************************************************************************
536 1.1 jruoho *
537 1.1 jruoho * FUNCTION: FlOpenIncludeWithPrefix
538 1.1 jruoho *
539 1.1 jruoho * PARAMETERS: PrefixDir - Prefix directory pathname. Can be a zero
540 1.1 jruoho * length string.
541 1.1 jruoho * Filename - The include filename from the source ASL.
542 1.1 jruoho *
543 1.1 jruoho * RETURN: Valid file descriptor if successful. Null otherwise.
544 1.1 jruoho *
545 1.1 jruoho * DESCRIPTION: Open an include file and push it on the input file stack.
546 1.1 jruoho *
547 1.1 jruoho ******************************************************************************/
548 1.1 jruoho
549 1.1 jruoho FILE *
550 1.1 jruoho FlOpenIncludeWithPrefix (
551 1.1 jruoho char *PrefixDir,
552 1.1 jruoho char *Filename)
553 1.1 jruoho {
554 1.1 jruoho FILE *IncludeFile;
555 1.1 jruoho char *Pathname;
556 1.1 jruoho
557 1.1 jruoho
558 1.1 jruoho /* Build the full pathname to the file */
559 1.1 jruoho
560 1.1 jruoho Pathname = ACPI_ALLOCATE (strlen (PrefixDir) + strlen (Filename) + 1);
561 1.1 jruoho
562 1.1 jruoho strcpy (Pathname, PrefixDir);
563 1.1 jruoho strcat (Pathname, Filename);
564 1.1 jruoho
565 1.1 jruoho DbgPrint (ASL_PARSE_OUTPUT, "\nAttempt to open include file: path %s\n\n",
566 1.1 jruoho Pathname);
567 1.1 jruoho
568 1.1 jruoho /* Attempt to open the file, push if successful */
569 1.1 jruoho
570 1.1 jruoho IncludeFile = fopen (Pathname, "r");
571 1.1 jruoho if (IncludeFile)
572 1.1 jruoho {
573 1.1 jruoho /* Push the include file on the open input file stack */
574 1.1 jruoho
575 1.1 jruoho AslPushInputFileStack (IncludeFile, Pathname);
576 1.1 jruoho return (IncludeFile);
577 1.1 jruoho }
578 1.1 jruoho
579 1.1 jruoho ACPI_FREE (Pathname);
580 1.1 jruoho return (NULL);
581 1.1 jruoho }
582 1.1 jruoho
583 1.1 jruoho
584 1.1 jruoho /*******************************************************************************
585 1.1 jruoho *
586 1.1 jruoho * FUNCTION: FlOpenIncludeFile
587 1.1 jruoho *
588 1.1 jruoho * PARAMETERS: Op - Parse node for the INCLUDE ASL statement
589 1.1 jruoho *
590 1.1 jruoho * RETURN: None.
591 1.1 jruoho *
592 1.1 jruoho * DESCRIPTION: Open an include file and push it on the input file stack.
593 1.1 jruoho *
594 1.1 jruoho ******************************************************************************/
595 1.1 jruoho
596 1.1 jruoho void
597 1.1 jruoho FlOpenIncludeFile (
598 1.1 jruoho ACPI_PARSE_OBJECT *Op)
599 1.1 jruoho {
600 1.1 jruoho FILE *IncludeFile;
601 1.1 jruoho ASL_INCLUDE_DIR *NextDir;
602 1.1 jruoho
603 1.1 jruoho
604 1.1 jruoho /* Op must be valid */
605 1.1 jruoho
606 1.1 jruoho if (!Op)
607 1.1 jruoho {
608 1.1 jruoho AslCommonError (ASL_ERROR, ASL_MSG_INCLUDE_FILE_OPEN,
609 1.1 jruoho Gbl_CurrentLineNumber, Gbl_LogicalLineNumber,
610 1.1 jruoho Gbl_InputByteCount, Gbl_CurrentColumn,
611 1.1 jruoho Gbl_Files[ASL_FILE_INPUT].Filename, " - Null parse node");
612 1.1 jruoho
613 1.1 jruoho return;
614 1.1 jruoho }
615 1.1 jruoho
616 1.1 jruoho /*
617 1.1 jruoho * Flush out the "include ()" statement on this line, start
618 1.1 jruoho * the actual include file on the next line
619 1.1 jruoho */
620 1.1 jruoho ResetCurrentLineBuffer ();
621 1.1 jruoho FlPrintFile (ASL_FILE_SOURCE_OUTPUT, "\n");
622 1.1 jruoho Gbl_CurrentLineOffset++;
623 1.1 jruoho
624 1.1 jruoho
625 1.1 jruoho /* Attempt to open the include file */
626 1.1 jruoho
627 1.1 jruoho /* If the file specifies an absolute path, just open it */
628 1.1 jruoho
629 1.1 jruoho if ((Op->Asl.Value.String[0] == '/') ||
630 1.1 jruoho (Op->Asl.Value.String[0] == '\\') ||
631 1.1 jruoho (Op->Asl.Value.String[1] == ':'))
632 1.1 jruoho {
633 1.1 jruoho IncludeFile = FlOpenIncludeWithPrefix ("", Op->Asl.Value.String);
634 1.1 jruoho if (!IncludeFile)
635 1.1 jruoho {
636 1.1 jruoho goto ErrorExit;
637 1.1 jruoho }
638 1.1 jruoho return;
639 1.1 jruoho }
640 1.1 jruoho
641 1.1 jruoho /*
642 1.1 jruoho * The include filename is not an absolute path.
643 1.1 jruoho *
644 1.1 jruoho * First, search for the file within the "local" directory -- meaning
645 1.1 jruoho * the same directory that contains the source file.
646 1.1 jruoho *
647 1.1 jruoho * Construct the file pathname from the global directory name.
648 1.1 jruoho */
649 1.1 jruoho IncludeFile = FlOpenIncludeWithPrefix (Gbl_DirectoryPath, Op->Asl.Value.String);
650 1.1 jruoho if (IncludeFile)
651 1.1 jruoho {
652 1.1 jruoho return;
653 1.1 jruoho }
654 1.1 jruoho
655 1.1 jruoho /*
656 1.1 jruoho * Second, search for the file within the (possibly multiple) directories
657 1.1 jruoho * specified by the -I option on the command line.
658 1.1 jruoho */
659 1.1 jruoho NextDir = Gbl_IncludeDirList;
660 1.1 jruoho while (NextDir)
661 1.1 jruoho {
662 1.1 jruoho IncludeFile = FlOpenIncludeWithPrefix (NextDir->Dir, Op->Asl.Value.String);
663 1.1 jruoho if (IncludeFile)
664 1.1 jruoho {
665 1.1 jruoho return;
666 1.1 jruoho }
667 1.1 jruoho
668 1.1 jruoho NextDir = NextDir->Next;
669 1.1 jruoho }
670 1.1 jruoho
671 1.1 jruoho /* We could not open the include file after trying very hard */
672 1.1 jruoho
673 1.1 jruoho ErrorExit:
674 1.1 jruoho sprintf (MsgBuffer, "%s, %s", Op->Asl.Value.String, strerror (errno));
675 1.1 jruoho AslError (ASL_ERROR, ASL_MSG_INCLUDE_FILE_OPEN, Op, MsgBuffer);
676 1.1 jruoho }
677 1.1 jruoho
678 1.1 jruoho
679 1.1 jruoho /*******************************************************************************
680 1.1 jruoho *
681 1.1 jruoho * FUNCTION: FlOpenInputFile
682 1.1 jruoho *
683 1.1 jruoho * PARAMETERS: InputFilename - The user-specified ASL source file to be
684 1.1 jruoho * compiled
685 1.1 jruoho *
686 1.1 jruoho * RETURN: Status
687 1.1 jruoho *
688 1.1 jruoho * DESCRIPTION: Open the specified input file, and save the directory path to
689 1.1 jruoho * the file so that include files can be opened in
690 1.1 jruoho * the same directory.
691 1.1 jruoho *
692 1.1 jruoho ******************************************************************************/
693 1.1 jruoho
694 1.1 jruoho ACPI_STATUS
695 1.1 jruoho FlOpenInputFile (
696 1.1 jruoho char *InputFilename)
697 1.1 jruoho {
698 1.1 jruoho
699 1.1 jruoho /* Open the input ASL file, text mode */
700 1.1 jruoho
701 1.1 jruoho FlOpenFile (ASL_FILE_INPUT, InputFilename, "r");
702 1.1 jruoho AslCompilerin = Gbl_Files[ASL_FILE_INPUT].Handle;
703 1.1 jruoho
704 1.1 jruoho return (AE_OK);
705 1.1 jruoho }
706 1.1 jruoho
707 1.1 jruoho
708 1.1 jruoho /*******************************************************************************
709 1.1 jruoho *
710 1.1 jruoho * FUNCTION: FlOpenAmlOutputFile
711 1.1 jruoho *
712 1.1 jruoho * PARAMETERS: FilenamePrefix - The user-specified ASL source file
713 1.1 jruoho *
714 1.1 jruoho * RETURN: Status
715 1.1 jruoho *
716 1.1 jruoho * DESCRIPTION: Create the output filename (*.AML) and open the file. The file
717 1.1 jruoho * is created in the same directory as the parent input file.
718 1.1 jruoho *
719 1.1 jruoho ******************************************************************************/
720 1.1 jruoho
721 1.1 jruoho ACPI_STATUS
722 1.1 jruoho FlOpenAmlOutputFile (
723 1.1 jruoho char *FilenamePrefix)
724 1.1 jruoho {
725 1.1 jruoho char *Filename;
726 1.1 jruoho
727 1.1 jruoho
728 1.1 jruoho /* Output filename usually comes from the ASL itself */
729 1.1 jruoho
730 1.1 jruoho Filename = Gbl_Files[ASL_FILE_AML_OUTPUT].Filename;
731 1.1 jruoho if (!Filename)
732 1.1 jruoho {
733 1.1 jruoho /* Create the output AML filename */
734 1.1 jruoho
735 1.1 jruoho Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_AML_CODE);
736 1.1 jruoho if (!Filename)
737 1.1 jruoho {
738 1.1 jruoho AslCommonError (ASL_ERROR, ASL_MSG_OUTPUT_FILENAME,
739 1.1 jruoho 0, 0, 0, 0, NULL, NULL);
740 1.1 jruoho return (AE_ERROR);
741 1.1 jruoho }
742 1.1 jruoho }
743 1.1 jruoho
744 1.1 jruoho /* Open the output AML file in binary mode */
745 1.1 jruoho
746 1.1 jruoho FlOpenFile (ASL_FILE_AML_OUTPUT, Filename, "w+b");
747 1.1 jruoho return (AE_OK);
748 1.1 jruoho }
749 1.1 jruoho
750 1.1 jruoho
751 1.1 jruoho /*******************************************************************************
752 1.1 jruoho *
753 1.1 jruoho * FUNCTION: FlOpenMiscOutputFiles
754 1.1 jruoho *
755 1.1 jruoho * PARAMETERS: FilenamePrefix - The user-specified ASL source file
756 1.1 jruoho *
757 1.1 jruoho * RETURN: Status
758 1.1 jruoho *
759 1.1 jruoho * DESCRIPTION: Create and open the various output files needed, depending on
760 1.1 jruoho * the command line options
761 1.1 jruoho *
762 1.1 jruoho ******************************************************************************/
763 1.1 jruoho
764 1.1 jruoho ACPI_STATUS
765 1.1 jruoho FlOpenMiscOutputFiles (
766 1.1 jruoho char *FilenamePrefix)
767 1.1 jruoho {
768 1.1 jruoho char *Filename;
769 1.1 jruoho
770 1.1 jruoho
771 1.1 jruoho /* Create/Open a combined source output file */
772 1.1 jruoho
773 1.1 jruoho Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_SOURCE);
774 1.1 jruoho if (!Filename)
775 1.1 jruoho {
776 1.1 jruoho AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
777 1.1 jruoho 0, 0, 0, 0, NULL, NULL);
778 1.1 jruoho return (AE_ERROR);
779 1.1 jruoho }
780 1.1 jruoho
781 1.1 jruoho /*
782 1.1 jruoho * Open the source output file, binary mode (so that LF does not get
783 1.1 jruoho * expanded to CR/LF on some systems, messing up our seek
784 1.1 jruoho * calculations.)
785 1.1 jruoho */
786 1.1 jruoho FlOpenFile (ASL_FILE_SOURCE_OUTPUT, Filename, "w+b");
787 1.1 jruoho
788 1.1 jruoho /* Create/Open a listing output file if asked */
789 1.1 jruoho
790 1.1 jruoho if (Gbl_ListingFlag)
791 1.1 jruoho {
792 1.1 jruoho Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_LISTING);
793 1.1 jruoho if (!Filename)
794 1.1 jruoho {
795 1.1 jruoho AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
796 1.1 jruoho 0, 0, 0, 0, NULL, NULL);
797 1.1 jruoho return (AE_ERROR);
798 1.1 jruoho }
799 1.1 jruoho
800 1.1 jruoho /* Open the listing file, text mode */
801 1.1 jruoho
802 1.1 jruoho FlOpenFile (ASL_FILE_LISTING_OUTPUT, Filename, "w+");
803 1.1 jruoho
804 1.1 jruoho AslCompilerSignon (ASL_FILE_LISTING_OUTPUT);
805 1.1 jruoho AslCompilerFileHeader (ASL_FILE_LISTING_OUTPUT);
806 1.1 jruoho }
807 1.1 jruoho
808 1.1 jruoho /* Create/Open a assembly code source output file if asked */
809 1.1 jruoho
810 1.1 jruoho if (Gbl_AsmOutputFlag)
811 1.1 jruoho {
812 1.1 jruoho Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_ASM_SOURCE);
813 1.1 jruoho if (!Filename)
814 1.1 jruoho {
815 1.1 jruoho AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
816 1.1 jruoho 0, 0, 0, 0, NULL, NULL);
817 1.1 jruoho return (AE_ERROR);
818 1.1 jruoho }
819 1.1 jruoho
820 1.1 jruoho /* Open the assembly code source file, text mode */
821 1.1 jruoho
822 1.1 jruoho FlOpenFile (ASL_FILE_ASM_SOURCE_OUTPUT, Filename, "w+");
823 1.1 jruoho
824 1.1 jruoho AslCompilerSignon (ASL_FILE_ASM_SOURCE_OUTPUT);
825 1.1 jruoho AslCompilerFileHeader (ASL_FILE_ASM_SOURCE_OUTPUT);
826 1.1 jruoho }
827 1.1 jruoho
828 1.1 jruoho /* Create/Open a C code source output file if asked */
829 1.1 jruoho
830 1.1 jruoho if (Gbl_C_OutputFlag)
831 1.1 jruoho {
832 1.1 jruoho Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_C_SOURCE);
833 1.1 jruoho if (!Filename)
834 1.1 jruoho {
835 1.1 jruoho AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
836 1.1 jruoho 0, 0, 0, 0, NULL, NULL);
837 1.1 jruoho return (AE_ERROR);
838 1.1 jruoho }
839 1.1 jruoho
840 1.1 jruoho /* Open the C code source file, text mode */
841 1.1 jruoho
842 1.1 jruoho FlOpenFile (ASL_FILE_C_SOURCE_OUTPUT, Filename, "w+");
843 1.1 jruoho
844 1.1 jruoho FlPrintFile (ASL_FILE_C_SOURCE_OUTPUT, "/*\n");
845 1.1 jruoho AslCompilerSignon (ASL_FILE_C_SOURCE_OUTPUT);
846 1.1 jruoho AslCompilerFileHeader (ASL_FILE_C_SOURCE_OUTPUT);
847 1.1 jruoho }
848 1.1 jruoho
849 1.1 jruoho /* Create/Open a assembly include output file if asked */
850 1.1 jruoho
851 1.1 jruoho if (Gbl_AsmIncludeOutputFlag)
852 1.1 jruoho {
853 1.1 jruoho Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_ASM_INCLUDE);
854 1.1 jruoho if (!Filename)
855 1.1 jruoho {
856 1.1 jruoho AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
857 1.1 jruoho 0, 0, 0, 0, NULL, NULL);
858 1.1 jruoho return (AE_ERROR);
859 1.1 jruoho }
860 1.1 jruoho
861 1.1 jruoho /* Open the assembly include file, text mode */
862 1.1 jruoho
863 1.1 jruoho FlOpenFile (ASL_FILE_ASM_INCLUDE_OUTPUT, Filename, "w+");
864 1.1 jruoho
865 1.1 jruoho AslCompilerSignon (ASL_FILE_ASM_INCLUDE_OUTPUT);
866 1.1 jruoho AslCompilerFileHeader (ASL_FILE_ASM_INCLUDE_OUTPUT);
867 1.1 jruoho }
868 1.1 jruoho
869 1.1 jruoho /* Create/Open a C include output file if asked */
870 1.1 jruoho
871 1.1 jruoho if (Gbl_C_IncludeOutputFlag)
872 1.1 jruoho {
873 1.1 jruoho Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_C_INCLUDE);
874 1.1 jruoho if (!Filename)
875 1.1 jruoho {
876 1.1 jruoho AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
877 1.1 jruoho 0, 0, 0, 0, NULL, NULL);
878 1.1 jruoho return (AE_ERROR);
879 1.1 jruoho }
880 1.1 jruoho
881 1.1 jruoho /* Open the C include file, text mode */
882 1.1 jruoho
883 1.1 jruoho FlOpenFile (ASL_FILE_C_INCLUDE_OUTPUT, Filename, "w+");
884 1.1 jruoho
885 1.1 jruoho FlPrintFile (ASL_FILE_C_INCLUDE_OUTPUT, "/*\n");
886 1.1 jruoho AslCompilerSignon (ASL_FILE_C_INCLUDE_OUTPUT);
887 1.1 jruoho AslCompilerFileHeader (ASL_FILE_C_INCLUDE_OUTPUT);
888 1.1 jruoho }
889 1.1 jruoho
890 1.1 jruoho /* Create/Open a hex output file if asked */
891 1.1 jruoho
892 1.1 jruoho if (Gbl_HexOutputFlag)
893 1.1 jruoho {
894 1.1 jruoho Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_HEX_DUMP);
895 1.1 jruoho if (!Filename)
896 1.1 jruoho {
897 1.1 jruoho AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
898 1.1 jruoho 0, 0, 0, 0, NULL, NULL);
899 1.1 jruoho return (AE_ERROR);
900 1.1 jruoho }
901 1.1 jruoho
902 1.1 jruoho /* Open the hex file, text mode */
903 1.1 jruoho
904 1.1 jruoho FlOpenFile (ASL_FILE_HEX_OUTPUT, Filename, "w+");
905 1.1 jruoho
906 1.1 jruoho AslCompilerSignon (ASL_FILE_HEX_OUTPUT);
907 1.1 jruoho AslCompilerFileHeader (ASL_FILE_HEX_OUTPUT);
908 1.1 jruoho }
909 1.1 jruoho
910 1.1 jruoho /* Create a namespace output file if asked */
911 1.1 jruoho
912 1.1 jruoho if (Gbl_NsOutputFlag)
913 1.1 jruoho {
914 1.1 jruoho Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_NAMESPACE);
915 1.1 jruoho if (!Filename)
916 1.1 jruoho {
917 1.1 jruoho AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
918 1.1 jruoho 0, 0, 0, 0, NULL, NULL);
919 1.1 jruoho return (AE_ERROR);
920 1.1 jruoho }
921 1.1 jruoho
922 1.1 jruoho /* Open the namespace file, text mode */
923 1.1 jruoho
924 1.1 jruoho FlOpenFile (ASL_FILE_NAMESPACE_OUTPUT, Filename, "w+");
925 1.1 jruoho
926 1.1 jruoho AslCompilerSignon (ASL_FILE_NAMESPACE_OUTPUT);
927 1.1 jruoho AslCompilerFileHeader (ASL_FILE_NAMESPACE_OUTPUT);
928 1.1 jruoho }
929 1.1 jruoho
930 1.1 jruoho /* Create/Open a debug output file if asked */
931 1.1 jruoho
932 1.1 jruoho if (Gbl_DebugFlag)
933 1.1 jruoho {
934 1.1 jruoho Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_DEBUG);
935 1.1 jruoho if (!Filename)
936 1.1 jruoho {
937 1.1 jruoho AslCommonError (ASL_ERROR, ASL_MSG_DEBUG_FILENAME,
938 1.1 jruoho 0, 0, 0, 0, NULL, NULL);
939 1.1 jruoho return (AE_ERROR);
940 1.1 jruoho }
941 1.1 jruoho
942 1.1 jruoho /* Open the debug file as STDERR, text mode */
943 1.1 jruoho
944 1.1 jruoho /* TBD: hide this behind a FlReopenFile function */
945 1.1 jruoho
946 1.1 jruoho Gbl_Files[ASL_FILE_DEBUG_OUTPUT].Filename = Filename;
947 1.1 jruoho Gbl_Files[ASL_FILE_DEBUG_OUTPUT].Handle =
948 1.1 jruoho freopen (Filename, "w+t", stderr);
949 1.1 jruoho
950 1.1 jruoho AslCompilerSignon (ASL_FILE_DEBUG_OUTPUT);
951 1.1 jruoho AslCompilerFileHeader (ASL_FILE_DEBUG_OUTPUT);
952 1.1 jruoho }
953 1.1 jruoho
954 1.1 jruoho return (AE_OK);
955 1.1 jruoho }
956 1.1 jruoho
957 1.1 jruoho
958 1.1 jruoho #ifdef ACPI_OBSOLETE_FUNCTIONS
959 1.1 jruoho /*******************************************************************************
960 1.1 jruoho *
961 1.1 jruoho * FUNCTION: FlParseInputPathname
962 1.1 jruoho *
963 1.1 jruoho * PARAMETERS: InputFilename - The user-specified ASL source file to be
964 1.1 jruoho * compiled
965 1.1 jruoho *
966 1.1 jruoho * RETURN: Status
967 1.1 jruoho *
968 1.1 jruoho * DESCRIPTION: Split the input path into a directory and filename part
969 1.1 jruoho * 1) Directory part used to open include files
970 1.1 jruoho * 2) Filename part used to generate output filenames
971 1.1 jruoho *
972 1.1 jruoho ******************************************************************************/
973 1.1 jruoho
974 1.1 jruoho ACPI_STATUS
975 1.1 jruoho FlParseInputPathname (
976 1.1 jruoho char *InputFilename)
977 1.1 jruoho {
978 1.1 jruoho char *Substring;
979 1.1 jruoho
980 1.1 jruoho
981 1.1 jruoho if (!InputFilename)
982 1.1 jruoho {
983 1.1 jruoho return (AE_OK);
984 1.1 jruoho }
985 1.1 jruoho
986 1.1 jruoho /* Get the path to the input filename's directory */
987 1.1 jruoho
988 1.1 jruoho Gbl_DirectoryPath = strdup (InputFilename);
989 1.1 jruoho if (!Gbl_DirectoryPath)
990 1.1 jruoho {
991 1.1 jruoho return (AE_NO_MEMORY);
992 1.1 jruoho }
993 1.1 jruoho
994 1.1 jruoho Substring = strrchr (Gbl_DirectoryPath, '\\');
995 1.1 jruoho if (!Substring)
996 1.1 jruoho {
997 1.1 jruoho Substring = strrchr (Gbl_DirectoryPath, '/');
998 1.1 jruoho if (!Substring)
999 1.1 jruoho {
1000 1.1 jruoho Substring = strrchr (Gbl_DirectoryPath, ':');
1001 1.1 jruoho }
1002 1.1 jruoho }
1003 1.1 jruoho
1004 1.1 jruoho if (!Substring)
1005 1.1 jruoho {
1006 1.1 jruoho Gbl_DirectoryPath[0] = 0;
1007 1.1 jruoho if (Gbl_UseDefaultAmlFilename)
1008 1.1 jruoho {
1009 1.1 jruoho Gbl_OutputFilenamePrefix = strdup (InputFilename);
1010 1.1 jruoho }
1011 1.1 jruoho }
1012 1.1 jruoho else
1013 1.1 jruoho {
1014 1.1 jruoho if (Gbl_UseDefaultAmlFilename)
1015 1.1 jruoho {
1016 1.1 jruoho Gbl_OutputFilenamePrefix = strdup (Substring + 1);
1017 1.1 jruoho }
1018 1.1 jruoho *(Substring+1) = 0;
1019 1.1 jruoho }
1020 1.1 jruoho
1021 1.1 jruoho return (AE_OK);
1022 1.1 jruoho }
1023 1.1 jruoho #endif
1024 1.1 jruoho
1025 1.1 jruoho
1026