1 /******************************************************************************
2 *
3 * Module Name: asllistsup - Listing file support utilities
4 *
5 *****************************************************************************/
6
7 /******************************************************************************
8 *
9 * 1. Copyright Notice
10 *
11 * Some or all of this work - Copyright (c) 1999 - 2023, 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 * Alternatively, you may choose to be licensed under the terms of the
117 * following license:
118 *
119 * Redistribution and use in source and binary forms, with or without
120 * modification, are permitted provided that the following conditions
121 * are met:
122 * 1. Redistributions of source code must retain the above copyright
123 * notice, this list of conditions, and the following disclaimer,
124 * without modification.
125 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126 * substantially similar to the "NO WARRANTY" disclaimer below
127 * ("Disclaimer") and any redistribution must be conditioned upon
128 * including a substantially similar Disclaimer requirement for further
129 * binary redistribution.
130 * 3. Neither the names of the above-listed copyright holders nor the names
131 * of any contributors may be used to endorse or promote products derived
132 * from this software without specific prior written permission.
133 *
134 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
135 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
136 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
137 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
138 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
139 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
140 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
141 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
142 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
144 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
145 *
146 * Alternatively, you may choose to be licensed under the terms of the
147 * GNU General Public License ("GPL") version 2 as published by the Free
148 * Software Foundation.
149 *
150 *****************************************************************************/
151
152 #include "aslcompiler.h"
153 #include "aslcompiler.y.h"
154
155
156 #define _COMPONENT ACPI_COMPILER
157 ACPI_MODULE_NAME ("aslistsup")
158
159
160 /*******************************************************************************
161 *
162 * FUNCTION: LsDumpAscii
163 *
164 * PARAMETERS: FileId - ID of current listing file
165 * Count - Number of bytes to convert
166 * Buffer - Buffer of bytes to convert
167 *
168 * RETURN: None
169 *
170 * DESCRIPTION: Convert hex bytes to ascii
171 *
172 ******************************************************************************/
173
174 void
LsDumpAscii(UINT32 FileId,UINT32 Count,UINT8 * Buffer)175 LsDumpAscii (
176 UINT32 FileId,
177 UINT32 Count,
178 UINT8 *Buffer)
179 {
180 UINT8 BufChar;
181 UINT32 i;
182
183
184 FlPrintFile (FileId, " \"");
185 for (i = 0; i < Count; i++)
186 {
187 BufChar = Buffer[i];
188 if (isprint (BufChar))
189 {
190 FlPrintFile (FileId, "%c", BufChar);
191 }
192 else
193 {
194 /* Not a printable character, just put out a dot */
195
196 FlPrintFile (FileId, ".");
197 }
198 }
199
200 FlPrintFile (FileId, "\"");
201 }
202
203
204 /*******************************************************************************
205 *
206 * FUNCTION: LsDumpAsciiInComment
207 *
208 * PARAMETERS: FileId - ID of current listing file
209 * Count - Number of bytes to convert
210 * Buffer - Buffer of bytes to convert
211 *
212 * RETURN: None
213 *
214 * DESCRIPTION: Convert hex bytes to ascii
215 *
216 ******************************************************************************/
217
218 void
LsDumpAsciiInComment(UINT32 FileId,UINT32 Count,UINT8 * Buffer)219 LsDumpAsciiInComment (
220 UINT32 FileId,
221 UINT32 Count,
222 UINT8 *Buffer)
223 {
224 UINT8 BufChar = 0;
225 UINT8 LastChar;
226 UINT32 i;
227
228
229 FlPrintFile (FileId, " \"");
230 for (i = 0; i < Count; i++)
231 {
232 LastChar = BufChar;
233 BufChar = Buffer[i];
234
235 if (isprint (BufChar))
236 {
237 /* Handle embedded C comment sequences */
238
239 if (((LastChar == '*') && (BufChar == '/')) ||
240 ((LastChar == '/') && (BufChar == '*')))
241 {
242 /* Insert a space to break the sequence */
243
244 FlPrintFile (FileId, " ");
245 }
246
247 FlPrintFile (FileId, "%c", BufChar);
248 }
249 else
250 {
251 /* Not a printable character, just put out a dot */
252
253 FlPrintFile (FileId, ".");
254 }
255 }
256
257 FlPrintFile (FileId, "\"");
258 }
259
260
261 /*******************************************************************************
262 *
263 * FUNCTION: LsCheckException
264 *
265 * PARAMETERS: LineNumber - Current logical (cumulative) line #
266 * FileId - ID of output listing file
267 *
268 * RETURN: None
269 *
270 * DESCRIPTION: Check if there is an exception for this line, and if there is,
271 * put it in the listing immediately. Handles multiple errors
272 * per line. AslGbl_NextError points to the next error in the
273 * sorted (by line #) list of compile errors/warnings.
274 *
275 ******************************************************************************/
276
277 void
LsCheckException(UINT32 LineNumber,UINT32 FileId)278 LsCheckException (
279 UINT32 LineNumber,
280 UINT32 FileId)
281 {
282
283 if ((!AslGbl_NextError) ||
284 (LineNumber < AslGbl_NextError->LogicalLineNumber ))
285 {
286 return;
287 }
288
289 /* Handle multiple errors per line */
290
291 if (FileId == ASL_FILE_LISTING_OUTPUT)
292 {
293 while (AslGbl_NextError &&
294 (LineNumber >= AslGbl_NextError->LogicalLineNumber))
295 {
296 AePrintException (FileId, AslGbl_NextError, "\n[****iasl****]\n");
297 AslGbl_NextError = AslGbl_NextError->Next;
298 }
299
300 FlPrintFile (FileId, "\n");
301 }
302 }
303
304
305 /*******************************************************************************
306 *
307 * FUNCTION: LsWriteListingHexBytes
308 *
309 * PARAMETERS: Buffer - AML code buffer
310 * Length - Number of AML bytes to write
311 * FileId - ID of current listing file.
312 *
313 * RETURN: None
314 *
315 * DESCRIPTION: Write the contents of the AML buffer to the listing file via
316 * the listing buffer. The listing buffer is flushed every 16
317 * AML bytes.
318 *
319 ******************************************************************************/
320
321 void
LsWriteListingHexBytes(UINT8 * Buffer,UINT32 Length,UINT32 FileId)322 LsWriteListingHexBytes (
323 UINT8 *Buffer,
324 UINT32 Length,
325 UINT32 FileId)
326 {
327 UINT32 i;
328
329
330 /* Transfer all requested bytes */
331
332 for (i = 0; i < Length; i++)
333 {
334 /* Print line header when buffer is empty */
335
336 if (AslGbl_CurrentHexColumn == 0)
337 {
338 if (AslGbl_HasIncludeFiles)
339 {
340 FlPrintFile (FileId, "%*s", 10, " ");
341 }
342
343 switch (FileId)
344 {
345 case ASL_FILE_LISTING_OUTPUT:
346
347 FlPrintFile (FileId, "%8.8X%s", AslGbl_CurrentAmlOffset,
348 ASL_LISTING_LINE_PREFIX);
349 break;
350
351 case ASL_FILE_ASM_SOURCE_OUTPUT:
352
353 FlPrintFile (FileId, " db ");
354 break;
355
356 case ASL_FILE_C_SOURCE_OUTPUT:
357
358 FlPrintFile (FileId, " ");
359 break;
360
361 default:
362
363 /* No other types supported */
364
365 return;
366 }
367 }
368
369 /* Transfer AML byte and update counts */
370
371 AslGbl_AmlBuffer[AslGbl_CurrentHexColumn] = Buffer[i];
372
373 AslGbl_CurrentHexColumn++;
374 AslGbl_CurrentAmlOffset++;
375
376 /* Flush buffer when it is full */
377
378 if (AslGbl_CurrentHexColumn >= HEX_LISTING_LINE_SIZE)
379 {
380 LsFlushListingBuffer (FileId);
381 }
382 }
383 }
384
385
386 /*******************************************************************************
387 *
388 * FUNCTION: LsWriteSourceLines
389 *
390 * PARAMETERS: ToLineNumber -
391 * ToLogicalLineNumber - Write up to this source line number
392 * FileId - ID of current listing file
393 *
394 * RETURN: None
395 *
396 * DESCRIPTION: Read then write source lines to the listing file until we have
397 * reached the specified logical (cumulative) line number. This
398 * automatically echos out comment blocks and other non-AML
399 * generating text until we get to the actual AML-generating line
400 * of ASL code specified by the logical line number.
401 *
402 ******************************************************************************/
403
404 void
LsWriteSourceLines(UINT32 ToLineNumber,UINT32 ToLogicalLineNumber,UINT32 FileId)405 LsWriteSourceLines (
406 UINT32 ToLineNumber,
407 UINT32 ToLogicalLineNumber,
408 UINT32 FileId)
409 {
410
411 /* Nothing to do for these file types */
412
413 if ((FileId == ASL_FILE_ASM_INCLUDE_OUTPUT) ||
414 (FileId == ASL_FILE_C_INCLUDE_OUTPUT))
415 {
416 return;
417 }
418
419 AslGbl_CurrentLine = ToLogicalLineNumber;
420
421 /* Flush any hex bytes remaining from the last opcode */
422
423 LsFlushListingBuffer (FileId);
424
425 /* Read lines and write them as long as we are not caught up */
426
427 if (AslGbl_SourceLine < AslGbl_CurrentLine)
428 {
429 /*
430 * If we just completed writing some AML hex bytes, output a linefeed
431 * to add some whitespace for readability.
432 */
433 if (AslGbl_HexBytesWereWritten)
434 {
435 FlPrintFile (FileId, "\n");
436 AslGbl_HexBytesWereWritten = FALSE;
437 }
438
439 if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
440 {
441 FlPrintFile (FileId, " /*\n");
442 }
443
444 /* Write one line at a time until we have reached the target line # */
445
446 while ((AslGbl_SourceLine < AslGbl_CurrentLine) &&
447 LsWriteOneSourceLine (FileId))
448 { ; }
449
450 if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
451 {
452 FlPrintFile (FileId, " */");
453 }
454
455 FlPrintFile (FileId, "\n");
456 }
457 }
458
459
460 /*******************************************************************************
461 *
462 * FUNCTION: LsWriteOneSourceLine
463 *
464 * PARAMETERS: FileId - ID of current listing file
465 *
466 * RETURN: FALSE on EOF (input source file), TRUE otherwise
467 *
468 * DESCRIPTION: Read one line from the input source file and echo it to the
469 * listing file, prefixed with the line number, and if the source
470 * file contains include files, prefixed with the current filename
471 *
472 ******************************************************************************/
473
474 UINT32
LsWriteOneSourceLine(UINT32 FileId)475 LsWriteOneSourceLine (
476 UINT32 FileId)
477 {
478 UINT8 FileByte;
479 UINT32 Column = 0;
480 UINT32 Index = 16;
481 BOOLEAN StartOfLine = FALSE;
482 BOOLEAN ProcessLongLine = FALSE;
483
484
485 AslGbl_SourceLine++;
486 AslGbl_ListingNode->LineNumber++;
487
488 /* Ignore lines that are completely blank (but count the line above) */
489
490 if (FlReadFile (ASL_FILE_SOURCE_OUTPUT, &FileByte, 1) != AE_OK)
491 {
492 return (0);
493 }
494 if (FileByte == '\n')
495 {
496 return (1);
497 }
498
499 /*
500 * This is a non-empty line, we will print the entire line with
501 * the line number and possibly other prefixes and transforms.
502 */
503
504 /* Line prefixes for special files, C and ASM output */
505
506 if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
507 {
508 FlPrintFile (FileId, " *");
509 }
510 if (FileId == ASL_FILE_ASM_SOURCE_OUTPUT)
511 {
512 FlPrintFile (FileId, "; ");
513 }
514
515 if (AslGbl_HasIncludeFiles)
516 {
517 /*
518 * This file contains "include" statements, print the current
519 * filename and line number within the current file
520 */
521 FlPrintFile (FileId, "%12s %5d%s",
522 AslGbl_ListingNode->Filename, AslGbl_ListingNode->LineNumber,
523 ASL_LISTING_LINE_PREFIX);
524 }
525 else
526 {
527 /* No include files, just print the line number */
528
529 FlPrintFile (FileId, "%8u%s", AslGbl_SourceLine,
530 ASL_LISTING_LINE_PREFIX);
531 }
532
533 /* Read the rest of this line (up to a newline or EOF) */
534
535 do
536 {
537 if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
538 {
539 if (FileByte == '/')
540 {
541 FileByte = '*';
542 }
543 }
544
545 /* Split long input lines for readability in the listing */
546
547 Column++;
548 if (Column >= 128)
549 {
550 if (!ProcessLongLine)
551 {
552 if ((FileByte != '}') &&
553 (FileByte != '{'))
554 {
555 goto WriteByte;
556 }
557
558 ProcessLongLine = TRUE;
559 }
560
561 if (FileByte == '{')
562 {
563 FlPrintFile (FileId, "\n%*s{\n", Index, " ");
564 StartOfLine = TRUE;
565 Index += 4;
566 continue;
567 }
568
569 else if (FileByte == '}')
570 {
571 if (!StartOfLine)
572 {
573 FlPrintFile (FileId, "\n");
574 }
575
576 StartOfLine = TRUE;
577 Index -= 4;
578 FlPrintFile (FileId, "%*s}\n", Index, " ");
579 continue;
580 }
581
582 /* Ignore spaces/tabs at the start of line */
583
584 else if ((FileByte == ' ') && StartOfLine)
585 {
586 continue;
587 }
588
589 else if (StartOfLine)
590 {
591 StartOfLine = FALSE;
592 FlPrintFile (FileId, "%*s", Index, " ");
593 }
594
595 WriteByte:
596 FlWriteFile (FileId, &FileByte, 1);
597 if (FileByte == '\n')
598 {
599 /*
600 * This line has been completed.
601 * Check if an error occurred on this source line during the compile.
602 * If so, we print the error message after the source line.
603 */
604 LsCheckException (AslGbl_SourceLine, FileId);
605 return (1);
606 }
607 }
608 else
609 {
610 FlWriteFile (FileId, &FileByte, 1);
611 if (FileByte == '\n')
612 {
613 /*
614 * This line has been completed.
615 * Check if an error occurred on this source line during the compile.
616 * If so, we print the error message after the source line.
617 */
618 LsCheckException (AslGbl_SourceLine, FileId);
619 return (1);
620 }
621 }
622
623 } while (FlReadFile (ASL_FILE_SOURCE_OUTPUT, &FileByte, 1) == AE_OK);
624
625 /* EOF on the input file was reached */
626
627 return (0);
628 }
629
630
631 /*******************************************************************************
632 *
633 * FUNCTION: LsFlushListingBuffer
634 *
635 * PARAMETERS: FileId - ID of the listing file
636 *
637 * RETURN: None
638 *
639 * DESCRIPTION: Flush out the current contents of the 16-byte hex AML code
640 * buffer. Usually called at the termination of a single line
641 * of source code or when the buffer is full.
642 *
643 ******************************************************************************/
644
645 void
LsFlushListingBuffer(UINT32 FileId)646 LsFlushListingBuffer (
647 UINT32 FileId)
648 {
649 UINT32 i;
650
651
652 if (AslGbl_CurrentHexColumn == 0)
653 {
654 return;
655 }
656
657 /* Write the hex bytes */
658
659 switch (FileId)
660 {
661 case ASL_FILE_LISTING_OUTPUT:
662
663 for (i = 0; i < AslGbl_CurrentHexColumn; i++)
664 {
665 FlPrintFile (FileId, "%2.2X ", AslGbl_AmlBuffer[i]);
666 }
667
668 for (i = 0; i < ((HEX_LISTING_LINE_SIZE - AslGbl_CurrentHexColumn) * 3); i++)
669 {
670 FlWriteFile (FileId, ".", 1);
671 }
672
673 /* Write the ASCII character associated with each of the bytes */
674
675 LsDumpAscii (FileId, AslGbl_CurrentHexColumn, AslGbl_AmlBuffer);
676 break;
677
678
679 case ASL_FILE_ASM_SOURCE_OUTPUT:
680
681 for (i = 0; i < AslGbl_CurrentHexColumn; i++)
682 {
683 if (i > 0)
684 {
685 FlPrintFile (FileId, ",");
686 }
687
688 FlPrintFile (FileId, "0%2.2Xh", AslGbl_AmlBuffer[i]);
689 }
690
691 for (i = 0; i < ((HEX_LISTING_LINE_SIZE - AslGbl_CurrentHexColumn) * 5); i++)
692 {
693 FlWriteFile (FileId, " ", 1);
694 }
695
696 FlPrintFile (FileId, " ;%8.8X",
697 AslGbl_CurrentAmlOffset - HEX_LISTING_LINE_SIZE);
698
699 /* Write the ASCII character associated with each of the bytes */
700
701 LsDumpAscii (FileId, AslGbl_CurrentHexColumn, AslGbl_AmlBuffer);
702 break;
703
704
705 case ASL_FILE_C_SOURCE_OUTPUT:
706
707 for (i = 0; i < AslGbl_CurrentHexColumn; i++)
708 {
709 FlPrintFile (FileId, "0x%2.2X,", AslGbl_AmlBuffer[i]);
710 }
711
712 /* Pad hex output with spaces if line is shorter than max line size */
713
714 for (i = 0; i < ((HEX_LISTING_LINE_SIZE - AslGbl_CurrentHexColumn) * 5); i++)
715 {
716 FlWriteFile (FileId, " ", 1);
717 }
718
719 /* AML offset for the start of the line */
720
721 FlPrintFile (FileId, " /* %8.8X",
722 AslGbl_CurrentAmlOffset - AslGbl_CurrentHexColumn);
723
724 /* Write the ASCII character associated with each of the bytes */
725
726 LsDumpAsciiInComment (FileId, AslGbl_CurrentHexColumn, AslGbl_AmlBuffer);
727 FlPrintFile (FileId, " */");
728 break;
729
730 default:
731
732 /* No other types supported */
733
734 return;
735 }
736
737 FlPrintFile (FileId, "\n");
738
739 AslGbl_CurrentHexColumn = 0;
740 AslGbl_HexBytesWereWritten = TRUE;
741 }
742
743
744 /*******************************************************************************
745 *
746 * FUNCTION: LsPushNode
747 *
748 * PARAMETERS: Filename - Pointer to the include filename
749 *
750 * RETURN: None
751 *
752 * DESCRIPTION: Push a listing node on the listing/include file stack. This
753 * stack enables tracking of include files (infinitely nested)
754 * and resumption of the listing of the parent file when the
755 * include file is finished.
756 *
757 ******************************************************************************/
758
759 void
LsPushNode(char * Filename)760 LsPushNode (
761 char *Filename)
762 {
763 ASL_LISTING_NODE *Lnode;
764
765
766 /* Create a new node */
767
768 Lnode = UtLocalCalloc (sizeof (ASL_LISTING_NODE));
769
770 /* Initialize */
771
772 Lnode->Filename = Filename;
773 Lnode->LineNumber = 0;
774
775 /* Link (push) */
776
777 Lnode->Next = AslGbl_ListingNode;
778 AslGbl_ListingNode = Lnode;
779 }
780
781
782 /*******************************************************************************
783 *
784 * FUNCTION: LsPopNode
785 *
786 * PARAMETERS: None
787 *
788 * RETURN: List head after current head is popped off
789 *
790 * DESCRIPTION: Pop the current head of the list, free it, and return the
791 * next node on the stack (the new current node).
792 *
793 ******************************************************************************/
794
795 ASL_LISTING_NODE *
LsPopNode(void)796 LsPopNode (
797 void)
798 {
799 ASL_LISTING_NODE *Lnode;
800
801
802 /* Just grab the node at the head of the list */
803
804 Lnode = AslGbl_ListingNode;
805 if ((!Lnode) ||
806 (!Lnode->Next))
807 {
808 AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, NULL,
809 "Could not pop empty listing stack");
810 return (AslGbl_ListingNode);
811 }
812
813 AslGbl_ListingNode = Lnode->Next;
814 ACPI_FREE (Lnode);
815
816 /* New "Current" node is the new head */
817
818 return (AslGbl_ListingNode);
819 }
820