[0074691a] | 1 | /* Task1 |
---|
| 2 | * |
---|
| 3 | * This task is the main line for the test. It creates other |
---|
| 4 | * tasks which can create |
---|
| 5 | * |
---|
| 6 | * Input parameters: |
---|
| 7 | * argument - task argument |
---|
| 8 | * |
---|
| 9 | * Output parameters: NONE |
---|
| 10 | * |
---|
| 11 | * COPYRIGHT (c) 1997 |
---|
| 12 | * Objective Design Systems Ltd Pty (ODS) |
---|
| 13 | * All rights reserved (R) Objective Design Systems Ltd Pty |
---|
| 14 | * |
---|
[b5a555a7] | 15 | * COPYRIGHT (c) 1989-2007. |
---|
[0074691a] | 16 | * On-Line Applications Research Corporation (OAR). |
---|
| 17 | * |
---|
[98e4ebf5] | 18 | * The license and distribution terms for this file may be |
---|
| 19 | * found in the file LICENSE in this distribution or at |
---|
[c499856] | 20 | * http://www.rtems.org/license/LICENSE. |
---|
[0074691a] | 21 | */ |
---|
| 22 | |
---|
[e93cc2d] | 23 | #ifdef HAVE_CONFIG_H |
---|
| 24 | #include "config.h" |
---|
| 25 | #endif |
---|
| 26 | |
---|
[2d60095] | 27 | #include <stdlib.h> |
---|
[0074691a] | 28 | #include <string.h> |
---|
| 29 | #include "System.h" |
---|
| 30 | |
---|
[1fcff14] | 31 | /* c.f. cpukit/score/include/rtems/score/priority.h */ |
---|
| 32 | #define PRIiPriority_Control PRIi32 |
---|
| 33 | /* rtems_task_priority is a typedef to Priority_Control */ |
---|
| 34 | #define PRIirtems_task_priority PRIiPriority_Control |
---|
| 35 | |
---|
| 36 | /* c.f. cpukit/rtems/include/rtems/rtems/modes.h */ |
---|
| 37 | #define PRIXModes_Control PRIX32 |
---|
[87bd3ee] | 38 | #define PRIiModes_Control PRIi32 |
---|
[1fcff14] | 39 | /* rtems_mode is a typedef to Modes_Control */ |
---|
| 40 | #define PRIXrtems_mode PRIXModes_Control |
---|
[87bd3ee] | 41 | #define PRIirtems_mode PRIiModes_Control |
---|
| 42 | |
---|
| 43 | /* c.f. cpukit/score/include/rtems/score/isr.h */ |
---|
| 44 | #define PRIiISR_Level PRIi32 |
---|
| 45 | /* rtems_interrupt_level is a typedef to ISR_Level */ |
---|
| 46 | #define PRIirtems_interrupt_level PRIiISR_Level |
---|
[1fcff14] | 47 | |
---|
[0074691a] | 48 | void Task1::body(rtems_task_argument argument) |
---|
| 49 | { |
---|
| 50 | rtems_test_pause_and_screen_number(1); |
---|
[e83be28] | 51 | |
---|
| 52 | printf(" START Task Class test\n"); |
---|
| 53 | |
---|
[0074691a] | 54 | printf("%s - test argument - ", name_string()); |
---|
| 55 | if (argument != 0xDEADDEAD) |
---|
| 56 | printf("argument is not 0xDEADDEAD\n"); |
---|
| 57 | else |
---|
| 58 | printf("argument matched\n"); |
---|
[e83be28] | 59 | |
---|
[0074691a] | 60 | screen1(); |
---|
| 61 | rtems_test_pause_and_screen_number(2); |
---|
| 62 | |
---|
| 63 | screen2(); |
---|
| 64 | rtems_test_pause_and_screen_number(3); |
---|
[e83be28] | 65 | |
---|
[0074691a] | 66 | screen3(); |
---|
| 67 | rtems_test_pause_and_screen_number(4); |
---|
[e83be28] | 68 | |
---|
[0074691a] | 69 | screen4(); |
---|
| 70 | rtems_test_pause_and_screen_number(5); |
---|
[e83be28] | 71 | |
---|
[0074691a] | 72 | screen5(); |
---|
| 73 | rtems_test_pause_and_screen_number(6); |
---|
[e83be28] | 74 | |
---|
[0074691a] | 75 | screen6(); |
---|
| 76 | |
---|
[2d60095] | 77 | // do not call exit(0) from this thread as this object is static |
---|
| 78 | // the static destructor call delete the task which is calling exit |
---|
| 79 | // so exit never completes |
---|
[e83be28] | 80 | |
---|
[2d60095] | 81 | EndTask end_task("ENDT", (rtems_task_priority) 1, RTEMS_MINIMUM_STACK_SIZE * 6); |
---|
| 82 | end_task.start(0); |
---|
| 83 | |
---|
| 84 | rtemsEvent block_me; |
---|
| 85 | rtems_event_set out; |
---|
[e83be28] | 86 | |
---|
[2d60095] | 87 | block_me.receive(RTEMS_SIGNAL_0, out); |
---|
| 88 | |
---|
| 89 | printf("**** TASK 1 did not block ????\n"); |
---|
[0074691a] | 90 | } |
---|
| 91 | |
---|
| 92 | void Task1::screen1(void) |
---|
| 93 | { |
---|
| 94 | // create two local task objects to connect to this task |
---|
| 95 | rtemsTask local_task_1 = *this; |
---|
| 96 | rtemsTask local_task_2; |
---|
| 97 | |
---|
| 98 | local_task_2 = *this; |
---|
[e83be28] | 99 | |
---|
[0074691a] | 100 | // check the copy constructor works |
---|
| 101 | printf("%s - copy constructor - ", name_string()); |
---|
| 102 | if (local_task_1.id_is() == id_is()) |
---|
| 103 | printf("local and this id's match\n"); |
---|
| 104 | else |
---|
| 105 | printf("local and this id's do not match\n"); |
---|
| 106 | |
---|
| 107 | printf("%s - copy constructor - ", name_string()); |
---|
| 108 | if (local_task_1.name_is() == name_is()) |
---|
| 109 | printf("local and this name's match\n"); |
---|
| 110 | else |
---|
| 111 | printf("local and this name's do not match\n"); |
---|
| 112 | |
---|
| 113 | // check the copy operator works |
---|
| 114 | printf("%s - copy operator - ", name_string()); |
---|
| 115 | if (local_task_2.id_is() == id_is()) |
---|
| 116 | printf("local and this id's match\n"); |
---|
| 117 | else |
---|
| 118 | printf("local and this id's do not match\n"); |
---|
| 119 | printf("%s - copy operator - ", name_string()); |
---|
| 120 | if (local_task_2.name_is() == name_is()) |
---|
| 121 | printf("local and this name's match\n"); |
---|
| 122 | else |
---|
| 123 | printf("local and this name's do not match\n"); |
---|
[e83be28] | 124 | |
---|
[0074691a] | 125 | // check that the owner of the id cannot delete this task |
---|
| 126 | printf("%s - not owner destroy's task - ", local_task_1.name_string()); |
---|
| 127 | local_task_1.destroy(); |
---|
| 128 | printf("%s\n", local_task_1.last_status_string()); |
---|
[e83be28] | 129 | |
---|
[0074691a] | 130 | // connect to a valid task |
---|
| 131 | printf("%s - connect to a local valid task name - ", local_task_2.name_string()); |
---|
| 132 | local_task_2.connect("TA1 ", RTEMS_SEARCH_ALL_NODES); |
---|
| 133 | printf("%s\n", local_task_2.last_status_string()); |
---|
[e83be28] | 134 | |
---|
[0074691a] | 135 | // connect to an invalid task |
---|
| 136 | printf("%s - connect to an invalid task name - ", local_task_2.name_string()); |
---|
| 137 | local_task_2.connect("BADT", RTEMS_SEARCH_ALL_NODES); |
---|
| 138 | printf("%s\n", local_task_2.last_status_string()); |
---|
[e83be28] | 139 | |
---|
[0074691a] | 140 | // connect to a task an invalid node |
---|
| 141 | printf("%s - connect to a task on an invalid node - ", local_task_2.name_string()); |
---|
| 142 | local_task_2.connect("BADT", 10); |
---|
| 143 | printf("%s\n", local_task_2.last_status_string()); |
---|
[e83be28] | 144 | |
---|
[0074691a] | 145 | // restart this task |
---|
| 146 | printf("%s - restart from a non-owner - ", name_string()); |
---|
| 147 | local_task_1.restart(0); |
---|
| 148 | printf("%s\n", local_task_1.last_status_string()); |
---|
| 149 | } |
---|
| 150 | |
---|
| 151 | void Task1::screen2(void) |
---|
| 152 | { |
---|
| 153 | // wake after using this object |
---|
[e83be28] | 154 | |
---|
[0074691a] | 155 | printf("%s - wake after 0 secs - ", name_string()); |
---|
| 156 | wake_after(0); |
---|
| 157 | printf("%s\n", last_status_string()); |
---|
[e83be28] | 158 | |
---|
[0074691a] | 159 | printf("%s - wake after 500 msecs - ", name_string()); |
---|
| 160 | wake_after(500000); |
---|
| 161 | printf("%s\n", last_status_string()); |
---|
[e83be28] | 162 | |
---|
[0074691a] | 163 | printf("%s - wake after 5 secs - ", name_string()); |
---|
| 164 | wake_after(5000000); |
---|
| 165 | printf("%s\n", last_status_string()); |
---|
| 166 | |
---|
| 167 | printf("%s - wake when - to do\n", name_string()); |
---|
| 168 | |
---|
| 169 | rtemsTask task_1 = *this; |
---|
[e83be28] | 170 | |
---|
[0074691a] | 171 | // wake after using a connected object |
---|
[e83be28] | 172 | |
---|
[0074691a] | 173 | printf("%s - connected object wake after 0 secs - ", task_1.name_string()); |
---|
| 174 | task_1.wake_after(0); |
---|
| 175 | printf("%s\n", task_1.last_status_string()); |
---|
[e83be28] | 176 | |
---|
[0074691a] | 177 | printf("%s - connected object wake after 500 msecs - ", task_1.name_string()); |
---|
| 178 | task_1.wake_after(500000); |
---|
| 179 | printf("%s\n", task_1.last_status_string()); |
---|
[e83be28] | 180 | |
---|
[0074691a] | 181 | printf("%s - connected object wake after 5 secs - ", task_1.name_string()); |
---|
| 182 | task_1.wake_after(5000000); |
---|
| 183 | printf("%s\n", task_1.last_status_string()); |
---|
| 184 | |
---|
| 185 | printf("%s - connected object wake when - to do\n", task_1.name_string()); |
---|
| 186 | |
---|
| 187 | rtemsTask task_2; |
---|
[e83be28] | 188 | |
---|
[0074691a] | 189 | // wake after using a self object |
---|
[e83be28] | 190 | |
---|
[0074691a] | 191 | printf("%s - self object wake after 0 secs - ", task_2.name_string()); |
---|
| 192 | task_2.wake_after(0); |
---|
| 193 | printf("%s\n", task_2.last_status_string()); |
---|
[e83be28] | 194 | |
---|
[0074691a] | 195 | printf("%s - self object wake after 500 msecs - ", task_2.name_string()); |
---|
| 196 | task_2.wake_after(500000); |
---|
| 197 | printf("%s\n", task_2.last_status_string()); |
---|
[e83be28] | 198 | |
---|
[0074691a] | 199 | printf("%s - self object wake after 5 secs - ", task_2.name_string()); |
---|
| 200 | task_2.wake_after(5000000); |
---|
| 201 | printf("%s\n", task_2.last_status_string()); |
---|
| 202 | |
---|
| 203 | printf("%s - self object wake when - to do\n", task_2.name_string()); |
---|
| 204 | |
---|
| 205 | rtems_task_priority current_priority; |
---|
| 206 | rtems_task_priority priority; |
---|
| 207 | |
---|
| 208 | // priorities with this object |
---|
[e83be28] | 209 | |
---|
[0074691a] | 210 | printf("%s - get priority - ", name_string()); |
---|
| 211 | get_priority(current_priority); |
---|
[1fcff14] | 212 | printf("%s, priority is %" PRIirtems_task_priority "\n", last_status_string(), current_priority); |
---|
[0074691a] | 213 | |
---|
| 214 | printf("%s - set priority to 512 - ", name_string()); |
---|
| 215 | set_priority(512); |
---|
| 216 | printf("%s\n", last_status_string()); |
---|
| 217 | |
---|
| 218 | printf("%s - set priority to 25 - ", name_string()); |
---|
| 219 | set_priority(25); |
---|
| 220 | printf("%s\n", last_status_string()); |
---|
| 221 | |
---|
| 222 | printf("%s - set priority to original - ", name_string()); |
---|
| 223 | set_priority(current_priority, priority); |
---|
[1fcff14] | 224 | printf("%s, priority was %" PRIirtems_task_priority "\n", last_status_string(), priority); |
---|
[0074691a] | 225 | |
---|
| 226 | // priorities with connected object |
---|
[e83be28] | 227 | |
---|
[0074691a] | 228 | printf("%s - connected object get priority - ", task_1.name_string()); |
---|
| 229 | task_1.get_priority(current_priority); |
---|
[1fcff14] | 230 | printf("%s, priority is %" PRIirtems_task_priority "\n", task_1.last_status_string(), current_priority); |
---|
[0074691a] | 231 | |
---|
| 232 | printf("%s - connected object set priority to 512 - ", task_1.name_string()); |
---|
| 233 | task_1.set_priority(512); |
---|
| 234 | printf("%s\n", task_1.last_status_string()); |
---|
| 235 | |
---|
| 236 | printf("%s - connected object set priority to 25 - ", task_1.name_string()); |
---|
| 237 | task_1.set_priority(25); |
---|
| 238 | printf("%s\n", task_1.last_status_string()); |
---|
| 239 | |
---|
| 240 | printf("%s - connected object set priority to original - ", task_1.name_string()); |
---|
| 241 | task_1.set_priority(current_priority, priority); |
---|
[e83be28] | 242 | printf("%s, priority was %" PRIirtems_task_priority "\n", task_1.last_status_string(), priority); |
---|
[0074691a] | 243 | |
---|
| 244 | // priorities with self object |
---|
[e83be28] | 245 | |
---|
[0074691a] | 246 | printf("%s - self object get priority - ", task_2.name_string()); |
---|
| 247 | task_2.get_priority(current_priority); |
---|
[1fcff14] | 248 | printf("%s, priority is %" PRIirtems_task_priority "\n", task_2.last_status_string(), current_priority); |
---|
[0074691a] | 249 | |
---|
| 250 | printf("%s - self object set priority to 512 - ", task_2.name_string()); |
---|
| 251 | task_2.set_priority(512); |
---|
| 252 | printf("%s\n", task_2.last_status_string()); |
---|
| 253 | |
---|
| 254 | printf("%s - self object set priority to 25 - ", task_2.name_string()); |
---|
| 255 | task_2.set_priority(25); |
---|
| 256 | printf("%s\n", task_2.last_status_string()); |
---|
| 257 | |
---|
| 258 | printf("%s - self object set priority to original - ", task_2.name_string()); |
---|
| 259 | task_2.set_priority(current_priority, priority); |
---|
[1fcff14] | 260 | printf("%s, priority was %" PRIirtems_task_priority "\n", task_2.last_status_string(), priority); |
---|
[0074691a] | 261 | |
---|
[9919946a] | 262 | uint32_t current_note; |
---|
| 263 | uint32_t note; |
---|
[e83be28] | 264 | |
---|
[0074691a] | 265 | // notepad registers for this object |
---|
| 266 | |
---|
| 267 | printf("%s - get note - ", name_string()); |
---|
| 268 | get_note(0, current_note); |
---|
[1fcff14] | 269 | printf("%s, note is %" PRIi32 "\n", last_status_string(), current_note); |
---|
[0074691a] | 270 | |
---|
| 271 | printf("%s - get with bad notepad number - ", name_string()); |
---|
| 272 | get_note(100, current_note); |
---|
[1fcff14] | 273 | printf("%s, note is %" PRIi32 "\n", last_status_string(), current_note); |
---|
[0074691a] | 274 | |
---|
| 275 | printf("%s - set note to 0xDEADBEEF - ", name_string()); |
---|
| 276 | set_note(0, 0xDEADBEEF); |
---|
| 277 | printf("%s\n", last_status_string()); |
---|
| 278 | |
---|
| 279 | printf("%s - get note - ", name_string()); |
---|
| 280 | get_note(0, note); |
---|
[1fcff14] | 281 | printf("%s, note is 0x%08" PRIX32 "\n", last_status_string(), note); |
---|
[0074691a] | 282 | |
---|
| 283 | printf("%s - set note to original value - ", name_string()); |
---|
| 284 | set_note(0, current_note); |
---|
| 285 | printf("%s\n", last_status_string()); |
---|
| 286 | |
---|
| 287 | // notepad registers for connected object |
---|
| 288 | |
---|
| 289 | printf("%s - connected object get note - ", task_1.name_string()); |
---|
| 290 | task_1.get_note(0, current_note); |
---|
[1fcff14] | 291 | printf("%s, notepad is %" PRIi32 "\n", task_1.last_status_string(), current_note); |
---|
[0074691a] | 292 | |
---|
| 293 | printf("%s - connected object get with bad notepad number - ", task_1.name_string()); |
---|
| 294 | task_1.get_note(100, current_note); |
---|
[1fcff14] | 295 | printf("%s, note is %" PRIi32 "\n", task_1.last_status_string(), current_note); |
---|
[0074691a] | 296 | |
---|
| 297 | printf("%s - connected object set note to 0xDEADBEEF - ", task_1.name_string()); |
---|
| 298 | task_1.set_note(0, 0xDEADBEEF); |
---|
| 299 | printf("%s\n", task_1.last_status_string()); |
---|
| 300 | |
---|
| 301 | printf("%s - connected object get note - ", task_1.name_string()); |
---|
| 302 | task_1.get_note(0, note); |
---|
[1fcff14] | 303 | printf("%s, note is 0x%08" PRIX32 "\n", task_1.last_status_string(), note); |
---|
[0074691a] | 304 | |
---|
| 305 | printf("%s - connected object set note to original value - ", task_1.name_string()); |
---|
| 306 | task_1.set_note(0, current_note); |
---|
| 307 | printf("%s\n", task_1.last_status_string()); |
---|
| 308 | |
---|
| 309 | // notepad registers for self object |
---|
| 310 | |
---|
| 311 | printf("%s - self object get note - ", task_2.name_string()); |
---|
| 312 | task_2.get_note(0, current_note); |
---|
[1fcff14] | 313 | printf("%s, note is %" PRIi32 "\n", task_2.last_status_string(), current_note); |
---|
[0074691a] | 314 | |
---|
| 315 | printf("%s - self object get with bad notepad number - ", task_2.name_string()); |
---|
| 316 | task_2.get_note(100, current_note); |
---|
[1fcff14] | 317 | printf("%s, note is %" PRIi32 "\n", task_2.last_status_string(), current_note); |
---|
[0074691a] | 318 | |
---|
| 319 | printf("%s - self object set note to 0xDEADBEEF - ", task_2.name_string()); |
---|
| 320 | task_2.set_note(0, 0xDEADBEEF); |
---|
| 321 | printf("%s\n", task_2.last_status_string()); |
---|
| 322 | |
---|
| 323 | printf("%s - self object get note - ", task_2.name_string()); |
---|
| 324 | task_2.get_note(0, note); |
---|
[1fcff14] | 325 | printf("%s, notepad is 0x%08" PRIX32 "\n", task_2.last_status_string(), note); |
---|
[0074691a] | 326 | |
---|
| 327 | printf("%s - self object set note to original value - ", task_2.name_string()); |
---|
| 328 | task_2.set_note(0, current_note); |
---|
| 329 | printf("%s\n", task_2.last_status_string()); |
---|
| 330 | |
---|
[e83be28] | 331 | printf(" END Task Class test\n"); |
---|
[0074691a] | 332 | } |
---|
| 333 | |
---|
| 334 | #define RTEMS_ALL_MODES (RTEMS_PREEMPT_MASK | \ |
---|
| 335 | RTEMS_TIMESLICE_MASK | \ |
---|
| 336 | RTEMS_ASR_MASK | \ |
---|
| 337 | RTEMS_INTERRUPT_MASK) |
---|
| 338 | |
---|
| 339 | void Task1::screen3(void) |
---|
| 340 | { |
---|
[e83be28] | 341 | printf(" START TaskMode Class test\n"); |
---|
[0074691a] | 342 | |
---|
| 343 | rtemsTask self; |
---|
| 344 | rtemsTaskMode task_mode; |
---|
| 345 | rtems_mode current_mode; |
---|
| 346 | rtems_mode mode; |
---|
| 347 | |
---|
| 348 | printf("%s - get mode - ", self.name_string()); |
---|
| 349 | task_mode.get_mode(current_mode); |
---|
[1fcff14] | 350 | printf("%s,\n\t mode is 0x%08" PRIXrtems_mode ", ", task_mode.last_status_string(), current_mode); |
---|
[0074691a] | 351 | print_mode(current_mode, RTEMS_ALL_MODES); |
---|
| 352 | printf("\n"); |
---|
| 353 | |
---|
| 354 | // PREEMPTION mode control |
---|
[e83be28] | 355 | |
---|
[0074691a] | 356 | printf("%s - get preemption state - ", self.name_string()); |
---|
| 357 | task_mode.get_preemption_state(mode); |
---|
[1fcff14] | 358 | printf("%s,\n\t mode is 0x%08" PRIXrtems_mode ", ", task_mode.last_status_string(), mode); |
---|
[0074691a] | 359 | print_mode(mode, RTEMS_PREEMPT_MASK); |
---|
| 360 | printf("\n"); |
---|
[e83be28] | 361 | |
---|
[0074691a] | 362 | printf("%s - set preemption state to RTEMS_PREEMPT - ", self.name_string()); |
---|
| 363 | task_mode.set_preemption_state(RTEMS_PREEMPT); |
---|
| 364 | task_mode.get_mode(mode); |
---|
[1fcff14] | 365 | printf("%s,\n\t mode is 0x%08" PRIXrtems_mode ", ", task_mode.last_status_string(), mode); |
---|
[0074691a] | 366 | print_mode(mode, RTEMS_ALL_MODES); |
---|
| 367 | printf("\n"); |
---|
[e83be28] | 368 | |
---|
[0074691a] | 369 | printf("%s - set preemption state to RTEMS_NO_PREEMPT - ", self.name_string()); |
---|
| 370 | task_mode.set_preemption_state(RTEMS_NO_PREEMPT); |
---|
| 371 | task_mode.get_mode(mode); |
---|
[1fcff14] | 372 | printf("%s,\n\t mode is 0x%08" PRIXrtems_mode ", ", task_mode.last_status_string(), mode); |
---|
[0074691a] | 373 | print_mode(mode, RTEMS_ALL_MODES); |
---|
| 374 | printf("\n"); |
---|
| 375 | |
---|
| 376 | // TIMESLICE mode control |
---|
[e83be28] | 377 | |
---|
[0074691a] | 378 | printf("%s - get timeslice state - ", self.name_string()); |
---|
| 379 | task_mode.get_timeslice_state(mode); |
---|
[1fcff14] | 380 | printf("%s,\n\t mode is 0x%08" PRIXrtems_mode ", ", task_mode.last_status_string(), mode); |
---|
[0074691a] | 381 | print_mode(mode, RTEMS_TIMESLICE_MASK); |
---|
| 382 | printf("\n"); |
---|
[e83be28] | 383 | |
---|
[0074691a] | 384 | printf("%s - set timeslice state to RTEMS_TIMESLICE - ", self.name_string()); |
---|
| 385 | task_mode.set_timeslice_state(RTEMS_TIMESLICE); |
---|
| 386 | task_mode.get_mode(mode); |
---|
[1fcff14] | 387 | printf("%s,\n\t mode is 0x%08" PRIXrtems_mode ", ", task_mode.last_status_string(), mode); |
---|
[0074691a] | 388 | print_mode(mode, RTEMS_ALL_MODES); |
---|
| 389 | printf("\n"); |
---|
[e83be28] | 390 | |
---|
[0074691a] | 391 | printf("%s - set timeslice state to RTEMS_NO_TIMESLICE - ", self.name_string()); |
---|
| 392 | task_mode.set_timeslice_state(RTEMS_NO_TIMESLICE); |
---|
| 393 | task_mode.get_mode(mode); |
---|
[1fcff14] | 394 | printf("%s,\n\t mode is 0x%08" PRIXrtems_mode ", ", task_mode.last_status_string(), mode); |
---|
[0074691a] | 395 | print_mode(mode, RTEMS_ALL_MODES); |
---|
| 396 | printf("\n"); |
---|
| 397 | |
---|
| 398 | // ASR mode control |
---|
[e83be28] | 399 | |
---|
[0074691a] | 400 | printf("%s - get asr state - ", self.name_string()); |
---|
| 401 | task_mode.get_asr_state(mode); |
---|
[1fcff14] | 402 | printf("%s,\n\t mode is 0x%08" PRIXrtems_mode ", ", task_mode.last_status_string(), mode); |
---|
[0074691a] | 403 | print_mode(mode, RTEMS_ASR_MASK); |
---|
| 404 | printf("\n"); |
---|
[e83be28] | 405 | |
---|
[0074691a] | 406 | printf("%s - set asr state to RTEMS_ASR - ", self.name_string()); |
---|
| 407 | task_mode.set_asr_state(RTEMS_ASR); |
---|
| 408 | task_mode.get_mode(mode); |
---|
[1fcff14] | 409 | printf("%s,\n\t mode is 0x%08" PRIXrtems_mode ", ", task_mode.last_status_string(), mode); |
---|
[0074691a] | 410 | print_mode(mode, RTEMS_ALL_MODES); |
---|
| 411 | printf("\n"); |
---|
[e83be28] | 412 | |
---|
[0074691a] | 413 | printf("%s - set asr state to RTEMS_NO_ASR - ", self.name_string()); |
---|
| 414 | task_mode.set_asr_state(RTEMS_NO_ASR); |
---|
| 415 | task_mode.get_mode(mode); |
---|
[1fcff14] | 416 | printf("%s,\n\t mode is 0x%08" PRIXrtems_mode ", ", task_mode.last_status_string(), mode); |
---|
[0074691a] | 417 | print_mode(mode, RTEMS_ALL_MODES); |
---|
| 418 | printf("\n"); |
---|
| 419 | |
---|
| 420 | // interrupt level control |
---|
[e83be28] | 421 | |
---|
[0074691a] | 422 | rtems_interrupt_level current_level; |
---|
| 423 | rtems_interrupt_level level; |
---|
| 424 | |
---|
| 425 | printf("%s - get current interrupt level - ", self.name_string()); |
---|
| 426 | task_mode.get_interrupt_level(current_level); |
---|
[87bd3ee] | 427 | printf("%s, level is %" PRIirtems_interrupt_level "\n", task_mode.last_status_string(), current_level); |
---|
[0074691a] | 428 | |
---|
| 429 | printf("%s - set interrupt level to 102 - ", self.name_string()); |
---|
| 430 | task_mode.set_interrupt_level(102); |
---|
| 431 | printf("%s\n", task_mode.last_status_string()); |
---|
[e83be28] | 432 | |
---|
[0074691a] | 433 | printf("%s - set interrupt level to original level - ", self.name_string()); |
---|
| 434 | task_mode.set_interrupt_level(current_level, level); |
---|
[87bd3ee] | 435 | printf("%s, level was %" PRIirtems_interrupt_level "\n", task_mode.last_status_string(), level); |
---|
[0074691a] | 436 | |
---|
| 437 | printf("%s - set mode to original mode - ", self.name_string()); |
---|
| 438 | task_mode.set_mode(current_mode, |
---|
| 439 | RTEMS_PREEMPT_MASK | RTEMS_TIMESLICE_MASK | |
---|
| 440 | RTEMS_ASR_MASK | RTEMS_INTERRUPT_MASK); |
---|
| 441 | task_mode.get_mode(mode); |
---|
[1fcff14] | 442 | printf("%s,\n\t mode is 0x%08" PRIXrtems_mode ", ", task_mode.last_status_string(), mode); |
---|
[0074691a] | 443 | print_mode(mode, RTEMS_ALL_MODES); |
---|
| 444 | printf("\n"); |
---|
[e83be28] | 445 | |
---|
| 446 | printf(" END TaskMode Class test\n"); |
---|
[0074691a] | 447 | } |
---|
| 448 | |
---|
| 449 | void Task1::screen4(void) |
---|
| 450 | { |
---|
[e83be28] | 451 | printf(" START Event Class test\n"); |
---|
[0074691a] | 452 | |
---|
| 453 | printf("%s - create task 2 - ", name_string()); |
---|
| 454 | Task2 task_2("TA2", (rtems_task_priority) 9, RTEMS_MINIMUM_STACK_SIZE * 6); |
---|
| 455 | printf("%s\n", task_2.last_status_string()); |
---|
| 456 | |
---|
| 457 | printf("%s - start task 2 - ", name_string()); |
---|
| 458 | task_2.start(0); |
---|
| 459 | printf("%s\n", task_2.last_status_string()); |
---|
[e83be28] | 460 | |
---|
[0074691a] | 461 | printf("%s - construct event connecting to task 2 - ", name_string()); |
---|
| 462 | rtemsEvent event_2("TA2 "); |
---|
| 463 | printf("%s\n", event_2.last_status_string()); |
---|
| 464 | |
---|
| 465 | // wait for task 2 to complete its timeout tests |
---|
| 466 | wake_after(7000000); |
---|
| 467 | |
---|
| 468 | printf("%s - send event signal 0 using the task id - ", name_string()); |
---|
| 469 | event_2.send(task_2.id_is(), RTEMS_SIGNAL_0); |
---|
| 470 | printf("%s\n", event_2.last_status_string()); |
---|
[e83be28] | 471 | |
---|
[0074691a] | 472 | wake_after(1000000); |
---|
| 473 | |
---|
| 474 | printf("%s - send event signal 0 using the task object reference - ", name_string()); |
---|
| 475 | event_2.send(task_2, RTEMS_SIGNAL_0); |
---|
| 476 | printf("%s\n", event_2.last_status_string()); |
---|
[e83be28] | 477 | |
---|
[0074691a] | 478 | wake_after(1000000); |
---|
| 479 | |
---|
| 480 | printf("%s - send event signal 31 using connected id - ", name_string()); |
---|
| 481 | event_2.send(RTEMS_SIGNAL_31); |
---|
| 482 | printf("%s\n", event_2.last_status_string()); |
---|
[e83be28] | 483 | |
---|
[0074691a] | 484 | wake_after(1000000); |
---|
| 485 | |
---|
| 486 | rtemsEvent event_2_2; |
---|
| 487 | |
---|
| 488 | event_2_2.connect("TA2"); |
---|
[e83be28] | 489 | |
---|
[0074691a] | 490 | printf("%s - send event signal 0 and 31 - ", name_string()); |
---|
| 491 | event_2_2.send(task_2, RTEMS_SIGNAL_0 | RTEMS_SIGNAL_31); |
---|
| 492 | printf("%s\n", event_2_2.last_status_string()); |
---|
[e83be28] | 493 | |
---|
[0074691a] | 494 | printf("%s - waiting 5 secs for TA2 to finish\n", name_string()); |
---|
| 495 | wake_after(500000); |
---|
[e83be28] | 496 | |
---|
| 497 | printf(" END Event Class test\n"); |
---|
[0074691a] | 498 | } |
---|
| 499 | |
---|
| 500 | void Task1::screen5(void) |
---|
| 501 | { |
---|
[e83be28] | 502 | printf(" START Interrupt Class test\n"); |
---|
[0074691a] | 503 | |
---|
| 504 | printf(" do not know a portable BSP type interrupt test\n"); |
---|
| 505 | |
---|
[e83be28] | 506 | printf(" END Interrupt Class test\n"); |
---|
[0074691a] | 507 | } |
---|
| 508 | |
---|
| 509 | void Task1::screen6(void) |
---|
| 510 | { |
---|
[e83be28] | 511 | printf(" START MessageQueue Class test\n"); |
---|
[0074691a] | 512 | |
---|
| 513 | printf("%s - construct message queue 1 with no memory error - ", name_string()); |
---|
| 514 | rtemsMessageQueue mq_1("MQ1", 1000000, 1000); |
---|
| 515 | printf("%s\n", mq_1.last_status_string()); |
---|
| 516 | |
---|
| 517 | printf("%s - construct/create message queue 2 - ", name_string()); |
---|
| 518 | rtemsMessageQueue mq_2("MQ2", 4, 50); |
---|
| 519 | printf("%s\n", mq_2.last_status_string()); |
---|
| 520 | |
---|
[a06eb01] | 521 | const char *u1 = "normal send"; |
---|
| 522 | const char *u2 = "urgent send"; |
---|
[0074691a] | 523 | char in[100]; |
---|
[b5a555a7] | 524 | size_t size; |
---|
| 525 | uint32_t count; |
---|
[e83be28] | 526 | |
---|
[0074691a] | 527 | printf("%s - send u1 to mq_2 - ", name_string()); |
---|
| 528 | mq_2.send(u1, strlen(u1) + 1); |
---|
| 529 | printf("%s\n", mq_2.last_status_string()); |
---|
[e83be28] | 530 | |
---|
[0074691a] | 531 | printf("%s - urgent send u2 to mq_2 - ", name_string()); |
---|
| 532 | mq_2.urgent(u2, strlen(u2) + 1); |
---|
| 533 | printf("%s\n", mq_2.last_status_string()); |
---|
[e83be28] | 534 | |
---|
[0074691a] | 535 | printf("%s - create task 3_1 - ", name_string()); |
---|
| 536 | Task3 task_3_1("TA31", 9, RTEMS_MINIMUM_STACK_SIZE * 6); |
---|
| 537 | printf("%s\n", task_3_1.last_status_string()); |
---|
| 538 | |
---|
| 539 | printf("%s - start task 3_1 - ", name_string()); |
---|
| 540 | task_3_1.start(0); |
---|
| 541 | printf("%s\n", task_3_1.last_status_string()); |
---|
[e83be28] | 542 | |
---|
[0074691a] | 543 | printf("%s - create task 3_2 - ", name_string()); |
---|
| 544 | Task3 task_3_2("TA32", 9, RTEMS_MINIMUM_STACK_SIZE * 6); |
---|
| 545 | printf("%s\n", task_3_2.last_status_string()); |
---|
| 546 | |
---|
| 547 | printf("%s - start task 3_2 - ", name_string()); |
---|
| 548 | task_3_2.start(0); |
---|
| 549 | printf("%s\n", task_3_1.last_status_string()); |
---|
[e83be28] | 550 | |
---|
[0074691a] | 551 | wake_after(1000000); |
---|
[e83be28] | 552 | |
---|
[0074691a] | 553 | printf("%s - receive u2 on mq_2 ...\n", name_string()); fflush(stdout); |
---|
| 554 | mq_2.receive(in, size, 5000000); |
---|
| 555 | printf("%s - %s\n", name_string(), mq_2.last_status_string()); |
---|
| 556 | |
---|
| 557 | if (size == (strlen(u2) + 5)) |
---|
| 558 | { |
---|
| 559 | if ((strncmp(in, task_3_1.name_string(), 4) == 0) && |
---|
| 560 | (strcmp(in + 4, u2) == 0)) |
---|
| 561 | { |
---|
| 562 | printf("%s - message u2 received correctly\n", name_string()); |
---|
| 563 | } |
---|
| 564 | else |
---|
| 565 | { |
---|
[7eab7ade] | 566 | printf("%s - message u2 received incorrectly, message='%s', size=%zu\n", |
---|
[0074691a] | 567 | name_string(), in, size); |
---|
| 568 | } |
---|
| 569 | } |
---|
| 570 | else |
---|
[7eab7ade] | 571 | printf("%s - message u2 size incorrect, size=%zu\n", name_string(), size); |
---|
[0074691a] | 572 | |
---|
| 573 | printf("%s - receive u1 on mq_2 ...\n", name_string()); fflush(stdout); |
---|
| 574 | mq_2.receive(in, size, 5000000); |
---|
| 575 | printf("%s - %s\n", name_string(), mq_2.last_status_string()); |
---|
| 576 | |
---|
| 577 | if (size == (strlen(u1) + 5)) |
---|
| 578 | { |
---|
| 579 | if ((strncmp(in, task_3_2.name_string(), 4) == 0) && |
---|
| 580 | (strcmp(in + 4, u1) == 0)) |
---|
| 581 | { |
---|
| 582 | printf("%s - message u1 received correctly\n", name_string()); |
---|
| 583 | } |
---|
| 584 | else |
---|
| 585 | { |
---|
[7eab7ade] | 586 | printf("%s - message u1 received incorrectly, message='%s', size=%zu\n", |
---|
[0074691a] | 587 | name_string(), in, size); |
---|
| 588 | } |
---|
| 589 | } |
---|
| 590 | else |
---|
[7eab7ade] | 591 | printf("%s - message u1 size incorrect, size=%zu\n", name_string(), size); |
---|
[0074691a] | 592 | |
---|
| 593 | wake_after(3000000); |
---|
[e83be28] | 594 | |
---|
[a06eb01] | 595 | const char *b1 = "broadcast message"; |
---|
[e83be28] | 596 | |
---|
[0074691a] | 597 | printf("%s - broadcast send b1 ...\n", name_string()); |
---|
| 598 | mq_2.broadcast(b1, strlen(b1) + 1, count); |
---|
[1fcff14] | 599 | printf("%s - mq_2 broadcast send - %s, count=%" PRIi32 "\n", |
---|
[0074691a] | 600 | name_string(), mq_2.last_status_string(), count); |
---|
| 601 | |
---|
| 602 | wake_after(1000000); |
---|
[e83be28] | 603 | |
---|
[0074691a] | 604 | printf("%s - receive message b1 on mq_2 from %s...\n", |
---|
| 605 | name_string(), task_3_1.name_string()); fflush(stdout); |
---|
| 606 | mq_2.receive(in, size, 5000000); |
---|
| 607 | printf("%s - %s\n", name_string(), mq_2.last_status_string()); |
---|
| 608 | |
---|
| 609 | if (size == (strlen(b1) + 5)) |
---|
| 610 | { |
---|
| 611 | if ((strncmp(in, task_3_1.name_string(), 4) == 0) && |
---|
| 612 | (strcmp(in + 4, b1) == 0)) |
---|
| 613 | { |
---|
| 614 | printf("%s - message b1 received correctly\n", name_string()); |
---|
| 615 | } |
---|
| 616 | else |
---|
| 617 | { |
---|
| 618 | printf("%s - message b1 received incorrectly, message='%s'\n", |
---|
| 619 | name_string(), in); |
---|
| 620 | } |
---|
| 621 | } |
---|
| 622 | else |
---|
[7eab7ade] | 623 | printf("%s - message b1 size incorrect, size=%zu\n", name_string(), size); |
---|
[0074691a] | 624 | |
---|
| 625 | printf("%s - receive message b1 on mq_2 from %s...\n", |
---|
| 626 | name_string(), task_3_1.name_string()); fflush(stdout); |
---|
| 627 | mq_2.receive(in, size, 5000000); |
---|
| 628 | printf("%s - %s\n", name_string(), mq_2.last_status_string()); |
---|
| 629 | |
---|
| 630 | if (size == (strlen(b1) + 5)) |
---|
| 631 | { |
---|
| 632 | if ((strncmp(in, task_3_2.name_string(), 4) == 0) && |
---|
| 633 | (strcmp(in + 4, b1) == 0)) |
---|
| 634 | { |
---|
| 635 | printf("%s - message b1 received correctly\n", name_string()); |
---|
| 636 | } |
---|
| 637 | else |
---|
| 638 | { |
---|
[7eab7ade] | 639 | printf("%s - message b1 received incorrectly, message='%s', size=%zu\n", |
---|
[0074691a] | 640 | name_string(), in, size); |
---|
| 641 | } |
---|
| 642 | } |
---|
| 643 | else |
---|
[7eab7ade] | 644 | printf("%s - message b1 size incorrect, size=%zu\n", name_string(), size); |
---|
[0074691a] | 645 | |
---|
[d9fe8e2] | 646 | // wait for task 3_1, and 3_2 to complete their timeout tests, will |
---|
| 647 | // start these after getting the broadcast message |
---|
[e83be28] | 648 | wake_after(7000000); |
---|
[0074691a] | 649 | |
---|
[a06eb01] | 650 | const char *f1 = "flush message"; |
---|
[e83be28] | 651 | |
---|
[0074691a] | 652 | printf("%s - send f1 to mq_2 - ", name_string()); |
---|
| 653 | mq_2.send(f1, strlen(f1) + 1); |
---|
| 654 | printf("%s\n", mq_2.last_status_string()); |
---|
[e83be28] | 655 | |
---|
[0074691a] | 656 | printf("%s - send f1 to mq_2 - ", name_string()); |
---|
| 657 | mq_2.send(f1, strlen(f1) + 1); |
---|
| 658 | printf("%s\n", mq_2.last_status_string()); |
---|
[e83be28] | 659 | |
---|
[0074691a] | 660 | printf("%s - send f1 to mq_2 - ", name_string()); |
---|
| 661 | mq_2.send(f1, strlen(f1) + 1); |
---|
| 662 | printf("%s\n", mq_2.last_status_string()); |
---|
| 663 | |
---|
| 664 | printf("%s - flush mq_2 - ", name_string()); |
---|
[b5a555a7] | 665 | mq_2.flush(count); |
---|
[1fcff14] | 666 | printf("%s, flushed=%" PRIi32 "\n", mq_2.last_status_string(), count); |
---|
[e83be28] | 667 | |
---|
| 668 | printf(" END MessageQueue Class test\n"); |
---|
[0074691a] | 669 | } |
---|
| 670 | |
---|
| 671 | void Task1::print_mode(rtems_mode mode, rtems_mode mask) |
---|
| 672 | { |
---|
| 673 | rtemsTaskMode task_mode; |
---|
| 674 | if (mask & RTEMS_PREEMPT_MASK) |
---|
| 675 | printf("RTEMS_%sPREEMPT ", |
---|
| 676 | task_mode.preemption_set(mode) ? "" : "NO_"); |
---|
| 677 | if (mask & RTEMS_TIMESLICE_MASK) |
---|
| 678 | printf("RTEMS_%sTIMESLICE ", |
---|
| 679 | task_mode.preemption_set(mode) ? "" : "NO_"); |
---|
| 680 | if (mask & RTEMS_ASR_MASK) |
---|
| 681 | printf("RTEMS_%sASR ", |
---|
| 682 | task_mode.asr_set(mode) ? "" : "NO_"); |
---|
| 683 | if (mask & RTEMS_INTERRUPT_MASK) |
---|
[87bd3ee] | 684 | printf("INTMASK=%" PRIirtems_mode, |
---|
[0074691a] | 685 | mode & RTEMS_INTERRUPT_MASK); |
---|
| 686 | } |
---|
[2d60095] | 687 | |
---|
| 688 | EndTask::EndTask(const char* name, |
---|
| 689 | const rtems_task_priority initial_priority, |
---|
[9919946a] | 690 | const uint32_t stack_size) |
---|
[2d60095] | 691 | : rtemsTask(name, initial_priority, stack_size, RTEMS_NO_PREEMPT) |
---|
| 692 | { |
---|
| 693 | } |
---|
[e83be28] | 694 | |
---|
[d9fe8e2] | 695 | void EndTask::body(rtems_task_argument) |
---|
[2d60095] | 696 | { |
---|
[f8b2eb03] | 697 | TEST_END(); |
---|
[2d60095] | 698 | exit(0); |
---|
| 699 | } |
---|
| 700 | |
---|