1    /*
2     * Some or all of this work - Copyright (c) 2006 - 2021, Intel Corp.
3     * All rights reserved.
4     *
5     * Redistribution and use in source and binary forms, with or without modification,
6     * are permitted provided that the following conditions are met:
7     *
8     * Redistributions of source code must retain the above copyright notice,
9     * this list of conditions and the following disclaimer.
10     * Redistributions in binary form must reproduce the above copyright notice,
11     * this list of conditions and the following disclaimer in the documentation
12     * and/or other materials provided with the distribution.
13     * Neither the name of Intel Corporation nor the names of its contributors
14     * may be used to endorse or promote products derived from this software
15     * without specific prior written permission.
16     *
17     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19     * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20     * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21     * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22     * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23     * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24     * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25     * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27     */
28    /*
29     * Bug 115:
30     *
31     * SUMMARY: Unexpected dereference of Index reference returned by Method and immediately passed to another Method
32     */
33    Method (ME7E, 2, NotSerialized)
34    {
35        Debug = Arg0
36        Arg0 = Arg1
37    }
38
39    Method (ME7F, 0, NotSerialized)
40    {
41        Return (PD04 [0x00])
42    }
43
44    Method (ME80, 0, NotSerialized)
45    {
46        Store (PD05 [0x00], Local0)
47        Return (Local0)
48    }
49
50    Method (ME81, 0, NotSerialized)
51    {
52        Return (Local0 = PD06 [0x00])
53    }
54
55    Method (ME82, 0, NotSerialized)
56    {
57        Local0 = PD07 [0x00]
58        Return (Local0)
59    }
60
61    Method (ME83, 0, NotSerialized)
62    {
63        Local1 = Local0 = PD08 [0x00]
64        Return (Local0)
65    }
66
67    Method (ME84, 0, NotSerialized)
68    {
69        Local1 = Local0 = PD09 [0x00]
70        Return (Local1)
71    }
72
73    Method (ME85, 0, NotSerialized)
74    {
75        Return (RefOf (ID10))
76    }
77
78    Method (ME86, 0, Serialized)
79    {
80        Name (PRN0, 0x00)
81        /* To show: the RefOf reference is actually passed to method (Ok) */
82
83        If (PRN0)
84        {
85            Debug = ME85 ()
86        }
87
88        Local0 = 0xABCD0000
89        ME7E (ME85 (), Local0)
90        If ((ID10 != Local0))
91        {
92            ERR (__METHOD__, ZFFF, __LINE__, 0x00, 0x00, ID10, Local0)
93        }
94
95        /* To show: all methods return Index references (Ok) */
96
97        If (PRN0)
98        {
99            Debug = ME7F ()
100            Debug = ME80 ()
101            Debug = ME81 ()
102            Debug = ME82 ()
103            Debug = ME83 ()
104            Debug = ME84 ()
105        }
106
107        /* To show: passed to methods are objects but */
108        /* not Index references to them as expected (Bug) */
109        Local0 = 0xABCD0001
110        ME7E (ME7F (), Local0)
111        Local1 = DerefOf (PD04 [0x00])
112        If ((Local1 != Local0))
113        {
114            ERR (__METHOD__, ZFFF, __LINE__, 0x00, 0x00, Local1, Local0)
115        }
116
117        Local0 = 0xABCD0002
118        ME7E (ME80 (), Local0)
119        Local1 = DerefOf (PD05 [0x00])
120        If ((Local1 != Local0))
121        {
122            ERR (__METHOD__, ZFFF, __LINE__, 0x00, 0x00, Local1, Local0)
123        }
124
125        Local0 = 0xABCD0003
126        ME7E (ME81 (), Local0)
127        Local1 = DerefOf (PD06 [0x00])
128        If ((Local1 != Local0))
129        {
130            ERR (__METHOD__, ZFFF, __LINE__, 0x00, 0x00, Local1, Local0)
131        }
132
133        Local0 = 0xABCD0004
134        ME7E (ME82 (), Local0)
135        Local1 = DerefOf (PD07 [0x00])
136        If ((Local1 != Local0))
137        {
138            ERR (__METHOD__, ZFFF, __LINE__, 0x00, 0x00, Local1, Local0)
139        }
140
141        Local0 = 0xABCD0005
142        ME7E (ME83 (), Local0)
143        Local1 = DerefOf (PD08 [0x00])
144        If ((Local1 != Local0))
145        {
146            ERR (__METHOD__, ZFFF, __LINE__, 0x00, 0x00, Local1, Local0)
147        }
148
149        Local0 = 0xABCD0006
150        ME7E (ME84 (), Local0)
151        Local1 = DerefOf (PD09 [0x00])
152        If ((Local1 != Local0))
153        {
154            ERR (__METHOD__, ZFFF, __LINE__, 0x00, 0x00, Local1, Local0)
155        }
156    }
157