aslstartup.c revision 1.1.1.2.24.1 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.2.24.1 rmind * Copyright (C) 2000 - 2013, 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
45 1.1 jruoho #include "aslcompiler.h"
46 1.1 jruoho #include "actables.h"
47 1.1.1.2.24.1 rmind #include "acdisasm.h"
48 1.1 jruoho #include "acapps.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.2.24.1 rmind static ACPI_STATUS
61 1.1.1.2.24.1 rmind AslDoDisassembly (
62 1.1.1.2.24.1 rmind void);
63 1.1.1.2.24.1 rmind
64 1.1.1.2.24.1 rmind
65 1.1.1.2.24.1 rmind /* Globals */
66 1.1.1.2.24.1 rmind
67 1.1.1.2.24.1 rmind static BOOLEAN AslToFile = TRUE;
68 1.1.1.2.24.1 rmind
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 jruoho Gbl_CurrentColumn = 0;
93 1.1 jruoho Gbl_CurrentLineNumber = 1;
94 1.1 jruoho Gbl_LogicalLineNumber = 1;
95 1.1 jruoho Gbl_CurrentLineOffset = 0;
96 1.1 jruoho Gbl_InputFieldCount = 0;
97 1.1.1.2.24.1 rmind Gbl_InputByteCount = 0;
98 1.1.1.2.24.1 rmind Gbl_NsLookupCount = 0;
99 1.1 jruoho Gbl_LineBufPtr = Gbl_CurrentLineBuffer;
100 1.1 jruoho
101 1.1 jruoho Gbl_ErrorLog = NULL;
102 1.1 jruoho Gbl_NextError = NULL;
103 1.1 jruoho Gbl_Signature = NULL;
104 1.1 jruoho Gbl_FileType = 0;
105 1.1 jruoho
106 1.1.1.2.24.1 rmind TotalExecutableOpcodes = 0;
107 1.1.1.2.24.1 rmind TotalNamedObjects = 0;
108 1.1.1.2.24.1 rmind TotalKeywords = 0;
109 1.1.1.2.24.1 rmind TotalParseNodes = 0;
110 1.1.1.2.24.1 rmind TotalMethods = 0;
111 1.1.1.2.24.1 rmind TotalAllocations = 0;
112 1.1.1.2.24.1 rmind TotalAllocated = 0;
113 1.1.1.2.24.1 rmind TotalFolds = 0;
114 1.1.1.2.24.1 rmind
115 1.1 jruoho AslGbl_NextEvent = 0;
116 1.1 jruoho for (i = 0; i < ASL_NUM_REPORT_LEVELS; i++)
117 1.1 jruoho {
118 1.1 jruoho Gbl_ExceptionCount[i] = 0;
119 1.1 jruoho }
120 1.1 jruoho
121 1.1.1.2.24.1 rmind for (i = ASL_FILE_INPUT; i <= ASL_MAX_FILE_TYPE; i++)
122 1.1 jruoho {
123 1.1.1.2.24.1 rmind Gbl_Files[i].Handle = NULL;
124 1.1.1.2.24.1 rmind Gbl_Files[i].Filename = NULL;
125 1.1 jruoho }
126 1.1 jruoho }
127 1.1 jruoho
128 1.1 jruoho
129 1.1 jruoho /*******************************************************************************
130 1.1 jruoho *
131 1.1 jruoho * FUNCTION: AslDetectSourceFileType
132 1.1 jruoho *
133 1.1 jruoho * PARAMETERS: Info - Name/Handle for the file (must be open)
134 1.1 jruoho *
135 1.1 jruoho * RETURN: File Type
136 1.1 jruoho *
137 1.1 jruoho * DESCRIPTION: Determine the type of the input file. Either binary (contains
138 1.1 jruoho * non-ASCII characters), ASL file, or an ACPI Data Table file.
139 1.1 jruoho *
140 1.1 jruoho ******************************************************************************/
141 1.1 jruoho
142 1.1.1.2 jruoho static UINT8
143 1.1 jruoho AslDetectSourceFileType (
144 1.1 jruoho ASL_FILE_INFO *Info)
145 1.1 jruoho {
146 1.1 jruoho char *FileChar;
147 1.1 jruoho UINT8 Type;
148 1.1 jruoho ACPI_STATUS Status;
149 1.1 jruoho
150 1.1 jruoho
151 1.1.1.2.24.1 rmind /* Check for a valid binary ACPI table */
152 1.1.1.2.24.1 rmind
153 1.1.1.2.24.1 rmind Status = FlCheckForAcpiTable (Info->Handle);
154 1.1.1.2.24.1 rmind if (ACPI_SUCCESS (Status))
155 1.1.1.2.24.1 rmind {
156 1.1.1.2.24.1 rmind Type = ASL_INPUT_TYPE_ACPI_TABLE;
157 1.1.1.2.24.1 rmind goto Cleanup;
158 1.1.1.2.24.1 rmind }
159 1.1.1.2.24.1 rmind
160 1.1 jruoho /* Check for 100% ASCII source file (comments are ignored) */
161 1.1 jruoho
162 1.1.1.2.24.1 rmind Status = FlCheckForAscii (Info->Handle, Info->Filename, TRUE);
163 1.1 jruoho if (ACPI_FAILURE (Status))
164 1.1 jruoho {
165 1.1 jruoho printf ("Non-ascii input file - %s\n", Info->Filename);
166 1.1.1.2.24.1 rmind
167 1.1.1.2.24.1 rmind if (!Gbl_IgnoreErrors)
168 1.1.1.2.24.1 rmind {
169 1.1.1.2.24.1 rmind Type = ASL_INPUT_TYPE_BINARY;
170 1.1.1.2.24.1 rmind goto Cleanup;
171 1.1.1.2.24.1 rmind }
172 1.1 jruoho }
173 1.1 jruoho
174 1.1 jruoho /*
175 1.1 jruoho * File is ASCII. Determine if this is an ASL file or an ACPI data
176 1.1 jruoho * table file.
177 1.1 jruoho */
178 1.1.1.2.24.1 rmind while (fgets (Gbl_CurrentLineBuffer, Gbl_LineBufferSize, Info->Handle))
179 1.1 jruoho {
180 1.1 jruoho /* Uppercase the buffer for caseless compare */
181 1.1 jruoho
182 1.1 jruoho FileChar = Gbl_CurrentLineBuffer;
183 1.1 jruoho while (*FileChar)
184 1.1 jruoho {
185 1.1 jruoho *FileChar = (char) toupper ((int) *FileChar);
186 1.1 jruoho FileChar++;
187 1.1 jruoho }
188 1.1 jruoho
189 1.1 jruoho /* Presence of "DefinitionBlock" indicates actual ASL code */
190 1.1 jruoho
191 1.1 jruoho if (strstr (Gbl_CurrentLineBuffer, "DEFINITIONBLOCK"))
192 1.1 jruoho {
193 1.1 jruoho /* Appears to be an ASL file */
194 1.1 jruoho
195 1.1 jruoho Type = ASL_INPUT_TYPE_ASCII_ASL;
196 1.1 jruoho goto Cleanup;
197 1.1 jruoho }
198 1.1 jruoho }
199 1.1 jruoho
200 1.1 jruoho /* Not an ASL source file, default to a data table source file */
201 1.1 jruoho
202 1.1 jruoho Type = ASL_INPUT_TYPE_ASCII_DATA;
203 1.1 jruoho
204 1.1 jruoho Cleanup:
205 1.1 jruoho
206 1.1 jruoho /* Must seek back to the start of the file */
207 1.1 jruoho
208 1.1 jruoho fseek (Info->Handle, 0, SEEK_SET);
209 1.1 jruoho return (Type);
210 1.1 jruoho }
211 1.1 jruoho
212 1.1 jruoho
213 1.1 jruoho /*******************************************************************************
214 1.1 jruoho *
215 1.1.1.2.24.1 rmind * FUNCTION: AslDoDisassembly
216 1.1.1.2.24.1 rmind *
217 1.1.1.2.24.1 rmind * PARAMETERS: None
218 1.1.1.2.24.1 rmind *
219 1.1.1.2.24.1 rmind * RETURN: Status
220 1.1.1.2.24.1 rmind *
221 1.1.1.2.24.1 rmind * DESCRIPTION: Initiate AML file disassembly. Uses ACPICA subsystem to build
222 1.1.1.2.24.1 rmind * namespace.
223 1.1.1.2.24.1 rmind *
224 1.1.1.2.24.1 rmind ******************************************************************************/
225 1.1.1.2.24.1 rmind
226 1.1.1.2.24.1 rmind static ACPI_STATUS
227 1.1.1.2.24.1 rmind AslDoDisassembly (
228 1.1.1.2.24.1 rmind void)
229 1.1.1.2.24.1 rmind {
230 1.1.1.2.24.1 rmind ACPI_STATUS Status;
231 1.1.1.2.24.1 rmind
232 1.1.1.2.24.1 rmind
233 1.1.1.2.24.1 rmind /* ACPICA subsystem initialization */
234 1.1.1.2.24.1 rmind
235 1.1.1.2.24.1 rmind Status = AdInitialize ();
236 1.1.1.2.24.1 rmind if (ACPI_FAILURE (Status))
237 1.1.1.2.24.1 rmind {
238 1.1.1.2.24.1 rmind return (Status);
239 1.1.1.2.24.1 rmind }
240 1.1.1.2.24.1 rmind
241 1.1.1.2.24.1 rmind Status = AcpiAllocateRootTable (4);
242 1.1.1.2.24.1 rmind if (ACPI_FAILURE (Status))
243 1.1.1.2.24.1 rmind {
244 1.1.1.2.24.1 rmind AcpiOsPrintf ("Could not initialize ACPI Table Manager, %s\n",
245 1.1.1.2.24.1 rmind AcpiFormatException (Status));
246 1.1.1.2.24.1 rmind return (Status);
247 1.1.1.2.24.1 rmind }
248 1.1.1.2.24.1 rmind
249 1.1.1.2.24.1 rmind /* This is where the disassembly happens */
250 1.1.1.2.24.1 rmind
251 1.1.1.2.24.1 rmind AcpiGbl_DbOpt_disasm = TRUE;
252 1.1.1.2.24.1 rmind Status = AdAmlDisassemble (AslToFile,
253 1.1.1.2.24.1 rmind Gbl_Files[ASL_FILE_INPUT].Filename, Gbl_OutputFilenamePrefix,
254 1.1.1.2.24.1 rmind &Gbl_Files[ASL_FILE_INPUT].Filename, Gbl_GetAllTables);
255 1.1.1.2.24.1 rmind if (ACPI_FAILURE (Status))
256 1.1.1.2.24.1 rmind {
257 1.1.1.2.24.1 rmind return (Status);
258 1.1.1.2.24.1 rmind }
259 1.1.1.2.24.1 rmind
260 1.1.1.2.24.1 rmind /* Check if any control methods were unresolved */
261 1.1.1.2.24.1 rmind
262 1.1.1.2.24.1 rmind AcpiDmUnresolvedWarning (0);
263 1.1.1.2.24.1 rmind
264 1.1.1.2.24.1 rmind #if 0
265 1.1.1.2.24.1 rmind /* TBD: Handle additional output files for disassembler */
266 1.1.1.2.24.1 rmind
267 1.1.1.2.24.1 rmind Status = FlOpenMiscOutputFiles (Gbl_OutputFilenamePrefix);
268 1.1.1.2.24.1 rmind NsDisplayNamespace ();
269 1.1.1.2.24.1 rmind #endif
270 1.1.1.2.24.1 rmind
271 1.1.1.2.24.1 rmind /* Shutdown compiler and ACPICA subsystem */
272 1.1.1.2.24.1 rmind
273 1.1.1.2.24.1 rmind AeClearErrorLog ();
274 1.1.1.2.24.1 rmind (void) AcpiTerminate ();
275 1.1.1.2.24.1 rmind
276 1.1.1.2.24.1 rmind /*
277 1.1.1.2.24.1 rmind * Gbl_Files[ASL_FILE_INPUT].Filename was replaced with the
278 1.1.1.2.24.1 rmind * .DSL disassembly file, which can now be compiled if requested
279 1.1.1.2.24.1 rmind */
280 1.1.1.2.24.1 rmind if (Gbl_DoCompile)
281 1.1.1.2.24.1 rmind {
282 1.1.1.2.24.1 rmind AcpiOsPrintf ("\nCompiling \"%s\"\n",
283 1.1.1.2.24.1 rmind Gbl_Files[ASL_FILE_INPUT].Filename);
284 1.1.1.2.24.1 rmind return (AE_CTRL_CONTINUE);
285 1.1.1.2.24.1 rmind }
286 1.1.1.2.24.1 rmind
287 1.1.1.2.24.1 rmind ACPI_FREE (Gbl_Files[ASL_FILE_INPUT].Filename);
288 1.1.1.2.24.1 rmind Gbl_Files[ASL_FILE_INPUT].Filename = NULL;
289 1.1.1.2.24.1 rmind return (AE_OK);
290 1.1.1.2.24.1 rmind }
291 1.1.1.2.24.1 rmind
292 1.1.1.2.24.1 rmind
293 1.1.1.2.24.1 rmind /*******************************************************************************
294 1.1.1.2.24.1 rmind *
295 1.1 jruoho * FUNCTION: AslDoOneFile
296 1.1 jruoho *
297 1.1 jruoho * PARAMETERS: Filename - Name of the file
298 1.1 jruoho *
299 1.1 jruoho * RETURN: Status
300 1.1 jruoho *
301 1.1 jruoho * DESCRIPTION: Process a single file - either disassemble, compile, or both
302 1.1 jruoho *
303 1.1 jruoho ******************************************************************************/
304 1.1 jruoho
305 1.1 jruoho ACPI_STATUS
306 1.1 jruoho AslDoOneFile (
307 1.1 jruoho char *Filename)
308 1.1 jruoho {
309 1.1 jruoho ACPI_STATUS Status;
310 1.1 jruoho
311 1.1 jruoho
312 1.1.1.2.24.1 rmind /* Re-initialize "some" compiler/preprocessor globals */
313 1.1 jruoho
314 1.1 jruoho AslInitializeGlobals ();
315 1.1.1.2.24.1 rmind PrInitializeGlobals ();
316 1.1 jruoho
317 1.1 jruoho /*
318 1.1.1.2.24.1 rmind * Extract the directory path. This path is used for possible include
319 1.1.1.2.24.1 rmind * files and the optional AML filename embedded in the input file
320 1.1.1.2.24.1 rmind * DefinitionBlock declaration.
321 1.1 jruoho */
322 1.1.1.2.24.1 rmind Status = FlSplitInputPathname (Filename, &Gbl_DirectoryPath, NULL);
323 1.1.1.2.24.1 rmind if (ACPI_FAILURE (Status))
324 1.1 jruoho {
325 1.1.1.2.24.1 rmind return (Status);
326 1.1.1.2.24.1 rmind }
327 1.1 jruoho
328 1.1.1.2.24.1 rmind Gbl_Files[ASL_FILE_INPUT].Filename = Filename;
329 1.1.1.2.24.1 rmind UtConvertBackslashes (Filename);
330 1.1 jruoho
331 1.1.1.2.24.1 rmind /*
332 1.1.1.2.24.1 rmind * AML Disassembly (Optional)
333 1.1.1.2.24.1 rmind */
334 1.1.1.2.24.1 rmind if (Gbl_DisasmFlag || Gbl_GetAllTables)
335 1.1.1.2.24.1 rmind {
336 1.1.1.2.24.1 rmind Status = AslDoDisassembly ();
337 1.1.1.2.24.1 rmind if (Status != AE_CTRL_CONTINUE)
338 1.1 jruoho {
339 1.1 jruoho return (Status);
340 1.1 jruoho }
341 1.1 jruoho }
342 1.1 jruoho
343 1.1 jruoho /*
344 1.1 jruoho * Open the input file. Here, this should be an ASCII source file,
345 1.1 jruoho * either an ASL file or a Data Table file
346 1.1 jruoho */
347 1.1 jruoho Status = FlOpenInputFile (Gbl_Files[ASL_FILE_INPUT].Filename);
348 1.1 jruoho if (ACPI_FAILURE (Status))
349 1.1 jruoho {
350 1.1 jruoho AePrintErrorLog (ASL_FILE_STDERR);
351 1.1 jruoho return (AE_ERROR);
352 1.1 jruoho }
353 1.1 jruoho
354 1.1 jruoho /* Determine input file type */
355 1.1 jruoho
356 1.1 jruoho Gbl_FileType = AslDetectSourceFileType (&Gbl_Files[ASL_FILE_INPUT]);
357 1.1 jruoho if (Gbl_FileType == ASL_INPUT_TYPE_BINARY)
358 1.1 jruoho {
359 1.1 jruoho return (AE_ERROR);
360 1.1 jruoho }
361 1.1 jruoho
362 1.1 jruoho /*
363 1.1 jruoho * If -p not specified, we will use the input filename as the
364 1.1 jruoho * output filename prefix
365 1.1 jruoho */
366 1.1 jruoho if (Gbl_UseDefaultAmlFilename)
367 1.1 jruoho {
368 1.1 jruoho Gbl_OutputFilenamePrefix = Gbl_Files[ASL_FILE_INPUT].Filename;
369 1.1 jruoho }
370 1.1 jruoho
371 1.1 jruoho /* Open the optional output files (listings, etc.) */
372 1.1 jruoho
373 1.1 jruoho Status = FlOpenMiscOutputFiles (Gbl_OutputFilenamePrefix);
374 1.1 jruoho if (ACPI_FAILURE (Status))
375 1.1 jruoho {
376 1.1 jruoho AePrintErrorLog (ASL_FILE_STDERR);
377 1.1 jruoho return (AE_ERROR);
378 1.1 jruoho }
379 1.1 jruoho
380 1.1 jruoho /*
381 1.1 jruoho * Compilation of ASL source versus DataTable source uses different
382 1.1 jruoho * compiler subsystems
383 1.1 jruoho */
384 1.1 jruoho switch (Gbl_FileType)
385 1.1 jruoho {
386 1.1 jruoho /*
387 1.1 jruoho * Data Table Compilation
388 1.1 jruoho */
389 1.1 jruoho case ASL_INPUT_TYPE_ASCII_DATA:
390 1.1 jruoho
391 1.1 jruoho Status = DtDoCompile ();
392 1.1.1.2.24.1 rmind if (ACPI_FAILURE (Status))
393 1.1.1.2.24.1 rmind {
394 1.1.1.2.24.1 rmind return (Status);
395 1.1.1.2.24.1 rmind }
396 1.1 jruoho
397 1.1 jruoho if (Gbl_Signature)
398 1.1 jruoho {
399 1.1 jruoho ACPI_FREE (Gbl_Signature);
400 1.1 jruoho Gbl_Signature = NULL;
401 1.1 jruoho }
402 1.1.1.2.24.1 rmind
403 1.1.1.2.24.1 rmind /* Check if any errors occurred during compile */
404 1.1.1.2.24.1 rmind
405 1.1.1.2.24.1 rmind Status = AslCheckForErrorExit ();
406 1.1.1.2.24.1 rmind if (ACPI_FAILURE (Status))
407 1.1.1.2.24.1 rmind {
408 1.1.1.2.24.1 rmind return (Status);
409 1.1.1.2.24.1 rmind }
410 1.1.1.2.24.1 rmind
411 1.1.1.2.24.1 rmind /* Cleanup (for next source file) and exit */
412 1.1.1.2.24.1 rmind
413 1.1 jruoho AeClearErrorLog ();
414 1.1.1.2.24.1 rmind PrTerminatePreprocessor ();
415 1.1 jruoho return (Status);
416 1.1 jruoho
417 1.1 jruoho /*
418 1.1.1.2.24.1 rmind * ASL Compilation
419 1.1 jruoho */
420 1.1 jruoho case ASL_INPUT_TYPE_ASCII_ASL:
421 1.1 jruoho
422 1.1 jruoho /* ACPICA subsystem initialization */
423 1.1 jruoho
424 1.1 jruoho Status = AdInitialize ();
425 1.1 jruoho if (ACPI_FAILURE (Status))
426 1.1 jruoho {
427 1.1 jruoho return (Status);
428 1.1 jruoho }
429 1.1 jruoho
430 1.1.1.2.24.1 rmind (void) CmDoCompile ();
431 1.1.1.2 jruoho (void) AcpiTerminate ();
432 1.1 jruoho
433 1.1.1.2.24.1 rmind /* Check if any errors occurred during compile */
434 1.1.1.2.24.1 rmind
435 1.1.1.2.24.1 rmind Status = AslCheckForErrorExit ();
436 1.1.1.2.24.1 rmind if (ACPI_FAILURE (Status))
437 1.1 jruoho {
438 1.1.1.2.24.1 rmind return (Status);
439 1.1 jruoho }
440 1.1 jruoho
441 1.1.1.2.24.1 rmind /* Cleanup (for next source file) and exit */
442 1.1.1.2.24.1 rmind
443 1.1 jruoho AeClearErrorLog ();
444 1.1.1.2.24.1 rmind PrTerminatePreprocessor ();
445 1.1 jruoho return (AE_OK);
446 1.1 jruoho
447 1.1.1.2.24.1 rmind /*
448 1.1.1.2.24.1 rmind * Binary ACPI table was auto-detected, disassemble it
449 1.1.1.2.24.1 rmind */
450 1.1.1.2.24.1 rmind case ASL_INPUT_TYPE_ACPI_TABLE:
451 1.1.1.2.24.1 rmind
452 1.1.1.2.24.1 rmind /* We have what appears to be an ACPI table, disassemble it */
453 1.1.1.2.24.1 rmind
454 1.1.1.2.24.1 rmind FlCloseFile (ASL_FILE_INPUT);
455 1.1.1.2.24.1 rmind Gbl_DoCompile = FALSE;
456 1.1.1.2.24.1 rmind Gbl_DisasmFlag = TRUE;
457 1.1.1.2.24.1 rmind Status = AslDoDisassembly ();
458 1.1.1.2.24.1 rmind return (Status);
459 1.1.1.2.24.1 rmind
460 1.1.1.2.24.1 rmind /* Unknown binary table */
461 1.1.1.2.24.1 rmind
462 1.1 jruoho case ASL_INPUT_TYPE_BINARY:
463 1.1 jruoho
464 1.1 jruoho AePrintErrorLog (ASL_FILE_STDERR);
465 1.1 jruoho return (AE_ERROR);
466 1.1 jruoho
467 1.1 jruoho default:
468 1.1.1.2.24.1 rmind
469 1.1 jruoho printf ("Unknown file type %X\n", Gbl_FileType);
470 1.1 jruoho return (AE_ERROR);
471 1.1 jruoho }
472 1.1 jruoho }
473 1.1 jruoho
474 1.1 jruoho
475 1.1 jruoho /*******************************************************************************
476 1.1 jruoho *
477 1.1.1.2.24.1 rmind * FUNCTION: AslCheckForErrorExit
478 1.1 jruoho *
479 1.1.1.2.24.1 rmind * PARAMETERS: None. Examines global exception count array
480 1.1 jruoho *
481 1.1 jruoho * RETURN: Status
482 1.1 jruoho *
483 1.1.1.2.24.1 rmind * DESCRIPTION: Determine if compiler should abort with error status
484 1.1 jruoho *
485 1.1 jruoho ******************************************************************************/
486 1.1 jruoho
487 1.1 jruoho ACPI_STATUS
488 1.1.1.2.24.1 rmind AslCheckForErrorExit (
489 1.1.1.2.24.1 rmind void)
490 1.1 jruoho {
491 1.1 jruoho
492 1.1.1.2.24.1 rmind /*
493 1.1.1.2.24.1 rmind * Return non-zero exit code if there have been errors, unless the
494 1.1.1.2.24.1 rmind * global ignore error flag has been set
495 1.1.1.2.24.1 rmind */
496 1.1.1.2.24.1 rmind if (!Gbl_IgnoreErrors)
497 1.1 jruoho {
498 1.1.1.2.24.1 rmind if (Gbl_ExceptionCount[ASL_ERROR] > 0)
499 1.1 jruoho {
500 1.1.1.2.24.1 rmind return (AE_ERROR);
501 1.1 jruoho }
502 1.1 jruoho
503 1.1.1.2.24.1 rmind /* Optionally treat warnings as errors */
504 1.1 jruoho
505 1.1.1.2.24.1 rmind if (Gbl_WarningsAsErrors)
506 1.1.1.2.24.1 rmind {
507 1.1.1.2.24.1 rmind if ((Gbl_ExceptionCount[ASL_WARNING] > 0) ||
508 1.1.1.2.24.1 rmind (Gbl_ExceptionCount[ASL_WARNING2] > 0) ||
509 1.1.1.2.24.1 rmind (Gbl_ExceptionCount[ASL_WARNING3] > 0))
510 1.1.1.2.24.1 rmind {
511 1.1.1.2.24.1 rmind return (AE_ERROR);
512 1.1.1.2.24.1 rmind }
513 1.1.1.2.24.1 rmind }
514 1.1 jruoho }
515 1.1 jruoho
516 1.1.1.2.24.1 rmind return (AE_OK);
517 1.1 jruoho }
518