summaryrefslogtreecommitdiffstats
path: root/testsuites/sptests/spintrcritical_support
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2009-07-10 20:31:17 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2009-07-10 20:31:17 +0000
commit0c196a192b1e894fb2143c8981c41d32ab7bfb1e (patch)
tree2298c498a24cced8fa14553bd8b586ab586c45e3 /testsuites/sptests/spintrcritical_support
parent2009-07-10 Joel Sherrill <joel.sherrill@OARcorp.com> (diff)
downloadrtems-0c196a192b1e894fb2143c8981c41d32ab7bfb1e.tar.bz2
2009-07-10 Joel Sherrill <joel.sherrill@OARcorp.com>
* spintrcritical_support/intrcritical.c, spintrcritical_support/intrcritical.h: New files.
Diffstat (limited to 'testsuites/sptests/spintrcritical_support')
-rw-r--r--testsuites/sptests/spintrcritical_support/intrcritical.c87
-rw-r--r--testsuites/sptests/spintrcritical_support/intrcritical.h26
2 files changed, 113 insertions, 0 deletions
diff --git a/testsuites/sptests/spintrcritical_support/intrcritical.c b/testsuites/sptests/spintrcritical_support/intrcritical.c
new file mode 100644
index 0000000000..63d1b12654
--- /dev/null
+++ b/testsuites/sptests/spintrcritical_support/intrcritical.c
@@ -0,0 +1,87 @@
+/*
+ * COPYRIGHT (c) 1989-2009.
+ * 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.com/license/LICENSE.
+ *
+ * $Id$
+ */
+
+#include <tmacros.h>
+#include <intrcritical.h>
+
+static uint32_t Maximum;
+static uint32_t Maximum_current;
+static rtems_id Timer;
+static rtems_timer_service_routine (*TSR)( rtems_id, void * );
+
+void interrupt_critical_section_test_support_initialize(
+ rtems_timer_service_routine (*tsr)( rtems_id, void * )
+)
+{
+ Watchdog_Interval initial;
+ uint32_t counter;
+
+ initial = _Watchdog_Ticks_since_boot;
+
+ Timer = 0;
+ TSR = tsr;
+ if ( tsr ) {
+ rtems_status_code rc;
+
+ puts( "Support - rtems_timer_create - creating timer 1" );
+ rc = rtems_timer_create( rtems_build_name( 'T', 'M', '1', ' ' ), &Timer );
+ directive_failed( rc, "rtems_timer_create" );
+ }
+
+ /*
+ * Wait for starting point
+ */
+ for (counter=0 ; initial == _Watchdog_Ticks_since_boot ; counter++)
+ ;
+
+ initial = _Watchdog_Ticks_since_boot;
+ /*
+ * Wait for ending point
+ */
+ for (counter=0 ; initial == _Watchdog_Ticks_since_boot ; counter++)
+ ;
+
+ Maximum = counter;
+ Maximum_current = counter;
+
+ #if 0
+ printf( "%d 0x%08x counts\n", counter, counter );
+ #endif
+}
+
+void interrupt_critical_section_test_support_delay(void)
+{
+ uint32_t counter;
+ Watchdog_Interval initial;
+
+ if (TSR) {
+ rtems_status_code rc;
+
+ rc = rtems_timer_fire_after( Timer, 1, TSR, NULL );
+ directive_failed( rc, "timer_fire_after failed" );
+ }
+
+ /*
+ * Count down
+ */
+ if ( !Maximum_current )
+ Maximum_current = Maximum;
+ initial = _Watchdog_Ticks_since_boot;
+ for (counter=Maximum_current ; counter ; counter--)
+ if ( initial != _Watchdog_Ticks_since_boot )
+ break;
+
+ Maximum_current--;
+
+ /*
+ * Return so the test can try to generate the condition
+ */
+}
diff --git a/testsuites/sptests/spintrcritical_support/intrcritical.h b/testsuites/sptests/spintrcritical_support/intrcritical.h
new file mode 100644
index 0000000000..4b523a656d
--- /dev/null
+++ b/testsuites/sptests/spintrcritical_support/intrcritical.h
@@ -0,0 +1,26 @@
+/*
+ * COPYRIGHT (c) 1989-2009.
+ * 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.com/license/LICENSE.
+ *
+ * $Id$
+ */
+
+#ifndef __INTERRUPT_CRITICAL_SECTIONS_TEST_SUPPORT_h
+#define __INTERRUPT_CRITICAL_SECTIONS_TEST_SUPPORT_h
+
+/**
+ * @brief Initialize Test Support
+ *
+ * @param[in] tsr is the optional timer service routine to fire
+ */
+void interrupt_critical_section_test_support_initialize(
+ rtems_timer_service_routine (*tsr)( rtems_id, void * )
+);
+
+void interrupt_critical_section_test_support_delay(void);
+#endif
+