Go to most recent revision | Details | 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 - 2010, Intel Corp. |
||
12 | * All rights reserved. |
||
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 | char *FileList[ASL_MAX_FILES]; |
||
127 | int FileCount; |
||
128 | BOOLEAN AslToFile = TRUE; |
||
129 | |||
130 | |||
131 | |||
132 | |||
133 | |||
134 | AslInitializeGlobals ( |
||
135 | void); |
||
136 | |||
137 | |||
138 | AsDoWildcard ( |
||
139 | char *DirectoryPathname, |
||
140 | char *FileSpecifier); |
||
141 | |||
142 | |||
143 | AslDetectSourceFileType ( |
||
144 | ASL_FILE_INFO *Info); |
||
145 | |||
146 | |||
147 | |||
148 | * |
||
149 | * FUNCTION: AslInitializeGlobals |
||
150 | * |
||
151 | * PARAMETERS: None |
||
152 | * |
||
153 | * RETURN: None |
||
154 | * |
||
155 | * DESCRIPTION: Re-initialize globals needed to restart the compiler. This |
||
156 | * allows multiple files to be disassembled and/or compiled. |
||
157 | * |
||
158 | ******************************************************************************/ |
||
159 | |||
160 | |||
161 | AslInitializeGlobals ( |
||
162 | void) |
||
163 | { |
||
164 | UINT32 i; |
||
165 | |||
166 | |||
167 | |||
168 | |||
169 | |||
170 | Gbl_CurrentLineNumber = 1; |
||
171 | Gbl_LogicalLineNumber = 1; |
||
172 | Gbl_CurrentLineOffset = 0; |
||
173 | Gbl_InputFieldCount = 0; |
||
174 | Gbl_LineBufPtr = Gbl_CurrentLineBuffer; |
||
175 | |||
176 | |||
177 | Gbl_NextError = NULL; |
||
178 | Gbl_Signature = NULL; |
||
179 | Gbl_FileType = 0; |
||
180 | |||
181 | |||
182 | for (i = 0; i < ASL_NUM_REPORT_LEVELS; i++) |
||
183 | { |
||
184 | Gbl_ExceptionCount[i] = 0; |
||
185 | } |
||
186 | |||
187 | |||
188 | Gbl_Files[ASL_FILE_AML_OUTPUT].Handle = NULL; |
||
189 | } |
||
190 | |||
191 | |||
192 | |||
193 | * |
||
194 | * FUNCTION: AsDoWildcard |
||
195 | * |
||
196 | * PARAMETERS: None |
||
197 | * |
||
198 | * RETURN: None |
||
199 | * |
||
200 | * DESCRIPTION: Process files via wildcards. This function is for the Windows |
||
201 | * case only. |
||
202 | * |
||
203 | ******************************************************************************/ |
||
204 | |||
205 | |||
206 | AsDoWildcard ( |
||
207 | char *DirectoryPathname, |
||
208 | char *FileSpecifier) |
||
209 | { |
||
210 | #ifdef WIN32 |
||
211 | void *DirInfo; |
||
212 | char *Filename; |
||
213 | |||
214 | |||
215 | |||
216 | |||
217 | |||
218 | |||
219 | |||
220 | if (!DirInfo) |
||
221 | { |
||
222 | /* Either the directory of file does not exist */ |
||
223 | |||
224 | |||
225 | FlFileError (ASL_FILE_INPUT, ASL_MSG_OPEN); |
||
226 | AslAbort (); |
||
227 | } |
||
228 | |||
229 | |||
230 | |||
231 | |||
232 | { |
||
233 | /* Add the filename to the file list */ |
||
234 | |||
235 | |||
236 | strcpy (FileList[FileCount], Filename); |
||
237 | FileCount++; |
||
238 | |||
239 | |||
240 | { |
||
241 | printf ("Max files reached\n"); |
||
242 | FileList[0] = NULL; |
||
243 | return (FileList); |
||
244 | } |
||
245 | } |
||
246 | |||
247 | |||
248 | |||
249 | |||
250 | FileList[FileCount] = NULL; |
||
251 | return (FileList); |
||
252 | |||
253 | |||
254 | /* |
||
255 | * Linux/Unix cases - Wildcards are expanded by the shell automatically. |
||
256 | * Just return the filename in a null terminated list |
||
257 | */ |
||
258 | FileList[0] = AcpiOsAllocate (strlen (FileSpecifier) + 1); |
||
259 | strcpy (FileList[0], FileSpecifier); |
||
260 | FileList[1] = NULL; |
||
261 | |||
262 | |||
263 | #endif |
||
264 | } |
||
265 | |||
266 | |||
267 | |||
268 | * |
||
269 | * FUNCTION: AslDetectSourceFileType |
||
270 | * |
||
271 | * PARAMETERS: Info - Name/Handle for the file (must be open) |
||
272 | * |
||
273 | * RETURN: File Type |
||
274 | * |
||
275 | * DESCRIPTION: Determine the type of the input file. Either binary (contains |
||
276 | * non-ASCII characters), ASL file, or an ACPI Data Table file. |
||
277 | * |
||
278 | ******************************************************************************/ |
||
279 | |||
280 | |||
281 | AslDetectSourceFileType ( |
||
282 | ASL_FILE_INFO *Info) |
||
283 | { |
||
284 | char *FileChar; |
||
285 | UINT8 Type; |
||
286 | ACPI_STATUS Status; |
||
287 | |||
288 | |||
289 | |||
290 | |||
291 | |||
292 | if (ACPI_FAILURE (Status)) |
||
293 | { |
||
294 | printf ("Non-ascii input file - %s\n", Info->Filename); |
||
295 | Type = ASL_INPUT_TYPE_BINARY; |
||
296 | goto Cleanup; |
||
297 | } |
||
298 | |||
299 | |||
300 | * File is ASCII. Determine if this is an ASL file or an ACPI data |
||
301 | * table file. |
||
302 | */ |
||
303 | while (fgets (Gbl_CurrentLineBuffer, ASL_LINE_BUFFER_SIZE, Info->Handle)) |
||
304 | { |
||
305 | /* Uppercase the buffer for caseless compare */ |
||
306 | |||
307 | |||
308 | while (*FileChar) |
||
309 | { |
||
310 | *FileChar = (char) toupper ((int) *FileChar); |
||
311 | FileChar++; |
||
312 | } |
||
313 | |||
314 | |||
315 | |||
316 | |||
317 | { |
||
318 | /* Appears to be an ASL file */ |
||
319 | |||
320 | |||
321 | goto Cleanup; |
||
322 | } |
||
323 | } |
||
324 | |||
325 | |||
326 | |||
327 | |||
328 | |||
329 | |||
330 | |||
331 | |||
332 | |||
333 | |||
334 | return (Type); |
||
335 | } |
||
336 | |||
337 | |||
338 | |||
339 | * |
||
340 | * FUNCTION: AslDoOneFile |
||
341 | * |
||
342 | * PARAMETERS: Filename - Name of the file |
||
343 | * |
||
344 | * RETURN: Status |
||
345 | * |
||
346 | * DESCRIPTION: Process a single file - either disassemble, compile, or both |
||
347 | * |
||
348 | ******************************************************************************/ |
||
349 | |||
350 | |||
351 | AslDoOneFile ( |
||
352 | char *Filename) |
||
353 | { |
||
354 | ACPI_STATUS Status; |
||
355 | |||
356 | |||
357 | |||
358 | |||
359 | |||
360 | |||
361 | |||
362 | |||
363 | |||
364 | * AML Disassembly (Optional) |
||
365 | */ |
||
366 | if (Gbl_DisasmFlag || Gbl_GetAllTables) |
||
367 | { |
||
368 | /* ACPICA subsystem initialization */ |
||
369 | |||
370 | |||
371 | if (ACPI_FAILURE (Status)) |
||
372 | { |
||
373 | return (Status); |
||
374 | } |
||
375 | |||
376 | |||
377 | if (ACPI_FAILURE (Status)) |
||
378 | { |
||
379 | AcpiOsPrintf ("Could not initialize ACPI Table Manager, %s\n", |
||
380 | AcpiFormatException (Status)); |
||
381 | return (Status); |
||
382 | } |
||
383 | |||
384 | |||
385 | |||
386 | |||
387 | Status = AdAmlDisassemble (AslToFile, |
||
388 | Gbl_Files[ASL_FILE_INPUT].Filename, |
||
389 | Gbl_OutputFilenamePrefix, |
||
390 | &Gbl_Files[ASL_FILE_INPUT].Filename, |
||
391 | Gbl_GetAllTables); |
||
392 | if (ACPI_FAILURE (Status)) |
||
393 | { |
||
394 | return (Status); |
||
395 | } |
||
396 | |||
397 | |||
398 | |||
399 | |||
400 | AcpiTerminate (); |
||
401 | |||
402 | |||
403 | * Gbl_Files[ASL_FILE_INPUT].Filename was replaced with the |
||
404 | * .DSL disassembly file, which can now be compiled if requested |
||
405 | */ |
||
406 | if (Gbl_DoCompile) |
||
407 | { |
||
408 | AcpiOsPrintf ("\nCompiling \"%s\"\n", |
||
409 | Gbl_Files[ASL_FILE_INPUT].Filename); |
||
410 | } |
||
411 | else |
||
412 | { |
||
413 | Gbl_Files[ASL_FILE_INPUT].Filename = NULL; |
||
414 | return (AE_OK); |
||
415 | } |
||
416 | } |
||
417 | |||
418 | |||
419 | * Open the input file. Here, this should be an ASCII source file, |
||
420 | * either an ASL file or a Data Table file |
||
421 | */ |
||
422 | Status = FlOpenInputFile (Gbl_Files[ASL_FILE_INPUT].Filename); |
||
423 | if (ACPI_FAILURE (Status)) |
||
424 | { |
||
425 | AePrintErrorLog (ASL_FILE_STDERR); |
||
426 | return (AE_ERROR); |
||
427 | } |
||
428 | |||
429 | |||
430 | |||
431 | |||
432 | if (Gbl_FileType == ASL_INPUT_TYPE_BINARY) |
||
433 | { |
||
434 | return (AE_ERROR); |
||
435 | } |
||
436 | |||
437 | |||
438 | * If -p not specified, we will use the input filename as the |
||
439 | * output filename prefix |
||
440 | */ |
||
441 | if (Gbl_UseDefaultAmlFilename) |
||
442 | { |
||
443 | Gbl_OutputFilenamePrefix = Gbl_Files[ASL_FILE_INPUT].Filename; |
||
444 | } |
||
445 | |||
446 | |||
447 | |||
448 | |||
449 | if (ACPI_FAILURE (Status)) |
||
450 | { |
||
451 | AePrintErrorLog (ASL_FILE_STDERR); |
||
452 | return (AE_ERROR); |
||
453 | } |
||
454 | |||
455 | |||
456 | * Compilation of ASL source versus DataTable source uses different |
||
457 | * compiler subsystems |
||
458 | */ |
||
459 | switch (Gbl_FileType) |
||
460 | { |
||
461 | /* |
||
462 | * Data Table Compilation |
||
463 | */ |
||
464 | case ASL_INPUT_TYPE_ASCII_DATA: |
||
465 | |||
466 | |||
467 | * Require use of command-line option to enable the data table |
||
468 | * compiler -- for now, until development of the compiler is |
||
469 | * complete. |
||
470 | */ |
||
471 | if (!Gbl_DataTableCompilerAvailable) |
||
472 | { |
||
473 | printf ("Data Table Compiler is not available yet\n"); |
||
474 | return (AE_SUPPORT); |
||
475 | } |
||
476 | |||
477 | |||
478 | |||
479 | |||
480 | { |
||
481 | ACPI_FREE (Gbl_Signature); |
||
482 | Gbl_Signature = NULL; |
||
483 | } |
||
484 | AeClearErrorLog (); |
||
485 | return (Status); |
||
486 | |||
487 | |||
488 | * ASL Compilation (Optional) |
||
489 | */ |
||
490 | case ASL_INPUT_TYPE_ASCII_ASL: |
||
491 | |||
492 | |||
493 | |||
494 | |||
495 | |||
496 | if (ACPI_FAILURE (Status)) |
||
497 | { |
||
498 | return (Status); |
||
499 | } |
||
500 | |||
501 | |||
502 | AcpiTerminate (); |
||
503 | |||
504 | |||
505 | * Return non-zero exit code if there have been errors, unless the |
||
506 | * global ignore error flag has been set |
||
507 | */ |
||
508 | if ((Gbl_ExceptionCount[ASL_ERROR] > 0) && (!Gbl_IgnoreErrors)) |
||
509 | { |
||
510 | return (AE_ERROR); |
||
511 | } |
||
512 | |||
513 | |||
514 | return (AE_OK); |
||
515 | |||
516 | |||
517 | |||
518 | |||
519 | return (AE_ERROR); |
||
520 | |||
521 | |||
522 | printf ("Unknown file type %X\n", Gbl_FileType); |
||
523 | return (AE_ERROR); |
||
524 | } |
||
525 | } |
||
526 | |||
527 | |||
528 | |||
529 | * |
||
530 | * FUNCTION: AslDoOnePathname |
||
531 | * |
||
532 | * PARAMETERS: Pathname - Full pathname, possibly with wildcards |
||
533 | * |
||
534 | * RETURN: Status |
||
535 | * |
||
536 | * DESCRIPTION: Process one pathname, possible terminated with a wildcard |
||
537 | * specification. If a wildcard, it is expanded and the multiple |
||
538 | * files are processed. |
||
539 | * |
||
540 | ******************************************************************************/ |
||
541 | |||
542 | |||
543 | AslDoOnePathname ( |
||
544 | char *Pathname) |
||
545 | { |
||
546 | ACPI_STATUS Status = AE_OK; |
||
547 | char **FileList; |
||
548 | char *Filename; |
||
549 | char *FullPathname; |
||
550 | |||
551 | |||
552 | |||
553 | |||
554 | |||
555 | if (ACPI_FAILURE (Status)) |
||
556 | { |
||
557 | return (Status); |
||
558 | } |
||
559 | |||
560 | |||
561 | |||
562 | |||
563 | while (*FileList) |
||
564 | { |
||
565 | FullPathname = ACPI_ALLOCATE ( |
||
566 | strlen (Gbl_DirectoryPath) + strlen (*FileList) + 1); |
||
567 | |||
568 | |||
569 | |||
570 | |||
571 | strcat (FullPathname, *FileList); |
||
572 | |||
573 | |||
574 | * If -p not specified, we will use the input filename as the |
||
575 | * output filename prefix |
||
576 | */ |
||
577 | if (Gbl_UseDefaultAmlFilename) |
||
578 | { |
||
579 | Gbl_OutputFilenamePrefix = FullPathname; |
||
580 | } |
||
581 | |||
582 | |||
583 | |||
584 | |||
585 | |||
586 | |||
587 | ACPI_FREE (*FileList); |
||
588 | *FileList = NULL; |
||
589 | FileList++; |
||
590 | } |
||
591 | |||
592 | |||
593 | ACPI_FREE (Filename); |
||
594 | return (Status); |
||
595 | }> |
||
596 |