Subversion Repositories Kolibri OS

Rev

Rev 1498 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1498 serge 1
 
2
 *
3
 * Module Name: exoparg1 - AML execution - opcodes with 1 argument
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
 
119
#include "accommon.h"
120
#include "acparser.h"
121
#include "acdispat.h"
122
#include "acinterp.h"
123
#include "amlcode.h"
124
#include "acnamesp.h"
125
126
 
127
 
128
        ACPI_MODULE_NAME    ("exoparg1")
129
130
 
131
 
132
 * Naming convention for AML interpreter execution routines.
133
 *
134
 * The routines that begin execution of AML opcodes are named with a common
135
 * convention based upon the number of arguments, the number of target operands,
136
 * and whether or not a value is returned:
137
 *
138
 *      AcpiExOpcode_xA_yT_zR
139
 *
140
 * Where:
141
 *
142
 * xA - ARGUMENTS:    The number of arguments (input operands) that are
143
 *                    required for this opcode type (0 through 6 args).
144
 * yT - TARGETS:      The number of targets (output operands) that are required
145
 *                    for this opcode type (0, 1, or 2 targets).
146
 * zR - RETURN VALUE: Indicates whether this opcode type returns a value
147
 *                    as the function return (0 or 1).
148
 *
149
 * The AcpiExOpcode* functions are called via the Dispatcher component with
150
 * fully resolved operands.
151
!*/
152
153
 
154
 *
155
 * FUNCTION:    AcpiExOpcode_0A_0T_1R
156
 *
157
 * PARAMETERS:  WalkState           - Current state (contains AML opcode)
158
 *
159
 * RETURN:      Status
160
 *
161
 * DESCRIPTION: Execute operator with no operands, one return value
162
 *
163
 ******************************************************************************/
164
165
 
166
AcpiExOpcode_0A_0T_1R (
167
    ACPI_WALK_STATE         *WalkState)
168
{
169
    ACPI_STATUS             Status = AE_OK;
170
    ACPI_OPERAND_OBJECT     *ReturnDesc = NULL;
171
172
 
173
 
174
        AcpiPsGetOpcodeName (WalkState->Opcode));
175
176
 
177
 
178
179
 
180
    {
181
    case AML_TIMER_OP:      /*  Timer () */
182
183
 
184
185
 
186
        if (!ReturnDesc)
187
        {
188
            Status = AE_NO_MEMORY;
189
            goto Cleanup;
190
        }
191
        break;
192
193
 
194
195
 
196
            WalkState->Opcode));
197
        Status = AE_AML_BAD_OPCODE;
198
        break;
199
    }
200
201
 
202
203
 
204
205
 
206
    {
207
        AcpiUtRemoveReference (ReturnDesc);
208
        WalkState->ResultObj = NULL;
209
    }
210
    else
211
    {
212
        /* Save the return value */
213
214
 
215
    }
216
217
 
218
}
219
220
 
221
 
222
 *
223
 * FUNCTION:    AcpiExOpcode_1A_0T_0R
224
 *
225
 * PARAMETERS:  WalkState           - Current state (contains AML opcode)
226
 *
227
 * RETURN:      Status
228
 *
229
 * DESCRIPTION: Execute Type 1 monadic operator with numeric operand on
230
 *              object stack
231
 *
232
 ******************************************************************************/
233
234
 
235
AcpiExOpcode_1A_0T_0R (
236
    ACPI_WALK_STATE         *WalkState)
237
{
238
    ACPI_OPERAND_OBJECT     **Operand = &WalkState->Operands[0];
239
    ACPI_STATUS             Status = AE_OK;
240
241
 
242
 
243
        AcpiPsGetOpcodeName (WalkState->Opcode));
244
245
 
246
 
247
248
 
249
    {
250
    case AML_RELEASE_OP:    /*  Release (MutexObject) */
251
252
 
253
        break;
254
255
 
256
 
257
258
 
259
        break;
260
261
 
262
 
263
264
 
265
        break;
266
267
 
268
 
269
270
 
271
        break;
272
273
 
274
 
275
276
 
277
        break;
278
279
 
280
 
281
282
 
283
        break;
284
285
 
286
 
287
288
 
289
            WalkState->Opcode));
