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    {
160250838Sjkim        Gbl_CurrentAmlOffset = 0;
161250838Sjkim
162249112Sjkim        /* Offset table file has a special header and footer */
163118611Snjl
164249112Sjkim        LsDoOffsetTableHeader (FileId);
165249112Sjkim
166249112Sjkim        TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, LsAmlOffsetWalk,
167249112Sjkim            NULL, (void *) ACPI_TO_POINTER (FileId));
168249112Sjkim        LsDoOffsetTableFooter (FileId);
169249112Sjkim        return;
170118611Snjl    }
171118611Snjl
172249112Sjkim    /* Process all parse nodes */
173118611Snjl
174249112Sjkim    TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, LsAmlListingWalk,
175249112Sjkim        NULL, (void *) ACPI_TO_POINTER (FileId));
176118611Snjl
177249112Sjkim    /* Final processing */
178118611Snjl
179249112Sjkim    LsFinishSourceListing (FileId);
180118611Snjl}
181118611Snjl
182118611Snjl
183118611Snjl/*******************************************************************************
184118611Snjl *
185118611Snjl * FUNCTION:    LsAmlListingWalk
186118611Snjl *
187118611Snjl * PARAMETERS:  ASL_WALK_CALLBACK
188118611Snjl *
189118611Snjl * RETURN:      Status
190118611Snjl *
191118611Snjl * DESCRIPTION: Process one node during a listing file generation.
192118611Snjl *
193118611Snjl ******************************************************************************/
194118611Snjl
195151937Sjkimstatic ACPI_STATUS
196118611SnjlLsAmlListingWalk (
197118611Snjl    ACPI_PARSE_OBJECT       *Op,
198118611Snjl    UINT32                  Level,
199118611Snjl    void                    *Context)
200118611Snjl{
201118611Snjl    UINT8                   FileByte;
202118611Snjl    UINT32                  i;
203167802Sjkim    UINT32                  FileId = (UINT32) ACPI_TO_INTEGER (Context);
204118611Snjl
205118611Snjl
206118611Snjl    LsWriteNodeToListing (Op, FileId);
207118611Snjl
208167802Sjkim    if (Op->Asl.CompileFlags & NODE_IS_RESOURCE_DATA)
209167802Sjkim    {
210167802Sjkim        /* Buffer is a resource template, don't dump the data all at once */
211167802Sjkim
212167802Sjkim        return (AE_OK);
213167802Sjkim    }
214167802Sjkim
215118611Snjl    /* Write the hex bytes to the listing file(s) (if requested) */
216118611Snjl
217118611Snjl    for (i = 0; i < Op->Asl.FinalAmlLength; i++)
218118611Snjl    {
219118611Snjl        if (ACPI_FAILURE (FlReadFile (ASL_FILE_AML_OUTPUT, &FileByte, 1)))
220118611Snjl        {
221118611Snjl            FlFileError (ASL_FILE_AML_OUTPUT, ASL_MSG_READ);
222118611Snjl            AslAbort ();
223118611Snjl        }
224118611Snjl        LsWriteListingHexBytes (&FileByte, 1, FileId);
225118611Snjl    }
226118611Snjl
227118611Snjl    return (AE_OK);
228118611Snjl}
229118611Snjl
230118611Snjl
231118611Snjl/*******************************************************************************
232118611Snjl *
233249112Sjkim * FUNCTION:    LsDumpParseTree, LsTreeWriteWalk
234118611Snjl *
235249112Sjkim * PARAMETERS:  None
236118611Snjl *
237118611Snjl * RETURN:      None
238118611Snjl *
239249112Sjkim * DESCRIPTION: Dump entire parse tree, for compiler debug only
240118611Snjl *
241118611Snjl ******************************************************************************/
242118611Snjl
243249112Sjkimvoid
244249112SjkimLsDumpParseTree (
245151937Sjkim    void)
246118611Snjl{
247118611Snjl
248249112Sjkim    if (!Gbl_DebugFlag)
249118611Snjl    {
250118611Snjl        return;
251118611Snjl    }
252118611Snjl
253249112Sjkim    DbgPrint (ASL_TREE_OUTPUT, "\nOriginal parse tree from parser:\n\n");
254249112Sjkim    TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD,
255249112Sjkim        LsTreeWriteWalk, NULL, NULL);
256118611Snjl}
257118611Snjl
258118611Snjl
259249112Sjkimstatic ACPI_STATUS
260249112SjkimLsTreeWriteWalk (
261249112Sjkim    ACPI_PARSE_OBJECT       *Op,
262249112Sjkim    UINT32                  Level,
263249112Sjkim    void                    *Context)
264118611Snjl{
265118611Snjl
266249112Sjkim    /* Debug output */
267118611Snjl
268249112Sjkim    DbgPrint (ASL_TREE_OUTPUT,
269249112Sjkim        "%5.5d [%2d]", Op->Asl.LogicalLineNumber, Level);
270250838Sjkim
271249112Sjkim    UtPrintFormattedName (Op->Asl.ParseOpcode, Level);
272118611Snjl
273250838Sjkim    DbgPrint (ASL_TREE_OUTPUT, "    (%.4X)\n", Op->Asl.ParseOpcode);
274249112Sjkim    return (AE_OK);
275118611Snjl}
276118611Snjl
277118611Snjl
278118611Snjl/*******************************************************************************
279118611Snjl *
280118611Snjl * FUNCTION:    LsWriteNodeToListing
281118611Snjl *
282249112Sjkim * PARAMETERS:  Op              - Parse node to write to the listing file.
283118611Snjl *              FileId          - ID of current listing file
284118611Snjl *
285118611Snjl * RETURN:      None.
286118611Snjl *
287241973Sjkim * DESCRIPTION: Write "a node" to the listing file. This means to
288118611Snjl *              1) Write out all of the source text associated with the node
289118611Snjl *              2) Write out all of the AML bytes associated with the node
290118611Snjl *              3) Write any compiler exceptions associated with the node
291118611Snjl *
292118611Snjl ******************************************************************************/
293118611Snjl
294151937Sjkimstatic void
295118611SnjlLsWriteNodeToListing (
296118611Snjl    ACPI_PARSE_OBJECT       *Op,
297118611Snjl    UINT32                  FileId)
298118611Snjl{
299118611Snjl    const ACPI_OPCODE_INFO  *OpInfo;
300118611Snjl    UINT32                  OpClass;
301118611Snjl    char                    *Pathname;
302118611Snjl    UINT32                  Length;
303118611Snjl    UINT32                  i;
304118611Snjl
305118611Snjl
306118611Snjl    OpInfo  = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode);
307118611Snjl    OpClass = OpInfo->Class;
308118611Snjl
309151937Sjkim    /* TBD: clean this up with a single flag that says:
310151937Sjkim     * I start a named output block
311151937Sjkim     */
312118611Snjl    if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
313118611Snjl    {
314118611Snjl        switch (Op->Asl.ParseOpcode)
315118611Snjl        {
316118611Snjl        case PARSEOP_DEFINITIONBLOCK:
317118611Snjl        case PARSEOP_METHODCALL:
318118611Snjl        case PARSEOP_INCLUDE:
319118611Snjl        case PARSEOP_INCLUDE_END:
320118611Snjl        case PARSEOP_DEFAULT_ARG:
321118611Snjl
322118611Snjl            break;
323118611Snjl
324118611Snjl        default:
325250838Sjkim
326118611Snjl            switch (OpClass)
327118611Snjl            {
328118611Snjl            case AML_CLASS_NAMED_OBJECT:
329250838Sjkim
330118611Snjl                switch (Op->Asl.AmlOpcode)
331118611Snjl                {
332118611Snjl                case AML_SCOPE_OP:
333118611Snjl                case AML_ALIAS_OP:
334250838Sjkim
335118611Snjl                    break;
336118611Snjl
337118611Snjl                default:
338250838Sjkim
339118611Snjl                    if (Op->Asl.ExternalName)
340118611Snjl                    {
341118611Snjl                        LsFlushListingBuffer (FileId);
342118611Snjl                        FlPrintFile (FileId, "    };\n");
343118611Snjl                    }
344118611Snjl                    break;
345118611Snjl                }
346118611Snjl                break;
347118611Snjl
348118611Snjl            default:
349250838Sjkim
350118611Snjl                /* Don't care about other objects */
351250838Sjkim
352118611Snjl                break;
353118611Snjl            }
354118611Snjl            break;
355118611Snjl        }
356118611Snjl    }
357118611Snjl
358118611Snjl    /* These cases do not have a corresponding AML opcode */
359118611Snjl
360118611Snjl    switch (Op->Asl.ParseOpcode)
361118611Snjl    {
362118611Snjl    case PARSEOP_DEFINITIONBLOCK:
363118611Snjl
364118611Snjl        LsWriteSourceLines (Op->Asl.EndLine, Op->Asl.EndLogicalLine, FileId);
365118611Snjl
366118611Snjl        /* Use the table Signature and TableId to build a unique name */
367118611Snjl
368118611Snjl        if (FileId == ASL_FILE_ASM_SOURCE_OUTPUT)
369118611Snjl        {
370151937Sjkim            FlPrintFile (FileId,
371151937Sjkim                "%s_%s_Header \\\n",
372118611Snjl                Gbl_TableSignature, Gbl_TableId);
373118611Snjl        }
374118611Snjl        if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
375118611Snjl        {
376151937Sjkim            FlPrintFile (FileId,
377151937Sjkim                "    unsigned char    %s_%s_Header [] =\n    {\n",
378118611Snjl                Gbl_TableSignature, Gbl_TableId);
379118611Snjl        }
380118611Snjl        if (FileId == ASL_FILE_ASM_INCLUDE_OUTPUT)
381118611Snjl        {
382151937Sjkim            FlPrintFile (FileId,
383151937Sjkim                "extrn %s_%s_Header : byte\n",
384118611Snjl                Gbl_TableSignature, Gbl_TableId);
385118611Snjl        }
386118611Snjl        if (FileId == ASL_FILE_C_INCLUDE_OUTPUT)
387118611Snjl        {
388151937Sjkim            FlPrintFile (FileId,
389151937Sjkim                "extern unsigned char    %s_%s_Header [];\n",
390118611Snjl                Gbl_TableSignature, Gbl_TableId);
391118611Snjl        }
392118611Snjl        return;
393118611Snjl
394118611Snjl
395118611Snjl    case PARSEOP_METHODCALL:
396118611Snjl
397151937Sjkim        LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber,
398151937Sjkim            FileId);
399118611Snjl        return;
400118611Snjl
401118611Snjl
402118611Snjl    case PARSEOP_INCLUDE:
403118611Snjl
404151937Sjkim        /* Flush everything up to and including the include source line */
405118611Snjl
406151937Sjkim        LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber,
407151937Sjkim            FileId);
408151937Sjkim
409151937Sjkim        /* Create a new listing node and push it */
410151937Sjkim
411118611Snjl        LsPushNode (Op->Asl.Child->Asl.Value.String);
412118611Snjl        return;
413118611Snjl
414118611Snjl
415118611Snjl    case PARSEOP_INCLUDE_END:
416118611Snjl
417151937Sjkim        /* Flush out the rest of the include file */
418118611Snjl
419151937Sjkim        LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber,
420151937Sjkim            FileId);
421151937Sjkim
422151937Sjkim        /* Pop off this listing node and go back to the parent file */
423151937Sjkim
424151937Sjkim        (void) LsPopNode ();
425118611Snjl        return;
426118611Snjl
427118611Snjl
428118611Snjl    case PARSEOP_DEFAULT_ARG:
429167802Sjkim
430167802Sjkim        if (Op->Asl.CompileFlags & NODE_IS_RESOURCE_DESC)
431167802Sjkim        {
432167802Sjkim            LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.EndLogicalLine,
433167802Sjkim                FileId);
434167802Sjkim        }
435118611Snjl        return;
436118611Snjl
437118611Snjl
438118611Snjl    default:
439250838Sjkim
440118611Snjl        /* All other opcodes have an AML opcode */
441250838Sjkim
442118611Snjl        break;
443118611Snjl    }
444118611Snjl
445118611Snjl    /*
446118611Snjl     * Otherwise, we look at the AML opcode because we can
447118611Snjl     * switch on the opcode type, getting an entire class
448118611Snjl     * at once
449118611Snjl     */
450118611Snjl    switch (OpClass)
451118611Snjl    {
452118611Snjl    case AML_CLASS_ARGUMENT:       /* argument type only */
453118611Snjl    case AML_CLASS_INTERNAL:
454118611Snjl
455118611Snjl        break;
456118611Snjl
457118611Snjl    case AML_CLASS_NAMED_OBJECT:
458118611Snjl
459118611Snjl        switch (Op->Asl.AmlOpcode)
460118611Snjl        {
461118611Snjl        case AML_FIELD_OP:
462118611Snjl        case AML_INDEX_FIELD_OP:
463118611Snjl        case AML_BANK_FIELD_OP:
464151937Sjkim            /*
465151937Sjkim             * For fields, we want to dump all the AML after the
466151937Sjkim             * entire definition
467151937Sjkim             */
468151937Sjkim            LsWriteSourceLines (Op->Asl.EndLine, Op->Asl.EndLogicalLine,
469151937Sjkim                FileId);
470118611Snjl            break;
471118611Snjl
472167802Sjkim        case AML_NAME_OP:
473167802Sjkim
474167802Sjkim            if (Op->Asl.CompileFlags & NODE_IS_RESOURCE_DESC)
475167802Sjkim            {
476167802Sjkim                LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber,
477167802Sjkim                    FileId);
478167802Sjkim            }
479167802Sjkim            else
480167802Sjkim            {
481167802Sjkim                /*
482167802Sjkim                 * For fields, we want to dump all the AML after the
483167802Sjkim                 * entire definition
484167802Sjkim                 */
485167802Sjkim                LsWriteSourceLines (Op->Asl.EndLine, Op->Asl.EndLogicalLine,
486167802Sjkim                    FileId);
487167802Sjkim            }
488167802Sjkim            break;
489167802Sjkim
490118611Snjl        default:
491250838Sjkim
492151937Sjkim            LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber,
493151937Sjkim                FileId);
494118611Snjl            break;
495118611Snjl        }
496118611Snjl
497118611Snjl        switch (Op->Asl.AmlOpcode)
498118611Snjl        {
499118611Snjl        case AML_SCOPE_OP:
500118611Snjl        case AML_ALIAS_OP:
501118611Snjl
502118611Snjl            /* These opcodes do not declare a new object, ignore them */
503118611Snjl
504118611Snjl            break;
505118611Snjl
506118611Snjl        default:
507118611Snjl
508118611Snjl            /* All other named object opcodes come here */
509118611Snjl
510118611Snjl            switch (FileId)
511118611Snjl            {
512118611Snjl            case ASL_FILE_ASM_SOURCE_OUTPUT:
513118611Snjl            case ASL_FILE_C_SOURCE_OUTPUT:
514118611Snjl            case ASL_FILE_ASM_INCLUDE_OUTPUT:
515118611Snjl            case ASL_FILE_C_INCLUDE_OUTPUT:
516118611Snjl                /*
517118611Snjl                 * For named objects, we will create a valid symbol so that the
518118611Snjl                 * AML code can be referenced from C or ASM
519118611Snjl                 */
520118611Snjl                if (Op->Asl.ExternalName)
521118611Snjl                {
522118611Snjl                    /* Get the full pathname associated with this node */
523118611Snjl
524118611Snjl                    Pathname = AcpiNsGetExternalPathname (Op->Asl.Node);
525118611Snjl                    Length = strlen (Pathname);
526118611Snjl                    if (Length >= 4)
527118611Snjl                    {
528118611Snjl                        /* Convert all dots in the path to underscores */
529118611Snjl
530118611Snjl                        for (i = 0; i < Length; i++)
531118611Snjl                        {
532118611Snjl                            if (Pathname[i] == '.')
533118611Snjl                            {
534118611Snjl                                Pathname[i] = '_';
535118611Snjl                            }
536118611Snjl                        }
537118611Snjl
538118611Snjl                        /* Create the appropriate symbol in the output file */
539118611Snjl
540118611Snjl                        if (FileId == ASL_FILE_ASM_SOURCE_OUTPUT)
541118611Snjl                        {
542151937Sjkim                            FlPrintFile (FileId,
543151937Sjkim                                "%s_%s_%s  \\\n",
544118611Snjl                                Gbl_TableSignature, Gbl_TableId, &Pathname[1]);
545118611Snjl                        }
546118611Snjl                        if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
547118611Snjl                        {
548151937Sjkim                            FlPrintFile (FileId,
549151937Sjkim                                "    unsigned char    %s_%s_%s [] =\n    {\n",
550118611Snjl                                Gbl_TableSignature, Gbl_TableId, &Pathname[1]);
551118611Snjl                        }
552118611Snjl                        if (FileId == ASL_FILE_ASM_INCLUDE_OUTPUT)
553118611Snjl                        {
554151937Sjkim                            FlPrintFile (FileId,
555151937Sjkim                                "extrn %s_%s_%s : byte\n",
556118611Snjl                                Gbl_TableSignature, Gbl_TableId, &Pathname[1]);
557118611Snjl                        }
558118611Snjl                        if (FileId == ASL_FILE_C_INCLUDE_OUTPUT)
559118611Snjl                        {
560151937Sjkim                            FlPrintFile (FileId,
561151937Sjkim                                "extern unsigned char    %s_%s_%s [];\n",
562118611Snjl                                Gbl_TableSignature, Gbl_TableId, &Pathname[1]);
563118611Snjl                        }
564118611Snjl                    }
565167802Sjkim                    ACPI_FREE (Pathname);
566118611Snjl                }
567118611Snjl                break;
568118611Snjl
569118611Snjl            default:
570250838Sjkim
571118611Snjl                /* Nothing to do for listing file */
572250838Sjkim
573118611Snjl                break;
574118611Snjl            }
575118611Snjl        }
576118611Snjl        break;
577118611Snjl
578118611Snjl    case AML_CLASS_EXECUTE:
579118611Snjl    case AML_CLASS_CREATE:
580118611Snjl    default:
581118611Snjl
582167802Sjkim        if ((Op->Asl.ParseOpcode == PARSEOP_BUFFER) &&
583167802Sjkim            (Op->Asl.CompileFlags & NODE_IS_RESOURCE_DESC))
584167802Sjkim        {
585167802Sjkim            return;
586167802Sjkim        }
587167802Sjkim
588151937Sjkim        LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber,
589151937Sjkim            FileId);
590118611Snjl        break;
591118611Snjl
592118611Snjl    case AML_CLASS_UNKNOWN:
593250838Sjkim
594118611Snjl        break;
595118611Snjl    }
596118611Snjl}
597249112Sjkim
598249112Sjkim
599249112Sjkim/*******************************************************************************
600249112Sjkim *
601249112Sjkim * FUNCTION:    LsFinishSourceListing
602249112Sjkim *
603249112Sjkim * PARAMETERS:  FileId          - ID of current listing file.
604249112Sjkim *
605249112Sjkim * RETURN:      None
606249112Sjkim *
607249112Sjkim * DESCRIPTION: Cleanup routine for the listing file. Flush the hex AML
608249112Sjkim *              listing buffer, and flush out any remaining lines in the
609249112Sjkim *              source input file.
610249112Sjkim *
611249112Sjkim ******************************************************************************/
612249112Sjkim
613249112Sjkimstatic void
614249112SjkimLsFinishSourceListing (
615249112Sjkim    UINT32                  FileId)
616249112Sjkim{
617249112Sjkim
618249112Sjkim    if ((FileId == ASL_FILE_ASM_INCLUDE_OUTPUT) ||
619249112Sjkim        (FileId == ASL_FILE_C_INCLUDE_OUTPUT))
620249112Sjkim    {
621249112Sjkim        return;
622249112Sjkim    }
623249112Sjkim
624249112Sjkim    LsFlushListingBuffer (FileId);
625249112Sjkim    Gbl_CurrentAmlOffset = 0;
626249112Sjkim
627249112Sjkim    /* Flush any remaining text in the source file */
628249112Sjkim
629249112Sjkim    if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
630249112Sjkim    {
631249112Sjkim        FlPrintFile (FileId, "    /*\n");
632249112Sjkim    }
633249112Sjkim
634249112Sjkim    while (LsWriteOneSourceLine (FileId))
635249112Sjkim    { ; }
636249112Sjkim
637249112Sjkim    if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
638249112Sjkim    {
639249112Sjkim        FlPrintFile (FileId, "\n     */\n    };\n");
640249112Sjkim    }
641249112Sjkim
642249112Sjkim    FlPrintFile (FileId, "\n");
643249112Sjkim
644249112Sjkim    if (FileId == ASL_FILE_LISTING_OUTPUT)
645249112Sjkim    {
646249112Sjkim        /* Print a summary of the compile exceptions */
647249112Sjkim
648249112Sjkim        FlPrintFile (FileId, "\n\nSummary of errors and warnings\n\n");
649249112Sjkim        AePrintErrorLog (FileId);
650249112Sjkim        FlPrintFile (FileId, "\n");
651249112Sjkim        UtDisplaySummary (FileId);
652249112Sjkim        FlPrintFile (FileId, "\n");
653249112Sjkim    }
654249112Sjkim}
655