1 | /* |
---|
2 | * COPYRIGHT (c) 1989-2011. |
---|
3 | * On-Line Applications Research Corporation (OAR). |
---|
4 | * |
---|
5 | * The license and distribution terms for this file may be |
---|
6 | * found in the file LICENSE in this distribution or at |
---|
7 | * http://www.rtems.org/license/LICENSE. |
---|
8 | */ |
---|
9 | |
---|
10 | #ifdef HAVE_CONFIG_H |
---|
11 | #include "config.h" |
---|
12 | #endif |
---|
13 | |
---|
14 | #include "system.h" |
---|
15 | |
---|
16 | rtems_task Task_1( |
---|
17 | rtems_task_argument argument |
---|
18 | ) |
---|
19 | { |
---|
20 | void *address_1; |
---|
21 | void *address_2; |
---|
22 | void *address_3; |
---|
23 | void *address_4; |
---|
24 | void *address_5; |
---|
25 | void *address_6; |
---|
26 | void *address_7; |
---|
27 | void *address_8; |
---|
28 | rtems_id region_id; |
---|
29 | Heap_Information_block region_info; |
---|
30 | uintptr_t segment_size; |
---|
31 | rtems_status_code status; |
---|
32 | |
---|
33 | /* Obtain the region id */ |
---|
34 | status = rtems_region_ident(Region_name[ 1 ], ®ion_id); |
---|
35 | printf( "TA1 - rtems_region_ident - 0x%08" PRIxrtems_id "\n", region_id ); |
---|
36 | directive_failed(status, "rtems_region_ident of RN01"); |
---|
37 | |
---|
38 | /* Get a 64 byte segment from the region */ |
---|
39 | puts( |
---|
40 | "TA1 - rtems_region_get_segment - wait on 64 byte segment from region 1" |
---|
41 | ); |
---|
42 | rtems_region_get_segment( |
---|
43 | Region_id[ 1 ], |
---|
44 | 64, |
---|
45 | RTEMS_DEFAULT_OPTIONS, |
---|
46 | RTEMS_NO_TIMEOUT, |
---|
47 | &address_1 |
---|
48 | ); |
---|
49 | directive_failed( status, "rtems_region_get_segment" ); |
---|
50 | puts_nocr( "TA1 - got segment from region 1 - " ); |
---|
51 | Put_address_from_area_1( address_1 ); |
---|
52 | new_line; |
---|
53 | |
---|
54 | /* Get the size of segment_1 */ |
---|
55 | puts_nocr( "TA1 - rtems_region_get_segment_size from - " ); |
---|
56 | Put_address_from_area_1( address_1 ); |
---|
57 | new_line; |
---|
58 | status = rtems_region_get_segment_size(region_id, address_1, &segment_size); |
---|
59 | directive_failed(status, "rtems_region_get_segment_size of segment 1"); |
---|
60 | printf( "TA1 - got segment size of %" PRIuPTR "\n", segment_size ); |
---|
61 | |
---|
62 | /* Get a 128 byte segment from the region */ |
---|
63 | puts( |
---|
64 | "TA1 - rtems_region_get_segment - wait on 128 byte segment from region 1" |
---|
65 | ); |
---|
66 | rtems_region_get_segment( |
---|
67 | Region_id[ 1 ], |
---|
68 | 128, |
---|
69 | RTEMS_DEFAULT_OPTIONS, |
---|
70 | RTEMS_NO_TIMEOUT, |
---|
71 | &address_2 |
---|
72 | ); |
---|
73 | directive_failed( status, "rtems_region_get_segment" ); |
---|
74 | puts_nocr( "TA1 - got segment from region 1 - " ); |
---|
75 | Put_address_from_area_1( address_2 ); |
---|
76 | new_line; |
---|
77 | |
---|
78 | /* Get a 256 byte segment from the region */ |
---|
79 | puts( |
---|
80 | "TA1 - rtems_region_get_segment - wait on 256 byte segment from region 1" |
---|
81 | ); |
---|
82 | rtems_region_get_segment( |
---|
83 | Region_id[ 1 ], |
---|
84 | 256, |
---|
85 | RTEMS_DEFAULT_OPTIONS, |
---|
86 | RTEMS_NO_TIMEOUT, |
---|
87 | &address_3 |
---|
88 | ); |
---|
89 | directive_failed( status, "rtems_region_get_segment" ); |
---|
90 | puts_nocr( "TA1 - got segment from region 1 - " ); |
---|
91 | Put_address_from_area_1( address_3 ); |
---|
92 | new_line; |
---|
93 | |
---|
94 | /* Get a 512 byte segment from the region */ |
---|
95 | puts( |
---|
96 | "TA1 - rtems_region_get_segment - wait on 512 byte segment from region 1" |
---|
97 | ); |
---|
98 | rtems_region_get_segment( |
---|
99 | Region_id[ 1 ], |
---|
100 | 512, |
---|
101 | RTEMS_DEFAULT_OPTIONS, |
---|
102 | RTEMS_NO_TIMEOUT, |
---|
103 | &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( address_4 ); |
---|
108 | new_line; |
---|
109 | |
---|
110 | /* Get a 1024 byte segment from the region */ |
---|
111 | puts( |
---|
112 | "TA1 - rtems_region_get_segment - wait on 1024 byte segment from region 1" |
---|
113 | ); |
---|
114 | rtems_region_get_segment( |
---|
115 | Region_id[ 1 ], |
---|
116 | 1024, |
---|
117 | RTEMS_DEFAULT_OPTIONS, |
---|
118 | RTEMS_NO_TIMEOUT, |
---|
119 | &address_5 |
---|
120 | ); |
---|
121 | directive_failed( status, "rtems_region_get_segment" ); |
---|
122 | puts_nocr( "TA1 - got segment from region 1 - " ); |
---|
123 | Put_address_from_area_1( address_5 ); |
---|
124 | new_line; |
---|
125 | |
---|
126 | /* Get a 2048 byte segment from the region */ |
---|
127 | puts( |
---|
128 | "TA1 - rtems_region_get_segment - wait on 2048 byte segment from region 1" |
---|
129 | ); |
---|
130 | rtems_region_get_segment( |
---|
131 | Region_id[ 1 ], |
---|
132 | 2048, |
---|
133 | RTEMS_DEFAULT_OPTIONS, |
---|
134 | RTEMS_NO_TIMEOUT, |
---|
135 | &address_6 |
---|
136 | ); |
---|
137 | directive_failed( status, "rtems_region_get_segment" ); |
---|
138 | puts_nocr( "TA1 - got segment from region 1 - " ); |
---|
139 | Put_address_from_area_1( address_6 ); |
---|
140 | new_line; |
---|
141 | |
---|
142 | /* Get a 4096 byte segment from the region */ |
---|
143 | puts( |
---|
144 | "TA1 - rtems_region_get_segment - wait on 4096 byte segment from region 1" |
---|
145 | ); |
---|
146 | rtems_region_get_segment( |
---|
147 | Region_id[ 1 ], |
---|
148 | 4096, |
---|
149 | RTEMS_DEFAULT_OPTIONS, |
---|
150 | RTEMS_NO_TIMEOUT, |
---|
151 | &address_7 |
---|
152 | ); |
---|
153 | directive_failed( status, "rtems_region_get_segment" ); |
---|
154 | puts_nocr( "TA1 - got segment from region 1 - " ); |
---|
155 | Put_address_from_area_1( address_7 ); |
---|
156 | new_line; |
---|
157 | |
---|
158 | /* Get a 8192 byte segment from the region */ |
---|
159 | puts( |
---|
160 | "TA1 - rtems_region_get_segment - wait on 8192 byte segment from region 1" |
---|
161 | ); |
---|
162 | rtems_region_get_segment( |
---|
163 | Region_id[ 1 ], |
---|
164 | 8192, |
---|
165 | RTEMS_DEFAULT_OPTIONS, |
---|
166 | RTEMS_NO_TIMEOUT, |
---|
167 | &address_8 |
---|
168 | ); |
---|
169 | directive_failed( status, "rtems_region_get_segment" ); |
---|
170 | puts_nocr( "TA1 - got segment from region 1 - " ); |
---|
171 | Put_address_from_area_1( address_8 ); |
---|
172 | new_line; |
---|
173 | |
---|
174 | /* Get the size of segment_8 */ |
---|
175 | puts_nocr( "TA1 - rtems_region_get_segment_size from - " ); |
---|
176 | Put_address_from_area_1( address_8 ); |
---|
177 | new_line; |
---|
178 | status = rtems_region_get_segment_size(region_id, address_8, &segment_size); |
---|
179 | directive_failed(status, "rtems_region_get_segment_size of segment 8"); |
---|
180 | printf( "TA1 - got segment size of %" PRIuPTR "\n", segment_size ); |
---|
181 | |
---|
182 | /* Get information about the region */ |
---|
183 | printf( |
---|
184 | "TA1 - rtems_region_get_information - 0x%08" PRIxrtems_id "\n", |
---|
185 | region_id |
---|
186 | ); |
---|
187 | status = rtems_region_get_information(region_id, ®ion_info); |
---|
188 | directive_failed(status, "rtems_region_get_information of RN01"); |
---|
189 | printf( |
---|
190 | "TA1 - got information - free = %" PRIu32 ", used = %" PRIu32 "\n", |
---|
191 | region_info.Free.number, |
---|
192 | region_info.Used.number |
---|
193 | ); |
---|
194 | |
---|
195 | printf( |
---|
196 | "TA1 - rtems_region_get_free_information - 0x%08" PRIxrtems_id "\n", |
---|
197 | region_id |
---|
198 | ); |
---|
199 | status = rtems_region_get_free_information(region_id, ®ion_info); |
---|
200 | directive_failed(status, "rtems_region_get_free_information of RN01"); |
---|
201 | printf( |
---|
202 | "TA1 - got free information - free = %" PRIu32 ", used = %" PRIu32 "\n", |
---|
203 | region_info.Free.number, |
---|
204 | region_info.Used.number |
---|
205 | ); |
---|
206 | |
---|
207 | rtems_test_pause(); |
---|
208 | |
---|
209 | puts_nocr( |
---|
210 | "TA1 - rtems_region_return_segment - return segment to region 1 - " |
---|
211 | ); |
---|
212 | Put_address_from_area_1( address_3 ); |
---|
213 | status = rtems_region_return_segment( Region_id[ 1 ], address_3 ); |
---|
214 | directive_failed( status, "rtems_region_return_segment" ); |
---|
215 | new_line; |
---|
216 | address_3 = 0; |
---|
217 | |
---|
218 | puts_nocr( |
---|
219 | "TA1 - rtems_region_return_segment - return segment to region 1 - " |
---|
220 | ); |
---|
221 | Put_address_from_area_1( address_4 ); |
---|
222 | status = rtems_region_return_segment( Region_id[ 1 ], address_4 ); |
---|
223 | directive_failed( status, "rtems_region_return_segment" ); |
---|
224 | new_line; |
---|
225 | address_4 = 0; |
---|
226 | |
---|
227 | puts_nocr( |
---|
228 | "TA1 - rtems_region_return_segment - return segment to region 1 - " |
---|
229 | ); |
---|
230 | Put_address_from_area_1( address_1 ); |
---|
231 | status = rtems_region_return_segment( Region_id[ 1 ], address_1 ); |
---|
232 | directive_failed( status, "rtems_region_return_segment" ); |
---|
233 | new_line; |
---|
234 | address_1 = 0; |
---|
235 | |
---|
236 | puts_nocr( |
---|
237 | "TA1 - rtems_region_return_segment - return segment to region 1 - " |
---|
238 | ); |
---|
239 | Put_address_from_area_1( address_2 ); |
---|
240 | status = rtems_region_return_segment( Region_id[ 1 ], address_2 ); |
---|
241 | directive_failed( status, "rtems_region_return_segment" ); |
---|
242 | new_line; |
---|
243 | address_2 = 0; |
---|
244 | |
---|
245 | puts_nocr( |
---|
246 | "TA1 - rtems_region_return_segment - return segment to region 1 - " |
---|
247 | ); |
---|
248 | Put_address_from_area_1( address_7 ); |
---|
249 | status = rtems_region_return_segment( Region_id[ 1 ], address_7 ); |
---|
250 | directive_failed( status, "rtems_region_return_segment" ); |
---|
251 | new_line; |
---|
252 | address_7 = 0; |
---|
253 | |
---|
254 | puts_nocr( |
---|
255 | "TA1 - rtems_region_return_segment - return segment to region 1 - " |
---|
256 | ); |
---|
257 | Put_address_from_area_1( address_6 ); |
---|
258 | status = rtems_region_return_segment( Region_id[ 1 ], address_6 ); |
---|
259 | directive_failed( status, "rtems_region_return_segment" ); |
---|
260 | new_line; |
---|
261 | address_6 = 0; |
---|
262 | |
---|
263 | puts_nocr( |
---|
264 | "TA1 - rtems_region_return_segment - return segment to region 1 - " |
---|
265 | ); |
---|
266 | Put_address_from_area_1( address_8 ); |
---|
267 | status = rtems_region_return_segment( Region_id[ 1 ], address_8 ); |
---|
268 | directive_failed( status, "rtems_region_return_segment" ); |
---|
269 | new_line; |
---|
270 | address_8 = 0; |
---|
271 | |
---|
272 | puts_nocr( |
---|
273 | "TA1 - rtems_region_return_segment - return segment to region 1 - " |
---|
274 | ); |
---|
275 | Put_address_from_area_1( address_5 ); |
---|
276 | status = rtems_region_return_segment( Region_id[ 1 ], address_5 ); |
---|
277 | directive_failed( status, "rtems_region_return_segment" ); |
---|
278 | new_line; |
---|
279 | address_5 = 0; |
---|
280 | |
---|
281 | puts( "TA1 - rtems_region_delete - walks heap if debug enabled" ); |
---|
282 | rtems_region_delete(Region_id[ 1 ]); |
---|
283 | |
---|
284 | TEST_END(); |
---|
285 | rtems_test_exit( 0 ); |
---|
286 | } |
---|