summaryrefslogtreecommitdiffstats
path: root/testsuites/sptests/spcache01
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2014-11-25 14:58:13 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2014-11-25 16:08:16 +0100
commit7e5c9b895e52c76376386e54a0008c3a9e4a1698 (patch)
treebb8f7db25258fc1438c58a60aa950d782d0d77ab /testsuites/sptests/spcache01
parentsptest/spcache01: New test cases (diff)
downloadrtems-7e5c9b895e52c76376386e54a0008c3a9e4a1698.tar.bz2
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.
Diffstat (limited to 'testsuites/sptests/spcache01')
-rw-r--r--testsuites/sptests/spcache01/init.c31
-rw-r--r--testsuites/sptests/spcache01/spcache01.doc1
-rw-r--r--testsuites/sptests/spcache01/spcache01.scn1
3 files changed, 33 insertions, 0 deletions
diff --git a/testsuites/sptests/spcache01/init.c b/testsuites/sptests/spcache01/init.c
index e303436224..95777e1a28 100644
--- a/testsuites/sptests/spcache01/init.c
+++ b/testsuites/sptests/spcache01/init.c
@@ -17,6 +17,7 @@
#endif
#include <stdio.h>
+#include <stdlib.h>
#include <inttypes.h>
#include <rtems.h>
@@ -379,12 +380,42 @@ static void test_timing(void)
rtems_interrupt_lock_destroy(&lock);
}
+static void test_cache_aligned_alloc(void)
+{
+ void *p0;
+ void *p1;
+ size_t cls;
+
+ printf("test rtems_cache_aligned_malloc()\n");
+
+ p0 = rtems_cache_aligned_malloc(1);
+ p1 = rtems_cache_aligned_malloc(1);
+
+ rtems_test_assert(p0 != NULL);
+ rtems_test_assert(p1 != NULL);
+
+ cls = rtems_cache_get_data_line_size();
+ if (cls > 0) {
+ size_t m = cls - 1;
+ uintptr_t a0 = (uintptr_t) p0;
+ uintptr_t a1 = (uintptr_t) p1;
+
+ rtems_test_assert(a1 - a0 > cls);
+ rtems_test_assert((a0 & m) == 0);
+ rtems_test_assert((a1 & m) == 0);
+ }
+
+ free(p0);
+ free(p1);
+}
+
static void Init(rtems_task_argument arg)
{
TEST_BEGIN();
test_data_flush_and_invalidate();
test_timing();
+ test_cache_aligned_alloc();
TEST_END();
diff --git a/testsuites/sptests/spcache01/spcache01.doc b/testsuites/sptests/spcache01/spcache01.doc
index bbc8f253c0..04e32a1e5d 100644
--- a/testsuites/sptests/spcache01/spcache01.doc
+++ b/testsuites/sptests/spcache01/spcache01.doc
@@ -13,6 +13,7 @@ directives:
- rtems_cache_invalidate_entire_instruction()
- rtems_cache_invalidate_multiple_data_lines()
- rtems_cache_invalidate_multiple_instruction_lines()
+ - rtems_cache_aligned_malloc()
concepts:
diff --git a/testsuites/sptests/spcache01/spcache01.scn b/testsuites/sptests/spcache01/spcache01.scn
index 80139451ef..4e7d53a9f6 100644
--- a/testsuites/sptests/spcache01/spcache01.scn
+++ b/testsuites/sptests/spcache01/spcache01.scn
@@ -42,4 +42,5 @@ invalidate multiple instruction
duration with normal cache 680 ns
duration with warm cache 640 ns
duration with invalidated cache 2600 ns
+test rtems_cache_aligned_malloc()
*** END OF TEST SPCACHE 1 ***