amiga_boottest
diff src/copper.c @ 1:48093e4bd99a
stuff
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Wed, 21 Feb 2018 18:00:45 +0200 |
parents | |
children | 58ebd84822e7 |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/copper.c Wed Feb 21 18:00:45 2018 +0200 1.3 @@ -0,0 +1,77 @@ 1.4 +#include "copper.h" 1.5 +#include "hwregs.h" 1.6 + 1.7 +uint32_t *copperlist, *copperlist_end; 1.8 +static uint32_t *copmem, *curlist; 1.9 +static int mode, copmem_size; 1.10 + 1.11 +extern uint32_t _mem_start; 1.12 + 1.13 +int init_copper(int maxlist, int nlists) 1.14 +{ 1.15 + /* allocate and set new copper lists */ 1.16 + if(maxlist <= 0) maxlist = 256; 1.17 + mode = nlists >= COPPER_DOUBLE ? COPPER_DOUBLE : COPPER_SINGLE; 1.18 + 1.19 + copmem_size = maxlist * 4 * mode; 1.20 + copmem = (uint32_t*)_mem_start; 1.21 + 1.22 + curlist = copperlist = copmem; 1.23 + *curlist = COPPER_END; 1.24 + 1.25 + if(mode == COPPER_DOUBLE) { 1.26 + copperlist = curlist + maxlist; 1.27 + *copperlist = COPPER_END; 1.28 + } 1.29 + copperlist_end = copperlist; 1.30 + 1.31 + REG32_COP1LC = (uint32_t)curlist; 1.32 + REG_COPJMP1 = 0; /* causes copper to read COP1LC */ 1.33 + return 0; 1.34 +} 1.35 + 1.36 +void cleanup_copper(void) 1.37 +{ 1.38 +} 1.39 + 1.40 +void enable_copper(void) 1.41 +{ 1.42 + REG_DMACON = SETBITS(DMA_COPPER); 1.43 +} 1.44 + 1.45 +void disable_copper(void) 1.46 +{ 1.47 + REG_DMACON = CLRBITS(DMA_COPPER); 1.48 +} 1.49 + 1.50 +void clear_copper(void) 1.51 +{ 1.52 + copperlist_end = copperlist; 1.53 + *copperlist_end = COPPER_END; 1.54 +} 1.55 + 1.56 +void add_copper(uint32_t cmd) 1.57 +{ 1.58 + *copperlist_end++ = cmd; 1.59 +} 1.60 + 1.61 +void sort_copper(void) 1.62 +{ 1.63 + /* TODO */ 1.64 +} 1.65 + 1.66 +void swap_copper(void) 1.67 +{ 1.68 + if(mode == COPPER_DOUBLE) { 1.69 + uint32_t *tmpptr; 1.70 + tmpptr = curlist; 1.71 + curlist = copperlist; 1.72 + copperlist = copperlist_end = tmpptr; 1.73 + 1.74 + REG32_COP1LC = (uint32_t)curlist; 1.75 + REG_COPJMP1 = 0; 1.76 + } else { 1.77 + copperlist_end = curlist; 1.78 + } 1.79 + *copperlist_end = COPPER_END; 1.80 +}