int rtos_create(Jim_GetOptInfo *goi, struct target *target) { int x; const char *cp; struct Jim_Obj *res; if (!goi->isconfigure && goi->argc != 0) { Jim_WrongNumArgs(goi->interp, goi->argc, goi->argv, "NO PARAMS"); return JIM_ERR; } os_free(target); Jim_GetOpt_String(goi, &cp, NULL); if (0 == strcmp(cp, "auto")) { /* Auto detect tries to look up all symbols for each RTOS, * and runs the RTOS driver's _detect() function when GDB * finds all symbols for any RTOS. See rtos_qsymbol(). */ target->rtos_auto_detect = true; /* 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]); } for (x = 0; rtos_types[x]; x++) if (0 == strcmp(cp, rtos_types[x]->name)) return os_alloc_create(target, rtos_types[x]); Jim_SetResultFormatted(goi->interp, "Unknown RTOS type %s, try one of: ", cp); res = Jim_GetResult(goi->interp); for (x = 0; rtos_types[x]; x++) Jim_AppendStrings(goi->interp, res, rtos_types[x]->name, ", ", NULL); Jim_AppendStrings(goi->interp, res, " or auto", NULL); return JIM_ERR; }
int rtos_create(Jim_GetOptInfo *goi, struct target * target) { int x; char *cp; if (! goi->isconfigure) { if (goi->argc != 0) { if (goi->argc != 0) { Jim_WrongNumArgs(goi->interp, goi->argc, goi->argv, "NO PARAMS"); return JIM_ERR; } Jim_SetResultString(goi->interp, target_type_name(target), -1); } } if (target->rtos) { free((void *)(target->rtos)); } // e = Jim_GetOpt_String(goi, &cp, NULL); // target->rtos = strdup(cp); Jim_GetOpt_String(goi, &cp, NULL); /* now does target type exist */ if ( 0 == strcmp( cp, "auto") ) { // auto detection of RTOS target->rtos_auto_detect = true; x = 0; } else { 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_thread = 0; target->rtos->symbols = NULL; target->rtos->target = target; if ( 0 != strcmp( cp, "auto") ) { target->rtos->type->create( target ); } return JIM_OK; }