290
        Status = AE_AML_BAD_OPCODE;
291
        break;
292
    }
293
294
 
295
}
296
297
 
298
 
299
 *
300
 * FUNCTION:    AcpiExOpcode_1A_1T_0R
301
 *
302
 * PARAMETERS:  WalkState           - Current state (contains AML opcode)
303
 *
304
 * RETURN:      Status
305
 *
306
 * DESCRIPTION: Execute opcode with one argument, one target, and no
307
 *              return value.
308
 *
309
 ******************************************************************************/
310
311
 
312
AcpiExOpcode_1A_1T_0R (
313
    ACPI_WALK_STATE         *WalkState)
314
{
315
    ACPI_STATUS             Status = AE_OK;
316
    ACPI_OPERAND_OBJECT     **Operand = &WalkState->Operands[0];
317
318
 
319
 
320
        AcpiPsGetOpcodeName (WalkState->Opcode));
321
322
 
323
 
324
325
 
326
    {
327
    case AML_LOAD_OP:
328
329
 
330
        break;
331
332
 
333
334
 
335
            WalkState->Opcode));
336
        Status = AE_AML_BAD_OPCODE;
337
        goto Cleanup;
338
    }
339
340
 
341
 
342
343
 
344
}
345
346
 
347
 
348
 *
349
 * FUNCTION:    AcpiExOpcode_1A_1T_1R
350
 *
351
 * PARAMETERS:  WalkState           - Current state (contains AML opcode)
352
 *
353
 * RETURN:      Status
354
 *
355
 * DESCRIPTION: Execute opcode with one argument, one target, and a
356
 *              return value.
357
 *
358
 ******************************************************************************/
359
360
 
361
AcpiExOpcode_1A_1T_1R (
362
    ACPI_WALK_STATE         *WalkState)
363
{
364
    ACPI_STATUS             Status = AE_OK;
365
    ACPI_OPERAND_OBJECT     **Operand = &WalkState->Operands[0];
366
    ACPI_OPERAND_OBJECT     *ReturnDesc = NULL;
367
    ACPI_OPERAND_OBJECT     *ReturnDesc2 = NULL;
368
    UINT32                  Temp32;
369
    UINT32                  i;
370
    UINT64                  PowerOfTen;
371
    UINT64                  Digit;
372
373
 
374
 
375
        AcpiPsGetOpcodeName (WalkState->Opcode));
376
377
 
378
 
379
380
 
