From ccd7d5cf73aee08715de035c5c17ecae7f17ac6f Mon Sep 17 00:00:00 2001 From: Daron Chabot Date: Fri, 13 Mar 2009 15:07:05 +0000 Subject: Add c++ sample template. --- org.rtems.cdt.feature/build.properties | 7 + org.rtems.cdt.feature/feature.xml | 22 +- org.rtems.cdt.update/artifacts.xml | 64 +- org.rtems.cdt.update/content.xml | 267 +++++++- .../features/org.rtems.cdt_1.1.0.jar | Bin 10996 -> 0 bytes .../features/org.rtems.cdt_1.2.0.jar | Bin 0 -> 11007 bytes .../plugins/org.rtems.cdt_1.1.0.jar | Bin 113059 -> 0 bytes .../plugins/org.rtems.cdt_1.2.0.jar | Bin 0 -> 125214 bytes org.rtems.cdt.update/site.xml | 2 +- org.rtems.cdt/META-INF/MANIFEST.MF | 2 +- org.rtems.cdt/about.mappings | 2 +- org.rtems.cdt/build.properties | 18 + org.rtems.cdt/plugin.xml | 13 + .../org/rtems/cdt/preferences/PreferencePage.java | 2 - .../templates/rtems++/include/buffer_test_io.h | 190 ++++++ org.rtems.cdt/templates/rtems++/include/tmacros.h | 260 ++++++++ org.rtems.cdt/templates/rtems++/src/Init.cc | 62 ++ org.rtems.cdt/templates/rtems++/src/System.h | 135 ++++ org.rtems.cdt/templates/rtems++/src/Task1.cc | 681 +++++++++++++++++++++ org.rtems.cdt/templates/rtems++/src/Task2.cc | 80 +++ org.rtems.cdt/templates/rtems++/src/Task3.cc | 80 +++ .../templates/rtems++/template.properties | 3 + org.rtems.cdt/templates/rtems++/template.xml | 90 +++ 23 files changed, 1970 insertions(+), 10 deletions(-) delete mode 100644 org.rtems.cdt.update/features/org.rtems.cdt_1.1.0.jar create mode 100644 org.rtems.cdt.update/features/org.rtems.cdt_1.2.0.jar delete mode 100644 org.rtems.cdt.update/plugins/org.rtems.cdt_1.1.0.jar create mode 100644 org.rtems.cdt.update/plugins/org.rtems.cdt_1.2.0.jar create mode 100644 org.rtems.cdt/templates/rtems++/include/buffer_test_io.h create mode 100644 org.rtems.cdt/templates/rtems++/include/tmacros.h create mode 100644 org.rtems.cdt/templates/rtems++/src/Init.cc create mode 100644 org.rtems.cdt/templates/rtems++/src/System.h create mode 100644 org.rtems.cdt/templates/rtems++/src/Task1.cc create mode 100644 org.rtems.cdt/templates/rtems++/src/Task2.cc create mode 100644 org.rtems.cdt/templates/rtems++/src/Task3.cc create mode 100644 org.rtems.cdt/templates/rtems++/template.properties create mode 100644 org.rtems.cdt/templates/rtems++/template.xml diff --git a/org.rtems.cdt.feature/build.properties b/org.rtems.cdt.feature/build.properties index e69de29..058df2f 100644 --- a/org.rtems.cdt.feature/build.properties +++ b/org.rtems.cdt.feature/build.properties @@ -0,0 +1,7 @@ +output.. = . +source.. = . +bin.includes = about.html,\ + epl-v10.html,\ + feature.xml,\ + feature.properties,\ + license.html \ No newline at end of file diff --git a/org.rtems.cdt.feature/feature.xml b/org.rtems.cdt.feature/feature.xml index a50485c..49d90df 100644 --- a/org.rtems.cdt.feature/feature.xml +++ b/org.rtems.cdt.feature/feature.xml @@ -2,7 +2,7 @@ @@ -21,4 +21,24 @@ + + + + + + + + + + + + + + + diff --git a/org.rtems.cdt.update/artifacts.xml b/org.rtems.cdt.update/artifacts.xml index 9c8464e..6235eb1 100644 --- a/org.rtems.cdt.update/artifacts.xml +++ b/org.rtems.cdt.update/artifacts.xml @@ -3,20 +3,26 @@ - + - + + + + + + + @@ -47,6 +53,18 @@ + + + + + + + + + + + + @@ -83,17 +101,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/org.rtems.cdt.update/content.xml b/org.rtems.cdt.update/content.xml index d400c86..5cbc48c 100644 --- a/org.rtems.cdt.update/content.xml +++ b/org.rtems.cdt.update/content.xml @@ -3,13 +3,13 @@ - + - + @@ -587,5 +587,268 @@ Bundle-Version: 1.1.0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Bundle-Vendor: Embedded Brains GmbH +Bundle-ManifestVersion: 2 +Bundle-Activator: org.rtems.cdt.Activator +Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-Name: RTEMS CDT Plug-in +Import-Package: org.eclipse.cdt.core.model,org.eclipse.cdt.managedbuilder.ui.wizards,org.eclipse.jface.resource,org.eclipse.ui.wizards.newresource +Require-Bundle: org.eclipse.cdt.managedbuilder.core,org.eclipse.swt,org.eclipse.ui,org.eclipse.core.resources,org.eclipse.cdt.ui,org.eclipse.core.runtime,org.eclipse.cdt.managedbuilder.ui,org.eclipse.cdt.core +Bundle-ActivationPolicy: lazy +Manifest-Version: 1.0 +Bundle-SymbolicName: org.rtems.cdt;singleton:=true +Bundle-Version: 1.1.1 + + + true + + + + + + + + + + + + + + + + + + + + + + + + + (org.eclipse.update.install.features=true) + + + + + + + + + true + + + + + + %license + + + + %copyright + + + + + + + + + + + + + + + + + + + + + + + + + (org.eclipse.update.install.features=true) + + + + + + + %license + + + + %copyright + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + (org.eclipse.update.install.features=true) + + + + + + + %license + + + + %copyright + + + + + + + + + + + + + + + + + + + + + + + (org.eclipse.update.install.features=true) + + + + + + + + + true + + + + + + %license + + + + %copyright + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Bundle-Vendor: Embedded Brains GmbH +Bundle-ManifestVersion: 2 +Bundle-Activator: org.rtems.cdt.Activator +Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-Name: RTEMS CDT Plug-in +Import-Package: org.eclipse.cdt.core.model,org.eclipse.cdt.managedbuilder.ui.wizards,org.eclipse.jface.resource,org.eclipse.ui.wizards.newresource +Require-Bundle: org.eclipse.cdt.managedbuilder.core,org.eclipse.swt,org.eclipse.ui,org.eclipse.core.resources,org.eclipse.cdt.ui,org.eclipse.core.runtime,org.eclipse.cdt.managedbuilder.ui,org.eclipse.cdt.core +Bundle-ActivationPolicy: lazy +Manifest-Version: 1.0 +Bundle-SymbolicName: org.rtems.cdt;singleton:=true +Bundle-Version: 1.2.0 + + + + diff --git a/org.rtems.cdt.update/features/org.rtems.cdt_1.1.0.jar b/org.rtems.cdt.update/features/org.rtems.cdt_1.1.0.jar deleted file mode 100644 index 03cb949..0000000 Binary files a/org.rtems.cdt.update/features/org.rtems.cdt_1.1.0.jar and /dev/null differ diff --git a/org.rtems.cdt.update/features/org.rtems.cdt_1.2.0.jar b/org.rtems.cdt.update/features/org.rtems.cdt_1.2.0.jar new file mode 100644 index 0000000..b39ec79 Binary files /dev/null and b/org.rtems.cdt.update/features/org.rtems.cdt_1.2.0.jar differ diff --git a/org.rtems.cdt.update/plugins/org.rtems.cdt_1.1.0.jar b/org.rtems.cdt.update/plugins/org.rtems.cdt_1.1.0.jar deleted file mode 100644 index dddc3bf..0000000 Binary files a/org.rtems.cdt.update/plugins/org.rtems.cdt_1.1.0.jar and /dev/null differ diff --git a/org.rtems.cdt.update/plugins/org.rtems.cdt_1.2.0.jar b/org.rtems.cdt.update/plugins/org.rtems.cdt_1.2.0.jar new file mode 100644 index 0000000..b254d95 Binary files /dev/null and b/org.rtems.cdt.update/plugins/org.rtems.cdt_1.2.0.jar differ diff --git a/org.rtems.cdt.update/site.xml b/org.rtems.cdt.update/site.xml index 18d8a7b..04a1ad1 100644 --- a/org.rtems.cdt.update/site.xml +++ b/org.rtems.cdt.update/site.xml @@ -1,6 +1,6 @@ - + diff --git a/org.rtems.cdt/META-INF/MANIFEST.MF b/org.rtems.cdt/META-INF/MANIFEST.MF index 21dd38f..35372de 100644 --- a/org.rtems.cdt/META-INF/MANIFEST.MF +++ b/org.rtems.cdt/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: RTEMS CDT Plug-in Bundle-SymbolicName: org.rtems.cdt;singleton:=true -Bundle-Version: 1.1.0 +Bundle-Version: 1.2.0 Bundle-RequiredExecutionEnvironment: J2SE-1.5 Require-Bundle: org.eclipse.cdt.managedbuilder.core, org.eclipse.swt, diff --git a/org.rtems.cdt/about.mappings b/org.rtems.cdt/about.mappings index 9bdadf0..2d62c95 100644 --- a/org.rtems.cdt/about.mappings +++ b/org.rtems.cdt/about.mappings @@ -1,3 +1,3 @@ # version number -0=1.1.0 \ No newline at end of file +0=1.2.0 \ No newline at end of file diff --git a/org.rtems.cdt/build.properties b/org.rtems.cdt/build.properties index 8b13789..e974d7c 100644 --- a/org.rtems.cdt/build.properties +++ b/org.rtems.cdt/build.properties @@ -1 +1,19 @@ +bin.includes = META-INF/,\ + plugin.xml,\ + .,\ + templates/,\ + icons/,\ + about.ini,\ + about.properties,\ + about.mappings,\ + license.html +source.. = src/ + + + + + + + + diff --git a/org.rtems.cdt/plugin.xml b/org.rtems.cdt/plugin.xml index d141430..83cb7be 100644 --- a/org.rtems.cdt/plugin.xml +++ b/org.rtems.cdt/plugin.xml @@ -389,10 +389,17 @@ + @@ -405,5 +412,11 @@ id="org.rtems.cdt.toolchain.cygwin"> + diff --git a/org.rtems.cdt/src/org/rtems/cdt/preferences/PreferencePage.java b/org.rtems.cdt/src/org/rtems/cdt/preferences/PreferencePage.java index de9cb5d..c56379a 100644 --- a/org.rtems.cdt/src/org/rtems/cdt/preferences/PreferencePage.java +++ b/org.rtems.cdt/src/org/rtems/cdt/preferences/PreferencePage.java @@ -25,7 +25,6 @@ package org.rtems.cdt.preferences; import org.eclipse.core.runtime.Platform; import org.eclipse.jface.preference.DirectoryFieldEditor; import org.eclipse.jface.preference.FieldEditorPreferencePage; -import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.ui.IWorkbenchPreferencePage; import org.eclipse.ui.IWorkbench; import org.rtems.cdt.Activator; @@ -38,7 +37,6 @@ public class PreferencePage super( GRID); setPreferenceStore( Activator.getDefault().getPreferenceStore()); setDescription( "Select the RTEMS base installation path and the board support package (BSP) installation path. This provides the default values for all projects."); - setImageDescriptor(Activator.imageDescriptorFromPlugin("org.rtems.cdt", "icons/rtems_logo-64x64.png")); } public void createFieldEditors() { diff --git a/org.rtems.cdt/templates/rtems++/include/buffer_test_io.h b/org.rtems.cdt/templates/rtems++/include/buffer_test_io.h new file mode 100644 index 0000000..aee3f53 --- /dev/null +++ b/org.rtems.cdt/templates/rtems++/include/buffer_test_io.h @@ -0,0 +1,190 @@ +/* + * Support for running the test output through a buffer + * + * $Id$ + */ + +#ifndef __BUFFER_TEST_IO_h +#define __BUFFER_TEST_IO_h + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Uncomment this to get buffered test output. When commented out, + * test output behaves as it always has and is printed using stdio. + */ + +/* #define TESTS_BUFFER_OUTPUT */ +/* #define TESTS_USE_PRINTK */ + +/* + * USE PRINTK TO MINIMIZE SIZE + */ +#if defined(TESTS_USE_PRINTK) + +#include + + #undef printf + #define printf(...) \ + do { \ + printk( __VA_ARGS__); \ + } while (0) + + #undef puts + #define puts(_s) \ + do { \ + printk( "%s\n", _s); \ + } while (0) + + #undef putchar + #define putchar(_c) \ + do { \ + printk( "%c", _c ); \ + } while (0) + + /* Do not call exit() since it closes stdin, etc and pulls in stdio code */ + #define rtems_test_exit(_s) \ + do { \ + rtems_shutdown_executive(0); \ + } while (0) + + #define FLUSH_OUTPUT() \ + do { \ + } while (0) + +/* + * BUFFER TEST OUTPUT + */ +#elif defined(TESTS_BUFFER_OUTPUT) + + #include + #include + + #define _TEST_OUTPUT_BUFFER_SIZE 2048 + extern char _test_output_buffer[_TEST_OUTPUT_BUFFER_SIZE]; + void _test_output_append(char *); + void _test_output_flush(void); + + #define rtems_test_exit(_s) \ + do { \ + _test_output_flush(); \ + exit(_s); \ + } while (0) + + #undef printf + #define printf(...) \ + do { \ + char _buffer[128]; \ + sprintf( _buffer, __VA_ARGS__); \ + _test_output_append( _buffer ); \ + } while (0) + + #undef puts + #define puts(_string) \ + do { \ + char _buffer[128]; \ + sprintf( _buffer, "%s\n", _string ); \ + _test_output_append( _buffer ); \ + } while (0) + + #undef putchar + #define putchar(_c) \ + do { \ + char _buffer[2]; \ + _buffer[0] = _c; \ + _buffer[1] = '\0'; \ + _test_output_append( _buffer ); \ + } while (0) + + /* we write to stderr when there is a pause() */ + #define FLUSH_OUTPUT() _test_output_flush() + + #if defined(TEST_INIT) || defined(CONFIGURE_INIT) + + char _test_output_buffer[_TEST_OUTPUT_BUFFER_SIZE]; + int _test_output_buffer_index = 0; + + void _test_output_append(char *_buffer) + { + char *p; + + for ( p=_buffer ; *p ; p++ ) { + _test_output_buffer[_test_output_buffer_index++] = *p; + _test_output_buffer[_test_output_buffer_index] = '\0'; + #if 0 + if ( *p == '\n' ) { + fprintf( stderr, "BUFFER -- %s", _test_output_buffer ); + _test_output_buffer_index = 0; + _test_output_buffer[0] = '\0'; + } + #endif + if ( _test_output_buffer_index >= (_TEST_OUTPUT_BUFFER_SIZE - 80) ) + _test_output_flush(); + } + } + + #include + #include + + void _test_output_flush(void) + { + fprintf( stderr, "%s", _test_output_buffer ); + _test_output_buffer_index = 0; + tcdrain( 2 ); + } + + #endif +/* + * USE IPRINT + */ +#else + + #include + #include + + /* do not use iprintf if strict ansi mode */ + #if defined(_NEWLIB_VERSION) && !defined(__STRICT_ANSI__) + #undef printf + #define printf(...) \ + do { \ + fiprintf( stderr, __VA_ARGS__ ); \ + } while (0) + #else + #undef printf + #define printf(...) \ + do { \ + fprintf( stderr, __VA_ARGS__ ); \ + } while (0) + #endif + + #undef puts + #define puts(_s) \ + do { \ + printf( "%s\n", _s ); \ + } while (0) + + #undef putchar + #define putchar(_c) \ + do { \ + printf( "%c", _c ); \ + } while (0) + + #define rtems_test_exit(_s) \ + do { \ + exit(_s); \ + } while (0) + + #define FLUSH_OUTPUT() \ + do { \ + fflush(stdout); \ + } while (0) + +#endif + +#ifdef __cplusplus +}; +#endif + +#endif diff --git a/org.rtems.cdt/templates/rtems++/include/tmacros.h b/org.rtems.cdt/templates/rtems++/include/tmacros.h new file mode 100644 index 0000000..71792bd --- /dev/null +++ b/org.rtems.cdt/templates/rtems++/include/tmacros.h @@ -0,0 +1,260 @@ +/* tmacros.h + * + * This include file contains macros which are useful in the RTEMS + * test suites. + * + * COPYRIGHT (c) 1989-2008. + * 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 __TMACROS_h +#define __TMACROS_h + +#ifdef __cplusplus +extern "C" { +#endif + +#include /* includes */ + +#include +#include +#include +#include +#include +#include + +#define FOREVER 1 /* infinite loop */ + +#ifdef CONFIGURE_INIT +#define TEST_EXTERN +#else +#define TEST_EXTERN extern +#endif + +#include + +/* + * Check that that the dispatch disable level is proper for the + * mode/state of the test. Normally it should be 0 when in task space. + */ + +#define check_dispatch_disable_level( _expect ) \ + do { \ + extern volatile uint32_t _Thread_Dispatch_disable_level; \ + if ( (_expect) != -1 && _Thread_Dispatch_disable_level != (_expect) ) { \ + printf( "\n_Thread_Dispatch_disable_level is (%d) not %d\n", \ + _Thread_Dispatch_disable_level, (_expect) ); \ + FLUSH_OUTPUT(); \ + rtems_test_exit( 1 ); \ + } \ + } while ( 0 ) + +/* + * These macros properly report errors within the Classic API + */ + +#define directive_failed( _dirstat, _failmsg ) \ + fatal_directive_status( _dirstat, RTEMS_SUCCESSFUL, _failmsg ) + +#define directive_failed_with_level( _dirstat, _failmsg, _level ) \ + fatal_directive_status_with_level( \ + _dirstat, RTEMS_SUCCESSFUL, _failmsg, _level ) + +#define fatal_directive_status( _stat, _desired, _msg ) \ + fatal_directive_status_with_level( _stat, _desired, _msg, 0 ) + +#define fatal_directive_check_status_only( _stat, _desired, _msg ) \ + do { \ + if ( (_stat) != (_desired) ) { \ + printf( "\n%s FAILED -- expected (%s) got (%s)\n", \ + (_msg), rtems_status_text(_desired), rtems_status_text(_stat) ); \ + FLUSH_OUTPUT(); \ + rtems_test_exit( _stat ); \ + } \ + } while ( 0 ) + +#define fatal_directive_status_with_level( _stat, _desired, _msg, _level ) \ + do { \ + check_dispatch_disable_level( _level ); \ + fatal_directive_check_status_only( _stat, _desired, _msg ); \ + } while ( 0 ) + +/* + * These macros properly report errors from the POSIX API + */ + +#define posix_service_failed( _dirstat, _failmsg ) \ + fatal_posix_service_status( _dirstat, RTEMS_SUCCESSFUL, _failmsg ) + +#define posix_service_failed_with_level( _dirstat, _failmsg, _level ) \ + fatal_posix_service_status_with_level( \ + _dirstat, RTEMS_SUCCESSFUL, _failmsg, _level ) + +#define fatal_posix_service_status_errno( _stat, _desired, _msg ) \ + if ( (_stat != -1) && (errno) != (_desired) ) { \ + check_dispatch_disable_level( 0 ); \ + printf( "\n%s FAILED -- expected (%d - %s) got (%d %d - %s)\n", \ + (_msg), _desired, strerror(_desired), \ + _stat, errno, strerror(errno) ); \ + FLUSH_OUTPUT(); \ + rtems_test_exit( _stat ); \ + } + +#define fatal_posix_service_status( _stat, _desired, _msg ) \ + fatal_posix_service_status_with_level( _stat, _desired, _msg, 0 ) + +#define fatal_posix_service_status_with_level( _stat, _desired, _msg, _level ) \ + do { \ + check_dispatch_disable_level( _level ); \ + if ( (_stat) != (_desired) ) { \ + printf( "\n%s FAILED -- expected (%d - %s) got (%d - %s)\n", \ + (_msg), _desired, strerror(_desired), _stat, strerror(_stat) ); \ + printf( "\n FAILED -- errno (%d - %s)\n", \ + errno, strerror(errno) ); \ + FLUSH_OUTPUT(); \ + rtems_test_exit( _stat ); \ + } \ + } while ( 0 ) + +/* + * Generic integer version of the error reporting + */ + +#define int_service_failed( _dirstat, _failmsg ) \ + fatal_int_service_status( _dirstat, RTEMS_SUCCESSFUL, _failmsg ) + +#define int_service_failed_with_level( _dirstat, _failmsg, _level ) \ + fatal_int_service_status_with_level( \ + _dirstat, RTEMS_SUCCESSFUL, _failmsg, _level ) + +#define fatal_int_service_status( _stat, _desired, _msg ) \ + fatal_int_service_status_with_level( _stat, _desired, _msg, 0 ) + +#define fatal_int_service_status_with_level( _stat, _desired, _msg, _level ) \ + do { \ + check_dispatch_disable_level( _level ); \ + if ( (_stat) != (_desired) ) { \ + printf( "\n%s FAILED -- expected (%d) got (%d)\n", \ + (_msg), (_desired), (_stat) ); \ + FLUSH_OUTPUT(); \ + rtems_test_exit( _stat ); \ + } \ + } while ( 0 ) + + +/* + * Print the time + */ + +#define sprint_time(_str, _s1, _tb, _s2) \ + do { \ + sprintf( (_str), "%s%02d:%02d:%02d %02d/%02d/%04d%s", \ + _s1, (_tb)->hour, (_tb)->minute, (_tb)->second, \ + (_tb)->month, (_tb)->day, (_tb)->year, _s2 ); \ + } while ( 0 ) + +#define print_time(_s1, _tb, _s2) \ + do { \ + printf( "%s%02d:%02d:%02d %02d/%02d/%04d%s", \ + _s1, (_tb)->hour, (_tb)->minute, (_tb)->second, \ + (_tb)->month, (_tb)->day, (_tb)->year, _s2 ); \ + } while ( 0 ) + +#define put_dot( _c ) \ + do { \ + putchar( _c ); \ + FLUSH_OUTPUT(); \ + } while ( 0 ) + +#define new_line puts( "" ) + +#define puts_nocr printf + +#ifdef RTEMS_TEST_NO_PAUSE +#define rtems_test_pause() \ + do { \ + printf( "\n" ); \ + FLUSH_OUTPUT(); \ + } while ( 0 ) + +#define rtems_test_pause_and_screen_number( _screen ) \ + do { \ + printf( "\n", (_screen) ); \ + FLUSH_OUTPUT(); \ + } while ( 0 ) +#else +#define rtems_test_pause() \ + do { \ + char buffer[ 80 ]; \ + printf( "" ); \ + FLUSH_OUTPUT(); \ + gets( buffer ); \ + puts( "" ); \ + } while ( 0 ) + +#define rtems_test_pause_and_screen_number( _screen ) \ + do { \ + char buffer[ 80 ]; \ + printf( "", (_screen) ); \ + FLUSH_OUTPUT(); \ + gets( buffer ); \ + puts( "" ); \ + } while ( 0 ) +#endif + +#define put_name( name, crlf ) \ +{ uint32_t c0, c1, c2, c3; \ + c0 = (name >> 24) & 0xff; \ + c1 = (name >> 16) & 0xff; \ + c2 = (name >> 8) & 0xff; \ + c3 = name & 0xff; \ + putchar( (isprint(c0)) ? c0 : '*' ); \ + if ( c1 ) putchar( (isprint(c1)) ? c1 : '*' ); \ + if ( c2 ) putchar( (isprint(c2)) ? c2 : '*' ); \ + if ( c3 ) putchar( (isprint(c3)) ? c3 : '*' ); \ + if ( crlf ) \ + putchar( '\n' ); \ +} + +#ifndef build_time +#define build_time( TB, MON, DAY, YR, HR, MIN, SEC, TK ) \ + { (TB)->year = YR; \ + (TB)->month = MON; \ + (TB)->day = DAY; \ + (TB)->hour = HR; \ + (TB)->minute = MIN; \ + (TB)->second = SEC; \ + (TB)->ticks = TK; } +#endif + +#define task_number( tid ) \ + ( rtems_object_id_get_index( tid ) - \ + rtems_configuration_get_rtems_api_configuration()-> \ + number_of_initialization_tasks ) + +static inline uint32_t get_ticks_per_second( void ) +{ + rtems_interval ticks_per_second; + (void) rtems_clock_get( RTEMS_CLOCK_GET_TICKS_PER_SECOND, &ticks_per_second ); + return ticks_per_second; +} + +#define TICKS_PER_SECOND get_ticks_per_second() + +#define rtems_test_assert(__exp) \ + if (!(__exp)) { \ + printf( "%s: %d %s\n", __FILE__, __LINE__, #__exp ); \ + rtems_test_exit(0); \ + } + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/org.rtems.cdt/templates/rtems++/src/Init.cc b/org.rtems.cdt/templates/rtems++/src/Init.cc new file mode 100644 index 0000000..e939b22 --- /dev/null +++ b/org.rtems.cdt/templates/rtems++/src/Init.cc @@ -0,0 +1,62 @@ +/* Init + * + * This routine is the initialization task for this test program. + * + * Input parameters: + * argument - task argument + * + * Output parameters: NONE + * + * COPYRIGHT (c) 1997 + * Objective Design Systems Ltd Pty (ODS) + * All rights reserved (R) Objective Design Systems Ltd Pty + * + * COPYRIGHT (c) 1989-1999. + * 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$ + */ + +#define CONFIGURE_INIT +#include "System.h" + +// make global so it lasts past the Init task's stack's life time +Task1 task_1; + +rtems_task Init(rtems_task_argument ) +{ + puts( "\n\n*** RTEMS++ TEST ***" ); + + printf( "INIT - Task.create() - " ); + task_1.create("TA1 ", 0, RTEMS_MINIMUM_STACK_SIZE); + printf("%s\n", task_1.last_status_string()); + + printf( "INIT - Task.create() - " ); + task_1.create("TA1 ", 10, RTEMS_MINIMUM_STACK_SIZE * 6); + printf("%s\n", task_1.last_status_string()); + + printf( "INIT - Task.create() - " ); + task_1.create("TA1 ", 10, RTEMS_MINIMUM_STACK_SIZE * 6); + printf("%s\n", task_1.last_status_string()); + + printf( "INIT - Task.restart() - " ); + task_1.restart(0); + printf("%s\n", task_1.last_status_string()); + + printf( "INIT - Task.start(0xDEADDEAD) - " ); + task_1.start(0xDEADDEAD); + printf("%s\n", task_1.last_status_string()); + + printf("INIT - Destroy it's self\n"); + + // needs to be in C, no C++ object owns the Init task + rtems_status_code status = rtems_task_delete( RTEMS_SELF ); + directive_failed( status, "rtems_task_delete of RTEMS_SELF" ); +} + + + diff --git a/org.rtems.cdt/templates/rtems++/src/System.h b/org.rtems.cdt/templates/rtems++/src/System.h new file mode 100644 index 0000000..61b8716 --- /dev/null +++ b/org.rtems.cdt/templates/rtems++/src/System.h @@ -0,0 +1,135 @@ +/* system.h + * + * This include file contains information that is included in every + * function in the test set. + * + * COPYRIGHT (c) 1989-2008. + * 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 +#include +#include +#include +#include + +/* functions */ + +extern "C" +{ + rtems_task Init( + rtems_task_argument argument + ); +} + +rtems_timer_service_routine Delayed_routine( + rtems_id ignored_id, + void *ignored_address +); + +class Task1 + : public rtemsTask +{ + void print_mode(rtems_mode mode, rtems_mode mask); + + void screen1(void); + void screen2(void); + void screen3(void); + void screen4(void); + void screen5(void); + void screen6(void); + +protected: + virtual void body(rtems_task_argument argument); + +public: +}; + +class Task2 + : public rtemsTask +{ + void screen4(void); + +protected: + virtual void body(rtems_task_argument argument); + +public: + Task2(const char* name, + const rtems_task_priority initial_priority, + const uint32_t stack_size); +}; + +class Task3 + : public rtemsTask +{ + void screen6(void); + +protected: + virtual void body(rtems_task_argument argument); + +public: + Task3(const char* name, + const rtems_task_priority initial_priority, + const uint32_t stack_size); +}; + +class EndTask + : public rtemsTask +{ +protected: + virtual void body(rtems_task_argument argument); + +public: + EndTask(const char* name, + const rtems_task_priority initial_priority, + const uint32_t stack_size); +}; + +#if 0 + +// +// Not sure this can be tested in a generic manner, any ideas anyone !! +// + +class Service_routine + : public rtemsInterrupt +{ +}; + +class Io_during_interrupt + : pubic rtemsTimer +{ + +}; + +#endif + +/* configuration information */ + +#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER + +#define CONFIGURE_MAXIMUM_TASKS 8 +#define CONFIGURE_MAXIMUM_TIMERS 1 +#define CONFIGURE_MAXIMUM_SEMAPHORES 2 +#define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 1 +#define CONFIGURE_MAXIMUM_PARTITIONS 1 +#define CONFIGURE_MAXIMUM_REGIONS 1 +#define CONFIGURE_MAXIMUM_PERIODS 1 +#define CONFIGURE_MAXIMUM_USER_EXTENSIONS 0 +#define CONFIGURE_TICKS_PER_TIMESLICE 100 + +#define CONFIGURE_RTEMS_INIT_TASKS_TABLE +#define CONFIGURE_INIT_TASK_STACK_SIZE (4 * RTEMS_MINIMUM_STACK_SIZE) + +#define CONFIGURE_EXTRA_TASK_STACKS (13 * RTEMS_MINIMUM_STACK_SIZE) + +#include + +/* end of include file */ diff --git a/org.rtems.cdt/templates/rtems++/src/Task1.cc b/org.rtems.cdt/templates/rtems++/src/Task1.cc new file mode 100644 index 0000000..c4dda82 --- /dev/null +++ b/org.rtems.cdt/templates/rtems++/src/Task1.cc @@ -0,0 +1,681 @@ +/* Task1 + * + * This task is the main line for the test. It creates other + * tasks which can create + * + * Input parameters: + * argument - task argument + * + * Output parameters: NONE + * + * COPYRIGHT (c) 1997 + * Objective Design Systems Ltd Pty (ODS) + * All rights reserved (R) Objective Design Systems Ltd Pty + * + * COPYRIGHT (c) 1989-2007. + * 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 +#include +#include "System.h" + +void Task1::body(rtems_task_argument argument) +{ + rtems_test_pause_and_screen_number(1); + + printf(" * START Task Class test *\n"); + + printf("%s - test argument - ", name_string()); + if (argument != 0xDEADDEAD) + printf("argument is not 0xDEADDEAD\n"); + else + printf("argument matched\n"); + + screen1(); + rtems_test_pause_and_screen_number(2); + + screen2(); + rtems_test_pause_and_screen_number(3); + + screen3(); + rtems_test_pause_and_screen_number(4); + + screen4(); + rtems_test_pause_and_screen_number(5); + + screen5(); + rtems_test_pause_and_screen_number(6); + + screen6(); + + // do not call exit(0) from this thread as this object is static + // the static destructor call delete the task which is calling exit + // so exit never completes + + EndTask end_task("ENDT", (rtems_task_priority) 1, RTEMS_MINIMUM_STACK_SIZE * 6); + end_task.start(0); + + rtemsEvent block_me; + rtems_event_set out; + + block_me.receive(RTEMS_SIGNAL_0, out); + + printf("**** TASK 1 did not block ????\n"); +} + +void Task1::screen1(void) +{ + // create two local task objects to connect to this task + rtemsTask local_task_1 = *this; + rtemsTask local_task_2; + + local_task_2 = *this; + + // check the copy constructor works + printf("%s - copy constructor - ", name_string()); + if (local_task_1.id_is() == id_is()) + printf("local and this id's match\n"); + else + printf("local and this id's do not match\n"); + + printf("%s - copy constructor - ", name_string()); + if (local_task_1.name_is() == name_is()) + printf("local and this name's match\n"); + else + printf("local and this name's do not match\n"); + + // check the copy operator works + printf("%s - copy operator - ", name_string()); + if (local_task_2.id_is() == id_is()) + printf("local and this id's match\n"); + else + printf("local and this id's do not match\n"); + printf("%s - copy operator - ", name_string()); + if (local_task_2.name_is() == name_is()) + printf("local and this name's match\n"); + else + printf("local and this name's do not match\n"); + + // check that the owner of the id cannot delete this task + printf("%s - not owner destroy's task - ", local_task_1.name_string()); + local_task_1.destroy(); + printf("%s\n", local_task_1.last_status_string()); + + // connect to a valid task + printf("%s - connect to a local valid task name - ", local_task_2.name_string()); + local_task_2.connect("TA1 ", RTEMS_SEARCH_ALL_NODES); + printf("%s\n", local_task_2.last_status_string()); + + // connect to an invalid task + printf("%s - connect to an invalid task name - ", local_task_2.name_string()); + local_task_2.connect("BADT", RTEMS_SEARCH_ALL_NODES); + printf("%s\n", local_task_2.last_status_string()); + + // connect to a task an invalid node + printf("%s - connect to a task on an invalid node - ", local_task_2.name_string()); + local_task_2.connect("BADT", 10); + printf("%s\n", local_task_2.last_status_string()); + + // restart this task + printf("%s - restart from a non-owner - ", name_string()); + local_task_1.restart(0); + printf("%s\n", local_task_1.last_status_string()); +} + +void Task1::screen2(void) +{ + // wake after using this object + + printf("%s - wake after 0 secs - ", name_string()); + wake_after(0); + printf("%s\n", last_status_string()); + + printf("%s - wake after 500 msecs - ", name_string()); + wake_after(500000); + printf("%s\n", last_status_string()); + + printf("%s - wake after 5 secs - ", name_string()); + wake_after(5000000); + printf("%s\n", last_status_string()); + + printf("%s - wake when - to do\n", name_string()); + + rtemsTask task_1 = *this; + + // wake after using a connected object + + printf("%s - connected object wake after 0 secs - ", task_1.name_string()); + task_1.wake_after(0); + printf("%s\n", task_1.last_status_string()); + + printf("%s - connected object wake after 500 msecs - ", task_1.name_string()); + task_1.wake_after(500000); + printf("%s\n", task_1.last_status_string()); + + printf("%s - connected object wake after 5 secs - ", task_1.name_string()); + task_1.wake_after(5000000); + printf("%s\n", task_1.last_status_string()); + + printf("%s - connected object wake when - to do\n", task_1.name_string()); + + rtemsTask task_2; + + // wake after using a self object + + printf("%s - self object wake after 0 secs - ", task_2.name_string()); + task_2.wake_after(0); + printf("%s\n", task_2.last_status_string()); + + printf("%s - self object wake after 500 msecs - ", task_2.name_string()); + task_2.wake_after(500000); + printf("%s\n", task_2.last_status_string()); + + printf("%s - self object wake after 5 secs - ", task_2.name_string()); + task_2.wake_after(5000000); + printf("%s\n", task_2.last_status_string()); + + printf("%s - self object wake when - to do\n", task_2.name_string()); + + rtems_task_priority current_priority; + rtems_task_priority priority; + + // priorities with this object + + printf("%s - get priority - ", name_string()); + get_priority(current_priority); + printf("%s, priority is %i\n", last_status_string(), current_priority); + + printf("%s - set priority to 512 - ", name_string()); + set_priority(512); + printf("%s\n", last_status_string()); + + printf("%s - set priority to 25 - ", name_string()); + set_priority(25); + printf("%s\n", last_status_string()); + + printf("%s - set priority to original - ", name_string()); + set_priority(current_priority, priority); + printf("%s, priority was %i\n", last_status_string(), priority); + + // priorities with connected object + + printf("%s - connected object get priority - ", task_1.name_string()); + task_1.get_priority(current_priority); + printf("%s, priority is %i\n", task_1.last_status_string(), current_priority); + + printf("%s - connected object set priority to 512 - ", task_1.name_string()); + task_1.set_priority(512); + printf("%s\n", task_1.last_status_string()); + + printf("%s - connected object set priority to 25 - ", task_1.name_string()); + task_1.set_priority(25); + printf("%s\n", task_1.last_status_string()); + + printf("%s - connected object set priority to original - ", task_1.name_string()); + task_1.set_priority(current_priority, priority); + printf("%s, priority was %i\n", task_1.last_status_string(), priority); + + // priorities with self object + + printf("%s - self object get priority - ", task_2.name_string()); + task_2.get_priority(current_priority); + printf("%s, priority is %i\n", task_2.last_status_string(), current_priority); + + printf("%s - self object set priority to 512 - ", task_2.name_string()); + task_2.set_priority(512); + printf("%s\n", task_2.last_status_string()); + + printf("%s - self object set priority to 25 - ", task_2.name_string()); + task_2.set_priority(25); + printf("%s\n", task_2.last_status_string()); + + printf("%s - self object set priority to original - ", task_2.name_string()); + task_2.set_priority(current_priority, priority); + printf("%s, priority was %i\n", task_2.last_status_string(), priority); + + uint32_t current_note; + uint32_t note; + + // notepad registers for this object + + printf("%s - get note - ", name_string()); + get_note(0, current_note); + printf("%s, note is %i\n", last_status_string(), current_note); + + printf("%s - get with bad notepad number - ", name_string()); + get_note(100, current_note); + printf("%s, note is %i\n", last_status_string(), current_note); + + printf("%s - set note to 0xDEADBEEF - ", name_string()); + set_note(0, 0xDEADBEEF); + printf("%s\n", last_status_string()); + + printf("%s - get note - ", name_string()); + get_note(0, note); + printf("%s, note is 0x%08X\n", last_status_string(), note); + + printf("%s - set note to original value - ", name_string()); + set_note(0, current_note); + printf("%s\n", last_status_string()); + + // notepad registers for connected object + + printf("%s - connected object get note - ", task_1.name_string()); + task_1.get_note(0, current_note); + printf("%s, notepad is %i\n", task_1.last_status_string(), current_note); + + printf("%s - connected object get with bad notepad number - ", task_1.name_string()); + task_1.get_note(100, current_note); + printf("%s, note is %i\n", task_1.last_status_string(), current_note); + + printf("%s - connected object set note to 0xDEADBEEF - ", task_1.name_string()); + task_1.set_note(0, 0xDEADBEEF); + printf("%s\n", task_1.last_status_string()); + + printf("%s - connected object get note - ", task_1.name_string()); + task_1.get_note(0, note); + printf("%s, note is 0x%08X\n", task_1.last_status_string(), note); + + printf("%s - connected object set note to original value - ", task_1.name_string()); + task_1.set_note(0, current_note); + printf("%s\n", task_1.last_status_string()); + + // notepad registers for self object + + printf("%s - self object get note - ", task_2.name_string()); + task_2.get_note(0, current_note); + printf("%s, note is %i\n", task_2.last_status_string(), current_note); + + printf("%s - self object get with bad notepad number - ", task_2.name_string()); + task_2.get_note(100, current_note); + printf("%s, note is %i\n", task_2.last_status_string(), current_note); + + printf("%s - self object set note to 0xDEADBEEF - ", task_2.name_string()); + task_2.set_note(0, 0xDEADBEEF); + printf("%s\n", task_2.last_status_string()); + + printf("%s - self object get note - ", task_2.name_string()); + task_2.get_note(0, note); + printf("%s, notepad is 0x%08X\n", task_2.last_status_string(), note); + + printf("%s - self object set note to original value - ", task_2.name_string()); + task_2.set_note(0, current_note); + printf("%s\n", task_2.last_status_string()); + + printf(" * END Task Class test *\n"); +} + +#define RTEMS_ALL_MODES (RTEMS_PREEMPT_MASK | \ + RTEMS_TIMESLICE_MASK | \ + RTEMS_ASR_MASK | \ + RTEMS_INTERRUPT_MASK) + +void Task1::screen3(void) +{ + printf(" * START TaskMode Class test *\n"); + + rtemsTask self; + rtemsTaskMode task_mode; + rtems_mode current_mode; + rtems_mode mode; + + printf("%s - get mode - ", self.name_string()); + task_mode.get_mode(current_mode); + printf("%s,\n\t mode is 0x%08X, ", task_mode.last_status_string(), current_mode); + print_mode(current_mode, RTEMS_ALL_MODES); + printf("\n"); + + // PREEMPTION mode control + + printf("%s - get preemption state - ", self.name_string()); + task_mode.get_preemption_state(mode); + printf("%s,\n\t mode is 0x%08X, ", task_mode.last_status_string(), mode); + print_mode(mode, RTEMS_PREEMPT_MASK); + printf("\n"); + + printf("%s - set preemption state to RTEMS_PREEMPT - ", self.name_string()); + task_mode.set_preemption_state(RTEMS_PREEMPT); + task_mode.get_mode(mode); + printf("%s,\n\t mode is 0x%08X, ", task_mode.last_status_string(), mode); + print_mode(mode, RTEMS_ALL_MODES); + printf("\n"); + + printf("%s - set preemption state to RTEMS_NO_PREEMPT - ", self.name_string()); + task_mode.set_preemption_state(RTEMS_NO_PREEMPT); + task_mode.get_mode(mode); + printf("%s,\n\t mode is 0x%08X, ", task_mode.last_status_string(), mode); + print_mode(mode, RTEMS_ALL_MODES); + printf("\n"); + + // TIMESLICE mode control + + printf("%s - get timeslice state - ", self.name_string()); + task_mode.get_timeslice_state(mode); + printf("%s,\n\t mode is 0x%08X, ", task_mode.last_status_string(), mode); + print_mode(mode, RTEMS_TIMESLICE_MASK); + printf("\n"); + + printf("%s - set timeslice state to RTEMS_TIMESLICE - ", self.name_string()); + task_mode.set_timeslice_state(RTEMS_TIMESLICE); + task_mode.get_mode(mode); + printf("%s,\n\t mode is 0x%08X, ", task_mode.last_status_string(), mode); + print_mode(mode, RTEMS_ALL_MODES); + printf("\n"); + + printf("%s - set timeslice state to RTEMS_NO_TIMESLICE - ", self.name_string()); + task_mode.set_timeslice_state(RTEMS_NO_TIMESLICE); + task_mode.get_mode(mode); + printf("%s,\n\t mode is 0x%08X, ", task_mode.last_status_string(), mode); + print_mode(mode, RTEMS_ALL_MODES); + printf("\n"); + + // ASR mode control + + printf("%s - get asr state - ", self.name_string()); + task_mode.get_asr_state(mode); + printf("%s,\n\t mode is 0x%08X, ", task_mode.last_status_string(), mode); + print_mode(mode, RTEMS_ASR_MASK); + printf("\n"); + + printf("%s - set asr state to RTEMS_ASR - ", self.name_string()); + task_mode.set_asr_state(RTEMS_ASR); + task_mode.get_mode(mode); + printf("%s,\n\t mode is 0x%08X, ", task_mode.last_status_string(), mode); + print_mode(mode, RTEMS_ALL_MODES); + printf("\n"); + + printf("%s - set asr state to RTEMS_NO_ASR - ", self.name_string()); + task_mode.set_asr_state(RTEMS_NO_ASR); + task_mode.get_mode(mode); + printf("%s,\n\t mode is 0x%08X, ", task_mode.last_status_string(), mode); + print_mode(mode, RTEMS_ALL_MODES); + printf("\n"); + + // interrupt level control + + rtems_interrupt_level current_level; + rtems_interrupt_level level; + + printf("%s - get current interrupt level - ", self.name_string()); + task_mode.get_interrupt_level(current_level); + printf("%s, level is %i\n", task_mode.last_status_string(), current_level); + + printf("%s - set interrupt level to 102 - ", self.name_string()); + task_mode.set_interrupt_level(102); + printf("%s\n", task_mode.last_status_string()); + + printf("%s - set interrupt level to original level - ", self.name_string()); + task_mode.set_interrupt_level(current_level, level); + printf("%s, level was %i\n", task_mode.last_status_string(), level); + + printf("%s - set mode to original mode - ", self.name_string()); + task_mode.set_mode(current_mode, + RTEMS_PREEMPT_MASK | RTEMS_TIMESLICE_MASK | + RTEMS_ASR_MASK | RTEMS_INTERRUPT_MASK); + task_mode.get_mode(mode); + printf("%s,\n\t mode is 0x%08X, ", task_mode.last_status_string(), mode); + print_mode(mode, RTEMS_ALL_MODES); + printf("\n"); + + printf(" * END TaskMode Class test *\n"); +} + +void Task1::screen4(void) +{ + printf(" * START Event Class test *\n"); + + printf("%s - create task 2 - ", name_string()); + Task2 task_2("TA2", (rtems_task_priority) 9, RTEMS_MINIMUM_STACK_SIZE * 6); + printf("%s\n", task_2.last_status_string()); + + printf("%s - start task 2 - ", name_string()); + task_2.start(0); + printf("%s\n", task_2.last_status_string()); + + printf("%s - construct event connecting to task 2 - ", name_string()); + rtemsEvent event_2("TA2 "); + printf("%s\n", event_2.last_status_string()); + + // wait for task 2 to complete its timeout tests + wake_after(7000000); + + printf("%s - send event signal 0 using the task id - ", name_string()); + event_2.send(task_2.id_is(), RTEMS_SIGNAL_0); + printf("%s\n", event_2.last_status_string()); + + wake_after(1000000); + + printf("%s - send event signal 0 using the task object reference - ", name_string()); + event_2.send(task_2, RTEMS_SIGNAL_0); + printf("%s\n", event_2.last_status_string()); + + wake_after(1000000); + + printf("%s - send event signal 31 using connected id - ", name_string()); + event_2.send(RTEMS_SIGNAL_31); + printf("%s\n", event_2.last_status_string()); + + wake_after(1000000); + + rtemsEvent event_2_2; + + event_2_2.connect("TA2"); + + printf("%s - send event signal 0 and 31 - ", name_string()); + event_2_2.send(task_2, RTEMS_SIGNAL_0 | RTEMS_SIGNAL_31); + printf("%s\n", event_2_2.last_status_string()); + + printf("%s - waiting 5 secs for TA2 to finish\n", name_string()); + wake_after(500000); + + printf(" * END Event Class test *\n"); +} + +void Task1::screen5(void) +{ + printf(" * START Interrupt Class test *\n"); + + printf(" do not know a portable BSP type interrupt test\n"); + + printf(" * END Interrupt Class test *\n"); +} + +void Task1::screen6(void) +{ + printf(" * START MessageQueue Class test *\n"); + + printf("%s - construct message queue 1 with no memory error - ", name_string()); + rtemsMessageQueue mq_1("MQ1", 1000000, 1000); + printf("%s\n", mq_1.last_status_string()); + + printf("%s - construct/create message queue 2 - ", name_string()); + rtemsMessageQueue mq_2("MQ2", 4, 50); + printf("%s\n", mq_2.last_status_string()); + + const char *u1 = "normal send"; + const char *u2 = "urgent send"; + char in[100]; + size_t size; + uint32_t count; + + printf("%s - send u1 to mq_2 - ", name_string()); + mq_2.send(u1, strlen(u1) + 1); + printf("%s\n", mq_2.last_status_string()); + + printf("%s - urgent send u2 to mq_2 - ", name_string()); + mq_2.urgent(u2, strlen(u2) + 1); + printf("%s\n", mq_2.last_status_string()); + + printf("%s - create task 3_1 - ", name_string()); + Task3 task_3_1("TA31", 9, RTEMS_MINIMUM_STACK_SIZE * 6); + printf("%s\n", task_3_1.last_status_string()); + + printf("%s - start task 3_1 - ", name_string()); + task_3_1.start(0); + printf("%s\n", task_3_1.last_status_string()); + + printf("%s - create task 3_2 - ", name_string()); + Task3 task_3_2("TA32", 9, RTEMS_MINIMUM_STACK_SIZE * 6); + printf("%s\n", task_3_2.last_status_string()); + + printf("%s - start task 3_2 - ", name_string()); + task_3_2.start(0); + printf("%s\n", task_3_1.last_status_string()); + + wake_after(1000000); + + printf("%s - receive u2 on mq_2 ...\n", name_string()); fflush(stdout); + mq_2.receive(in, size, 5000000); + printf("%s - %s\n", name_string(), mq_2.last_status_string()); + + if (size == (strlen(u2) + 5)) + { + if ((strncmp(in, task_3_1.name_string(), 4) == 0) && + (strcmp(in + 4, u2) == 0)) + { + printf("%s - message u2 received correctly\n", name_string()); + } + else + { + printf("%s - message u2 received incorrectly, message='%s', size=%i\n", + name_string(), in, size); + } + } + else + printf("%s - message u2 size incorrect, size=%i\n", name_string(), size); + + printf("%s - receive u1 on mq_2 ...\n", name_string()); fflush(stdout); + mq_2.receive(in, size, 5000000); + printf("%s - %s\n", name_string(), mq_2.last_status_string()); + + if (size == (strlen(u1) + 5)) + { + if ((strncmp(in, task_3_2.name_string(), 4) == 0) && + (strcmp(in + 4, u1) == 0)) + { + printf("%s - message u1 received correctly\n", name_string()); + } + else + { + printf("%s - message u1 received incorrectly, message='%s', size=%i\n", + name_string(), in, size); + } + } + else + printf("%s - message u1 size incorrect, size=%i\n", name_string(), size); + + wake_after(3000000); + + const char *b1 = "broadcast message"; + + printf("%s - broadcast send b1 ...\n", name_string()); + mq_2.broadcast(b1, strlen(b1) + 1, count); + printf("%s - mq_2 broadcast send - %s, count=%i\n", + name_string(), mq_2.last_status_string(), count); + + wake_after(1000000); + + printf("%s - receive message b1 on mq_2 from %s...\n", + name_string(), task_3_1.name_string()); fflush(stdout); + mq_2.receive(in, size, 5000000); + printf("%s - %s\n", name_string(), mq_2.last_status_string()); + + if (size == (strlen(b1) + 5)) + { + if ((strncmp(in, task_3_1.name_string(), 4) == 0) && + (strcmp(in + 4, b1) == 0)) + { + printf("%s - message b1 received correctly\n", name_string()); + } + else + { + printf("%s - message b1 received incorrectly, message='%s'\n", + name_string(), in); + } + } + else + printf("%s - message b1 size incorrect, size=%i\n", name_string(), size); + + printf("%s - receive message b1 on mq_2 from %s...\n", + name_string(), task_3_1.name_string()); fflush(stdout); + mq_2.receive(in, size, 5000000); + printf("%s - %s\n", name_string(), mq_2.last_status_string()); + + if (size == (strlen(b1) + 5)) + { + if ((strncmp(in, task_3_2.name_string(), 4) == 0) && + (strcmp(in + 4, b1) == 0)) + { + printf("%s - message b1 received correctly\n", name_string()); + } + else + { + printf("%s - message b1 received incorrectly, message='%s', size=%i\n", + name_string(), in, size); + } + } + else + printf("%s - message b1 size incorrect, size=%i\n", name_string(), size); + + // wait for task 3_1, and 3_2 to complete their timeout tests, will + // start these after getting the broadcast message + wake_after(7000000); + + const char *f1 = "flush message"; + + printf("%s - send f1 to mq_2 - ", name_string()); + mq_2.send(f1, strlen(f1) + 1); + printf("%s\n", mq_2.last_status_string()); + + printf("%s - send f1 to mq_2 - ", name_string()); + mq_2.send(f1, strlen(f1) + 1); + printf("%s\n", mq_2.last_status_string()); + + printf("%s - send f1 to mq_2 - ", name_string()); + mq_2.send(f1, strlen(f1) + 1); + printf("%s\n", mq_2.last_status_string()); + + printf("%s - flush mq_2 - ", name_string()); + mq_2.flush(count); + printf("%s, flushed=%i\n", mq_2.last_status_string(), count); + + printf(" * END MessageQueue Class test *\n"); +} + +void Task1::print_mode(rtems_mode mode, rtems_mode mask) +{ + rtemsTaskMode task_mode; + if (mask & RTEMS_PREEMPT_MASK) + printf("RTEMS_%sPREEMPT ", + task_mode.preemption_set(mode) ? "" : "NO_"); + if (mask & RTEMS_TIMESLICE_MASK) + printf("RTEMS_%sTIMESLICE ", + task_mode.preemption_set(mode) ? "" : "NO_"); + if (mask & RTEMS_ASR_MASK) + printf("RTEMS_%sASR ", + task_mode.asr_set(mode) ? "" : "NO_"); + if (mask & RTEMS_INTERRUPT_MASK) + printf("INTMASK=%i", + mode & RTEMS_INTERRUPT_MASK); +} + +EndTask::EndTask(const char* name, + const rtems_task_priority initial_priority, + const uint32_t stack_size) + : rtemsTask(name, initial_priority, stack_size, RTEMS_NO_PREEMPT) +{ +} + +void EndTask::body(rtems_task_argument) +{ + printf("*** END OF RTEMS++ TEST ***\n"); + exit(0); +} + diff --git a/org.rtems.cdt/templates/rtems++/src/Task2.cc b/org.rtems.cdt/templates/rtems++/src/Task2.cc new file mode 100644 index 0000000..3173905 --- /dev/null +++ b/org.rtems.cdt/templates/rtems++/src/Task2.cc @@ -0,0 +1,80 @@ +/* Task_2 + * + * This routine serves as a test task. Its only purpose is to generate the + * error where a semaphore is deleted while a task is waiting for it. + * + * Input parameters: + * argument - task argument + * + * Output parameters: NONE + * + * COPYRIGHT (c) 1989-1999. + * 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 "System.h" + +Task2::Task2(const char* name, + const rtems_task_priority initial_priority, + const uint32_t stack_size) + : rtemsTask(name, initial_priority, stack_size, RTEMS_NO_PREEMPT) +{ +} + +void Task2::body(rtems_task_argument ) +{ + screen4(); + + printf("%s - destroy itself\n", name_string()); + destroy(); +} + +void Task2::screen4() +{ + rtemsEvent event; + + // block waiting for any event + rtems_event_set out; + + printf("%s - event no wait - ", name_string()); + event.receive(RTEMS_SIGNAL_0, out, 0, rtemsEvent::no_wait); + printf("%s\n", event.last_status_string()); + + printf("%s - event 5 secs timeout - ", name_string()); fflush(stdout); + event.receive(RTEMS_SIGNAL_0, out, 5000000); + printf("%s\n", event.last_status_string()); + + // send using task id + printf("%s - event wait forever for signal 0 from TA1 ....\n", name_string()); + event.receive(RTEMS_SIGNAL_0, out); + printf("%s - %s, signals out are 0x%08X\n", name_string(), event.last_status_string(), out); + + // send using task object reference + printf("%s - event wait forever for signal 0 from TA1 ....\n", name_string()); + event.receive(RTEMS_SIGNAL_0, out); + printf("%s - %s, signals out are 0x%08X\n", name_string(), event.last_status_string(), out); + + printf("%s - event wait forever for signal 31 from TA1 ....\n", name_string()); + event.receive(RTEMS_SIGNAL_31, out); + printf("%s - %s, signals out are 0x%08X\n", name_string(), event.last_status_string(), out); + + printf("%s - event wait forever for signal 0 and 31 from TA1 ....\n", name_string()); + event.receive(RTEMS_SIGNAL_0 | RTEMS_SIGNAL_31, out, 0, rtemsEvent::wait, rtemsEvent::all); + printf("%s - %s, signals out are 0x%08X\n", name_string(), event.last_status_string(), out); + + printf("%s - send event signal 1 - ", name_string()); + event.send(RTEMS_SIGNAL_1); + printf("%s\n", event.last_status_string()); + + printf("%s - event wait forever for signal 1 from TA2 - ", name_string()); + event.receive(RTEMS_SIGNAL_1, out, 0, rtemsEvent::wait, rtemsEvent::all); + printf("%s, signals out are 0x%08X\n", event.last_status_string(), out); +} + + diff --git a/org.rtems.cdt/templates/rtems++/src/Task3.cc b/org.rtems.cdt/templates/rtems++/src/Task3.cc new file mode 100644 index 0000000..25ab22c --- /dev/null +++ b/org.rtems.cdt/templates/rtems++/src/Task3.cc @@ -0,0 +1,80 @@ +/* Task_3 + * + * This routine serves as a test task. Loopback the messages and test + * timeouts + * + * Input parameters: + * argument - task argument + * + * Output parameters: NONE + * + * COPYRIGHT (c) 1989-2007. + * 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 "System.h" + +Task3::Task3(const char* name, + const rtems_task_priority initial_priority, + const uint32_t stack_size) + : rtemsTask(name, initial_priority, stack_size, RTEMS_NO_PREEMPT) +{ +} + +void Task3::body(rtems_task_argument ) +{ + screen6(); + + printf("%s - destroy itself\n", name_string()); + destroy(); +} + +void Task3::screen6() +{ + rtemsMessageQueue mq_2("MQ2"); + printf("%s - construction connect mq_2 - %s\n", name_string(), mq_2.last_status_string()); + + if (mq_2.successful()) + { + char in[100]; + char out[100]; + size_t size; + bool loopback = true; + + while (loopback) + { + printf("%s - loopback from mq_2 to mq_2 ...\n", name_string()); fflush(stdout); + + mq_2.receive(in, size); + printf("%s - mq_2 receive - %s, size=%i, message string size=%i\n", + name_string(), mq_2.last_status_string(), size, (int) strlen(in)); + if (mq_2.successful()) + { + if (size > (100 - 5)) + printf("%s - size to large\n", name_string()); + else + { + strcpy(out, name_string()); + strcpy(out + 4, in); + + printf("%s - loopback to mq_2 - ", name_string()); + mq_2.send(out, strlen(out) + 1); + printf("%s\n", mq_2.last_status_string()); + } + + if (strcmp(in, "broadcast message") == 0) + loopback = false; + else + wake_after(1500000); + } + } + } +} + + diff --git a/org.rtems.cdt/templates/rtems++/template.properties b/org.rtems.cdt/templates/rtems++/template.properties new file mode 100644 index 0000000..134458b --- /dev/null +++ b/org.rtems.cdt/templates/rtems++/template.properties @@ -0,0 +1,3 @@ +#Template Default Values +RTEMS.Cxx.Template.Label=RTEMS C++ Sample +RTEMS.Cxx.Template.Label.Description=An example exercising librtems++. diff --git a/org.rtems.cdt/templates/rtems++/template.xml b/org.rtems.cdt/templates/rtems++/template.xml new file mode 100644 index 0000000..73766b6 --- /dev/null +++ b/org.rtems.cdt/templates/rtems++/template.xml @@ -0,0 +1,90 @@ + + + -- cgit v1.2.3