2014-02-10 20:20:52 +04:00
|
|
|
#include "macros.inc"
|
2011-09-06 03:55:57 +04:00
|
|
|
|
2016-09-06 06:55:13 +03:00
|
|
|
#define CCOUNT_SHIFT 4
|
|
|
|
#define WAIT_LOOPS 20
|
2019-02-18 17:55:15 +03:00
|
|
|
#define level1 kernel
|
|
|
|
#define INTERRUPT_LEVEL(n) glue3(XCHAL_INT, n, _LEVEL)
|
2016-09-06 06:55:13 +03:00
|
|
|
|
|
|
|
.macro make_ccount_delta target, delta
|
|
|
|
rsr \delta, ccount
|
|
|
|
rsr \target, ccount
|
|
|
|
sub \delta, \target, \delta
|
|
|
|
slli \delta, \delta, CCOUNT_SHIFT
|
|
|
|
add \target, \target, \delta
|
|
|
|
.endm
|
|
|
|
|
2011-09-06 03:55:57 +04:00
|
|
|
test_suite timer
|
|
|
|
|
2019-02-18 17:55:15 +03:00
|
|
|
#if XCHAL_HAVE_CCOUNT
|
|
|
|
|
2011-09-06 03:55:57 +04:00
|
|
|
test ccount
|
|
|
|
rsr a3, ccount
|
|
|
|
rsr a4, ccount
|
2016-09-06 06:55:13 +03:00
|
|
|
assert ne, a3, a4
|
2011-09-06 03:55:57 +04:00
|
|
|
test_end
|
|
|
|
|
2017-01-15 19:42:31 +03:00
|
|
|
test ccount_write
|
|
|
|
rsr a3, ccount
|
|
|
|
rsr a4, ccount
|
|
|
|
sub a4, a4, a3
|
|
|
|
movi a2, 0x12345678
|
|
|
|
wsr a2, ccount
|
|
|
|
esync
|
|
|
|
rsr a3, ccount
|
|
|
|
sub a3, a3, a2
|
|
|
|
slli a4, a4, 2
|
|
|
|
assert ltu, a3, a4
|
|
|
|
test_end
|
|
|
|
|
2019-02-18 17:55:15 +03:00
|
|
|
#if XCHAL_NUM_TIMERS
|
|
|
|
|
2022-04-27 20:06:00 +03:00
|
|
|
#if INTERRUPT_LEVEL(XCHAL_TIMER0_INTERRUPT) == 1
|
|
|
|
#define TIMER0_VECTOR kernel
|
|
|
|
#else
|
|
|
|
#define TIMER0_VECTOR glue(level, INTERRUPT_LEVEL(XCHAL_TIMER0_INTERRUPT))
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if XCHAL_NUM_TIMERS > 1
|
|
|
|
#if INTERRUPT_LEVEL(XCHAL_TIMER1_INTERRUPT) == 1
|
|
|
|
#define TIMER1_VECTOR kernel
|
|
|
|
#else
|
|
|
|
#define TIMER1_VECTOR glue(level, INTERRUPT_LEVEL(XCHAL_TIMER1_INTERRUPT))
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if XCHAL_NUM_TIMERS > 2
|
|
|
|
#if INTERRUPT_LEVEL(XCHAL_TIMER2_INTERRUPT) == 1
|
|
|
|
#define TIMER2_VECTOR kernel
|
|
|
|
#else
|
|
|
|
#define TIMER2_VECTOR glue(level, INTERRUPT_LEVEL(XCHAL_TIMER2_INTERRUPT))
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2017-01-15 19:42:31 +03:00
|
|
|
test ccount_update_deadline
|
|
|
|
movi a2, 0
|
|
|
|
wsr a2, intenable
|
|
|
|
rsr a2, interrupt
|
|
|
|
wsr a2, intclear
|
|
|
|
movi a2, 0
|
2019-02-18 17:55:15 +03:00
|
|
|
#if XCHAL_NUM_TIMERS > 1
|
2017-01-15 19:42:31 +03:00
|
|
|
wsr a2, ccompare1
|
2019-02-18 17:55:15 +03:00
|
|
|
#endif
|
|
|
|
#if XCHAL_NUM_TIMERS > 2
|
2017-01-15 19:42:31 +03:00
|
|
|
wsr a2, ccompare2
|
2019-02-18 17:55:15 +03:00
|
|
|
#endif
|
2017-01-15 19:42:31 +03:00
|
|
|
movi a2, 0x12345678
|
|
|
|
wsr a2, ccompare0
|
|
|
|
rsr a3, interrupt
|
|
|
|
assert eqi, a3, 0
|
|
|
|
movi a2, 0x12345677
|
|
|
|
wsr a2, ccount
|
|
|
|
esync
|
|
|
|
nop
|
|
|
|
rsr a2, interrupt
|
|
|
|
movi a3, 1 << XCHAL_TIMER0_INTERRUPT
|
|
|
|
assert eq, a2, a3
|
|
|
|
test_end
|
|
|
|
|
2011-09-06 03:55:57 +04:00
|
|
|
test ccompare
|
|
|
|
movi a2, 0
|
|
|
|
wsr a2, intenable
|
|
|
|
rsr a2, interrupt
|
|
|
|
wsr a2, intclear
|
2011-10-10 06:25:04 +04:00
|
|
|
movi a2, 0
|
2019-02-18 17:55:15 +03:00
|
|
|
#if XCHAL_NUM_TIMERS > 1
|
2011-09-06 03:55:57 +04:00
|
|
|
wsr a2, ccompare1
|
2019-02-18 17:55:15 +03:00
|
|
|
#endif
|
|
|
|
#if XCHAL_NUM_TIMERS > 2
|
2011-09-06 03:55:57 +04:00
|
|
|
wsr a2, ccompare2
|
2019-02-18 17:55:15 +03:00
|
|
|
#endif
|
2011-09-06 03:55:57 +04:00
|
|
|
|
2016-09-06 06:55:13 +03:00
|
|
|
make_ccount_delta a2, a15
|
2011-09-06 03:55:57 +04:00
|
|
|
wsr a2, ccompare0
|
|
|
|
1:
|
2016-09-06 06:55:13 +03:00
|
|
|
rsr a3, interrupt
|
|
|
|
rsr a4, ccount
|
|
|
|
rsr a5, interrupt
|
|
|
|
sub a4, a4, a2
|
|
|
|
bgez a4, 2f
|
|
|
|
assert eqi, a3, 0
|
|
|
|
j 1b
|
2011-09-06 03:55:57 +04:00
|
|
|
2:
|
2016-09-06 06:55:13 +03:00
|
|
|
assert nei, a5, 0
|
2011-09-06 03:55:57 +04:00
|
|
|
test_end
|
|
|
|
|
|
|
|
test ccompare0_interrupt
|
2022-04-27 20:06:00 +03:00
|
|
|
set_vector TIMER0_VECTOR, 2f
|
2011-09-06 03:55:57 +04:00
|
|
|
movi a2, 0
|
|
|
|
wsr a2, intenable
|
|
|
|
rsr a2, interrupt
|
|
|
|
wsr a2, intclear
|
2011-10-10 06:25:04 +04:00
|
|
|
movi a2, 0
|
2019-02-18 17:55:15 +03:00
|
|
|
#if XCHAL_NUM_TIMERS > 1
|
2011-09-06 03:55:57 +04:00
|
|
|
wsr a2, ccompare1
|
2019-02-18 17:55:15 +03:00
|
|
|
#endif
|
|
|
|
#if XCHAL_NUM_TIMERS > 2
|
2011-09-06 03:55:57 +04:00
|
|
|
wsr a2, ccompare2
|
2019-02-18 17:55:15 +03:00
|
|
|
#endif
|
2011-09-06 03:55:57 +04:00
|
|
|
|
2016-09-06 06:55:13 +03:00
|
|
|
movi a3, WAIT_LOOPS
|
|
|
|
make_ccount_delta a2, a15
|
2011-09-06 03:55:57 +04:00
|
|
|
wsr a2, ccompare0
|
|
|
|
rsync
|
|
|
|
rsr a2, interrupt
|
|
|
|
assert eqi, a2, 0
|
|
|
|
|
2017-01-15 06:58:55 +03:00
|
|
|
movi a2, 1 << XCHAL_TIMER0_INTERRUPT
|
2011-09-06 03:55:57 +04:00
|
|
|
wsr a2, intenable
|
|
|
|
rsil a2, 0
|
|
|
|
1:
|
2022-04-26 04:12:53 +03:00
|
|
|
addi a3, a3, -1
|
|
|
|
bnez a3, 1b
|
2011-09-06 03:55:57 +04:00
|
|
|
test_fail
|
|
|
|
2:
|
2022-04-27 20:06:00 +03:00
|
|
|
#if INTERRUPT_LEVEL(XCHAL_TIMER0_INTERRUPT) == 1
|
2011-09-06 03:55:57 +04:00
|
|
|
rsr a2, exccause
|
|
|
|
assert eqi, a2, 4 /* LEVEL1_INTERRUPT_CAUSE */
|
2019-02-18 17:55:15 +03:00
|
|
|
#endif
|
2022-04-27 20:06:00 +03:00
|
|
|
test_end
|
2019-02-18 17:55:15 +03:00
|
|
|
|
|
|
|
#if XCHAL_NUM_TIMERS > 1
|
2011-09-06 03:55:57 +04:00
|
|
|
|
|
|
|
test ccompare1_interrupt
|
2022-04-27 20:06:00 +03:00
|
|
|
set_vector TIMER1_VECTOR, 2f
|
2011-09-06 03:55:57 +04:00
|
|
|
movi a2, 0
|
|
|
|
wsr a2, intenable
|
|
|
|
rsr a2, interrupt
|
|
|
|
wsr a2, intclear
|
2011-10-10 06:25:04 +04:00
|
|
|
movi a2, 0
|
2011-09-06 03:55:57 +04:00
|
|
|
wsr a2, ccompare0
|
2019-02-18 17:55:15 +03:00
|
|
|
#if XCHAL_NUM_TIMERS > 2
|
2011-09-06 03:55:57 +04:00
|
|
|
wsr a2, ccompare2
|
2019-02-18 17:55:15 +03:00
|
|
|
#endif
|
2011-09-06 03:55:57 +04:00
|
|
|
|
2016-09-06 06:55:13 +03:00
|
|
|
movi a3, WAIT_LOOPS
|
|
|
|
make_ccount_delta a2, a15
|
2011-09-06 03:55:57 +04:00
|
|
|
wsr a2, ccompare1
|
|
|
|
rsync
|
|
|
|
rsr a2, interrupt
|
|
|
|
assert eqi, a2, 0
|
2017-01-15 06:58:55 +03:00
|
|
|
movi a2, 1 << XCHAL_TIMER1_INTERRUPT
|
2011-09-06 03:55:57 +04:00
|
|
|
wsr a2, intenable
|
2019-02-18 17:55:15 +03:00
|
|
|
rsil a2, INTERRUPT_LEVEL(XCHAL_TIMER1_INTERRUPT) - 1
|
2011-09-06 03:55:57 +04:00
|
|
|
1:
|
2022-04-26 04:12:53 +03:00
|
|
|
addi a3, a3, -1
|
|
|
|
bnez a3, 1b
|
2011-09-06 03:55:57 +04:00
|
|
|
test_fail
|
|
|
|
2:
|
2022-04-27 20:06:00 +03:00
|
|
|
#if INTERRUPT_LEVEL(XCHAL_TIMER1_INTERRUPT) == 1
|
|
|
|
rsr a2, exccause
|
|
|
|
assert eqi, a2, 4 /* LEVEL1_INTERRUPT_CAUSE */
|
|
|
|
#endif
|
2011-09-06 03:55:57 +04:00
|
|
|
test_end
|
|
|
|
|
2019-02-18 17:55:15 +03:00
|
|
|
#endif
|
|
|
|
#if XCHAL_NUM_TIMERS > 2
|
|
|
|
|
2011-09-06 03:55:57 +04:00
|
|
|
test ccompare2_interrupt
|
2022-04-27 20:06:00 +03:00
|
|
|
set_vector TIMER2_VECTOR, 2f
|
2011-09-06 03:55:57 +04:00
|
|
|
movi a2, 0
|
|
|
|
wsr a2, intenable
|
|
|
|
rsr a2, interrupt
|
|
|
|
wsr a2, intclear
|
2011-10-10 06:25:04 +04:00
|
|
|
movi a2, 0
|
2011-09-06 03:55:57 +04:00
|
|
|
wsr a2, ccompare0
|
|
|
|
wsr a2, ccompare1
|
|
|
|
|
2016-09-06 06:55:13 +03:00
|
|
|
movi a3, WAIT_LOOPS
|
|
|
|
make_ccount_delta a2, a15
|
2011-09-06 03:55:57 +04:00
|
|
|
wsr a2, ccompare2
|
|
|
|
rsync
|
|
|
|
rsr a2, interrupt
|
|
|
|
assert eqi, a2, 0
|
2017-01-15 06:58:55 +03:00
|
|
|
movi a2, 1 << XCHAL_TIMER2_INTERRUPT
|
2011-09-06 03:55:57 +04:00
|
|
|
wsr a2, intenable
|
2019-02-18 17:55:15 +03:00
|
|
|
rsil a2, INTERRUPT_LEVEL(XCHAL_TIMER2_INTERRUPT) - 1
|
2011-09-06 03:55:57 +04:00
|
|
|
1:
|
2022-04-26 04:12:53 +03:00
|
|
|
addi a3, a3, -1
|
|
|
|
bnez a3, 1b
|
2011-09-06 03:55:57 +04:00
|
|
|
test_fail
|
|
|
|
2:
|
2022-04-27 20:06:00 +03:00
|
|
|
#if INTERRUPT_LEVEL(XCHAL_TIMER2_INTERRUPT) == 1
|
|
|
|
rsr a2, exccause
|
|
|
|
assert eqi, a2, 4 /* LEVEL1_INTERRUPT_CAUSE */
|
|
|
|
#endif
|
2011-09-06 03:55:57 +04:00
|
|
|
test_end
|
|
|
|
|
2019-02-18 17:55:15 +03:00
|
|
|
#endif
|
|
|
|
|
2011-10-10 06:25:04 +04:00
|
|
|
test ccompare_interrupt_masked
|
2022-04-27 20:06:00 +03:00
|
|
|
set_vector TIMER0_VECTOR, 2f
|
2011-10-10 06:25:04 +04:00
|
|
|
movi a2, 0
|
|
|
|
wsr a2, intenable
|
|
|
|
rsr a2, interrupt
|
|
|
|
wsr a2, intclear
|
|
|
|
movi a2, 0
|
2019-02-18 17:55:15 +03:00
|
|
|
#if XCHAL_NUM_TIMERS > 2
|
2011-10-10 06:25:04 +04:00
|
|
|
wsr a2, ccompare2
|
2019-02-18 17:55:15 +03:00
|
|
|
#endif
|
2011-10-10 06:25:04 +04:00
|
|
|
|
2022-04-26 04:12:53 +03:00
|
|
|
movi a3, WAIT_LOOPS
|
2016-09-06 06:55:13 +03:00
|
|
|
make_ccount_delta a2, a15
|
2019-02-18 17:55:15 +03:00
|
|
|
#if XCHAL_NUM_TIMERS > 1
|
2011-10-10 06:25:04 +04:00
|
|
|
wsr a2, ccompare1
|
2019-02-18 17:55:15 +03:00
|
|
|
#endif
|
2016-09-06 06:55:13 +03:00
|
|
|
add a2, a2, a15
|
2011-10-10 06:25:04 +04:00
|
|
|
wsr a2, ccompare0
|
|
|
|
rsync
|
|
|
|
rsr a2, interrupt
|
|
|
|
assert eqi, a2, 0
|
|
|
|
|
2017-01-15 06:58:55 +03:00
|
|
|
movi a2, 1 << XCHAL_TIMER0_INTERRUPT
|
2011-10-10 06:25:04 +04:00
|
|
|
wsr a2, intenable
|
|
|
|
rsil a2, 0
|
|
|
|
1:
|
2022-04-26 04:12:53 +03:00
|
|
|
addi a3, a3, -1
|
|
|
|
bnez a3, 1b
|
|
|
|
|
2011-10-10 06:25:04 +04:00
|
|
|
test_fail
|
|
|
|
2:
|
2022-04-27 20:06:00 +03:00
|
|
|
#if INTERRUPT_LEVEL(XCHAL_TIMER0_INTERRUPT) == 1
|
2011-10-10 06:25:04 +04:00
|
|
|
rsr a2, exccause
|
|
|
|
assert eqi, a2, 4 /* LEVEL1_INTERRUPT_CAUSE */
|
2022-04-27 20:06:00 +03:00
|
|
|
#endif
|
2011-10-10 06:25:04 +04:00
|
|
|
test_end
|
|
|
|
|
|
|
|
test ccompare_interrupt_masked_waiti
|
2022-04-27 20:06:00 +03:00
|
|
|
set_vector TIMER0_VECTOR, 2f
|
2011-10-10 06:25:04 +04:00
|
|
|
movi a2, 0
|
|
|
|
wsr a2, intenable
|
|
|
|
rsr a2, interrupt
|
|
|
|
wsr a2, intclear
|
|
|
|
movi a2, 0
|
2019-02-18 17:55:15 +03:00
|
|
|
#if XCHAL_NUM_TIMERS > 2
|
2011-10-10 06:25:04 +04:00
|
|
|
wsr a2, ccompare2
|
2019-02-18 17:55:15 +03:00
|
|
|
#endif
|
2011-10-10 06:25:04 +04:00
|
|
|
|
2016-09-06 06:55:13 +03:00
|
|
|
make_ccount_delta a2, a15
|
2019-02-18 17:55:15 +03:00
|
|
|
#if XCHAL_NUM_TIMERS > 1
|
2011-10-10 06:25:04 +04:00
|
|
|
wsr a2, ccompare1
|
2019-02-18 17:55:15 +03:00
|
|
|
#endif
|
2016-09-06 06:55:13 +03:00
|
|
|
add a2, a2, a15
|
2011-10-10 06:25:04 +04:00
|
|
|
wsr a2, ccompare0
|
|
|
|
rsync
|
|
|
|
rsr a2, interrupt
|
|
|
|
assert eqi, a2, 0
|
|
|
|
|
2017-01-15 06:58:55 +03:00
|
|
|
movi a2, 1 << XCHAL_TIMER0_INTERRUPT
|
2011-10-10 06:25:04 +04:00
|
|
|
wsr a2, intenable
|
|
|
|
waiti 0
|
|
|
|
test_fail
|
|
|
|
2:
|
2022-04-27 20:06:00 +03:00
|
|
|
#if INTERRUPT_LEVEL(XCHAL_TIMER0_INTERRUPT) == 1
|
2011-10-10 06:25:04 +04:00
|
|
|
rsr a2, exccause
|
|
|
|
assert eqi, a2, 4 /* LEVEL1_INTERRUPT_CAUSE */
|
2022-04-27 20:06:00 +03:00
|
|
|
#endif
|
2011-10-10 06:25:04 +04:00
|
|
|
test_end
|
|
|
|
|
2019-02-18 17:55:15 +03:00
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2011-09-06 03:55:57 +04:00
|
|
|
test_suite_end
|