Subversion Repositories Kolibri OS

Rev

Rev 1498 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1498 serge 1
 
2
 *
3
 * Module Name: asltransform - Parse tree transforms
4
 *
5
 *****************************************************************************/
6
7
 
8
 *
9
 * 1. Copyright Notice
10
 *
11
 * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp.
2216 Serge 12
 * All rights reserved.
1498 serge 13
 *
14
 * 2. License
15
 *
16
 * 2.1. This is your license from Intel Corp. under its intellectual property
17
 * rights.  You may have additional license terms from the party that provided
18
 * you this software, covering your right to use that party's intellectual
19
 * property rights.
20
 *
21
 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22
 * copy of the source code appearing in this file ("Covered Code") an
23
 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24
 * base code distributed originally by Intel ("Original Intel Code") to copy,
25
 * make derivatives, distribute, use and display any portion of the Covered
26
 * Code in any form, with the right to sublicense such rights; and
27
 *
28
 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29
 * license (with the right to sublicense), under only those claims of Intel
30
 * patents that are infringed by the Original Intel Code, to make, use, sell,
31
 * offer to sell, and import the Covered Code and derivative works thereof
32
 * solely to the minimum extent necessary to exercise the above copyright
33
 * license, and in no event shall the patent license extend to any additions
34
 * to or modifications of the Original Intel Code.  No other license or right
35
 * is granted directly or by implication, estoppel or otherwise;
36
 *
37
 * The above copyright and patent license is granted only if the following
38
 * conditions are met:
39
 *
40
 * 3. Conditions
41
 *
42
 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43
 * Redistribution of source code of any substantial portion of the Covered
44
 * Code or modification with rights to further distribute source must include
45
 * the above Copyright Notice, the above License, this list of Conditions,
46
 * and the following Disclaimer and Export Compliance provision.  In addition,
47
 * Licensee must cause all Covered Code to which Licensee contributes to
48
 * contain a file documenting the changes Licensee made to create that Covered
49
 * Code and the date of any change.  Licensee must include in that file the
50
 * documentation of any changes made by any predecessor Licensee.  Licensee
51
 * must include a prominent statement that the modification is derived,
52
 * directly or indirectly, from Original Intel Code.
53
 *
54
 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55
 * Redistribution of source code of any substantial portion of the Covered
56
 * Code or modification without rights to further distribute source must
57
 * include the following Disclaimer and Export Compliance provision in the
58
 * documentation and/or other materials provided with distribution.  In
59
 * addition, Licensee may not authorize further sublicense of source of any
60
 * portion of the Covered Code, and must include terms to the effect that the
61
 * license from Licensee to its licensee is limited to the intellectual
62
 * property embodied in the software Licensee provides to its licensee, and
63
 * not to intellectual property embodied in modifications its licensee may
64
 * make.
65
 *
66
 * 3.3. Redistribution of Executable. Redistribution in executable form of any
67
 * substantial portion of the Covered Code or modification must reproduce the
68
 * above Copyright Notice, and the following Disclaimer and Export Compliance
69
 * provision in the documentation and/or other materials provided with the
70
 * distribution.
71
 *
72
 * 3.4. Intel retains all right, title, and interest in and to the Original
73
 * Intel Code.
74
 *
75
 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76
 * Intel shall be used in advertising or otherwise to promote the sale, use or
77
 * other dealings in products derived from or relating to the Covered Code
78
 * without prior written authorization from Intel.
79
 *
80
 * 4. Disclaimer and Export Compliance
81
 *
82
 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83
 * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84
 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
85
 * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
86
 * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
87
 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
88
 * PARTICULAR PURPOSE.
89
 *
90
 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91
 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92
 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93
 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94
 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95
 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
96
 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
97
 * LIMITED REMEDY.
98
 *
99
 * 4.3. Licensee shall not export, either directly or indirectly, any of this
100
 * software or system incorporating such software without first obtaining any
