FreeCalypso > hg > freecalypso-tools
comparison target-utils/dspdump/dspops.c @ 540:27b5526ba1a8
dspdump target program written, compiles
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 28 Oct 2019 08:19:33 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
539:4f346c10f056 | 540:27b5526ba1a8 |
---|---|
1 #include "types.h" | |
2 #include "leadapi.h" | |
3 #include "dumpagent.h" | |
4 | |
5 wait_for_dsp_ready() | |
6 { | |
7 unsigned cnt; | |
8 | |
9 for (cnt = 0; cnt < 10000; cnt++) | |
10 if (DOWNLOAD_STATUS == LEAD_READY) | |
11 return(0); | |
12 return(-1); | |
13 } | |
14 | |
15 boot_dsp_dump_agent() | |
16 { | |
17 const u16 *src; | |
18 volatile u16 *api; | |
19 unsigned n; | |
20 | |
21 /* put it into reset first */ | |
22 CLKM_CNTL_RST |= CLKM_LEAD_RST; | |
23 /* generous 1 ms for the reset pulse */ | |
24 wait_ARM_cycles(13000); | |
25 /* lift it out of reset */ | |
26 CLKM_CNTL_RST &= ~CLKM_LEAD_RST; | |
27 /* another generous 1 ms */ | |
28 wait_ARM_cycles(13000); | |
29 /* bootloader should be ready for us now */ | |
30 if (wait_for_dsp_ready() < 0) { | |
31 printf("ERROR: DSP bootloader not ready out of reset\n"); | |
32 return(-1); | |
33 } | |
34 /* upload the agent code */ | |
35 src = dsp_agent_code; | |
36 api = (volatile u16 *) APIF_ADDR; | |
37 for (n = 0; n < DSP_DUMPCODE_LEN; n++) | |
38 *api++ = *src++; | |
39 DOWNLOAD_EXT_PAGE = 0; | |
40 DOWNLOAD_SIZE = DSP_DUMPCODE_LEN; | |
41 DOWNLOAD_ADDR = DSP_DUMPCODE_START; | |
42 DOWNLOAD_STATUS = BLOCK_READY; | |
43 if (wait_for_dsp_ready() < 0) { | |
44 printf("ERROR: DSP bl not ready after block write\n"); | |
45 return(-1); | |
46 } | |
47 /* start it! */ | |
48 DOWNLOAD_EXT_PAGE = 0; | |
49 DOWNLOAD_SIZE = 0; | |
50 DOWNLOAD_ADDR = DSP_DUMPCODE_START; | |
51 DOWNLOAD_STATUS = BLOCK_READY; | |
52 if (wait_for_dsp_ready() < 0) { | |
53 printf("ERROR: DSP not ready after commanded jump to agent\n"); | |
54 return(-1); | |
55 } | |
56 } | |
57 | |
58 dsp_read_op(mode, addr, blklen) | |
59 u16 mode, blklen; | |
60 u32 addr; | |
61 { | |
62 int rc; | |
63 | |
64 APIRAM_FIRST_WORD = mode; | |
65 DOWNLOAD_STATUS = PAGE_SELECTION; | |
66 rc = wait_for_dsp_ready(); | |
67 if (rc < 0) | |
68 return(rc); | |
69 DOWNLOAD_EXT_PAGE = addr >> 16; | |
70 DOWNLOAD_SIZE = blklen; | |
71 DOWNLOAD_ADDR = addr; | |
72 DOWNLOAD_STATUS = BLOCK_READY; | |
73 rc = wait_for_dsp_ready(); | |
74 return(rc); | |
75 } |