diff options
Diffstat (limited to 'src/target_dsp')
-rw-r--r-- | src/target_dsp/.gitignore | 4 | ||||
-rw-r--r-- | src/target_dsp/calypso/Makefile | 7 | ||||
-rwxr-xr-x | src/target_dsp/calypso/bin2cfile.py | 50 | ||||
-rw-r--r-- | src/target_dsp/calypso/bl_stage3.S | 142 | ||||
-rw-r--r-- | src/target_dsp/calypso/dsp_dump.lds | 22 |
5 files changed, 225 insertions, 0 deletions
diff --git a/src/target_dsp/.gitignore b/src/target_dsp/.gitignore new file mode 100644 index 00000000..5cf144ea --- /dev/null +++ b/src/target_dsp/.gitignore @@ -0,0 +1,4 @@ +*.o +*.a +*.coff +*.bin diff --git a/src/target_dsp/calypso/Makefile b/src/target_dsp/calypso/Makefile new file mode 100644 index 00000000..ff21e694 --- /dev/null +++ b/src/target_dsp/calypso/Makefile @@ -0,0 +1,7 @@ +dsp_dump.bin: bl_stage3.S dsp_dump.lds + c54x-coff-as bl_stage3.S -o bl_stage3.o + c54x-coff-ld --script dsp_dump.lds bl_stage3.o -o dsp_dump.coff + c54x-coff-objcopy -j .text -O binary dsp_dump.coff dsp_dump.bin + +clean: + rm -f *.o *.bin *.coff diff --git a/src/target_dsp/calypso/bin2cfile.py b/src/target_dsp/calypso/bin2cfile.py new file mode 100755 index 00000000..51401b8f --- /dev/null +++ b/src/target_dsp/calypso/bin2cfile.py @@ -0,0 +1,50 @@ +#!/usr/bin/env python + +import struct +import sys + +def group_by_n(s, n, do_join=True): + return ( ''.join(x) for x in zip(*[s[i::n] for i in range(n)]) ) + + +def main(pn, filename): + # Get all bytes + f = open(filename, 'r') + d = f.read() + f.close() + + # Get the data + ops = ''.join([ + '0x%04x,%c' % ( + struct.unpack('=H', x)[0], + '\n' if (i&3==3) else ' ' + ) + for i, x + in enumerate(group_by_n(d, 2)) + ])[:-1] + + # Header / footer + print """ +#define _SA_DECL (const uint16_t *)&(const uint16_t []) + +static const struct dsp_section dsp_xxx[] = { + { + .addr = 0x, + .size = 0x%04x, + .data = _SA_DECL { +%s + }, + }, + { /* Guard */ + .addr = 0, + .size = 0, + .data = NULL, + }, +}; + +#undef _SA_DECL +""" % (len(d)/2, ops) + + +if __name__ == "__main__": + main(*sys.argv) diff --git a/src/target_dsp/calypso/bl_stage3.S b/src/target_dsp/calypso/bl_stage3.S new file mode 100644 index 00000000..402c3c59 --- /dev/null +++ b/src/target_dsp/calypso/bl_stage3.S @@ -0,0 +1,142 @@ + +BCSR .equ 0x29 + +CMD_IDLE .equ 1 ; Do nothing / DSP ready for commands +CMD_COPY_BLOCK .equ 2 ; (if size == 0, then exec) +CMD_COPY_MODE .equ 4 ; Select copy mode + ; (0=code write, 1=data write, + ; 2=code read, 3=data read, + ; 4=prom read, 5=drom read) +CMD_VERSION .equ 0xffff ; API_RAM[0] = bootloader version + +VERSION .equ 0x0100 ; 1.00 + + + .section .apiram + + .org 0x07fc +bl_addr_hi .ds 1 +bl_size .ds 1 +bl_addr_lo .ds 1 +bl_status .ds 1 + + + .text + .mmregs +_start: + orm #2, *(BCSR) ; ? + + ld #0x1f, DP + stm #0x1100, SP + stm #0, AR4 +_done: + stm #_api_ram, AR2 + st #CMD_IDLE, @bl_status +_loop: + ; Version + cmpm @bl_status, #CMD_VERSION + bc 1f, ntc + + bd _done + st #VERSION, *AR2 +1: + + ; Select copy mode + cmpm @bl_status, #CMD_COPY_MODE + bc 1f, ntc + + bd _done + mvdm @_api_ram, AR4 +1: + + ; Copy + cmpm @bl_status, #CMD_COPY_BLOCK + bc _loop, ntc + + ; Capture values for copy operations + ; A = full address + ; AR1 size-1 + ; AR2 api_ram (set previously) + ; AR3 data/code address + ; AR4 mode + + ldu @bl_addr_lo, A + stlm A, AR3 + add @bl_addr_hi, 16, A + + ldu @bl_size, B + stlm B, AR1 + ; mar *AR1- ; We do this in a delay slot later on ... + + ; Start + bc 1f, bneq ; B still contains size + bacc A + +1: + ; Select + stm #AR4, AR5 ; AR5 = &AR4 + bit *AR5, 13 ; Test mode(2) + bcd _read_rom, tc + mar *AR1- + bit *AR5, 15 ; Test mode(0) lsb + bcd _copy_data, tc + bit *AR5, 14 ; Test mode(1) + nop + + ; Copy to/from Program space +_copy_prog: + bc _read_prog, tc + + ; Copy from API -> prog space (mode 0) +_write_prog: + rpt *(AR1) + writa *AR2+ + b _done + + ; Copy from prog space -> API (mode 2) +_read_prog: + rpt *(AR1) + reada *AR2+ + b _done + + ; Copy to/from Data space +_copy_data: + bc _read_data, tc + + ; Copy from API -> data space (mode 1) +_write_data: + rpt *(AR1) + mvdd *AR2+, *AR3+ + b _done + + ; Copy from data space -> API (mode 3) +_read_data: + rpt *(AR1) + mvdd *AR3+, *AR2+ + b _done + + ; Read from {D,P}ROM bypassing protection +_read_rom: + ldm AR1, B ; Can't put those two ops in the delay slot of + stlm B, BRC ; 'bc' because of unprotected pipeline conflicts + bc _read_rom_data, tc + +_read_rom_prog: + rptb 1f - 1 + call prom_read_xplt +1: + b _done + +_read_rom_data: + rptb 1f - 1 + call drom_read_xplt +1: + b _done + + +drom_read_xplt .equ 0xe4b8 +prom_read_xplt .equ 0x7213 + + + .end + diff --git a/src/target_dsp/calypso/dsp_dump.lds b/src/target_dsp/calypso/dsp_dump.lds new file mode 100644 index 00000000..56633026 --- /dev/null +++ b/src/target_dsp/calypso/dsp_dump.lds @@ -0,0 +1,22 @@ +OUTPUT_FORMAT("coff1-c54x") +OUTPUT_ARCH("") +MEMORY +{ + apiram (RWXI) : ORIGIN = 0x0800, LENGTH = 0x2000 +} +SECTIONS +{ + . = 0x0800; + + .apiram : + { + PROVIDE(_api_ram = .); + *(.apiram) + } > apiram + + .text : + { + *(.text) + } > apiram +} + |