101
 * required license or other approval from the U. S. Department of Commerce or
102
 * any other agency or department of the United States Government.  In the
103
 * event Licensee exports any such software from the United States or
104
 * re-exports any such software from a foreign destination, Licensee shall
105
 * ensure that the distribution and export/re-export of the software is in
106
 * compliance with all laws, regulations, orders, or other restrictions of the
107
 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108
 * any of its subsidiaries will export/re-export any technical data, process,
109
 * software, or service, directly or indirectly, to any country for which the
110
 * United States government or any agency thereof requires an export license,
111
 * other governmental approval, or letter of assurance, without first obtaining
112
 * such license, approval or letter.
113
 *
114
 *****************************************************************************/
115
116
 
117
 
118
#include "aslcompiler.y.h"
119
120
 
121
        ACPI_MODULE_NAME    ("asltransform")
122
123
 
124
125
 
126
TrTransformSubtree (
127
    ACPI_PARSE_OBJECT       *Op);
128
129
 
130
TrAmlGetNextTempName (
131
    ACPI_PARSE_OBJECT       *Op,
132
    UINT8                   *TempCount);
133
134
 
135
TrAmlInitLineNumbers (
136
    ACPI_PARSE_OBJECT       *Op,
137
    ACPI_PARSE_OBJECT       *Neighbor);
138
139
 
140
TrAmlInitNode (
141
    ACPI_PARSE_OBJECT       *Op,
142
    UINT16                  ParseOpcode);
143
144
 
145
TrAmlSetSubtreeParent (
146
    ACPI_PARSE_OBJECT       *Op,
147
    ACPI_PARSE_OBJECT       *Parent);
148
149
 
150
TrAmlInsertPeer (
151
    ACPI_PARSE_OBJECT       *Op,
152
    ACPI_PARSE_OBJECT       *NewPeer);
153
154
 
155
TrDoDefinitionBlock (
156
    ACPI_PARSE_OBJECT       *Op);
157
158
 
159
TrDoSwitch (
160
    ACPI_PARSE_OBJECT       *StartNode);
161
162
 
163
 
164
 *
165
 * FUNCTION:    TrAmlGetNextTempName
166
 *
167
 * PARAMETERS:  Op              - Current parse op
168
 *              TempCount       - Current temporary counter. Was originally
169
 *                                per-module; Currently per method, could be
170
 *                                expanded to per-scope.
171
 *
172
 * RETURN:      A pointer to name (allocated here).
173
 *
174
 * DESCRIPTION: Generate an ACPI name of the form _T_x.  These names are
175
 *              reserved for use by the ASL compiler. (_T_0 through _T_Z)
176
 *
177
 ******************************************************************************/
178
179
 
180
TrAmlGetNextTempName (
181
    ACPI_PARSE_OBJECT       *Op,
182
    UINT8                   *TempCount)
183
{
184
    char                    *TempName;
185
186
 
187
 
188
    {
189
        /* Too many temps */
190
191
 
192
        return (NULL);
193
    }
194
195
 
196
197
 
198
    {
199
        TempName[3] = (char) (*TempCount + '0');
200
    }
201
    else                    /* 10-35: A-Z */
202
    {
203
        TempName[3] = (char) (*TempCount + ('A' - 10));
204
    }
205
    (*TempCount)++;
206
207
 
208
209
 
210
    TempName[1] = 'T';
211
    TempName[2] = '_';
212
213
 
214
}
215
216
 
217
 
218
 *
219
 * FUNCTION:    TrAmlInitLineNumbers
220
 *
221
 * PARAMETERS:  Op              - Op to be initialized
222
 *              Neighbor        - Op used for initialization values
223
 *
224
 * RETURN:      None
225
 *
226
 * DESCRIPTION: Initialized the various line numbers for a parse node.
227
 *
228
 ******************************************************************************/
229
230
 
231
TrAmlInitLineNumbers (
232
    ACPI_PARSE_OBJECT       *Op,
233
    ACPI_PARSE_OBJECT       *Neighbor)
