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: exresop - AML Interpreter operand/object resolution
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 "amlcode.h"
121
#include "acparser.h"
122
#include "acinterp.h"
123
#include "acnamesp.h"
124
125
 
126
 
127
        ACPI_MODULE_NAME    ("exresop")
128
129
 
130
131
 
132
AcpiExCheckObjectType (
133
    ACPI_OBJECT_TYPE        TypeNeeded,
134
    ACPI_OBJECT_TYPE        ThisType,
135
    void                    *Object);
136
137
 
138
 
139
 *
140
 * FUNCTION:    AcpiExCheckObjectType
141
 *
142
 * PARAMETERS:  TypeNeeded          Object type needed
143
 *              ThisType            Actual object type
144
 *              Object              Object pointer
145
 *
146
 * RETURN:      Status
147
 *
148
 * DESCRIPTION: Check required type against actual type
149
 *
150
 ******************************************************************************/
151
152
 
153
AcpiExCheckObjectType (
154
    ACPI_OBJECT_TYPE        TypeNeeded,
155
    ACPI_OBJECT_TYPE        ThisType,
156
    void                    *Object)
157
{
158
    ACPI_FUNCTION_ENTRY ();
159
160
 
161
 
162
    {
163
        /* All types OK, so we don't perform any typechecks */
164
165
 
166
    }
167
168
 
169
    {
170
        /*
171
         * Allow the AML "Constant" opcodes (Zero, One, etc.) to be reference
172
         * objects and thus allow them to be targets.  (As per the ACPI
173
         * specification, a store to a constant is a noop.)
174
         */
175
        if ((ThisType == ACPI_TYPE_INTEGER) &&
176
            (((ACPI_OPERAND_OBJECT *) Object)->Common.Flags & AOPOBJ_AML_CONSTANT))
177
        {
178
            return (AE_OK);
179
        }
180
    }
181
182
 
183
    {
184
        ACPI_ERROR ((AE_INFO,
185
            "Needed type [%s], found [%s] %p",
186
            AcpiUtGetTypeName (TypeNeeded),
187
            AcpiUtGetTypeName (ThisType), Object));
188
189
 
190
    }
191
192
 
193
}
194
195
 
196
 
197
 *
198
 * FUNCTION:    AcpiExResolveOperands
199
 *
200
 * PARAMETERS:  Opcode              - Opcode being interpreted
201
 *              StackPtr            - Pointer to the operand stack to be
202
 *                                    resolved
203
 *              WalkState           - Current state
204
 *
205
 * RETURN:      Status
206
 *
207
 * DESCRIPTION: Convert multiple input operands to the types required by the
208
 *              target operator.
209
 *
210
 *      Each 5-bit group in ArgTypes represents one required
211
 *      operand and indicates the required Type. The corresponding operand
212
 *      will be converted to the required type if possible, otherwise we
213
 *      abort with an exception.
214
 *
215
 ******************************************************************************/
216
217
 
218
AcpiExResolveOperands (
219
    UINT16                  Opcode,
220
    ACPI_OPERAND_OBJECT     **StackPtr,
221
    ACPI_WALK_STATE         *WalkState)
222
{
223
    ACPI_OPERAND_OBJECT     *ObjDesc;
224
    ACPI_STATUS             Status = AE_OK;
225
    UINT8                   ObjectType;
226
    UINT32                  ArgTypes;
227
    const ACPI_OPCODE_INFO  *OpInfo;
228
    UINT32                  ThisArgType;
229
    ACPI_OBJECT_TYPE        TypeNeeded;
230
    UINT16                  TargetOp = 0;
231
232
 
233
 
234
235
 
236
 
237
    if (OpInfo->Class == AML_CLASS_UNKNOWN)
238
    {
239
        return_ACPI_STATUS (AE_AML_BAD_OPCODE);
240
    }
241
242
 
243
    if (ArgTypes == ARGI_INVALID_OPCODE)
244
    {
245
        ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
246
            Opcode));
247
248
 
249
    }
250
251
 
252
        "Opcode %X [%s] RequiredOperandTypes=%8.8X\n",
253
        Opcode, OpInfo->Name, ArgTypes));
254
255
 
256
     * Normal exit is with (ArgTypes == 0) at end of argument list.
257
     * Function will return an exception from within the loop upon
258
     * finding an entry which is not (or cannot be converted
259
     * to) the required type; if stack underflows; or upon
