From bf2d407f1d51befda95ddf845385e7eb6eda6dab Mon Sep 17 00:00:00 2001 From: Lephe Date: Thu, 18 Jun 2020 20:20:55 +0200 Subject: [PATCH] tmu: fix dreadful omission of timer ID in ETMU handler This change fixes a never-should-have-worked problem where the ETMU interrupt handler loses track of the timer ID before attempting to call timer_stop(), resulting in complete nonsense. And also a similar problem in timer_wait(). --- src/tmu/inth.s | 10 +++++----- src/tmu/tmu.c | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/tmu/inth.s b/src/tmu/inth.s index 2a32128..9867495 100644 --- a/src/tmu/inth.s +++ b/src/tmu/inth.s @@ -147,6 +147,7 @@ _inth_etmu2: mov #5, r1 .shared4: + mov.l r1, @-r15 sts.l pr, @-r15 mov.l r0, @-r15 @@ -158,9 +159,8 @@ _inth_etmu2: /* Prepare invoking the callback function */ mov.l @r15+, r0 mov.l .gint_inth_callback_2, r1 - mov.l @r0, r4 bra _inth_etmu_help - mov.l @(4, r0), r5 + mov.l @r0, r4 .storage_etmu2: .long 0 /* Callback: Configured dynamically */ @@ -171,19 +171,19 @@ _inth_etmu_help: /* Invoke callback; if return value is non-zero, stop timer */ jsr @r1 - nop + mov.l @(4, r0), r5 tst r0, r0 bt .shared5 mov.l .timer_stop_2, r1 jsr @r1 - nop + mov.l @(4, r15), r4 /* Clear the flag and possibly stop the timer */ .shared5: lds.l @r15+, pr rts - nop + add #4, r15 .gint_inth_callback_2: .long _gint_inth_callback diff --git a/src/tmu/tmu.c b/src/tmu/tmu.c index 4b9a111..129dc6f 100644 --- a/src/tmu/tmu.c +++ b/src/tmu/tmu.c @@ -173,7 +173,7 @@ void timer_wait(int id) } else { - etmu_t *T = &ETMU[id]; + etmu_t *T = &ETMU[id-3]; while(T->TSTR) if(T->TCR.UNIE) sleep(); } }