234
{
235
236
 
237
    Op->Asl.EndLogicalLine    = Neighbor->Asl.EndLogicalLine;
238
    Op->Asl.LineNumber        = Neighbor->Asl.LineNumber;
239
    Op->Asl.LogicalByteOffset = Neighbor->Asl.LogicalByteOffset;
240
    Op->Asl.LogicalLineNumber = Neighbor->Asl.LogicalLineNumber;
241
}
242
243
 
244
 
245
 *
246
 * FUNCTION:    TrAmlInitNode
247
 *
248
 * PARAMETERS:  Op              - Op to be initialized
249
 *              ParseOpcode     - Opcode for this node
250
 *
251
 * RETURN:      None
252
 *
253
 * DESCRIPTION: Initialize a node with the parse opcode and opcode name.
254
 *
255
 ******************************************************************************/
256
257
 
258
TrAmlInitNode (
259
    ACPI_PARSE_OBJECT       *Op,
260
    UINT16                  ParseOpcode)
261
{
262
263
 
264
    UtSetParseOpName (Op);
265
}
266
267
 
268
 
269
 *
270
 * FUNCTION:    TrAmlSetSubtreeParent
271
 *
272
 * PARAMETERS:  Op              - First node in a list of peer nodes
273
 *              Parent          - Parent of the subtree
274
 *
275
 * RETURN:      None
276
 *
277
 * DESCRIPTION: Set the parent for all peer nodes in a subtree
278
 *
279
 ******************************************************************************/
280
281
 
282
TrAmlSetSubtreeParent (
283
    ACPI_PARSE_OBJECT       *Op,
284
    ACPI_PARSE_OBJECT       *Parent)
285
{
286
    ACPI_PARSE_OBJECT       *Next;
287
288
 
289
 
290
    while (Next)
291
    {
292
        Next->Asl.Parent = Parent;
293
        Next             = Next->Asl.Next;
294
    }
295
}
296
297
 
298
 
299
 *
300
 * FUNCTION:    TrAmlInsertPeer
301
 *
302
 * PARAMETERS:  Op              - First node in a list of peer nodes
303
 *              NewPeer         - Peer node to insert
304
 *
305
 * RETURN:      None
306
 *
307
 * DESCRIPTION: Insert a new peer node into a list of peers.
308
 *
309
 ******************************************************************************/
310
311
 
312
TrAmlInsertPeer (
313
    ACPI_PARSE_OBJECT       *Op,
314
    ACPI_PARSE_OBJECT       *NewPeer)
315
{
316
317
 
318
    Op->Asl.Next      = NewPeer;
319
}
320
321
 
322
 
323
 *
324
 * FUNCTION:    TrAmlTransformWalk
325
 *
326
 * PARAMETERS:  ASL_WALK_CALLBACK
327
 *
328
 * RETURN:      None
329
 *
330
 * DESCRIPTION: Parse tree walk to generate both the AML opcodes and the AML
331
 *              operands.
332
 *
333
 ******************************************************************************/
334
335
 
336
TrAmlTransformWalk (
337
    ACPI_PARSE_OBJECT       *Op,
338
    UINT32                  Level,
339
    void                    *Context)
340
{
341
342
 
343
    return (AE_OK);
344
}
345
346
 
347
 
348
 *
349
 * FUNCTION:    TrTransformSubtree
350
 *
351
 * PARAMETERS:  Op        - The parent parse node
352
 *
353
 * RETURN:      None
354
 *
355
 * DESCRIPTION: Prepare nodes to be output as AML data and operands.  The more
356
 *              complex AML opcodes require processing of the child nodes
357
 *              (arguments/operands).
358
 *
359
 ******************************************************************************/
360
361
 
362
TrTransformSubtree (
363
    ACPI_PARSE_OBJECT           *Op)