381
    {
382
    case AML_BIT_NOT_OP:
383
    case AML_FIND_SET_LEFT_BIT_OP:
384
    case AML_FIND_SET_RIGHT_BIT_OP:
385
    case AML_FROM_BCD_OP:
386
    case AML_TO_BCD_OP:
387
    case AML_COND_REF_OF_OP:
388
389
 
390
391
 
392
        if (!ReturnDesc)
393
        {
394
            Status = AE_NO_MEMORY;
395
            goto Cleanup;
396
        }
397
398
 
399
        {
400
        case AML_BIT_NOT_OP:            /* Not (Operand, Result)  */
401
402
 
403
            break;
404
405
 
406
 
407
408
 
409
410
 
411
             * Acpi specification describes Integer type as a little
412
             * endian unsigned value, so this boundary condition is valid.
413
             */
414
            for (Temp32 = 0; ReturnDesc->Integer.Value &&
415
                             Temp32 < ACPI_INTEGER_BIT_SIZE; ++Temp32)
416
            {
417
                ReturnDesc->Integer.Value >>= 1;
418
            }
419
420
 
421
            break;
422
423
 
424
 
425
426
 
427
428
 
429
             * The Acpi specification describes Integer type as a little
430
             * endian unsigned value, so this boundary condition is valid.
431
             */
432
            for (Temp32 = 0; ReturnDesc->Integer.Value &&
433
                             Temp32 < ACPI_INTEGER_BIT_SIZE; ++Temp32)
434
            {
435
                ReturnDesc->Integer.Value <<= 1;
436
            }
437
438
 
439
440
 
441
                Temp32 == 0 ? 0 : (ACPI_INTEGER_BIT_SIZE + 1) - Temp32;
442
            break;
443
444
 
445
 
446
447
 
448
             * The 64-bit ACPI integer can hold 16 4-bit BCD characters
449
             * (if table is 32-bit, integer can hold 8 BCD characters)
450
             * Convert each 4-bit BCD value
451
             */
452
            PowerOfTen = 1;
453
            ReturnDesc->Integer.Value = 0;
454
            Digit = Operand[0]->Integer.Value;
455
456
 
457
458
 
459
            {
460
                /* Get the least significant 4-bit BCD digit */
461
462
 
463
464
 
465
466
 
467
                {
468
                    ACPI_ERROR ((AE_INFO,
469
                        "BCD digit too large (not decimal): 0x%X",
470
                        Temp32));
471
472
 
473
                    goto Cleanup;
474
                }
475
476
 
477
478
 
479
                    (((UINT64) Temp32) * PowerOfTen);
480
481
 
482
483
 
484
485
 
486
487
 
488
            }
489
            break;
490
491
 
492
 
493
494
 
495
            Digit = Operand[0]->Integer.Value;
496
497
 
498
499
 
500
            {
501
                (void) AcpiUtShortDivide (Digit, 10, &Digit, &Temp32);
502
503
 
504
                 * Insert the BCD digit that resides in the
505
                 * remainder from above
506
                 */
507
                ReturnDesc->Integer.Value |=
508
                    (((UINT64) Temp32) << ACPI_MUL_4 (i));
509
            }
510
511
 
512
513
 
514
            {
515
                ACPI_ERROR ((AE_INFO,
516
                    "Integer too large to convert to BCD: 0x%8.8X%8.8X",
517
                    ACPI_FORMAT_UINT64 (Operand[0]->Integer.Value)));
518
                Status = AE_AML_NUMERIC_OVERFLOW;
519
                goto Cleanup;
520
            }
521
            break;
522
523
 
524
 
525
526
 
527
             * This op is a little strange because the internal return value is
528
             * different than the return value stored in the result descriptor
529
             * (There are really two return values)
530
             */
531
            if ((ACPI_NAMESPACE_NODE *) Operand[0] == AcpiGbl_RootNode)
532
            {
533
                /*
534
                 * This means that the object does not exist in the namespace,
535
                 * return FALSE
536
                 */
537
                ReturnDesc->Integer.Value = 0;
538
                goto Cleanup;
539
            }
540
541
 
542
543
 
544
                        &ReturnDesc2, WalkState);
545
            if (ACPI_FAILURE (Status))
546
            {
547
                goto Cleanup;
548
            }
549
550
 
551
            AcpiUtRemoveReference (ReturnDesc2);
552
553
 
554
555
 
556
            goto Cleanup;
557
558
 
559
 
560
            /* No other opcodes get here */
561
            break;
562
        }
563
        break;
564
565
 
566
 
567
568
 
569
         * A store operand is typically a number, string, buffer or lvalue
570
         * Be careful about deleting the source object,
571
         * since the object itself may have been stored.
572
         */
573
        Status = AcpiExStore (Operand[0], Operand[1], WalkState);
574
        if (ACPI_FAILURE (Status))
575
        {
576
            return_ACPI_STATUS (Status);
577
        }
578
579
 
580
581
 
582
        {
583
            /*
584
             * Normally, we would remove a reference on the Operand[0]
585
             * parameter; But since it is being used as the internal return
586
             * object (meaning we would normally increment it), the two
587
             * cancel out, and we simply don't do anything.
588
             */
589
            WalkState->ResultObj = Operand[0];
590
            WalkState->Operands[0] = NULL;  /* Prevent deletion */
591
        }
