source: rtems/c/src/ada-tests/sptests/sp14/sptest.adb @ f6bcc8f5

Last change on this file since f6bcc8f5 was f6bcc8f5, checked in by Joel Sherrill <joel.sherrill@…>, on 09/04/03 at 13:25:16

2003-09-04 Joel Sherrill <joel@…>

  • samples/base_sp/base_sp.adb, samples/base_sp/config.h, samples/base_sp/sptest.adb, samples/base_sp/sptest.ads, samples/hello/config.h, samples/hello/hello.adb, samples/hello/sptest.adb, samples/hello/sptest.ads, samples/ticker/config.h, samples/ticker/sptest.adb, samples/ticker/sptest.ads, samples/ticker/ticker.adb, sptests/sp01/config.h, sptests/sp01/sp01.adb, sptests/sp01/sptest.adb, sptests/sp01/sptest.ads, sptests/sp02/config.h, sptests/sp02/sp02.adb, sptests/sp02/sptest.adb, sptests/sp02/sptest.ads, sptests/sp03/config.h, sptests/sp03/sp03.adb, sptests/sp03/sptest.adb, sptests/sp03/sptest.ads, sptests/sp04/config.h, sptests/sp04/sp04.adb, sptests/sp04/sptest.adb, sptests/sp04/sptest.ads, sptests/sp05/config.h, sptests/sp05/sp05.adb, sptests/sp05/sptest.adb, sptests/sp05/sptest.ads, sptests/sp06/config.h, sptests/sp06/sp06.adb, sptests/sp06/sptest.adb, sptests/sp06/sptest.ads, sptests/sp07/config.h, sptests/sp07/sp07.adb, sptests/sp07/sptest.adb, sptests/sp07/sptest.ads, sptests/sp08/config.h, sptests/sp08/sp08.adb, sptests/sp08/sptest.adb, sptests/sp08/sptest.ads, sptests/sp09/config.h, sptests/sp09/sp09.adb, sptests/sp09/sptest.adb, sptests/sp09/sptest.ads, sptests/sp11/config.h, sptests/sp11/sp11.adb, sptests/sp11/sptest.adb, sptests/sp11/sptest.ads, sptests/sp12/config.h, sptests/sp12/sp12.adb, sptests/sp12/sptest.adb, sptests/sp12/sptest.ads, sptests/sp13/config.h, sptests/sp13/sp13.adb, sptests/sp13/sptest.adb, sptests/sp13/sptest.ads, sptests/sp14/config.h, sptests/sp14/sp14.adb, sptests/sp14/sptest.adb, sptests/sp14/sptest.ads, sptests/sp15/config.h, sptests/sp15/sp15.adb, sptests/sp15/sptest.adb, sptests/sp15/sptest.ads, sptests/sp16/config.h, sptests/sp16/sp16.adb, sptests/sp16/sptest.adb, sptests/sp16/sptest.ads, sptests/sp17/config.h, sptests/sp17/sp17.adb, sptests/sp17/sptest.adb, sptests/sp17/sptest.ads, sptests/sp19/config.h, sptests/sp19/sp19.adb, sptests/sp19/sptest.adp, sptests/sp19/sptest.ads, sptests/sp20/config.h, sptests/sp20/sp20.adb, sptests/sp20/sptest.adb, sptests/sp20/sptest.ads, sptests/sp21/config.h, sptests/sp21/sp21.adb, sptests/sp21/sptest.adb, sptests/sp21/sptest.ads, sptests/sp22/config.h, sptests/sp22/sp22.adb, sptests/sp22/sptest.adb, sptests/sp22/sptest.ads, sptests/sp23/config.h, sptests/sp23/sp23.adb, sptests/sp23/sptest.adb, sptests/sp23/sptest.ads, sptests/sp24/config.h, sptests/sp24/sp24.adb, sptests/sp24/sptest.adb, sptests/sp24/sptest.ads, sptests/sp25/config.h, sptests/sp25/sp25.adb, sptests/sp25/sptest.adb, sptests/sp25/sptest.ads, sptests/spsize/spsize.adb, sptests/spsize/sptest.adb, sptests/spsize/sptest.ads, support/address_io.adb, support/address_io.ads, support/float_io.ads, support/fp.inc, support/init.c, support/integer.inc, support/rtems_calling_overhead.ads, support/status_io.ads, support/test_support.adb, support/test_support.ads, support/time_test_support.adb, support/time_test_support.ads, support/timer_driver.adb, support/timer_driver.ads, support/unsigned32_io.ads, tmtests/tm01/config.h, tmtests/tm01/tm01.adb, tmtests/tm01/tmtest.adb, tmtests/tm01/tmtest.ads, tmtests/tm02/config.h, tmtests/tm02/tm02.adb, tmtests/tm02/tmtest.adb, tmtests/tm02/tmtest.ads, tmtests/tm03/config.h, tmtests/tm03/tm03.adb, tmtests/tm03/tmtest.adb, tmtests/tm03/tmtest.ads, tmtests/tm04/config.h, tmtests/tm04/tm04.adb, tmtests/tm04/tmtest.adb, tmtests/tm04/tmtest.ads, tmtests/tm05/config.h, tmtests/tm05/tm05.adb, tmtests/tm05/tmtest.adb, tmtests/tm05/tmtest.ads, tmtests/tm06/config.h, tmtests/tm06/tm06.adb, tmtests/tm06/tmtest.adb, tmtests/tm06/tmtest.ads, tmtests/tm07/config.h, tmtests/tm07/tm07.adb, tmtests/tm07/tmtest.adb, tmtests/tm07/tmtest.ads, tmtests/tm08/config.h, tmtests/tm08/tm08.adb, tmtests/tm08/tmtest.adb, tmtests/tm08/tmtest.ads, tmtests/tm09/config.h, tmtests/tm09/tm09.adb, tmtests/tm09/tmtest.adb, tmtests/tm09/tmtest.ads, tmtests/tm10/config.h, tmtests/tm10/tm10.adb, tmtests/tm10/tmtest.adb, tmtests/tm10/tmtest.ads, tmtests/tm11/config.h, tmtests/tm11/tm11.adb, tmtests/tm11/tmtest.adb, tmtests/tm11/tmtest.ads, tmtests/tm12/config.h, tmtests/tm12/tm12.adb, tmtests/tm12/tmtest.adb, tmtests/tm12/tmtest.ads, tmtests/tm13/config.h, tmtests/tm13/tm13.adb, tmtests/tm13/tmtest.adb, tmtests/tm13/tmtest.ads, tmtests/tm14/config.h, tmtests/tm14/tm14.adb, tmtests/tm14/tmtest.adb, tmtests/tm14/tmtest.ads, tmtests/tm15/config.h, tmtests/tm15/tm15.adb, tmtests/tm15/tmtest.adb, tmtests/tm15/tmtest.ads, tmtests/tm16/config.h, tmtests/tm16/tm16.adb, tmtests/tm16/tmtest.adb, tmtests/tm16/tmtest.ads, tmtests/tm17/config.h, tmtests/tm17/tm17.adb, tmtests/tm17/tmtest.adb, tmtests/tm17/tmtest.ads, tmtests/tm18/config.h, tmtests/tm18/tm18.adb, tmtests/tm18/tmtest.adb, tmtests/tm18/tmtest.ads, tmtests/tm19/config.h, tmtests/tm19/tm19.adb, tmtests/tm19/tmtest.adb, tmtests/tm19/tmtest.ads, tmtests/tm20/config.h, tmtests/tm20/tm20.adb, tmtests/tm20/tmtest.adb, tmtests/tm20/tmtest.ads, tmtests/tm21/config.h, tmtests/tm21/tm21.adb, tmtests/tm21/tmtest.adb, tmtests/tm21/tmtest.ads, tmtests/tm22/config.h, tmtests/tm22/tm22.adb, tmtests/tm22/tmtest.adb, tmtests/tm22/tmtest.ads, tmtests/tm23/config.h, tmtests/tm23/tm23.adb, tmtests/tm23/tmtest.adb, tmtests/tm23/tmtest.ads, tmtests/tm24/config.h, tmtests/tm24/tm24.adb, tmtests/tm24/tmtest.adb, tmtests/tm24/tmtest.ads, tmtests/tm25/config.h, tmtests/tm25/tm25.adb, tmtests/tm25/tmtest.adb, tmtests/tm25/tmtest.ads, tmtests/tm28/config.h, tmtests/tm28/tm28.adb, tmtests/tm28/tmtest.adb, tmtests/tm28/tmtest.ads, tmtests/tm29/config.h, tmtests/tm29/tm29.adb, tmtests/tm29/tmtest.adb, tmtests/tm29/tmtest.ads, tmtests/tmck/config.h, tmtests/tmck/tmck.adb, tmtests/tmck/tmtest.adb, tmtests/tmck/tmtest.ads, tmtests/tmoverhd/config.h, tmtests/tmoverhd/dummy_rtems.adb, tmtests/tmoverhd/dummy_rtems.ads, tmtests/tmoverhd/tmoverhd.adb, tmtests/tmoverhd/tmtest.adb, tmtests/tmoverhd/tmtest.ads: Removed incorrect statement about copyright assignment.
  • Property mode set to 100644
