diff options
author | Aubrey.Li <aubrey.adi@gmail.com> | 2007-03-09 13:38:44 +0800 |
---|---|---|
committer | Aubrey.Li <aubrey.adi@gmail.com> | 2007-03-09 13:38:44 +0800 |
commit | 3f0606ad0b5639f7f22848fe5b4574e754d0470f (patch) | |
tree | 3cb4fd316134b6a176607ad61739720aeb971a5a /lib_blackfin/bf533_string.c | |
parent | eb92f613556800f7483666db09d9a237ad911d4a (diff) | |
download | u-boot-imx-3f0606ad0b5639f7f22848fe5b4574e754d0470f.zip u-boot-imx-3f0606ad0b5639f7f22848fe5b4574e754d0470f.tar.gz u-boot-imx-3f0606ad0b5639f7f22848fe5b4574e754d0470f.tar.bz2 |
[Blackfin]PATCH-1/2]: Remove obsolete blackfin port and add bf533 platform support
Diffstat (limited to 'lib_blackfin/bf533_string.c')
-rw-r--r-- | lib_blackfin/bf533_string.c | 183 |
1 files changed, 94 insertions, 89 deletions
diff --git a/lib_blackfin/bf533_string.c b/lib_blackfin/bf533_string.c index c8b1a3a..1d0aeb6 100644 --- a/lib_blackfin/bf533_string.c +++ b/lib_blackfin/bf533_string.c @@ -28,9 +28,14 @@ #include <common.h> #include <asm/setup.h> #include <asm/page.h> -#include <asm/cpu/defBF533.h> +#include <config.h> +#include <asm/blackfin.h> -void *dma_memcpy(void *,const void *,size_t); +extern void blackfin_icache_flush_range(const void *, const void *); +extern void blackfin_dcache_flush_range(const void *, const void *); +extern void *memcpy_ASM(void *dest, const void *src, size_t count); + +void *dma_memcpy(void *, const void *, size_t); char *strcpy(char *dest, const char *src) { @@ -38,11 +43,11 @@ char *strcpy(char *dest, const char *src) char temp = 0; __asm__ __volatile__ - ("1:\t%2 = B [%1++] (Z);\n\t" - "B [%0++] = %2;\n\t" - "CC = %2;\n\t" - "if cc jump 1b (bp);\n":"=a"(dest), "=a"(src), "=d"(temp) - :"0"(dest), "1"(src), "2"(temp):"memory"); + ("1:\t%2 = B [%1++] (Z);\n\t" + "B [%0++] = %2;\n\t" + "CC = %2;\n\t" + "if cc jump 1b (bp);\n":"=a"(dest), "=a"(src), "=d"(temp) + :"0"(dest), "1"(src), "2"(temp):"memory"); return xdest; } @@ -56,16 +61,16 @@ char *strncpy(char *dest, const char *src, size_t n) return xdest; __asm__ __volatile__ - ("1:\t%3 = B [%1++] (Z);\n\t" - "B [%0++] = %3;\n\t" - "CC = %3;\n\t" - "if ! cc jump 2f;\n\t" - "%2 += -1;\n\t" - "CC = %2 == 0;\n\t" - "if ! cc jump 1b (bp);\n" - "2:\n":"=a"(dest), "=a"(src), "=da"(n), "=d"(temp) - :"0"(dest), "1"(src), "2"(n), "3"(temp) - :"memory"); + ("1:\t%3 = B [%1++] (Z);\n\t" + "B [%0++] = %3;\n\t" + "CC = %3;\n\t" + "if ! cc jump 2f;\n\t" + "%2 += -1;\n\t" + "CC = %2 == 0;\n\t" + "if ! cc jump 1b (bp);\n" + "2:\n":"=a"(dest), "=a"(src), "=da"(n), "=d"(temp) + :"0"(dest), "1"(src), "2"(n), "3"(temp) + :"memory"); return xdest; } @@ -74,18 +79,16 @@ int strcmp(const char *cs, const char *ct) { char __res1, __res2; - __asm__ - ("1:\t%2 = B[%0++] (Z);\n\t" /* get *cs */ - "%3 = B[%1++] (Z);\n\t" /* get *ct */ - "CC = %2 == %3;\n\t" /* compare a byte */ - "if ! cc jump 2f;\n\t" /* not equal, break out */ - "CC = %2;\n\t" /* at end of cs? */ + __asm__("1:\t%2 = B[%0++] (Z);\n\t" /* get *cs */ + "%3 = B[%1++] (Z);\n\t" /* get *ct */ + "CC = %2 == %3;\n\t" /* compare a byte */ + "if ! cc jump 2f;\n\t" /* not equal, break out */ + "CC = %2;\n\t" /* at end of cs? */ "if cc jump 1b (bp);\n\t" /* no, keep going */ - "jump.s 3f;\n" /* strings are equal */ - "2:\t%2 = %2 - %3;\n" /* *cs - *ct */ - "3:\n": "=a"(cs), "=a"(ct), "=d"(__res1), - "=d"(__res2) - : "0"(cs), "1"(ct)); + "jump.s 3f;\n" /* strings are equal */ + "2:\t%2 = %2 - %3;\n" /* *cs - *ct */ + "3:\n": "=a"(cs), "=a"(ct), "=d"(__res1), "=d"(__res2) + : "0"(cs), "1"(ct)); return __res1; } @@ -97,20 +100,19 @@ int strncmp(const char *cs, const char *ct, size_t count) if (!count) return 0; - __asm__ - ("1:\t%3 = B[%0++] (Z);\n\t" /* get *cs */ - "%4 = B[%1++] (Z);\n\t" /* get *ct */ - "CC = %3 == %4;\n\t" /* compare a byte */ - "if ! cc jump 3f;\n\t" /* not equal, break out */ - "CC = %3;\n\t" /* at end of cs? */ - "if ! cc jump 4f;\n\t" /* yes, all done */ - "%2 += -1;\n\t" /* no, adjust count */ + __asm__("1:\t%3 = B[%0++] (Z);\n\t" /* get *cs */ + "%4 = B[%1++] (Z);\n\t" /* get *ct */ + "CC = %3 == %4;\n\t" /* compare a byte */ + "if ! cc jump 3f;\n\t" /* not equal, break out */ + "CC = %3;\n\t" /* at end of cs? */ + "if ! cc jump 4f;\n\t" /* yes, all done */ + "%2 += -1;\n\t" /* no, adjust count */ "CC = %2 == 0;\n\t" "if ! cc jump 1b;\n" /* more to do, keep going */ - "2:\t%3 = 0;\n\t" /* strings are equal */ + "2:\t%3 = 0;\n\t" /* strings are equal */ "jump.s 4f;\n" "3:\t%3 = %3 - %4;\n" /* *cs - *ct */ - "4:": "=a"(cs), "=a"(ct), "=da"(count), "=d"(__res1), + "4:": "=a"(cs), "=a"(ct), "=da"(count), "=d"(__res1), "=d"(__res2) - : "0"(cs), "1"(ct), "2"(count)); + : "0"(cs), "1"(ct), "2"(count)); return __res1; } @@ -124,62 +126,65 @@ int strncmp(const char *cs, const char *ct, size_t count) * You should not use this function to access IO space, use memcpy_toio() * or memcpy_fromio() instead. */ -void * memcpy(void * dest,const void *src,size_t count) +void *memcpy(void *dest, const void *src, size_t count) { - char *tmp = (char *) dest, *s = (char *) src; - -/* Turn off the cache, if destination in the L1 memory */ - if ( (tmp >= (char *)L1_ISRAM) && (tmp < (char *)L1_ISRAM_END) - || (tmp >= (char *)DATA_BANKA_SRAM) && (tmp < DATA_BANKA_SRAM_END) - || (tmp >= (char *)DATA_BANKB_SRAM) && (tmp < DATA_BANKB_SRAM_END) ){ - if(icache_status()){ - blackfin_icache_flush_range(src, src+count); - icache_disable(); - } - if(dcache_status()){ - blackfin_dcache_flush_range(src, src+count); - dcache_disable(); - } - dma_memcpy(dest,src,count); - }else{ - while(count--) - *tmp++ = *s++; + char *tmp = (char *)dest, *s = (char *)src; + + /* L1_ISRAM can only be accessed via dma */ + if ((tmp >= (char *)L1_ISRAM) && (tmp < (char *)L1_ISRAM_END)) { + /* L1 is the destination */ + dma_memcpy(dest, src, count); + + if (icache_status()) { + blackfin_icache_flush_range(src, src + count); + } + } else if ((s >= (char *)L1_ISRAM) && (s < (char *)L1_ISRAM_END)) { + /* L1 is the source */ + dma_memcpy(dest, src, count); + + if (icache_status()) { + blackfin_icache_flush_range(dest, dest + count); + } + if (dcache_status()) { + blackfin_dcache_flush_range(dest, dest + count); + } + } else { + memcpy_ASM(dest, src, count); } return dest; } -void *dma_memcpy(void * dest,const void *src,size_t count) +void *dma_memcpy(void *dest, const void *src, size_t count) { - - *pMDMA_D0_IRQ_STATUS = DMA_DONE | DMA_ERR; - - /* Copy sram functions from sdram to sram */ - /* Setup destination start address */ - *pMDMA_D0_START_ADDR = (volatile void **)dest; - /* Setup destination xcount */ - *pMDMA_D0_X_COUNT = count ; - /* Setup destination xmodify */ - *pMDMA_D0_X_MODIFY = 1; - - /* Setup Source start address */ - *pMDMA_S0_START_ADDR = (volatile void **)src; - /* Setup Source xcount */ - *pMDMA_S0_X_COUNT = count; - /* Setup Source xmodify */ - *pMDMA_S0_X_MODIFY = 1; - - /* Enable source DMA */ - *pMDMA_S0_CONFIG = (DMAEN); - asm("ssync;"); - - *pMDMA_D0_CONFIG = ( WNR | DMAEN); - - while(*pMDMA_D0_IRQ_STATUS & DMA_RUN){ - *pMDMA_D0_IRQ_STATUS |= (DMA_DONE | DMA_ERR); - } + *pMDMA_D0_IRQ_STATUS = DMA_DONE | DMA_ERR; + + /* Copy sram functions from sdram to sram */ + /* Setup destination start address */ + *pMDMA_D0_START_ADDR = (volatile void **)dest; + /* Setup destination xcount */ + *pMDMA_D0_X_COUNT = count; + /* Setup destination xmodify */ + *pMDMA_D0_X_MODIFY = 1; + + /* Setup Source start address */ + *pMDMA_S0_START_ADDR = (volatile void **)src; + /* Setup Source xcount */ + *pMDMA_S0_X_COUNT = count; + /* Setup Source xmodify */ + *pMDMA_S0_X_MODIFY = 1; + + /* Enable source DMA */ + *pMDMA_S0_CONFIG = (DMAEN); + __builtin_bfin_ssync(); + + *pMDMA_D0_CONFIG = (WNR | DMAEN); + + while (*pMDMA_D0_IRQ_STATUS & DMA_RUN) { *pMDMA_D0_IRQ_STATUS |= (DMA_DONE | DMA_ERR); + } + *pMDMA_D0_IRQ_STATUS |= (DMA_DONE | DMA_ERR); - dest += count; - src += count; - return dest; + dest += count; + src += count; + return dest; } |