364
{
365
366
 
367
    {
368
        return;
369
    }
370
371
 
372
    {
373
    case PARSEOP_DEFINITIONBLOCK:
374
        TrDoDefinitionBlock (Op);
375
        break;
376
377
 
378
        TrDoSwitch (Op);
379
        break;
380
381
 
382
383
 
384
         * TBD: Zero the tempname (_T_x) count. Probably shouldn't be a global,
385
         * however
386
         */
387
        Gbl_TempCount = 0;
388
        break;
389
390
 
391
        /* Nothing to do here for other opcodes */
392
        break;
393
    }
394
}
395
396
 
397
 
398
 *
399
 * FUNCTION:    TrDoDefinitionBlock
400
 *
401
 * PARAMETERS:  Op        - Parse node
402
 *
403
 * RETURN:      None
404
 *
405
 * DESCRIPTION: Find the end of the definition block and set a global to this
406
 *              node.  It is used by the compiler to insert compiler-generated
407
 *              names at the root level of the namespace.
408
 *
409
 ******************************************************************************/
410
411
 
412
TrDoDefinitionBlock (
413
    ACPI_PARSE_OBJECT       *Op)
414
{
415
    ACPI_PARSE_OBJECT       *Next;
416
    UINT32                  i;
417
418
 
419
 
420
    for (i = 0; i < 5; i++)
421
    {
422
        Next = Next->Asl.Next;
423
        if (i == 0)
424
        {
425
            /*
426
             * This is the table signature. Only the DSDT can be assumed
427
             * to be at the root of the namespace;  Therefore, namepath
428
             * optimization can only be performed on the DSDT.
429
             */
430
            if (!ACPI_COMPARE_NAME (Next->Asl.Value.String, ACPI_SIG_DSDT))
431
            {
432
                Gbl_ReferenceOptimizationFlag = FALSE;
433
            }
434
        }
435
    }
436
437
 
438
}
439
440
 
441
 
442
 *
443
 * FUNCTION:    TrDoSwitch
444
 *
445
 * PARAMETERS:  StartNode        - Parse node for SWITCH
446
 *
447
 * RETURN:      None
448
 *
449
 *
450
 * DESCRIPTION: Translate ASL SWITCH statement to if/else pairs.  There is
451
 *              no actual AML opcode for SWITCH -- it must be simulated.
452
 *
453
 ******************************************************************************/
454
455
 
456
TrDoSwitch (
457
    ACPI_PARSE_OBJECT       *StartNode)
