gint/dsp: add a test for DSP startup and basics
This commit is contained in:
parent
fb561d1310
commit
d03970f5ad
8
Makefile
8
Makefile
|
@ -120,18 +120,18 @@ build-cg/%.c.o: %.c
|
|||
# Assembler sources
|
||||
build-fx/%.s.o: %.s
|
||||
@ mkdir -p $(dir $@)
|
||||
$(TOOLCHAIN_FX)-gcc -c $< -o $@
|
||||
$(TOOLCHAIN_FX)-gcc -c $< -o $@ -Wa,--dsp
|
||||
build-cg/%.s.o: %.s
|
||||
@ mkdir -p $(dir $@)
|
||||
$(TOOLCHAIN_CG)-gcc -c $< -o $@
|
||||
$(TOOLCHAIN_CG)-gcc -c $< -o $@ -Wa,--dsp
|
||||
|
||||
# Preprocessed assembler sources
|
||||
build-fx/%.S.o: %.S
|
||||
@ mkdir -p $(dir $@)
|
||||
$(TOOLCHAIN_FX)-gcc -c $< -o $@ $(INCLUDE)
|
||||
$(TOOLCHAIN_FX)-gcc -c $< -o $@ $(INCLUDE) -Wa,--dsp
|
||||
build-cg/%.S.o: %.S
|
||||
@ mkdir -p $(dir $@)
|
||||
$(TOOLCHAIN_CG)-gcc -c $< -o $@ $(INCLUDE)
|
||||
$(TOOLCHAIN_CG)-gcc -c $< -o $@ $(INCLUDE) -Wa,--dsp
|
||||
|
||||
# Images
|
||||
build-fx/assets/img/%.o: assets-fx/img/%
|
||||
|
|
|
@ -11,6 +11,9 @@ void gintctl_gint_hardware(void);
|
|||
/* gintctl_gint_ram(): Determine the size of some memory areas */
|
||||
void gintctl_gint_ram(void);
|
||||
|
||||
/* gintctl_gint_dsp(): DSP initialization and configuration */
|
||||
void gintctl_gint_dsp(void);
|
||||
|
||||
/* gintctl_gint_dump(): Dump memory to filesystem */
|
||||
void gintctl_gint_dump(void);
|
||||
|
||||
|
|
|
@ -0,0 +1,101 @@
|
|||
#include <gint/display.h>
|
||||
#include <gint/keyboard.h>
|
||||
|
||||
#include <gintctl/gint.h>
|
||||
#include <gintctl/util.h>
|
||||
|
||||
#ifdef FXCG50
|
||||
|
||||
extern void dsp_ldrc(void);
|
||||
extern int dsp_padd(int x, int y);
|
||||
extern int dsp_cpumul(int x, int y);
|
||||
extern int dsp_loop(int x);
|
||||
|
||||
/* gintctl_gint_dsp(): DSP initialization and configuration */
|
||||
void gintctl_gint_dsp(void)
|
||||
{
|
||||
int key = 0;
|
||||
|
||||
int padd_x=27, padd_y=15;
|
||||
int padd_done = 0;
|
||||
int padd_result = 0;
|
||||
|
||||
int mul_x=12, mul_y=14;
|
||||
int mul_done = 0;
|
||||
int mul_result = 0;
|
||||
|
||||
int loop_x = 16;
|
||||
int loop_done = 0;
|
||||
int loop_result = 0;
|
||||
|
||||
while(key != KEY_EXIT)
|
||||
{
|
||||
dclear(C_WHITE);
|
||||
row_title("DSP initialization and basic instructions");
|
||||
|
||||
row_print(1, 1, "F1: LDRC instruction");
|
||||
row_print(2, 1, "F2: PADD instruction");
|
||||
if(!padd_done)
|
||||
{
|
||||
row_print(3, 3, "%d + %d = (not tested yet)", padd_x,
|
||||
padd_y);
|
||||
}
|
||||
else
|
||||
{
|
||||
row_print(3, 3, "%d + %d = %d", padd_x, padd_y,
|
||||
padd_result);
|
||||
}
|
||||
row_print(4, 1, "F3: Multiplication by CPU");
|
||||
if(!mul_done)
|
||||
{
|
||||
row_print(5, 3, "%d * %d = (not tested yet)", mul_x,
|
||||
mul_y);
|
||||
}
|
||||
else
|
||||
{
|
||||
row_print(5, 3, "%d * %d = %d", mul_x, mul_y,
|
||||
mul_result);
|
||||
}
|
||||
row_print(6, 1, "F4: Repeat loop");
|
||||
if(!loop_done)
|
||||
{
|
||||
row_print(7, 3, "%d times 1 = (not tested yet)",
|
||||
loop_x);
|
||||
}
|
||||
else
|
||||
{
|
||||
row_print(7, 3, "%d times 1 = %d", loop_x,
|
||||
loop_result);
|
||||
}
|
||||
|
||||
fkey_button(1, "LDRC");
|
||||
fkey_button(2, "PADD");
|
||||
fkey_button(3, "PMULS");
|
||||
fkey_button(4, "LOOP");
|
||||
|
||||
dupdate();
|
||||
key = getkey().key;
|
||||
|
||||
if(key == KEY_F1)
|
||||
{
|
||||
dsp_ldrc();
|
||||
}
|
||||
if(key == KEY_F2)
|
||||
{
|
||||
padd_result = dsp_padd(padd_x, padd_y);
|
||||
padd_done = 1;
|
||||
}
|
||||
if(key == KEY_F3)
|
||||
{
|
||||
mul_result = dsp_cpumul(mul_x, mul_y);
|
||||
mul_done = 1;
|
||||
}
|
||||
if(key == KEY_F4)
|
||||
{
|
||||
loop_result = dsp_loop(loop_x);
|
||||
loop_done = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,54 @@
|
|||
.global _dsp_ldrc
|
||||
.global _dsp_padd
|
||||
.global _dsp_cpumul
|
||||
.global _dsp_loop
|
||||
|
||||
_dsp_ldrc:
|
||||
/* Check that LDRC is available */
|
||||
ldrc #16
|
||||
rts
|
||||
nop
|
||||
|
||||
_dsp_padd:
|
||||
/* Add some numbers */
|
||||
lds r4, x0
|
||||
lds r5, y0
|
||||
padd x0, y0, a0
|
||||
sts a0, r0
|
||||
rts
|
||||
nop
|
||||
|
||||
_dsp_cpumul:
|
||||
/* Multiply stuff but use the CPU */
|
||||
lds r4, x0
|
||||
lds r5, y0
|
||||
|
||||
/* Make it normal registers... (slow) */
|
||||
sts x0, r0
|
||||
sts y0, r1
|
||||
mul.l r0, r1
|
||||
/* Take result back directly to DSP (latency?) */
|
||||
psts macl, a0
|
||||
|
||||
/* Return the result in r0 */
|
||||
sts a0, r0
|
||||
rts
|
||||
nop
|
||||
|
||||
_dsp_loop:
|
||||
mov #1, r0
|
||||
lds r0, x0
|
||||
pclr y0
|
||||
|
||||
ldrs 1f
|
||||
ldre 2f
|
||||
ldrc r4
|
||||
nop
|
||||
|
||||
1:
|
||||
2:
|
||||
padd x0, y0, y0
|
||||
|
||||
sts y0, r0
|
||||
rts
|
||||
nop
|
|
@ -63,6 +63,10 @@ void show_mpucpu(void)
|
|||
|
||||
volatile uint32_t *CPUOPM = (void *)0xff2f0000;
|
||||
row_print(6, 1, _(" CPUOPM:"," CPU Operation Mode: ") "%08x", *CPUOPM);
|
||||
|
||||
uint32_t SR;
|
||||
__asm__("stc sr, %0" : "=r"(SR));
|
||||
row_print(7, 1, _(" SR:", " Status Register: ") "%08x", SR);
|
||||
}
|
||||
|
||||
/* Memory */
|
||||
|
|
|
@ -35,6 +35,9 @@ struct menu menu_gint = {
|
|||
|
||||
{ "Hardware", gintctl_gint_hardware },
|
||||
{ "RAM discovery", gintctl_gint_ram },
|
||||
#ifdef FXCG50
|
||||
{ "DSP processors", gintctl_gint_dsp },
|
||||
#endif
|
||||
{ "Memory dump", gintctl_gint_dump },
|
||||
{ "Switching to OS", gintctl_gint_switch },
|
||||
{ "TLB management", gintctl_gint_tlb },
|
||||
|
|
Loading…
Reference in New Issue