aslstartup.c revision 1.1.1.9 1 1.1 jruoho /******************************************************************************
2 1.1 jruoho *
3 1.1 jruoho * Module Name: aslstartup - Compiler startup routines, called from main
4 1.1 jruoho *
5 1.1 jruoho *****************************************************************************/
6 1.1 jruoho
7 1.1.1.2 jruoho /*
8 1.1.1.8 christos * Copyright (C) 2000 - 2017, Intel Corp.
9 1.1 jruoho * All rights reserved.
10 1.1 jruoho *
11 1.1.1.2 jruoho * Redistribution and use in source and binary forms, with or without
12 1.1.1.2 jruoho * modification, are permitted provided that the following conditions
13 1.1.1.2 jruoho * are met:
14 1.1.1.2 jruoho * 1. Redistributions of source code must retain the above copyright
15 1.1.1.2 jruoho * notice, this list of conditions, and the following disclaimer,
16 1.1.1.2 jruoho * without modification.
17 1.1.1.2 jruoho * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 1.1.1.2 jruoho * substantially similar to the "NO WARRANTY" disclaimer below
19 1.1.1.2 jruoho * ("Disclaimer") and any redistribution must be conditioned upon
20 1.1.1.2 jruoho * including a substantially similar Disclaimer requirement for further
21 1.1.1.2 jruoho * binary redistribution.
22 1.1.1.2 jruoho * 3. Neither the names of the above-listed copyright holders nor the names
23 1.1.1.2 jruoho * of any contributors may be used to endorse or promote products derived
24 1.1.1.2 jruoho * from this software without specific prior written permission.
25 1.1.1.2 jruoho *
26 1.1.1.2 jruoho * Alternatively, this software may be distributed under the terms of the
27 1.1.1.2 jruoho * GNU General Public License ("GPL") version 2 as published by the Free
28 1.1.1.2 jruoho * Software Foundation.
29 1.1.1.2 jruoho *
30 1.1.1.2 jruoho * NO WARRANTY
31 1.1.1.2 jruoho * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 1.1.1.2 jruoho * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 1.1.1.2 jruoho * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 1.1.1.2 jruoho * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 1.1.1.2 jruoho * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 1.1.1.2 jruoho * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 1.1.1.2 jruoho * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 1.1.1.2 jruoho * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 1.1.1.2 jruoho * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 1.1.1.2 jruoho * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 1.1.1.2 jruoho * POSSIBILITY OF SUCH DAMAGES.
42 1.1.1.2 jruoho */
43 1.1 jruoho
44 1.1 jruoho #include "aslcompiler.h"
45 1.1 jruoho #include "actables.h"
46 1.1.1.3 christos #include "acdisasm.h"
47 1.1 jruoho #include "acapps.h"
48 1.1.1.9 christos #include "acconvert.h"
49 1.1 jruoho
50 1.1 jruoho #define _COMPONENT ACPI_COMPILER
51 1.1 jruoho ACPI_MODULE_NAME ("aslstartup")
52 1.1 jruoho
53 1.1 jruoho
54 1.1 jruoho /* Local prototypes */
55 1.1 jruoho
56 1.1.1.2 jruoho static UINT8
57 1.1 jruoho AslDetectSourceFileType (
58 1.1 jruoho ASL_FILE_INFO *Info);
59 1.1 jruoho
60 1.1.1.3 christos static ACPI_STATUS
61 1.1.1.3 christos AslDoDisassembly (
62 1.1.1.3 christos void);
63 1.1.1.3 christos
64 1.1.1.3 christos
65 1.1.1.3 christos /* Globals */
66 1.1.1.3 christos
67 1.1.1.3 christos static BOOLEAN AslToFile = TRUE;
68 1.1.1.3 christos
69 1.1 jruoho
70 1.1 jruoho /*******************************************************************************
71 1.1 jruoho *
72 1.1 jruoho * FUNCTION: AslInitializeGlobals
73 1.1 jruoho *
74 1.1 jruoho * PARAMETERS: None
75 1.1 jruoho *
76 1.1 jruoho * RETURN: None
77 1.1 jruoho *
78 1.1 jruoho * DESCRIPTION: Re-initialize globals needed to restart the compiler. This
79 1.1 jruoho * allows multiple files to be disassembled and/or compiled.
80 1.1 jruoho *
81 1.1 jruoho ******************************************************************************/
82 1.1 jruoho
83 1.1.1.2 jruoho void
84 1.1 jruoho AslInitializeGlobals (
85 1.1 jruoho void)
86 1.1 jruoho {
87 1.1 jruoho UINT32 i;
88 1.1 jruoho
89 1.1 jruoho
90 1.1 jruoho /* Init compiler globals */
91 1.1 jruoho
92 1.1.1.5 christos Gbl_SyntaxError = 0;
93 1.1 jruoho Gbl_CurrentColumn = 0;
94 1.1 jruoho Gbl_CurrentLineNumber = 1;
95 1.1 jruoho Gbl_LogicalLineNumber = 1;
96 1.1 jruoho Gbl_CurrentLineOffset = 0;
97 1.1 jruoho Gbl_InputFieldCount = 0;
98 1.1.1.3 christos Gbl_InputByteCount = 0;
99 1.1.1.3 christos Gbl_NsLookupCount = 0;
100 1.1 jruoho Gbl_LineBufPtr = Gbl_CurrentLineBuffer;
101 1.1 jruoho
102 1.1 jruoho Gbl_ErrorLog = NULL;
103 1.1 jruoho Gbl_NextError = NULL;
104 1.1 jruoho Gbl_Signature = NULL;
105 1.1 jruoho Gbl_FileType = 0;
106 1.1 jruoho
107 1.1.1.3 christos TotalExecutableOpcodes = 0;
108 1.1.1.3 christos TotalNamedObjects = 0;
109 1.1.1.3 christos TotalKeywords = 0;
110 1.1.1.3 christos TotalParseNodes = 0;
111 1.1.1.3 christos TotalMethods = 0;
112 1.1.1.3 christos TotalAllocations = 0;
113 1.1.1.3 christos TotalAllocated = 0;
114 1.1.1.3 christos TotalFolds = 0;
115 1.1.1.3 christos
116 1.1 jruoho AslGbl_NextEvent = 0;
117 1.1 jruoho for (i = 0; i < ASL_NUM_REPORT_LEVELS; i++)
118 1.1 jruoho {
119 1.1 jruoho Gbl_ExceptionCount[i] = 0;
120 1.1 jruoho }
121 1.1 jruoho
122 1.1.1.3 christos for (i = ASL_FILE_INPUT; i <= ASL_MAX_FILE_TYPE; i++)
123 1.1 jruoho {
124 1.1.1.3 christos Gbl_Files[i].Handle = NULL;
125 1.1.1.3 christos Gbl_Files[i].Filename = NULL;
126 1.1 jruoho }
127 1.1.1.9 christos
128 1.1.1.9 christos if (Gbl_CaptureComments)
129 1.1.1.9 christos {
130 1.1.1.9 christos Gbl_CommentState.SpacesBefore = 0;
131 1.1.1.9 christos Gbl_CommentState.CommentType = 1;
132 1.1.1.9 christos Gbl_CommentState.Latest_Parse_Node = NULL;
133 1.1.1.9 christos Gbl_CommentState.ParsingParenBraceNode = NULL;
134 1.1.1.9 christos Gbl_CommentState.CaptureComments = TRUE;
135 1.1.1.9 christos }
136 1.1 jruoho }
137 1.1 jruoho
138 1.1 jruoho
139 1.1 jruoho /*******************************************************************************
140 1.1 jruoho *
141 1.1 jruoho * FUNCTION: AslDetectSourceFileType
142 1.1 jruoho *
143 1.1 jruoho * PARAMETERS: Info - Name/Handle for the file (must be open)
144 1.1 jruoho *
145 1.1 jruoho * RETURN: File Type
146 1.1 jruoho *
147 1.1 jruoho * DESCRIPTION: Determine the type of the input file. Either binary (contains
148 1.1 jruoho * non-ASCII characters), ASL file, or an ACPI Data Table file.
149 1.1 jruoho *
150 1.1 jruoho ******************************************************************************/
151 1.1 jruoho
152 1.1.1.2 jruoho static UINT8
153 1.1 jruoho AslDetectSourceFileType (
154 1.1 jruoho ASL_FILE_INFO *Info)
155 1.1 jruoho {
156 1.1 jruoho char *FileChar;
157 1.1.1.7 christos UINT8 Type = ASL_INPUT_TYPE_ASCII_DATA; /* default */
158 1.1 jruoho ACPI_STATUS Status;
159 1.1 jruoho
160 1.1 jruoho
161 1.1.1.7 christos /* Check for 100% ASCII source file (comments are ignored) */
162 1.1.1.3 christos
163 1.1.1.7 christos Status = FlIsFileAsciiSource (Info->Filename, FALSE);
164 1.1.1.3 christos if (ACPI_SUCCESS (Status))
165 1.1.1.3 christos {
166 1.1.1.7 christos /*
167 1.1.1.7 christos * File contains ASCII source code. Determine if this is an ASL
168 1.1.1.7 christos * file or an ACPI data table file.
169 1.1.1.7 christos */
170 1.1.1.7 christos while (fgets (Gbl_CurrentLineBuffer, Gbl_LineBufferSize, Info->Handle))
171 1.1.1.7 christos {
172 1.1.1.7 christos /* Uppercase the buffer for caseless compare */
173 1.1.1.3 christos
174 1.1.1.7 christos FileChar = Gbl_CurrentLineBuffer;
175 1.1.1.7 christos while (*FileChar)
176 1.1.1.7 christos {
177 1.1.1.7 christos *FileChar = (char) toupper ((int) *FileChar);
178 1.1.1.7 christos FileChar++;
179 1.1.1.7 christos }
180 1.1 jruoho
181 1.1.1.7 christos /* Presence of "DefinitionBlock" indicates actual ASL code */
182 1.1.1.3 christos
183 1.1.1.7 christos if (strstr (Gbl_CurrentLineBuffer, "DEFINITIONBLOCK"))
184 1.1.1.7 christos {
185 1.1.1.7 christos /* Appears to be an ASL file */
186 1.1.1.7 christos
187 1.1.1.7 christos Type = ASL_INPUT_TYPE_ASCII_ASL;
188 1.1.1.7 christos goto Cleanup;
189 1.1.1.7 christos }
190 1.1.1.3 christos }
191 1.1 jruoho
192 1.1.1.7 christos /* Appears to be an ASCII data table source file */
193 1.1 jruoho
194 1.1.1.7 christos Type = ASL_INPUT_TYPE_ASCII_DATA;
195 1.1.1.7 christos goto Cleanup;
196 1.1.1.7 christos }
197 1.1 jruoho
198 1.1.1.7 christos /* We have some sort of binary table, check for valid ACPI table */
199 1.1 jruoho
200 1.1.1.7 christos fseek (Info->Handle, 0, SEEK_SET);
201 1.1 jruoho
202 1.1.1.7 christos Status = AcValidateTableHeader (Info->Handle, 0);
203 1.1.1.7 christos if (ACPI_SUCCESS (Status))
204 1.1.1.7 christos {
205 1.1.1.7 christos fprintf (stderr,
206 1.1.1.7 christos "Binary file appears to be a valid ACPI table, disassembling\n");
207 1.1.1.7 christos
208 1.1.1.7 christos Type = ASL_INPUT_TYPE_BINARY_ACPI_TABLE;
209 1.1.1.7 christos goto Cleanup;
210 1.1 jruoho }
211 1.1 jruoho
212 1.1.1.7 christos Type = ASL_INPUT_TYPE_BINARY;
213 1.1 jruoho
214 1.1 jruoho
215 1.1 jruoho Cleanup:
216 1.1 jruoho
217 1.1 jruoho /* Must seek back to the start of the file */
218 1.1 jruoho
219 1.1 jruoho fseek (Info->Handle, 0, SEEK_SET);
220 1.1 jruoho return (Type);
221 1.1 jruoho }
222 1.1 jruoho
223 1.1 jruoho
224 1.1 jruoho /*******************************************************************************
225 1.1 jruoho *
226 1.1.1.3 christos * FUNCTION: AslDoDisassembly
227 1.1.1.3 christos *
228 1.1.1.3 christos * PARAMETERS: None
229 1.1.1.3 christos *
230 1.1.1.3 christos * RETURN: Status
231 1.1.1.3 christos *
232 1.1.1.3 christos * DESCRIPTION: Initiate AML file disassembly. Uses ACPICA subsystem to build
233 1.1.1.3 christos * namespace.
234 1.1.1.3 christos *
235 1.1.1.3 christos ******************************************************************************/
236 1.1.1.3 christos
237 1.1.1.3 christos static ACPI_STATUS
238 1.1.1.3 christos AslDoDisassembly (
239 1.1.1.3 christos void)
240 1.1.1.3 christos {
241 1.1.1.3 christos ACPI_STATUS Status;
242 1.1.1.3 christos
243 1.1.1.3 christos
244 1.1.1.3 christos /* ACPICA subsystem initialization */
245 1.1.1.3 christos
246 1.1.1.3 christos Status = AdInitialize ();
247 1.1.1.3 christos if (ACPI_FAILURE (Status))
248 1.1.1.3 christos {
249 1.1.1.3 christos return (Status);
250 1.1.1.3 christos }
251 1.1.1.3 christos
252 1.1.1.3 christos Status = AcpiAllocateRootTable (4);
253 1.1.1.3 christos if (ACPI_FAILURE (Status))
254 1.1.1.3 christos {
255 1.1.1.3 christos AcpiOsPrintf ("Could not initialize ACPI Table Manager, %s\n",
256 1.1.1.3 christos AcpiFormatException (Status));
257 1.1.1.3 christos return (Status);
258 1.1.1.3 christos }
259 1.1.1.3 christos
260 1.1.1.6 christos /* Handle additional output files for disassembler */
261 1.1.1.6 christos
262 1.1.1.7 christos Gbl_FileType = ASL_INPUT_TYPE_BINARY_ACPI_TABLE;
263 1.1.1.6 christos Status = FlOpenMiscOutputFiles (Gbl_OutputFilenamePrefix);
264 1.1.1.6 christos
265 1.1.1.3 christos /* This is where the disassembly happens */
266 1.1.1.3 christos
267 1.1.1.7 christos AcpiGbl_DmOpt_Disasm = TRUE;
268 1.1.1.3 christos Status = AdAmlDisassemble (AslToFile,
269 1.1.1.3 christos Gbl_Files[ASL_FILE_INPUT].Filename, Gbl_OutputFilenamePrefix,
270 1.1.1.4 christos &Gbl_Files[ASL_FILE_INPUT].Filename);
271 1.1.1.3 christos if (ACPI_FAILURE (Status))
272 1.1.1.3 christos {
273 1.1.1.3 christos return (Status);
274 1.1.1.3 christos }
275 1.1.1.3 christos
276 1.1.1.3 christos /* Check if any control methods were unresolved */
277 1.1.1.3 christos
278 1.1.1.3 christos AcpiDmUnresolvedWarning (0);
279 1.1.1.3 christos
280 1.1.1.3 christos /* Shutdown compiler and ACPICA subsystem */
281 1.1.1.3 christos
282 1.1.1.3 christos AeClearErrorLog ();
283 1.1.1.3 christos (void) AcpiTerminate ();
284 1.1.1.3 christos
285 1.1.1.3 christos /*
286 1.1.1.3 christos * Gbl_Files[ASL_FILE_INPUT].Filename was replaced with the
287 1.1.1.3 christos * .DSL disassembly file, which can now be compiled if requested
288 1.1.1.3 christos */
289 1.1.1.3 christos if (Gbl_DoCompile)
290 1.1.1.3 christos {
291 1.1.1.3 christos AcpiOsPrintf ("\nCompiling \"%s\"\n",
292 1.1.1.3 christos Gbl_Files[ASL_FILE_INPUT].Filename);
293 1.1.1.3 christos return (AE_CTRL_CONTINUE);
294 1.1.1.3 christos }
295 1.1.1.3 christos
296 1.1.1.4 christos /* No need to free the filename string */
297 1.1.1.4 christos
298 1.1.1.3 christos Gbl_Files[ASL_FILE_INPUT].Filename = NULL;
299 1.1.1.4 christos
300 1.1.1.4 christos CmDeleteCaches ();
301 1.1.1.3 christos return (AE_OK);
302 1.1.1.3 christos }
303 1.1.1.3 christos
304 1.1.1.3 christos
305 1.1.1.3 christos /*******************************************************************************
306 1.1.1.3 christos *
307 1.1 jruoho * FUNCTION: AslDoOneFile
308 1.1 jruoho *
309 1.1 jruoho * PARAMETERS: Filename - Name of the file
310 1.1 jruoho *
311 1.1 jruoho * RETURN: Status
312 1.1 jruoho *
313 1.1 jruoho * DESCRIPTION: Process a single file - either disassemble, compile, or both
314 1.1 jruoho *
315 1.1 jruoho ******************************************************************************/
316 1.1 jruoho
317 1.1 jruoho ACPI_STATUS
318 1.1 jruoho AslDoOneFile (
319 1.1 jruoho char *Filename)
320 1.1 jruoho {
321 1.1 jruoho ACPI_STATUS Status;
322 1.1 jruoho
323 1.1 jruoho
324 1.1.1.3 christos /* Re-initialize "some" compiler/preprocessor globals */
325 1.1 jruoho
326 1.1 jruoho AslInitializeGlobals ();
327 1.1.1.3 christos PrInitializeGlobals ();
328 1.1 jruoho
329 1.1 jruoho /*
330 1.1.1.3 christos * Extract the directory path. This path is used for possible include
331 1.1.1.3 christos * files and the optional AML filename embedded in the input file
332 1.1.1.3 christos * DefinitionBlock declaration.
333 1.1 jruoho */
334 1.1.1.3 christos Status = FlSplitInputPathname (Filename, &Gbl_DirectoryPath, NULL);
335 1.1.1.3 christos if (ACPI_FAILURE (Status))
336 1.1 jruoho {
337 1.1.1.3 christos return (Status);
338 1.1.1.3 christos }
339 1.1 jruoho
340 1.1.1.4 christos /* Take a copy of the input filename, convert any backslashes */
341 1.1.1.4 christos
342 1.1.1.4 christos Gbl_Files[ASL_FILE_INPUT].Filename =
343 1.1.1.4 christos UtStringCacheCalloc (strlen (Filename) + 1);
344 1.1.1.4 christos
345 1.1.1.4 christos strcpy (Gbl_Files[ASL_FILE_INPUT].Filename, Filename);
346 1.1.1.4 christos UtConvertBackslashes (Gbl_Files[ASL_FILE_INPUT].Filename);
347 1.1 jruoho
348 1.1.1.3 christos /*
349 1.1.1.3 christos * AML Disassembly (Optional)
350 1.1.1.3 christos */
351 1.1.1.4 christos if (Gbl_DisasmFlag)
352 1.1.1.3 christos {
353 1.1.1.3 christos Status = AslDoDisassembly ();
354 1.1.1.3 christos if (Status != AE_CTRL_CONTINUE)
355 1.1 jruoho {
356 1.1 jruoho return (Status);
357 1.1 jruoho }
358 1.1 jruoho }
359 1.1 jruoho
360 1.1 jruoho /*
361 1.1 jruoho * Open the input file. Here, this should be an ASCII source file,
362 1.1 jruoho * either an ASL file or a Data Table file
363 1.1 jruoho */
364 1.1 jruoho Status = FlOpenInputFile (Gbl_Files[ASL_FILE_INPUT].Filename);
365 1.1 jruoho if (ACPI_FAILURE (Status))
366 1.1 jruoho {
367 1.1 jruoho AePrintErrorLog (ASL_FILE_STDERR);
368 1.1 jruoho return (AE_ERROR);
369 1.1 jruoho }
370 1.1 jruoho
371 1.1.1.6 christos Gbl_OriginalInputFileSize = FlGetFileSize (ASL_FILE_INPUT);
372 1.1.1.6 christos
373 1.1 jruoho /* Determine input file type */
374 1.1 jruoho
375 1.1 jruoho Gbl_FileType = AslDetectSourceFileType (&Gbl_Files[ASL_FILE_INPUT]);
376 1.1 jruoho if (Gbl_FileType == ASL_INPUT_TYPE_BINARY)
377 1.1 jruoho {
378 1.1 jruoho return (AE_ERROR);
379 1.1 jruoho }
380 1.1 jruoho
381 1.1 jruoho /*
382 1.1 jruoho * If -p not specified, we will use the input filename as the
383 1.1 jruoho * output filename prefix
384 1.1 jruoho */
385 1.1 jruoho if (Gbl_UseDefaultAmlFilename)
386 1.1 jruoho {
387 1.1 jruoho Gbl_OutputFilenamePrefix = Gbl_Files[ASL_FILE_INPUT].Filename;
388 1.1 jruoho }
389 1.1 jruoho
390 1.1 jruoho /* Open the optional output files (listings, etc.) */
391 1.1 jruoho
392 1.1 jruoho Status = FlOpenMiscOutputFiles (Gbl_OutputFilenamePrefix);
393 1.1 jruoho if (ACPI_FAILURE (Status))
394 1.1 jruoho {
395 1.1 jruoho AePrintErrorLog (ASL_FILE_STDERR);
396 1.1 jruoho return (AE_ERROR);
397 1.1 jruoho }
398 1.1 jruoho
399 1.1 jruoho /*
400 1.1 jruoho * Compilation of ASL source versus DataTable source uses different
401 1.1 jruoho * compiler subsystems
402 1.1 jruoho */
403 1.1 jruoho switch (Gbl_FileType)
404 1.1 jruoho {
405 1.1 jruoho /*
406 1.1 jruoho * Data Table Compilation
407 1.1 jruoho */
408 1.1 jruoho case ASL_INPUT_TYPE_ASCII_DATA:
409 1.1 jruoho
410 1.1 jruoho Status = DtDoCompile ();
411 1.1.1.3 christos if (ACPI_FAILURE (Status))
412 1.1.1.3 christos {
413 1.1.1.3 christos return (Status);
414 1.1.1.3 christos }
415 1.1 jruoho
416 1.1 jruoho if (Gbl_Signature)
417 1.1 jruoho {
418 1.1 jruoho Gbl_Signature = NULL;
419 1.1 jruoho }
420 1.1.1.3 christos
421 1.1.1.3 christos /* Check if any errors occurred during compile */
422 1.1.1.3 christos
423 1.1.1.3 christos Status = AslCheckForErrorExit ();
424 1.1.1.3 christos if (ACPI_FAILURE (Status))
425 1.1.1.3 christos {
426 1.1.1.3 christos return (Status);
427 1.1.1.3 christos }
428 1.1.1.3 christos
429 1.1.1.3 christos /* Cleanup (for next source file) and exit */
430 1.1.1.3 christos
431 1.1 jruoho AeClearErrorLog ();
432 1.1.1.3 christos PrTerminatePreprocessor ();
433 1.1 jruoho return (Status);
434 1.1 jruoho
435 1.1 jruoho /*
436 1.1.1.3 christos * ASL Compilation
437 1.1 jruoho */
438 1.1 jruoho case ASL_INPUT_TYPE_ASCII_ASL:
439 1.1 jruoho
440 1.1 jruoho /* ACPICA subsystem initialization */
441 1.1 jruoho
442 1.1 jruoho Status = AdInitialize ();
443 1.1 jruoho if (ACPI_FAILURE (Status))
444 1.1 jruoho {
445 1.1 jruoho return (Status);
446 1.1 jruoho }
447 1.1 jruoho
448 1.1.1.3 christos (void) CmDoCompile ();
449 1.1.1.2 jruoho (void) AcpiTerminate ();
450 1.1 jruoho
451 1.1.1.3 christos /* Check if any errors occurred during compile */
452 1.1.1.3 christos
453 1.1.1.3 christos Status = AslCheckForErrorExit ();
454 1.1.1.3 christos if (ACPI_FAILURE (Status))
455 1.1 jruoho {
456 1.1.1.3 christos return (Status);
457 1.1 jruoho }
458 1.1 jruoho
459 1.1.1.3 christos /* Cleanup (for next source file) and exit */
460 1.1.1.3 christos
461 1.1 jruoho AeClearErrorLog ();
462 1.1.1.3 christos PrTerminatePreprocessor ();
463 1.1.1.9 christos
464 1.1.1.9 christos /* ASL-to-ASL+ conversion - Perform immediate disassembly */
465 1.1.1.9 christos
466 1.1.1.9 christos if (Gbl_DoAslConversion)
467 1.1.1.9 christos {
468 1.1.1.9 christos /*
469 1.1.1.9 christos * New input file is the output AML file from above.
470 1.1.1.9 christos * New output is from the input ASL file from above.
471 1.1.1.9 christos */
472 1.1.1.9 christos Gbl_OutputFilenamePrefix = Gbl_Files[ASL_FILE_INPUT].Filename;
473 1.1.1.9 christos CvDbgPrint ("OUTPUTFILENAME: %s\n", Gbl_OutputFilenamePrefix);
474 1.1.1.9 christos Gbl_Files[ASL_FILE_INPUT].Filename =
475 1.1.1.9 christos Gbl_Files[ASL_FILE_AML_OUTPUT].Filename;
476 1.1.1.9 christos
477 1.1.1.9 christos fprintf (stderr, "\n");
478 1.1.1.9 christos AslDoDisassembly ();
479 1.1.1.9 christos
480 1.1.1.9 christos /* delete the AML file. This AML file should never be utilized by AML interpreters. */
481 1.1.1.9 christos
482 1.1.1.9 christos FlDeleteFile (ASL_FILE_AML_OUTPUT);
483 1.1.1.9 christos }
484 1.1.1.9 christos
485 1.1 jruoho return (AE_OK);
486 1.1 jruoho
487 1.1.1.3 christos /*
488 1.1.1.3 christos * Binary ACPI table was auto-detected, disassemble it
489 1.1.1.3 christos */
490 1.1.1.7 christos case ASL_INPUT_TYPE_BINARY_ACPI_TABLE:
491 1.1.1.3 christos
492 1.1.1.3 christos /* We have what appears to be an ACPI table, disassemble it */
493 1.1.1.3 christos
494 1.1.1.3 christos FlCloseFile (ASL_FILE_INPUT);
495 1.1.1.3 christos Gbl_DoCompile = FALSE;
496 1.1.1.3 christos Gbl_DisasmFlag = TRUE;
497 1.1.1.3 christos Status = AslDoDisassembly ();
498 1.1.1.3 christos return (Status);
499 1.1.1.3 christos
500 1.1.1.3 christos /* Unknown binary table */
501 1.1.1.3 christos
502 1.1 jruoho case ASL_INPUT_TYPE_BINARY:
503 1.1 jruoho
504 1.1 jruoho AePrintErrorLog (ASL_FILE_STDERR);
505 1.1 jruoho return (AE_ERROR);
506 1.1 jruoho
507 1.1 jruoho default:
508 1.1.1.3 christos
509 1.1 jruoho printf ("Unknown file type %X\n", Gbl_FileType);
510 1.1 jruoho return (AE_ERROR);
511 1.1 jruoho }
512 1.1 jruoho }
513 1.1 jruoho
514 1.1 jruoho
515 1.1 jruoho /*******************************************************************************
516 1.1 jruoho *
517 1.1.1.3 christos * FUNCTION: AslCheckForErrorExit
518 1.1 jruoho *
519 1.1.1.3 christos * PARAMETERS: None. Examines global exception count array
520 1.1 jruoho *
521 1.1 jruoho * RETURN: Status
522 1.1 jruoho *
523 1.1.1.3 christos * DESCRIPTION: Determine if compiler should abort with error status
524 1.1 jruoho *
525 1.1 jruoho ******************************************************************************/
526 1.1 jruoho
527 1.1 jruoho ACPI_STATUS
528 1.1.1.3 christos AslCheckForErrorExit (
529 1.1.1.3 christos void)
530 1.1 jruoho {
531 1.1 jruoho
532 1.1.1.3 christos /*
533 1.1.1.3 christos * Return non-zero exit code if there have been errors, unless the
534 1.1.1.3 christos * global ignore error flag has been set
535 1.1.1.3 christos */
536 1.1.1.3 christos if (!Gbl_IgnoreErrors)
537 1.1 jruoho {
538 1.1.1.3 christos if (Gbl_ExceptionCount[ASL_ERROR] > 0)
539 1.1 jruoho {
540 1.1.1.3 christos return (AE_ERROR);
541 1.1 jruoho }
542 1.1 jruoho
543 1.1.1.3 christos /* Optionally treat warnings as errors */
544 1.1 jruoho
545 1.1.1.3 christos if (Gbl_WarningsAsErrors)
546 1.1.1.3 christos {
547 1.1.1.3 christos if ((Gbl_ExceptionCount[ASL_WARNING] > 0) ||
548 1.1.1.3 christos (Gbl_ExceptionCount[ASL_WARNING2] > 0) ||
549 1.1.1.3 christos (Gbl_ExceptionCount[ASL_WARNING3] > 0))
550 1.1.1.3 christos {
551 1.1.1.3 christos return (AE_ERROR);
552 1.1.1.3 christos }
553 1.1.1.3 christos }
554 1.1 jruoho }
555 1.1 jruoho
556 1.1.1.3 christos return (AE_OK);
557 1.1 jruoho }
558