458
{
459
    ACPI_PARSE_OBJECT       *Next;
460
    ACPI_PARSE_OBJECT       *CaseOp = NULL;
461
    ACPI_PARSE_OBJECT       *CaseBlock = NULL;
462
    ACPI_PARSE_OBJECT       *DefaultOp = NULL;
463
    ACPI_PARSE_OBJECT       *CurrentParentNode;
464
    ACPI_PARSE_OBJECT       *Conditional = NULL;
465
    ACPI_PARSE_OBJECT       *Predicate;
466
    ACPI_PARSE_OBJECT       *Peer;
467
    ACPI_PARSE_OBJECT       *NewOp;
468
    ACPI_PARSE_OBJECT       *NewOp2;
469
    ACPI_PARSE_OBJECT       *MethodOp;
470
    ACPI_PARSE_OBJECT       *StoreOp;
471
    ACPI_PARSE_OBJECT       *BreakOp;
472
    char                    *PredicateValueName;
473
    UINT16                  Index;
474
    UINT32                  Btype;
475
476
 
477
 
478
479
 
480
481
 
482
483
 
484
    if (!PredicateValueName)
485
    {
486
        return;
487
    }
488
489
 
490
491
 
492
493
 
494
     * Examine the return type of the Switch Value -
495
     * must be Integer/Buffer/String
496
     */
497
    Index = (UINT16) (Next->Asl.ParseOpcode - ASL_PARSE_OPCODE_BASE);
498
    Btype = AslKeywordMapping[Index].AcpiBtype;
499
    if ((Btype != ACPI_BTYPE_INTEGER) &&
500
        (Btype != ACPI_BTYPE_STRING)  &&
501
        (Btype != ACPI_BTYPE_BUFFER))
502
    {
503
        AslError (ASL_WARNING, ASL_MSG_SWITCH_TYPE, Next, NULL);
504
        Btype = ACPI_BTYPE_INTEGER;
505
    }
506
507
 
508
509
 
510
    while (Peer)
511
    {
512
        Next = Peer;
513
        Peer = Next->Asl.Next;
514
515
 
516
        {
517
            if (CaseOp)
518
            {
519
                /* Add an ELSE to complete the previous CASE */
520
521
 
522
                {
523
                    return;
524
                }
525
                NewOp             = TrCreateLeafNode (PARSEOP_ELSE);
526
                NewOp->Asl.Parent = Conditional->Asl.Parent;
527
                TrAmlInitLineNumbers (NewOp, NewOp->Asl.Parent);
528
529
 
530
531
 
532
                CurrentParentNode = NewOp;
533
            }
534
535
 
536
            Conditional = CaseOp;
537
            CaseBlock   = CaseOp->Asl.Child->Asl.Next;
538
            Conditional->Asl.Child->Asl.Next = NULL;
539
            Predicate = CaseOp->Asl.Child;
540
541
 
542
                (Predicate->Asl.ParseOpcode == PARSEOP_VAR_PACKAGE))
543
            {
544
                /*
545
                 * Convert the package declaration to this form:
546
                 *
547
                 * If (LNotEqual (Match (Package(){},
548
                 *                       MEQ, _T_x, MTR, Zero, Zero), Ones))
549
                 */
550
                NewOp2              = TrCreateLeafNode (PARSEOP_MATCHTYPE_MEQ);
551
                Predicate->Asl.Next = NewOp2;
552
                TrAmlInitLineNumbers (NewOp2, Conditional);
553
554
 
555
                NewOp2              = TrCreateValuedLeafNode (PARSEOP_NAMESTRING,
556
                                        (UINT64) ACPI_TO_INTEGER (PredicateValueName));
557
                NewOp->Asl.Next     = NewOp2;
558
                TrAmlInitLineNumbers (NewOp2, Predicate);
559
560
 
561
                NewOp2              = TrCreateLeafNode (PARSEOP_MATCHTYPE_MTR);
562
                NewOp->Asl.Next     = NewOp2;
563
                TrAmlInitLineNumbers (NewOp2, Predicate);
564
565
 
566
                NewOp2              = TrCreateLeafNode (PARSEOP_ZERO);
567
                NewOp->Asl.Next     = NewOp2;
568
                TrAmlInitLineNumbers (NewOp2, Predicate);
569
570
 
571
                NewOp2              = TrCreateLeafNode (PARSEOP_ZERO);
572
                NewOp->Asl.Next     = NewOp2;
573
                TrAmlInitLineNumbers (NewOp2, Predicate);
574
575
 
576
                NewOp2->Asl.Child   = Predicate;  /* PARSEOP_PACKAGE */
577
                TrAmlInitLineNumbers (NewOp2, Conditional);
578
                TrAmlSetSubtreeParent (Predicate, NewOp2);
579
580
 
581
                NewOp2              = TrCreateLeafNode (PARSEOP_ONES);
582
                NewOp->Asl.Next     = NewOp2;
583
                TrAmlInitLineNumbers (NewOp2, Conditional);
584
585
 
586
                NewOp2->Asl.Child   = NewOp;
587
                NewOp->Asl.Parent   = NewOp2;
588
                TrAmlInitLineNumbers (NewOp2, Conditional);
589
                TrAmlSetSubtreeParent (NewOp, NewOp2);
590
591
 
592
                NewOp2              = TrCreateLeafNode (PARSEOP_LNOT);
593
                NewOp2->Asl.Child   = NewOp;
594
                NewOp2->Asl.Parent  = Conditional;
595
                NewOp->Asl.Parent   = NewOp2;
596
                TrAmlInitLineNumbers (NewOp2, Conditional);
597
598
 
599
                NewOp2->Asl.Next = CaseBlock;
600
            }
601
            else
602
            {
603
                /*
604
                 * Integer and Buffer case.
605
                 *
606
                 * Change CaseOp() to:  If (LEqual (SwitchValue, CaseValue)) {...}
607
                 * Note: SwitchValue is first to allow the CaseValue to be implicitly
608
                 * converted to the type of SwitchValue if necessary.
609
                 *
610
                 * CaseOp->Child is the case value
611
                 * CaseOp->Child->Peer is the beginning of the case block
612
                 */
613
                NewOp = TrCreateValuedLeafNode (PARSEOP_NAMESTRING,
614
                            (UINT64) ACPI_TO_INTEGER (PredicateValueName));
615
                NewOp->Asl.Next = Predicate;
616
                TrAmlInitLineNumbers (NewOp, Predicate);
617
618
 
619
                NewOp2->Asl.Parent  = Conditional;
620
                NewOp2->Asl.Child   = NewOp;
621
                TrAmlInitLineNumbers (NewOp2, Conditional);
622
623
 
624
625
 
626
                Predicate->Asl.Next = CaseBlock;
627
628
 
629
                Conditional->Asl.Child = Predicate;
630
            }
631
632
 
633
634
 
635
636
 
637
             * The first CASE(IF) is not nested under an ELSE.
638
             * All other CASEs are children of a parent ELSE.
639
             */
640
            if (CurrentParentNode == StartNode)
641
            {
642
                Conditional->Asl.Next = NULL;
643
            }
644
            else
645
            {
646
                /*
647
                 * The IF is a child of previous IF/ELSE.  It
648
                 * is therefore without peer.
649
                 */
650
                CurrentParentNode->Asl.Child = Conditional;
651
                Conditional->Asl.Parent      = CurrentParentNode;
652
                Conditional->Asl.Next        = NULL;
653
            }
654
        }
655
        else if (Next->Asl.ParseOpcode == PARSEOP_DEFAULT)
656
        {
657
            if (DefaultOp)
658
            {
659
                /*
660
                 * More than one Default
661
                 * (Parser does not catch this, must check here)
662
                 */
663
                AslError (ASL_ERROR, ASL_MSG_MULTIPLE_DEFAULT, Next, NULL);
664
            }
665
            else
666
            {
667
                /* Save the DEFAULT node for later, after CASEs */
668
669
 
670
            }
671
        }
672
        else
673
        {
674
            /* Unknown peer opcode */
675
676
 
677
                        Next->Asl.ParseOpName, Next->Asl.ParseOpcode);
678
        }
