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