* 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., *
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
#ifdef HAVE_CONFIG_H
#include <transport/transport.h>
#include <helper/time_support.h>
-static int jim_newtap_expected_id(Jim_Nvp *n, Jim_GetOptInfo *goi,
+static int jim_newtap_expected_id(struct jim_nvp *n, struct jim_getopt_info *goi,
struct jtag_tap *pTap)
{
jim_wide w;
- int e = Jim_GetOpt_Wide(goi, &w);
+ int e = jim_getopt_wide(goi, &w);
if (e != JIM_OK) {
Jim_SetResultFormatted(goi->interp, "option: %s bad parameter",
n->name);
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)
+static int jim_hl_newtap_cmd(struct jim_getopt_info *goi)
{
struct jtag_tap *pTap;
int x;
int e;
- Jim_Nvp *n;
+ struct jim_nvp *n;
char *cp;
- const Jim_Nvp opts[] = {
- {.name = "-expected-id", .value = NTAP_OPT_EXPECTED_ID},
- {.name = NULL, .value = -1},
+ const struct jim_nvp opts[] = {
+ { .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));
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;
pTap->chip, pTap->tapname, pTap->dotted_name, goi->argc);
while (goi->argc) {
- e = Jim_GetOpt_Nvp(goi, opts, &n);
+ e = jim_getopt_nvp(goi, opts, &n);
if (e != JIM_OK) {
- Jim_GetOpt_NvpUnknown(goi, opts, 0);
+ jim_getopt_nvp_unknown(goi, opts, 0);
free(cp);
free(pTap);
return e;
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) */
int jim_hl_newtap(Jim_Interp *interp, int argc, Jim_Obj * const *argv)
{
- Jim_GetOptInfo goi;
- Jim_GetOpt_Setup(&goi, interp, argc - 1, argv + 1);
+ struct jim_getopt_info goi;
+ jim_getopt_setup(&goi, interp, argc - 1, argv + 1);
return jim_hl_newtap_cmd(&goi);
}