summaryrefslogtreecommitdiff
path: root/irq_test_c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2007-10-17 20:55:06 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2007-10-17 20:55:06 +0000
commit14f44a3474b5177a73aede9d3ab142ab003f5796 (patch)
treeeeab866e741b2a851d712497384f45ea56717863 /irq_test_c
parent2059da67a23d7a3be0316e154ff736c255c267a8 (diff)
2007-10-17 Joel Sherrill <joel.sherrill@oarcorp.com>
* Makefile, Makefile.shared, rtems_init.c, irq_test/interrupt_pkg.adb, irq_test/interrupt_pkg.ads, irq_test/irqforce.c, irq_test/irqtest.adb, rootfs/etc/hosts: Adding new tests as improvements are made to the RTEMS port of the GNAT run-time. * empty/Makefile, empty/README, empty/empty.adb, hello_via_task/.cvsignore, hello_via_task/Makefile, hello_via_task/hello.adb, irq_test/.cvsignore, irq_test/Makefile, irq_test/README, irq_test_c/.cvsignore, irq_test_c/Makefile, irq_test_c/README, irq_test_c/init.c, irq_test_c/irqforce.c: New files.
Diffstat (limited to 'irq_test_c')
-rw-r--r--irq_test_c/.cvsignore3
-rw-r--r--irq_test_c/Makefile27
-rw-r--r--irq_test_c/README26
-rw-r--r--irq_test_c/init.c156
-rw-r--r--irq_test_c/irqforce.c15
5 files changed, 227 insertions, 0 deletions
diff --git a/irq_test_c/.cvsignore b/irq_test_c/.cvsignore
new file mode 100644
index 0000000..34f3eae
--- /dev/null
+++ b/irq_test_c/.cvsignore
@@ -0,0 +1,3 @@
+o-optimize
+*.swp
+.gdbinit
diff --git a/irq_test_c/Makefile b/irq_test_c/Makefile
new file mode 100644
index 0000000..1765cc6
--- /dev/null
+++ b/irq_test_c/Makefile
@@ -0,0 +1,27 @@
+#
+# Makefile
+#
+
+#
+# RTEMS_MAKEFILE_PATH is typically set in an environment variable
+#
+
+PGM=${ARCH}/c_irq_text.exe
+
+# optional managers required
+MANAGERS=all
+
+# C source names
+CSRCS = init.c irqforce.c
+COBJS = $(CSRCS:%.c=${ARCH}/%.o)
+
+include $(RTEMS_MAKEFILE_PATH)/Makefile.inc
+include $(RTEMS_CUSTOM)
+include $(PROJECT_ROOT)/make/leaf.cfg
+
+OBJS= $(COBJS)
+
+all: ${ARCH} $(PGM)
+
+$(PGM): $(OBJS)
+ $(make-exe)
diff --git a/irq_test_c/README b/irq_test_c/README
new file mode 100644
index 0000000..28a0309
--- /dev/null
+++ b/irq_test_c/README
@@ -0,0 +1,26 @@
+#
+# $Id$
+#
+
+WARNING!!! Code is ERC32 specific.
+
+The directories irq_test and irq_test_c are related and provided
+for performance comparisons.
+
+This directory contains a simple benchmark in C of a forced interrupt
+and provides a baseline comparison point for the performance
+of the GNAT implementation of Ada interrupt tasks on RTEMS.
+
+On 17 October 2007, this program run on TSIM reported that
+it took 158 microseconds on a 14 Mhz SPARC/ERC32 to complete
+the following sequence:
+
+ + Init: Start Timer
+ + Init: Force IRQ
+ + ISR: Release a simple binary semaphore
+ + ISR Task: Wake up from simple binary semaphore
+ + ISR Task: Stop Timer
+
+In comparison, an Ada program implementing the same
+sequence but using Ada interrupt tasks took 315 microseconds
+on the same target.
diff --git a/irq_test_c/init.c b/irq_test_c/init.c
new file mode 100644
index 0000000..a67235e
--- /dev/null
+++ b/irq_test_c/init.c
@@ -0,0 +1,156 @@
+/*
+ * COPYRIGHT (c) 1989-2003.
+ * 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 <stdio.h>
+#include <stdlib.h>
+
+#include <bsp.h>
+#include <rtems/score/timespec.h> /* _Timespec_Substract */
+
+struct timespec start;
+#if defined(INCLUDE_TO_ISR)
+ struct timespec to_isr;
+#endif
+struct timespec stop_in_task;
+
+rtems_id semaphore;
+rtems_id task_id;
+
+void irqforce(int);
+
+void ISR( uint32_t arg )
+{
+ rtems_status_code status;
+ #if defined(INCLUDE_TO_ISR)
+ _TOD_Get( &to_isr );
+ #endif
+ status = rtems_semaphore_release( semaphore );
+}
+
+rtems_task ISR_Task(
+ rtems_task_argument argument
+)
+{
+ rtems_status_code status;
+ struct timespec diff1, diff2;
+
+ #define print_timespec( _t ) \
+ printf ( "%ld:%ld ", (long) _t.tv_sec, (long) _t.tv_nsec );
+
+ /*
+ * Print base overhead
+ */
+
+ _TOD_Get( &start );
+ _TOD_Get( &stop_in_task );
+ _Timespec_Subtract( &start, &stop_in_task, &diff1 );
+ printf( "Timer Overhead: " );
+ print_timespec( start );
+ print_timespec( stop_in_task );
+ printf( "--> " );
+ print_timespec( diff1 );
+ printf( "\n" );
+
+ while (1) {
+ status = rtems_semaphore_obtain( semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT );
+ _TOD_Get( &stop_in_task );
+
+ _Timespec_Subtract( &start, &stop_in_task, &diff2 );
+ print_timespec( start );
+ #if defined(INCLUDE_TO_ISR)
+ _Timespec_Subtract( &start, &to_isr, &diff1 );
+ print_timespec( to_isr );
+ #endif
+ print_timespec( stop_in_task );
+ printf( "--> " );
+ #if defined(INCLUDE_TO_ISR)
+ print_timespec( diff1 );
+ #endif
+ print_timespec( diff2 );
+ printf( "\n" );
+ }
+}
+
+rtems_task Init(
+ rtems_task_argument argument
+)
+{
+ rtems_status_code status;
+ rtems_time_of_day time;
+ int i;
+
+ puts( "\n\n*** IRQ FORCE TEST ***" );
+
+ time.year = 2007;
+ time.month = 10;
+ time.day = 17;
+ time.hour = 13;
+ time.minute = 45;
+ time.second = 0;
+ time.ticks = 0;
+
+ status = rtems_clock_set( &time );
+
+ /*
+ * Create the simple semaphore used to wake us up
+ */
+
+ status = rtems_semaphore_create(
+ rtems_build_name( 'A', 'I', 'S', 'R' ),
+ 0,
+ RTEMS_SIMPLE_BINARY_SEMAPHORE | RTEMS_FIFO,
+ 0,
+ &semaphore
+ );
+
+ status = rtems_task_create(
+ rtems_build_name( 'A', 'I', 'S', 'R' ),
+ 1, RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES,
+ RTEMS_DEFAULT_ATTRIBUTES, &task_id
+ );
+ status = rtems_task_start( task_id, ISR_Task, 1 );
+
+
+ /*
+ * Now generate the interrupt and time it
+ */
+
+ set_vector( ISR, 17, 1 );
+ for ( i=0 ; i<= 10 ; i++ ) {
+ sleep(1);
+ _TOD_Get( &start );
+ irqforce(1);
+ }
+ sleep(1);
+
+ exit( 0 );
+}
+
+/**************** START OF CONFIGURATION INFORMATION ****************/
+
+#define CONFIGURE_INIT
+
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
+
+#define CONFIGURE_MAXIMUM_TASKS 4
+#define CONFIGURE_MAXIMUM_SEMAPHORES 1
+
+#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
+#define CONFIGURE_INIT_TASK_PRIORITY 5
+#define CONFIGURE_INIT_TASK_INITIAL_MODES RTEMS_PREEMPT
+
+#define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE)
+
+#include <rtems/confdefs.h>
+
+/**************** END OF CONFIGURATION INFORMATION ****************/
+
diff --git a/irq_test_c/irqforce.c b/irq_test_c/irqforce.c
new file mode 100644
index 0000000..ad46b8b
--- /dev/null
+++ b/irq_test_c/irqforce.c
@@ -0,0 +1,15 @@
+/*
+ * 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 <bsp.h>
+
+void irqforce(int irq)
+{
+ ERC32_Unmask_interrupt(irq);
+ ERC32_Force_interrupt(irq);
+}