source: rtems/testsuites/sptests/sp45/init.c @ b84f1fdc

4.104.115
Last change on this file since b84f1fdc was b84f1fdc, checked in by Joel Sherrill <joel.sherrill@…>, on 05/10/09 at 14:39:46

2009-05-10 Joel Sherrill <joel.sherrill@…>

  • sp04/system.h, sp04/task1.c, sp04/tswitch.c, sp07/init.c, sp12/init.c, sp13/putbuff.c, sp13/system.h, sp13/task1.c, sp15/init.c, sp16/system.h, sp19/fptask.c, sp25/system.h, sp26/task1.c, sp27/init.c, sp28/init.c, sp29/init.c, sp31/task1.c, sp33/init.c, sp34/changepri.c, sp35/priinv.c, sp37/init.c, sp38/init.c, sp39/init.c, sp41/init.c, sp42/init.c, sp43/init.c, sp44/init.c, sp45/init.c, sp46/init.c, sp47/init.c, sp48/init.c, spfatal03/testcase.h, spfatal05/testcase.h, spfatal06/testcase.h, spfatal_support/system.h, spobjgetnext/init.c, spsize/getint.c, spsize/size.c: Fix warnings.
  • Property mode set to 100644
File size: 3.5 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2009.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.com/license/LICENSE.
8 *
9 *  $Id$
10 */
11
12#include <tmacros.h>
13
14rtems_task Init(
15  rtems_task_argument argument
16);
17rtems_timer_service_routine Malloc_From_TSR(
18  rtems_id  ignored_id,
19  void     *ignored_address
20);
21
22rtems_id   Timer_id[ 3 ];    /* array of timer ids */
23rtems_name Timer_name[ 3 ];  /* array of timer names */
24
25volatile int TSR_fired;
26volatile void *TSR_malloc_ptr;
27
28rtems_timer_service_routine Malloc_From_TSR(
29  rtems_id  ignored_id,
30  void     *ignored_address
31)
32{
33  rtems_status_code  status;
34
35  TSR_fired = 2;
36  puts( "TSR: calling malloc" );
37  TSR_malloc_ptr = malloc( 64 );
38
39  puts( "TSR: calling free" );
40  free( (void *) TSR_malloc_ptr );
41
42  puts( "TSR: delaying with rtems_task_wake_after" );
43  status = rtems_task_wake_after( TICKS_PER_SECOND / 2 );
44  directive_failed( status, "rtems_task_wake_after" );
45}
46
47rtems_task Init(
48  rtems_task_argument argument
49)
50{
51  rtems_status_code  status;
52
53  puts( "\n\n*** TEST 45 ***" );
54
55  status = rtems_timer_initiate_server(
56    RTEMS_TIMER_SERVER_DEFAULT_PRIORITY,
57    RTEMS_MINIMUM_STACK_SIZE,
58    RTEMS_DEFAULT_ATTRIBUTES
59  );
60  directive_failed( status, "rtems_timer_initiate_server" );
61
62  /*
63   * Initialize Timers
64   */
65
66  Timer_name[ 1 ] = rtems_build_name( 'T', 'M', '1', ' ' );
67  Timer_name[ 2 ] = rtems_build_name( 'T', 'M', '2', ' ' );
68
69  puts( "INIT - rtems_timer_create - creating timer 1" );
70  status = rtems_timer_create( Timer_name[ 1 ], &Timer_id[ 1 ] );
71  directive_failed( status, "rtems_timer_create" );
72  printf( "INIT - timer 1 has id (0x%x)\n", Timer_id[ 1 ] );
73
74  puts( "INIT - rtems_timer_create - creating timer 2" );
75  status = rtems_timer_create( Timer_name[ 2 ], &Timer_id[ 2 ] );
76  directive_failed( status, "rtems_timer_create" );
77  printf( "INIT - timer 2 has id (0x%x)\n", Timer_id[ 2 ] );
78
79  /*
80   *  Schedule malloc TSR for 1 second from now
81   */
82
83  TSR_fired = 0;
84  TSR_malloc_ptr = (void *) 0xa5a5a5;
85  puts( "TA1 - rtems_timer_server_fire_after - timer 1 in 1 seconds" );
86  status = rtems_timer_server_fire_after(
87    Timer_id[ 1 ],
88    1 * TICKS_PER_SECOND,
89    Malloc_From_TSR,
90    NULL
91  );
92  directive_failed( status, "rtems_timer_server_fire_after" );
93
94  puts( "TA1 - rtems_task_wake_after - 2 second" );
95  status = rtems_task_wake_after( 2 * TICKS_PER_SECOND );
96  directive_failed( status, "rtems_task_wake_after" );
97
98  if ( TSR_fired == 2 &&
99       (TSR_malloc_ptr && TSR_malloc_ptr != (void *)0xa5a5a5) )
100    puts( "TSR appears to have executed OK" );
101  else {
102    printf( "FAILURE ptr=%p TSR_fired=%d\n", TSR_malloc_ptr, TSR_fired );
103    rtems_test_exit( 0 );
104  }
105
106  /*
107   *  Delete timer and exit test
108   */
109  puts( "TA1 - timer_deleting - timer 1" );
110  status = rtems_timer_delete( Timer_id[ 1 ] );
111  directive_failed( status, "rtems_timer_delete" );
112
113
114  puts( "*** END OF TEST 45 *** " );
115  rtems_test_exit( 0 );
116}
117
118#define CONFIGURE_INIT
119/* configuration information */
120
121#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
122#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
123
124/* Two Tasks: Init and Timer Server */
125#define CONFIGURE_MAXIMUM_TASKS           2
126#define CONFIGURE_MAXIMUM_TIMERS          2
127#define CONFIGURE_INIT_TASK_STACK_SIZE    (RTEMS_MINIMUM_STACK_SIZE * 2)
128
129#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
130
131#define CONFIGURE_EXTRA_TASK_STACKS       (1 * RTEMS_MINIMUM_STACK_SIZE)
132
133#include <rtems/confdefs.h>
134
Note: See TracBrowser for help on using the repository browser.