File indexing completed on 2025-05-11 08:24:45
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029 #ifdef HAVE_CONFIG_H
0030 #include "config.h"
0031 #endif
0032
0033 #include <tmacros.h>
0034
0035 const char rtems_test_name[] = "SP 45";
0036
0037 rtems_task Init(
0038 rtems_task_argument argument
0039 );
0040 rtems_timer_service_routine Malloc_From_TSR(
0041 rtems_id ignored_id,
0042 void *ignored_address
0043 );
0044
0045 rtems_id Timer_id[ 3 ];
0046 rtems_name Timer_name[ 3 ];
0047
0048 volatile int TSR_fired;
0049 volatile void *TSR_malloc_ptr;
0050
0051 rtems_timer_service_routine Malloc_From_TSR(
0052 rtems_id ignored_id,
0053 void *ignored_address
0054 )
0055 {
0056 rtems_status_code status;
0057
0058 TSR_fired = 2;
0059 puts( "TSR: calling malloc" );
0060 TSR_malloc_ptr = malloc( 64 );
0061
0062 puts( "TSR: calling free" );
0063 free( (void *) TSR_malloc_ptr );
0064
0065 puts( "TSR: delaying with rtems_task_wake_after" );
0066 status = rtems_task_wake_after( rtems_clock_get_ticks_per_second() / 2 );
0067 directive_failed( status, "rtems_task_wake_after" );
0068 }
0069
0070 rtems_task Init(
0071 rtems_task_argument argument
0072 )
0073 {
0074 rtems_status_code status;
0075
0076 TEST_BEGIN();
0077
0078 status = rtems_timer_initiate_server(
0079 RTEMS_TIMER_SERVER_DEFAULT_PRIORITY,
0080 RTEMS_MINIMUM_STACK_SIZE,
0081 RTEMS_DEFAULT_ATTRIBUTES
0082 );
0083 directive_failed( status, "rtems_timer_initiate_server" );
0084
0085
0086
0087
0088
0089 Timer_name[ 1 ] = rtems_build_name( 'T', 'M', '1', ' ' );
0090 Timer_name[ 2 ] = rtems_build_name( 'T', 'M', '2', ' ' );
0091
0092 puts( "INIT - rtems_timer_create - creating timer 1" );
0093 status = rtems_timer_create( Timer_name[ 1 ], &Timer_id[ 1 ] );
0094 directive_failed( status, "rtems_timer_create" );
0095 printf( "INIT - timer 1 has id (0x%" PRIxrtems_id ")\n", Timer_id[ 1 ] );
0096
0097 puts( "INIT - rtems_timer_create - creating timer 2" );
0098 status = rtems_timer_create( Timer_name[ 2 ], &Timer_id[ 2 ] );
0099 directive_failed( status, "rtems_timer_create" );
0100 printf( "INIT - timer 2 has id (0x%" PRIxrtems_id ")\n", Timer_id[ 2 ] );
0101
0102
0103
0104
0105
0106 TSR_fired = 0;
0107 TSR_malloc_ptr = (void *) 0xa5a5a5;
0108 puts( "TA1 - rtems_timer_server_fire_after - timer 1 in 1 seconds" );
0109 status = rtems_timer_server_fire_after(
0110 Timer_id[ 1 ],
0111 1 * rtems_clock_get_ticks_per_second(),
0112 Malloc_From_TSR,
0113 NULL
0114 );
0115 directive_failed( status, "rtems_timer_server_fire_after" );
0116
0117 puts( "TA1 - rtems_task_wake_after - 2 second" );
0118 status = rtems_task_wake_after( 2 * rtems_clock_get_ticks_per_second() );
0119 directive_failed( status, "rtems_task_wake_after" );
0120
0121 if ( TSR_fired == 2 &&
0122 (TSR_malloc_ptr && TSR_malloc_ptr != (void *)0xa5a5a5) )
0123 puts( "TSR appears to have executed OK" );
0124 else {
0125 printf( "FAILURE ptr=%p TSR_fired=%d\n", TSR_malloc_ptr, TSR_fired );
0126 rtems_test_exit( 0 );
0127 }
0128
0129
0130
0131
0132 puts( "TA1 - timer_deleting - timer 1" );
0133 status = rtems_timer_delete( Timer_id[ 1 ] );
0134 directive_failed( status, "rtems_timer_delete" );
0135
0136
0137 TEST_END();
0138 rtems_test_exit( 0 );
0139 }
0140
0141 #define CONFIGURE_INIT
0142
0143
0144 #define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
0145 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
0146
0147
0148 #define CONFIGURE_MAXIMUM_TASKS 2
0149 #define CONFIGURE_MAXIMUM_TIMERS 2
0150 #define CONFIGURE_INIT_TASK_STACK_SIZE (RTEMS_MINIMUM_STACK_SIZE * 2)
0151
0152 #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
0153
0154 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
0155
0156 #define CONFIGURE_EXTRA_TASK_STACKS (1 * RTEMS_MINIMUM_STACK_SIZE)
0157
0158 #include <rtems/confdefs.h>
0159