From cfc4231d8fe1056fa501508a929c8ccaa1dd11be Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Mon, 27 Aug 2018 10:36:35 +0200 Subject: score: Add flexible per-CPU data Update #3507. --- testsuites/sptests/Makefile.am | 9 + testsuites/sptests/configure.ac | 1 + testsuites/sptests/sppercpudata01/init.c | 290 +++++++++++++++++++++ testsuites/sptests/sppercpudata01/item.c | 21 ++ .../sptests/sppercpudata01/sppercpudata01.doc | 13 + testsuites/sptests/sppercpudata01/sppercpudata01.h | 30 +++ .../sptests/sppercpudata01/sppercpudata01.scn | 7 + 7 files changed, 371 insertions(+) create mode 100644 testsuites/sptests/sppercpudata01/init.c create mode 100644 testsuites/sptests/sppercpudata01/item.c create mode 100644 testsuites/sptests/sppercpudata01/sppercpudata01.doc create mode 100644 testsuites/sptests/sppercpudata01/sppercpudata01.h create mode 100644 testsuites/sptests/sppercpudata01/sppercpudata01.scn (limited to 'testsuites') diff --git a/testsuites/sptests/Makefile.am b/testsuites/sptests/Makefile.am index 6d28acdfbb..d9a6bf235e 100644 --- a/testsuites/sptests/Makefile.am +++ b/testsuites/sptests/Makefile.am @@ -1594,6 +1594,15 @@ sppartition_err01_CPPFLAGS = $(AM_CPPFLAGS) \ $(TEST_FLAGS_sppartition_err01) $(support_includes) endif +if TEST_sppercpudata01 +sp_tests += sppercpudata01 +sp_screens += sppercpudata01/sppercpudata01.scn +sp_docs += sppercpudata01/sppercpudata01.doc +sppercpudata01_SOURCES = sppercpudata01/init.c sppercpudata01/item.c +sppercpudata01_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_FLAGS_sppercpudata01) \ + $(support_includes) +endif + if TEST_spport_err01 sp_tests += spport_err01 sp_screens += spport_err01/spport_err01.scn diff --git a/testsuites/sptests/configure.ac b/testsuites/sptests/configure.ac index 0c9788ae1b..6418ad0bc8 100644 --- a/testsuites/sptests/configure.ac +++ b/testsuites/sptests/configure.ac @@ -205,6 +205,7 @@ RTEMS_TEST_CHECK([spnsext01]) RTEMS_TEST_CHECK([spobjgetnext]) RTEMS_TEST_CHECK([sppagesize]) RTEMS_TEST_CHECK([sppartition_err01]) +RTEMS_TEST_CHECK([sppercpudata01]) RTEMS_TEST_CHECK([spport_err01]) RTEMS_TEST_CHECK([spprintk]) RTEMS_TEST_CHECK([spprivenv01]) diff --git a/testsuites/sptests/sppercpudata01/init.c b/testsuites/sptests/sppercpudata01/init.c new file mode 100644 index 0000000000..4c20ea7e2b --- /dev/null +++ b/testsuites/sptests/sppercpudata01/init.c @@ -0,0 +1,290 @@ +/* + * Copyright (c) 2018 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * + * + * 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include + +#include + +#include "sppercpudata01.h" + +const char rtems_test_name[] = "SPPERCPUDATA 1"; + +static PER_CPU_DATA_ITEM(unsigned char, c) = 1; + +static PER_CPU_DATA_ITEM(unsigned char, cz); + +static PER_CPU_DATA_ITEM(unsigned short, s) = 2; + +static PER_CPU_DATA_ITEM(unsigned short, sz); + +static PER_CPU_DATA_ITEM(unsigned int, i) = 3; + +static PER_CPU_DATA_ITEM(unsigned int, iz); + +static PER_CPU_DATA_ITEM(unsigned long, l) = 4; + +static PER_CPU_DATA_ITEM(unsigned long, lz); + +static PER_CPU_DATA_ITEM(unsigned int, a[3]) = { 5, 6, 7 }; + +static PER_CPU_DATA_ITEM(unsigned int, az[3]); + +typedef struct t { + unsigned int a; + unsigned int b; + unsigned int c; +} t; + +static PER_CPU_DATA_ITEM(t, t) = { .a = 8, .b = 9, .c = 10 }; + +static void set_affinity(uint32_t cpu_index) +{ + rtems_status_code sc; + cpu_set_t set; + + CPU_ZERO(&set); + CPU_SET((int) cpu_index, &set); + sc = rtems_task_set_affinity(RTEMS_SELF, sizeof(set), &set); + rtems_test_assert(sc == RTEMS_SUCCESSFUL); +} + +static void test_initial_values(void) +{ + uint32_t cpu_index; + + for (cpu_index = 0; cpu_index < rtems_get_processor_count(); ++cpu_index) { + Per_CPU_Control *cpu; + unsigned char *c; + unsigned short *s; + unsigned int *i; + unsigned long *l; + t *pt; + + set_affinity(cpu_index); + cpu = _Per_CPU_Get_by_index(cpu_index); + + c = PER_CPU_DATA_GET(cpu, unsigned char, c); + rtems_test_assert(*c == 1); + + c = PER_CPU_DATA_GET(cpu, unsigned char, cz); + rtems_test_assert(*c == 0); + + s = PER_CPU_DATA_GET(cpu, unsigned short, s); + rtems_test_assert(*s == 2); + + s = PER_CPU_DATA_GET(cpu, unsigned short, sz); + rtems_test_assert(*s == 0); + + i = PER_CPU_DATA_GET(cpu, unsigned int, i); + rtems_test_assert(*i == 3); + + i = PER_CPU_DATA_GET(cpu, unsigned int, iz); + rtems_test_assert(*i == 0); + + l = PER_CPU_DATA_GET(cpu, unsigned long, l); + rtems_test_assert(*l == 4); + + l = PER_CPU_DATA_GET(cpu, unsigned long, lz); + rtems_test_assert(*l == 0); + + i = PER_CPU_DATA_GET(cpu, unsigned int, a[0]); + rtems_test_assert(i[0] == 5); + rtems_test_assert(i[1] == 6); + rtems_test_assert(i[2] == 7); + + i = PER_CPU_DATA_GET(cpu, unsigned int, az[0]); + rtems_test_assert(i[0] == 0); + rtems_test_assert(i[1] == 0); + rtems_test_assert(i[2] == 0); + + pt = PER_CPU_DATA_GET(cpu, t, t); + rtems_test_assert(pt->a == 8); + rtems_test_assert(pt->b == 9); + rtems_test_assert(pt->c == 10); + + pt = PER_CPU_DATA_GET(cpu, struct t, t); + rtems_test_assert(pt->a == 8); + rtems_test_assert(pt->b == 9); + rtems_test_assert(pt->c == 10); + + i = PER_CPU_DATA_GET(cpu, unsigned int, g); + rtems_test_assert(*i == 11); + } +} + +static void set_unique_values(unsigned int v) +{ + uint32_t cpu_index; + + for (cpu_index = 0; cpu_index < rtems_get_processor_count(); ++cpu_index) { + Per_CPU_Control *cpu; + unsigned char *c; + unsigned short *s; + unsigned int *i; + unsigned long *l; + t *pt; + + set_affinity(cpu_index); + cpu = _Per_CPU_Get_by_index(cpu_index); + + c = PER_CPU_DATA_GET(cpu, unsigned char, c); + *c = (unsigned char) ++v; + + c = PER_CPU_DATA_GET(cpu, unsigned char, cz); + *c = (unsigned char) ++v; + + s = PER_CPU_DATA_GET(cpu, unsigned short, s); + *s = (unsigned short) ++v; + + s = PER_CPU_DATA_GET(cpu, unsigned short, sz); + *s = (unsigned short) ++v; + + i = PER_CPU_DATA_GET(cpu, unsigned int, i); + *i = ++v; + + i = PER_CPU_DATA_GET(cpu, unsigned int, iz); + *i = ++v; + + l = PER_CPU_DATA_GET(cpu, unsigned long, l); + *l = ++v; + + l = PER_CPU_DATA_GET(cpu, unsigned long, lz); + *l = ++v; + + i = PER_CPU_DATA_GET(cpu, unsigned int, a[0]); + i[0] = ++v; + i[1] = ++v; + i[2] = ++v; + + i = PER_CPU_DATA_GET(cpu, unsigned int, az[0]); + i[0] = ++v; + i[1] = ++v; + i[2] = ++v; + + pt = PER_CPU_DATA_GET(cpu, t, t); + pt->a = ++v; + pt->b = ++v; + pt->c = ++v; + + i = PER_CPU_DATA_GET(cpu, unsigned int, g); + *i = ++v; + } +} + +static void test_unique_values(unsigned int v) +{ + uint32_t cpu_index; + + for (cpu_index = 0; cpu_index < rtems_get_processor_count(); ++cpu_index) { + Per_CPU_Control *cpu; + unsigned char *c; + unsigned short *s; + unsigned int *i; + unsigned long *l; + t *pt; + + set_affinity(cpu_index); + cpu = _Per_CPU_Get_by_index(cpu_index); + + c = PER_CPU_DATA_GET(cpu, unsigned char, c); + ++v; + rtems_test_assert(*c == (unsigned char) v); + + c = PER_CPU_DATA_GET(cpu, unsigned char, cz); + ++v; + rtems_test_assert(*c == (unsigned char) v); + + s = PER_CPU_DATA_GET(cpu, unsigned short, s); + ++v; + rtems_test_assert(*s == (unsigned short) v); + + s = PER_CPU_DATA_GET(cpu, unsigned short, sz); + ++v; + rtems_test_assert(*s == (unsigned short) v); + + i = PER_CPU_DATA_GET(cpu, unsigned int, i); + ++v; + rtems_test_assert(*i == v); + + i = PER_CPU_DATA_GET(cpu, unsigned int, iz); + ++v; + rtems_test_assert(*i == v); + + l = PER_CPU_DATA_GET(cpu, unsigned long, l); + ++v; + rtems_test_assert(*l == v); + + l = PER_CPU_DATA_GET(cpu, unsigned long, lz); + ++v; + rtems_test_assert(*l == v); + + i = PER_CPU_DATA_GET(cpu, unsigned int, a[0]); + ++v; + rtems_test_assert(i[0] == v); + ++v; + rtems_test_assert(i[1] == v); + ++v; + rtems_test_assert(i[2] == v); + + i = PER_CPU_DATA_GET(cpu, unsigned int, az[0]); + ++v; + rtems_test_assert(i[0] == v); + ++v; + rtems_test_assert(i[1] == v); + ++v; + rtems_test_assert(i[2] == v); + + pt = PER_CPU_DATA_GET(cpu, t, t); + ++v; + rtems_test_assert(pt->a == v); + ++v; + rtems_test_assert(pt->b == v); + ++v; + rtems_test_assert(pt->c == v); + + i = PER_CPU_DATA_GET(cpu, unsigned int, g); + ++v; + rtems_test_assert(*i == v); + } +} + +static void Init(rtems_task_argument arg) +{ + TEST_BEGIN(); + test_initial_values(); + set_unique_values(12); + test_unique_values(12); + TEST_END(); + rtems_test_exit(0); +} + +#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER + +#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION + +#define CONFIGURE_MAXIMUM_PROCESSORS 32 + +#define CONFIGURE_MAXIMUM_TASKS 1 + +#define CONFIGURE_RTEMS_INIT_TASKS_TABLE + +#define CONFIGURE_INIT + +#include diff --git a/testsuites/sptests/sppercpudata01/item.c b/testsuites/sptests/sppercpudata01/item.c new file mode 100644 index 0000000000..2c29449a28 --- /dev/null +++ b/testsuites/sptests/sppercpudata01/item.c @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2018 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * + * + * 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "sppercpudata01.h" + +PER_CPU_DATA_ITEM(unsigned int, g) = 11; diff --git a/testsuites/sptests/sppercpudata01/sppercpudata01.doc b/testsuites/sptests/sppercpudata01/sppercpudata01.doc new file mode 100644 index 0000000000..6ad5546ba8 --- /dev/null +++ b/testsuites/sptests/sppercpudata01/sppercpudata01.doc @@ -0,0 +1,13 @@ +This file describes the directives and concepts tested by this test set. + +test set name: smppercpudata01 + +directives: + + - PER_CPU_DATA_ITEM_DECLARE() + - PER_CPU_DATA_ITEM() + - PER_CPU_DATA_GET() + +concepts: + + - Ensure that the flexible per-CPU data works. diff --git a/testsuites/sptests/sppercpudata01/sppercpudata01.h b/testsuites/sptests/sppercpudata01/sppercpudata01.h new file mode 100644 index 0000000000..efed3cf5f5 --- /dev/null +++ b/testsuites/sptests/sppercpudata01/sppercpudata01.h @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2018 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * + * + * 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. + */ + +#ifndef SPPERCPUDATA01_H +#define SPPERCPUDATA01_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include + +PER_CPU_DATA_ITEM_DECLARE(unsigned int, g); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SPPERCPUDATA01_H */ diff --git a/testsuites/sptests/sppercpudata01/sppercpudata01.scn b/testsuites/sptests/sppercpudata01/sppercpudata01.scn new file mode 100644 index 0000000000..15516a5e21 --- /dev/null +++ b/testsuites/sptests/sppercpudata01/sppercpudata01.scn @@ -0,0 +1,7 @@ +*** BEGIN OF TEST SMPPERCPUDATA 1 *** +*** TEST VERSION: 5.0.0.6d70a1190539ade3f6ec67358461292908473066 +*** TEST STATE: EXPECTED-PASS +*** TEST BUILD: RTEMS_SMP +*** TEST TOOLS: 7.3.0 20180125 (RTEMS 5, RSB 02302026ccc257ece411d955836a3ac9b8afb9dc, Newlib d13c84eb07e35984bf7a974cd786a6cdac29e6b9) + +*** END OF TEST SMPPERCPUDATA 1 *** -- cgit v1.2.3