use less static RAM to improve SH3 support

This commit is contained in:
Lephe 2020-07-10 16:05:11 +02:00
parent b2f580a009
commit ece65927f0
No known key found for this signature in database
GPG key ID: 1BBA026E13FC0495
4 changed files with 24 additions and 16 deletions

View file

@ -48,7 +48,7 @@ typedef volatile struct
);
pad(19);
} GPACKED(0x10) etmu_t;
} GPACKED(4) etmu_t;
//---
// SH7705 Timer Unit. Refer to:

View file

@ -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)

View file

@ -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

View file

@ -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;