592
        return_ACPI_STATUS (Status);
593
594
 
595
 
596
     * ACPI 2.0 Opcodes
597
     */
598
    case AML_COPY_OP:               /* Copy (Source, Target) */
599
600
 
601
                    WalkState);
602
        break;
603
604
 
605
 
606
607
 
608
                    ACPI_EXPLICIT_CONVERT_DECIMAL);
609
        if (ReturnDesc == Operand[0])
610
        {
611
            /* No conversion performed, add ref to handle return value */
612
            AcpiUtAddReference (ReturnDesc);
613
        }
614
        break;
615
616
 
617
 
618
619
 
620
                    ACPI_EXPLICIT_CONVERT_HEX);
621
        if (ReturnDesc == Operand[0])
622
        {
623
            /* No conversion performed, add ref to handle return value */
624
            AcpiUtAddReference (ReturnDesc);
625
        }
626
        break;
627
628
 
629
 
630
631
 
632
        if (ReturnDesc == Operand[0])
633
        {
634
            /* No conversion performed, add ref to handle return value */
635
            AcpiUtAddReference (ReturnDesc);
636
        }
637
        break;
638
639
 
640
 
641
642
 
643
                    ACPI_ANY_BASE);
644
        if (ReturnDesc == Operand[0])
645
        {
646
            /* No conversion performed, add ref to handle return value */
647
            AcpiUtAddReference (ReturnDesc);
648
        }
649
        break;
650
651
 
652
 
653
    case AML_SHIFT_RIGHT_BIT_OP:    /* ShiftRightBit (Source, BitNum) */
654
655
 
656
657
 
658
            "%s is obsolete and not implemented",
659
            AcpiPsGetOpcodeName (WalkState->Opcode)));
660
        Status = AE_SUPPORT;
661
        goto Cleanup;
662
663
 
664
 
665
666
 
667
            WalkState->Opcode));
668
        Status = AE_AML_BAD_OPCODE;
669
        goto Cleanup;
670
    }
671
672
 
673
    {
674
        /* Store the return value computed above into the target object */
675
676
 
677
    }
678
679
 
680
 
681
682
 
683
684
 
685
    {
686
        AcpiUtRemoveReference (ReturnDesc);
687
    }
688
689
 
690
691
 
692
    {
693
        WalkState->ResultObj = ReturnDesc;
694
    }
695
696
 
697
}
698
699
 
700
 
701
 *
702
 * FUNCTION:    AcpiExOpcode_1A_0T_1R
703
 *
704
 * PARAMETERS:  WalkState           - Current state (contains AML opcode)
705
 *
706
 * RETURN:      Status
707
 *
708
 * DESCRIPTION: Execute opcode with one argument, no target, and a return value
709
 *
710
 ******************************************************************************/
711
712
 
713
AcpiExOpcode_1A_0T_1R (
714
    ACPI_WALK_STATE         *WalkState)
715
{
716
    ACPI_OPERAND_OBJECT     **Operand = &WalkState->Operands[0];
717
    ACPI_OPERAND_OBJECT     *TempDesc;
718
    ACPI_OPERAND_OBJECT     *ReturnDesc = NULL;
719
    ACPI_STATUS             Status = AE_OK;
720
    UINT32                  Type;
721
    UINT64                  Value;
722
723
 
724
 
725
        AcpiPsGetOpcodeName (WalkState->Opcode));
726
727
 
728
 
729
730
 
