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