From cc5846c4836007b69d8ea794c753f13fcd318734 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Fr=C3=B6schle?= Date: Tue, 5 Nov 2013 20:23:41 +0000 Subject: [PATCH] modified to be able to replace memcpy() --- sources/dma.c | 71 +-------------------------------------------------- 1 file changed, 1 insertion(+), 70 deletions(-) diff --git a/sources/dma.c b/sources/dma.c index 3a78240..10d4570 100644 --- a/sources/dma.c +++ b/sources/dma.c @@ -50,36 +50,6 @@ void *dma_memcpy(void *dst, void *src, size_t n) volatile int32_t time; volatile int32_t start; volatile int32_t end; - uint8_t *d; - uint8_t *s; - - xprintf("compare memcpy() to memory to memory DMA from %p to %p (0x%x bytes ending at 0x%x)\r\n", - src, dst, n, dst + n); - d = dst; - s = src; - - start = MCF_SLT0_SCNT; - /* first check if we can do a "traditional" memcpy() to the destination and measure speed */ - - memcpy(d, s, n); - - end = MCF_SLT0_SCNT; - - time = (start - end) / (SYSCLK / 1000) / 1000; - xprintf("memcpy() took %d ms (%f Mbytes/second)\r\n", - time, n / (float) time / 1000.0); - flush_and_invalidate_caches(); - - xprintf("clear target area after memcpy():"); - start = MCF_SLT0_SCNT; - bzero(dst, n); - end = MCF_SLT0_SCNT; - time = (start - end) / (SYSCLK / 1000); - xprintf("bzero() took %d ms (%f Mbytes/second)\r\n", time, n / (float) time / 1000.0); - - xprintf(" finished, flush caches: "); - flush_and_invalidate_caches(); - xprintf("finished\r\n"); start = MCF_SLT0_SCNT; ret = MCD_startDma(1, src, 4, dst, 4, n, 4, DMA_ALWAYS, 0, MCD_SINGLE_DMA, 0); @@ -127,47 +97,8 @@ void *dma_memcpy(void *dst, void *src, size_t n) end = MCF_SLT0_SCNT; time = (start - end) / (SYSCLK / 1000) / 1000; - //xprintf("start = %d, end = %d, time = %d\r\n", start, end, time); xprintf("took %d ms (%f Mbytes/second)\r\n", time, n / (float) time / 1000.0); - /* - * verify if copy succeeded - */ - xprintf("verify if DMA copy succeeded:\r\n"); - - xprintf("flush caches first:"); - flush_and_invalidate_caches(); - xprintf(" done.\r\n"); - - s = src; - d = dst; - - start = MCF_SLT0_SCNT; - do - { - if (*d != *s) - { - xprintf("copy verification failed: %d (%p) != %d (%p) !\r\n", *d, d, *s, s); - break; - } - d++; s++; - } while (d < (uint8_t *) dst + n); - if (d >= (uint8_t *) dst + n) - { - xprintf("DMA copy verification successful!\r\n"); - end = MCF_SLT0_SCNT; - - time = (start - end) / (SYSCLK / 1000) / 1000; - xprintf("took %d ms (%f Mbytes/second)\r\n", time, n / (float) time / 1000.0); - - } - -#ifdef _NOT_USED_ - __asm__ __volatile__("move.w sr,d0\n\t" - "stop #0x2700\n\t" - "move.w d0,sr": : :); /* halt CPU until DMA finished */ -#endif /* _NOT_USED_ */ - return dst; } @@ -188,7 +119,7 @@ int dma_init(void) xprintf("DMA API version %d.%d initialized. Tasks are at %p\r\n", version / 0xff, version % 0xff, SYS_SRAM); // test - dma_memcpy((void *) 0x01000000, (void *) 0xe0000000, 0x00100000); /* copy one megabyte of flash to RAM */ + dma_memcpy((void *) 0x10000, (void *) 0xe0000000, 0x00100000); /* copy one megabyte of flash to RAM */ xprintf("DMA finished\r\n"); return 0;