731
    {
732
    case AML_LNOT_OP:               /* LNot (Operand) */
733
734
 
735
        if (!ReturnDesc)
736
        {
737
            Status = AE_NO_MEMORY;
738
            goto Cleanup;
739
        }
740
741
 
742
         * Set result to ONES (TRUE) if Value == 0.  Note:
743
         * ReturnDesc->Integer.Value is initially == 0 (FALSE) from above.
744
         */
745
        if (!Operand[0]->Integer.Value)
746
        {
747
            ReturnDesc->Integer.Value = ACPI_UINT64_MAX;
748
        }
749
        break;
750
751
 
752
 
753
    case AML_INCREMENT_OP:          /* Increment (Operand)  */
754
755
 
756
         * Create a new integer.  Can't just get the base integer and
757
         * increment it because it may be an Arg or Field.
758
         */
759
        ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
760
        if (!ReturnDesc)
761
        {
762
            Status = AE_NO_MEMORY;
763
            goto Cleanup;
764
        }
765
766
 
767
         * Since we are expecting a Reference operand, it can be either a
768
         * NS Node or an internal object.
769
         */
770
        TempDesc = Operand[0];
771
        if (ACPI_GET_DESCRIPTOR_TYPE (TempDesc) == ACPI_DESC_TYPE_OPERAND)
772
        {
773
            /* Internal reference object - prevent deletion */
774
775
 
776
        }
777
778
 
779
         * Convert the Reference operand to an Integer (This removes a
780
         * reference on the Operand[0] object)
781
         *
782
         * NOTE:  We use LNOT_OP here in order to force resolution of the
783
         * reference operand to an actual integer.
784
         */
785
        Status = AcpiExResolveOperands (AML_LNOT_OP, &TempDesc, WalkState);
786
        if (ACPI_FAILURE (Status))
787
        {
788
            ACPI_EXCEPTION ((AE_INFO, Status,
789
                "While resolving operands for [%s]",
790
                AcpiPsGetOpcodeName (WalkState->Opcode)));
791
792
 
793
        }
794
795
 
796
         * TempDesc is now guaranteed to be an Integer object --
797
         * Perform the actual increment or decrement
798
         */
799
        if (WalkState->Opcode == AML_INCREMENT_OP)
800
        {
801
            ReturnDesc->Integer.Value = TempDesc->Integer.Value +1;
802
        }
803
        else
804
        {
805
            ReturnDesc->Integer.Value = TempDesc->Integer.Value -1;
806
        }
807
808
 
809
810
 
811
812
 
813
         * Store the result back (indirectly) through the original
814
         * Reference object
815
         */
816
        Status = AcpiExStore (ReturnDesc, Operand[0], WalkState);
817
        break;
818
819
 
820
 
821
822
 
823
         * Note: The operand is not resolved at this point because we want to
824
         * get the associated object, not its value.  For example, we don't
825
         * want to resolve a FieldUnit to its value, we want the actual
826
         * FieldUnit object.
827
         */
828
829
 
830
831
 
832
        if (ACPI_FAILURE (Status))
833
        {
834
            goto Cleanup;
835
        }
836
837
 
838
839
 
840
        if (!ReturnDesc)
841
        {
842
            Status = AE_NO_MEMORY;
843
            goto Cleanup;
844
        }
845
        break;
846
847
 
848
 
849
850
 
851
         * Note: The operand is not resolved at this point because we want to
852
         * get the associated object, not its value.
853
         */
854
855
 
856
857
 
858
                    Operand[0], &Type, &TempDesc);
859
        if (ACPI_FAILURE (Status))
860
        {
861
            goto Cleanup;
862
        }
863
864
 
865
         * The type of the base object must be integer, buffer, string, or
866
         * package.  All others are not supported.
867
         *
868
         * NOTE: Integer is not specifically supported by the ACPI spec,
869
         * but is supported implicitly via implicit operand conversion.
870
         * rather than bother with conversion, we just use the byte width
871
         * global (4 or 8 bytes).
872
         */
873
        switch (Type)
874
        {
875
        case ACPI_TYPE_INTEGER:
876
            Value = AcpiGbl_IntegerByteWidth;
877
            break;
878
879
 
880
            Value = TempDesc->String.Length;
881
            break;
882
883
 
884
885
 
886
887
 
888
            Value = TempDesc->Buffer.Length;
889
            break;
890
891
 
892
893
 
894
895
 
896
            Value = TempDesc->Package.Count;
897
            break;
898
899
 
900
            ACPI_ERROR ((AE_INFO,
901
                "Operand must be Buffer/Integer/String/Package - found type %s",
902
                AcpiUtGetTypeName (Type)));
903
            Status = AE_AML_OPERAND_TYPE;
904
            goto Cleanup;
905
        }
