1118611Snjl/******************************************************************************
2118611Snjl *
3118611Snjl * Module Name: asloperands - AML operand processing
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>
48118611Snjl
49118611Snjl#define _COMPONENT          ACPI_COMPILER
50118611Snjl        ACPI_MODULE_NAME    ("asloperands")
51118611Snjl
52151937Sjkim/* Local prototypes */
53118611Snjl
54151937Sjkimstatic void
55151937SjkimOpnDoField (
56151937Sjkim    ACPI_PARSE_OBJECT       *Op);
57151937Sjkim
58151937Sjkimstatic void
59151937SjkimOpnDoBankField (
60151937Sjkim    ACPI_PARSE_OBJECT       *Op);
61151937Sjkim
62151937Sjkimstatic void
63151937SjkimOpnDoBuffer (
64151937Sjkim    ACPI_PARSE_OBJECT       *Op);
65151937Sjkim
66151937Sjkimstatic void
67151937SjkimOpnDoDefinitionBlock (
68151937Sjkim    ACPI_PARSE_OBJECT       *Op);
69151937Sjkim
70151937Sjkimstatic void
71151937SjkimOpnDoFieldCommon (
72151937Sjkim    ACPI_PARSE_OBJECT       *FieldOp,
73151937Sjkim    ACPI_PARSE_OBJECT       *Op);
74151937Sjkim
75151937Sjkimstatic void
76151937SjkimOpnDoIndexField (
77151937Sjkim    ACPI_PARSE_OBJECT       *Op);
78151937Sjkim
79151937Sjkimstatic void
80151937SjkimOpnDoLoadTable (
81151937Sjkim    ACPI_PARSE_OBJECT       *Op);
82151937Sjkim
83151937Sjkimstatic void
84151937SjkimOpnDoMethod (
85151937Sjkim    ACPI_PARSE_OBJECT       *Op);
86151937Sjkim
87151937Sjkimstatic void
88151937SjkimOpnDoMutex (
89151937Sjkim    ACPI_PARSE_OBJECT       *Op);
90151937Sjkim
91151937Sjkimstatic void
92151937SjkimOpnDoRegion (
93151937Sjkim    ACPI_PARSE_OBJECT       *Op);
94151937Sjkim
95151937Sjkimstatic void
96151937SjkimOpnAttachNameToNode (
97151937Sjkim    ACPI_PARSE_OBJECT       *Op);
98151937Sjkim
99151937Sjkim
100118611Snjl/*******************************************************************************
101118611Snjl *
102151937Sjkim * FUNCTION:    OpnDoMutex
103151937Sjkim *
104151937Sjkim * PARAMETERS:  Op        - The parent parse node
105151937Sjkim *
106151937Sjkim * RETURN:      None
107151937Sjkim *
108151937Sjkim * DESCRIPTION: Construct the operands for the MUTEX ASL keyword.
109151937Sjkim *
110151937Sjkim ******************************************************************************/
111151937Sjkim
112151937Sjkimstatic void
113151937SjkimOpnDoMutex (
114151937Sjkim    ACPI_PARSE_OBJECT       *Op)
115151937Sjkim{
116151937Sjkim    ACPI_PARSE_OBJECT       *Next;
117151937Sjkim
118151937Sjkim
119151937Sjkim    Next = Op->Asl.Child;
120151937Sjkim    Next = Next->Asl.Next;
121151937Sjkim
122151937Sjkim    if (Next->Asl.Value.Integer > 15)
123151937Sjkim    {
124151937Sjkim        AslError (ASL_ERROR, ASL_MSG_SYNC_LEVEL, Next, NULL);
125151937Sjkim    }
126151937Sjkim    return;
127151937Sjkim}
128151937Sjkim
129151937Sjkim
130151937Sjkim/*******************************************************************************
131151937Sjkim *
132118611Snjl * FUNCTION:    OpnDoMethod
133118611Snjl *
134118611Snjl * PARAMETERS:  Op        - The parent parse node
135118611Snjl *
136118611Snjl * RETURN:      None
137118611Snjl *
138118611Snjl * DESCRIPTION: Construct the operands for the METHOD ASL keyword.
139118611Snjl *
140118611Snjl ******************************************************************************/
141118611Snjl
142151937Sjkimstatic void
143118611SnjlOpnDoMethod (
144118611Snjl    ACPI_PARSE_OBJECT       *Op)
145118611Snjl{
146118611Snjl    ACPI_PARSE_OBJECT       *Next;
147118611Snjl
148118611Snjl    /* Optional arguments for this opcode with defaults */
149118611Snjl
150118611Snjl    UINT8                   NumArgs = 0;
151118611Snjl    UINT8                   Serialized = 0;
152118611Snjl    UINT8                   Concurrency = 0;
153118611Snjl    UINT8                   MethodFlags;
154118611Snjl
155118611Snjl
156118611Snjl    /* Opcode and package length first */
157118611Snjl    /* Method name */
158118611Snjl
159118611Snjl    Next = Op->Asl.Child;
160118611Snjl
161118611Snjl    /* Num args */
162118611Snjl
163118611Snjl    Next = Next->Asl.Next;
164118611Snjl    if (Next->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
165118611Snjl    {
166118611Snjl        NumArgs = (UINT8) Next->Asl.Value.Integer;
167118611Snjl        Next->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
168118611Snjl    }
169118611Snjl
170118611Snjl    /* Serialized Flag */
171118611Snjl
172118611Snjl    Next = Next->Asl.Next;
173118611Snjl    if (Next->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
174118611Snjl    {
175118611Snjl        Serialized = (UINT8) Next->Asl.Value.Integer;
176118611Snjl        Next->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
177118611Snjl    }
178118611Snjl
179151937Sjkim    /* Concurrency value (valid values are 0-15) */
180118611Snjl
181118611Snjl    Next = Next->Asl.Next;
182118611Snjl    if (Next->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
183118611Snjl    {
184240716Sjkim        /* This is a ByteConstExpr, so eval the constant now */
185240716Sjkim
186240716Sjkim        OpcAmlConstantWalk (Next, 0, NULL);
187240716Sjkim
188151937Sjkim        if (Next->Asl.Value.Integer > 15)
189151937Sjkim        {
190151937Sjkim            AslError (ASL_ERROR, ASL_MSG_SYNC_LEVEL, Next, NULL);
191151937Sjkim        }
192118611Snjl        Concurrency = (UINT8) Next->Asl.Value.Integer;
193118611Snjl    }
194118611Snjl
195118611Snjl    /* Put the bits in their proper places */
196118611Snjl
197118611Snjl    MethodFlags = (UINT8) ((NumArgs & 0x7) |
198118611Snjl                          ((Serialized & 0x1) << 3) |
199118611Snjl                          ((Concurrency & 0xF) << 4));
200118611Snjl
201118611Snjl    /* Use the last node for the combined flags byte */
202118611Snjl
203118611Snjl    Next->Asl.Value.Integer = MethodFlags;
204118611Snjl    Next->Asl.AmlOpcode = AML_RAW_DATA_BYTE;
205118611Snjl    Next->Asl.AmlLength = 1;
206118611Snjl    Next->Asl.ParseOpcode = PARSEOP_RAW_DATA;
207118611Snjl
208118611Snjl    /* Save the arg count in the first node */
209118611Snjl
210118611Snjl    Op->Asl.Extra = NumArgs;
211118611Snjl}
212118611Snjl
213118611Snjl
214118611Snjl/*******************************************************************************
215118611Snjl *
216118611Snjl * FUNCTION:    OpnDoFieldCommon
217118611Snjl *
218118611Snjl * PARAMETERS:  FieldOp       - Node for an ASL field
219118611Snjl *              Op            - The parent parse node
220118611Snjl *
221118611Snjl * RETURN:      None
222118611Snjl *
223118611Snjl * DESCRIPTION: Construct the AML operands for the various field keywords,
224118611Snjl *              FIELD, BANKFIELD, INDEXFIELD
225118611Snjl *
226118611Snjl ******************************************************************************/
227118611Snjl
228151937Sjkimstatic void
229118611SnjlOpnDoFieldCommon (
230118611Snjl    ACPI_PARSE_OBJECT       *FieldOp,
231118611Snjl    ACPI_PARSE_OBJECT       *Op)
232118611Snjl{
233118611Snjl    ACPI_PARSE_OBJECT       *Next;
234118611Snjl    ACPI_PARSE_OBJECT       *PkgLengthNode;
235118611Snjl    UINT32                  CurrentBitOffset;
236118611Snjl    UINT32                  NewBitOffset;
237118611Snjl    UINT8                   AccessType;
238118611Snjl    UINT8                   LockRule;
239118611Snjl    UINT8                   UpdateRule;
240118611Snjl    UINT8                   FieldFlags;
241118611Snjl    UINT32                  MinimumLength;
242118611Snjl
243118611Snjl
244118611Snjl    /* AccessType -- not optional, so no need to check for DEFAULT_ARG */
245118611Snjl
246118611Snjl    AccessType = (UINT8) Op->Asl.Value.Integer;
247118611Snjl    Op->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
248118611Snjl
249118611Snjl    /* Set the access type in the parent (field) node for use later */
250118611Snjl
251118611Snjl    FieldOp->Asl.Value.Integer = AccessType;
252118611Snjl
253118611Snjl    /* LockRule -- not optional, so no need to check for DEFAULT_ARG */
254118611Snjl
255118611Snjl    Next = Op->Asl.Next;
256118611Snjl    LockRule = (UINT8) Next->Asl.Value.Integer;
257118611Snjl    Next->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
258118611Snjl
259118611Snjl    /* UpdateRule -- not optional, so no need to check for DEFAULT_ARG */
260118611Snjl
261118611Snjl    Next = Next->Asl.Next;
262118611Snjl    UpdateRule = (UINT8) Next->Asl.Value.Integer;
263118611Snjl
264118611Snjl    /*
265241973Sjkim     * Generate the flags byte. The various fields are already
266118611Snjl     * in the right bit position via translation from the
267118611Snjl     * keywords by the parser.
268118611Snjl     */
269118611Snjl    FieldFlags = (UINT8) (AccessType | LockRule | UpdateRule);
270118611Snjl
271118611Snjl    /* Use the previous node to be the FieldFlags node */
272118611Snjl
273118611Snjl    /* Set the node to RAW_DATA */
274118611Snjl
275118611Snjl    Next->Asl.Value.Integer = FieldFlags;
276118611Snjl    Next->Asl.AmlOpcode     = AML_RAW_DATA_BYTE;
277118611Snjl    Next->Asl.AmlLength     = 1;
278118611Snjl    Next->Asl.ParseOpcode   = PARSEOP_RAW_DATA;
279118611Snjl
280118611Snjl    /* Process the FieldUnitList */
281118611Snjl
282118611Snjl    Next = Next->Asl.Next;
283118611Snjl    CurrentBitOffset = 0;
284118611Snjl
285118611Snjl    while (Next)
286118611Snjl    {
287118611Snjl        /* Save the offset of this field unit */
288118611Snjl
289118611Snjl        Next->Asl.ExtraValue = CurrentBitOffset;
290118611Snjl
291118611Snjl        switch (Next->Asl.ParseOpcode)
292118611Snjl        {
293118611Snjl        case PARSEOP_ACCESSAS:
294118611Snjl
295118611Snjl            PkgLengthNode = Next->Asl.Child;
296118611Snjl            AccessType = (UINT8) PkgLengthNode->Asl.Value.Integer;
297118611Snjl
298118611Snjl            /* Nothing additional to do */
299118611Snjl            break;
300118611Snjl
301118611Snjl        case PARSEOP_OFFSET:
302118611Snjl
303118611Snjl            /* New offset into the field */
304118611Snjl
305118611Snjl            PkgLengthNode = Next->Asl.Child;
306118611Snjl            NewBitOffset = ((UINT32) PkgLengthNode->Asl.Value.Integer) * 8;
307118611Snjl
308118611Snjl            /*
309118611Snjl             * Examine the specified offset in relation to the
310118611Snjl             * current offset counter.
311118611Snjl             */
312118611Snjl            if (NewBitOffset < CurrentBitOffset)
313118611Snjl            {
314118611Snjl                /*
315118611Snjl                 * Not allowed to specify a backwards offset!
316118611Snjl                 * Issue error and ignore this node.
317118611Snjl                 */
318151937Sjkim                AslError (ASL_ERROR, ASL_MSG_BACKWARDS_OFFSET, PkgLengthNode,
319151937Sjkim                    NULL);
320118611Snjl                Next->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
321118611Snjl                PkgLengthNode->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
322118611Snjl            }
323118611Snjl            else if (NewBitOffset == CurrentBitOffset)
324118611Snjl            {
325118611Snjl                /*
326118611Snjl                 * Offset is redundant; we don't need to output an
327241973Sjkim                 * offset opcode. Just set these nodes to default
328118611Snjl                 */
329118611Snjl                Next->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
330118611Snjl                PkgLengthNode->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
331118611Snjl            }
332118611Snjl            else
333118611Snjl            {
334118611Snjl                /*
335118611Snjl                 * Valid new offset - set the value to be inserted into the AML
336118611Snjl                 * and update the offset counter.
337118611Snjl                 */
338151937Sjkim                PkgLengthNode->Asl.Value.Integer =
339151937Sjkim                    NewBitOffset - CurrentBitOffset;
340118611Snjl                CurrentBitOffset = NewBitOffset;
341118611Snjl            }
342118611Snjl            break;
343118611Snjl
344118611Snjl        case PARSEOP_NAMESEG:
345118611Snjl        case PARSEOP_RESERVED_BYTES:
346118611Snjl
347118611Snjl            /* Named or reserved field entry */
348118611Snjl
349118611Snjl            PkgLengthNode     = Next->Asl.Child;
350118611Snjl            NewBitOffset      = (UINT32) PkgLengthNode->Asl.Value.Integer;
351118611Snjl            CurrentBitOffset += NewBitOffset;
352118611Snjl
353118611Snjl            /* Save the current AccessAs value for error checking later */
354118611Snjl
355118611Snjl            switch (AccessType)
356118611Snjl            {
357118611Snjl                case AML_FIELD_ACCESS_ANY:
358118611Snjl                case AML_FIELD_ACCESS_BYTE:
359118611Snjl                case AML_FIELD_ACCESS_BUFFER:
360118611Snjl                default:
361250838Sjkim
362118611Snjl                    MinimumLength = 8;
363118611Snjl                    break;
364118611Snjl
365118611Snjl                case AML_FIELD_ACCESS_WORD:
366118611Snjl                    MinimumLength = 16;
367118611Snjl                    break;
368118611Snjl
369118611Snjl                case AML_FIELD_ACCESS_DWORD:
370118611Snjl                    MinimumLength = 32;
371118611Snjl                    break;
372118611Snjl
373118611Snjl                case AML_FIELD_ACCESS_QWORD:
374118611Snjl                    MinimumLength = 64;
375118611Snjl                    break;
376118611Snjl            }
377118611Snjl
378118611Snjl            PkgLengthNode->Asl.ExtraValue = MinimumLength;
379118611Snjl            break;
380118611Snjl
381118611Snjl        default:
382250838Sjkim
383118611Snjl            /* All supported field opcodes must appear above */
384250838Sjkim
385118611Snjl            break;
386118611Snjl        }
387118611Snjl
388118611Snjl        /* Move on to next entry in the field list */
389118611Snjl
390118611Snjl        Next = Next->Asl.Next;
391118611Snjl    }
392118611Snjl}
393118611Snjl
394118611Snjl
395118611Snjl/*******************************************************************************
396118611Snjl *
397118611Snjl * FUNCTION:    OpnDoField
398118611Snjl *
399118611Snjl * PARAMETERS:  Op        - The parent parse node
400118611Snjl *
401118611Snjl * RETURN:      None
402118611Snjl *
403118611Snjl * DESCRIPTION: Construct the AML operands for the FIELD ASL keyword
404118611Snjl *
405118611Snjl ******************************************************************************/
406118611Snjl
407151937Sjkimstatic void
408118611SnjlOpnDoField (
409118611Snjl    ACPI_PARSE_OBJECT       *Op)
410118611Snjl{
411118611Snjl    ACPI_PARSE_OBJECT       *Next;
412118611Snjl
413118611Snjl
414118611Snjl    /* Opcode is parent node */
415118611Snjl    /* First child is field name */
416118611Snjl
417118611Snjl    Next = Op->Asl.Child;
418118611Snjl
419118611Snjl    /* Second child is the AccessType */
420118611Snjl
421118611Snjl    OpnDoFieldCommon (Op, Next->Asl.Next);
422118611Snjl}
423118611Snjl
424118611Snjl
425118611Snjl/*******************************************************************************
426118611Snjl *
427118611Snjl * FUNCTION:    OpnDoIndexField
428118611Snjl *
429118611Snjl * PARAMETERS:  Op        - The parent parse node
430118611Snjl *
431118611Snjl * RETURN:      None
432118611Snjl *
433118611Snjl * DESCRIPTION: Construct the AML operands for the INDEXFIELD ASL keyword
434118611Snjl *
435118611Snjl ******************************************************************************/
436118611Snjl
437151937Sjkimstatic void
438118611SnjlOpnDoIndexField (
439118611Snjl    ACPI_PARSE_OBJECT       *Op)
440118611Snjl{
441118611Snjl    ACPI_PARSE_OBJECT       *Next;
442118611Snjl
443118611Snjl
444118611Snjl    /* Opcode is parent node */
445118611Snjl    /* First child is the index name */
446118611Snjl
447118611Snjl    Next = Op->Asl.Child;
448118611Snjl
449118611Snjl    /* Second child is the data name */
450118611Snjl
451118611Snjl    Next = Next->Asl.Next;
452118611Snjl
453118611Snjl    /* Third child is the AccessType */
454118611Snjl
455118611Snjl    OpnDoFieldCommon (Op, Next->Asl.Next);
456118611Snjl}
457118611Snjl
458118611Snjl
459118611Snjl/*******************************************************************************
460118611Snjl *
461118611Snjl * FUNCTION:    OpnDoBankField
462118611Snjl *
463118611Snjl * PARAMETERS:  Op        - The parent parse node
464118611Snjl *
465118611Snjl * RETURN:      None
466118611Snjl *
467118611Snjl * DESCRIPTION: Construct the AML operands for the BANKFIELD ASL keyword
468118611Snjl *
469118611Snjl ******************************************************************************/
470118611Snjl
471151937Sjkimstatic void
472118611SnjlOpnDoBankField (
473118611Snjl    ACPI_PARSE_OBJECT       *Op)
474118611Snjl{
475118611Snjl    ACPI_PARSE_OBJECT       *Next;
476118611Snjl
477118611Snjl
478118611Snjl    /* Opcode is parent node */
479118611Snjl    /* First child is the region name */
480118611Snjl
481118611Snjl    Next = Op->Asl.Child;
482118611Snjl
483118611Snjl    /* Second child is the bank name */
484118611Snjl
485118611Snjl    Next = Next->Asl.Next;
486118611Snjl
487118611Snjl    /* Third child is the bank value */
488118611Snjl
489118611Snjl    Next = Next->Asl.Next;
490118611Snjl
491118611Snjl    /* Fourth child is the AccessType */
492118611Snjl
493118611Snjl    OpnDoFieldCommon (Op, Next->Asl.Next);
494118611Snjl}
495118611Snjl
496118611Snjl
497118611Snjl/*******************************************************************************
498118611Snjl *
499118611Snjl * FUNCTION:    OpnDoRegion
500118611Snjl *
501118611Snjl * PARAMETERS:  Op        - The parent parse node
502118611Snjl *
503118611Snjl * RETURN:      None
504118611Snjl *
505241973Sjkim * DESCRIPTION: Tries to get the length of the region. Can only do this at
506118611Snjl *              compile time if the length is a constant.
507118611Snjl *
508118611Snjl ******************************************************************************/
509118611Snjl
510151937Sjkimstatic void
511118611SnjlOpnDoRegion (
512118611Snjl    ACPI_PARSE_OBJECT       *Op)
513118611Snjl{
514118611Snjl    ACPI_PARSE_OBJECT       *Next;
515118611Snjl
516118611Snjl
517118611Snjl    /* Opcode is parent node */
518118611Snjl    /* First child is the region name */
519118611Snjl
520118611Snjl    Next = Op->Asl.Child;
521118611Snjl
522118611Snjl    /* Second child is the space ID*/
523118611Snjl
524118611Snjl    Next = Next->Asl.Next;
525118611Snjl
526118611Snjl    /* Third child is the region offset */
527118611Snjl
528118611Snjl    Next = Next->Asl.Next;
529118611Snjl
530118611Snjl    /* Fourth child is the region length */
531118611Snjl
532118611Snjl    Next = Next->Asl.Next;
533118611Snjl    if (Next->Asl.ParseOpcode == PARSEOP_INTEGER)
534118611Snjl    {
535118611Snjl        Op->Asl.Value.Integer = Next->Asl.Value.Integer;
536118611Snjl    }
537118611Snjl    else
538118611Snjl    {
539202771Sjkim        Op->Asl.Value.Integer = ACPI_UINT64_MAX;
540118611Snjl    }
541118611Snjl}
542118611Snjl
543118611Snjl
544118611Snjl/*******************************************************************************
545118611Snjl *
546118611Snjl * FUNCTION:    OpnDoBuffer
547118611Snjl *
548118611Snjl * PARAMETERS:  Op        - The parent parse node
549118611Snjl *
550118611Snjl * RETURN:      None
551118611Snjl *
552241973Sjkim * DESCRIPTION: Construct the AML operands for the BUFFER ASL keyword. We
553118611Snjl *              build a single raw byte buffer from the initialization nodes,
554118611Snjl *              each parse node contains a buffer byte.
555118611Snjl *
556118611Snjl ******************************************************************************/
557118611Snjl
558151937Sjkimstatic void
559118611SnjlOpnDoBuffer (
560118611Snjl    ACPI_PARSE_OBJECT       *Op)
561118611Snjl{
562118611Snjl    ACPI_PARSE_OBJECT       *InitializerOp;
563118611Snjl    ACPI_PARSE_OBJECT       *BufferLengthOp;
564118611Snjl
565118611Snjl    /* Optional arguments for this opcode with defaults */
566118611Snjl
567118611Snjl    UINT32                  BufferLength = 0;
568118611Snjl
569118611Snjl
570118611Snjl    /* Opcode and package length first */
571118611Snjl    /* Buffer Length is next, followed by the initializer list */
572118611Snjl
573118611Snjl    BufferLengthOp = Op->Asl.Child;
574118611Snjl    InitializerOp = BufferLengthOp->Asl.Next;
575118611Snjl
576118611Snjl    /*
577118611Snjl     * If the BufferLength is not an INTEGER or was not specified in the ASL
578118611Snjl     * (DEFAULT_ARG), it is a TermArg that is
579118611Snjl     * evaluated at run-time, and we are therefore finished.
580118611Snjl     */
581118611Snjl    if ((BufferLengthOp->Asl.ParseOpcode != PARSEOP_INTEGER) &&
582118611Snjl        (BufferLengthOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG))
583118611Snjl    {
584118611Snjl        return;
585118611Snjl    }
586118611Snjl
587118611Snjl    /*
588118611Snjl     * We want to count the number of items in the initializer list, because if
589118611Snjl     * it is larger than the buffer length, we will define the buffer size
590118611Snjl     * to be the size of the initializer list (as per the ACPI Specification)
591118611Snjl     */
592118611Snjl    switch (InitializerOp->Asl.ParseOpcode)
593118611Snjl    {
594118611Snjl    case PARSEOP_INTEGER:
595118611Snjl    case PARSEOP_BYTECONST:
596118611Snjl    case PARSEOP_WORDCONST:
597118611Snjl    case PARSEOP_DWORDCONST:
598118611Snjl
599118611Snjl        /* The peer list contains the byte list (if any...) */
600118611Snjl
601118611Snjl        while (InitializerOp)
602118611Snjl        {
603118611Snjl            /* For buffers, this is a list of raw bytes */
604118611Snjl
605118611Snjl            InitializerOp->Asl.AmlOpcode      = AML_RAW_DATA_BYTE;
606118611Snjl            InitializerOp->Asl.AmlLength      = 1;
607118611Snjl            InitializerOp->Asl.ParseOpcode    = PARSEOP_RAW_DATA;
608118611Snjl
609118611Snjl            BufferLength++;
610118611Snjl            InitializerOp = ASL_GET_PEER_NODE (InitializerOp);
611118611Snjl        }
612118611Snjl        break;
613118611Snjl
614118611Snjl    case PARSEOP_STRING_LITERAL:
615118611Snjl
616118611Snjl        /*
617241973Sjkim         * Only one initializer, the string. Buffer must be big enough to hold
618118611Snjl         * the string plus the null termination byte
619118611Snjl         */
620118611Snjl        BufferLength = strlen (InitializerOp->Asl.Value.String) + 1;
621118611Snjl
622118611Snjl        InitializerOp->Asl.AmlOpcode      = AML_RAW_DATA_BUFFER;
623118611Snjl        InitializerOp->Asl.AmlLength      = BufferLength;
624118611Snjl        InitializerOp->Asl.ParseOpcode    = PARSEOP_RAW_DATA;
625118611Snjl        break;
626118611Snjl
627118611Snjl    case PARSEOP_RAW_DATA:
628118611Snjl
629118611Snjl        /* Buffer nodes are already initialized (e.g. Unicode operator) */
630118611Snjl        return;
631118611Snjl
632118611Snjl    case PARSEOP_DEFAULT_ARG:
633118611Snjl        break;
634118611Snjl
635250838Sjkim    default:
636118611Snjl
637118611Snjl        AslError (ASL_ERROR, ASL_MSG_INVALID_OPERAND, InitializerOp,
638118611Snjl            "Unknown buffer initializer opcode");
639118611Snjl        printf ("Unknown buffer initializer opcode [%s]\n",
640118611Snjl                        UtGetOpName (InitializerOp->Asl.ParseOpcode));
641118611Snjl        return;
642118611Snjl    }
643118611Snjl
644118611Snjl    /* Check if initializer list is longer than the buffer length */
645118611Snjl
646118611Snjl    if (BufferLengthOp->Asl.Value.Integer > BufferLength)
647118611Snjl    {
648118611Snjl        BufferLength = (UINT32) BufferLengthOp->Asl.Value.Integer;
649118611Snjl    }
650118611Snjl
651118611Snjl    if (!BufferLength)
652118611Snjl    {
653151937Sjkim        /* No length AND no items -- issue notice */
654118611Snjl
655151937Sjkim        AslError (ASL_REMARK, ASL_MSG_BUFFER_LENGTH, BufferLengthOp, NULL);
656118611Snjl
657118611Snjl        /* But go ahead and put the buffer length of zero into the AML */
658118611Snjl    }
659118611Snjl
660118611Snjl    /*
661118611Snjl     * Just set the buffer size node to be the buffer length, regardless
662118611Snjl     * of whether it was previously an integer or a default_arg placeholder
663118611Snjl     */
664118611Snjl    BufferLengthOp->Asl.ParseOpcode   = PARSEOP_INTEGER;
665118611Snjl    BufferLengthOp->Asl.AmlOpcode     = AML_DWORD_OP;
666118611Snjl    BufferLengthOp->Asl.Value.Integer = BufferLength;
667118611Snjl
668118611Snjl    (void) OpcSetOptimalIntegerSize (BufferLengthOp);
669118611Snjl
670118611Snjl    /* Remaining nodes are handled via the tree walk */
671118611Snjl}
672118611Snjl
673118611Snjl
674118611Snjl/*******************************************************************************
675118611Snjl *
676118611Snjl * FUNCTION:    OpnDoPackage
677118611Snjl *
678118611Snjl * PARAMETERS:  Op        - The parent parse node
679118611Snjl *
680118611Snjl * RETURN:      None
681118611Snjl *
682241973Sjkim * DESCRIPTION: Construct the AML operands for the PACKAGE ASL keyword. NOTE:
683151937Sjkim *              can only be called after constants have been folded, to ensure
684151937Sjkim *              that the PackageLength operand has been fully reduced.
685118611Snjl *
686118611Snjl ******************************************************************************/
687118611Snjl
688118611Snjlvoid
689118611SnjlOpnDoPackage (
690118611Snjl    ACPI_PARSE_OBJECT       *Op)
691118611Snjl{
692118611Snjl    ACPI_PARSE_OBJECT       *InitializerOp;
693118611Snjl    ACPI_PARSE_OBJECT       *PackageLengthOp;
694151937Sjkim    UINT32                  PackageLength = 0;
695118611Snjl
696118611Snjl
697151937Sjkim    /* Opcode and package length first, followed by the initializer list */
698118611Snjl
699118611Snjl    PackageLengthOp = Op->Asl.Child;
700118611Snjl    InitializerOp = PackageLengthOp->Asl.Next;
701118611Snjl
702151937Sjkim    /* Count the number of items in the initializer list */
703151937Sjkim
704118611Snjl    if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
705118611Snjl    {
706118611Snjl        /* The peer list contains the byte list (if any...) */
707118611Snjl
708118611Snjl        while (InitializerOp)
709118611Snjl        {
710118611Snjl            PackageLength++;
711118611Snjl            InitializerOp = InitializerOp->Asl.Next;
712118611Snjl        }
713118611Snjl    }
714118611Snjl
715151937Sjkim    /* If package length is a constant, compare to the initializer list */
716118611Snjl
717118611Snjl    if ((PackageLengthOp->Asl.ParseOpcode == PARSEOP_INTEGER)      ||
718151937Sjkim        (PackageLengthOp->Asl.ParseOpcode == PARSEOP_QWORDCONST))
719118611Snjl    {
720199337Sjkim        if (PackageLengthOp->Asl.Value.Integer > PackageLength)
721118611Snjl        {
722199337Sjkim            /*
723199337Sjkim             * Allow package length to be longer than the initializer
724199337Sjkim             * list -- but if the length of initializer list is nonzero,
725199337Sjkim             * issue a message since this is probably a coding error,
726199337Sjkim             * even though technically legal.
727199337Sjkim             */
728199337Sjkim            if (PackageLength > 0)
729199337Sjkim            {
730199337Sjkim                AslError (ASL_REMARK, ASL_MSG_LIST_LENGTH_SHORT,
731199337Sjkim                    PackageLengthOp, NULL);
732199337Sjkim            }
733151937Sjkim
734118611Snjl            PackageLength = (UINT32) PackageLengthOp->Asl.Value.Integer;
735118611Snjl        }
736199337Sjkim        else if (PackageLengthOp->Asl.Value.Integer < PackageLength)
737151937Sjkim        {
738151937Sjkim            /*
739199337Sjkim             * The package length is smaller than the length of the
740199337Sjkim             * initializer list. This is an error as per the ACPI spec.
741151937Sjkim             */
742199337Sjkim            AslError (ASL_ERROR, ASL_MSG_LIST_LENGTH_LONG,
743199337Sjkim                PackageLengthOp, NULL);
744151937Sjkim        }
745118611Snjl    }
746118611Snjl
747151937Sjkim    if (PackageLengthOp->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG)
748151937Sjkim    {
749151937Sjkim        /*
750151937Sjkim         * This is the case if the PackageLength was left empty - Package()
751151937Sjkim         * The package length becomes the length of the initializer list
752151937Sjkim         */
753151937Sjkim        Op->Asl.Child->Asl.ParseOpcode = PARSEOP_INTEGER;
754151937Sjkim        Op->Asl.Child->Asl.Value.Integer = PackageLength;
755151937Sjkim
756151937Sjkim        /* Set the AML opcode */
757151937Sjkim
758151937Sjkim        (void) OpcSetOptimalIntegerSize (Op->Asl.Child);
759151937Sjkim    }
760151937Sjkim
761151937Sjkim    /* If not a variable-length package, check for a zero package length */
762151937Sjkim
763118611Snjl    if ((PackageLengthOp->Asl.ParseOpcode == PARSEOP_INTEGER)      ||
764151937Sjkim        (PackageLengthOp->Asl.ParseOpcode == PARSEOP_QWORDCONST)   ||
765228110Sjkim        (PackageLengthOp->Asl.ParseOpcode == PARSEOP_ZERO)         ||
766118611Snjl        (PackageLengthOp->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG))
767118611Snjl    {
768118611Snjl        if (!PackageLength)
769118611Snjl        {
770151937Sjkim            /* No length AND no initializer list -- issue a remark */
771118611Snjl
772151937Sjkim            AslError (ASL_REMARK, ASL_MSG_PACKAGE_LENGTH,
773151937Sjkim                PackageLengthOp, NULL);
774118611Snjl
775118611Snjl            /* But go ahead and put the buffer length of zero into the AML */
776118611Snjl        }
777118611Snjl    }
778118611Snjl
779118611Snjl    /*
780151937Sjkim     * If the PackageLength is a constant <= 255, we can change the
781151937Sjkim     * AML opcode from VarPackage to a simple (ACPI 1.0) Package opcode.
782118611Snjl     */
783228110Sjkim    if (((Op->Asl.Child->Asl.ParseOpcode == PARSEOP_INTEGER) &&
784228110Sjkim            (Op->Asl.Child->Asl.Value.Integer <= 255))  ||
785228110Sjkim        (Op->Asl.Child->Asl.ParseOpcode == PARSEOP_ONE) ||
786228110Sjkim        (Op->Asl.Child->Asl.ParseOpcode == PARSEOP_ONES)||
787228110Sjkim        (Op->Asl.Child->Asl.ParseOpcode == PARSEOP_ZERO))
788151937Sjkim    {
789151937Sjkim        Op->Asl.AmlOpcode = AML_PACKAGE_OP;
790151937Sjkim        Op->Asl.ParseOpcode = PARSEOP_PACKAGE;
791118611Snjl
792151937Sjkim        /*
793151937Sjkim         * Just set the package size node to be the package length, regardless
794151937Sjkim         * of whether it was previously an integer or a default_arg placeholder
795151937Sjkim         */
796151937Sjkim        PackageLengthOp->Asl.AmlOpcode = AML_RAW_DATA_BYTE;
797151937Sjkim        PackageLengthOp->Asl.AmlLength = 1;
798151937Sjkim        PackageLengthOp->Asl.ParseOpcode = PARSEOP_RAW_DATA;
799151937Sjkim        PackageLengthOp->Asl.Value.Integer = PackageLength;
800151937Sjkim    }
801151937Sjkim
802118611Snjl    /* Remaining nodes are handled via the tree walk */
803118611Snjl}
804118611Snjl
805118611Snjl
806118611Snjl/*******************************************************************************
807118611Snjl *
808118611Snjl * FUNCTION:    OpnDoLoadTable
809118611Snjl *
810118611Snjl * PARAMETERS:  Op        - The parent parse node
811118611Snjl *
812118611Snjl * RETURN:      None
813118611Snjl *
814118611Snjl * DESCRIPTION: Construct the AML operands for the LOADTABLE ASL keyword.
815118611Snjl *
816118611Snjl ******************************************************************************/
817118611Snjl
818151937Sjkimstatic void
819118611SnjlOpnDoLoadTable (
820118611Snjl    ACPI_PARSE_OBJECT       *Op)
821118611Snjl{
822118611Snjl    ACPI_PARSE_OBJECT       *Next;
823118611Snjl
824118611Snjl
825118611Snjl    /* Opcode is parent node */
826118611Snjl    /* First child is the table signature */
827118611Snjl
828118611Snjl    Next = Op->Asl.Child;
829118611Snjl
830118611Snjl    /* Second child is the OEM ID*/
831118611Snjl
832118611Snjl    Next = Next->Asl.Next;
833118611Snjl
834118611Snjl    /* Third child is the OEM table ID */
835118611Snjl
836118611Snjl    Next = Next->Asl.Next;
837118611Snjl
838118611Snjl    /* Fourth child is the RootPath string */
839118611Snjl
840118611Snjl    Next = Next->Asl.Next;
841118611Snjl    if (Next->Asl.ParseOpcode == PARSEOP_ZERO)
842118611Snjl    {
843118611Snjl        Next->Asl.ParseOpcode    = PARSEOP_STRING_LITERAL;
844118611Snjl        Next->Asl.Value.String   = "\\";
845118611Snjl        Next->Asl.AmlLength      = 2;
846118611Snjl        OpcGenerateAmlOpcode (Next);
847118611Snjl    }
848118611Snjl
849151937Sjkim#ifdef ASL_FUTURE_IMPLEMENTATION
850151937Sjkim
851151937Sjkim    /* TBD: NOT IMPLEMENTED */
852118611Snjl    /* Fifth child is the [optional] ParameterPathString */
853118611Snjl    /* Sixth child is the [optional] ParameterData */
854118611Snjl
855118611Snjl    Next = Next->Asl.Next;
856118611Snjl    if (Next->Asl.ParseOpcode == DEFAULT_ARG)
857118611Snjl    {
858118611Snjl        Next->Asl.AmlLength = 1;
859118611Snjl        Next->Asl.ParseOpcode = ZERO;
860118611Snjl        OpcGenerateAmlOpcode (Next);
861118611Snjl    }
862118611Snjl
863118611Snjl
864118611Snjl    Next = Next->Asl.Next;
865118611Snjl    if (Next->Asl.ParseOpcode == DEFAULT_ARG)
866118611Snjl    {
867118611Snjl        Next->Asl.AmlLength = 1;
868118611Snjl        Next->Asl.ParseOpcode = ZERO;
869118611Snjl        OpcGenerateAmlOpcode (Next);
870118611Snjl    }
871151937Sjkim#endif
872118611Snjl}
873118611Snjl
874118611Snjl
875118611Snjl/*******************************************************************************
876118611Snjl *
877118611Snjl * FUNCTION:    OpnDoDefinitionBlock
878118611Snjl *
879118611Snjl * PARAMETERS:  Op        - The parent parse node
880118611Snjl *
881118611Snjl * RETURN:      None
882118611Snjl *
883118611Snjl * DESCRIPTION: Construct the AML operands for the DEFINITIONBLOCK ASL keyword
884118611Snjl *
885118611Snjl ******************************************************************************/
886118611Snjl
887151937Sjkimstatic void
888118611SnjlOpnDoDefinitionBlock (
889118611Snjl    ACPI_PARSE_OBJECT       *Op)
890118611Snjl{
891118611Snjl    ACPI_PARSE_OBJECT       *Child;
892118611Snjl    ACPI_SIZE               Length;
893193529Sjkim    UINT32                  i;
894193529Sjkim    char                    *Filename;
895118611Snjl
896118611Snjl
897118611Snjl    /*
898241973Sjkim     * These nodes get stuffed into the table header. They are special
899118611Snjl     * cased when the table is written to the output file.
900118611Snjl     *
901118611Snjl     * Mark all of these nodes as non-usable so they won't get output
902118611Snjl     * as AML opcodes!
903118611Snjl     */
904118611Snjl
905167802Sjkim    /* Get AML filename. Use it if non-null */
906118611Snjl
907118611Snjl    Child = Op->Asl.Child;
908167802Sjkim    if (Child->Asl.Value.Buffer  &&
909167802Sjkim        *Child->Asl.Value.Buffer &&
910167802Sjkim        (Gbl_UseDefaultAmlFilename))
911118611Snjl    {
912193529Sjkim        /*
913193529Sjkim         * We will use the AML filename that is embedded in the source file
914193529Sjkim         * for the output filename.
915193529Sjkim         */
916193529Sjkim        Filename = ACPI_ALLOCATE (strlen (Gbl_DirectoryPath) +
917193529Sjkim                    strlen ((char *) Child->Asl.Value.Buffer) + 1);
918193529Sjkim
919193529Sjkim        /* Prepend the current directory path */
920193529Sjkim
921193529Sjkim        strcpy (Filename, Gbl_DirectoryPath);
922193529Sjkim        strcat (Filename, (char *) Child->Asl.Value.Buffer);
923193529Sjkim
924193529Sjkim        Gbl_OutputFilenamePrefix = Filename;
925118611Snjl    }
926118611Snjl    Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
927118611Snjl
928118611Snjl    /* Signature */
929118611Snjl
930118611Snjl    Child = Child->Asl.Next;
931118611Snjl    Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
932118611Snjl    if (Child->Asl.Value.String)
933118611Snjl    {
934118611Snjl        Gbl_TableSignature = Child->Asl.Value.String;
935118611Snjl        if (ACPI_STRLEN (Gbl_TableSignature) != 4)
936118611Snjl        {
937151937Sjkim            AslError (ASL_ERROR, ASL_MSG_TABLE_SIGNATURE, Child,
938151937Sjkim                "Length not exactly 4");
939118611Snjl        }
940118611Snjl
941118611Snjl        for (i = 0; i < 4; i++)
942118611Snjl        {
943202771Sjkim            if (!isalnum ((int) Gbl_TableSignature[i]))
944118611Snjl            {
945151937Sjkim                AslError (ASL_ERROR, ASL_MSG_TABLE_SIGNATURE, Child,
946151937Sjkim                    "Contains non-alphanumeric characters");
947118611Snjl            }
948118611Snjl        }
949118611Snjl    }
950118611Snjl
951118611Snjl    /* Revision */
952118611Snjl
953118611Snjl    Child = Child->Asl.Next;
954118611Snjl    Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
955167802Sjkim    /*
956167802Sjkim     * We used the revision to set the integer width earlier
957167802Sjkim     */
958118611Snjl
959118611Snjl    /* OEMID */
960118611Snjl
961118611Snjl    Child = Child->Asl.Next;
962118611Snjl    Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
963118611Snjl
964118611Snjl    /* OEM TableID */
965118611Snjl
966118611Snjl    Child = Child->Asl.Next;
967118611Snjl    Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
968118611Snjl    if (Child->Asl.Value.String)
969118611Snjl    {
970118611Snjl        Length = ACPI_STRLEN (Child->Asl.Value.String);
971118611Snjl        Gbl_TableId = AcpiOsAllocate (Length + 1);
972118611Snjl        ACPI_STRCPY (Gbl_TableId, Child->Asl.Value.String);
973118611Snjl
974253690Sjkim        /*
975253690Sjkim         * Convert anything non-alphanumeric to an underscore. This
976253690Sjkim         * allows us to use the TableID to generate unique C symbols.
977253690Sjkim         */
978118611Snjl        for (i = 0; i < Length; i++)
979118611Snjl        {
980253690Sjkim            if (!isalnum ((int) Gbl_TableId[i]))
981118611Snjl            {
982253690Sjkim                Gbl_TableId[i] = '_';
983118611Snjl            }
984118611Snjl        }
985118611Snjl    }
986118611Snjl
987118611Snjl    /* OEM Revision */
988118611Snjl
989118611Snjl    Child = Child->Asl.Next;
990118611Snjl    Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
991118611Snjl}
992118611Snjl
993118611Snjl
994118611Snjl/*******************************************************************************
995118611Snjl *
996118611Snjl * FUNCTION:    UtGetArg
997118611Snjl *
998118611Snjl * PARAMETERS:  Op              - Get an argument for this op
999118611Snjl *              Argn            - Nth argument to get
1000118611Snjl *
1001241973Sjkim * RETURN:      The argument (as an Op object). NULL if argument does not exist
1002118611Snjl *
1003118611Snjl * DESCRIPTION: Get the specified op's argument (peer)
1004118611Snjl *
1005118611Snjl ******************************************************************************/
1006118611Snjl
1007118611SnjlACPI_PARSE_OBJECT *
1008118611SnjlUtGetArg (
1009118611Snjl    ACPI_PARSE_OBJECT       *Op,
1010118611Snjl    UINT32                  Argn)
1011118611Snjl{
1012118611Snjl    ACPI_PARSE_OBJECT       *Arg = NULL;
1013118611Snjl
1014118611Snjl
1015118611Snjl    /* Get the requested argument object */
1016118611Snjl
1017118611Snjl    Arg = Op->Asl.Child;
1018118611Snjl    while (Arg && Argn)
1019118611Snjl    {
1020118611Snjl        Argn--;
1021118611Snjl        Arg = Arg->Asl.Next;
1022118611Snjl    }
1023118611Snjl
1024118611Snjl    return (Arg);
1025118611Snjl}
1026118611Snjl
1027118611Snjl
1028118611Snjl/*******************************************************************************
1029118611Snjl *
1030118611Snjl * FUNCTION:    OpnAttachNameToNode
1031118611Snjl *
1032118611Snjl * PARAMETERS:  Op        - The parent parse node
1033118611Snjl *
1034118611Snjl * RETURN:      None
1035118611Snjl *
1036118611Snjl * DESCRIPTION: For the named ASL/AML operators, get the actual name from the
1037118611Snjl *              argument list and attach it to the parent node so that we
1038118611Snjl *              can get to it quickly later.
1039118611Snjl *
1040118611Snjl ******************************************************************************/
1041118611Snjl
1042151937Sjkimstatic void
1043118611SnjlOpnAttachNameToNode (
1044118611Snjl    ACPI_PARSE_OBJECT       *Op)
1045118611Snjl{
1046118611Snjl    ACPI_PARSE_OBJECT       *Child = NULL;
1047118611Snjl
1048118611Snjl
1049118611Snjl    if (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL)
1050118611Snjl    {
1051118611Snjl        Child = UtGetArg (Op, 0);
1052118611Snjl    }
1053118611Snjl    else switch (Op->Asl.AmlOpcode)
1054118611Snjl    {
1055118611Snjl    case AML_DATA_REGION_OP:
1056118611Snjl    case AML_DEVICE_OP:
1057118611Snjl    case AML_EVENT_OP:
1058118611Snjl    case AML_METHOD_OP:
1059118611Snjl    case AML_MUTEX_OP:
1060118611Snjl    case AML_REGION_OP:
1061118611Snjl    case AML_POWER_RES_OP:
1062118611Snjl    case AML_PROCESSOR_OP:
1063118611Snjl    case AML_THERMAL_ZONE_OP:
1064118611Snjl    case AML_NAME_OP:
1065118611Snjl    case AML_SCOPE_OP:
1066118611Snjl
1067118611Snjl        Child = UtGetArg (Op, 0);
1068118611Snjl        break;
1069118611Snjl
1070118611Snjl    case AML_ALIAS_OP:
1071118611Snjl
1072118611Snjl        Child = UtGetArg (Op, 1);
1073118611Snjl        break;
1074118611Snjl
1075118611Snjl    case AML_CREATE_BIT_FIELD_OP:
1076118611Snjl    case AML_CREATE_BYTE_FIELD_OP:
1077118611Snjl    case AML_CREATE_WORD_FIELD_OP:
1078118611Snjl    case AML_CREATE_DWORD_FIELD_OP:
1079118611Snjl    case AML_CREATE_QWORD_FIELD_OP:
1080118611Snjl
1081118611Snjl        Child = UtGetArg (Op, 2);
1082118611Snjl        break;
1083118611Snjl
1084118611Snjl    case AML_CREATE_FIELD_OP:
1085118611Snjl
1086118611Snjl        Child = UtGetArg (Op, 3);
1087118611Snjl        break;
1088118611Snjl
1089118611Snjl    case AML_BANK_FIELD_OP:
1090118611Snjl    case AML_INDEX_FIELD_OP:
1091118611Snjl    case AML_FIELD_OP:
1092118611Snjl
1093118611Snjl        return;
1094118611Snjl
1095118611Snjl    default:
1096250838Sjkim
1097118611Snjl        return;
1098118611Snjl    }
1099118611Snjl
1100118611Snjl    if (Child)
1101118611Snjl    {
1102118611Snjl        UtAttachNamepathToOwner (Op, Child);
1103118611Snjl    }
1104118611Snjl}
1105118611Snjl
1106118611Snjl
1107118611Snjl/*******************************************************************************
1108118611Snjl *
1109118611Snjl * FUNCTION:    OpnGenerateAmlOperands
1110118611Snjl *
1111118611Snjl * PARAMETERS:  Op        - The parent parse node
1112118611Snjl *
1113118611Snjl * RETURN:      None
1114118611Snjl *
1115241973Sjkim * DESCRIPTION: Prepare nodes to be output as AML data and operands. The more
1116118611Snjl *              complex AML opcodes require processing of the child nodes
1117118611Snjl *              (arguments/operands).
1118118611Snjl *
1119118611Snjl ******************************************************************************/
1120118611Snjl
1121118611Snjlvoid
1122118611SnjlOpnGenerateAmlOperands (
1123118611Snjl    ACPI_PARSE_OBJECT       *Op)
1124118611Snjl{
1125118611Snjl
1126118611Snjl
1127118611Snjl    if (Op->Asl.AmlOpcode == AML_RAW_DATA_BYTE)
1128118611Snjl    {
1129118611Snjl        return;
1130118611Snjl    }
1131118611Snjl
1132118611Snjl    switch (Op->Asl.ParseOpcode)
1133118611Snjl    {
1134118611Snjl    case PARSEOP_DEFINITIONBLOCK:
1135250838Sjkim
1136118611Snjl        OpnDoDefinitionBlock (Op);
1137118611Snjl        break;
1138118611Snjl
1139118611Snjl    case PARSEOP_METHOD:
1140250838Sjkim
1141118611Snjl        OpnDoMethod (Op);
1142118611Snjl        break;
1143118611Snjl
1144151937Sjkim    case PARSEOP_MUTEX:
1145250838Sjkim
1146151937Sjkim        OpnDoMutex (Op);
1147151937Sjkim        break;
1148151937Sjkim
1149118611Snjl    case PARSEOP_FIELD:
1150250838Sjkim
1151118611Snjl        OpnDoField (Op);
1152118611Snjl        break;
1153118611Snjl
1154118611Snjl    case PARSEOP_INDEXFIELD:
1155250838Sjkim
1156118611Snjl        OpnDoIndexField (Op);
1157118611Snjl        break;
1158118611Snjl
1159118611Snjl    case PARSEOP_BANKFIELD:
1160250838Sjkim
1161118611Snjl        OpnDoBankField (Op);
1162118611Snjl        break;
1163118611Snjl
1164118611Snjl    case PARSEOP_BUFFER:
1165250838Sjkim
1166118611Snjl        OpnDoBuffer (Op);
1167118611Snjl        break;
1168118611Snjl
1169118611Snjl    case PARSEOP_LOADTABLE:
1170250838Sjkim
1171118611Snjl        OpnDoLoadTable (Op);
1172118611Snjl        break;
1173118611Snjl
1174118611Snjl    case PARSEOP_OPERATIONREGION:
1175250838Sjkim
1176118611Snjl        OpnDoRegion (Op);
1177118611Snjl        break;
1178118611Snjl
1179118611Snjl    case PARSEOP_RESOURCETEMPLATE:
1180250838Sjkim
1181118611Snjl        RsDoResourceTemplate (Op);
1182118611Snjl        break;
1183118611Snjl
1184118611Snjl    case PARSEOP_NAMESEG:
1185118611Snjl    case PARSEOP_NAMESTRING:
1186118611Snjl    case PARSEOP_METHODCALL:
1187118611Snjl    case PARSEOP_STRING_LITERAL:
1188250838Sjkim
1189118611Snjl        break;
1190118611Snjl
1191118611Snjl    default:
1192250838Sjkim
1193118611Snjl        break;
1194118611Snjl    }
1195118611Snjl
1196118611Snjl    /* TBD: move */
1197118611Snjl
1198118611Snjl    OpnAttachNameToNode (Op);
1199118611Snjl}
1200