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