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     * Trying to get the chain of calls of methods such that
30     * sections of operative stack corresponding to different
31     * methods contain the internal object (itself, not a RefOf
32     * reference to it) of the same Name Space node.
33     *
34     * Then force (by Store/CopyObject):
35     *   1) changing the value of that internal object
36     *   2) replacing the internal object itself by some another one
37     *
38     * Check that the changing/replacing has no effect on the
39     * values evaluated on the lowest stages of calculation.
40     */
41    Name (Z154, 0x9A)
42    /*
43     * Named Integer i000
44     */
45    Method (M000, 1, Serialized)
46    {
47        Name (I000, 0x01)
48        Name (P000, Package (0x04)
49        {
50            0x01,
51            0x02,
52            0x03,
53            0x04
54        })
55        Name (I001, 0x00)
56        CH03 (__METHOD__, Z154, __LINE__, 0x00, 0x00)
57        I001 = Arg0
58        Method (M001, 0, NotSerialized)
59        {
60            Method (M002, 0, NotSerialized)
61            {
62                Method (M003, 0, NotSerialized)
63                {
64                    If (I001)
65                    {
66                        CopyObject (P000, I000) /* \M000.I000 */
67                    }
68
69                    Return (0xABCD0000)
70                }
71
72                Return ((I000 + M003 ()))
73            }
74
75            Return ((I000 + M002 ()))
76        }
77
78        Store ((I000 + M001 ()), Local0)
79        If ((Local0 != 0xABCD0003))
80        {
81            ERR (__METHOD__, Z154, __LINE__, 0x00, 0x00, Local0, 0xABCD0003)
82        }
83
84        Debug = Local0
85        CH03 (__METHOD__, Z154, __LINE__, 0x00, 0x00)
86    }
87
88    Method (M001, 1, Serialized)
89    {
90        Name (I000, 0x01)
91        Name (I001, 0x00)
92        Name (P000, Package (0x04)
93        {
94            0x01,
95            0x02,
96            0x03,
97            0x04
98        })
99        I001 = Arg0
100        Method (M001, 0, NotSerialized)
101        {
102            Method (M002, 0, NotSerialized)
103            {
104                Method (M003, 0, NotSerialized)
105                {
106                    Method (M004, 0, NotSerialized)
107                    {
108                        Method (M005, 0, NotSerialized)
109                        {
110                            Method (M006, 0, NotSerialized)
111                            {
112                                Method (M007, 0, NotSerialized)
113                                {
114                                    Method (M008, 0, NotSerialized)
115                                    {
116                                        If (I001)
117                                        {
118                                            CopyObject (P000, I000) /* \M001.I000 */
119                                        }
120
121                                        Return (0x00)
122                                    }
123
124                                    I000 = 0x80000000
125                                    Return ((I000 + M008 ()))
126                                }
127
128                                I000 = 0x07000000
129                                Return ((I000 + M007 ()))
130                            }
131
132                            I000 = 0x00600000
133                            Return ((I000 + M006 ()))
134                        }
135
136                        I000 = 0x00050000
137                        Return ((I000 + M005 ()))
138                    }
139
140                    I000 = 0x4000
141                    Return ((I000 + M004 ()))
142                }
143
144                I000 = 0x0300
145                Return ((I000 + M003 ()))
146            }
147
148            I000 = 0x20
149            Return ((I000 + M002 ()))
150        }
151
152        Store ((I000 + M001 ()), Local0)
153        If ((Local0 != 0x87654321))
154        {
155            ERR (__METHOD__, Z154, __LINE__, 0x00, 0x00, Local0, 0x87654321)
156        }
157
158        If ((I000 != 0x80000000))
159        {
160            ERR (__METHOD__, Z154, __LINE__, 0x00, 0x00, I000, 0x80000000)
161        }
162
163        CH03 (__METHOD__, Z154, __LINE__, 0x00, 0x00)
164    }
165
166    Method (M002, 0, Serialized)
167    {
168        Name (I000, 0x00100000)
169        Name (I001, 0x00)
170        Method (M001, 0, NotSerialized)
171        {
172            If ((I001 < 0x64))
173            {
174                I000++
175                I001++
176                Local0 = (I000 + M001 ())
177                Return (Local0)
178            }
179
180            Return (0x00)
181        }
182
183        Store ((I000 + M001 ()), Local0)
184        If ((Local0 != 0x065013BA))
185        {
186            ERR (__METHOD__, Z154, __LINE__, 0x00, 0x00, Local0, 0x065013BA)
187        }
188
189        If ((I000 != 0x00100064))
190        {
191            ERR (__METHOD__, Z154, __LINE__, 0x00, 0x00, I000, 0x00100064)
192        }
193
194        CH03 (__METHOD__, Z154, __LINE__, 0x00, 0x00)
195    }
196
197    Method (M003, 0, Serialized)
198    {
199        Name (I000, 0x00100000)
200        Name (I001, 0x00)
201        Method (M001, 0, NotSerialized)
202        {
203            If ((I001 < 0x64))
204            {
205                I000++
206                I001++
207                Return (Local0 = (I000 + M001 ()))
208            }
209
210            Return (0x00)
211        }
212
213        Store ((I000 + M001 ()), Local0)
214        If ((Local0 != 0x065013BA))
215        {
216            ERR (__METHOD__, Z154, __LINE__, 0x00, 0x00, Local0, 0x065013BA)
217        }
218
219        If ((I000 != 0x00100064))
220        {
221            ERR (__METHOD__, Z154, __LINE__, 0x00, 0x00, I000, 0x00100064)
222        }
223
224        CH03 (__METHOD__, Z154, __LINE__, 0x00, 0x00)
225    }
226
227    /*
228     * Local instead of i000 (in m001)
229     */
230    Method (M004, 1, Serialized)
231    {
232        Name (I001, 0x00)
233        Name (P000, Package (0x04)
234        {
235            0x01,
236            0x02,
237            0x03,
238            0x04
239        })
240        I001 = Arg0
241        Local7 = 0x01
242        Method (M001, 0, NotSerialized)
243        {
244            Method (M002, 0, NotSerialized)
245            {
246                Method (M003, 0, NotSerialized)
247                {
248                    Method (M004, 0, NotSerialized)
249                    {
250                        Method (M005, 0, NotSerialized)
251                        {
252                            Method (M006, 0, NotSerialized)
253                            {
254                                Method (M007, 0, NotSerialized)
255                                {
256                                    Method (M008, 0, NotSerialized)
257                                    {
258                                        If (I001)
259                                        {
260                                            CopyObject (P000, Local7)
261                                        }
262
263                                        Return (0x00)
264                                    }
265
266                                    Local7 = 0x80000000
267                                    Return ((Local7 + M008 ()))
268                                }
269
270                                Local7 = 0x07000000
271                                Return ((Local7 + M007 ()))
272                            }
273
274                            Local7 = 0x00600000
275                            Return ((Local7 + M006 ()))
276                        }
277
278                        Local7 = 0x00050000
279                        Return ((Local7 + M005 ()))
280                    }
281
282                    Local7 = 0x4000
283                    Return ((Local7 + M004 ()))
284                }
285
286                Local7 = 0x0300
287                Return ((Local7 + M003 ()))
288            }
289
290            Local7 = 0x20
291            Return ((Local7 + M002 ()))
292        }
293
294        Store ((Local7 + M001 ()), Local0)
295        If ((Local0 != 0x87654321))
296        {
297            ERR (__METHOD__, Z154, __LINE__, 0x00, 0x00, Local0, 0x87654321)
298        }
299
300        If ((Local7 != 0x01))
301        {
302            ERR (__METHOD__, Z154, __LINE__, 0x00, 0x00, Local7, 0x01)
303        }
304
305        CH03 (__METHOD__, Z154, __LINE__, 0x00, 0x00)
306    }
307
308    /*
309     * Arg instead of i000 (in m001)
310     */
311    Method (M005, 2, Serialized)
312    {
313        Name (I001, 0x00)
314        Name (P000, Package (0x04)
315        {
316            0x01,
317            0x02,
318            0x03,
319            0x04
320        })
321        I001 = Arg0
322        Arg1 = 0x01
323        Method (M001, 0, NotSerialized)
324        {
325            Method (M002, 0, NotSerialized)
326            {
327                Method (M003, 0, NotSerialized)
328                {
329                    Method (M004, 0, NotSerialized)
330                    {
331                        Method (M005, 0, NotSerialized)
332                        {
333                            Method (M006, 0, NotSerialized)
334                            {
335                                Method (M007, 0, NotSerialized)
336                                {
337                                    Method (M008, 0, NotSerialized)
338                                    {
339                                        If (I001)
340                                        {
341                                            CopyObject (P000, Arg1)
342                                        }
343
344                                        Return (0x00)
345                                    }
346
347                                    Arg1 = 0x80000000
348                                    Return ((Arg1 + M008 ()))
349                                }
350
351                                Arg1 = 0x07000000
352                                Return ((Arg1 + M007 ()))
353                            }
354
355                            Arg1 = 0x00600000
356                            Return ((Arg1 + M006 ()))
357                        }
358
359                        Arg1 = 0x00050000
360                        Return ((Arg1 + M005 ()))
361                    }
362
363                    Arg1 = 0x4000
364                    Return ((Arg1 + M004 ()))
365                }
366
367                Arg1 = 0x0300
368                Return ((Arg1 + M003 ()))
369            }
370
371            Arg1 = 0x20
372            Return ((Arg1 + M002 ()))
373        }
374
375        Store ((Arg1 + M001 ()), Local0)
376        If ((Local0 != 0x87654321))
377        {
378            ERR (__METHOD__, Z154, __LINE__, 0x00, 0x00, Local0, 0x87654321)
379        }
380
381        If ((Arg1 != 0x01))
382        {
383            ERR (__METHOD__, Z154, __LINE__, 0x00, 0x00, Arg1, 0x01)
384        }
385
386        CH03 (__METHOD__, Z154, __LINE__, 0x00, 0x00)
387    }
388
389    Method (N000, 0, NotSerialized)
390    {
391        If (0x01)
392        {
393            SRMT ("m000-0")
394            M000 (0x00)
395            SRMT ("m000-1")
396            M000 (0x01)
397            SRMT ("m001-0")
398            M001 (0x00)
399            SRMT ("m001-1")
400            If (Y200)
401            {
402                M001 (0x01)
403            }
404            Else
405            {
406                BLCK ()
407            }
408
409            SRMT ("m002")
410            M002 ()
411            SRMT ("m003")
412            M003 ()
413            SRMT ("m004-0")
414            M004 (0x00)
415            SRMT ("m004-1")
416            M004 (0x01)
417            SRMT ("m005-0")
418            M005 (0x00, 0x00)
419            SRMT ("m005-1")
420            M005 (0x01, 0x00)
421        }
422        Else
423        {
424            SRMT ("m000-0")
425            M000 (0x00)
426            SRMT ("m000-1")
427            M000 (0x01)
428        }
429    }
430