source: rtems/testsuites/sptests/sp45/init.c @ 1055ce20

4.104.115
Last change on this file since 1055ce20 was ab29fef, checked in by Joel Sherrill <joel.sherrill@…>, on 12/03/08 at 21:33:17

2008-12-03 Joel Sherrill <joel.sherrill@…>

  • sp45/init.c: New file.
  • Property mode set to 100644
File size: 3.3 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2008.
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_id   Timer_id[ 3 ];    /* array of timer ids */
15rtems_name Timer_name[ 3 ];  /* array of timer names */
16
17volatile int TSR_fired;
18volatile void *TSR_malloc_ptr;
19
20rtems_timer_service_routine Malloc_From_TSR(
21  rtems_id  ignored_id,
22  void     *ignored_address
23)
24{
25  rtems_status_code  status;
26
27  TSR_fired = 2;
28  puts( "TSR: calling malloc" );
29  TSR_malloc_ptr = malloc( 64 );
30
31  puts( "TSR: calling free" );
32  free( (void *) TSR_malloc_ptr );
33
34  puts( "TSR: delaying with rtems_task_wake_after" );
35  status = rtems_task_wake_after( TICKS_PER_SECOND / 2 );
36  directive_failed( status, "rtems_task_wake_after" );
37}
38
39rtems_task Init(
40  rtems_task_argument argument
41)
42{
43  rtems_status_code  status;
44
45  puts( "\n\n*** TEST 45 ***" );
46
47  status = rtems_timer_initiate_server(
48    RTEMS_TIMER_SERVER_DEFAULT_PRIORITY,
49    RTEMS_MINIMUM_STACK_SIZE,
50    RTEMS_DEFAULT_ATTRIBUTES
51  );
52  directive_failed( status, "rtems_timer_initiate_server" );
53
54  /*
55   * Initialize Timers
56   */
57
58  Timer_name[ 1 ] = rtems_build_name( 'T', 'M', '1', ' ' );
59  Timer_name[ 2 ] = rtems_build_name( 'T', 'M', '2', ' ' );
60
61  puts( "INIT - rtems_timer_create - creating timer 1" );
62  status = rtems_timer_create( Timer_name[ 1 ], &Timer_id[ 1 ] );
63  directive_failed( status, "rtems_timer_create" );
64  printf( "INIT - timer 1 has id (0x%x)\n", Timer_id[ 1 ] );
65
66  puts( "INIT - rtems_timer_create - creating timer 2" );
67  status = rtems_timer_create( Timer_name[ 2 ], &Timer_id[ 2 ] );
68  directive_failed( status, "rtems_timer_create" );
69  printf( "INIT - timer 2 has id (0x%x)\n", Timer_id[ 2 ] );
70
71  /*
72   *  Schedule malloc TSR for 1 second from now
73   */
74
75  TSR_fired = 0;
76  TSR_malloc_ptr = (void *) 0xa5a5a5;
77  puts( "TA1 - rtems_timer_server_fire_after - timer 1 in 1 seconds" );
78  status = rtems_timer_server_fire_after(
79    Timer_id[ 1 ],
80    1 * TICKS_PER_SECOND,
81    Malloc_From_TSR,
82    NULL
83  );
84  directive_failed( status, "rtems_timer_server_fire_after" );
85
86  puts( "TA1 - rtems_task_wake_after - 2 second" );
87  status = rtems_task_wake_after( 2 * TICKS_PER_SECOND );
88  directive_failed( status, "rtems_task_wake_after" );
89
90  if ( TSR_fired == 2 &&
91       (TSR_malloc_ptr && TSR_malloc_ptr != (void *)0xa5a5a5) )
92    puts( "TSR appears to have executed OK" );
93  else {
94    printf( "FAILURE ptr=%p TSR_fired=%d\n", TSR_malloc_ptr, TSR_fired );
95    rtems_test_exit( 0 );
96  }
97
98  /*
99   *  Delete timer and exit test
100   */
101  puts( "TA1 - timer_deleting - timer 1" );
102  status = rtems_timer_delete( Timer_id[ 1 ] );
103  directive_failed( status, "rtems_timer_delete" );
104
105
106  puts( "*** END OF TEST 45 *** " );
107  rtems_test_exit( 0 );
108}
109
110#define CONFIGURE_INIT
111/* configuration information */
112
113#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
114#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
115
116/* Two Tasks: Init and Timer Server */
117#define CONFIGURE_MAXIMUM_TASKS           2
118#define CONFIGURE_MAXIMUM_TIMERS          2
119#define CONFIGURE_INIT_TASK_STACK_SIZE    (RTEMS_MINIMUM_STACK_SIZE * 2)
120
121#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
122
123#define CONFIGURE_EXTRA_TASK_STACKS       (1 * RTEMS_MINIMUM_STACK_SIZE)
124
125#include <rtems/confdefs.h>
126
Note: See TracBrowser for help on using the repository browser.