679
    }
680
681
 
682
683
 
684
    {
685
        /* If no CASE statements, this is an error - see below */
686
687
 
688
        {
689
            /* Convert the DEFAULT node to an ELSE */
690
691
 
692
            {
693
                return;
694
            }
695
696
 
697
            DefaultOp->Asl.Parent = Conditional->Asl.Parent;
698
699
 
700
701
 
702
        }
703
    }
704
705
 
706
    {
707
        AslError (ASL_ERROR, ASL_MSG_NO_CASES, StartNode, NULL);
708
    }
709
710
 
711
 
712
     * Create a Name(_T_x, ...) statement. This statement must appear at the
713
     * method level, in case a loop surrounds the switch statement and could
714
     * cause the name to be created twice (error).
715
     */
716
717
 
718
719
 
720
    NewOp = TrCreateLeafNode (PARSEOP_NAME);
721
722
 
723
724
 
725
    while ((Next->Asl.ParseOpcode != PARSEOP_METHOD) &&
726
           (Next->Asl.ParseOpcode != PARSEOP_DEFINITIONBLOCK))
727
    {
728
        Next = Next->Asl.Parent;
729
    }
730
    MethodOp = Next;
731
732
 
733
    NewOp->Asl.Parent = Next;
734
735
 
736
737
 
