diff options
-rw-r--r-- | lib_blackfin/bf533_string.c | 83 | ||||
-rw-r--r-- | lib_blackfin/cache.c | 8 | ||||
-rw-r--r-- | lib_blackfin/cache.h | 35 |
3 files changed, 77 insertions, 49 deletions
diff --git a/lib_blackfin/bf533_string.c b/lib_blackfin/bf533_string.c index 4bc4e3c..1553f1b 100644 --- a/lib_blackfin/bf533_string.c +++ b/lib_blackfin/bf533_string.c @@ -30,12 +30,7 @@ #include <config.h> #include <asm/blackfin.h> #include <asm/io.h> - -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); +#include "cache.h" char *strcpy(char *dest, const char *src) { @@ -117,44 +112,7 @@ int strncmp(const char *cs, const char *ct, size_t count) return __res1; } -/* - * memcpy - Copy one area of memory to another - * @dest: Where to copy to - * @src: Where to copy from - * @count: The size of the area. - * - * 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) -{ - 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) +static void *dma_memcpy(void *dest, const void *src, size_t count) { *pMDMA_D0_IRQ_STATUS = DMA_DONE | DMA_ERR; @@ -188,3 +146,40 @@ void *dma_memcpy(void *dest, const void *src, size_t count) src += count; return dest; } + +/* + * memcpy - Copy one area of memory to another + * @dest: Where to copy to + * @src: Where to copy from + * @count: The size of the area. + * + * You should not use this function to access IO space, use memcpy_toio() + * or memcpy_fromio() instead. + */ +extern void *memcpy_ASM(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; + + if (dcache_status()) { + blackfin_dcache_flush_range(src, src+count); + } + /* 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); + } 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_invalidate_range(dest, dest+count); + } + } else { + memcpy_ASM(dest,src,count); + } + return dest; +} diff --git a/lib_blackfin/cache.c b/lib_blackfin/cache.c index 6c3c17b..9d71bcb 100644 --- a/lib_blackfin/cache.c +++ b/lib_blackfin/cache.c @@ -29,9 +29,7 @@ #include <config.h> #include <common.h> #include <asm/blackfin.h> - -extern void blackfin_icache_flush_range(unsigned long, unsigned long); -extern void blackfin_dcache_flush_range(unsigned long, unsigned long); +#include "cache.h" void flush_cache(unsigned long dummy1, unsigned long dummy2) { @@ -43,9 +41,9 @@ void flush_cache(unsigned long dummy1, unsigned long dummy2) return; if (icache_status()) - blackfin_icache_flush_range(dummy1, dummy1 + dummy2); + blackfin_icache_flush_range((void*)dummy1, (void*)(dummy1 + dummy2)); if (dcache_status()) - blackfin_dcache_flush_range(dummy1, dummy1 + dummy2); + blackfin_dcache_flush_range((void*)dummy1, (void*)(dummy1 + dummy2)); return; } diff --git a/lib_blackfin/cache.h b/lib_blackfin/cache.h new file mode 100644 index 0000000..3ea6809 --- /dev/null +++ b/lib_blackfin/cache.h @@ -0,0 +1,35 @@ +/* + * U-boot - prototypes for cache handling functions. + * + * Copyright (c) 2005-2007 Analog Devices Inc. + * + * (C) Copyright 2000-2004 + * Wolfgang Denk, DENX Software Engineering, wd@denx.de. + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see the file COPYING, or write + * to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef _LIB_BLACKFIN_CACHE_H_ +#define _LIB_BLACKFIN_CACHE_H_ + +extern void blackfin_icache_flush_range(const void *, const void *); +extern void blackfin_dcache_flush_range(const void *, const void *); +extern void blackfin_dcache_invalidate_range(const void *, const void *); + +#endif |