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