1 |
30 |
unneback |
/* Task_1
|
2 |
|
|
*
|
3 |
|
|
* This routine serves as a test task. It tests the region manager.
|
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:33 chris Exp $
|
18 |
|
|
*/
|
19 |
|
|
|
20 |
|
|
#include "system.h"
|
21 |
|
|
|
22 |
|
|
rtems_task Task_1(
|
23 |
|
|
rtems_task_argument argument
|
24 |
|
|
)
|
25 |
|
|
{
|
26 |
|
|
rtems_id rnid;
|
27 |
|
|
void *segment_address_1;
|
28 |
|
|
void *segment_address_2;
|
29 |
|
|
void *segment_address_3;
|
30 |
|
|
void *segment_address_4;
|
31 |
|
|
rtems_status_code status;
|
32 |
|
|
|
33 |
|
|
status = rtems_region_ident( Region_name[ 1 ], &rnid );
|
34 |
|
|
printf( "TA1 - rtems_region_ident - rnid => %08x\n", rnid );
|
35 |
|
|
directive_failed( status, "rtems_region_ident of RN1" );
|
36 |
|
|
|
37 |
|
|
puts(
|
38 |
|
|
"TA1 - rtems_region_get_segment - wait on 100 byte segment from region 2"
|
39 |
|
|
);
|
40 |
|
|
status = rtems_region_get_segment(
|
41 |
|
|
Region_id[ 2 ],
|
42 |
|
|
100,
|
43 |
|
|
RTEMS_DEFAULT_OPTIONS,
|
44 |
|
|
RTEMS_NO_TIMEOUT,
|
45 |
|
|
&segment_address_1
|
46 |
|
|
);
|
47 |
|
|
directive_failed( status, "rtems_region_get_segment" );
|
48 |
|
|
puts_nocr( "TA1 - got segment from region 2 - " );
|
49 |
|
|
Put_address_from_area_2( segment_address_1 );
|
50 |
|
|
new_line;
|
51 |
|
|
|
52 |
|
|
puts( "TA1 - rtems_region_get_segment - wait on 3K segment from region 3" );
|
53 |
|
|
status = rtems_region_get_segment(
|
54 |
|
|
Region_id[ 3 ],
|
55 |
|
|
3072,
|
56 |
|
|
RTEMS_DEFAULT_OPTIONS,
|
57 |
|
|
RTEMS_NO_TIMEOUT,
|
58 |
|
|
&segment_address_2
|
59 |
|
|
);
|
60 |
|
|
directive_failed( status, "rtems_region_get_segment" );
|
61 |
|
|
puts_nocr( "TA1 - got segment from region 3 - " );
|
62 |
|
|
Put_address_from_area_3( segment_address_2 );
|
63 |
|
|
new_line;
|
64 |
|
|
|
65 |
|
|
puts_nocr( "TA1 - rtems_region_get_segment - get 3080 byte segment " );
|
66 |
|
|
puts ( "from region 1 - NO_WAIT" );
|
67 |
|
|
status = rtems_region_get_segment(
|
68 |
|
|
Region_id[ 1 ],
|
69 |
|
|
3080,
|
70 |
|
|
RTEMS_NO_WAIT,
|
71 |
|
|
RTEMS_NO_TIMEOUT,
|
72 |
|
|
&segment_address_3
|
73 |
|
|
);
|
74 |
|
|
directive_failed( status, "rtems_region_get_segment" );
|
75 |
|
|
puts_nocr( "TA1 - got segment from region 1 - " );
|
76 |
|
|
Put_address_from_area_1( segment_address_3 );
|
77 |
|
|
new_line;
|
78 |
|
|
|
79 |
|
|
puts( "TA1 - rtems_task_wake_after - yield processor" );
|
80 |
|
|
status = rtems_task_wake_after( RTEMS_YIELD_PROCESSOR );
|
81 |
|
|
directive_failed( status, "rtems_task_wake_after" );
|
82 |
|
|
|
83 |
|
|
rtems_test_pause();
|
84 |
|
|
|
85 |
|
|
puts_nocr(
|
86 |
|
|
"TA1 - rtems_region_return_segment - return segment to region 1 - "
|
87 |
|
|
);
|
88 |
|
|
Put_address_from_area_1( segment_address_3 );
|
89 |
|
|
status = rtems_region_return_segment( Region_id[ 1 ], segment_address_3 );
|
90 |
|
|
directive_failed( status, "rtems_region_return_segment" );
|
91 |
|
|
new_line;
|
92 |
|
|
|
93 |
|
|
puts(
|
94 |
|
|
"TA1 - rtems_region_get_segment - wait 10 seconds for 3K "
|
95 |
|
|
"segment from region 1"
|
96 |
|
|
);
|
97 |
|
|
status = rtems_region_get_segment(
|
98 |
|
|
Region_id[ 1 ],
|
99 |
|
|
3072,
|
100 |
|
|
RTEMS_DEFAULT_OPTIONS,
|
101 |
|
|
10 * TICKS_PER_SECOND,
|
102 |
|
|
&segment_address_4
|
103 |
|
|
);
|
104 |
|
|
directive_failed( status, "rtems_region_get_segment" );
|
105 |
|
|
puts_nocr( "TA1 - got segment from region 1 - " );
|
106 |
|
|
Put_address_from_area_1( segment_address_4 );
|
107 |
|
|
new_line;
|
108 |
|
|
|
109 |
|
|
puts_nocr(
|
110 |
|
|
"TA1 - rtems_region_return_segment - return segment to region 2 - "
|
111 |
|
|
);
|
112 |
|
|
Put_address_from_area_2( segment_address_1 );
|
113 |
|
|
new_line;
|
114 |
|
|
status = rtems_region_return_segment( Region_id[ 2 ], segment_address_1 );
|
115 |
|
|
directive_failed( status, "rtems_region_return_segment" );
|
116 |
|
|
|
117 |
|
|
puts( "TA1 - rtems_task_wake_after - yield processor" );
|
118 |
|
|
status = rtems_task_wake_after( RTEMS_YIELD_PROCESSOR );
|
119 |
|
|
directive_failed( status, "rtems_task_wake_after" );
|
120 |
|
|
|
121 |
|
|
puts( "TA1 - rtems_task_delete - delete TA3" );
|
122 |
|
|
status = rtems_task_delete( Task_id[ 3 ] );
|
123 |
|
|
directive_failed( status, "rtems_task_delete of TA3" );
|
124 |
|
|
|
125 |
|
|
rtems_test_pause();
|
126 |
|
|
|
127 |
|
|
status = rtems_task_create(
|
128 |
|
|
Task_name[ 4 ],
|
129 |
|
|
BASE_PRIORITY,
|
130 |
|
|
RTEMS_MINIMUM_STACK_SIZE,
|
131 |
|
|
RTEMS_DEFAULT_MODES,
|
132 |
|
|
RTEMS_DEFAULT_ATTRIBUTES,
|
133 |
|
|
&Task_id[ 4 ]
|
134 |
|
|
);
|
135 |
|
|
directive_failed( status, "rtems_task_create of TA4" );
|
136 |
|
|
|
137 |
|
|
status = rtems_task_create(
|
138 |
|
|
Task_name[ 5 ],
|
139 |
|
|
BASE_PRIORITY,
|
140 |
|
|
RTEMS_MINIMUM_STACK_SIZE,
|
141 |
|
|
RTEMS_DEFAULT_MODES,
|
142 |
|
|
RTEMS_DEFAULT_ATTRIBUTES,
|
143 |
|
|
&Task_id[ 5 ]
|
144 |
|
|
);
|
145 |
|
|
directive_failed( status, "rtems_task_create of TA5" );
|
146 |
|
|
|
147 |
|
|
status = rtems_task_start( Task_id[ 4 ], Task_4, 0 );
|
148 |
|
|
directive_failed( status, "rtems_task_start of TA4" );
|
149 |
|
|
|
150 |
|
|
status = rtems_task_start( Task_id[ 5 ], Task5, 0 );
|
151 |
|
|
directive_failed( status, "rtems_task_start of TA5" );
|
152 |
|
|
|
153 |
|
|
puts( "TA1 - rtems_task_wake_after - yield processor" );
|
154 |
|
|
status = rtems_task_wake_after( 1 * TICKS_PER_SECOND );
|
155 |
|
|
directive_failed( status, "rtems_task_wake_after" );
|
156 |
|
|
|
157 |
|
|
puts_nocr(
|
158 |
|
|
"TA1 - rtems_region_return_segment - return segment to region 1 - "
|
159 |
|
|
);
|
160 |
|
|
Put_address_from_area_1( segment_address_4 );
|
161 |
|
|
status = rtems_region_return_segment( Region_id[ 1 ], segment_address_4 );
|
162 |
|
|
directive_failed( status, "rtems_region_return_segment" );
|
163 |
|
|
new_line;
|
164 |
|
|
|
165 |
|
|
puts( "TA1 - rtems_task_wake_after - yield processor" );
|
166 |
|
|
status = rtems_task_wake_after( 1 * TICKS_PER_SECOND );
|
167 |
|
|
directive_failed( status, "rtems_task_wake_after" );
|
168 |
|
|
|
169 |
|
|
puts_nocr( "TA1 - rtems_region_get_segment - wait 10 seconds for 3K " );
|
170 |
|
|
puts ( "segment from region 1");
|
171 |
|
|
status = rtems_region_get_segment(
|
172 |
|
|
Region_id[ 1 ],
|
173 |
|
|
3072,
|
174 |
|
|
RTEMS_DEFAULT_OPTIONS,
|
175 |
|
|
10 * TICKS_PER_SECOND,
|
176 |
|
|
&segment_address_4
|
177 |
|
|
);
|
178 |
|
|
directive_failed( status, "rtems_region_get_segment" );
|
179 |
|
|
puts_nocr( "TA1 - got segment from region 1 - " );
|
180 |
|
|
Put_address_from_area_1( segment_address_4 );
|
181 |
|
|
new_line;
|
182 |
|
|
|
183 |
|
|
puts( "TA1 - rtems_task_wake_after - yield processor" );
|
184 |
|
|
status = rtems_task_wake_after( 1 * TICKS_PER_SECOND );
|
185 |
|
|
directive_failed( status, "rtems_task_wake_after" );
|
186 |
|
|
|
187 |
|
|
puts( "TA1 - rtems_task_delete - delete TA4" );
|
188 |
|
|
status = rtems_task_delete( Task_id[ 4 ] );
|
189 |
|
|
directive_failed( status, "rtems_task_delete of TA4" );
|
190 |
|
|
|
191 |
|
|
puts_nocr(
|
192 |
|
|
"TA1 - rtems_region_return_segment - return segment to region 1 - "
|
193 |
|
|
);
|
194 |
|
|
Put_address_from_area_1( segment_address_4 );
|
195 |
|
|
status = rtems_region_return_segment( Region_id[ 1 ], segment_address_4 );
|
196 |
|
|
directive_failed( status, "rtems_region_return_segment" );
|
197 |
|
|
new_line;
|
198 |
|
|
|
199 |
|
|
puts( "TA1 - rtems_task_wake_after - yield processor" );
|
200 |
|
|
status = rtems_task_wake_after( RTEMS_YIELD_PROCESSOR );
|
201 |
|
|
|
202 |
|
|
puts( "TA1 - rtems_region_delete - delete region 1" );
|
203 |
|
|
status = rtems_region_delete( Region_id[ 1 ] );
|
204 |
|
|
directive_failed( status, "rtems_region_delete" );
|
205 |
|
|
|
206 |
|
|
puts( "TA1 - rtems_region_get_segment - get 3K segment from region 4" );
|
207 |
|
|
status = rtems_region_get_segment(
|
208 |
|
|
Region_id[ 4 ],
|
209 |
|
|
3072,
|
210 |
|
|
RTEMS_DEFAULT_OPTIONS,
|
211 |
|
|
RTEMS_NO_TIMEOUT,
|
212 |
|
|
&segment_address_1
|
213 |
|
|
);
|
214 |
|
|
directive_failed( status, "rtems_region_get_segment" );
|
215 |
|
|
puts_nocr( "TA1 - got segment from region 4 - " );
|
216 |
|
|
Put_address_from_area_4( segment_address_1 );
|
217 |
|
|
new_line;
|
218 |
|
|
|
219 |
|
|
puts(
|
220 |
|
|
"TA1 - rtems_region_get_segment - attempt to get 3K segment from region 4"
|
221 |
|
|
);
|
222 |
|
|
status = rtems_region_get_segment(
|
223 |
|
|
Region_id[ 4 ],
|
224 |
|
|
3072,
|
225 |
|
|
RTEMS_NO_WAIT,
|
226 |
|
|
RTEMS_NO_TIMEOUT,
|
227 |
|
|
&segment_address_2
|
228 |
|
|
);
|
229 |
|
|
fatal_directive_status(
|
230 |
|
|
status,
|
231 |
|
|
RTEMS_UNSATISFIED,
|
232 |
|
|
"rtems_task_get_segment with no memory left"
|
233 |
|
|
);
|
234 |
|
|
puts( "TA1 - rtems_task_get_note - RTEMS_UNSATISFIED" );
|
235 |
|
|
|
236 |
|
|
puts( "TA1 - rtems_region_extend - extend region 4 by 4K" );
|
237 |
|
|
status = rtems_region_extend(
|
238 |
|
|
Region_id[ 4 ],
|
239 |
|
|
&Area_4[4096],
|
240 |
|
|
4096
|
241 |
|
|
);
|
242 |
|
|
directive_failed( status, "rtems_region_extend" );
|
243 |
|
|
|
244 |
|
|
puts(
|
245 |
|
|
"TA1 - rtems_region_get_segment - attempt to get 3K segment from region 4"
|
246 |
|
|
);
|
247 |
|
|
status = rtems_region_get_segment(
|
248 |
|
|
Region_id[ 4 ],
|
249 |
|
|
3072,
|
250 |
|
|
RTEMS_NO_WAIT,
|
251 |
|
|
RTEMS_NO_TIMEOUT,
|
252 |
|
|
&segment_address_3
|
253 |
|
|
);
|
254 |
|
|
directive_failed( status, "rtems_region_get_segment" );
|
255 |
|
|
puts_nocr( "TA1 - got 3K segment from region 4 - " );
|
256 |
|
|
Put_address_from_area_4( segment_address_3 );
|
257 |
|
|
new_line;
|
258 |
|
|
|
259 |
|
|
puts_nocr(
|
260 |
|
|
"TA1 - rtems_region_return_segment - return segment to region 4 - "
|
261 |
|
|
);
|
262 |
|
|
Put_address_from_area_4( segment_address_1 );
|
263 |
|
|
status = rtems_region_return_segment( Region_id[ 4 ], segment_address_1 );
|
264 |
|
|
directive_failed( status, "rtems_region_return_segment" );
|
265 |
|
|
new_line;
|
266 |
|
|
|
267 |
|
|
puts_nocr(
|
268 |
|
|
"TA1 - rtems_region_return_segment - return segment to region 4 - "
|
269 |
|
|
);
|
270 |
|
|
Put_address_from_area_4( segment_address_3 );
|
271 |
|
|
status = rtems_region_return_segment( Region_id[ 4 ], segment_address_3 );
|
272 |
|
|
directive_failed( status, "rtems_region_return_segment" );
|
273 |
|
|
new_line;
|
274 |
|
|
|
275 |
|
|
puts( "TA1 - rtems_region_delete - delete region 4" );
|
276 |
|
|
status = rtems_region_delete( Region_id[ 4 ] );
|
277 |
|
|
directive_failed( status, "rtems_region_delete" );
|
278 |
|
|
|
279 |
|
|
puts( "*** END OF TEST 16 ***" );
|
280 |
|
|
exit( 0 );
|
281 |
|
|
}
|