From 0f6a88260b6d41a095d11655e8957a8349bbaa1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Fr=C3=B6schle?= Date: Sat, 24 Aug 2013 07:46:15 +0000 Subject: [PATCH] fixed a few MDMA-related quirks. DMA still doesn't work when running from RAM --- Makefile | 2 +- bas.lk.in | 5 +++-- mcdapi/MCD_dma.h | 2 +- mcdapi/MCD_tasksInit.c | 1 + sources/dma.c | 19 ++++++++++--------- sources/startcf.S | 2 +- 6 files changed, 17 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index cc4d169..21dcc69 100644 --- a/Makefile +++ b/Makefile @@ -35,7 +35,7 @@ CFLAGS=-mcpu=5474\ -g\ -Wno-multichar\ -Winline\ - -Os \ + -O \ -fomit-frame-pointer\ -ffreestanding\ -fleading-underscore\ diff --git a/bas.lk.in b/bas.lk.in index 5192220..e733401 100644 --- a/bas.lk.in +++ b/bas.lk.in @@ -154,6 +154,8 @@ SECTIONS __RAMBAR0 = 0xFF100000; __RAMBAR0_SIZE = 0x00001000; + __SUP_SP = __RAMBAR0 + __RAMBAR0_SIZE - 4; + /* system variables */ /* RAMBAR0 0 to 0x7FF -> exception vectors */ @@ -175,8 +177,7 @@ SECTIONS _video_sbt = __RAMBAR0 + 0x83C; _rt_mbar = __RAMBAR0 + 0x844; /* (c)0f */ - /* 4KB on-chip Core SRAM1: -> supervisor stack */ + /* 4KB on-chip Core SRAM1 */ __RAMBAR1 = 0xFF101000; __RAMBAR1_SIZE = 0x00001000; - __SUP_SP = __RAMBAR1 + __RAMBAR1_SIZE - 4; } diff --git a/mcdapi/MCD_dma.h b/mcdapi/MCD_dma.h index 3df2e43..1506fff 100755 --- a/mcdapi/MCD_dma.h +++ b/mcdapi/MCD_dma.h @@ -11,13 +11,13 @@ * Turn Execution Unit tasks ON (#define) or OFF (#undef) */ #undef MCD_INCLUDE_EU +//#define MCD_INCLUDE_EU /* * Number of DMA channels */ #define NCHANNELS 16 -#define MCD_INCLUDE_EU /* * Total number of variants */ diff --git a/mcdapi/MCD_tasksInit.c b/mcdapi/MCD_tasksInit.c index fd651b2..58ab8ce 100755 --- a/mcdapi/MCD_tasksInit.c +++ b/mcdapi/MCD_tasksInit.c @@ -11,6 +11,7 @@ */ #include "MCD_dma.h" +#include "MCD_tasksInit.h" extern dmaRegs *MCD_dmaBar; diff --git a/sources/dma.c b/sources/dma.c index 2204af6..8b70e7a 100644 --- a/sources/dma.c +++ b/sources/dma.c @@ -42,9 +42,11 @@ void *dma_memcpy(void *dst, void *src, size_t n) memcpy(d, s, n); +//#endif /* _NOT_USED_ */ + end = MCF_SLT0_SCNT; - time = (start - end) / 132; + time = (start - end) / 132 / 1000; xprintf("memcpy() took %d ms (%d.%d Mbytes/second)\r\n", time, n / time / 1000, n / time % 1000); flush_and_invalidate_caches(); @@ -62,15 +64,15 @@ void *dma_memcpy(void *dst, void *src, size_t n) xprintf("finished\r\n"); start = MCF_SLT0_SCNT; - ret = MCD_startDma(0, src, 4, dst, 4, n, 4, DMA_ALWAYS, 7, MCD_SINGLE_DMA|MCD_TT_FLAGS_CW|MCD_TT_FLAGS_RL|MCD_TT_FLAGS_SP, 0); + ret = MCD_startDma(1, src, 4, dst, 4, n, 4, DMA_ALWAYS, 0, MCD_SINGLE_DMA, 0); if (ret == MCD_OK) { - xprintf("DMA on channel 0 successfully started\r\n"); + xprintf("DMA on channel 1 successfully started\r\n"); } do { - ret = MCD_dmaStatus(0); + ret = MCD_dmaStatus(1); switch (ret) { case MCD_NO_DMA: @@ -102,10 +104,9 @@ void *dma_memcpy(void *dst, void *src, size_t n) break; } } while (ret != MCD_DONE); - xprintf("\r\n"); end = MCF_SLT0_SCNT; - time = (start - end) / 132; + time = (start - end) / 132 / 1000; xprintf("start = %d, end = %d, time = %d\r\n", start, end, time); xprintf("took %d ms (%d.%d Mbytes/second)\r\n", time, n / time / 1000, n / time % 1000); @@ -136,14 +137,14 @@ void *dma_memcpy(void *dst, void *src, size_t n) xprintf("DMA copy verification successful!\r\n"); end = MCF_SLT0_SCNT; - time = (start - end) / 132; + time = (start - end) / 132 / 1000; xprintf("took %d ms (%d.%d Mbytes/second)\r\n", time, n / time / 1000, n / time % 1000); } #ifdef _NOT_USED_ __asm__ __volatile__("move.w sr,d0\n\t" - "stop #0x270\n\t" + "stop #0x2700\n\t" "move.w d0,sr": : :); /* halt CPU until DMA finished */ #endif /* _NOT_USED_ */ @@ -157,7 +158,7 @@ int dma_init(void) char *long_version; xprintf("MCD DMA API initialization: "); - res = MCD_initDma((dmaRegs *) &MCF_DMA_TASKBAR, SYS_SRAM, MCD_RELOC_TASKS | MCD_COMM_PREFETCH_EN); + res = MCD_initDma((dmaRegs *) &_MBAR[0x8000], SYS_SRAM, MCD_RELOC_TASKS | MCD_COMM_PREFETCH_EN); if (res != MCD_OK) { xprintf("DMA API initialization failed (0x%x)\r\n", res); diff --git a/sources/startcf.S b/sources/startcf.S index ea238d7..ca1dc26 100644 --- a/sources/startcf.S +++ b/sources/startcf.S @@ -44,7 +44,7 @@ _rom_entry: move.l #__RAMBAR1 + 0x1,d0 movec d0,RAMBAR1 - /* set stack pointer to end of SRAM1 */ + /* set stack pointer to end of SRAM */ lea __SUP_SP,a7 move.l #0,(sp)