asllisting.c revision 250838
1139749Simp/******************************************************************************
237785Smsmith *
337785Smsmith * Module Name: asllisting - Listing file generation
437785Smsmith *
537785Smsmith *****************************************************************************/
637785Smsmith
737785Smsmith/*
837785Smsmith * Copyright (C) 2000 - 2013, Intel Corp.
937785Smsmith * All rights reserved.
1037785Smsmith *
1137785Smsmith * Redistribution and use in source and binary forms, with or without
1237785Smsmith * modification, are permitted provided that the following conditions
1337785Smsmith * are met:
1437785Smsmith * 1. Redistributions of source code must retain the above copyright
1537785Smsmith *    notice, this list of conditions, and the following disclaimer,
1637785Smsmith *    without modification.
1737785Smsmith * 2. Redistributions in binary form must reproduce at minimum a disclaimer
1837785Smsmith *    substantially similar to the "NO WARRANTY" disclaimer below
1937785Smsmith *    ("Disclaimer") and any redistribution must be conditioned upon
2037785Smsmith *    including a substantially similar Disclaimer requirement for further
2137785Smsmith *    binary redistribution.
2237785Smsmith * 3. Neither the names of the above-listed copyright holders nor the names
2337785Smsmith *    of any contributors may be used to endorse or promote products derived
2437785Smsmith *    from this software without specific prior written permission.
2537785Smsmith *
2637785Smsmith * Alternatively, this software may be distributed under the terms of the
2737785Smsmith * GNU General Public License ("GPL") version 2 as published by the Free
2837785Smsmith * Software Foundation.
29119418Sobrien *
30119418Sobrien * NO WARRANTY
31119418Sobrien * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
3237785Smsmith * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
3337785Smsmith * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
3437785Smsmith * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
3537785Smsmith * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3637785Smsmith * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3737785Smsmith * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3858816Simp * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
3958816Simp * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
4058816Simp * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
4137785Smsmith * POSSIBILITY OF SUCH DAMAGES.
4237785Smsmith */
4337785Smsmith
4437785Smsmith#include <contrib/dev/acpica/compiler/aslcompiler.h>
4558816Simp#include "aslcompiler.y.h"
4658816Simp#include <contrib/dev/acpica/include/amlcode.h>
4737785Smsmith#include <contrib/dev/acpica/include/acparser.h>
4837785Smsmith#include <contrib/dev/acpica/include/acnamesp.h>
4938592Smsmith
5037785Smsmith
5137785Smsmith#define _COMPONENT          ACPI_COMPILER
5258816Simp        ACPI_MODULE_NAME    ("asllisting")
5358816Simp
5458816Simp
5558816Simp/* Local prototypes */
5658816Simp
5758816Simpstatic void
5837785SmsmithLsGenerateListing (
5937785Smsmith    UINT32                  FileId);
60156559Sphilip
6137785Smsmithstatic ACPI_STATUS
62147256SbrooksLsAmlListingWalk (
6337785Smsmith    ACPI_PARSE_OBJECT       *Op,
6437785Smsmith    UINT32                  Level,
6537785Smsmith    void                    *Context);
6672940Simp
6758816Simpstatic ACPI_STATUS
6837785SmsmithLsTreeWriteWalk (
6937785Smsmith    ACPI_PARSE_OBJECT       *Op,
7037785Smsmith    UINT32                  Level,
7137785Smsmith    void                    *Context);
7237785Smsmith
7337785Smsmithstatic void
7437785SmsmithLsWriteNodeToListing (
75122024Simp    ACPI_PARSE_OBJECT       *Op,
76179560Sjhb    UINT32                  FileId);
77122024Simp
78122024Simpstatic void
79179560SjhbLsFinishSourceListing (
80122024Simp    UINT32                  FileId);
81122024Simp
82179560Sjhb
8338592Smsmith/*******************************************************************************
84122024Simp *
85122024Simp * FUNCTION:    LsDoListings
86122024Simp *
8758816Simp * PARAMETERS:  None. Examines the various output file global flags.
8837785Smsmith *
8937785Smsmith * RETURN:      None
9037785Smsmith *
9137785Smsmith * DESCRIPTION: Generate all requested listing files.
9237785Smsmith *
93122024Simp ******************************************************************************/
94122024Simp
9537785Smsmithvoid
9637785SmsmithLsDoListings (
9737785Smsmith    void)
9837785Smsmith{
9937785Smsmith
10037785Smsmith    if (Gbl_C_OutputFlag)
10137785Smsmith    {
10271316Simp        LsGenerateListing (ASL_FILE_C_SOURCE_OUTPUT);
103179597Simp    }
10437785Smsmith
105122024Simp    if (Gbl_ListingFlag)
106227309Sed    {
107122024Simp        LsGenerateListing (ASL_FILE_LISTING_OUTPUT);
108122024Simp    }
109122024Simp
110122024Simp    if (Gbl_AsmOutputFlag)
111122024Simp    {
112122024Simp        LsGenerateListing (ASL_FILE_ASM_SOURCE_OUTPUT);
113122024Simp    }
114122024Simp
115140925Simp    if (Gbl_C_IncludeOutputFlag)
116122024Simp    {
117122024Simp        LsGenerateListing (ASL_FILE_C_INCLUDE_OUTPUT);
118179532Simp    }
119179532Simp
120179532Simp    if (Gbl_AsmIncludeOutputFlag)
121179532Simp    {
122179532Simp        LsGenerateListing (ASL_FILE_ASM_INCLUDE_OUTPUT);
123179532Simp    }
124179532Simp
125179532Simp    if (Gbl_C_OffsetTableFlag)
126179532Simp    {
127179532Simp        LsGenerateListing (ASL_FILE_C_OFFSET_OUTPUT);
12837785Smsmith    }
129122024Simp}
13037785Smsmith
13137785Smsmith
13237785Smsmith/*******************************************************************************
13337785Smsmith *
134179620Simp * FUNCTION:    LsGenerateListing
13537785Smsmith *
136122024Simp * PARAMETERS:  FileId      - ID of listing file
137122024Simp *
138122024Simp * RETURN:      None
13937785Smsmith *
14072940Simp * DESCRIPTION: Generate a listing file. This can be one of the several types
141122024Simp *              of "listings" supported.
14272940Simp *
14372940Simp ******************************************************************************/
14437785Smsmith
14537785Smsmithstatic void
146179591SimpLsGenerateListing (
14737785Smsmith    UINT32                  FileId)
14837785Smsmith{
14937785Smsmith
15037785Smsmith    /* Start at the beginning of both the source and AML files */
15137785Smsmith
15237785Smsmith    FlSeekFile (ASL_FILE_SOURCE_OUTPUT, 0);
15372940Simp    FlSeekFile (ASL_FILE_AML_OUTPUT, 0);
15437785Smsmith    Gbl_SourceLine = 0;
15537785Smsmith    Gbl_CurrentHexColumn = 0;
15637785Smsmith    LsPushNode (Gbl_Files[ASL_FILE_INPUT].Filename);
157122024Simp
15837785Smsmith    if (FileId == ASL_FILE_C_OFFSET_OUTPUT)
159122024Simp    {
160122024Simp        Gbl_CurrentAmlOffset = 0;
16137785Smsmith
162122024Simp        /* Offset table file has a special header and footer */
163122024Simp
16437785Smsmith        LsDoOffsetTableHeader (FileId);
165179591Simp
166122024Simp        TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, LsAmlOffsetWalk,
167122024Simp            NULL, (void *) ACPI_TO_POINTER (FileId));
16837785Smsmith        LsDoOffsetTableFooter (FileId);
16937785Smsmith        return;
17037785Smsmith    }
17137785Smsmith
17237785Smsmith    /* Process all parse nodes */
173179620Simp
174179620Simp    TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, LsAmlListingWalk,
175179620Simp        NULL, (void *) ACPI_TO_POINTER (FileId));
176179620Simp
177179620Simp    /* Final processing */
178179620Simp
179179620Simp    LsFinishSourceListing (FileId);
180179620Simp}
181179620Simp
182179620Simp
183179620Simp/*******************************************************************************
184179620Simp *
185179620Simp * FUNCTION:    LsAmlListingWalk
186179621Simp *
187179621Simp * PARAMETERS:  ASL_WALK_CALLBACK
188179620Simp *
189179621Simp * RETURN:      Status
190179620Simp *
191179620Simp * DESCRIPTION: Process one node during a listing file generation.
192179620Simp *
19337785Smsmith ******************************************************************************/
19437785Smsmith
19537785Smsmithstatic ACPI_STATUS
19637785SmsmithLsAmlListingWalk (
19737785Smsmith    ACPI_PARSE_OBJECT       *Op,
19837785Smsmith    UINT32                  Level,
19937785Smsmith    void                    *Context)
20037785Smsmith{
20137785Smsmith    UINT8                   FileByte;
20237785Smsmith    UINT32                  i;
20337785Smsmith    UINT32                  FileId = (UINT32) ACPI_TO_INTEGER (Context);
20472940Simp
205180388Simp
20637785Smsmith    LsWriteNodeToListing (Op, FileId);
20737785Smsmith
20837785Smsmith    if (Op->Asl.CompileFlags & NODE_IS_RESOURCE_DATA)
20937785Smsmith    {
21037785Smsmith        /* Buffer is a resource template, don't dump the data all at once */
21137785Smsmith
212140927Simp        return (AE_OK);
213140927Simp    }
21472940Simp
21572940Simp    /* Write the hex bytes to the listing file(s) (if requested) */
216140927Simp
217179597Simp    for (i = 0; i < Op->Asl.FinalAmlLength; i++)
218162321Sglebius    {
219140927Simp        if (ACPI_FAILURE (FlReadFile (ASL_FILE_AML_OUTPUT, &FileByte, 1)))
22037785Smsmith        {
221140927Simp            FlFileError (ASL_FILE_AML_OUTPUT, ASL_MSG_READ);
222140927Simp            AslAbort ();
223140927Simp        }
224140927Simp        LsWriteListingHexBytes (&FileByte, 1, FileId);
225140928Simp    }
22637785Smsmith
22737785Smsmith    return (AE_OK);
22837785Smsmith}
22937785Smsmith
23037785Smsmith
23137785Smsmith/*******************************************************************************
23272940Simp *
23337785Smsmith * FUNCTION:    LsDumpParseTree, LsTreeWriteWalk
234140928Simp *
23537785Smsmith * PARAMETERS:  None
23637785Smsmith *
23737785Smsmith * RETURN:      None
23837785Smsmith *
23937785Smsmith * DESCRIPTION: Dump entire parse tree, for compiler debug only
24037785Smsmith *
24172940Simp ******************************************************************************/
24272940Simp
243179597Simpvoid
244140928SimpLsDumpParseTree (
24537785Smsmith    void)
24637785Smsmith{
24737785Smsmith
24837785Smsmith    if (!Gbl_DebugFlag)
24937785Smsmith    {
25037785Smsmith        return;
25172940Simp    }
25272940Simp
253179597Simp    DbgPrint (ASL_TREE_OUTPUT, "\nOriginal parse tree from parser:\n\n");
254140928Simp    TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD,
25537785Smsmith        LsTreeWriteWalk, NULL, NULL);
25637785Smsmith}
25771316Simp
25858816Simp
25937785Smsmithstatic ACPI_STATUS
26058816SimpLsTreeWriteWalk (
26158816Simp    ACPI_PARSE_OBJECT       *Op,
26258816Simp    UINT32                  Level,
26358816Simp    void                    *Context)
26437785Smsmith{
265122024Simp
26658816Simp    /* Debug output */
267122024Simp
26837785Smsmith    DbgPrint (ASL_TREE_OUTPUT,
26937785Smsmith        "%5.5d [%2d]", Op->Asl.LogicalLineNumber, Level);
270179620Simp
27158816Simp    UtPrintFormattedName (Op->Asl.ParseOpcode, Level);
27258816Simp
27358816Simp    DbgPrint (ASL_TREE_OUTPUT, "    (%.4X)\n", Op->Asl.ParseOpcode);
27458816Simp    return (AE_OK);
27572940Simp}
27637785Smsmith
27737785Smsmith
27858816Simp/*******************************************************************************
27972940Simp *
28072940Simp * FUNCTION:    LsWriteNodeToListing
28172940Simp *
28272940Simp * PARAMETERS:  Op              - Parse node to write to the listing file.
28372940Simp *              FileId          - ID of current listing file
28458816Simp *
28537785Smsmith * RETURN:      None.
28637785Smsmith *
28772940Simp * DESCRIPTION: Write "a node" to the listing file. This means to
28872940Simp *              1) Write out all of the source text associated with the node
28972940Simp *              2) Write out all of the AML bytes associated with the node
29072940Simp *              3) Write any compiler exceptions associated with the node
29172940Simp *
29272940Simp ******************************************************************************/
29358816Simp
29437785Smsmithstatic void
29572940SimpLsWriteNodeToListing (
29637785Smsmith    ACPI_PARSE_OBJECT       *Op,
29737785Smsmith    UINT32                  FileId)
29837785Smsmith{
29937785Smsmith    const ACPI_OPCODE_INFO  *OpInfo;
30058816Simp    UINT32                  OpClass;
301179532Simp    char                    *Pathname;
30237785Smsmith    UINT32                  Length;
30337785Smsmith    UINT32                  i;
30437785Smsmith
30537785Smsmith
30637785Smsmith    OpInfo  = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode);
30737785Smsmith    OpClass = OpInfo->Class;
30837785Smsmith
30937785Smsmith    /* TBD: clean this up with a single flag that says:
31037785Smsmith     * I start a named output block
31137785Smsmith     */
312140927Simp    if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
313140927Simp    {
314140927Simp        switch (Op->Asl.ParseOpcode)
315140927Simp        {
316140927Simp        case PARSEOP_DEFINITIONBLOCK:
317140927Simp        case PARSEOP_METHODCALL:
318140927Simp        case PARSEOP_INCLUDE:
319179532Simp        case PARSEOP_INCLUDE_END:
32037785Smsmith        case PARSEOP_DEFAULT_ARG:
32158816Simp
32258816Simp            break;
32358816Simp
32458816Simp        default:
32558816Simp
32672940Simp            switch (OpClass)
32758816Simp            {
328179532Simp            case AML_CLASS_NAMED_OBJECT:
329179532Simp
330179532Simp                switch (Op->Asl.AmlOpcode)
331179532Simp                {
33237785Smsmith                case AML_SCOPE_OP:
333180388Simp                case AML_ALIAS_OP:
334180388Simp
335180388Simp                    break;
336179532Simp
337179532Simp                default:
338179532Simp
339179532Simp                    if (Op->Asl.ExternalName)
340179532Simp                    {
341179532Simp                        LsFlushListingBuffer (FileId);
342179532Simp                        FlPrintFile (FileId, "    };\n");
343179532Simp                    }
344179532Simp                    break;
345179532Simp                }
346179532Simp                break;
347179532Simp
348179532Simp            default:
34937785Smsmith
350179532Simp                /* Don't care about other objects */
351179532Simp
35237785Smsmith                break;
353179532Simp            }
354179532Simp            break;
355179532Simp        }
356179532Simp    }
357179532Simp
358179532Simp    /* These cases do not have a corresponding AML opcode */
359179532Simp
360140927Simp    switch (Op->Asl.ParseOpcode)
361140927Simp    {
36237785Smsmith    case PARSEOP_DEFINITIONBLOCK:
363179532Simp
364140927Simp        LsWriteSourceLines (Op->Asl.EndLine, Op->Asl.EndLogicalLine, FileId);
365217538Sjhb
366179532Simp        /* Use the table Signature and TableId to build a unique name */
367179532Simp
368179532Simp        if (FileId == ASL_FILE_ASM_SOURCE_OUTPUT)
369140927Simp        {
370179532Simp            FlPrintFile (FileId,
371179532Simp                "%s_%s_Header \\\n",
372140927Simp                Gbl_TableSignature, Gbl_TableId);
373179532Simp        }
374179532Simp        if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
37558816Simp        {
37658816Simp            FlPrintFile (FileId,
377179507Simp                "    unsigned char    %s_%s_Header [] =\n    {\n",
37858816Simp                Gbl_TableSignature, Gbl_TableId);
379179507Simp        }
380140927Simp        if (FileId == ASL_FILE_ASM_INCLUDE_OUTPUT)
381140927Simp        {
382179507Simp            FlPrintFile (FileId,
383179507Simp                "extrn %s_%s_Header : byte\n",
384179507Simp                Gbl_TableSignature, Gbl_TableId);
385140927Simp        }
386140927Simp        if (FileId == ASL_FILE_C_INCLUDE_OUTPUT)
387140927Simp        {
388140927Simp            FlPrintFile (FileId,
38972940Simp                "extern unsigned char    %s_%s_Header [];\n",
39037785Smsmith                Gbl_TableSignature, Gbl_TableId);
391104252Sbrooks        }
392140928Simp        return;
39337785Smsmith
394140927Simp
39537785Smsmith    case PARSEOP_METHODCALL:
39637785Smsmith
39758816Simp        LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber,
398179532Simp            FileId);
399179532Simp        return;
40037785Smsmith
40137785Smsmith
40237785Smsmith    case PARSEOP_INCLUDE:
40358816Simp
40437785Smsmith        /* Flush everything up to and including the include source line */
405140927Simp
406140927Simp        LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber,
407140927Simp            FileId);
408140927Simp
409140927Simp        /* Create a new listing node and push it */
41037785Smsmith
411140928Simp        LsPushNode (Op->Asl.Child->Asl.Value.String);
41237785Smsmith        return;
41337785Smsmith
41437785Smsmith
41558816Simp    case PARSEOP_INCLUDE_END:
41658816Simp
417179560Sjhb        /* Flush out the rest of the include file */
418179560Sjhb
41958816Simp        LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber,
420140927Simp            FileId);
421140927Simp
42258816Simp        /* Pop off this listing node and go back to the parent file */
423140927Simp
424140927Simp        (void) LsPopNode ();
425140928Simp        return;
426140927Simp
427140928Simp
428140928Simp    case PARSEOP_DEFAULT_ARG:
429140928Simp
43058816Simp        if (Op->Asl.CompileFlags & NODE_IS_RESOURCE_DESC)
43158816Simp        {
43258816Simp            LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.EndLogicalLine,
43358816Simp                FileId);
43458816Simp        }
435179560Sjhb        return;
436179597Simp
43758816Simp
438140927Simp    default:
439140927Simp
44058816Simp        /* All other opcodes have an AML opcode */
441179597Simp
442140928Simp        break;
443140927Simp    }
444140928Simp
445140928Simp    /*
446140928Simp     * Otherwise, we look at the AML opcode because we can
44758816Simp     * switch on the opcode type, getting an entire class
44858816Simp     * at once
44958816Simp     */
45058816Simp    switch (OpClass)
45158816Simp    {
452179560Sjhb    case AML_CLASS_ARGUMENT:       /* argument type only */
453179560Sjhb    case AML_CLASS_INTERNAL:
45458816Simp
455140927Simp        break;
45658816Simp
457140927Simp    case AML_CLASS_NAMED_OBJECT:
458140927Simp
459140927Simp        switch (Op->Asl.AmlOpcode)
460140927Simp        {
461140927Simp        case AML_FIELD_OP:
462140927Simp        case AML_INDEX_FIELD_OP:
463140927Simp        case AML_BANK_FIELD_OP:
464140927Simp            /*
465140927Simp             * For fields, we want to dump all the AML after the
466140927Simp             * entire definition
46758816Simp             */
46858816Simp            LsWriteSourceLines (Op->Asl.EndLine, Op->Asl.EndLogicalLine,
46958816Simp                FileId);
47037785Smsmith            break;
47137785Smsmith
47271316Simp        case AML_NAME_OP:
473121816Sbrooks
47437785Smsmith            if (Op->Asl.CompileFlags & NODE_IS_RESOURCE_DESC)
475179560Sjhb            {
476201758Smbr                LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber,
477147256Sbrooks                    FileId);
47837785Smsmith            }
479162321Sglebius            else
480162321Sglebius            {
481147256Sbrooks                /*
482147256Sbrooks                 * For fields, we want to dump all the AML after the
483147256Sbrooks                 * entire definition
484179560Sjhb                 */
485179560Sjhb                LsWriteSourceLines (Op->Asl.EndLine, Op->Asl.EndLogicalLine,
486147256Sbrooks                    FileId);
487147256Sbrooks            }
488179560Sjhb            break;
489179560Sjhb
490179560Sjhb        default:
49158816Simp
492179560Sjhb            LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber,
493179560Sjhb                FileId);
494179560Sjhb            break;
495179560Sjhb        }
496121752Sbrooks
497121816Sbrooks        switch (Op->Asl.AmlOpcode)
498121752Sbrooks        {
499121752Sbrooks        case AML_SCOPE_OP:
500121752Sbrooks        case AML_ALIAS_OP:
501207554Ssobomax
50237785Smsmith            /* These opcodes do not declare a new object, ignore them */
503179560Sjhb
50437785Smsmith            break;
505121752Sbrooks
506121752Sbrooks        default:
507121752Sbrooks
50837785Smsmith            /* All other named object opcodes come here */
509121752Sbrooks
510121752Sbrooks            switch (FileId)
511121816Sbrooks            {
512121816Sbrooks            case ASL_FILE_ASM_SOURCE_OUTPUT:
513121752Sbrooks            case ASL_FILE_C_SOURCE_OUTPUT:
514121752Sbrooks            case ASL_FILE_ASM_INCLUDE_OUTPUT:
515121752Sbrooks            case ASL_FILE_C_INCLUDE_OUTPUT:
516121752Sbrooks                /*
517121752Sbrooks                 * For named objects, we will create a valid symbol so that the
51837785Smsmith                 * AML code can be referenced from C or ASM
519121752Sbrooks                 */
52037785Smsmith                if (Op->Asl.ExternalName)
521121752Sbrooks                {
522121752Sbrooks                    /* Get the full pathname associated with this node */
523162321Sglebius
524179560Sjhb                    Pathname = AcpiNsGetExternalPathname (Op->Asl.Node);
525179560Sjhb                    Length = strlen (Pathname);
526179560Sjhb                    if (Length >= 4)
527179560Sjhb                    {
528121752Sbrooks                        /* Convert all dots in the path to underscores */
52937785Smsmith
530121752Sbrooks                        for (i = 0; i < Length; i++)
531121752Sbrooks                        {
532121752Sbrooks                            if (Pathname[i] == '.')
533121752Sbrooks                            {
53437785Smsmith                                Pathname[i] = '_';
535121752Sbrooks                            }
536121752Sbrooks                        }
537121752Sbrooks
538121752Sbrooks                        /* Create the appropriate symbol in the output file */
539121752Sbrooks
540121752Sbrooks                        if (FileId == ASL_FILE_ASM_SOURCE_OUTPUT)
541121752Sbrooks                        {
542121752Sbrooks                            FlPrintFile (FileId,
543121752Sbrooks                                "%s_%s_%s  \\\n",
54437785Smsmith                                Gbl_TableSignature, Gbl_TableId, &Pathname[1]);
545121752Sbrooks                        }
546121752Sbrooks                        if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
54737785Smsmith                        {
548121752Sbrooks                            FlPrintFile (FileId,
549121752Sbrooks                                "    unsigned char    %s_%s_%s [] =\n    {\n",
55037785Smsmith                                Gbl_TableSignature, Gbl_TableId, &Pathname[1]);
551121752Sbrooks                        }
552121752Sbrooks                        if (FileId == ASL_FILE_ASM_INCLUDE_OUTPUT)
55337785Smsmith                        {
554121752Sbrooks                            FlPrintFile (FileId,
555121752Sbrooks                                "extrn %s_%s_%s : byte\n",
556121752Sbrooks                                Gbl_TableSignature, Gbl_TableId, &Pathname[1]);
557121752Sbrooks                        }
558121752Sbrooks                        if (FileId == ASL_FILE_C_INCLUDE_OUTPUT)
559121752Sbrooks                        {
560122024Simp                            FlPrintFile (FileId,
561162321Sglebius                                "extern unsigned char    %s_%s_%s [];\n",
562122024Simp                                Gbl_TableSignature, Gbl_TableId, &Pathname[1]);
563122024Simp                        }
564122024Simp                    }
565122024Simp                    ACPI_FREE (Pathname);
566122024Simp                }
567122024Simp                break;
568122024Simp
569122024Simp            default:
570122024Simp
571122024Simp                /* Nothing to do for listing file */
57237785Smsmith
573121752Sbrooks                break;
574121752Sbrooks            }
57537785Smsmith        }
576147256Sbrooks        break;
577121752Sbrooks
578179560Sjhb    case AML_CLASS_EXECUTE:
579179560Sjhb    case AML_CLASS_CREATE:
580179560Sjhb    default:
581179560Sjhb
582179560Sjhb        if ((Op->Asl.ParseOpcode == PARSEOP_BUFFER) &&
583179560Sjhb            (Op->Asl.CompileFlags & NODE_IS_RESOURCE_DESC))
584179560Sjhb        {
585179560Sjhb            return;
586179560Sjhb        }
587179560Sjhb
588179560Sjhb        LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber,
58958816Simp            FileId);
59037785Smsmith        break;
59137785Smsmith
592140888Simp    case AML_CLASS_UNKNOWN:
593140888Simp
594140888Simp        break;
595140888Simp    }
596140888Simp}
597140888Simp
598140888Simp
599147256Sbrooks/*******************************************************************************
600140888Simp *
601179560Sjhb * FUNCTION:    LsFinishSourceListing
602140888Simp *
603179560Sjhb * PARAMETERS:  FileId          - ID of current listing file.
604179560Sjhb *
605140888Simp * RETURN:      None
606179560Sjhb *
607150306Simp * DESCRIPTION: Cleanup routine for the listing file. Flush the hex AML
608179560Sjhb *              listing buffer, and flush out any remaining lines in the
609147256Sbrooks *              source input file.
610179560Sjhb *
611140888Simp ******************************************************************************/
612140888Simp
613140888Simpstatic void
61437785SmsmithLsFinishSourceListing (
61537785Smsmith    UINT32                  FileId)
61637785Smsmith{
61737785Smsmith
61837785Smsmith    if ((FileId == ASL_FILE_ASM_INCLUDE_OUTPUT) ||
61937785Smsmith        (FileId == ASL_FILE_C_INCLUDE_OUTPUT))
62037785Smsmith    {
621179560Sjhb        return;
622179560Sjhb    }
623179560Sjhb
624179560Sjhb    LsFlushListingBuffer (FileId);
625179560Sjhb    Gbl_CurrentAmlOffset = 0;
626179560Sjhb
627179560Sjhb    /* Flush any remaining text in the source file */
628179560Sjhb
629179560Sjhb    if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
630147256Sbrooks    {
631179560Sjhb        FlPrintFile (FileId, "    /*\n");
63237785Smsmith    }
63337785Smsmith
634179560Sjhb    while (LsWriteOneSourceLine (FileId))
63537785Smsmith    { ; }
636179560Sjhb
63737785Smsmith    if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
63837785Smsmith    {
63937785Smsmith        FlPrintFile (FileId, "\n     */\n    };\n");
64037785Smsmith    }
64137785Smsmith
64237785Smsmith    FlPrintFile (FileId, "\n");
64337785Smsmith
64472940Simp    if (FileId == ASL_FILE_LISTING_OUTPUT)
64572940Simp    {
64637785Smsmith        /* Print a summary of the compile exceptions */
64737785Smsmith
64837785Smsmith        FlPrintFile (FileId, "\n\nSummary of errors and warnings\n\n");
64937785Smsmith        AePrintErrorLog (FileId);
65037785Smsmith        FlPrintFile (FileId, "\n");
65137785Smsmith        UtDisplaySummary (FileId);
65237785Smsmith        FlPrintFile (FileId, "\n");
65337785Smsmith    }
65437785Smsmith}
655140927Simp