aslcodegen.c revision 217365
1118611Snjl
2118611Snjl/******************************************************************************
3118611Snjl *
4118611Snjl * Module Name: aslcodegen - AML code generation
5118611Snjl *
6118611Snjl *****************************************************************************/
7118611Snjl
8217365Sjkim/*
9217365Sjkim * Copyright (C) 2000 - 2011, Intel Corp.
10118611Snjl * All rights reserved.
11118611Snjl *
12217365Sjkim * Redistribution and use in source and binary forms, with or without
13217365Sjkim * modification, are permitted provided that the following conditions
14217365Sjkim * are met:
15217365Sjkim * 1. Redistributions of source code must retain the above copyright
16217365Sjkim *    notice, this list of conditions, and the following disclaimer,
17217365Sjkim *    without modification.
18217365Sjkim * 2. Redistributions in binary form must reproduce at minimum a disclaimer
19217365Sjkim *    substantially similar to the "NO WARRANTY" disclaimer below
20217365Sjkim *    ("Disclaimer") and any redistribution must be conditioned upon
21217365Sjkim *    including a substantially similar Disclaimer requirement for further
22217365Sjkim *    binary redistribution.
23217365Sjkim * 3. Neither the names of the above-listed copyright holders nor the names
24217365Sjkim *    of any contributors may be used to endorse or promote products derived
25217365Sjkim *    from this software without specific prior written permission.
26118611Snjl *
27217365Sjkim * Alternatively, this software may be distributed under the terms of the
28217365Sjkim * GNU General Public License ("GPL") version 2 as published by the Free
29217365Sjkim * Software Foundation.
30118611Snjl *
31217365Sjkim * NO WARRANTY
32217365Sjkim * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
33217365Sjkim * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34217365Sjkim * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
35217365Sjkim * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
36217365Sjkim * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37217365Sjkim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38217365Sjkim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39217365Sjkim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40217365Sjkim * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
41217365Sjkim * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42217365Sjkim * POSSIBILITY OF SUCH DAMAGES.
43217365Sjkim */
44118611Snjl
45118611Snjl
46151937Sjkim#include <contrib/dev/acpica/compiler/aslcompiler.h>
47118611Snjl#include "aslcompiler.y.h"
48193529Sjkim#include <contrib/dev/acpica/include/amlcode.h>
49118611Snjl
50118611Snjl#define _COMPONENT          ACPI_COMPILER
51118611Snjl        ACPI_MODULE_NAME    ("aslcodegen")
52118611Snjl
53151937Sjkim/* Local prototypes */
54118611Snjl
55151937Sjkimstatic ACPI_STATUS
56151937SjkimCgAmlWriteWalk (
57151937Sjkim    ACPI_PARSE_OBJECT       *Op,
58151937Sjkim    UINT32                  Level,
59151937Sjkim    void                    *Context);
60151937Sjkim
61151937Sjkimstatic void
62151937SjkimCgLocalWriteAmlData (
63151937Sjkim    ACPI_PARSE_OBJECT       *Op,
64151937Sjkim    void                    *Buffer,
65151937Sjkim    UINT32                  Length);
66151937Sjkim
67151937Sjkimstatic void
68151937SjkimCgWriteAmlOpcode (
69151937Sjkim    ACPI_PARSE_OBJECT       *Op);
70151937Sjkim
71151937Sjkimstatic void
72151937SjkimCgWriteTableHeader (
73151937Sjkim    ACPI_PARSE_OBJECT       *Op);
74151937Sjkim
75151937Sjkimstatic void
76151937SjkimCgCloseTable (
77151937Sjkim    void);
78151937Sjkim
79151937Sjkimstatic void
80151937SjkimCgWriteNode (
81151937Sjkim    ACPI_PARSE_OBJECT       *Op);
82151937Sjkim
83151937Sjkim
84118611Snjl/*******************************************************************************
85118611Snjl *
86118611Snjl * FUNCTION:    CgGenerateAmlOutput
87118611Snjl *
88118611Snjl * PARAMETERS:  None.
89118611Snjl *
90118611Snjl * RETURN:      None
91118611Snjl *
92118611Snjl * DESCRIPTION: Generate AML code.  Currently generates the listing file
93118611Snjl *              simultaneously.
94118611Snjl *
95118611Snjl ******************************************************************************/
96118611Snjl
97118611Snjlvoid
98151937SjkimCgGenerateAmlOutput (
99151937Sjkim    void)
100118611Snjl{
101118611Snjl
102118611Snjl    DbgPrint (ASL_DEBUG_OUTPUT, "\nWriting AML\n\n");
103118611Snjl
104118611Snjl    /* Generate the AML output file */
105118611Snjl
106118611Snjl    FlSeekFile (ASL_FILE_SOURCE_OUTPUT, 0);
107118611Snjl    Gbl_SourceLine = 0;
108118611Snjl    Gbl_NextError = Gbl_ErrorLog;
109118611Snjl
110151937Sjkim    TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD,
111151937Sjkim        CgAmlWriteWalk, NULL, NULL);
112118611Snjl    CgCloseTable ();
113118611Snjl}
114118611Snjl
115118611Snjl
116118611Snjl/*******************************************************************************
117118611Snjl *
118118611Snjl * FUNCTION:    CgAmlWriteWalk
119118611Snjl *
120118611Snjl * PARAMETERS:  ASL_WALK_CALLBACK
121118611Snjl *
122118611Snjl * RETURN:      Status
123118611Snjl *
124118611Snjl * DESCRIPTION: Parse tree walk to generate the AML code.
125118611Snjl *
126118611Snjl ******************************************************************************/
127118611Snjl
128151937Sjkimstatic ACPI_STATUS
129118611SnjlCgAmlWriteWalk (
130118611Snjl    ACPI_PARSE_OBJECT       *Op,
131118611Snjl    UINT32                  Level,
132118611Snjl    void                    *Context)
133118611Snjl{
134118611Snjl
135167802Sjkim    /*
136167802Sjkim     * Print header at level 0. Alignment assumes 32-bit pointers
137167802Sjkim     */
138167802Sjkim    if (!Level)
139167802Sjkim    {
140167802Sjkim        DbgPrint (ASL_TREE_OUTPUT,
141167802Sjkim            "Final parse tree used for AML output:\n");
142167802Sjkim        DbgPrint (ASL_TREE_OUTPUT,
143167802Sjkim            "%*s Value    P_Op A_Op OpLen PByts Len  SubLen PSubLen OpPtr    Child    Parent   Flags    AcTyp    Final Col L\n",
144167802Sjkim            76, " ");
145167802Sjkim    }
146167802Sjkim
147151937Sjkim    /* Debug output */
148151937Sjkim
149118611Snjl    DbgPrint (ASL_TREE_OUTPUT,
150118611Snjl        "%5.5d [%2d]", Op->Asl.LogicalLineNumber, Level);
151118611Snjl    UtPrintFormattedName (Op->Asl.ParseOpcode, Level);
152118611Snjl
153118611Snjl    if (Op->Asl.ParseOpcode == PARSEOP_NAMESEG    ||
154118611Snjl        Op->Asl.ParseOpcode == PARSEOP_NAMESTRING ||
155118611Snjl        Op->Asl.ParseOpcode == PARSEOP_METHODCALL)
156118611Snjl    {
157118611Snjl        DbgPrint (ASL_TREE_OUTPUT,
158118611Snjl            "%10.32s      ", Op->Asl.ExternalName);
159118611Snjl    }
160118611Snjl    else
161118611Snjl    {
162118611Snjl        DbgPrint (ASL_TREE_OUTPUT, "                ");
163118611Snjl    }
164118611Snjl
165193529Sjkim    DbgPrint (ASL_TREE_OUTPUT,
166193529Sjkim    "%08X %04X %04X %01X     %04X  %04X %04X   %04X    %08X %08X %08X %08X %08X %04X  %02d  %02d\n",
167193529Sjkim            /* 1  */ (UINT32) Op->Asl.Value.Integer,
168193529Sjkim            /* 2  */ Op->Asl.ParseOpcode,
169193529Sjkim            /* 3  */ Op->Asl.AmlOpcode,
170193529Sjkim            /* 4  */ Op->Asl.AmlOpcodeLength,
171193529Sjkim            /* 5  */ Op->Asl.AmlPkgLenBytes,
172193529Sjkim            /* 6  */ Op->Asl.AmlLength,
173193529Sjkim            /* 7  */ Op->Asl.AmlSubtreeLength,
174193529Sjkim            /* 8  */ Op->Asl.Parent ? Op->Asl.Parent->Asl.AmlSubtreeLength : 0,
175193529Sjkim            /* 9  */ Op,
176193529Sjkim            /* 10 */ Op->Asl.Child,
177193529Sjkim            /* 11 */ Op->Asl.Parent,
178193529Sjkim            /* 12 */ Op->Asl.CompileFlags,
179193529Sjkim            /* 13 */ Op->Asl.AcpiBtype,
180193529Sjkim            /* 14 */ Op->Asl.FinalAmlLength,
181193529Sjkim            /* 15 */ Op->Asl.Column,
182193529Sjkim            /* 16 */ Op->Asl.LineNumber);
183118611Snjl
184151937Sjkim    /* Generate the AML for this node */
185151937Sjkim
186118611Snjl    CgWriteNode (Op);
187118611Snjl    return (AE_OK);
188118611Snjl}
189118611Snjl
190118611Snjl
191118611Snjl/*******************************************************************************
192118611Snjl *
193118611Snjl * FUNCTION:    CgLocalWriteAmlData
194118611Snjl *
195151937Sjkim * PARAMETERS:  Op              - Current parse op
196151937Sjkim *              Buffer          - Buffer to write
197118611Snjl *              Length          - Size of data in buffer
198118611Snjl *
199118611Snjl * RETURN:      None
200118611Snjl *
201118611Snjl * DESCRIPTION: Write a buffer of AML data to the AML output file.
202118611Snjl *
203118611Snjl ******************************************************************************/
204118611Snjl
205151937Sjkimstatic void
206118611SnjlCgLocalWriteAmlData (
207118611Snjl    ACPI_PARSE_OBJECT       *Op,
208118611Snjl    void                    *Buffer,
209118611Snjl    UINT32                  Length)
210118611Snjl{
211118611Snjl
212118611Snjl    /* Write the raw data to the AML file */
213118611Snjl
214118611Snjl    FlWriteFile (ASL_FILE_AML_OUTPUT, Buffer, Length);
215118611Snjl
216118611Snjl    /* Update the final AML length for this node (used for listings) */
217118611Snjl
218118611Snjl    if (Op)
219118611Snjl    {
220118611Snjl        Op->Asl.FinalAmlLength += Length;
221118611Snjl    }
222118611Snjl}
223118611Snjl
224118611Snjl
225118611Snjl/*******************************************************************************
226118611Snjl *
227118611Snjl * FUNCTION:    CgWriteAmlOpcode
228118611Snjl *
229118611Snjl * PARAMETERS:  Op            - Parse node with an AML opcode
230118611Snjl *
231118611Snjl * RETURN:      None.
232118611Snjl *
233118611Snjl * DESCRIPTION: Write the AML opcode corresponding to a parse node.
234118611Snjl *
235118611Snjl ******************************************************************************/
236118611Snjl
237151937Sjkimstatic void
238118611SnjlCgWriteAmlOpcode (
239151937Sjkim    ACPI_PARSE_OBJECT       *Op)
240118611Snjl{
241151937Sjkim    UINT8                   PkgLenFirstByte;
242151937Sjkim    UINT32                  i;
243118611Snjl    union {
244151937Sjkim        UINT16                  Opcode;
245151937Sjkim        UINT8                   OpcodeBytes[2];
246118611Snjl    } Aml;
247118611Snjl    union {
248151937Sjkim        UINT32                  Len;
249151937Sjkim        UINT8                   LenBytes[4];
250118611Snjl    } PkgLen;
251118611Snjl
252118611Snjl
253118611Snjl    /* We expect some DEFAULT_ARGs, just ignore them */
254118611Snjl
255118611Snjl    if (Op->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG)
256118611Snjl    {
257118611Snjl        return;
258118611Snjl    }
259118611Snjl
260118611Snjl    switch (Op->Asl.AmlOpcode)
261118611Snjl    {
262118611Snjl    case AML_UNASSIGNED_OPCODE:
263118611Snjl
264118611Snjl        /* These opcodes should not get here */
265118611Snjl
266118611Snjl        printf ("Found a node with an unassigned AML opcode\n");
267118611Snjl        fprintf (stderr, "Found a node with an unassigned AML opcode\n");
268118611Snjl        return;
269118611Snjl
270118611Snjl    case AML_INT_RESERVEDFIELD_OP:
271118611Snjl
272118611Snjl        /* Special opcodes for within a field definition */
273118611Snjl
274118611Snjl        Aml.Opcode = 0x00;
275118611Snjl        break;
276118611Snjl
277118611Snjl    case AML_INT_ACCESSFIELD_OP:
278118611Snjl
279118611Snjl        Aml.Opcode = 0x01;
280118611Snjl        break;
281118611Snjl
282118611Snjl    default:
283118611Snjl        Aml.Opcode = Op->Asl.AmlOpcode;
284118611Snjl        break;
285118611Snjl    }
286118611Snjl
287118611Snjl
288118611Snjl    switch (Aml.Opcode)
289118611Snjl    {
290118611Snjl    case AML_PACKAGE_LENGTH:
291118611Snjl
292118611Snjl        /* Value is the length to be encoded (Used in field definitions) */
293118611Snjl
294118611Snjl        PkgLen.Len = (UINT32) Op->Asl.Value.Integer;
295118611Snjl        break;
296118611Snjl
297118611Snjl    default:
298118611Snjl
299118611Snjl        /* Check for two-byte opcode */
300118611Snjl
301118611Snjl        if (Aml.Opcode > 0x00FF)
302118611Snjl        {
303118611Snjl            /* Write the high byte first */
304118611Snjl
305118611Snjl            CgLocalWriteAmlData (Op, &Aml.OpcodeBytes[1], 1);
306118611Snjl        }
307118611Snjl
308118611Snjl        CgLocalWriteAmlData (Op, &Aml.OpcodeBytes[0], 1);
309118611Snjl
310118611Snjl        /* Subtreelength doesn't include length of package length bytes */
311118611Snjl
312118611Snjl        PkgLen.Len = Op->Asl.AmlSubtreeLength + Op->Asl.AmlPkgLenBytes;
313118611Snjl        break;
314118611Snjl    }
315118611Snjl
316118611Snjl    /* Does this opcode have an associated "PackageLength" field? */
317118611Snjl
318118611Snjl    if (Op->Asl.CompileFlags & NODE_AML_PACKAGE)
319118611Snjl    {
320118611Snjl        if (Op->Asl.AmlPkgLenBytes == 1)
321118611Snjl        {
322118611Snjl            /* Simplest case -- no bytes to follow, just write the count */
323118611Snjl
324118611Snjl            CgLocalWriteAmlData (Op, &PkgLen.LenBytes[0], 1);
325118611Snjl        }
326167802Sjkim        else if (Op->Asl.AmlPkgLenBytes != 0)
327118611Snjl        {
328118611Snjl            /*
329118611Snjl             * Encode the "bytes to follow" in the first byte, top two bits.
330118611Snjl             * The low-order nybble of the length is in the bottom 4 bits
331118611Snjl             */
332151937Sjkim            PkgLenFirstByte = (UINT8)
333151937Sjkim                (((UINT32) (Op->Asl.AmlPkgLenBytes - 1) << 6) |
334151937Sjkim                (PkgLen.LenBytes[0] & 0x0F));
335118611Snjl
336118611Snjl            CgLocalWriteAmlData (Op, &PkgLenFirstByte, 1);
337118611Snjl
338151937Sjkim            /*
339151937Sjkim             * Shift the length over by the 4 bits we just stuffed
340151937Sjkim             * in the first byte
341151937Sjkim             */
342118611Snjl            PkgLen.Len >>= 4;
343118611Snjl
344118611Snjl            /* Now we can write the remaining bytes - either 1, 2, or 3 bytes */
345118611Snjl
346118611Snjl            for (i = 0; i < (UINT32) (Op->Asl.AmlPkgLenBytes - 1); i++)
347118611Snjl            {
348118611Snjl                CgLocalWriteAmlData (Op, &PkgLen.LenBytes[i], 1);
349118611Snjl            }
350118611Snjl        }
351118611Snjl    }
352118611Snjl
353118611Snjl    switch (Aml.Opcode)
354118611Snjl    {
355118611Snjl    case AML_BYTE_OP:
356118611Snjl
357151937Sjkim        CgLocalWriteAmlData (Op, &Op->Asl.Value.Integer, 1);
358118611Snjl        break;
359118611Snjl
360118611Snjl    case AML_WORD_OP:
361118611Snjl
362151937Sjkim        CgLocalWriteAmlData (Op, &Op->Asl.Value.Integer, 2);
363118611Snjl       break;
364118611Snjl
365118611Snjl    case AML_DWORD_OP:
366118611Snjl
367151937Sjkim        CgLocalWriteAmlData (Op, &Op->Asl.Value.Integer, 4);
368118611Snjl        break;
369118611Snjl
370118611Snjl    case AML_QWORD_OP:
371118611Snjl
372118611Snjl        CgLocalWriteAmlData (Op, &Op->Asl.Value.Integer, 8);
373118611Snjl        break;
374118611Snjl
375118611Snjl    case AML_STRING_OP:
376118611Snjl
377118611Snjl        CgLocalWriteAmlData (Op, Op->Asl.Value.String, Op->Asl.AmlLength);
378118611Snjl        break;
379118611Snjl
380118611Snjl    default:
381118611Snjl        /* All data opcodes must appear above */
382118611Snjl        break;
383118611Snjl    }
384118611Snjl}
385118611Snjl
386118611Snjl
387118611Snjl/*******************************************************************************
388118611Snjl *
389118611Snjl * FUNCTION:    CgWriteTableHeader
390118611Snjl *
391118611Snjl * PARAMETERS:  Op        - The DEFINITIONBLOCK node
392118611Snjl *
393151937Sjkim * RETURN:      None
394118611Snjl *
395118611Snjl * DESCRIPTION: Write a table header corresponding to the DEFINITIONBLOCK
396118611Snjl *
397118611Snjl ******************************************************************************/
398118611Snjl
399151937Sjkimstatic void
400118611SnjlCgWriteTableHeader (
401151937Sjkim    ACPI_PARSE_OBJECT       *Op)
402118611Snjl{
403151937Sjkim    ACPI_PARSE_OBJECT       *Child;
404118611Snjl
405118611Snjl
406118611Snjl    /* AML filename */
407118611Snjl
408118611Snjl    Child = Op->Asl.Child;
409118611Snjl
410118611Snjl    /* Signature */
411118611Snjl
412118611Snjl    Child = Child->Asl.Next;
413118611Snjl    strncpy (TableHeader.Signature, Child->Asl.Value.String, 4);
414118611Snjl
415118611Snjl    /* Revision */
416118611Snjl
417118611Snjl    Child = Child->Asl.Next;
418118611Snjl    TableHeader.Revision = (UINT8) Child->Asl.Value.Integer;
419118611Snjl
420138287Smarks    /* Command-line Revision override */
421138287Smarks
422138287Smarks    if (Gbl_RevisionOverride)
423138287Smarks    {
424138287Smarks        TableHeader.Revision = Gbl_RevisionOverride;
425138287Smarks    }
426138287Smarks
427118611Snjl    /* OEMID */
428118611Snjl
429118611Snjl    Child = Child->Asl.Next;
430118611Snjl    strncpy (TableHeader.OemId, Child->Asl.Value.String, 6);
431118611Snjl
432118611Snjl    /* OEM TableID */
433118611Snjl
434118611Snjl    Child = Child->Asl.Next;
435118611Snjl    strncpy (TableHeader.OemTableId, Child->Asl.Value.String, 8);
436118611Snjl
437118611Snjl    /* OEM Revision */
438118611Snjl
439118611Snjl    Child = Child->Asl.Next;
440118611Snjl    TableHeader.OemRevision = (UINT32) Child->Asl.Value.Integer;
441118611Snjl
442118611Snjl    /* Compiler ID */
443118611Snjl
444213806Sjkim    strncpy (TableHeader.AslCompilerId, ASL_CREATOR_ID, 4);
445118611Snjl
446118611Snjl    /* Compiler version */
447118611Snjl
448213806Sjkim    TableHeader.AslCompilerRevision = ASL_REVISION;
449118611Snjl
450151937Sjkim    /* Table length. Checksum zero for now, will rewrite later */
451118611Snjl
452118611Snjl    TableHeader.Length   = Gbl_TableLength;
453118611Snjl    TableHeader.Checksum = 0;
454118611Snjl
455118611Snjl    CgLocalWriteAmlData (Op, &TableHeader, sizeof (ACPI_TABLE_HEADER));
456118611Snjl}
457118611Snjl
458118611Snjl
459118611Snjl/*******************************************************************************
460118611Snjl *
461118611Snjl * FUNCTION:    CgCloseTable
462118611Snjl *
463118611Snjl * PARAMETERS:  None.
464118611Snjl *
465118611Snjl * RETURN:      None.
466118611Snjl *
467118611Snjl * DESCRIPTION: Complete the ACPI table by calculating the checksum and
468118611Snjl *              re-writing the header.
469118611Snjl *
470118611Snjl ******************************************************************************/
471118611Snjl
472151937Sjkimstatic void
473151937SjkimCgCloseTable (
474151937Sjkim    void)
475118611Snjl{
476118611Snjl    signed char         Sum;
477118611Snjl    UINT8               FileByte;
478118611Snjl
479118611Snjl
480118611Snjl    FlSeekFile (ASL_FILE_AML_OUTPUT, 0);
481118611Snjl    Sum = 0;
482118611Snjl
483118611Snjl    /* Calculate the checksum over the entire file */
484118611Snjl
485118611Snjl    while (FlReadFile (ASL_FILE_AML_OUTPUT, &FileByte, 1) == AE_OK)
486118611Snjl    {
487118611Snjl        Sum = (signed char) (Sum + FileByte);
488118611Snjl    }
489118611Snjl
490118611Snjl    /* Re-write the table header with the checksum */
491118611Snjl
492118611Snjl    TableHeader.Checksum = (UINT8) (0 - Sum);
493118611Snjl
494118611Snjl    FlSeekFile (ASL_FILE_AML_OUTPUT, 0);
495118611Snjl    CgLocalWriteAmlData (NULL, &TableHeader, sizeof (ACPI_TABLE_HEADER));
496118611Snjl}
497118611Snjl
498118611Snjl
499118611Snjl/*******************************************************************************
500118611Snjl *
501118611Snjl * FUNCTION:    CgWriteNode
502118611Snjl *
503118611Snjl * PARAMETERS:  Op            - Parse node to write.
504118611Snjl *
505118611Snjl * RETURN:      None.
506118611Snjl *
507118611Snjl * DESCRIPTION: Write the AML that corresponds to a parse node.
508118611Snjl *
509118611Snjl ******************************************************************************/
510118611Snjl
511151937Sjkimstatic void
512118611SnjlCgWriteNode (
513118611Snjl    ACPI_PARSE_OBJECT       *Op)
514118611Snjl{
515118611Snjl    ASL_RESOURCE_NODE       *Rnode;
516118611Snjl
517118611Snjl
518118611Snjl    /* Always check for DEFAULT_ARG and other "Noop" nodes */
519118611Snjl    /* TBD: this may not be the best place for this check */
520118611Snjl
521118611Snjl    if ((Op->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG)  ||
522118611Snjl        (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL)     ||
523118611Snjl        (Op->Asl.ParseOpcode == PARSEOP_INCLUDE)      ||
524118611Snjl        (Op->Asl.ParseOpcode == PARSEOP_INCLUDE_END))
525118611Snjl    {
526118611Snjl        return;
527118611Snjl    }
528118611Snjl
529167802Sjkim    Op->Asl.FinalAmlLength = 0;
530167802Sjkim
531118611Snjl    switch (Op->Asl.AmlOpcode)
532118611Snjl    {
533118611Snjl    case AML_RAW_DATA_BYTE:
534118611Snjl    case AML_RAW_DATA_WORD:
535118611Snjl    case AML_RAW_DATA_DWORD:
536118611Snjl    case AML_RAW_DATA_QWORD:
537118611Snjl
538118611Snjl        CgLocalWriteAmlData (Op, &Op->Asl.Value.Integer, Op->Asl.AmlLength);
539118611Snjl        return;
540118611Snjl
541118611Snjl
542118611Snjl    case AML_RAW_DATA_BUFFER:
543118611Snjl
544118611Snjl        CgLocalWriteAmlData (Op, Op->Asl.Value.Buffer, Op->Asl.AmlLength);
545118611Snjl        return;
546118611Snjl
547118611Snjl
548118611Snjl    case AML_RAW_DATA_CHAIN:
549118611Snjl
550118611Snjl        Rnode = ACPI_CAST_PTR (ASL_RESOURCE_NODE, Op->Asl.Value.Buffer);
551118611Snjl        while (Rnode)
552118611Snjl        {
553118611Snjl            CgLocalWriteAmlData (Op, Rnode->Buffer, Rnode->BufferLength);
554118611Snjl            Rnode = Rnode->Next;
555118611Snjl        }
556118611Snjl        return;
557118611Snjl
558118611Snjl    default:
559118611Snjl        /* Internal data opcodes must all appear above */
560118611Snjl        break;
561118611Snjl    }
562118611Snjl
563118611Snjl    switch (Op->Asl.ParseOpcode)
564118611Snjl    {
565118611Snjl    case PARSEOP_DEFAULT_ARG:
566118611Snjl
567118611Snjl        break;
568118611Snjl
569118611Snjl    case PARSEOP_DEFINITIONBLOCK:
570118611Snjl
571118611Snjl        CgWriteTableHeader (Op);
572118611Snjl        break;
573118611Snjl
574118611Snjl    case PARSEOP_NAMESEG:
575118611Snjl    case PARSEOP_NAMESTRING:
576118611Snjl    case PARSEOP_METHODCALL:
577118611Snjl
578118611Snjl        CgLocalWriteAmlData (Op, Op->Asl.Value.String, Op->Asl.AmlLength);
579118611Snjl        break;
580118611Snjl
581118611Snjl    default:
582118611Snjl
583118611Snjl        CgWriteAmlOpcode (Op);
584118611Snjl        break;
585118611Snjl    }
586118611Snjl}
587118611Snjl
588118611Snjl
589