aslstartup.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: aslstartup - Compiler startup routines, called from main
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
46 1.1.1.2.2.2 bouyer #include "aslcompiler.h"
47 1.1.1.2.2.2 bouyer #include "actables.h"
48 1.1.1.2.2.2 bouyer #include "acapps.h"
49 1.1.1.2.2.2 bouyer
50 1.1.1.2.2.2 bouyer #define _COMPONENT ACPI_COMPILER
51 1.1.1.2.2.2 bouyer ACPI_MODULE_NAME ("aslstartup")
52 1.1.1.2.2.2 bouyer
53 1.1.1.2.2.2 bouyer
54 1.1.1.2.2.2 bouyer #define ASL_MAX_FILES 256
55 1.1.1.2.2.2 bouyer static char *FileList[ASL_MAX_FILES];
56 1.1.1.2.2.2 bouyer static BOOLEAN AslToFile = TRUE;
57 1.1.1.2.2.2 bouyer
58 1.1.1.2.2.2 bouyer
59 1.1.1.2.2.2 bouyer /* Local prototypes */
60 1.1.1.2.2.2 bouyer
61 1.1.1.2.2.2 bouyer static char **
62 1.1.1.2.2.2 bouyer AsDoWildcard (
63 1.1.1.2.2.2 bouyer char *DirectoryPathname,
64 1.1.1.2.2.2 bouyer char *FileSpecifier);
65 1.1.1.2.2.2 bouyer
66 1.1.1.2.2.2 bouyer static UINT8
67 1.1.1.2.2.2 bouyer AslDetectSourceFileType (
68 1.1.1.2.2.2 bouyer ASL_FILE_INFO *Info);
69 1.1.1.2.2.2 bouyer
70 1.1.1.2.2.2 bouyer
71 1.1.1.2.2.2 bouyer /*******************************************************************************
72 1.1.1.2.2.2 bouyer *
73 1.1.1.2.2.2 bouyer * FUNCTION: AslInitializeGlobals
74 1.1.1.2.2.2 bouyer *
75 1.1.1.2.2.2 bouyer * PARAMETERS: None
76 1.1.1.2.2.2 bouyer *
77 1.1.1.2.2.2 bouyer * RETURN: None
78 1.1.1.2.2.2 bouyer *
79 1.1.1.2.2.2 bouyer * DESCRIPTION: Re-initialize globals needed to restart the compiler. This
80 1.1.1.2.2.2 bouyer * allows multiple files to be disassembled and/or compiled.
81 1.1.1.2.2.2 bouyer *
82 1.1.1.2.2.2 bouyer ******************************************************************************/
83 1.1.1.2.2.2 bouyer
84 1.1.1.2.2.2 bouyer void
85 1.1.1.2.2.2 bouyer AslInitializeGlobals (
86 1.1.1.2.2.2 bouyer void)
87 1.1.1.2.2.2 bouyer {
88 1.1.1.2.2.2 bouyer UINT32 i;
89 1.1.1.2.2.2 bouyer
90 1.1.1.2.2.2 bouyer
91 1.1.1.2.2.2 bouyer /* Init compiler globals */
92 1.1.1.2.2.2 bouyer
93 1.1.1.2.2.2 bouyer Gbl_CurrentColumn = 0;
94 1.1.1.2.2.2 bouyer Gbl_CurrentLineNumber = 1;
95 1.1.1.2.2.2 bouyer Gbl_LogicalLineNumber = 1;
96 1.1.1.2.2.2 bouyer Gbl_CurrentLineOffset = 0;
97 1.1.1.2.2.2 bouyer Gbl_InputFieldCount = 0;
98 1.1.1.2.2.2 bouyer Gbl_LineBufPtr = Gbl_CurrentLineBuffer;
99 1.1.1.2.2.2 bouyer
100 1.1.1.2.2.2 bouyer Gbl_ErrorLog = NULL;
101 1.1.1.2.2.2 bouyer Gbl_NextError = NULL;
102 1.1.1.2.2.2 bouyer Gbl_Signature = NULL;
103 1.1.1.2.2.2 bouyer Gbl_FileType = 0;
104 1.1.1.2.2.2 bouyer
105 1.1.1.2.2.2 bouyer AslGbl_NextEvent = 0;
106 1.1.1.2.2.2 bouyer for (i = 0; i < ASL_NUM_REPORT_LEVELS; i++)
107 1.1.1.2.2.2 bouyer {
108 1.1.1.2.2.2 bouyer Gbl_ExceptionCount[i] = 0;
109 1.1.1.2.2.2 bouyer }
110 1.1.1.2.2.2 bouyer
111 1.1.1.2.2.2 bouyer Gbl_Files[ASL_FILE_AML_OUTPUT].Filename = NULL;
112 1.1.1.2.2.2 bouyer Gbl_Files[ASL_FILE_AML_OUTPUT].Handle = NULL;
113 1.1.1.2.2.2 bouyer
114 1.1.1.2.2.2 bouyer Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Filename = NULL;
115 1.1.1.2.2.2 bouyer Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Handle = NULL;
116 1.1.1.2.2.2 bouyer }
117 1.1.1.2.2.2 bouyer
118 1.1.1.2.2.2 bouyer
119 1.1.1.2.2.2 bouyer /******************************************************************************
120 1.1.1.2.2.2 bouyer *
121 1.1.1.2.2.2 bouyer * FUNCTION: AsDoWildcard
122 1.1.1.2.2.2 bouyer *
123 1.1.1.2.2.2 bouyer * PARAMETERS: None
124 1.1.1.2.2.2 bouyer *
125 1.1.1.2.2.2 bouyer * RETURN: None
126 1.1.1.2.2.2 bouyer *
127 1.1.1.2.2.2 bouyer * DESCRIPTION: Process files via wildcards. This function is for the Windows
128 1.1.1.2.2.2 bouyer * case only.
129 1.1.1.2.2.2 bouyer *
130 1.1.1.2.2.2 bouyer ******************************************************************************/
131 1.1.1.2.2.2 bouyer
132 1.1.1.2.2.2 bouyer static char **
133 1.1.1.2.2.2 bouyer AsDoWildcard (
134 1.1.1.2.2.2 bouyer char *DirectoryPathname,
135 1.1.1.2.2.2 bouyer char *FileSpecifier)
136 1.1.1.2.2.2 bouyer {
137 1.1.1.2.2.2 bouyer #ifdef WIN32
138 1.1.1.2.2.2 bouyer void *DirInfo;
139 1.1.1.2.2.2 bouyer char *Filename;
140 1.1.1.2.2.2 bouyer int FileCount;
141 1.1.1.2.2.2 bouyer
142 1.1.1.2.2.2 bouyer
143 1.1.1.2.2.2 bouyer FileCount = 0;
144 1.1.1.2.2.2 bouyer
145 1.1.1.2.2.2 bouyer /* Open parent directory */
146 1.1.1.2.2.2 bouyer
147 1.1.1.2.2.2 bouyer DirInfo = AcpiOsOpenDirectory (DirectoryPathname, FileSpecifier, REQUEST_FILE_ONLY);
148 1.1.1.2.2.2 bouyer if (!DirInfo)
149 1.1.1.2.2.2 bouyer {
150 1.1.1.2.2.2 bouyer /* Either the directory of file does not exist */
151 1.1.1.2.2.2 bouyer
152 1.1.1.2.2.2 bouyer Gbl_Files[ASL_FILE_INPUT].Filename = FileSpecifier;
153 1.1.1.2.2.2 bouyer FlFileError (ASL_FILE_INPUT, 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 /* Process each file that matches the wildcard specification */
158 1.1.1.2.2.2 bouyer
159 1.1.1.2.2.2 bouyer while ((Filename = AcpiOsGetNextFilename (DirInfo)))
160 1.1.1.2.2.2 bouyer {
161 1.1.1.2.2.2 bouyer /* Add the filename to the file list */
162 1.1.1.2.2.2 bouyer
163 1.1.1.2.2.2 bouyer FileList[FileCount] = AcpiOsAllocate (strlen (Filename) + 1);
164 1.1.1.2.2.2 bouyer strcpy (FileList[FileCount], Filename);
165 1.1.1.2.2.2 bouyer FileCount++;
166 1.1.1.2.2.2 bouyer
167 1.1.1.2.2.2 bouyer if (FileCount >= ASL_MAX_FILES)
168 1.1.1.2.2.2 bouyer {
169 1.1.1.2.2.2 bouyer printf ("Max files reached\n");
170 1.1.1.2.2.2 bouyer FileList[0] = NULL;
171 1.1.1.2.2.2 bouyer return (FileList);
172 1.1.1.2.2.2 bouyer }
173 1.1.1.2.2.2 bouyer }
174 1.1.1.2.2.2 bouyer
175 1.1.1.2.2.2 bouyer /* Cleanup */
176 1.1.1.2.2.2 bouyer
177 1.1.1.2.2.2 bouyer AcpiOsCloseDirectory (DirInfo);
178 1.1.1.2.2.2 bouyer FileList[FileCount] = NULL;
179 1.1.1.2.2.2 bouyer return (FileList);
180 1.1.1.2.2.2 bouyer
181 1.1.1.2.2.2 bouyer #else
182 1.1.1.2.2.2 bouyer /*
183 1.1.1.2.2.2 bouyer * Linux/Unix cases - Wildcards are expanded by the shell automatically.
184 1.1.1.2.2.2 bouyer * Just return the filename in a null terminated list
185 1.1.1.2.2.2 bouyer */
186 1.1.1.2.2.2 bouyer FileList[0] = AcpiOsAllocate (strlen (FileSpecifier) + 1);
187 1.1.1.2.2.2 bouyer strcpy (FileList[0], FileSpecifier);
188 1.1.1.2.2.2 bouyer FileList[1] = NULL;
189 1.1.1.2.2.2 bouyer
190 1.1.1.2.2.2 bouyer return (FileList);
191 1.1.1.2.2.2 bouyer #endif
192 1.1.1.2.2.2 bouyer }
193 1.1.1.2.2.2 bouyer
194 1.1.1.2.2.2 bouyer
195 1.1.1.2.2.2 bouyer /*******************************************************************************
196 1.1.1.2.2.2 bouyer *
197 1.1.1.2.2.2 bouyer * FUNCTION: AslDetectSourceFileType
198 1.1.1.2.2.2 bouyer *
199 1.1.1.2.2.2 bouyer * PARAMETERS: Info - Name/Handle for the file (must be open)
200 1.1.1.2.2.2 bouyer *
201 1.1.1.2.2.2 bouyer * RETURN: File Type
202 1.1.1.2.2.2 bouyer *
203 1.1.1.2.2.2 bouyer * DESCRIPTION: Determine the type of the input file. Either binary (contains
204 1.1.1.2.2.2 bouyer * non-ASCII characters), ASL file, or an ACPI Data Table file.
205 1.1.1.2.2.2 bouyer *
206 1.1.1.2.2.2 bouyer ******************************************************************************/
207 1.1.1.2.2.2 bouyer
208 1.1.1.2.2.2 bouyer static UINT8
209 1.1.1.2.2.2 bouyer AslDetectSourceFileType (
210 1.1.1.2.2.2 bouyer ASL_FILE_INFO *Info)
211 1.1.1.2.2.2 bouyer {
212 1.1.1.2.2.2 bouyer char *FileChar;
213 1.1.1.2.2.2 bouyer UINT8 Type;
214 1.1.1.2.2.2 bouyer ACPI_STATUS Status;
215 1.1.1.2.2.2 bouyer
216 1.1.1.2.2.2 bouyer
217 1.1.1.2.2.2 bouyer /* Check for 100% ASCII source file (comments are ignored) */
218 1.1.1.2.2.2 bouyer
219 1.1.1.2.2.2 bouyer Status = FlCheckForAscii (Info);
220 1.1.1.2.2.2 bouyer if (ACPI_FAILURE (Status))
221 1.1.1.2.2.2 bouyer {
222 1.1.1.2.2.2 bouyer printf ("Non-ascii input file - %s\n", Info->Filename);
223 1.1.1.2.2.2 bouyer Type = ASL_INPUT_TYPE_BINARY;
224 1.1.1.2.2.2 bouyer goto Cleanup;
225 1.1.1.2.2.2 bouyer }
226 1.1.1.2.2.2 bouyer
227 1.1.1.2.2.2 bouyer /*
228 1.1.1.2.2.2 bouyer * File is ASCII. Determine if this is an ASL file or an ACPI data
229 1.1.1.2.2.2 bouyer * table file.
230 1.1.1.2.2.2 bouyer */
231 1.1.1.2.2.2 bouyer while (fgets (Gbl_CurrentLineBuffer, ASL_LINE_BUFFER_SIZE, Info->Handle))
232 1.1.1.2.2.2 bouyer {
233 1.1.1.2.2.2 bouyer /* Uppercase the buffer for caseless compare */
234 1.1.1.2.2.2 bouyer
235 1.1.1.2.2.2 bouyer FileChar = Gbl_CurrentLineBuffer;
236 1.1.1.2.2.2 bouyer while (*FileChar)
237 1.1.1.2.2.2 bouyer {
238 1.1.1.2.2.2 bouyer *FileChar = (char) toupper ((int) *FileChar);
239 1.1.1.2.2.2 bouyer FileChar++;
240 1.1.1.2.2.2 bouyer }
241 1.1.1.2.2.2 bouyer
242 1.1.1.2.2.2 bouyer /* Presence of "DefinitionBlock" indicates actual ASL code */
243 1.1.1.2.2.2 bouyer
244 1.1.1.2.2.2 bouyer if (strstr (Gbl_CurrentLineBuffer, "DEFINITIONBLOCK"))
245 1.1.1.2.2.2 bouyer {
246 1.1.1.2.2.2 bouyer /* Appears to be an ASL file */
247 1.1.1.2.2.2 bouyer
248 1.1.1.2.2.2 bouyer Type = ASL_INPUT_TYPE_ASCII_ASL;
249 1.1.1.2.2.2 bouyer goto Cleanup;
250 1.1.1.2.2.2 bouyer }
251 1.1.1.2.2.2 bouyer }
252 1.1.1.2.2.2 bouyer
253 1.1.1.2.2.2 bouyer /* Not an ASL source file, default to a data table source file */
254 1.1.1.2.2.2 bouyer
255 1.1.1.2.2.2 bouyer Type = ASL_INPUT_TYPE_ASCII_DATA;
256 1.1.1.2.2.2 bouyer
257 1.1.1.2.2.2 bouyer Cleanup:
258 1.1.1.2.2.2 bouyer
259 1.1.1.2.2.2 bouyer /* Must seek back to the start of the file */
260 1.1.1.2.2.2 bouyer
261 1.1.1.2.2.2 bouyer fseek (Info->Handle, 0, SEEK_SET);
262 1.1.1.2.2.2 bouyer return (Type);
263 1.1.1.2.2.2 bouyer }
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 * FUNCTION: AslDoOneFile
269 1.1.1.2.2.2 bouyer *
270 1.1.1.2.2.2 bouyer * PARAMETERS: Filename - Name of the file
271 1.1.1.2.2.2 bouyer *
272 1.1.1.2.2.2 bouyer * RETURN: Status
273 1.1.1.2.2.2 bouyer *
274 1.1.1.2.2.2 bouyer * DESCRIPTION: Process a single file - either disassemble, compile, or both
275 1.1.1.2.2.2 bouyer *
276 1.1.1.2.2.2 bouyer ******************************************************************************/
277 1.1.1.2.2.2 bouyer
278 1.1.1.2.2.2 bouyer ACPI_STATUS
279 1.1.1.2.2.2 bouyer AslDoOneFile (
280 1.1.1.2.2.2 bouyer char *Filename)
281 1.1.1.2.2.2 bouyer {
282 1.1.1.2.2.2 bouyer ACPI_STATUS Status;
283 1.1.1.2.2.2 bouyer
284 1.1.1.2.2.2 bouyer
285 1.1.1.2.2.2 bouyer Gbl_Files[ASL_FILE_INPUT].Filename = Filename;
286 1.1.1.2.2.2 bouyer
287 1.1.1.2.2.2 bouyer /* Re-initialize "some" compiler globals */
288 1.1.1.2.2.2 bouyer
289 1.1.1.2.2.2 bouyer AslInitializeGlobals ();
290 1.1.1.2.2.2 bouyer
291 1.1.1.2.2.2 bouyer /*
292 1.1.1.2.2.2 bouyer * AML Disassembly (Optional)
293 1.1.1.2.2.2 bouyer */
294 1.1.1.2.2.2 bouyer if (Gbl_DisasmFlag || Gbl_GetAllTables)
295 1.1.1.2.2.2 bouyer {
296 1.1.1.2.2.2 bouyer /* ACPICA subsystem initialization */
297 1.1.1.2.2.2 bouyer
298 1.1.1.2.2.2 bouyer Status = AdInitialize ();
299 1.1.1.2.2.2 bouyer if (ACPI_FAILURE (Status))
300 1.1.1.2.2.2 bouyer {
301 1.1.1.2.2.2 bouyer return (Status);
302 1.1.1.2.2.2 bouyer }
303 1.1.1.2.2.2 bouyer
304 1.1.1.2.2.2 bouyer Status = AcpiAllocateRootTable (4);
305 1.1.1.2.2.2 bouyer if (ACPI_FAILURE (Status))
306 1.1.1.2.2.2 bouyer {
307 1.1.1.2.2.2 bouyer AcpiOsPrintf ("Could not initialize ACPI Table Manager, %s\n",
308 1.1.1.2.2.2 bouyer AcpiFormatException (Status));
309 1.1.1.2.2.2 bouyer return (Status);
310 1.1.1.2.2.2 bouyer }
311 1.1.1.2.2.2 bouyer
312 1.1.1.2.2.2 bouyer /* This is where the disassembly happens */
313 1.1.1.2.2.2 bouyer
314 1.1.1.2.2.2 bouyer AcpiGbl_DbOpt_disasm = TRUE;
315 1.1.1.2.2.2 bouyer Status = AdAmlDisassemble (AslToFile,
316 1.1.1.2.2.2 bouyer Gbl_Files[ASL_FILE_INPUT].Filename,
317 1.1.1.2.2.2 bouyer Gbl_OutputFilenamePrefix,
318 1.1.1.2.2.2 bouyer &Gbl_Files[ASL_FILE_INPUT].Filename,
319 1.1.1.2.2.2 bouyer Gbl_GetAllTables);
320 1.1.1.2.2.2 bouyer if (ACPI_FAILURE (Status))
321 1.1.1.2.2.2 bouyer {
322 1.1.1.2.2.2 bouyer return (Status);
323 1.1.1.2.2.2 bouyer }
324 1.1.1.2.2.2 bouyer
325 1.1.1.2.2.2 bouyer /* Shutdown compiler and ACPICA subsystem */
326 1.1.1.2.2.2 bouyer
327 1.1.1.2.2.2 bouyer AeClearErrorLog ();
328 1.1.1.2.2.2 bouyer (void) AcpiTerminate ();
329 1.1.1.2.2.2 bouyer
330 1.1.1.2.2.2 bouyer /*
331 1.1.1.2.2.2 bouyer * Gbl_Files[ASL_FILE_INPUT].Filename was replaced with the
332 1.1.1.2.2.2 bouyer * .DSL disassembly file, which can now be compiled if requested
333 1.1.1.2.2.2 bouyer */
334 1.1.1.2.2.2 bouyer if (Gbl_DoCompile)
335 1.1.1.2.2.2 bouyer {
336 1.1.1.2.2.2 bouyer AcpiOsPrintf ("\nCompiling \"%s\"\n",
337 1.1.1.2.2.2 bouyer Gbl_Files[ASL_FILE_INPUT].Filename);
338 1.1.1.2.2.2 bouyer }
339 1.1.1.2.2.2 bouyer else
340 1.1.1.2.2.2 bouyer {
341 1.1.1.2.2.2 bouyer Gbl_Files[ASL_FILE_INPUT].Filename = NULL;
342 1.1.1.2.2.2 bouyer return (AE_OK);
343 1.1.1.2.2.2 bouyer }
344 1.1.1.2.2.2 bouyer }
345 1.1.1.2.2.2 bouyer
346 1.1.1.2.2.2 bouyer /*
347 1.1.1.2.2.2 bouyer * Open the input file. Here, this should be an ASCII source file,
348 1.1.1.2.2.2 bouyer * either an ASL file or a Data Table file
349 1.1.1.2.2.2 bouyer */
350 1.1.1.2.2.2 bouyer Status = FlOpenInputFile (Gbl_Files[ASL_FILE_INPUT].Filename);
351 1.1.1.2.2.2 bouyer if (ACPI_FAILURE (Status))
352 1.1.1.2.2.2 bouyer {
353 1.1.1.2.2.2 bouyer AePrintErrorLog (ASL_FILE_STDERR);
354 1.1.1.2.2.2 bouyer return (AE_ERROR);
355 1.1.1.2.2.2 bouyer }
356 1.1.1.2.2.2 bouyer
357 1.1.1.2.2.2 bouyer /* Determine input file type */
358 1.1.1.2.2.2 bouyer
359 1.1.1.2.2.2 bouyer Gbl_FileType = AslDetectSourceFileType (&Gbl_Files[ASL_FILE_INPUT]);
360 1.1.1.2.2.2 bouyer if (Gbl_FileType == ASL_INPUT_TYPE_BINARY)
361 1.1.1.2.2.2 bouyer {
362 1.1.1.2.2.2 bouyer return (AE_ERROR);
363 1.1.1.2.2.2 bouyer }
364 1.1.1.2.2.2 bouyer
365 1.1.1.2.2.2 bouyer /*
366 1.1.1.2.2.2 bouyer * If -p not specified, we will use the input filename as the
367 1.1.1.2.2.2 bouyer * output filename prefix
368 1.1.1.2.2.2 bouyer */
369 1.1.1.2.2.2 bouyer if (Gbl_UseDefaultAmlFilename)
370 1.1.1.2.2.2 bouyer {
371 1.1.1.2.2.2 bouyer Gbl_OutputFilenamePrefix = Gbl_Files[ASL_FILE_INPUT].Filename;
372 1.1.1.2.2.2 bouyer }
373 1.1.1.2.2.2 bouyer
374 1.1.1.2.2.2 bouyer /* Open the optional output files (listings, etc.) */
375 1.1.1.2.2.2 bouyer
376 1.1.1.2.2.2 bouyer Status = FlOpenMiscOutputFiles (Gbl_OutputFilenamePrefix);
377 1.1.1.2.2.2 bouyer if (ACPI_FAILURE (Status))
378 1.1.1.2.2.2 bouyer {
379 1.1.1.2.2.2 bouyer AePrintErrorLog (ASL_FILE_STDERR);
380 1.1.1.2.2.2 bouyer return (AE_ERROR);
381 1.1.1.2.2.2 bouyer }
382 1.1.1.2.2.2 bouyer
383 1.1.1.2.2.2 bouyer /*
384 1.1.1.2.2.2 bouyer * Compilation of ASL source versus DataTable source uses different
385 1.1.1.2.2.2 bouyer * compiler subsystems
386 1.1.1.2.2.2 bouyer */
387 1.1.1.2.2.2 bouyer switch (Gbl_FileType)
388 1.1.1.2.2.2 bouyer {
389 1.1.1.2.2.2 bouyer /*
390 1.1.1.2.2.2 bouyer * Data Table Compilation
391 1.1.1.2.2.2 bouyer */
392 1.1.1.2.2.2 bouyer case ASL_INPUT_TYPE_ASCII_DATA:
393 1.1.1.2.2.2 bouyer
394 1.1.1.2.2.2 bouyer Status = DtDoCompile ();
395 1.1.1.2.2.2 bouyer
396 1.1.1.2.2.2 bouyer if (Gbl_Signature)
397 1.1.1.2.2.2 bouyer {
398 1.1.1.2.2.2 bouyer ACPI_FREE (Gbl_Signature);
399 1.1.1.2.2.2 bouyer Gbl_Signature = NULL;
400 1.1.1.2.2.2 bouyer }
401 1.1.1.2.2.2 bouyer AeClearErrorLog ();
402 1.1.1.2.2.2 bouyer return (Status);
403 1.1.1.2.2.2 bouyer
404 1.1.1.2.2.2 bouyer /*
405 1.1.1.2.2.2 bouyer * ASL Compilation (Optional)
406 1.1.1.2.2.2 bouyer */
407 1.1.1.2.2.2 bouyer case ASL_INPUT_TYPE_ASCII_ASL:
408 1.1.1.2.2.2 bouyer
409 1.1.1.2.2.2 bouyer /* ACPICA subsystem initialization */
410 1.1.1.2.2.2 bouyer
411 1.1.1.2.2.2 bouyer Status = AdInitialize ();
412 1.1.1.2.2.2 bouyer if (ACPI_FAILURE (Status))
413 1.1.1.2.2.2 bouyer {
414 1.1.1.2.2.2 bouyer return (Status);
415 1.1.1.2.2.2 bouyer }
416 1.1.1.2.2.2 bouyer
417 1.1.1.2.2.2 bouyer Status = CmDoCompile ();
418 1.1.1.2.2.2 bouyer (void) AcpiTerminate ();
419 1.1.1.2.2.2 bouyer
420 1.1.1.2.2.2 bouyer /*
421 1.1.1.2.2.2 bouyer * Return non-zero exit code if there have been errors, unless the
422 1.1.1.2.2.2 bouyer * global ignore error flag has been set
423 1.1.1.2.2.2 bouyer */
424 1.1.1.2.2.2 bouyer if ((Gbl_ExceptionCount[ASL_ERROR] > 0) && (!Gbl_IgnoreErrors))
425 1.1.1.2.2.2 bouyer {
426 1.1.1.2.2.2 bouyer return (AE_ERROR);
427 1.1.1.2.2.2 bouyer }
428 1.1.1.2.2.2 bouyer
429 1.1.1.2.2.2 bouyer AeClearErrorLog ();
430 1.1.1.2.2.2 bouyer return (AE_OK);
431 1.1.1.2.2.2 bouyer
432 1.1.1.2.2.2 bouyer case ASL_INPUT_TYPE_BINARY:
433 1.1.1.2.2.2 bouyer
434 1.1.1.2.2.2 bouyer AePrintErrorLog (ASL_FILE_STDERR);
435 1.1.1.2.2.2 bouyer return (AE_ERROR);
436 1.1.1.2.2.2 bouyer
437 1.1.1.2.2.2 bouyer default:
438 1.1.1.2.2.2 bouyer printf ("Unknown file type %X\n", Gbl_FileType);
439 1.1.1.2.2.2 bouyer return (AE_ERROR);
440 1.1.1.2.2.2 bouyer }
441 1.1.1.2.2.2 bouyer }
442 1.1.1.2.2.2 bouyer
443 1.1.1.2.2.2 bouyer
444 1.1.1.2.2.2 bouyer /*******************************************************************************
445 1.1.1.2.2.2 bouyer *
446 1.1.1.2.2.2 bouyer * FUNCTION: AslDoOnePathname
447 1.1.1.2.2.2 bouyer *
448 1.1.1.2.2.2 bouyer * PARAMETERS: Pathname - Full pathname, possibly with wildcards
449 1.1.1.2.2.2 bouyer *
450 1.1.1.2.2.2 bouyer * RETURN: Status
451 1.1.1.2.2.2 bouyer *
452 1.1.1.2.2.2 bouyer * DESCRIPTION: Process one pathname, possible terminated with a wildcard
453 1.1.1.2.2.2 bouyer * specification. If a wildcard, it is expanded and the multiple
454 1.1.1.2.2.2 bouyer * files are processed.
455 1.1.1.2.2.2 bouyer *
456 1.1.1.2.2.2 bouyer ******************************************************************************/
457 1.1.1.2.2.2 bouyer
458 1.1.1.2.2.2 bouyer ACPI_STATUS
459 1.1.1.2.2.2 bouyer AslDoOnePathname (
460 1.1.1.2.2.2 bouyer char *Pathname,
461 1.1.1.2.2.2 bouyer ASL_PATHNAME_CALLBACK PathCallback)
462 1.1.1.2.2.2 bouyer {
463 1.1.1.2.2.2 bouyer ACPI_STATUS Status = AE_OK;
464 1.1.1.2.2.2 bouyer char **WildcardList;
465 1.1.1.2.2.2 bouyer char *Filename;
466 1.1.1.2.2.2 bouyer char *FullPathname;
467 1.1.1.2.2.2 bouyer
468 1.1.1.2.2.2 bouyer
469 1.1.1.2.2.2 bouyer /* Split incoming path into a directory/filename combo */
470 1.1.1.2.2.2 bouyer
471 1.1.1.2.2.2 bouyer Status = FlSplitInputPathname (Pathname, &Gbl_DirectoryPath, &Filename);
472 1.1.1.2.2.2 bouyer if (ACPI_FAILURE (Status))
473 1.1.1.2.2.2 bouyer {
474 1.1.1.2.2.2 bouyer return (Status);
475 1.1.1.2.2.2 bouyer }
476 1.1.1.2.2.2 bouyer
477 1.1.1.2.2.2 bouyer /* Expand possible wildcard into a file list (Windows/DOS only) */
478 1.1.1.2.2.2 bouyer
479 1.1.1.2.2.2 bouyer WildcardList = AsDoWildcard (Gbl_DirectoryPath, Filename);
480 1.1.1.2.2.2 bouyer while (*WildcardList)
481 1.1.1.2.2.2 bouyer {
482 1.1.1.2.2.2 bouyer FullPathname = ACPI_ALLOCATE (
483 1.1.1.2.2.2 bouyer strlen (Gbl_DirectoryPath) + strlen (*WildcardList) + 1);
484 1.1.1.2.2.2 bouyer
485 1.1.1.2.2.2 bouyer /* Construct a full path to the file */
486 1.1.1.2.2.2 bouyer
487 1.1.1.2.2.2 bouyer strcpy (FullPathname, Gbl_DirectoryPath);
488 1.1.1.2.2.2 bouyer strcat (FullPathname, *WildcardList);
489 1.1.1.2.2.2 bouyer
490 1.1.1.2.2.2 bouyer /*
491 1.1.1.2.2.2 bouyer * If -p not specified, we will use the input filename as the
492 1.1.1.2.2.2 bouyer * output filename prefix
493 1.1.1.2.2.2 bouyer */
494 1.1.1.2.2.2 bouyer if (Gbl_UseDefaultAmlFilename)
495 1.1.1.2.2.2 bouyer {
496 1.1.1.2.2.2 bouyer Gbl_OutputFilenamePrefix = FullPathname;
497 1.1.1.2.2.2 bouyer }
498 1.1.1.2.2.2 bouyer
499 1.1.1.2.2.2 bouyer /* Save status from all compiles */
500 1.1.1.2.2.2 bouyer
501 1.1.1.2.2.2 bouyer Status |= (*PathCallback) (FullPathname);
502 1.1.1.2.2.2 bouyer
503 1.1.1.2.2.2 bouyer ACPI_FREE (FullPathname);
504 1.1.1.2.2.2 bouyer ACPI_FREE (*WildcardList);
505 1.1.1.2.2.2 bouyer *WildcardList = NULL;
506 1.1.1.2.2.2 bouyer WildcardList++;
507 1.1.1.2.2.2 bouyer }
508 1.1.1.2.2.2 bouyer
509 1.1.1.2.2.2 bouyer ACPI_FREE (Gbl_DirectoryPath);
510 1.1.1.2.2.2 bouyer ACPI_FREE (Filename);
511 1.1.1.2.2.2 bouyer return (Status);
512 1.1.1.2.2.2 bouyer }
513 1.1.1.2.2.2 bouyer
514