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     * Bug 47:
30     *
31     * SUMMARY: Timer operator doesn�t provide gradually increased values
32     *
33     * APPEARANCE
34     *
35     * The ASL Timer operator is declared as a 64-bit one
36     * "17.5.117 Timer (Get 64-Bit Timer Value)" but actually,
37     * we observe it is overrun during each 15 minutes, but we
38     * expect that to be one time in more than 50 thousand years!
39     *
40     * SPECS (17.5.117)
41     *
42     * The value resulting from this opcode is 64-bits.
43     * It is monotonically increasing, but it is not guaranteed
44     * that every result will be unique,  i.e. two subsequent
45     * instructions may return the same value. The only guarantee
46     * is that each subsequent evaluation will be greater-than or
47     * equal to the previous ones.
48     *
49     * Timer operator doesn�t provide
50     * gradually increased values. The test takes long time,
51     * and ends only when encounters error. Since the test is
52     * based on Timer operator which is under testing and works
53     * incorrectly we excluded this test from the normally run
54     * tests set. We can't even control the time the run of test
55     * is in progress from inside the test.
56     */
57    Method (MD77, 0, Serialized)
58    {
59        Name (LPN0, 0x00)
60        Name (LPC0, 0x00)
61        Name (TSLP, 0x1388)    /* MilliSecs to sleep each cycle (5 secs) */
62        Name (NCCL, 0xB4) /* Number of cycles */
63        LPN0 = NCCL /* \MD77.NCCL */
64        LPC0 = 0x00
65        Local0 = (TSLP * LPN0) /* \MD77.LPN0 */
66        Divide (Local0, 0x03E8, Local1, Local2)
67        Debug = Concatenate ("Maximal time of execution (in seconds): 0x", Local2)
68        Local0 = Timer
69        Local5 = 0x00
70        Debug = Concatenate ("Start value of Timer : 0x", Local0)
71        While (LPN0)
72        {
73            Local7 = Timer
74            Debug = Concatenate ("Timer: 0x", Local7)
75            If ((Local0 > Local7))
76            {
77                /* if (Local5) { */
78
79                ERR (__METHOD__, ZFFF, __LINE__, 0x00, 0x00, Local0, Local7)
80                Debug = Concatenate ("Cur   timer    : 0x", Local7)
81                Debug = Concatenate ("Start timer    : 0x", Local0)
82                Debug = Concatenate ("Step of cycle  : 0x", TSLP)
83                Break
84                /* } */
85                /* First time in more than 50 thousand years! */
86                Local5 = 0x01
87            }
88
89            Sleep (TSLP)
90            LPN0--
91            LPC0++
92        }
93
94        Debug = Concatenate ("Start  timer: 0x", Local0)
95        Debug = Concatenate ("Finish timer: 0x", Local7)
96        Local6 = (Local7 - Local0)
97        Local0 = TMR0 (Local6)
98        Debug = Concatenate ("Run time (in seconds): 0x", Local0)
99    }
100