From 7e5c9b895e52c76376386e54a0008c3a9e4a1698 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Tue, 25 Nov 2014 14:58:13 +0100 Subject: rtems: Move rtems_cache_aligned_malloc() Make sure also the size is cache aligned since otherwise we may have some overlap with the next allocation block. A cache invalidate on this area would be fatal. --- c/src/lib/libcpu/Makefile.am | 1 - c/src/lib/libcpu/bfin/Makefile.am | 2 +- c/src/lib/libcpu/i386/Makefile.am | 2 +- c/src/lib/libcpu/lm32/Makefile.am | 1 - c/src/lib/libcpu/m68k/Makefile.am | 1 - c/src/lib/libcpu/mips/Makefile.am | 2 +- c/src/lib/libcpu/nios2/Makefile.am | 1 - c/src/lib/libcpu/powerpc/Makefile.am | 2 +- c/src/lib/libcpu/sh/Makefile.am | 3 +- c/src/lib/libcpu/shared/src/cache_aligned_malloc.c | 43 ---------------------- c/src/lib/libcpu/sparc/Makefile.am | 2 +- c/src/lib/libcpu/sparc64/Makefile.am | 2 +- 12 files changed, 7 insertions(+), 55 deletions(-) delete mode 100644 c/src/lib/libcpu/shared/src/cache_aligned_malloc.c (limited to 'c/src/lib/libcpu') diff --git a/c/src/lib/libcpu/Makefile.am b/c/src/lib/libcpu/Makefile.am index 7d3a43e4f6..630f5256a0 100644 --- a/c/src/lib/libcpu/Makefile.am +++ b/c/src/lib/libcpu/Makefile.am @@ -2,7 +2,6 @@ include_libcpudir = $(includedir)/libcpu EXTRA_DIST = EXTRA_DIST += shared/include/cache.h -EXTRA_DIST += shared/src/cache_aligned_malloc.c EXTRA_DIST += shared/src/cache_manager.c SUBDIRS = @libcpu_cpu_subdir@ diff --git a/c/src/lib/libcpu/bfin/Makefile.am b/c/src/lib/libcpu/bfin/Makefile.am index 06e2315457..cc0b70bfbe 100644 --- a/c/src/lib/libcpu/bfin/Makefile.am +++ b/c/src/lib/libcpu/bfin/Makefile.am @@ -54,7 +54,7 @@ include_libcpu_HEADERS += include/gpioRegs.h include_libcpu_HEADERS += ../shared/include/cache.h noinst_PROGRAMS += cache.rel -cache_rel_SOURCES = cache/cache.c ../shared/src/cache_aligned_malloc.c \ +cache_rel_SOURCES = cache/cache.c \ ../shared/src/cache_manager.c cache/cache_.h cache_rel_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/cache cache_rel_LDFLAGS = $(RTEMS_RELLDFLAGS) diff --git a/c/src/lib/libcpu/i386/Makefile.am b/c/src/lib/libcpu/i386/Makefile.am index 0330ba31ef..0869435025 100644 --- a/c/src/lib/libcpu/i386/Makefile.am +++ b/c/src/lib/libcpu/i386/Makefile.am @@ -11,7 +11,7 @@ include_libcpu_HEADERS += ../shared/include/cache.h include_libcpu_HEADERS += byteorder.h noinst_PROGRAMS += cache.rel -cache_rel_SOURCES = cache.c cache_.h ../shared/src/cache_aligned_malloc.c \ +cache_rel_SOURCES = cache.c cache_.h \ ../shared/src/cache_manager.c ../shared/include/cache.h cache_rel_CPPFLAGS = $(AM_CPPFLAGS) cache_rel_LDFLAGS = $(RTEMS_RELLDFLAGS) diff --git a/c/src/lib/libcpu/lm32/Makefile.am b/c/src/lib/libcpu/lm32/Makefile.am index f51d0ebe35..e571885e1b 100644 --- a/c/src/lib/libcpu/lm32/Makefile.am +++ b/c/src/lib/libcpu/lm32/Makefile.am @@ -13,7 +13,6 @@ include_libcpudir = $(includedir)/libcpu include_libcpu_HEADERS = ../shared/include/cache.h noinst_PROGRAMS += shared/cache.rel shared_cache_rel_SOURCES = ../shared/src/no_cache.c shared/cache/cache_.h \ - ../shared/src/cache_aligned_malloc.c \ ../shared/src/cache_manager.c shared_cache_rel_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/shared/cache shared_cache_rel_LDFLAGS = $(RTEMS_RELLDFLAGS) diff --git a/c/src/lib/libcpu/m68k/Makefile.am b/c/src/lib/libcpu/m68k/Makefile.am index 19f500f1e1..45d7634b0f 100644 --- a/c/src/lib/libcpu/m68k/Makefile.am +++ b/c/src/lib/libcpu/m68k/Makefile.am @@ -13,7 +13,6 @@ include_libcpu_HEADERS = ../shared/include/cache.h noinst_PROGRAMS += shared/cache.rel shared_cache_rel_SOURCES = shared/cache/cache.c shared_cache_rel_SOURCES += shared/cache/cache_.h -shared_cache_rel_SOURCES += ../shared/src/cache_aligned_malloc.c shared_cache_rel_SOURCES += ../shared/src/cache_manager.c shared_cache_rel_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/shared/cache shared_cache_rel_LDFLAGS = $(RTEMS_RELLDFLAGS) diff --git a/c/src/lib/libcpu/mips/Makefile.am b/c/src/lib/libcpu/mips/Makefile.am index be4d2c0df7..b261afe92f 100644 --- a/c/src/lib/libcpu/mips/Makefile.am +++ b/c/src/lib/libcpu/mips/Makefile.am @@ -12,7 +12,7 @@ include_libcpudir = $(includedir)/libcpu include_libcpu_HEADERS = ../shared/include/cache.h noinst_PROGRAMS += shared/cache.rel -shared_cache_rel_SOURCES = shared/cache/cache.c ../shared/src/cache_aligned_malloc.c \ +shared_cache_rel_SOURCES = shared/cache/cache.c \ ../shared/src/cache_manager.c shared/cache/cache_.h shared_cache_rel_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/shared/cache shared_cache_rel_LDFLAGS = $(RTEMS_RELLDFLAGS) diff --git a/c/src/lib/libcpu/nios2/Makefile.am b/c/src/lib/libcpu/nios2/Makefile.am index 233b5a15b3..e249998acf 100644 --- a/c/src/lib/libcpu/nios2/Makefile.am +++ b/c/src/lib/libcpu/nios2/Makefile.am @@ -13,7 +13,6 @@ include_libcpudir = $(includedir)/libcpu include_libcpu_HEADERS = ../shared/include/cache.h noinst_PROGRAMS += shared/cache.rel shared_cache_rel_SOURCES = ../shared/src/no_cache.c shared/cache/cache_.h \ - ../shared/src/cache_aligned_malloc.c \ ../shared/src/cache_manager.c shared_cache_rel_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/shared/cache shared_cache_rel_LDFLAGS = $(RTEMS_RELLDFLAGS) diff --git a/c/src/lib/libcpu/powerpc/Makefile.am b/c/src/lib/libcpu/powerpc/Makefile.am index 5b83288c6e..f7d7e64e5c 100644 --- a/c/src/lib/libcpu/powerpc/Makefile.am +++ b/c/src/lib/libcpu/powerpc/Makefile.am @@ -72,7 +72,7 @@ include_libcpu_HEADERS += shared/include/cpuIdent.h # shared/cache noinst_PROGRAMS += shared/cache.rel shared_cache_rel_SOURCES = shared/src/cache_.h \ - ../shared/src/cache_aligned_malloc.c ../shared/src/cache_manager.c \ + ../shared/src/cache_manager.c \ ../shared/include/cache.h shared_cache_rel_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/shared/src shared_cache_rel_LDFLAGS = $(RTEMS_RELLDFLAGS) diff --git a/c/src/lib/libcpu/sh/Makefile.am b/c/src/lib/libcpu/sh/Makefile.am index 532597fdbf..5c0a6ed960 100644 --- a/c/src/lib/libcpu/sh/Makefile.am +++ b/c/src/lib/libcpu/sh/Makefile.am @@ -8,8 +8,7 @@ include_libcpudir = $(includedir)/libcpu include_libcpu_HEADERS = ../shared/include/cache.h noinst_PROGRAMS += cache.rel -cache_rel_SOURCES = ../shared/src/cache_aligned_malloc.c -cache_rel_SOURCES += ../shared/src/cache_manager.c +cache_rel_SOURCES = ../shared/src/cache_manager.c cache_rel_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/cache cache_rel_LDFLAGS = $(RTEMS_RELLDFLAGS) diff --git a/c/src/lib/libcpu/shared/src/cache_aligned_malloc.c b/c/src/lib/libcpu/shared/src/cache_aligned_malloc.c deleted file mode 100644 index 17fc46814b..0000000000 --- a/c/src/lib/libcpu/shared/src/cache_aligned_malloc.c +++ /dev/null @@ -1,43 +0,0 @@ -/* - * RTEMS Cache Aligned Malloc - * - * - * COPYRIGHT (c) 1989-1999. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#include - -#include -#include -#include - -/* - * rtems_cache_aligned_malloc - * - * DESCRIPTION: - * - * This function is used to allocate storage that spans an - * integral number of cache blocks. - */ - -void *rtems_cache_aligned_malloc ( - size_t nbytes -) -{ - /* - * Arrange to have the user storage start on the first cache - * block beyond the header. - */ -#if defined(CPU_DATA_CACHE_ALIGNMENT) - return (void *) ((((unsigned long) - malloc( nbytes + CPU_DATA_CACHE_ALIGNMENT - 1 )) - + CPU_DATA_CACHE_ALIGNMENT - 1 ) &(~(CPU_DATA_CACHE_ALIGNMENT - 1)) ); -#else - return malloc( nbytes ); -#endif -} diff --git a/c/src/lib/libcpu/sparc/Makefile.am b/c/src/lib/libcpu/sparc/Makefile.am index 9f8bacbe8a..ceed3bcc65 100644 --- a/c/src/lib/libcpu/sparc/Makefile.am +++ b/c/src/lib/libcpu/sparc/Makefile.am @@ -11,7 +11,7 @@ include_libcpu_HEADERS += include/libcpu/access.h noinst_PROGRAMS += cache.rel cache_rel_SOURCES = cache/cache.c cache/cache_.h \ - ../shared/src/cache_aligned_malloc.c ../shared/src/cache_manager.c + ../shared/src/cache_manager.c cache_rel_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/cache cache_rel_LDFLAGS = $(RTEMS_RELLDFLAGS) diff --git a/c/src/lib/libcpu/sparc64/Makefile.am b/c/src/lib/libcpu/sparc64/Makefile.am index a95672e8d8..b0a1f84bcb 100644 --- a/c/src/lib/libcpu/sparc64/Makefile.am +++ b/c/src/lib/libcpu/sparc64/Makefile.am @@ -27,7 +27,7 @@ shared_sparc64_syscall_rel_LDFLAGS = $(RTEMS_RELLDFLAGS) noinst_PROGRAMS += shared/cache.rel shared_cache_rel_SOURCES = shared/cache/cache.c shared/cache/cache_.h \ - ../shared/src/cache_aligned_malloc.c ../shared/src/cache_manager.c + ../shared/src/cache_manager.c shared_cache_rel_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/shared/cache shared_cache_rel_LDFLAGS = $(RTEMS_RELLDFLAGS) endif -- cgit v1.2.3