From 3083373e471be76b1624e0583c5a3f2f455d41c1 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Thu, 6 Aug 2009 20:25:58 +0000 Subject: Initial import of reorganized examples. --- ChangeLog | 0 LICENSE | 23 ++ Makefile | 9 + README | 12 + SUPPORT | 22 ++ VERSION | 0 classic_api/Makefile | 9 + classic_api/classic_signal/.cvsignore | 1 + classic_api/classic_signal/Makefile | 27 +++ classic_api/classic_signal/test.c | 110 ++++++++++ classic_api/triple_period/.cvsignore | 1 + classic_api/triple_period/Makefile | 25 +++ classic_api/triple_period/init.c | 77 +++++++ classic_api/triple_period/system.h | 136 ++++++++++++ classic_api/triple_period/tasks.c | 170 +++++++++++++++ hello/Makefile | 14 ++ hello/both_hello/.cvsignore | 1 + hello/both_hello/Makefile | 27 +++ hello/both_hello/test.c | 42 ++++ hello/hello_world_c/.cvsignore | 1 + hello/hello_world_c/Makefile | 27 +++ hello/hello_world_c/test.c | 35 +++ hello/posix_hello_world/.cvsignore | 1 + hello/posix_hello_world/Makefile | 27 +++ hello/posix_hello_world/test.c | 34 +++ led/Makefile | 20 ++ led/README | 29 +++ led/complex1/.cvsignore | 1 + led/complex1/.main.cc.swp | Bin 0 -> 12243 bytes led/complex1/ChangeLog | 38 ++++ led/complex1/LocalMessageQueuePOSIX10031c.h | 326 ++++++++++++++++++++++++++++ led/complex1/Makefile | 33 +++ led/complex1/Makefile.linux | 24 ++ led/complex1/MessageQueueT.h | 122 +++++++++++ led/complex1/MessageQueueT_BASE.h | 114 ++++++++++ led/complex1/ledServer.h | 166 ++++++++++++++ led/complex1/main.cc | 63 ++++++ led/complex1/menu.cc | 196 +++++++++++++++++ led/complex1/menu.h | 80 +++++++ led/complex1/periodic.c | 119 ++++++++++ led/complex1/periodic.h | 24 ++ led/complex1/test.cc | 238 ++++++++++++++++++++ led/delay/.cvsignore | 1 + led/delay/Makefile | 27 +++ led/delay/init.c | 52 +++++ led/event_server/.cvsignore | 1 + led/event_server/Makefile | 27 +++ led/event_server/init.c | 100 +++++++++ led/led.h | 79 +++++++ led/msg_server/.cvsignore | 1 + led/msg_server/Makefile | 27 +++ led/msg_server/init.c | 110 ++++++++++ led/posix_cond_server/.cvsignore | 1 + led/posix_cond_server/Makefile | 27 +++ led/posix_cond_server/test.c | 93 ++++++++ led/posix_delay_nanosleep/.cvsignore | 1 + led/posix_delay_nanosleep/Makefile | 27 +++ led/posix_delay_nanosleep/test.c | 49 +++++ led/posix_delay_sleep/.cvsignore | 1 + led/posix_delay_sleep/Makefile | 27 +++ led/posix_delay_sleep/test.c | 45 ++++ led/posix_mutex_server/.cvsignore | 1 + led/posix_mutex_server/Makefile | 27 +++ led/posix_mutex_server/test.c | 113 ++++++++++ led/ratemon1/.cvsignore | 1 + led/ratemon1/Makefile | 27 +++ led/ratemon1/init.c | 65 ++++++ led/ratemon2/.cvsignore | 1 + led/ratemon2/Makefile | 27 +++ led/ratemon2/init.c | 76 +++++++ led/ratemon_cond_server/.cvsignore | 1 + led/ratemon_cond_server/Makefile | 27 +++ led/ratemon_cond_server/test.c | 110 ++++++++++ led/sem_server/.cvsignore | 1 + led/sem_server/Makefile | 27 +++ led/sem_server/init.c | 122 +++++++++++ led/timeout_event/.cvsignore | 1 + led/timeout_event/Makefile | 27 +++ led/timeout_event/init.c | 69 ++++++ led/timer/.cvsignore | 1 + led/timer/Makefile | 27 +++ led/timer/init.c | 135 ++++++++++++ misc/Makefile | 9 + misc/minimum/.cvsignore | 1 + misc/minimum/Makefile | 27 +++ misc/minimum/test.c | 112 ++++++++++ testmacros.h | 81 +++++++ ticker/Makefile | 10 + ticker/low_ticker/.cvsignore | 1 + ticker/low_ticker/Makefile | 27 +++ ticker/low_ticker/init.c | 90 ++++++++ ticker/low_ticker1/.cvsignore | 1 + ticker/low_ticker1/Makefile | 27 +++ ticker/low_ticker1/init.c | 87 ++++++++ ticker/low_ticker2/.cvsignore | 1 + ticker/low_ticker2/Makefile | 27 +++ ticker/low_ticker2/init.c | 80 +++++++ ticker/ticker/.cvsignore | 1 + ticker/ticker/Makefile | 27 +++ ticker/ticker/init.c | 107 +++++++++ 100 files changed, 4722 insertions(+) create mode 100644 ChangeLog create mode 100644 LICENSE create mode 100644 Makefile create mode 100644 README create mode 100644 SUPPORT create mode 100644 VERSION create mode 100644 classic_api/Makefile create mode 100644 classic_api/classic_signal/.cvsignore create mode 100644 classic_api/classic_signal/Makefile create mode 100644 classic_api/classic_signal/test.c create mode 100644 classic_api/triple_period/.cvsignore create mode 100644 classic_api/triple_period/Makefile create mode 100644 classic_api/triple_period/init.c create mode 100644 classic_api/triple_period/system.h create mode 100644 classic_api/triple_period/tasks.c create mode 100644 hello/Makefile create mode 100644 hello/both_hello/.cvsignore create mode 100644 hello/both_hello/Makefile create mode 100644 hello/both_hello/test.c create mode 100644 hello/hello_world_c/.cvsignore create mode 100644 hello/hello_world_c/Makefile create mode 100644 hello/hello_world_c/test.c create mode 100644 hello/posix_hello_world/.cvsignore create mode 100644 hello/posix_hello_world/Makefile create mode 100644 hello/posix_hello_world/test.c create mode 100644 led/Makefile create mode 100644 led/README create mode 100644 led/complex1/.cvsignore create mode 100644 led/complex1/.main.cc.swp create mode 100644 led/complex1/ChangeLog create mode 100644 led/complex1/LocalMessageQueuePOSIX10031c.h create mode 100644 led/complex1/Makefile create mode 100644 led/complex1/Makefile.linux create mode 100644 led/complex1/MessageQueueT.h create mode 100644 led/complex1/MessageQueueT_BASE.h create mode 100644 led/complex1/ledServer.h create mode 100644 led/complex1/main.cc create mode 100644 led/complex1/menu.cc create mode 100644 led/complex1/menu.h create mode 100644 led/complex1/periodic.c create mode 100644 led/complex1/periodic.h create mode 100644 led/complex1/test.cc create mode 100644 led/delay/.cvsignore create mode 100644 led/delay/Makefile create mode 100644 led/delay/init.c create mode 100644 led/event_server/.cvsignore create mode 100644 led/event_server/Makefile create mode 100644 led/event_server/init.c create mode 100644 led/led.h create mode 100644 led/msg_server/.cvsignore create mode 100644 led/msg_server/Makefile create mode 100644 led/msg_server/init.c create mode 100644 led/posix_cond_server/.cvsignore create mode 100644 led/posix_cond_server/Makefile create mode 100644 led/posix_cond_server/test.c create mode 100644 led/posix_delay_nanosleep/.cvsignore create mode 100644 led/posix_delay_nanosleep/Makefile create mode 100644 led/posix_delay_nanosleep/test.c create mode 100644 led/posix_delay_sleep/.cvsignore create mode 100644 led/posix_delay_sleep/Makefile create mode 100644 led/posix_delay_sleep/test.c create mode 100644 led/posix_mutex_server/.cvsignore create mode 100644 led/posix_mutex_server/Makefile create mode 100644 led/posix_mutex_server/test.c create mode 100644 led/ratemon1/.cvsignore create mode 100644 led/ratemon1/Makefile create mode 100644 led/ratemon1/init.c create mode 100644 led/ratemon2/.cvsignore create mode 100644 led/ratemon2/Makefile create mode 100644 led/ratemon2/init.c create mode 100644 led/ratemon_cond_server/.cvsignore create mode 100644 led/ratemon_cond_server/Makefile create mode 100644 led/ratemon_cond_server/test.c create mode 100644 led/sem_server/.cvsignore create mode 100644 led/sem_server/Makefile create mode 100644 led/sem_server/init.c create mode 100644 led/timeout_event/.cvsignore create mode 100644 led/timeout_event/Makefile create mode 100644 led/timeout_event/init.c create mode 100644 led/timer/.cvsignore create mode 100644 led/timer/Makefile create mode 100644 led/timer/init.c create mode 100644 misc/Makefile create mode 100644 misc/minimum/.cvsignore create mode 100644 misc/minimum/Makefile create mode 100644 misc/minimum/test.c create mode 100644 testmacros.h create mode 100644 ticker/Makefile create mode 100644 ticker/low_ticker/.cvsignore create mode 100644 ticker/low_ticker/Makefile create mode 100644 ticker/low_ticker/init.c create mode 100644 ticker/low_ticker1/.cvsignore create mode 100644 ticker/low_ticker1/Makefile create mode 100644 ticker/low_ticker1/init.c create mode 100644 ticker/low_ticker2/.cvsignore create mode 100644 ticker/low_ticker2/Makefile create mode 100644 ticker/low_ticker2/init.c create mode 100644 ticker/ticker/.cvsignore create mode 100644 ticker/ticker/Makefile create mode 100644 ticker/ticker/init.c diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..e69de29 diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..7487195 --- /dev/null +++ b/LICENSE @@ -0,0 +1,23 @@ +# +# $Id$ +# + LICENSE INFORMATION + +RTEMS is free software; you can redistribute it and/or modify it under +terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) any +later version. RTEMS is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. You should have received +a copy of the GNU General Public License along with RTEMS; see +file COPYING. If not, write to the Free Software Foundation, 675 +Mass Ave, Cambridge, MA 02139, USA. + +As a special exception, including RTEMS header files in a file, +instantiating RTEMS generics or templates, or linking other files +with RTEMS objects to produce an executable application, does not +by itself cause the resulting executable application to be covered +by the GNU General Public License. This exception does not +however invalidate any other reasons why the executable file might be +covered by the GNU Public License. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..058647b --- /dev/null +++ b/Makefile @@ -0,0 +1,9 @@ +# +# $Id$ +# + +include $(RTEMS_MAKEFILE_PATH)/Makefile.inc +include $(RTEMS_CUSTOM) +include $(RTEMS_ROOT)/make/directory.cfg + +SUBDIRS=classic_api hello led misc ticker diff --git a/README b/README new file mode 100644 index 0000000..972a9cb --- /dev/null +++ b/README @@ -0,0 +1,12 @@ +# +# $Id$ +# + +This is a set of example RTEMS programs. Each subdirectory +reflects a set of related examples. + +classic_api - Classic API examples (no LED) +hello - Hello World Variations +led - LED Blinker Varations +misc - Miscellaneous +ticker - Ticker Variations diff --git a/SUPPORT b/SUPPORT new file mode 100644 index 0000000..3f191fd --- /dev/null +++ b/SUPPORT @@ -0,0 +1,22 @@ +# +# $Id$ +# + +On-Line Applications Research Corporation (OAR) offers support, +customization, and training for RTEMS. Custom RTEMS development services +includes porting RTEMS to new processors and the development of custom board +support packages and device drivers. In addition, OAR is available +to assist in the development of your real-time embedded application. + +For more information, email Joel Sherrill at joel.sherrill@OARcorp.com +or contact OAR at: + +On-Line Applications Research Corporation +4910-L Corporate Drive +Huntsville AL 35805 +Voice: (205) 722-9985 +Fax: (205 722-0985 + +RTEMS maintenance and development is funded solely by RTEMS users. +The future of RTEMS depends on its user base. + diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..e69de29 diff --git a/classic_api/Makefile b/classic_api/Makefile new file mode 100644 index 0000000..f5e1477 --- /dev/null +++ b/classic_api/Makefile @@ -0,0 +1,9 @@ +# +# $Id$ +# + +include $(RTEMS_MAKEFILE_PATH)/Makefile.inc +include $(RTEMS_CUSTOM) +include $(RTEMS_ROOT)/make/directory.cfg + +SUBDIRS=classic_signal triple_period diff --git a/classic_api/classic_signal/.cvsignore b/classic_api/classic_signal/.cvsignore new file mode 100644 index 0000000..fecf58a --- /dev/null +++ b/classic_api/classic_signal/.cvsignore @@ -0,0 +1 @@ +o-optimize diff --git a/classic_api/classic_signal/Makefile b/classic_api/classic_signal/Makefile new file mode 100644 index 0000000..9fe9919 --- /dev/null +++ b/classic_api/classic_signal/Makefile @@ -0,0 +1,27 @@ +# +# $Id$ +# + +# +# RTEMS_MAKEFILE_PATH is typically set in an environment variable +# + +PGM=${ARCH}/hello.exe + +# optional managers required +MANAGERS=all + +# C source names +CSRCS = test.c +COBJS = $(CSRCS:%.c=${ARCH}/%.o) + +include $(RTEMS_MAKEFILE_PATH)/Makefile.inc +include $(RTEMS_CUSTOM) +include $(PROJECT_ROOT)/make/leaf.cfg + +OBJS= $(COBJS) $(CXXOBJS) $(ASOBJS) + +all: ${ARCH} $(PGM) + +$(PGM): $(OBJS) + $(make-exe) diff --git a/classic_api/classic_signal/test.c b/classic_api/classic_signal/test.c new file mode 100644 index 0000000..0742a93 --- /dev/null +++ b/classic_api/classic_signal/test.c @@ -0,0 +1,110 @@ +/* + * Classic API Signal to Task from ISR + * + * 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 "../../testmacros.h" + +#include +#include +#include + +volatile bool signal_sent; +volatile bool signal_processed; + +rtems_id main_task; + +void signal_handler( + rtems_signal_set signals +) +{ + signal_processed = TRUE; +} + +rtems_timer_service_routine test_signal_from_isr( + rtems_id timer, + void *arg +) +{ + rtems_status_code status; + + status = rtems_signal_send( main_task, 0x0a0b0c0d ); + + signal_sent = TRUE; +} + +rtems_task Init( + rtems_task_argument argument +) +{ + rtems_status_code status; + rtems_id timer; + rtems_interval start; + rtems_interval now; + + puts( "\n\n*** SIGNAL FROM TST TEST ***" ); + + main_task = rtems_task_self(); + + /* + * Timer used in multiple ways + */ + status = rtems_timer_create( 1, &timer ); + assert( status == RTEMS_SUCCESSFUL ); + + /* + * Get starting time + */ + status = rtems_clock_get( RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &start ); + assert( status == RTEMS_SUCCESSFUL ); + + status = rtems_signal_catch( signal_handler, RTEMS_DEFAULT_MODES ); + assert( status == RTEMS_SUCCESSFUL ); + puts( "rtems_signal_catch - handler installed" ); + + /* + * Test Signal from ISR + */ + signal_sent = FALSE; + + status = rtems_timer_fire_after( timer, 50, test_signal_from_isr, NULL ); + assert( status == RTEMS_SUCCESSFUL ); + + while (1) { + status = rtems_clock_get( RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &now ); + assert( status == RTEMS_SUCCESSFUL ); + if ( (now-start) > 100 ) { + puts( "Signal from ISR did not get processed\n" ); + exit( 0 ); + } + if ( signal_processed ) + break; + } + + puts( "Signal sent from ISR has been processed" ); + puts( "*** END OF SIGNAL FROM TSR TEST ***" ); + exit( 0 ); +} + +/* configuration information */ + +#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER + +#define CONFIGURE_RTEMS_INIT_TASKS_TABLE + +#define CONFIGURE_MAXIMUM_TASKS 1 +#define CONFIGURE_MAXIMUM_TIMERS 1 + +#define CONFIGURE_INIT + +#include diff --git a/classic_api/triple_period/.cvsignore b/classic_api/triple_period/.cvsignore new file mode 100644 index 0000000..fecf58a --- /dev/null +++ b/classic_api/triple_period/.cvsignore @@ -0,0 +1 @@ +o-optimize diff --git a/classic_api/triple_period/Makefile b/classic_api/triple_period/Makefile new file mode 100644 index 0000000..32f9eef --- /dev/null +++ b/classic_api/triple_period/Makefile @@ -0,0 +1,25 @@ +# +# $Id$ +# + +PGM=${ARCH}/triple_period.exe + +# optional managers required +MANAGERS=all + +# C source names, if any, go here -- minus the .c +CSRCS = init.c tasks.c +COBJS = $(CSRCS:%.c=${ARCH}/%.o) + +H_FILES=system.h + +OBJS=$(COBJS) + +include $(RTEMS_MAKEFILE_PATH)/Makefile.inc +include $(RTEMS_CUSTOM) +include $(RTEMS_ROOT)/make/leaf.cfg + +all: ${ARCH} $(PGM) + +${PGM}: ${OBJS} + $(make-exe) diff --git a/classic_api/triple_period/init.c b/classic_api/triple_period/init.c new file mode 100644 index 0000000..f35494a --- /dev/null +++ b/classic_api/triple_period/init.c @@ -0,0 +1,77 @@ +/* + * 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$ + */ +/* updated for triple test, 2003/11/06, Erik Adli */ + +#define CONFIGURE_INIT +#include "system.h" +#include +#include + +/* + * Keep the names and IDs in global variables so another task can use them. + */ +rtems_id Task_id[ 4 ]; /* array of task ids */ +rtems_name Task_name[ 4 ]; /* array of task names */ + +rtems_task Init( + rtems_task_argument argument +) +{ + rtems_status_code status; + rtems_time_of_day time; + uint32_t ticks_per_second, ticks_since_boot; + + puts( "\n\n\n*** PERIODIC TASKING TRIPLE TEST ***" ); + puts( "*** This demo shows three different ways of running periodic tasks ***" ); + puts( "*** It also demonstrates the CPU usage and Rate Monotonic statitistics utilities ***" ); + + rtems_clock_get( RTEMS_CLOCK_GET_TICKS_PER_SECOND, &ticks_per_second ); + printf("\nTicks per second in your system: %" PRIu32 "\n", ticks_per_second); + rtems_clock_get( RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &ticks_since_boot ); + printf("Ticks since boot: %" PRIu32 "\n\n", ticks_since_boot); + + time.year = 1988; + time.month = 12; + time.day = 31; + time.hour = 9; + time.minute = 0; + time.second = 0; + time.ticks = 0; + + status = rtems_clock_set( &time ); + + Task_name[ 1 ] = rtems_build_name( 'T', 'A', '1', ' ' ); + Task_name[ 2 ] = rtems_build_name( 'T', 'A', '2', ' ' ); + Task_name[ 3 ] = rtems_build_name( 'T', 'A', '3', ' ' ); + + // prototype: rtems_task_create( name, initial_priority, stack_size, initial_modes, attribute_set, *id ); + status = rtems_task_create( + Task_name[ 1 ], 1, RTEMS_MINIMUM_STACK_SIZE * 2, RTEMS_DEFAULT_MODES, + RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 1 ] + ); + status = rtems_task_create( + Task_name[ 2 ], 1, RTEMS_MINIMUM_STACK_SIZE * 2, RTEMS_DEFAULT_MODES, + RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 2 ] + ); + status = rtems_task_create( + Task_name[ 3 ], 1, RTEMS_MINIMUM_STACK_SIZE * 2, RTEMS_DEFAULT_MODES, + RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 3 ] + ); + + // prototype: rtems_task_start( id, entry_point, argument ); + status = rtems_task_start( Task_id[ 1 ], Task_Absolute_Period, 1 ); + status = rtems_task_start( Task_id[ 2 ], Task_Rate_Monotonic_Period, 2 ); + status = rtems_task_start( Task_id[ 3 ], Task_Relative_Period, 3 ); + + + // delete init task after starting the three working tasks + status = rtems_task_delete( RTEMS_SELF ); +} diff --git a/classic_api/triple_period/system.h b/classic_api/triple_period/system.h new file mode 100644 index 0000000..4538bf8 --- /dev/null +++ b/classic_api/triple_period/system.h @@ -0,0 +1,136 @@ +/* + * + * 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$ + */ +/* updated for triple test, 20003/11/06, Erik Adli */ + + +#include +#include + +/* functions */ + +rtems_task Init( + rtems_task_argument argument +); + +rtems_task Task_Absolute_Period( + rtems_task_argument argument +); + +rtems_task Task_Rate_Monotonic_Period( + rtems_task_argument argument +); + +rtems_task Task_Relative_Period( + rtems_task_argument argument +); + +/* global variables */ + +/* + * Keep the names and IDs in global variables so another task can use them. + */ +extern rtems_id Task_id[ 4 ]; /* array of task ids */ +extern rtems_name Task_name[ 4 ]; /* array of task names */ + + + +/* configuration information */ + +#include /* for device driver prototypes */ + +#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER + +#define CONFIGURE_MICROSECONDS_PER_TICK 500 // NB: 10 and lower gives system failure for erc32 simulator + +#define CONFIGURE_MAXIMUM_TASKS 4 + +#define CONFIGURE_EXTRA_TASK_STACKS (6 * RTEMS_MINIMUM_STACK_SIZE) + +// Needed for RM Mangager +#define CONFIGURE_MAXIMUM_PERIODS 1 + +#define CONFIGURE_RTEMS_INIT_TASKS_TABLE + + +/* Needed for erc32 simulator.. */ +/* ..for using "CPU_usage_Dump", since it uses printf("%f") if your processor has floating points) */ +/* If you want to take away FP support (to avoid heavy context switch), you must rewrite CPU_usage_Dump instead */ +#define CONFIGURE_INIT_TASK_ATTRIBUTES RTEMS_FLOATING_POINT + + +#include + +/* + * Handy macros and static inline functions + */ + +/* + * Macro to hide the ugliness of printing the time. + */ + +#define print_time(_s1, _tb, _s2) \ + do { \ + printf( "%s%02" PRIu32 ":%02" PRIu32 ":%02" PRIu32 \ + " %02" PRIu32 "/%02" PRIu32 "/%04" PRIu32 "%s", \ + _s1, (_tb)->hour, (_tb)->minute, (_tb)->second, \ + (_tb)->month, (_tb)->day, (_tb)->year, _s2 ); \ + fflush(stdout); \ + } while ( 0 ) + +/* + * Macro to print an task name that is composed of ASCII characters. + * + */ + +#define put_name( _name, _crlf ) \ + do { \ + uint32_t c0, c1, c2, c3; \ + \ + c0 = ((_name) >> 24) & 0xff; \ + c1 = ((_name) >> 16) & 0xff; \ + c2 = ((_name) >> 8) & 0xff; \ + c3 = (_name) & 0xff; \ + putchar( (char)c0 ); \ + if ( c1 ) putchar( (char)c1 ); \ + if ( c2 ) putchar( (char)c2 ); \ + if ( c3 ) putchar( (char)c3 ); \ + if ( (_crlf) ) \ + putchar( '\n' ); \ + } while (0) + +/* + * static inline routine to make obtaining ticks per second easier. + */ + +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; +} + + +/* + * This allows us to view the "Test_task" instantiations as a set + * of numbered tasks by eliminating the number of application + * tasks created. + * + * In reality, this is too complex for the purposes of this + * example. It would have been easier to pass a task argument. :) + * But it shows how rtems_id's can sometimes be used. + */ + +#define task_number( tid ) \ + ( rtems_get_index( tid ) - \ + rtems_configuration_get_rtems_api_configuration()->number_of_initialization_tasks ) + +/* end of include file */ diff --git a/classic_api/triple_period/tasks.c b/classic_api/triple_period/tasks.c new file mode 100644 index 0000000..dbf1f6e --- /dev/null +++ b/classic_api/triple_period/tasks.c @@ -0,0 +1,170 @@ +/* + * 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$ + */ +/* updated for triple test, 20003/11/06, Erik Adli */ + +#include "system.h" +#include +#include + +/* CPU usage and Rate monotonic manger statistics */ +#include "rtems/cpuuse.h" + +// Periods for the various tasks [seconds] +#define PERIOD_TASK_ABSOLUTE 1 +#define PERIOD_TASK_RATE_MONOTONIC 2 +#define PERIOD_TASK_RELATIVE 3 + + + +// TASK 1 +// +// * Absolute timing for task 1 +// * CPU usage statistics +// * Demo end criteria +// +rtems_task Task_Absolute_Period( + rtems_task_argument unused +) +{ + rtems_time_of_day time; + rtems_status_code status; + uint32_t ticks_since_boot; + uint32_t count; + + count = 0; + rtems_cpu_usage_reset(); + + while( 1 ) { + status = rtems_clock_get( RTEMS_CLOCK_GET_TOD, &time ); + count++; + + // sets end criteria for demo application (60 seconds) + if ( time.second >= 60 ) { + puts( "*** END OF PERIODIC TASKING TRIPLE TEST ***" ); + exit( 0 ); + } + + printf( + "\n\nTask 1 - activating every %d second using " + "absolute time (rtems_task_wake_when)\n", + PERIOD_TASK_ABSOLUTE + ); + print_time( " - rtems_clock_get - ", &time, "\n" ); + rtems_clock_get( RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &ticks_since_boot ); + printf(" - Ticks since boot: %" PRIu32 "\n", ticks_since_boot); + + rtems_time_of_day time; + + time.year = 1988; + time.month = 12; + time.day = 31; + time.hour = 9; + time.minute = 0; + time.second = count * PERIOD_TASK_ABSOLUTE; // Every N1 seconds + time.ticks = 0; // NB!! 'ticks' is don't care ( = does not work); rtems_task_wait_when has granularity of 1 second ( "taskwakewhen.c" nullifies time.ticks ) + + status = rtems_task_wake_when( &time ); + + // dump CPU usage every 5th period + if( 0 == (count % 5) ) { + //CPU_usage_Dump( ); // UNCOMMENT ME FOR WORKING CPU_usage_Dump + } + } +}; + + +// TASK 2 +// +// * RM schdeling for task 2 +// * Rate Monotonic usage statistics +// +rtems_task Task_Rate_Monotonic_Period( + rtems_task_argument unused +) +{ + rtems_time_of_day time; + rtems_status_code status; + uint32_t ticks_since_boot; + rtems_name my_period_name; + rtems_id RM_period; + bool is_RM_created = 0; + uint32_t count; + + count = 0; + + while( 1 ) { + status = rtems_clock_get( RTEMS_CLOCK_GET_TOD, &time ); + count++; + + printf( "\n\nTask 2 - activating every %d second using rate monotonic manager to schedule (rtems_rate_monotonic_period)\n", PERIOD_TASK_RATE_MONOTONIC); + print_time( " - rtems_clock_get - ", &time, "\n" ); + rtems_clock_get( RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &ticks_since_boot ); + printf(" - Ticks since boot: %" PRIu32 "\n", ticks_since_boot); + + if( TRUE != is_RM_created ) { + count = 0; + my_period_name = rtems_build_name( 'P', 'E', 'R', '1' ); + status = rtems_rate_monotonic_create( my_period_name, &RM_period ); + if( RTEMS_SUCCESSFUL != status ) { + printf("RM failed with status: %d\n", status); + exit(1); + } + // Initiate RM periode + status = rtems_rate_monotonic_period( RM_period, get_ticks_per_second() * PERIOD_TASK_RATE_MONOTONIC ); // Every N2 seconds + if( RTEMS_SUCCESSFUL != status ) { + printf("RM failed with status: %d\n", status); + exit(1); + } + + is_RM_created = TRUE; + } + // Block until RM period has expired + status = rtems_rate_monotonic_period( RM_period, get_ticks_per_second() * PERIOD_TASK_RATE_MONOTONIC ); // Every N2 seconds + if( RTEMS_SUCCESSFUL != status ) { + if( RTEMS_TIMEOUT != status ) { + printf("RM missed period!\n"); + } + printf("RM failed with status: %d\n", status); + exit(1); + } + + // dump Rate Monotonic usage every 5th period + if( 0 == (count % 5) ) { + ; // rtems_rate_monotonic_report_statistics(); + } + } +} + + +// TASK 3 +// +// * relative delay for task 3 +// +rtems_task Task_Relative_Period( + rtems_task_argument unused +) +{ + rtems_time_of_day time; + rtems_status_code status; + uint32_t ticks_since_boot; + + while( 1 ) { + status = rtems_clock_get( RTEMS_CLOCK_GET_TOD, &time ); + + printf( "\n\nTask 3 - activating after every %d second using relative time (rtems_task_wake_after)\n", PERIOD_TASK_RELATIVE); + print_time( " - rtems_clock_get - ", &time, "\n" ); + rtems_clock_get( RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &ticks_since_boot ); + printf(" - Ticks since boot: %" PRIu32 "\n", ticks_since_boot); // Note how the ticks are drifting with this method + + status = rtems_task_wake_after( get_ticks_per_second() * PERIOD_TASK_RELATIVE ); // Every N3 seconds + } +} + diff --git a/hello/Makefile b/hello/Makefile new file mode 100644 index 0000000..9f3b0c3 --- /dev/null +++ b/hello/Makefile @@ -0,0 +1,14 @@ +# +# $Id$ +# + +include $(RTEMS_MAKEFILE_PATH)/Makefile.inc +include $(RTEMS_CUSTOM) +include $(RTEMS_ROOT)/make/directory.cfg + +SUBDIRS=hello_world_c + +# If the POSIX API isn't enabled, we can't build these +ifeq ($(RTEMS_HAS_POSIX_API),yes) +SUBDIRS += posix_hello_world both_hello +endif diff --git a/hello/both_hello/.cvsignore b/hello/both_hello/.cvsignore new file mode 100644 index 0000000..fecf58a --- /dev/null +++ b/hello/both_hello/.cvsignore @@ -0,0 +1 @@ +o-optimize diff --git a/hello/both_hello/Makefile b/hello/both_hello/Makefile new file mode 100644 index 0000000..e9d3ea2 --- /dev/null +++ b/hello/both_hello/Makefile @@ -0,0 +1,27 @@ +# +# $Id$ +# + +# +# RTEMS_MAKEFILE_PATH is typically set in an environment variable +# + +PGM=${ARCH}/both_hello.exe + +# optional managers required +MANAGERS=all + +# C source names +CSRCS = test.c +COBJS = $(CSRCS:%.c=${ARCH}/%.o) + +include $(RTEMS_MAKEFILE_PATH)/Makefile.inc +include $(RTEMS_CUSTOM) +include $(PROJECT_ROOT)/make/leaf.cfg + +OBJS= $(COBJS) $(CXXOBJS) $(ASOBJS) + +all: ${ARCH} $(PGM) + +$(PGM): $(OBJS) + $(make-exe) diff --git a/hello/both_hello/test.c b/hello/both_hello/test.c new file mode 100644 index 0000000..f8947b9 --- /dev/null +++ b/hello/both_hello/test.c @@ -0,0 +1,42 @@ +/* + * Simple test program -- simplified version of sample test hello. + */ + +#include + +#include +#include + +rtems_task Init( + rtems_task_argument ignored +) +{ + printf( "Classic -- Hello World\n" ); + rtems_task_delete( RTEMS_SELF ); +} + +void *POSIX_Init( + void *argument +) +{ + printf( "POSIX -- Hello World\n" ); + sleep( 1 ); + exit( 0 ); +} + +/* configuration information */ + +#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER + +#define CONFIGURE_POSIX_INIT_THREAD_TABLE +#define CONFIGURE_RTEMS_INIT_TASKS_TABLE + +#define CONFIGURE_MAXIMUM_TASKS 1 +#define CONFIGURE_MAXIMUM_POSIX_THREADS 1 + +#define CONFIGURE_INIT + +#include + +/* end of file */ diff --git a/hello/hello_world_c/.cvsignore b/hello/hello_world_c/.cvsignore new file mode 100644 index 0000000..fecf58a --- /dev/null +++ b/hello/hello_world_c/.cvsignore @@ -0,0 +1 @@ +o-optimize diff --git a/hello/hello_world_c/Makefile b/hello/hello_world_c/Makefile new file mode 100644 index 0000000..9fe9919 --- /dev/null +++ b/hello/hello_world_c/Makefile @@ -0,0 +1,27 @@ +# +# $Id$ +# + +# +# RTEMS_MAKEFILE_PATH is typically set in an environment variable +# + +PGM=${ARCH}/hello.exe + +# optional managers required +MANAGERS=all + +# C source names +CSRCS = test.c +COBJS = $(CSRCS:%.c=${ARCH}/%.o) + +include $(RTEMS_MAKEFILE_PATH)/Makefile.inc +include $(RTEMS_CUSTOM) +include $(PROJECT_ROOT)/make/leaf.cfg + +OBJS= $(COBJS) $(CXXOBJS) $(ASOBJS) + +all: ${ARCH} $(PGM) + +$(PGM): $(OBJS) + $(make-exe) diff --git a/hello/hello_world_c/test.c b/hello/hello_world_c/test.c new file mode 100644 index 0000000..d9354f7 --- /dev/null +++ b/hello/hello_world_c/test.c @@ -0,0 +1,35 @@ +/* + * Simple test program -- simplified version of sample test hello. + * + * $Id$ + */ + +#include + +#include +#include + +rtems_task Init( + rtems_task_argument ignored +) +{ + printf( "\n\n*** HELLO WORLD TEST ***\n" ); + printf( "Hello World\n" ); + printf( "*** END OF HELLO WORLD TEST ***\n" ); + exit( 0 ); +} + +/* configuration information */ + +/* NOTICE: the clock driver is explicitly disabled */ +#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER + +#define CONFIGURE_RTEMS_INIT_TASKS_TABLE +#define CONFIGURE_MAXIMUM_TASKS 1 + +#define CONFIGURE_INIT + +#include + +/* end of file */ diff --git a/hello/posix_hello_world/.cvsignore b/hello/posix_hello_world/.cvsignore new file mode 100644 index 0000000..fecf58a --- /dev/null +++ b/hello/posix_hello_world/.cvsignore @@ -0,0 +1 @@ +o-optimize diff --git a/hello/posix_hello_world/Makefile b/hello/posix_hello_world/Makefile new file mode 100644 index 0000000..bc6693f --- /dev/null +++ b/hello/posix_hello_world/Makefile @@ -0,0 +1,27 @@ +# +# $Id$ +# + +# +# RTEMS_MAKEFILE_PATH is typically set in an environment variable +# + +PGM=${ARCH}/posix_hello.exe + +# optional managers required +MANAGERS=all + +# C source names +CSRCS = test.c +COBJS = $(CSRCS:%.c=${ARCH}/%.o) + +include $(RTEMS_MAKEFILE_PATH)/Makefile.inc +include $(RTEMS_CUSTOM) +include $(PROJECT_ROOT)/make/leaf.cfg + +OBJS= $(COBJS) $(CXXOBJS) $(ASOBJS) + +all: ${ARCH} $(PGM) + +$(PGM): $(OBJS) + $(make-exe) diff --git a/hello/posix_hello_world/test.c b/hello/posix_hello_world/test.c new file mode 100644 index 0000000..0386b5b --- /dev/null +++ b/hello/posix_hello_world/test.c @@ -0,0 +1,34 @@ +/* + * Simple test program -- simplified version of sample test hello. + */ + +#include + +#include +#include + +void *POSIX_Init( + void *argument +) +{ + printf( "\n\n*** HELLO WORLD TEST ***\n" ); + printf( "Hello World\n" ); + printf( "*** END OF HELLO WORLD TEST ***\n" ); + exit( 0 ); +} + +/* configuration information */ + +/* NOTICE: the clock driver is explicitly disabled */ +#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER + +#define CONFIGURE_POSIX_INIT_THREAD_TABLE + +#define CONFIGURE_MAXIMUM_POSIX_THREADS 1 + +#define CONFIGURE_INIT + +#include + +/* end of file */ diff --git a/led/Makefile b/led/Makefile new file mode 100644 index 0000000..bb165a6 --- /dev/null +++ b/led/Makefile @@ -0,0 +1,20 @@ +# +# $Id$ +# + +include $(RTEMS_MAKEFILE_PATH)/Makefile.inc +include $(RTEMS_CUSTOM) +include $(RTEMS_ROOT)/make/directory.cfg + +SUBDIRS=delay event_server msg_server sem_server ratemon1 ratemon2 \ + timeout_event + +# If the POSIX API isn't enabled, we can't build these +ifeq ($(RTEMS_HAS_POSIX_API),yes) +SUBDIRS += posix_cond_server posix_delay_sleep posix_delay_nanosleep \ + posix_mutex_server ratemon_cond_server + # This test requires POSIX and C++ + ifneq ($(CXX_FOR_TARGET),) + SUBDIRS += complex1 + endif +endif diff --git a/led/README b/led/README new file mode 100644 index 0000000..7096bfd --- /dev/null +++ b/led/README @@ -0,0 +1,29 @@ +# +# $Id$ +# + +This is a set of example RTEMS programs. Most of these programs are +demonstrations various ways to use inter-task communication to +turn and LED on and off at a fixed rate. + +You must edit led.h so it knows how to turn an LED on and off on your +target hardware. + +The example programs form a logical sequence in the following order: + +hello_world_c +posix_hello_world +ticker +delay +ratemon1 +ratemon2 +timeout_event +event_server +sem_server +msg_server +timer +cpuuse +posix_delay_nanosleep +posix_delay_sleep +posix_mutex_server + diff --git a/led/complex1/.cvsignore b/led/complex1/.cvsignore new file mode 100644 index 0000000..fecf58a --- /dev/null +++ b/led/complex1/.cvsignore @@ -0,0 +1 @@ +o-optimize diff --git a/led/complex1/.main.cc.swp b/led/complex1/.main.cc.swp new file mode 100644 index 0000000..5abb194 Binary files /dev/null and b/led/complex1/.main.cc.swp differ diff --git a/led/complex1/ChangeLog b/led/complex1/ChangeLog new file mode 100644 index 0000000..f45a0b1 --- /dev/null +++ b/led/complex1/ChangeLog @@ -0,0 +1,38 @@ +2008-11-26 Joel Sherrill + + * main.cc: Rework to avoid new GCC error: + "ISO C++ forbids taking address of function ::main" + +2008-09-26 Joel Sherrill + + * main.cc: Update STACK_CHECKER_ON to CONFIGURE_STACK_CHECKER_ENABLED. + +2008-09-26 Joel Sherrill + + * periodic.c: Change boolean to bool. + +2008-03-12 Joel Sherrill + + * LocalMessageQueuePOSIX10031c.h, test.cc: Add include files needed by + gcc 4.3 and later. + +2007-11-05 Joel Sherrill + + * test.cc: Make LEDs work on IceCube board. + +2007-11-02 Joel Sherrill + + * .cvsignore: Correct this. + +2007-11-02 Joel Sherrill + + * ChangeLog, LocalMessageQueuePOSIX10031c.h, Makefile, MessageQueueT.h, + main.cc, periodic.c, test.cc: Now builds and runs. Apparently I + forgot to merge changes from the last class. + +2004-09-22 Joel Sherrill + + * .cvsignore, ChangeLog, LocalMessageQueuePOSIX10031c.h, Makefile, + Makefile.linux, MessageQueueT.h, MessageQueueT_BASE.h, ledServer.h, + main.cc, menu.cc, menu.h, periodic.c, periodic.h, test.cc: New files. + diff --git a/led/complex1/LocalMessageQueuePOSIX10031c.h b/led/complex1/LocalMessageQueuePOSIX10031c.h new file mode 100644 index 0000000..29aa7ca --- /dev/null +++ b/led/complex1/LocalMessageQueuePOSIX10031c.h @@ -0,0 +1,326 @@ +// +// +// $Id$ +// +// + +/*! @file LocalMessageQueuePOSIX10031c.h + @brief LocalMessageQueuePOSIX10031c Specification + + This file contains the implementation of the LocalMessageQueuePOSIX10031c + template class. + */ + +#ifndef __LocalMessageQueuePOSIX10031c_h +#define __LocalMessageQueuePOSIX10031c_h + +#include +#include +#include + +namespace OSWrapper { + /*! @class LocalMessageQueuePOSIX10031c + @brief POSIX10031c Message Queue Class + + Message queues allow application threads and processes to send + messages amongst themselves. Threads may block waiting for a + message to arrive. + + This is a POSIX10031c implementation of a Message Queue class. It is + useful for initial porting efforts and as a template for new + implementations. It is intended for internal consumption by the + implementation and is not expected to be used by applications. + */ + template< + class MessageClass + > + class LocalMessageQueuePOSIX10031c { + public: + /*! This is the constructor for the POSIX10031c Message Queue + implementation. + + @param name is the string name of the message queue + @param depth is the maximum number of pending messages + + @returns a new Message Queue + */ + LocalMessageQueuePOSIX10031c( + std::string name, + size_t depth = INT_MAX + ) + { + int status; + + depthM = depth; + nameM = name; + + pendingM.clear(); + inactiveM.clear(); + + status = pthread_cond_init(&conditionM, NULL); + if (status) { + std::cerr << "Local MQ " << nameM << " cond init failed\n"; + throw "Local MQ cond init failed"; + } + + status = pthread_mutex_init( &mutexM, NULL ); + if ( status ) { + std::cerr << "Local MQ " << nameM << " mutex init failed\n"; + throw "Local MQ mutex init failed"; + } + } + + /*! This is the destructor for the POSIX10031c Message Queue + implementation. + */ + ~LocalMessageQueuePOSIX10031c() + { + int status; + + status = pthread_cond_destroy( &conditionM ); + if (status) { + std::cerr << "Local MQ " << nameM << " cond destroy failed\n"; + throw "Local MQ cond destroy failed"; + } + + status = pthread_mutex_destroy( &mutexM ); + if ( status ) { + std::cerr << "Local MQ " << nameM << " mutex destroy failed\n"; + throw "Local MQ mutex destroy failed"; + } + + } + + /*! This method allocates a message from the inactive pool. + */ + MessageClass *Allocate( void ) + { + MessageClass *m; + + lock(); + if ( inactiveM.empty() ) { + m = new MessageClass(); + } else { + inactiveM.pop_front(); + } + unlock(); + + +// fprintf( stderr, "Allocate %p\n", m ); + return m; + } + + /*! This method returns a message to the inactive pool. + */ + void Deallocate( MessageClass *message ) + { + lock(); + inactiveM.push_back( message ); + unlock(); + } + + /*! This method sends the specified message to the queue. + + @param message is a pointer to the message buffer. + + @return true if message successfully sent + */ + bool Send( MessageClass *message ) + { + if ( !message ) + return false; + + lock(); + +// fprintf( stderr, "Send %p\n", message ); + if ( pendingM.size() >= depthM ) { + unlock(); + return false; + } + + pendingM.push_back( message ); + signal(); + + unlock(); + return true; + } + + /*! This method is invoked to block indefinitely waiting for + a message to arrive at this queue. When a message is available, + it will be returned to the caller. + + @returns the message received + */ + MessageClass *Receive( void ) + { + MessageClass *m; + + lock(); +// fprintf( stderr, "Receive start\n" ); + if ( pendingM.size() != 0 ) { + m = pendingM.front(); + } else { + do { + wait(); + if ( pendingM.size() == 0 ) + continue; + m = pendingM.front(); + } while ( !m ); + } + pendingM.pop_front(); +// fprintf( stderr, "Receiving %p\n", m ); + unlock(); + return m; + } + + /*! This method is invoked to poll for a message pending at the queue. + If a message is available, it will be returned to the caller. + + @returns the message received or NULL if none available. + */ + MessageClass *ReceivePoll( void ) + { + MessageClass *m; + + lock(); + if ( pendingM.size() == 0 ) { + m = pendingM.front(); + pendingM.pop_front(); + } else + m = NULL; + unlock(); + return m; + } + + /*! This method returns true if a message is available. + */ + bool IsAvailable( void ) + { + bool retval; + lock(); + retval = (pendingM.size() != 0); + unlock(); + + return retval; + } + + /*! This method returns a pointer to a string indicating the + implementation of this Message Queue. + + @returns a pointer to a string specifying the flavor + */ + std::string Flavor(void) + { + return "POSIX10031c"; + } + + /*! This method returns a pointer to a string indicating the name + of this Message Queue. + + @returns the name of this queue + */ + std::string Name(void) + { + return nameM; + } + + + /*! This method returns the number of messages pending on this + Message Queue. + + @returns the number of pending messages + */ + unsigned int getNumberPending(void) + { + size_t size; + + lock(); + size = pendingM.size(); + unlock(); + + return size; + } + + protected: + + /*! This method locks the mutex protecting the Message Queue. + */ + void lock(void) + { + int status; + status = pthread_mutex_lock( &mutexM ); + if ( status ) { + std::cerr << "Local MQ " << nameM << " mutex lock failed\n"; + throw "Local MQ mutex lock failed"; + } + } + + /*! This method unlocks the mutex protecting the Message Queue. + */ + void unlock(void) + { + int status; + status = pthread_mutex_unlock( &mutexM ); + if ( status ) { + std::cerr << "Local MQ " << nameM << " mutex unlock failed\n"; + throw "Local MQ mutex lock failed"; + } + } + + /*! This method signals the condition variable for the Message Queue. + */ + void signal(void) + { + int status; + status = pthread_cond_signal( &conditionM ); + if ( status ) { + std::cerr << "Local MQ " << nameM << " condvar signal failed\n"; + throw "Local MQ condvar signal failed"; + } + } + + /*! This method waits for the condition variable for the Message Queue. + */ + void wait(void) + { + int status; + status = pthread_cond_wait( &conditionM, &mutexM ); + if ( status ) { + std::cerr << "Local MQ " << nameM << " condvar wait failed\n"; + throw "Local MQ condvar wait failed"; + } + } + + /*! This variable points to the string name that the user has + associated with this message queue. The name is used by + clients and servers to locate the Message Queue. + */ + std::string nameM; + + /*! This variable contains the maximum number of pending messages + for this Message Queue. + */ + size_t depthM; + + /*! This variable contains the set of unused messages. + */ + std::list inactiveM; + + /*! This variable contains the set of pending messages. + */ + std::list pendingM; + + /*! This variable is the handle for the condition variable used to + * signal when messages are available. + */ + pthread_cond_t conditionM; + + /*! This variable is the handle for the mutex used to protect the + * Message Queue. + */ + pthread_mutex_t mutexM; + + }; +} + +#endif diff --git a/led/complex1/Makefile b/led/complex1/Makefile new file mode 100644 index 0000000..110e52b --- /dev/null +++ b/led/complex1/Makefile @@ -0,0 +1,33 @@ +# +# $Id$ +# + +# +# RTEMS_MAKEFILE_PATH is typically set in an environment variable +# + +PGM=${ARCH}/complex1.exe + +# optional managers required +MANAGERS=all + +# C source names +CSRCS = periodic.c +COBJS = $(CSRCS:%.c=${ARCH}/%.o) + +# C++ source names +CXXSRCS = main.cc menu.cc test.cc +CXXOBJS_ = $(CXXSRCS:.cc=.o) +CXXOBJS = $(CXXOBJS_:%=${ARCH}/%) + +include $(RTEMS_MAKEFILE_PATH)/Makefile.inc +LINK.c=$(CXX) +include $(RTEMS_CUSTOM) +include $(PROJECT_ROOT)/make/leaf.cfg + +OBJS= $(COBJS) $(CXXOBJS) $(ASOBJS) + +all: ${ARCH} $(PGM) + +$(PGM): $(OBJS) + $(make-exe) diff --git a/led/complex1/Makefile.linux b/led/complex1/Makefile.linux new file mode 100644 index 0000000..a1edce0 --- /dev/null +++ b/led/complex1/Makefile.linux @@ -0,0 +1,24 @@ +# +# $Id$ +# + +CXXFLAGS=-Wall +LDFLAGS=-lpthread + +PROGRAMS=example + +OBJECTS=main.o menu.o test.o + +all: $(PROGRAMS) + +main.o: main.cc +menu.o: menu.cc +test.o: test.cc + +example: $(OBJECTS) + $(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) + +clean: + rm -f core* $(PROGRAMS) *.o + +install: diff --git a/led/complex1/MessageQueueT.h b/led/complex1/MessageQueueT.h new file mode 100644 index 0000000..ae86dd1 --- /dev/null +++ b/led/complex1/MessageQueueT.h @@ -0,0 +1,122 @@ +// +// MessageQueue Template +// +// $Id$ +// + +#ifndef __MessageQueueT_OE3_h +#define __MessageQueueT_OE3_h + +#include +#include + +#include "LocalMessageQueuePOSIX10031c.h" +namespace OSWrapper { + + template< + typename QueueType + > + class MessageQueueTemplate { + public: + + typedef void (*Converter_t)( const QueueType *src, QueueType *dest ); + + private: + + typedef OSWrapper::LocalMessageQueuePOSIX10031c Queue_t; + + std::string mName; + Converter_t mHTON; + Converter_t mNTOH; + Queue_t *mQueue; + + public: + + MessageQueueTemplate( + std::string name, + unsigned int depth, + Converter_t hton_f = NULL, + Converter_t ntoh_f = NULL + ) + { + mName = name; + this->mHTON = hton_f; + this->mNTOH = ntoh_f; + + // create the message queue + mQueue = new Queue_t( name, depth ); + } + + MessageQueueTemplate() + { + // destroy the message queue object + delete mQueue; + + // destroy anything else + } + + bool IsAvailable(void) + { + return mQueue->IsAvailable(); + } + + bool Read( + QueueType *buffer + ) + { + QueueType *b; + + // MessageClass *Receive( void ) + // Get the message + try { + + b = mQueue->Receive(); + // read the message queue + if ( !b ) { + std::cerr << mName << " Queue not Read" << std::endl; + return false; + } + } catch (...) { + std::cerr << mName << " Queue not Read: Exception" << std::endl; + return false; + } + + // convert from network neutral + if ( mNTOH ) + (*mNTOH)( b, buffer ); + else + memcpy( buffer, b, sizeof(QueueType) ); + + mQueue->Deallocate( b ); + + return true; + } + + bool Write( + QueueType *buffer + ) + { + bool status; + QueueType *b = mQueue->Allocate(); + + // convert to network neutral + if ( mHTON ) { + (*mHTON)( buffer, b ); + } else { + memcpy( b, buffer, sizeof(QueueType) ); + } + + // write the message + status = mQueue->Send( b ); + if ( !status ) { + std::cerr << mName << " Queue not Written " << std::endl; + return false; + } + return true; + } + }; + +}; + + +#endif diff --git a/led/complex1/MessageQueueT_BASE.h b/led/complex1/MessageQueueT_BASE.h new file mode 100644 index 0000000..a9ac3f7 --- /dev/null +++ b/led/complex1/MessageQueueT_BASE.h @@ -0,0 +1,114 @@ +// +// MessageQueue Template Base +// +// $Id$ +// + +#ifndef __MessageQueueT_OE3_h +#define __MessageQueueT_OE3_h + +#include +#include + +namespace OSWrapper { + + template< + typename QueueType + > + class MessageQueueTemplate { + public: + + typedef void (*Converter_t)( const QueueType *src, QueueType *dest ); + + private: + + std::string mName; + Converter_t mHTON; + Converter_t mNTOH; + void *mQueue; + + public: + + MessageQueueTemplate::MessageQueueTemplate( + const char *name, + unsigned int depth, + Converter_t hton_f, + Converter_t ntoh_f + ) + { + mName = name; + this->mHTON = hton_f; + this->mNTOH = ntoh_f; + + // create the message queue + mQueue = NULL; + } + + MessageQueueTemplate::~MessageQueueTemplate() + { + // destroy the message queue object + // delete mQueue; + // destroy anything else + } + + bool MessageQueueTemplate::Read( + QueueType *buffer + ) + { + int status = 0; + QueueType tbuffer; + + // Get the message + try { + if ( mNTOH ) { + status = 1; // read into tbuffer + } else { + status = 1; // read into buffer + } + + // read the message queue + if ( status ) { + std::cerr << mName << " Queue not Read: " << status << std::endl; + return false; + } + } catch (...) { + std::cerr << mName << " Queue not Read: Exception" << std::endl; + return false; + } + + // convert from network neutral + if ( mNTOH ) + (*mNTOH)( &tbuffer, buffer ); + + return true; + } + + bool MessageQueueTemplate::Write( + QueueType *buffer + ) + { + int status = 0; + QueueType tbuffer; + QueueType *b = buffer; + + // convert to network neutral + if ( mHTON ) { + (*mHTON)( buffer, &tbuffer ); + b = &tbuffer; + } + + + // write the message + status = 1; // write( b ); + if ( status ) { + std::cerr << mName << " Queue not Written: " << status << std::endl; + return false; + } + return true; + } + }; + +}; + + +#endif diff --git a/led/complex1/ledServer.h b/led/complex1/ledServer.h new file mode 100644 index 0000000..35b7af1 --- /dev/null +++ b/led/complex1/ledServer.h @@ -0,0 +1,166 @@ +// +// $Id$ +// + +#ifndef __LED_SERVER_h +#define __LED_SERVER_h + +#include "MessageQueueT.h" + +#include +#include + +#include "../led.h" + +namespace Examples { + class LEDServer { + private: + typedef enum { + StopLED, + StartLED, + ShutdownLED, + SetRate + } Discriminator_t; + + typedef struct { + Discriminator_t discriminator; + union { + struct { + unsigned int on_period_in_milliseconds; + unsigned int off_period_in_milliseconds; + } Rate; + } Args; + } Message_t; + + typedef OSWrapper::MessageQueueTemplate LEDQ_t; + + LEDQ_t *mQueue; + pthread_t mThread; + + static void *LEDServerThread( void *arg ) + { + Examples::LEDServer *led = (Examples::LEDServer *)arg; + + return led->ThreadBody(); + } + + public: + void *ThreadBody(void) + { + bool active = false; + unsigned int ledCount = 0; + unsigned int onPeriod = 0; + unsigned int offPeriod = 0; + + Message_t m; + while ( 1 ) { + if ( mQueue->IsAvailable() ) { + mQueue->Read( &m ); + switch ( m.discriminator ) { + case StartLED: + std::cerr << "StartLED" << std::endl; + active = true; + break; + case StopLED: + std::cerr << "StopLED" << std::endl; + active = false; + break; + case SetRate: + std::cerr << "SetRate: " + << "on=" << m.Args.Rate.on_period_in_milliseconds + << " off=" << m.Args.Rate.off_period_in_milliseconds + << std::endl; + + onPeriod = m.Args.Rate.on_period_in_milliseconds; + offPeriod = m.Args.Rate.off_period_in_milliseconds; + break; + case ShutdownLED: + std::cerr << "Shutdown of LED Server requested" << std::endl; + goto thread_exit; + break; + default: + break; + } + } + if ( active ) { + struct timespec ts; + unsigned int p; + + if ( (++ledCount % 2) == 1 ) { + LED_ON(); + p = onPeriod; + } else { + LED_OFF(); + p = offPeriod; + } + + p = (p) ? p : 500; + ts.tv_sec = (p / 1000); + ts.tv_nsec = (p * 1000000) % 1000000000; + nanosleep( &ts, NULL ); + } else { + sleep(1); + } + } + thread_exit: + return NULL; + } + + public: + LEDServer() + { + int status; + + mQueue = new LEDQ_t( std::string("LEDQ"), (unsigned int) 10 ); + status = + pthread_create( &mThread, NULL, LEDServerThread, (void *)this ); + if ( status ) { + std::cerr << "LEDServer: pthread_create failed " + << status << std::endl; + } + } + + ~LEDServer() + { + Message_t msg; + + msg.discriminator = ShutdownLED; + mQueue->Write( &msg ); + sleep(1); + + delete mQueue; + } + + void start( void ) + { + Message_t msg; + + msg.discriminator = StartLED; + mQueue->Write( &msg ); + } + + void stop( void ) + { + Message_t msg; + + msg.discriminator = StopLED; + mQueue->Write( &msg ); + } + + void setPeriod( unsigned int on, unsigned int off ) + { + Message_t msg; + + if ( !on || !off ) { + std::cerr << "setPeriod: 0 period is not allowed" << std::endl; + return; + } + msg.discriminator = SetRate; + msg.Args.Rate.on_period_in_milliseconds = on; + msg.Args.Rate.off_period_in_milliseconds = off; + mQueue->Write( &msg ); + } + }; +} +#endif + diff --git a/led/complex1/main.cc b/led/complex1/main.cc new file mode 100644 index 0000000..38381f1 --- /dev/null +++ b/led/complex1/main.cc @@ -0,0 +1,63 @@ +/* + * Starting point for this example. Can be compiled on RTEMS or Linux. + * + * $Id$ + */ + + +#include +#include +#include + +extern void doTest(void); + +#if defined(__rtems__) +#include + +extern "C" { + rtems_task Init( + rtems_task_argument arg + ); +}; + +rtems_task Init( + rtems_task_argument arg +) +#else +int main( + int argc, + char **argv +) +#endif +{ + doTest(); + exit( 0 ); +} + +#if defined(__rtems__) +/* RTEMS configuration information */ + +#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER +#define CONFIGURE_MICROSECONDS_PER_TICK RTEMS_MILLISECONDS_TO_MICROSECONDS(1) + +#define CONFIGURE_RTEMS_INIT_TASKS_TABLE + +#define CONFIGURE_MAXIMUM_TASKS 102 +#define CONFIGURE_MAXIMUM_PERIODS 100 +#define CONFIGURE_MAXIMUM_POSIX_THREADS 2 +#define CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES 2 +#define CONFIGURE_MAXIMUM_POSIX_MUTEXES 2 +#define CONFIGURE_EXTRA_TASK_STACKS (32 * 1024) + +#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM +#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 20 + +#define CONFIGURE_STACK_CHECKER_ENABLED + +#define CONFIGURE_INIT + +#include +#endif + +/* end of file */ diff --git a/led/complex1/menu.cc b/led/complex1/menu.cc new file mode 100644 index 0000000..d6918ac --- /dev/null +++ b/led/complex1/menu.cc @@ -0,0 +1,196 @@ +/* + * This is a general set of routines to provide a user interface + * for testing. + * + * $Id$ + */ + +#include +#include +#include +#include + +#include "menu.h" + +int Test_menu_Get_int_bounded( + const char *str, + int min, + int max +) +{ + int selection = 0x80000000; + char Message[ 80 ]; + int i=0; + bool done = false; + char *temp; + + assert( min <= max ); + do { + if (i != 0) + printf(" Invalid Entry\n"); + + printf("\n %s (%d:%d) > ", str, min, max ); + fflush( stdout ); + fflush( stdin ); + fgets( Message, 80, stdin ); + if ((Message[0] != '\0') && (Message[0] != '\n')) { + selection = strtol( Message, &temp, 10 ); + if ((*temp == '\0') || (*temp == '\n') || (*temp == '\r') ) + if (!( selection < min || selection > max )) + done = true; + } + i++; + } + while (!done ); + + return selection; +} +int Test_menu_Get_int( + const char *str +) +{ + int selection = 0x80000000; + char Message[ 80 ]; + int i=0; + bool done = false; + char *temp; + + do { + if (i != 0) + printf(" Invalid Entry\n"); + + printf("\n %s > ", str ); + fflush( stdout ); + fflush( stdin ); + fgets( Message, 80, stdin ); + selection = strtol( Message, &temp, 10 ); + if ( *temp == '\0' ) + done = true; + i++; + } + while (!done ); + + return selection; +} + +float Test_menu_Get_float_bounded( + const char *str, + float min, + float max +) +{ + double selection = -99999999.0; + char Message[ 80 ]; + int i=0; + bool done = false; + char *temp; + + assert( min <= max ); + + do { + if (i != 0) + printf(" Invalid Entry\n"); + + printf("\n %s (%f:%f) > ", str, min, max ); + fflush( stdout ); + fflush( stdin ); + fgets( Message, 80, stdin ); + selection = strtod( Message, &temp ); + if (( *temp == '\0' ) || ( *temp == '\n' )) + if (!( selection < min || selection > max )) + done = true; + i++; + } + while (!done ); + + return (float)selection; +} + +int Test_menu_Get_selection( + const char *title, + int count, + char *selection[] +) +{ + int i; + int value; + + printf("\n %s \n ", title); + for(i=0; i<(int)strlen(title);i++) + printf("="); + printf("\n"); + + if ( count<21 ) { + for (i=0; i= count ) break; + printf(" (%2d) %-30s", i, selection[i] ); + i++; + } + } + + value = Test_menu_Get_int_bounded( + " Enter your selection> ", + 0, + count-1 + ); + + return value; +} + + +char *Test_menu_Get_string( + const char *str +) +{ + static char Message[ 500 ]; + int last; + + printf("\n Enter %s : ", str); + fgets( Message, 500, stdin ); + last = strlen( Message ); + + if (Message[last-1] == '\n') + Message[last-1] = '\0'; + + return Message; +} + +void Test_menu_run( + Test_menu *menu +) +{ + int selection; + bool done = false; + int i; + + while ( !done ) { + + printf("\n %s \n ", menu->header); + for(i=0; i<(int)strlen(menu->header);i++) + printf("="); + printf("\n"); + + for (i=0; i<(int)menu->number_of_entries; i++) + printf("\n (%d) %s", i+1, menu->entry[i].name ); + + printf("\n (0) Exit\n"); + + selection = Test_menu_Get_int_bounded( + " Enter your selection> ", + 0, + menu->number_of_entries + ); + + if ( selection == 0 ) { + // printf( "Exiting %s\n", menu->header ); + done = true; + } else { + (*menu->entry[ selection - 1 ].routine)(); + } + } +} + diff --git a/led/complex1/menu.h b/led/complex1/menu.h new file mode 100644 index 0000000..11ac9ba --- /dev/null +++ b/led/complex1/menu.h @@ -0,0 +1,80 @@ +/* + * This is a general set of routines to provide a user interface + * for testing. + * + * $Id$ + */ + +#ifndef __menu_h +#define __menu_h + +#ifdef __cplusplus +extern "C" { +#endif + + +typedef void (*test_menu_routine_t)( void ); /* Test routine */ + + typedef struct { /* entry for a test */ + const char *name; + test_menu_routine_t routine; +} Menu_entry; + + typedef struct { /* A menu */ + const char *header; + unsigned int number_of_entries; + Menu_entry *entry; +} Test_menu; + + /* + * returns an int between min and max for value described by str. + */ + +int Test_menu_Get_int_bounded( + const char *str, + int min, + int max +); + +float Test_menu_Get_float_bounded( + const char *str, + float min, + float max +); + +int Test_menu_Get_int( + char *str +); + +/* + * Returns a selection from the selection list. + */ + +int Test_menu_Get_selection( + const char *title, + int select_count, + char *selection[] +); + +/* + * Returns a user entered string. This is a static local variable. + */ + +char *Test_menu_Get_string( + const char *str +); + + /* + * Displays and processes the menu passed in. + */ + +void Test_menu_run( + Test_menu *menu +); + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/led/complex1/periodic.c b/led/complex1/periodic.c new file mode 100644 index 0000000..b57e0f0 --- /dev/null +++ b/led/complex1/periodic.c @@ -0,0 +1,119 @@ +/* + * $Id$ + */ + +#if defined(__rtems__) +#include +#include +#include "periodic.h" + +#define MAX_PERIODIC 100 + +rtems_id PeriodicThreads_Ids[100]; +rtems_id PeriodicThreads_Periods[100]; + +bool PeriodicThreads_initialized = FALSE; +bool PeriodicThreads_running = FALSE; + +unsigned int PeriodicThreads_Count = 10; + +int factorial( int i ); + +rtems_task PeriodicThreads_Body( + rtems_task_argument index +) +{ + /* int i; */ + int t = index + 1; + + fprintf( stderr, "Periodic task %d starting\n", t ); + /* this doesn't seem to dirty the stack :( */ + factorial(t * 100); + while (1) { + rtems_rate_monotonic_period( PeriodicThreads_Periods[index], t * 2 ); + /* for (i=0 ; i<(100000 * t) ; i++ ) ; */ + rtems_task_wake_after( t * 2 ); + } +} + +/* this doesn't seem to dirty the stack :( */ +int factorial( int i ) +{ + if ( i == 1 ) { + return 1; + } + return i * (i - 1); +} + +void PeriodicThreads_Initialize(void) +{ + int i; + rtems_status_code s; + rtems_name name; + char buf[6]; + + if ( PeriodicThreads_initialized ) + return; + PeriodicThreads_running = FALSE; + + for( i=0 ; i +#include "ledServer.h" +#include "menu.h" + +#include +#include +#include +#include +#include +#include +#include + +Examples::LEDServer *led; + +void StartLED(void) +{ + led->start(); +} + +void StopLED(void) +{ + led->stop(); +} + +void SetPeriodOfLED(void) +{ + unsigned int onPeriod; + unsigned int offPeriod; + onPeriod = Test_menu_Get_int_bounded( + "Length LED is ON (in milliseconds)", + 1, + 10000 + ); + offPeriod = Test_menu_Get_int_bounded( + "Length LED is OFF (in milliseconds)", + 1, + 10000 + ); + led->setPeriod( onPeriod, offPeriod ); +} + +Menu_entry LEDMenu_entries[] = { + { "Activate LED Server", StartLED }, + { "Deactivate LED Server", StopLED }, + { "Set Period of LED Server", SetPeriodOfLED }, +}; + +Test_menu LEDMenu = { + "LED Server Control Menu", + (sizeof(LEDMenu_entries) / sizeof(LEDMenu_entries[0])), + LEDMenu_entries +}; + + +/* + * Top level menu + */ + +#define MAX_FILES_IN_MENU 60 + +char *FileNames[MAX_FILES_IN_MENU]; +int FileCount = 0; +bool FileNamesLoaded = false; + +extern "C" { + // strcasecmp is not 100% portable + int Mystrcasecmp( const char *s1, const char *s2 ) + { + while (*s1 != '\0' && tolower(*s1) == tolower(*s2)) { + s1++; + s2++; + } + return tolower(*(unsigned char *) s1) - tolower(*(unsigned char *) s2); + } + + static int qsortcmp( const void *l, const void *r ) + { + char **ld = (char **)l; + char **rd = (char **)r; + + // fprintf( stderr, "-%s- -%s-\n", *ld, *rd ); + return Mystrcasecmp( *ld, *rd ); + } +}; + +int LoadDirectoryMenu(void) +{ + DIR *dir; + struct dirent *d; + + if (FileNamesLoaded) + return 0; + FileNamesLoaded = true; + + /* initialize */ + dir = opendir("."); + + if (!dir) { + fprintf( stderr, "Unable to open current directory\n" ); + return -1; + } + + /* find all the .txt files */ + + FileNames[ FileCount++ ] = strdup("Return to previous menu"); + + for ( ; ; ) { + d = readdir(dir); + if (!d) + break; + + FileNames[ FileCount++ ] = strdup( d->d_name ); + + /* fprintf( stderr, "%s\n", d->d_name ); */ + if ( FileCount >= MAX_FILES_IN_MENU ) { + fprintf( stderr, "Too many files in current directory\n" ); + return -1; + } + } + + /* shutdown */ + closedir( dir ); + + qsort( &FileNames[1], FileCount - 1, sizeof(char *), qsortcmp ); + + return 0; +} + +void LEDMenuFunction(void) +{ + Test_menu_run( &LEDMenu ); +} + +void statFile() +{ + int selected; + struct stat statb; + + if ( LoadDirectoryMenu() ) + return; + + selected = Test_menu_Get_selection( + "Select a File To stat()", + FileCount, + FileNames + ); + if ( selected == 0 ) + return; + + fprintf( stderr, + "You picked %d --> %s\n", selected, FileNames[selected] ); + + if ( stat( FileNames[selected], &statb ) ) { + fprintf( stderr, "Error stating file\n" ); + return; + } + + fprintf( stderr, "Owner/Group: %d %d Permissions: 0%o\n" + "Size... in bytes: %ld in blocks: %ld of %ld\n" + "Times of Last.. Access: %ld Modification %ld Change: %ld\n", + statb.st_uid, statb.st_gid, statb.st_mode, + (long) statb.st_size, (long) statb.st_blocks, (long) statb.st_blksize, + (long) statb.st_atime, (long) statb.st_mtime, (long) statb.st_ctime ); +} + +#if defined(__rtems__) +#include +#include +#include + +#include "periodic.h" + +void SetNumberOfPeriodicThreads(void) +{ + unsigned int threads = Test_menu_Get_int_bounded( + "How many periodic threads do you want to create", + 1, + 100 + ); + PeriodicThreads_Count = threads; +} + +Menu_entry PeriodicThreadsMenu_entries[] = { + { "Start Periodic Threads", PeriodicThreads_Start}, + { "Stop Periodic Threads", PeriodicThreads_Stop}, + { "Set Number Of Periodic Threads", SetNumberOfPeriodicThreads}, +}; + +Test_menu PeriodicThreadsMenu = { + "Periodic Threads Menu", + (sizeof(PeriodicThreadsMenu_entries) / + sizeof(PeriodicThreadsMenu_entries[0])), + PeriodicThreadsMenu_entries +}; + +void PeriodicThreadsFunction(void) +{ + Test_menu_run( &PeriodicThreadsMenu ); +} + +#endif + +Menu_entry MainMenu_entries[] = { + { "LED Server Control Menu", LEDMenuFunction }, + { "stat() a file", statFile }, +#if defined(__rtems__) + { "Periodic Threads Control Menu", PeriodicThreadsFunction }, + { "Stack Usage Report", rtems_stack_checker_report_usage }, + { "CPU Usage Report", rtems_cpu_usage_report }, + { "Reset CPU Usage Statistics", rtems_cpu_usage_reset }, + { "Period Usage Report", rtems_rate_monotonic_report_statistics }, + { "Reset Period Usage Statistics", rtems_rate_monotonic_reset_all_statistics}, +#endif +}; + +Test_menu MainMenu = { + "Main Menu", + (sizeof(MainMenu_entries) / sizeof(MainMenu_entries[0])), + MainMenu_entries +}; + +void doTest(void) +{ + LED_INIT(); + + led = new Examples::LEDServer(); + + Test_menu_run( &MainMenu ); +#if defined(__rtems__) + PeriodicThreads_Stop(); +#endif + delete led; +} + diff --git a/led/delay/.cvsignore b/led/delay/.cvsignore new file mode 100644 index 0000000..fecf58a --- /dev/null +++ b/led/delay/.cvsignore @@ -0,0 +1 @@ +o-optimize diff --git a/led/delay/Makefile b/led/delay/Makefile new file mode 100644 index 0000000..c74de73 --- /dev/null +++ b/led/delay/Makefile @@ -0,0 +1,27 @@ +# +# $Id$ +# + +# +# RTEMS_MAKEFILE_PATH is typically set in an environment variable +# + +PGM=${ARCH}/delay.exe + +# optional managers required +MANAGERS=all + +# C source names +CSRCS = init.c +COBJS = $(CSRCS:%.c=${ARCH}/%.o) + +include $(RTEMS_MAKEFILE_PATH)/Makefile.inc +include $(RTEMS_CUSTOM) +include $(PROJECT_ROOT)/make/leaf.cfg + +OBJS= $(COBJS) $(CXXOBJS) $(ASOBJS) + +all: ${ARCH} $(PGM) + +$(PGM): $(OBJS) + $(make-exe) diff --git a/led/delay/init.c b/led/delay/init.c new file mode 100644 index 0000000..373f432 --- /dev/null +++ b/led/delay/init.c @@ -0,0 +1,52 @@ +/* + * 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 "../../testmacros.h" +#include "../led.h" + +rtems_task Init( + rtems_task_argument argument +) +{ + rtems_status_code status; + + puts( "\n\n*** LED BLINKER -- task wake after ***" ); + + LED_INIT(); + + while (1) { + + (void) rtems_task_wake_after( 1 * get_ticks_per_second() ); + LED_ON(); + (void) rtems_task_wake_after( 1 * get_ticks_per_second() ); + LED_OFF(); + + } + + status = rtems_task_delete( RTEMS_SELF ); +} + +/**************** START OF CONFIGURATION INFORMATION ****************/ + +#define CONFIGURE_INIT +#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER + +#define CONFIGURE_MAXIMUM_TASKS 1 + +#define CONFIGURE_RTEMS_INIT_TASKS_TABLE + +#include + +/**************** END OF CONFIGURATION INFORMATION ****************/ diff --git a/led/event_server/.cvsignore b/led/event_server/.cvsignore new file mode 100644 index 0000000..fecf58a --- /dev/null +++ b/led/event_server/.cvsignore @@ -0,0 +1 @@ +o-optimize diff --git a/led/event_server/Makefile b/led/event_server/Makefile new file mode 100644 index 0000000..dc82e98 --- /dev/null +++ b/led/event_server/Makefile @@ -0,0 +1,27 @@ +# +# $Id$ +# + +# +# RTEMS_MAKEFILE_PATH is typically set in an environment variable +# + +PGM=${ARCH}/event_server.exe + +# optional managers required +MANAGERS=all + +# C source names +CSRCS = init.c +COBJS = $(CSRCS:%.c=${ARCH}/%.o) + +include $(RTEMS_MAKEFILE_PATH)/Makefile.inc +include $(RTEMS_CUSTOM) +include $(PROJECT_ROOT)/make/leaf.cfg + +OBJS= $(COBJS) $(CXXOBJS) $(ASOBJS) + +all: ${ARCH} $(PGM) + +$(PGM): $(OBJS) + $(make-exe) diff --git a/led/event_server/init.c b/led/event_server/init.c new file mode 100644 index 0000000..f629621 --- /dev/null +++ b/led/event_server/init.c @@ -0,0 +1,100 @@ +/* + * 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 + +#include "../../testmacros.h" +#include "../led.h" + +rtems_task Test_task( + rtems_task_argument unused +) +{ + rtems_event_set events; + rtems_status_code status; + + LED_INIT(); + + for ( ; ; ) { + events = 0; + status = rtems_event_receive( + (RTEMS_EVENT_1 | RTEMS_EVENT_2), + RTEMS_EVENT_ANY, + RTEMS_NO_TIMEOUT, + &events + ); + + if ( events == RTEMS_EVENT_1 ) { + LED_ON(); + } else if ( events == RTEMS_EVENT_2 ) { + LED_OFF(); + } else { + fprintf( stderr, "Incorrect event set 0x%08" PRIx32 "\n", events ); + } + } +} + +/* + * Keep the names and IDs in global variables so another task can use them. + */ + +rtems_id Task_id[ 4 ]; /* array of task ids */ +rtems_name Task_name[ 4 ]; /* array of task names */ + +rtems_task Init( + rtems_task_argument argument +) +{ + rtems_status_code status; + uint32_t count = 0; + rtems_event_set events; + + puts( "\n\n*** LED BLINKER -- event receive server ***" ); + + Task_name[ 1 ] = rtems_build_name( 'T', 'A', '1', ' ' ); + + status = rtems_task_create( + Task_name[ 1 ], 1, RTEMS_MINIMUM_STACK_SIZE * 2, RTEMS_DEFAULT_MODES, + RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 1 ] + ); + + status = rtems_task_start( Task_id[ 1 ], Test_task, 1 ); + + while (1) { + + events = ( (count++ % 2) == 0 ) ? RTEMS_EVENT_1 : RTEMS_EVENT_2; + status = rtems_event_send( Task_id[ 1 ], events ); + if ( status != RTEMS_SUCCESSFUL ) + fputs( "send did not work\n", stderr ); + + status = rtems_task_wake_after( get_ticks_per_second() ); + } + + status = rtems_task_delete( RTEMS_SELF ); +} + +/**************** START OF CONFIGURATION INFORMATION ****************/ + +#define CONFIGURE_INIT +#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER + +#define CONFIGURE_MAXIMUM_TASKS 2 + +#define CONFIGURE_RTEMS_INIT_TASKS_TABLE + +#define CONFIGURE_EXTRA_TASK_STACKS (RTEMS_MINIMUM_STACK_SIZE) + +#include + +/**************** END OF CONFIGURATION INFORMATION ****************/ diff --git a/led/led.h b/led/led.h new file mode 100644 index 0000000..4004248 --- /dev/null +++ b/led/led.h @@ -0,0 +1,79 @@ +/* + * LED -- simple LED support + * + * $Id$ + */ + +#ifndef __LED_h +#define __LED_h + +#define __LONG_LED + +#include + +#if defined(mbx860) + +#define MBX_LED_REG *((volatile unsigned char *)0xfa100001) + +#define LED_ON() MBX_LED_REG = 0x0F +#define LED_OFF() MBX_LED_REG = 0x00 + +#elif defined(icecube) + +#include + +#define LED_INIT() \ + do { \ + mpc5200.gpiosen |= 0x30000000; \ + mpc5200.gpiosdd |= 0x30000000; \ + } while (0) + +#define LED_ON() \ + do { \ + mpc5200.gpiosdo |= 0x30000000; \ + } while (0) + +#define LED_OFF() \ + do { \ + mpc5200.gpiosdo &= ~0x30000000; \ + } while (0) + +#elif defined(MPC8313ERDB) + +/* This rotates a single LED off around the back of 8. */ +volatile uint8_t *MPC8313_LED_REG; +uint8_t MPC8313_LED_Values[] = + { 0x01, 0x02, 0x04, 0x08, 0x80, 0x40, 0x20, 0x10}; +uint8_t MPC8313_LED_Count; + +#define LED_INIT() \ + do { \ + MPC8313_LED_REG = (uint8_t *) 0xfa000000; \ + MPC8313_LED_Count = 0; \ + } while (0) + +#define LED_ROTATE() \ + do { \ + *MPC8313_LED_REG = MPC8313_LED_Values[MPC8313_LED_Count]; \ + /* printk( "v=0x%02x ", MPC8313_LED_Values[MPC8313_LED_Count] ); */ \ + if ( ++MPC8313_LED_Count == 9 ) \ + MPC8313_LED_Count = 0; \ + } while (0) + +#define LED_ON() LED_ROTATE() +#define LED_OFF() LED_ROTATE() + +#else +/* default case is to print */ + +#define __LED_PRINTING 1 +#define LED_ON() fputs( "LED ON\n", stderr ) +#define LED_OFF() fputs( "LED OFF\n", stderr ) + +#endif + +#ifndef LED_INIT +#define LED_INIT() +#endif + +#endif diff --git a/led/msg_server/.cvsignore b/led/msg_server/.cvsignore new file mode 100644 index 0000000..fecf58a --- /dev/null +++ b/led/msg_server/.cvsignore @@ -0,0 +1 @@ +o-optimize diff --git a/led/msg_server/Makefile b/led/msg_server/Makefile new file mode 100644 index 0000000..24ce4c3 --- /dev/null +++ b/led/msg_server/Makefile @@ -0,0 +1,27 @@ +# +# $Id$ +# + +# +# RTEMS_MAKEFILE_PATH is typically set in an environment variable +# + +PGM=${ARCH}/msg_server.exe + +# optional managers required +MANAGERS=all + +# C source names +CSRCS = init.c +COBJS = $(CSRCS:%.c=${ARCH}/%.o) + +include $(RTEMS_MAKEFILE_PATH)/Makefile.inc +include $(RTEMS_CUSTOM) +include $(PROJECT_ROOT)/make/leaf.cfg + +OBJS= $(COBJS) $(CXXOBJS) $(ASOBJS) + +all: ${ARCH} $(PGM) + +$(PGM): $(OBJS) + $(make-exe) diff --git a/led/msg_server/init.c b/led/msg_server/init.c new file mode 100644 index 0000000..721aa08 --- /dev/null +++ b/led/msg_server/init.c @@ -0,0 +1,110 @@ +/* + * 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 "../../testmacros.h" +#include "../led.h" + +/* + * Keep the names and IDs in global variables so another task can use them. + */ + +rtems_id Task_id[ 4 ]; /* array of task ids */ +rtems_name Task_name[ 4 ]; /* array of task names */ +rtems_id Queue_id; + + +rtems_task Test_task( + rtems_task_argument unused +) +{ + uint32_t count; + size_t received; + rtems_status_code status; + + LED_INIT(); + + for ( ; ; ) { + count = 0xFFFFFFFF; + status = rtems_message_queue_receive( + Queue_id, + (void *) &count, + &received, + RTEMS_DEFAULT_OPTIONS, + RTEMS_NO_TIMEOUT + ); + + if ( (count % 2) == 0 ) { + LED_ON(); + } else { + LED_OFF(); + } + } +} + +rtems_task Init( + rtems_task_argument argument +) +{ + rtems_status_code status; + uint32_t count = 0; + + puts( "\n\n*** LED BLINKER -- message receive server ***" ); + + Task_name[ 1 ] = rtems_build_name( 'T', 'A', '1', ' ' ); + + status = rtems_task_create( + Task_name[ 1 ], 1, RTEMS_MINIMUM_STACK_SIZE * 2, RTEMS_DEFAULT_MODES, + RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 1 ] + ); + + status = rtems_task_start( Task_id[ 1 ], Test_task, 1 ); + + status = rtems_message_queue_create( + rtems_build_name( 'Q', '1', ' ', ' ' ), + 1, + sizeof(uint32_t), + RTEMS_DEFAULT_ATTRIBUTES, + &Queue_id + ); + while (1) { + + count++; + /* fprintf( stderr, "send 0x%d\n", count ); */ + status = rtems_message_queue_send( Queue_id, &count, sizeof(uint32_t) ); + if ( status != RTEMS_SUCCESSFUL ) + fputs( "send did not work\n", stderr ); + + status = rtems_task_wake_after( get_ticks_per_second() ); + } + + status = rtems_task_delete( RTEMS_SELF ); +} + +/**************** 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_MESSAGE_QUEUES 1 + +#define CONFIGURE_RTEMS_INIT_TASKS_TABLE + +#define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE) + +#include + +/**************** END OF CONFIGURATION INFORMATION ****************/ diff --git a/led/posix_cond_server/.cvsignore b/led/posix_cond_server/.cvsignore new file mode 100644 index 0000000..fecf58a --- /dev/null +++ b/led/posix_cond_server/.cvsignore @@ -0,0 +1 @@ +o-optimize diff --git a/led/posix_cond_server/Makefile b/led/posix_cond_server/Makefile new file mode 100644 index 0000000..690f91c --- /dev/null +++ b/led/posix_cond_server/Makefile @@ -0,0 +1,27 @@ +# +# $Id$ +# + +# +# RTEMS_MAKEFILE_PATH is typically set in an environment variable +# + +PGM=${ARCH}/posix_condvar.exe + +# optional managers required +MANAGERS=all + +# C source names +CSRCS = test.c +COBJS = $(CSRCS:%.c=${ARCH}/%.o) + +include $(RTEMS_MAKEFILE_PATH)/Makefile.inc +include $(RTEMS_CUSTOM) +include $(PROJECT_ROOT)/make/leaf.cfg + +OBJS= $(COBJS) $(CXXOBJS) $(ASOBJS) + +all: ${ARCH} $(PGM) + +$(PGM): $(OBJS) + $(make-exe) diff --git a/led/posix_cond_server/test.c b/led/posix_cond_server/test.c new file mode 100644 index 0000000..c476ed0 --- /dev/null +++ b/led/posix_cond_server/test.c @@ -0,0 +1,93 @@ +/* + * Simple test program -- simplified version of sample test hello. + */ + +#include + +#include +#include +#include +#include + +#include "../led.h" + +pthread_mutex_t Mutex; +pthread_cond_t Condition; + +void *Server( + void * ignored +) +{ + int status; + int count = 0; + + LED_INIT(); + + status = pthread_mutex_lock( &Mutex ); + if ( status ) + fprintf( stderr, "Server - lock did not work (%d)\n", status ); + + for ( ; ; ) { + + status = pthread_cond_wait( &Condition, &Mutex ); + if ( status ) + fprintf( stderr, "Server - condition wait did not work (%d)\n", status ); + + if ((++count % 2) == 0) + LED_OFF(); + else + LED_ON(); + } + return NULL; +} + +void *POSIX_Init( + void *argument +) +{ + pthread_t thread_id; + int status; + + puts( "\n\n*** LED BLINKER -- sleep with pthread condition variables ***" ); + + status = pthread_mutex_init( &Mutex, NULL ); + if (status) + fprintf( stderr, "mutex init (%d) \n", status ); + /* fprintf( stderr, "mutex id --> 0x%08x\n", Mutex ); */ + + status = pthread_cond_init( &Condition, NULL ); + if (status) + fprintf( stderr, "cond init (%d) \n", status ); + /* fprintf( stderr, "cond id --> 0x%08x\n", Condition ); */ + + status = pthread_create( &thread_id, NULL, Server, NULL ); + if (status) + fprintf( stderr, "pthread_create --> %d\n", status ); + + for ( ; ; ) { + + status = sleep( 1 ); + + status = pthread_cond_signal( &Condition ); + if ( status ) + fprintf( stderr, "Condition - signal did not work (%d)\n", status ); + } + exit( 0 ); +} + +/* configuration information */ + +#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER + +#define CONFIGURE_POSIX_INIT_THREAD_TABLE + +#define CONFIGURE_MAXIMUM_POSIX_THREADS 2 +#define CONFIGURE_MAXIMUM_POSIX_MUTEXES 1 +#define CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES 1 + +#define CONFIGURE_INIT + +#include + +/* end of file */ diff --git a/led/posix_delay_nanosleep/.cvsignore b/led/posix_delay_nanosleep/.cvsignore new file mode 100644 index 0000000..fecf58a --- /dev/null +++ b/led/posix_delay_nanosleep/.cvsignore @@ -0,0 +1 @@ +o-optimize diff --git a/led/posix_delay_nanosleep/Makefile b/led/posix_delay_nanosleep/Makefile new file mode 100644 index 0000000..d1f6715 --- /dev/null +++ b/led/posix_delay_nanosleep/Makefile @@ -0,0 +1,27 @@ +# +# $Id$ +# + +# +# RTEMS_MAKEFILE_PATH is typically set in an environment variable +# + +PGM=${ARCH}/posix_delay_nanosleep.exe + +# optional managers required +MANAGERS=all + +# C source names +CSRCS = test.c +COBJS = $(CSRCS:%.c=${ARCH}/%.o) + +include $(RTEMS_MAKEFILE_PATH)/Makefile.inc +include $(RTEMS_CUSTOM) +include $(PROJECT_ROOT)/make/leaf.cfg + +OBJS= $(COBJS) $(CXXOBJS) $(ASOBJS) + +all: ${ARCH} $(PGM) + +$(PGM): $(OBJS) + $(make-exe) diff --git a/led/posix_delay_nanosleep/test.c b/led/posix_delay_nanosleep/test.c new file mode 100644 index 0000000..7000a73 --- /dev/null +++ b/led/posix_delay_nanosleep/test.c @@ -0,0 +1,49 @@ +/* + * Simple test program -- simplified version of sample test hello. + */ + +#include + +#include +#include +#include + +#include "../led.h" + +void *POSIX_Init( + void *argument +) +{ + struct timespec delay; + + puts( "\n\n*** LED BLINKER -- nanosleep ***" ); + + LED_INIT(); + + delay.tv_sec = 1; + delay.tv_nsec = 0; + while (1) { + + (void) nanosleep( &delay, NULL ); + LED_ON(); + (void) nanosleep( &delay, NULL ); + LED_OFF(); + + } + exit( 0 ); +} + +/* configuration information */ + +#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER + +#define CONFIGURE_POSIX_INIT_THREAD_TABLE + +#define CONFIGURE_MAXIMUM_POSIX_THREADS 1 + +#define CONFIGURE_INIT + +#include + +/* end of file */ diff --git a/led/posix_delay_sleep/.cvsignore b/led/posix_delay_sleep/.cvsignore new file mode 100644 index 0000000..fecf58a --- /dev/null +++ b/led/posix_delay_sleep/.cvsignore @@ -0,0 +1 @@ +o-optimize diff --git a/led/posix_delay_sleep/Makefile b/led/posix_delay_sleep/Makefile new file mode 100644 index 0000000..d1f6715 --- /dev/null +++ b/led/posix_delay_sleep/Makefile @@ -0,0 +1,27 @@ +# +# $Id$ +# + +# +# RTEMS_MAKEFILE_PATH is typically set in an environment variable +# + +PGM=${ARCH}/posix_delay_nanosleep.exe + +# optional managers required +MANAGERS=all + +# C source names +CSRCS = test.c +COBJS = $(CSRCS:%.c=${ARCH}/%.o) + +include $(RTEMS_MAKEFILE_PATH)/Makefile.inc +include $(RTEMS_CUSTOM) +include $(PROJECT_ROOT)/make/leaf.cfg + +OBJS= $(COBJS) $(CXXOBJS) $(ASOBJS) + +all: ${ARCH} $(PGM) + +$(PGM): $(OBJS) + $(make-exe) diff --git a/led/posix_delay_sleep/test.c b/led/posix_delay_sleep/test.c new file mode 100644 index 0000000..6f34a7b --- /dev/null +++ b/led/posix_delay_sleep/test.c @@ -0,0 +1,45 @@ +/* + * Simple test program -- simplified version of sample test hello. + */ + +#include + +#include +#include +#include + +#include "../led.h" + +void *POSIX_Init( + void *argument +) +{ + puts( "\n\n*** LED BLINKER -- sleep ***" ); + + LED_INIT(); + + while (1) { + + (void) sleep( 1 ); + LED_ON(); + (void) sleep( 1 ); + LED_OFF(); + + } + exit( 0 ); +} + +/* configuration information */ + +#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER + +#define CONFIGURE_POSIX_INIT_THREAD_TABLE + +#define CONFIGURE_MAXIMUM_POSIX_THREADS 1 + +#define CONFIGURE_INIT + +#include + +/* end of file */ diff --git a/led/posix_mutex_server/.cvsignore b/led/posix_mutex_server/.cvsignore new file mode 100644 index 0000000..fecf58a --- /dev/null +++ b/led/posix_mutex_server/.cvsignore @@ -0,0 +1 @@ +o-optimize diff --git a/led/posix_mutex_server/Makefile b/led/posix_mutex_server/Makefile new file mode 100644 index 0000000..fd2239c --- /dev/null +++ b/led/posix_mutex_server/Makefile @@ -0,0 +1,27 @@ +# +# $Id$ +# + +# +# RTEMS_MAKEFILE_PATH is typically set in an environment variable +# + +PGM=${ARCH}/posix_mutex_server.exe + +# optional managers required +MANAGERS=all + +# C source names +CSRCS = test.c +COBJS = $(CSRCS:%.c=${ARCH}/%.o) + +include $(RTEMS_MAKEFILE_PATH)/Makefile.inc +include $(RTEMS_CUSTOM) +include $(PROJECT_ROOT)/make/leaf.cfg + +OBJS= $(COBJS) $(CXXOBJS) $(ASOBJS) + +all: ${ARCH} $(PGM) + +$(PGM): $(OBJS) + $(make-exe) diff --git a/led/posix_mutex_server/test.c b/led/posix_mutex_server/test.c new file mode 100644 index 0000000..ce6617a --- /dev/null +++ b/led/posix_mutex_server/test.c @@ -0,0 +1,113 @@ +/* + * Simple test program -- simplified version of sample test hello. + */ + +#include + +#include +#include +#include +#include + +#include "../led.h" + +pthread_mutex_t Mutex; + +void *Server( + void * ignored +) +{ + int status; + + LED_INIT(); + + sleep( 1 ); + + for ( ; ; ) { + status = pthread_mutex_lock( &Mutex ); + if ( status ) + fprintf( stderr, "Server - lock did not work (%d)\n", status ); + + LED_OFF(); + + status = sleep( 1 ); + + status = pthread_mutex_unlock( &Mutex ); + if ( status ) + fprintf( stderr, "Server - unlock did not work (%d)\n", status ); + + + } + return NULL; +} + +void *POSIX_Init( + void *argument +) +{ +#if defined(DEFINE_MUTEX_ATTRIBUTES) + pthread_mutexattr_t mutex_attr; +#endif + pthread_t thread_id; + int status; + + puts( "\n\n*** LED BLINKER -- pthread_mutex ***" ); + +#if defined(DEFINE_MUTEX_ATTRIBUTES) + status = pthread_mutexattr_init( &mutex_attr ); + status = pthread_mutexattr_setprotocol( &mutex_attr, PTHREAD_PRIO_INHERIT ); + status = pthread_mutexattr_setprioceiling( &mutex_attr, 128 ); + + status = pthread_mutex_init( &Mutex, &mutex_attr ); +#else + status = pthread_mutex_init( &Mutex, NULL ); +#endif + if (status) + fprintf( stderr, "mutex init (%d) \n", status ); + /* fprintf( stderr, "Mutex id --> 0x%08x\n", Mutex ); */ + + status = pthread_create( &thread_id, NULL, Server, NULL ); + if (status) + fprintf( stderr, "pthread_create --> %d\n", status ); + + status = pthread_mutex_lock( &Mutex ); + if (status) + fprintf( stderr, "Main -- first lock did not work (%d)\n", status ); + + if ( status ) + fprintf( stderr, "Main - lock did not work (%d)\n", status ); + + for ( ; ; ) { + LED_ON(); + + status = sleep( 1 ); + + status = pthread_mutex_unlock( &Mutex ); + if ( status ) + fprintf( stderr, "Main - unlock did not work (%d)\n", status ); + + status = pthread_mutex_lock( &Mutex ); + if ( status ) + fprintf( stderr, "Main - lock did not work (%d)\n", status ); + + + + } + exit( 0 ); +} + +/* configuration information */ + +#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER + +#define CONFIGURE_POSIX_INIT_THREAD_TABLE + +#define CONFIGURE_MAXIMUM_POSIX_THREADS 2 +#define CONFIGURE_MAXIMUM_POSIX_MUTEXES 1 + +#define CONFIGURE_INIT + +#include + +/* end of file */ diff --git a/led/ratemon1/.cvsignore b/led/ratemon1/.cvsignore new file mode 100644 index 0000000..fecf58a --- /dev/null +++ b/led/ratemon1/.cvsignore @@ -0,0 +1 @@ +o-optimize diff --git a/led/ratemon1/Makefile b/led/ratemon1/Makefile new file mode 100644 index 0000000..a2b130f --- /dev/null +++ b/led/ratemon1/Makefile @@ -0,0 +1,27 @@ +# +# $Id$ +# + +# +# RTEMS_MAKEFILE_PATH is typically set in an environment variable +# + +PGM=${ARCH}/ratemon1.exe + +# optional managers required +MANAGERS=all + +# C source names +CSRCS = init.c #task.c +COBJS = $(CSRCS:%.c=${ARCH}/%.o) + +include $(RTEMS_MAKEFILE_PATH)/Makefile.inc +include $(RTEMS_CUSTOM) +include $(PROJECT_ROOT)/make/leaf.cfg + +OBJS= $(COBJS) $(CXXOBJS) $(ASOBJS) + +all: ${ARCH} $(PGM) + +$(PGM): $(OBJS) + $(make-exe) diff --git a/led/ratemon1/init.c b/led/ratemon1/init.c new file mode 100644 index 0000000..c666ed3 --- /dev/null +++ b/led/ratemon1/init.c @@ -0,0 +1,65 @@ +/* + * 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 "../../testmacros.h" +#include "../led.h" + +rtems_task Init( + rtems_task_argument argument +) +{ + rtems_status_code status; + rtems_id period_id; + rtems_interval ticks; + uint32_t count; + + puts( "\n\n*** LED BLINKER -- single period ***" ); + + LED_INIT(); + + status = rtems_rate_monotonic_create( + rtems_build_name( 'P', 'E', 'R', '1' ), + &period_id + ); + + count = 0; + ticks = get_ticks_per_second(); + + while (1) { + status = rtems_rate_monotonic_period( period_id, ticks ); + if ( (++count % 2) == 0 ) + LED_ON(); + else + LED_OFF(); + } + + status = rtems_task_delete( RTEMS_SELF ); +} + +/**************** START OF CONFIGURATION INFORMATION ****************/ + +#define CONFIGURE_INIT +#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER + +#define CONFIGURE_MAXIMUM_TASKS 1 +#define CONFIGURE_MAXIMUM_PERIODS 1 + +#define CONFIGURE_RTEMS_INIT_TASKS_TABLE + +#define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE) + +#include + +/**************** END OF CONFIGURATION INFORMATION ****************/ diff --git a/led/ratemon2/.cvsignore b/led/ratemon2/.cvsignore new file mode 100644 index 0000000..fecf58a --- /dev/null +++ b/led/ratemon2/.cvsignore @@ -0,0 +1 @@ +o-optimize diff --git a/led/ratemon2/Makefile b/led/ratemon2/Makefile new file mode 100644 index 0000000..eabe66f --- /dev/null +++ b/led/ratemon2/Makefile @@ -0,0 +1,27 @@ +# +# $Id$ +# + +# +# RTEMS_MAKEFILE_PATH is typically set in an environment variable +# + +PGM=${ARCH}/ratemon2.exe + +# optional managers required +MANAGERS=all + +# C source names +CSRCS = init.c +COBJS = $(CSRCS:%.c=${ARCH}/%.o) + +include $(RTEMS_MAKEFILE_PATH)/Makefile.inc +include $(RTEMS_CUSTOM) +include $(PROJECT_ROOT)/make/leaf.cfg + +OBJS= $(COBJS) $(CXXOBJS) $(ASOBJS) + +all: ${ARCH} $(PGM) + +$(PGM): $(OBJS) + $(make-exe) diff --git a/led/ratemon2/init.c b/led/ratemon2/init.c new file mode 100644 index 0000000..167db5f --- /dev/null +++ b/led/ratemon2/init.c @@ -0,0 +1,76 @@ +/* + * 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 "../../testmacros.h" +#include "../led.h" + +rtems_task Init( + rtems_task_argument argument +) +{ + rtems_status_code status; + rtems_id period_id1; + rtems_id period_id2; + rtems_interval ticks; + + puts( "\n\n*** LED BLINKER -- two periods ***" ); + + LED_INIT(); + + status = rtems_rate_monotonic_create( + rtems_build_name( 'P', 'E', 'R', '1' ), + &period_id1 + ); + + status = rtems_rate_monotonic_create( + rtems_build_name( 'P', 'E', 'R', '2' ), + &period_id2 + ); + + ticks = get_ticks_per_second(); + + status = rtems_rate_monotonic_period( period_id1, 2 * ticks ); + LED_ON(); + + (void) rtems_task_wake_after( 1 * get_ticks_per_second() ); + status = rtems_rate_monotonic_period( period_id2, 2 * ticks ); + LED_OFF(); + + while (1) { + status = rtems_rate_monotonic_period( period_id1, 2 * ticks ); + LED_ON(); + + status = rtems_rate_monotonic_period( period_id2, 2 * ticks ); + LED_OFF(); + } + + status = rtems_task_delete( RTEMS_SELF ); +} + +/**************** 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_PERIODS 2 + +#define CONFIGURE_RTEMS_INIT_TASKS_TABLE + +#define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE) + +#include + +/**************** END OF CONFIGURATION INFORMATION ****************/ diff --git a/led/ratemon_cond_server/.cvsignore b/led/ratemon_cond_server/.cvsignore new file mode 100644 index 0000000..fecf58a --- /dev/null +++ b/led/ratemon_cond_server/.cvsignore @@ -0,0 +1 @@ +o-optimize diff --git a/led/ratemon_cond_server/Makefile b/led/ratemon_cond_server/Makefile new file mode 100644 index 0000000..e3b775b --- /dev/null +++ b/led/ratemon_cond_server/Makefile @@ -0,0 +1,27 @@ +# +# $Id$ +# + +# +# RTEMS_MAKEFILE_PATH is typically set in an environment variable +# + +PGM=${ARCH}/ratemon_cond_server.exe + +# optional managers required +MANAGERS=all + +# C source names +CSRCS = test.c +COBJS = $(CSRCS:%.c=${ARCH}/%.o) + +include $(RTEMS_MAKEFILE_PATH)/Makefile.inc +include $(RTEMS_CUSTOM) +include $(PROJECT_ROOT)/make/leaf.cfg + +OBJS= $(COBJS) $(CXXOBJS) $(ASOBJS) + +all: ${ARCH} $(PGM) + +$(PGM): $(OBJS) + $(make-exe) diff --git a/led/ratemon_cond_server/test.c b/led/ratemon_cond_server/test.c new file mode 100644 index 0000000..a481847 --- /dev/null +++ b/led/ratemon_cond_server/test.c @@ -0,0 +1,110 @@ +/* + * Simple test program -- simplified version of sample test hello. + */ + +#include + +#include +#include +#include +#include + +#include "../../testmacros.h" +#include "../led.h" + +pthread_mutex_t Mutex; +pthread_cond_t Condition; + +void *POSIX_Init( + void *argument +) +{ + int status; + int count = 0; + + LED_INIT(); + + status = pthread_mutex_lock( &Mutex ); + if ( status ) + fprintf( stderr, "Server - lock did not work (%d)\n", status ); + + for ( ; ; ) { + + status = pthread_cond_wait( &Condition, &Mutex ); + if ( status ) + fprintf( stderr, "Server - condition wait did not work (%d)\n", status ); + + if ((++count % 2) == 0) + LED_OFF(); + else + LED_ON(); + } + return NULL; +} + +rtems_task Init( + rtems_task_argument argument +) +{ + int status; + rtems_status_code rt_status; + rtems_id period_id; + rtems_interval ticks; + + puts( + "\n\n*** LED BLINKER -- rate monotonic period with " + "pthread condition variables ***" + ); + + status = pthread_mutex_init( &Mutex, NULL ); + if (status) + fprintf( stderr, "mutex init (%d) \n", status ); + /* fprintf( stderr, "mutex id --> 0x%08x\n", Mutex ); */ + + status = pthread_cond_init( &Condition, NULL ); + if (status) + fprintf( stderr, "cond init (%d) \n", status ); + /* fprintf( stderr, "cond id --> 0x%08x\n", Condition ); */ + + rt_status = rtems_rate_monotonic_create( + rtems_build_name( 'P', 'E', 'R', '1' ), + &period_id + ); + if ( rt_status ) + fprintf( stderr, "Period - did not work (%d)\n", rt_status ); + + ticks = get_ticks_per_second(); + + for ( ; ; ) { + + rt_status = rtems_rate_monotonic_period( period_id, ticks ); + if ( status ) + fprintf( stderr, "Period - did not work (%d)\n", status ); + + status = pthread_cond_signal( &Condition ); + if ( status ) + fprintf( stderr, "Condition - signal did not work (%d)\n", status ); + } + exit( 0 ); +} + +/* configuration information */ + +#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER + +#define CONFIGURE_POSIX_INIT_THREAD_TABLE +#define CONFIGURE_RTEMS_INIT_TASKS_TABLE + +#define CONFIGURE_MAXIMUM_TASKS 1 +#define CONFIGURE_MAXIMUM_PERIODS 1 + +#define CONFIGURE_MAXIMUM_POSIX_THREADS 2 +#define CONFIGURE_MAXIMUM_POSIX_MUTEXES 1 +#define CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES 1 + +#define CONFIGURE_INIT + +#include + +/* end of file */ diff --git a/led/sem_server/.cvsignore b/led/sem_server/.cvsignore new file mode 100644 index 0000000..fecf58a --- /dev/null +++ b/led/sem_server/.cvsignore @@ -0,0 +1 @@ +o-optimize diff --git a/led/sem_server/Makefile b/led/sem_server/Makefile new file mode 100644 index 0000000..aeb0fde --- /dev/null +++ b/led/sem_server/Makefile @@ -0,0 +1,27 @@ +# +# $Id$ +# + +# +# RTEMS_MAKEFILE_PATH is typically set in an environment variable +# + +PGM=${ARCH}/sem_server.exe + +# optional managers required +MANAGERS=all + +# C source names +CSRCS = init.c +COBJS = $(CSRCS:%.c=${ARCH}/%.o) + +include $(RTEMS_MAKEFILE_PATH)/Makefile.inc +include $(RTEMS_CUSTOM) +include $(PROJECT_ROOT)/make/leaf.cfg + +OBJS= $(COBJS) $(CXXOBJS) $(ASOBJS) + +all: ${ARCH} $(PGM) + +$(PGM): $(OBJS) + $(make-exe) diff --git a/led/sem_server/init.c b/led/sem_server/init.c new file mode 100644 index 0000000..d0792eb --- /dev/null +++ b/led/sem_server/init.c @@ -0,0 +1,122 @@ +/* + * 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 + +#include "../../testmacros.h" +#include "../led.h" + +/* + * Keep the names and IDs in global variables so another task can use them. + */ + +rtems_id Task_id[ 4 ]; /* array of task ids */ +rtems_name Task_name[ 4 ]; /* array of task names */ +rtems_id Sem_id; + +rtems_task Test_task( + rtems_task_argument unused +) +{ + rtems_status_code status; + + LED_INIT(); + + for ( ; ; ) { + status = rtems_semaphore_obtain( + Sem_id, + RTEMS_DEFAULT_OPTIONS, + RTEMS_NO_TIMEOUT + ); + if ( status != RTEMS_SUCCESSFUL ) + fputs( "Task - obtain did not work\n", stderr ); + + LED_OFF(); + + status = rtems_task_wake_after( get_ticks_per_second() ); + assert( status == RTEMS_SUCCESSFUL ); + + status = rtems_semaphore_release( Sem_id ); + if ( status != RTEMS_SUCCESSFUL ) + fputs( "Task - release did not work\n", stderr ); + } +} + +rtems_task Init( + rtems_task_argument argument +) +{ + rtems_status_code status; + + puts( "\n\n*** LED BLINKER -- semaphore ping/pong ***" ); + + Task_name[ 1 ] = rtems_build_name( 'T', 'A', '1', ' ' ); + + status = rtems_semaphore_create( + rtems_build_name( 'S', 'E', 'M', ' ' ), + 0, + RTEMS_DEFAULT_ATTRIBUTES, + 0, + &Sem_id + ); + assert( status == RTEMS_SUCCESSFUL ); + + status = rtems_task_create( + Task_name[ 1 ], 1, RTEMS_MINIMUM_STACK_SIZE * 2, RTEMS_DEFAULT_MODES, + RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 1 ] + ); + assert( status == RTEMS_SUCCESSFUL ); + + status = rtems_task_start( Task_id[ 1 ], Test_task, 1 ); + assert( status == RTEMS_SUCCESSFUL ); + + while (1) { + + LED_ON(); + status = rtems_task_wake_after( get_ticks_per_second() ); + assert( status == RTEMS_SUCCESSFUL ); + + status = rtems_semaphore_release( Sem_id ); + if ( status != RTEMS_SUCCESSFUL ) + fputs( "init - release did not work\n", stderr ); + + status = rtems_semaphore_obtain( + Sem_id, + RTEMS_DEFAULT_OPTIONS, + RTEMS_NO_TIMEOUT + ); + if ( status != RTEMS_SUCCESSFUL ) + fputs( "init - obtain did not work\n", stderr ); + + } + + status = rtems_task_delete( RTEMS_SELF ); + assert( status == RTEMS_SUCCESSFUL ); +} + +/**************** 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_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE) + +#include + +/**************** END OF CONFIGURATION INFORMATION ****************/ diff --git a/led/timeout_event/.cvsignore b/led/timeout_event/.cvsignore new file mode 100644 index 0000000..fecf58a --- /dev/null +++ b/led/timeout_event/.cvsignore @@ -0,0 +1 @@ +o-optimize diff --git a/led/timeout_event/Makefile b/led/timeout_event/Makefile new file mode 100644 index 0000000..9ff8572 --- /dev/null +++ b/led/timeout_event/Makefile @@ -0,0 +1,27 @@ +# +# $Id$ +# + +# +# RTEMS_MAKEFILE_PATH is typically set in an environment variable +# + +PGM=${ARCH}/timeout_event.exe + +# optional managers required +MANAGERS=all + +# C source names +CSRCS = init.c +COBJS = $(CSRCS:%.c=${ARCH}/%.o) + +include $(RTEMS_MAKEFILE_PATH)/Makefile.inc +include $(RTEMS_CUSTOM) +include $(PROJECT_ROOT)/make/leaf.cfg + +OBJS= $(COBJS) $(CXXOBJS) $(ASOBJS) + +all: ${ARCH} $(PGM) + +$(PGM): $(OBJS) + $(make-exe) diff --git a/led/timeout_event/init.c b/led/timeout_event/init.c new file mode 100644 index 0000000..71cce63 --- /dev/null +++ b/led/timeout_event/init.c @@ -0,0 +1,69 @@ +/* + * 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 + +#include "../../testmacros.h" +#include "../led.h" + +/* + * Keep the names and IDs in global variables so another task can use them. + */ + +rtems_id Task_id[ 4 ]; /* array of task ids */ +rtems_name Task_name[ 4 ]; /* array of task names */ + +rtems_task Init( + rtems_task_argument argument +) +{ + rtems_status_code status; + rtems_event_set events; + uint32_t count = 0; + + puts( "\n\n*** LED BLINKER -- event receive timeout ***" ); + + LED_INIT(); + + while (1) { + + status = rtems_event_receive( RTEMS_EVENT_1, + RTEMS_DEFAULT_OPTIONS, get_ticks_per_second(), &events ); + if ( status != RTEMS_TIMEOUT ) + fputs( "receive did not timeout\n", stderr ); + + if ( (count++ % 2) == 0 ) + LED_ON(); + else + LED_OFF(); + + } + + status = rtems_task_delete( RTEMS_SELF ); +} + +/**************** 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_RTEMS_INIT_TASKS_TABLE + +#define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE) + +#include + +/**************** END OF CONFIGURATION INFORMATION ****************/ diff --git a/led/timer/.cvsignore b/led/timer/.cvsignore new file mode 100644 index 0000000..fecf58a --- /dev/null +++ b/led/timer/.cvsignore @@ -0,0 +1 @@ +o-optimize diff --git a/led/timer/Makefile b/led/timer/Makefile new file mode 100644 index 0000000..4ce2a92 --- /dev/null +++ b/led/timer/Makefile @@ -0,0 +1,27 @@ +# +# $Id$ +# + +# +# RTEMS_MAKEFILE_PATH is typically set in an environment variable +# + +PGM=${ARCH}/timer.exe + +# optional managers required +MANAGERS=all + +# C source names +CSRCS = init.c +COBJS = $(CSRCS:%.c=${ARCH}/%.o) + +include $(RTEMS_MAKEFILE_PATH)/Makefile.inc +include $(RTEMS_CUSTOM) +include $(PROJECT_ROOT)/make/leaf.cfg + +OBJS= $(COBJS) $(CXXOBJS) $(ASOBJS) + +all: ${ARCH} $(PGM) + +$(PGM): $(OBJS) + $(make-exe) diff --git a/led/timer/init.c b/led/timer/init.c new file mode 100644 index 0000000..f9e3a36 --- /dev/null +++ b/led/timer/init.c @@ -0,0 +1,135 @@ +/* + * 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 "../../testmacros.h" +#include "../led.h" + +rtems_id Timer1; +rtems_id Timer2; + +#define USE_TIMER_SERVER +#if defined(__LED_PRINTING) +volatile int led_do_print; +volatile int led_value; +#endif + +rtems_timer_service_routine Timer_Routine( rtems_id id, void *ignored ) +{ + rtems_status_code status; + +#if defined(__LED_PRINTING) + if ( id == Timer1 ) + led_value = 1; + else + led_value = 0; + led_do_print = 1; +#else + if ( id == Timer1 ) + LED_ON(); + else + LED_OFF(); +#endif + +#if defined(USE_TIMER_SERVER) + status = rtems_timer_server_fire_after( +#else + status = rtems_timer_fire_after( +#endif + id, + 2 * get_ticks_per_second(), + Timer_Routine, + NULL + ); +} + +rtems_task Init( + rtems_task_argument argument +) +{ + rtems_status_code status; + + puts( "\n\n*** LED BLINKER -- timer ***" ); + + LED_INIT(); + +#if defined(USE_TIMER_SERVER) + status = rtems_timer_initiate_server( + 1, + RTEMS_MINIMUM_STACK_SIZE * 2, + RTEMS_DEFAULT_ATTRIBUTES + ); + + if ( status != RTEMS_SUCCESSFUL ) + fputs( "timer create server failed\n", stderr ); +#endif + + status = rtems_timer_create(rtems_build_name( 'T', 'M', 'R', '1' ), &Timer1); + if ( status != RTEMS_SUCCESSFUL ) + fputs( "Timer1 create failed\n", stderr ); + + status = rtems_timer_create(rtems_build_name( 'T', 'M', 'R', '2' ), &Timer2); + if ( status != RTEMS_SUCCESSFUL ) + fputs( "Timer2 create failed\n", stderr ); + + Timer_Routine(Timer1, NULL); + + status = rtems_task_wake_after( get_ticks_per_second() ); + + Timer_Routine(Timer2, NULL); + + +#if defined(__LED_PRINTING) + + while (1) { + int _led_do_print; + int _led_value; + + status = rtems_task_wake_after( 10 ); + + /* technically the following 4 statements are a critical section */ + _led_do_print = led_do_print; + _led_value = led_value; + led_do_print = 0; + led_value = 0; + + if ( _led_do_print ) { + if ( _led_value ) + LED_ON(); + else + LED_OFF(); + + } + } +#endif + status = rtems_task_delete( RTEMS_SELF ); +} + + +/**************** 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_TIMERS 2 +#define CONFIGURE_MAXIMUM_SEMAPHORES 20 + +#define CONFIGURE_RTEMS_INIT_TASKS_TABLE + +#define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE) + +#include + +/**************** END OF CONFIGURATION INFORMATION ****************/ diff --git a/misc/Makefile b/misc/Makefile new file mode 100644 index 0000000..5b748cb --- /dev/null +++ b/misc/Makefile @@ -0,0 +1,9 @@ +# +# $Id$ +# + +include $(RTEMS_MAKEFILE_PATH)/Makefile.inc +include $(RTEMS_CUSTOM) +include $(RTEMS_ROOT)/make/directory.cfg + +SUBDIRS=minimum diff --git a/misc/minimum/.cvsignore b/misc/minimum/.cvsignore new file mode 100644 index 0000000..fecf58a --- /dev/null +++ b/misc/minimum/.cvsignore @@ -0,0 +1 @@ +o-optimize diff --git a/misc/minimum/Makefile b/misc/minimum/Makefile new file mode 100644 index 0000000..8baab25 --- /dev/null +++ b/misc/minimum/Makefile @@ -0,0 +1,27 @@ +# +# $Id$ +# + +# +# RTEMS_MAKEFILE_PATH is typically set in an environment variable +# + +PGM=${ARCH}/minimum.exe + +# optional managers required +MANAGERS=all + +# C source names +CSRCS = test.c +COBJS = $(CSRCS:%.c=${ARCH}/%.o) + +include $(RTEMS_MAKEFILE_PATH)/Makefile.inc +include $(RTEMS_CUSTOM) +include $(PROJECT_ROOT)/make/leaf.cfg + +OBJS= $(COBJS) $(CXXOBJS) $(ASOBJS) + +all: ${ARCH} $(PGM) + +$(PGM): $(OBJS) + $(make-exe) diff --git a/misc/minimum/test.c b/misc/minimum/test.c new file mode 100644 index 0000000..1ecb748 --- /dev/null +++ b/misc/minimum/test.c @@ -0,0 +1,112 @@ +/* Minimum Size Application Initialization + * + * 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 + +rtems_task Init( + rtems_task_argument ignored +) +{ + rtems_mode mode; + + /* initialize application */ + + /* Real application would call idle loop functionality */ + + /* but in this case, just return and fall into a fatal error */ +} + +/* configuration information */ + +/* + * This application has no device drivers. + */ +/* NOTICE: the clock driver is explicitly disabled */ +#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER + +/* + * This application has no filesytem and libio support. + */ +#define CONFIGURE_APPLICATION_DISABLE_FILESYSTEM + +/* + * This disables reentrancy support in the C Library. It is usually + * not something an application wants to do unless the development + * team is committed to using C Library routines that are KNOWN to + * be reentrant. Caveat Emptor!! + */ +#define CONFIGURE_DISABLE_NEWLIB_REENTRANCY + +/* + * This test does not need the console driver so there is no reason + * to configure termios. + */ +#define CONFIGURE_TERMIOS_DISABLED + +/* + * This test does not use any stdio. + */ +#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 0 + +/* + * This may prevent us from running on every architecture but it + * demonstrates that the user can specify how small of a minimum + * stack they want. + */ +#define CONFIGURE_MINIMUM_TASK_STACK_SIZE 512 + +/* + * This lowers the number of priorities that this test is able to + * use. The Idle task will be running at the lowest priority. + */ +#define CONFIGURE_MAXIMUM_PRIORITY 15 + +/* + * This disables Classic API Notepads and saves 16 uint32_t's of RAM + * per Task Control Block. If you aren't using these and are tight + * on RAM, this is an option. + */ +#define CONFIGURE_DISABLE_CLASSIC_API_NOTEPADS + +/* + * This configures RTEMS to use a single memory pool for the RTEMS Workspace + * and C Program Heap. If not defined, there will be separate memory pools + * for the RTEMS Workspace and C Program Heap. Having separate pools + * does haved some advantages in the event a task blows a stack or writes + * outside its memory area. However, in low memory systems the overhead of + * the two pools plus the potential for unused memory in either pool is + * very undesirable. + * + * In high memory environments, this is desirable when you want to use + * the RTEMS "unlimited" objects option. You will be able to create objects + * until you run out of memory. + */ +#define CONFIGURE_UNIFIED_WORK_AREAS + +/* + * In this application, the initialization task performs the system + * initialization and then transforms itself into the idle task. + */ +#define CONFIGURE_IDLE_TASK_BODY Init +#define CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION + +/* + * If you are debugging confdefs.h, define this + */ +/* #define CONFIGURE_CONFDEFS_DEBUG */ + +/* + * Instantiate the configuration tables. + */ +#define CONFIGURE_INIT + +#include diff --git a/testmacros.h b/testmacros.h new file mode 100644 index 0000000..fe0f044 --- /dev/null +++ b/testmacros.h @@ -0,0 +1,81 @@ +/* testmacros.h + * + * This include file contains some commonly used test macros. + * + * 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$ + */ + +#ifndef __TEST_MACROS_h +#define __TEST_MACROS_h + +/* + * Handy macros and static inline functions + */ + +/* + * Macro to hide the ugliness of printing the time. + */ + +#define print_time(_s1, _tb, _s2) \ + do { \ + printf( "%s%02d:%02d:%02d %02d/%02d/%04d%s", \ + _s1, (int) (_tb)->hour, (int) (_tb)->minute, (int) (_tb)->second, \ + (int) (_tb)->month, (int) (_tb)->day, (int) (_tb)->year, _s2 ); \ + fflush(stdout); \ + } while ( 0 ) + +/* + * Macro to print an task name that is composed of ASCII characters. + * + */ + +#define put_name( _name, _crlf ) \ + do { \ + uint32_t c0, c1, c2, c3; \ + \ + c0 = ((_name) >> 24) & 0xff; \ + c1 = ((_name) >> 16) & 0xff; \ + c2 = ((_name) >> 8) & 0xff; \ + c3 = (_name) & 0xff; \ + putchar( (char)c0 ); \ + if ( c1 ) putchar( (char)c1 ); \ + if ( c2 ) putchar( (char)c2 ); \ + if ( c3 ) putchar( (char)c3 ); \ + if ( (_crlf) ) \ + putchar( '\n' ); \ + } while (0) + +/* + * static inline routine to make obtaining ticks per second easier. + */ + +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; +} + + +/* + * This allows us to view the "Test_task" instantiations as a set + * of numbered tasks by eliminating the number of application + * tasks created. + * + * In reality, this is too complex for the purposes of this + * example. It would have been easier to pass a task argument. :) + * But it shows how rtems_id's can sometimes be used. + */ + +#define task_number( tid ) \ + ( rtems_object_id_get_index( tid ) - \ + rtems_configuration_get_rtems_api_configuration()->number_of_initialization_tasks ) + +#endif +/* end of include file */ diff --git a/ticker/Makefile b/ticker/Makefile new file mode 100644 index 0000000..827a6cd --- /dev/null +++ b/ticker/Makefile @@ -0,0 +1,10 @@ +# +# $Id$ +# + +include $(RTEMS_MAKEFILE_PATH)/Makefile.inc +include $(RTEMS_CUSTOM) +include $(RTEMS_ROOT)/make/directory.cfg + +# Ticker Variations +SUBDIRS = ticker low_ticker low_ticker1 low_ticker2 diff --git a/ticker/low_ticker/.cvsignore b/ticker/low_ticker/.cvsignore new file mode 100644 index 0000000..fecf58a --- /dev/null +++ b/ticker/low_ticker/.cvsignore @@ -0,0 +1 @@ +o-optimize diff --git a/ticker/low_ticker/Makefile b/ticker/low_ticker/Makefile new file mode 100644 index 0000000..4201727 --- /dev/null +++ b/ticker/low_ticker/Makefile @@ -0,0 +1,27 @@ +# +# $Id$ +# + +# +# RTEMS_MAKEFILE_PATH is typically set in an environment variable +# + +PGM=${ARCH}/low_ticker.exe + +# optional managers required +MANAGERS=all + +# C source names +CSRCS = init.c +COBJS = $(CSRCS:%.c=${ARCH}/%.o) + +include $(RTEMS_MAKEFILE_PATH)/Makefile.inc +include $(RTEMS_CUSTOM) +include $(PROJECT_ROOT)/make/leaf.cfg + +OBJS= $(COBJS) $(CXXOBJS) $(ASOBJS) + +all: ${ARCH} $(PGM) + +$(PGM): $(OBJS) + $(make-exe) diff --git a/ticker/low_ticker/init.c b/ticker/low_ticker/init.c new file mode 100644 index 0000000..27e27b2 --- /dev/null +++ b/ticker/low_ticker/init.c @@ -0,0 +1,90 @@ +/* + * 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 + +rtems_task Test_task( + rtems_task_argument task_index +) +{ + rtems_time_of_day time; + rtems_status_code status; + + for ( ; ; ) { + status = rtems_clock_get_tod( &time ); + if ( time.second >= 35 ) { + printk( "*** END OF LOW MEMORY CLOCK TICK TEST ***\n" ); + rtems_shutdown_executive( 0 ); + } + printk( "TA%d %s%02d:%02d:%02d %02d/%02d/%04d\n", + task_index, " - rtems_clock_get - ", + (int) time.hour, (int) time.minute, (int) time.second, + (int) time.month, (int) time.day, (int) time.year ); + status = rtems_task_wake_after( + task_index * 5 * rtems_clock_get_ticks_per_second() ); + } +} + +rtems_task Init( + rtems_task_argument argument +) +{ + rtems_status_code status; + rtems_time_of_day time; + rtems_id id; + int i; + + printk( "\n\n*** LOW MEMORY CLOCK TICK TEST ***\n" ); + + time.year = 1988; + time.month = 12; + time.day = 31; + time.hour = 9; + time.minute = 0; + time.second = 0; + time.ticks = 0; + + status = rtems_clock_set( &time ); + + for (i=1 ; i<=3 ; i++ ) { + status = rtems_task_create( + rtems_build_name( 'T', 'A', 0x30+1, ' ' ), 1, 0, RTEMS_DEFAULT_MODES, + RTEMS_DEFAULT_ATTRIBUTES, &id + ); + status = rtems_task_start( id, Test_task, i ); + } + + while( 1 ) + ; +} + +/**************** START OF CONFIGURATION INFORMATION ****************/ + +#define CONFIGURE_INIT + +#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER +#define CONFIGURE_APPLICATION_DISABLE_FILESYSTEM +#define CONFIGURE_DISABLE_NEWLIB_REENTRANCY +#define CONFIGURE_TERMIOS_DISABLED +#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 0 +#define CONFIGURE_MINIMUM_TASK_STACK_SIZE 512 +#define CONFIGURE_MAXIMUM_PRIORITY 15 +#define CONFIGURE_DISABLE_CLASSIC_API_NOTEPADS +#define CONFIGURE_IDLE_TASK_BODY Init +#define CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION + +#define CONFIGURE_MAXIMUM_TASKS 3 + +#include + +/**************** END OF CONFIGURATION INFORMATION ****************/ diff --git a/ticker/low_ticker1/.cvsignore b/ticker/low_ticker1/.cvsignore new file mode 100644 index 0000000..fecf58a --- /dev/null +++ b/ticker/low_ticker1/.cvsignore @@ -0,0 +1 @@ +o-optimize diff --git a/ticker/low_ticker1/Makefile b/ticker/low_ticker1/Makefile new file mode 100644 index 0000000..e9c88b9 --- /dev/null +++ b/ticker/low_ticker1/Makefile @@ -0,0 +1,27 @@ +# +# $Id$ +# + +# +# RTEMS_MAKEFILE_PATH is typically set in an environment variable +# + +PGM=${ARCH}/low_ticker1.exe + +# optional managers required +MANAGERS=all + +# C source names +CSRCS = init.c +COBJS = $(CSRCS:%.c=${ARCH}/%.o) + +include $(RTEMS_MAKEFILE_PATH)/Makefile.inc +include $(RTEMS_CUSTOM) +include $(PROJECT_ROOT)/make/leaf.cfg + +OBJS= $(COBJS) $(CXXOBJS) $(ASOBJS) + +all: ${ARCH} $(PGM) + +$(PGM): $(OBJS) + $(make-exe) diff --git a/ticker/low_ticker1/init.c b/ticker/low_ticker1/init.c new file mode 100644 index 0000000..ef46f41 --- /dev/null +++ b/ticker/low_ticker1/init.c @@ -0,0 +1,87 @@ +/* + * 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 + +rtems_task Test_task( + rtems_task_argument task_index +) +{ + rtems_status_code status; + rtems_id period_id; + rtems_interval ticks; + struct timespec uptime; + + status = rtems_rate_monotonic_create( + rtems_build_name( 'P', 'E', 'R', 0x30+task_index ), + &period_id + ); + + ticks = task_index * 5 * rtems_clock_get_ticks_per_second(); + for ( ; ; ) { + status = rtems_rate_monotonic_period( period_id, ticks ); + + status = rtems_clock_get_uptime( &uptime ); + if ( uptime.tv_sec >= 35 ) { + printk( "*** END OF LOW MEMORY CLOCK TICK TEST (PERIODs) ***\n" ); + rtems_shutdown_executive( 0 ); + } + printk( "TA%d - rtems_clock_uptime - %d:%d\n", + task_index, uptime.tv_sec, uptime.tv_nsec + ); + } +} + +rtems_task Init( + rtems_task_argument argument +) +{ + rtems_status_code status; + rtems_id id; + int i; + + printk( "\n\n*** LOW MEMORY CLOCK TICK TEST (PERIODs) ***\n" ); + + for (i=1 ; i<=3 ; i++ ) { + status = rtems_task_create( + rtems_build_name( 'T', 'A', 0x30+1, ' ' ), 1, 0, RTEMS_DEFAULT_MODES, + RTEMS_DEFAULT_ATTRIBUTES, &id + ); + status = rtems_task_start( id, Test_task, i ); + } + + while( 1 ) + ; +} + +/**************** START OF CONFIGURATION INFORMATION ****************/ + +#define CONFIGURE_INIT + +#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER +#define CONFIGURE_APPLICATION_DISABLE_FILESYSTEM +#define CONFIGURE_DISABLE_NEWLIB_REENTRANCY +#define CONFIGURE_TERMIOS_DISABLED +#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 0 +#define CONFIGURE_MINIMUM_TASK_STACK_SIZE 512 +#define CONFIGURE_MAXIMUM_PRIORITY 15 +#define CONFIGURE_DISABLE_CLASSIC_API_NOTEPADS +#define CONFIGURE_IDLE_TASK_BODY Init +#define CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION + +#define CONFIGURE_MAXIMUM_TASKS 3 +#define CONFIGURE_MAXIMUM_PERIODS 3 + +#include + +/**************** END OF CONFIGURATION INFORMATION ****************/ diff --git a/ticker/low_ticker2/.cvsignore b/ticker/low_ticker2/.cvsignore new file mode 100644 index 0000000..fecf58a --- /dev/null +++ b/ticker/low_ticker2/.cvsignore @@ -0,0 +1 @@ +o-optimize diff --git a/ticker/low_ticker2/Makefile b/ticker/low_ticker2/Makefile new file mode 100644 index 0000000..123f1fd --- /dev/null +++ b/ticker/low_ticker2/Makefile @@ -0,0 +1,27 @@ +# +# $Id$ +# + +# +# RTEMS_MAKEFILE_PATH is typically set in an environment variable +# + +PGM=${ARCH}/low_ticker2.exe + +# optional managers required +MANAGERS=all + +# C source names +CSRCS = init.c +COBJS = $(CSRCS:%.c=${ARCH}/%.o) + +include $(RTEMS_MAKEFILE_PATH)/Makefile.inc +include $(RTEMS_CUSTOM) +include $(PROJECT_ROOT)/make/leaf.cfg + +OBJS= $(COBJS) $(CXXOBJS) $(ASOBJS) + +all: ${ARCH} $(PGM) + +$(PGM): $(OBJS) + $(make-exe) diff --git a/ticker/low_ticker2/init.c b/ticker/low_ticker2/init.c new file mode 100644 index 0000000..fca66ca --- /dev/null +++ b/ticker/low_ticker2/init.c @@ -0,0 +1,80 @@ +/* + * 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 + +rtems_task Test_task( + rtems_task_argument task_index +) +{ + rtems_status_code status; + rtems_interval ticks; + struct timespec uptime; + + ticks = task_index * 5 * rtems_clock_get_ticks_per_second(); + for ( ; ; ) { + status = rtems_task_wake_after( ticks ); + + status = rtems_clock_get_uptime( &uptime ); + if ( uptime.tv_sec >= 35 ) { + printk( "*** END OF LOW MEMORY CLOCK TICK TEST (delay) ***\n" ); + rtems_shutdown_executive( 0 ); + } + printk( "TA%d - rtems_clock_uptime - %d:%d\n", + task_index, uptime.tv_sec, uptime.tv_nsec + ); + } +} + +rtems_task Init( + rtems_task_argument argument +) +{ + rtems_status_code status; + rtems_id id; + int i; + + printk( "\n\n*** LOW MEMORY CLOCK TICK TEST (delay) ***\n" ); + + for (i=1 ; i<=3 ; i++ ) { + status = rtems_task_create( + rtems_build_name( 'T', 'A', 0x30+1, ' ' ), 1, 0, RTEMS_DEFAULT_MODES, + RTEMS_DEFAULT_ATTRIBUTES, &id + ); + status = rtems_task_start( id, Test_task, i ); + } + + while( 1 ) + ; +} + +/**************** START OF CONFIGURATION INFORMATION ****************/ + +#define CONFIGURE_INIT + +#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER +#define CONFIGURE_APPLICATION_DISABLE_FILESYSTEM +#define CONFIGURE_DISABLE_NEWLIB_REENTRANCY +#define CONFIGURE_TERMIOS_DISABLED +#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 0 +#define CONFIGURE_MINIMUM_TASK_STACK_SIZE 512 +#define CONFIGURE_MAXIMUM_PRIORITY 15 +#define CONFIGURE_DISABLE_CLASSIC_API_NOTEPADS +#define CONFIGURE_IDLE_TASK_BODY Init +#define CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION + +#define CONFIGURE_MAXIMUM_TASKS 3 + +#include + +/**************** END OF CONFIGURATION INFORMATION ****************/ diff --git a/ticker/ticker/.cvsignore b/ticker/ticker/.cvsignore new file mode 100644 index 0000000..fecf58a --- /dev/null +++ b/ticker/ticker/.cvsignore @@ -0,0 +1 @@ +o-optimize diff --git a/ticker/ticker/Makefile b/ticker/ticker/Makefile new file mode 100644 index 0000000..5a92e90 --- /dev/null +++ b/ticker/ticker/Makefile @@ -0,0 +1,27 @@ +# +# $Id$ +# + +# +# RTEMS_MAKEFILE_PATH is typically set in an environment variable +# + +PGM=${ARCH}/ticker.exe + +# optional managers required +MANAGERS=all + +# C source names +CSRCS = init.c +COBJS = $(CSRCS:%.c=${ARCH}/%.o) + +include $(RTEMS_MAKEFILE_PATH)/Makefile.inc +include $(RTEMS_CUSTOM) +include $(PROJECT_ROOT)/make/leaf.cfg + +OBJS= $(COBJS) $(CXXOBJS) $(ASOBJS) + +all: ${ARCH} $(PGM) + +$(PGM): $(OBJS) + $(make-exe) diff --git a/ticker/ticker/init.c b/ticker/ticker/init.c new file mode 100644 index 0000000..f3e8feb --- /dev/null +++ b/ticker/ticker/init.c @@ -0,0 +1,107 @@ +/* + * 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 + +#include "../../testmacros.h" + +rtems_id Task_id[ 4 ]; /* array of task ids */ +rtems_name Task_name[ 4 ]; /* array of task names */ + +rtems_task Test_task( + rtems_task_argument unused +) +{ + rtems_id tid; + rtems_time_of_day time; + uint32_t task_index; + rtems_status_code status; + + status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &tid ); + task_index = task_number( tid ); + for ( ; ; ) { + status = rtems_clock_get( RTEMS_CLOCK_GET_TOD, &time ); + if ( time.second >= 35 ) { + puts( "*** END OF CLOCK TICK TEST ***" ); + exit( 0 ); + } + put_name( Task_name[ task_index ], FALSE ); + print_time( " - rtems_clock_get - ", &time, "\n" ); + status = rtems_task_wake_after( task_index * 5 * get_ticks_per_second() ); + } +} + +rtems_task Init( + rtems_task_argument argument +) +{ + rtems_status_code status; + rtems_time_of_day time; + + puts( "\n\n*** CLOCK TICK TEST ***" ); + + time.year = 1988; + time.month = 12; + time.day = 31; + time.hour = 9; + time.minute = 0; + time.second = 0; + time.ticks = 0; + + status = rtems_clock_set( &time ); + + Task_name[ 1 ] = rtems_build_name( 'T', 'A', '1', ' ' ); + Task_name[ 2 ] = rtems_build_name( 'T', 'A', '2', ' ' ); + Task_name[ 3 ] = rtems_build_name( 'T', 'A', '3', ' ' ); + + status = rtems_task_create( + Task_name[ 1 ], 1, RTEMS_MINIMUM_STACK_SIZE * 2, RTEMS_DEFAULT_MODES, + RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 1 ] + ); + status = rtems_task_create( + Task_name[ 2 ], 1, RTEMS_MINIMUM_STACK_SIZE * 2, RTEMS_DEFAULT_MODES, + RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 2 ] + ); + status = rtems_task_create( + Task_name[ 3 ], 1, RTEMS_MINIMUM_STACK_SIZE * 2, RTEMS_DEFAULT_MODES, + RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 3 ] + ); + + status = rtems_task_start( Task_id[ 1 ], Test_task, 1 ); + status = rtems_task_start( Task_id[ 2 ], Test_task, 2 ); + status = rtems_task_start( Task_id[ 3 ], Test_task, 3 ); + + status = rtems_task_delete( RTEMS_SELF ); +} + +/**************** 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_RTEMS_INIT_TASKS_TABLE +#define CONFIGURE_INIT_TASK_STACK_SIZE (2 * RTEMS_MINIMUM_STACK_SIZE) + +#define CONFIGURE_EXTRA_TASK_STACKS (4 * RTEMS_MINIMUM_STACK_SIZE) + +#define CONFIGURE_MICROSECONDS_PER_TICK 1 + +#include + +/**************** END OF CONFIGURATION INFORMATION ****************/ + -- cgit v1.2.3