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/*
30 * Method invocations do add layers of Packages processing
31 *
32 * 0x1 Outstanding allocations because of
33 * AcpiExec doesn't run the unload of the table have been processed.
34 * All they are caused by call to SRMT Method.
35 *
36 * Outstanding: 0x1 allocations after execution.
37 */
38
39/*
40 * Web of references performed by several method invocations
41 */
42Method(mfd9,, Serialized)
43{
44	Name(sz, 32)	// full size of Package applied in algorithm
45	Name(szzz, 64)	// full size of Package
46	Name(prt, 16)	// number of different parts
47	Name(nm16, 0)	// 1/16 of size
48	Name(i1, 0)		// 1/16 of size
49	Name(i2, 0)		// 2/16 of size
50	Name(i3, 0)
51	Name(i4, 0)
52	Name(i5, 0)
53	Name(i6, 0)
54	Name(i8, 0)
55	Name(i9, 0)
56	Name(i10, 0)
57	Name(i11, 0)
58	Name(i12, 0)
59	Name(i13, 0)
60	Name(i14, 0)
61	Name(i16, 0)
62
63	Name(p000, Package(szzz) {})
64	Name(p001, Package(szzz) {})
65	Name(p002, Package(szzz) {})
66	Name(p003, Package(szzz) {})
67	Name(p004, Package(szzz) {})
68	Name(p005, Package(szzz) {})
69	Name(p006, Package(szzz) {})
70	Name(p007, Package(szzz) {})
71
72	Name(i000, 0xabcd0000)
73	Name(i001, 0xabcd0100)
74	Name(i002, 0xabcd0200)
75	Name(i003, 0xabcd0300)
76	Name(i004, 0xabcd0400)
77	Name(i005, 0xabcd0500)
78	Name(i006, 0xabcd0600)
79	Name(i007, 0xabcd0700)
80
81	Divide(sz, prt, Local0, nm16)
82
83	Store(nm16, i1)
84	Multiply(nm16, 2, i2)
85	Multiply(nm16, 3, i3)
86	Multiply(nm16, 4, i4)
87	Multiply(nm16, 5, i5)
88	Multiply(nm16, 6, i6)
89	Multiply(nm16, 8, i8)
90	Multiply(nm16, 9, i9)
91	Multiply(nm16, 10, i10)
92	Multiply(nm16, 11, i11)
93	Multiply(nm16, 12, i12)
94	Multiply(nm16, 13, i13)
95	Multiply(nm16, 14, i14)
96	Multiply(nm16, 16, i16)
97
98
99	/* Initializing full Packages with monotone increasing Integers */
100	Method(m000,, Serialized)
101	{
102		Name(qq00, 0)
103		Name(qq01, 0)
104
105		Method(m000)
106		{
107			mfc7(p000, 0, sz, i000)
108			mfc7(p001, 0, sz, i001)
109		}
110		Method(m001)
111		{
112			if (qq00) {
113				m000()
114			}
115
116			mfc7(p002, 0, sz, i002)
117			mfc7(p003, 0, sz, i003)
118			mfc7(p004, 0, sz, i004)
119		}
120		Method(m002)
121		{
122			mfc7(p005, 0, sz, i005)
123			if (qq01) {
124				Store("never", Debug)
125			} else {
126				mfc7(p006, 0, sz, i006)
127			}
128		}
129
130		Store(1, qq00)
131		if (qq00) {
132			m001()
133		}
134		m002()
135		if (qq00) {
136			mfc7(p007, 0, sz, i007)
137		}
138	}
139
140	/* Initializing the Package with IRefs */
141
142	/* Generate two-directional ring of references */
143
144	Method(m001,, Serialized)
145	{
146		Name(uu00, 0xeeff0000)
147		Name(ii00, 0xabcd0000)
148		Name(pp00, Package(sz) {})
149
150		Name(qq00, 0)
151
152		Method(m001)
153		{
154			mfc8(p000, p001, 0, i8, nm16, 0, 0)
155		}
156		Method(m002)
157		{
158			mfc8(p001, p002, 0, i8, nm16, 0, 0)
159		}
160		Method(m003)
161		{
162			m001()
163			m002()
164			mfc8(p002, p003, 0, i8, nm16, 0, 0)
165		}
166		Method(m004)
167		{
168			m003()
169			mfc8(p003, p004, 0, i8, nm16, 0, 0)
170		}
171		Method(m005)
172		{
173			m004()
174			mfc8(p004, p005, 0, i8, nm16, 0, 0)
175		}
176		Method(m006)
177		{
178			mfc8(p005, p006, 0, i8, nm16, 0, 0)
179		}
180		Method(m007)
181		{
182			if (qq00) {
183				mfc8(p006, p007, 0, i8, nm16, 0, 0)
184			}
185		}
186		Method(m008)
187		{
188			if (qq00) {
189				m005()
190				m006()
191				m007()
192				mfc8(p007, p000, 0, i8, nm16, 0, 0)
193			}
194		}
195
196
197		Method(m009)
198		{
199			if (qq00) {
200				mfc8(p007, p006, i1, i9, nm16, 0, 0)
201			}
202		}
203		Method(m00a)
204		{
205			if (qq00) {
206				mfc8(p006, p005, i1, i9, nm16, 0, 0)
207			}
208		}
209		Method(m00b)
210		{
211			if (qq00) {
212				mfc8(p005, p004, i1, i9, nm16, 0, 0)
213			}
214		}
215		Method(m00c)
216		{
217			if (qq00) {
218				mfc8(p004, p003, i1, i9, nm16, 0, 0)
219			}
220		}
221		Method(m00d)
222		{
223			if (qq00) {
224				mfc8(p003, p002, i1, i9, nm16, 0, 0)
225			}
226		}
227		Method(m00e)
228		{
229			if (qq00) {
230				mfc8(p002, p001, i1, i9, nm16, 0, 0)
231			}
232		}
233		Method(m00f)
234		{
235			if (qq00) {
236				mfc8(p001, p000, i1, i9, nm16, 0, 0)
237			}
238		}
239		Method(m010)
240		{
241			m00b()
242			m00c()
243			m00d()
244			m00e()
245			m00f()
246			mfc8(p000, p007, i1, i9, nm16, 0, 0)
247		}
248
249		Store(1, qq00)
250
251		m000()
252
253		if (qq00) {
254			m008()
255			m009()
256			m00a()
257		}
258
259		mfc7(pp00, 0, sz, uu00)
260
261		// Causes Outstanding allocations
262		mfc8(p000, pp00, 0, i8, nm16, 0, 0)
263
264		mfc8(pp00, p000, 0, i16, nm16, 0, 0)
265
266		m010()
267
268		mfcc(pp00, i8, nm16, ii00, 0, 0x100)
269		mfcc(p000, i16, nm16, uu00, 0, 0x101)
270	}
271
272	/*
273	 * Join all other packages
274	 * (two directions for each two points)
275	 */
276	Method(m002,, Serialized)
277	{
278		Name(qq01, 0)
279
280		m001()
281
282		if (qq01) {
283			Store("never", Debug)
284		} else {
285			mfc8(p002, p000, i2, i10, nm16, 0, 0)
286			mfc8(p003, p000, i3, i11, nm16, 0, 0)
287			if (qq01) {
288				Store("never", Debug)
289			} else {
290				mfc8(p004, p000, i4, i12, nm16, 0, 0)
291				mfc8(p005, p000, i5, i13, nm16, 0, 0)
292			}
293			mfc8(p006, p000, i6, i14, nm16, 0, 0)
294		}
295
296		mfc8(p003, p001, i3, i11, nm16, 0, 0)
297		mfc8(p004, p001, i4, i12, nm16, 0, 0)
298		mfc8(p005, p001, i5, i13, nm16, 0, 0)
299		mfc8(p006, p001, i6, i14, nm16, 0, 0)
300		mfc8(p007, p001, i2, i10, nm16, 0, 0)
301
302		mfc8(p004, p002, i4, i12, nm16, 0, 0)
303		mfc8(p005, p002, i5, i13, nm16, 0, 0)
304		mfc8(p006, p002, i6, i14, nm16, 0, 0)
305		mfc8(p007, p002, i2, i10, nm16, 0, 0)
306		mfc8(p000, p002, i3, i11, nm16, 0, 0)
307
308		mfc8(p005, p003, i5, i13, nm16, 0, 0)
309		mfc8(p006, p003, i6, i14, nm16, 0, 0)
310		mfc8(p007, p003, i2, i10, nm16, 0, 0)
311		mfc8(p000, p003, i3, i11, nm16, 0, 0)
312		mfc8(p001, p003, i4, i12, nm16, 0, 0)
313
314		mfc8(p006, p004, i6, i14, nm16, 0, 0)
315		mfc8(p007, p004, i2, i10, nm16, 0, 0)
316		mfc8(p000, p004, i3, i11, nm16, 0, 0)
317		mfc8(p001, p004, i4, i12, nm16, 0, 0)
318		mfc8(p002, p004, i5, i13, nm16, 0, 0)
319
320		mfc8(p007, p005, i2, i10, nm16, 0, 0)
321		mfc8(p000, p005, i3, i11, nm16, 0, 0)
322		mfc8(p001, p005, i4, i12, nm16, 0, 0)
323		mfc8(p002, p005, i5, i13, nm16, 0, 0)
324		mfc8(p003, p005, i6, i14, nm16, 0, 0)
325
326		mfc8(p000, p006, i3, i11, nm16, 0, 0)
327		mfc8(p001, p006, i4, i12, nm16, 0, 0)
328		mfc8(p002, p006, i5, i13, nm16, 0, 0)
329		mfc8(p003, p006, i6, i14, nm16, 0, 0)
330		mfc8(p004, p006, i2, i10, nm16, 0, 0)
331
332		mfc8(p001, p007, i4, i12, nm16, 0, 0)
333		mfc8(p002, p007, i5, i13, nm16, 0, 0)
334		mfc8(p003, p007, i6, i14, nm16, 0, 0)
335		mfc8(p004, p007, i2, i10, nm16, 0, 0)
336		mfc8(p005, p007, i3, i11, nm16, 0, 0)
337	}
338
339	/* Verifying access to Packages through the IRefs */
340
341	/* Two-directional ring of references */
342
343	Method(m003)
344	{
345		m002()
346
347		mfcc(p001, i8, nm16, i000, 0, 0x102)
348		mfcc(p002, i8, nm16, i001, 0, 0x103)
349		mfcc(p003, i8, nm16, i002, 0, 0x104)
350		mfcc(p004, i8, nm16, i003, 0, 0x105)
351		mfcc(p005, i8, nm16, i004, 0, 0x106)
352		mfcc(p006, i8, nm16, i005, 0, 0x107)
353		mfcc(p007, i8, nm16, i006, 0, 0x108)
354		mfcc(p000, i8, nm16, i007, 0, 0x109)
355	}
356
357	Method(m004)
358	{
359		Method(m000)
360		{
361			Add(i002, nm16, i002)
362			Add(i001, nm16, i001)
363			Add(i000, nm16, i000)
364
365			mfcc(p006, i9, nm16, i007, 0, 0x10a)
366			mfcc(p005, i9, nm16, i006, 0, 0x10b)
367		}
368
369		m003()
370
371		Add(i007, nm16, i007)
372		Add(i006, nm16, i006)
373		Add(i005, nm16, i005)
374		Add(i004, nm16, i004)
375		Add(i003, nm16, i003)
376
377		m000()
378
379		mfcc(p004, i9, nm16, i005, 0, 0x10c)
380		mfcc(p003, i9, nm16, i004, 0, 0x10d)
381		mfcc(p002, i9, nm16, i003, 0, 0x10e)
382		mfcc(p001, i9, nm16, i002, 0, 0x10f)
383		mfcc(p000, i9, nm16, i001, 0, 0x110)
384		mfcc(p007, i9, nm16, i000, 0, 0x111)
385	}
386
387	/* Verify other references */
388
389	Method(m005)
390	{
391            Method(m000)
392            {
393             Method(m000)
394             {
395              Method(m000)
396              {
397               Method(m000)
398               {
399                Method(m000)
400                {
401                 Method(m000)
402                 {
403                  Method(m000)
404                  {
405                   Method(m000)
406                   {
407                    Method(m000)
408                    {
409                     Method(m000)
410                     {
411                      Method(m000)
412                      {
413                       Method(m000)
414                       {
415                        Method(m000)
416                        {
417                         Method(m000)
418                         {
419                          Method(m000)
420                          {
421                           mfcc(p006, i10, nm16, i004, 0, 0x112)
422                           mfcc(p007, i10, nm16, i004, 0, 0x113)
423                          }
424                          mfcc(p005, i10, nm16, i007, 0, 0x114)
425                          m000()
426                         }
427                         mfcc(p004, i10, nm16, i007, 0, 0x115)
428                         m000()
429                        }
430                        mfcc(p003, i10, nm16, i007, 0, 0x116)
431                        m000()
432                       }
433                       mfcc(p002, i10, nm16, i007, 0, 0x117)
434                       m000()
435                      }
436                      mfcc(p001, i10, nm16, i007, 0, 0x118)
437                      m000()
438                     }
439                     mfcc(p000, i10, nm16, i002, 0, 0x119)
440                     m000()
441                    }
442                    Add(i000, nm16, i000)
443                    m000()
444                   }
445                   Add(i001, nm16, i001)
446                   m000()
447                  }
448                  Add(i002, nm16, i002)
449                  m000()
450                 }
451                 Add(i003, nm16, i003)
452                 m000()
453                }
454                Add(i004, nm16, i004)
455                m000()
456               }
457               Add(i005, nm16, i005)
458               m000()
459              }
460              Add(i006, nm16, i006)
461              m000()
462             }
463             Add(i007, nm16, i007)
464             m000()
465		}
466
467		m004()
468
469		m000()
470	}
471
472	Method(m006)
473	{
474		m005()
475
476		Add(i007, nm16, i007)
477		Add(i006, nm16, i006)
478		Add(i005, nm16, i005)
479		Add(i004, nm16, i004)
480		Add(i003, nm16, i003)
481		Add(i002, nm16, i002)
482		Add(i001, nm16, i001)
483		Add(i000, nm16, i000)
484
485		mfcc(p000, i11, nm16, i003, 0, 0x11a)
486		mfcc(p001, i11, nm16, i003, 0, 0x11b)
487		mfcc(p002, i11, nm16, i000, 0, 0x11c)
488		mfcc(p003, i11, nm16, i000, 0, 0x11d)
489		mfcc(p004, i11, nm16, i000, 0, 0x11e)
490		mfcc(p005, i11, nm16, i000, 0, 0x11f)
491		mfcc(p006, i11, nm16, i000, 0, 0x120)
492		mfcc(p007, i11, nm16, i005, 0, 0x121)
493	}
494
495	Method(m007,, Serialized)
496	{
497		Name(qq00, 0)
498
499		m006()
500
501		Add(i007, nm16, i007)
502		Add(i006, nm16, i006)
503		Add(i005, nm16, i005)
504		Add(i004, nm16, i004)
505		Add(i003, nm16, i003)
506		Add(i002, nm16, i002)
507		Add(i001, nm16, i001)
508		Add(i000, nm16, i000)
509
510            if (qq00) {
511			Store("never", Debug)
512		} else {
513			mfcc(p000, i12, nm16, i004, 0, 0x122)
514			mfcc(p001, i12, nm16, i004, 0, 0x123)
515			mfcc(p002, i12, nm16, i004, 0, 0x124)
516			mfcc(p003, i12, nm16, i001, 0, 0x125)
517			mfcc(p004, i12, nm16, i001, 0, 0x126)
518			mfcc(p005, i12, nm16, i001, 0, 0x127)
519			mfcc(p006, i12, nm16, i001, 0, 0x128)
520			mfcc(p007, i12, nm16, i001, 0, 0x129)
521            }
522	}
523
524	Method(m008)
525	{
526		m007()
527
528		Add(i007, nm16, i007)
529		Add(i006, nm16, i006)
530		Add(i005, nm16, i005)
531		Add(i004, nm16, i004)
532		Add(i003, nm16, i003)
533		Add(i002, nm16, i002)
534		Add(i001, nm16, i001)
535		Add(i000, nm16, i000)
536
537		mfcc(p000, i13, nm16, i005, 0, 0x12a)
538		mfcc(p001, i13, nm16, i005, 0, 0x12b)
539		mfcc(p002, i13, nm16, i005, 0, 0x12c)
540		mfcc(p003, i13, nm16, i005, 0, 0x12d)
541		mfcc(p004, i13, nm16, i002, 0, 0x12e)
542		mfcc(p005, i13, nm16, i002, 0, 0x12f)
543		mfcc(p006, i13, nm16, i002, 0, 0x130)
544		mfcc(p007, i13, nm16, i002, 0, 0x131)
545	}
546
547	Method(m009,, Serialized)
548	{
549		Name(uu00, 0xeeff0000)
550		Name(ii00, 0xabcd0000)
551		Name(pp00, Package(sz) {})
552
553		m008()
554
555		Add(i007, nm16, i007)
556		Add(i006, nm16, i006)
557		Add(i005, nm16, i005)
558		Add(i004, nm16, i004)
559		Add(i003, nm16, i003)
560		Add(i002, nm16, i002)
561		Add(i001, nm16, i001)
562		Add(i000, nm16, i000)
563
564		mfc7(pp00, 0, sz, uu00)
565		mfc8(p000, pp00, 0, i8, nm16, 0, 0)
566		mfc8(pp00, p000, 0, i16, nm16, 0, 0)
567
568		mfcc(p000, i14, nm16, i006, 0, 0x132)
569		mfcc(p001, i14, nm16, i006, 0, 0x133)
570		mfcc(p002, i14, nm16, i006, 0, 0x134)
571		mfcc(p003, i14, nm16, i006, 0, 0x135)
572		mfcc(p004, i14, nm16, i006, 0, 0x136)
573		mfcc(p005, i14, nm16, i003, 0, 0x137)
574		mfcc(p006, i14, nm16, i003, 0, 0x138)
575		mfcc(p007, i14, nm16, i003, 0, 0x139)
576
577		mfcc(pp00, i8, nm16, ii00, 0, 0x13a)
578		mfcc(p000, i16, nm16, uu00, 0, 0x13b)
579	}
580
581	m009()
582}
583
584Method(mfda)
585{
586	SRMT("mfd9")
587	mfd9()
588}
589