xref: /freebsd/sys/contrib/dev/acpica/compiler/asllisting.c (revision bdd1243df58e60e85101c09001d9812a789b6bc4)
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 - 2022, 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 <contrib/dev/acpica/compiler/aslcompiler.h>
153 #include "aslcompiler.y.h"
154 #include <contrib/dev/acpica/include/amlcode.h>
155 #include <contrib/dev/acpica/include/acparser.h>
156 #include <contrib/dev/acpica/include/acnamesp.h>
157 
158 
159 #define _COMPONENT          ACPI_COMPILER
160         ACPI_MODULE_NAME    ("asllisting")
161 
162 
163 /* Local prototypes */
164 
165 static void
166 LsGenerateListing (
167     UINT32                  FileId);
168 
169 static ACPI_STATUS
170 LsAmlListingWalk (
171     ACPI_PARSE_OBJECT       *Op,
172     UINT32                  Level,
173     void                    *Context);
174 
175 static ACPI_STATUS
176 LsTreeWriteWalk (
177     ACPI_PARSE_OBJECT       *Op,
178     UINT32                  Level,
179     void                    *Context);
180 
181 static void
182 LsWriteNodeToListing (
183     ACPI_PARSE_OBJECT       *Op,
184     UINT32                  FileId);
185 
186 static void
187 LsFinishSourceListing (
188     UINT32                  FileId);
189 
190 
191 /*******************************************************************************
192  *
193  * FUNCTION:    LsDoListings
194  *
195  * PARAMETERS:  None. Examines the various output file global flags.
196  *
197  * RETURN:      None
198  *
199  * DESCRIPTION: Generate all requested listing files.
200  *
201  ******************************************************************************/
202 
203 void
204 LsDoListings (
205     void)
206 {
207 
208     if (AslGbl_C_OutputFlag)
209     {
210         LsGenerateListing (ASL_FILE_C_SOURCE_OUTPUT);
211     }
212 
213     if (AslGbl_ListingFlag)
214     {
215         LsGenerateListing (ASL_FILE_LISTING_OUTPUT);
216     }
217 
218     if (AslGbl_AsmOutputFlag)
219     {
220         LsGenerateListing (ASL_FILE_ASM_SOURCE_OUTPUT);
221     }
222 
223     if (AslGbl_C_IncludeOutputFlag)
224     {
225         LsGenerateListing (ASL_FILE_C_INCLUDE_OUTPUT);
226     }
227 
228     if (AslGbl_AsmIncludeOutputFlag)
229     {
230         LsGenerateListing (ASL_FILE_ASM_INCLUDE_OUTPUT);
231     }
232 
233     if (AslGbl_C_OffsetTableFlag)
234     {
235         LsGenerateListing (ASL_FILE_C_OFFSET_OUTPUT);
236     }
237 }
238 
239 
240 /*******************************************************************************
241  *
242  * FUNCTION:    LsGenerateListing
243  *
244  * PARAMETERS:  FileId      - ID of listing file
245  *
246  * RETURN:      None
247  *
248  * DESCRIPTION: Generate a listing file. This can be one of the several types
249  *              of "listings" supported.
250  *
251  ******************************************************************************/
252 
253 static void
254 LsGenerateListing (
255     UINT32                  FileId)
256 {
257     UINT32                  WalkMode = ASL_WALK_VISIT_DOWNWARD | ASL_WALK_VISIT_DB_SEPARATELY;
258 
259     /* Start at the beginning of both the source and AML files */
260 
261     FlSeekFile (ASL_FILE_SOURCE_OUTPUT, 0);
262     FlSeekFile (ASL_FILE_AML_OUTPUT, 0);
263     AslGbl_SourceLine = 0;
264     AslGbl_CurrentHexColumn = 0;
265     LsPushNode (AslGbl_Files[ASL_FILE_INPUT].Filename);
266 
267     if (FileId == ASL_FILE_C_OFFSET_OUTPUT)
268     {
269         AslGbl_CurrentAmlOffset = 0;
270 
271         /* Offset table file has a special header and footer */
272 
273         LsDoOffsetTableHeader (FileId);
274 
275         TrWalkParseTree (AslGbl_CurrentDB, WalkMode,
276             LsAmlOffsetWalk, NULL, (void *) ACPI_TO_POINTER (FileId));
277         LsDoOffsetTableFooter (FileId);
278         return;
279     }
280 
281     /* Process all parse nodes */
282 
283     TrWalkParseTree (AslGbl_CurrentDB, WalkMode,
284         LsAmlListingWalk, NULL, (void *) ACPI_TO_POINTER (FileId));
285 
286     /* Final processing */
287 
288     LsFinishSourceListing (FileId);
289 }
290 
291 
292 /*******************************************************************************
293  *
294  * FUNCTION:    LsAmlListingWalk
295  *
296  * PARAMETERS:  ASL_WALK_CALLBACK
297  *
298  * RETURN:      Status
299  *
300  * DESCRIPTION: Process one node during a listing file generation.
301  *
302  ******************************************************************************/
303 
304 static ACPI_STATUS
305 LsAmlListingWalk (
306     ACPI_PARSE_OBJECT       *Op,
307     UINT32                  Level,
308     void                    *Context)
309 {
310     UINT8                   FileByte;
311     UINT32                  i;
312     UINT32                  FileId = (UINT32) ACPI_TO_INTEGER (Context);
313 
314 
315     LsWriteNodeToListing (Op, FileId);
316 
317     if (Op->Asl.CompileFlags & OP_IS_RESOURCE_DATA)
318     {
319         /* Buffer is a resource template, don't dump the data all at once */
320 
321         return (AE_OK);
322     }
323 
324     if ((FileId == ASL_FILE_ASM_INCLUDE_OUTPUT) ||
325         (FileId == ASL_FILE_C_INCLUDE_OUTPUT))
326     {
327         return (AE_OK);
328     }
329 
330     /* Write the hex bytes to the listing file(s) (if requested) */
331 
332     for (i = 0; i < Op->Asl.FinalAmlLength; i++)
333     {
334         if (ACPI_FAILURE (FlReadFile (ASL_FILE_AML_OUTPUT, &FileByte, 1)))
335         {
336             FlFileError (ASL_FILE_AML_OUTPUT, ASL_MSG_READ);
337             AslAbort ();
338         }
339 
340         LsWriteListingHexBytes (&FileByte, 1, FileId);
341     }
342 
343     return (AE_OK);
344 }
345 
346 
347 /*******************************************************************************
348  *
349  * FUNCTION:    LsDumpParseTree, LsTreeWriteWalk
350  *
351  * PARAMETERS:  None
352  *
353  * RETURN:      None
354  *
355  * DESCRIPTION: Dump entire parse tree, for compiler debug only
356  *
357  ******************************************************************************/
358 
359 void
360 LsDumpParseTree (
361     void)
362 {
363 
364     if (!AslGbl_DebugFlag)
365     {
366         return;
367     }
368 
369     DbgPrint (ASL_TREE_OUTPUT, "\nOriginal parse tree from parser:\n\n");
370     DbgPrint (ASL_TREE_OUTPUT, ASL_PARSE_TREE_HEADER1);
371 
372     TrWalkParseTree (AslGbl_ParseTreeRoot, ASL_WALK_VISIT_DOWNWARD,
373         LsTreeWriteWalk, NULL, NULL);
374 
375     DbgPrint (ASL_TREE_OUTPUT, ASL_PARSE_TREE_HEADER1);
376 }
377 
378 
379 static ACPI_STATUS
380 LsTreeWriteWalk (
381     ACPI_PARSE_OBJECT       *Op,
382     UINT32                  Level,
383     void                    *Context)
384 {
385 
386     /* Dump ParseOp name and possible value */
387 
388     switch (Op->Asl.ParseOpcode)
389     {
390         case PARSEOP_NAMESEG:
391         case PARSEOP_NAMESTRING:
392         case PARSEOP_METHODCALL:
393         case PARSEOP_STRING_LITERAL:
394 
395         UtDumpStringOp (Op, Level);
396         break;
397 
398     case PARSEOP_BYTECONST:
399 
400         UtDumpIntegerOp (Op, Level, 2);
401         break;
402 
403     case PARSEOP_WORDCONST:
404     case PARSEOP_PACKAGE_LENGTH:
405 
406         UtDumpIntegerOp (Op, Level, 4);
407         break;
408 
409     case PARSEOP_DWORDCONST:
410     case PARSEOP_EISAID:
411 
412         UtDumpIntegerOp (Op, Level, 8);
413         break;
414 
415     case PARSEOP_QWORDCONST:
416     case PARSEOP_INTEGER:
417     case PARSEOP_ONE:
418     case PARSEOP_ZERO:
419     case PARSEOP_ONES:
420 
421         UtDumpIntegerOp (Op, Level, 16);
422         break;
423 
424     case PARSEOP_INCLUDE:
425 
426         DbgPrint (ASL_TREE_OUTPUT,
427             "Open: %s\n", Op->Asl.Value.String);
428         return (AE_OK);
429 
430     case PARSEOP_INCLUDE_END:
431 
432         DbgPrint (ASL_TREE_OUTPUT,
433             "Close: %s\n", Op->Asl.Filename);
434         return (AE_OK);
435 
436     default:
437 
438         UtDumpBasicOp (Op, Level);
439         break;
440     }
441 
442     /* Dump the remaining data */
443 
444     DbgPrint (ASL_TREE_OUTPUT, ASL_PARSE_TREE_DEBUG1,
445         Op->Asl.ParseOpcode, Op->Asl.CompileFlags,
446         Op->Asl.LineNumber, Op->Asl.EndLine,
447         Op->Asl.LogicalLineNumber, Op->Asl.EndLogicalLine);
448 
449     TrPrintOpFlags (Op->Asl.CompileFlags, ASL_TREE_OUTPUT);
450     DbgPrint (ASL_TREE_OUTPUT, "\n");
451     return (AE_OK);
452 }
453 
454 
455 /*******************************************************************************
456  *
457  * FUNCTION:    LsWriteNodeToListing
458  *
459  * PARAMETERS:  Op              - Parse node to write to the listing file.
460  *              FileId          - ID of current listing file
461  *
462  * RETURN:      None.
463  *
464  * DESCRIPTION: Write "a node" to the listing file. This means to
465  *              1) Write out all of the source text associated with the node
466  *              2) Write out all of the AML bytes associated with the node
467  *              3) Write any compiler exceptions associated with the node
468  *
469  ******************************************************************************/
470 
471 static void
472 LsWriteNodeToListing (
473     ACPI_PARSE_OBJECT       *Op,
474     UINT32                  FileId)
475 {
476     const ACPI_OPCODE_INFO  *OpInfo;
477     UINT32                  OpClass;
478     char                    *Pathname;
479     UINT32                  Length;
480     UINT32                  i;
481 
482 
483     OpInfo  = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode);
484     OpClass = OpInfo->Class;
485 
486     /* TBD: clean this up with a single flag that says:
487      * I start a named output block
488      */
489     if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
490     {
491         switch (Op->Asl.ParseOpcode)
492         {
493         case PARSEOP_DEFINITION_BLOCK:
494         case PARSEOP_METHODCALL:
495         case PARSEOP_INCLUDE:
496         case PARSEOP_INCLUDE_END:
497         case PARSEOP_DEFAULT_ARG:
498 
499             break;
500 
501         default:
502 
503             switch (OpClass)
504             {
505             case AML_CLASS_NAMED_OBJECT:
506 
507                 switch (Op->Asl.AmlOpcode)
508                 {
509                 case AML_SCOPE_OP:
510                 case AML_ALIAS_OP:
511 
512                     break;
513 
514                 default:
515 
516                     if (Op->Asl.ExternalName)
517                     {
518                         LsFlushListingBuffer (FileId);
519                         FlPrintFile (FileId, "    };\n");
520                     }
521                     break;
522                 }
523                 break;
524 
525             default:
526 
527                 /* Don't care about other objects */
528 
529                 break;
530             }
531             break;
532         }
533     }
534 
535     /* These cases do not have a corresponding AML opcode */
536 
537     switch (Op->Asl.ParseOpcode)
538     {
539     case PARSEOP_DEFINITION_BLOCK:
540 
541         /* Always start a definition block at AML offset zero */
542 
543         AslGbl_CurrentAmlOffset = 0;
544         LsWriteSourceLines (Op->Asl.EndLine, Op->Asl.EndLogicalLine, FileId);
545 
546         /* Use the table Signature and TableId to build a unique name */
547 
548         switch (FileId)
549         {
550         case ASL_FILE_ASM_SOURCE_OUTPUT:
551 
552             FlPrintFile (FileId,
553                 "%s_%s_Header \\\n",
554                 AslGbl_TableSignature, AslGbl_TableId);
555             break;
556 
557         case ASL_FILE_C_SOURCE_OUTPUT:
558 
559             FlPrintFile (FileId,
560                 "    unsigned char    %s_%s_Header [] =\n    {\n",
561                 AslGbl_TableSignature, AslGbl_TableId);
562             break;
563 
564         case ASL_FILE_ASM_INCLUDE_OUTPUT:
565 
566             FlPrintFile (FileId,
567                 "extrn %s_%s_Header : byte\n",
568                 AslGbl_TableSignature, AslGbl_TableId);
569             break;
570 
571         case ASL_FILE_C_INCLUDE_OUTPUT:
572 
573             FlPrintFile (FileId,
574                 "extern unsigned char    %s_%s_Header [];\n",
575                 AslGbl_TableSignature, AslGbl_TableId);
576             break;
577 
578         default:
579             break;
580         }
581 
582         return;
583 
584 
585     case PARSEOP_METHODCALL:
586 
587         LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber,
588             FileId);
589         return;
590 
591 
592     case PARSEOP_INCLUDE:
593 
594         /* Flush everything up to and including the include source line */
595 
596         LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber,
597             FileId);
598 
599         /* Create a new listing node and push it */
600 
601         LsPushNode (Op->Asl.Value.String);
602         return;
603 
604 
605     case PARSEOP_INCLUDE_END:
606 
607         /* Flush out the rest of the include file */
608 
609         LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber,
610             FileId);
611 
612         /* Pop off this listing node and go back to the parent file */
613 
614         (void) LsPopNode ();
615         return;
616 
617 
618     case PARSEOP_DEFAULT_ARG:
619 
620         if (Op->Asl.CompileFlags & OP_IS_RESOURCE_DESC)
621         {
622             LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.EndLogicalLine,
623                 FileId);
624         }
625         return;
626 
627 
628     default:
629 
630         /* All other opcodes have an AML opcode */
631 
632         break;
633     }
634 
635     /*
636      * Otherwise, we look at the AML opcode because we can
637      * switch on the opcode type, getting an entire class
638      * at once
639      */
640     switch (OpClass)
641     {
642     case AML_CLASS_ARGUMENT:       /* argument type only */
643     case AML_CLASS_INTERNAL:
644 
645         break;
646 
647     case AML_CLASS_NAMED_OBJECT:
648 
649         switch (Op->Asl.AmlOpcode)
650         {
651         case AML_FIELD_OP:
652         case AML_INDEX_FIELD_OP:
653         case AML_BANK_FIELD_OP:
654             /*
655              * For fields, we want to dump all the AML after the
656              * entire definition
657              */
658             LsWriteSourceLines (Op->Asl.EndLine, Op->Asl.EndLogicalLine,
659                 FileId);
660             break;
661 
662         case AML_NAME_OP:
663 
664             if (Op->Asl.CompileFlags & OP_IS_RESOURCE_DESC)
665             {
666                 LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber,
667                     FileId);
668             }
669             else
670             {
671                 /*
672                  * For fields, we want to dump all the AML after the
673                  * entire definition
674                  */
675                 LsWriteSourceLines (Op->Asl.EndLine, Op->Asl.EndLogicalLine,
676                     FileId);
677             }
678             break;
679 
680         default:
681 
682             LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber,
683                 FileId);
684             break;
685         }
686 
687         switch (Op->Asl.AmlOpcode)
688         {
689         case AML_SCOPE_OP:
690         case AML_ALIAS_OP:
691 
692             /* These opcodes do not declare a new object, ignore them */
693 
694             break;
695 
696         default:
697 
698             /* All other named object opcodes come here */
699 
700             switch (FileId)
701             {
702             case ASL_FILE_ASM_SOURCE_OUTPUT:
703             case ASL_FILE_C_SOURCE_OUTPUT:
704             case ASL_FILE_ASM_INCLUDE_OUTPUT:
705             case ASL_FILE_C_INCLUDE_OUTPUT:
706                 /*
707                  * For named objects, we will create a valid symbol so that the
708                  * AML code can be referenced from C or ASM
709                  */
710                 if (Op->Asl.ExternalName)
711                 {
712                     /* Get the full pathname associated with this node */
713 
714                     Pathname = AcpiNsGetExternalPathname (Op->Asl.Node);
715                     Length = strlen (Pathname);
716                     if (Length >= 4)
717                     {
718                         /* Convert all dots in the path to underscores */
719 
720                         for (i = 0; i < Length; i++)
721                         {
722                             if (Pathname[i] == '.')
723                             {
724                                 Pathname[i] = '_';
725                             }
726                         }
727 
728                         /* Create the appropriate symbol in the output file */
729 
730                         switch (FileId)
731                         {
732                         case ASL_FILE_ASM_SOURCE_OUTPUT:
733 
734                             FlPrintFile (FileId,
735                                 "%s_%s_%s  \\\n",
736                                 AslGbl_TableSignature, AslGbl_TableId, &Pathname[1]);
737                             break;
738 
739                         case ASL_FILE_C_SOURCE_OUTPUT:
740 
741                             FlPrintFile (FileId,
742                                 "    unsigned char    %s_%s_%s [] =\n    {\n",
743                                 AslGbl_TableSignature, AslGbl_TableId, &Pathname[1]);
744                             break;
745 
746                         case ASL_FILE_ASM_INCLUDE_OUTPUT:
747 
748                             FlPrintFile (FileId,
749                                 "extrn %s_%s_%s : byte\n",
750                                 AslGbl_TableSignature, AslGbl_TableId, &Pathname[1]);
751                             break;
752 
753                         case ASL_FILE_C_INCLUDE_OUTPUT:
754 
755                             FlPrintFile (FileId,
756                                 "extern unsigned char    %s_%s_%s [];\n",
757                                 AslGbl_TableSignature, AslGbl_TableId, &Pathname[1]);
758                             break;
759 
760                         default:
761                             break;
762                         }
763                     }
764 
765                     ACPI_FREE (Pathname);
766                 }
767                 break;
768 
769             default:
770 
771                 /* Nothing to do for listing file */
772 
773                 break;
774             }
775         }
776         break;
777 
778     case AML_CLASS_EXECUTE:
779     case AML_CLASS_CREATE:
780     default:
781 
782         if ((Op->Asl.ParseOpcode == PARSEOP_BUFFER) &&
783             (Op->Asl.CompileFlags & OP_IS_RESOURCE_DESC))
784         {
785             return;
786         }
787 
788         LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber,
789             FileId);
790         break;
791 
792     case AML_CLASS_UNKNOWN:
793 
794         break;
795     }
796 }
797 
798 
799 /*******************************************************************************
800  *
801  * FUNCTION:    LsFinishSourceListing
802  *
803  * PARAMETERS:  FileId          - ID of current listing file.
804  *
805  * RETURN:      None
806  *
807  * DESCRIPTION: Cleanup routine for the listing file. Flush the hex AML
808  *              listing buffer, and flush out any remaining lines in the
809  *              source input file.
810  *
811  ******************************************************************************/
812 
813 static void
814 LsFinishSourceListing (
815     UINT32                  FileId)
816 {
817 
818     if ((FileId == ASL_FILE_ASM_INCLUDE_OUTPUT) ||
819         (FileId == ASL_FILE_C_INCLUDE_OUTPUT))
820     {
821         return;
822     }
823 
824     LsFlushListingBuffer (FileId);
825     AslGbl_CurrentAmlOffset = 0;
826 
827     /* Flush any remaining text in the source file */
828 
829     if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
830     {
831         FlPrintFile (FileId, "    /*\n");
832     }
833 
834     while (LsWriteOneSourceLine (FileId))
835     { ; }
836 
837     if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
838     {
839         FlPrintFile (FileId, "\n     */\n    };\n");
840     }
841 
842     FlPrintFile (FileId, "\n");
843 
844     if (FileId == ASL_FILE_LISTING_OUTPUT)
845     {
846         /* Print a summary of the compile exceptions */
847 
848         FlPrintFile (FileId, "\n\nSummary of errors and warnings\n\n");
849         AePrintErrorLog (FileId);
850         FlPrintFile (FileId, "\n");
851         UtDisplayOneSummary (FileId, TRUE);
852         FlPrintFile (FileId, "\n");
853     }
854 }
855