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 * Objects of common use to provide the common control of test run,
31 * provide the uniform structure of all run-time tests.
32 *
33 * The full applied hierarchy of test-concepts follows:
34 * - test suite       (aslts)
35 * - test collection  (functional, complex, exceptions,...)
36 * - test case        (arithmetic, bfield, exc, opackageel,..)
37 * - test (or root method) simplest test unit supplied with the
38 *         status line and evaluated as [PASS|FAIL|BLOCKED|SKIPPED].
39 */
40
41Name(z062, 62)
42
43Name(ff32, 0xffffffff)         // -1, 32-bit
44Name(ff64, 0xffffffffffffffff) // -1, 64-bit
45
46// Test execution trace
47
48Name(TRCF, 0)            // Trace enabling flag
49Name(TRCH, "ASLTS")      // Head of trace message
50Name(STST, "STST")	 // Head of summary status message of test run
51Name(CTST, "CTST")	 // Head of curent status message of test run
52
53Name(pr01, 1)            // Printing starts of sub-tests
54Name(pr02, 1)            // More detailed printing
55
56// Start time (Timer-time) of running test
57Name(tmt0, 0)
58
59// Flag of multi-threading mode
60Name(MTHR, 0)
61
62/* Set the multi-threading mode flag */
63Method(SET3, 1)
64{
65	Store(arg0, MTHR)
66}
67
68// From Integer arithmetic
69Name(c000, 10)
70Name(c001, 5)
71
72// From Logical operators
73Name(c002, 13)
74Name(c003, 12)
75Name(c004, 6)
76Name(c005, 4)
77Name(c006, 31)
78Name(c007, 51)
79
80// Types, as returned by ObjectType
81Name(c008, 0)	// Uninitialized
82Name(c009, 1)	// Integer
83Name(c00a, 2)	// String
84Name(c00b, 3)	// Buffer
85Name(c00c, 4)	// Package
86Name(c00d, 5)	// Field Unit
87Name(c00e, 6)	// Device
88Name(c00f, 7)	// Event
89Name(c010, 8)	// Method
90Name(c011, 9)	// Mutex
91Name(c012, 10)	// Operation Region
92Name(c013, 11)	// Power Resource
93Name(c014, 12)	// Processor
94Name(c015, 13)	// Thermal Zone
95Name(c016, 14)	// Buffer Field
96Name(c017, 15)	// DDB Handle
97Name(c018, 16)	// Debug Object
98Name(c019, 17)	// LOCAL_REGION_FIELD
99Name(c01a, 18)	// LOCAL_BANK_FIELD
100Name(c01b, 19)	// LOCAL_INDEX_FIELD
101Name(c01c, 20)	// LOCAL_REFERENCE
102Name(c01d, 21)	// LOCAL_ALIAS
103Name(c01e, 22)	// LOCAL_METHOD_ALIAS
104Name(c01f, 23)	// LOCAL_NOTIFY
105Name(c020, 24)	// LOCAL_ADDRESS_HANDLER
106Name(c021, 25)	// LOCAL_RESOURCE
107Name(c022, 26)	// LOCAL_RESOURCE_FIELD
108Name(c023, 27)	// LOCAL_SCOPE
109Name(c024, 28)	// LOCAL_EXTRA
110Name(c025, 29)	// LOCAL_DATA
111Name(c027, 30)	// Number of different types
112
113Name(c028, 0)	// Reserved (first)
114
115// The name of type Package
116Name(NMTP, Package() {
117	"Uninitialized",
118	"Integer",
119	"String",
120	"Buffer",
121	"Package",
122	"Field Unit",
123	"Device",
124	"Event",
125	"Method",
126	"Mutex",
127	"Operation Region",
128	"Power Resource",
129	"Processor",
130	"Thermal Zone",
131	"Buffer Field",
132	"DDB Handle",
133	"Debug Object",
134	"LOCAL_REGION_FIELD",
135	"LOCAL_BANK_FIELD",
136	"LOCAL_INDEX_FIELD",
137	"LOCAL_REFERENCE",
138	"LOCAL_ALIAS",
139	"LOCAL_METHOD_ALIAS",
140	"LOCAL_NOTIFY",
141	"LOCAL_ADDRESS_HANDLER",
142	"LOCAL_RESOURCE",
143	"LOCAL_RESOURCE_FIELD",
144	"LOCAL_SCOPE",
145	"LOCAL_EXTRA",
146	"LOCAL_DATA",
147	"--",
148	"--"})
149
150// Global variables for an arbitrary use inside the particular Run-methods
151Name(c080, 0)
152Name(c081, 0)
153Name(c082, 0)
154Name(c083, 0)
155Name(c084, 0)
156Name(c085, 0)
157Name(c086, 0)
158Name(c087, 0)
159Name(c088, 0)
160Name(c089, 0)
161Name(c08a, 0)
162Name(c08b, 0)
163Name(c08c, 7900000) // used in operand tests (801 - 2 msec)
164
165/*
166 * Flag:
167 *    non-zero - prohibits non-precise opcode exceptions
168 *               (one particular opcode of exception is verified).
169 *    0 - only presence of some exception(s) is verified.
170 */
171Name(EXCV, 0)
172
173
174/*
175 * An "absolute index of file reporting error" used for reporting errors
176 * from the bug-demo files (only!). It is the same for all the bug-demo files
177 * (files of TCLD type tests). It is not even an index of file as such in this
178 * case but only designation of reporting error from some bug-demo file. The
179 * actual number of bug (NNN) in this case is taken from TIND and the same file
180 * name like this "*NNN.asl" is reported for all the bug-demo files corresponding
181 * to the same bug where NNN is the number of bug. So, "indexes of errors
182 * (inside the file)" corresponding to the same bug should differ through
183 * all files of that bug.
184 */
185Name(zFFF, 0x7FF)
186
187/*
188 * Flag: 0 - 32, 1 - 64
189 */
190Name(F64, 0)
191
192/*
193 * Byte and character size of Integer
194 */
195Name(ISZ0, 0)
196Name(ISZC, 0)
197
198/*
199 * The tests execution trace.
200 *
201 * ETR0 - the size of trace Packages
202 * ETR1 - the number of units (ETR0/3) in trace Packages
203 * ERRP - Package for summary information about the first ETR1 errors
204 * RP0P - Package to store the first ETR0 status lines of the
205 *        root Methods run results.
206 * RMRC - current number of root Methods runs
207 */
208Name(ETR0, 1200)
209Name(ETR1, 400)
210Name(ERRP, Package(ETR0) {})
211Name(RP0P, Package(ETR0) {})
212Name(RMRC, 0)
213
214/*
215 * Errors handling
216 * (ERR0 & ERR2) overwrite (arg3 & arg4) of err()
217 * (but there is no remained ArgX for ERR1 in err()).
218 */
219Name(ERRS, 0)	// Errors counter
220Name(ERRB, 0)	// Error opcode base
221Name(ERR0, 0)	// Absolute index of file initiating the checking
222Name(ERR1, 0)	// Name of Method initiating the checking
223Name(ERR2, 0)	// Index of checking
224Name(ERR3, 0)	// Current indicator of errors
225Name(ERR4, 0)	// Full print out of ERRORS SUMMARY
226Name(ERR5, 0)	// Used to calculate the number of errors of root Method
227Name(ERR6, 0)	// The number of failed root Methods (tests)
228Name(ERR7, 0)	// The number of errors detected during the loading stage
229
230Name(FNAM, 0)   // Test filename
231
232/*
233 * Set parameters of current checking
234 *
235 * arg0 - absolute index of file initiating the checking
236 * arg1 - name of Method initiating the checking
237 * arg2 - index of checking (inside the file)
238 *
239 * ATTENTION:
240 * These globals are introduced due to the lack of
241 * parameters of ASL-Method (7).
242 * Sometimes these parameters may mislead, because
243 * may be redirected by the following more deeper
244 * calls. We don't restore the previous values - it
245 * would be too complicated.
246 *
247 * Apply it when the common Methods are used and
248 * the initial Method which initialized the checking
249 * is somewhere in another file and there is no remained
250 * ArgX to pass that information.
251 *
252 * Apply it also when there are many entries with the
253 * "index of checking" in the same file. It is more
254 * convenient to arrange them inside the particular
255 * Methods than to update all them inside the entire
256 * file each time when it is needed to change any
257 * or add some new.
258 *
259 * Note:
260 * Due to the lack of ArgX the direct call to err()
261 * doesn't allow to print the "Name of Method initiating
262 * the checking". This is possible due to SET0 as well.
263 *
264 * Note:
265 * Dont attempt to set up the zero "index of checking"
266 * by this Method. It will be ignored and overwritten
267 * by arg4 of err().
268 *
269 * Note:
270 * Nevertheless, in any case, the err() provides
271 * not exact address of error but only hints where
272 * to seek the actual source Method of error.
273 */
274Method(SET0, 3) {
275	if (ERR0) {
276		err("SET0", z062, 0, 0, 0, ERR0, 0)
277	} else {
278		CopyObject(arg0, ERR0)
279		CopyObject(arg1, ERR1)
280		CopyObject(arg2, ERR2)
281	}
282}
283
284// Reset parameters of current checking
285Method(RST0) {
286	CopyObject(0, ERR0)
287	CopyObject(0, ERR1)
288	CopyObject(0, ERR2)
289	CopyObject(0, FNAM)
290}
291
292// Reset current indicator of errors
293Method(RST2) {
294	Store(0, ERR3)
295}
296
297// Get current indicator of errors
298Method(GET2) {
299	Return (ERR3)
300}
301
302// Collections of tests
303Name(TCLA, 0)	// compilation
304Name(TCLF, 1)	// functional
305Name(TCLC, 2)	// complex
306Name(TCLE, 3)	// exceptions
307Name(TCLD, 4)	// bug-demo (bdemo)
308Name(TCLS, 5)	// service
309Name(TCLM, 6)	// mt
310Name(TCLT, 7)	// Identity2MS
311Name(TCLI, 8)	// implementation dependent
312Name(MAXC, 8)	// equal to last maximal
313
314// Current index of tests collection
315Name(TCLL, 0)
316
317// Index of current test inside the collection
318Name(TIND, 0x12345678)
319
320// Name of test
321Name(TSNM, "NAME_OF_TEST")
322
323// Name of root method
324Name(NRMT, "")
325
326/*
327 * Flag, execution of root-method was skipped.
328 *
329 * It means that there where no conditions to run the test,
330 * the test was not run and the reported status is 'skipped'.
331 * The relevant assertion specified by the test is not to be
332 * verified under the particular conditions at all.
333 *
334 * For example, the test can be run only in 64-bit mode, in
335 * 32-bit mode the result of the test is undefined, so in
336 * 32-bit mode, dont run it but only report the status of
337 * test as skipped.
338 */
339Name(FLG5, 0)
340
341/*
342 * Flag, execution of root-method was blocked.
343 *
344 * It means that for some reason the test at present can not be run.
345 * The tests was not run and the relevant assertion was not verified.
346 * The test will be run when the conditions are changed. Up to that
347 * moment, the status of such test is reported as 'blocked'.
348 *
349 * For example, some tests temporarily cause abort of testing,
350 * thus preventing normal completion of all the tests of aslts
351 * and generating the summary status of run of aslts.
352 * To provide the normal conditions for other tests of aslts
353 * we block the tests which prevent normal work
354 * until the relevant causes are fixed in ACPICA.
355 */
356Name(FLG6, 0)
357
358/*
359 * Flag, compiler the test in the abbu layout
360 */
361Name(ABUU, 0)
362
363// Set global test filename
364Method(SETF, 1) {
365    CopyObject(arg0, FNAM)
366}
367
368/*
369 * Test Header - Display common test header
370 *
371 * Arg0 - Name of test (RT25, etc)
372 * Arg1 - Full Name of test ("Resource Descriptor Macro", etc.)
373 * Arg2 - Test filename (via __FILE__ macro)
374 */
375Method (THDR, 3)
376{
377    // Save the test filename in the FNAM global
378	SETF (Arg2)
379
380	// Build output string and store to debug object
381    Concatenate ("TEST: ", Arg0, Local1)
382    Concatenate (Local1, ", ", Local2)
383    Concatenate (Local2, Arg1, Local3)
384    Concatenate (Local3, " (", Local4)
385    Concatenate (Local4, Arg2, Local5)
386    Concatenate (Local5, ")", Local6)
387
388    Store (Local6, Debug)
389}
390
391
392// Report completion of root Method
393Method(RPT0) {
394
395	// To get the same view in both 32-bit and 64-bit modes
396	Name(b000, Buffer(4) {})
397
398	if (SizeOf(NRMT)) {
399
400		// Analize previous run of root Method
401
402		Concatenate(":", TCN0(TCLL), Local1)
403		Concatenate(Local1, ":", Local0)
404		Concatenate(Local0, TNIC(TCLL, TIND), Local1)
405		Concatenate(Local1, ":", Local0)
406		Concatenate(Local0, NRMT, Local1)
407		Concatenate(Local1, ":", Local0)
408
409		Subtract(ERRS, ERR5, Local7)
410
411		if (FLG5) {
412			Concatenate(Local0, "SKIPPED:", Local1)
413		} elseif (FLG6) {
414			Concatenate(Local0, "BLOCKED:", Local1)
415		} elseif (Local7) {
416			Concatenate(Local0, "FAIL:Errors # ", Local2)
417			Store(Local7, b000)
418			Concatenate(Local2, b000, Local0)
419			Concatenate(Local0, ":", Local1)
420			Increment(ERR6)
421		} else {
422			Concatenate(Local0, "PASS:", Local1)
423		}
424
425		Concatenate(":", CTST, Local0)
426		Concatenate(Local0, Local1, Local2)
427
428		Store(Local2, Debug)
429
430		if (LLess(RMRC, ETR0)) {
431			Concatenate(":", STST, Local2)
432			Concatenate(Local2, Local1, Local0)
433			Store(Local0, Index(RP0P, RMRC))
434		}
435
436		Increment(RMRC)
437	}
438	Store(0, ERR5)
439	Store(0, FLG5)
440	Store(0, FLG6)
441}
442
443// Set the name of current root method
444Method(SRMT, 1) {
445
446	// Report completion of previous root Method
447	RPT0()
448
449	// Current number of errors
450	Store(ERRS, ERR5)
451
452	if (1) {
453		Concatenate(arg0, " test started", Debug)
454	}
455
456	Store(arg0, NRMT)
457}
458
459/*
460 * Set 'skipped' status of execution of root method.
461 * Used only to report that the root-method was not
462 * run but skipped.
463 */
464Method(SKIP) {
465	Store(1, FLG5)
466}
467
468/*
469 * Set 'blocked' status of execution of root method.
470 * Used only to report that the root-method was not
471 * run, it was blocked.
472 */
473Method(BLCK) {
474	Store(1, FLG6)
475}
476
477/*
478 * Open sub-test
479 *
480 * arg0 - absolute index of file initiating the checking
481 * arg1 - the name of Method initiating the checking
482 */
483Method(BEG0, 2) {
484	SET0(arg0, arg1, 0)
485}
486
487// Close sub-test
488Method(END0) {
489	RST0()
490}
491
492/*
493 * Current test start
494 * arg0 - name of test
495 * arg1 - index of tests collection
496 * arg2 - index of test inside the collection
497 * arg3 - run mode parameter of test
498 */
499Method(STTT, 4) {
500	Store(arg0, TSNM)
501	Store(arg1, TCLL)
502	Store(arg2, TIND)
503
504	Store("", NRMT)
505	Store(0, FLG5)
506	Store(0, FLG6)
507	Store(0, ERR5)
508
509	// Pack up ID of test case to use it in err()
510	Store(PK00(arg1, arg2), ERRB)
511
512	// Initial work for any test
513
514	Concatenate("TEST (", TCN0(TCLL), Local1)
515	Concatenate(Local1, "), ", Local0)
516	Concatenate(Local0, TSNM, Local1)
517
518	if (RTPT) {
519
520		// Run Tests Parameters Technique (RTPT)
521		// When running a group of tests (collections), full*
522
523		Store(0, Local7)
524		if (LEqual(RUN0, 0)) {
525			Store(1, Local7)
526		} elseif (LEqual(RUN0, 1)) {
527			if (arg3) {
528				Store(1, Local7)
529			}
530		} elseif (LEqual(RUN0, 2)) {
531			if (LEqual(arg3, 0)) {
532				Store(1, Local7)
533			}
534		} elseif (LEqual(RUN0, 3)) {
535			if (LEqual(arg3, RUN1)) {
536				Store(1, Local7)
537			}
538		} elseif (LEqual(RUN0, 4)) {
539			if (LEqual(arg1, RUN2)) {
540				if (LEqual(arg2, RUN3)) {
541					Store(1, Local7)
542				}
543			}
544		}
545	} else {
546		Store(1, Local7)
547	}
548
549	if (LNot(Local7)) {
550		Concatenate(Local1, ", SKIPPED", Local0)
551		Store(Local0, Local1)
552	}
553
554	Store(Local1, Debug)
555
556	return (Local7)
557}
558
559// Current test finish
560Method(FTTT) {
561	CH03("FTTT", 0, 0, 0, 0)
562
563	// Report completion of previous root Method
564	RPT0()
565
566	Store("NAME_OF_TEST", TSNM)
567	Store(0, TCLL)
568	Store(0x12345678, TIND)
569	Store("", NRMT)
570	Store(0, FLG5)
571	Store(0, FLG6)
572	Store(0, ERR5)
573}
574
575/*
576 * Pack up ID of test case
577 *
578 * arg0 - index of tests collection
579 * arg1 - index of test inside the collection
580 */
581Method(PK00, 2)
582{
583	And(arg0, 0x0f, Local0)
584	And(arg1, 0x1f, Local1)
585	ShiftLeft(Local0, 5, Local2)
586	Or(Local2, Local1, Local0)
587	ShiftLeft(Local0, 23, Local7)
588	return (Local7)
589}
590
591/*
592 * Pack up information of checking
593 *
594 * arg0 - absolute index of file initiating the checking
595 * arg1 - index of checking (inside the file)
596 */
597Method(PK01, 2)
598{
599	And(arg0, 0x07ff, Local0)
600	And(arg1, 0x0fff, Local1)
601	ShiftLeft(Local0, 12, Local2)
602	Or(Local2, Local1, Local7)
603
604	return (Local7)
605}
606
607/*
608 * Pack up index of bug
609 *
610 * arg0 - index of bug
611 */
612Method(PK02, 1)
613{
614	And(arg0, 0x1ff, Local0)
615	ShiftLeft(Local0, 23, Local7)
616
617	return (Local7)
618}
619
620/*
621 * Pack up information of error
622 *
623 * arg0 - absolute index of file reporting the error
624 * arg1 - index of error (inside the file)
625 */
626Method(PK03, 2)
627{
628	And(arg0, 0x07ff, Local0)
629	And(arg1, 0x0fff, Local1)
630	ShiftLeft(Local0, 12, Local2)
631	Or(Local2, Local1, Local7)
632	return (Local7)
633}
634
635
636/*
637 * Errors processing
638 *
639 * NOTE: looks we have exceeded some of the fields below
640 *       but don't actually use them though pack them up.
641 *
642 * The layout of opcode of error (three 32-bit words)
643 *
644 * Word 0) 0xctfffeee (information of error)
645 *
646 * [31:28,4]   - c   0xf0000000
647 * [27:23,5]   - t   0x0f800000
648 * [22:12,11]  - fff 0x007ff000
649 * [11:0,12]   - eee 0x00000fff
650 *
651 * Word 1) 0xmmzzzuuu (information of checking)
652 *
653 * [31:23,9]   - m   0xff800000
654 * [22:12,11]  - zzz 0x007ff000
655 * [11:0,12]   - uuu 0x00000fff
656 *
657 * Word 2) 0xnnnnnnnn (name of method)
658 *
659 *   c - index of tests collection
660 *   t - index of test inside the collection
661 *   f - absolute index of file reporting the error
662 *   e - index of error (inside the file)
663 *
664 *   z - absolute index of file initiating the checking
665 *   u - index of checking
666 *   m - miscellaneous:
667 *       1) in case of TCLD tests there is an index of bug
668 *
669 *   n - name of Method initiating the checking
670 *
671 * arg0 - diagnostic message (usually, the name of method conglomeration of tests)
672 * arg1 - absolute index of file reporting the error
673 * arg2 - index of error (inside the file)
674 * arg3 - absolute index of file initiating the checking
675 * arg4 - index of checking (inside the file)
676 * arg5 - first value (usually, received value)
677 * arg6 - second value (usually, expected value)
678 */
679
680Method(err, 7)
681{
682	Store(0, Local3)
683	Store(0, Local6)
684
685	if (ERR0) {
686
687		// ERR0 (Local4) - absolute index of file initiating the checking
688		// ERR1 (Local3) - name of Method initiating the checking
689		// ERR2 (Local5) - index of checking
690
691		Store(ERR0, Local4)
692		Store(ERR1, Local3)
693
694		// Dont attempt to set up the zero "index of checking"
695		// by SET0. It will be ignored and overwritten by arg4
696		// of err().
697
698		if (ERR2) {
699			Store(ERR2, Local5)
700		} else {
701			Store(arg4, Local5)
702		}
703
704	} else {
705		Store(0, Local4)
706		Store(arg4, Local5)
707		if (LEqual(TCLL, TCLD)) {
708			if (Local5) {
709				Store(zFFF, Local4)
710			}
711		} else {
712			Store(arg3, Local4)
713		}
714		if (LEqual(ObjectType(arg0), c00a)) {
715			Store(arg0, Local3)
716		}
717	}
718
719	if (Local4) {
720		// Pack up information of checking
721		Store(PK01(Local4, Local5), Local6)
722	}
723
724	if (LEqual(TCLL, TCLD)) {
725
726		// Pack up index of bug
727		Store(PK02(TIND), Local0)
728		Or(Local6, Local0, Local6)
729	}
730
731	// Pack up information of error
732	Store(PK03(arg1, arg2), Local0)
733
734	// Add ID of test case being executed
735	Or(ERRB, Local0, Local7)
736
737	Concatenate("---------- ERROR    : 0x", Local7, Local1)
738	Concatenate(", 0x", Local6, Local2)
739	Concatenate(Local1, Local2, Local0)
740	Concatenate(Local0, ", ", Local1)
741	Concatenate(Local1, arg0, Local0)
742	Store(Local0, Debug)
743
744	ERP0(arg1, arg2, Local4, Local3, Local5)
745
746    if (LEqual (ObjectType (arg5), 1)) // Check for Integer
747    {
748        /* Format/print the Expected result value */
749
750        ToHexString (arg6, Local0)
751        ToDecimalString (arg6, Local1)
752
753        Concatenate ("**** Expected Result: 0x", Local0, Local0)
754        Concatenate (Local0, ", (", Local0)
755        Concatenate (Local0, Local1, Local0)
756        Concatenate (Local0, ")", Local0)
757        Store (Local0, Debug)
758
759         /* Format/print the Actual result value */
760
761        ToHexString (arg5, Local0)
762        ToDecimalString (arg5, Local1)
763
764        Concatenate ("**** Actual Result  : 0x", Local0, Local0)
765        Concatenate (Local0, ", (", Local0)
766        Concatenate (Local0, Local1, Local0)
767        Concatenate (Local0, ")", Local0)
768        Store (Local0, Debug)
769   }
770    else
771    {
772	    Store("**** Actual Result:", Debug)
773	    Store(arg5, Debug)
774	    Store("**** Expected Result:", Debug)
775	    Store(arg6, Debug)
776    }
777	Store("---------- END\n", Debug)
778
779	// Pack the summary information about the first N errors
780
781	if (LLess(ERRS, ETR1)) {
782		Multiply(ERRS, 3, Local0)
783		Store(Local7, Index(ERRP, Local0)) // information of error
784		Increment(Local0)
785		Store(Local6, Index(ERRP, Local0)) // information of checking
786		Increment(Local0)
787		Store(Local3, Index(ERRP, Local0)) // name of method
788	}
789
790	Increment(ERRS)
791
792	// Set current indicator of errors
793	Store(1, ERR3)
794}
795
796/*
797 * Report parameters of error
798 * arg0 - absolute index of file reporting the error
799 * arg1 - index of error
800 * arg2 - absolute index of file initiating the checking
801 * arg3 - name of Method initiating the checking
802 * arg4 - index of checking
803 */
804Method(ERP0, 5)
805{
806	Concatenate("TITLE               : ", TSNM, Local0)
807	Store(Local0, Debug)
808
809	Concatenate("COLLECTION          : ", TCN0(TCLL), Local0)
810	Store(TNIC(TCLL, TIND), Local1)
811
812	Store(Local0, Debug)
813
814	Concatenate("TEST CASE           : ", Local1, Local0)
815	Store(Local0, Debug)
816
817	Concatenate("TEST                : ", NRMT, Local0)
818	Store(Local0, Debug)
819
820	// Error
821
822    if (LNotEqual (FNAM, 0))
823    {
824        // Use global filename, set via SETF
825        Store (FNAM, Local1)
826    }
827	elseif (LEqual(arg0, zFFF)) {
828
829		// ATTENTION: dont use zFFF in tests other than TCLD
830
831		Store(SB00(TIND, 0), Local1)
832	} else {
833		Store(DeRefOf(Index(TFN0, arg0)), Local1)
834	}
835	Concatenate("ERROR,    File      : ", Local1, Local0)
836	Store(Local0, Debug)
837
838	Concatenate("          Index     : 0x", arg1, Local0)
839	Concatenate(Local0, ", (", Local0)
840	Concatenate(Local0, ToDecimalString (arg1), Local0)
841	Concatenate(Local0, ")", Local0)
842	Store(Local0, Debug)
843
844	// Checking
845
846	if (arg2) {
847		if (LEqual(arg2, zFFF)) {
848			// ATTENTION: dont use zFFF in tests other than TCLD
849			Store(SB00(TIND, 0), Local1)
850		} else {
851			Store(DeRefOf(Index(TFN0, arg2)), Local1)
852		}
853
854		Concatenate("CHECKING, File      : ", Local1, Local0)
855		Store(Local0, Debug)
856
857		if (LEqual(ObjectType(arg3), c00a)) {
858			Concatenate("             Method : ", arg3, Local0)
859			Store(Local0, Debug)
860		}
861
862		Concatenate("             Index  : ", arg4, Local0)
863		Store(Local0, Debug)
864	}
865}
866
867/*
868 * Service for bug-demo.
869 *
870 * arg0 - index of bug
871 * arg1 - type of work:
872 *          0 - return the name of test corresponding to bug-demo
873 *          1 - return the name of file ..
874 */
875Method(SB00, 2) {
876
877	Store("?", Local7)
878
879	if (LEqual(arg1, 0)) {
880		ToDecimalString(arg0, Local0)
881		Concatenate("*", Local0, Local1)
882		Concatenate(Local1, ".asl", Local7)
883	} elseif (LEqual(arg1, 1)) {
884		ToDecimalString(arg0, Local0)
885		Concatenate("Demo of bug ", Local0, Local7)
886	}
887
888	return (Local7)
889}
890
891// Print out the whole contents, not only 32 bytes as debugger does
892Method(prn0, 1, Serialized) {
893
894	Name(lpN0, 0)
895	Name(lpC0, 0)
896
897	Store(SizeOf(arg0), lpN0)
898	Store(0, lpC0)
899
900	While (lpN0) {
901		Store(DeRefOf(Index(arg0, lpC0)), Local0)
902		Store(Local0, Debug)
903		Decrement(lpN0)
904		Increment(lpC0)
905	}
906}
907
908/*
909 * Check result of operation on equal to Zero
910 * arg0 - message of error
911 * arg1 - arg5 of err, "received value"
912 * arg2 - arg6 of err, "expected value"
913 * arg3 - value
914 */
915Method(CH00, 4)
916{
917	if (LNotEqual(arg3, Zero)) {
918		err(arg0, z062, 1, 0, 0, arg1, arg2)
919	}
920}
921
922/*
923 * Check result of operation on equal to Non-Zero (Ones)
924 * arg0 - message of error
925 * arg1 - arg5 of err, "received value"
926 * arg2 - arg6 of err, "expected value"
927 * arg3 - value
928 */
929Method(CH01, 4)
930{
931	if (LNotEqual(arg3, Ones)) {
932		err(arg0, z062, 2, 0, 0, arg1, arg2)
933	}
934}
935
936/*
937 * True, when the value is in range
938 *
939 * arg0 - Value
940 * arg1 - RangeMin
941 * arg2 - RangeMax
942 */
943Method(RNG0, 3)
944{
945	if (LGreater(arg1, arg2)) {
946		Store("RNG0: RangeMin greater than RangeMax", Debug)
947		Fatal(0, 0, 0) // Type, Code, Arg
948	}
949	if (LGreater(arg1, arg0)) {
950		return (Zero)
951	} else {
952		if (LGreater(arg0, arg2)) {
953			return (Zero)
954		}
955	}
956	return (Ones)
957}
958
959// 200 symbols (without '\0')
960Name(BIG0, "qwertyuiopasdfghjklzxcvbnm1234567890QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm1234567890QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm1234567890QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdf")
961
962// All symbols
963Name(ALL0, "`1234567890-=qwertyuiop[]\\asdfghjkl;'zxcvbnm,./~!@#$%^&*()_+QWERTYUIOP{}|ASDFGHJKL:\"ZXCVBNM<>?")
964
965// Check all the constants are not corrupted
966Method(CST0)
967{
968	if (LNotEqual(c000, 10)) {
969		err("c000 corrupted", z062, 3, 0, 0, 0, 0)
970	}
971	if (LNotEqual(c001, 5)) {
972		err("c001 corrupted", z062, 4, 0, 0, 0, 0)
973	}
974
975	if (LNotEqual(c002, 13)) {
976		err("c002 corrupted", z062, 5, 0, 0, 0, 0)
977	}
978	if (LNotEqual(c003, 12)) {
979		err("c003 corrupted", z062, 6, 0, 0, 0, 0)
980	}
981	if (LNotEqual(c004, 6)) {
982		err("c004 corrupted", z062, 7, 0, 0, 0, 0)
983	}
984	if (LNotEqual(c005, 4)) {
985		err("c005 corrupted", z062, 8, 0, 0, 0, 0)
986	}
987	if (LNotEqual(c006, 31)) {
988		err("c006 corrupted", z062, 9, 0, 0, 0, 0)
989	}
990	if (LNotEqual(c007, 51)) {
991		err("c007 corrupted", z062, 10, 0, 0, 0, 0)
992	}
993
994	if (LNotEqual(c008, 0)) {
995		err("c008 corrupted", z062, 11, 0, 0, 0, 0)
996	}
997	if (LNotEqual(c009, 1)) {
998		err("c009 corrupted", z062, 12, 0, 0, 0, 0)
999	}
1000	if (LNotEqual(c00a, 2)) {
1001		err("c00a corrupted", z062, 13, 0, 0, 0, 0)
1002	}
1003	if (LNotEqual(c00b, 3)) {
1004		err("c00b corrupted", z062, 14, 0, 0, 0, 0)
1005	}
1006	if (LNotEqual(c00c, 4)) {
1007		err("c00c corrupted", z062, 15, 0, 0, 0, 0)
1008	}
1009	if (LNotEqual(c00d, 5)) {
1010		err("c00d corrupted", z062, 16, 0, 0, 0, 0)
1011	}
1012	if (LNotEqual(c00e, 6)) {
1013		err("c00e corrupted", z062, 17, 0, 0, 0, 0)
1014	}
1015	if (LNotEqual(c00f, 7)) {
1016		err("c00f corrupted", z062, 18, 0, 0, 0, 0)
1017	}
1018	if (LNotEqual(c010, 8)) {
1019		err("c010 corrupted", z062, 19, 0, 0, 0, 0)
1020	}
1021	if (LNotEqual(c011, 9)) {
1022		err("c011 corrupted", z062, 20, 0, 0, 0, 0)
1023	}
1024	if (LNotEqual(c012, 10)) {
1025		err("c012 corrupted", z062, 21, 0, 0, 0, 0)
1026	}
1027	if (LNotEqual(c013, 11)) {
1028		err("c013 corrupted", z062, 22, 0, 0, 0, 0)
1029	}
1030	if (LNotEqual(c014, 12)) {
1031		err("c014 corrupted", z062, 23, 0, 0, 0, 0)
1032	}
1033	if (LNotEqual(c015, 13)) {
1034		err("c015 corrupted", z062, 24, 0, 0, 0, 0)
1035	}
1036	if (LNotEqual(c016, 14)) {
1037		err("c016 corrupted", z062, 25, 0, 0, 0, 0)
1038	}
1039	if (LNotEqual(c017, 15)) {
1040		err("c017 corrupted", z062, 26, 0, 0, 0, 0)
1041	}
1042	if (LNotEqual(c018, 16)) {
1043		err("c018 corrupted", z062, 27, 0, 0, 0, 0)
1044	}
1045	if (LNotEqual(c019, 17)) {
1046		err("c019 corrupted", z062, 28, 0, 0, 0, 0)
1047	}
1048}
1049
1050/*
1051 * Shift elements of buffer
1052 * <buf>,
1053 * <byte size of buf>,
1054 * <cmd: 0 - left, 1 - right>
1055 * <n shift: {1-7}>
1056 */
1057Method(sft0, 4, Serialized)
1058{
1059	Name(n000, 0)
1060	Name(ncur, 0)
1061
1062	Store(arg1, n000)
1063	Store(0, ncur)
1064
1065	Store(0, Local6)
1066
1067	if (arg2) {
1068		Store(arg3, Local3)
1069		Subtract(8, Local3, Local5)
1070	} else {
1071		Store(arg3, Local5)
1072		Subtract(8, Local5, Local3)
1073	}
1074
1075	Store(arg1, Local0)
1076	Increment(Local0)
1077	Name(b000, Buffer(Local0) {})
1078
1079	While (n000) {
1080		Store(DeRefOf(Index(arg0, ncur)), Local0)
1081		ShiftRight(Local0, Local3, Local1)
1082		And(Local1, 0xff, Local2)
1083		Or(Local2, Local6, Local1)
1084		ShiftLeft(Local0, Local5, Local4)
1085		And(Local4, 0xff, Local6)
1086		Store(Local1, Index(b000, ncur))
1087		Decrement(n000)
1088		Increment(ncur)
1089	}
1090
1091	Store(Local6, Index(b000, ncur))
1092
1093	// Store(arg0, Debug)
1094	// Store(b000, Debug)
1095
1096	return (b000)
1097}
1098
1099/*
1100 * The entire byte size of buffer (starting with the
1101 * first byte of buffer, not field) affected by field.
1102 *
1103 * <index of bit>,
1104 * <num of bits>,
1105 */
1106Method(MBS0, 2)
1107{
1108	Add(arg0, arg1, Local0)
1109	Add(Local0, 7, Local1)
1110	Divide(Local1, 8, Local2, Local0)
1111
1112	return (Local0)
1113}
1114
1115/*
1116 * Bit-shift (0-7) elements of buffer
1117 *
1118 * <buf>,
1119 * <n shift: {0-7}>
1120 * <bit size of shift area>,
1121 * <source value of first byte>,
1122 * <source value of last byte>,
1123 */
1124Method(sft1, 5, Serialized)
1125{
1126	Name(prev, 0)
1127	Name(ms00, 0)
1128	Name(ms01, 0)
1129	Name(ms02, 0)
1130	Name(ms03, 0)
1131	Name(tail, 0)
1132	Name(lbt0, 0)
1133
1134	// Loop 0
1135	Name(lpN0, 0)
1136	Name(lpC0, 0)
1137
1138	// Byte size of result buffer
1139	Name(nb01, 0)
1140
1141	// Reqular processed bytes number
1142	Name(nreg, 0)
1143
1144	// Bit-size of low part of byte
1145	Name(nb08, 0)
1146	// Bit-size of high part of byte
1147	Name(nb09, 0)
1148	// Bit-size of last byte
1149	Name(rest, 0)
1150
1151	if (LLess(arg2, 1)) {
1152		err("sft", z062, 29, 0, 0, arg2, 1)
1153		return (Ones)
1154	}
1155
1156	if (LGreater(arg1, 7)) {
1157		err("sft", z062, 30, 0, 0, arg1, 7)
1158		return (Ones)
1159	}
1160
1161	Store(MBS0(arg1, arg2), nb01)
1162
1163	Name(b000, Buffer(nb01) {})
1164
1165	// Layout of regulsr bytes
1166	Store(arg1, nb08)
1167	Subtract(8, nb08, nb09)
1168
1169	// Produce masks of regulsr byte
1170	ShiftRight(0xff, nb08, Local0)
1171	ShiftLeft(Local0, nb08, ms01)
1172	Not(ms01, ms00)
1173
1174	// Last byte size
1175	Add(arg1, arg2, Local7)
1176	Mod(Local7, 8, rest)
1177	if (LEqual(rest, 0)) {
1178		Store(8, rest)
1179	}
1180
1181	// Substitute field usually determined on previous step
1182	And(arg3, ms00, prev)
1183
1184	// Reqular processing repetition number
1185	if (LGreaterEqual(arg2, nb09)) {
1186		Store(1, nreg)
1187		Subtract(arg2, nb09, Local7)
1188		Divide(Local7, 8, Local1, Local0)
1189		Add(nreg, Local0, nreg)
1190	}
1191
1192	// Regular processing
1193
1194	Store(nreg, lpN0)
1195	Store(0, lpC0)
1196	While (lpN0) {
1197
1198		Store(DeRefOf(Index(arg0, lpC0)), Local7)
1199		ShiftLeft(Local7, nb08, Local0)
1200		Or(Local0, prev, Local1)
1201		Store(Local1, Index(b000, lpC0))
1202		ShiftRight(Local7, nb09, prev)
1203
1204		Decrement(lpN0)
1205		Increment(lpC0)
1206	}
1207
1208	if (LEqual(rest, 8)) {
1209		Store(0, tail)
1210	} elseif (LLessEqual(rest, nb08)) {
1211		Store(1, tail)
1212	} else {
1213		Store(2, tail)
1214		Store(DeRefOf(Index(arg0, lpC0)), lbt0)
1215	}
1216
1217	// ===================
1218	// Processing the tail
1219	// ===================
1220
1221	if (LEqual(tail, 1)) {
1222
1223		// Produce masks
1224		ShiftRight(0xff, rest, Local0)
1225		ShiftLeft(Local0, rest, ms03)
1226		Not(ms03, ms02)
1227
1228		And(prev, ms02, Local0)
1229		And(arg4, ms03, Local1)
1230		Or(Local0, Local1, Local2)
1231
1232		Store(Local2, Index(b000, lpC0))
1233
1234	} elseif (LEqual(tail, 2)) {
1235
1236		And(prev, ms00, Local0)
1237		ShiftLeft(lbt0, nb08, Local1)
1238		Or(Local0, Local1, Local7)
1239
1240		/*
1241		 * Byte layout:
1242		 * 000011112222
1243		 * rem sz  nb08
1244		 * 33333333
1245		 * nb09
1246		 *     44444444
1247		 *     rest
1248		 */
1249
1250		// Produce masks of rem field
1251		ShiftRight(0xff, rest, Local2)
1252		ShiftLeft(Local2, rest, Local0)
1253		Not(Local0, Local1)
1254
1255		// Determine contents of field
1256		And(Local7, Local1, Local2)
1257
1258		// Remained of original last (first) byte
1259		And(arg4, Local0, Local3)
1260
1261		// Result
1262		Or(Local2, Local3, Local0)
1263
1264		Store(Local0, Index(b000, lpC0))
1265	}
1266
1267	return (b000)
1268}
1269
1270/*
1271 * Verify result
1272 *
1273 * arg0 - name of test
1274 * arg1 - result
1275 * arg2 - expected value (64-bit mode)
1276 * arg3 - expected value (32-bit mode)
1277 * DISADVANTAGE: information about the actual place
1278 *               in errors reports is lost, should be
1279 *               resolved in the future.
1280 */
1281Method(m4c0, 4, Serialized)
1282{
1283	Name(tmp0, 0)
1284	Name(tmp1, 0)
1285
1286	Store(0, Local7)
1287
1288	Store(ObjectType(arg1), tmp0)
1289
1290	if (F64) {
1291		Store(ObjectType(arg2), tmp1)
1292		if (LNotEqual(tmp0, tmp1)) {
1293			err(arg0, z062, 31, 0, 0, tmp0, tmp1)
1294			Store(1, Local7)
1295		} elseif (LNotEqual(arg1, arg2)) {
1296			err(arg0, z062, 32, 0, 0, arg1, arg2)
1297			Store(1, Local7)
1298		}
1299	} else {
1300		Store(ObjectType(arg3), tmp1)
1301		if (LNotEqual(tmp0, tmp1)) {
1302			err(arg0, z062, 33, 0, 0, tmp0, tmp1)
1303			Store(1, Local7)
1304		} elseif (LNotEqual(arg1, arg3)) {
1305			err(arg0, z062, 34, 0, 0, arg1, arg3)
1306			Store(1, Local7)
1307		}
1308	}
1309
1310	return (Local7)
1311}
1312
1313/*
1314 * Return one-symbol string
1315 *
1316 * arg0 - source string contains desirable symbols
1317 * srg1 - index inside the source string
1318 */
1319Method(m4a1, 2, Serialized)
1320{
1321	Name(s000, " ")
1322	Store(DeRefOf(Index(arg0, arg1)), Local0)
1323	Store(Local0, Index(s000, 0))
1324	return (s000)
1325}
1326
1327// Initialization
1328Method(STRT, 1, Serialized)
1329{
1330	Method(m555)
1331	{
1332	}
1333
1334	/* Data to determine 32/64 mode, global because of mt-tests */
1335	DataTableRegion (HDR, "DSDT", "", "")
1336	Field(HDR, AnyAcc, NoLock, Preserve) {
1337		SIG, 32,
1338		LENG, 32,
1339		REV, 8,
1340		SUM, 8,
1341		OID, 48,
1342		OTID, 64,
1343		OREV, 32,
1344		CID, 32,
1345		CREV, 32,
1346	}
1347
1348	/*
1349	 * The first fictitious Method execution which statistics
1350	 * is then used for to estimate all other Methods executions.
1351	 */
1352	m555()
1353
1354	Store(Timer, tmt0)
1355
1356	If (LLess (REV, 2)) {
1357		Store(0, F64)
1358		Store(4, ISZ0)
1359		Store(8, ISZC)
1360		Store ("32-bit mode", Debug)
1361	} else {
1362		Store(1, F64)
1363		Store(8, ISZ0)
1364		Store(16, ISZC)
1365		Store ("64-bit mode", Debug)
1366	}
1367
1368	/*
1369	 * Check that the total number of exceptions is zero here.
1370	 * The internal data about the exceptions initiated by some
1371	 * bdemo tests on a global level should be reset by them to
1372	 * this point as they didn't take place. Otherwise, an error
1373	 * will be below registrated.
1374	 */
1375	if (CH02()) {
1376		Increment(ERR7)
1377
1378		/* Reset internal information about exceptions */
1379
1380		CH03("", 0, 0x888, 0, 0)
1381		Store(0, EXC0)
1382		Store(0, EXC1)
1383	}
1384
1385	SRTP(arg0)
1386
1387	RTPI()
1388
1389	RST0()
1390	RST2()
1391
1392	/* Adjust some skippings of tests for different ACPICA releases */
1393	SET2(SETN)
1394}
1395
1396Name(TCNP, Package() {
1397	"compilation",
1398	"functional",
1399	"complex",
1400	"exceptions",
1401	"bdemo",
1402	"service",
1403	"mt",
1404	"Identity2MS",
1405	"IMPL",
1406})
1407
1408/*
1409 * Test collection name
1410 * arg0 - index of test collection
1411 */
1412Method(TCN0, 1) {
1413	Store("?", Local7)
1414	if (LLessEqual(arg0, MAXC)) {
1415		Store(DerefOf(Index(TCNP, arg0)), Local7)
1416	}
1417	Return(Local7)
1418}
1419
1420/*
1421 * Name of test inside collection
1422 * arg0 - index of test collection
1423 * arg1 - index of test inside the collection
1424 */
1425Method(TNIC, 2, Serialized) {
1426	Store("?", Local7)
1427	switch (ToInteger (arg0)) {
1428		case (1) {
1429			Store(DeRefOf(Index(TNF0, arg1)), Local7)
1430		}
1431		case (2) {
1432			Store(DeRefOf(Index(TNC0, arg1)), Local7)
1433		}
1434		case (3) {
1435			Store(DeRefOf(Index(TNE0, arg1)), Local7)
1436		}
1437		case (4) {
1438			Store(SB00(arg1, 1), Local7)
1439		}
1440		case (5) {
1441			Store(DeRefOf(Index(TNS0, arg1)), Local7)
1442		}
1443		case (6) {
1444			Store(DeRefOf(Index(TNM0, arg1)), Local7)
1445		}
1446		case (7) {
1447			Store(DeRefOf(Index(TNT0, arg1)), Local7)
1448		}
1449		case (8) {
1450			Store(DeRefOf(Index(TNI0, arg1)), Local7)
1451		}
1452	}
1453
1454	Return(Local7)
1455}
1456
1457// Names of functional tests
1458Name(TNF0, Package() {
1459	"arithmetic",
1460	"bfield",
1461	"constant",
1462	"control",
1463	"descriptor",
1464	"extern",
1465	"local",
1466	"logic",
1467	"manipulation",
1468	"name",
1469	"reference",
1470	"region",
1471	"synchronization",
1472	"table",
1473	"module"
1474})
1475
1476// Names of complex tests
1477Name(TNC0, Package() {
1478	"misc",
1479	"provoke",
1480	"oarg",
1481	"oconst",
1482	"olocal",
1483	"oreturn",
1484	"onamedloc",
1485	"onamedglob",
1486	"opackageel",
1487	"oreftonamed",
1488	"oconversion",
1489	"oreftopackageel",
1490	"rstore",
1491	"roptional",
1492	"rconversion",
1493	"rcopyobject",
1494	"rindecrement",
1495	"rexplicitconv",
1496	"badasl",
1497	"namespace"
1498})
1499
1500// Names of exceptions tests
1501Name(TNE0, Package() {
1502	"exc",
1503	"exc_operand1",
1504	"exc_operand2",
1505	"exc_result1",
1506	"exc_result2",
1507	"exc_ref",
1508	"exc_tbl"
1509})
1510
1511// Names of service tests
1512Name(TNS0, Package() {
1513	"condbranches"
1514})
1515
1516// Names of mt tests
1517Name(TNM0, Package() {
1518	"mt-mutex"
1519})
1520
1521// Names of Identity2MS tests
1522Name(TNT0, Package() {
1523	"abbu"
1524})
1525
1526// Names of IMPL tests
1527Name(TNI0, Package() {
1528	"dynobj"
1529})
1530
1531// Names of test files
1532Name(TFN0, Package() {
1533	"UNDEF",		// 0
1534	"crbuffield.asl",
1535	"constants.asl",
1536	"ctl0.asl",
1537	"ctl1.asl",
1538	"ctl2.asl",
1539	"timing.asl",
1540	"concatenaterestemplate.asl",
1541	"dependentfn.asl",
1542	"dma.asl",
1543	"dwordio.asl",
1544	"dwordmemory.asl",
1545	"dwordspace.asl",
1546	"extendedio.asl",
1547	"extendedmemory.asl",
1548	"extendedspace.asl",
1549	"fixedio.asl",
1550	"interrupt.asl",
1551	"io.asl",
1552	"irq.asl",
1553	"irqnoflags.asl",
1554	"memory24.asl",
1555	"memory32.asl",
1556	"memory32fixed.asl",
1557	"qwordio.asl",
1558	"qwordmemory.asl",	// 25
1559	"qwordspace.asl",
1560	"register.asl",
1561	"resourcetemplate.asl",
1562	"rtemplate.asl",
1563	"vendorlong.asl",
1564	"vendorshort.asl",
1565	"wordbusnumber.asl",
1566	"wordio.asl",
1567	"wordspace.asl",
1568	"logical.asl",
1569	"concatenate.asl",
1570	"eisaid.asl",
1571	"match1.asl",
1572	"mid.asl",
1573	"objecttype.asl",
1574	"sizeof.asl",
1575	"store.asl",
1576	"tobuffer.asl",
1577	"todecimalstring.asl",
1578	"tofrombcd.asl",
1579	"tohexstring.asl",
1580	"tointeger.asl",
1581	"tostring.asl",
1582	"touuid.asl",
1583	"unicode.asl",	// 50
1584	"package.asl",
1585	"event.asl",
1586	"mutex.asl",
1587	"misc.asl",
1588	"provoke.asl",
1589	"oconversion.asl",
1590	"rconversion.asl",
1591	"exc.asl",
1592	"exc_operand1.asl",
1593	"exc_result.asl",
1594	"XXXXXX.asl",	// 61 - RESERVED, not in use
1595	"common.asl",
1596	"ehandle.asl",
1597	"oproc.asl",
1598	"otest.asl",
1599	"rproc.asl",
1600	"rtest.asl",
1601	"switch1.asl",
1602	"switch2.asl",
1603	"switch3.asl",
1604	"switch4.asl",
1605	"switch5.asl",
1606	"switch6.asl",
1607	"while.asl",
1608	"match2.asl",
1609	"ref00.asl",
1610	"ref01.asl",
1611	"ref02.asl",
1612	"ref03.asl",
1613	"ref04.asl",
1614	"ref70.asl",
1615	"operations.asl",
1616	"arithmetic.asl",
1617	"ocommon.asl",
1618	"oconst.asl",
1619	"onamedglob1.asl",
1620	"onamedglob2.asl",
1621	"onamedloc1.asl",
1622	"onamedloc2.asl",
1623	"opackageel.asl",
1624	"oreftonamed1.asl",
1625	"exc_00_undef.asl",
1626	"exc_01_int.asl",
1627	"exc_02_str.asl",
1628	"exc_03_buf.asl",
1629	"exc_04_pckg.asl",
1630	"exc_05_funit.asl",
1631	"exc_06_dev.asl",
1632	"exc_07_event.asl",
1633	"exc_08_method.asl",	// 100
1634	"exc_09_mux.asl",
1635	"exc_10_oreg.asl",
1636	"exc_11_pwr.asl",
1637	"exc_12_proc.asl",
1638	"exc_13_tzone.asl",
1639	"exc_14_bfield.asl",
1640	"exc_operand2.asl",
1641	"ref05.asl",
1642	"ref71.asl",
1643	"ref06.asl",
1644	"ref50.asl",
1645	"name.asl",
1646	"data.asl",
1647	"dataproc.asl",
1648	"datastproc.asl",
1649	"ref07.asl",		// 116
1650	"olocal.asl",
1651	"oreturn.asl",
1652	"oreftopackageel.asl",
1653	"oreftonamed2.asl",	// 120
1654	"oarg.asl",
1655	"rcommon.asl",
1656	"rstore.asl",
1657	"rcopyobject.asl",
1658	"rindecrement.asl",
1659	"rexplicitconv.asl",
1660	"roptional.asl",
1661	"tcicmd.asl",
1662	"dobexec.asl",
1663	"dobdecl.asl",	// 130
1664	"dobctl.asl",
1665	"dobexceptions.asl",
1666	"method.asl",
1667	"function.asl",
1668	"condbranches.asl",
1669	"add.asl",
1670	"standaloneRet.asl",
1671	"store.asl",
1672	"return.asl",
1673	"dobmisc.asl",	// 140
1674	"opregions.asl",
1675	"dtregions.asl",
1676	"regionfield.asl",
1677	"indexfield.asl",
1678	"bankfield.asl",
1679	"badasl.asl",
1680	"mt-common.asl",
1681	"mt-mutex.asl",
1682	"mt-mxs.asl",
1683	"mutex2.asl",	// 150
1684	"mutex_proc.asl",
1685	"mt-tests.asl",
1686	"mt-service.asl",
1687	"ns0.asl",
1688	"ns1.asl",
1689	"ns2.asl",
1690	"ns3.asl",
1691	"ns4.asl",
1692	"ns5.asl",
1693	"ns6.asl",			// 160
1694	"I2MS_msfail0.asl",
1695	"I2MS_st0.asl",
1696	"I2MS_ns_in00.asl",
1697	"I2MS_ns_in10.asl",
1698	"I2MS_ns_in20.asl",
1699	"I2MS_ns_in30.asl",
1700	"I2MS_ns_in40.asl",
1701	"I2MS_ns_in50.asl",
1702	"I2MS_mt0_abbu.asl",
1703	"I2MS_mt0_aslts.asl",	// 170
1704	"I2MS_recursion_abbu.asl",
1705	"I2MS_recursion_aslts.asl",
1706	"serialized.asl",
1707	"load.asl",			// 174
1708	"unload.asl",
1709	"loadtable.asl",
1710	"recursion.asl",
1711	"ns-scope.asl",		// 178
1712	"ns-fullpath.asl",
1713	"scope.asl",
1714	"object.asl",
1715
1716
1717// below are incorrect yet:
1718
1719	"I2MS_ns_dv00.asl",
1720	"I2MS_ns_dv10.asl",
1721	"I2MS_ns_dv20.asl",
1722	"I2MS_ns_dv30.asl",	// 170
1723
1724	"I2MS_ns_device.asl",
1725	"I2MS_ns_device_abbu.asl",
1726	"I2MS_ns_device_aslts.asl",
1727
1728// see these files can be not used at all:
1729	"I2MS_ns4.asl",
1730	"I2MS_ns5.asl",
1731	"I2MS_ns6.asl",
1732	
1733// ACPI 5.0
1734    "fixeddma.asl", // 177
1735    "gpioint.asl",
1736    "gpioio.asl",
1737    "i2cserialbus.asl",
1738    "spiserialbus.asl",
1739    "uartserialbus.asl",
1740})
1741
1742/*
1743 * Unpack error
1744 *
1745 * arg0 - information of error (Word 0)
1746 * arg1 - information of checking (Word 1)
1747 * arg2 - name of Method initiating the checking (Word 2)
1748 */
1749Method(UNP0, 3, Serialized)
1750{
1751	// c - index of tests collection
1752	ShiftRight(arg0, 28, Local7)
1753	And(Local7, 0x0f, Local0)
1754
1755	// t - index of test inside the collection
1756	ShiftRight(arg0, 23, Local7)
1757	And(Local7, 0x1f, Local1)
1758
1759	// f - absolute index of file reporting the error
1760	ShiftRight(arg0, 12, Local7)
1761	And(Local7, 0x07ff, Local2)
1762
1763	// e - index of error (inside the file)
1764	And(arg0, 0x0fff, Local3)
1765
1766	Store("", Local6)
1767	Store("", Local7)
1768
1769	Switch (ToInteger (Local0)) {
1770		case (1) {
1771			Store(DeRefOf(Index(TNF0, Local1)), Local6)
1772			if (ERR4) {
1773				Store(", functional, ", Local7)
1774			}
1775		}
1776		case (2) {
1777			Store(DeRefOf(Index(TNC0, Local1)), Local6)
1778			if (ERR4) {
1779				Store(", complex, ", Local7)
1780			}
1781		}
1782		case (3) {
1783			Store(DeRefOf(Index(TNE0, Local1)), Local6)
1784			if (ERR4) {
1785				Store(", exceptions, ", Local7)
1786			}
1787		}
1788		case (4) {
1789
1790			// m - in case of TCLD tests there is an index of bug
1791
1792			ShiftRight(arg1, 23, Local0)
1793			And(Local0, 0x1ff, Local1)
1794			Store(SB00(Local1, 1), Local6)
1795			if (ERR4) {
1796				Store(", bug-demo, ", Local7)
1797			}
1798		}
1799		case (5) {
1800			Store(DeRefOf(Index(TNS0, Local1)), Local6)
1801			if (ERR4) {
1802				Store(", service, ", Local7)
1803			}
1804		}
1805		case (6) {
1806			Store(DeRefOf(Index(TNM0, Local1)), Local6)
1807			if (ERR4) {
1808				Store(", mt, ", Local7)
1809			}
1810		}
1811		case (7) {
1812			Store(DeRefOf(Index(TNT0, Local1)), Local6)
1813			if (ERR4) {
1814				Store(", Identity2MS, ", Local7)
1815			}
1816		}
1817		case (8) {
1818			Store(DeRefOf(Index(TNI0, Local1)), Local6)
1819			if (ERR4) {
1820				Store(", IMPL, ", Local7)
1821			}
1822		}
1823	}
1824
1825	Concatenate(Local7, Local6, Local5)
1826	Concatenate(Local5, ", ", Local1)
1827
1828	// Error
1829
1830	if (LEqual(Local2, zFFF)) {
1831
1832		// ATTENTION: dont use zFFF in tests other than TCLD
1833		// m - in case of TCLD tests there is an index of bug
1834
1835		ShiftRight(arg1, 23, Local0)
1836		And(Local0, 0x1ff, Local2)
1837		Store(SB00(Local2, 0), Local6)
1838
1839	} else {
1840		Store(DeRefOf(Index(TFN0, Local2)), Local6)
1841	}
1842
1843	Concatenate(Local1, Local6, Local7)
1844	Concatenate(Local7, ", ", Local1)
1845	Concatenate(Local1, Local3, Local7)
1846
1847	// (z+u) - entire field of checking
1848
1849	And(arg1, 0x07fffff, Local5)
1850
1851	if (Local5) {
1852		// z - absolute index of file initiating the checking
1853		ShiftRight(arg1, 12, Local5)
1854		And(Local5, 0x07ff, Local2)
1855
1856		// u - index of checking
1857		And(arg1, 0x0fff, Local3)
1858
1859		if (LEqual(Local2, zFFF)) {
1860			// ATTENTION: dont use zFFF in tests other than TCLD
1861			// m - in case of TCLD tests there is an index of bug
1862			ShiftRight(arg1, 23, Local0)
1863			And(Local0, 0x1ff, Local2)
1864			Store(SB00(Local2, 0), Local6)
1865		} else {
1866			Store(DeRefOf(Index(TFN0, Local2)), Local6)
1867		}
1868
1869		Concatenate(Local7, ", ", Local1)
1870		Concatenate(Local1, Local6, Local5)
1871		Concatenate(Local5, ", ", Local1)
1872		Concatenate(Local1, Local3, Local7)
1873
1874		if (LEqual(ObjectType(arg2), c00a)) {
1875			Concatenate(Local7, ", ", Local1)
1876			Concatenate(Local1, arg2, Local7)
1877		}
1878	}
1879
1880	return (Local7)
1881}
1882
1883// Report errors
1884Method(RERR,, Serialized)
1885{
1886	Name(lpN0, 0)
1887	Name(lpC0, 0)
1888
1889	Store(ETR1, lpN0)
1890
1891	if (LLess(ERRS, lpN0)) {
1892		Store(ERRS, lpN0)
1893	}
1894
1895	Store(0, Local0)
1896
1897	Store("========= ERRORS SUMMARY (max 400):", Debug)
1898
1899	While (lpN0) {
1900
1901		Store(DeRefOf(Index(ERRP, Local0)), Local7)
1902		Increment(Local0)
1903		Store(DeRefOf(Index(ERRP, Local0)), Local6)
1904		Increment(Local0)
1905		Store(DeRefOf(Index(ERRP, Local0)), Local4)
1906		Increment(Local0)
1907
1908		Store(UNP0(Local7, Local6, Local4), Local1)
1909
1910		if (ERR4) {
1911			Concatenate("", Local7, Local2)
1912			Concatenate(Local2, ", ", Local5)
1913			Concatenate(Local5, Local6, Local2)
1914			Concatenate(Local2, Local1, Local7)
1915		} else {
1916			Concatenate("", Local1, Local7)
1917		}
1918
1919		Store(Local7, Debug)
1920
1921		Decrement(lpN0)
1922		Increment(lpC0)
1923	}
1924
1925	if (LGreater(ERRS, ETR1)) {
1926		Store("********* Not all errors were traced, maximum exceeded!", Debug)
1927	}
1928	Store("========= END.", Debug)
1929}
1930
1931// Report root Methods run results
1932Method(RRM0,, Serialized, 3)
1933{
1934	Name(lpN0, 0)
1935	Name(lpC0, 0)
1936
1937	Store(ETR0, lpN0)
1938
1939	if (LLess(RMRC, lpN0)) {
1940		Store(RMRC, lpN0)
1941	}
1942
1943	Store("========= ROOT METHODS SUMMARY (max 600):", Debug)
1944	While (lpN0) {
1945		Store(DeRefOf(Index(RP0P, lpC0)), Local7)
1946		Store(Local7, Debug)
1947		Decrement(lpN0)
1948		Increment(lpC0)
1949	}
1950	if (LGreater(RMRC, ETR0)) {
1951		Store("********* Not all root Methods were traced, maximum exceeded!", Debug)
1952	}
1953	Store("========= END.", Debug)
1954}
1955
1956// Final actions
1957Method(FNSH)
1958{
1959	// Check, the current number of exceptions is zero
1960
1961	CH03("FNSH", 0, 0, 0, 0)
1962
1963	// Check all the constants are not corrupted
1964
1965	CST0()
1966
1967	// Run time
1968
1969	Store(Timer, Local7)
1970	Subtract(Local7, tmt0, Local6)
1971	Divide(Local6, 10, Local1, Local2)
1972	Divide(Local2, 1000000, Local1, Local0)
1973	Store(Concatenate("Run time (in seconds): 0x", Local0), Debug)
1974
1975	// Exceptions total
1976
1977	Store(Concatenate("The total number of exceptions handled: 0x", EXC1), Debug)
1978
1979	// Status of test run
1980
1981	if (ERRS) {
1982		RERR()
1983	}
1984
1985	// Report root Methods run results
1986	RRM0()
1987
1988	if (F64) {
1989		Concatenate("TEST ACPICA: ", "64-bit :", Local0)
1990	} else {
1991		Concatenate("TEST ACPICA: ", "32-bit :", Local0)
1992	}
1993
1994	if (ERR7) {
1995		Concatenate("!!!! ERRORS were detected during the loading stage, # 0x", ERR7, Debug)
1996	}
1997
1998	Store(0, EXC1)
1999
2000	if (LOr(ERRS, ERR7)) {
2001		Concatenate(Local0, " FAIL : Errors # 0x", Local1)
2002		Concatenate(Local1, ERRS, Local2)
2003		Concatenate(Local2, ", Failed tests # 0x", Local1)
2004		Store (Concatenate(Local1, ERR6), Debug)
2005
2006		return (1)
2007	}
2008
2009	Store(Concatenate(Local0, " PASS"), Debug)
2010
2011	return (0)
2012}
2013
2014// Trace execution
2015
2016/*
2017 * Report write operation
2018 * arg0 - object where writing
2019 * arg1 - index where writing
2020 * arg2 - value
2021 */
2022Method(TRC0, 3)
2023{
2024	if (TRCF) {
2025		Concatenate(TRCH, ", WRITE: where ", Local0)
2026		Concatenate(Local0, arg1, Local1)
2027		Concatenate(Local1, ", ", Local0)
2028		Concatenate(Local0, arg2, Local1)
2029		Store(Local1, Debug)
2030	}
2031}
2032
2033/*
2034 * Report read operation
2035 * arg0 - object from where reading
2036 * arg1 - index from where reading
2037 * arg2 - obtained value
2038 */
2039Method(TRC1, 3)
2040{
2041	if (TRCF) {
2042		Concatenate(TRCH, ", READ: where ", Local0)
2043		Concatenate(Local0, arg1, Local1)
2044		Concatenate(Local1, ", ", Local0)
2045		Concatenate(Local0, arg2, Local1)
2046		Store(Local1, Debug)
2047	}
2048}
2049
2050/*
2051 * Report string
2052 * arg0 - string
2053 */
2054Method(TRC2, 1)
2055{
2056	if (TRCF) {
2057		Concatenate(TRCH, ", ", Local0)
2058		Concatenate(Local0, arg0, Local1)
2059		Store(Local1, Debug)
2060	}
2061}
2062
2063// Switch on trace
2064Method(TRC8)
2065{
2066	Store(1, TRCF)
2067}
2068
2069// Switch off trace
2070Method(TRC9)
2071{
2072	Store(0, TRCF)
2073}
2074
2075// Start of test
2076Method(ts00, 1)
2077{
2078	if (pr01) {
2079		Concatenate("Test ", arg0, Local0)
2080		Concatenate(Local0, " started", Local1)
2081		Store(Local1, Debug)
2082	}
2083}
2084
2085/*
2086 * Convert the Timer units (one unit - 100 nsecs) to Seconds
2087 * arg0 - interval in Timer units
2088 */
2089Method(TMR0, 1)
2090{
2091	// Convert to microseconds
2092	Divide(arg0, 10, Local0, Local1)
2093	// Convert to seconds
2094	Divide(Local1, 1000000, Local0, Local2)
2095	Return (Local2)
2096}
2097