Rev 1498 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1498 | serge | 1 | |
2 | * |
||
3 | * Module Name: aslstartup - Compiler startup routines, called from main |
||
4 | * |
||
5 | *****************************************************************************/ |
||
6 | |||
7 | |||
8 | * |
||
9 | * 1. Copyright Notice |
||
10 | * |
||
11 | * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. |
||
2216 | Serge | 12 | * All rights reserved. |
1498 | serge | 13 | * |
14 | * 2. License |
||
15 | * |
||
16 | * 2.1. This is your license from Intel Corp. under its intellectual property |
||
17 | * rights. You may have additional license terms from the party that provided |
||
18 | * you this software, covering your right to use that party's intellectual |
||
19 | * property rights. |
||
20 | * |
||
21 | * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a |
||
22 | * copy of the source code appearing in this file ("Covered Code") an |
||
23 | * irrevocable, perpetual, worldwide license under Intel's copyrights in the |
||
24 | * base code distributed originally by Intel ("Original Intel Code") to copy, |
||
25 | * make derivatives, distribute, use and display any portion of the Covered |
||
26 | * Code in any form, with the right to sublicense such rights; and |
||
27 | * |
||
28 | * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent |
||
29 | * license (with the right to sublicense), under only those claims of Intel |
||
30 | * patents that are infringed by the Original Intel Code, to make, use, sell, |
||
31 | * offer to sell, and import the Covered Code and derivative works thereof |
||
32 | * solely to the minimum extent necessary to exercise the above copyright |
||
33 | * license, and in no event shall the patent license extend to any additions |
||
34 | * to or modifications of the Original Intel Code. No other license or right |
||
35 | * is granted directly or by implication, estoppel or otherwise; |
||
36 | * |
||
37 | * The above copyright and patent license is granted only if the following |
||
38 | * conditions are met: |
||
39 | * |
||
40 | * 3. Conditions |
||
41 | * |
||
42 | * 3.1. Redistribution of Source with Rights to Further Distribute Source. |
||
43 | * Redistribution of source code of any substantial portion of the Covered |
||
44 | * Code or modification with rights to further distribute source must include |
||
45 | * the above Copyright Notice, the above License, this list of Conditions, |
||
46 | * and the following Disclaimer and Export Compliance provision. In addition, |
||
47 | * Licensee must cause all Covered Code to which Licensee contributes to |
||
48 | * contain a file documenting the changes Licensee made to create that Covered |
||
49 | * Code and the date of any change. Licensee must include in that file the |
||
50 | * documentation of any changes made by any predecessor Licensee. Licensee |
||
51 | * must include a prominent statement that the modification is derived, |
||
52 | * directly or indirectly, from Original Intel Code. |
||
53 | * |
||
54 | * 3.2. Redistribution of Source with no Rights to Further Distribute Source. |
||
55 | * Redistribution of source code of any substantial portion of the Covered |
||
56 | * Code or modification without rights to further distribute source must |
||
57 | * include the following Disclaimer and Export Compliance provision in the |
||
58 | * documentation and/or other materials provided with distribution. In |
||
59 | * addition, Licensee may not authorize further sublicense of source of any |
||
60 | * portion of the Covered Code, and must include terms to the effect that the |
||
61 | * license from Licensee to its licensee is limited to the intellectual |
||
62 | * property embodied in the software Licensee provides to its licensee, and |
||
63 | * not to intellectual property embodied in modifications its licensee may |
||
64 | * make. |
||
65 | * |
||
66 | * 3.3. Redistribution of Executable. Redistribution in executable form of any |
||
67 | * substantial portion of the Covered Code or modification must reproduce the |
||
68 | * above Copyright Notice, and the following Disclaimer and Export Compliance |
||
69 | * provision in the documentation and/or other materials provided with the |
||
70 | * distribution. |
||
71 | * |
||
72 | * 3.4. Intel retains all right, title, and interest in and to the Original |
||
73 | * Intel Code. |
||
74 | * |
||
75 | * 3.5. Neither the name Intel nor any other trademark owned or controlled by |
||
76 | * Intel shall be used in advertising or otherwise to promote the sale, use or |
||
77 | * other dealings in products derived from or relating to the Covered Code |
||
78 | * without prior written authorization from Intel. |
||
79 | * |
||
80 | * 4. Disclaimer and Export Compliance |
||
81 | * |
||
82 | * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED |
||
83 | * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE |
||
84 | * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, |
||
85 | * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY |
||
86 | * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY |
||
87 | * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A |
||
88 | * PARTICULAR PURPOSE. |
||
89 | * |
||
90 | * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES |
||
91 | * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR |
||
92 | * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, |
||
93 | * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY |
||
94 | * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL |
||
95 | * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS |
||
96 | * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY |
||
97 | * LIMITED REMEDY. |
||
98 | * |
||
99 | * 4.3. Licensee shall not export, either directly or indirectly, any of this |
||
100 | * software or system incorporating such software without first obtaining any |
||
101 | * required license or other approval from the U. S. Department of Commerce or |
||
102 | * any other agency or department of the United States Government. In the |
||
103 | * event Licensee exports any such software from the United States or |
||
104 | * re-exports any such software from a foreign destination, Licensee shall |
||
105 | * ensure that the distribution and export/re-export of the software is in |
||
106 | * compliance with all laws, regulations, orders, or other restrictions of the |
||
107 | * U.S. Export Administration Regulations. Licensee agrees that neither it nor |
||
108 | * any of its subsidiaries will export/re-export any technical data, process, |
||
109 | * software, or service, directly or indirectly, to any country for which the |
||
110 | * United States government or any agency thereof requires an export license, |
||
111 | * other governmental approval, or letter of assurance, without first obtaining |
||
112 | * such license, approval or letter. |
||
113 | * |
||
114 | *****************************************************************************/ |
||
115 | |||
116 | |||
117 | |||
118 | #include "actables.h" |
||
119 | #include "acapps.h" |
||
120 | |||
121 | |||
122 | ACPI_MODULE_NAME ("aslstartup") |
||
123 | |||
124 | |||
125 | |||
126 | static char *FileList[ASL_MAX_FILES]; |
||
2216 | Serge | 127 | static BOOLEAN AslToFile = TRUE; |
128 | |||
1498 | serge | 129 | |
130 | |||
131 | |||
132 | |||
133 | AsDoWildcard ( |
||
134 | char *DirectoryPathname, |
||
135 | char *FileSpecifier); |
||
136 | |||
137 | |||
2216 | Serge | 138 | AslDetectSourceFileType ( |
1498 | serge | 139 | ASL_FILE_INFO *Info); |
140 | |||
141 | |||
142 | |||
143 | * |
||
144 | * FUNCTION: AslInitializeGlobals |
||
145 | * |
||
146 | * PARAMETERS: None |
||
147 | * |
||
148 | * RETURN: None |
||
149 | * |
||
150 | * DESCRIPTION: Re-initialize globals needed to restart the compiler. This |
||
151 | * allows multiple files to be disassembled and/or compiled. |
||
152 | * |
||
153 | ******************************************************************************/ |
||
154 | |||
155 | |||
2216 | Serge | 156 | AslInitializeGlobals ( |
1498 | serge | 157 | void) |
158 | { |
||
159 | UINT32 i; |
||
160 | |||
161 | |||
162 | |||
163 | |||
164 | |||
165 | Gbl_CurrentLineNumber = 1; |
||
166 | Gbl_LogicalLineNumber = 1; |
||
167 | Gbl_CurrentLineOffset = 0; |
||
168 | Gbl_InputFieldCount = 0; |
||
169 | Gbl_LineBufPtr = Gbl_CurrentLineBuffer; |
||
170 | |||
171 | |||
172 | Gbl_NextError = NULL; |
||
173 | Gbl_Signature = NULL; |
||
174 | Gbl_FileType = 0; |
||
175 | |||
176 | |||
177 | for (i = 0; i < ASL_NUM_REPORT_LEVELS; i++) |
||
178 | { |
||
179 | Gbl_ExceptionCount[i] = 0; |
||
180 | } |
||
181 | |||
182 | |||
183 | Gbl_Files[ASL_FILE_AML_OUTPUT].Handle = NULL; |
||
184 | |||
2216 | Serge | 185 | |
186 | Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Handle = NULL; |
||
187 | } |
||
1498 | serge | 188 | |
189 | |||
190 | |||
191 | * |
||
192 | * FUNCTION: AsDoWildcard |
||
193 | * |
||
194 | * PARAMETERS: None |
||
195 | * |
||
196 | * RETURN: None |
||
197 | * |
||
198 | * DESCRIPTION: Process files via wildcards. This function is for the Windows |
||
199 | * case only. |
||
200 | * |
||
201 | ******************************************************************************/ |
||
202 | |||
203 | |||
204 | AsDoWildcard ( |
||
205 | char *DirectoryPathname, |
||
206 | char *FileSpecifier) |
||
207 | { |
||
208 | #ifdef WIN32 |
||
209 | void *DirInfo; |
||
210 | char *Filename; |
||
211 | int FileCount; |
||
2216 | Serge | 212 | |
1498 | serge | 213 | |
214 | |||
215 | |||
216 | |||
217 | |||
218 | |||
219 | if (!DirInfo) |
||
220 | { |
||
221 | /* Either the directory of file does not exist */ |
||
222 | |||
223 | |||
224 | FlFileError (ASL_FILE_INPUT, ASL_MSG_OPEN); |
||
225 | AslAbort (); |
||
226 | } |
||
227 | |||
228 | |||
229 | |||
230 | |||
231 | { |
||
232 | /* Add the filename to the file list */ |
||
233 | |||
234 | |||
235 | strcpy (FileList[FileCount], Filename); |
||
236 | FileCount++; |
||
237 | |||
238 | |||
239 | { |
||
240 | printf ("Max files reached\n"); |
||
241 | FileList[0] = NULL; |
||
242 | return (FileList); |
||
243 | } |
||
244 | } |
||
245 | |||
246 | |||
247 | |||
248 | |||
249 | FileList[FileCount] = NULL; |
||
250 | return (FileList); |
||
251 | |||
252 | |||
253 | /* |
||
254 | * Linux/Unix cases - Wildcards are expanded by the shell automatically. |
||
255 | * Just return the filename in a null terminated list |
||
256 | */ |
||
257 | FileList[0] = AcpiOsAllocate (strlen (FileSpecifier) + 1); |
||
258 | strcpy (FileList[0], FileSpecifier); |
||
259 | FileList[1] = NULL; |
||
260 | |||
261 | |||
262 | #endif |
||
263 | } |
||
264 | |||
265 | |||
266 | |||
267 | * |
||
268 | * FUNCTION: AslDetectSourceFileType |
||
269 | * |
||
270 | * PARAMETERS: Info - Name/Handle for the file (must be open) |
||
271 | * |
||
272 | * RETURN: File Type |
||
273 | * |
||
274 | * DESCRIPTION: Determine the type of the input file. Either binary (contains |
||
275 | * non-ASCII characters), ASL file, or an ACPI Data Table file. |
||
276 | * |
||
277 | ******************************************************************************/ |
||
278 | |||
279 | |||
2216 | Serge | 280 | AslDetectSourceFileType ( |
1498 | serge | 281 | ASL_FILE_INFO *Info) |
282 | { |
||
283 | char *FileChar; |
||
284 | UINT8 Type; |
||
285 | ACPI_STATUS Status; |
||
286 | |||
287 | |||
288 | |||
289 | |||
290 | |||
291 | if (ACPI_FAILURE (Status)) |
||
292 | { |
||
293 | printf ("Non-ascii input file - %s\n", Info->Filename); |
||
294 | Type = ASL_INPUT_TYPE_BINARY; |
||
295 | goto Cleanup; |
||
296 | } |
||
297 | |||
298 | |||
299 | * File is ASCII. Determine if this is an ASL file or an ACPI data |
||
300 | * table file. |
||
301 | */ |
||
302 | while (fgets (Gbl_CurrentLineBuffer, ASL_LINE_BUFFER_SIZE, Info->Handle)) |
||
303 | { |
||
304 | /* Uppercase the buffer for caseless compare */ |
||
305 | |||
306 | |||
307 | while (*FileChar) |
||
308 | { |
||
309 | *FileChar = (char) toupper ((int) *FileChar); |
||
310 | FileChar++; |
||
311 | } |
||
312 | |||
313 | |||
314 | |||
315 | |||
316 | { |
||
317 | /* Appears to be an ASL file */ |
||
318 | |||
319 | |||
320 | goto Cleanup; |
||
321 | } |
||
322 | } |
||
323 | |||
324 | |||
325 | |||
326 | |||
327 | |||
328 | |||
329 | |||
330 | |||
331 | |||
332 | |||
333 | return (Type); |
||
334 | } |
||
335 | |||
336 | |||
337 | |||
338 | * |
||
339 | * FUNCTION: AslDoOneFile |
||
340 | * |
||
341 | * PARAMETERS: Filename - Name of the file |
||
342 | * |
||
343 | * RETURN: Status |
||
344 | * |
||
345 | * DESCRIPTION: Process a single file - either disassemble, compile, or both |
||
346 | * |
||
347 | ******************************************************************************/ |
||
348 | |||
349 | |||
350 | AslDoOneFile ( |
||
351 | char *Filename) |
||
352 | { |
||
353 | ACPI_STATUS Status; |
||
354 | |||
355 | |||
356 | |||
357 | |||
358 | |||
359 | |||
360 | |||
361 | |||
362 | |||
363 | * AML Disassembly (Optional) |
||
364 | */ |
||
365 | if (Gbl_DisasmFlag || Gbl_GetAllTables) |
||
366 | { |
||
367 | /* ACPICA subsystem initialization */ |
||
368 | |||
369 | |||
370 | if (ACPI_FAILURE (Status)) |
||
371 | { |
||
372 | return (Status); |
||
373 | } |
||
374 | |||
375 | |||
376 | if (ACPI_FAILURE (Status)) |
||
377 | { |
||
378 | AcpiOsPrintf ("Could not initialize ACPI Table Manager, %s\n", |
||
379 | AcpiFormatException (Status)); |
||
380 | return (Status); |
||
381 | } |
||
382 | |||
383 | |||
384 | |||
385 | |||
386 | Status = AdAmlDisassemble (AslToFile, |
||
387 | Gbl_Files[ASL_FILE_INPUT].Filename, |
||
388 | Gbl_OutputFilenamePrefix, |
||
389 | &Gbl_Files[ASL_FILE_INPUT].Filename, |
||
390 | Gbl_GetAllTables); |
||
391 | if (ACPI_FAILURE (Status)) |
||
392 | { |
||
393 | return (Status); |
||
394 | } |
||
395 | |||
396 | |||
397 | |||
398 | |||
399 | (void) AcpiTerminate (); |
||
2216 | Serge | 400 | |
1498 | serge | 401 | |
402 | * Gbl_Files[ASL_FILE_INPUT].Filename was replaced with the |
||
403 | * .DSL disassembly file, which can now be compiled if requested |
||
404 | */ |
||
405 | if (Gbl_DoCompile) |
||
406 | { |
||
407 | AcpiOsPrintf ("\nCompiling \"%s\"\n", |
||
408 | Gbl_Files[ASL_FILE_INPUT].Filename); |
||
409 | } |
||
410 | else |
||
411 | { |
||
412 | Gbl_Files[ASL_FILE_INPUT].Filename = NULL; |
||
413 | return (AE_OK); |
||
414 | } |
||
415 | } |
||
416 | |||
417 | |||
418 | * Open the input file. Here, this should be an ASCII source file, |
||
419 | * either an ASL file or a Data Table file |
||
420 | */ |
||
421 | Status = FlOpenInputFile (Gbl_Files[ASL_FILE_INPUT].Filename); |
||
422 | if (ACPI_FAILURE (Status)) |
||
423 | { |
||
424 | AePrintErrorLog (ASL_FILE_STDERR); |
||
425 | return (AE_ERROR); |
||
426 | } |
||
427 | |||
428 | |||
429 | |||
430 | |||
431 | if (Gbl_FileType == ASL_INPUT_TYPE_BINARY) |
||
432 | { |
||
433 | return (AE_ERROR); |
||
434 | } |
||
435 | |||
436 | |||
437 | * If -p not specified, we will use the input filename as the |
||
438 | * output filename prefix |
||
439 | */ |
||
440 | if (Gbl_UseDefaultAmlFilename) |
||
441 | { |
||
442 | Gbl_OutputFilenamePrefix = Gbl_Files[ASL_FILE_INPUT].Filename; |
||
443 | } |
||
444 | |||
445 | |||
446 | |||
447 | |||
448 | if (ACPI_FAILURE (Status)) |
||
449 | { |
||
450 | AePrintErrorLog (ASL_FILE_STDERR); |
||
451 | return (AE_ERROR); |
||
452 | } |
||
453 | |||
454 | |||
455 | * Compilation of ASL source versus DataTable source uses different |
||
456 | * compiler subsystems |
||
457 | */ |
||
458 | switch (Gbl_FileType) |
||
459 | { |
||
460 | /* |
||
461 | * Data Table Compilation |
||
462 | */ |
||
463 | case ASL_INPUT_TYPE_ASCII_DATA: |
||
464 | |||
465 | |||
466 | |||
467 | |||
468 | { |
||
469 | ACPI_FREE (Gbl_Signature); |
||
470 | Gbl_Signature = NULL; |
||
471 | } |
||
472 | AeClearErrorLog (); |
||
473 | return (Status); |
||
474 | |||
475 | |||
476 | * ASL Compilation (Optional) |
||
477 | */ |
||
478 | case ASL_INPUT_TYPE_ASCII_ASL: |
||
479 | |||
480 | |||
481 | |||
482 | |||
483 | if (ACPI_FAILURE (Status)) |
||
484 | { |
||
485 | return (Status); |
||
486 | } |
||
487 | |||
488 | |||
489 | (void) AcpiTerminate (); |
||
2216 | Serge | 490 | |
1498 | serge | 491 | |
492 | * Return non-zero exit code if there have been errors, unless the |
||
493 | * global ignore error flag has been set |
||
494 | */ |
||
495 | if ((Gbl_ExceptionCount[ASL_ERROR] > 0) && (!Gbl_IgnoreErrors)) |
||
496 | { |
||
497 | return (AE_ERROR); |
||
498 | } |
||
499 | |||
500 | |||
501 | return (AE_OK); |
||
502 | |||
503 | |||
504 | |||
505 | |||
506 | return (AE_ERROR); |
||
507 | |||
508 | |||
509 | printf ("Unknown file type %X\n", Gbl_FileType); |
||
510 | return (AE_ERROR); |
||
511 | } |
||
512 | } |
||
513 | |||
514 | |||
515 | |||
516 | * |
||
517 | * FUNCTION: AslDoOnePathname |
||
518 | * |
||
519 | * PARAMETERS: Pathname - Full pathname, possibly with wildcards |
||
520 | * |
||
521 | * RETURN: Status |
||
522 | * |
||
523 | * DESCRIPTION: Process one pathname, possible terminated with a wildcard |
||
524 | * specification. If a wildcard, it is expanded and the multiple |
||
525 | * files are processed. |
||
526 | * |
||
527 | ******************************************************************************/ |
||
528 | |||
529 | |||
530 | AslDoOnePathname ( |
||
531 | char *Pathname, |
||
2216 | Serge | 532 | ASL_PATHNAME_CALLBACK PathCallback) |
533 | { |
||
1498 | serge | 534 | ACPI_STATUS Status = AE_OK; |
535 | char **WildcardList; |
||
2216 | Serge | 536 | char *Filename; |
1498 | serge | 537 | char *FullPathname; |
538 | |||
539 | |||
540 | |||
541 | |||
542 | |||
543 | if (ACPI_FAILURE (Status)) |
||
544 | { |
||
545 | return (Status); |
||
546 | } |
||
547 | |||
548 | |||
549 | |||
550 | |||
2216 | Serge | 551 | while (*WildcardList) |
552 | { |
||
1498 | serge | 553 | FullPathname = ACPI_ALLOCATE ( |
554 | strlen (Gbl_DirectoryPath) + strlen (*WildcardList) + 1); |
||
2216 | Serge | 555 | |
1498 | serge | 556 | |
557 | |||
558 | |||
559 | strcat (FullPathname, *WildcardList); |
||
2216 | Serge | 560 | |
1498 | serge | 561 | |
562 | * If -p not specified, we will use the input filename as the |
||
563 | * output filename prefix |
||
564 | */ |
||
565 | if (Gbl_UseDefaultAmlFilename) |
||
566 | { |
||
567 | Gbl_OutputFilenamePrefix = FullPathname; |
||
568 | } |
||
569 | |||
570 | |||
571 | |||
572 | |||
2216 | Serge | 573 | |
1498 | serge | 574 | |
575 | ACPI_FREE (*WildcardList); |
||
2216 | Serge | 576 | *WildcardList = NULL; |
577 | WildcardList++; |
||
578 | } |
||
1498 | serge | 579 | |
580 | |||
581 | ACPI_FREE (Filename); |
||
582 | return (Status); |
||
583 | }> |
||
584 |