asllisting.c revision 281687
1118611Snjl/******************************************************************************
2118611Snjl *
3118611Snjl * Module Name: asllisting - Listing file generation
4118611Snjl *
5118611Snjl *****************************************************************************/
6118611Snjl
7217365Sjkim/*
8281075Sdim * Copyright (C) 2000 - 2015, 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
273281687Sjkim    DbgPrint (ASL_TREE_OUTPUT, "    (%.4X) Flags %8.8X",
274281687Sjkim        Op->Asl.ParseOpcode, Op->Asl.CompileFlags);
275281687Sjkim    TrPrintNodeCompileFlags (Op->Asl.CompileFlags);
276281687Sjkim    DbgPrint (ASL_TREE_OUTPUT, "\n");
277249112Sjkim    return (AE_OK);
278118611Snjl}
279118611Snjl
280118611Snjl
281118611Snjl/*******************************************************************************
282118611Snjl *
283118611Snjl * FUNCTION:    LsWriteNodeToListing
284118611Snjl *
285249112Sjkim * PARAMETERS:  Op              - Parse node to write to the listing file.
286118611Snjl *              FileId          - ID of current listing file
287118611Snjl *
288118611Snjl * RETURN:      None.
289118611Snjl *
290241973Sjkim * DESCRIPTION: Write "a node" to the listing file. This means to
291118611Snjl *              1) Write out all of the source text associated with the node
292118611Snjl *              2) Write out all of the AML bytes associated with the node
293118611Snjl *              3) Write any compiler exceptions associated with the node
294118611Snjl *
295118611Snjl ******************************************************************************/
296118611Snjl
297151937Sjkimstatic void
298118611SnjlLsWriteNodeToListing (
299118611Snjl    ACPI_PARSE_OBJECT       *Op,
300118611Snjl    UINT32                  FileId)
301118611Snjl{
302118611Snjl    const ACPI_OPCODE_INFO  *OpInfo;
303118611Snjl    UINT32                  OpClass;
304118611Snjl    char                    *Pathname;
305118611Snjl    UINT32                  Length;
306118611Snjl    UINT32                  i;
307118611Snjl
308118611Snjl
309118611Snjl    OpInfo  = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode);
310118611Snjl    OpClass = OpInfo->Class;
311118611Snjl
312151937Sjkim    /* TBD: clean this up with a single flag that says:
313151937Sjkim     * I start a named output block
314151937Sjkim     */
315118611Snjl    if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
316118611Snjl    {
317118611Snjl        switch (Op->Asl.ParseOpcode)
318118611Snjl        {
319118611Snjl        case PARSEOP_DEFINITIONBLOCK:
320118611Snjl        case PARSEOP_METHODCALL:
321118611Snjl        case PARSEOP_INCLUDE:
322118611Snjl        case PARSEOP_INCLUDE_END:
323118611Snjl        case PARSEOP_DEFAULT_ARG:
324118611Snjl
325118611Snjl            break;
326118611Snjl
327118611Snjl        default:
328250838Sjkim
329118611Snjl            switch (OpClass)
330118611Snjl            {
331118611Snjl            case AML_CLASS_NAMED_OBJECT:
332250838Sjkim
333118611Snjl                switch (Op->Asl.AmlOpcode)
334118611Snjl                {
335118611Snjl                case AML_SCOPE_OP:
336118611Snjl                case AML_ALIAS_OP:
337250838Sjkim
338118611Snjl                    break;
339118611Snjl
340118611Snjl                default:
341250838Sjkim
342118611Snjl                    if (Op->Asl.ExternalName)
343118611Snjl                    {
344118611Snjl                        LsFlushListingBuffer (FileId);
345118611Snjl                        FlPrintFile (FileId, "    };\n");
346118611Snjl                    }
347118611Snjl                    break;
348118611Snjl                }
349118611Snjl                break;
350118611Snjl
351118611Snjl            default:
352250838Sjkim
353118611Snjl                /* Don't care about other objects */
354250838Sjkim
355118611Snjl                break;
356118611Snjl            }
357118611Snjl            break;
358118611Snjl        }
359118611Snjl    }
360118611Snjl
361118611Snjl    /* These cases do not have a corresponding AML opcode */
362118611Snjl
363118611Snjl    switch (Op->Asl.ParseOpcode)
364118611Snjl    {
365118611Snjl    case PARSEOP_DEFINITIONBLOCK:
366118611Snjl
367118611Snjl        LsWriteSourceLines (Op->Asl.EndLine, Op->Asl.EndLogicalLine, FileId);
368118611Snjl
369118611Snjl        /* Use the table Signature and TableId to build a unique name */
370118611Snjl
371118611Snjl        if (FileId == ASL_FILE_ASM_SOURCE_OUTPUT)
372118611Snjl        {
373151937Sjkim            FlPrintFile (FileId,
374151937Sjkim                "%s_%s_Header \\\n",
375118611Snjl                Gbl_TableSignature, Gbl_TableId);
376118611Snjl        }
377118611Snjl        if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
378118611Snjl        {
379151937Sjkim            FlPrintFile (FileId,
380151937Sjkim                "    unsigned char    %s_%s_Header [] =\n    {\n",
381118611Snjl                Gbl_TableSignature, Gbl_TableId);
382118611Snjl        }
383118611Snjl        if (FileId == ASL_FILE_ASM_INCLUDE_OUTPUT)
384118611Snjl        {
385151937Sjkim            FlPrintFile (FileId,
386151937Sjkim                "extrn %s_%s_Header : byte\n",
387118611Snjl                Gbl_TableSignature, Gbl_TableId);
388118611Snjl        }
389118611Snjl        if (FileId == ASL_FILE_C_INCLUDE_OUTPUT)
390118611Snjl        {
391151937Sjkim            FlPrintFile (FileId,
392151937Sjkim                "extern unsigned char    %s_%s_Header [];\n",
393118611Snjl                Gbl_TableSignature, Gbl_TableId);
394118611Snjl        }
395118611Snjl        return;
396118611Snjl
397118611Snjl
398118611Snjl    case PARSEOP_METHODCALL:
399118611Snjl
400151937Sjkim        LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber,
401151937Sjkim            FileId);
402118611Snjl        return;
403118611Snjl
404118611Snjl
405118611Snjl    case PARSEOP_INCLUDE:
406118611Snjl
407151937Sjkim        /* Flush everything up to and including the include source line */
408118611Snjl
409151937Sjkim        LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber,
410151937Sjkim            FileId);
411151937Sjkim
412151937Sjkim        /* Create a new listing node and push it */
413151937Sjkim
414118611Snjl        LsPushNode (Op->Asl.Child->Asl.Value.String);
415118611Snjl        return;
416118611Snjl
417118611Snjl
418118611Snjl    case PARSEOP_INCLUDE_END:
419118611Snjl
420151937Sjkim        /* Flush out the rest of the include file */
421118611Snjl
422151937Sjkim        LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber,
423151937Sjkim            FileId);
424151937Sjkim
425151937Sjkim        /* Pop off this listing node and go back to the parent file */
426151937Sjkim
427151937Sjkim        (void) LsPopNode ();
428118611Snjl        return;
429118611Snjl
430118611Snjl
431118611Snjl    case PARSEOP_DEFAULT_ARG:
432167802Sjkim
433167802Sjkim        if (Op->Asl.CompileFlags & NODE_IS_RESOURCE_DESC)
434167802Sjkim        {
435167802Sjkim            LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.EndLogicalLine,
436167802Sjkim                FileId);
437167802Sjkim        }
438118611Snjl        return;
439118611Snjl
440118611Snjl
441118611Snjl    default:
442250838Sjkim
443118611Snjl        /* All other opcodes have an AML opcode */
444250838Sjkim
445118611Snjl        break;
446118611Snjl    }
447118611Snjl
448118611Snjl    /*
449118611Snjl     * Otherwise, we look at the AML opcode because we can
450118611Snjl     * switch on the opcode type, getting an entire class
451118611Snjl     * at once
452118611Snjl     */
453118611Snjl    switch (OpClass)
454118611Snjl    {
455118611Snjl    case AML_CLASS_ARGUMENT:       /* argument type only */
456118611Snjl    case AML_CLASS_INTERNAL:
457118611Snjl
458118611Snjl        break;
459118611Snjl
460118611Snjl    case AML_CLASS_NAMED_OBJECT:
461118611Snjl
462118611Snjl        switch (Op->Asl.AmlOpcode)
463118611Snjl        {
464118611Snjl        case AML_FIELD_OP:
465118611Snjl        case AML_INDEX_FIELD_OP:
466118611Snjl        case AML_BANK_FIELD_OP:
467151937Sjkim            /*
468151937Sjkim             * For fields, we want to dump all the AML after the
469151937Sjkim             * entire definition
470151937Sjkim             */
471151937Sjkim            LsWriteSourceLines (Op->Asl.EndLine, Op->Asl.EndLogicalLine,
472151937Sjkim                FileId);
473118611Snjl            break;
474118611Snjl
475167802Sjkim        case AML_NAME_OP:
476167802Sjkim
477167802Sjkim            if (Op->Asl.CompileFlags & NODE_IS_RESOURCE_DESC)
478167802Sjkim            {
479167802Sjkim                LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber,
480167802Sjkim                    FileId);
481167802Sjkim            }
482167802Sjkim            else
483167802Sjkim            {
484167802Sjkim                /*
485167802Sjkim                 * For fields, we want to dump all the AML after the
486167802Sjkim                 * entire definition
487167802Sjkim                 */
488167802Sjkim                LsWriteSourceLines (Op->Asl.EndLine, Op->Asl.EndLogicalLine,
489167802Sjkim                    FileId);
490167802Sjkim            }
491167802Sjkim            break;
492167802Sjkim
493118611Snjl        default:
494250838Sjkim
495151937Sjkim            LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber,
496151937Sjkim                FileId);
497118611Snjl            break;
498118611Snjl        }
499118611Snjl
500118611Snjl        switch (Op->Asl.AmlOpcode)
501118611Snjl        {
502118611Snjl        case AML_SCOPE_OP:
503118611Snjl        case AML_ALIAS_OP:
504118611Snjl
505118611Snjl            /* These opcodes do not declare a new object, ignore them */
506118611Snjl
507118611Snjl            break;
508118611Snjl
509118611Snjl        default:
510118611Snjl
511118611Snjl            /* All other named object opcodes come here */
512118611Snjl
513118611Snjl            switch (FileId)
514118611Snjl            {
515118611Snjl            case ASL_FILE_ASM_SOURCE_OUTPUT:
516118611Snjl            case ASL_FILE_C_SOURCE_OUTPUT:
517118611Snjl            case ASL_FILE_ASM_INCLUDE_OUTPUT:
518118611Snjl            case ASL_FILE_C_INCLUDE_OUTPUT:
519118611Snjl                /*
520118611Snjl                 * For named objects, we will create a valid symbol so that the
521118611Snjl                 * AML code can be referenced from C or ASM
522118611Snjl                 */
523118611Snjl                if (Op->Asl.ExternalName)
524118611Snjl                {
525118611Snjl                    /* Get the full pathname associated with this node */
526118611Snjl
527118611Snjl                    Pathname = AcpiNsGetExternalPathname (Op->Asl.Node);
528118611Snjl                    Length = strlen (Pathname);
529118611Snjl                    if (Length >= 4)
530118611Snjl                    {
531118611Snjl                        /* Convert all dots in the path to underscores */
532118611Snjl
533118611Snjl                        for (i = 0; i < Length; i++)
534118611Snjl                        {
535118611Snjl                            if (Pathname[i] == '.')
536118611Snjl                            {
537118611Snjl                                Pathname[i] = '_';
538118611Snjl                            }
539118611Snjl                        }
540118611Snjl
541118611Snjl                        /* Create the appropriate symbol in the output file */
542118611Snjl
543118611Snjl                        if (FileId == ASL_FILE_ASM_SOURCE_OUTPUT)
544118611Snjl                        {
545151937Sjkim                            FlPrintFile (FileId,
546151937Sjkim                                "%s_%s_%s  \\\n",
547118611Snjl                                Gbl_TableSignature, Gbl_TableId, &Pathname[1]);
548118611Snjl                        }
549118611Snjl                        if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
550118611Snjl                        {
551151937Sjkim                            FlPrintFile (FileId,
552151937Sjkim                                "    unsigned char    %s_%s_%s [] =\n    {\n",
553118611Snjl                                Gbl_TableSignature, Gbl_TableId, &Pathname[1]);
554118611Snjl                        }
555118611Snjl                        if (FileId == ASL_FILE_ASM_INCLUDE_OUTPUT)
556118611Snjl                        {
557151937Sjkim                            FlPrintFile (FileId,
558151937Sjkim                                "extrn %s_%s_%s : byte\n",
559118611Snjl                                Gbl_TableSignature, Gbl_TableId, &Pathname[1]);
560118611Snjl                        }
561118611Snjl                        if (FileId == ASL_FILE_C_INCLUDE_OUTPUT)
562118611Snjl                        {
563151937Sjkim                            FlPrintFile (FileId,
564151937Sjkim                                "extern unsigned char    %s_%s_%s [];\n",
565118611Snjl                                Gbl_TableSignature, Gbl_TableId, &Pathname[1]);
566118611Snjl                        }
567118611Snjl                    }
568167802Sjkim                    ACPI_FREE (Pathname);
569118611Snjl                }
570118611Snjl                break;
571118611Snjl
572118611Snjl            default:
573250838Sjkim
574118611Snjl                /* Nothing to do for listing file */
575250838Sjkim
576118611Snjl                break;
577118611Snjl            }
578118611Snjl        }
579118611Snjl        break;
580118611Snjl
581118611Snjl    case AML_CLASS_EXECUTE:
582118611Snjl    case AML_CLASS_CREATE:
583118611Snjl    default:
584118611Snjl
585167802Sjkim        if ((Op->Asl.ParseOpcode == PARSEOP_BUFFER) &&
586167802Sjkim            (Op->Asl.CompileFlags & NODE_IS_RESOURCE_DESC))
587167802Sjkim        {
588167802Sjkim            return;
589167802Sjkim        }
590167802Sjkim
591151937Sjkim        LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber,
592151937Sjkim            FileId);
593118611Snjl        break;
594118611Snjl
595118611Snjl    case AML_CLASS_UNKNOWN:
596250838Sjkim
597118611Snjl        break;
598118611Snjl    }
599118611Snjl}
600249112Sjkim
601249112Sjkim
602249112Sjkim/*******************************************************************************
603249112Sjkim *
604249112Sjkim * FUNCTION:    LsFinishSourceListing
605249112Sjkim *
606249112Sjkim * PARAMETERS:  FileId          - ID of current listing file.
607249112Sjkim *
608249112Sjkim * RETURN:      None
609249112Sjkim *
610249112Sjkim * DESCRIPTION: Cleanup routine for the listing file. Flush the hex AML
611249112Sjkim *              listing buffer, and flush out any remaining lines in the
612249112Sjkim *              source input file.
613249112Sjkim *
614249112Sjkim ******************************************************************************/
615249112Sjkim
616249112Sjkimstatic void
617249112SjkimLsFinishSourceListing (
618249112Sjkim    UINT32                  FileId)
619249112Sjkim{
620249112Sjkim
621249112Sjkim    if ((FileId == ASL_FILE_ASM_INCLUDE_OUTPUT) ||
622249112Sjkim        (FileId == ASL_FILE_C_INCLUDE_OUTPUT))
623249112Sjkim    {
624249112Sjkim        return;
625249112Sjkim    }
626249112Sjkim
627249112Sjkim    LsFlushListingBuffer (FileId);
628249112Sjkim    Gbl_CurrentAmlOffset = 0;
629249112Sjkim
630249112Sjkim    /* Flush any remaining text in the source file */
631249112Sjkim
632249112Sjkim    if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
633249112Sjkim    {
634249112Sjkim        FlPrintFile (FileId, "    /*\n");
635249112Sjkim    }
636249112Sjkim
637249112Sjkim    while (LsWriteOneSourceLine (FileId))
638249112Sjkim    { ; }
639249112Sjkim
640249112Sjkim    if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
641249112Sjkim    {
642249112Sjkim        FlPrintFile (FileId, "\n     */\n    };\n");
643249112Sjkim    }
644249112Sjkim
645249112Sjkim    FlPrintFile (FileId, "\n");
646249112Sjkim
647249112Sjkim    if (FileId == ASL_FILE_LISTING_OUTPUT)
648249112Sjkim    {
649249112Sjkim        /* Print a summary of the compile exceptions */
650249112Sjkim
651249112Sjkim        FlPrintFile (FileId, "\n\nSummary of errors and warnings\n\n");
652249112Sjkim        AePrintErrorLog (FileId);
653249112Sjkim        FlPrintFile (FileId, "\n");
654249112Sjkim        UtDisplaySummary (FileId);
655249112Sjkim        FlPrintFile (FileId, "\n");
656249112Sjkim    }
657249112Sjkim}
658