revision 815:866c103d72cd
summary |
tree |
shortlog |
changelog |
graph |
changeset |
raw | bz2 | zip | gz changeset | 815:866c103d72cd |
parent | 814:f1a21df54e19 |
child | 816:2c3cf97de0f5 |
author | nkeynes |
date | Mon Aug 18 12:20:28 2008 +0000 (15 years ago) |
Implement memcpy_to_aica, still a work in progress though
![]() | test/Makefile.in | view | annotate | diff | log | |
![]() | test/asic.c | view | annotate | diff | log | |
![]() | test/asic.h | view | annotate | diff | log | |
![]() | test/dmac.c | view | annotate | diff | log | |
![]() | test/interrupt.s | view | annotate | diff | log | |
![]() | test/lib.h | view | annotate | diff | log |
1.1 --- a/test/Makefile.in Mon Aug 18 12:18:10 2008 +00001.2 +++ b/test/Makefile.in Mon Aug 18 12:20:28 2008 +00001.3 @@ -105,7 +105,7 @@1.4 $(SH4CC) $(SH4LDFLAGS) $^ -o $@ $(SH4LIBS)1.5 $(SH4OBJCOPY) testta testta.bin1.7 -testaica: lib/crt0.so $(SHARED_OBJECTS) testaica.so dmac.so asic.so lib.so1.8 +testaica: lib/crt0.so $(SHARED_OBJECTS) testaica.so dmac.so asic.so lib.so interrupt.so1.9 $(SH4CC) $(SH4LDFLAGS) $^ -o $@ $(SH4LIBS)1.10 $(SH4OBJCOPY) testaica testaica.bin
2.1 --- a/test/asic.c Mon Aug 18 12:18:10 2008 +00002.2 +++ b/test/asic.c Mon Aug 18 12:20:28 2008 +00002.3 @@ -23,6 +23,7 @@2.4 #define ASIC_IRQA(n) (ASIC_BASE + 0x910 + (n<<2))2.5 #define ASIC_IRQB(n) (ASIC_BASE + 0x920 + (n<<2))2.6 #define ASIC_IRQC(n) (ASIC_BASE + 0x930 + (n<<2))2.7 +#define G2_FIFO (ASIC_BASE + 0x88C)2.8 #define TIMEOUT 100000002.10 /**2.11 @@ -111,3 +112,18 @@2.12 }2.13 fprintf( f, "\n" );2.14 }2.15 +2.16 +/**2.17 + * Wait until the g2 fifo is clear to write more data.2.18 + */2.19 +int g2_fifo_wait()2.20 +{2.21 + int i;2.22 + for (i=0; i<0x1800; i++) {2.23 + if (!(long_read(G2_FIFO) & 0x11)) {2.24 + return 0;2.25 + }2.26 +2.27 + }2.28 + return -1;2.29 +}2.30 \ No newline at end of file
3.1 --- a/test/asic.h Mon Aug 18 12:18:10 2008 +00003.2 +++ b/test/asic.h Mon Aug 18 12:20:28 2008 +00003.3 @@ -60,3 +60,8 @@3.4 void asic_dump( FILE *f );3.6 void asic_mask_all();3.7 +3.8 +/**3.9 + * Wait until the G2 FIFO buffer is clear to write3.10 + */3.11 +int g2_fifo_wait();
4.1 --- a/test/dmac.c Mon Aug 18 12:18:10 2008 +00004.2 +++ b/test/dmac.c Mon Aug 18 12:20:28 2008 +00004.3 @@ -16,6 +16,7 @@4.4 * GNU General Public License for more details.4.5 */4.7 +#include <assert.h>4.8 #include "dma.h"4.9 #include "asic.h"4.11 @@ -40,7 +41,8 @@4.12 #define SORT_DMA_CTL (ASIC_BASE+0x820)4.13 #define SORT_DMA_COUNT (ASIC_BASE+0x860)4.15 -#define G2BASERAM 0x008000004.16 +#define AICA_RAM_BASE 0xA08000004.17 +#define AICA_RAM_SIZE 0x002000004.19 #define G2DMABASE 0xA05F78004.20 #define G2DMATIMEOUT (G2DMABASE+0x90)4.21 @@ -203,3 +205,23 @@4.22 {4.23 return aica_dma_transfer( aica_addr, data, size, 0 );4.24 }4.25 +4.26 +int memcpy_to_aica( uint32_t aica_addr, void *data, size_t size )4.27 +{4.28 + assert( (aica_addr & 0x03) == 0 );4.29 + uint32_t *src = (uint32_t *)data;4.30 + uint32_t *dest = (uint32_t *)aica_addr;4.31 + while( size > 0 ) {4.32 + int i;4.33 + if( g2_fifo_wait() != 0 ) {4.34 + return -1;4.35 + }4.36 + irq_disable();4.37 + for( i=0; i<8 && size > 0; i++ ) {4.38 + *dest++ = *src++;4.39 + size -= 4;4.40 + }4.41 + irq_enable();4.42 + }4.43 + return 0;4.44 +}
5.1 --- a/test/interrupt.s Mon Aug 18 12:18:10 2008 +00005.2 +++ b/test/interrupt.s Mon Aug 18 12:20:28 2008 +00005.3 @@ -265,3 +265,35 @@5.4 handler_stack:5.5 .skip 0x2005.6 handler_stack_end:5.7 +5.8 +5.9 +.globl _irq_disable5.10 +_irq_disable:5.11 + mov.l _irqd_and,r15.12 + mov.l _irqd_or,r25.13 + stc sr,r05.14 + and r0,r15.15 + or r2,r15.16 + ldc r1,sr5.17 + rts5.18 + nop5.19 +5.20 + .align 25.21 +_irqd_and:5.22 + .long 0xefffff0f5.23 +_irqd_or:5.24 + .long 0x000000f05.25 +5.26 +5.27 +.globl _irq_enable5.28 +_irq_enable:5.29 + mov.l _irqe_and,r15.30 + stc sr,r05.31 + and r0,r15.32 + ldc r1,sr5.33 + rts5.34 + nop5.35 +5.36 + .align 25.37 +_irqe_and:5.38 + .long 0xefffff0f
6.1 --- a/test/lib.h Mon Aug 18 12:18:10 2008 +00006.2 +++ b/test/lib.h Mon Aug 18 12:20:28 2008 +00006.3 @@ -38,7 +38,6 @@6.4 void *align32(char *buf );6.5 void write_asic_status(void);6.6 void reset_asic_status(void);6.7 -void g2_fifo_wait( void );6.9 #define aica_enable() long_write( AICA_RESET, (long_read(AICA_RESET) & 0xFFFFFFFE) )6.10 #define aica_disable() long_write( AICA_RESET, (long_read(AICA_RESET) | 1) )
.