OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [tests/] [sptests/] [sp11/] [task1.c] - Blame information for rev 389

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*  Task_1
2
 *
3
 *  This routine serves as a test task.  It verifies the event maager.
4
 *
5
 *  Input parameters:
6
 *    argument - task argument
7
 *
8
 *  Output parameters:  NONE
9
 *
10
 *  COPYRIGHT (c) 1989-1999.
11
 *  On-Line Applications Research Corporation (OAR).
12
 *
13
 *  The license and distribution terms for this file may be
14
 *  found in the file LICENSE in this distribution or at
15
 *  http://www.OARcorp.com/rtems/license.html.
16
 *
17
 *  $Id: task1.c,v 1.2 2001-09-27 12:02:32 chris Exp $
18
 */
19
 
20
#include "system.h"
21
 
22
rtems_task Task_1(
23
  rtems_task_argument argument
24
)
25
{
26
  rtems_event_set   eventout;
27
  rtems_time_of_day time;
28
  rtems_status_code status;
29
  rtems_unsigned32  index;
30
 
31
  puts( "TA1 - rtems_event_send - send RTEMS_EVENT_16 to TA2" );
32
  status = rtems_event_send( Task_id[ 2 ], RTEMS_EVENT_16 );
33
  directive_failed( status, "rtems_event_send" );
34
 
35
  puts(
36
    "TA1 - rtems_event_receive - waiting forever on "
37
      "RTEMS_EVENT_14 and RTEMS_EVENT_15"
38
  );
39
  status = rtems_event_receive(
40
    RTEMS_EVENT_14 | RTEMS_EVENT_15,
41
    RTEMS_DEFAULT_OPTIONS,
42
    RTEMS_NO_TIMEOUT,
43
    &eventout
44
  );
45
  directive_failed( status, "rtems_event_receive" );
46
  printf(
47
    "TA1 - RTEMS_EVENT_14 and RTEMS_EVENT_15 received - eventout => %08x\n",
48
    eventout
49
  );
50
 
51
  puts( "TA1 - rtems_event_send - send RTEMS_EVENT_18 to TA2" );
52
  status = rtems_event_send( Task_id[ 2 ], RTEMS_EVENT_18 );
53
  directive_failed( status, "rtems_event_send" );
54
 
55
  puts(
56
  "TA1 - rtems_event_receive - waiting with 10 second timeout on RTEMS_EVENT_14"
57
  );
58
  status = rtems_event_receive(
59
    RTEMS_EVENT_14,
60
    RTEMS_DEFAULT_OPTIONS,
61
    10 * TICKS_PER_SECOND,
62
    &eventout
63
  );
64
  directive_failed( status, "rtems_event_receive" );
65
  printf( "TA1 - RTEMS_EVENT_14 received - eventout => %08x\n", eventout );
66
 
67
  puts( "TA1 - rtems_event_send - send RTEMS_EVENT_19 to TA2" );
68
  status = rtems_event_send( Task_id[ 2 ], RTEMS_EVENT_19 );
69
  directive_failed( status, "rtems_event_send" );
70
 
71
  status = rtems_clock_get( RTEMS_CLOCK_GET_TOD, &time );
72
  directive_failed( status, "rtems_clock_get" );
73
  print_time( "TA1 - rtems_clock_get - ", &time, "\n" );
74
 
75
rtems_test_pause();
76
 
77
  puts( "TA1 - rtems_event_send - send RTEMS_EVENT_18 to self after 5 seconds");
78
  status = rtems_timer_fire_after(
79
    Timer_id[ 1 ],
80
    5 * TICKS_PER_SECOND,
81
    TA1_send_18_to_self_5_seconds,
82
    NULL
83
  );
84
  directive_failed( status, "rtems_timer_fire_after 5 seconds" );
85
 
86
  puts( "TA1 - rtems_event_receive - waiting forever on RTEMS_EVENT_18"  );
87
  status = rtems_event_receive(
88
    RTEMS_EVENT_18,
89
    RTEMS_DEFAULT_OPTIONS,
90
    RTEMS_NO_TIMEOUT,
91
    &eventout
92
  );
93
  directive_failed( status, "rtems_event_receive of 18" );
94
  printf( "TA1 - RTEMS_EVENT_18 received - eventout => %08x\n", eventout );
95
 
96
  status = rtems_clock_get( RTEMS_CLOCK_GET_TOD, &time );
97
  directive_failed( status, "TA1 rtems_clock_get" );
98
  print_time( "TA1 - rtems_clock_get - ", &time, "\n" );
99
 
100
  puts( "TA1 - rtems_event_send - send RTEMS_EVENT_3 to self" );
101
  status = rtems_event_send( RTEMS_SELF, RTEMS_EVENT_3 );
102
  directive_failed( status, "rtems_event_send" );
103
 
104
  puts(
105
    "TA1 - rtems_event_receive - RTEMS_EVENT_3 or "
106
      "RTEMS_EVENT_22 - NO_WAIT and ANY"
107
  );
108
  status = rtems_event_receive(
109
    RTEMS_EVENT_3 | RTEMS_EVENT_22,
110
    RTEMS_NO_WAIT | RTEMS_EVENT_ANY,
111
    RTEMS_NO_TIMEOUT,
112
    &eventout
113
  );
114
  directive_failed( status, "rtems_event_receive of 3 and 22" );
115
  printf( "TA1 - RTEMS_EVENT_3 received - eventout => %08x\n", eventout );
116
 
117
  puts( "TA1 - rtems_event_send - send RTEMS_EVENT_4 to self" );
118
  status = rtems_event_send( RTEMS_SELF, RTEMS_EVENT_4 );
119
  directive_failed( status, "rtems_event_send" );
120
 
121
  puts (
122
  "TA1 - rtems_event_receive - RTEMS_EVENT_4 or "
123
      "RTEMS_EVENT_5 - forever and ANY"
124
  );
125
  status = rtems_event_receive(
126
    RTEMS_EVENT_4 | RTEMS_EVENT_5,
127
    RTEMS_EVENT_ANY,
128
    RTEMS_NO_TIMEOUT,
129
    &eventout
130
  );
131
  directive_failed( status, "rtems_event_receive" );
132
  printf( "TA1 - RTEMS_EVENT_4 received - eventout => %08x\n", eventout );
133
 
134
rtems_test_pause();
135
 
136
  puts( "TA1 - rtems_event_send - send RTEMS_EVENT_18 to self after 5 seconds");
137
  status = rtems_timer_fire_after(
138
    Timer_id[ 1 ],
139
    5 * TICKS_PER_SECOND,
140
    TA1_send_18_to_self_5_seconds,
141
    NULL
142
  );
143
  directive_failed( status, "rtems_timer_fire_after 5 seconds" );
144
 
145
  puts( "TA1 - rtems_timer_cancel - cancelling timer for event RTEMS_EVENT_18");
146
  status = rtems_timer_cancel( Timer_id[ 1 ] );
147
  directive_failed( status, "rtems_timer_cancel" );
148
 
149
  puts( "TA1 - rtems_event_send - send RTEMS_EVENT_8 to self after 60 seconds");
150
  status = rtems_timer_fire_after(
151
    Timer_id[ 1 ],
152
    60 * TICKS_PER_SECOND,
153
    TA1_send_8_to_self_60_seconds,
154
    NULL
155
  );
156
  directive_failed( status, "rtems_timer_fire_after 60 seconds" );
157
 
158
  puts( "TA1 - rtems_event_send - send RTEMS_EVENT_9 to self after 60 seconds");
159
  status = rtems_timer_fire_after(
160
    Timer_id[ 2 ],
161
    60 * TICKS_PER_SECOND,
162
    TA1_send_9_to_self_60_seconds,
163
    NULL
164
  );
165
  directive_failed( status, "rtems_timer_fire_after 60 seconds" );
166
 
167
  puts(
168
    "TA1 - rtems_event_send - send RTEMS_EVENT_10 to self after 60 seconds"
169
  );
170
  status = rtems_timer_fire_after(
171
    Timer_id[ 3 ],
172
    60 * TICKS_PER_SECOND,
173
    TA1_send_10_to_self,
174
    NULL
175
  );
176
  directive_failed( status, "rtems_timer_fire_after 60 seconds" );
177
 
178
  puts( "TA1 - rtems_timer_cancel - cancelling timer for event RTEMS_EVENT_8" );
179
  status = rtems_timer_cancel( Timer_id[ 1 ] );
180
  directive_failed( status, "rtems_timer_cancel" );
181
 
182
  build_time( &time, 2, 12, 1988, 8, 15, 0, 0 );
183
 
184
  print_time( "TA1 - rtems_clock_set - ", &time, "\n" );
185
  status = rtems_clock_set( &time );
186
  directive_failed( status, "rtems_clock_set" );
187
 
188
  puts( "TA1 - rtems_event_send - send RTEMS_EVENT_1 every second" );
189
  status = rtems_timer_fire_after(
190
    Timer_id[ 1 ],
191
    TICKS_PER_SECOND,
192
    TA1_send_1_to_self_every_second,
193
    NULL
194
  );
195
  directive_failed( status, "rtems_timer_fire_after 1 second" );
196
 
197
  for ( index = 0; index < 3; index++ ) {
198
 
199
    status = rtems_event_receive(
200
      RTEMS_EVENT_1,
201
      RTEMS_EVENT_ANY,
202
      RTEMS_NO_TIMEOUT,
203
      &eventout
204
    );
205
    directive_failed( status, "rtems_event_receive" );
206
 
207
    status = rtems_clock_get( RTEMS_CLOCK_GET_TOD, &time );
208
    directive_failed( status, "rtems_clock_get" );
209
 
210
    printf( "TA1 - RTEMS_EVENT_1 received - eventout => %08x - ", eventout );
211
    print_time( "at ", &time, "\n" );
212
 
213
    if ( index < 2 ) {
214
      status = rtems_timer_reset( Timer_id[ 1 ] );
215
      directive_failed( status, "rtems_timer_reset" );
216
    };
217
 
218
  }
219
 
220
  puts( "TA1 - rtems_timer_cancel - cancelling timer for event RTEMS_EVENT_1" );
221
  status = rtems_timer_cancel( Timer_id[ 1 ] );
222
  directive_failed( status, "rtems_timer_cancel" );
223
 
224
rtems_test_pause();
225
 
226
  time.day = 13;
227
  puts( "TA1 - rtems_event_send - sending RTEMS_EVENT_11 to self in 1 day" );
228
  status = rtems_timer_fire_when(
229
    Timer_id[ 1 ],
230
    &time,
231
    TA1_send_11_to_self,
232
    NULL
233
  );
234
  directive_failed( status, "rtems_timer_fire_when 1 day" );
235
 
236
  time.hour = 7;
237
  puts( "TA1 - rtems_event_send - sending RTEMS_EVENT_11 to self in 1 day" );
238
  status = rtems_timer_fire_when(
239
    Timer_id[ 2 ],
240
    &time,
241
    TA1_send_11_to_self,
242
    NULL
243
  );
244
  directive_failed( status, "rtems_timer_fire_when 1 day" );
245
 
246
  time.hour = 8;   /* so code below has correct time/date */
247
  time.day = 14;
248
  puts( "TA1 - rtems_event_send - sending RTEMS_EVENT_11 to self in 2 days" );
249
  status = rtems_timer_fire_when(
250
    Timer_id[ 3 ],
251
    &time,
252
    TA1_send_11_to_self,
253
    NULL
254
  );
255
  directive_failed( status, "rtems_timer_fire_when 2 days" );
256
 
257
  puts("TA1 - rtems_timer_cancel - cancelling RTEMS_EVENT_11 to self in 1 day");
258
  status = rtems_timer_cancel( Timer_id[ 1 ] );
259
  directive_failed( status, "rtems_timer_cancel" );
260
 
261
  puts(
262
    "TA1 - rtems_timer_cancel - cancelling RTEMS_EVENT_11 to self in 2 days"
263
  );
264
  status = rtems_timer_cancel( Timer_id[ 3 ] );
265
  directive_failed( status, "rtems_timer_cancel" );
266
 
267
  puts(
268
    "TA1 - rtems_event_send - resending RTEMS_EVENT_11 to self in 2 days"
269
  );
270
  status = rtems_timer_fire_when(
271
    Timer_id[ 3 ],
272
    &time,
273
    TA1_send_11_to_self,
274
    NULL
275
  );
276
  directive_failed( status, "rtems_timer_fire_when 2 days" );
277
 
278
  time.day = 15;
279
  print_time( "TA1 - rtems_clock_set - ", &time, "\n" );
280
  status = rtems_clock_set( &time );
281
  directive_failed( status, "TA1 rtems_clock_set" );
282
 
283
  puts( "TA1 - rtems_event_receive - waiting forever on RTEMS_EVENT_11" );
284
  status = rtems_event_receive(
285
    RTEMS_EVENT_11,
286
    RTEMS_DEFAULT_OPTIONS,
287
    RTEMS_NO_TIMEOUT,
288
    &eventout
289
  );
290
  directive_failed( status, "rtems_event_receive" );
291
  printf( "TA1 - RTEMS_EVENT_11 received - eventout => %08x\n", eventout );
292
 
293
rtems_test_pause();
294
 
295
  puts( "TA1 - rtems_event_send/rtems_event_receive combination" );
296
  status = rtems_timer_fire_after(
297
    Timer_id[ 1 ],
298
    10,
299
    TA1_send_11_to_self,
300
    NULL
301
  );
302
  directive_failed( status, "rtems_timer_fire_after 10 ticks" );
303
 
304
  status = rtems_event_receive(
305
    RTEMS_EVENT_11,
306
    RTEMS_DEFAULT_OPTIONS,
307
    RTEMS_NO_TIMEOUT,
308
    &eventout
309
  );
310
  directive_failed( status, "rtems_event_receive" );
311
 
312
  build_time( &time, 2, 12, 1988, 8, 15, 0, 0 );
313
 
314
  print_time( "TA1 - rtems_clock_set - ", &time, "\n" );
315
  status = rtems_clock_set( &time );
316
  directive_failed( status, "rtems_clock_set" );
317
 
318
  time.day = 13;
319
  puts( "TA1 - rtems_event_receive all outstanding events" );
320
  status  = rtems_event_receive(
321
    RTEMS_ALL_EVENTS,
322
    RTEMS_NO_WAIT | RTEMS_EVENT_ANY,
323
    0,
324
    &eventout
325
  );
326
  fatal_directive_status(
327
    status,
328
    RTEMS_UNSATISFIED,
329
    "rtems_event_receive all events"
330
  );
331
 
332
  puts( "TA1 - rtems_event_send - sending RTEMS_EVENT_10 to self in 1 day" );
333
  status = rtems_timer_fire_when(
334
    Timer_id[ 1 ],
335
    &time,
336
    TA1_send_10_to_self,
337
    NULL
338
  );
339
  directive_failed( status, "rtems_timer_fire_when 1 day" );
340
 
341
  time.day = 14;
342
  puts( "TA1 - rtems_event_send - sending RTEMS_EVENT_11 to self in 2 days" );
343
  status = rtems_timer_fire_when(
344
    Timer_id[ 2 ],
345
    &time,
346
    TA1_send_11_to_self,
347
    NULL
348
  );
349
  directive_failed( status, "rtems_timer_fire_when 2 days" );
350
 
351
  build_time( &time, 2, 12, 1988, 7, 15, 0, 0 );
352
 
353
  print_time( "TA1 - rtems_clock_set - ", &time, "\n" );
354
  puts( "TA1 - set time backwards" );
355
  status = rtems_clock_set( &time );
356
  directive_failed( status, "rtems_clock_set" );
357
 
358
  status  = rtems_event_receive(
359
    RTEMS_ALL_EVENTS,
360
    RTEMS_NO_WAIT | RTEMS_EVENT_ANY,
361
    RTEMS_NO_TIMEOUT,
362
    &eventout
363
  );
364
  if ( eventout ) printf( "ERROR -0x%08x events received\n", eventout );
365
  else            puts( "TA1 - no events received" );
366
  fatal_directive_status(
367
    status,
368
    RTEMS_UNSATISFIED,
369
    "rtems_event_receive all events"
370
  );
371
 
372
  build_time( &time, 2, 14, 1988, 7, 15, 0, 0 );
373
 
374
  print_time( "TA1 - rtems_clock_set - ", &time, "\n" );
375
  puts( "TA1 - set time forwards (leave a timer)" );
376
  status = rtems_clock_set( &time );
377
  directive_failed( status, "rtems_clock_set" );
378
 
379
  status  = rtems_event_receive(
380
    RTEMS_ALL_EVENTS,
381
    RTEMS_NO_WAIT | RTEMS_EVENT_ANY,
382
    RTEMS_NO_TIMEOUT,
383
    &eventout
384
  );
385
  if ( eventout == RTEMS_EVENT_10 ) puts( "TA1 - RTEMS_EVENT_10 received" );
386
  else      printf( "ERROR -0x%08x events received\n", eventout );
387
  directive_failed( status, "rtems_event_receive all events" );
388
 
389
  puts( "TA1 - rtems_event_send - sending RTEMS_EVENT_11 to self in 100 ticks");
390
  status = rtems_timer_fire_after(
391
    Timer_id[ 1 ],
392
    100,
393
    TA1_send_11_to_self,
394
    NULL
395
  );
396
  directive_failed( status, "rtems_timer_fire_after 100 ticks" );
397
 
398
  puts( "TA1 - rtems_event_send - sending RTEMS_EVENT_11 to self in 200 ticks");
399
  status = rtems_timer_fire_after(
400
    Timer_id[ 1 ],
401
    200,
402
    TA1_send_11_to_self,
403
    NULL
404
  );
405
  directive_failed( status, "rtems_timer_fire_after 200 ticks" );
406
 
407
  puts( "*** END OF TEST 11 ***" );
408
  exit( 0 );
409
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.