X-Git-Url: https://review.openocd.org/gitweb?p=openocd.git;a=blobdiff_plain;f=src%2Fjtag%2Fhla%2Fhla_tcl.c;h=73f78fc8a563563c04d9dab5e9f8d8db69832380;hp=86838b0ca8ad0311d18a98df49ca3d5196b40401;hb=6c6b42664a460da505a55c9062708fe314a9fcd8;hpb=549d9bc72cbca3ba352e6b4bcd6e31d9fd9a0bc7;ds=sidebyside diff --git a/src/jtag/hla/hla_tcl.c b/src/jtag/hla/hla_tcl.c index 86838b0ca8..73f78fc8a5 100644 --- a/src/jtag/hla/hla_tcl.c +++ b/src/jtag/hla/hla_tcl.c @@ -16,9 +16,7 @@ * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + * along with this program. If not, see . * ***************************************************************************/ #ifdef HAVE_CONFIG_H @@ -41,25 +39,26 @@ static int jim_newtap_expected_id(Jim_Nvp *n, Jim_GetOptInfo *goi, return e; } - unsigned expected_len = sizeof(uint32_t) * pTap->expected_ids_cnt; - uint32_t *new_expected_ids = malloc(expected_len + sizeof(uint32_t)); - if (new_expected_ids == NULL) { + uint32_t *p = realloc(pTap->expected_ids, + (pTap->expected_ids_cnt + 1) * sizeof(uint32_t)); + if (!p) { Jim_SetResultFormatted(goi->interp, "no memory"); return JIM_ERR; } - memcpy(new_expected_ids, pTap->expected_ids, expected_len); - - new_expected_ids[pTap->expected_ids_cnt] = w; - - free(pTap->expected_ids); - pTap->expected_ids = new_expected_ids; - pTap->expected_ids_cnt++; + pTap->expected_ids = p; + pTap->expected_ids[pTap->expected_ids_cnt++] = w; return JIM_OK; } -#define NTAP_OPT_EXPECTED_ID 0 +#define NTAP_OPT_IRLEN 0 +#define NTAP_OPT_IRMASK 1 +#define NTAP_OPT_IRCAPTURE 2 +#define NTAP_OPT_ENABLED 3 +#define NTAP_OPT_DISABLED 4 +#define NTAP_OPT_EXPECTED_ID 5 +#define NTAP_OPT_VERSION 6 static int jim_hl_newtap_cmd(Jim_GetOptInfo *goi) { @@ -69,8 +68,14 @@ static int jim_hl_newtap_cmd(Jim_GetOptInfo *goi) Jim_Nvp *n; char *cp; const Jim_Nvp opts[] = { - {.name = "-expected-id", .value = NTAP_OPT_EXPECTED_ID}, - {.name = NULL, .value = -1}, + { .name = "-irlen", .value = NTAP_OPT_IRLEN }, + { .name = "-irmask", .value = NTAP_OPT_IRMASK }, + { .name = "-ircapture", .value = NTAP_OPT_IRCAPTURE }, + { .name = "-enable", .value = NTAP_OPT_ENABLED }, + { .name = "-disable", .value = NTAP_OPT_DISABLED }, + { .name = "-expected-id", .value = NTAP_OPT_EXPECTED_ID }, + { .name = "-ignore-version", .value = NTAP_OPT_VERSION }, + { .name = NULL, .value = -1}, }; pTap = calloc(1, sizeof(struct jtag_tap)); @@ -88,11 +93,13 @@ static int jim_hl_newtap_cmd(Jim_GetOptInfo *goi) free(pTap); return JIM_ERR; } - Jim_GetOpt_String(goi, &cp, NULL); - pTap->chip = strdup(cp); - Jim_GetOpt_String(goi, &cp, NULL); - pTap->tapname = strdup(cp); + const char *tmp; + Jim_GetOpt_String(goi, &tmp, NULL); + pTap->chip = strdup(tmp); + + Jim_GetOpt_String(goi, &tmp, NULL); + pTap->tapname = strdup(tmp); /* name + dot + name + null */ x = strlen(pTap->chip) + 1 + strlen(pTap->tapname) + 1; @@ -107,7 +114,7 @@ static int jim_hl_newtap_cmd(Jim_GetOptInfo *goi) e = Jim_GetOpt_Nvp(goi, opts, &n); if (e != JIM_OK) { Jim_GetOpt_NvpUnknown(goi, opts, 0); - free((void *)pTap->dotted_name); + free(cp); free(pTap); return e; } @@ -116,11 +123,17 @@ static int jim_hl_newtap_cmd(Jim_GetOptInfo *goi) case NTAP_OPT_EXPECTED_ID: e = jim_newtap_expected_id(n, goi, pTap); if (JIM_OK != e) { - free((void *)pTap->dotted_name); + free(cp); free(pTap); return e; } break; + case NTAP_OPT_IRLEN: + case NTAP_OPT_IRMASK: + case NTAP_OPT_IRCAPTURE: + /* dummy read to ignore the next argument */ + Jim_GetOpt_Wide(goi, NULL); + break; } /* switch (n->value) */ } /* while (goi->argc) */