738
    Next = Next->Asl.Next;  /* NumArgs */
739
    Next = Next->Asl.Next;  /* SerializeRule */
740
741
 
742
     * If method is not Serialized, we must make is so, because of the way
743
     * that Switch() must be implemented -- we cannot allow multiple threads
744
     * to execute this method concurrently since we need to create local
745
     * temporary name(s).
746
     */
747
    if (Next->Asl.ParseOpcode != PARSEOP_SERIALIZERULE_SERIAL)
748
    {
749
        AslError (ASL_REMARK, ASL_MSG_SERIALIZED, MethodOp, "Due to use of Switch operator");
750
        Next->Asl.ParseOpcode = PARSEOP_SERIALIZERULE_SERIAL;
751
    }
752
753
 
754
    Next = Next->Asl.Next;  /* ReturnType */
755
    Next = Next->Asl.Next;  /* ParameterTypes */
756
757
 
758
    TrAmlInitLineNumbers (NewOp, Next);
759
760
 
761
762
 
763
                (UINT64) ACPI_TO_INTEGER (PredicateValueName));
764
    NewOp2->Asl.CompileFlags |= NODE_IS_NAME_DECLARATION;
765
    NewOp->Asl.Child  = NewOp2;
766
767
 
768
769
 
770
    {
771
    case ACPI_BTYPE_INTEGER:
772
        NewOp2->Asl.Next = TrCreateValuedLeafNode (PARSEOP_ZERO,
773
                                (UINT64) 0);
774
        break;
775
776
 
777
        NewOp2->Asl.Next = TrCreateValuedLeafNode (PARSEOP_STRING_LITERAL,
778
                                (UINT64) ACPI_TO_INTEGER (""));
779
        break;
780
781
 
782
        (void) TrLinkPeerNode (NewOp2, TrCreateValuedLeafNode (PARSEOP_BUFFER,
783
                                    (UINT64) 0));
784
        Next = NewOp2->Asl.Next;
785
        (void) TrLinkChildren (Next, 1, TrCreateValuedLeafNode (PARSEOP_ZERO,
786
                                    (UINT64) 1));
787
        (void) TrLinkPeerNode (Next->Asl.Child,
788
            TrCreateValuedLeafNode (PARSEOP_DEFAULT_ARG, (UINT64) 0));
789
790
 
791
        break;
792
793
 
794
        break;
795
    }
796
797
 
798
799
 
800
     * Transform the Switch() into a While(One)-Break node.
801
     * And create a Store() node which will be used to save the
802
     * Switch() value.  The store is of the form: Store (Value, _T_x)
803
     * where _T_x is the temp variable.
804
     */
805
    TrAmlInitNode (StartNode, PARSEOP_WHILE);
806
    NewOp = TrCreateLeafNode (PARSEOP_ONE);
807
    NewOp->Asl.Next = Predicate->Asl.Next;
808
    NewOp->Asl.Parent = StartNode;
809
    StartNode->Asl.Child = NewOp;
810
811
 
812
813
 
814
    StoreOp->Asl.Parent = StartNode;
815
    TrAmlInsertPeer (NewOp, StoreOp);
816
817
 
818
819
 
820
    Predicate->Asl.Parent = StoreOp;
821
822
 
823
                (UINT64) ACPI_TO_INTEGER (PredicateValueName));
824
    NewOp->Asl.Parent    = StoreOp;
825
    Predicate->Asl.Next  = NewOp;
826
827
 
828
829
 
830
    while (Conditional->Asl.Next)
831
    {
832
        Conditional = Conditional->Asl.Next;
833
    }
834
835
 
836
    BreakOp->Asl.Parent = StartNode;
837
    TrAmlInsertPeer (Conditional, BreakOp);
838
}
839