aslcodegen.c revision 228110
1116742Ssam
2116904Ssam/******************************************************************************
3178354Ssam *
4116742Ssam * Module Name: aslcodegen - AML code generation
5116742Ssam *
6116742Ssam *****************************************************************************/
7116742Ssam
8116742Ssam/*
9116742Ssam * Copyright (C) 2000 - 2011, Intel Corp.
10116904Ssam * All rights reserved.
11116904Ssam *
12116904Ssam * Redistribution and use in source and binary forms, with or without
13116904Ssam * modification, are permitted provided that the following conditions
14116742Ssam * are met:
15116904Ssam * 1. Redistributions of source code must retain the above copyright
16116904Ssam *    notice, this list of conditions, and the following disclaimer,
17116904Ssam *    without modification.
18116904Ssam * 2. Redistributions in binary form must reproduce at minimum a disclaimer
19116904Ssam *    substantially similar to the "NO WARRANTY" disclaimer below
20116904Ssam *    ("Disclaimer") and any redistribution must be conditioned upon
21116904Ssam *    including a substantially similar Disclaimer requirement for further
22116904Ssam *    binary redistribution.
23116904Ssam * 3. Neither the names of the above-listed copyright holders nor the names
24116904Ssam *    of any contributors may be used to endorse or promote products derived
25116742Ssam *    from this software without specific prior written permission.
26116742Ssam *
27116742Ssam * Alternatively, this software may be distributed under the terms of the
28116742Ssam * GNU General Public License ("GPL") version 2 as published by the Free
29116742Ssam * Software Foundation.
30116742Ssam *
31116742Ssam * NO WARRANTY
32116742Ssam * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
33116742Ssam * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34116742Ssam * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
35178354Ssam * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
36116742Ssam * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37116742Ssam * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38138568Ssam * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39170530Ssam * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40170530Ssam * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
41116742Ssam * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42178354Ssam * POSSIBILITY OF SUCH DAMAGES.
43116742Ssam */
44116742Ssam
45116742Ssam
46138568Ssam#include <contrib/dev/acpica/compiler/aslcompiler.h>
47116742Ssam#include "aslcompiler.y.h"
48116742Ssam#include <contrib/dev/acpica/include/amlcode.h>
49178354Ssam
50178354Ssam#define _COMPONENT          ACPI_COMPILER
51178354Ssam        ACPI_MODULE_NAME    ("aslcodegen")
52178354Ssam
53178354Ssam/* Local prototypes */
54178354Ssam
55116742Ssamstatic ACPI_STATUS
56138568SsamCgAmlWriteWalk (
57138568Ssam    ACPI_PARSE_OBJECT       *Op,
58138568Ssam    UINT32                  Level,
59116742Ssam    void                    *Context);
60116742Ssam
61116742Ssamstatic void
62116742SsamCgLocalWriteAmlData (
63116742Ssam    ACPI_PARSE_OBJECT       *Op,
64172230Ssam    void                    *Buffer,
65116742Ssam    UINT32                  Length);
66138568Ssam
67138568Ssamstatic void
68138568SsamCgWriteAmlOpcode (
69138568Ssam    ACPI_PARSE_OBJECT       *Op);
70138568Ssam
71138568Ssamstatic void
72167283SsamCgWriteTableHeader (
73167283Ssam    ACPI_PARSE_OBJECT       *Op);
74167283Ssam
75178354Ssamstatic void
76167283SsamCgCloseTable (
77167283Ssam    void);
78167283Ssam
79167283Ssamstatic void
80117811SsamCgWriteNode (
81117811Ssam    ACPI_PARSE_OBJECT       *Op);
82117811Ssam
83117811Ssam
84117811Ssam/*******************************************************************************
85172058Ssam *
86172058Ssam * FUNCTION:    CgGenerateAmlOutput
87172058Ssam *
88172058Ssam * PARAMETERS:  None.
89117811Ssam *
90138568Ssam * RETURN:      None
91138568Ssam *
92138568Ssam * DESCRIPTION: Generate AML code.  Currently generates the listing file
93138568Ssam *              simultaneously.
94138568Ssam *
95138568Ssam ******************************************************************************/
96138568Ssam
97116742Ssamvoid
98191746SthompsaCgGenerateAmlOutput (
99191746Sthompsa    void)
100178354Ssam{
101191746Sthompsa
102191746Sthompsa    DbgPrint (ASL_DEBUG_OUTPUT, "\nWriting AML\n\n");
103191746Sthompsa
104191746Sthompsa    /* Generate the AML output file */
105178354Ssam
106178354Ssam    FlSeekFile (ASL_FILE_SOURCE_OUTPUT, 0);
107117811Ssam    Gbl_SourceLine = 0;
108178354Ssam    Gbl_NextError = Gbl_ErrorLog;
109178354Ssam
110178354Ssam    TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD,
111172211Ssam        CgAmlWriteWalk, NULL, NULL);
112178354Ssam    CgCloseTable ();
113178354Ssam}
114178354Ssam
115178354Ssam
116178354Ssam/*******************************************************************************
117172211Ssam *
118172211Ssam * FUNCTION:    CgAmlWriteWalk
119116742Ssam *
120138568Ssam * PARAMETERS:  ASL_WALK_CALLBACK
121116742Ssam *
122138568Ssam * RETURN:      Status
123116742Ssam *
124178354Ssam * DESCRIPTION: Parse tree walk to generate the AML code.
125178354Ssam *
126178354Ssam ******************************************************************************/
127178354Ssam
128178354Ssamstatic ACPI_STATUS
129178354SsamCgAmlWriteWalk (
130178354Ssam    ACPI_PARSE_OBJECT       *Op,
131178354Ssam    UINT32                  Level,
132178354Ssam    void                    *Context)
133178354Ssam{
134178354Ssam
135178354Ssam    /*
136127648Ssam     * Print header at level 0. Alignment assumes 32-bit pointers
137116742Ssam     */
138178354Ssam    if (!Level)
139191746Sthompsa    {
140191746Sthompsa        DbgPrint (ASL_TREE_OUTPUT,
141191746Sthompsa            "Final parse tree used for AML output:\n");
142191746Sthompsa        DbgPrint (ASL_TREE_OUTPUT,
143178354Ssam            "%*s Value    P_Op A_Op OpLen PByts Len  SubLen PSubLen OpPtr    Child    Parent   Flags    AcTyp    Final Col L\n",
144138568Ssam            76, " ");
145138568Ssam    }
146138568Ssam
147116742Ssam    /* Debug output */
148116742Ssam
149178354Ssam    DbgPrint (ASL_TREE_OUTPUT,
150178354Ssam        "%5.5d [%2d]", Op->Asl.LogicalLineNumber, Level);
151178354Ssam    UtPrintFormattedName (Op->Asl.ParseOpcode, Level);
152178354Ssam
153178354Ssam    if (Op->Asl.ParseOpcode == PARSEOP_NAMESEG    ||
154178354Ssam        Op->Asl.ParseOpcode == PARSEOP_NAMESTRING ||
155178354Ssam        Op->Asl.ParseOpcode == PARSEOP_METHODCALL)
156116742Ssam    {
157116742Ssam        DbgPrint (ASL_TREE_OUTPUT,
158116742Ssam            "%10.32s      ", Op->Asl.ExternalName);
159138568Ssam    }
160116742Ssam    else
161178354Ssam    {
162178354Ssam        DbgPrint (ASL_TREE_OUTPUT, "                ");
163178354Ssam    }
164178354Ssam
165178354Ssam    DbgPrint (ASL_TREE_OUTPUT,
166178354Ssam    "%08X %04X %04X %01X     %04X  %04X %04X   %04X    %08X %08X %08X %08X %08X %04X  %02d  %02d\n",
167116742Ssam            /* 1  */ (UINT32) Op->Asl.Value.Integer,
168178354Ssam            /* 2  */ Op->Asl.ParseOpcode,
169178354Ssam            /* 3  */ Op->Asl.AmlOpcode,
170178354Ssam            /* 4  */ Op->Asl.AmlOpcodeLength,
171178354Ssam            /* 5  */ Op->Asl.AmlPkgLenBytes,
172178354Ssam            /* 6  */ Op->Asl.AmlLength,
173178354Ssam            /* 7  */ Op->Asl.AmlSubtreeLength,
174178354Ssam            /* 8  */ Op->Asl.Parent ? Op->Asl.Parent->Asl.AmlSubtreeLength : 0,
175178354Ssam            /* 9  */ Op,
176178354Ssam            /* 10 */ Op->Asl.Child,
177178354Ssam            /* 11 */ Op->Asl.Parent,
178178354Ssam            /* 12 */ Op->Asl.CompileFlags,
179178354Ssam            /* 13 */ Op->Asl.AcpiBtype,
180178354Ssam            /* 14 */ Op->Asl.FinalAmlLength,
181178354Ssam            /* 15 */ Op->Asl.Column,
182178354Ssam            /* 16 */ Op->Asl.LineNumber);
183178354Ssam
184178354Ssam    /* Generate the AML for this node */
185178354Ssam
186178354Ssam    CgWriteNode (Op);
187178354Ssam    return (AE_OK);
188191746Sthompsa}
189191746Sthompsa
190138568Ssam
191178354Ssam/*******************************************************************************
192178354Ssam *
193178354Ssam * FUNCTION:    CgLocalWriteAmlData
194178354Ssam *
195178354Ssam * PARAMETERS:  Op              - Current parse op
196188779Ssam *              Buffer          - Buffer to write
197178354Ssam *              Length          - Size of data in buffer
198178354Ssam *
199178354Ssam * RETURN:      None
200188779Ssam *
201188779Ssam * DESCRIPTION: Write a buffer of AML data to the AML output file.
202188779Ssam *
203188779Ssam ******************************************************************************/
204188779Ssam
205188779Ssamstatic void
206188779SsamCgLocalWriteAmlData (
207188779Ssam    ACPI_PARSE_OBJECT       *Op,
208188779Ssam    void                    *Buffer,
209178354Ssam    UINT32                  Length)
210178354Ssam{
211178354Ssam
212178354Ssam    /* Write the raw data to the AML file */
213178354Ssam
214178354Ssam    FlWriteFile (ASL_FILE_AML_OUTPUT, Buffer, Length);
215178354Ssam
216178354Ssam    /* Update the final AML length for this node (used for listings) */
217178354Ssam
218178354Ssam    if (Op)
219178354Ssam    {
220178354Ssam        Op->Asl.FinalAmlLength += Length;
221178354Ssam    }
222178354Ssam}
223178354Ssam
224178354Ssam
225186302Ssam/*******************************************************************************
226178354Ssam *
227178354Ssam * FUNCTION:    CgWriteAmlOpcode
228178354Ssam *
229178354Ssam * PARAMETERS:  Op            - Parse node with an AML opcode
230178354Ssam *
231178354Ssam * RETURN:      None.
232178354Ssam *
233138568Ssam * DESCRIPTION: Write the AML opcode corresponding to a parse node.
234138568Ssam *
235138568Ssam ******************************************************************************/
236138568Ssam
237178354Ssamstatic void
238178354SsamCgWriteAmlOpcode (
239138568Ssam    ACPI_PARSE_OBJECT       *Op)
240138568Ssam{
241138568Ssam    UINT8                   PkgLenFirstByte;
242178354Ssam    UINT32                  i;
243178354Ssam    union {
244178354Ssam        UINT16                  Opcode;
245178354Ssam        UINT8                   OpcodeBytes[2];
246178354Ssam    } Aml;
247178354Ssam    union {
248178354Ssam        UINT32                  Len;
249178354Ssam        UINT8                   LenBytes[4];
250178354Ssam    } PkgLen;
251178354Ssam
252116742Ssam
253116742Ssam    /* We expect some DEFAULT_ARGs, just ignore them */
254138568Ssam
255138568Ssam    if (Op->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG)
256138568Ssam    {
257138568Ssam        return;
258138568Ssam    }
259138568Ssam
260138568Ssam    switch (Op->Asl.AmlOpcode)
261138568Ssam    {
262138568Ssam    case AML_UNASSIGNED_OPCODE:
263138568Ssam
264138568Ssam        /* These opcodes should not get here */
265138568Ssam
266138568Ssam        printf ("Found a node with an unassigned AML opcode\n");
267138568Ssam        fprintf (stderr, "Found a node with an unassigned AML opcode\n");
268138568Ssam        return;
269138568Ssam
270138568Ssam    case AML_INT_RESERVEDFIELD_OP:
271138568Ssam
272138568Ssam        /* Special opcodes for within a field definition */
273138568Ssam
274138568Ssam        Aml.Opcode = AML_FIELD_OFFSET_OP;
275138568Ssam        break;
276138568Ssam
277138568Ssam    case AML_INT_ACCESSFIELD_OP:
278138568Ssam
279138568Ssam        Aml.Opcode = AML_FIELD_ACCESS_OP;
280138568Ssam        break;
281138568Ssam
282138568Ssam    case AML_INT_CONNECTION_OP:
283138568Ssam
284138568Ssam        Aml.Opcode = AML_FIELD_CONNECTION_OP;
285138568Ssam        break;
286138568Ssam
287138568Ssam    default:
288138568Ssam        Aml.Opcode = Op->Asl.AmlOpcode;
289138568Ssam        break;
290138568Ssam    }
291138568Ssam
292138568Ssam
293138568Ssam    switch (Aml.Opcode)
294138568Ssam    {
295138568Ssam    case AML_PACKAGE_LENGTH:
296138568Ssam
297138568Ssam        /* Value is the length to be encoded (Used in field definitions) */
298138568Ssam
299138568Ssam        PkgLen.Len = (UINT32) Op->Asl.Value.Integer;
300116742Ssam        break;
301138568Ssam
302138568Ssam    default:
303116742Ssam
304138568Ssam        /* Check for two-byte opcode */
305138568Ssam
306138568Ssam        if (Aml.Opcode > 0x00FF)
307138568Ssam        {
308138568Ssam            /* Write the high byte first */
309138568Ssam
310138568Ssam            CgLocalWriteAmlData (Op, &Aml.OpcodeBytes[1], 1);
311138568Ssam        }
312138568Ssam
313138568Ssam        CgLocalWriteAmlData (Op, &Aml.OpcodeBytes[0], 1);
314138568Ssam
315138568Ssam        /* Subtreelength doesn't include length of package length bytes */
316138568Ssam
317138568Ssam        PkgLen.Len = Op->Asl.AmlSubtreeLength + Op->Asl.AmlPkgLenBytes;
318138568Ssam        break;
319138568Ssam    }
320138568Ssam
321138568Ssam    /* Does this opcode have an associated "PackageLength" field? */
322138568Ssam
323138568Ssam    if (Op->Asl.CompileFlags & NODE_AML_PACKAGE)
324138568Ssam    {
325138568Ssam        if (Op->Asl.AmlPkgLenBytes == 1)
326138568Ssam        {
327138568Ssam            /* Simplest case -- no bytes to follow, just write the count */
328138568Ssam
329138568Ssam            CgLocalWriteAmlData (Op, &PkgLen.LenBytes[0], 1);
330138568Ssam        }
331138568Ssam        else if (Op->Asl.AmlPkgLenBytes != 0)
332138568Ssam        {
333138568Ssam            /*
334138568Ssam             * Encode the "bytes to follow" in the first byte, top two bits.
335138568Ssam             * The low-order nybble of the length is in the bottom 4 bits
336138568Ssam             */
337138568Ssam            PkgLenFirstByte = (UINT8)
338138568Ssam                (((UINT32) (Op->Asl.AmlPkgLenBytes - 1) << 6) |
339138568Ssam                (PkgLen.LenBytes[0] & 0x0F));
340138568Ssam
341138568Ssam            CgLocalWriteAmlData (Op, &PkgLenFirstByte, 1);
342138568Ssam
343138568Ssam            /*
344138568Ssam             * Shift the length over by the 4 bits we just stuffed
345138568Ssam             * in the first byte
346138568Ssam             */
347138568Ssam            PkgLen.Len >>= 4;
348170530Ssam
349138568Ssam            /* Now we can write the remaining bytes - either 1, 2, or 3 bytes */
350170530Ssam
351116742Ssam            for (i = 0; i < (UINT32) (Op->Asl.AmlPkgLenBytes - 1); i++)
352116742Ssam            {
353116742Ssam                CgLocalWriteAmlData (Op, &PkgLen.LenBytes[i], 1);
354116742Ssam            }
355116742Ssam        }
356116742Ssam    }
357116742Ssam
358116742Ssam    switch (Aml.Opcode)
359116742Ssam    {
360116742Ssam    case AML_BYTE_OP:
361116742Ssam
362116742Ssam        CgLocalWriteAmlData (Op, &Op->Asl.Value.Integer, 1);
363116742Ssam        break;
364116742Ssam
365116742Ssam    case AML_WORD_OP:
366116742Ssam
367116742Ssam        CgLocalWriteAmlData (Op, &Op->Asl.Value.Integer, 2);
368116742Ssam       break;
369116742Ssam
370116742Ssam    case AML_DWORD_OP:
371116742Ssam
372116742Ssam        CgLocalWriteAmlData (Op, &Op->Asl.Value.Integer, 4);
373170530Ssam        break;
374170530Ssam
375116742Ssam    case AML_QWORD_OP:
376138568Ssam
377116742Ssam        CgLocalWriteAmlData (Op, &Op->Asl.Value.Integer, 8);
378116742Ssam        break;
379138568Ssam
380116742Ssam    case AML_STRING_OP:
381116742Ssam
382116742Ssam        CgLocalWriteAmlData (Op, Op->Asl.Value.String, Op->Asl.AmlLength);
383116742Ssam        break;
384116742Ssam
385116742Ssam    default:
386116742Ssam        /* All data opcodes must appear above */
387116742Ssam        break;
388116742Ssam    }
389116742Ssam}
390116742Ssam
391116742Ssam
392116742Ssam/*******************************************************************************
393116742Ssam *
394116742Ssam * FUNCTION:    CgWriteTableHeader
395116742Ssam *
396116742Ssam * PARAMETERS:  Op        - The DEFINITIONBLOCK node
397170530Ssam *
398116742Ssam * RETURN:      None
399116742Ssam *
400116742Ssam * DESCRIPTION: Write a table header corresponding to the DEFINITIONBLOCK
401116742Ssam *
402116742Ssam ******************************************************************************/
403116742Ssam
404116742Ssamstatic void
405116742SsamCgWriteTableHeader (
406116742Ssam    ACPI_PARSE_OBJECT       *Op)
407116742Ssam{
408116742Ssam    ACPI_PARSE_OBJECT       *Child;
409116742Ssam
410116742Ssam
411116742Ssam    /* AML filename */
412116742Ssam
413116742Ssam    Child = Op->Asl.Child;
414116742Ssam
415116742Ssam    /* Signature */
416170530Ssam
417170530Ssam    Child = Child->Asl.Next;
418170530Ssam    strncpy (TableHeader.Signature, Child->Asl.Value.String, 4);
419170530Ssam
420170530Ssam    /* Revision */
421170530Ssam
422138568Ssam    Child = Child->Asl.Next;
423170530Ssam    TableHeader.Revision = (UINT8) Child->Asl.Value.Integer;
424170530Ssam
425170530Ssam    /* Command-line Revision override */
426170530Ssam
427170530Ssam    if (Gbl_RevisionOverride)
428170530Ssam    {
429170530Ssam        TableHeader.Revision = Gbl_RevisionOverride;
430170530Ssam    }
431170530Ssam
432138568Ssam    /* OEMID */
433116742Ssam
434116742Ssam    Child = Child->Asl.Next;
435116742Ssam    strncpy (TableHeader.OemId, Child->Asl.Value.String, 6);
436116742Ssam
437116742Ssam    /* OEM TableID */
438116742Ssam
439116742Ssam    Child = Child->Asl.Next;
440116742Ssam    strncpy (TableHeader.OemTableId, Child->Asl.Value.String, 8);
441116742Ssam
442116742Ssam    /* OEM Revision */
443116742Ssam
444116742Ssam    Child = Child->Asl.Next;
445116742Ssam    TableHeader.OemRevision = (UINT32) Child->Asl.Value.Integer;
446116742Ssam
447116742Ssam    /* Compiler ID */
448165887Ssam
449165887Ssam    strncpy (TableHeader.AslCompilerId, ASL_CREATOR_ID, 4);
450165887Ssam
451165887Ssam    /* Compiler version */
452165887Ssam
453165887Ssam    TableHeader.AslCompilerRevision = ASL_REVISION;
454165887Ssam
455165887Ssam    /* Table length. Checksum zero for now, will rewrite later */
456165887Ssam
457165887Ssam    TableHeader.Length   = Gbl_TableLength;
458165887Ssam    TableHeader.Checksum = 0;
459116742Ssam
460167442Ssam    CgLocalWriteAmlData (Op, &TableHeader, sizeof (ACPI_TABLE_HEADER));
461167442Ssam}
462116742Ssam
463116742Ssam
464178354Ssam/*******************************************************************************
465148299Ssam *
466165887Ssam * FUNCTION:    CgCloseTable
467178354Ssam *
468165569Ssam * PARAMETERS:  None.
469170530Ssam *
470116742Ssam * RETURN:      None.
471116742Ssam *
472170530Ssam * DESCRIPTION: Complete the ACPI table by calculating the checksum and
473178354Ssam *              re-writing the header.
474178354Ssam *
475178354Ssam ******************************************************************************/
476178354Ssam
477178354Ssamstatic void
478178354SsamCgCloseTable (
479178354Ssam    void)
480178354Ssam{
481178354Ssam    signed char         Sum;
482178354Ssam    UINT8               FileByte;
483178354Ssam
484178354Ssam
485178354Ssam    FlSeekFile (ASL_FILE_AML_OUTPUT, 0);
486178354Ssam    Sum = 0;
487178354Ssam
488178354Ssam    /* Calculate the checksum over the entire file */
489178354Ssam
490178354Ssam    while (FlReadFile (ASL_FILE_AML_OUTPUT, &FileByte, 1) == AE_OK)
491178354Ssam    {
492178354Ssam        Sum = (signed char) (Sum + FileByte);
493178354Ssam    }
494178354Ssam
495178354Ssam    /* Re-write the table header with the checksum */
496178354Ssam
497170530Ssam    TableHeader.Checksum = (UINT8) (0 - Sum);
498178354Ssam
499178354Ssam    FlSeekFile (ASL_FILE_AML_OUTPUT, 0);
500178354Ssam    CgLocalWriteAmlData (NULL, &TableHeader, sizeof (ACPI_TABLE_HEADER));
501178354Ssam}
502178354Ssam
503178354Ssam
504178354Ssam/*******************************************************************************
505178354Ssam *
506178354Ssam * FUNCTION:    CgWriteNode
507178354Ssam *
508178354Ssam * PARAMETERS:  Op            - Parse node to write.
509178354Ssam *
510178354Ssam * RETURN:      None.
511120482Ssam *
512116742Ssam * DESCRIPTION: Write the AML that corresponds to a parse node.
513116742Ssam *
514116742Ssam ******************************************************************************/
515116742Ssam
516116742Ssamstatic void
517116742SsamCgWriteNode (
518116742Ssam    ACPI_PARSE_OBJECT       *Op)
519116742Ssam{
520116742Ssam    ASL_RESOURCE_NODE       *Rnode;
521116742Ssam
522116742Ssam
523116742Ssam    /* Always check for DEFAULT_ARG and other "Noop" nodes */
524116742Ssam    /* TBD: this may not be the best place for this check */
525116742Ssam
526165887Ssam    if ((Op->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG)  ||
527170530Ssam        (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL)     ||
528170530Ssam        (Op->Asl.ParseOpcode == PARSEOP_INCLUDE)      ||
529178354Ssam        (Op->Asl.ParseOpcode == PARSEOP_INCLUDE_END))
530170530Ssam    {
531170530Ssam        return;
532165887Ssam    }
533165887Ssam
534165887Ssam    Op->Asl.FinalAmlLength = 0;
535116742Ssam
536165887Ssam    switch (Op->Asl.AmlOpcode)
537120482Ssam    {
538120482Ssam    case AML_RAW_DATA_BYTE:
539120482Ssam    case AML_RAW_DATA_WORD:
540165887Ssam    case AML_RAW_DATA_DWORD:
541120482Ssam    case AML_RAW_DATA_QWORD:
542120482Ssam
543165887Ssam        CgLocalWriteAmlData (Op, &Op->Asl.Value.Integer, Op->Asl.AmlLength);
544120482Ssam        return;
545116742Ssam
546165887Ssam
547165887Ssam    case AML_RAW_DATA_BUFFER:
548165887Ssam
549165887Ssam        CgLocalWriteAmlData (Op, Op->Asl.Value.Buffer, Op->Asl.AmlLength);
550165887Ssam        return;
551165887Ssam
552116742Ssam
553116742Ssam    case AML_RAW_DATA_CHAIN:
554165887Ssam
555116742Ssam        Rnode = ACPI_CAST_PTR (ASL_RESOURCE_NODE, Op->Asl.Value.Buffer);
556116742Ssam        while (Rnode)
557116742Ssam        {
558165887Ssam            CgLocalWriteAmlData (Op, Rnode->Buffer, Rnode->BufferLength);
559165887Ssam            Rnode = Rnode->Next;
560165887Ssam        }
561165887Ssam        return;
562165887Ssam
563116742Ssam    default:
564165887Ssam        /* Internal data opcodes must all appear above */
565116742Ssam        break;
566116742Ssam    }
567116742Ssam
568138568Ssam    switch (Op->Asl.ParseOpcode)
569178354Ssam    {
570178354Ssam    case PARSEOP_DEFAULT_ARG:
571178354Ssam
572178354Ssam        break;
573178354Ssam
574116742Ssam    case PARSEOP_DEFINITIONBLOCK:
575178354Ssam
576116742Ssam        CgWriteTableHeader (Op);
577116742Ssam        break;
578116742Ssam
579116742Ssam    case PARSEOP_NAMESEG:
580138568Ssam    case PARSEOP_NAMESTRING:
581138568Ssam    case PARSEOP_METHODCALL:
582138568Ssam
583138568Ssam        CgLocalWriteAmlData (Op, Op->Asl.Value.String, Op->Asl.AmlLength);
584138568Ssam        break;
585138568Ssam
586138568Ssam    default:
587138568Ssam
588138568Ssam        CgWriteAmlOpcode (Op);
589138568Ssam        break;
590138568Ssam    }
591138568Ssam}
592138568Ssam
593138568Ssam
594138568Ssam