- for (x = 0 ; rtos_types[x] ; x++) {
- if (0 == strcmp(cp, rtos_types[x]->name)) {
- /* found */
- break;
- }
- }
- if (rtos_types[x] == NULL) {
- Jim_SetResultFormatted(goi->interp, "Unknown rtos type %s, try one of ", cp);
- for (x = 0 ; rtos_types[x] ; x++) {
- if (rtos_types[x + 1]) {
- Jim_AppendStrings(goi->interp,
- Jim_GetResult(goi->interp),
- rtos_types[x]->name,
- ", ", NULL);
- } else {
- Jim_AppendStrings(goi->interp,
- Jim_GetResult(goi->interp),
- " or ",
- rtos_types[x]->name,NULL);
- }
- }
- return JIM_ERR;
- }
- }
- /* Create it */
- target->rtos = calloc(1,sizeof(struct rtos));
- target->rtos->type = rtos_types[x];
- target->rtos->current_threadid = -1;
- target->rtos->current_thread = 0;
- target->rtos->symbols = NULL;
- target->rtos->target = target;
- /* put default thread handler in linux usecase it is overloaded*/
- target->rtos->gdb_thread_packet = rtos_thread_packet;
-
- if ( 0 != strcmp( cp, "auto") )
- {
- target->rtos->type->create( target );
+ /* rtos_qsymbol() will iterate over all RTOSes. Allocate
+ * target->rtos here, and set it to the first RTOS type. */
+ return os_alloc(target, rtos_types[0]);