asllisting.c revision 249112
1118611Snjl/******************************************************************************
2118611Snjl *
3118611Snjl * Module Name: asllisting - Listing file generation
4118611Snjl *
5118611Snjl *****************************************************************************/
6118611Snjl
7217365Sjkim/*
8245582Sjkim * Copyright (C) 2000 - 2013, Intel Corp.
9118611Snjl * All rights reserved.
10118611Snjl *
11217365Sjkim * Redistribution and use in source and binary forms, with or without
12217365Sjkim * modification, are permitted provided that the following conditions
13217365Sjkim * are met:
14217365Sjkim * 1. Redistributions of source code must retain the above copyright
15217365Sjkim *    notice, this list of conditions, and the following disclaimer,
16217365Sjkim *    without modification.
17217365Sjkim * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18217365Sjkim *    substantially similar to the "NO WARRANTY" disclaimer below
19217365Sjkim *    ("Disclaimer") and any redistribution must be conditioned upon
20217365Sjkim *    including a substantially similar Disclaimer requirement for further
21217365Sjkim *    binary redistribution.
22217365Sjkim * 3. Neither the names of the above-listed copyright holders nor the names
23217365Sjkim *    of any contributors may be used to endorse or promote products derived
24217365Sjkim *    from this software without specific prior written permission.
25118611Snjl *
26217365Sjkim * Alternatively, this software may be distributed under the terms of the
27217365Sjkim * GNU General Public License ("GPL") version 2 as published by the Free
28217365Sjkim * Software Foundation.
29118611Snjl *
30217365Sjkim * NO WARRANTY
31217365Sjkim * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32217365Sjkim * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33217365Sjkim * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34217365Sjkim * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35217365Sjkim * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36217365Sjkim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37217365Sjkim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38217365Sjkim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39217365Sjkim * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40217365Sjkim * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41217365Sjkim * POSSIBILITY OF SUCH DAMAGES.
42217365Sjkim */
43118611Snjl
44151937Sjkim#include <contrib/dev/acpica/compiler/aslcompiler.h>
45118611Snjl#include "aslcompiler.y.h"
46193529Sjkim#include <contrib/dev/acpica/include/amlcode.h>
47193529Sjkim#include <contrib/dev/acpica/include/acparser.h>
48193529Sjkim#include <contrib/dev/acpica/include/acnamesp.h>
49118611Snjl
50249112Sjkim
51118611Snjl#define _COMPONENT          ACPI_COMPILER
52249112Sjkim        ACPI_MODULE_NAME    ("asllisting")
53118611Snjl
54249112Sjkim
55151937Sjkim/* Local prototypes */
56118611Snjl
57151937Sjkimstatic void
58249112SjkimLsGenerateListing (
59249112Sjkim    UINT32                  FileId);
60151937Sjkim
61151937Sjkimstatic ACPI_STATUS
62151937SjkimLsAmlListingWalk (
63151937Sjkim    ACPI_PARSE_OBJECT       *Op,
64151937Sjkim    UINT32                  Level,
65151937Sjkim    void                    *Context);
66151937Sjkim
67249112Sjkimstatic ACPI_STATUS
68249112SjkimLsTreeWriteWalk (
69249112Sjkim    ACPI_PARSE_OBJECT       *Op,
70249112Sjkim    UINT32                  Level,
71249112Sjkim    void                    *Context);
72151937Sjkim
73151937Sjkimstatic void
74249112SjkimLsWriteNodeToListing (
75249112Sjkim    ACPI_PARSE_OBJECT       *Op,
76151937Sjkim    UINT32                  FileId);
77151937Sjkim
78151937Sjkimstatic void
79151937SjkimLsFinishSourceListing (
80151937Sjkim    UINT32                  FileId);
81151937Sjkim
82151937Sjkim
83118611Snjl/*******************************************************************************
84118611Snjl *
85245582Sjkim * FUNCTION:    LsDoListings
86245582Sjkim *
87249112Sjkim * PARAMETERS:  None. Examines the various output file global flags.
88245582Sjkim *
89245582Sjkim * RETURN:      None
90245582Sjkim *
91245582Sjkim * DESCRIPTION: Generate all requested listing files.
92245582Sjkim *
93245582Sjkim ******************************************************************************/
94245582Sjkim
95245582Sjkimvoid
96245582SjkimLsDoListings (
97245582Sjkim    void)
98245582Sjkim{
99245582Sjkim
100245582Sjkim    if (Gbl_C_OutputFlag)
101245582Sjkim    {
102245582Sjkim        LsGenerateListing (ASL_FILE_C_SOURCE_OUTPUT);
103245582Sjkim    }
104245582Sjkim
105245582Sjkim    if (Gbl_ListingFlag)
106245582Sjkim    {
107245582Sjkim        LsGenerateListing (ASL_FILE_LISTING_OUTPUT);
108245582Sjkim    }
109245582Sjkim
110245582Sjkim    if (Gbl_AsmOutputFlag)
111245582Sjkim    {
112245582Sjkim        LsGenerateListing (ASL_FILE_ASM_SOURCE_OUTPUT);
113245582Sjkim    }
114245582Sjkim
115245582Sjkim    if (Gbl_C_IncludeOutputFlag)
116245582Sjkim    {
117245582Sjkim        LsGenerateListing (ASL_FILE_C_INCLUDE_OUTPUT);
118245582Sjkim    }
119245582Sjkim
120245582Sjkim    if (Gbl_AsmIncludeOutputFlag)
121245582Sjkim    {
122245582Sjkim        LsGenerateListing (ASL_FILE_ASM_INCLUDE_OUTPUT);
123245582Sjkim    }
124245582Sjkim
125249112Sjkim    if (Gbl_C_OffsetTableFlag)
126167802Sjkim    {
127249112Sjkim        LsGenerateListing (ASL_FILE_C_OFFSET_OUTPUT);
128167802Sjkim    }
129167802Sjkim}
130167802Sjkim
131167802Sjkim
132167802Sjkim/*******************************************************************************
133167802Sjkim *
134249112Sjkim * FUNCTION:    LsGenerateListing
135118611Snjl *
136249112Sjkim * PARAMETERS:  FileId      - ID of listing file
137118611Snjl *
138245582Sjkim * RETURN:      None
139118611Snjl *
140249112Sjkim * DESCRIPTION: Generate a listing file. This can be one of the several types
141249112Sjkim *              of "listings" supported.
142118611Snjl *
143118611Snjl ******************************************************************************/
144118611Snjl
145151937Sjkimstatic void
146249112SjkimLsGenerateListing (
147249112Sjkim    UINT32                  FileId)
148118611Snjl{
149118611Snjl
150249112Sjkim    /* Start at the beginning of both the source and AML files */
151118611Snjl
152249112Sjkim    FlSeekFile (ASL_FILE_SOURCE_OUTPUT, 0);
153249112Sjkim    FlSeekFile (ASL_FILE_AML_OUTPUT, 0);
154249112Sjkim    Gbl_SourceLine = 0;
155249112Sjkim    Gbl_CurrentHexColumn = 0;
156249112Sjkim    LsPushNode (Gbl_Files[ASL_FILE_INPUT].Filename);
157249112Sjkim
158249112Sjkim    if (FileId == ASL_FILE_C_OFFSET_OUTPUT)
159118611Snjl    {
160249112Sjkim        /* Offset table file has a special header and footer */
161118611Snjl
162249112Sjkim        LsDoOffsetTableHeader (FileId);
163249112Sjkim
164249112Sjkim        TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, LsAmlOffsetWalk,
165249112Sjkim            NULL, (void *) ACPI_TO_POINTER (FileId));
166249112Sjkim        LsDoOffsetTableFooter (FileId);
167249112Sjkim        return;
168118611Snjl    }
169118611Snjl
170249112Sjkim    /* Process all parse nodes */
171118611Snjl
172249112Sjkim    TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, LsAmlListingWalk,
173249112Sjkim        NULL, (void *) ACPI_TO_POINTER (FileId));
174118611Snjl
175249112Sjkim    /* Final processing */
176118611Snjl
177249112Sjkim    LsFinishSourceListing (FileId);
178118611Snjl}
179118611Snjl
180118611Snjl
181118611Snjl/*******************************************************************************
182118611Snjl *
183118611Snjl * FUNCTION:    LsAmlListingWalk
184118611Snjl *
185118611Snjl * PARAMETERS:  ASL_WALK_CALLBACK
186118611Snjl *
187118611Snjl * RETURN:      Status
188118611Snjl *
189118611Snjl * DESCRIPTION: Process one node during a listing file generation.
190118611Snjl *
191118611Snjl ******************************************************************************/
192118611Snjl
193151937Sjkimstatic ACPI_STATUS
194118611SnjlLsAmlListingWalk (
195118611Snjl    ACPI_PARSE_OBJECT       *Op,
196118611Snjl    UINT32                  Level,
197118611Snjl    void                    *Context)
198118611Snjl{
199118611Snjl    UINT8                   FileByte;
200118611Snjl    UINT32                  i;
201167802Sjkim    UINT32                  FileId = (UINT32) ACPI_TO_INTEGER (Context);
202118611Snjl
203118611Snjl
204118611Snjl    LsWriteNodeToListing (Op, FileId);
205118611Snjl
206167802Sjkim    if (Op->Asl.CompileFlags & NODE_IS_RESOURCE_DATA)
207167802Sjkim    {
208167802Sjkim        /* Buffer is a resource template, don't dump the data all at once */
209167802Sjkim
210167802Sjkim        return (AE_OK);
211167802Sjkim    }
212167802Sjkim
213118611Snjl    /* Write the hex bytes to the listing file(s) (if requested) */
214118611Snjl
215118611Snjl    for (i = 0; i < Op->Asl.FinalAmlLength; i++)
216118611Snjl    {
217118611Snjl        if (ACPI_FAILURE (FlReadFile (ASL_FILE_AML_OUTPUT, &FileByte, 1)))
218118611Snjl        {
219118611Snjl            FlFileError (ASL_FILE_AML_OUTPUT, ASL_MSG_READ);
220118611Snjl            AslAbort ();
221118611Snjl        }
222118611Snjl        LsWriteListingHexBytes (&FileByte, 1, FileId);
223118611Snjl    }
224118611Snjl
225118611Snjl    return (AE_OK);
226118611Snjl}
227118611Snjl
228118611Snjl
229118611Snjl/*******************************************************************************
230118611Snjl *
231249112Sjkim * FUNCTION:    LsDumpParseTree, LsTreeWriteWalk
232118611Snjl *
233249112Sjkim * PARAMETERS:  None
234118611Snjl *
235118611Snjl * RETURN:      None
236118611Snjl *
237249112Sjkim * DESCRIPTION: Dump entire parse tree, for compiler debug only
238118611Snjl *
239118611Snjl ******************************************************************************/
240118611Snjl
241249112Sjkimvoid
242249112SjkimLsDumpParseTree (
243151937Sjkim    void)
244118611Snjl{
245118611Snjl
246249112Sjkim    if (!Gbl_DebugFlag)
247118611Snjl    {
248118611Snjl        return;
249118611Snjl    }
250118611Snjl
251249112Sjkim    DbgPrint (ASL_TREE_OUTPUT, "\nOriginal parse tree from parser:\n\n");
252249112Sjkim    TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD,
253249112Sjkim        LsTreeWriteWalk, NULL, NULL);
254118611Snjl}
255118611Snjl
256118611Snjl
257249112Sjkimstatic ACPI_STATUS
258249112SjkimLsTreeWriteWalk (
259249112Sjkim    ACPI_PARSE_OBJECT       *Op,
260249112Sjkim    UINT32                  Level,
261249112Sjkim    void                    *Context)
262118611Snjl{
263118611Snjl
264249112Sjkim    /* Debug output */
265118611Snjl
266249112Sjkim    DbgPrint (ASL_TREE_OUTPUT,
267249112Sjkim        "%5.5d [%2d]", Op->Asl.LogicalLineNumber, Level);
268249112Sjkim    UtPrintFormattedName (Op->Asl.ParseOpcode, Level);
269118611Snjl
270249112Sjkim    DbgPrint (ASL_TREE_OUTPUT, "\n");
271249112Sjkim    return (AE_OK);
272118611Snjl}
273118611Snjl
274118611Snjl
275118611Snjl/*******************************************************************************
276118611Snjl *
277118611Snjl * FUNCTION:    LsWriteNodeToListing
278118611Snjl *
279249112Sjkim * PARAMETERS:  Op              - Parse node to write to the listing file.
280118611Snjl *              FileId          - ID of current listing file
281118611Snjl *
282118611Snjl * RETURN:      None.
283118611Snjl *
284241973Sjkim * DESCRIPTION: Write "a node" to the listing file. This means to
285118611Snjl *              1) Write out all of the source text associated with the node
286118611Snjl *              2) Write out all of the AML bytes associated with the node
287118611Snjl *              3) Write any compiler exceptions associated with the node
288118611Snjl *
289118611Snjl ******************************************************************************/
290118611Snjl
291151937Sjkimstatic void
292118611SnjlLsWriteNodeToListing (
293118611Snjl    ACPI_PARSE_OBJECT       *Op,
294118611Snjl    UINT32                  FileId)
295118611Snjl{
296118611Snjl    const ACPI_OPCODE_INFO  *OpInfo;
297118611Snjl    UINT32                  OpClass;
298118611Snjl    char                    *Pathname;
299118611Snjl    UINT32                  Length;
300118611Snjl    UINT32                  i;
301118611Snjl
302118611Snjl
303118611Snjl    OpInfo  = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode);
304118611Snjl    OpClass = OpInfo->Class;
305118611Snjl
306151937Sjkim    /* TBD: clean this up with a single flag that says:
307151937Sjkim     * I start a named output block
308151937Sjkim     */
309118611Snjl    if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
310118611Snjl    {
311118611Snjl        switch (Op->Asl.ParseOpcode)
312118611Snjl        {
313118611Snjl        case PARSEOP_DEFINITIONBLOCK:
314118611Snjl        case PARSEOP_METHODCALL:
315118611Snjl        case PARSEOP_INCLUDE:
316118611Snjl        case PARSEOP_INCLUDE_END:
317118611Snjl        case PARSEOP_DEFAULT_ARG:
318118611Snjl
319118611Snjl            break;
320118611Snjl
321118611Snjl        default:
322118611Snjl            switch (OpClass)
323118611Snjl            {
324118611Snjl            case AML_CLASS_NAMED_OBJECT:
325118611Snjl                switch (Op->Asl.AmlOpcode)
326118611Snjl                {
327118611Snjl                case AML_SCOPE_OP:
328118611Snjl                case AML_ALIAS_OP:
329118611Snjl                    break;
330118611Snjl
331118611Snjl                default:
332118611Snjl                    if (Op->Asl.ExternalName)
333118611Snjl                    {
334118611Snjl                        LsFlushListingBuffer (FileId);
335118611Snjl                        FlPrintFile (FileId, "    };\n");
336118611Snjl                    }
337118611Snjl                    break;
338118611Snjl                }
339118611Snjl                break;
340118611Snjl
341118611Snjl            default:
342118611Snjl                /* Don't care about other objects */
343118611Snjl                break;
344118611Snjl            }
345118611Snjl            break;
346118611Snjl        }
347118611Snjl    }
348118611Snjl
349118611Snjl    /* These cases do not have a corresponding AML opcode */
350118611Snjl
351118611Snjl    switch (Op->Asl.ParseOpcode)
352118611Snjl    {
353118611Snjl    case PARSEOP_DEFINITIONBLOCK:
354118611Snjl
355118611Snjl        LsWriteSourceLines (Op->Asl.EndLine, Op->Asl.EndLogicalLine, FileId);
356118611Snjl
357118611Snjl        /* Use the table Signature and TableId to build a unique name */
358118611Snjl
359118611Snjl        if (FileId == ASL_FILE_ASM_SOURCE_OUTPUT)
360118611Snjl        {
361151937Sjkim            FlPrintFile (FileId,
362151937Sjkim                "%s_%s_Header \\\n",
363118611Snjl                Gbl_TableSignature, Gbl_TableId);
364118611Snjl        }
365118611Snjl        if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
366118611Snjl        {
367151937Sjkim            FlPrintFile (FileId,
368151937Sjkim                "    unsigned char    %s_%s_Header [] =\n    {\n",
369118611Snjl                Gbl_TableSignature, Gbl_TableId);
370118611Snjl        }
371118611Snjl        if (FileId == ASL_FILE_ASM_INCLUDE_OUTPUT)
372118611Snjl        {
373151937Sjkim            FlPrintFile (FileId,
374151937Sjkim                "extrn %s_%s_Header : byte\n",
375118611Snjl                Gbl_TableSignature, Gbl_TableId);
376118611Snjl        }
377118611Snjl        if (FileId == ASL_FILE_C_INCLUDE_OUTPUT)
378118611Snjl        {
379151937Sjkim            FlPrintFile (FileId,
380151937Sjkim                "extern unsigned char    %s_%s_Header [];\n",
381118611Snjl                Gbl_TableSignature, Gbl_TableId);
382118611Snjl        }
383118611Snjl        return;
384118611Snjl
385118611Snjl
386118611Snjl    case PARSEOP_METHODCALL:
387118611Snjl
388151937Sjkim        LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber,
389151937Sjkim            FileId);
390118611Snjl        return;
391118611Snjl
392118611Snjl
393118611Snjl    case PARSEOP_INCLUDE:
394118611Snjl
395151937Sjkim        /* Flush everything up to and including the include source line */
396118611Snjl
397151937Sjkim        LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber,
398151937Sjkim            FileId);
399151937Sjkim
400151937Sjkim        /* Create a new listing node and push it */
401151937Sjkim
402118611Snjl        LsPushNode (Op->Asl.Child->Asl.Value.String);
403118611Snjl        return;
404118611Snjl
405118611Snjl
406118611Snjl    case PARSEOP_INCLUDE_END:
407118611Snjl
408151937Sjkim        /* Flush out the rest of the include file */
409118611Snjl
410151937Sjkim        LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber,
411151937Sjkim            FileId);
412151937Sjkim
413151937Sjkim        /* Pop off this listing node and go back to the parent file */
414151937Sjkim
415151937Sjkim        (void) LsPopNode ();
416118611Snjl        return;
417118611Snjl
418118611Snjl
419118611Snjl    case PARSEOP_DEFAULT_ARG:
420167802Sjkim
421167802Sjkim        if (Op->Asl.CompileFlags & NODE_IS_RESOURCE_DESC)
422167802Sjkim        {
423167802Sjkim            LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.EndLogicalLine,
424167802Sjkim                FileId);
425167802Sjkim        }
426118611Snjl        return;
427118611Snjl
428118611Snjl
429118611Snjl    default:
430118611Snjl        /* All other opcodes have an AML opcode */
431118611Snjl        break;
432118611Snjl    }
433118611Snjl
434118611Snjl    /*
435118611Snjl     * Otherwise, we look at the AML opcode because we can
436118611Snjl     * switch on the opcode type, getting an entire class
437118611Snjl     * at once
438118611Snjl     */
439118611Snjl    switch (OpClass)
440118611Snjl    {
441118611Snjl    case AML_CLASS_ARGUMENT:       /* argument type only */
442118611Snjl    case AML_CLASS_INTERNAL:
443118611Snjl
444118611Snjl        break;
445118611Snjl
446118611Snjl
447118611Snjl    case AML_CLASS_NAMED_OBJECT:
448118611Snjl
449118611Snjl        switch (Op->Asl.AmlOpcode)
450118611Snjl        {
451118611Snjl        case AML_FIELD_OP:
452118611Snjl        case AML_INDEX_FIELD_OP:
453118611Snjl        case AML_BANK_FIELD_OP:
454118611Snjl
455151937Sjkim            /*
456151937Sjkim             * For fields, we want to dump all the AML after the
457151937Sjkim             * entire definition
458151937Sjkim             */
459151937Sjkim            LsWriteSourceLines (Op->Asl.EndLine, Op->Asl.EndLogicalLine,
460151937Sjkim                FileId);
461118611Snjl            break;
462118611Snjl
463167802Sjkim        case AML_NAME_OP:
464167802Sjkim
465167802Sjkim            if (Op->Asl.CompileFlags & NODE_IS_RESOURCE_DESC)
466167802Sjkim            {
467167802Sjkim                LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber,
468167802Sjkim                    FileId);
469167802Sjkim            }
470167802Sjkim            else
471167802Sjkim            {
472167802Sjkim                /*
473167802Sjkim                 * For fields, we want to dump all the AML after the
474167802Sjkim                 * entire definition
475167802Sjkim                 */
476167802Sjkim                LsWriteSourceLines (Op->Asl.EndLine, Op->Asl.EndLogicalLine,
477167802Sjkim                    FileId);
478167802Sjkim            }
479167802Sjkim            break;
480167802Sjkim
481118611Snjl        default:
482151937Sjkim            LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber,
483151937Sjkim                FileId);
484118611Snjl            break;
485118611Snjl        }
486118611Snjl
487118611Snjl        switch (Op->Asl.AmlOpcode)
488118611Snjl        {
489118611Snjl        case AML_SCOPE_OP:
490118611Snjl        case AML_ALIAS_OP:
491118611Snjl
492118611Snjl            /* These opcodes do not declare a new object, ignore them */
493118611Snjl
494118611Snjl            break;
495118611Snjl
496118611Snjl        default:
497118611Snjl
498118611Snjl            /* All other named object opcodes come here */
499118611Snjl
500118611Snjl            switch (FileId)
501118611Snjl            {
502118611Snjl            case ASL_FILE_ASM_SOURCE_OUTPUT:
503118611Snjl            case ASL_FILE_C_SOURCE_OUTPUT:
504118611Snjl            case ASL_FILE_ASM_INCLUDE_OUTPUT:
505118611Snjl            case ASL_FILE_C_INCLUDE_OUTPUT:
506118611Snjl
507118611Snjl                /*
508118611Snjl                 * For named objects, we will create a valid symbol so that the
509118611Snjl                 * AML code can be referenced from C or ASM
510118611Snjl                 */
511118611Snjl                if (Op->Asl.ExternalName)
512118611Snjl                {
513118611Snjl                    /* Get the full pathname associated with this node */
514118611Snjl
515118611Snjl                    Pathname = AcpiNsGetExternalPathname (Op->Asl.Node);
516118611Snjl                    Length = strlen (Pathname);
517118611Snjl                    if (Length >= 4)
518118611Snjl                    {
519118611Snjl                        /* Convert all dots in the path to underscores */
520118611Snjl
521118611Snjl                        for (i = 0; i < Length; i++)
522118611Snjl                        {
523118611Snjl                            if (Pathname[i] == '.')
524118611Snjl                            {
525118611Snjl                                Pathname[i] = '_';
526118611Snjl                            }
527118611Snjl                        }
528118611Snjl
529118611Snjl                        /* Create the appropriate symbol in the output file */
530118611Snjl
531118611Snjl                        if (FileId == ASL_FILE_ASM_SOURCE_OUTPUT)
532118611Snjl                        {
533151937Sjkim                            FlPrintFile (FileId,
534151937Sjkim                                "%s_%s_%s  \\\n",
535118611Snjl                                Gbl_TableSignature, Gbl_TableId, &Pathname[1]);
536118611Snjl                        }
537118611Snjl                        if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
538118611Snjl                        {
539151937Sjkim                            FlPrintFile (FileId,
540151937Sjkim                                "    unsigned char    %s_%s_%s [] =\n    {\n",
541118611Snjl                                Gbl_TableSignature, Gbl_TableId, &Pathname[1]);
542118611Snjl                        }
543118611Snjl                        if (FileId == ASL_FILE_ASM_INCLUDE_OUTPUT)
544118611Snjl                        {
545151937Sjkim                            FlPrintFile (FileId,
546151937Sjkim                                "extrn %s_%s_%s : byte\n",
547118611Snjl                                Gbl_TableSignature, Gbl_TableId, &Pathname[1]);
548118611Snjl                        }
549118611Snjl                        if (FileId == ASL_FILE_C_INCLUDE_OUTPUT)
550118611Snjl                        {
551151937Sjkim                            FlPrintFile (FileId,
552151937Sjkim                                "extern unsigned char    %s_%s_%s [];\n",
553118611Snjl                                Gbl_TableSignature, Gbl_TableId, &Pathname[1]);
554118611Snjl                        }
555118611Snjl                    }
556167802Sjkim                    ACPI_FREE (Pathname);
557118611Snjl                }
558118611Snjl                break;
559118611Snjl
560118611Snjl            default:
561118611Snjl                /* Nothing to do for listing file */
562118611Snjl                break;
563118611Snjl            }
564118611Snjl        }
565118611Snjl        break;
566118611Snjl
567118611Snjl    case AML_CLASS_EXECUTE:
568118611Snjl    case AML_CLASS_CREATE:
569118611Snjl    default:
570118611Snjl
571167802Sjkim        if ((Op->Asl.ParseOpcode == PARSEOP_BUFFER) &&
572167802Sjkim            (Op->Asl.CompileFlags & NODE_IS_RESOURCE_DESC))
573167802Sjkim        {
574167802Sjkim            return;
575167802Sjkim        }
576167802Sjkim
577151937Sjkim        LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber,
578151937Sjkim            FileId);
579118611Snjl        break;
580118611Snjl
581118611Snjl    case AML_CLASS_UNKNOWN:
582118611Snjl        break;
583118611Snjl    }
584118611Snjl}
585249112Sjkim
586249112Sjkim
587249112Sjkim/*******************************************************************************
588249112Sjkim *
589249112Sjkim * FUNCTION:    LsFinishSourceListing
590249112Sjkim *
591249112Sjkim * PARAMETERS:  FileId          - ID of current listing file.
592249112Sjkim *
593249112Sjkim * RETURN:      None
594249112Sjkim *
595249112Sjkim * DESCRIPTION: Cleanup routine for the listing file. Flush the hex AML
596249112Sjkim *              listing buffer, and flush out any remaining lines in the
597249112Sjkim *              source input file.
598249112Sjkim *
599249112Sjkim ******************************************************************************/
600249112Sjkim
601249112Sjkimstatic void
602249112SjkimLsFinishSourceListing (
603249112Sjkim    UINT32                  FileId)
604249112Sjkim{
605249112Sjkim
606249112Sjkim    if ((FileId == ASL_FILE_ASM_INCLUDE_OUTPUT) ||
607249112Sjkim        (FileId == ASL_FILE_C_INCLUDE_OUTPUT))
608249112Sjkim    {
609249112Sjkim        return;
610249112Sjkim    }
611249112Sjkim
612249112Sjkim    LsFlushListingBuffer (FileId);
613249112Sjkim    Gbl_CurrentAmlOffset = 0;
614249112Sjkim
615249112Sjkim    /* Flush any remaining text in the source file */
616249112Sjkim
617249112Sjkim    if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
618249112Sjkim    {
619249112Sjkim        FlPrintFile (FileId, "    /*\n");
620249112Sjkim    }
621249112Sjkim
622249112Sjkim    while (LsWriteOneSourceLine (FileId))
623249112Sjkim    { ; }
624249112Sjkim
625249112Sjkim    if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
626249112Sjkim    {
627249112Sjkim        FlPrintFile (FileId, "\n     */\n    };\n");
628249112Sjkim    }
629249112Sjkim
630249112Sjkim    FlPrintFile (FileId, "\n");
631249112Sjkim
632249112Sjkim    if (FileId == ASL_FILE_LISTING_OUTPUT)
633249112Sjkim    {
634249112Sjkim        /* Print a summary of the compile exceptions */
635249112Sjkim
636249112Sjkim        FlPrintFile (FileId, "\n\nSummary of errors and warnings\n\n");
637249112Sjkim        AePrintErrorLog (FileId);
638249112Sjkim        FlPrintFile (FileId, "\n");
639249112Sjkim        UtDisplaySummary (FileId);
640249112Sjkim        FlPrintFile (FileId, "\n");
641249112Sjkim    }
642249112Sjkim}
643