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/*
31
32   ============================
33   !!!!!!!!!!!!!!!!!!!!!!!!!!!!
34   IT IS IN PROGRESS !!!!!!!!!!
35   !!!!!!!!!!!!!!!!!!!!!!!!!!!!
36   ============================
37
38SEE: ????????????
39
401) Add 0 into the middle of any Buffer
412) Do BOTH directions for Concatenation:
42   - First argument - String
43   - First argument - Buffer
443) Extend the test, if possible, for all the operators
454) add method m480 with the different objects creations.
465) change Name(ss08, "1234567890abCdeF")
47   to     Name(ss08, "1234567830abCdeF")
486) do the same as m480() but use LocalX instead ArgX
49   in Operators invocations:
50          Store(Add(Local0, Local1, Local7), local7)
51*/
52
53// Methods for Conversion tests
54//
55// (low number of available arguments {Arg0-Arg6} complicates algorithms).
56//
57// Currently from the mask of exceptions to be forced are excluded bits
58// corresponding to the following types ("dont know how" have to be added):
59//
60// - Method        (dont know how)
61// - Thermal Zones (dont know how)
62// - DDB Handle    (dont know how)
63// - Debug Object  (impossible, Compiler refuses)
64// - Uninitialized (update needed, currently the test is implemented incorrectly.
65//                  Uninitialized type have to be passed immediately as operands
66//                  in m480).
67//
68// Currently excluded from all the total scales of unacceptable types
69// (to be added later):
70//
71//	0x0100 - Method
72//	0x2000 - Thermal Zone
73//	0x8000 - DDB Handle
74//
75// Total scale of acceptable types:
76//
77//	int - 0xc02e - Integer, String, Buffer, Field Unit, Buffer Field, DDB Handle
78//
79
80// NOTE: many entries are commented not to cause crashes.
81//       Have to be uncommented after ACPICA will be fixed.
82//
83
84Name(z064, 64)
85
86// Commutative two operands operation
87// (CAUTION: dont forget to clean it)
88Name(com2, 0)
89
90// Flags exception expected
91// (needed due to the lack of Arguments number)
92Name(FLG0, 0x19283746)
93
94// Flag - verify result with the contents of Package
95Name(FLG1, 0)
96
97// Package contains benchmarks of results
98Name(PKG0, Package(1) {0x10000001})
99Name(PKG1, Package(1) {0x11111111})
100Name(PKG2, Package(1) {0x22222222})
101
102Name(df00, 0)
103Name(df01, 0)
104Name(df02, 0)
105Name(df03, 0)
106Name(df04, 0)
107Event(e000)
108Mutex(mx00, 0)
109Name(i000, 0x58765432)
110Name(i001, 0xabcdefabaabbccdd)
111Name(s000, "qwrt")
112Name(b001, Buffer() {0x91,0x22,0x83})
113Name(p08b, Package() {19,27})
114Device(dv00) {}
115Method(m4a3) { return (0) }
116OperationRegion(rg00, SystemMemory, 0x100, 0x100)
117Field(rg00, ByteAcc, NoLock, Preserve) { fr20, 7 }
118PowerResource(pwr0, 1, 0) {Method(m000){return (0)}}
119Processor(prc0, 0, 0xFFFFFFFF, 0) {}
120Name(b002, Buffer(100) {})
121CreateDWordField(b002, 3, bfz0)
122
123
124// Return object of required type
125//
126// arg0 - type of object
127Method(m484, 1, Serialized)
128{
129	Name(ts, "m484")
130
131	Event(e001)
132	Mutex(mx01, 0)
133
134	Name(ss01, "svnmjkl")
135	Name(ss02, "1234zyq")
136	Name(ss03, "abcdefzyq")
137	Name(ss04, "9876")
138	Name(ss05, "aBcD")
139	Name(ss06, "1234567890987654")
140	Name(ss07, "daFeCBaabbddffee")
141	Name(ss08, "1234567890abCdeF")
142	Name(ss09, "FdeAcb0132547698")
143	Name(ss0a, "12345678909876540")
144	Name(ss0b, "fdeacb01325476980")
145	Name(ss0c, "123456789011223344556677889998765432199983337744")
146	Name(ss0d, "abcdefaAbbccddeeffffeeddccaabbddeeffaaaabbbbeeefffdd")
147	Name(ss0e, "1234567890abcdef9876543210fedbca1122334455667788fdeacb")
148	Name(ss0f, "defa1234567890abcdef9876543210fedbca1122334455667788fdeacb")
149	Name(ss10, "123456789011223344556677889998765432199983337744z")
150	Name(ss11, "0xF1dAB98e0D794Bc5")
151
152	Name(bb01, Buffer() {0x80})
153	Name(bb02, Buffer() {0x81,0x82})
154	Name(bb03, Buffer() {0x83,0x84,0x85,0x86})
155	Name(bb04, Buffer() {0x87,0x98,0x99,0x9a,0x9b})
156	Name(bb05, Buffer() {0x9c,0x9d,0x9e,0x9f,0xa0,0xa1,0xa2,0xa3})
157	Name(bb06, Buffer() {0xa4,0xa5,0xa6,0xa7,0xb8,0xb9,0xba,0xbb,0xbc})
158	Name(bb07, Buffer(200) {
159		 0x91, 0x92, 0x93, 0x94, 95, 96, 97, 98, 99, 10, 11, 12, 13, 14, 15, 16,
160		 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
161		 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
162		 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
163		 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
164		 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
165		 97, 98, 99,100,101,102,103,104,105,106,107,108,109,110,111,112,
166		113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,
167		129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,
168		145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,
169		161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,
170		177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,
171		193,194,195,196,197,198,199,200})
172	Name(bb08, Buffer(257) {
173		  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16,
174		 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
175		 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
176		 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
177		 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
178		 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
179		 97, 98, 99,100,101,102,103,104,105,106,107,108,109,110,111,112,
180		113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,
181		129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,
182		145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,
183		161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,
184		177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,
185		193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,
186		209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,
187		225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,
188		241,242,243,244,245,246,247,248,249,250,251,252,253,254,255, 0, 1})
189
190	// Field Units
191
192	OperationRegion(r001, SystemMemory, 0x100, 0x100)
193
194	Field(r001, ByteAcc, NoLock, Preserve) {
195		f001, 3,
196		f002, 8,
197		f003, 16,
198		f004, 32,
199		f005, 33,//33
200		f006, 63,//63
201		f007, 64,//64
202		f008, 65,//65
203		f009, 127,
204		f00a, 257,
205		// f00b, 201*8, do it also
206	}
207
208	// Buffer Fields
209
210	Name(bb09, Buffer(200) {})
211
212	CreateField(bb09, 1, 3, bf01)
213	CreateField(bb09, 4, 8, bf02)
214	CreateField(bb09, 12, 16, bf03)
215	CreateField(bb09, 28, 32, bf04)
216	CreateField(bb09, 60, 33, bf05)
217	CreateField(bb09, 93, 63, bf06)//93
218	CreateField(bb09, 156, 64, bf07)//156
219	CreateField(bb09, 220, 65, bf08)//220
220	CreateField(bb09, 285, 127, bf09)//285
221	CreateField(bb09, 412, 257, bf0a)//412
222
223//	CreateField(bb09, xxx, 201*8, bf0b)
224
225	CreateDWordField(bb09, 151, bf0b)
226
227	/////////////////////////////////////////////////////////////////////
228
229	Store(0xff, fr20)
230	Store(0xff, f001)
231	Store(0x8a8b8c8d, f002)
232	Store(0x8a8b8c8d, f003)
233	Store(0x8a8b8c8d, f004)
234	Store(Buffer() {0xff,0xff,0xff,0xff,0xff}, f005)
235	Store(Buffer() {0x58,0x46,0x37,0x88,0x19,0xfa,0xde,0xdc,0xfa}, f006)
236	Store(Buffer() {0x58,0x9a,0x37,0x88,0x19,0xfa,0xde,0xdc,0xfa}, f007)
237	Store(Buffer() {0x58,0xc7,0x37,0x88,0x19,0xfa,0xde,0xdc,0xfa}, f008)
238	Store(Buffer() {0x82,0x34,0x56,0x78,0x90,0xab,0xcd,0xef,0x55}, f009)
239	Store(Buffer() {0x93,0xab,0xcd,0xef,0x99,0x12,0xcd,0x52,0x87}, f00a)
240
241	Store(0x918654ab, bfz0)
242	Store(0xff, bf01)
243	Store(0x8a8b8c8d, bf02)
244	Store(0x8a8b8c8d, bf03)
245	Store(0x8a8b8c8d, bf04)
246	Store(Buffer() {0xff,0xff,0xff,0xff,0xff}, bf05)
247	Store(Buffer() {0x58,0x46,0x37,0x88,0x19,0xfa,0xde,0xdc,0xfa}, bf06)
248	Store(Buffer() {0x58,0x9a,0x37,0x88,0x19,0xfa,0xde,0xdc,0xfa}, bf07)
249	Store(Buffer() {0x58,0xc7,0x37,0x88,0x19,0xfa,0xde,0xdc,0xfa}, bf08)
250	Store(Buffer() {0x82,0x34,0x56,0x78,0x90,0xab,0xcd,0xef,0x55}, bf09)
251	Store(Buffer() {0x93,0xab,0xcd,0xef,0x99,0x12,0xcd,0x52,0x87}, bf0a)
252
253	Store(0xa2b3c4d5, bf0b)
254
255	/////////////////////////////////////////////////////////////////////
256
257	Name(pp01, Package() {19})
258	Device(dv01) {}
259	Method(m001) { return (0) }
260	OperationRegion(r002, SystemMemory, 0x100, 0x100)
261	PowerResource(pwr1, 1, 0) {Method(m000){return (0)}}
262	Processor(pr01, 0, 0xFFFFFFFF, 0) {}
263
264	Store(0, Local7)
265
266	switch (ToInteger(Arg0)) {
267
268		// Uninitialized
269
270		/*
271		 * case (0x000) {
272		 * }
273		 */
274
275		// Integers
276
277		case (0x100) {
278			Store(i000, Local7)
279		}
280		case (0x101) {
281			Store(i001, Local7)
282		}
283		case (0x102) {
284			Store(0x12345678, Local7)
285		}
286		case (0x103) {
287			Store(0xabedf18942345678, Local7)
288		}
289		case (0x104) {
290			Store(Zero, Local7)
291		}
292		case (0x105) {
293			Store(One, Local7)
294		}
295		case (0x106) {
296			Store(Ones, Local7)
297		}
298		case (0x107) {
299			Store(Revision, Local7)
300		}
301		case (0x108) {
302			Store(0x123, Local7)
303		}
304		case (0x109) {
305			Store(11, Local7)
306		}
307
308		// Strings
309
310		case (0x200) {
311			Store(s000, Local7)
312		}
313		case (0x201) {
314			Store(ss01, Local7)
315		}
316		case (0x202) {
317			Store(ss02, Local7)
318		}
319		case (0x203) {
320			Store(ss03, Local7)
321		}
322		case (0x204) {
323			Store(ss04, Local7)
324		}
325		case (0x205) {
326			Store(ss05, Local7)
327		}
328		case (0x206) {
329			Store(ss06, Local7)
330		}
331		case (0x207) {
332			Store(ss07, Local7)
333		}
334		case (0x208) {
335			Store(ss08, Local7)
336		}
337		case (0x209) {
338			Store(ss09, Local7)
339		}
340		case (0x20a) {
341			Store(ss0a, Local7)
342		}
343		case (0x20b) {
344			Store(ss0b, Local7)
345		}
346		case (0x20c) {
347			Store(ss0c, Local7)
348		}
349		case (0x20d) {
350			Store(ss0d, Local7)
351		}
352		case (0x20e) {
353			Store(ss0e, Local7)
354		}
355		case (0x20f) {
356			Store(ss0f, Local7)
357		}
358		case (0x210) {
359			Store(ss10, Local7)
360		}
361		case (0x211) {
362			Store(ss11, Local7)
363		}
364
365		// Buffers
366
367		case (0x300) {
368			Store(b001, Local7)
369		}
370		case (0x301) {
371			Store(bb01, Local7)
372		}
373		case (0x302) {
374			Store(bb02, Local7)
375		}
376		case (0x303) {
377			Store(bb03, Local7)
378		}
379		case (0x304) {
380			Store(bb04, Local7)
381		}
382		case (0x305) {
383			Store(bb05, Local7)
384		}
385		case (0x306) {
386			Store(bb06, Local7)
387		}
388		case (0x307) {
389			Store(bb07, Local7)
390		}
391		case (0x308) {
392			Store(bb08, Local7)
393		}
394
395		// Packages
396
397		case (0x400) {
398			Store(p08b, Local7)
399		}
400		case (0x401) {
401			Store(pp01, Local7)
402		}
403
404		// Field Units
405
406		case (0x500) {
407			Store(fr20, Local7)
408		}
409		case (0x501) {
410			Store(f001, Local7)
411		}
412		case (0x502) {
413			Store(f002, Local7)
414		}
415		case (0x503) {
416			Store(f003, Local7)
417		}
418		case (0x504) {
419			Store(f004, Local7)
420		}
421		case (0x505) {
422			Store(f005, Local7)
423		}
424		case (0x506) {
425			Store(f006, Local7)
426		}
427		case (0x507) {
428			Store(f007, Local7)
429		}
430		case (0x508) {
431			Store(f008, Local7)
432		}
433		case (0x509) {
434			Store(f009, Local7)
435		}
436		case (0x50a) {
437			Store(f00a, Local7)
438		}
439
440/*
441// Removed 09/2015: iASL now disallows these stores
442		// Devices
443
444		case (0x600) {
445			Store(dv00, Local7)
446		}
447		case (0x601) {
448			Store(dv01, Local7)
449		}
450
451		// Events
452
453		case (0x700) {
454			Store(e000, Local7)
455		}
456		case (0x701) {
457			Store(e001, Local7)
458		}
459
460		// Methods
461
462		case (0x800) {
463			Store(m4a3, Local7)
464		}
465		case (0x801) {
466			Store(m001, Local7)
467		}
468
469		// Mutexes
470
471		case (0x900) {
472			Store(mx00, Local7)
473		}
474		case (0x901) {
475			Store(mx01, Local7)
476		}
477
478		// Operation Regions
479
480		case (0xa00) {
481			Store(rg00, Local7)
482		}
483		case (0xa01) {
484			Store(r001, Local7)
485		}
486		case (0xa02) {
487			Store(r002, Local7)
488		}
489
490		// Power Resources
491
492		case (0xb00) {
493			Store(pwr0, Local7)
494		}
495		case (0xb01) {
496			Store(pwr1, Local7)
497		}
498
499		// Processor
500
501		case (0xc00) {
502			Store(prc0, Local7)
503		}
504		case (0xc01) {
505			Store(pr01, Local7)
506		}
507
508		// Thermal Zones
509*/
510		/*
511		 * case (0xd00) {
512		 *		Store(Debug, Local7)
513		 * }
514		 */
515
516		// Buffer Field
517
518		case (0xe00) {
519			Store(bfz0, Local7)
520		}
521		case (0xe01) {
522			Store(bf01, Local7)
523		}
524		case (0xe02) {
525			Store(bf02, Local7)
526		}
527		case (0xe03) {
528			Store(bf03, Local7)
529		}
530		case (0xe04) {
531			Store(bf04, Local7)
532		}
533		case (0xe05) {
534			Store(bf05, Local7)
535		}
536		case (0xe06) {
537			Store(bf06, Local7)
538		}
539		case (0xe07) {
540			Store(bf07, Local7)
541		}
542		case (0xe08) {
543			Store(bf08, Local7)
544		}
545		case (0xe09) {
546			Store(bf09, Local7)
547		}
548		case (0xe0a) {
549			Store(bf0a, Local7)
550		}
551		case (0xe0b) {
552			Store(bf0b, Local7)
553		}
554
555		// DDB Handle
556
557		/*
558		 * case (0xf00) {
559		 *		Store(Debug, Local7)
560		 * }
561		 */
562
563		// Debug Object
564
565		/*
566		 * case (0x1000) {
567		 *		Store(Debug, Local7)
568		 * }
569		 */
570
571		default {
572			if (LNotEqual(arg0, 0)) {
573				err("----------- ERROR, m484: incorrect Arg0:", z064, 0, 0, 0, 0, 0)
574				Store(arg0, Debug)
575			}
576		}
577	}
578
579	return (Local7)
580}
581
582// arg0 - opcode of operation
583// arg1 - type of 0-th argument
584// arg2 - type of 1-th argument
585// arg3 - type of 2-th argument
586// arg4 - type of 3-th argument
587// arg5 - type of 4-th argument
588// arg6 - {Ones - flag of exception, otherwise - index of result pair}
589Method(m485, 7, Serialized)
590{
591	if (0) {
592		Store("##################################################################", Debug)
593		Store(arg6, Debug)
594	}
595
596	Name(ts, "m485")
597	Name(ex00, 0)
598	Name(tmp0, 0)
599
600	if (LEqual(arg6, FLG0)) {
601		Store(1, ex00)
602	} else {
603		Store(m48c(PKG1, arg6), Local5)
604		Store(ObjectType(Local5), Local7)
605		if (LEqual(Local7, 2)) {
606			if (LEqual(Local5, "Exc")) {
607				Store(1, ex00)
608			}
609		}
610	}
611
612	Store(0, Local7)
613
614	// m482:
615	//
616	// arg0-arg4 - parameters of operators
617	// arg5      - miscellaneous
618	// arg6      - opcode of operation
619
620
621/*
622 * //// ?????????????????????????
623 * Uninitialized data should be passed to the operators immediately
624 * in the m480 but not here to these Store opreations!!!!!!!!!!!!!!
625 * But this will a few complicate m480 !!!!!!!!!!!!!!!!!!!!!!!!!!!!
626 * //// ?????????????????????????
627 */
628
629	// Parameters (if not to save them Uninitialized)
630	if (LNotEqual(arg1, 0xfff)) {
631		Store(m484(arg1), Local0)
632	}
633	if (LNotEqual(arg2, 0xfff)) {
634		Store(m484(arg2), Local1)
635	}
636	if (LNotEqual(arg3, 0xfff)) {
637		Store(m484(arg3), Local2)
638	}
639	if (LNotEqual(arg4, 0xfff)) {
640		Store(m484(arg4), Local3)
641	}
642	if (LNotEqual(arg5, 0xfff)) {
643		Store(m484(arg5), Local4)
644	}
645
646	if (ex00) {
647		Store(FLG2, tmp0)
648		CH03(ts, z064, 0, 0, 0)
649	}
650
651	Store(m482(Local0, Local1, Local2, Local3, Local4, tmp0, arg0), Local7)
652
653	if (ex00) {
654		CH04(ts, 0, 0xff, z064, 1, 0, 0)
655	} elseif (FLG1) {
656		// Verify the first result
657		m489(ts, Local7, Local5)
658	}
659
660	if (com2) {
661
662		// The same operation but the first two arguments interchange
663
664		if (LNotEqual(arg6, FLG0)) {
665			if (LEqual(com2, 2)) {
666				Store(0, ex00)
667				Store(m48c(PKG2, arg6), Local5)
668				Store(ObjectType(Local5), Local7)
669				if (LEqual(Local7, 2)) {
670					if (LEqual(Local5, "Exc")) {
671						Store(1, ex00)
672					}
673				}
674			}
675		}
676
677		if (ex00) {
678			CH03(ts, z064, 2, 0, 0)
679		}
680
681		Store(m482(Local1, Local0, Local2, Local3, Local4, tmp0, arg0), Local7)
682
683		if (ex00) {
684			CH04(ts, 0, 0xff, z064, 3, 0, 0)
685		} elseif (FLG1) {
686			// Verify the second result
687			m489(ts, Local7, Local5)
688		}
689	}
690
691	return (Local7)
692}
693
694// Init all parameters as non-usable
695Method(m486)
696{
697	Store(0, df00)
698	Store(0, df01)
699	Store(0, df02)
700	Store(0, df03)
701	Store(0, df04)
702}
703
704// Return the object of required type.
705// Allowed types are {1-12,14}, == 0x5fff.
706// Returned 0xfff is flag of "Uninitialized".
707//
708// These have to be implemented:
709//
710//	Method, Thermal Zone, DDB Handle
711//
712Method(m487, 1, Serialized)
713{
714	switch (ToInteger (Arg0)) {
715
716		case (0) {
717			// Uninitialized
718			Store(0xfff, Local7)
719		}
720		case (1) {
721			// Integers
722			Store(0x100, Local7)
723		}
724		case (2) {
725			// Strings
726			Store(0x204, Local7)
727		}
728		case (3) {
729			// Buffers
730			Store(0x300, Local7)
731		}
732		case (4) {
733			// Packages
734			Store(0x400, Local7)
735		}
736		case (5) {
737			// Field Units
738			Store(0x500, Local7)
739		}
740		case (6) {
741			// Devices
742			Store(0x600, Local7)
743		}
744		case (7) {
745			// Events
746			Store(0x700, Local7)
747		}
748		case (8) {
749			// Methods
750			Store(0x800, Local7)
751		}
752		case (9) {
753			// Mutexes
754			Store(0x900, Local7)
755		}
756		case (10) {
757			// Operation Regions
758			Store(0xa00, Local7)
759		}
760		case (11) {
761			// Power Resources
762			Store(0xb00, Local7)
763		}
764		case (12) {
765			// Processor
766			Store(0xc00, Local7)
767		}
768		/*
769		 * case (0xd00) {
770		 *	// Thermal Zones
771		 *	Store(Debug, Local7)
772		 * }
773		 */
774		case (14) {
775			// Buffer Field
776			Store(0xe00, Local7)
777		}
778		/*
779		 * case (0xf00) {
780		 *	// DDB Handle
781		 *	Store(Debug, Local7)
782		 * }
783		 *
784		 *
785		 * case (0x1000) {
786		 *	// Debug Object
787		 *	Store(Debug, Local7)
788		 * }
789		 */
790
791		default {
792			if (LNotEqual(arg0, 0)) {
793				err("----------- ERROR, m487: incorrect Arg0:", z064, 1, 0, 0, 0, 0)
794				Store(arg0, Debug)
795				Store(0, Local7)
796			}
797		}
798	}
799
800	return (Local7)
801}
802
803// Initiate exception by inappropreate operand
804Method(m488, 6, Serialized)
805{
806	Store(0, Local7)
807
808	Name(lpN0, 0)
809	Name(lpC0, 0)
810
811	if (And(arg1, 0x5fff)) {
812		Store(16, lpN0)
813		Store(0, lpC0)
814		While (lpN0) {
815			ShiftLeft(1, lpC0, Local6)
816			if (And(arg1, Local6)) {
817				Store(m487(lpC0), Local5)
818				Store(m485(arg0, Local5, df01, df02, df03, df04, FLG0), Local7)
819			}
820			Decrement(lpN0)
821			Increment(lpC0)
822		}
823	}
824
825	if (And(arg2, 0x5fff)) {
826		Store(16, lpN0)
827		Store(0, lpC0)
828		While (lpN0) {
829			ShiftLeft(1, lpC0, Local6)
830			if (And(arg2, Local6)) {
831				Store(m487(lpC0), Local5)
832				Store(m485(arg0, df00, Local5, df02, df03, df04, FLG0), Local7)
833			}
834			Decrement(lpN0)
835			Increment(lpC0)
836		}
837	}
838
839	if (And(arg3, 0x5fff)) {
840		Store(16, lpN0)
841		Store(0, lpC0)
842		While (lpN0) {
843			ShiftLeft(1, lpC0, Local6)
844			if (And(arg3, Local6)) {
845				Store(m487(lpC0), Local5)
846				Store(m485(arg0, df00, df01, Local5, df03, df04, FLG0), Local7)
847			}
848			Decrement(lpN0)
849			Increment(lpC0)
850		}
851	}
852
853	if (And(arg4, 0x5fff)) {
854		Store(16, lpN0)
855		Store(0, lpC0)
856		While (lpN0) {
857			ShiftLeft(1, lpC0, Local6)
858			if (And(arg4, Local6)) {
859				Store(m487(lpC0), Local5)
860				Store(m485(arg0, df00, df01, df02, Local5, df04, FLG0), Local7)
861			}
862			Decrement(lpN0)
863			Increment(lpC0)
864		}
865	}
866
867	if (And(arg5, 0x5fff)) {
868		Store(16, lpN0)
869		Store(0, lpC0)
870		While (lpN0) {
871			ShiftLeft(1, lpC0, Local6)
872			if (And(arg5, Local6)) {
873				Store(m487(lpC0), Local5)
874				Store(m485(arg0, df00, df01, df02, df03, Local5, FLG0), Local7)
875			}
876			Decrement(lpN0)
877			Increment(lpC0)
878		}
879	}
880
881	return (Local7)
882}
883
884Method(m489, 3)
885{
886	Store(ObjectType(arg1), Local0)
887	Store(ObjectType(arg2), Local1)
888
889	if (LNotEqual(Local0, Local1)) {
890		err(arg0, z064, 2, 0, 0, Local0, Local1)
891	} elseif (LNotEqual(arg1, arg2)) {
892		err(arg0, z064, 3, 0, 0, arg1, arg2)
893	}
894}
895
896// Verify result
897// <name>,<results>,<result>,<index of result pair>
898Method(m48a, 4)
899{
900	Multiply(arg3, 2, Local0)
901	Store(DeRefOf(Index(arg1, Local0)), Local7)
902	Increment(Local0)
903	Store(DeRefOf(Index(arg1, Local0)), Local6)
904
905	if (F64) {
906		if (LNotEqual(arg2, Local7)) {
907			err(arg0, z064, 4, 0, 0, arg2, Local7)
908		}
909	} else {
910		if (LNotEqual(arg2, Local6)) {
911			err(arg0, z064, 5, 0, 0, arg2, Local6)
912		}
913	}
914}
915
916// Integer two operands operation
917// <operation>,<type of first operand>
918//
919// NOTE: now it work only by particular parts,
920//       all together produce crashes. Uncomment
921//       in future.
922Method(m48b, 2)
923{
924	// X - Integer
925
926	Store(m485(arg0, arg1, 0x100, 0, 0, 0, 0), Local7)
927
928	// X - String
929
930	Store(m485(arg0, arg1, 0x200, 0, 0, 0, 1), Local7)
931	Store(m485(arg0, arg1, 0x201, 0, 0, 0, 2), Local7)
932	Store(m485(arg0, arg1, 0x202, 0, 0, 0, 3), Local7)
933	Store(m485(arg0, arg1, 0x203, 0, 0, 0, 4), Local7)
934	Store(m485(arg0, arg1, 0x204, 0, 0, 0, 5), Local7)
935	Store(m485(arg0, arg1, 0x205, 0, 0, 0, 6), Local7)
936	Store(m485(arg0, arg1, 0x206, 0, 0, 0, 7), Local7)
937	Store(m485(arg0, arg1, 0x207, 0, 0, 0, 8), Local7)
938	Store(m485(arg0, arg1, 0x208, 0, 0, 0, 9), Local7)
939	Store(m485(arg0, arg1, 0x209, 0, 0, 0, 10), Local7)
940	Store(m485(arg0, arg1, 0x20a, 0, 0, 0, 11), Local7)
941	Store(m485(arg0, arg1, 0x20b, 0, 0, 0, 12), Local7)
942	Store(m485(arg0, arg1, 0x20c, 0, 0, 0, 13), Local7)
943	Store(m485(arg0, arg1, 0x20d, 0, 0, 0, 14), Local7)
944	Store(m485(arg0, arg1, 0x20e, 0, 0, 0, 15), Local7)
945	Store(m485(arg0, arg1, 0x20f, 0, 0, 0, 16), Local7)
946	Store(m485(arg0, arg1, 0x210, 0, 0, 0, 17), Local7)
947
948	// X - Buffer
949
950	Store(m485(arg0, arg1, 0x300, 0, 0, 0, 18), Local7)
951	Store(m485(arg0, arg1, 0x301, 0, 0, 0, 19), Local7)
952	Store(m485(arg0, arg1, 0x302, 0, 0, 0, 20), Local7)
953	Store(m485(arg0, arg1, 0x303, 0, 0, 0, 21), Local7)
954	Store(m485(arg0, arg1, 0x304, 0, 0, 0, 22), Local7)
955	Store(m485(arg0, arg1, 0x305, 0, 0, 0, 23), Local7)
956	Store(m485(arg0, arg1, 0x306, 0, 0, 0, 24), Local7)
957	Store(m485(arg0, arg1, 0x307, 0, 0, 0, 25), Local7)
958	Store(m485(arg0, arg1, 0x308, 0, 0, 0, 26), Local7)
959
960	// X - Field Unit
961
962	Store(m485(arg0, arg1, 0x500, 0, 0, 0, 27), Local7)
963	Store(m485(arg0, arg1, 0x501, 0, 0, 0, 28), Local7)
964	Store(m485(arg0, arg1, 0x502, 0, 0, 0, 29), Local7)
965	Store(m485(arg0, arg1, 0x503, 0, 0, 0, 30), Local7)
966	Store(m485(arg0, arg1, 0x504, 0, 0, 0, 31), Local7)
967	Store(m485(arg0, arg1, 0x505, 0, 0, 0, 32), Local7)
968	Store(m485(arg0, arg1, 0x506, 0, 0, 0, 33), Local7)
969	Store(m485(arg0, arg1, 0x507, 0, 0, 0, 34), Local7)
970	Store(m485(arg0, arg1, 0x508, 0, 0, 0, 35), Local7)
971	Store(m485(arg0, arg1, 0x509, 0, 0, 0, 36), Local7)
972	Store(m485(arg0, arg1, 0x50a, 0, 0, 0, 37), Local7)
973
974	// X - Buffer Field
975
976	Store(m485(arg0, arg1, 0xe00, 0, 0, 0, 38), Local7)
977	Store(m485(arg0, arg1, 0xe01, 0, 0, 0, 39), Local7)
978	Store(m485(arg0, arg1, 0xe02, 0, 0, 0, 40), Local7)
979	Store(m485(arg0, arg1, 0xe03, 0, 0, 0, 41), Local7)
980	Store(m485(arg0, arg1, 0xe04, 0, 0, 0, 42), Local7)
981	Store(m485(arg0, arg1, 0xe05, 0, 0, 0, 43), Local7)
982	Store(m485(arg0, arg1, 0xe06, 0, 0, 0, 44), Local7)
983	Store(m485(arg0, arg1, 0xe07, 0, 0, 0, 45), Local7)
984	Store(m485(arg0, arg1, 0xe08, 0, 0, 0, 46), Local7)
985	Store(m485(arg0, arg1, 0xe09, 0, 0, 0, 47), Local7)
986	Store(m485(arg0, arg1, 0xe0a, 0, 0, 0, 48), Local7)
987}
988
989// Return element of Package
990// <Package>,<index of elements-pair>
991// pair: {F64-element, F32-element}
992Method(m48c, 2)
993{
994	Multiply(arg1, 2, Local0)
995
996	if (F64) {
997		Store(DeRefOf(Index(arg0, Local0)), Local7)
998	} else {
999		Increment(Local0)
1000		Store(DeRefOf(Index(arg0, Local0)), Local7)
1001	}
1002	return (Local7)
1003}
1004
1005// arg0 - opcode of operation
1006//
1007// arg1 - type of 0-th argument
1008// arg2 - type of 1-th argument
1009// arg3 - type of 2-th argument
1010// arg4 - type of 3-th argument
1011//
1012// arg5 - expected 64-bit result
1013// arg6 - expected 32-bit result
1014Method(m48d, 7, Serialized)
1015{
1016	Name(ts, "m48d")
1017	Name(tmp0, 0)
1018
1019	if (0) {
1020		Store("##################################################################", Debug)
1021		Store(arg6, Debug)
1022	}
1023
1024	Name(ex00, 0)
1025
1026	if (F64) {
1027		Store(ObjectType(arg5), Local0)
1028		if (LEqual(Local0, 2)) {
1029			if (LEqual(arg5, "Exc")) {
1030				Store(1, ex00)
1031			}
1032		}
1033	} else {
1034		Store(ObjectType(arg6), Local0)
1035		if (LEqual(Local0, 2)) {
1036			if (LEqual(arg6, "Exc")) {
1037				Store(1, ex00)
1038			}
1039		}
1040	}
1041
1042	Store(0, Local7)
1043
1044	// m482:
1045	//
1046	// arg0-arg4 - parameters of operators
1047	// arg5      - miscellaneous
1048	// arg6      - opcode of operation
1049
1050	Store(m484(arg1), Local0)
1051	Store(m484(arg2), Local1)
1052	Store(m484(arg3), Local2)
1053	Store(m484(arg4), Local3)
1054
1055	if (ex00) {
1056		Store(FLG2, tmp0)
1057		CH03(ts, z064, 4, 0, 0)
1058	}
1059
1060	Store(m482(Local0, Local1, Local2, Local3, 0, tmp0, arg0), Local7)
1061
1062	if (ex00) {
1063		CH04(ts, 0, 0xff, z064, 5, 0, 0)
1064	} else {
1065
1066		// Verify the result
1067
1068		if (F64) {
1069			m489(ts, Local7, arg5)
1070		} else {
1071			m489(ts, Local7, arg6)
1072		}
1073	}
1074
1075	return (Local7)
1076}
1077