260
     * finding a NULL stack entry (which should not happen).
261
     */
262
    while (GET_CURRENT_ARG_TYPE (ArgTypes))
263
    {
264
        if (!StackPtr || !*StackPtr)
265
        {
266
            ACPI_ERROR ((AE_INFO, "Null stack entry at %p",
267
                StackPtr));
268
269
 
270
        }
271
272
 
273
274
 
275
276
 
277
278
 
279
        {
280
        case ACPI_DESC_TYPE_NAMED:
281
282
 
283
284
 
285
286
 
287
             * Resolve an alias object. The construction of these objects
288
             * guarantees that there is only one level of alias indirection;
289
             * thus, the attached object is always the aliased namespace node
290
             */
291
            if (ObjectType == ACPI_TYPE_LOCAL_ALIAS)
292
            {
293
                ObjDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) ObjDesc);
294
                *StackPtr = ObjDesc;
295
                ObjectType = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type;
296
            }
297
            break;
298
299
 
300
 
301
302
 
303
304
 
305
306
 
307
308
 
309
            {
310
                ACPI_ERROR ((AE_INFO,
311
                    "Bad operand object type [0x%X]", ObjectType));
312
313
 
314
            }
315
316
 
317
            {
318
                /* Validate the Reference */
319
320
 
321
                {
322
                case ACPI_REFCLASS_DEBUG:
323
324
 
325
326
 
327
328
 
329
                case ACPI_REFCLASS_LOCAL:
330
                case ACPI_REFCLASS_INDEX:
331
                case ACPI_REFCLASS_REFOF:
332
                case ACPI_REFCLASS_TABLE:    /* DdbHandle from LOAD_OP or LOAD_TABLE_OP */
333
                case ACPI_REFCLASS_NAME:     /* Reference to a named object */
334
335
 
336
                        "Operand is a Reference, Class [%s] %2.2X\n",
337
                        AcpiUtGetReferenceName (ObjDesc),
338
                        ObjDesc->Reference.Class));
339
                    break;
340
341
 
342
343
 
344
                        "Unknown Reference Class 0x%2.2X in %p",
345
                        ObjDesc->Reference.Class, ObjDesc));
346
347
 
348
                }
349
            }
350
            break;
351
352
 
353
 
354
355
 
356
357
 
358
                ObjDesc, AcpiUtGetDescriptorName (ObjDesc)));
359
360
 
361
        }
362
363
 
364
365
 
366
        INCREMENT_ARG_LIST (ArgTypes);
367
368
 
369
         * Handle cases where the object does not need to be
370
         * resolved to a value
371
         */
372
        switch (ThisArgType)
373
        {
374
        case ARGI_REF_OR_STRING:        /* Can be a String or Reference */
375
376
 
377
                (ObjDesc->Common.Type == ACPI_TYPE_STRING))
378
            {
379
                /*
380
                 * String found - the string references a named object and
381
                 * must be resolved to a node
382
                 */
383
                goto NextOperand;
384
            }
385
386
 
387
             * Else not a string - fall through to the normal Reference
388
             * case below
389
             */
390
            /*lint -fallthrough */
391
392
 
393
        case ARGI_INTEGER_REF:
394
        case ARGI_OBJECT_REF:
395
        case ARGI_DEVICE_REF:
396
        case ARGI_TARGETREF:     /* Allows implicit conversion rules before store */
397
        case ARGI_FIXED_TARGET:  /* No implicit conversion before store to target */
398
        case ARGI_SIMPLE_TARGET: /* Name, Local, or Arg - no implicit conversion  */
399
400
 
401
             * Need an operand of type ACPI_TYPE_LOCAL_REFERENCE
402
             * A Namespace Node is OK as-is
403
             */
404
            if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_NAMED)
405
            {
406
                goto NextOperand;
407
            }
408
409
 
410
                            ObjectType, ObjDesc);
411
            if (ACPI_FAILURE (Status))
412
            {
413
                return_ACPI_STATUS (Status);
414
            }
415
            goto NextOperand;
416
417
 
418
 
419
420
 
421
             * We don't want to resolve IndexOp reference objects during
422
             * a store because this would be an implicit DeRefOf operation.
423
             * Instead, we just want to store the reference object.
424
             * -- All others must be resolved below.
425
             */
