[PATCH 3/4] INTERNAL_ERROR_ILLEGAL_USE_OF_FLOATING_POINT_UNIT

Sebastian Huber sebastian.huber at embedded-brains.de
Wed Jul 19 08:21:17 UTC 2017


Add new fatal error INTERNAL_ERROR_ILLEGAL_USE_OF_FLOATING_POINT_UNIT.

Update #3077.
---
 c/src/lib/libbsp/sparc/erc32/startup/spurious.c |  4 ++
 c/src/lib/libbsp/sparc/leon2/startup/spurious.c |  4 ++
 c/src/lib/libbsp/sparc/leon3/startup/spurious.c |  4 ++
 cpukit/sapi/src/interrtext.c                    |  5 +-
 cpukit/score/include/rtems/score/interr.h       |  3 +-
 testsuites/sptests/Makefile.am                  |  2 +
 testsuites/sptests/configure.ac                 |  2 +
 testsuites/sptests/spfatal30/Makefile.am        | 19 +++++
 testsuites/sptests/spfatal30/init.c             | 80 +++++++++++++++++++++
 testsuites/sptests/spfatal30/spfatal30.doc      | 12 ++++
 testsuites/sptests/spfatal30/spfatal30.scn      |  2 +
 testsuites/sptests/spfatal31/Makefile.am        | 19 +++++
 testsuites/sptests/spfatal31/init.c             | 96 +++++++++++++++++++++++++
 testsuites/sptests/spfatal31/spfatal31.doc      | 12 ++++
 testsuites/sptests/spfatal31/spfatal31.scn      |  2 +
 testsuites/sptests/spinternalerror02/init.c     |  4 +-
 16 files changed, 265 insertions(+), 5 deletions(-)
 create mode 100644 testsuites/sptests/spfatal30/Makefile.am
 create mode 100644 testsuites/sptests/spfatal30/init.c
 create mode 100644 testsuites/sptests/spfatal30/spfatal30.doc
 create mode 100644 testsuites/sptests/spfatal30/spfatal30.scn
 create mode 100644 testsuites/sptests/spfatal31/Makefile.am
 create mode 100644 testsuites/sptests/spfatal31/init.c
 create mode 100644 testsuites/sptests/spfatal31/spfatal31.doc
 create mode 100644 testsuites/sptests/spfatal31/spfatal31.scn

diff --git a/c/src/lib/libbsp/sparc/erc32/startup/spurious.c b/c/src/lib/libbsp/sparc/erc32/startup/spurious.c
index 4e52892c5f..2b262af169 100644
--- a/c/src/lib/libbsp/sparc/erc32/startup/spurious.c
+++ b/c/src/lib/libbsp/sparc/erc32/startup/spurious.c
@@ -133,6 +133,10 @@ static rtems_isr bsp_spurious_handler(
     .isf = isf
   };
 
