Esempio n. 1
0
static int jim_newtap_expected_id(Jim_Nvp *n, Jim_GetOptInfo *goi,
				  struct jtag_tap *pTap)
{
	jim_wide 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) {
		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++;

	return JIM_OK;
}
Esempio n. 2
0
static int jim_newtap_ir_param(Jim_Nvp *n, Jim_GetOptInfo *goi,
		struct jtag_tap *pTap)
{
	jim_wide w;
	int e = Jim_GetOpt_Wide(goi, &w);
	if (e != JIM_OK)
	{
		Jim_SetResultFormatted(goi->interp,
				"option: %s bad parameter", n->name);
		free((void *)pTap->dotted_name);
		return e;
	}
	switch (n->value) {
	case NTAP_OPT_IRLEN:
		if (w > (jim_wide) (8 * sizeof(pTap->ir_capture_value)))
		{
			LOG_WARNING("%s: huge IR length %d",
					pTap->dotted_name, (int) w);
		}
		pTap->ir_length = w;
		break;
	case NTAP_OPT_IRMASK:
		if (is_bad_irval(pTap->ir_length, w))
		{
			LOG_ERROR("%s: IR mask %x too big",
					pTap->dotted_name,
					(int) w);
			return JIM_ERR;
		}
		if ((w & 3) != 3)
			LOG_WARNING("%s: nonstandard IR mask", pTap->dotted_name);
		pTap->ir_capture_mask = w;
		break;
	case NTAP_OPT_IRCAPTURE:
		if (is_bad_irval(pTap->ir_length, w))
		{
			LOG_ERROR("%s: IR capture %x too big",
					pTap->dotted_name, (int) w);
			return JIM_ERR;
		}
		if ((w & 3) != 1)
			LOG_WARNING("%s: nonstandard IR value",
					pTap->dotted_name);
		pTap->ir_capture_value = w;
		break;
	default:
		return JIM_ERR;
	}
	return JIM_OK;
}
Esempio n. 3
0
static int jim_newtap_expected_id(Jim_Nvp *n, Jim_GetOptInfo *goi,
	struct jtag_tap *pTap)
{
	jim_wide w;
	int e = Jim_GetOpt_Wide(goi, &w);
	if (e != JIM_OK) {
		Jim_SetResultFormatted(goi->interp, "option: %s bad parameter", n->name);
		return e;
	}

	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;
	}

	pTap->expected_ids = p;
	pTap->expected_ids[pTap->expected_ids_cnt++] = w;

	return JIM_OK;
}