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