asllisting.c revision 245582
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
44118611Snjl
45151937Sjkim#include <contrib/dev/acpica/compiler/aslcompiler.h>
46118611Snjl#include "aslcompiler.y.h"
47193529Sjkim#include <contrib/dev/acpica/include/amlcode.h>
48193529Sjkim#include <contrib/dev/acpica/include/acparser.h>
49193529Sjkim#include <contrib/dev/acpica/include/acnamesp.h>
50118611Snjl
51118611Snjl#define _COMPONENT          ACPI_COMPILER
52118611Snjl        ACPI_MODULE_NAME    ("aslisting")
53118611Snjl
54151937Sjkim/* Local prototypes */
55118611Snjl
56151937Sjkimstatic void
57151937SjkimLsDumpAscii (
58151937Sjkim    UINT32                  FileId,
59151937Sjkim    UINT32                  Count,
60151937Sjkim    UINT8                   *Buffer);
61151937Sjkim
62151937Sjkimstatic ACPI_STATUS
63151937SjkimLsAmlListingWalk (
64151937Sjkim    ACPI_PARSE_OBJECT       *Op,
65151937Sjkim    UINT32                  Level,
66151937Sjkim    void                    *Context);
67151937Sjkim
68151937Sjkimstatic void
69151937SjkimLsGenerateListing (
70151937Sjkim    UINT32                  FileId);
71151937Sjkim
72151937Sjkimstatic void
73151937SjkimLsPushNode (
74151937Sjkim    char                    *Filename);
75151937Sjkim
76151937Sjkimstatic ASL_LISTING_NODE *
77151937SjkimLsPopNode (
78151937Sjkim    void);
79151937Sjkim
80151937Sjkimstatic void
81151937SjkimLsCheckException (
82151937Sjkim    UINT32                  LineNumber,
83151937Sjkim    UINT32                  FileId);
84151937Sjkim
85151937Sjkimstatic void
86151937SjkimLsFlushListingBuffer (
87151937Sjkim    UINT32                  FileId);
88151937Sjkim
89151937Sjkimstatic void
90151937SjkimLsWriteListingHexBytes (
91151937Sjkim    UINT8                   *Buffer,
92151937Sjkim    UINT32                  Length,
93151937Sjkim    UINT32                  FileId);
94151937Sjkim
95151937Sjkimstatic UINT32
96151937SjkimLsWriteOneSourceLine (
97151937Sjkim    UINT32                  FileId);
98151937Sjkim
99151937Sjkimstatic void
100151937SjkimLsFinishSourceListing (
101151937Sjkim    UINT32                  FileId);
102151937Sjkim
103151937Sjkimstatic void
104151937SjkimLsWriteSourceLines (
105151937Sjkim    UINT32                  ToLineNumber,
106151937Sjkim    UINT32                  ToLogicalLineNumber,
107151937Sjkim    UINT32                  FileId);
108151937Sjkim
109151937Sjkimstatic void
110151937SjkimLsWriteNodeToListing (
111151937Sjkim    ACPI_PARSE_OBJECT       *Op,
112151937Sjkim    UINT32                  FileId);
113151937Sjkim
114212761Sjkimstatic ACPI_STATUS
115193529SjkimLsTreeWriteWalk (
116193529Sjkim    ACPI_PARSE_OBJECT       *Op,
117193529Sjkim    UINT32                  Level,
118193529Sjkim    void                    *Context);
119151937Sjkim
120245582Sjkim#define ASL_LISTING_LINE_PREFIX         ":  "
121193529Sjkim
122243347Sjkim
123118611Snjl/*******************************************************************************
124118611Snjl *
125245582Sjkim * FUNCTION:    LsDoListings
126245582Sjkim *
127245582Sjkim * PARAMETERS:  None
128245582Sjkim *
129245582Sjkim * RETURN:      None
130245582Sjkim *
131245582Sjkim * DESCRIPTION: Generate all requested listing files.
132245582Sjkim *
133245582Sjkim ******************************************************************************/
134245582Sjkim
135245582Sjkimvoid
136245582SjkimLsDoListings (
137245582Sjkim    void)
138245582Sjkim{
139245582Sjkim
140245582Sjkim    if (Gbl_C_OutputFlag)
141245582Sjkim    {
142245582Sjkim        LsGenerateListing (ASL_FILE_C_SOURCE_OUTPUT);
143245582Sjkim    }
144245582Sjkim
145245582Sjkim    if (Gbl_ListingFlag)
146245582Sjkim    {
147245582Sjkim        LsGenerateListing (ASL_FILE_LISTING_OUTPUT);
148245582Sjkim    }
149245582Sjkim
150245582Sjkim    if (Gbl_AsmOutputFlag)
151245582Sjkim    {
152245582Sjkim        LsGenerateListing (ASL_FILE_ASM_SOURCE_OUTPUT);
153245582Sjkim    }
154245582Sjkim
155245582Sjkim    if (Gbl_C_IncludeOutputFlag)
156245582Sjkim    {
157245582Sjkim        LsGenerateListing (ASL_FILE_C_INCLUDE_OUTPUT);
158245582Sjkim    }
159245582Sjkim
160245582Sjkim    if (Gbl_AsmIncludeOutputFlag)
161245582Sjkim    {
162245582Sjkim        LsGenerateListing (ASL_FILE_ASM_INCLUDE_OUTPUT);
163245582Sjkim    }
164245582Sjkim}
165245582Sjkim
166245582Sjkim
167245582Sjkim/*******************************************************************************
168245582Sjkim *
169167802Sjkim * FUNCTION:    LsTreeWriteWalk
170167802Sjkim *
171167802Sjkim * PARAMETERS:  ASL_WALK_CALLBACK
172167802Sjkim *
173167802Sjkim *
174245582Sjkim * RETURN:      None
175167802Sjkim *
176167802Sjkim * DESCRIPTION: Dump entire parse tree, for compiler debug only
177167802Sjkim *
178167802Sjkim ******************************************************************************/
179167802Sjkim
180212761Sjkimstatic ACPI_STATUS
181167802SjkimLsTreeWriteWalk (
182167802Sjkim    ACPI_PARSE_OBJECT       *Op,
183167802Sjkim    UINT32                  Level,
184167802Sjkim    void                    *Context)
185167802Sjkim{
186167802Sjkim
187167802Sjkim    /* Debug output */
188167802Sjkim
189167802Sjkim    DbgPrint (ASL_TREE_OUTPUT,
190167802Sjkim        "%5.5d [%2d]", Op->Asl.LogicalLineNumber, Level);
191167802Sjkim    UtPrintFormattedName (Op->Asl.ParseOpcode, Level);
192167802Sjkim
193167802Sjkim
194167802Sjkim    DbgPrint (ASL_TREE_OUTPUT, "\n");
195167802Sjkim    return (AE_OK);
196167802Sjkim}
197167802Sjkim
198167802Sjkim
199167802Sjkimvoid
200167802SjkimLsDumpParseTree (
201167802Sjkim    void)
202167802Sjkim{
203167802Sjkim
204167802Sjkim    if (!Gbl_DebugFlag)
205167802Sjkim    {
206167802Sjkim        return;
207167802Sjkim    }
208167802Sjkim
209167802Sjkim    DbgPrint (ASL_TREE_OUTPUT, "\nOriginal parse tree from parser:\n\n");
210167802Sjkim    TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD,
211167802Sjkim        LsTreeWriteWalk, NULL, NULL);
212167802Sjkim}
213167802Sjkim
214167802Sjkim
215167802Sjkim/*******************************************************************************
216167802Sjkim *
217118611Snjl * FUNCTION:    LsDumpAscii
218118611Snjl *
219118611Snjl * PARAMETERS:  FileId          - ID of current listing file
220118611Snjl *              Count           - Number of bytes to convert
221118611Snjl *              Buffer          - Buffer of bytes to convert
222118611Snjl *
223245582Sjkim * RETURN:      None
224118611Snjl *
225118611Snjl * DESCRIPTION: Convert hex bytes to ascii
226118611Snjl *
227118611Snjl ******************************************************************************/
228118611Snjl
229151937Sjkimstatic void
230118611SnjlLsDumpAscii (
231118611Snjl    UINT32                  FileId,
232118611Snjl    UINT32                  Count,
233118611Snjl    UINT8                   *Buffer)
234118611Snjl{
235118611Snjl    UINT8                   BufChar;
236118611Snjl    UINT32                  i;
237118611Snjl
238118611Snjl
239118611Snjl    FlPrintFile (FileId, "    \"");
240118611Snjl    for (i = 0; i < Count; i++)
241118611Snjl    {
242118611Snjl        BufChar = Buffer[i];
243118611Snjl        if (isprint (BufChar))
244118611Snjl        {
245118611Snjl            FlPrintFile (FileId, "%c", BufChar);
246118611Snjl        }
247118611Snjl        else
248118611Snjl        {
249118611Snjl            /* Not a printable character, just put out a dot */
250118611Snjl
251118611Snjl            FlPrintFile (FileId, ".");
252118611Snjl        }
253118611Snjl    }
254118611Snjl    FlPrintFile (FileId, "\"");
255118611Snjl}
256118611Snjl
257118611Snjl
258118611Snjl/*******************************************************************************
259118611Snjl *
260118611Snjl * FUNCTION:    LsDumpAsciiInComment
261118611Snjl *
262118611Snjl * PARAMETERS:  FileId          - ID of current listing file
263118611Snjl *              Count           - Number of bytes to convert
264118611Snjl *              Buffer          - Buffer of bytes to convert
265118611Snjl *
266245582Sjkim * RETURN:      None
267118611Snjl *
268118611Snjl * DESCRIPTION: Convert hex bytes to ascii
269118611Snjl *
270118611Snjl ******************************************************************************/
271118611Snjl
272245582Sjkimvoid
273118611SnjlLsDumpAsciiInComment (
274118611Snjl    UINT32                  FileId,
275118611Snjl    UINT32                  Count,
276118611Snjl    UINT8                   *Buffer)
277118611Snjl{
278118611Snjl    UINT8                   BufChar = 0;
279118611Snjl    UINT8                   LastChar;
280118611Snjl    UINT32                  i;
281118611Snjl
282118611Snjl
283118611Snjl    FlPrintFile (FileId, "    \"");
284118611Snjl    for (i = 0; i < Count; i++)
285118611Snjl    {
286118611Snjl        LastChar = BufChar;
287118611Snjl        BufChar = Buffer[i];
288118611Snjl
289118611Snjl        if (isprint (BufChar))
290118611Snjl        {
291118611Snjl            /* Handle embedded C comment sequences */
292118611Snjl
293118611Snjl            if (((LastChar == '*') && (BufChar == '/')) ||
294118611Snjl                ((LastChar == '/') && (BufChar == '*')))
295118611Snjl            {
296118611Snjl                /* Insert a space to break the sequence */
297118611Snjl
298118611Snjl                FlPrintFile (FileId, ".", BufChar);
299118611Snjl            }
300118611Snjl
301118611Snjl            FlPrintFile (FileId, "%c", BufChar);
302118611Snjl        }
303118611Snjl        else
304118611Snjl        {
305118611Snjl            /* Not a printable character, just put out a dot */
306118611Snjl
307118611Snjl            FlPrintFile (FileId, ".");
308118611Snjl        }
309118611Snjl    }
310118611Snjl    FlPrintFile (FileId, "\"");
311118611Snjl}
312118611Snjl
313118611Snjl
314118611Snjl/*******************************************************************************
315118611Snjl *
316118611Snjl * FUNCTION:    LsAmlListingWalk
317118611Snjl *
318118611Snjl * PARAMETERS:  ASL_WALK_CALLBACK
319118611Snjl *
320118611Snjl * RETURN:      Status
321118611Snjl *
322118611Snjl * DESCRIPTION: Process one node during a listing file generation.
323118611Snjl *
324118611Snjl ******************************************************************************/
325118611Snjl
326151937Sjkimstatic ACPI_STATUS
327118611SnjlLsAmlListingWalk (
328118611Snjl    ACPI_PARSE_OBJECT       *Op,
329118611Snjl    UINT32                  Level,
330118611Snjl    void                    *Context)
331118611Snjl{
332118611Snjl    UINT8                   FileByte;
333118611Snjl    UINT32                  i;
334167802Sjkim    UINT32                  FileId = (UINT32) ACPI_TO_INTEGER (Context);
335118611Snjl
336118611Snjl
337118611Snjl    LsWriteNodeToListing (Op, FileId);
338118611Snjl
339167802Sjkim    if (Op->Asl.CompileFlags & NODE_IS_RESOURCE_DATA)
340167802Sjkim    {
341167802Sjkim        /* Buffer is a resource template, don't dump the data all at once */
342167802Sjkim
343167802Sjkim        return (AE_OK);
344167802Sjkim    }
345167802Sjkim
346118611Snjl    /* Write the hex bytes to the listing file(s) (if requested) */
347118611Snjl
348118611Snjl    for (i = 0; i < Op->Asl.FinalAmlLength; i++)
349118611Snjl    {
350118611Snjl        if (ACPI_FAILURE (FlReadFile (ASL_FILE_AML_OUTPUT, &FileByte, 1)))
351118611Snjl        {
352118611Snjl            FlFileError (ASL_FILE_AML_OUTPUT, ASL_MSG_READ);
353118611Snjl            AslAbort ();
354118611Snjl        }
355118611Snjl        LsWriteListingHexBytes (&FileByte, 1, FileId);
356118611Snjl    }
357118611Snjl
358118611Snjl    return (AE_OK);
359118611Snjl}
360118611Snjl
361118611Snjl
362118611Snjl/*******************************************************************************
363118611Snjl *
364118611Snjl * FUNCTION:    LsGenerateListing
365118611Snjl *
366118611Snjl * PARAMETERS:  FileId      - ID of listing file
367118611Snjl *
368118611Snjl * RETURN:      None
369118611Snjl *
370241973Sjkim * DESCRIPTION: Generate a listing file. This can be one of the several types
371118611Snjl *              of "listings" supported.
372118611Snjl *
373118611Snjl ******************************************************************************/
374118611Snjl
375151937Sjkimstatic void
376118611SnjlLsGenerateListing (
377118611Snjl    UINT32                  FileId)
378118611Snjl{
379118611Snjl
380118611Snjl    /* Start at the beginning of both the source and AML files */
381118611Snjl
382118611Snjl    FlSeekFile (ASL_FILE_SOURCE_OUTPUT, 0);
383118611Snjl    FlSeekFile (ASL_FILE_AML_OUTPUT, 0);
384118611Snjl    Gbl_SourceLine = 0;
385118611Snjl    Gbl_CurrentHexColumn = 0;
386118611Snjl    LsPushNode (Gbl_Files[ASL_FILE_INPUT].Filename);
387118611Snjl
388118611Snjl    /* Process all parse nodes */
389118611Snjl
390118611Snjl    TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, LsAmlListingWalk,
391118611Snjl                        NULL, (void *) ACPI_TO_POINTER (FileId));
392118611Snjl
393118611Snjl    /* Final processing */
394118611Snjl
395118611Snjl    LsFinishSourceListing (FileId);
396118611Snjl}
397118611Snjl
398118611Snjl
399118611Snjl/*******************************************************************************
400118611Snjl *
401118611Snjl * FUNCTION:    LsPushNode
402118611Snjl *
403118611Snjl * PARAMETERS:  Filename        - Pointer to the include filename
404118611Snjl *
405118611Snjl * RETURN:      None
406118611Snjl *
407241973Sjkim * DESCRIPTION: Push a listing node on the listing/include file stack. This
408118611Snjl *              stack enables tracking of include files (infinitely nested)
409118611Snjl *              and resumption of the listing of the parent file when the
410118611Snjl *              include file is finished.
411118611Snjl *
412118611Snjl ******************************************************************************/
413118611Snjl
414151937Sjkimstatic void
415118611SnjlLsPushNode (
416118611Snjl    char                    *Filename)
417118611Snjl{
418118611Snjl    ASL_LISTING_NODE        *Lnode;
419118611Snjl
420118611Snjl
421118611Snjl    /* Create a new node */
422118611Snjl
423118611Snjl    Lnode = UtLocalCalloc (sizeof (ASL_LISTING_NODE));
424118611Snjl
425118611Snjl    /* Initialize */
426118611Snjl
427118611Snjl    Lnode->Filename = Filename;
428118611Snjl    Lnode->LineNumber = 0;
429118611Snjl
430118611Snjl    /* Link (push) */
431118611Snjl
432118611Snjl    Lnode->Next = Gbl_ListingNode;
433118611Snjl    Gbl_ListingNode = Lnode;
434118611Snjl}
435118611Snjl
436118611Snjl
437118611Snjl/*******************************************************************************
438118611Snjl *
439118611Snjl * FUNCTION:    LsPopNode
440118611Snjl *
441118611Snjl * PARAMETERS:  None
442118611Snjl *
443118611Snjl * RETURN:      List head after current head is popped off
444118611Snjl *
445118611Snjl * DESCRIPTION: Pop the current head of the list, free it, and return the
446118611Snjl *              next node on the stack (the new current node).
447118611Snjl *
448118611Snjl ******************************************************************************/
449118611Snjl
450151937Sjkimstatic ASL_LISTING_NODE *
451151937SjkimLsPopNode (
452151937Sjkim    void)
453118611Snjl{
454118611Snjl    ASL_LISTING_NODE        *Lnode;
455118611Snjl
456118611Snjl
457118611Snjl    /* Just grab the node at the head of the list */
458118611Snjl
459118611Snjl    Lnode = Gbl_ListingNode;
460118611Snjl    if ((!Lnode) ||
461118611Snjl        (!Lnode->Next))
462118611Snjl    {
463151937Sjkim        AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, NULL,
464151937Sjkim            "Could not pop empty listing stack");
465241973Sjkim        return (Gbl_ListingNode);
466118611Snjl    }
467118611Snjl
468118611Snjl    Gbl_ListingNode = Lnode->Next;
469167802Sjkim    ACPI_FREE (Lnode);
470118611Snjl
471118611Snjl    /* New "Current" node is the new head */
472118611Snjl
473118611Snjl    return (Gbl_ListingNode);
474118611Snjl}
475118611Snjl
476118611Snjl
477118611Snjl/*******************************************************************************
478118611Snjl *
479118611Snjl * FUNCTION:    LsCheckException
480118611Snjl *
481118611Snjl * PARAMETERS:  LineNumber          - Current logical (cumulative) line #
482118611Snjl *              FileId              - ID of output listing file
483118611Snjl *
484118611Snjl * RETURN:      None
485118611Snjl *
486118611Snjl * DESCRIPTION: Check if there is an exception for this line, and if there is,
487241973Sjkim *              put it in the listing immediately. Handles multiple errors
488241973Sjkim *              per line. Gbl_NextError points to the next error in the
489118611Snjl *              sorted (by line #) list of compile errors/warnings.
490118611Snjl *
491118611Snjl ******************************************************************************/
492118611Snjl
493151937Sjkimstatic void
494118611SnjlLsCheckException (
495118611Snjl    UINT32                  LineNumber,
496118611Snjl    UINT32                  FileId)
497118611Snjl{
498118611Snjl
499118611Snjl    if ((!Gbl_NextError) ||
500118611Snjl        (LineNumber < Gbl_NextError->LogicalLineNumber ))
501118611Snjl    {
502118611Snjl        return;
503118611Snjl    }
504118611Snjl
505118611Snjl    /* Handle multiple errors per line */
506118611Snjl
507118611Snjl    if (FileId == ASL_FILE_LISTING_OUTPUT)
508118611Snjl    {
509118611Snjl        while (Gbl_NextError &&
510118611Snjl              (LineNumber >= Gbl_NextError->LogicalLineNumber))
511118611Snjl        {
512118611Snjl            AePrintException (FileId, Gbl_NextError, "\n[****iasl****]\n");
513118611Snjl
514118611Snjl            Gbl_NextError = Gbl_NextError->Next;
515118611Snjl        }
516118611Snjl
517118611Snjl        FlPrintFile (FileId, "\n");
518118611Snjl    }
519118611Snjl}
520118611Snjl
521118611Snjl
522118611Snjl/*******************************************************************************
523118611Snjl *
524118611Snjl * FUNCTION:    LsFlushListingBuffer
525118611Snjl *
526118611Snjl * PARAMETERS:  FileId          - ID of the listing file
527118611Snjl *
528118611Snjl * RETURN:      None
529118611Snjl *
530118611Snjl * DESCRIPTION: Flush out the current contents of the 16-byte hex AML code
531241973Sjkim *              buffer. Usually called at the termination of a single line
532118611Snjl *              of source code or when the buffer is full.
533118611Snjl *
534118611Snjl ******************************************************************************/
535118611Snjl
536151937Sjkimstatic void
537118611SnjlLsFlushListingBuffer (
538118611Snjl    UINT32                  FileId)
539118611Snjl{
540118611Snjl    UINT32                  i;
541118611Snjl
542118611Snjl
543118611Snjl    if (Gbl_CurrentHexColumn == 0)
544118611Snjl    {
545118611Snjl        return;
546118611Snjl    }
547118611Snjl
548118611Snjl    /* Write the hex bytes */
549118611Snjl
550118611Snjl    switch (FileId)
551118611Snjl    {
552118611Snjl    case ASL_FILE_LISTING_OUTPUT:
553118611Snjl
554118611Snjl        for (i = 0; i < Gbl_CurrentHexColumn; i++)
555118611Snjl        {
556118611Snjl            FlPrintFile (FileId, "%2.2X ", Gbl_AmlBuffer[i]);
557118611Snjl        }
558118611Snjl
559118611Snjl        for (i = 0; i < ((HEX_LISTING_LINE_SIZE - Gbl_CurrentHexColumn) * 3); i++)
560118611Snjl        {
561118611Snjl            FlWriteFile (FileId, ".", 1);
562118611Snjl        }
563118611Snjl
564118611Snjl        /* Write the ASCII character associated with each of the bytes */
565118611Snjl
566118611Snjl        LsDumpAscii (FileId, Gbl_CurrentHexColumn, Gbl_AmlBuffer);
567118611Snjl        break;
568118611Snjl
569118611Snjl
570118611Snjl    case ASL_FILE_ASM_SOURCE_OUTPUT:
571118611Snjl
572118611Snjl        for (i = 0; i < Gbl_CurrentHexColumn; i++)
573118611Snjl        {
574118611Snjl            if (i > 0)
575118611Snjl            {
576118611Snjl                FlPrintFile (FileId, ",");
577118611Snjl            }
578118611Snjl            FlPrintFile (FileId, "0%2.2Xh", Gbl_AmlBuffer[i]);
579118611Snjl        }
580118611Snjl
581118611Snjl        for (i = 0; i < ((HEX_LISTING_LINE_SIZE - Gbl_CurrentHexColumn) * 5); i++)
582118611Snjl        {
583118611Snjl            FlWriteFile (FileId, " ", 1);
584118611Snjl        }
585118611Snjl
586151937Sjkim        FlPrintFile (FileId, "  ;%8.8X",
587151937Sjkim            Gbl_CurrentAmlOffset - HEX_LISTING_LINE_SIZE);
588118611Snjl
589118611Snjl        /* Write the ASCII character associated with each of the bytes */
590118611Snjl
591118611Snjl        LsDumpAscii (FileId, Gbl_CurrentHexColumn, Gbl_AmlBuffer);
592118611Snjl        break;
593118611Snjl
594118611Snjl
595118611Snjl    case ASL_FILE_C_SOURCE_OUTPUT:
596118611Snjl
597118611Snjl        for (i = 0; i < Gbl_CurrentHexColumn; i++)
598118611Snjl        {
599118611Snjl            FlPrintFile (FileId, "0x%2.2X,", Gbl_AmlBuffer[i]);
600118611Snjl        }
601118611Snjl
602118611Snjl        for (i = 0; i < ((HEX_LISTING_LINE_SIZE - Gbl_CurrentHexColumn) * 5); i++)
603118611Snjl        {
604118611Snjl            FlWriteFile (FileId, " ", 1);
605118611Snjl        }
606118611Snjl
607151937Sjkim        FlPrintFile (FileId, "    /* %8.8X",
608151937Sjkim            Gbl_CurrentAmlOffset - HEX_LISTING_LINE_SIZE);
609118611Snjl
610118611Snjl        /* Write the ASCII character associated with each of the bytes */
611118611Snjl
612118611Snjl        LsDumpAsciiInComment (FileId, Gbl_CurrentHexColumn, Gbl_AmlBuffer);
613118611Snjl        FlPrintFile (FileId, " */");
614118611Snjl        break;
615118611Snjl
616118611Snjl    default:
617118611Snjl        /* No other types supported */
618118611Snjl        return;
619118611Snjl    }
620118611Snjl
621118611Snjl    FlPrintFile (FileId, "\n");
622118611Snjl
623118611Snjl    Gbl_CurrentHexColumn = 0;
624118611Snjl    Gbl_HexBytesWereWritten = TRUE;
625118611Snjl}
626118611Snjl
627118611Snjl
628118611Snjl/*******************************************************************************
629118611Snjl *
630118611Snjl * FUNCTION:    LsWriteListingHexBytes
631118611Snjl *
632118611Snjl * PARAMETERS:  Buffer          - AML code buffer
633118611Snjl *              Length          - Number of AML bytes to write
634118611Snjl *              FileId          - ID of current listing file.
635118611Snjl *
636118611Snjl * RETURN:      None
637118611Snjl *
638118611Snjl * DESCRIPTION: Write the contents of the AML buffer to the listing file via
639241973Sjkim *              the listing buffer. The listing buffer is flushed every 16
640118611Snjl *              AML bytes.
641118611Snjl *
642118611Snjl ******************************************************************************/
643118611Snjl
644151937Sjkimstatic void
645118611SnjlLsWriteListingHexBytes (
646118611Snjl    UINT8                   *Buffer,
647118611Snjl    UINT32                  Length,
648118611Snjl    UINT32                  FileId)
649118611Snjl{
650118611Snjl    UINT32                  i;
651118611Snjl
652118611Snjl
653118611Snjl    /* Transfer all requested bytes */
654118611Snjl
655118611Snjl    for (i = 0; i < Length; i++)
656118611Snjl    {
657118611Snjl        /* Print line header when buffer is empty */
658118611Snjl
659118611Snjl        if (Gbl_CurrentHexColumn == 0)
660118611Snjl        {
661118611Snjl            if (Gbl_HasIncludeFiles)
662118611Snjl            {
663118611Snjl                FlPrintFile (FileId, "%*s", 10, " ");
664118611Snjl            }
665118611Snjl
666118611Snjl            switch (FileId)
667118611Snjl            {
668118611Snjl            case ASL_FILE_LISTING_OUTPUT:
669118611Snjl
670245582Sjkim                FlPrintFile (FileId, "%8.8X%s", Gbl_CurrentAmlOffset,
671245582Sjkim                    ASL_LISTING_LINE_PREFIX);
672118611Snjl                break;
673118611Snjl
674118611Snjl            case ASL_FILE_ASM_SOURCE_OUTPUT:
675118611Snjl
676118611Snjl                FlPrintFile (FileId, "    db ");
677118611Snjl                break;
678118611Snjl
679118611Snjl            case ASL_FILE_C_SOURCE_OUTPUT:
680118611Snjl
681118611Snjl                FlPrintFile (FileId, "        ");
682118611Snjl                break;
683118611Snjl
684118611Snjl            default:
685118611Snjl                /* No other types supported */
686118611Snjl                return;
687118611Snjl            }
688118611Snjl        }
689118611Snjl
690118611Snjl        /* Transfer AML byte and update counts */
691118611Snjl
692118611Snjl        Gbl_AmlBuffer[Gbl_CurrentHexColumn] = Buffer[i];
693118611Snjl
694118611Snjl        Gbl_CurrentHexColumn++;
695118611Snjl        Gbl_CurrentAmlOffset++;
696118611Snjl
697118611Snjl        /* Flush buffer when it is full */
698118611Snjl
699118611Snjl        if (Gbl_CurrentHexColumn >= HEX_LISTING_LINE_SIZE)
700118611Snjl        {
701118611Snjl            LsFlushListingBuffer (FileId);
702118611Snjl        }
703118611Snjl    }
704118611Snjl}
705118611Snjl
706118611Snjl
707118611Snjl/*******************************************************************************
708118611Snjl *
709118611Snjl * FUNCTION:    LsWriteOneSourceLine
710118611Snjl *
711118611Snjl * PARAMETERS:  FileID          - ID of current listing file
712118611Snjl *
713118611Snjl * RETURN:      FALSE on EOF (input source file), TRUE otherwise
714118611Snjl *
715118611Snjl * DESCRIPTION: Read one line from the input source file and echo it to the
716118611Snjl *              listing file, prefixed with the line number, and if the source
717118611Snjl *              file contains include files, prefixed with the current filename
718118611Snjl *
719118611Snjl ******************************************************************************/
720118611Snjl
721151937Sjkimstatic UINT32
722118611SnjlLsWriteOneSourceLine (
723118611Snjl    UINT32                  FileId)
724118611Snjl{
725118611Snjl    UINT8                   FileByte;
726118611Snjl
727118611Snjl
728118611Snjl    Gbl_SourceLine++;
729118611Snjl    Gbl_ListingNode->LineNumber++;
730118611Snjl
731245582Sjkim    /* Ignore lines that are completely blank (but count the line above) */
732245582Sjkim
733245582Sjkim    if (FlReadFile (ASL_FILE_SOURCE_OUTPUT, &FileByte, 1) != AE_OK)
734245582Sjkim    {
735245582Sjkim        return (0);
736245582Sjkim    }
737245582Sjkim    if (FileByte == '\n')
738245582Sjkim    {
739245582Sjkim        return (1);
740245582Sjkim    }
741245582Sjkim
742245582Sjkim    /*
743245582Sjkim     * This is a non-empty line, we will print the entire line with
744245582Sjkim     * the line number and possibly other prefixes and transforms.
745245582Sjkim     */
746245582Sjkim
747245582Sjkim    /* Line prefixes for special files, C and ASM output */
748245582Sjkim
749118611Snjl    if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
750118611Snjl    {
751118611Snjl        FlPrintFile (FileId, "     *");
752118611Snjl    }
753118611Snjl    if (FileId == ASL_FILE_ASM_SOURCE_OUTPUT)
754118611Snjl    {
755118611Snjl        FlPrintFile (FileId, "; ");
756118611Snjl    }
757118611Snjl
758118611Snjl    if (Gbl_HasIncludeFiles)
759118611Snjl    {
760118611Snjl        /*
761118611Snjl         * This file contains "include" statements, print the current
762118611Snjl         * filename and line number within the current file
763118611Snjl         */
764245582Sjkim        FlPrintFile (FileId, "%12s %5d%s",
765245582Sjkim            Gbl_ListingNode->Filename, Gbl_ListingNode->LineNumber,
766245582Sjkim            ASL_LISTING_LINE_PREFIX);
767118611Snjl    }
768118611Snjl    else
769118611Snjl    {
770118611Snjl        /* No include files, just print the line number */
771118611Snjl
772245582Sjkim        FlPrintFile (FileId, "%8u%s", Gbl_SourceLine,
773245582Sjkim            ASL_LISTING_LINE_PREFIX);
774118611Snjl    }
775118611Snjl
776245582Sjkim    /* Read the rest of this line (up to a newline or EOF) */
777118611Snjl
778245582Sjkim    do
779118611Snjl    {
780118611Snjl        if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
781118611Snjl        {
782118611Snjl            if (FileByte == '/')
783118611Snjl            {
784118611Snjl                FileByte = '*';
785118611Snjl            }
786118611Snjl        }
787118611Snjl
788118611Snjl        FlWriteFile (FileId, &FileByte, 1);
789118611Snjl        if (FileByte == '\n')
790118611Snjl        {
791118611Snjl            /*
792245582Sjkim             * This line has been completed.
793118611Snjl             * Check if an error occurred on this source line during the compile.
794118611Snjl             * If so, we print the error message after the source line.
795118611Snjl             */
796118611Snjl            LsCheckException (Gbl_SourceLine, FileId);
797118611Snjl            return (1);
798118611Snjl        }
799118611Snjl
800245582Sjkim    } while (FlReadFile (ASL_FILE_SOURCE_OUTPUT, &FileByte, 1) == AE_OK);
801245582Sjkim
802118611Snjl    /* EOF on the input file was reached */
803118611Snjl
804118611Snjl    return (0);
805118611Snjl}
806118611Snjl
807118611Snjl
808118611Snjl/*******************************************************************************
809118611Snjl *
810118611Snjl * FUNCTION:    LsFinishSourceListing
811118611Snjl *
812118611Snjl * PARAMETERS:  FileId          - ID of current listing file.
813118611Snjl *
814118611Snjl * RETURN:      None
815118611Snjl *
816241973Sjkim * DESCRIPTION: Cleanup routine for the listing file. Flush the hex AML
817118611Snjl *              listing buffer, and flush out any remaining lines in the
818118611Snjl *              source input file.
819118611Snjl *
820118611Snjl ******************************************************************************/
821118611Snjl
822151937Sjkimstatic void
823118611SnjlLsFinishSourceListing (
824118611Snjl    UINT32                  FileId)
825118611Snjl{
826118611Snjl
827118611Snjl    if ((FileId == ASL_FILE_ASM_INCLUDE_OUTPUT) ||
828118611Snjl        (FileId == ASL_FILE_C_INCLUDE_OUTPUT))
829118611Snjl    {
830118611Snjl        return;
831118611Snjl    }
832118611Snjl
833118611Snjl    LsFlushListingBuffer (FileId);
834118611Snjl    Gbl_CurrentAmlOffset = 0;
835118611Snjl
836118611Snjl    /* Flush any remaining text in the source file */
837118611Snjl
838118611Snjl    if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
839118611Snjl    {
840118611Snjl        FlPrintFile (FileId, "    /*\n");
841118611Snjl    }
842118611Snjl
843118611Snjl    while (LsWriteOneSourceLine (FileId))
844118611Snjl    { ; }
845118611Snjl
846118611Snjl    if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
847118611Snjl    {
848118611Snjl        FlPrintFile (FileId, "\n     */\n    };\n");
849118611Snjl    }
850118611Snjl
851118611Snjl    FlPrintFile (FileId, "\n");
852118611Snjl
853118611Snjl    if (FileId == ASL_FILE_LISTING_OUTPUT)
854118611Snjl    {
855118611Snjl        /* Print a summary of the compile exceptions */
856118611Snjl
857118611Snjl        FlPrintFile (FileId, "\n\nSummary of errors and warnings\n\n");
858118611Snjl        AePrintErrorLog (FileId);
859228110Sjkim        FlPrintFile (FileId, "\n");
860118611Snjl        UtDisplaySummary (FileId);
861228110Sjkim        FlPrintFile (FileId, "\n");
862118611Snjl    }
863118611Snjl}
864118611Snjl
865118611Snjl
866118611Snjl/*******************************************************************************
867118611Snjl *
868118611Snjl * FUNCTION:    LsWriteSourceLines
869118611Snjl *
870118611Snjl * PARAMETERS:  ToLineNumber            -
871118611Snjl *              ToLogicalLineNumber     - Write up to this source line number
872118611Snjl *              FileId                  - ID of current listing file
873118611Snjl *
874118611Snjl * RETURN:      None
875118611Snjl *
876118611Snjl * DESCRIPTION: Read then write source lines to the listing file until we have
877241973Sjkim *              reached the specified logical (cumulative) line number. This
878118611Snjl *              automatically echos out comment blocks and other non-AML
879118611Snjl *              generating text until we get to the actual AML-generating line
880118611Snjl *              of ASL code specified by the logical line number.
881118611Snjl *
882118611Snjl ******************************************************************************/
883118611Snjl
884151937Sjkimstatic void
885118611SnjlLsWriteSourceLines (
886118611Snjl    UINT32                  ToLineNumber,
887118611Snjl    UINT32                  ToLogicalLineNumber,
888118611Snjl    UINT32                  FileId)
889118611Snjl{
890118611Snjl
891118611Snjl    if ((FileId == ASL_FILE_ASM_INCLUDE_OUTPUT) ||
892118611Snjl        (FileId == ASL_FILE_C_INCLUDE_OUTPUT))
893118611Snjl    {
894118611Snjl        return;
895118611Snjl    }
896118611Snjl
897118611Snjl    Gbl_CurrentLine = ToLogicalLineNumber;
898118611Snjl
899118611Snjl    /* Flush any hex bytes remaining from the last opcode */
900118611Snjl
901118611Snjl    LsFlushListingBuffer (FileId);
902118611Snjl
903151937Sjkim    /* Read lines and write them as long as we are not caught up */
904151937Sjkim
905118611Snjl    if (Gbl_SourceLine < Gbl_CurrentLine)
906118611Snjl    {
907118611Snjl        /*
908118611Snjl         * If we just completed writing some AML hex bytes, output a linefeed
909118611Snjl         * to add some whitespace for readability.
910118611Snjl         */
911118611Snjl        if (Gbl_HexBytesWereWritten)
912118611Snjl        {
913118611Snjl            FlPrintFile (FileId, "\n");
914118611Snjl            Gbl_HexBytesWereWritten = FALSE;
915118611Snjl        }
916118611Snjl
917118611Snjl        if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
918118611Snjl        {
919118611Snjl            FlPrintFile (FileId, "    /*\n");
920118611Snjl        }
921118611Snjl
922151937Sjkim        /* Write one line at a time until we have reached the target line # */
923151937Sjkim
924118611Snjl        while ((Gbl_SourceLine < Gbl_CurrentLine) &&
925118611Snjl                LsWriteOneSourceLine (FileId))
926118611Snjl        { ; }
927118611Snjl
928118611Snjl        if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
929118611Snjl        {
930118611Snjl            FlPrintFile (FileId, "     */");
931118611Snjl        }
932118611Snjl        FlPrintFile (FileId, "\n");
933118611Snjl    }
934118611Snjl}
935118611Snjl
936118611Snjl
937118611Snjl/*******************************************************************************
938118611Snjl *
939118611Snjl * FUNCTION:    LsWriteNodeToListing
940118611Snjl *
941118611Snjl * PARAMETERS:  Op            - Parse node to write to the listing file.
942118611Snjl *              FileId          - ID of current listing file
943118611Snjl *
944118611Snjl * RETURN:      None.
945118611Snjl *
946241973Sjkim * DESCRIPTION: Write "a node" to the listing file. This means to
947118611Snjl *              1) Write out all of the source text associated with the node
948118611Snjl *              2) Write out all of the AML bytes associated with the node
949118611Snjl *              3) Write any compiler exceptions associated with the node
950118611Snjl *
951118611Snjl ******************************************************************************/
952118611Snjl
953151937Sjkimstatic void
954118611SnjlLsWriteNodeToListing (
955118611Snjl    ACPI_PARSE_OBJECT       *Op,
956118611Snjl    UINT32                  FileId)
957118611Snjl{
958118611Snjl    const ACPI_OPCODE_INFO  *OpInfo;
959118611Snjl    UINT32                  OpClass;
960118611Snjl    char                    *Pathname;
961118611Snjl    UINT32                  Length;
962118611Snjl    UINT32                  i;
963118611Snjl
964118611Snjl
965118611Snjl    OpInfo  = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode);
966118611Snjl    OpClass = OpInfo->Class;
967118611Snjl
968151937Sjkim    /* TBD: clean this up with a single flag that says:
969151937Sjkim     * I start a named output block
970151937Sjkim     */
971118611Snjl    if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
972118611Snjl    {
973118611Snjl        switch (Op->Asl.ParseOpcode)
974118611Snjl        {
975118611Snjl        case PARSEOP_DEFINITIONBLOCK:
976118611Snjl        case PARSEOP_METHODCALL:
977118611Snjl        case PARSEOP_INCLUDE:
978118611Snjl        case PARSEOP_INCLUDE_END:
979118611Snjl        case PARSEOP_DEFAULT_ARG:
980118611Snjl
981118611Snjl            break;
982118611Snjl
983118611Snjl        default:
984118611Snjl            switch (OpClass)
985118611Snjl            {
986118611Snjl            case AML_CLASS_NAMED_OBJECT:
987118611Snjl                switch (Op->Asl.AmlOpcode)
988118611Snjl                {
989118611Snjl                case AML_SCOPE_OP:
990118611Snjl                case AML_ALIAS_OP:
991118611Snjl                    break;
992118611Snjl
993118611Snjl                default:
994118611Snjl                    if (Op->Asl.ExternalName)
995118611Snjl                    {
996118611Snjl                        LsFlushListingBuffer (FileId);
997118611Snjl                        FlPrintFile (FileId, "    };\n");
998118611Snjl                    }
999118611Snjl                    break;
1000118611Snjl                }
1001118611Snjl                break;
1002118611Snjl
1003118611Snjl            default:
1004118611Snjl                /* Don't care about other objects */
1005118611Snjl                break;
1006118611Snjl            }
1007118611Snjl            break;
1008118611Snjl        }
1009118611Snjl    }
1010118611Snjl
1011118611Snjl    /* These cases do not have a corresponding AML opcode */
1012118611Snjl
1013118611Snjl    switch (Op->Asl.ParseOpcode)
1014118611Snjl    {
1015118611Snjl    case PARSEOP_DEFINITIONBLOCK:
1016118611Snjl
1017118611Snjl        LsWriteSourceLines (Op->Asl.EndLine, Op->Asl.EndLogicalLine, FileId);
1018118611Snjl
1019118611Snjl        /* Use the table Signature and TableId to build a unique name */
1020118611Snjl
1021118611Snjl        if (FileId == ASL_FILE_ASM_SOURCE_OUTPUT)
1022118611Snjl        {
1023151937Sjkim            FlPrintFile (FileId,
1024151937Sjkim                "%s_%s_Header \\\n",
1025118611Snjl                Gbl_TableSignature, Gbl_TableId);
1026118611Snjl        }
1027118611Snjl        if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
1028118611Snjl        {
1029151937Sjkim            FlPrintFile (FileId,
1030151937Sjkim                "    unsigned char    %s_%s_Header [] =\n    {\n",
1031118611Snjl                Gbl_TableSignature, Gbl_TableId);
1032118611Snjl        }
1033118611Snjl        if (FileId == ASL_FILE_ASM_INCLUDE_OUTPUT)
1034118611Snjl        {
1035151937Sjkim            FlPrintFile (FileId,
1036151937Sjkim                "extrn %s_%s_Header : byte\n",
1037118611Snjl                Gbl_TableSignature, Gbl_TableId);
1038118611Snjl        }
1039118611Snjl        if (FileId == ASL_FILE_C_INCLUDE_OUTPUT)
1040118611Snjl        {
1041151937Sjkim            FlPrintFile (FileId,
1042151937Sjkim                "extern unsigned char    %s_%s_Header [];\n",
1043118611Snjl                Gbl_TableSignature, Gbl_TableId);
1044118611Snjl        }
1045118611Snjl        return;
1046118611Snjl
1047118611Snjl
1048118611Snjl    case PARSEOP_METHODCALL:
1049118611Snjl
1050151937Sjkim        LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber,
1051151937Sjkim            FileId);
1052118611Snjl        return;
1053118611Snjl
1054118611Snjl
1055118611Snjl    case PARSEOP_INCLUDE:
1056118611Snjl
1057151937Sjkim        /* Flush everything up to and including the include source line */
1058118611Snjl
1059151937Sjkim        LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber,
1060151937Sjkim            FileId);
1061151937Sjkim
1062151937Sjkim        /* Create a new listing node and push it */
1063151937Sjkim
1064118611Snjl        LsPushNode (Op->Asl.Child->Asl.Value.String);
1065118611Snjl        return;
1066118611Snjl
1067118611Snjl
1068118611Snjl    case PARSEOP_INCLUDE_END:
1069118611Snjl
1070151937Sjkim        /* Flush out the rest of the include file */
1071118611Snjl
1072151937Sjkim        LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber,
1073151937Sjkim            FileId);
1074151937Sjkim
1075151937Sjkim        /* Pop off this listing node and go back to the parent file */
1076151937Sjkim
1077151937Sjkim        (void) LsPopNode ();
1078118611Snjl        return;
1079118611Snjl
1080118611Snjl
1081118611Snjl    case PARSEOP_DEFAULT_ARG:
1082167802Sjkim
1083167802Sjkim        if (Op->Asl.CompileFlags & NODE_IS_RESOURCE_DESC)
1084167802Sjkim        {
1085167802Sjkim            LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.EndLogicalLine,
1086167802Sjkim                FileId);
1087167802Sjkim        }
1088118611Snjl        return;
1089118611Snjl
1090118611Snjl
1091118611Snjl    default:
1092118611Snjl        /* All other opcodes have an AML opcode */
1093118611Snjl        break;
1094118611Snjl    }
1095118611Snjl
1096118611Snjl    /*
1097118611Snjl     * Otherwise, we look at the AML opcode because we can
1098118611Snjl     * switch on the opcode type, getting an entire class
1099118611Snjl     * at once
1100118611Snjl     */
1101118611Snjl    switch (OpClass)
1102118611Snjl    {
1103118611Snjl    case AML_CLASS_ARGUMENT:       /* argument type only */
1104118611Snjl    case AML_CLASS_INTERNAL:
1105118611Snjl
1106118611Snjl        break;
1107118611Snjl
1108118611Snjl
1109118611Snjl    case AML_CLASS_NAMED_OBJECT:
1110118611Snjl
1111118611Snjl        switch (Op->Asl.AmlOpcode)
1112118611Snjl        {
1113118611Snjl        case AML_FIELD_OP:
1114118611Snjl        case AML_INDEX_FIELD_OP:
1115118611Snjl        case AML_BANK_FIELD_OP:
1116118611Snjl
1117151937Sjkim            /*
1118151937Sjkim             * For fields, we want to dump all the AML after the
1119151937Sjkim             * entire definition
1120151937Sjkim             */
1121151937Sjkim            LsWriteSourceLines (Op->Asl.EndLine, Op->Asl.EndLogicalLine,
1122151937Sjkim                FileId);
1123118611Snjl            break;
1124118611Snjl
1125167802Sjkim        case AML_NAME_OP:
1126167802Sjkim
1127167802Sjkim            if (Op->Asl.CompileFlags & NODE_IS_RESOURCE_DESC)
1128167802Sjkim            {
1129167802Sjkim                LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber,
1130167802Sjkim                    FileId);
1131167802Sjkim            }
1132167802Sjkim            else
1133167802Sjkim            {
1134167802Sjkim                /*
1135167802Sjkim                 * For fields, we want to dump all the AML after the
1136167802Sjkim                 * entire definition
1137167802Sjkim                 */
1138167802Sjkim                LsWriteSourceLines (Op->Asl.EndLine, Op->Asl.EndLogicalLine,
1139167802Sjkim                    FileId);
1140167802Sjkim            }
1141167802Sjkim            break;
1142167802Sjkim
1143118611Snjl        default:
1144151937Sjkim            LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber,
1145151937Sjkim                FileId);
1146118611Snjl            break;
1147118611Snjl        }
1148118611Snjl
1149118611Snjl        switch (Op->Asl.AmlOpcode)
1150118611Snjl        {
1151118611Snjl        case AML_SCOPE_OP:
1152118611Snjl        case AML_ALIAS_OP:
1153118611Snjl
1154118611Snjl            /* These opcodes do not declare a new object, ignore them */
1155118611Snjl
1156118611Snjl            break;
1157118611Snjl
1158118611Snjl        default:
1159118611Snjl
1160118611Snjl            /* All other named object opcodes come here */
1161118611Snjl
1162118611Snjl            switch (FileId)
1163118611Snjl            {
1164118611Snjl            case ASL_FILE_ASM_SOURCE_OUTPUT:
1165118611Snjl            case ASL_FILE_C_SOURCE_OUTPUT:
1166118611Snjl            case ASL_FILE_ASM_INCLUDE_OUTPUT:
1167118611Snjl            case ASL_FILE_C_INCLUDE_OUTPUT:
1168118611Snjl
1169118611Snjl                /*
1170118611Snjl                 * For named objects, we will create a valid symbol so that the
1171118611Snjl                 * AML code can be referenced from C or ASM
1172118611Snjl                 */
1173118611Snjl                if (Op->Asl.ExternalName)
1174118611Snjl                {
1175118611Snjl                    /* Get the full pathname associated with this node */
1176118611Snjl
1177118611Snjl                    Pathname = AcpiNsGetExternalPathname (Op->Asl.Node);
1178118611Snjl                    Length = strlen (Pathname);
1179118611Snjl                    if (Length >= 4)
1180118611Snjl                    {
1181118611Snjl                        /* Convert all dots in the path to underscores */
1182118611Snjl
1183118611Snjl                        for (i = 0; i < Length; i++)
1184118611Snjl                        {
1185118611Snjl                            if (Pathname[i] == '.')
1186118611Snjl                            {
1187118611Snjl                                Pathname[i] = '_';
1188118611Snjl                            }
1189118611Snjl                        }
1190118611Snjl
1191118611Snjl                        /* Create the appropriate symbol in the output file */
1192118611Snjl
1193118611Snjl                        if (FileId == ASL_FILE_ASM_SOURCE_OUTPUT)
1194118611Snjl                        {
1195151937Sjkim                            FlPrintFile (FileId,
1196151937Sjkim                                "%s_%s_%s  \\\n",
1197118611Snjl                                Gbl_TableSignature, Gbl_TableId, &Pathname[1]);
1198118611Snjl                        }
1199118611Snjl                        if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
1200118611Snjl                        {
1201151937Sjkim                            FlPrintFile (FileId,
1202151937Sjkim                                "    unsigned char    %s_%s_%s [] =\n    {\n",
1203118611Snjl                                Gbl_TableSignature, Gbl_TableId, &Pathname[1]);
1204118611Snjl                        }
1205118611Snjl                        if (FileId == ASL_FILE_ASM_INCLUDE_OUTPUT)
1206118611Snjl                        {
1207151937Sjkim                            FlPrintFile (FileId,
1208151937Sjkim                                "extrn %s_%s_%s : byte\n",
1209118611Snjl                                Gbl_TableSignature, Gbl_TableId, &Pathname[1]);
1210118611Snjl                        }
1211118611Snjl                        if (FileId == ASL_FILE_C_INCLUDE_OUTPUT)
1212118611Snjl                        {
1213151937Sjkim                            FlPrintFile (FileId,
1214151937Sjkim                                "extern unsigned char    %s_%s_%s [];\n",
1215118611Snjl                                Gbl_TableSignature, Gbl_TableId, &Pathname[1]);
1216118611Snjl                        }
1217118611Snjl                    }
1218167802Sjkim                    ACPI_FREE (Pathname);
1219118611Snjl                }
1220118611Snjl                break;
1221118611Snjl
1222118611Snjl            default:
1223118611Snjl                /* Nothing to do for listing file */
1224118611Snjl                break;
1225118611Snjl            }
1226118611Snjl        }
1227118611Snjl        break;
1228118611Snjl
1229118611Snjl    case AML_CLASS_EXECUTE:
1230118611Snjl    case AML_CLASS_CREATE:
1231118611Snjl    default:
1232118611Snjl
1233167802Sjkim        if ((Op->Asl.ParseOpcode == PARSEOP_BUFFER) &&
1234167802Sjkim            (Op->Asl.CompileFlags & NODE_IS_RESOURCE_DESC))
1235167802Sjkim        {
1236167802Sjkim            return;
1237167802Sjkim        }
1238167802Sjkim
1239151937Sjkim        LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber,
1240151937Sjkim            FileId);
1241118611Snjl        break;
1242118611Snjl
1243118611Snjl    case AML_CLASS_UNKNOWN:
1244118611Snjl        break;
1245118611Snjl    }
1246118611Snjl}
1247