906
907
 
908
        {
909
            goto Cleanup;
910
        }
911
912
 
913
         * Now that we have the size of the object, create a result
914
         * object to hold the value
915
         */
916
        ReturnDesc = AcpiUtCreateIntegerObject (Value);
917
        if (!ReturnDesc)
918
        {
919
            Status = AE_NO_MEMORY;
920
            goto Cleanup;
921
        }
922
        break;
923
924
 
925
 
926
927
 
928
        if (ACPI_FAILURE (Status))
929
        {
930
            goto Cleanup;
931
        }
932
        break;
933
934
 
935
 
936
937
 
938
939
 
940
        {
941
            TempDesc = AcpiNsGetAttachedObject (
942
                           (ACPI_NAMESPACE_NODE *) Operand[0]);
943
            if (TempDesc &&
944
                 ((TempDesc->Common.Type == ACPI_TYPE_STRING) ||
945
                  (TempDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE)))
946
            {
947
                Operand[0] = TempDesc;
948
                AcpiUtAddReference (TempDesc);
949
            }
950
            else
951
            {
952
                Status = AE_AML_OPERAND_TYPE;
953
                goto Cleanup;
954
            }
955
        }
956
        else
957
        {
958
            switch ((Operand[0])->Common.Type)
959
            {
960
            case ACPI_TYPE_LOCAL_REFERENCE:
961
                /*
962
                 * This is a DerefOf (LocalX | ArgX)
963
                 *
964
                 * Must resolve/dereference the local/arg reference first
965
                 */
966
                switch (Operand[0]->Reference.Class)
967
                {
968
                case ACPI_REFCLASS_LOCAL:
969
                case ACPI_REFCLASS_ARG:
970
971
 
972
973
 
974
                                Operand[0]->Reference.Class,
975
                                Operand[0]->Reference.Value,
976
                                WalkState, &TempDesc);
977
                    if (ACPI_FAILURE (Status))
978
                    {
979
                        goto Cleanup;
980
                    }
981
982
 
983
                     * Delete our reference to the input object and
984
                     * point to the object just retrieved
985
                     */
986
                    AcpiUtRemoveReference (Operand[0]);
987
                    Operand[0] = TempDesc;
988
                    break;
989
990
 
991
992
 
993
994
 
995
                    AcpiUtRemoveReference (Operand[0]);
996
                    Operand[0] = TempDesc;
997
                    break;
998
999
 
1000
1001
 
1002
                    break;
1003
                }
1004
                break;
1005
1006
 
1007
                break;
1008
1009
 
1010
                Status = AE_AML_OPERAND_TYPE;
1011
                goto Cleanup;
1012
            }
1013
        }
1014
1015
 
1016
        {
1017
            if ((Operand[0])->Common.Type == ACPI_TYPE_STRING)
1018
            {
1019
                /*
1020
                 * This is a DerefOf (String). The string is a reference
1021
                 * to a named ACPI object.
1022
                 *
1023
                 * 1) Find the owning Node
1024
                 * 2) Dereference the node to an actual object. Could be a
1025
                 *    Field, so we need to resolve the node to a value.
1026
                 */
1027
                Status = AcpiNsGetNode (WalkState->ScopeInfo->Scope.Node,
1028
                            Operand[0]->String.Pointer,
1029
                            ACPI_NS_SEARCH_PARENT,
1030
                            ACPI_CAST_INDIRECT_PTR (
1031
                                ACPI_NAMESPACE_NODE, &ReturnDesc));
1032
                if (ACPI_FAILURE (Status))
1033
                {
1034
                    goto Cleanup;
1035
                }
1036
1037
 
1038
                            ACPI_CAST_INDIRECT_PTR (
1039
                                ACPI_NAMESPACE_NODE, &ReturnDesc),
1040
                            WalkState);
1041
                goto Cleanup;
1042
            }
