1/*
2 * Some or all of this work - Copyright (c) 2006 - 2016, 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/*
30 * Trying to get the chain of calls of methods such that
31 * sections of operative stack corresponding to different
32 * methods contain the internal object (itself, not a RefOf
33 * reference to it) of the same Name Space node.
34 *
35 * Then force (by Store/CopyObject):
36 *   1) changing the value of that internal object
37 *   2) replacing the internal object itself by some another one
38 *
39 * Check that the changing/replacing has no effect on the
40 * values evaluated on the lowest stages of calculation.
41 */
42Name(z154, 154)
43
44/*
45 * Named Integer i000
46 */
47
48Method(m000, 1, Serialized)
49{
50	Name(ts, "m000")
51	Name(i000, 0x00000001)
52	Name(p000, Package() {1,2,3,4})
53
54	Name(i001, 0)
55
56	CH03(ts, z154, 0x000, 0, 0)
57
58	Store(arg0, i001)
59
60	Method(m001)
61	{
62		Method(m002)
63		{
64			Method(m003)
65			{
66				if (i001) {
67					CopyObject(p000, i000)
68				}
69				Return (0xabcd0000)
70			}
71			Return (Add(i000, m003()))
72		}
73		Return (Add(i000, m002()))
74	}
75	Store(Add(i000, m001()), Local0)
76	if (LNotEqual(Local0, 0xabcd0003)) {
77		err(ts, z154, 0x001, 0, 0, Local0, 0xabcd0003)
78	}
79	Store(Local0, Debug)
80
81	CH03(ts, z154, 0x002, 0, 0)
82}
83
84Method(m001, 1, Serialized)
85{
86	Name(ts, "m001")
87	Name(i000, 0x00000001)
88	Name(i001, 0)
89	Name(p000, Package() {1,2,3,4})
90
91	Store(arg0, i001)
92
93	Method(m001)
94	{
95		Method(m002)
96		{
97			Method(m003)
98			{
99				Method(m004)
100				{
101					Method(m005)
102					{
103						Method(m006)
104						{
105							Method(m007)
106							{
107								Method(m008)
108								{
109									if (i001)
110									{
111										CopyObject(p000, i000)
112									}
113									Return (0)
114								}
115								Store(0x80000000, i000)
116								Return (Add(i000, m008()))
117							}
118							Store(0x07000000, i000)
119							Return (Add(i000, m007()))
120						}
121						Store(0x00600000, i000)
122						Return (Add(i000, m006()))
123					}
124					Store(0x00050000, i000)
125					Return (Add(i000, m005()))
126				}
127				Store(0x00004000, i000)
128				Return (Add(i000, m004()))
129			}
130			Store(0x00000300, i000)
131			Return (Add(i000, m003()))
132		}
133		Store(0x00000020, i000)
134		Return (Add(i000, m002()))
135	}
136	Store(Add(i000, m001()), Local0)
137
138	if (LNotEqual(Local0, 0x87654321)) {
139		err(ts, z154, 0x003, 0, 0, Local0, 0x87654321)
140	}
141
142	if (LNotEqual(i000, 0x80000000)) {
143		err(ts, z154, 0x004, 0, 0, i000, 0x80000000)
144	}
145
146	CH03(ts, z154, 0x005, 0, 0)
147}
148
149Method(m002,, Serialized)
150{
151	Name(ts, "m002")
152	Name(i000, 0x00100000)
153	Name(i001, 0)
154
155	Method(m001)
156	{
157		if (LLess(i001, 100)) {
158			Increment(i000)
159			Increment(i001)
160			Add(i000, m001(), Local0)
161			Return (Local0)
162		}
163		Return (0)
164	}
165	Store(Add(i000, m001()), Local0)
166
167	if (LNotEqual(Local0, 0x065013BA)) {
168		err(ts, z154, 0x006, 0, 0, Local0, 0x065013BA)
169	}
170
171	if (LNotEqual(i000, 0x00100064)) {
172		err(ts, z154, 0x007, 0, 0, i000, 0x00100064)
173	}
174
175	CH03(ts, z154, 0x008, 0, 0)
176}
177
178Method(m003,, Serialized)
179{
180	Name(ts, "m003")
181	Name(i000, 0x00100000)
182	Name(i001, 0)
183
184	Method(m001)
185	{
186		if (LLess(i001, 100)) {
187			Increment(i000)
188			Increment(i001)
189			Return (Add(i000, m001(), Local0))
190		}
191		Return (0)
192	}
193	Store(Add(i000, m001()), Local0)
194
195	if (LNotEqual(Local0, 0x065013BA)) {
196		err(ts, z154, 0x009, 0, 0, Local0, 0x065013BA)
197	}
198
199	if (LNotEqual(i000, 0x00100064)) {
200		err(ts, z154, 0x00a, 0, 0, i000, 0x00100064)
201	}
202
203	CH03(ts, z154, 0x00b, 0, 0)
204}
205
206/*
207 * Local instead of i000 (in m001)
208 */
209Method(m004, 1, Serialized)
210{
211	Name(ts, "m004")
212	Name(i001, 0)
213	Name(p000, Package() {1,2,3,4})
214
215	Store(arg0, i001)
216
217	Store(0x00000001, Local7)
218
219	Method(m001)
220	{
221		Method(m002)
222		{
223			Method(m003)
224			{
225				Method(m004)
226				{
227					Method(m005)
228					{
229						Method(m006)
230						{
231							Method(m007)
232							{
233								Method(m008)
234								{
235									if (i001)
236									{
237										CopyObject(p000, Local7)
238									}
239									Return (0)
240								}
241								Store(0x80000000, Local7)
242								Return (Add(Local7, m008()))
243							}
244							Store(0x07000000, Local7)
245							Return (Add(Local7, m007()))
246						}
247						Store(0x00600000, Local7)
248						Return (Add(Local7, m006()))
249					}
250					Store(0x00050000, Local7)
251					Return (Add(Local7, m005()))
252				}
253				Store(0x00004000, Local7)
254				Return (Add(Local7, m004()))
255			}
256			Store(0x00000300, Local7)
257			Return (Add(Local7, m003()))
258		}
259		Store(0x00000020, Local7)
260		Return (Add(Local7, m002()))
261	}
262	Store(Add(Local7, m001()), Local0)
263
264	if (LNotEqual(Local0, 0x87654321)) {
265		err(ts, z154, 0x00c, 0, 0, Local0, 0x87654321)
266	}
267
268	if (LNotEqual(Local7, 1)) {
269		err(ts, z154, 0x00d, 0, 0, Local7, 1)
270	}
271
272	CH03(ts, z154, 0x00e, 0, 0)
273}
274
275/*
276 * Arg instead of i000 (in m001)
277 */
278Method(m005, 2, Serialized)
279{
280	Name(ts, "m005")
281	Name(i001, 0)
282	Name(p000, Package() {1,2,3,4})
283
284	Store(arg0, i001)
285
286	Store(0x00000001, arg1)
287
288	Method(m001)
289	{
290		Method(m002)
291		{
292			Method(m003)
293			{
294				Method(m004)
295				{
296					Method(m005)
297					{
298						Method(m006)
299						{
300							Method(m007)
301							{
302								Method(m008)
303								{
304									if (i001)
305									{
306										CopyObject(p000, arg1)
307									}
308									Return (0)
309								}
310								Store(0x80000000, arg1)
311								Return (Add(arg1, m008()))
312							}
313							Store(0x07000000, arg1)
314							Return (Add(arg1, m007()))
315						}
316						Store(0x00600000, arg1)
317						Return (Add(arg1, m006()))
318					}
319					Store(0x00050000, arg1)
320					Return (Add(arg1, m005()))
321				}
322				Store(0x00004000, arg1)
323				Return (Add(arg1, m004()))
324			}
325			Store(0x00000300, arg1)
326			Return (Add(arg1, m003()))
327		}
328		Store(0x00000020, arg1)
329		Return (Add(arg1, m002()))
330	}
331	Store(Add(arg1, m001()), Local0)
332
333	if (LNotEqual(Local0, 0x87654321)) {
334		err(ts, z154, 0x00f, 0, 0, Local0, 0x87654321)
335	}
336
337	if (LNotEqual(arg1, 1)) {
338		err(ts, z154, 0x010, 0, 0, arg1, 1)
339	}
340
341	CH03(ts, z154, 0x011, 0, 0)
342}
343
344Method(n000)
345{
346if (1) {
347	SRMT("m000-0")
348	m000(0)
349	SRMT("m000-1")
350	m000(1)
351	SRMT("m001-0")
352	m001(0)
353	SRMT("m001-1")
354	if (y200) {
355		m001(1)
356	} else {
357		BLCK()
358	}
359	SRMT("m002")
360	m002()
361	SRMT("m003")
362	m003()
363	SRMT("m004-0")
364	m004(0)
365	SRMT("m004-1")
366	m004(1)
367	SRMT("m005-0")
368	m005(0, 0)
369	SRMT("m005-1")
370	m005(1, 0)
371} else {
372	SRMT("m000-0")
373	m000(0)
374	SRMT("m000-1")
375	m000(1)
376}
377}
378
379