2008-07-26 05:32:11 -05:00
|
|
|
/***************************************************************************
|
|
|
|
* Copyright (C) 2008 by Spencer Oliver *
|
|
|
|
* spen@spen-soft.co.uk *
|
|
|
|
* *
|
|
|
|
* Copyright (C) 2008 by David T.L. Wong *
|
|
|
|
* *
|
2009-07-17 14:54:25 -05:00
|
|
|
* Copyright (C) 2007,2008 Øyvind Harboe *
|
2008-10-07 13:04:14 -05:00
|
|
|
* oyvind.harboe@zylin.com *
|
|
|
|
* *
|
2011-07-07 10:41:20 -05:00
|
|
|
* Copyright (C) 2011 by Drasko DRASKOVIC *
|
|
|
|
* drasko.draskovic@gmail.com *
|
|
|
|
* *
|
2008-07-26 05:32:11 -05:00
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
2016-05-16 15:41:00 -05:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
2008-07-26 05:32:11 -05:00
|
|
|
***************************************************************************/
|
2012-02-05 06:03:04 -06:00
|
|
|
|
2008-07-26 05:32:11 -05:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "mips32.h"
|
2010-01-13 04:12:34 -06:00
|
|
|
#include "breakpoints.h"
|
|
|
|
#include "algorithm.h"
|
2009-11-16 02:35:14 -06:00
|
|
|
#include "register.h"
|
2008-07-26 05:32:11 -05:00
|
|
|
|
2012-02-05 06:03:04 -06:00
|
|
|
static const char *mips_isa_strings[] = {
|
2017-05-07 11:39:17 -05:00
|
|
|
"MIPS32", "MIPS16", "", "MICRO MIPS32",
|
2010-01-08 16:35:08 -06:00
|
|
|
};
|
|
|
|
|
2014-02-25 14:16:58 -06:00
|
|
|
#define MIPS32_GDB_DUMMY_FP_REG 1
|
|
|
|
|
|
|
|
/*
|
|
|
|
* GDB registers
|
|
|
|
* based on gdb-7.6.2/gdb/features/mips-{fpu,cp0,cpu}.xml
|
|
|
|
*/
|
2014-02-09 02:15:06 -06:00
|
|
|
static const struct {
|
|
|
|
unsigned id;
|
|
|
|
const char *name;
|
2014-02-25 14:16:58 -06:00
|
|
|
enum reg_type type;
|
|
|
|
const char *group;
|
|
|
|
const char *feature;
|
|
|
|
int flag;
|
|
|
|
} mips32_regs[] = {
|
|
|
|
{ 0, "r0", REG_TYPE_INT, NULL, "org.gnu.gdb.mips.cpu", 0 },
|
|
|
|
{ 1, "r1", REG_TYPE_INT, NULL, "org.gnu.gdb.mips.cpu", 0 },
|
|
|
|
{ 2, "r2", REG_TYPE_INT, NULL, "org.gnu.gdb.mips.cpu", 0 },
|
|
|
|
{ 3, "r3", REG_TYPE_INT, NULL, "org.gnu.gdb.mips.cpu", 0 },
|
|
|
|
{ 4, "r4", REG_TYPE_INT, NULL, "org.gnu.gdb.mips.cpu", 0 },
|
|
|
|
{ 5, "r5", REG_TYPE_INT, NULL, "org.gnu.gdb.mips.cpu", 0 },
|
|
|
|
{ 6, "r6", REG_TYPE_INT, NULL, "org.gnu.gdb.mips.cpu", 0 },
|
|
|
|
{ 7, "r7", REG_TYPE_INT, NULL, "org.gnu.gdb.mips.cpu", 0 },
|
|
|
|
{ 8, "r8", REG_TYPE_INT, NULL, "org.gnu.gdb.mips.cpu", 0 },
|
|
|
|
{ 9, "r9", REG_TYPE_INT, NULL, "org.gnu.gdb.mips.cpu", 0 },
|
|
|
|
{ 10, "r10", REG_TYPE_INT, NULL, "org.gnu.gdb.mips.cpu", 0 },
|
|
|
|
{ 11, "r11", REG_TYPE_INT, NULL, "org.gnu.gdb.mips.cpu", 0 },
|
|
|
|
{ 12, "r12", REG_TYPE_INT, NULL, "org.gnu.gdb.mips.cpu", 0 },
|
|
|
|
{ 13, "r13", REG_TYPE_INT, NULL, "org.gnu.gdb.mips.cpu", 0 },
|
|
|
|
{ 14, "r14", REG_TYPE_INT, NULL, "org.gnu.gdb.mips.cpu", 0 },
|
|
|
|
{ 15, "r15", REG_TYPE_INT, NULL, "org.gnu.gdb.mips.cpu", 0 },
|
|
|
|
{ 16, "r16", REG_TYPE_INT, NULL, "org.gnu.gdb.mips.cpu", 0 },
|
|
|
|
{ 17, "r17", REG_TYPE_INT, NULL, "org.gnu.gdb.mips.cpu", 0 },
|
|
|
|
{ 18, "r18", REG_TYPE_INT, NULL, "org.gnu.gdb.mips.cpu", 0 },
|
|
|
|
{ 19, "r19", REG_TYPE_INT, NULL, "org.gnu.gdb.mips.cpu", 0 },
|
|
|
|
{ 20, "r20", REG_TYPE_INT, NULL, "org.gnu.gdb.mips.cpu", 0 },
|
|
|
|
{ 21, "r21", REG_TYPE_INT, NULL, "org.gnu.gdb.mips.cpu", 0 },
|
|
|
|
{ 22, "r22", REG_TYPE_INT, NULL, "org.gnu.gdb.mips.cpu", 0 },
|
|
|
|
{ 23, "r23", REG_TYPE_INT, NULL, "org.gnu.gdb.mips.cpu", 0 },
|
|
|
|
{ 24, "r24", REG_TYPE_INT, NULL, "org.gnu.gdb.mips.cpu", 0 },
|
|
|
|
{ 25, "r25", REG_TYPE_INT, NULL, "org.gnu.gdb.mips.cpu", 0 },
|
|
|
|
{ 26, "r26", REG_TYPE_INT, NULL, "org.gnu.gdb.mips.cpu", 0 },
|
|
|
|
{ 27, "r27", REG_TYPE_INT, NULL, "org.gnu.gdb.mips.cpu", 0 },
|
|
|
|
{ 28, "r28", REG_TYPE_INT, NULL, "org.gnu.gdb.mips.cpu", 0 },
|
|
|
|
{ 29, "r29", REG_TYPE_INT, NULL, "org.gnu.gdb.mips.cpu", 0 },
|
|
|
|
{ 30, "r30", REG_TYPE_INT, NULL, "org.gnu.gdb.mips.cpu", 0 },
|
|
|
|
{ 31, "r31", REG_TYPE_INT, NULL, "org.gnu.gdb.mips.cpu", 0 },
|
|
|
|
{ 32, "status", REG_TYPE_INT, NULL, "org.gnu.gdb.mips.cp0", 0 },
|
|
|
|
{ 33, "lo", REG_TYPE_INT, NULL, "org.gnu.gdb.mips.cpu", 0 },
|
|
|
|
{ 34, "hi", REG_TYPE_INT, NULL, "org.gnu.gdb.mips.cpu", 0 },
|
|
|
|
{ 35, "badvaddr", REG_TYPE_INT, NULL, "org.gnu.gdb.mips.cp0", 0 },
|
|
|
|
{ 36, "cause", REG_TYPE_INT, NULL, "org.gnu.gdb.mips.cp0", 0 },
|
|
|
|
{ 37, "pc", REG_TYPE_INT, NULL, "org.gnu.gdb.mips.cpu", 0 },
|
|
|
|
|
|
|
|
{ 38, "f0", REG_TYPE_IEEE_SINGLE, NULL,
|
|
|
|
"org.gnu.gdb.mips.fpu", MIPS32_GDB_DUMMY_FP_REG },
|
|
|
|
{ 39, "f1", REG_TYPE_IEEE_SINGLE, NULL,
|
|
|
|
"org.gnu.gdb.mips.fpu", MIPS32_GDB_DUMMY_FP_REG },
|
|
|
|
{ 40, "f2", REG_TYPE_IEEE_SINGLE, NULL,
|
|
|
|
"org.gnu.gdb.mips.fpu", MIPS32_GDB_DUMMY_FP_REG },
|
|
|
|
{ 41, "f3", REG_TYPE_IEEE_SINGLE, NULL,
|
|
|
|
"org.gnu.gdb.mips.fpu", MIPS32_GDB_DUMMY_FP_REG },
|
|
|
|
{ 42, "f4", REG_TYPE_IEEE_SINGLE, NULL,
|
|
|
|
"org.gnu.gdb.mips.fpu", MIPS32_GDB_DUMMY_FP_REG },
|
|
|
|
{ 43, "f5", REG_TYPE_IEEE_SINGLE, NULL,
|
|
|
|
"org.gnu.gdb.mips.fpu", MIPS32_GDB_DUMMY_FP_REG },
|
|
|
|
{ 44, "f6", REG_TYPE_IEEE_SINGLE, NULL,
|
|
|
|
"org.gnu.gdb.mips.fpu", MIPS32_GDB_DUMMY_FP_REG },
|
|
|
|
{ 45, "f7", REG_TYPE_IEEE_SINGLE, NULL,
|
|
|
|
"org.gnu.gdb.mips.fpu", MIPS32_GDB_DUMMY_FP_REG },
|
|
|
|
{ 46, "f8", REG_TYPE_IEEE_SINGLE, NULL,
|
|
|
|
"org.gnu.gdb.mips.fpu", MIPS32_GDB_DUMMY_FP_REG },
|
|
|
|
{ 47, "f9", REG_TYPE_IEEE_SINGLE, NULL,
|
|
|
|
"org.gnu.gdb.mips.fpu", MIPS32_GDB_DUMMY_FP_REG },
|
|
|
|
{ 48, "f10", REG_TYPE_IEEE_SINGLE, NULL,
|
|
|
|
"org.gnu.gdb.mips.fpu", MIPS32_GDB_DUMMY_FP_REG },
|
|
|
|
{ 49, "f11", REG_TYPE_IEEE_SINGLE, NULL,
|
|
|
|
"org.gnu.gdb.mips.fpu", MIPS32_GDB_DUMMY_FP_REG },
|
|
|
|
{ 50, "f12", REG_TYPE_IEEE_SINGLE, NULL,
|
|
|
|
"org.gnu.gdb.mips.fpu", MIPS32_GDB_DUMMY_FP_REG },
|
|
|
|
{ 51, "f13", REG_TYPE_IEEE_SINGLE, NULL,
|
|
|
|
"org.gnu.gdb.mips.fpu", MIPS32_GDB_DUMMY_FP_REG },
|
|
|
|
{ 52, "f14", REG_TYPE_IEEE_SINGLE, NULL,
|
|
|
|
"org.gnu.gdb.mips.fpu", MIPS32_GDB_DUMMY_FP_REG },
|
|
|
|
{ 53, "f15", REG_TYPE_IEEE_SINGLE, NULL,
|
|
|
|
"org.gnu.gdb.mips.fpu", MIPS32_GDB_DUMMY_FP_REG },
|
|
|
|
{ 54, "f16", REG_TYPE_IEEE_SINGLE, NULL,
|
|
|
|
"org.gnu.gdb.mips.fpu", MIPS32_GDB_DUMMY_FP_REG },
|
|
|
|
{ 55, "f17", REG_TYPE_IEEE_SINGLE, NULL,
|
|
|
|
"org.gnu.gdb.mips.fpu", MIPS32_GDB_DUMMY_FP_REG },
|
|
|
|
{ 56, "f18", REG_TYPE_IEEE_SINGLE, NULL,
|
|
|
|
"org.gnu.gdb.mips.fpu", MIPS32_GDB_DUMMY_FP_REG },
|
|
|
|
{ 57, "f19", REG_TYPE_IEEE_SINGLE, NULL,
|
|
|
|
"org.gnu.gdb.mips.fpu", MIPS32_GDB_DUMMY_FP_REG },
|
|
|
|
{ 58, "f20", REG_TYPE_IEEE_SINGLE, NULL,
|
|
|
|
"org.gnu.gdb.mips.fpu", MIPS32_GDB_DUMMY_FP_REG },
|
|
|
|
{ 59, "f21", REG_TYPE_IEEE_SINGLE, NULL,
|
|
|
|
"org.gnu.gdb.mips.fpu", MIPS32_GDB_DUMMY_FP_REG },
|
|
|
|
{ 60, "f22", REG_TYPE_IEEE_SINGLE, NULL,
|
|
|
|
"org.gnu.gdb.mips.fpu", MIPS32_GDB_DUMMY_FP_REG },
|
|
|
|
{ 61, "f23", REG_TYPE_IEEE_SINGLE, NULL,
|
|
|
|
"org.gnu.gdb.mips.fpu", MIPS32_GDB_DUMMY_FP_REG },
|
|
|
|
{ 62, "f24", REG_TYPE_IEEE_SINGLE, NULL,
|
|
|
|
"org.gnu.gdb.mips.fpu", MIPS32_GDB_DUMMY_FP_REG },
|
|
|
|
{ 63, "f25", REG_TYPE_IEEE_SINGLE, NULL,
|
|
|
|
"org.gnu.gdb.mips.fpu", MIPS32_GDB_DUMMY_FP_REG },
|
|
|
|
{ 64, "f26", REG_TYPE_IEEE_SINGLE, NULL,
|
|
|
|
"org.gnu.gdb.mips.fpu", MIPS32_GDB_DUMMY_FP_REG },
|
|
|
|
{ 65, "f27", REG_TYPE_IEEE_SINGLE, NULL,
|
|
|
|
"org.gnu.gdb.mips.fpu", MIPS32_GDB_DUMMY_FP_REG },
|
|
|
|
{ 66, "f28", REG_TYPE_IEEE_SINGLE, NULL,
|
|
|
|
"org.gnu.gdb.mips.fpu", MIPS32_GDB_DUMMY_FP_REG },
|
|
|
|
{ 67, "f29", REG_TYPE_IEEE_SINGLE, NULL,
|
|
|
|
"org.gnu.gdb.mips.fpu", MIPS32_GDB_DUMMY_FP_REG },
|
|
|
|
{ 68, "f30", REG_TYPE_IEEE_SINGLE, NULL,
|
|
|
|
"org.gnu.gdb.mips.fpu", MIPS32_GDB_DUMMY_FP_REG },
|
|
|
|
{ 69, "f31", REG_TYPE_IEEE_SINGLE, NULL,
|
|
|
|
"org.gnu.gdb.mips.fpu", MIPS32_GDB_DUMMY_FP_REG },
|
|
|
|
{ 70, "fcsr", REG_TYPE_INT, "float",
|
|
|
|
"org.gnu.gdb.mips.fpu", MIPS32_GDB_DUMMY_FP_REG },
|
|
|
|
{ 71, "fir", REG_TYPE_INT, "float",
|
|
|
|
"org.gnu.gdb.mips.fpu", MIPS32_GDB_DUMMY_FP_REG },
|
2008-07-26 05:32:11 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-02-25 14:16:58 -06:00
|
|
|
#define MIPS32_NUM_REGS ARRAY_SIZE(mips32_regs)
|
2008-07-26 05:32:11 -05:00
|
|
|
|
2010-04-10 12:16:14 -05:00
|
|
|
static uint8_t mips32_gdb_dummy_fp_value[] = {0, 0, 0, 0};
|
2008-07-26 05:32:11 -05:00
|
|
|
|
2010-04-10 12:16:14 -05:00
|
|
|
static int mips32_get_core_reg(struct reg *reg)
|
2008-07-26 05:32:11 -05:00
|
|
|
{
|
|
|
|
int retval;
|
2009-11-13 10:43:33 -06:00
|
|
|
struct mips32_core_reg *mips32_reg = reg->arch_info;
|
2009-11-13 12:11:13 -06:00
|
|
|
struct target *target = mips32_reg->target;
|
2010-01-08 16:35:08 -06:00
|
|
|
struct mips32_common *mips32_target = target_to_mips32(target);
|
2009-06-23 17:49:23 -05:00
|
|
|
|
2008-07-26 05:32:11 -05:00
|
|
|
if (target->state != TARGET_HALTED)
|
|
|
|
return ERROR_TARGET_NOT_HALTED;
|
|
|
|
|
|
|
|
retval = mips32_target->read_core_reg(target, mips32_reg->num);
|
2009-06-23 17:49:23 -05:00
|
|
|
|
2008-07-26 05:32:11 -05:00
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2010-04-10 12:16:14 -05:00
|
|
|
static int mips32_set_core_reg(struct reg *reg, uint8_t *buf)
|
2008-07-26 05:32:11 -05:00
|
|
|
{
|
2009-11-13 10:43:33 -06:00
|
|
|
struct mips32_core_reg *mips32_reg = reg->arch_info;
|
2009-11-13 12:11:13 -06:00
|
|
|
struct target *target = mips32_reg->target;
|
2009-06-18 02:09:35 -05:00
|
|
|
uint32_t value = buf_get_u32(buf, 0, 32);
|
2009-06-23 17:49:23 -05:00
|
|
|
|
2008-07-26 05:32:11 -05:00
|
|
|
if (target->state != TARGET_HALTED)
|
|
|
|
return ERROR_TARGET_NOT_HALTED;
|
2009-06-23 17:49:23 -05:00
|
|
|
|
2008-07-26 05:32:11 -05:00
|
|
|
buf_set_u32(reg->value, 0, 32, value);
|
2019-02-26 07:10:48 -06:00
|
|
|
reg->dirty = true;
|
|
|
|
reg->valid = true;
|
2008-07-26 05:32:11 -05:00
|
|
|
|
|
|
|
return ERROR_OK;
|
|
|
|
}
|
|
|
|
|
2014-07-15 02:59:04 -05:00
|
|
|
static int mips32_read_core_reg(struct target *target, unsigned int num)
|
2008-07-26 05:32:11 -05:00
|
|
|
{
|
2009-06-18 02:09:35 -05:00
|
|
|
uint32_t reg_value;
|
2009-06-23 17:49:23 -05:00
|
|
|
|
2008-07-26 05:32:11 -05:00
|
|
|
/* get pointers to arch-specific information */
|
2010-01-08 16:35:08 -06:00
|
|
|
struct mips32_common *mips32 = target_to_mips32(target);
|
2009-06-23 17:49:23 -05:00
|
|
|
|
2014-02-25 14:16:58 -06:00
|
|
|
if (num >= MIPS32_NUM_REGS)
|
2011-12-28 05:56:08 -06:00
|
|
|
return ERROR_COMMAND_SYNTAX_ERROR;
|
2008-07-26 05:32:11 -05:00
|
|
|
|
|
|
|
reg_value = mips32->core_regs[num];
|
|
|
|
buf_set_u32(mips32->core_cache->reg_list[num].value, 0, 32, reg_value);
|
2019-02-26 07:10:48 -06:00
|
|
|
mips32->core_cache->reg_list[num].valid = true;
|
|
|
|
mips32->core_cache->reg_list[num].dirty = false;
|
2009-06-23 17:49:23 -05:00
|
|
|
|
|
|
|
return ERROR_OK;
|
2008-07-26 05:32:11 -05:00
|
|
|
}
|
|
|
|
|
2014-07-15 02:59:04 -05:00
|
|
|
static int mips32_write_core_reg(struct target *target, unsigned int num)
|
2008-07-26 05:32:11 -05:00
|
|
|
{
|
2009-06-18 02:09:35 -05:00
|
|
|
uint32_t reg_value;
|
2009-06-23 17:49:23 -05:00
|
|
|
|
2008-07-26 05:32:11 -05:00
|
|
|
/* get pointers to arch-specific information */
|
2010-01-08 16:35:08 -06:00
|
|
|
struct mips32_common *mips32 = target_to_mips32(target);
|
2008-07-26 05:32:11 -05:00
|
|
|
|
2014-02-25 14:16:58 -06:00
|
|
|
if (num >= MIPS32_NUM_REGS)
|
2011-12-28 05:56:08 -06:00
|
|
|
return ERROR_COMMAND_SYNTAX_ERROR;
|
2009-06-23 17:49:23 -05:00
|
|
|
|
2008-07-26 05:32:11 -05:00
|
|
|
reg_value = buf_get_u32(mips32->core_cache->reg_list[num].value, 0, 32);
|
|
|
|
mips32->core_regs[num] = reg_value;
|
2009-06-20 22:17:03 -05:00
|
|
|
LOG_DEBUG("write core reg %i value 0x%" PRIx32 "", num , reg_value);
|
2019-02-26 07:10:48 -06:00
|
|
|
mips32->core_cache->reg_list[num].valid = true;
|
|
|
|
mips32->core_cache->reg_list[num].dirty = false;
|
2009-06-23 17:49:23 -05:00
|
|
|
|
2008-07-26 05:32:11 -05:00
|
|
|
return ERROR_OK;
|
|
|
|
}
|
|
|
|
|
2013-05-07 08:43:35 -05:00
|
|
|
int mips32_get_gdb_reg_list(struct target *target, struct reg **reg_list[],
|
|
|
|
int *reg_list_size, enum target_register_class reg_class)
|
2008-07-26 05:32:11 -05:00
|
|
|
{
|
|
|
|
/* get pointers to arch-specific information */
|
2010-01-08 16:35:08 -06:00
|
|
|
struct mips32_common *mips32 = target_to_mips32(target);
|
2014-07-15 02:59:04 -05:00
|
|
|
unsigned int i;
|
2009-06-23 17:49:23 -05:00
|
|
|
|
2009-01-13 07:45:08 -06:00
|
|
|
/* include floating point registers */
|
2014-02-25 14:16:58 -06:00
|
|
|
*reg_list_size = MIPS32_NUM_REGS;
|
2012-02-05 06:03:04 -06:00
|
|
|
*reg_list = malloc(sizeof(struct reg *) * (*reg_list_size));
|
2009-06-23 17:49:23 -05:00
|
|
|
|
2014-02-25 14:16:58 -06:00
|
|
|
for (i = 0; i < MIPS32_NUM_REGS; i++)
|
2008-07-26 05:32:11 -05:00
|
|
|
(*reg_list)[i] = &mips32->core_cache->reg_list[i];
|
2009-06-23 17:49:23 -05:00
|
|
|
|
2008-07-26 05:32:11 -05:00
|
|
|
return ERROR_OK;
|
|
|
|
}
|
|
|
|
|
2009-11-13 12:11:13 -06:00
|
|
|
int mips32_save_context(struct target *target)
|
2008-07-26 05:32:11 -05:00
|
|
|
{
|
2014-07-15 02:59:04 -05:00
|
|
|
unsigned int i;
|
2009-06-23 17:49:23 -05:00
|
|
|
|
2008-07-26 05:32:11 -05:00
|
|
|
/* get pointers to arch-specific information */
|
2010-01-08 16:35:08 -06:00
|
|
|
struct mips32_common *mips32 = target_to_mips32(target);
|
2009-11-13 10:43:36 -06:00
|
|
|
struct mips_ejtag *ejtag_info = &mips32->ejtag_info;
|
2009-06-23 17:49:23 -05:00
|
|
|
|
2008-07-26 05:32:11 -05:00
|
|
|
/* read core registers */
|
|
|
|
mips32_pracc_read_regs(ejtag_info, mips32->core_regs);
|
2009-06-23 17:49:23 -05:00
|
|
|
|
2014-02-25 14:16:58 -06:00
|
|
|
for (i = 0; i < MIPS32_NUM_REGS; i++) {
|
2008-07-26 05:32:11 -05:00
|
|
|
if (!mips32->core_cache->reg_list[i].valid)
|
|
|
|
mips32->read_core_reg(target, i);
|
|
|
|
}
|
2009-06-23 17:49:23 -05:00
|
|
|
|
|
|
|
return ERROR_OK;
|
2008-07-26 05:32:11 -05:00
|
|
|
}
|
|
|
|
|
2009-11-13 12:11:13 -06:00
|
|
|
int mips32_restore_context(struct target *target)
|
2008-07-26 05:32:11 -05:00
|
|
|
{
|
2014-07-15 02:59:04 -05:00
|
|
|
unsigned int i;
|
2009-06-23 17:49:23 -05:00
|
|
|
|
2008-07-26 05:32:11 -05:00
|
|
|
/* get pointers to arch-specific information */
|
2010-01-08 16:35:08 -06:00
|
|
|
struct mips32_common *mips32 = target_to_mips32(target);
|
2009-11-13 10:43:36 -06:00
|
|
|
struct mips_ejtag *ejtag_info = &mips32->ejtag_info;
|
2009-06-23 17:49:23 -05:00
|
|
|
|
2014-02-25 14:16:58 -06:00
|
|
|
for (i = 0; i < MIPS32_NUM_REGS; i++) {
|
2008-07-26 05:32:11 -05:00
|
|
|
if (mips32->core_cache->reg_list[i].dirty)
|
|
|
|
mips32->write_core_reg(target, i);
|
|
|
|
}
|
2009-06-23 17:49:23 -05:00
|
|
|
|
2008-07-26 05:32:11 -05:00
|
|
|
/* write core regs */
|
|
|
|
mips32_pracc_write_regs(ejtag_info, mips32->core_regs);
|
2009-06-23 17:49:23 -05:00
|
|
|
|
|
|
|
return ERROR_OK;
|
2008-07-26 05:32:11 -05:00
|
|
|
}
|
|
|
|
|
2009-11-13 12:11:13 -06:00
|
|
|
int mips32_arch_state(struct target *target)
|
2008-07-26 05:32:11 -05:00
|
|
|
{
|
2010-01-08 16:35:08 -06:00
|
|
|
struct mips32_common *mips32 = target_to_mips32(target);
|
2009-06-23 17:49:23 -05:00
|
|
|
|
2010-01-08 16:35:08 -06:00
|
|
|
LOG_USER("target halted in %s mode due to %s, pc: 0x%8.8" PRIx32 "",
|
|
|
|
mips_isa_strings[mips32->isa_mode],
|
2009-12-07 16:55:08 -06:00
|
|
|
debug_reason_name(target),
|
2008-07-26 05:32:11 -05:00
|
|
|
buf_get_u32(mips32->core_cache->reg_list[MIPS32_PC].value, 0, 32));
|
2009-06-23 17:49:23 -05:00
|
|
|
|
2008-07-26 05:32:11 -05:00
|
|
|
return ERROR_OK;
|
|
|
|
}
|
|
|
|
|
2009-11-17 11:06:45 -06:00
|
|
|
static const struct reg_arch_type mips32_reg_type = {
|
|
|
|
.get = mips32_get_core_reg,
|
|
|
|
.set = mips32_set_core_reg,
|
|
|
|
};
|
|
|
|
|
2009-11-13 12:11:13 -06:00
|
|
|
struct reg_cache *mips32_build_reg_cache(struct target *target)
|
2008-07-26 05:32:11 -05:00
|
|
|
{
|
|
|
|
/* get pointers to arch-specific information */
|
2010-01-08 16:35:08 -06:00
|
|
|
struct mips32_common *mips32 = target_to_mips32(target);
|
2008-07-26 05:32:11 -05:00
|
|
|
|
2014-02-25 14:16:58 -06:00
|
|
|
int num_regs = MIPS32_NUM_REGS;
|
2009-11-13 10:44:08 -06:00
|
|
|
struct reg_cache **cache_p = register_get_last_cache_p(&target->reg_cache);
|
|
|
|
struct reg_cache *cache = malloc(sizeof(struct reg_cache));
|
2014-04-12 08:22:00 -05:00
|
|
|
struct reg *reg_list = calloc(num_regs, sizeof(struct reg));
|
2009-11-13 10:43:33 -06:00
|
|
|
struct mips32_core_reg *arch_info = malloc(sizeof(struct mips32_core_reg) * num_regs);
|
2014-02-25 14:16:58 -06:00
|
|
|
struct reg_feature *feature;
|
2008-07-26 05:32:11 -05:00
|
|
|
int i;
|
2009-06-23 17:49:23 -05:00
|
|
|
|
|
|
|
/* Build the process context cache */
|
2008-07-26 05:32:11 -05:00
|
|
|
cache->name = "mips32 registers";
|
|
|
|
cache->next = NULL;
|
|
|
|
cache->reg_list = reg_list;
|
|
|
|
cache->num_regs = num_regs;
|
|
|
|
(*cache_p) = cache;
|
|
|
|
mips32->core_cache = cache;
|
2009-06-23 17:49:23 -05:00
|
|
|
|
2012-02-05 06:03:04 -06:00
|
|
|
for (i = 0; i < num_regs; i++) {
|
2014-02-09 02:15:06 -06:00
|
|
|
arch_info[i].num = mips32_regs[i].id;
|
2008-07-26 05:32:11 -05:00
|
|
|
arch_info[i].target = target;
|
|
|
|
arch_info[i].mips32_common = mips32;
|
2014-02-09 02:15:06 -06:00
|
|
|
|
|
|
|
reg_list[i].name = mips32_regs[i].name;
|
2008-07-26 05:32:11 -05:00
|
|
|
reg_list[i].size = 32;
|
2014-02-25 14:16:58 -06:00
|
|
|
|
|
|
|
if (mips32_regs[i].flag == MIPS32_GDB_DUMMY_FP_REG) {
|
|
|
|
reg_list[i].value = mips32_gdb_dummy_fp_value;
|
2019-02-26 07:10:48 -06:00
|
|
|
reg_list[i].valid = true;
|
2014-02-25 14:16:58 -06:00
|
|
|
reg_list[i].arch_info = NULL;
|
|
|
|
register_init_dummy(®_list[i]);
|
|
|
|
} else {
|
|
|
|
reg_list[i].value = calloc(1, 4);
|
2019-02-26 07:10:48 -06:00
|
|
|
reg_list[i].valid = false;
|
2014-02-25 14:16:58 -06:00
|
|
|
reg_list[i].type = &mips32_reg_type;
|
|
|
|
reg_list[i].arch_info = &arch_info[i];
|
|
|
|
|
|
|
|
reg_list[i].reg_data_type = calloc(1, sizeof(struct reg_data_type));
|
|
|
|
if (reg_list[i].reg_data_type)
|
|
|
|
reg_list[i].reg_data_type->type = mips32_regs[i].type;
|
|
|
|
else
|
|
|
|
LOG_ERROR("unable to allocate reg type list");
|
|
|
|
}
|
|
|
|
|
2019-02-26 07:10:48 -06:00
|
|
|
reg_list[i].dirty = false;
|
2014-02-25 14:16:58 -06:00
|
|
|
|
|
|
|
reg_list[i].group = mips32_regs[i].group;
|
|
|
|
reg_list[i].number = i;
|
|
|
|
reg_list[i].exist = true;
|
|
|
|
reg_list[i].caller_save = true; /* gdb defaults to true */
|
|
|
|
|
|
|
|
feature = calloc(1, sizeof(struct reg_feature));
|
|
|
|
if (feature) {
|
|
|
|
feature->name = mips32_regs[i].feature;
|
|
|
|
reg_list[i].feature = feature;
|
|
|
|
} else
|
|
|
|
LOG_ERROR("unable to allocate feature list");
|
2008-07-26 05:32:11 -05:00
|
|
|
}
|
2009-06-23 17:49:23 -05:00
|
|
|
|
2008-07-26 05:32:11 -05:00
|
|
|
return cache;
|
|
|
|
}
|
|
|
|
|
2009-11-13 12:11:13 -06:00
|
|
|
int mips32_init_arch_info(struct target *target, struct mips32_common *mips32, struct jtag_tap *tap)
|
2008-07-26 05:32:11 -05:00
|
|
|
{
|
|
|
|
target->arch_info = mips32;
|
|
|
|
mips32->common_magic = MIPS32_COMMON_MAGIC;
|
2011-01-04 06:29:49 -06:00
|
|
|
mips32->fast_data_area = NULL;
|
2017-05-07 11:39:17 -05:00
|
|
|
mips32->isa_imp = MIPS32_ONLY; /* default */
|
2009-06-23 17:49:23 -05:00
|
|
|
|
2014-10-07 03:36:55 -05:00
|
|
|
/* has breakpoint/watchpoint unit been scanned */
|
2008-11-17 11:56:44 -06:00
|
|
|
mips32->bp_scanned = 0;
|
|
|
|
mips32->data_break_list = NULL;
|
2009-06-23 17:49:23 -05:00
|
|
|
|
2008-11-30 16:25:43 -06:00
|
|
|
mips32->ejtag_info.tap = tap;
|
2008-07-26 05:32:11 -05:00
|
|
|
mips32->read_core_reg = mips32_read_core_reg;
|
|
|
|
mips32->write_core_reg = mips32_write_core_reg;
|
2017-05-07 04:58:25 -05:00
|
|
|
/* if unknown endianness defaults to little endian, 1 */
|
|
|
|
mips32->ejtag_info.endianness = target->endianness == TARGET_BIG_ENDIAN ? 0 : 1;
|
|
|
|
mips32->ejtag_info.scan_delay = MIPS32_SCAN_DELAY_LEGACY_MODE;
|
mips: m4k alternate pracc code. Patch 1
This patch and the following patches define another way of doing processor access without the need to read back
the pracc address as needed in current pracc code.
Current pracc code is executed linearly and unconditionally. The processor starts execution at 0xff200200
and the fetch address is ever incremented by 4, including the last instruction in the delay slot of the branch to start.
Most of the processor accesses are fetch and some are store accesses.
After a previous patch regarding the way of restoring registers (reg8 and reg9), there are no load processor accesses.
The pracc address for a store depends only on the store instruction given before.
m4k core has a 5 stage pipeline and the memory access is done in the 3rth stage. This means that the store access
will not arrive immediately after a store instruction, it appears after another instruction enters the pipeline.
For reference: MD00249 mips32 m4k manual.
A new struct pracc_queue_info is defined to help each function in generating the code. The field pracc_list holds in the
lower half the list of instructions and in the upper half the store addressess, if any. In this way the list can be used by
current code or by the new one to generate the sequence of pracc accesses.
For every pracc access only one scan to register "all" is used by calling the new function mips_ejtag_add_scan_96().
This function does not call jtag_execute_queue(), all the scans needed can be queued before calling for execution.
The pracc bit is not checked before execution, is checked after the queue has been executed.
Without calling the wait function the code works much faster, but the scan frequency must be limited. For pic32mx
with core clock at 4Mhz works up to 600Khz and with 8Mhz up to 1200. To increase the scan frequency a delay
between scans is added by calling jtag_add_cloks().
A time delay in nano seconds is stored in scan_delay, a new field in ejtag_info, and a handler is provided for it.
A mode field is added to ejtag_info to hold the working mode. If a time delay of 2ms (2000000 ns) or higher is set,
current code is executed, if lower, new code is executed.
Initial default values are set in function mips32_init_arch_info. A reset does not change this settings.
Change-Id: I266bdb386b24744435b6e29d8489a68c0c15ff65
Signed-off-by: Salvador Arroyo <sarroyofdez@yahoo.es>
Reviewed-on: http://openocd.zylin.com/1193
Tested-by: jenkins
Reviewed-by: Freddie Chopin <freddie.chopin@gmail.com>
2013-03-03 03:50:42 -06:00
|
|
|
mips32->ejtag_info.mode = 0; /* Initial default value */
|
2017-05-07 04:58:25 -05:00
|
|
|
mips32->ejtag_info.isa = 0; /* isa on debug mips32, updated by poll function */
|
2017-05-07 11:39:17 -05:00
|
|
|
mips32->ejtag_info.config_regs = 0; /* no config register read */
|
2008-07-26 05:32:11 -05:00
|
|
|
return ERROR_OK;
|
|
|
|
}
|
|
|
|
|
2010-01-13 04:12:34 -06:00
|
|
|
/* run to exit point. return error if exit point was not reached. */
|
2013-09-23 03:27:03 -05:00
|
|
|
static int mips32_run_and_wait(struct target *target, target_addr_t entry_point,
|
|
|
|
int timeout_ms, target_addr_t exit_point, struct mips32_common *mips32)
|
2008-07-26 05:32:11 -05:00
|
|
|
{
|
2010-01-13 04:12:34 -06:00
|
|
|
uint32_t pc;
|
|
|
|
int retval;
|
|
|
|
/* This code relies on the target specific resume() and poll()->debug_entry()
|
|
|
|
* sequence to write register values to the processor and the read them back */
|
2012-02-05 06:03:04 -06:00
|
|
|
retval = target_resume(target, 0, entry_point, 0, 1);
|
|
|
|
if (retval != ERROR_OK)
|
2010-01-13 04:12:34 -06:00
|
|
|
return retval;
|
|
|
|
|
|
|
|
retval = target_wait_state(target, TARGET_HALTED, timeout_ms);
|
|
|
|
/* If the target fails to halt due to the breakpoint, force a halt */
|
2012-02-05 06:03:04 -06:00
|
|
|
if (retval != ERROR_OK || target->state != TARGET_HALTED) {
|
|
|
|
retval = target_halt(target);
|
|
|
|
if (retval != ERROR_OK)
|
2010-01-13 04:12:34 -06:00
|
|
|
return retval;
|
2012-02-05 06:03:04 -06:00
|
|
|
retval = target_wait_state(target, TARGET_HALTED, 500);
|
|
|
|
if (retval != ERROR_OK)
|
2010-01-13 04:12:34 -06:00
|
|
|
return retval;
|
|
|
|
return ERROR_TARGET_TIMEOUT;
|
|
|
|
}
|
|
|
|
|
|
|
|
pc = buf_get_u32(mips32->core_cache->reg_list[MIPS32_PC].value, 0, 32);
|
2012-02-05 06:03:04 -06:00
|
|
|
if (exit_point && (pc != exit_point)) {
|
2011-03-16 21:22:12 -05:00
|
|
|
LOG_DEBUG("failed algorithm halted at 0x%" PRIx32 " ", pc);
|
2010-01-13 04:12:34 -06:00
|
|
|
return ERROR_TARGET_TIMEOUT;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ERROR_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
int mips32_run_algorithm(struct target *target, int num_mem_params,
|
|
|
|
struct mem_param *mem_params, int num_reg_params,
|
2013-09-23 03:27:03 -05:00
|
|
|
struct reg_param *reg_params, target_addr_t entry_point,
|
|
|
|
target_addr_t exit_point, int timeout_ms, void *arch_info)
|
2010-01-13 04:12:34 -06:00
|
|
|
{
|
|
|
|
struct mips32_common *mips32 = target_to_mips32(target);
|
|
|
|
struct mips32_algorithm *mips32_algorithm_info = arch_info;
|
|
|
|
enum mips32_isa_mode isa_mode = mips32->isa_mode;
|
|
|
|
|
2014-02-25 14:16:58 -06:00
|
|
|
uint32_t context[MIPS32_NUM_REGS];
|
2010-01-13 04:12:34 -06:00
|
|
|
int retval = ERROR_OK;
|
|
|
|
|
|
|
|
LOG_DEBUG("Running algorithm");
|
|
|
|
|
|
|
|
/* NOTE: mips32_run_algorithm requires that each algorithm uses a software breakpoint
|
|
|
|
* at the exit point */
|
|
|
|
|
2012-02-05 06:03:04 -06:00
|
|
|
if (mips32->common_magic != MIPS32_COMMON_MAGIC) {
|
2010-01-13 04:12:34 -06:00
|
|
|
LOG_ERROR("current target isn't a MIPS32 target");
|
|
|
|
return ERROR_TARGET_INVALID;
|
|
|
|
}
|
|
|
|
|
2012-02-05 06:03:04 -06:00
|
|
|
if (target->state != TARGET_HALTED) {
|
2010-01-13 04:12:34 -06:00
|
|
|
LOG_WARNING("target not halted");
|
|
|
|
return ERROR_TARGET_NOT_HALTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* refresh core register cache */
|
2014-02-25 14:16:58 -06:00
|
|
|
for (unsigned int i = 0; i < MIPS32_NUM_REGS; i++) {
|
2010-01-13 04:12:34 -06:00
|
|
|
if (!mips32->core_cache->reg_list[i].valid)
|
|
|
|
mips32->read_core_reg(target, i);
|
|
|
|
context[i] = buf_get_u32(mips32->core_cache->reg_list[i].value, 0, 32);
|
|
|
|
}
|
|
|
|
|
2014-07-15 02:59:04 -05:00
|
|
|
for (int i = 0; i < num_mem_params; i++) {
|
2018-12-17 09:07:29 -06:00
|
|
|
if (mem_params[i].direction == PARAM_IN)
|
|
|
|
continue;
|
2012-02-05 06:03:04 -06:00
|
|
|
retval = target_write_buffer(target, mem_params[i].address,
|
|
|
|
mem_params[i].size, mem_params[i].value);
|
|
|
|
if (retval != ERROR_OK)
|
2010-01-13 04:12:34 -06:00
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2014-07-15 02:59:04 -05:00
|
|
|
for (int i = 0; i < num_reg_params; i++) {
|
2018-12-18 10:17:33 -06:00
|
|
|
if (reg_params[i].direction == PARAM_IN)
|
|
|
|
continue;
|
|
|
|
|
2010-01-13 04:12:34 -06:00
|
|
|
struct reg *reg = register_get_by_name(mips32->core_cache, reg_params[i].reg_name, 0);
|
|
|
|
|
2012-02-05 06:03:04 -06:00
|
|
|
if (!reg) {
|
2010-01-13 04:12:34 -06:00
|
|
|
LOG_ERROR("BUG: register '%s' not found", reg_params[i].reg_name);
|
2011-12-28 05:56:08 -06:00
|
|
|
return ERROR_COMMAND_SYNTAX_ERROR;
|
2010-01-13 04:12:34 -06:00
|
|
|
}
|
|
|
|
|
2012-02-05 06:03:04 -06:00
|
|
|
if (reg->size != reg_params[i].size) {
|
2010-01-13 04:12:34 -06:00
|
|
|
LOG_ERROR("BUG: register '%s' size doesn't match reg_params[i].size",
|
|
|
|
reg_params[i].reg_name);
|
2011-12-28 05:56:08 -06:00
|
|
|
return ERROR_COMMAND_SYNTAX_ERROR;
|
2010-01-13 04:12:34 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
mips32_set_core_reg(reg, reg_params[i].value);
|
|
|
|
}
|
|
|
|
|
|
|
|
mips32->isa_mode = mips32_algorithm_info->isa_mode;
|
|
|
|
|
|
|
|
retval = mips32_run_and_wait(target, entry_point, timeout_ms, exit_point, mips32);
|
|
|
|
|
|
|
|
if (retval != ERROR_OK)
|
|
|
|
return retval;
|
|
|
|
|
2014-07-15 02:59:04 -05:00
|
|
|
for (int i = 0; i < num_mem_params; i++) {
|
2012-02-05 06:03:04 -06:00
|
|
|
if (mem_params[i].direction != PARAM_OUT) {
|
|
|
|
retval = target_read_buffer(target, mem_params[i].address, mem_params[i].size,
|
|
|
|
mem_params[i].value);
|
|
|
|
if (retval != ERROR_OK)
|
2010-01-13 04:12:34 -06:00
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-15 02:59:04 -05:00
|
|
|
for (int i = 0; i < num_reg_params; i++) {
|
2012-02-05 06:03:04 -06:00
|
|
|
if (reg_params[i].direction != PARAM_OUT) {
|
2010-01-13 04:12:34 -06:00
|
|
|
struct reg *reg = register_get_by_name(mips32->core_cache, reg_params[i].reg_name, 0);
|
2012-02-05 06:03:04 -06:00
|
|
|
if (!reg) {
|
2010-01-13 04:12:34 -06:00
|
|
|
LOG_ERROR("BUG: register '%s' not found", reg_params[i].reg_name);
|
2011-12-28 05:56:08 -06:00
|
|
|
return ERROR_COMMAND_SYNTAX_ERROR;
|
2010-01-13 04:12:34 -06:00
|
|
|
}
|
|
|
|
|
2012-02-05 06:03:04 -06:00
|
|
|
if (reg->size != reg_params[i].size) {
|
2010-01-13 04:12:34 -06:00
|
|
|
LOG_ERROR("BUG: register '%s' size doesn't match reg_params[i].size",
|
|
|
|
reg_params[i].reg_name);
|
2011-12-28 05:56:08 -06:00
|
|
|
return ERROR_COMMAND_SYNTAX_ERROR;
|
2010-01-13 04:12:34 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
buf_set_u32(reg_params[i].value, 0, 32, buf_get_u32(reg->value, 0, 32));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* restore everything we saved before */
|
2014-02-25 14:16:58 -06:00
|
|
|
for (unsigned int i = 0; i < MIPS32_NUM_REGS; i++) {
|
2010-01-13 04:12:34 -06:00
|
|
|
uint32_t regvalue;
|
|
|
|
regvalue = buf_get_u32(mips32->core_cache->reg_list[i].value, 0, 32);
|
2012-02-05 06:03:04 -06:00
|
|
|
if (regvalue != context[i]) {
|
2010-01-13 04:12:34 -06:00
|
|
|
LOG_DEBUG("restoring register %s with value 0x%8.8" PRIx32,
|
|
|
|
mips32->core_cache->reg_list[i].name, context[i]);
|
|
|
|
buf_set_u32(mips32->core_cache->reg_list[i].value,
|
|
|
|
0, 32, context[i]);
|
2019-02-26 07:10:48 -06:00
|
|
|
mips32->core_cache->reg_list[i].valid = true;
|
|
|
|
mips32->core_cache->reg_list[i].dirty = true;
|
2010-01-13 04:12:34 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mips32->isa_mode = isa_mode;
|
|
|
|
|
2008-07-26 05:32:11 -05:00
|
|
|
return ERROR_OK;
|
|
|
|
}
|
2008-11-17 11:56:44 -06:00
|
|
|
|
2009-11-13 12:11:13 -06:00
|
|
|
int mips32_examine(struct target *target)
|
2008-11-17 11:56:44 -06:00
|
|
|
{
|
2010-01-08 16:35:08 -06:00
|
|
|
struct mips32_common *mips32 = target_to_mips32(target);
|
2009-06-23 17:49:23 -05:00
|
|
|
|
2012-02-05 06:03:04 -06:00
|
|
|
if (!target_was_examined(target)) {
|
2009-05-31 04:38:43 -05:00
|
|
|
target_set_examined(target);
|
2009-06-23 17:49:23 -05:00
|
|
|
|
2008-11-17 11:56:44 -06:00
|
|
|
/* we will configure later */
|
|
|
|
mips32->bp_scanned = 0;
|
|
|
|
mips32->num_inst_bpoints = 0;
|
|
|
|
mips32->num_data_bpoints = 0;
|
|
|
|
mips32->num_inst_bpoints_avail = 0;
|
|
|
|
mips32->num_data_bpoints_avail = 0;
|
|
|
|
}
|
2009-06-23 17:49:23 -05:00
|
|
|
|
2008-11-17 11:56:44 -06:00
|
|
|
return ERROR_OK;
|
|
|
|
}
|
|
|
|
|
2013-06-26 03:56:23 -05:00
|
|
|
static int mips32_configure_ibs(struct target *target)
|
|
|
|
{
|
|
|
|
struct mips32_common *mips32 = target_to_mips32(target);
|
2013-04-15 05:10:04 -05:00
|
|
|
struct mips_ejtag *ejtag_info = &mips32->ejtag_info;
|
2013-06-26 03:56:23 -05:00
|
|
|
int retval, i;
|
|
|
|
uint32_t bpinfo;
|
|
|
|
|
|
|
|
/* get number of inst breakpoints */
|
2013-04-15 05:10:04 -05:00
|
|
|
retval = target_read_u32(target, ejtag_info->ejtag_ibs_addr, &bpinfo);
|
2013-06-26 03:56:23 -05:00
|
|
|
if (retval != ERROR_OK)
|
|
|
|
return retval;
|
|
|
|
|
|
|
|
mips32->num_inst_bpoints = (bpinfo >> 24) & 0x0F;
|
|
|
|
mips32->num_inst_bpoints_avail = mips32->num_inst_bpoints;
|
|
|
|
mips32->inst_break_list = calloc(mips32->num_inst_bpoints,
|
|
|
|
sizeof(struct mips32_comparator));
|
|
|
|
|
|
|
|
for (i = 0; i < mips32->num_inst_bpoints; i++)
|
|
|
|
mips32->inst_break_list[i].reg_address =
|
2013-04-15 05:10:04 -05:00
|
|
|
ejtag_info->ejtag_iba0_addr +
|
|
|
|
(ejtag_info->ejtag_iba_step_size * i);
|
2013-06-26 03:56:23 -05:00
|
|
|
|
|
|
|
/* clear IBIS reg */
|
2013-04-15 05:10:04 -05:00
|
|
|
retval = target_write_u32(target, ejtag_info->ejtag_ibs_addr, 0);
|
2013-06-26 03:56:23 -05:00
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mips32_configure_dbs(struct target *target)
|
|
|
|
{
|
|
|
|
struct mips32_common *mips32 = target_to_mips32(target);
|
2013-04-15 05:10:04 -05:00
|
|
|
struct mips_ejtag *ejtag_info = &mips32->ejtag_info;
|
2013-06-26 03:56:23 -05:00
|
|
|
int retval, i;
|
|
|
|
uint32_t bpinfo;
|
|
|
|
|
|
|
|
/* get number of data breakpoints */
|
2013-04-15 05:10:04 -05:00
|
|
|
retval = target_read_u32(target, ejtag_info->ejtag_dbs_addr, &bpinfo);
|
2013-06-26 03:56:23 -05:00
|
|
|
if (retval != ERROR_OK)
|
|
|
|
return retval;
|
|
|
|
|
|
|
|
mips32->num_data_bpoints = (bpinfo >> 24) & 0x0F;
|
|
|
|
mips32->num_data_bpoints_avail = mips32->num_data_bpoints;
|
|
|
|
mips32->data_break_list = calloc(mips32->num_data_bpoints,
|
|
|
|
sizeof(struct mips32_comparator));
|
|
|
|
|
|
|
|
for (i = 0; i < mips32->num_data_bpoints; i++)
|
|
|
|
mips32->data_break_list[i].reg_address =
|
2013-04-15 05:10:04 -05:00
|
|
|
ejtag_info->ejtag_dba0_addr +
|
|
|
|
(ejtag_info->ejtag_dba_step_size * i);
|
2013-06-26 03:56:23 -05:00
|
|
|
|
|
|
|
/* clear DBIS reg */
|
2013-04-15 05:10:04 -05:00
|
|
|
retval = target_write_u32(target, ejtag_info->ejtag_dbs_addr, 0);
|
2013-06-26 03:56:23 -05:00
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2009-11-13 12:11:13 -06:00
|
|
|
int mips32_configure_break_unit(struct target *target)
|
2008-11-17 11:56:44 -06:00
|
|
|
{
|
|
|
|
/* get pointers to arch-specific information */
|
2010-01-08 16:35:08 -06:00
|
|
|
struct mips32_common *mips32 = target_to_mips32(target);
|
2013-04-15 05:10:04 -05:00
|
|
|
struct mips_ejtag *ejtag_info = &mips32->ejtag_info;
|
2008-11-17 11:56:44 -06:00
|
|
|
int retval;
|
2013-06-26 03:56:23 -05:00
|
|
|
uint32_t dcr;
|
2009-06-23 17:49:23 -05:00
|
|
|
|
2008-11-17 11:56:44 -06:00
|
|
|
if (mips32->bp_scanned)
|
|
|
|
return ERROR_OK;
|
2009-06-23 17:49:23 -05:00
|
|
|
|
2008-11-17 11:56:44 -06:00
|
|
|
/* get info about breakpoint support */
|
2012-02-05 06:03:04 -06:00
|
|
|
retval = target_read_u32(target, EJTAG_DCR, &dcr);
|
|
|
|
if (retval != ERROR_OK)
|
2008-11-17 11:56:44 -06:00
|
|
|
return retval;
|
2009-06-23 17:49:23 -05:00
|
|
|
|
2014-02-05 16:11:15 -06:00
|
|
|
/* EJTAG 2.0 defines IB and DB bits in IMP instead of DCR. */
|
2014-01-21 13:48:14 -06:00
|
|
|
if (ejtag_info->ejtag_version == EJTAG_VERSION_20) {
|
2014-02-05 16:11:15 -06:00
|
|
|
ejtag_info->debug_caps = dcr & EJTAG_DCR_ENM;
|
2014-01-21 13:48:14 -06:00
|
|
|
if (!(ejtag_info->impcode & EJTAG_V20_IMP_NOIB))
|
2014-02-05 16:11:15 -06:00
|
|
|
ejtag_info->debug_caps |= EJTAG_DCR_IB;
|
2014-01-21 13:48:14 -06:00
|
|
|
if (!(ejtag_info->impcode & EJTAG_V20_IMP_NODB))
|
2014-02-05 16:11:15 -06:00
|
|
|
ejtag_info->debug_caps |= EJTAG_DCR_DB;
|
|
|
|
} else
|
|
|
|
/* keep debug caps for later use */
|
|
|
|
ejtag_info->debug_caps = dcr & (EJTAG_DCR_ENM
|
|
|
|
| EJTAG_DCR_IB | EJTAG_DCR_DB);
|
|
|
|
|
2013-04-15 05:10:04 -05:00
|
|
|
|
2014-02-05 16:11:15 -06:00
|
|
|
if (ejtag_info->debug_caps & EJTAG_DCR_IB) {
|
2013-06-26 03:56:23 -05:00
|
|
|
retval = mips32_configure_ibs(target);
|
2012-02-05 06:03:04 -06:00
|
|
|
if (retval != ERROR_OK)
|
2008-11-17 11:56:44 -06:00
|
|
|
return retval;
|
|
|
|
}
|
2009-06-23 17:49:23 -05:00
|
|
|
|
2014-02-05 16:11:15 -06:00
|
|
|
if (ejtag_info->debug_caps & EJTAG_DCR_DB) {
|
2013-06-26 03:56:23 -05:00
|
|
|
retval = mips32_configure_dbs(target);
|
2012-02-05 06:03:04 -06:00
|
|
|
if (retval != ERROR_OK)
|
2008-11-17 11:56:44 -06:00
|
|
|
return retval;
|
|
|
|
}
|
2009-06-23 17:49:23 -05:00
|
|
|
|
2011-05-30 09:21:04 -05:00
|
|
|
/* check if target endianness settings matches debug control register */
|
2014-02-05 16:11:15 -06:00
|
|
|
if (((ejtag_info->debug_caps & EJTAG_DCR_ENM)
|
|
|
|
&& (target->endianness == TARGET_LITTLE_ENDIAN)) ||
|
|
|
|
(!(ejtag_info->debug_caps & EJTAG_DCR_ENM)
|
|
|
|
&& (target->endianness == TARGET_BIG_ENDIAN)))
|
2011-05-30 09:21:04 -05:00
|
|
|
LOG_WARNING("DCR endianness settings does not match target settings");
|
|
|
|
|
2010-01-13 04:12:34 -06:00
|
|
|
LOG_DEBUG("DCR 0x%" PRIx32 " numinst %i numdata %i", dcr, mips32->num_inst_bpoints,
|
|
|
|
mips32->num_data_bpoints);
|
2009-06-23 17:49:23 -05:00
|
|
|
|
2008-11-17 11:56:44 -06:00
|
|
|
mips32->bp_scanned = 1;
|
2009-06-23 17:49:23 -05:00
|
|
|
|
2008-11-17 11:56:44 -06:00
|
|
|
return ERROR_OK;
|
|
|
|
}
|
2009-05-20 00:07:34 -05:00
|
|
|
|
2009-11-13 12:11:13 -06:00
|
|
|
int mips32_enable_interrupts(struct target *target, int enable)
|
2009-05-20 00:07:34 -05:00
|
|
|
{
|
|
|
|
int retval;
|
|
|
|
int update = 0;
|
2009-06-18 02:09:35 -05:00
|
|
|
uint32_t dcr;
|
2009-06-23 17:49:23 -05:00
|
|
|
|
2009-05-20 00:07:34 -05:00
|
|
|
/* read debug control register */
|
2012-02-05 06:03:04 -06:00
|
|
|
retval = target_read_u32(target, EJTAG_DCR, &dcr);
|
|
|
|
if (retval != ERROR_OK)
|
2009-05-20 00:07:34 -05:00
|
|
|
return retval;
|
2009-06-23 17:49:23 -05:00
|
|
|
|
2012-02-05 06:03:04 -06:00
|
|
|
if (enable) {
|
|
|
|
if (!(dcr & EJTAG_DCR_INTE)) {
|
2009-05-20 00:07:34 -05:00
|
|
|
/* enable interrupts */
|
2010-01-08 16:35:08 -06:00
|
|
|
dcr |= EJTAG_DCR_INTE;
|
2009-05-20 00:07:34 -05:00
|
|
|
update = 1;
|
|
|
|
}
|
2012-02-05 06:03:04 -06:00
|
|
|
} else {
|
|
|
|
if (dcr & EJTAG_DCR_INTE) {
|
2009-05-20 00:07:34 -05:00
|
|
|
/* disable interrupts */
|
2010-01-08 16:35:08 -06:00
|
|
|
dcr &= ~EJTAG_DCR_INTE;
|
2009-05-20 00:07:34 -05:00
|
|
|
update = 1;
|
|
|
|
}
|
|
|
|
}
|
2009-06-23 17:49:23 -05:00
|
|
|
|
2012-02-05 06:03:04 -06:00
|
|
|
if (update) {
|
|
|
|
retval = target_write_u32(target, EJTAG_DCR, dcr);
|
|
|
|
if (retval != ERROR_OK)
|
2009-05-20 00:07:34 -05:00
|
|
|
return retval;
|
|
|
|
}
|
2009-06-23 17:49:23 -05:00
|
|
|
|
2009-05-20 00:07:34 -05:00
|
|
|
return ERROR_OK;
|
|
|
|
}
|
2010-01-13 04:12:34 -06:00
|
|
|
|
2017-05-07 11:39:17 -05:00
|
|
|
/* read config to config3 cp0 registers and log isa implementation */
|
|
|
|
int mips32_read_config_regs(struct target *target)
|
|
|
|
{
|
|
|
|
struct mips32_common *mips32 = target_to_mips32(target);
|
|
|
|
struct mips_ejtag *ejtag_info = &mips32->ejtag_info;
|
|
|
|
|
|
|
|
if (ejtag_info->config_regs == 0)
|
|
|
|
for (int i = 0; i != 4; i++) {
|
|
|
|
int retval = mips32_cp0_read(ejtag_info, &ejtag_info->config[i], 16, i);
|
|
|
|
if (retval != ERROR_OK) {
|
|
|
|
LOG_ERROR("isa info not available, failed to read cp0 config register: %" PRId32, i);
|
|
|
|
ejtag_info->config_regs = 0;
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
ejtag_info->config_regs = i + 1;
|
|
|
|
if ((ejtag_info->config[i] & (1 << 31)) == 0)
|
|
|
|
break; /* no more config registers implemented */
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return ERROR_OK; /* already succesfully read */
|
|
|
|
|
|
|
|
LOG_DEBUG("read %"PRId32" config registers", ejtag_info->config_regs);
|
|
|
|
|
|
|
|
if (ejtag_info->impcode & EJTAG_IMP_MIPS16) {
|
|
|
|
mips32->isa_imp = MIPS32_MIPS16;
|
|
|
|
LOG_USER("MIPS32 with MIPS16 support implemented");
|
|
|
|
|
|
|
|
} else if (ejtag_info->config_regs >= 4) { /* config3 implemented */
|
|
|
|
unsigned isa_imp = (ejtag_info->config[3] & MIPS32_CONFIG3_ISA_MASK) >> MIPS32_CONFIG3_ISA_SHIFT;
|
|
|
|
if (isa_imp == 1) {
|
|
|
|
mips32->isa_imp = MMIPS32_ONLY;
|
|
|
|
LOG_USER("MICRO MIPS32 only implemented");
|
|
|
|
|
|
|
|
} else if (isa_imp != 0) {
|
|
|
|
mips32->isa_imp = MIPS32_MMIPS32;
|
|
|
|
LOG_USER("MIPS32 and MICRO MIPS32 implemented");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mips32->isa_imp == MIPS32_ONLY) /* initial default value */
|
|
|
|
LOG_USER("MIPS32 only implemented");
|
|
|
|
|
|
|
|
return ERROR_OK;
|
|
|
|
}
|
2013-09-23 03:27:03 -05:00
|
|
|
int mips32_checksum_memory(struct target *target, target_addr_t address,
|
2012-02-05 06:03:04 -06:00
|
|
|
uint32_t count, uint32_t *checksum)
|
2010-01-13 04:12:34 -06:00
|
|
|
{
|
|
|
|
struct working_area *crc_algorithm;
|
|
|
|
struct reg_param reg_params[2];
|
|
|
|
struct mips32_algorithm mips32_info;
|
|
|
|
|
2017-05-07 06:36:12 -05:00
|
|
|
struct mips32_common *mips32 = target_to_mips32(target);
|
|
|
|
struct mips_ejtag *ejtag_info = &mips32->ejtag_info;
|
2010-10-28 04:08:16 -05:00
|
|
|
|
2017-05-07 06:36:12 -05:00
|
|
|
/* see contrib/loaders/checksum/mips32.s for src */
|
|
|
|
uint32_t isa = ejtag_info->isa ? 1 : 0;
|
|
|
|
|
|
|
|
uint32_t mips_crc_code[] = {
|
|
|
|
MIPS32_ADDIU(isa, 12, 4, 0), /* addiu $t4, $a0, 0 */
|
|
|
|
MIPS32_ADDIU(isa, 10, 5, 0), /* addiu $t2, $a1, 0 */
|
|
|
|
MIPS32_ADDIU(isa, 4, 0, 0xFFFF), /* addiu $a0, $zero, 0xffff */
|
|
|
|
MIPS32_BEQ(isa, 0, 0, 0x10 << isa), /* beq $zero, $zero, ncomp */
|
|
|
|
MIPS32_ADDIU(isa, 11, 0, 0), /* addiu $t3, $zero, 0 */
|
2010-01-13 04:12:34 -06:00
|
|
|
/* nbyte: */
|
2017-05-07 06:36:12 -05:00
|
|
|
MIPS32_LB(isa, 5, 0, 12), /* lb $a1, ($t4) */
|
|
|
|
MIPS32_ADDI(isa, 12, 12, 1), /* addi $t4, $t4, 1 */
|
|
|
|
MIPS32_SLL(isa, 5, 5, 24), /* sll $a1, $a1, 24 */
|
|
|
|
MIPS32_LUI(isa, 2, 0x04c1), /* lui $v0, 0x04c1 */
|
|
|
|
MIPS32_XOR(isa, 4, 4, 5), /* xor $a0, $a0, $a1 */
|
|
|
|
MIPS32_ORI(isa, 7, 2, 0x1db7), /* ori $a3, $v0, 0x1db7 */
|
|
|
|
MIPS32_ADDU(isa, 6, 0, 0), /* addu $a2, $zero, $zero */
|
|
|
|
/* loop */
|
|
|
|
MIPS32_SLL(isa, 8, 4, 1), /* sll $t0, $a0, 1 */
|
|
|
|
MIPS32_ADDIU(isa, 6, 6, 1), /* addiu $a2, $a2, 1 */
|
|
|
|
MIPS32_SLTI(isa, 4, 4, 0), /* slti $a0, $a0, 0 */
|
|
|
|
MIPS32_XOR(isa, 9, 8, 7), /* xor $t1, $t0, $a3 */
|
|
|
|
MIPS32_MOVN(isa, 8, 9, 4), /* movn $t0, $t1, $a0 */
|
|
|
|
MIPS32_SLTI(isa, 3, 6, 8), /* slti $v1, $a2, 8 */
|
|
|
|
MIPS32_BNE(isa, 3, 0, NEG16(7 << isa)), /* bne $v1, $zero, loop */
|
|
|
|
MIPS32_ADDU(isa, 4, 8, 0), /* addu $a0, $t0, $zero */
|
|
|
|
/* ncomp */
|
|
|
|
MIPS32_BNE(isa, 10, 11, NEG16(16 << isa)), /* bne $t2, $t3, nbyte */
|
|
|
|
MIPS32_ADDIU(isa, 11, 11, 1), /* addiu $t3, $t3, 1 */
|
|
|
|
MIPS32_SDBBP(isa),
|
2010-01-13 04:12:34 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
/* make sure we have a working area */
|
|
|
|
if (target_alloc_working_area(target, sizeof(mips_crc_code), &crc_algorithm) != ERROR_OK)
|
|
|
|
return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
|
|
|
|
|
2017-05-07 06:36:12 -05:00
|
|
|
pracc_swap16_array(ejtag_info, mips_crc_code, ARRAY_SIZE(mips_crc_code));
|
|
|
|
|
2013-08-23 11:50:43 -05:00
|
|
|
/* convert mips crc code into a buffer in target endianness */
|
|
|
|
uint8_t mips_crc_code_8[sizeof(mips_crc_code)];
|
|
|
|
target_buffer_set_u32_array(target, mips_crc_code_8,
|
|
|
|
ARRAY_SIZE(mips_crc_code), mips_crc_code);
|
|
|
|
|
2017-05-07 06:36:12 -05:00
|
|
|
int retval = target_write_buffer(target, crc_algorithm->address, sizeof(mips_crc_code), mips_crc_code_8);
|
|
|
|
if (retval != ERROR_OK)
|
|
|
|
return retval;
|
2010-01-13 04:12:34 -06:00
|
|
|
|
|
|
|
mips32_info.common_magic = MIPS32_COMMON_MAGIC;
|
2017-05-07 11:39:17 -05:00
|
|
|
mips32_info.isa_mode = isa ? MIPS32_ISA_MMIPS32 : MIPS32_ISA_MIPS32; /* run isa as in debug mode */
|
2010-01-13 04:12:34 -06:00
|
|
|
|
2014-02-25 14:16:58 -06:00
|
|
|
init_reg_param(®_params[0], "r4", 32, PARAM_IN_OUT);
|
2010-01-13 04:12:34 -06:00
|
|
|
buf_set_u32(reg_params[0].value, 0, 32, address);
|
|
|
|
|
2014-02-25 14:16:58 -06:00
|
|
|
init_reg_param(®_params[1], "r5", 32, PARAM_OUT);
|
2010-01-13 04:12:34 -06:00
|
|
|
buf_set_u32(reg_params[1].value, 0, 32, count);
|
|
|
|
|
2010-05-10 08:15:12 -05:00
|
|
|
int timeout = 20000 * (1 + (count / (1024 * 1024)));
|
|
|
|
|
2017-05-07 11:39:17 -05:00
|
|
|
retval = target_run_algorithm(target, 0, NULL, 2, reg_params, crc_algorithm->address,
|
|
|
|
crc_algorithm->address + (sizeof(mips_crc_code) - 4), timeout, &mips32_info);
|
2010-01-13 04:12:34 -06:00
|
|
|
|
2013-08-23 11:50:43 -05:00
|
|
|
if (retval == ERROR_OK)
|
|
|
|
*checksum = buf_get_u32(reg_params[0].value, 0, 32);
|
2010-01-13 04:12:34 -06:00
|
|
|
|
|
|
|
destroy_reg_param(®_params[0]);
|
|
|
|
destroy_reg_param(®_params[1]);
|
|
|
|
|
|
|
|
target_free_working_area(target, crc_algorithm);
|
|
|
|
|
2013-08-23 11:50:43 -05:00
|
|
|
return retval;
|
2010-01-13 04:12:34 -06:00
|
|
|
}
|
|
|
|
|
2016-05-08 16:49:07 -05:00
|
|
|
/** Checks whether a memory region is erased. */
|
2010-01-13 04:12:34 -06:00
|
|
|
int mips32_blank_check_memory(struct target *target,
|
2017-11-23 02:18:24 -06:00
|
|
|
struct target_memory_check_block *blocks, int num_blocks,
|
|
|
|
uint8_t erased_value)
|
2010-01-13 04:12:34 -06:00
|
|
|
{
|
|
|
|
struct working_area *erase_check_algorithm;
|
|
|
|
struct reg_param reg_params[3];
|
|
|
|
struct mips32_algorithm mips32_info;
|
|
|
|
|
2017-05-07 06:36:12 -05:00
|
|
|
struct mips32_common *mips32 = target_to_mips32(target);
|
|
|
|
struct mips_ejtag *ejtag_info = &mips32->ejtag_info;
|
2010-01-13 04:12:34 -06:00
|
|
|
|
2016-05-08 16:49:07 -05:00
|
|
|
if (erased_value != 0xff) {
|
|
|
|
LOG_ERROR("Erase value 0x%02" PRIx8 " not yet supported for MIPS32",
|
|
|
|
erased_value);
|
|
|
|
return ERROR_FAIL;
|
|
|
|
}
|
2017-05-07 06:36:12 -05:00
|
|
|
uint32_t isa = ejtag_info->isa ? 1 : 0;
|
|
|
|
uint32_t erase_check_code[] = {
|
|
|
|
/* nbyte: */
|
|
|
|
MIPS32_LB(isa, 8, 0, 4), /* lb $t0, ($a0) */
|
|
|
|
MIPS32_AND(isa, 6, 6, 8), /* and $a2, $a2, $t0 */
|
|
|
|
MIPS32_ADDIU(isa, 5, 5, NEG16(1)), /* addiu $a1, $a1, -1 */
|
|
|
|
MIPS32_BNE(isa, 5, 0, NEG16(4 << isa)), /* bne $a1, $zero, nbyte */
|
|
|
|
MIPS32_ADDIU(isa, 4, 4, 1), /* addiu $a0, $a0, 1 */
|
|
|
|
MIPS32_SDBBP(isa) /* sdbbp */
|
|
|
|
};
|
2016-05-08 16:49:07 -05:00
|
|
|
|
2010-01-13 04:12:34 -06:00
|
|
|
/* make sure we have a working area */
|
|
|
|
if (target_alloc_working_area(target, sizeof(erase_check_code), &erase_check_algorithm) != ERROR_OK)
|
|
|
|
return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
|
|
|
|
|
2017-05-07 06:36:12 -05:00
|
|
|
pracc_swap16_array(ejtag_info, erase_check_code, ARRAY_SIZE(erase_check_code));
|
|
|
|
|
2013-08-23 11:50:43 -05:00
|
|
|
/* convert erase check code into a buffer in target endianness */
|
|
|
|
uint8_t erase_check_code_8[sizeof(erase_check_code)];
|
|
|
|
target_buffer_set_u32_array(target, erase_check_code_8,
|
|
|
|
ARRAY_SIZE(erase_check_code), erase_check_code);
|
|
|
|
|
2017-05-07 06:36:12 -05:00
|
|
|
int retval = target_write_buffer(target, erase_check_algorithm->address,
|
|
|
|
sizeof(erase_check_code), erase_check_code_8);
|
|
|
|
if (retval != ERROR_OK)
|
2017-11-23 02:18:24 -06:00
|
|
|
goto cleanup;
|
2010-01-13 04:12:34 -06:00
|
|
|
|
|
|
|
mips32_info.common_magic = MIPS32_COMMON_MAGIC;
|
2017-05-07 11:39:17 -05:00
|
|
|
mips32_info.isa_mode = isa ? MIPS32_ISA_MMIPS32 : MIPS32_ISA_MIPS32;
|
2010-01-13 04:12:34 -06:00
|
|
|
|
2014-02-25 14:16:58 -06:00
|
|
|
init_reg_param(®_params[0], "r4", 32, PARAM_OUT);
|
2017-11-23 02:18:24 -06:00
|
|
|
buf_set_u32(reg_params[0].value, 0, 32, blocks[0].address);
|
2010-01-13 04:12:34 -06:00
|
|
|
|
2014-02-25 14:16:58 -06:00
|
|
|
init_reg_param(®_params[1], "r5", 32, PARAM_OUT);
|
2017-11-23 02:18:24 -06:00
|
|
|
buf_set_u32(reg_params[1].value, 0, 32, blocks[0].size);
|
2010-01-13 04:12:34 -06:00
|
|
|
|
2014-02-25 14:16:58 -06:00
|
|
|
init_reg_param(®_params[2], "r6", 32, PARAM_IN_OUT);
|
2016-05-08 16:49:07 -05:00
|
|
|
buf_set_u32(reg_params[2].value, 0, 32, erased_value);
|
2010-01-13 04:12:34 -06:00
|
|
|
|
2017-05-07 11:39:17 -05:00
|
|
|
retval = target_run_algorithm(target, 0, NULL, 3, reg_params, erase_check_algorithm->address,
|
|
|
|
erase_check_algorithm->address + (sizeof(erase_check_code) - 4), 10000, &mips32_info);
|
2010-01-13 04:12:34 -06:00
|
|
|
|
2013-08-23 11:50:43 -05:00
|
|
|
if (retval == ERROR_OK)
|
2017-11-23 02:18:24 -06:00
|
|
|
blocks[0].result = buf_get_u32(reg_params[2].value, 0, 32);
|
2010-01-13 04:12:34 -06:00
|
|
|
|
|
|
|
destroy_reg_param(®_params[0]);
|
|
|
|
destroy_reg_param(®_params[1]);
|
|
|
|
destroy_reg_param(®_params[2]);
|
|
|
|
|
2017-11-23 02:18:24 -06:00
|
|
|
cleanup:
|
2010-01-13 04:12:34 -06:00
|
|
|
target_free_working_area(target, erase_check_algorithm);
|
|
|
|
|
2017-11-23 02:18:24 -06:00
|
|
|
if (retval != ERROR_OK)
|
|
|
|
return retval;
|
|
|
|
|
|
|
|
return 1; /* only one block has been checked */
|
2010-01-13 04:12:34 -06:00
|
|
|
}
|
2011-07-07 10:41:20 -05:00
|
|
|
|
2019-03-31 21:57:01 -05:00
|
|
|
static int mips32_verify_pointer(struct command_invocation *cmd,
|
2011-07-07 10:41:20 -05:00
|
|
|
struct mips32_common *mips32)
|
|
|
|
{
|
|
|
|
if (mips32->common_magic != MIPS32_COMMON_MAGIC) {
|
helper/command: change prototype of command_print/command_print_sameline
To prepare for handling TCL return values consistently, all calls
to command_print/command_print_sameline should switch to CMD as
first parameter.
Change prototype of command_print() and command_print_sameline()
to pass CMD instead of CMD_CTX.
Since the first parameter is currently not used, the change can be
done though scripts without manual coding.
This patch is created using the command:
sed -i PATTERN $(find src/ doc/ -type f)
with all the following patters:
's/\(command_print(cmd\)->ctx,/\1,/'
's/\(command_print(CMD\)_CTX,/\1,/'
's/\(command_print(struct command_\)context \*context,/\1invocation *cmd,/'
's/\(command_print_sameline(cmd\)->ctx,/\1,/'
's/\(command_print_sameline(CMD\)_CTX,/\1,/'
's/\(command_print_sameline(struct command_\)context \*context,/\1invocation *cmd,/'
This change is inspired by http://openocd.zylin.com/1815 from Paul
Fertser but is now done through scripting.
Change-Id: I3386d8f96cdc477e7a2308dd18269de3bed04385
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/5081
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2019-04-03 03:37:24 -05:00
|
|
|
command_print(cmd, "target is not an MIPS32");
|
2011-07-07 10:41:20 -05:00
|
|
|
return ERROR_TARGET_INVALID;
|
|
|
|
}
|
|
|
|
return ERROR_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* MIPS32 targets expose command interface
|
|
|
|
* to manipulate CP0 registers
|
|
|
|
*/
|
|
|
|
COMMAND_HANDLER(mips32_handle_cp0_command)
|
|
|
|
{
|
|
|
|
int retval;
|
|
|
|
struct target *target = get_current_target(CMD_CTX);
|
|
|
|
struct mips32_common *mips32 = target_to_mips32(target);
|
|
|
|
struct mips_ejtag *ejtag_info = &mips32->ejtag_info;
|
|
|
|
|
|
|
|
|
2019-03-31 21:57:01 -05:00
|
|
|
retval = mips32_verify_pointer(CMD, mips32);
|
2011-07-07 10:41:20 -05:00
|
|
|
if (retval != ERROR_OK)
|
|
|
|
return retval;
|
|
|
|
|
2012-02-05 06:03:04 -06:00
|
|
|
if (target->state != TARGET_HALTED) {
|
helper/command: change prototype of command_print/command_print_sameline
To prepare for handling TCL return values consistently, all calls
to command_print/command_print_sameline should switch to CMD as
first parameter.
Change prototype of command_print() and command_print_sameline()
to pass CMD instead of CMD_CTX.
Since the first parameter is currently not used, the change can be
done though scripts without manual coding.
This patch is created using the command:
sed -i PATTERN $(find src/ doc/ -type f)
with all the following patters:
's/\(command_print(cmd\)->ctx,/\1,/'
's/\(command_print(CMD\)_CTX,/\1,/'
's/\(command_print(struct command_\)context \*context,/\1invocation *cmd,/'
's/\(command_print_sameline(cmd\)->ctx,/\1,/'
's/\(command_print_sameline(CMD\)_CTX,/\1,/'
's/\(command_print_sameline(struct command_\)context \*context,/\1invocation *cmd,/'
This change is inspired by http://openocd.zylin.com/1815 from Paul
Fertser but is now done through scripting.
Change-Id: I3386d8f96cdc477e7a2308dd18269de3bed04385
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/5081
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2019-04-03 03:37:24 -05:00
|
|
|
command_print(CMD, "target must be stopped for \"%s\" command", CMD_NAME);
|
2011-07-07 10:41:20 -05:00
|
|
|
return ERROR_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* two or more argument, access a single register/select (write if third argument is given) */
|
|
|
|
if (CMD_ARGC < 2)
|
2012-02-05 06:03:04 -06:00
|
|
|
return ERROR_COMMAND_SYNTAX_ERROR;
|
|
|
|
else {
|
2011-07-07 10:41:20 -05:00
|
|
|
uint32_t cp0_reg, cp0_sel;
|
|
|
|
COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], cp0_reg);
|
|
|
|
COMMAND_PARSE_NUMBER(u32, CMD_ARGV[1], cp0_sel);
|
|
|
|
|
2012-02-05 06:03:04 -06:00
|
|
|
if (CMD_ARGC == 2) {
|
2011-07-07 10:41:20 -05:00
|
|
|
uint32_t value;
|
|
|
|
|
2012-02-05 06:03:04 -06:00
|
|
|
retval = mips32_cp0_read(ejtag_info, &value, cp0_reg, cp0_sel);
|
|
|
|
if (retval != ERROR_OK) {
|
helper/command: change prototype of command_print/command_print_sameline
To prepare for handling TCL return values consistently, all calls
to command_print/command_print_sameline should switch to CMD as
first parameter.
Change prototype of command_print() and command_print_sameline()
to pass CMD instead of CMD_CTX.
Since the first parameter is currently not used, the change can be
done though scripts without manual coding.
This patch is created using the command:
sed -i PATTERN $(find src/ doc/ -type f)
with all the following patters:
's/\(command_print(cmd\)->ctx,/\1,/'
's/\(command_print(CMD\)_CTX,/\1,/'
's/\(command_print(struct command_\)context \*context,/\1invocation *cmd,/'
's/\(command_print_sameline(cmd\)->ctx,/\1,/'
's/\(command_print_sameline(CMD\)_CTX,/\1,/'
's/\(command_print_sameline(struct command_\)context \*context,/\1invocation *cmd,/'
This change is inspired by http://openocd.zylin.com/1815 from Paul
Fertser but is now done through scripting.
Change-Id: I3386d8f96cdc477e7a2308dd18269de3bed04385
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/5081
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2019-04-03 03:37:24 -05:00
|
|
|
command_print(CMD,
|
2011-07-07 10:41:20 -05:00
|
|
|
"couldn't access reg %" PRIi32,
|
|
|
|
cp0_reg);
|
|
|
|
return ERROR_OK;
|
|
|
|
}
|
helper/command: change prototype of command_print/command_print_sameline
To prepare for handling TCL return values consistently, all calls
to command_print/command_print_sameline should switch to CMD as
first parameter.
Change prototype of command_print() and command_print_sameline()
to pass CMD instead of CMD_CTX.
Since the first parameter is currently not used, the change can be
done though scripts without manual coding.
This patch is created using the command:
sed -i PATTERN $(find src/ doc/ -type f)
with all the following patters:
's/\(command_print(cmd\)->ctx,/\1,/'
's/\(command_print(CMD\)_CTX,/\1,/'
's/\(command_print(struct command_\)context \*context,/\1invocation *cmd,/'
's/\(command_print_sameline(cmd\)->ctx,/\1,/'
's/\(command_print_sameline(CMD\)_CTX,/\1,/'
's/\(command_print_sameline(struct command_\)context \*context,/\1invocation *cmd,/'
This change is inspired by http://openocd.zylin.com/1815 from Paul
Fertser but is now done through scripting.
Change-Id: I3386d8f96cdc477e7a2308dd18269de3bed04385
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/5081
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2019-04-03 03:37:24 -05:00
|
|
|
command_print(CMD, "cp0 reg %" PRIi32 ", select %" PRIi32 ": %8.8" PRIx32,
|
2011-07-07 10:41:20 -05:00
|
|
|
cp0_reg, cp0_sel, value);
|
2013-03-02 09:20:42 -06:00
|
|
|
|
2012-02-05 06:03:04 -06:00
|
|
|
} else if (CMD_ARGC == 3) {
|
2011-07-07 10:41:20 -05:00
|
|
|
uint32_t value;
|
|
|
|
COMMAND_PARSE_NUMBER(u32, CMD_ARGV[2], value);
|
2012-02-05 06:03:04 -06:00
|
|
|
retval = mips32_cp0_write(ejtag_info, value, cp0_reg, cp0_sel);
|
|
|
|
if (retval != ERROR_OK) {
|
helper/command: change prototype of command_print/command_print_sameline
To prepare for handling TCL return values consistently, all calls
to command_print/command_print_sameline should switch to CMD as
first parameter.
Change prototype of command_print() and command_print_sameline()
to pass CMD instead of CMD_CTX.
Since the first parameter is currently not used, the change can be
done though scripts without manual coding.
This patch is created using the command:
sed -i PATTERN $(find src/ doc/ -type f)
with all the following patters:
's/\(command_print(cmd\)->ctx,/\1,/'
's/\(command_print(CMD\)_CTX,/\1,/'
's/\(command_print(struct command_\)context \*context,/\1invocation *cmd,/'
's/\(command_print_sameline(cmd\)->ctx,/\1,/'
's/\(command_print_sameline(CMD\)_CTX,/\1,/'
's/\(command_print_sameline(struct command_\)context \*context,/\1invocation *cmd,/'
This change is inspired by http://openocd.zylin.com/1815 from Paul
Fertser but is now done through scripting.
Change-Id: I3386d8f96cdc477e7a2308dd18269de3bed04385
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/5081
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2019-04-03 03:37:24 -05:00
|
|
|
command_print(CMD,
|
2011-07-07 10:41:20 -05:00
|
|
|
"couldn't access cp0 reg %" PRIi32 ", select %" PRIi32,
|
|
|
|
cp0_reg, cp0_sel);
|
|
|
|
return ERROR_OK;
|
|
|
|
}
|
helper/command: change prototype of command_print/command_print_sameline
To prepare for handling TCL return values consistently, all calls
to command_print/command_print_sameline should switch to CMD as
first parameter.
Change prototype of command_print() and command_print_sameline()
to pass CMD instead of CMD_CTX.
Since the first parameter is currently not used, the change can be
done though scripts without manual coding.
This patch is created using the command:
sed -i PATTERN $(find src/ doc/ -type f)
with all the following patters:
's/\(command_print(cmd\)->ctx,/\1,/'
's/\(command_print(CMD\)_CTX,/\1,/'
's/\(command_print(struct command_\)context \*context,/\1invocation *cmd,/'
's/\(command_print_sameline(cmd\)->ctx,/\1,/'
's/\(command_print_sameline(CMD\)_CTX,/\1,/'
's/\(command_print_sameline(struct command_\)context \*context,/\1invocation *cmd,/'
This change is inspired by http://openocd.zylin.com/1815 from Paul
Fertser but is now done through scripting.
Change-Id: I3386d8f96cdc477e7a2308dd18269de3bed04385
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/5081
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2019-04-03 03:37:24 -05:00
|
|
|
command_print(CMD, "cp0 reg %" PRIi32 ", select %" PRIi32 ": %8.8" PRIx32,
|
2011-07-07 10:41:20 -05:00
|
|
|
cp0_reg, cp0_sel, value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ERROR_OK;
|
|
|
|
}
|
|
|
|
|
mips: m4k alternate pracc code. Patch 1
This patch and the following patches define another way of doing processor access without the need to read back
the pracc address as needed in current pracc code.
Current pracc code is executed linearly and unconditionally. The processor starts execution at 0xff200200
and the fetch address is ever incremented by 4, including the last instruction in the delay slot of the branch to start.
Most of the processor accesses are fetch and some are store accesses.
After a previous patch regarding the way of restoring registers (reg8 and reg9), there are no load processor accesses.
The pracc address for a store depends only on the store instruction given before.
m4k core has a 5 stage pipeline and the memory access is done in the 3rth stage. This means that the store access
will not arrive immediately after a store instruction, it appears after another instruction enters the pipeline.
For reference: MD00249 mips32 m4k manual.
A new struct pracc_queue_info is defined to help each function in generating the code. The field pracc_list holds in the
lower half the list of instructions and in the upper half the store addressess, if any. In this way the list can be used by
current code or by the new one to generate the sequence of pracc accesses.
For every pracc access only one scan to register "all" is used by calling the new function mips_ejtag_add_scan_96().
This function does not call jtag_execute_queue(), all the scans needed can be queued before calling for execution.
The pracc bit is not checked before execution, is checked after the queue has been executed.
Without calling the wait function the code works much faster, but the scan frequency must be limited. For pic32mx
with core clock at 4Mhz works up to 600Khz and with 8Mhz up to 1200. To increase the scan frequency a delay
between scans is added by calling jtag_add_cloks().
A time delay in nano seconds is stored in scan_delay, a new field in ejtag_info, and a handler is provided for it.
A mode field is added to ejtag_info to hold the working mode. If a time delay of 2ms (2000000 ns) or higher is set,
current code is executed, if lower, new code is executed.
Initial default values are set in function mips32_init_arch_info. A reset does not change this settings.
Change-Id: I266bdb386b24744435b6e29d8489a68c0c15ff65
Signed-off-by: Salvador Arroyo <sarroyofdez@yahoo.es>
Reviewed-on: http://openocd.zylin.com/1193
Tested-by: jenkins
Reviewed-by: Freddie Chopin <freddie.chopin@gmail.com>
2013-03-03 03:50:42 -06:00
|
|
|
COMMAND_HANDLER(mips32_handle_scan_delay_command)
|
|
|
|
{
|
|
|
|
struct target *target = get_current_target(CMD_CTX);
|
|
|
|
struct mips32_common *mips32 = target_to_mips32(target);
|
|
|
|
struct mips_ejtag *ejtag_info = &mips32->ejtag_info;
|
|
|
|
|
|
|
|
if (CMD_ARGC == 1)
|
2013-09-30 04:31:57 -05:00
|
|
|
COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], ejtag_info->scan_delay);
|
mips: m4k alternate pracc code. Patch 1
This patch and the following patches define another way of doing processor access without the need to read back
the pracc address as needed in current pracc code.
Current pracc code is executed linearly and unconditionally. The processor starts execution at 0xff200200
and the fetch address is ever incremented by 4, including the last instruction in the delay slot of the branch to start.
Most of the processor accesses are fetch and some are store accesses.
After a previous patch regarding the way of restoring registers (reg8 and reg9), there are no load processor accesses.
The pracc address for a store depends only on the store instruction given before.
m4k core has a 5 stage pipeline and the memory access is done in the 3rth stage. This means that the store access
will not arrive immediately after a store instruction, it appears after another instruction enters the pipeline.
For reference: MD00249 mips32 m4k manual.
A new struct pracc_queue_info is defined to help each function in generating the code. The field pracc_list holds in the
lower half the list of instructions and in the upper half the store addressess, if any. In this way the list can be used by
current code or by the new one to generate the sequence of pracc accesses.
For every pracc access only one scan to register "all" is used by calling the new function mips_ejtag_add_scan_96().
This function does not call jtag_execute_queue(), all the scans needed can be queued before calling for execution.
The pracc bit is not checked before execution, is checked after the queue has been executed.
Without calling the wait function the code works much faster, but the scan frequency must be limited. For pic32mx
with core clock at 4Mhz works up to 600Khz and with 8Mhz up to 1200. To increase the scan frequency a delay
between scans is added by calling jtag_add_cloks().
A time delay in nano seconds is stored in scan_delay, a new field in ejtag_info, and a handler is provided for it.
A mode field is added to ejtag_info to hold the working mode. If a time delay of 2ms (2000000 ns) or higher is set,
current code is executed, if lower, new code is executed.
Initial default values are set in function mips32_init_arch_info. A reset does not change this settings.
Change-Id: I266bdb386b24744435b6e29d8489a68c0c15ff65
Signed-off-by: Salvador Arroyo <sarroyofdez@yahoo.es>
Reviewed-on: http://openocd.zylin.com/1193
Tested-by: jenkins
Reviewed-by: Freddie Chopin <freddie.chopin@gmail.com>
2013-03-03 03:50:42 -06:00
|
|
|
else if (CMD_ARGC > 1)
|
|
|
|
return ERROR_COMMAND_SYNTAX_ERROR;
|
|
|
|
|
helper/command: change prototype of command_print/command_print_sameline
To prepare for handling TCL return values consistently, all calls
to command_print/command_print_sameline should switch to CMD as
first parameter.
Change prototype of command_print() and command_print_sameline()
to pass CMD instead of CMD_CTX.
Since the first parameter is currently not used, the change can be
done though scripts without manual coding.
This patch is created using the command:
sed -i PATTERN $(find src/ doc/ -type f)
with all the following patters:
's/\(command_print(cmd\)->ctx,/\1,/'
's/\(command_print(CMD\)_CTX,/\1,/'
's/\(command_print(struct command_\)context \*context,/\1invocation *cmd,/'
's/\(command_print_sameline(cmd\)->ctx,/\1,/'
's/\(command_print_sameline(CMD\)_CTX,/\1,/'
's/\(command_print_sameline(struct command_\)context \*context,/\1invocation *cmd,/'
This change is inspired by http://openocd.zylin.com/1815 from Paul
Fertser but is now done through scripting.
Change-Id: I3386d8f96cdc477e7a2308dd18269de3bed04385
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/5081
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2019-04-03 03:37:24 -05:00
|
|
|
command_print(CMD, "scan delay: %d nsec", ejtag_info->scan_delay);
|
2014-10-21 09:46:30 -05:00
|
|
|
if (ejtag_info->scan_delay >= MIPS32_SCAN_DELAY_LEGACY_MODE) {
|
mips: m4k alternate pracc code. Patch 1
This patch and the following patches define another way of doing processor access without the need to read back
the pracc address as needed in current pracc code.
Current pracc code is executed linearly and unconditionally. The processor starts execution at 0xff200200
and the fetch address is ever incremented by 4, including the last instruction in the delay slot of the branch to start.
Most of the processor accesses are fetch and some are store accesses.
After a previous patch regarding the way of restoring registers (reg8 and reg9), there are no load processor accesses.
The pracc address for a store depends only on the store instruction given before.
m4k core has a 5 stage pipeline and the memory access is done in the 3rth stage. This means that the store access
will not arrive immediately after a store instruction, it appears after another instruction enters the pipeline.
For reference: MD00249 mips32 m4k manual.
A new struct pracc_queue_info is defined to help each function in generating the code. The field pracc_list holds in the
lower half the list of instructions and in the upper half the store addressess, if any. In this way the list can be used by
current code or by the new one to generate the sequence of pracc accesses.
For every pracc access only one scan to register "all" is used by calling the new function mips_ejtag_add_scan_96().
This function does not call jtag_execute_queue(), all the scans needed can be queued before calling for execution.
The pracc bit is not checked before execution, is checked after the queue has been executed.
Without calling the wait function the code works much faster, but the scan frequency must be limited. For pic32mx
with core clock at 4Mhz works up to 600Khz and with 8Mhz up to 1200. To increase the scan frequency a delay
between scans is added by calling jtag_add_cloks().
A time delay in nano seconds is stored in scan_delay, a new field in ejtag_info, and a handler is provided for it.
A mode field is added to ejtag_info to hold the working mode. If a time delay of 2ms (2000000 ns) or higher is set,
current code is executed, if lower, new code is executed.
Initial default values are set in function mips32_init_arch_info. A reset does not change this settings.
Change-Id: I266bdb386b24744435b6e29d8489a68c0c15ff65
Signed-off-by: Salvador Arroyo <sarroyofdez@yahoo.es>
Reviewed-on: http://openocd.zylin.com/1193
Tested-by: jenkins
Reviewed-by: Freddie Chopin <freddie.chopin@gmail.com>
2013-03-03 03:50:42 -06:00
|
|
|
ejtag_info->mode = 0;
|
helper/command: change prototype of command_print/command_print_sameline
To prepare for handling TCL return values consistently, all calls
to command_print/command_print_sameline should switch to CMD as
first parameter.
Change prototype of command_print() and command_print_sameline()
to pass CMD instead of CMD_CTX.
Since the first parameter is currently not used, the change can be
done though scripts without manual coding.
This patch is created using the command:
sed -i PATTERN $(find src/ doc/ -type f)
with all the following patters:
's/\(command_print(cmd\)->ctx,/\1,/'
's/\(command_print(CMD\)_CTX,/\1,/'
's/\(command_print(struct command_\)context \*context,/\1invocation *cmd,/'
's/\(command_print_sameline(cmd\)->ctx,/\1,/'
's/\(command_print_sameline(CMD\)_CTX,/\1,/'
's/\(command_print_sameline(struct command_\)context \*context,/\1invocation *cmd,/'
This change is inspired by http://openocd.zylin.com/1815 from Paul
Fertser but is now done through scripting.
Change-Id: I3386d8f96cdc477e7a2308dd18269de3bed04385
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/5081
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2019-04-03 03:37:24 -05:00
|
|
|
command_print(CMD, "running in legacy mode");
|
mips: m4k alternate pracc code. Patch 1
This patch and the following patches define another way of doing processor access without the need to read back
the pracc address as needed in current pracc code.
Current pracc code is executed linearly and unconditionally. The processor starts execution at 0xff200200
and the fetch address is ever incremented by 4, including the last instruction in the delay slot of the branch to start.
Most of the processor accesses are fetch and some are store accesses.
After a previous patch regarding the way of restoring registers (reg8 and reg9), there are no load processor accesses.
The pracc address for a store depends only on the store instruction given before.
m4k core has a 5 stage pipeline and the memory access is done in the 3rth stage. This means that the store access
will not arrive immediately after a store instruction, it appears after another instruction enters the pipeline.
For reference: MD00249 mips32 m4k manual.
A new struct pracc_queue_info is defined to help each function in generating the code. The field pracc_list holds in the
lower half the list of instructions and in the upper half the store addressess, if any. In this way the list can be used by
current code or by the new one to generate the sequence of pracc accesses.
For every pracc access only one scan to register "all" is used by calling the new function mips_ejtag_add_scan_96().
This function does not call jtag_execute_queue(), all the scans needed can be queued before calling for execution.
The pracc bit is not checked before execution, is checked after the queue has been executed.
Without calling the wait function the code works much faster, but the scan frequency must be limited. For pic32mx
with core clock at 4Mhz works up to 600Khz and with 8Mhz up to 1200. To increase the scan frequency a delay
between scans is added by calling jtag_add_cloks().
A time delay in nano seconds is stored in scan_delay, a new field in ejtag_info, and a handler is provided for it.
A mode field is added to ejtag_info to hold the working mode. If a time delay of 2ms (2000000 ns) or higher is set,
current code is executed, if lower, new code is executed.
Initial default values are set in function mips32_init_arch_info. A reset does not change this settings.
Change-Id: I266bdb386b24744435b6e29d8489a68c0c15ff65
Signed-off-by: Salvador Arroyo <sarroyofdez@yahoo.es>
Reviewed-on: http://openocd.zylin.com/1193
Tested-by: jenkins
Reviewed-by: Freddie Chopin <freddie.chopin@gmail.com>
2013-03-03 03:50:42 -06:00
|
|
|
} else {
|
|
|
|
ejtag_info->mode = 1;
|
helper/command: change prototype of command_print/command_print_sameline
To prepare for handling TCL return values consistently, all calls
to command_print/command_print_sameline should switch to CMD as
first parameter.
Change prototype of command_print() and command_print_sameline()
to pass CMD instead of CMD_CTX.
Since the first parameter is currently not used, the change can be
done though scripts without manual coding.
This patch is created using the command:
sed -i PATTERN $(find src/ doc/ -type f)
with all the following patters:
's/\(command_print(cmd\)->ctx,/\1,/'
's/\(command_print(CMD\)_CTX,/\1,/'
's/\(command_print(struct command_\)context \*context,/\1invocation *cmd,/'
's/\(command_print_sameline(cmd\)->ctx,/\1,/'
's/\(command_print_sameline(CMD\)_CTX,/\1,/'
's/\(command_print_sameline(struct command_\)context \*context,/\1invocation *cmd,/'
This change is inspired by http://openocd.zylin.com/1815 from Paul
Fertser but is now done through scripting.
Change-Id: I3386d8f96cdc477e7a2308dd18269de3bed04385
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/5081
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2019-04-03 03:37:24 -05:00
|
|
|
command_print(CMD, "running in fast queued mode");
|
mips: m4k alternate pracc code. Patch 1
This patch and the following patches define another way of doing processor access without the need to read back
the pracc address as needed in current pracc code.
Current pracc code is executed linearly and unconditionally. The processor starts execution at 0xff200200
and the fetch address is ever incremented by 4, including the last instruction in the delay slot of the branch to start.
Most of the processor accesses are fetch and some are store accesses.
After a previous patch regarding the way of restoring registers (reg8 and reg9), there are no load processor accesses.
The pracc address for a store depends only on the store instruction given before.
m4k core has a 5 stage pipeline and the memory access is done in the 3rth stage. This means that the store access
will not arrive immediately after a store instruction, it appears after another instruction enters the pipeline.
For reference: MD00249 mips32 m4k manual.
A new struct pracc_queue_info is defined to help each function in generating the code. The field pracc_list holds in the
lower half the list of instructions and in the upper half the store addressess, if any. In this way the list can be used by
current code or by the new one to generate the sequence of pracc accesses.
For every pracc access only one scan to register "all" is used by calling the new function mips_ejtag_add_scan_96().
This function does not call jtag_execute_queue(), all the scans needed can be queued before calling for execution.
The pracc bit is not checked before execution, is checked after the queue has been executed.
Without calling the wait function the code works much faster, but the scan frequency must be limited. For pic32mx
with core clock at 4Mhz works up to 600Khz and with 8Mhz up to 1200. To increase the scan frequency a delay
between scans is added by calling jtag_add_cloks().
A time delay in nano seconds is stored in scan_delay, a new field in ejtag_info, and a handler is provided for it.
A mode field is added to ejtag_info to hold the working mode. If a time delay of 2ms (2000000 ns) or higher is set,
current code is executed, if lower, new code is executed.
Initial default values are set in function mips32_init_arch_info. A reset does not change this settings.
Change-Id: I266bdb386b24744435b6e29d8489a68c0c15ff65
Signed-off-by: Salvador Arroyo <sarroyofdez@yahoo.es>
Reviewed-on: http://openocd.zylin.com/1193
Tested-by: jenkins
Reviewed-by: Freddie Chopin <freddie.chopin@gmail.com>
2013-03-03 03:50:42 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
return ERROR_OK;
|
|
|
|
}
|
|
|
|
|
2011-07-07 10:41:20 -05:00
|
|
|
static const struct command_registration mips32_exec_command_handlers[] = {
|
|
|
|
{
|
|
|
|
.name = "cp0",
|
|
|
|
.handler = mips32_handle_cp0_command,
|
|
|
|
.mode = COMMAND_EXEC,
|
|
|
|
.usage = "regnum select [value]",
|
|
|
|
.help = "display/modify cp0 register",
|
mips: m4k alternate pracc code. Patch 1
This patch and the following patches define another way of doing processor access without the need to read back
the pracc address as needed in current pracc code.
Current pracc code is executed linearly and unconditionally. The processor starts execution at 0xff200200
and the fetch address is ever incremented by 4, including the last instruction in the delay slot of the branch to start.
Most of the processor accesses are fetch and some are store accesses.
After a previous patch regarding the way of restoring registers (reg8 and reg9), there are no load processor accesses.
The pracc address for a store depends only on the store instruction given before.
m4k core has a 5 stage pipeline and the memory access is done in the 3rth stage. This means that the store access
will not arrive immediately after a store instruction, it appears after another instruction enters the pipeline.
For reference: MD00249 mips32 m4k manual.
A new struct pracc_queue_info is defined to help each function in generating the code. The field pracc_list holds in the
lower half the list of instructions and in the upper half the store addressess, if any. In this way the list can be used by
current code or by the new one to generate the sequence of pracc accesses.
For every pracc access only one scan to register "all" is used by calling the new function mips_ejtag_add_scan_96().
This function does not call jtag_execute_queue(), all the scans needed can be queued before calling for execution.
The pracc bit is not checked before execution, is checked after the queue has been executed.
Without calling the wait function the code works much faster, but the scan frequency must be limited. For pic32mx
with core clock at 4Mhz works up to 600Khz and with 8Mhz up to 1200. To increase the scan frequency a delay
between scans is added by calling jtag_add_cloks().
A time delay in nano seconds is stored in scan_delay, a new field in ejtag_info, and a handler is provided for it.
A mode field is added to ejtag_info to hold the working mode. If a time delay of 2ms (2000000 ns) or higher is set,
current code is executed, if lower, new code is executed.
Initial default values are set in function mips32_init_arch_info. A reset does not change this settings.
Change-Id: I266bdb386b24744435b6e29d8489a68c0c15ff65
Signed-off-by: Salvador Arroyo <sarroyofdez@yahoo.es>
Reviewed-on: http://openocd.zylin.com/1193
Tested-by: jenkins
Reviewed-by: Freddie Chopin <freddie.chopin@gmail.com>
2013-03-03 03:50:42 -06:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "scan_delay",
|
|
|
|
.handler = mips32_handle_scan_delay_command,
|
|
|
|
.mode = COMMAND_ANY,
|
|
|
|
.help = "display/set scan delay in nano seconds",
|
|
|
|
.usage = "[value]",
|
2011-07-07 10:41:20 -05:00
|
|
|
},
|
|
|
|
COMMAND_REGISTRATION_DONE
|
|
|
|
};
|
|
|
|
|
|
|
|
const struct command_registration mips32_command_handlers[] = {
|
|
|
|
{
|
|
|
|
.name = "mips32",
|
|
|
|
.mode = COMMAND_ANY,
|
|
|
|
.help = "mips32 command group",
|
2012-01-16 07:35:23 -06:00
|
|
|
.usage = "",
|
2011-07-07 10:41:20 -05:00
|
|
|
.chain = mips32_exec_command_handlers,
|
|
|
|
},
|
|
|
|
COMMAND_REGISTRATION_DONE
|
|
|
|
};
|