1043
        }
1044
1045
 
1046
1047
 
1048
        {
1049
            /*
1050
             * This is a DerefOf (ObjectReference)
1051
             * Get the actual object from the Node (This is the dereference).
1052
             * This case may only happen when a LocalX or ArgX is
1053
             * dereferenced above.
1054
             */
1055
            ReturnDesc = AcpiNsGetAttachedObject (
1056
                            (ACPI_NAMESPACE_NODE *) Operand[0]);
1057
            AcpiUtAddReference (ReturnDesc);
1058
        }
1059
        else
1060
        {
1061
            /*
1062
             * This must be a reference object produced by either the
1063
             * Index() or RefOf() operator
1064
             */
1065
            switch (Operand[0]->Reference.Class)
1066
            {
1067
            case ACPI_REFCLASS_INDEX:
1068
1069
 
1070
                 * The target type for the Index operator must be
1071
                 * either a Buffer or a Package
1072
                 */
1073
                switch (Operand[0]->Reference.TargetType)
1074
                {
1075
                case ACPI_TYPE_BUFFER_FIELD:
1076
1077
 
1078
1079
 
1080
                     * Create a new object that contains one element of the
1081
                     * buffer -- the element pointed to by the index.
1082
                     *
1083
                     * NOTE: index into a buffer is NOT a pointer to a
1084
                     * sub-buffer of the main buffer, it is only a pointer to a
1085
                     * single element (byte) of the buffer!
1086
                     *
1087
                     * Since we are returning the value of the buffer at the
1088
                     * indexed location, we don't need to add an additional
1089
                     * reference to the buffer itself.
1090
                     */
1091
                    ReturnDesc = AcpiUtCreateIntegerObject ((UINT64)
1092
                        TempDesc->Buffer.Pointer[Operand[0]->Reference.Value]);
1093
                    if (!ReturnDesc)
1094
                    {
1095
                        Status = AE_NO_MEMORY;
1096
                        goto Cleanup;
1097
                    }
1098
                    break;
1099
1100
 
1101
 
1102
1103
 
1104
                     * Return the referenced element of the package.  We must
1105
                     * add another reference to the referenced object, however.
1106
                     */
1107
                    ReturnDesc = *(Operand[0]->Reference.Where);
1108
                    if (ReturnDesc)
1109
                    {
1110
                        AcpiUtAddReference (ReturnDesc);
1111
                    }
1112
                    break;
1113
1114
 
1115
 
1116
1117
 
1118
                        "Unknown Index TargetType 0x%X in reference object %p",
1119
                        Operand[0]->Reference.TargetType, Operand[0]));
1120
                    Status = AE_AML_OPERAND_TYPE;
1121
                    goto Cleanup;
1122
                }
1123
                break;
1124
1125
 
1126
 
1127
1128
 
1129
1130
 
1131
                        ACPI_DESC_TYPE_NAMED)
1132
                {
1133
                    ReturnDesc = AcpiNsGetAttachedObject (
1134
                                    (ACPI_NAMESPACE_NODE *) ReturnDesc);
1135
                }
1136
1137
 
1138
1139
 
1140
                break;
1141
1142
 
1143
 
1144
                ACPI_ERROR ((AE_INFO,
1145
                    "Unknown class in reference(%p) - 0x%2.2X",
1146
                    Operand[0], Operand[0]->Reference.Class));
1147
1148
 
1149
                goto Cleanup;
1150
            }
1151
        }
1152
        break;
1153
1154
 
1155
 
1156
1157
 
1158
            WalkState->Opcode));
1159
        Status = AE_AML_BAD_OPCODE;
1160
        goto Cleanup;
1161
    }
1162
1163
 
1164
 
1165
1166
 
1167
1168
 
1169
    {
1170
        AcpiUtRemoveReference (ReturnDesc);
1171
    }
1172
1173
 
1174
1175
 
1176
    {
1177
        WalkState->ResultObj = ReturnDesc;
1178
    }
1179
1180
 
1181
}
1182