diff --git a/include/gint/mpu/tmu.h b/include/gint/mpu/tmu.h index 5194401..5d3de58 100644 --- a/include/gint/mpu/tmu.h +++ b/include/gint/mpu/tmu.h @@ -48,7 +48,7 @@ typedef volatile struct ); pad(19); -} GPACKED(0x10) etmu_t; +} GPACKED(4) etmu_t; //--- // SH7705 Timer Unit. Refer to: diff --git a/src/intc/intc.c b/src/intc/intc.c index ae35990..8d2f6ed 100644 --- a/src/intc/intc.c +++ b/src/intc/intc.c @@ -66,7 +66,7 @@ static struct info { /* intc_priority(): Configure the level of interrupts */ int intc_priority(int intname, int level) { - struct info *i = &info[intname]; + struct info const *i = &info[intname]; int IPRn = i->IPR4, IPRbits = i->IPR4bits; if(isSH3() && i->IPR3bits != 0) diff --git a/src/std/stdio.c b/src/std/stdio.c index bdfdb7e..14dcdcb 100644 --- a/src/std/stdio.c +++ b/src/std/stdio.c @@ -20,7 +20,7 @@ // kprint() definitions //--- -#define KPRINT_BUFSIZE 256 +#define KPRINT_BUFSIZE 64 #define KFORMAT_ARGS \ GUNUSED int spec, GUNUSED struct kprint_options *opt, va_list *args diff --git a/src/tmu/tmu.c b/src/tmu/tmu.c index 0de8ad4..a45d394 100644 --- a/src/tmu/tmu.c +++ b/src/tmu/tmu.c @@ -423,10 +423,16 @@ static void init(void) // Context system for this driver //--- +struct stored_timer { + uint32_t TCOR; + uint32_t TCNT; + uint16_t TCR; + uint16_t TSTR; +}; + typedef struct { - tmu_t std[3]; - etmu_t extra[6]; + struct stored_timer t[9]; uint8_t TSTR; } ctx_t; @@ -440,20 +446,21 @@ static void ctx_save(void *buf) for(int i = 0; i < 3; i++) { - tmu_t *c = &ctx->std[i]; + struct stored_timer *c = &ctx->t[i]; c->TCOR = TMU[i].TCOR; c->TCNT = TMU[i].TCNT; - c->TCR.word = TMU[i].TCR.word; + c->TCR = TMU[i].TCR.word; } - for(int i = 0; i < timer_count() - 3; i++) + for(int i = 3; i < timer_count(); i++) { - etmu_t *T = &ETMU[i], *c = &ctx->extra[i]; + struct stored_timer *c = &ctx->t[i]; + etmu_t *T = &ETMU[i-3]; /* Don't snapshot an interrupt state, because the timer state is sometimes garbage protected by a masked interrupt. */ c->TCOR = T->TCOR ? T->TCOR : 0xffffffff; c->TCNT = T->TCNT ? T->TCNT : c->TCOR; - c->TCR.byte = T->TCR.byte & 0xd; + c->TCR = T->TCR.byte & 0xd; c->TSTR = T->TSTR; } } @@ -465,14 +472,15 @@ static void ctx_restore(void *buf) for(int i = 0; i < 3; i++) { - tmu_t *c = &ctx->std[i]; + struct stored_timer *c = &ctx->t[i]; TMU[i].TCOR = c->TCOR; TMU[i].TCNT = c->TCNT; - TMU[i].TCR.word = c->TCR.word; + TMU[i].TCR.word = c->TCR; } - for(int i = 0; i < timer_count() - 3; i++) + for(int i = 3; i < timer_count(); i++) { - etmu_t *T = &ETMU[i], *c = &ctx->extra[i]; + struct stored_timer *c = &ctx->t[i]; + etmu_t *T = &ETMU[i-3]; do T->TCOR = c->TCOR; while(T->TCOR != c->TCOR); @@ -483,8 +491,8 @@ static void ctx_restore(void *buf) do T->TCNT = c->TCNT; while(T->TCNT != c->TCNT); - do T->TCR.byte = c->TCR.byte; - while(T->TCR.byte != c->TCR.byte); + do T->TCR.byte = c->TCR; + while(T->TCR.byte != c->TCR); } *TSTR = ctx->TSTR;