Rev 1498 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1498 | serge | 1 | |
2 | * |
||
3 | * Module Name: asllisting - Listing file generation |
||
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 "aslcompiler.y.h" |
||
119 | #include "amlcode.h" |
||
120 | #include "acparser.h" |
||
121 | #include "acnamesp.h" |
||
122 | |||
123 | |||
124 | ACPI_MODULE_NAME ("aslisting") |
||
125 | |||
126 | |||
127 | |||
128 | |||
129 | LsDumpAscii ( |
||
130 | UINT32 FileId, |
||
131 | UINT32 Count, |
||
132 | UINT8 *Buffer); |
||
133 | |||
134 | |||
135 | LsDumpAsciiInComment ( |
||
136 | UINT32 FileId, |
||
137 | UINT32 Count, |
||
138 | UINT8 *Buffer); |
||
139 | |||
140 | |||
141 | LsAmlListingWalk ( |
||
142 | ACPI_PARSE_OBJECT *Op, |
||
143 | UINT32 Level, |
||
144 | void *Context); |
||
145 | |||
146 | |||
147 | LsGenerateListing ( |
||
148 | UINT32 FileId); |
||
149 | |||
150 | |||
151 | LsPushNode ( |
||
152 | char *Filename); |
||
153 | |||
154 | |||
155 | LsPopNode ( |
||
156 | void); |
||
157 | |||
158 | |||
159 | LsCheckException ( |
||
160 | UINT32 LineNumber, |
||
161 | UINT32 FileId); |
||
162 | |||
163 | |||
164 | LsFlushListingBuffer ( |
||
165 | UINT32 FileId); |
||
166 | |||
167 | |||
168 | LsWriteListingHexBytes ( |
||
169 | UINT8 *Buffer, |
||
170 | UINT32 Length, |
||
171 | UINT32 FileId); |
||
172 | |||
173 | |||
174 | LsWriteOneSourceLine ( |
||
175 | UINT32 FileId); |
||
176 | |||
177 | |||
178 | LsFinishSourceListing ( |
||
179 | UINT32 FileId); |
||
180 | |||
181 | |||
182 | LsWriteSourceLines ( |
||
183 | UINT32 ToLineNumber, |
||
184 | UINT32 ToLogicalLineNumber, |
||
185 | UINT32 FileId); |
||
186 | |||
187 | |||
188 | LsWriteNodeToListing ( |
||
189 | ACPI_PARSE_OBJECT *Op, |
||
190 | UINT32 FileId); |
||
191 | |||
192 | |||
193 | LsDoHexOutputC ( |
||
194 | void); |
||
195 | |||
196 | |||
197 | LsDoHexOutputAsm ( |
||
198 | void); |
||
199 | |||
200 | |||
201 | LsDoHexOutputAsl ( |
||
202 | void); |
||
203 | |||
204 | |||
2216 | Serge | 205 | LsTreeWriteWalk ( |
1498 | serge | 206 | ACPI_PARSE_OBJECT *Op, |
207 | UINT32 Level, |
||
208 | void *Context); |
||
209 | |||
210 | |||
211 | |||
212 | * |
||
213 | * FUNCTION: LsTreeWriteWalk |
||
214 | * |
||
215 | * PARAMETERS: ASL_WALK_CALLBACK |
||
216 | * |
||
217 | * |
||
218 | * RETURN: None. |
||
219 | * |
||
220 | * DESCRIPTION: Dump entire parse tree, for compiler debug only |
||
221 | * |
||
222 | ******************************************************************************/ |
||
223 | |||
224 | |||
2216 | Serge | 225 | LsTreeWriteWalk ( |
1498 | serge | 226 | ACPI_PARSE_OBJECT *Op, |
227 | UINT32 Level, |
||
228 | void *Context) |
||
229 | { |
||
230 | |||
231 | |||
232 | |||
233 | |||
234 | "%5.5d [%2d]", Op->Asl.LogicalLineNumber, Level); |
||
235 | UtPrintFormattedName (Op->Asl.ParseOpcode, Level); |
||
236 | |||
237 | |||
238 | |||
239 | return (AE_OK); |
||
240 | } |
||
241 | |||
242 | |||
243 | |||
244 | LsDumpParseTree ( |
||
245 | void) |
||
246 | { |
||
247 | |||
248 | |||
249 | { |
||
250 | return; |
||
251 | } |
||
252 | |||
253 | |||
254 | TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, |
||
255 | LsTreeWriteWalk, NULL, NULL); |
||
256 | } |
||
257 | |||
258 | |||
259 | |||
260 | * |
||
261 | * FUNCTION: LsDumpAscii |
||
262 | * |
||
263 | * PARAMETERS: FileId - ID of current listing file |
||
264 | * Count - Number of bytes to convert |
||
265 | * Buffer - Buffer of bytes to convert |
||
266 | * |
||
267 | * RETURN: None. |
||
268 | * |
||
269 | * DESCRIPTION: Convert hex bytes to ascii |
||
270 | * |
||
271 | ******************************************************************************/ |
||
272 | |||
273 | |||
274 | LsDumpAscii ( |
||
275 | UINT32 FileId, |
||
276 | UINT32 Count, |
||
277 | UINT8 *Buffer) |
||
278 | { |
||
279 | UINT8 BufChar; |
||
280 | UINT32 i; |
||
281 | |||
282 | |||
283 | |||
284 | for (i = 0; i < Count; i++) |
||
285 | { |
||
286 | BufChar = Buffer[i]; |
||
287 | if (isprint (BufChar)) |
||
288 | { |
||
289 | FlPrintFile (FileId, "%c", BufChar); |
||
290 | } |
||
291 | else |
||
292 | { |
||
293 | /* Not a printable character, just put out a dot */ |
||
294 | |||
295 | |||
296 | } |
||
297 | } |
||
298 | FlPrintFile (FileId, "\""); |
||
299 | } |
||
300 | |||
301 | |||
302 | |||
303 | * |
||
304 | * FUNCTION: LsDumpAsciiInComment |
||
305 | * |
||
306 | * PARAMETERS: FileId - ID of current listing file |
||
307 | * Count - Number of bytes to convert |
||
308 | * Buffer - Buffer of bytes to convert |
||
309 | * |
||
310 | * RETURN: None. |
||
311 | * |
||
312 | * DESCRIPTION: Convert hex bytes to ascii |
||
313 | * |
||
314 | ******************************************************************************/ |
||
315 | |||
316 | |||
317 | LsDumpAsciiInComment ( |
||
318 | UINT32 FileId, |
||
319 | UINT32 Count, |
||
320 | UINT8 *Buffer) |
||
321 | { |
||
322 | UINT8 BufChar = 0; |
||
323 | UINT8 LastChar; |
||
324 | UINT32 i; |
||
325 | |||
326 | |||
327 | |||
328 | for (i = 0; i < Count; i++) |
||
329 | { |
||
330 | LastChar = BufChar; |
||
331 | BufChar = Buffer[i]; |
||
332 | |||
333 | |||
334 | { |
||
335 | /* Handle embedded C comment sequences */ |
||
336 | |||
337 | |||
338 | ((LastChar == '/') && (BufChar == '*'))) |
||
339 | { |
||
340 | /* Insert a space to break the sequence */ |
||
341 | |||
342 | |||
343 | } |
||
344 | |||
345 | |||
346 | } |
||
347 | else |
||
348 | { |
||
349 | /* Not a printable character, just put out a dot */ |
||
350 | |||
351 | |||
352 | } |
||
353 | } |
||
354 | FlPrintFile (FileId, "\""); |
||
355 | } |
||
356 | |||
357 | |||
358 | |||
359 | * |
||
360 | * FUNCTION: LsAmlListingWalk |
||
361 | * |
||
362 | * PARAMETERS: ASL_WALK_CALLBACK |
||
363 | * |
||
364 | * RETURN: Status |
||
365 | * |
||
366 | * DESCRIPTION: Process one node during a listing file generation. |
||
367 | * |
||
368 | ******************************************************************************/ |
||
369 | |||
370 | |||
371 | LsAmlListingWalk ( |
||
372 | ACPI_PARSE_OBJECT *Op, |
||
373 | UINT32 Level, |
||
374 | void *Context) |
||
375 | { |
||
376 | UINT8 FileByte; |
||
377 | UINT32 i; |
||
378 | UINT32 FileId = (UINT32) ACPI_TO_INTEGER (Context); |
||
379 | |||
380 | |||
381 | |||
382 | |||
383 | |||
384 | { |
||
385 | /* Buffer is a resource template, don't dump the data all at once */ |
||
386 | |||
387 | |||
388 | } |
||
389 | |||
390 | |||
391 | |||
392 | |||
393 | { |
||
394 | if (ACPI_FAILURE (FlReadFile (ASL_FILE_AML_OUTPUT, &FileByte, 1))) |
||
395 | { |
||
396 | FlFileError (ASL_FILE_AML_OUTPUT, ASL_MSG_READ); |
||
397 | AslAbort (); |
||
398 | } |
||
399 | LsWriteListingHexBytes (&FileByte, 1, FileId); |
||
400 | } |
||
401 | |||
402 | |||
403 | } |
||
404 | |||
405 | |||
406 | |||
407 | * |
||
408 | * FUNCTION: LsGenerateListing |
||
409 | * |
||
410 | * PARAMETERS: FileId - ID of listing file |
||
411 | * |
||
412 | * RETURN: None |
||
413 | * |
||
414 | * DESCRIPTION: Generate a listing file. This can be one of the several types |
||
415 | * of "listings" supported. |
||
416 | * |
||
417 | ******************************************************************************/ |
||
418 | |||
419 | |||
420 | LsGenerateListing ( |
||
421 | UINT32 FileId) |
||
422 | { |
||
423 | |||
424 | |||
425 | |||
426 | |||
427 | FlSeekFile (ASL_FILE_AML_OUTPUT, 0); |
||
428 | Gbl_SourceLine = 0; |
||
429 | Gbl_CurrentHexColumn = 0; |
||
430 | LsPushNode (Gbl_Files[ASL_FILE_INPUT].Filename); |
||
431 | |||
432 | |||
433 | |||
434 | |||
435 | NULL, (void *) ACPI_TO_POINTER (FileId)); |
||
436 | |||
437 | |||
438 | |||
439 | |||
440 | } |
||
441 | |||
442 | |||
443 | |||
444 | * |
||
445 | * FUNCTION: LsDoListings |
||
446 | * |
||
447 | * PARAMETERS: None. |
||
448 | * |
||
449 | * RETURN: None |
||
450 | * |
||
451 | * DESCRIPTION: Generate all requested listing files. |
||
452 | * |
||
453 | ******************************************************************************/ |
||
454 | |||
455 | |||
456 | LsDoListings ( |
||
457 | void) |
||
458 | { |
||
459 | |||
460 | |||
461 | { |
||
462 | LsGenerateListing (ASL_FILE_C_SOURCE_OUTPUT); |
||
463 | } |
||
464 | |||
465 | |||
466 | { |
||
467 | LsGenerateListing (ASL_FILE_LISTING_OUTPUT); |
||
468 | } |
||
469 | |||
470 | |||
471 | { |
||
472 | LsGenerateListing (ASL_FILE_ASM_SOURCE_OUTPUT); |
||
473 | } |
||
474 | |||
475 | |||
476 | { |
||
477 | LsGenerateListing (ASL_FILE_C_INCLUDE_OUTPUT); |
||
478 | } |
||
479 | |||
480 | |||
481 | { |
||
482 | LsGenerateListing (ASL_FILE_ASM_INCLUDE_OUTPUT); |
||
483 | } |
||
484 | } |
||
485 | |||
486 | |||
487 | |||
488 | * |
||
489 | * FUNCTION: LsPushNode |
||
490 | * |
||
491 | * PARAMETERS: Filename - Pointer to the include filename |
||
492 | * |
||
493 | * RETURN: None |
||
494 | * |
||
495 | * DESCRIPTION: Push a listing node on the listing/include file stack. This |
||
496 | * stack enables tracking of include files (infinitely nested) |
||
497 | * and resumption of the listing of the parent file when the |
||
498 | * include file is finished. |
||
499 | * |
||
500 | ******************************************************************************/ |
||
501 | |||
502 | |||
503 | LsPushNode ( |
||
504 | char *Filename) |
||
505 | { |
||
506 | ASL_LISTING_NODE *Lnode; |
||
507 | |||
508 | |||
509 | |||
510 | |||
511 | |||
512 | |||
513 | |||
514 | |||
515 | |||
516 | Lnode->LineNumber = 0; |
||
517 | |||
518 | |||
519 | |||
520 | |||
521 | Gbl_ListingNode = Lnode; |
||
522 | } |
||
523 | |||
524 | |||
525 | |||
526 | * |
||
527 | * FUNCTION: LsPopNode |
||
528 | * |
||
529 | * PARAMETERS: None |
||
530 | * |
||
531 | * RETURN: List head after current head is popped off |
||
532 | * |
||
533 | * DESCRIPTION: Pop the current head of the list, free it, and return the |
||
534 | * next node on the stack (the new current node). |
||
535 | * |
||
536 | ******************************************************************************/ |
||
537 | |||
538 | |||
539 | LsPopNode ( |
||
540 | void) |
||
541 | { |
||
542 | ASL_LISTING_NODE *Lnode; |
||
543 | |||
544 | |||
545 | |||
546 | |||
547 | |||
548 | if ((!Lnode) || |
||
549 | (!Lnode->Next)) |
||
550 | { |
||
551 | AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, NULL, |
||
552 | "Could not pop empty listing stack"); |
||
553 | return Gbl_ListingNode; |
||
554 | } |
||
555 | |||
556 | |||
557 | ACPI_FREE (Lnode); |
||
558 | |||
559 | |||
560 | |||
561 | |||
562 | } |
||
563 | |||
564 | |||
565 | |||
566 | * |
||
567 | * FUNCTION: LsCheckException |
||
568 | * |
||
569 | * PARAMETERS: LineNumber - Current logical (cumulative) line # |
||
570 | * FileId - ID of output listing file |
||
571 | * |
||
572 | * RETURN: None |
||
573 | * |
||
574 | * DESCRIPTION: Check if there is an exception for this line, and if there is, |
||
575 | * put it in the listing immediately. Handles multiple errors |
||
576 | * per line. Gbl_NextError points to the next error in the |
||
577 | * sorted (by line #) list of compile errors/warnings. |
||
578 | * |
||
579 | ******************************************************************************/ |
||
580 | |||
581 | |||
582 | LsCheckException ( |
||
583 | UINT32 LineNumber, |
||
584 | UINT32 FileId) |
||
585 | { |
||
586 | |||
587 | |||
588 | (LineNumber < Gbl_NextError->LogicalLineNumber )) |
||
589 | { |
||
590 | return; |
||
591 | } |
||
592 | |||
593 | |||
594 | |||
595 | |||
596 | { |
||
597 | while (Gbl_NextError && |
||
598 | (LineNumber >= Gbl_NextError->LogicalLineNumber)) |
||
599 | { |
||
600 | AePrintException (FileId, Gbl_NextError, "\n[****iasl****]\n"); |
||
601 | |||
602 | |||
603 | } |
||
604 | |||
605 | |||
606 | } |
||
607 | } |
||
608 | |||
609 | |||
610 | |||
611 | * |
||
612 | * FUNCTION: LsFlushListingBuffer |
||
613 | * |
||
614 | * PARAMETERS: FileId - ID of the listing file |
||
615 | * |
||
616 | * RETURN: None |
||
617 | * |
||
618 | * DESCRIPTION: Flush out the current contents of the 16-byte hex AML code |
||
619 | * buffer. Usually called at the termination of a single line |
||
620 | * of source code or when the buffer is full. |
||
621 | * |
||
622 | ******************************************************************************/ |
||
623 | |||
624 | |||
625 | LsFlushListingBuffer ( |
||
626 | UINT32 FileId) |
||
627 | { |
||
628 | UINT32 i; |
||
629 | |||
630 | |||
631 | |||
632 | { |
||
633 | return; |
||
634 | } |
||
635 | |||
636 | |||
637 | |||
638 | |||
639 | { |
||
640 | case ASL_FILE_LISTING_OUTPUT: |
||
641 | |||
642 | |||
643 | { |
||
644 | FlPrintFile (FileId, "%2.2X ", Gbl_AmlBuffer[i]); |
||
645 | } |
||
646 | |||
647 | |||
648 | { |
||
649 | FlWriteFile (FileId, ".", 1); |
||
650 | } |
||
651 | |||
652 | |||
653 | |||
654 | |||
655 | break; |
||
656 | |||
657 | |||
658 | |||
659 | |||
660 | |||
661 | { |
||
662 | if (i > 0) |
||
663 | { |
||
664 | FlPrintFile (FileId, ","); |
||
665 | } |
||
666 | FlPrintFile (FileId, "0%2.2Xh", Gbl_AmlBuffer[i]); |
||
667 | } |
||
668 | |||
669 | |||
670 | { |
||
671 | FlWriteFile (FileId, " ", 1); |
||
672 | } |
||
673 | |||
674 | |||
675 | Gbl_CurrentAmlOffset - HEX_LISTING_LINE_SIZE); |
||
676 | |||
677 | |||
678 | |||
679 | |||
680 | break; |
||
681 | |||
682 | |||
683 | |||
684 | |||
685 | |||
686 | { |
||
687 | FlPrintFile (FileId, "0x%2.2X,", Gbl_AmlBuffer[i]); |
||
688 | } |
||
689 | |||
690 | |||
691 | { |
||
692 | FlWriteFile (FileId, " ", 1); |
||
693 | } |
||
694 | |||
695 | |||
696 | Gbl_CurrentAmlOffset - HEX_LISTING_LINE_SIZE); |
||
697 | |||
698 | |||
699 | |||
700 | |||
701 | FlPrintFile (FileId, " */"); |
||
702 | break; |
||
703 | |||
704 | |||
705 | /* No other types supported */ |
||
706 | return; |
||
707 | } |
||
708 | |||
709 | |||
710 | |||
711 | |||
712 | Gbl_HexBytesWereWritten = TRUE; |
||
713 | } |
||
714 | |||
715 | |||
716 | |||
717 | * |
||
718 | * FUNCTION: LsWriteListingHexBytes |
||
719 | * |
||
720 | * PARAMETERS: Buffer - AML code buffer |
||
721 | * Length - Number of AML bytes to write |
||
722 | * FileId - ID of current listing file. |
||
723 | * |
||
724 | * RETURN: None |
||
725 | * |
||
726 | * DESCRIPTION: Write the contents of the AML buffer to the listing file via |
||
727 | * the listing buffer. The listing buffer is flushed every 16 |
||
728 | * AML bytes. |
||
729 | * |
||
730 | ******************************************************************************/ |
||
731 | |||
732 | |||
733 | LsWriteListingHexBytes ( |
||
734 | UINT8 *Buffer, |
||
735 | UINT32 Length, |
||
736 | UINT32 FileId) |
||
737 | { |
||
738 | UINT32 i; |
||
739 | |||
740 | |||
741 | |||
742 | |||
743 | |||
744 | { |
||
745 | /* Print line header when buffer is empty */ |
||
746 | |||
747 | |||
748 | { |
||
749 | if (Gbl_HasIncludeFiles) |
||
750 | { |
||
751 | FlPrintFile (FileId, "%*s", 10, " "); |
||
752 | } |
||
753 | |||
754 | |||
755 | { |
||
756 | case ASL_FILE_LISTING_OUTPUT: |
||
757 | |||
758 | |||
759 | break; |
||
760 | |||
761 | |||
762 | |||
763 | |||
764 | break; |
||
765 | |||
766 | |||
767 | |||
768 | |||
769 | break; |
||
770 | |||
771 | |||
772 | /* No other types supported */ |
||
773 | return; |
||
774 | } |
||
775 | } |
||
776 | |||
777 | |||
778 | |||
779 | |||
780 | |||
781 | |||
782 | Gbl_CurrentAmlOffset++; |
||
783 | |||
784 | |||
785 | |||
786 | |||
787 | { |
||
788 | LsFlushListingBuffer (FileId); |
||
789 | } |
||
790 | } |
||
791 | } |
||
792 | |||
793 | |||
794 | |||
795 | * |
||
796 | * FUNCTION: LsWriteOneSourceLine |
||
797 | * |
||
798 | * PARAMETERS: FileID - ID of current listing file |
||
799 | * |
||
800 | * RETURN: FALSE on EOF (input source file), TRUE otherwise |
||
801 | * |
||
802 | * DESCRIPTION: Read one line from the input source file and echo it to the |
||
803 | * listing file, prefixed with the line number, and if the source |
||
804 | * file contains include files, prefixed with the current filename |
||
805 | * |
||
806 | ******************************************************************************/ |
||
807 | |||
808 | |||
809 | LsWriteOneSourceLine ( |
||
810 | UINT32 FileId) |
||
811 | { |
||
812 | UINT8 FileByte; |
||
813 | |||
814 | |||
815 | |||
816 | Gbl_ListingNode->LineNumber++; |
||
817 | |||
818 | |||
819 | { |
||
820 | FlPrintFile (FileId, " *"); |
||
821 | } |
||
822 | if (FileId == ASL_FILE_ASM_SOURCE_OUTPUT) |
||
823 | { |
||
824 | FlPrintFile (FileId, "; "); |
||
825 | } |
||
826 | |||
827 | |||
828 | { |
||
829 | /* |
||
830 | * This file contains "include" statements, print the current |
||
831 | * filename and line number within the current file |
||
832 | */ |
||
833 | FlPrintFile (FileId, "%12s %5d....", |
||
834 | Gbl_ListingNode->Filename, Gbl_ListingNode->LineNumber); |
||
835 | } |
||
836 | else |
||
837 | { |
||
838 | /* No include files, just print the line number */ |
||
839 | |||
840 | |||
841 | } |
||
842 | |||
843 | |||
844 | |||
845 | |||
846 | { |
||
847 | if (FileId == ASL_FILE_C_SOURCE_OUTPUT) |
||
848 | { |
||
849 | if (FileByte == '/') |
||
850 | { |
||
851 | FileByte = '*'; |
||
852 | } |
||
853 | } |
||
854 | |||
855 | |||
856 | if (FileByte == '\n') |
||
857 | { |
||
858 | /* |
||
859 | * Check if an error occurred on this source line during the compile. |
||
860 | * If so, we print the error message after the source line. |
||
861 | */ |
||
862 | LsCheckException (Gbl_SourceLine, FileId); |
||
863 | return (1); |
||
864 | } |
||
865 | } |
||
866 | |||
867 | |||
868 | |||
869 | |||
870 | } |
||
871 | |||
872 | |||
873 | |||
874 | * |
||
875 | * FUNCTION: LsFinishSourceListing |
||
876 | * |
||
877 | * PARAMETERS: FileId - ID of current listing file. |
||
878 | * |
||
879 | * RETURN: None |
||
880 | * |
||
881 | * DESCRIPTION: Cleanup routine for the listing file. Flush the hex AML |
||
882 | * listing buffer, and flush out any remaining lines in the |
||
883 | * source input file. |
||
884 | * |
||
885 | ******************************************************************************/ |
||
886 | |||
887 | |||
888 | LsFinishSourceListing ( |
||
889 | UINT32 FileId) |
||
890 | { |
||
891 | |||
892 | |||
893 | (FileId == ASL_FILE_C_INCLUDE_OUTPUT)) |
||
894 | { |
||
895 | return; |
||
896 | } |
||
897 | |||
898 | |||
899 | Gbl_CurrentAmlOffset = 0; |
||
900 | |||
901 | |||
902 | |||
903 | |||
904 | { |
||
905 | FlPrintFile (FileId, " /*\n"); |
||
906 | } |
||
907 | |||
908 | |||
909 | { ; } |
||
910 | |||
911 | |||
912 | { |
||
913 | FlPrintFile (FileId, "\n */\n };\n"); |
||
914 | } |
||
915 | |||
916 | |||
917 | |||
918 | |||
919 | { |
||
920 | /* Print a summary of the compile exceptions */ |
||
921 | |||
922 | |||
923 | AePrintErrorLog (FileId); |
||
924 | FlPrintFile (FileId, "\n\n"); |
||
925 | UtDisplaySummary (FileId); |
||
926 | FlPrintFile (FileId, "\n\n"); |
||
927 | } |
||
928 | } |
||
929 | |||
930 | |||
931 | |||
932 | * |
||
933 | * FUNCTION: LsWriteSourceLines |
||
934 | * |
||
935 | * PARAMETERS: ToLineNumber - |
||
936 | * ToLogicalLineNumber - Write up to this source line number |
||
937 | * FileId - ID of current listing file |
||
938 | * |
||
939 | * RETURN: None |
||
940 | * |
||
941 | * DESCRIPTION: Read then write source lines to the listing file until we have |
||
942 | * reached the specified logical (cumulative) line number. This |
||
943 | * automatically echos out comment blocks and other non-AML |
||
944 | * generating text until we get to the actual AML-generating line |
||
945 | * of ASL code specified by the logical line number. |
||
946 | * |
||
947 | ******************************************************************************/ |
||
948 | |||
949 | |||
950 | LsWriteSourceLines ( |
||
951 | UINT32 ToLineNumber, |
||
952 | UINT32 ToLogicalLineNumber, |
||
953 | UINT32 FileId) |
||
954 | { |
||
955 | |||
956 | |||
957 | (FileId == ASL_FILE_C_INCLUDE_OUTPUT)) |
||
958 | { |
||
959 | return; |
||
960 | } |
||
961 | |||
962 | |||
963 | |||
964 | |||
965 | |||
966 | |||
967 | |||
968 | |||
969 | |||
970 | |||
971 | { |
||
972 | /* |
||
973 | * If we just completed writing some AML hex bytes, output a linefeed |
||
974 | * to add some whitespace for readability. |
||
975 | */ |
||
976 | if (Gbl_HexBytesWereWritten) |
||
977 | { |
||
978 | FlPrintFile (FileId, "\n"); |
||
979 | Gbl_HexBytesWereWritten = FALSE; |
||
980 | } |
||
981 | |||
982 | |||
983 | { |
||
984 | FlPrintFile (FileId, " /*\n"); |
||
985 | } |
||
986 | |||
987 | |||
988 | |||
989 | |||
990 | LsWriteOneSourceLine (FileId)) |
||
991 | { ; } |
||
992 | |||
993 | |||
994 | { |
||
995 | FlPrintFile (FileId, " */"); |
||
996 | } |
||
997 | FlPrintFile (FileId, "\n"); |
||
998 | } |
||
999 | } |
||
1000 | |||
1001 | |||
1002 | |||
1003 | * |
||
1004 | * FUNCTION: LsWriteNodeToListing |
||
1005 | * |
||
1006 | * PARAMETERS: Op - Parse node to write to the listing file. |
||
1007 | * FileId - ID of current listing file |
||
1008 | * |
||
1009 | * RETURN: None. |
||
1010 | * |
||
1011 | * DESCRIPTION: Write "a node" to the listing file. This means to |
||
1012 | * 1) Write out all of the source text associated with the node |
||
1013 | * 2) Write out all of the AML bytes associated with the node |
||
1014 | * 3) Write any compiler exceptions associated with the node |
||
1015 | * |
||
1016 | ******************************************************************************/ |
||
1017 | |||
1018 | |||
1019 | LsWriteNodeToListing ( |
||
1020 | ACPI_PARSE_OBJECT *Op, |
||
1021 | UINT32 FileId) |
||
1022 | { |
||
1023 | const ACPI_OPCODE_INFO *OpInfo; |
||
1024 | UINT32 OpClass; |
||
1025 | char *Pathname; |
||
1026 | UINT32 Length; |
||
1027 | UINT32 i; |
||
1028 | |||
1029 | |||
1030 | |||
1031 | OpClass = OpInfo->Class; |
||
1032 | |||
1033 | |||
1034 | * I start a named output block |
||
1035 | */ |
||
1036 | if (FileId == ASL_FILE_C_SOURCE_OUTPUT) |
||
1037 | { |
||
1038 | switch (Op->Asl.ParseOpcode) |
||
1039 | { |
||
1040 | case PARSEOP_DEFINITIONBLOCK: |
||
1041 | case PARSEOP_METHODCALL: |
||
1042 | case PARSEOP_INCLUDE: |
||
1043 | case PARSEOP_INCLUDE_END: |
||
1044 | case PARSEOP_DEFAULT_ARG: |
||
1045 | |||
1046 | |||
1047 | |||
1048 | |||
1049 | switch (OpClass) |
||
1050 | { |
||
1051 | case AML_CLASS_NAMED_OBJECT: |
||
1052 | switch (Op->Asl.AmlOpcode) |
||
1053 | { |
||
1054 | case AML_SCOPE_OP: |
||
1055 | case AML_ALIAS_OP: |
||
1056 | break; |
||
1057 | |||
1058 | |||
1059 | if (Op->Asl.ExternalName) |
||
1060 | { |
||
1061 | LsFlushListingBuffer (FileId); |
||
1062 | FlPrintFile (FileId, " };\n"); |
||
1063 | } |
||
1064 | break; |
||
1065 | } |
||
1066 | break; |
||
1067 | |||
1068 | |||
1069 | /* Don't care about other objects */ |
||
1070 | break; |
||
1071 | } |
||
1072 | break; |
||
1073 | } |
||
1074 | } |
||
1075 | |||
1076 | |||
1077 | |||
1078 | |||
1079 | { |
||
1080 | case PARSEOP_DEFINITIONBLOCK: |
||
1081 | |||
1082 | |||
1083 | |||
1084 | |||
1085 | |||
1086 | |||
1087 | { |
||
1088 | FlPrintFile (FileId, |
||
1089 | "%s_%s_Header \\\n", |
||
1090 | Gbl_TableSignature, Gbl_TableId); |
||
1091 | } |
||
1092 | if (FileId == ASL_FILE_C_SOURCE_OUTPUT) |
||
1093 | { |
||
1094 | FlPrintFile (FileId, |
||
1095 | " unsigned char %s_%s_Header [] =\n {\n", |
||
1096 | Gbl_TableSignature, Gbl_TableId); |
||
1097 | } |
||
1098 | if (FileId == ASL_FILE_ASM_INCLUDE_OUTPUT) |
||
1099 | { |
||
1100 | FlPrintFile (FileId, |
||
1101 | "extrn %s_%s_Header : byte\n", |
||
1102 | Gbl_TableSignature, Gbl_TableId); |
||
1103 | } |
||
1104 | if (FileId == ASL_FILE_C_INCLUDE_OUTPUT) |
||
1105 | { |
||
1106 | FlPrintFile (FileId, |
||
1107 | "extern unsigned char %s_%s_Header [];\n", |
||
1108 | Gbl_TableSignature, Gbl_TableId); |
||
1109 | } |
||
1110 | return; |
||
1111 | |||
1112 | |||
1113 | |||
1114 | |||
1115 | |||
1116 | FileId); |
||
1117 | return; |
||
1118 | |||
1119 | |||
1120 | |||
1121 | |||
1122 | |||
1123 | |||
1124 | |||
1125 | FileId); |
||
1126 | |||
1127 | |||
1128 | |||
1129 | |||
1130 | return; |
||
1131 | |||
1132 | |||
1133 | |||
1134 | |||
1135 | |||
1136 | |||
1137 | |||
1138 | FileId); |
||
1139 | |||
1140 | |||
1141 | |||
1142 | |||
1143 | return; |
||
1144 | |||
1145 | |||
1146 | |||
1147 | |||
1148 | |||
1149 | { |
||
1150 | LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.EndLogicalLine, |
||
1151 | FileId); |
||
1152 | } |
||
1153 | return; |
||
1154 | |||
1155 | |||
1156 | |||
1157 | /* All other opcodes have an AML opcode */ |
||
1158 | break; |
||
1159 | } |
||
1160 | |||
1161 | |||
1162 | * Otherwise, we look at the AML opcode because we can |
||
1163 | * switch on the opcode type, getting an entire class |
||
1164 | * at once |
||
1165 | */ |
||
1166 | switch (OpClass) |
||
1167 | { |
||
1168 | case AML_CLASS_ARGUMENT: /* argument type only */ |
||
1169 | case AML_CLASS_INTERNAL: |
||
1170 | |||
1171 | |||
1172 | |||
1173 | |||
1174 | |||
1175 | |||
1176 | |||
1177 | { |
||
1178 | case AML_FIELD_OP: |
||
1179 | case AML_INDEX_FIELD_OP: |
||
1180 | case AML_BANK_FIELD_OP: |
||
1181 | |||
1182 | |||
1183 | * For fields, we want to dump all the AML after the |
||
1184 | * entire definition |
||
1185 | */ |
||
1186 | LsWriteSourceLines (Op->Asl.EndLine, Op->Asl.EndLogicalLine, |
||
1187 | FileId); |
||
1188 | break; |
||
1189 | |||
1190 | |||
1191 | |||
1192 | |||
1193 | { |
||
1194 | LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber, |
||
1195 | FileId); |
||
1196 | } |
||
1197 | else |
||
1198 | { |
||
1199 | /* |
||
1200 | * For fields, we want to dump all the AML after the |
||
1201 | * entire definition |
||
1202 | */ |
||
1203 | LsWriteSourceLines (Op->Asl.EndLine, Op->Asl.EndLogicalLine, |
||
1204 | FileId); |
||
1205 | } |
||
1206 | break; |
||
1207 | |||
1208 | |||
1209 | LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber, |
||
1210 | FileId); |
||
1211 | break; |
||
1212 | } |
||
1213 | |||
1214 | |||
1215 | { |
||
1216 | case AML_SCOPE_OP: |
||
1217 | case AML_ALIAS_OP: |
||
1218 | |||
1219 | |||
1220 | |||
1221 | |||
1222 | |||
1223 | |||
1224 | |||
1225 | |||
1226 | |||
1227 | |||
1228 | { |
||
1229 | case ASL_FILE_ASM_SOURCE_OUTPUT: |
||
1230 | case ASL_FILE_C_SOURCE_OUTPUT: |
||
1231 | case ASL_FILE_ASM_INCLUDE_OUTPUT: |
||
1232 | case ASL_FILE_C_INCLUDE_OUTPUT: |
||
1233 | |||
1234 | |||
1235 | * For named objects, we will create a valid symbol so that the |
||
1236 | * AML code can be referenced from C or ASM |
||
1237 | */ |
||
1238 | if (Op->Asl.ExternalName) |
||
1239 | { |
||
1240 | /* Get the full pathname associated with this node */ |
||
1241 | |||
1242 | |||
1243 | Length = strlen (Pathname); |
||
1244 | if (Length >= 4) |
||
1245 | { |
||
1246 | /* Convert all dots in the path to underscores */ |
||
1247 | |||
1248 | |||
1249 | { |
||
1250 | if (Pathname[i] == '.') |
||
1251 | { |
||
1252 | Pathname[i] = '_'; |
||
1253 | } |
||
1254 | } |
||
1255 | |||
1256 | |||
1257 | |||
1258 | |||
1259 | { |
||
1260 | FlPrintFile (FileId, |
||
1261 | "%s_%s_%s \\\n", |
||
1262 | Gbl_TableSignature, Gbl_TableId, &Pathname[1]); |
||
1263 | } |
||
1264 | if (FileId == ASL_FILE_C_SOURCE_OUTPUT) |
||
1265 | { |
||
1266 | FlPrintFile (FileId, |
||
1267 | " unsigned char %s_%s_%s [] =\n {\n", |
||
1268 | Gbl_TableSignature, Gbl_TableId, &Pathname[1]); |
||
1269 | } |
||
1270 | if (FileId == ASL_FILE_ASM_INCLUDE_OUTPUT) |
||
1271 | { |
||
1272 | FlPrintFile (FileId, |
||
1273 | "extrn %s_%s_%s : byte\n", |
||
1274 | Gbl_TableSignature, Gbl_TableId, &Pathname[1]); |
||
1275 | } |
||
1276 | if (FileId == ASL_FILE_C_INCLUDE_OUTPUT) |
||
1277 | { |
||
1278 | FlPrintFile (FileId, |
||
1279 | "extern unsigned char %s_%s_%s [];\n", |
||
1280 | Gbl_TableSignature, Gbl_TableId, &Pathname[1]); |
||
1281 | } |
||
1282 | } |
||
1283 | ACPI_FREE (Pathname); |
||
1284 | } |
||
1285 | break; |
||
1286 | |||
1287 | |||
1288 | /* Nothing to do for listing file */ |
||
1289 | break; |
||
1290 | } |
||
1291 | } |
||
1292 | break; |
||
1293 | |||
1294 | |||
1295 | case AML_CLASS_CREATE: |
||
1296 | default: |
||
1297 | |||
1298 | |||
1299 | (Op->Asl.CompileFlags & NODE_IS_RESOURCE_DESC)) |
||
1300 | { |
||
1301 | return; |
||
1302 | } |
||
1303 | |||
1304 | |||
1305 | FileId); |
||
1306 | break; |
||
1307 | |||
1308 | |||
1309 | break; |
||
1310 | } |
||
1311 | } |
||
1312 | |||
1313 | |||
1314 | |||
1315 | * |
||
1316 | * FUNCTION: LsDoHexOutput |
||
1317 | * |
||
1318 | * PARAMETERS: None |
||
1319 | * |
||
1320 | * RETURN: None. |
||
1321 | * |
||
1322 | * DESCRIPTION: Create the hex output file. |
||
1323 | * |
||
1324 | ******************************************************************************/ |
||
1325 | |||
1326 | |||
1327 | LsDoHexOutput ( |
||
1328 | void) |
||
1329 | { |
||
1330 | |||
1331 | |||
1332 | { |
||
1333 | case HEX_OUTPUT_C: |
||
1334 | |||
1335 | |||
1336 | break; |
||
1337 | |||
1338 | |||
1339 | |||
1340 | |||
1341 | break; |
||
1342 | |||
1343 | |||
1344 | |||
1345 | |||
1346 | break; |
||
1347 | |||
1348 | |||
1349 | /* No other output types supported */ |
||
1350 | break; |
||
1351 | } |
||
1352 | } |
||
1353 | |||
1354 | |||
1355 | |||
1356 | * |
||
1357 | * FUNCTION: LsDoHexOutputC |
||
1358 | * |
||
1359 | * PARAMETERS: None |
||
1360 | * |
||
1361 | * RETURN: None. |
||
1362 | * |
||
1363 | * DESCRIPTION: Create the hex output file. This is the same data as the AML |
||
1364 | * output file, but formatted into hex/ascii bytes suitable for |
||
1365 | * inclusion into a C source file. |
||
1366 | * |
||
1367 | ******************************************************************************/ |
||
1368 | |||
1369 | |||
1370 | LsDoHexOutputC ( |
||
1371 | void) |
||
1372 | { |
||
1373 | UINT8 FileData[HEX_TABLE_LINE_SIZE]; |
||
1374 | UINT32 LineLength; |
||
1375 | UINT32 Offset = 0; |
||
1376 | UINT32 AmlFileSize; |
||
1377 | UINT32 i; |
||
1378 | |||
1379 | |||
1380 | |||
1381 | |||
1382 | |||
1383 | |||
1384 | |||
1385 | FlPrintFile (ASL_FILE_HEX_OUTPUT, " * AML code block contains 0x%X bytes\n *\n */\n", |
||
1386 | AmlFileSize); |
||
1387 | FlPrintFile (ASL_FILE_HEX_OUTPUT, "unsigned char AmlCode[] =\n{\n"); |
||
1388 | |||
1389 | |||
1390 | { |
||
1391 | /* Read enough bytes needed for one output line */ |
||
1392 | |||
1393 | |||
1394 | Gbl_Files[ASL_FILE_AML_OUTPUT].Handle); |
||
1395 | if (!LineLength) |
||
1396 | { |
||
1397 | break; |
||
1398 | } |
||
1399 | |||
1400 | |||
1401 | |||
1402 | |||
1403 | { |
||
1404 | /* |
||
1405 | * Print each hex byte. |
||
1406 | * Add a comma until the very last byte of the AML file |
||
1407 | * (Some C compilers complain about a trailing comma) |
||
1408 | */ |
||
1409 | FlPrintFile (ASL_FILE_HEX_OUTPUT, "0x%2.2X", FileData[i]); |
||
1410 | if ((Offset + i + 1) < AmlFileSize) |
||
1411 | { |
||
1412 | FlPrintFile (ASL_FILE_HEX_OUTPUT, ","); |
||
1413 | } |
||
1414 | else |
||
1415 | { |
||
1416 | FlPrintFile (ASL_FILE_HEX_OUTPUT, " "); |
||
1417 | } |
||
1418 | } |
||
1419 | |||
1420 | |||
1421 | |||
1422 | |||
1423 | { |
||
1424 | FlPrintFile (ASL_FILE_HEX_OUTPUT, "%*s", |
||
1425 | 5 * (HEX_TABLE_LINE_SIZE - LineLength), " "); |
||
1426 | } |
||
1427 | |||
1428 | |||
1429 | |||
1430 | |||
1431 | LsDumpAsciiInComment (ASL_FILE_HEX_OUTPUT, LineLength, FileData); |
||
1432 | FlPrintFile (ASL_FILE_HEX_OUTPUT, "%*s*/\n", |
||
1433 | HEX_TABLE_LINE_SIZE - LineLength + 1, " "); |
||
1434 | |||
1435 | |||
1436 | } |
||
1437 | |||
1438 | |||
1439 | FlCloseFile (ASL_FILE_HEX_OUTPUT); |
||
1440 | } |
||
1441 | |||
1442 | |||
1443 | |||
1444 | * |
||
1445 | * FUNCTION: LsDoHexOutputAsl |
||
1446 | * |
||
1447 | * PARAMETERS: None |
||
1448 | * |
||
1449 | * RETURN: None. |
||
1450 | * |
||
1451 | * DESCRIPTION: Create the hex output file. This is the same data as the AML |
||
1452 | * output file, but formatted into hex/ascii bytes suitable for |
||
1453 | * inclusion into a C source file. |
||
1454 | * |
||
1455 | ******************************************************************************/ |
||
1456 | |||
1457 | |||
1458 | LsDoHexOutputAsl ( |
||
1459 | void) |
||
1460 | { |
||
1461 | UINT8 FileData[HEX_TABLE_LINE_SIZE]; |
||
1462 | UINT32 LineLength; |
||
1463 | UINT32 Offset = 0; |
||
1464 | UINT32 AmlFileSize; |
||
1465 | UINT32 i; |
||
1466 | |||
1467 | |||
1468 | |||
1469 | |||
1470 | |||
1471 | |||
1472 | |||
1473 | FlPrintFile (ASL_FILE_HEX_OUTPUT, " * AML code block contains 0x%X bytes\n *\n */\n", |
||
1474 | AmlFileSize); |
||
1475 | FlPrintFile (ASL_FILE_HEX_OUTPUT, " Name (BUF1, Buffer()\n {\n"); |
||
1476 | |||
1477 | |||
1478 | { |
||
1479 | /* Read enough bytes needed for one output line */ |
||
1480 | |||
1481 | |||
1482 | Gbl_Files[ASL_FILE_AML_OUTPUT].Handle); |
||
1483 | if (!LineLength) |
||
1484 | { |
||
1485 | break; |
||
1486 | } |
||
1487 | |||
1488 | |||
1489 | |||
1490 | |||
1491 | { |
||
1492 | /* |
||
1493 | * Print each hex byte. |
||
1494 | * Add a comma until the very last byte of the AML file |
||
1495 | * (Some C compilers complain about a trailing comma) |
||
1496 | */ |
||
1497 | FlPrintFile (ASL_FILE_HEX_OUTPUT, "0x%2.2X", FileData[i]); |
||
1498 | if ((Offset + i + 1) < AmlFileSize) |
||
1499 | { |
||
1500 | FlPrintFile (ASL_FILE_HEX_OUTPUT, ","); |
||
1501 | } |
||
1502 | else |
||
1503 | { |
||
1504 | FlPrintFile (ASL_FILE_HEX_OUTPUT, " "); |
||
1505 | } |
||
1506 | } |
||
1507 | |||
1508 | |||
1509 | |||
1510 | |||
1511 | { |
||
1512 | FlPrintFile (ASL_FILE_HEX_OUTPUT, "%*s", |
||
1513 | 5 * (HEX_TABLE_LINE_SIZE - LineLength), " "); |
||
1514 | } |
||
1515 | |||
1516 | |||
1517 | |||
1518 | |||
1519 | LsDumpAsciiInComment (ASL_FILE_HEX_OUTPUT, LineLength, FileData); |
||
1520 | FlPrintFile (ASL_FILE_HEX_OUTPUT, "%*s*/\n", |
||
1521 | HEX_TABLE_LINE_SIZE - LineLength + 1, " "); |
||
1522 | |||
1523 | |||
1524 | } |
||
1525 | |||
1526 | |||
1527 | FlCloseFile (ASL_FILE_HEX_OUTPUT); |
||
1528 | } |
||
1529 | |||
1530 | |||
1531 | |||
1532 | * |
||
1533 | * FUNCTION: LsDoHexOutputAsm |
||
1534 | * |
||
1535 | * PARAMETERS: None |
||
1536 | * |
||
1537 | * RETURN: None. |
||
1538 | * |
||
1539 | * DESCRIPTION: Create the hex output file. This is the same data as the AML |
||
1540 | * output file, but formatted into hex/ascii bytes suitable for |
||
1541 | * inclusion into a ASM source file. |
||
1542 | * |
||
1543 | ******************************************************************************/ |
||
1544 | |||
1545 | |||
1546 | LsDoHexOutputAsm ( |
||
1547 | void) |
||
1548 | { |
||
1549 | UINT8 FileData[HEX_TABLE_LINE_SIZE]; |
||
1550 | UINT32 LineLength; |
||
1551 | UINT32 Offset = 0; |
||
1552 | UINT32 AmlFileSize; |
||
1553 | UINT32 i; |
||
1554 | |||
1555 | |||
1556 | |||
1557 | |||
1558 | |||
1559 | |||
1560 | |||
1561 | FlPrintFile (ASL_FILE_HEX_OUTPUT, "; AML code block contains 0x%X bytes\n;\n", |
||
1562 | AmlFileSize); |
||
1563 | |||
1564 | |||
1565 | { |
||
1566 | /* Read enough bytes needed for one output line */ |
||
1567 | |||
1568 | |||
1569 | Gbl_Files[ASL_FILE_AML_OUTPUT].Handle); |
||
1570 | if (!LineLength) |
||
1571 | { |
||
1572 | break; |
||
1573 | } |
||
1574 | |||
1575 | |||
1576 | |||
1577 | |||
1578 | { |
||
1579 | /* |
||
1580 | * Print each hex byte. |
||
1581 | * Add a comma until the last byte of the line |
||
1582 | */ |
||
1583 | FlPrintFile (ASL_FILE_HEX_OUTPUT, "0%2.2Xh", FileData[i]); |
||
1584 | if ((i + 1) < LineLength) |
||
1585 | { |
||
1586 | FlPrintFile (ASL_FILE_HEX_OUTPUT, ","); |
||
1587 | } |
||
1588 | } |
||
1589 | |||
1590 | |||
1591 | |||
1592 | |||
1593 | |||
1594 | |||
1595 | { |
||
1596 | FlPrintFile (ASL_FILE_HEX_OUTPUT, "%*s", |
||
1597 | 5 * (HEX_TABLE_LINE_SIZE - LineLength), " "); |
||
1598 | } |
||
1599 | |||
1600 | |||
1601 | |||
1602 | |||
1603 | LsDumpAsciiInComment (ASL_FILE_HEX_OUTPUT, LineLength, FileData); |
||
1604 | FlPrintFile (ASL_FILE_HEX_OUTPUT, "\n"); |
||
1605 | |||
1606 | |||
1607 | } |
||
1608 | |||
1609 | |||
1610 | FlCloseFile (ASL_FILE_HEX_OUTPUT); |
||
1611 | }>>>>>>>>>>>>>>>>>>>>>>>>>> |
||
1612 |