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