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
29Name(z155, 155)
30
31/*
32 * Three tests below are here
33 * as specific type arguments passing -
34 * arguments though passed directly to method, not as references,
35 * nevertheless allow access to the elements of original objects.
36 */
37
38Method(m100,, Serialized)
39{
40	Name(ts, "m100")
41	Name(p000, Package() {0xabcd0000, 0xabcd0001, 0xabcd0002})
42	Method(m001, 2)
43	{
44		Store(0x11112222, Index(arg0, 0))
45	}
46
47	m001(p000, RefOf(p000))
48
49	Store(DerefOf(Index(p000, 0)), Local0)
50
51	if (LNotEqual(Local0, 0x11112222)) {
52		err(ts, z155, 0x000, 0, 0, Local0, 0x11112222)
53	}
54
55	CH03(ts, z155, 0x001, 0, 0)
56}
57
58Method(m101,, Serialized)
59{
60	Name(ts, "m101")
61	Name(b000, Buffer() {0x10, 0x11, 0x12})
62	Method(m001, 2)
63	{
64		Store(0x67, Index(arg0, 0))
65	}
66
67	m001(b000, RefOf(b000))
68
69	Store(DerefOf(Index(b000, 0)), Local0)
70
71	if (LNotEqual(Local0, 0x67)) {
72		err(ts, z155, 0x002, 0, 0, Local0, 0x67)
73	}
74
75	CH03(ts, z155, 0x003, 0, 0)
76}
77
78Method(m102,, Serialized)
79{
80	Name(ts, "m102")
81	Name(s000, "qqqqqqqqqqqqqq")
82	Method(m001, 2)
83	{
84		Store(0x38, Index(arg0, 0))
85	}
86
87	m001(s000, RefOf(s000))
88
89	Store(DerefOf(Index(s000, 0)), Local0)
90
91	if (LNotEqual(Local0, 0x38)) {
92		err(ts, z155, 0x004, 0, 0, Local0, 0x38)
93	}
94
95	CH03(ts, z155, 0x005, 0, 0)
96}
97
98/*
99 * Element of Package instead of i000 (in m001)
100 */
101Method(m103, 1, Serialized)
102{
103	Name(ts, "m103")
104	Name(i001, 0)
105	Name(p000, Package() {1,2,3,4})
106	Name(pp00, Package() {0x11111111, 0x00000001, 0x22223333})
107
108	CH03(ts, z155, 0x006, 0, 0)
109
110	Store(arg0, i001)
111
112	Method(m001)
113	{
114		Method(m002)
115		{
116			Method(m003)
117			{
118				Method(m004)
119				{
120					Method(m005)
121					{
122						Method(m006)
123						{
124							Method(m007)
125							{
126								Method(m008)
127								{
128									if (i001)
129									{
130										Store(p000, Index(pp00, 1))
131									}
132									Return (0)
133								}
134								Store(0x80000000, Index(pp00, 1))
135								Return (Add(DerefOf(Index(pp00, 1)), m008()))
136							}
137							Store(0x07000000, Index(pp00, 1))
138							Return (Add(DerefOf(Index(pp00, 1)), m007()))
139						}
140						Store(0x00600000, Index(pp00, 1))
141						Return (Add(DerefOf(Index(pp00, 1)), m006()))
142					}
143					Store(0x00050000, Index(pp00, 1))
144					Return (Add(DerefOf(Index(pp00, 1)), m005()))
145				}
146				Store(0x00004000, Index(pp00, 1))
147				Return (Add(DerefOf(Index(pp00, 1)), m004()))
148			}
149			Store(0x00000300, Index(pp00, 1))
150			Return (Add(DerefOf(Index(pp00, 1)), m003()))
151		}
152		Store(0x00000020, Index(pp00, 1))
153		Return (Add(DerefOf(Index(pp00, 1)), m002()))
154	}
155	Store(Add(DerefOf(Index(pp00, 1)), m001()), Local0)
156
157	if (LNotEqual(Local0, 0x87654321)) {
158		err(ts, z155, 0x007, 0, 0, Local0, 0x87654321)
159	}
160
161	Store(DerefOf(Index(pp00, 1)), Local0)
162
163	if (LNotEqual(Local0, 0x80000000)) {
164		err(ts, z155, 0x008, 0, 0, Local0, 0x80000000)
165	}
166
167	CH03(ts, z155, 0x009, 0, 0)
168}
169
170/*
171 * Element of Package instead of i000 (in m002)
172 */
173Method(m104,, Serialized)
174{
175	Name(ts, "m104")
176	Name(i001, 0)
177	Name(pp00, Package() {0x11111111, 0x00100000, 0x22223333})
178
179	Method(m001)
180	{
181		if (LLess(i001, 100)) {
182
183			Store(DerefOf(Index(pp00, 1)), Local0)
184			Increment(Local0)
185			Store(Local0, Index(pp00, 1))
186			Increment(i001)
187			Add(DerefOf(Index(pp00, 1)), m001(), Local0)
188			Return (Local0)
189		}
190		Return (0)
191	}
192	Store(Add(DerefOf(Index(pp00, 1)), m001()), Local0)
193
194	if (LNotEqual(Local0, 0x065013BA)) {
195		err(ts, z155, 0x00a, 0, 0, Local0, 0x065013BA)
196	}
197
198	Store(DerefOf(Index(pp00, 1)), Local0)
199
200	if (LNotEqual(Local0, 0x00100064)) {
201		err(ts, z155, 0x00b, 0, 0, Local0, 0x00100064)
202	}
203
204	CH03(ts, z155, 0x00c, 0, 0)
205}
206
207/*
208 * Buffer Field instead of i000 (in m001)
209 */
210Method(m105, 1, Serialized)
211{
212	Name(ts, "m105")
213	Name(i001, 0)
214	Name(b000, Buffer(16) {})
215	CreateField(b000, 5, 32, bf00)
216
217	CH03(ts, z155, 0x00d, 0, 0)
218
219	Store(arg0, i001)
220
221	Method(m001)
222	{
223		Method(m002)
224		{
225			Method(m003)
226			{
227				Method(m004)
228				{
229					Method(m005)
230					{
231						Method(m006)
232						{
233							Method(m007)
234							{
235								Method(m008)
236								{
237									if (i001)
238									{
239										Store(0x11223344, bf00)
240									}
241									Return (0)
242								}
243								Store(0x80000000, bf00)
244								Return (Add(bf00, m008()))
245							}
246							Store(0x07000000, bf00)
247							Return (Add(bf00, m007()))
248						}
249						Store(0x00600000, bf00)
250						Return (Add(bf00, m006()))
251					}
252					Store(0x00050000, bf00)
253					Return (Add(bf00, m005()))
254				}
255				Store(0x00004000, bf00)
256				Return (Add(bf00, m004()))
257			}
258			Store(0x00000300, bf00)
259			Return (Add(bf00, m003()))
260		}
261		Store(0x00000020, bf00)
262		Return (Add(bf00, m002()))
263	}
264
265	Store(0x00000001, bf00)
266
267	Store(Add(bf00, m001()), Local0)
268
269	if (LNotEqual(Local0, 0x87654321)) {
270		err(ts, z155, 0x00e, 0, 0, Local0, 0x87654321)
271	}
272
273	if (arg0) {
274		Store(0x11223344, Local1)
275	} else {
276		Store(0x80000000, Local1)
277	}
278
279	if (LNotEqual(bf00, Local1)) {
280		err(ts, z155, 0x00f, 0, 0, bf00, Local1)
281	}
282
283	CH03(ts, z155, 0x010, 0, 0)
284}
285
286/*
287 * Field instead of i000 (in m001)
288 */
289Method(m106, 1, Serialized)
290{
291	Name(ts, "m106")
292	Name(i001, 0)
293	OperationRegion(r000, SystemMemory, 0x100, 0x100)
294	Field(r000, ByteAcc, NoLock, Preserve) { f000,32, f001,32 }
295
296	CH03(ts, z155, 0x011, 0, 0)
297
298	Store(arg0, i001)
299
300	Method(m001)
301	{
302		Method(m002)
303		{
304			Method(m003)
305			{
306				Method(m004)
307				{
308					Method(m005)
309					{
310						Method(m006)
311						{
312							Method(m007)
313							{
314								Method(m008)
315								{
316									if (i001)
317									{
318										Store(0x11223344, f001)
319									}
320									Return (0)
321								}
322								Store(0x80000000, f001)
323								Return (Add(f001, m008()))
324							}
325							Store(0x07000000, f001)
326							Return (Add(f001, m007()))
327						}
328						Store(0x00600000, f001)
329						Return (Add(f001, m006()))
330					}
331					Store(0x00050000, f001)
332					Return (Add(f001, m005()))
333				}
334				Store(0x00004000, f001)
335				Return (Add(f001, m004()))
336			}
337			Store(0x00000300, f001)
338			Return (Add(f001, m003()))
339		}
340		Store(0x00000020, f001)
341		Return (Add(f001, m002()))
342	}
343
344	Store(0x00000001, f001)
345
346	Store(Add(f001, m001()), Local0)
347
348	if (LNotEqual(Local0, 0x87654321)) {
349		err(ts, z155, 0x012, 0, 0, Local0, 0x87654321)
350	}
351
352	if (arg0) {
353		Store(0x11223344, Local1)
354	} else {
355		Store(0x80000000, Local1)
356	}
357
358	if (LNotEqual(f001, Local1)) {
359		err(ts, z155, 0x013, 0, 0, f001, Local1)
360	}
361
362	CH03(ts, z155, 0x014, 0, 0)
363}
364
365/*
366 * Bank Field instead of i000 (in m001)
367 *
368 * (is this test correct?)
369 */
370Method(m107, 1, Serialized)
371{
372	Name(ts, "m107")
373	Name(i001, 0)
374	OperationRegion(r000, SystemMemory, 0x100, 0x100)
375	Field(r000, ByteAcc, NoLock, Preserve) { f000,32, f001,32 }
376	BankField(r000, f001, 0, ByteAcc, NoLock, Preserve) { bnk0, 32 }
377
378	CH03(ts, z155, 0x015, 0, 0)
379
380	Store(arg0, i001)
381
382	Method(m001)
383	{
384		Method(m002)
385		{
386			Method(m003)
387			{
388				Method(m004)
389				{
390					Method(m005)
391					{
392						Method(m006)
393						{
394							Method(m007)
395							{
396								Method(m008)
397								{
398									if (i001)
399									{
400										Store(0x11223344, bnk0)
401									}
402									Return (0)
403								}
404								Store(0x80000000, bnk0)
405								Return (Add(bnk0, m008()))
406							}
407							Store(0x07000000, bnk0)
408							Return (Add(bnk0, m007()))
409						}
410						Store(0x00600000, bnk0)
411						Return (Add(bnk0, m006()))
412					}
413					Store(0x00050000, bnk0)
414					Return (Add(bnk0, m005()))
415				}
416				Store(0x00004000, bnk0)
417				Return (Add(bnk0, m004()))
418			}
419			Store(0x00000300, bnk0)
420			Return (Add(bnk0, m003()))
421		}
422		Store(0x00000020, bnk0)
423		Return (Add(bnk0, m002()))
424	}
425
426	Store(0x00000001, bnk0)
427
428	Store(Add(bnk0, m001()), Local0)
429
430	if (LNotEqual(Local0, 0x87654321)) {
431		err(ts, z155, 0x016, 0, 0, Local0, 0x87654321)
432	}
433
434	if (arg0) {
435		Store(0x11223344, Local1)
436	} else {
437		Store(0x80000000, Local1)
438	}
439
440	if (LNotEqual(bnk0, Local1)) {
441		err(ts, z155, 0x017, 0, 0, bnk0, Local1)
442	}
443
444	CH03(ts, z155, 0x018, 0, 0)
445}
446
447/*
448 * Index Field instead of i000 (in m001)
449 *
450 * (is this test correct?)
451 */
452Method(m108, 1, Serialized)
453{
454	Name(ts, "m108")
455	Name(i001, 0)
456	OperationRegion(r000, SystemMemory, 0x100, 0x100)
457	Field(r000, ByteAcc, NoLock, Preserve) { f000,32, f001,32 }
458	IndexField(f000, f001, ByteAcc, NoLock, Preserve) { if00, 32 }
459
460	CH03(ts, z155, 0x019, 0, 0)
461
462	Store(arg0, i001)
463
464	Method(m001)
465	{
466		Method(m002)
467		{
468			Method(m003)
469			{
470				Method(m004)
471				{
472					Method(m005)
473					{
474						Method(m006)
475						{
476							Method(m007)
477							{
478								Method(m008)
479								{
480									if (i001)
481									{
482										Store(0x11223344, if00)
483									}
484									Return (0)
485								}
486								Store(0x80000000, if00)
487								Return (Add(if00, m008()))
488							}
489							Store(0x07000000, if00)
490							Return (Add(if00, m007()))
491						}
492						Store(0x00600000, if00)
493						Return (Add(if00, m006()))
494					}
495					Store(0x00050000, if00)
496					Return (Add(if00, m005()))
497				}
498				Store(0x00004000, if00)
499				Return (Add(if00, m004()))
500			}
501			Store(0x00000300, if00)
502			Return (Add(if00, m003()))
503		}
504		Store(0x00000020, if00)
505		Return (Add(if00, m002()))
506	}
507
508	Store(0x00000001, if00)
509
510	Store(Add(if00, m001()), Local0)
511
512	if (LNotEqual(Local0, 0x87654321)) {
513		err(ts, z155, 0x01a, 0, 0, Local0, 0x87654321)
514	}
515
516	if (arg0) {
517		Store(0x11223344, Local1)
518	} else {
519		Store(0x80000000, Local1)
520	}
521
522	if (LNotEqual(if00, Local1)) {
523		err(ts, z155, 0x01b, 0, 0, if00, Local1)
524	}
525
526	CH03(ts, z155, 0x01c, 0, 0)
527}
528
529/*
530 * Element of Buffer instead of i000 (in m001)
531 */
532Method(m109, 1, Serialized)
533{
534	Name(ts, "m109")
535	Name(i001, 0)
536	Name(b000, Buffer() {0x11, 0x01, 0x22})
537
538	CH03(ts, z155, 0x01d, 0, 0)
539
540	Store(arg0, i001)
541
542	Method(m001)
543	{
544		Method(m002)
545		{
546			Method(m003)
547			{
548				Method(m004)
549				{
550					Method(m005)
551					{
552						Method(m006)
553						{
554							Method(m007)
555							{
556								Method(m008)
557								{
558									if (i001)
559									{
560										Store(0xff, Index(b000, 1))
561									}
562									Return (0)
563								}
564								Store(0x08, Index(b000, 1))
565								Return (Add(DerefOf(Index(b000, 1)), m008()))
566							}
567							Store(0x07, Index(b000, 1))
568							Return (Add(DerefOf(Index(b000, 1)), m007()))
569						}
570						Store(0x06, Index(b000, 1))
571						Return (Add(DerefOf(Index(b000, 1)), m006()))
572					}
573					Store(0x05, Index(b000, 1))
574					Return (Add(DerefOf(Index(b000, 1)), m005()))
575				}
576				Store(0x04, Index(b000, 1))
577				Return (Add(DerefOf(Index(b000, 1)), m004()))
578			}
579			Store(0x03, Index(b000, 1))
580			Return (Add(DerefOf(Index(b000, 1)), m003()))
581		}
582		Store(0x02, Index(b000, 1))
583		Return (Add(DerefOf(Index(b000, 1)), m002()))
584	}
585	Store(Add(DerefOf(Index(b000, 1)), m001()), Local0)
586
587	if (LNotEqual(Local0, 0x24)) {
588		err(ts, z155, 0x01e, 0, 0, Local0, 0x24)
589	}
590
591	Store(DerefOf(Index(b000, 1)), Local0)
592
593	if (arg0) {
594		Store(0xff, Local1)
595	} else {
596		Store(0x08, Local1)
597	}
598
599	if (LNotEqual(Local0, Local1)) {
600		err(ts, z155, 0x01f, 0, 0, Local0, Local1)
601	}
602
603	CH03(ts, z155, 0x020, 0, 0)
604}
605
606/*
607 * Element of String instead of i000 (in m001)
608 */
609Method(m10a, 1, Serialized)
610{
611	Name(ts, "m10a")
612	Name(i001, 0)
613	Name(s000, "q\001ertyuiop")
614
615	CH03(ts, z155, 0x021, 0, 0)
616
617	Store(arg0, i001)
618
619	Method(m001)
620	{
621		Method(m002)
622		{
623			Method(m003)
624			{
625				Method(m004)
626				{
627					Method(m005)
628					{
629						Method(m006)
630						{
631							Method(m007)
632							{
633								Method(m008)
634								{
635									if (i001)
636									{
637										Store(0xff, Index(s000, 1))
638									}
639									Return (0)
640								}
641								Store(0x08, Index(s000, 1))
642								Return (Add(DerefOf(Index(s000, 1)), m008()))
643							}
644							Store(0x07, Index(s000, 1))
645							Return (Add(DerefOf(Index(s000, 1)), m007()))
646						}
647						Store(0x06, Index(s000, 1))
648						Return (Add(DerefOf(Index(s000, 1)), m006()))
649					}
650					Store(0x05, Index(s000, 1))
651					Return (Add(DerefOf(Index(s000, 1)), m005()))
652				}
653				Store(0x04, Index(s000, 1))
654				Return (Add(DerefOf(Index(s000, 1)), m004()))
655			}
656			Store(0x03, Index(s000, 1))
657			Return (Add(DerefOf(Index(s000, 1)), m003()))
658		}
659		Store(0x02, Index(s000, 1))
660		Return (Add(DerefOf(Index(s000, 1)), m002()))
661	}
662	Store(Add(DerefOf(Index(s000, 1)), m001()), Local0)
663
664	if (LNotEqual(Local0, 0x24)) {
665		err(ts, z155, 0x022, 0, 0, Local0, 0x24)
666	}
667
668	Store(DerefOf(Index(s000, 1)), Local0)
669
670	if (arg0) {
671		Store(0xff, Local1)
672	} else {
673		Store(0x08, Local1)
674	}
675
676	if (LNotEqual(Local0, Local1)) {
677		err(ts, z155, 0x023, 0, 0, Local0, Local1)
678	}
679
680	CH03(ts, z155, 0x024, 0, 0)
681}
682
683Method(n001)
684{
685if (1) {
686	SRMT("m100")
687	m100()
688	SRMT("m101")
689	m101()
690	SRMT("m102")
691	m102()
692	SRMT("m103-0")
693	m103(0)
694	SRMT("m103-1")
695	if (y200) {
696		m103(1)
697	} else {
698		BLCK()
699	}
700	SRMT("m104")
701	m104()
702	SRMT("m105-0")
703	m105(0)
704	SRMT("m105-1")
705	m105(1)
706	SRMT("m106-0")
707	m106(0)
708	SRMT("m106-1")
709	m106(1)
710	SRMT("m107-0")
711	m107(0)
712	SRMT("m107-1")
713	m107(1)
714	SRMT("m108-0")
715	m108(0)
716	SRMT("m108-1")
717	m108(1)
718	SRMT("m109-0")
719	m109(0)
720	SRMT("m109-1")
721	m109(1)
722	SRMT("m10a-0")
723	m10a(0)
724	SRMT("m10a-1")
725	m10a(1)
726	SRMT("m10a-0-2") // Run it twice: see bug 265
727	m10a(0)
728	m10a(0)
729} else {
730	SRMT("m10a-0")
731	m10a(0)
732	SRMT("m10a-1")
733	m10a(0)
734}
735}
736
737