source: rtems/testsuites/mptests/mp14/init.c @ c499856

4.115
Last change on this file since c499856 was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

Change all references of rtems.com to rtems.org.

  • Property mode set to 100644
File size: 5.2 KB
Line 
1/*  Init
2 *
3 *  This routine is the initialization task for this test program.
4 *  It is a user initialization task and has the responsibility for creating
5 *  and starting the tasks that make up the test.  If the time of day
6 *  clock is required for the test, it should also be set to a known
7 *  value by this function.
8 *
9 *  Input parameters:
10 *    argument - task argument
11 *
12 *  Output parameters:  NONE
13 *
14 *  COPYRIGHT (c) 1989-2009.
15 *  On-Line Applications Research Corporation (OAR).
16 *
17 *  The license and distribution terms for this file may be
18 *  found in the file LICENSE in this distribution or at
19 *  http://www.rtems.org/license/LICENSE.
20 */
21
22#ifdef HAVE_CONFIG_H
23#include "config.h"
24#endif
25
26#define CONFIGURE_INIT
27#include "system.h"
28
29uint8_t   my_partition[0x30000] CPU_STRUCTURE_ALIGNMENT;
30
31rtems_timer_service_routine Stop_Test_TSR(
32  rtems_id  ignored_id,
33  void     *ignored_address
34)
35{
36  Stop_Test = true;
37}
38
39rtems_task Init(
40  rtems_task_argument argument
41)
42{
43  rtems_status_code   status;
44  rtems_task_priority previous_priority;
45
46  printf(
47    "\n\n*** TEST 14 -- NODE %" PRId32 " ***\n",
48    Multiprocessing_configuration.node
49  );
50
51  Stop_Test = false;
52
53  status = rtems_timer_create(
54    rtems_build_name('S', 'T', 'O', 'P'),
55    &timer_id
56  );
57  directive_failed( status, "rtems_timer_create" );
58
59  status = rtems_timer_fire_after(
60    timer_id,
61    MAX_LONG_TEST_DURATION * rtems_clock_get_ticks_per_second(),
62    Stop_Test_TSR,
63    NULL
64  );
65  directive_failed( status, "rtems_timer_fire_after" );
66
67  Task_name[ 1 ] = rtems_build_name( '1', '1', '1', ' ' );
68  Task_name[ 2 ] = rtems_build_name( '2', '2', '2', ' ' );
69
70  Queue_task_name[ 1 ] = rtems_build_name( 'M', 'T', '1', ' ' );
71  Queue_task_name[ 2 ] = rtems_build_name( 'M', 'T', '2', ' ' );
72
73  Partition_task_name[ 1 ] = rtems_build_name( 'P', 'T', '1', ' ' );
74  Partition_task_name[ 2 ] = rtems_build_name( 'P', 'T', '2', ' ' );
75
76  Semaphore_task_name[ 1 ] = rtems_build_name( 'S', 'M', '1', ' ' );
77  Semaphore_task_name[ 2 ] = rtems_build_name( 'S', 'M', '2', ' ' );
78
79  Semaphore_name[ 1 ] =  rtems_build_name( 'S', 'E', 'M', ' ' );
80
81  Queue_name[ 1 ] = rtems_build_name( 'M', 'S', 'G', ' ' );
82
83  Partition_name[ 1 ] = rtems_build_name( 'P', 'A', 'R', ' ' );
84
85  Timer_name[ 1 ] = rtems_build_name( 'T', 'M', 'R', ' ' );
86
87  if ( Multiprocessing_configuration.node == 1 ) {
88    puts( "Creating Semaphore (Global)" );
89    status = rtems_semaphore_create(
90      Semaphore_name[ 1 ],
91      1,
92      RTEMS_GLOBAL,
93      RTEMS_NO_PRIORITY,
94      &Semaphore_id[ 1 ]
95    );
96    directive_failed( status, "rtems_semaphore_create" );
97
98    puts( "Creating Message Queue (Global)" );
99    status = rtems_message_queue_create(
100      Queue_name[ 1 ],
101      1,
102      16,
103      RTEMS_GLOBAL,
104      &Queue_id[ 1 ]
105    );
106    directive_failed( status, "rtems_message_queue_create" );
107
108    puts( "Creating Partition (Global)" );
109    status = rtems_partition_create(
110      Partition_name[ 1 ],
111      (void *)my_partition,
112      0x8000,
113      0x3800,
114      RTEMS_GLOBAL,
115      &Partition_id[ 1 ]
116    );
117    directive_failed( status, "rtems_partition_create" );
118  }
119
120  puts( "Creating Event task (Global)" );
121  status = rtems_task_create(
122    Task_name[ Multiprocessing_configuration.node ],
123    2,
124    RTEMS_MINIMUM_STACK_SIZE,
125    RTEMS_TIMESLICE,
126    RTEMS_GLOBAL,
127    &Event_task_id[ 1 ]
128  );
129  directive_failed( status, "rtems_task_create" );
130
131  puts( "Starting Event task (Global)" );
132  status = rtems_task_start( Event_task_id[ 1 ], Test_task, 0 );
133  directive_failed( status, "rtems_task_start" );
134
135  puts( "Creating Semaphore task (Global)" );
136  status = rtems_task_create(
137    Semaphore_task_name[ Multiprocessing_configuration.node ],
138    2,
139    RTEMS_MINIMUM_STACK_SIZE,
140    RTEMS_TIMESLICE,
141    RTEMS_GLOBAL,
142    &Semaphore_task_id[ 1 ]
143  );
144  directive_failed( status, "rtems_task_create" );
145
146  puts( "Starting Semaphore task (Global)" );
147  status = rtems_task_start( Semaphore_task_id[ 1 ], Semaphore_task, 0 );
148  directive_failed( status, "rtems_task_start" );
149
150  puts( "Creating Message Queue task (Global)" );
151  status = rtems_task_create(
152    Queue_task_name[ Multiprocessing_configuration.node ],
153    2,
154    RTEMS_MINIMUM_STACK_SIZE,
155    RTEMS_TIMESLICE,
156    RTEMS_GLOBAL,
157    &Queue_task_id[ 1 ]
158  );
159  directive_failed( status, "rtems_task_create" );
160
161  /* argument is index into Buffers */
162  puts( "Starting Message Queue task (Global)" );
163  status = rtems_task_start( Queue_task_id[ 1 ], Message_queue_task, 1 );
164  directive_failed( status, "rtems_task_start" );
165
166  puts( "Creating Partition task (Global)" );
167  status = rtems_task_create(
168    Partition_task_name[ Multiprocessing_configuration.node ],
169    2,
170    RTEMS_MINIMUM_STACK_SIZE * 2,
171    RTEMS_TIMESLICE,
172    RTEMS_GLOBAL,
173    &Partition_task_id[ 1 ]
174  );
175  directive_failed( status, "rtems_task_create" );
176
177  puts( "Starting Partition task (Global)" );
178  status = rtems_task_start( Partition_task_id[ 1 ], Partition_task, 0 );
179  directive_failed( status, "rtems_task_start" );
180
181  status = rtems_task_set_priority( RTEMS_SELF, 2, &previous_priority );
182  directive_failed( status, "rtems_task_set_priority" );
183
184  status = rtems_task_ident(
185    RTEMS_SELF,
186    RTEMS_SEARCH_ALL_NODES,
187    &Task_id[ 1 ]
188  );
189  directive_failed( status, "rtems_task_ident" );
190
191  Delayed_events_task( 1 );
192}
Note: See TracBrowser for help on using the repository browser.