timer_callbacks: add an ICS test

This commit is contained in:
Lephenixnoir 2021-06-18 14:45:23 +02:00
parent c9d01109c7
commit ebc9b5c1c2
Signed by: Lephenixnoir
GPG Key ID: 1BBA026E13FC0495
3 changed files with 40 additions and 20 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

@ -11,15 +11,14 @@ static int tests = 0;
/* Auxiliary timer for tests than need an interrupt during the callback */
static int auxiliary_timer = -1;
static int callback_simple(volatile void *arg)
static int callback_simple(volatile int *base)
{
/* Perform a multiplication to check basic register saves */
int base = *(volatile int *)arg;
tests++;
return base * 387 + TIMER_STOP;
return (*base) * 387 + TIMER_STOP;
}
static int callback_sleep(GUNUSED volatile void *arg)
static int callback_sleep(void)
{
/* Start the aux. timer to have a guaranteed non-masked interrupt */
timer_start(auxiliary_timer);
@ -28,7 +27,7 @@ static int callback_sleep(GUNUSED volatile void *arg)
return TIMER_STOP;
}
static int callback_timer(GUNUSED volatile void *arg)
static int callback_timer(void)
{
/* Wait specifically on the auxiliary timer */
timer_start(auxiliary_timer);
@ -37,6 +36,13 @@ static int callback_timer(GUNUSED volatile void *arg)
return TIMER_STOP;
}
static int callback_ics(cpu_csleep_t *ics)
{
cpu_csleep_cancel(ics);
tests++;
return TIMER_STOP;
}
/* gintctl_gint_timer_callbacks(): Stunts in the environment of callbacks */
void gintctl_gint_timer_callbacks(void)
{
@ -59,7 +65,7 @@ void gintctl_gint_timer_callbacks(void)
extern bopti_image_t img_opt_gint_timer_callbacks;
dimage(0, 56, &img_opt_gint_timer_callbacks);
dprint(69, 56, C_BLACK, "Done:%d", tests);
dprint(86, 56, C_BLACK, "Done:%d", tests);
#endif
#ifdef FXCG50
@ -77,33 +83,41 @@ void gintctl_gint_timer_callbacks(void)
"TIMER runs a callback that starts a timer (with its");
row_print(8, 1,
"own callback) and waits for the interrupt.");
row_print(10, 1,
"ICS uses an interrupt-cancellable sleep.");
row_print(10, 1, "Tests run: %d", tests);
row_print(12, 1, "Tests run: %d", tests);
if(status == 1) row_print(12, 1, "Success!");
if(status == 2) row_print(12, 1, "Not enough timers!");
if(status == 1) row_print(13, 1, "Success!");
if(status == 2) row_print(13, 1, "Not enough timers!");
fkey_action(1, "SIMPLE");
fkey_action(2, "SLEEP");
fkey_action(3, "TIMER");
fkey_button(1, "SIMPLE");
fkey_button(2, "SLEEP");
fkey_button(3, "TIMER");
fkey_button(4, "ICS");
#endif
dupdate();
key = getkey().key;
status = 0;
int (*callback)(volatile void *arg) = NULL;
volatile void *arg = NULL;
gint_call_t cb;
auxiliary_timer = -1;
if(key == KEY_F1) callback = callback_simple, arg = &base;
if(key == KEY_F2) callback = callback_sleep;
if(key == KEY_F3) callback = callback_timer;
cpu_csleep_t ics;
if(!callback) continue;
if(key == KEY_F4)
{
cpu_csleep_init(&ics);
cb = GINT_CALL(callback_ics, (void *)&ics);
}
else if(key == KEY_F1) cb = GINT_CALL(callback_simple, &base);
else if(key == KEY_F2) cb = GINT_CALL(callback_sleep);
else if(key == KEY_F3) cb = GINT_CALL(callback_timer);
else continue;
/* Allocate a first timer to run the callback */
int t = timer_configure(TIMER_ANY, 40000, GINT_CALL(callback, arg));
int t = timer_configure(TIMER_ANY, 40000, cb);
if(t < 0)
{
status = 2;
@ -128,7 +142,10 @@ void gintctl_gint_timer_callbacks(void)
status = 1;
timer_start(t);
timer_wait(t);
/* Test the ICS on F4 */
if(key == KEY_F4) cpu_csleep(&ics);
else timer_wait(t);
}
}

View File

@ -22,6 +22,7 @@ extern void memory_dsp_xyram_memcpy(volatile uint8_t *dst,
GILRAM GALIGNED(32) static char ilram_buffer[0x800];
GXRAM GALIGNED(32) static char xram_buffer[0x800];
GYRAM GALIGNED(32) static char yram_buffer[0x800];
#define pram0 ((void *)0xfe200000)
struct results
{
@ -288,6 +289,7 @@ void gintctl_perf_memory(void)
fkey_button(2, "ILRAM");
fkey_button(3, "XRAM");
fkey_button(4, "YRAM");
fkey_button(5, "PRAM0");
#endif
dfont(old_font);
@ -299,6 +301,7 @@ void gintctl_perf_memory(void)
if(key == KEY_F2) test(&r, &ilram_buffer, 0x800, 64);
if(key == KEY_F3) test(&r, &xram_buffer, 0x800, 64);
if(key == KEY_F4) test(&r, &yram_buffer, 0x800, 64);
if(key == KEY_F5) test(&r, pram0, 0x8000, 1);
}
}
}