426
            if ((Opcode == AML_STORE_OP) &&
427
                ((*StackPtr)->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) &&
428
                ((*StackPtr)->Reference.Class == ACPI_REFCLASS_INDEX))
429
            {
430
                goto NextOperand;
431
            }
432
            break;
433
434
 
435
            /* All cases covered above */
436
            break;
437
        }
438
439
 
440
         * Resolve this object to a value
441
         */
442
        Status = AcpiExResolveToValue (StackPtr, WalkState);
443
        if (ACPI_FAILURE (Status))
444
        {
445
            return_ACPI_STATUS (Status);
446
        }
447
448
 
449
450
 
451
452
 
453
         * Check the resulting object (value) type
454
         */
455
        switch (ThisArgType)
456
        {
457
        /*
458
         * For the simple cases, only one type of resolved object
459
         * is allowed
460
         */
461
        case ARGI_MUTEX:
462
463
 
464
465
 
466
            break;
467
468
 
469
470
 
471
472
 
473
            break;
474
475
 
476
477
 
478
479
 
480
            break;
481
482
 
483
484
 
485
486
 
487
            break;
488
489
 
490
491
 
492
493
 
494
            break;
495
496
 
497
 
498
         * The more complex cases allow multiple resolved object types
499
         */
500
        case ARGI_INTEGER:
501
502
 
503
             * Need an operand of type ACPI_TYPE_INTEGER,
504
             * But we can implicitly convert from a STRING or BUFFER
505
             * Aka - "Implicit Source Operand Conversion"
506
             */
507
            Status = AcpiExConvertToInteger (ObjDesc, StackPtr, 16);
508
            if (ACPI_FAILURE (Status))
509
            {
510
                if (Status == AE_TYPE)
511
                {
512
                    ACPI_ERROR ((AE_INFO,
513
                        "Needed [Integer/String/Buffer], found [%s] %p",
514
                        AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
515
516
 
517
                }
518
519
 
520
            }
521
522
 
523
            {
524
                AcpiUtRemoveReference (ObjDesc);
525
            }
526
            goto NextOperand;
527
528
 
529
 
530
531
 
532
             * Need an operand of type ACPI_TYPE_BUFFER,
533
             * But we can implicitly convert from a STRING or INTEGER
534
             * Aka - "Implicit Source Operand Conversion"
535
             */
536
            Status = AcpiExConvertToBuffer (ObjDesc, StackPtr);
537
            if (ACPI_FAILURE (Status))
538
            {
539
                if (Status == AE_TYPE)
540
                {
541
                    ACPI_ERROR ((AE_INFO,
542
                        "Needed [Integer/String/Buffer], found [%s] %p",
543
                        AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
544
545
 
546
                }
547
548
 
549
            }
550
551
 
552
            {
553
                AcpiUtRemoveReference (ObjDesc);
554
            }
555
            goto NextOperand;
556
557
 
558
 
559
560
 
561
             * Need an operand of type ACPI_TYPE_STRING,
562
             * But we can implicitly convert from a BUFFER or INTEGER
563
             * Aka - "Implicit Source Operand Conversion"
564
             */
565
            Status = AcpiExConvertToString (ObjDesc, StackPtr,
566
                        ACPI_IMPLICIT_CONVERT_HEX);
567
            if (ACPI_FAILURE (Status))
568
            {
569
                if (Status == AE_TYPE)
570
                {
571
                    ACPI_ERROR ((AE_INFO,
572
                        "Needed [Integer/String/Buffer], found [%s] %p",
573
                        AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
574
575
 
576
                }
577
578
 
579
            }
580
581
 
582
            {
583
                AcpiUtRemoveReference (ObjDesc);
584
            }
585
            goto NextOperand;
586
587
 
588
 
589
590
 
591
592
 
593
            {
594
            case ACPI_TYPE_INTEGER:
595
            case ACPI_TYPE_STRING:
596
            case ACPI_TYPE_BUFFER:
597
598
 
599
               break;
600
601
 
602
                ACPI_ERROR ((AE_INFO,
603
                    "Needed [Integer/String/Buffer], found [%s] %p",
604
                    AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
605
606
 
607
            }
608
            goto NextOperand;
609
610
 
611
 
612
613
 
614
615
 
616
            {
617
            case ACPI_TYPE_STRING:
618
            case ACPI_TYPE_BUFFER:
619
620
 
621
               break;
622
623
 
624
625
 
626
627
 
628
                if (ACPI_FAILURE (Status))
629
                {
630
                    return_ACPI_STATUS (Status);
631
                }
632
633
 
634
                {
635
                    AcpiUtRemoveReference (ObjDesc);
636
                }
637
                break;
638
639
 
640
                ACPI_ERROR ((AE_INFO,
641
                    "Needed [Integer/String/Buffer], found [%s] %p",
642
                    AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
643
644
 
645
            }
646
            goto NextOperand;
647
648
 
649
 
650
            /*
651
             * ARGI_DATAOBJECT is only used by the SizeOf operator.
652
             * Need a buffer, string, package, or RefOf reference.
653
             *
654
             * The only reference allowed here is a direct reference to
655
             * a namespace node.
656
             */
657
            switch (ObjDesc->Common.Type)
658
            {
659
            case ACPI_TYPE_PACKAGE:
660
            case ACPI_TYPE_STRING:
661
            case ACPI_TYPE_BUFFER:
662
            case ACPI_TYPE_LOCAL_REFERENCE:
663
664
 
665
                break;
666
667
 
668
                ACPI_ERROR ((AE_INFO,
669
                    "Needed [Buffer/String/Package/Reference], found [%s] %p",
670
                    AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
671
672
 
673
            }
674
            goto NextOperand;
675
676
 
677
 
678
679
 
680
681
 
682
            {
683
            case ACPI_TYPE_PACKAGE:
684
            case ACPI_TYPE_STRING:
685
            case ACPI_TYPE_BUFFER:
686
687
 
688
                break;
689
690
 
691
                ACPI_ERROR ((AE_INFO,
692
                    "Needed [Buffer/String/Package], found [%s] %p",
693
                    AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
694
695
 
696
            }
697
            goto NextOperand;
698
699
 
700
 
701
702
 
703
704
 
705
            {
706
            case ACPI_TYPE_BUFFER:
707
            case ACPI_TYPE_REGION:
708
709
 
710
                break;
711
712
 
713
                ACPI_ERROR ((AE_INFO,
714
                    "Needed [Region/Buffer], found [%s] %p",
715
                    AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
716
717
 
718
            }
719
            goto NextOperand;
720
721
 
722
 
723
724
 
725
726
 
727
            {
728
            case ACPI_TYPE_INTEGER:
729
            case ACPI_TYPE_PACKAGE:
730
            case ACPI_TYPE_STRING:
731
            case ACPI_TYPE_BUFFER:
732
            case ACPI_TYPE_BUFFER_FIELD:
733
            case ACPI_TYPE_LOCAL_REFERENCE:
734
            case ACPI_TYPE_LOCAL_REGION_FIELD:
735
            case ACPI_TYPE_LOCAL_BANK_FIELD:
736
            case ACPI_TYPE_LOCAL_INDEX_FIELD:
737
            case ACPI_TYPE_DDB_HANDLE:
738
739
 
740
                break;
741
742
 
743
744
 
745
                {
746
                    /*
747
                     * Enable original behavior of Store(), allowing any and all
748
                     * objects as the source operand.  The ACPI spec does not
749
                     * allow this, however.
750
                     */
751
                    break;
752
                }
753
754
 
755
                {
756
                    /* Allow store of any object to the Debug object */
757
758
 
759
                }
760
761
 
762
                    "Needed Integer/Buffer/String/Package/Ref/Ddb], found [%s] %p",
763
                    AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
764
765
 
766
            }
767
            goto NextOperand;
768
769
 
770
 
771
772
 
773
774
 
775
                "Internal - Unknown ARGI (required operand) type 0x%X",
776
                ThisArgType));
777
778
 
779
        }
780
781
 
782
         * Make sure that the original object was resolved to the
783
         * required object type (Simple cases only).
784
         */
785
        Status = AcpiExCheckObjectType (TypeNeeded,
786
                        (*StackPtr)->Common.Type, *StackPtr);
787
        if (ACPI_FAILURE (Status))
788
        {
789
            return_ACPI_STATUS (Status);
790
        }
791
792
 
793
        /*
794
         * If more operands needed, decrement StackPtr to point
795
         * to next operand on stack
796
         */
797
        if (GET_CURRENT_ARG_TYPE (ArgTypes))
798
        {
799
            StackPtr--;
800
        }
801
    }
802
803
 
804
        AcpiPsGetOpcodeName (Opcode), WalkState->NumOperands);
805
806
 
807
}
808