2010-04-03 14:04:50 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
2010-05-09 19:23:26 +00:00
|
|
|
* Copyright (C) 2010 Thomas Martitz, Andree Buschmann
|
2010-04-03 14:04:50 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include "plugin.h"
|
|
|
|
|
|
|
|
PLUGIN_HEADER
|
|
|
|
|
2010-05-24 23:18:30 +00:00
|
|
|
#if PLUGIN_BUFFER_SIZE <= 0x8000
|
|
|
|
#define BUF_SIZE (1<<12) /* 16 KB = (1<<12)*sizeof(int) */
|
|
|
|
#else
|
2010-05-09 19:23:26 +00:00
|
|
|
#define BUF_SIZE (1<<13) /* 32 KB = (1<<13)*sizeof(int) */
|
2010-05-24 23:18:30 +00:00
|
|
|
#endif
|
2010-05-09 19:23:26 +00:00
|
|
|
|
|
|
|
#define LOOP_REPEAT_DRAM 256
|
|
|
|
static volatile int buf_dram[BUF_SIZE];
|
|
|
|
|
|
|
|
#if defined(PLUGIN_USE_IRAM)
|
|
|
|
#define LOOP_REPEAT_IRAM 1024
|
|
|
|
static volatile int buf_iram[BUF_SIZE] IBSS_ATTR;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* (Byte per loop * loops)>>20 * ticks per s * 10 / ticks = dMB per s */
|
|
|
|
#define dMB_PER_SEC(cnt, delta) ((((BUF_SIZE*sizeof(int)*cnt)>>20)*HZ*10)/delta)
|
|
|
|
|
2010-05-18 10:14:15 +00:00
|
|
|
void memset_test(volatile int *buf, int buf_size, int loop_cnt,
|
|
|
|
int line, char *ramtype)
|
|
|
|
{
|
|
|
|
int delta, dMB, i;
|
|
|
|
int last_tick = *rb->current_tick;
|
|
|
|
|
|
|
|
for(i=0; i < loop_cnt; i++)
|
2010-05-24 17:13:48 +00:00
|
|
|
{
|
|
|
|
memset((void *)buf, 0xff, buf_size*sizeof(int));
|
|
|
|
}
|
2010-05-18 10:14:15 +00:00
|
|
|
|
|
|
|
delta = *rb->current_tick - last_tick;
|
|
|
|
delta = delta>0 ? delta : delta+1;
|
|
|
|
dMB = dMB_PER_SEC(loop_cnt, delta);
|
2010-05-24 17:13:48 +00:00
|
|
|
rb->screens[0]->putsf(0, line, "%s st: %3d.%d MB/s (%3d ticks for %d MB)",
|
2010-05-18 10:14:15 +00:00
|
|
|
ramtype, dMB/10, dMB%10, delta,
|
|
|
|
(loop_cnt*BUF_SIZE*4)>>20);
|
|
|
|
}
|
|
|
|
|
|
|
|
void memcpy_test(volatile int *buf, int buf_size, int loop_cnt,
|
|
|
|
int line, char *ramtype)
|
|
|
|
{
|
|
|
|
int delta, dMB, i;
|
|
|
|
int last_tick = *rb->current_tick;
|
|
|
|
|
2010-05-24 17:13:48 +00:00
|
|
|
/* double loop count to compensate for half size memcpy */
|
|
|
|
for(i=0; i < loop_cnt*2; i++)
|
|
|
|
{
|
|
|
|
memcpy((void *)buf+(buf_size*sizeof(int)/2),
|
|
|
|
(void *)buf, buf_size*sizeof(int)/2);
|
|
|
|
}
|
2010-05-18 10:14:15 +00:00
|
|
|
|
|
|
|
delta = *rb->current_tick - last_tick;
|
|
|
|
delta = delta>0 ? delta : delta+1;
|
|
|
|
dMB = dMB_PER_SEC(loop_cnt, delta);
|
2010-05-24 17:13:48 +00:00
|
|
|
rb->screens[0]->putsf(0, line, "%s cp: %3d.%d MB/s (%3d ticks for %d MB)",
|
2010-05-18 10:14:15 +00:00
|
|
|
ramtype, dMB/10, dMB%10, delta,
|
|
|
|
(loop_cnt*BUF_SIZE*4)>>21);
|
|
|
|
}
|
|
|
|
|
2010-05-09 19:23:26 +00:00
|
|
|
void write_test(volatile int *buf, int buf_size, int loop_cnt,
|
|
|
|
int line, char *ramtype)
|
|
|
|
{
|
|
|
|
int delta, dMB;
|
|
|
|
int last_tick = *rb->current_tick;
|
|
|
|
|
|
|
|
#if defined(CPU_ARM)
|
|
|
|
asm volatile (
|
|
|
|
"mov r0, #0 \n"
|
|
|
|
"mov r1, #1 \n"
|
|
|
|
"mov r2, #2 \n"
|
|
|
|
"mov r3, #3 \n"
|
|
|
|
"mov r6, %[loops] \n"
|
|
|
|
".outer_loop_read: \n"
|
|
|
|
"mov r4, %[buf_p] \n"
|
|
|
|
"mov r5, %[size] \n"
|
|
|
|
".inner_loop_read: \n"
|
|
|
|
"stmia r4!, {r0-r3} \n"
|
|
|
|
"stmia r4!, {r0-r3} \n"
|
|
|
|
"subs r5, r5, #8 \n"
|
|
|
|
"bgt .inner_loop_read \n"
|
|
|
|
"subs r6, r6, #1 \n"
|
|
|
|
"bgt .outer_loop_read \n"
|
|
|
|
:
|
|
|
|
: [loops] "r" (loop_cnt), [size] "r" (buf_size), [buf_p] "r" (buf)
|
2010-05-24 17:13:48 +00:00
|
|
|
: "r0", "r1", "r2", "r3", "r4", "r5", "r6", "memory", "cc"
|
2010-05-09 19:23:26 +00:00
|
|
|
);
|
|
|
|
#else
|
|
|
|
int i, j;
|
|
|
|
for(i = 0; i < loop_cnt; i++)
|
|
|
|
{
|
|
|
|
for (j = 0; j < buf_size; j+=4)
|
|
|
|
{
|
|
|
|
buf[j ] = j;
|
|
|
|
buf[j+1] = j+1;
|
|
|
|
buf[j+2] = j+2;
|
|
|
|
buf[j+3] = j+3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
delta = *rb->current_tick - last_tick;
|
|
|
|
delta = delta>0 ? delta : delta+1;
|
|
|
|
dMB = dMB_PER_SEC(loop_cnt, delta);
|
2010-05-24 17:13:48 +00:00
|
|
|
rb->screens[0]->putsf(0, line, "%s wr: %3d.%d MB/s (%3d ticks for %d MB)",
|
2010-05-09 19:23:26 +00:00
|
|
|
ramtype, dMB/10, dMB%10, delta,
|
|
|
|
(loop_cnt*BUF_SIZE*4)>>20);
|
|
|
|
}
|
|
|
|
|
|
|
|
void read_test(volatile int *buf, int buf_size, int loop_cnt,
|
|
|
|
int line, char *ramtype)
|
|
|
|
{
|
|
|
|
int delta, dMB;
|
|
|
|
int last_tick = *rb->current_tick;
|
|
|
|
|
|
|
|
#if defined(CPU_ARM)
|
|
|
|
asm volatile (
|
|
|
|
"mov r6, %[loops] \n"
|
|
|
|
".outer_loop_write: \n"
|
|
|
|
"mov r4, %[buf_p] \n"
|
|
|
|
"mov r5, %[size] \n"
|
|
|
|
".inner_loop_write: \n"
|
|
|
|
"ldmia r4!, {r0-r3} \n"
|
|
|
|
"ldmia r4!, {r0-r3} \n"
|
|
|
|
"subs r5, r5, #8 \n"
|
|
|
|
"bgt .inner_loop_write \n"
|
|
|
|
"subs r6, r6, #1 \n"
|
|
|
|
"bgt .outer_loop_write \n"
|
|
|
|
:
|
|
|
|
: [loops] "r" (loop_cnt), [size] "r" (buf_size), [buf_p] "r" (buf)
|
2010-05-24 17:13:48 +00:00
|
|
|
: "r0", "r1", "r2", "r3", "r4", "r5", "r6", "memory", "cc"
|
2010-05-09 19:23:26 +00:00
|
|
|
);
|
|
|
|
#else
|
|
|
|
int i, j, x;
|
|
|
|
for(i = 0; i < loop_cnt; i++)
|
|
|
|
{
|
|
|
|
for(j = 0; j < buf_size; j+=4)
|
|
|
|
{
|
|
|
|
x = buf[j ];
|
|
|
|
x = buf[j+2];
|
|
|
|
x = buf[j+3];
|
|
|
|
x = buf[j+4];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
delta = *rb->current_tick - last_tick;
|
|
|
|
delta = delta>0 ? delta : delta+1;
|
|
|
|
dMB = dMB_PER_SEC(loop_cnt, delta);
|
2010-05-24 17:13:48 +00:00
|
|
|
rb->screens[0]->putsf(0, line, "%s rd: %3d.%d MB/s (%3d ticks for %d MB)",
|
2010-05-09 19:23:26 +00:00
|
|
|
ramtype, dMB/10, dMB%10, delta,
|
|
|
|
(loop_cnt*BUF_SIZE*4)>>20);
|
|
|
|
}
|
2010-05-07 21:42:22 +00:00
|
|
|
|
2010-04-03 14:04:50 +00:00
|
|
|
|
|
|
|
enum plugin_status plugin_start(const void* parameter)
|
|
|
|
{
|
|
|
|
(void)parameter;
|
|
|
|
bool done = false;
|
|
|
|
bool boost = false;
|
|
|
|
int count = 0;
|
|
|
|
|
2010-05-24 23:18:30 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2010-04-03 14:04:50 +00:00
|
|
|
rb->lcd_setfont(FONT_SYSFIXED);
|
2010-05-24 23:18:30 +00:00
|
|
|
#endif
|
2010-05-09 19:23:26 +00:00
|
|
|
|
|
|
|
rb->screens[0]->clear_display();
|
|
|
|
rb->screens[0]->putsf(0, 0, "patience, may take some seconds...");
|
|
|
|
rb->screens[0]->update();
|
2010-04-03 14:04:50 +00:00
|
|
|
|
|
|
|
while (!done)
|
|
|
|
{
|
|
|
|
int line = 0;
|
|
|
|
|
|
|
|
rb->screens[0]->clear_display();
|
|
|
|
rb->screens[0]->putsf(0, line++, "%s", boost?"boosted":"unboosted");
|
2010-05-09 19:23:26 +00:00
|
|
|
#ifndef SIMULATOR
|
|
|
|
rb->screens[0]->putsf(0, line++, "clock: %d Hz", *rb->cpu_frequency);
|
|
|
|
#endif
|
2010-04-03 14:04:50 +00:00
|
|
|
rb->screens[0]->putsf(0, line++, "loop#: %d", ++count);
|
2010-05-09 19:23:26 +00:00
|
|
|
|
2010-05-24 17:13:48 +00:00
|
|
|
read_test (buf_dram, BUF_SIZE, LOOP_REPEAT_DRAM, line++, "DRAM");
|
|
|
|
write_test (buf_dram, BUF_SIZE, LOOP_REPEAT_DRAM, line++, "DRAM");
|
2010-05-18 10:14:15 +00:00
|
|
|
memset_test(buf_dram, BUF_SIZE, LOOP_REPEAT_DRAM, line++, "DRAM");
|
|
|
|
memcpy_test(buf_dram, BUF_SIZE, LOOP_REPEAT_DRAM, line++, "DRAM");
|
2010-05-09 19:23:26 +00:00
|
|
|
#if defined(PLUGIN_USE_IRAM)
|
2010-05-24 17:13:48 +00:00
|
|
|
read_test (buf_iram, BUF_SIZE, LOOP_REPEAT_IRAM, line++, "IRAM");
|
|
|
|
write_test (buf_iram, BUF_SIZE, LOOP_REPEAT_IRAM, line++, "IRAM");
|
2010-05-18 10:14:15 +00:00
|
|
|
memset_test(buf_iram, BUF_SIZE, LOOP_REPEAT_DRAM, line++, "IRAM");
|
|
|
|
memcpy_test(buf_iram, BUF_SIZE, LOOP_REPEAT_DRAM, line++, "IRAM");
|
2010-05-09 19:23:26 +00:00
|
|
|
#endif
|
|
|
|
|
2010-04-03 14:04:50 +00:00
|
|
|
rb->screens[0]->update();
|
|
|
|
|
2010-05-09 19:23:26 +00:00
|
|
|
switch (rb->get_action(CONTEXT_STD, HZ/5))
|
2010-04-03 14:04:50 +00:00
|
|
|
{
|
2010-04-03 23:14:25 +00:00
|
|
|
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
|
|
|
|
case ACTION_STD_PREV:
|
2010-04-03 14:04:50 +00:00
|
|
|
if (!boost)
|
|
|
|
{
|
|
|
|
rb->cpu_boost(true);
|
|
|
|
boost = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2010-04-03 23:14:25 +00:00
|
|
|
case ACTION_STD_NEXT:
|
2010-04-03 14:04:50 +00:00
|
|
|
if (boost)
|
|
|
|
{
|
|
|
|
rb->cpu_boost(false);
|
|
|
|
boost = false;
|
|
|
|
}
|
|
|
|
break;
|
2010-04-03 23:14:25 +00:00
|
|
|
#endif
|
|
|
|
case ACTION_STD_CANCEL:
|
2010-04-03 14:04:50 +00:00
|
|
|
done = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return PLUGIN_OK;
|
|
|
|
}
|