File size: 8.7 KB
Line 
1--
2--  SPTEST / BODY
3--
4--  DESCRIPTION:
5--
6--  This package is the implementation of Test 14 of the RTEMS
7--  Single Processor Test Suite.
8--
9--  DEPENDENCIES:
10--
11-- 
12--
13--  COPYRIGHT (c) 1989-1997.
14--  On-Line Applications Research Corporation (OAR).
15--
16--  The license and distribution terms for this file may in
17--  the file LICENSE in this distribution or at
18--  http://www.OARcorp.com/rtems/license.html.
19--
20--  $Id$
21--
22
23with ADDRESS_IO;
24with RTEMS;
25with TEST_SUPPORT;
26with TEXT_IO;
27with UNSIGNED32_IO;
28with INTERFACES; use INTERFACES;
29
30package body SPTEST is
31
32--PAGE
33--
34--  INIT
35--
36
37   procedure INIT (
38      ARGUMENT : in     RTEMS.TASK_ARGUMENT
39   ) is
40      TIME   : RTEMS.TIME_OF_DAY;
41      STATUS : RTEMS.STATUS_CODES;
42   begin
43
44      TEXT_IO.NEW_LINE( 2 );
45      TEXT_IO.PUT_LINE( "*** TEST 14 ***" );
46
47      SPTEST.TASK_NAME( 1 ) := RTEMS.BUILD_NAME(  'T', 'A', '1', ' ' );
48      SPTEST.TASK_NAME( 2 ) := RTEMS.BUILD_NAME(  'T', 'A', '2', ' ' );
49
50      RTEMS.TASK_CREATE(
51         SPTEST.TASK_NAME( 1 ),
52         1,
53         RTEMS.MINIMUM_STACK_SIZE * 2,
54         RTEMS.DEFAULT_MODES,
55         RTEMS.DEFAULT_ATTRIBUTES,
56         SPTEST.TASK_ID( 1 ),
57         STATUS
58      );
59      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_CREATE OF TA1" );
60
61      RTEMS.TASK_CREATE(
62         SPTEST.TASK_NAME( 2 ),
63         1,
64         RTEMS.MINIMUM_STACK_SIZE * 2,
65         RTEMS.DEFAULT_MODES,
66         RTEMS.DEFAULT_ATTRIBUTES,
67         SPTEST.TASK_ID( 2 ),
68         STATUS
69      );
70      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_CREATE OF TA2" );
71
72      RTEMS.TASK_START(
73         SPTEST.TASK_ID( 1 ),
74         SPTEST.TASK_1'ACCESS,
75         0,
76         STATUS
77      );
78      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_START OF TA1" );
79
80      RTEMS.TASK_START(
81         SPTEST.TASK_ID( 2 ),
82         SPTEST.TASK_2'ACCESS,
83         0,
84         STATUS
85      );
86      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_START OF TA2" );
87
88      SPTEST.TIMER_NAME( 1 ) := RTEMS.BUILD_NAME(  'T', 'M', '1', ' ' );
89
90      RTEMS.TIMER_CREATE(
91         SPTEST.TIMER_NAME( 1 ),
92         SPTEST.TIMER_ID( 1 ),
93         STATUS
94      );
95      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TIMER_CREATE OF TM1" );
96
97      RTEMS.TASK_DELETE( RTEMS.SELF, STATUS );
98      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_DELETE OF SELF" );
99
100   end INIT;
101
102--PAGE
103--
104--  SIGNAL_3_TO_TASK_1
105--
106
107   procedure SIGNAL_3_TO_TASK_1 (
108      ID      : in     RTEMS.ID;
109      POINTER : in     RTEMS.ADDRESS
110   ) is
111      STATUS : RTEMS.STATUS_CODES;
112   begin
113
114      RTEMS.SIGNAL_SEND( SPTEST.TASK_ID( 1 ), RTEMS.SIGNAL_3, STATUS );
115      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "SIGNAL_SEND of 3" );
116
117      SPTEST.TIMER_GOT_THIS_ID      := ID;
118      SPTEST.TIMER_GOT_THIS_POINTER := POINTER;
119
120      SPTEST.SIGNAL_SENT := TRUE;
121
122   end SIGNAL_3_TO_TASK_1;
123
124--PAGE
125--
126--  TASK_1
127--
128
129   procedure TASK_1 (
130      ARGUMENT : in     RTEMS.TASK_ARGUMENT
131   ) is
132      PREVIOUS_MODE : RTEMS.MODE;
133      STATUS        : RTEMS.STATUS_CODES;
134   begin
135
136      TEXT_IO.PUT_LINE( "TA1 - signal_catch - INTERRUPT_LEVEL( 3 )" );
137      RTEMS.SIGNAL_CATCH(
138         SPTEST.PROCESS_ASR'ACCESS,
139         RTEMS.INTERRUPT_LEVEL( 3 ),
140         STATUS
141      );
142      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "SIGNAL_CATCH INTERRUPT(3)" );
143   
144      TEXT_IO.PUT_LINE( "TA1 - signal_send - SIGNAL_16 to self" );
145      RTEMS.SIGNAL_SEND( RTEMS.SELF, RTEMS.SIGNAL_16, STATUS );
146      TEST_SUPPORT.DIRECTIVE_FAILED(
147         STATUS,
148         "SIGNAL_SEND - SIGNAL_16 to SELF"
149      );
150
151      TEXT_IO.PUT_LINE( "TA1 - signal_send - SIGNAL_0 to self" );
152      RTEMS.SIGNAL_SEND( RTEMS.SELF, RTEMS.SIGNAL_0, STATUS );
153      TEST_SUPPORT.DIRECTIVE_FAILED(
154         STATUS,
155         "SIGNAL_SEND - SIGNAL_0 to SELF"
156      );
157
158      TEXT_IO.PUT_LINE( "TA1 - signal_catch - NO_ASR" );
159      RTEMS.SIGNAL_CATCH(SPTEST.PROCESS_ASR'ACCESS, RTEMS.NO_ASR, STATUS);
160      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "SIGNAL_CATCH - NO_ASR" );
161
162      TEST_SUPPORT.PAUSE;
163
164      TEXT_IO.PUT_LINE( "TA1 - signal_send - SIGNAL_1 to self" );
165      RTEMS.SIGNAL_SEND( RTEMS.SELF, RTEMS.SIGNAL_1, STATUS );
166      TEST_SUPPORT.DIRECTIVE_FAILED(
167         STATUS,
168         "SIGNAL_SEND - SIGNAL_1 to SELF"
169      );
170
171      TEXT_IO.PUT_LINE( "TA1 - task_mode - disable ASRs" );
172      RTEMS.TASK_MODE(
173         RTEMS.NO_ASR,
174         RTEMS.ASR_MASK,
175         PREVIOUS_MODE,
176         STATUS
177      );
178      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_MODE" );
179
180      SPTEST.TIMER_GOT_THIS_ID := 0;
181      SPTEST.TIMER_GOT_THIS_POINTER := RTEMS.NULL_ADDRESS;
182
183      TEXT_IO.PUT_LINE( "TA1 - sending signal to SELF from timer" );
184      RTEMS.TIMER_FIRE_AFTER(
185         SPTEST.TIMER_ID( 1 ),
186         TEST_SUPPORT.TICKS_PER_SECOND / 2,
187         SPTEST.SIGNAL_3_TO_TASK_1'ACCESS,
188         SPTEST.TASK_1'ADDRESS,
189         STATUS
190      );
191      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TIMER_FIRE_AFTER" );
192
193      TEXT_IO.PUT_LINE( "TA1 - waiting for signal to arrive" );
194
195      SPTEST.SIGNAL_SENT := FALSE;
196      SPTEST.ASR_FIRED   := FALSE;
197
198      loop
199         exit when SPTEST.SIGNAL_SENT = TRUE;
200      end loop;
201
202      if SPTEST.TIMER_GOT_THIS_ID = SPTEST.TIMER_ID( 1 ) and then
203         RTEMS.ARE_EQUAL(SPTEST.TIMER_GOT_THIS_POINTER,
204             SPTEST.TASK_1'ADDRESS) then
205 
206         TEXT_IO.PUT_LINE( "TA1 - timer routine got the correct arguments" );
207
208      else
209
210         TEXT_IO.PUT( "TA1 - timer got (" );
211         UNSIGNED32_IO.PUT( SPTEST.TIMER_GOT_THIS_ID  );
212         TEXT_IO.PUT( "," );
213         ADDRESS_IO.PUT( SPTEST.TIMER_GOT_THIS_POINTER  );
214         TEXT_IO.PUT( ") instead of (" );
215         UNSIGNED32_IO.PUT( SPTEST.TIMER_ID( 1 ) );
216         TEXT_IO.PUT( "," );
217         ADDRESS_IO.PUT( SPTEST.TASK_1'ADDRESS  );
218         TEXT_IO.PUT_LINE( ")!!!!" );
219
220      end if;
221
222      TEXT_IO.PUT_LINE( "TA1 - task_mode - enable ASRs" );
223      RTEMS.TASK_MODE(
224         RTEMS.ASR,
225         RTEMS.ASR_MASK,
226         PREVIOUS_MODE,
227         STATUS
228      );
229      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_MODE" );
230
231      TEXT_IO.PUT_LINE( "TA1 - signal_catch - ASR ADDRESS of NULL" );
232      RTEMS.SIGNAL_CATCH( NULL, RTEMS.DEFAULT_MODES, STATUS );
233      TEST_SUPPORT.DIRECTIVE_FAILED(
234         STATUS,
235         "SIGNAL_CATCH - NULL ADDRESS"
236      );
237   
238      TEXT_IO.PUT_LINE( "TA1 - task_delete - delete self" );
239      RTEMS.TASK_DELETE( RTEMS.SELF, STATUS );
240      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_DELETE OF SELF" );
241
242   end TASK_1;
243
244--PAGE
245--
246--  TASK_2
247--
248
249   procedure TASK_2 (
250      ARGUMENT : in     RTEMS.TASK_ARGUMENT
251   ) is
252      STATUS : RTEMS.STATUS_CODES;
253   begin
254
255      TEXT_IO.PUT_LINE( "TA2 - signal_send - SIGNAL_17 to TA1" );
256      RTEMS.SIGNAL_SEND( SPTEST.TASK_ID( 1 ), RTEMS.SIGNAL_17, STATUS );
257      TEST_SUPPORT.DIRECTIVE_FAILED(
258         STATUS,
259         "SIGNAL_SEND - SIGNAL_17 to TA1"
260      );
261
262      TEXT_IO.PUT_LINE( "TA2 - task_wake_after - yield processor" );
263      RTEMS.TASK_WAKE_AFTER( RTEMS.YIELD_PROCESSOR, STATUS );
264      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_WAKE_AFTER YIELD" );
265
266      TEXT_IO.PUT_LINE(
267         "TA2 - signal_send - SIGNAL_18 and SIGNAL_19 to TA1"
268      );
269      RTEMS.SIGNAL_SEND(
270         SPTEST.TASK_ID( 1 ),
271         RTEMS.SIGNAL_18 + RTEMS.SIGNAL_19,
272         STATUS
273      );
274      TEST_SUPPORT.DIRECTIVE_FAILED(
275         STATUS,
276         "SIGNAL_SEND - SIGNAL_18 and SIGNAL_19 to TA1"
277      );
278
279      TEXT_IO.PUT_LINE( "TA2 - task_wake_after - yield processor" );
280      RTEMS.TASK_WAKE_AFTER( RTEMS.YIELD_PROCESSOR, STATUS );
281      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_WAKE_AFTER YIELD" );
282
283      TEXT_IO.PUT_LINE( "*** END OF TEST 14 ***" );
284      RTEMS.SHUTDOWN_EXECUTIVE( 0 );
285
286   end TASK_2;
287
288--PAGE
289--
290--  PROCESS_ASR
291--
292
293   procedure PROCESS_ASR (
294      THE_SIGNAL_SET : in     RTEMS.SIGNAL_SET
295   ) is
296      STATUS : RTEMS.STATUS_CODES;
297   begin
298
299      TEXT_IO.PUT( "ASR - ENTRY - signal => " );
300      UNSIGNED32_IO.PUT( THE_SIGNAL_SET, BASE => 16, WIDTH => 8 );
301      TEXT_IO.NEW_LINE;
302
303      if THE_SIGNAL_SET = RTEMS.SIGNAL_16 or else
304             THE_SIGNAL_SET = RTEMS.SIGNAL_17 or else
305             THE_SIGNAL_SET = RTEMS.SIGNAL_18 + RTEMS.SIGNAL_19 then
306         NULL;
307
308      elsif THE_SIGNAL_SET = RTEMS.SIGNAL_0 or else
309              THE_SIGNAL_SET = RTEMS.SIGNAL_1 then
310         TEXT_IO.PUT_LINE( "ASR - task_wake_after - yield processor" );
311         RTEMS.TASK_WAKE_AFTER( RTEMS.YIELD_PROCESSOR, STATUS );
312         TEST_SUPPORT.DIRECTIVE_FAILED(
313            STATUS,
314            "TASK_WAKE_AFTER YIELD"
315         );
316
317      elsif THE_SIGNAL_SET = RTEMS.SIGNAL_3 then
318
319         SPTEST.ASR_FIRED := TRUE;
320
321      end if;
322
323      TEXT_IO.PUT( "ASR - EXIT  - signal => " );
324      UNSIGNED32_IO.PUT( THE_SIGNAL_SET, BASE => 16, WIDTH => 8 );
325      TEXT_IO.NEW_LINE;
326
327   end PROCESS_ASR;
328     
329end SPTEST;
Note: See TracBrowser for help on using the repository browser.