diff --git a/c/src/tests/samples/base_mp/apptask.c b/c/src/tests/samples/base_mp/apptask.c index 5303b180d4..566ca7188f 100644 --- a/c/src/tests/samples/base_mp/apptask.c +++ b/c/src/tests/samples/base_mp/apptask.c @@ -20,6 +20,7 @@ */ #include "system.h" +#include rtems_task Application_task( rtems_task_argument node diff --git a/c/src/tests/samples/base_mp/init.c b/c/src/tests/samples/base_mp/init.c index d47113d832..a30bed867f 100644 --- a/c/src/tests/samples/base_mp/init.c +++ b/c/src/tests/samples/base_mp/init.c @@ -20,8 +20,9 @@ * $Id$ */ -#define TEST_INIT +#define CONFIGURE_INIT #include "system.h" +#include rtems_task Init( rtems_task_argument argument diff --git a/c/src/tests/samples/base_mp/system.h b/c/src/tests/samples/base_mp/system.h index 83d0255c0f..23d5006d81 100644 --- a/c/src/tests/samples/base_mp/system.h +++ b/c/src/tests/samples/base_mp/system.h @@ -13,7 +13,7 @@ * $Id$ */ -#include +#include /* functions */ @@ -27,6 +27,8 @@ rtems_task Application_task( /* configuration information */ +#include /* for device driver prototypes */ + #define CONFIGURE_MP_APPLICATION #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER @@ -40,8 +42,4 @@ rtems_task Application_task( #include -/* variables */ - -TEST_EXTERN rtems_id Global_variable; /* example global variable */ - /* end of include file */ diff --git a/c/src/tests/samples/base_sp/apptask.c b/c/src/tests/samples/base_sp/apptask.c index c7b6580fad..050b2130bf 100644 --- a/c/src/tests/samples/base_sp/apptask.c +++ b/c/src/tests/samples/base_sp/apptask.c @@ -19,6 +19,7 @@ */ #include "system.h" +#include rtems_task Application_task( rtems_task_argument argument diff --git a/c/src/tests/samples/base_sp/init.c b/c/src/tests/samples/base_sp/init.c index d787f0233e..e5eae4c9a5 100644 --- a/c/src/tests/samples/base_sp/init.c +++ b/c/src/tests/samples/base_sp/init.c @@ -20,8 +20,9 @@ * $Id$ */ -#define TEST_INIT +#define CONFIGURE_INIT #include "system.h" +#include #define ARGUMENT 0 diff --git a/c/src/tests/samples/base_sp/system.h b/c/src/tests/samples/base_sp/system.h index b76cb28298..e9822987fd 100644 --- a/c/src/tests/samples/base_sp/system.h +++ b/c/src/tests/samples/base_sp/system.h @@ -13,7 +13,7 @@ * $Id$ */ -#include +#include /* functions */ @@ -27,6 +27,8 @@ rtems_task Application_task( /* configuration information */ +#include /* for device driver prototypes */ + #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER @@ -34,8 +36,4 @@ rtems_task Application_task( #include -/* global variables */ - -TEST_EXTERN rtems_id Global_variable; /* example global variable */ - /* end of include file */ diff --git a/c/src/tests/samples/cdtest/init.c b/c/src/tests/samples/cdtest/init.c index 807cd9e5ab..1df5302b50 100644 --- a/c/src/tests/samples/cdtest/init.c +++ b/c/src/tests/samples/cdtest/init.c @@ -20,6 +20,6 @@ * $Id$ */ -#define TEST_INIT +#define CONFIGURE_INIT #include "system.h" #include diff --git a/c/src/tests/samples/cdtest/system.h b/c/src/tests/samples/cdtest/system.h index e1d3177277..39d7b3026f 100644 --- a/c/src/tests/samples/cdtest/system.h +++ b/c/src/tests/samples/cdtest/system.h @@ -13,7 +13,7 @@ * $Id$ */ -#include +#include /* functions */ @@ -23,6 +23,8 @@ rtems_task main_task( /* configuration information */ +#include /* for device driver prototypes */ + #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER @@ -32,8 +34,4 @@ rtems_task main_task( #include -/* global variables */ - -TEST_EXTERN rtems_id Global_variable; /* example global variable */ - /* end of include file */ diff --git a/c/src/tests/samples/hello/init.c b/c/src/tests/samples/hello/init.c index 344617d598..adda41cd20 100644 --- a/c/src/tests/samples/hello/init.c +++ b/c/src/tests/samples/hello/init.c @@ -20,7 +20,7 @@ * $Id$ */ -#define TEST_INIT +#define CONFIGURE_INIT #include "system.h" #include diff --git a/c/src/tests/samples/hello/system.h b/c/src/tests/samples/hello/system.h index f62f457e89..7538f571ad 100644 --- a/c/src/tests/samples/hello/system.h +++ b/c/src/tests/samples/hello/system.h @@ -13,7 +13,7 @@ * $Id$ */ -#include +#include /* functions */ @@ -23,6 +23,8 @@ rtems_task Init( /* configuration information */ +#include /* for device driver prototypes */ + #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER #define CONFIGURE_RTEMS_INIT_TASKS_TABLE @@ -31,8 +33,4 @@ rtems_task Init( #include -/* global variables */ - -TEST_EXTERN rtems_id Global_variable; /* example global variable */ - /* end of include file */ diff --git a/c/src/tests/samples/paranoia/init.c b/c/src/tests/samples/paranoia/init.c index 980a07d7c8..9b836519c3 100644 --- a/c/src/tests/samples/paranoia/init.c +++ b/c/src/tests/samples/paranoia/init.c @@ -20,8 +20,9 @@ * $Id$ */ -#define TEST_INIT +#define CONFIGURE_INIT #include "system.h" +#include extern int paranoia(int, char **); diff --git a/c/src/tests/samples/paranoia/system.h b/c/src/tests/samples/paranoia/system.h index 0651034acd..05b8efbcb7 100644 --- a/c/src/tests/samples/paranoia/system.h +++ b/c/src/tests/samples/paranoia/system.h @@ -13,7 +13,7 @@ * $Id$ */ -#include +#include /* functions */ @@ -23,6 +23,8 @@ rtems_task Init( /* configuration information */ +#include /* for device driver prototypes */ + #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER @@ -34,8 +36,4 @@ rtems_task Init( #include -/* global variables */ - -TEST_EXTERN rtems_id Global_variable; /* example global variable */ - /* end of include file */ diff --git a/c/src/tests/samples/ticker/init.c b/c/src/tests/samples/ticker/init.c index cd8c688887..36f3fd58f6 100644 --- a/c/src/tests/samples/ticker/init.c +++ b/c/src/tests/samples/ticker/init.c @@ -20,8 +20,16 @@ * $Id$ */ -#define TEST_INIT +#define CONFIGURE_INIT #include "system.h" +#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 @@ -32,7 +40,14 @@ rtems_task Init( puts( "\n\n*** CLOCK TICK TEST ***" ); - build_time( &time, 12, 31, 1988, 9, 0, 0, 0 ); + 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', ' ' ); diff --git a/c/src/tests/samples/ticker/system.h b/c/src/tests/samples/ticker/system.h index 73a4d3b55f..8e11ed42cf 100644 --- a/c/src/tests/samples/ticker/system.h +++ b/c/src/tests/samples/ticker/system.h @@ -13,7 +13,7 @@ * $Id$ */ -#include +#include /* functions */ @@ -25,8 +25,20 @@ rtems_task Test_task( 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 @@ -36,9 +48,66 @@ rtems_task Test_task( #include -/* global variables */ +/* + * Handy macros and static inline functions + */ -TEST_EXTERN rtems_id Task_id[ 4 ]; /* array of task ids */ -TEST_EXTERN rtems_name Task_name[ 4 ]; /* array of task names */ +/* + * 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, (_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 { \ + rtems_unsigned32 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 rtems_unsigned32 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/c/src/tests/samples/ticker/tasks.c b/c/src/tests/samples/ticker/tasks.c index b87a26cbbe..d539b967bd 100644 --- a/c/src/tests/samples/ticker/tasks.c +++ b/c/src/tests/samples/ticker/tasks.c @@ -18,6 +18,7 @@ */ #include "system.h" +#include rtems_task Test_task( rtems_task_argument unused @@ -30,7 +31,7 @@ rtems_task Test_task( status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &tid ); task_index = task_number( tid ); - while( FOREVER ) { + for ( ; ; ) { status = rtems_clock_get( RTEMS_CLOCK_GET_TOD, &time ); if ( time.second >= 35 ) { puts( "*** END OF CLOCK TICK TEST ***" ); @@ -38,6 +39,6 @@ rtems_task Test_task( } put_name( Task_name[ task_index ], FALSE ); print_time( " - rtems_clock_get - ", &time, "\n" ); - status = rtems_task_wake_after( task_index * 5 * TICKS_PER_SECOND ); + status = rtems_task_wake_after( task_index * 5 * get_ticks_per_second() ); } } diff --git a/c/src/tests/samples/unlimited/init.c b/c/src/tests/samples/unlimited/init.c index 5036e72527..043e60dafd 100644 --- a/c/src/tests/samples/unlimited/init.c +++ b/c/src/tests/samples/unlimited/init.c @@ -21,7 +21,7 @@ * $Id$ */ -#define TEST_INIT +#define CONFIGURE_INIT #include "system.h" #include diff --git a/c/src/tests/samples/unlimited/system.h b/c/src/tests/samples/unlimited/system.h index 57c0279e54..a48aa0a5a0 100644 --- a/c/src/tests/samples/unlimited/system.h +++ b/c/src/tests/samples/unlimited/system.h @@ -16,8 +16,6 @@ #include -#include - /* functions */ rtems_task Init( @@ -43,6 +41,8 @@ void test3(); /* configuration information */ +#include /* for device driver prototypes */ + #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER #define CONFIGURE_RTEMS_INIT_TASKS_TABLE @@ -54,10 +54,6 @@ void test3(); #include -/* global variables */ - -TEST_EXTERN rtems_id Global_variable; /* example global variable */ - /* * Keep track of the task id's created, use a large array. */