int num_iparam;
uint32_t *local_oparam;
int num_oparam;
- uint32_t *code;
+ const uint32_t *code;
int code_len;
uint32_t stack[32];
int stack_offset;
return ERROR_OK;
}
-int mips32_pracc_exec(struct mips_ejtag *ejtag_info, int code_len, uint32_t *code, int num_param_in, uint32_t *param_in, int num_param_out, uint32_t *param_out, int cycle)
+int mips32_pracc_exec(struct mips_ejtag *ejtag_info, int code_len, const uint32_t *code, int num_param_in, uint32_t *param_in, int num_param_out, uint32_t *param_out, int cycle)
{
uint32_t ejtag_ctrl;
uint32_t address, data;
int mips32_pracc_read_mem32(struct mips_ejtag *ejtag_info, uint32_t addr, int count, uint32_t *buf)
{
- uint32_t code[] = {
+ static const uint32_t code[] = {
/* start: */
MIPS32_MTC0(15,31,0), /* move $15 to COP0 DeSave */
MIPS32_LUI(15,UPPER16(MIPS32_PRACC_STACK)), /* $15 = MIPS32_PRACC_STACK */
param_in[0] = addr;
param_in[1] = blocksize;
- if ((retval = mips32_pracc_exec(ejtag_info, sizeof(code)/sizeof(code[0]), code,
- sizeof(param_in)/sizeof(param_in[0]), param_in, blocksize, &buf[bytesread], 1)) != ERROR_OK)
+ if ((retval = mips32_pracc_exec(ejtag_info, ARRAY_SIZE(code), code,
+ ARRAY_SIZE(param_in), param_in, blocksize, &buf[bytesread], 1)) != ERROR_OK)
{
return retval;
}
int mips32_pracc_read_u32(struct mips_ejtag *ejtag_info, uint32_t addr, uint32_t *buf)
{
- uint32_t code[] = {
+ static const uint32_t code[] = {
/* start: */
MIPS32_MTC0(15,31,0), /* move $15 to COP0 DeSave */
MIPS32_LUI(15,UPPER16(MIPS32_PRACC_STACK)), /* $15 = MIPS32_PRACC_STACK */
param_in[0] = addr;
- if ((retval = mips32_pracc_exec(ejtag_info, sizeof(code)/sizeof(code[0]), code,
- sizeof(param_in)/sizeof(param_in[0]), param_in, sizeof(uint32_t), buf, 1)) != ERROR_OK)
+ if ((retval = mips32_pracc_exec(ejtag_info, ARRAY_SIZE(code), code,
+ ARRAY_SIZE(param_in), param_in, sizeof(uint32_t), buf, 1)) != ERROR_OK)
{
return retval;
}
int mips32_pracc_read_mem16(struct mips_ejtag *ejtag_info, uint32_t addr, int count, uint16_t *buf)
{
- uint32_t code[] = {
+ static const uint32_t code[] = {
/* start: */
MIPS32_MTC0(15,31,0), /* move $15 to COP0 DeSave */
MIPS32_LUI(15,UPPER16(MIPS32_PRACC_STACK)), /* $15 = MIPS32_PRACC_STACK */
};
// /* TODO remove array */
- uint32_t param_out[count];
+ uint32_t *param_out = malloc(count * sizeof(uint32_t));
int i;
// int retval;
param_in[0] = addr;
param_in[1] = blocksize;
- mips32_pracc_exec(ejtag_info, sizeof(code)/sizeof(code[0]), code, \
- sizeof(param_in)/sizeof(param_in[0]), param_in, count, param_out, 1);
+ mips32_pracc_exec(ejtag_info, ARRAY_SIZE(code), code, \
+ ARRAY_SIZE(param_in), param_in, count, param_out, 1);
// count -= blocksize;
// addr += blocksize;
buf[i] = param_out[i];
}
+ free(param_out);
+
return ERROR_OK;
}
int mips32_pracc_read_mem8(struct mips_ejtag *ejtag_info, uint32_t addr, int count, uint8_t *buf)
{
- uint32_t code[] = {
+ static const uint32_t code[] = {
/* start: */
MIPS32_MTC0(15,31,0), /* move $15 to COP0 DeSave */
MIPS32_LUI(15,UPPER16(MIPS32_PRACC_STACK)), /* $15 = MIPS32_PRACC_STACK */
};
// /* TODO remove array */
- uint32_t param_out[count];
+ uint32_t *param_out = malloc(count * sizeof(uint32_t));
int i;
// int retval;
param_in[0] = addr;
param_in[1] = blocksize;
- mips32_pracc_exec(ejtag_info, sizeof(code)/sizeof(code[0]), code, \
- sizeof(param_in)/sizeof(param_in[0]), param_in, count, param_out, 1);
+ mips32_pracc_exec(ejtag_info, ARRAY_SIZE(code), code, \
+ ARRAY_SIZE(param_in), param_in, count, param_out, 1);
// count -= blocksize;
// addr += blocksize;
buf[i] = param_out[i];
}
+ free(param_out);
+
return ERROR_OK;
}
{
//NC: use destination pointer as loop counter (last address is in $10)
- uint32_t code[] = {
+ static const uint32_t code[] = {
/* start: */
MIPS32_MTC0(15,31,0), /* move $15 to COP0 DeSave */
MIPS32_LUI(15,UPPER16(MIPS32_PRACC_STACK)), /* $15 = MIPS32_PRACC_STACK */
};
/* TODO remove array */
- uint32_t param_in[count + 2];
+ uint32_t *param_in = malloc((count + 2) * sizeof(uint32_t));
param_in[0] = addr;
param_in[1] = addr + count * sizeof(uint32_t); //last address
memcpy(¶m_in[2], buf, count * sizeof(uint32_t));
- mips32_pracc_exec(ejtag_info, sizeof(code)/sizeof(code[0]), code, \
- sizeof(param_in)/sizeof(param_in[0]),param_in, 0, NULL, 1);
+ mips32_pracc_exec(ejtag_info, ARRAY_SIZE(code), code, \
+ count + 2, param_in, 0, NULL, 1);
+
+ free(param_in);
return ERROR_OK;
}
int mips32_pracc_write_u32(struct mips_ejtag *ejtag_info, uint32_t addr, uint32_t *buf)
{
- uint32_t code[] = {
+ static const uint32_t code[] = {
/* start: */
MIPS32_MTC0(15,31,0), /* move $15 to COP0 DeSave */
MIPS32_LUI(15,UPPER16(MIPS32_PRACC_STACK)), /* $15 = MIPS32_PRACC_STACK */
param_in[0] = addr;
param_in[1] = *buf;
- mips32_pracc_exec(ejtag_info, sizeof(code)/sizeof(code[0]), code, \
- sizeof(param_in)/sizeof(param_in[0]),param_in, 0, NULL, 1);
+ mips32_pracc_exec(ejtag_info, ARRAY_SIZE(code), code, \
+ ARRAY_SIZE(param_in),param_in, 0, NULL, 1);
return ERROR_OK;
}
int mips32_pracc_write_mem16(struct mips_ejtag *ejtag_info, uint32_t addr, int count, uint16_t *buf)
{
- uint32_t code[] = {
+ static const uint32_t code[] = {
/* start: */
MIPS32_MTC0(15,31,0), /* move $15 to COP0 DeSave */
MIPS32_LUI(15,UPPER16(MIPS32_PRACC_STACK)), /* $15 = MIPS32_PRACC_STACK */
};
/* TODO remove array */
- uint32_t param_in[count + 2];
+ uint32_t *param_in = malloc((count + 2) * sizeof(uint32_t));
int i;
param_in[0] = addr;
param_in[1] = count;
param_in[i + 2] = buf[i];
}
- mips32_pracc_exec(ejtag_info, sizeof(code)/sizeof(code[0]), code, \
- sizeof(param_in)/sizeof(param_in[0]), param_in, 0, NULL, 1);
+ mips32_pracc_exec(ejtag_info, ARRAY_SIZE(code), code, \
+ count + 2, param_in, 0, NULL, 1);
+
+ free(param_in);
return ERROR_OK;
}
int mips32_pracc_write_mem8(struct mips_ejtag *ejtag_info, uint32_t addr, int count, uint8_t *buf)
{
- uint32_t code[] = {
+ static const uint32_t code[] = {
/* start: */
MIPS32_MTC0(15,31,0), /* move $15 to COP0 DeSave */
MIPS32_LUI(15,UPPER16(MIPS32_PRACC_STACK)), /* $15 = MIPS32_PRACC_STACK */
};
/* TODO remove array */
- uint32_t param_in[count + 2];
+ uint32_t *param_in = malloc((count + 2) * sizeof(uint32_t));
int retval;
int i;
param_in[0] = addr;
param_in[i + 2] = buf[i];
}
- retval = mips32_pracc_exec(ejtag_info, sizeof(code)/sizeof(code[0]), code, \
- sizeof(param_in)/sizeof(param_in[0]), param_in, 0, NULL, 1);
+ retval = mips32_pracc_exec(ejtag_info, ARRAY_SIZE(code), code, \
+ count +2, param_in, 0, NULL, 1);
+
+ free(param_in);
return retval;
}
int mips32_pracc_write_regs(struct mips_ejtag *ejtag_info, uint32_t *regs)
{
- uint32_t code[] = {
+ static const uint32_t code[] = {
/* start: */
MIPS32_LUI(2,UPPER16(MIPS32_PRACC_PARAM_IN)), /* $2 = MIPS32_PRACC_PARAM_IN */
MIPS32_ORI(2,2,LOWER16(MIPS32_PRACC_PARAM_IN)),
int retval;
- retval = mips32_pracc_exec(ejtag_info, sizeof(code)/sizeof(code[0]), code, \
+ retval = mips32_pracc_exec(ejtag_info, ARRAY_SIZE(code), code, \
38, regs, 0, NULL, 1);
return retval;
int mips32_pracc_read_regs(struct mips_ejtag *ejtag_info, uint32_t *regs)
{
- uint32_t code[] = {
+ static const uint32_t code[] = {
/* start: */
MIPS32_MTC0(2,31,0), /* move $2 to COP0 DeSave */
MIPS32_LUI(2,UPPER16(MIPS32_PRACC_PARAM_OUT)), /* $2 = MIPS32_PRACC_PARAM_OUT */
int retval;
- retval = mips32_pracc_exec(ejtag_info, sizeof(code)/sizeof(code[0]), code, \
+ retval = mips32_pracc_exec(ejtag_info, ARRAY_SIZE(code), code, \
0, NULL, 38, regs, 1);
return retval;