+  if ( SPARC_REAL_TRAP_NUMBER( trap ) == 4 ) {
+    _Internal_error( INTERNAL_ERROR_ILLEGAL_USE_OF_FLOATING_POINT_UNIT );
+  }
+
   rtems_fatal(
     RTEMS_FATAL_SOURCE_EXCEPTION,
     (rtems_fatal_code) &frame
diff --git a/c/src/lib/libbsp/sparc/leon2/startup/spurious.c b/c/src/lib/libbsp/sparc/leon2/startup/spurious.c
index a4cd1fa38d..58ba4fc797 100644
--- a/c/src/lib/libbsp/sparc/leon2/startup/spurious.c
+++ b/c/src/lib/libbsp/sparc/leon2/startup/spurious.c
@@ -120,6 +120,10 @@ static rtems_isr bsp_spurious_handler(
     .isf = isf
   };
 
+  if ( SPARC_REAL_TRAP_NUMBER( trap ) == 4 ) {
+    _Internal_error( INTERNAL_ERROR_ILLEGAL_USE_OF_FLOATING_POINT_UNIT );
+  }
+
   rtems_fatal(
     RTEMS_FATAL_SOURCE_EXCEPTION,
     (rtems_fatal_code) &frame
diff --git a/c/src/lib/libbsp/sparc/leon3/startup/spurious.c b/c/src/lib/libbsp/sparc/leon3/startup/spurious.c
index 647ecd0e0d..88d977d603 100644
--- a/c/src/lib/libbsp/sparc/leon3/startup/spurious.c
+++ b/c/src/lib/libbsp/sparc/leon3/startup/spurious.c
@@ -119,6 +119,10 @@ static rtems_isr bsp_spurious_handler(
     .isf = isf
   };
 
+  if ( SPARC_REAL_TRAP_NUMBER( trap ) == 4 ) {
+    _Internal_error( INTERNAL_ERROR_ILLEGAL_USE_OF_FLOATING_POINT_UNIT );
+  }
+
   rtems_fatal(
     RTEMS_FATAL_SOURCE_EXCEPTION,
     (rtems_fatal_code) &frame
diff --git a/cpukit/sapi/src/interrtext.c b/cpukit/sapi/src/interrtext.c
index c92f922878..6fada4be26 100644
--- a/cpukit/sapi/src/interrtext.c
+++ b/cpukit/sapi/src/interrtext.c
@@ -7,7 +7,7 @@
  */
 
 /*
- * Copyright (c) 2012, 2016 embedded brains GmbH.  All rights reserved.
+ * Copyright (c) 2012, 2017 embedded brains GmbH.  All rights reserved.
  *
  *  embedded brains GmbH
  *  Dornierstr. 4
@@ -64,7 +64,8 @@ static const char *const internal_error_text[] = {
   "INTERNAL_ERROR_LIBIO_USER_ENV_KEY_CREATE_FAILED",
   "INTERNAL_ERROR_LIBIO_SEM_CREATE_FAILED",
   "INTERNAL_ERROR_LIBIO_STDOUT_FD_OPEN_FAILED",
-  "INTERNAL_ERROR_LIBIO_STDERR_FD_OPEN_FAILED"
+  "INTERNAL_ERROR_LIBIO_STDERR_FD_OPEN_FAILED",
+  "INTERNAL_ERROR_ILLEGAL_USE_OF_FLOATING_POINT_UNIT"
 };
 
 const char *rtems_internal_error_text( rtems_fatal_code error )
diff --git a/cpukit/score/include/rtems/score/interr.h b/cpukit/score/include/rtems/score/interr.h
index 7dd6168f7a..ca64341948 100644
--- a/cpukit/score/include/rtems/score/interr.h
+++ b/cpukit/score/include/rtems/score/interr.h
@@ -177,7 +177,8 @@ typedef enum {
   INTERNAL_ERROR_LIBIO_USER_ENV_KEY_CREATE_FAILED = 34,
   INTERNAL_ERROR_LIBIO_SEM_CREATE_FAILED = 35,
   INTERNAL_ERROR_LIBIO_STDOUT_FD_OPEN_FAILED = 36,
-  INTERNAL_ERROR_LIBIO_STDERR_FD_OPEN_FAILED = 37
+  INTERNAL_ERROR_LIBIO_STDERR_FD_OPEN_FAILED = 37,
+  INTERNAL_ERROR_ILLEGAL_USE_OF_FLOATING_POINT_UNIT = 38
 } Internal_errors_Core_list;
 
 typedef CPU_Uint32ptr Internal_errors_t;
diff --git a/testsuites/sptests/Makefile.am b/testsuites/sptests/Makefile.am
index c50e7575bc..890dd38571 100644
--- a/testsuites/sptests/Makefile.am
+++ b/testsuites/sptests/Makefile.am
@@ -34,6 +34,8 @@ _SUBDIRS = \
     spsem_err02 sptask_err01 spevent_err03 sptask_err03 sptask_err02 \
     sptask_err04 spclock_err01
 _SUBDIRS += spfatal29
+_SUBDIRS += spfatal30
+_SUBDIRS += spfatal31
 _SUBDIRS += spmutex01
 _SUBDIRS += spextensions01
 _SUBDIRS += spsysinit01
diff --git a/testsuites/sptests/configure.ac b/testsuites/sptests/configure.ac
index e14c937cab..88d6ed6aa2 100644
--- a/testsuites/sptests/configure.ac
+++ b/testsuites/sptests/configure.ac
@@ -36,6 +36,8 @@ AM_CONDITIONAL(HAS_SMP,test "$rtems_cv_RTEMS_SMP" = "yes")
 
 # Explicitly list all Makefiles here
 AC_CONFIG_FILES([Makefile
+spfatal31/Makefile
+spfatal30/Makefile
 spmutex01/Makefile
 spextensions01/Makefile
 sptimerserver01/Makefile
diff --git a/testsuites/sptests/spfatal30/Makefile.am b/testsuites/sptests/spfatal30/Makefile.am
new file mode 100644
index 0000000000..efd5d44f42
--- /dev/null
+++ b/testsuites/sptests/spfatal30/Makefile.am
@@ -0,0 +1,19 @@
+rtems_tests_PROGRAMS = spfatal30
+spfatal30_SOURCES = init.c
+
+dist_rtems_tests_DATA = spfatal30.scn spfatal30.doc
+
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP at .cfg
+include $(top_srcdir)/../automake/compile.am
+include $(top_srcdir)/../automake/leaf.am
+
+AM_CPPFLAGS += -I$(top_srcdir)/../support/include
+
+LINK_OBJS = $(spfatal30_OBJECTS)
+LINK_LIBS = $(spfatal30_LDLIBS)
+
+spfatal30$(EXEEXT): $(spfatal30_OBJECTS) $(spfatal30_DEPENDENCIES)
+	@rm -f spfatal30$(EXEEXT)
+	$(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/sptests/spfatal30/init.c b/testsuites/sptests/spfatal30/init.c
new file mode 100644
index 0000000000..e1a89c49eb
--- /dev/null
+++ b/testsuites/sptests/spfatal30/init.c
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2017 embedded brains GmbH.  All rights reserved.
+ *
+ *  embedded brains GmbH
+ *  Dornierstr. 4
+ *  82178 Puchheim
+ *  Germany
+ *  <rtems at embedded-brains.de>
+ *
+ * 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
+
+#define TESTS_USE_PRINTK
+#include "tmacros.h"
+
+#include <rtems.h>
+
+const char rtems_test_name[] = "SPFATAL 30";
+
+#if CPU_HARDWARE_FP == TRUE && CPU_ALL_TASKS_ARE_FP == FALSE
+#define EXPECT_ILLEGAL_USE_OF_FLOATING_POINT_UNIT
+#endif
+
+static volatile double f = 1.0;
+
+static void Init(rtems_task_argument arg)
+{
+  TEST_BEGIN();
+
+  f *= 123.456;
+
+#ifdef EXPECT_ILLEGAL_USE_OF_FLOATING_POINT_UNIT
+  rtems_test_assert(0);
+#else
+  TEST_END();
+  rtems_test_exit(0);
+#endif
+}
+
+#ifdef EXPECT_ILLEGAL_USE_OF_FLOATING_POINT_UNIT
+static void fatal_extension(
+  rtems_fatal_source source,
+  bool always_set_to_false,
+  rtems_fatal_code code
+)
+{
+  if (
+    source == INTERNAL_ERROR_CORE
+      && !always_set_to_false
+      && code == INTERNAL_ERROR_ILLEGAL_USE_OF_FLOATING_POINT_UNIT
+  ) {
+    TEST_END();
+  }
+}
+
+#define CONFIGURE_INITIAL_EXTENSIONS \
+  { .fatal = fatal_extension }, \
+  RTEMS_TEST_INITIAL_EXTENSION
+
+#else /* EXPECT_ILLEGAL_USE_OF_FLOATING_POINT_UNIT */
+
+#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
+
+#endif /* EXPECT_ILLEGAL_USE_OF_FLOATING_POINT_UNIT */
+
+#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
+
+#define CONFIGURE_MAXIMUM_TASKS 1
+
+#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
+
+#define CONFIGURE_INIT
+
+#include <rtems/confdefs.h>
diff --git a/testsuites/sptests/spfatal30/spfatal30.doc b/testsuites/sptests/spfatal30/spfatal30.doc
new file mode 100644
index 0000000000..6fff5cfc2e
--- /dev/null
+++ b/testsuites/sptests/spfatal30/spfatal30.doc
@@ -0,0 +1,12 @@
+This file describes the directives and concepts tested by this test set.
+
+test set name: spfatal30
+
+directives:
+
+  - _Internal_error()
+
+concepts:
+
+  - Provoke an illegal use of the floating point unit in thread context and
+    ensure that the right internal error occurs.
diff --git a/testsuites/sptests/spfatal30/spfatal30.scn b/testsuites/sptests/spfatal30/spfatal30.scn
new file mode 100644
index 0000000000..ec69033143
--- /dev/null
+++ b/testsuites/sptests/spfatal30/spfatal30.scn
@@ -0,0 +1,2 @@
+*** BEGIN OF TEST SPFATAL 30 ***
+*** END OF TEST SPFATAL 30 ***
diff --git a/testsuites/sptests/spfatal31/Makefile.am b/testsuites/sptests/spfatal31/Makefile.am
new file mode 100644
index 0000000000..ec6161b313
--- /dev/null
+++ b/testsuites/sptests/spfatal31/Makefile.am
@@ -0,0 +1,19 @@
+rtems_tests_PROGRAMS = spfatal31
+spfatal31_SOURCES = init.c
+
+dist_rtems_tests_DATA = spfatal31.scn spfatal31.doc
+
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP at .cfg
+include $(top_srcdir)/../automake/compile.am
+include $(top_srcdir)/../automake/leaf.am
+
+AM_CPPFLAGS += -I$(top_srcdir)/../support/include
+
+LINK_OBJS = $(spfatal31_OBJECTS)
+LINK_LIBS = $(spfatal31_LDLIBS)
+
+spfatal31$(EXEEXT): $(spfatal31_OBJECTS) $(spfatal31_DEPENDENCIES)
+	@rm -f spfatal31$(EXEEXT)
+	$(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/sptests/spfatal31/init.c b/testsuites/sptests/spfatal31/init.c
new file mode 100644
index 0000000000..b5066c0825
--- /dev/null
+++ b/testsuites/sptests/spfatal31/init.c
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2017 embedded brains GmbH.  All rights reserved.
+ *
+ *  embedded brains GmbH
+ *  Dornierstr. 4
+ *  82178 Puchheim
+ *  Germany
+ *  <rtems at embedded-brains.de>
+ *
+ * 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
+
+#define TESTS_USE_PRINTK
+#include "tmacros.h"
+
+#include <rtems.h>
+
+const char rtems_test_name[] = "SPFATAL 31";
+
+#if CPU_HARDWARE_FP == TRUE && defined(__sparc__)
+#define EXPECT_ILLEGAL_USE_OF_FLOATING_POINT_UNIT
+#endif
+
+static volatile double f = 1.0;
+
+static void timer(rtems_id id, void *arg)
+{
+  f *= 123.456;
+}
+
+static void Init(rtems_task_argument arg)
+{
+  rtems_status_code sc;
+  rtems_id id;
+
+  TEST_BEGIN();
+
+  sc = rtems_timer_create(rtems_build_name('T', 'I', 'M', 'E'), &id);
+  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+  sc = rtems_timer_fire_after(id, 1, timer, NULL);
+  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+  sc = rtems_task_wake_after(2);
+  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+#ifdef EXPECT_ILLEGAL_USE_OF_FLOATING_POINT_UNIT
+  rtems_test_assert(0);
+#else
+  TEST_END();
+  rtems_test_exit(0);
+#endif
+}
+
+#ifdef EXPECT_ILLEGAL_USE_OF_FLOATING_POINT_UNIT
+static void fatal_extension(
+  rtems_fatal_source source,
+  bool always_set_to_false,
+  rtems_fatal_code code
+)
+{
+  if (
+    source == INTERNAL_ERROR_CORE
+      && !always_set_to_false
+      && code == INTERNAL_ERROR_ILLEGAL_USE_OF_FLOATING_POINT_UNIT
+  ) {
+    TEST_END();
+  }
+}
+
+#define CONFIGURE_INITIAL_EXTENSIONS \
+  { .fatal = fatal_extension }, \
+  RTEMS_TEST_INITIAL_EXTENSION
+
+#else /* EXPECT_ILLEGAL_USE_OF_FLOATING_POINT_UNIT */
+
+#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
+
+#endif /* EXPECT_ILLEGAL_USE_OF_FLOATING_POINT_UNIT */
+
+#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
+
+#define CONFIGURE_MAXIMUM_TASKS 1
+#define CONFIGURE_MAXIMUM_TIMERS 1
+
+#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
+
+#define CONFIGURE_INIT
+
+#include <rtems/confdefs.h>
diff --git a/testsuites/sptests/spfatal31/spfatal31.doc b/testsuites/sptests/spfatal31/spfatal31.doc
new file mode 100644
index 0000000000..5e5a450f52
--- /dev/null
+++ b/testsuites/sptests/spfatal31/spfatal31.doc
@@ -0,0 +1,12 @@
+This file describes the directives and concepts tested by this test set.
+
+test set name: spfatal31
+
+directives:
+
+  - _Internal_error()
+
+concepts:
+
+  - Provoke an illegal use of the floating point unit in interrupt context and
+    ensure that the right internal error occurs.
diff --git a/testsuites/sptests/spfatal31/spfatal31.scn b/testsuites/sptests/spfatal31/spfatal31.scn
new file mode 100644
index 0000000000..2210acec10
--- /dev/null
+++ b/testsuites/sptests/spfatal31/spfatal31.scn
@@ -0,0 +1,2 @@
+*** BEGIN OF TEST SPFATAL 31 ***
+*** END OF TEST SPFATAL 31 ***
diff --git a/testsuites/sptests/spinternalerror02/init.c b/testsuites/sptests/spinternalerror02/init.c
index 412675535f..2ed4c955d8 100644
--- a/testsuites/sptests/spinternalerror02/init.c
+++ b/testsuites/sptests/spinternalerror02/init.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2016 embedded brains GmbH.  All rights reserved.
+ * Copyright (c) 2012, 2017 embedded brains GmbH.  All rights reserved.
  *
  *  embedded brains GmbH
  *  Donierstr. 4
@@ -36,7 +36,7 @@ static void test_internal_error_text(void)
   } while ( text != text_last );
 
   rtems_test_assert(
-    error - 3 == INTERNAL_ERROR_LIBIO_STDERR_FD_OPEN_FAILED
+    error - 3 == INTERNAL_ERROR_ILLEGAL_USE_OF_FLOATING_POINT_UNIT
   );
 }
 
-- 
2.12.3




More information about the devel mailing list