2008-02-25 11:48:04 -06:00
|
|
|
/***************************************************************************
|
|
|
|
* Copyright (C) 2008 digenius technology GmbH. *
|
2009-05-18 02:02:12 -05:00
|
|
|
* Michael Bruck *
|
2008-09-20 05:50:53 -05:00
|
|
|
* *
|
2009-08-28 08:43:26 -05:00
|
|
|
* Copyright (C) 2008,2009 Oyvind Harboe oyvind.harboe@zylin.com *
|
2008-02-25 11:48:04 -06:00
|
|
|
* *
|
2008-10-07 06:08:57 -05:00
|
|
|
* Copyright (C) 2008 Georg Acher <acher@in.tum.de> *
|
|
|
|
* *
|
2008-02-25 11:48:04 -06: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 *
|
|
|
|
* along with this program; if not, write to the *
|
|
|
|
* Free Software Foundation, Inc., *
|
|
|
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
|
|
|
***************************************************************************/
|
2008-03-04 00:46:44 -06:00
|
|
|
|
2008-02-25 11:48:04 -06:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2009-11-16 12:19:33 -06:00
|
|
|
#include "etm.h"
|
2009-11-16 02:34:57 -06:00
|
|
|
#include "breakpoints.h"
|
2009-11-06 05:50:26 -06:00
|
|
|
#include "arm11_dbgtap.h"
|
2009-08-27 02:35:47 -05:00
|
|
|
#include "arm_simulator.h"
|
2009-12-03 06:14:29 -06:00
|
|
|
#include <helper/time_support.h>
|
2009-05-31 07:38:28 -05:00
|
|
|
#include "target_type.h"
|
2009-11-16 02:35:05 -06:00
|
|
|
#include "algorithm.h"
|
2009-11-16 02:35:14 -06:00
|
|
|
#include "register.h"
|
2008-02-25 11:48:04 -06:00
|
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
#define _DEBUG_INSTRUCTION_EXECUTION_
|
|
|
|
#endif
|
|
|
|
|
2009-12-03 18:08:04 -06:00
|
|
|
|
|
|
|
/* FIXME none of these flags should be global to all ARM11 cores!
|
|
|
|
* Most of them shouldn't exist at all, once the code works...
|
|
|
|
*/
|
2009-11-06 05:36:46 -06:00
|
|
|
static bool arm11_config_memwrite_burst = true;
|
|
|
|
static bool arm11_config_memwrite_error_fatal = true;
|
|
|
|
static uint32_t arm11_vcr = 0;
|
|
|
|
static bool arm11_config_step_irq_enable = false;
|
|
|
|
static bool arm11_config_hardware_step = false;
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-11-13 12:11:13 -06:00
|
|
|
static int arm11_step(struct target *target, int current,
|
2009-11-06 05:36:46 -06:00
|
|
|
uint32_t address, int handle_breakpoints);
|
|
|
|
|
2008-02-25 11:48:04 -06:00
|
|
|
|
|
|
|
/** Check and if necessary take control of the system
|
|
|
|
*
|
|
|
|
* \param arm11 Target state variable.
|
|
|
|
*/
|
2009-12-03 00:57:08 -06:00
|
|
|
static int arm11_check_init(struct arm11_common *arm11)
|
2008-02-25 11:48:04 -06:00
|
|
|
{
|
2009-12-03 00:57:08 -06:00
|
|
|
CHECK_RETVAL(arm11_read_DSCR(arm11));
|
|
|
|
LOG_DEBUG("DSCR %08x", (unsigned) arm11->dscr);
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-12-03 18:08:04 -06:00
|
|
|
if (!(arm11->dscr & DSCR_HALT_DBG_MODE))
|
2008-10-08 15:16:51 -05:00
|
|
|
{
|
2009-04-22 13:39:59 -05:00
|
|
|
LOG_DEBUG("Bringing target into debug mode");
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-12-03 18:08:04 -06:00
|
|
|
arm11->dscr |= DSCR_HALT_DBG_MODE;
|
2009-12-03 00:57:08 -06:00
|
|
|
arm11_write_DSCR(arm11, arm11->dscr);
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-04-22 13:39:59 -05:00
|
|
|
/* add further reset initialization here */
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-04-22 13:39:59 -05:00
|
|
|
arm11->simulate_reset_on_next_halt = true;
|
2008-03-06 06:01:52 -06:00
|
|
|
|
2009-12-03 18:08:04 -06:00
|
|
|
if (arm11->dscr & DSCR_CORE_HALTED)
|
2009-04-22 13:39:59 -05:00
|
|
|
{
|
|
|
|
/** \todo TODO: this needs further scrutiny because
|
2009-12-03 00:57:07 -06:00
|
|
|
* arm11_debug_entry() never gets called. (WHY NOT?)
|
2009-05-18 02:02:12 -05:00
|
|
|
* As a result we don't read the actual register states from
|
|
|
|
* the target.
|
2009-04-22 13:39:59 -05:00
|
|
|
*/
|
2008-03-06 06:01:52 -06:00
|
|
|
|
2009-12-03 00:57:07 -06:00
|
|
|
arm11->arm.target->state = TARGET_HALTED;
|
2009-12-03 18:08:04 -06:00
|
|
|
arm_dpm_report_dscr(arm11->arm.dpm, arm11->dscr);
|
2009-04-22 13:39:59 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-12-03 00:57:07 -06:00
|
|
|
arm11->arm.target->state = TARGET_RUNNING;
|
|
|
|
arm11->arm.target->debug_reason = DBG_REASON_NOTHALTED;
|
2009-04-22 13:39:59 -05:00
|
|
|
}
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-04-22 13:39:59 -05:00
|
|
|
arm11_sc7_clear_vbw(arm11);
|
2008-10-08 15:16:51 -05:00
|
|
|
}
|
2009-04-27 06:24:01 -05:00
|
|
|
|
|
|
|
return ERROR_OK;
|
2008-02-25 11:48:04 -06:00
|
|
|
}
|
|
|
|
|
2009-12-03 00:57:07 -06:00
|
|
|
/**
|
|
|
|
* Save processor state. This is called after a HALT instruction
|
|
|
|
* succeeds, and on other occasions the processor enters debug mode
|
2009-12-03 00:57:08 -06:00
|
|
|
* (breakpoint, watchpoint, etc). Caller has updated arm11->dscr.
|
2009-12-03 00:57:07 -06:00
|
|
|
*/
|
2009-12-03 00:57:08 -06:00
|
|
|
static int arm11_debug_entry(struct arm11_common *arm11)
|
2008-02-25 11:48:04 -06:00
|
|
|
{
|
2009-08-28 08:43:26 -05:00
|
|
|
int retval;
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-12-03 00:57:07 -06:00
|
|
|
arm11->arm.target->state = TARGET_HALTED;
|
2009-12-03 18:08:04 -06:00
|
|
|
arm_dpm_report_dscr(arm11->arm.dpm, arm11->dscr);
|
2009-12-03 00:57:07 -06:00
|
|
|
|
ARM11: partial support for standard ARM register interfaces.
This provides "standard" ARM register support -- with twenty or
more shadow registers on top of what this code now handles, but
properly associated with the various core modes -- parallel to
the current register code. That is, the current code is stilil
managing the "current" registers; the new code shadows them.
You can see all the registers with "arm reg", modify the shadows
like "r8_fiq" or "sp_abt" with "reg", and see them get properly
written back when you step. (Just don't do that with any of the
registers managed by the "old" code ...)
It also switches to using more standard code, relying on those
standard registers, in two places: (a) the poll status display,
which now shows core state (ARM/Thumb/...) and mode (Supervisor,
IRQ, etc); and (b) GDB register access.
So it's not a full migration, there are warts -- every place that
touches the old register cache is a potential bug -- but it's a
small more-or-less-comprehensible step that's even somewhat useful.
Later patches complete the migration.
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-24 03:27:16 -06:00
|
|
|
/* REVISIT entire cache should already be invalid !!! */
|
|
|
|
register_cache_invalidate(arm11->arm.core_cache);
|
|
|
|
|
2009-11-24 03:27:29 -06:00
|
|
|
/* See e.g. ARM1136 TRM, "14.8.4 Entering Debug state" */
|
|
|
|
|
2009-12-03 00:57:08 -06:00
|
|
|
/* maybe save wDTR (pending DCC write to debug SW, e.g. libdcc) */
|
2009-12-03 18:08:04 -06:00
|
|
|
arm11->is_wdtr_saved = !!(arm11->dscr & DSCR_DTR_TX_FULL);
|
2009-12-03 00:57:07 -06:00
|
|
|
if (arm11->is_wdtr_saved)
|
2008-10-08 15:16:51 -05:00
|
|
|
{
|
2009-04-22 13:39:59 -05:00
|
|
|
arm11_add_debug_SCAN_N(arm11, 0x05, ARM11_TAP_DEFAULT);
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-04-22 13:39:59 -05:00
|
|
|
arm11_add_IR(arm11, ARM11_INTEST, ARM11_TAP_DEFAULT);
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-11-13 05:28:03 -06:00
|
|
|
struct scan_field chain5_fields[3];
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-12-03 00:57:07 -06:00
|
|
|
arm11_setup_field(arm11, 32, NULL,
|
|
|
|
&arm11->saved_wdtr, chain5_fields + 0);
|
2009-05-18 02:02:12 -05:00
|
|
|
arm11_setup_field(arm11, 1, NULL, NULL, chain5_fields + 1);
|
|
|
|
arm11_setup_field(arm11, 1, NULL, NULL, chain5_fields + 2);
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-11-16 05:29:30 -06:00
|
|
|
arm11_add_dr_scan_vc(ARRAY_SIZE(chain5_fields), chain5_fields, TAP_DRPAUSE);
|
2009-12-03 00:57:08 -06:00
|
|
|
|
2008-10-08 15:16:51 -05:00
|
|
|
}
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-12-03 18:08:04 -06:00
|
|
|
/* DSCR: set the Execute ARM instruction enable bit.
|
2009-11-24 03:27:29 -06:00
|
|
|
*
|
|
|
|
* ARM1176 spec says this is needed only for wDTR/rDTR's "ITR mode",
|
2009-12-03 18:08:04 -06:00
|
|
|
* but not to issue ITRs(?). The ARMv7 arch spec says it's required
|
|
|
|
* for executing instructions via ITR.
|
2009-11-24 03:27:29 -06:00
|
|
|
*/
|
2009-12-03 18:08:04 -06:00
|
|
|
arm11_write_DSCR(arm11, DSCR_ITR_EN | arm11->dscr);
|
2008-02-25 11:48:04 -06:00
|
|
|
|
|
|
|
|
2008-10-08 15:16:51 -05:00
|
|
|
/* From the spec:
|
2009-04-22 13:39:59 -05:00
|
|
|
Before executing any instruction in debug state you have to drain the write buffer.
|
|
|
|
This ensures that no imprecise Data Aborts can return at a later point:*/
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2008-10-08 15:16:51 -05:00
|
|
|
/** \todo TODO: Test drain write buffer. */
|
2008-02-25 11:48:04 -06:00
|
|
|
|
|
|
|
#if 0
|
2008-10-08 15:16:51 -05:00
|
|
|
while (1)
|
|
|
|
{
|
2009-04-22 13:39:59 -05:00
|
|
|
/* MRC p14,0,R0,c5,c10,0 */
|
|
|
|
// arm11_run_instr_no_data1(arm11, /*0xee150e1a*/0xe320f000);
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-04-22 13:39:59 -05:00
|
|
|
/* mcr 15, 0, r0, cr7, cr10, {4} */
|
|
|
|
arm11_run_instr_no_data1(arm11, 0xee070f9a);
|
2008-10-07 06:08:57 -05:00
|
|
|
|
2009-06-18 02:08:52 -05:00
|
|
|
uint32_t dscr = arm11_read_DSCR(arm11);
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-04-22 13:39:59 -05:00
|
|
|
LOG_DEBUG("DRAIN, DSCR %08x", dscr);
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-04-22 13:39:59 -05:00
|
|
|
if (dscr & ARM11_DSCR_STICKY_IMPRECISE_DATA_ABORT)
|
|
|
|
{
|
|
|
|
arm11_run_instr_no_data1(arm11, 0xe320f000);
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-04-22 13:39:59 -05:00
|
|
|
dscr = arm11_read_DSCR(arm11);
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-04-22 13:39:59 -05:00
|
|
|
LOG_DEBUG("DRAIN, DSCR %08x (DONE)", dscr);
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-04-22 13:39:59 -05:00
|
|
|
break;
|
|
|
|
}
|
2008-02-25 11:48:04 -06:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-11-24 03:27:29 -06:00
|
|
|
/* Save registers.
|
|
|
|
*
|
|
|
|
* NOTE: ARM1136 TRM suggests saving just R0 here now, then
|
|
|
|
* CPSR and PC after the rDTR stuff. We do it all at once.
|
|
|
|
*/
|
ARM11: partial support for standard ARM register interfaces.
This provides "standard" ARM register support -- with twenty or
more shadow registers on top of what this code now handles, but
properly associated with the various core modes -- parallel to
the current register code. That is, the current code is stilil
managing the "current" registers; the new code shadows them.
You can see all the registers with "arm reg", modify the shadows
like "r8_fiq" or "sp_abt" with "reg", and see them get properly
written back when you step. (Just don't do that with any of the
registers managed by the "old" code ...)
It also switches to using more standard code, relying on those
standard registers, in two places: (a) the poll status display,
which now shows core state (ARM/Thumb/...) and mode (Supervisor,
IRQ, etc); and (b) GDB register access.
So it's not a full migration, there are warts -- every place that
touches the old register cache is a potential bug -- but it's a
small more-or-less-comprehensible step that's even somewhat useful.
Later patches complete the migration.
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-24 03:27:16 -06:00
|
|
|
retval = arm_dpm_read_current_registers(&arm11->dpm);
|
|
|
|
if (retval != ERROR_OK)
|
|
|
|
LOG_ERROR("DPM REG READ -- fail %d", retval);
|
|
|
|
|
2009-10-09 03:00:05 -05:00
|
|
|
retval = arm11_run_instr_data_prepare(arm11);
|
|
|
|
if (retval != ERROR_OK)
|
|
|
|
return retval;
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-12-03 00:57:08 -06:00
|
|
|
/* maybe save rDTR (pending DCC read from debug SW, e.g. libdcc) */
|
2009-12-03 18:08:04 -06:00
|
|
|
arm11->is_rdtr_saved = !!(arm11->dscr & DSCR_DTR_RX_FULL);
|
2009-12-03 00:57:07 -06:00
|
|
|
if (arm11->is_rdtr_saved)
|
2008-10-08 15:16:51 -05:00
|
|
|
{
|
2009-04-22 13:39:59 -05:00
|
|
|
/* MRC p14,0,R0,c0,c5,0 (move rDTR -> r0 (-> wDTR -> local var)) */
|
2009-12-03 00:57:07 -06:00
|
|
|
retval = arm11_run_instr_data_from_core_via_r0(arm11,
|
|
|
|
0xEE100E15, &arm11->saved_rdtr);
|
2009-10-09 03:00:05 -05:00
|
|
|
if (retval != ERROR_OK)
|
|
|
|
return retval;
|
2008-10-08 15:16:51 -05:00
|
|
|
}
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-11-24 03:27:29 -06:00
|
|
|
/* REVISIT Now that we've saved core state, there's may also
|
|
|
|
* be MMU and cache state to care about ...
|
|
|
|
*/
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2008-10-08 15:16:51 -05:00
|
|
|
if (arm11->simulate_reset_on_next_halt)
|
|
|
|
{
|
2009-04-22 13:39:59 -05:00
|
|
|
arm11->simulate_reset_on_next_halt = false;
|
2008-03-04 00:46:44 -06:00
|
|
|
|
2009-04-22 13:39:59 -05:00
|
|
|
LOG_DEBUG("Reset c1 Control Register");
|
2008-03-04 00:46:44 -06:00
|
|
|
|
2009-04-22 13:39:59 -05:00
|
|
|
/* Write 0 (reset value) to Control register 0 to disable MMU/Cache etc. */
|
2008-03-04 00:46:44 -06:00
|
|
|
|
2009-04-22 13:39:59 -05:00
|
|
|
/* MCR p15,0,R0,c1,c0,0 */
|
2009-10-09 03:00:05 -05:00
|
|
|
retval = arm11_run_instr_data_to_core_via_r0(arm11, 0xee010f10, 0);
|
|
|
|
if (retval != ERROR_OK)
|
|
|
|
return retval;
|
2008-03-04 00:46:44 -06:00
|
|
|
|
2008-10-08 15:16:51 -05:00
|
|
|
}
|
2008-03-04 00:46:44 -06:00
|
|
|
|
2009-12-04 20:57:31 -06:00
|
|
|
if (arm11->arm.target->debug_reason == DBG_REASON_WATCHPOINT) {
|
|
|
|
uint32_t wfar;
|
|
|
|
|
|
|
|
/* MRC p15, 0, <Rd>, c6, c0, 1 ; Read WFAR */
|
|
|
|
retval = arm11_run_instr_data_from_core_via_r0(arm11,
|
|
|
|
ARMV4_5_MRC(15, 0, 0, 6, 0, 1),
|
|
|
|
&wfar);
|
|
|
|
if (retval != ERROR_OK)
|
|
|
|
return retval;
|
|
|
|
arm_dpm_report_wfar(arm11->arm.dpm, wfar);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-10-09 03:00:05 -05:00
|
|
|
retval = arm11_run_instr_data_finish(arm11);
|
|
|
|
if (retval != ERROR_OK)
|
|
|
|
return retval;
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-04-27 06:24:01 -05:00
|
|
|
return ERROR_OK;
|
2008-02-29 01:03:28 -06:00
|
|
|
}
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-12-01 23:47:45 -06:00
|
|
|
/**
|
|
|
|
* Restore processor state. This is called in preparation for
|
|
|
|
* the RESTART function.
|
|
|
|
*/
|
|
|
|
static int arm11_leave_debug_state(struct arm11_common *arm11, bool bpwp)
|
2008-02-25 11:48:04 -06:00
|
|
|
{
|
2009-10-09 03:00:05 -05:00
|
|
|
int retval;
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-11-24 03:27:29 -06:00
|
|
|
/* See e.g. ARM1136 TRM, "14.8.5 Leaving Debug state" */
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-11-24 03:27:29 -06:00
|
|
|
/* NOTE: the ARM1136 TRM suggests restoring all registers
|
|
|
|
* except R0/PC/CPSR right now. Instead, we do them all
|
|
|
|
* at once, just a bit later on.
|
|
|
|
*/
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-11-24 03:27:29 -06:00
|
|
|
/* REVISIT once we start caring about MMU and cache state,
|
|
|
|
* address it here ...
|
|
|
|
*/
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2008-10-08 15:16:51 -05:00
|
|
|
/* spec says clear wDTR and rDTR; we assume they are clear as
|
|
|
|
otherwise our programming would be sloppy */
|
|
|
|
{
|
2009-12-03 00:57:08 -06:00
|
|
|
CHECK_RETVAL(arm11_read_DSCR(arm11));
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-12-03 18:08:04 -06:00
|
|
|
if (arm11->dscr & (DSCR_DTR_RX_FULL | DSCR_DTR_TX_FULL))
|
2009-04-22 13:39:59 -05:00
|
|
|
{
|
2009-10-13 05:06:55 -05:00
|
|
|
/*
|
|
|
|
The wDTR/rDTR two registers that are used to send/receive data to/from
|
|
|
|
the core in tandem with corresponding instruction codes that are
|
|
|
|
written into the core. The RDTR FULL/WDTR FULL flag indicates that the
|
|
|
|
registers hold data that was written by one side (CPU or JTAG) and not
|
|
|
|
read out by the other side.
|
|
|
|
*/
|
2009-12-03 00:57:08 -06:00
|
|
|
LOG_ERROR("wDTR/rDTR inconsistent (DSCR %08x)",
|
|
|
|
(unsigned) arm11->dscr);
|
2009-10-12 07:10:49 -05:00
|
|
|
return ERROR_FAIL;
|
2009-04-22 13:39:59 -05:00
|
|
|
}
|
2008-02-25 11:48:04 -06:00
|
|
|
}
|
|
|
|
|
2009-11-24 03:27:29 -06:00
|
|
|
/* maybe restore original wDTR */
|
2009-12-03 00:57:07 -06:00
|
|
|
if (arm11->is_wdtr_saved)
|
2008-10-08 15:16:51 -05:00
|
|
|
{
|
2009-11-24 03:27:29 -06:00
|
|
|
retval = arm11_run_instr_data_prepare(arm11);
|
|
|
|
if (retval != ERROR_OK)
|
|
|
|
return retval;
|
|
|
|
|
2009-04-22 13:39:59 -05:00
|
|
|
/* MCR p14,0,R0,c0,c5,0 */
|
2009-12-03 00:57:07 -06:00
|
|
|
retval = arm11_run_instr_data_to_core_via_r0(arm11,
|
|
|
|
0xee000e15, arm11->saved_wdtr);
|
2009-10-09 03:00:05 -05:00
|
|
|
if (retval != ERROR_OK)
|
|
|
|
return retval;
|
|
|
|
|
2009-11-24 03:27:29 -06:00
|
|
|
retval = arm11_run_instr_data_finish(arm11);
|
|
|
|
if (retval != ERROR_OK)
|
|
|
|
return retval;
|
|
|
|
}
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-11-24 03:27:29 -06:00
|
|
|
/* restore CPSR, PC, and R0 ... after flushing any modified
|
|
|
|
* registers.
|
|
|
|
*/
|
2009-12-01 23:47:45 -06:00
|
|
|
retval = arm_dpm_write_dirty_registers(&arm11->dpm, bpwp);
|
ARM11: partial support for standard ARM register interfaces.
This provides "standard" ARM register support -- with twenty or
more shadow registers on top of what this code now handles, but
properly associated with the various core modes -- parallel to
the current register code. That is, the current code is stilil
managing the "current" registers; the new code shadows them.
You can see all the registers with "arm reg", modify the shadows
like "r8_fiq" or "sp_abt" with "reg", and see them get properly
written back when you step. (Just don't do that with any of the
registers managed by the "old" code ...)
It also switches to using more standard code, relying on those
standard registers, in two places: (a) the poll status display,
which now shows core state (ARM/Thumb/...) and mode (Supervisor,
IRQ, etc); and (b) GDB register access.
So it's not a full migration, there are warts -- every place that
touches the old register cache is a potential bug -- but it's a
small more-or-less-comprehensible step that's even somewhat useful.
Later patches complete the migration.
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-24 03:27:16 -06:00
|
|
|
|
2009-12-04 20:57:31 -06:00
|
|
|
retval = arm11_bpwp_flush(arm11);
|
|
|
|
|
ARM11: partial support for standard ARM register interfaces.
This provides "standard" ARM register support -- with twenty or
more shadow registers on top of what this code now handles, but
properly associated with the various core modes -- parallel to
the current register code. That is, the current code is stilil
managing the "current" registers; the new code shadows them.
You can see all the registers with "arm reg", modify the shadows
like "r8_fiq" or "sp_abt" with "reg", and see them get properly
written back when you step. (Just don't do that with any of the
registers managed by the "old" code ...)
It also switches to using more standard code, relying on those
standard registers, in two places: (a) the poll status display,
which now shows core state (ARM/Thumb/...) and mode (Supervisor,
IRQ, etc); and (b) GDB register access.
So it's not a full migration, there are warts -- every place that
touches the old register cache is a potential bug -- but it's a
small more-or-less-comprehensible step that's even somewhat useful.
Later patches complete the migration.
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-24 03:27:16 -06:00
|
|
|
register_cache_invalidate(arm11->arm.core_cache);
|
|
|
|
|
2008-10-08 15:16:51 -05:00
|
|
|
/* restore DSCR */
|
2009-12-03 00:57:08 -06:00
|
|
|
arm11_write_DSCR(arm11, arm11->dscr);
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-11-24 03:27:29 -06:00
|
|
|
/* maybe restore rDTR */
|
2009-12-03 00:57:07 -06:00
|
|
|
if (arm11->is_rdtr_saved)
|
2008-10-08 15:16:51 -05:00
|
|
|
{
|
2009-04-22 13:39:59 -05:00
|
|
|
arm11_add_debug_SCAN_N(arm11, 0x05, ARM11_TAP_DEFAULT);
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-04-22 13:39:59 -05:00
|
|
|
arm11_add_IR(arm11, ARM11_EXTEST, ARM11_TAP_DEFAULT);
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-11-13 05:28:03 -06:00
|
|
|
struct scan_field chain5_fields[3];
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-06-18 02:04:08 -05:00
|
|
|
uint8_t Ready = 0; /* ignored */
|
|
|
|
uint8_t Valid = 0; /* ignored */
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-12-03 00:57:07 -06:00
|
|
|
arm11_setup_field(arm11, 32, &arm11->saved_rdtr,
|
|
|
|
NULL, chain5_fields + 0);
|
2009-04-22 13:39:59 -05:00
|
|
|
arm11_setup_field(arm11, 1, &Ready, NULL, chain5_fields + 1);
|
|
|
|
arm11_setup_field(arm11, 1, &Valid, NULL, chain5_fields + 2);
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-11-16 05:29:30 -06:00
|
|
|
arm11_add_dr_scan_vc(ARRAY_SIZE(chain5_fields), chain5_fields, TAP_DRPAUSE);
|
2008-10-08 15:16:51 -05:00
|
|
|
}
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-11-24 03:27:29 -06:00
|
|
|
/* now processor is ready to RESTART */
|
|
|
|
|
2009-04-27 06:24:01 -05:00
|
|
|
return ERROR_OK;
|
2008-02-29 01:03:28 -06:00
|
|
|
}
|
2008-02-25 11:48:04 -06:00
|
|
|
|
|
|
|
/* poll current target status */
|
2009-11-13 12:11:13 -06:00
|
|
|
static int arm11_poll(struct target *target)
|
2008-02-25 11:48:04 -06:00
|
|
|
{
|
2009-08-28 08:43:26 -05:00
|
|
|
int retval;
|
2009-11-13 18:22:36 -06:00
|
|
|
struct arm11_common *arm11 = target_to_arm11(target);
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-12-03 00:57:08 -06:00
|
|
|
CHECK_RETVAL(arm11_check_init(arm11));
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-12-03 18:08:04 -06:00
|
|
|
if (arm11->dscr & DSCR_CORE_HALTED)
|
2008-10-08 15:16:51 -05:00
|
|
|
{
|
2009-04-22 13:39:59 -05:00
|
|
|
if (target->state != TARGET_HALTED)
|
|
|
|
{
|
|
|
|
enum target_state old_state = target->state;
|
2008-02-29 01:03:28 -06:00
|
|
|
|
2009-04-22 13:39:59 -05:00
|
|
|
LOG_DEBUG("enter TARGET_HALTED");
|
2009-12-03 00:57:08 -06:00
|
|
|
retval = arm11_debug_entry(arm11);
|
2009-08-28 08:43:26 -05:00
|
|
|
if (retval != ERROR_OK)
|
|
|
|
return retval;
|
2008-02-29 01:03:28 -06:00
|
|
|
|
2009-04-22 13:39:59 -05:00
|
|
|
target_call_event_callbacks(target,
|
|
|
|
old_state == TARGET_DEBUG_RUNNING ? TARGET_EVENT_DEBUG_HALTED : TARGET_EVENT_HALTED);
|
|
|
|
}
|
2008-10-08 15:16:51 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-04-22 13:39:59 -05:00
|
|
|
if (target->state != TARGET_RUNNING && target->state != TARGET_DEBUG_RUNNING)
|
|
|
|
{
|
|
|
|
LOG_DEBUG("enter TARGET_RUNNING");
|
2009-05-18 02:02:12 -05:00
|
|
|
target->state = TARGET_RUNNING;
|
2009-04-22 13:39:59 -05:00
|
|
|
target->debug_reason = DBG_REASON_NOTHALTED;
|
|
|
|
}
|
2008-02-25 11:48:04 -06:00
|
|
|
}
|
|
|
|
|
2008-10-08 15:16:51 -05:00
|
|
|
return ERROR_OK;
|
2008-02-25 11:48:04 -06:00
|
|
|
}
|
|
|
|
/* architecture specific status reply */
|
2009-11-13 12:11:13 -06:00
|
|
|
static int arm11_arch_state(struct target *target)
|
2008-02-25 11:48:04 -06:00
|
|
|
{
|
2009-12-04 20:57:31 -06:00
|
|
|
struct arm11_common *arm11 = target_to_arm11(target);
|
ARM11: partial support for standard ARM register interfaces.
This provides "standard" ARM register support -- with twenty or
more shadow registers on top of what this code now handles, but
properly associated with the various core modes -- parallel to
the current register code. That is, the current code is stilil
managing the "current" registers; the new code shadows them.
You can see all the registers with "arm reg", modify the shadows
like "r8_fiq" or "sp_abt" with "reg", and see them get properly
written back when you step. (Just don't do that with any of the
registers managed by the "old" code ...)
It also switches to using more standard code, relying on those
standard registers, in two places: (a) the poll status display,
which now shows core state (ARM/Thumb/...) and mode (Supervisor,
IRQ, etc); and (b) GDB register access.
So it's not a full migration, there are warts -- every place that
touches the old register cache is a potential bug -- but it's a
small more-or-less-comprehensible step that's even somewhat useful.
Later patches complete the migration.
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-24 03:27:16 -06:00
|
|
|
int retval;
|
2009-04-27 07:12:44 -05:00
|
|
|
|
ARM11: partial support for standard ARM register interfaces.
This provides "standard" ARM register support -- with twenty or
more shadow registers on top of what this code now handles, but
properly associated with the various core modes -- parallel to
the current register code. That is, the current code is stilil
managing the "current" registers; the new code shadows them.
You can see all the registers with "arm reg", modify the shadows
like "r8_fiq" or "sp_abt" with "reg", and see them get properly
written back when you step. (Just don't do that with any of the
registers managed by the "old" code ...)
It also switches to using more standard code, relying on those
standard registers, in two places: (a) the poll status display,
which now shows core state (ARM/Thumb/...) and mode (Supervisor,
IRQ, etc); and (b) GDB register access.
So it's not a full migration, there are warts -- every place that
touches the old register cache is a potential bug -- but it's a
small more-or-less-comprehensible step that's even somewhat useful.
Later patches complete the migration.
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-24 03:27:16 -06:00
|
|
|
retval = armv4_5_arch_state(target);
|
2008-02-25 11:48:04 -06:00
|
|
|
|
ARM11: partial support for standard ARM register interfaces.
This provides "standard" ARM register support -- with twenty or
more shadow registers on top of what this code now handles, but
properly associated with the various core modes -- parallel to
the current register code. That is, the current code is stilil
managing the "current" registers; the new code shadows them.
You can see all the registers with "arm reg", modify the shadows
like "r8_fiq" or "sp_abt" with "reg", and see them get properly
written back when you step. (Just don't do that with any of the
registers managed by the "old" code ...)
It also switches to using more standard code, relying on those
standard registers, in two places: (a) the poll status display,
which now shows core state (ARM/Thumb/...) and mode (Supervisor,
IRQ, etc); and (b) GDB register access.
So it's not a full migration, there are warts -- every place that
touches the old register cache is a potential bug -- but it's a
small more-or-less-comprehensible step that's even somewhat useful.
Later patches complete the migration.
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-24 03:27:16 -06:00
|
|
|
/* REVISIT also display ARM11-specific MMU and cache status ... */
|
|
|
|
|
2009-12-04 20:57:31 -06:00
|
|
|
if (target->debug_reason == DBG_REASON_WATCHPOINT)
|
|
|
|
LOG_USER("Watchpoint triggered at PC %#08x",
|
|
|
|
(unsigned) arm11->dpm.wp_pc);
|
|
|
|
|
ARM11: partial support for standard ARM register interfaces.
This provides "standard" ARM register support -- with twenty or
more shadow registers on top of what this code now handles, but
properly associated with the various core modes -- parallel to
the current register code. That is, the current code is stilil
managing the "current" registers; the new code shadows them.
You can see all the registers with "arm reg", modify the shadows
like "r8_fiq" or "sp_abt" with "reg", and see them get properly
written back when you step. (Just don't do that with any of the
registers managed by the "old" code ...)
It also switches to using more standard code, relying on those
standard registers, in two places: (a) the poll status display,
which now shows core state (ARM/Thumb/...) and mode (Supervisor,
IRQ, etc); and (b) GDB register access.
So it's not a full migration, there are warts -- every place that
touches the old register cache is a potential bug -- but it's a
small more-or-less-comprehensible step that's even somewhat useful.
Later patches complete the migration.
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-24 03:27:16 -06:00
|
|
|
return retval;
|
2008-02-25 11:48:04 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/* target request support */
|
2009-11-13 12:11:13 -06:00
|
|
|
static int arm11_target_request_data(struct target *target,
|
2009-11-06 05:36:46 -06:00
|
|
|
uint32_t size, uint8_t *buffer)
|
2008-02-25 11:48:04 -06:00
|
|
|
{
|
2009-11-22 17:50:24 -06:00
|
|
|
LOG_WARNING("Not implemented: %s", __func__);
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-11-22 17:50:24 -06:00
|
|
|
return ERROR_FAIL;
|
2008-02-25 11:48:04 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/* target execution control */
|
2009-11-13 12:11:13 -06:00
|
|
|
static int arm11_halt(struct target *target)
|
2008-02-25 11:48:04 -06:00
|
|
|
{
|
2009-11-13 18:22:36 -06:00
|
|
|
struct arm11_common *arm11 = target_to_arm11(target);
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2008-10-08 15:16:51 -05:00
|
|
|
LOG_DEBUG("target->state: %s",
|
2009-06-27 21:40:08 -05:00
|
|
|
target_state_name(target));
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2008-10-08 15:16:51 -05:00
|
|
|
if (target->state == TARGET_UNKNOWN)
|
|
|
|
{
|
2009-04-22 13:39:59 -05:00
|
|
|
arm11->simulate_reset_on_next_halt = true;
|
2008-10-08 15:16:51 -05:00
|
|
|
}
|
2008-03-04 00:46:44 -06:00
|
|
|
|
2008-10-08 15:16:51 -05:00
|
|
|
if (target->state == TARGET_HALTED)
|
|
|
|
{
|
2008-04-04 08:47:38 -05:00
|
|
|
LOG_DEBUG("target was already halted");
|
|
|
|
return ERROR_OK;
|
2008-10-08 15:16:51 -05:00
|
|
|
}
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2008-12-13 00:25:50 -06:00
|
|
|
arm11_add_IR(arm11, ARM11_HALT, TAP_IDLE);
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-04-28 02:29:18 -05:00
|
|
|
CHECK_RETVAL(jtag_execute_queue());
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-10-07 07:05:37 -05:00
|
|
|
int i = 0;
|
2009-12-03 00:57:07 -06:00
|
|
|
|
2008-10-08 15:16:51 -05:00
|
|
|
while (1)
|
|
|
|
{
|
2009-12-03 00:57:08 -06:00
|
|
|
CHECK_RETVAL(arm11_read_DSCR(arm11));
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-12-03 18:08:04 -06:00
|
|
|
if (arm11->dscr & DSCR_CORE_HALTED)
|
2009-04-22 13:39:59 -05:00
|
|
|
break;
|
2009-10-07 07:05:37 -05:00
|
|
|
|
|
|
|
|
|
|
|
long long then = 0;
|
|
|
|
if (i == 1000)
|
|
|
|
{
|
|
|
|
then = timeval_ms();
|
|
|
|
}
|
|
|
|
if (i >= 1000)
|
|
|
|
{
|
|
|
|
if ((timeval_ms()-then) > 1000)
|
|
|
|
{
|
|
|
|
LOG_WARNING("Timeout (1000ms) waiting for instructions to complete");
|
|
|
|
return ERROR_FAIL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
i++;
|
2008-10-08 15:16:51 -05:00
|
|
|
}
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2008-10-08 15:16:51 -05:00
|
|
|
enum target_state old_state = target->state;
|
2008-02-29 01:03:28 -06:00
|
|
|
|
2009-12-03 00:57:08 -06:00
|
|
|
arm11_debug_entry(arm11);
|
2008-02-29 01:03:28 -06:00
|
|
|
|
2009-04-28 02:29:18 -05:00
|
|
|
CHECK_RETVAL(
|
|
|
|
target_call_event_callbacks(target,
|
|
|
|
old_state == TARGET_DEBUG_RUNNING ? TARGET_EVENT_DEBUG_HALTED : TARGET_EVENT_HALTED));
|
2008-02-29 01:03:28 -06:00
|
|
|
|
2008-10-08 15:16:51 -05:00
|
|
|
return ERROR_OK;
|
2008-02-25 11:48:04 -06:00
|
|
|
}
|
|
|
|
|
2009-11-24 03:27:29 -06:00
|
|
|
static uint32_t
|
|
|
|
arm11_nextpc(struct arm11_common *arm11, int current, uint32_t address)
|
|
|
|
{
|
|
|
|
void *value = arm11->arm.core_cache->reg_list[15].value;
|
|
|
|
|
|
|
|
if (!current)
|
|
|
|
buf_set_u32(value, 0, 32, address);
|
|
|
|
else
|
|
|
|
address = buf_get_u32(value, 0, 32);
|
|
|
|
|
|
|
|
return address;
|
|
|
|
}
|
|
|
|
|
2009-11-13 12:11:13 -06:00
|
|
|
static int arm11_resume(struct target *target, int current,
|
2009-11-06 05:36:46 -06:00
|
|
|
uint32_t address, int handle_breakpoints, int debug_execution)
|
2008-02-25 11:48:04 -06:00
|
|
|
{
|
2009-04-22 13:39:59 -05:00
|
|
|
// LOG_DEBUG("current %d address %08x handle_breakpoints %d debug_execution %d",
|
|
|
|
// current, address, handle_breakpoints, debug_execution);
|
2008-02-29 01:03:28 -06:00
|
|
|
|
2009-11-13 18:22:36 -06:00
|
|
|
struct arm11_common *arm11 = target_to_arm11(target);
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2008-10-08 15:16:51 -05:00
|
|
|
LOG_DEBUG("target->state: %s",
|
2009-06-27 21:40:08 -05:00
|
|
|
target_state_name(target));
|
2008-08-24 13:20:49 -05:00
|
|
|
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2008-10-08 15:16:51 -05:00
|
|
|
if (target->state != TARGET_HALTED)
|
2008-08-17 14:40:17 -05:00
|
|
|
{
|
|
|
|
LOG_ERROR("Target not halted");
|
|
|
|
return ERROR_TARGET_NOT_HALTED;
|
|
|
|
}
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-11-24 03:27:29 -06:00
|
|
|
address = arm11_nextpc(arm11, current, address);
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-11-24 03:27:29 -06:00
|
|
|
LOG_DEBUG("RESUME PC %08" PRIx32 "%s", address, !current ? "!" : "");
|
2008-02-29 01:03:28 -06:00
|
|
|
|
2008-10-08 15:16:51 -05:00
|
|
|
/* clear breakpoints/watchpoints and VCR*/
|
|
|
|
arm11_sc7_clear_vbw(arm11);
|
2008-02-29 01:03:28 -06:00
|
|
|
|
2008-10-08 15:16:51 -05:00
|
|
|
if (!debug_execution)
|
2009-11-24 03:27:24 -06:00
|
|
|
target_free_all_working_areas(target);
|
|
|
|
|
|
|
|
/* Set up breakpoints */
|
|
|
|
if (handle_breakpoints)
|
2008-10-08 15:16:51 -05:00
|
|
|
{
|
2009-04-22 13:39:59 -05:00
|
|
|
/* check if one matches PC and step over it if necessary */
|
2008-02-29 01:03:28 -06:00
|
|
|
|
2009-11-13 11:15:32 -06:00
|
|
|
struct breakpoint * bp;
|
2008-02-29 01:03:28 -06:00
|
|
|
|
2009-04-22 13:39:59 -05:00
|
|
|
for (bp = target->breakpoints; bp; bp = bp->next)
|
2008-10-08 15:16:51 -05:00
|
|
|
{
|
2009-11-24 03:27:29 -06:00
|
|
|
if (bp->address == address)
|
2009-04-22 13:39:59 -05:00
|
|
|
{
|
2009-06-20 22:14:58 -05:00
|
|
|
LOG_DEBUG("must step over %08" PRIx32 "", bp->address);
|
2009-04-22 13:39:59 -05:00
|
|
|
arm11_step(target, 1, 0, 0);
|
|
|
|
break;
|
|
|
|
}
|
2008-10-08 15:16:51 -05:00
|
|
|
}
|
2008-02-29 01:03:28 -06:00
|
|
|
|
2009-04-22 13:39:59 -05:00
|
|
|
/* set all breakpoints */
|
2008-02-29 01:03:28 -06:00
|
|
|
|
2009-11-22 12:21:22 -06:00
|
|
|
unsigned brp_num = 0;
|
2008-10-07 06:08:57 -05:00
|
|
|
|
2009-04-22 13:39:59 -05:00
|
|
|
for (bp = target->breakpoints; bp; bp = bp->next)
|
|
|
|
{
|
2009-11-13 10:39:54 -06:00
|
|
|
struct arm11_sc7_action brp[2];
|
2008-02-29 01:03:28 -06:00
|
|
|
|
2009-04-22 13:39:59 -05:00
|
|
|
brp[0].write = 1;
|
|
|
|
brp[0].address = ARM11_SC7_BVR0 + brp_num;
|
|
|
|
brp[0].value = bp->address;
|
|
|
|
brp[1].write = 1;
|
|
|
|
brp[1].address = ARM11_SC7_BCR0 + brp_num;
|
|
|
|
brp[1].value = 0x1 | (3 << 1) | (0x0F << 5) | (0 << 14) | (0 << 16) | (0 << 20) | (0 << 21);
|
2008-10-07 06:08:57 -05:00
|
|
|
|
2009-11-16 05:29:30 -06:00
|
|
|
arm11_sc7_run(arm11, brp, ARRAY_SIZE(brp));
|
2008-02-29 01:03:28 -06:00
|
|
|
|
2009-11-22 12:21:22 -06:00
|
|
|
LOG_DEBUG("Add BP %d at %08" PRIx32, brp_num,
|
|
|
|
bp->address);
|
2008-02-29 01:03:28 -06:00
|
|
|
|
2009-04-22 13:39:59 -05:00
|
|
|
brp_num++;
|
|
|
|
}
|
2008-02-29 01:03:28 -06:00
|
|
|
|
2009-12-04 20:57:30 -06:00
|
|
|
if (arm11_vcr)
|
|
|
|
arm11_sc7_set_vcr(arm11, arm11_vcr);
|
2008-10-08 15:16:51 -05:00
|
|
|
}
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-12-01 23:47:45 -06:00
|
|
|
arm11_leave_debug_state(arm11, handle_breakpoints);
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2008-12-13 00:25:50 -06:00
|
|
|
arm11_add_IR(arm11, ARM11_RESTART, TAP_IDLE);
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-04-28 02:29:18 -05:00
|
|
|
CHECK_RETVAL(jtag_execute_queue());
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-10-07 07:05:37 -05:00
|
|
|
int i = 0;
|
2008-10-08 15:16:51 -05:00
|
|
|
while (1)
|
|
|
|
{
|
2009-12-03 00:57:08 -06:00
|
|
|
CHECK_RETVAL(arm11_read_DSCR(arm11));
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-12-03 00:57:08 -06:00
|
|
|
LOG_DEBUG("DSCR %08x", (unsigned) arm11->dscr);
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-12-03 18:08:04 -06:00
|
|
|
if (arm11->dscr & DSCR_CORE_RESTARTED)
|
2009-04-22 13:39:59 -05:00
|
|
|
break;
|
2009-10-07 07:05:37 -05:00
|
|
|
|
|
|
|
|
|
|
|
long long then = 0;
|
|
|
|
if (i == 1000)
|
|
|
|
{
|
|
|
|
then = timeval_ms();
|
|
|
|
}
|
|
|
|
if (i >= 1000)
|
|
|
|
{
|
|
|
|
if ((timeval_ms()-then) > 1000)
|
|
|
|
{
|
|
|
|
LOG_WARNING("Timeout (1000ms) waiting for instructions to complete");
|
|
|
|
return ERROR_FAIL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
i++;
|
2008-10-08 15:16:51 -05:00
|
|
|
}
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-12-03 18:08:04 -06:00
|
|
|
target->debug_reason = DBG_REASON_NOTHALTED;
|
2008-10-08 15:16:51 -05:00
|
|
|
if (!debug_execution)
|
2009-12-03 18:08:04 -06:00
|
|
|
target->state = TARGET_RUNNING;
|
2008-10-08 15:16:51 -05:00
|
|
|
else
|
2009-12-03 18:08:04 -06:00
|
|
|
target->state = TARGET_DEBUG_RUNNING;
|
|
|
|
CHECK_RETVAL(target_call_event_callbacks(target, TARGET_EVENT_RESUMED));
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2008-10-08 15:16:51 -05:00
|
|
|
return ERROR_OK;
|
2008-02-25 11:48:04 -06:00
|
|
|
}
|
|
|
|
|
2009-11-13 12:11:13 -06:00
|
|
|
static int arm11_step(struct target *target, int current,
|
2009-11-06 05:36:46 -06:00
|
|
|
uint32_t address, int handle_breakpoints)
|
2008-02-25 11:48:04 -06:00
|
|
|
{
|
2008-10-08 15:16:51 -05:00
|
|
|
LOG_DEBUG("target->state: %s",
|
2009-06-27 21:40:08 -05:00
|
|
|
target_state_name(target));
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2008-10-08 15:16:51 -05:00
|
|
|
if (target->state != TARGET_HALTED)
|
|
|
|
{
|
2009-04-22 13:39:59 -05:00
|
|
|
LOG_WARNING("target was not halted");
|
|
|
|
return ERROR_TARGET_NOT_HALTED;
|
2008-10-08 15:16:51 -05:00
|
|
|
}
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-11-13 18:22:36 -06:00
|
|
|
struct arm11_common *arm11 = target_to_arm11(target);
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-11-24 03:27:29 -06:00
|
|
|
address = arm11_nextpc(arm11, current, address);
|
2008-02-29 01:03:28 -06:00
|
|
|
|
2009-11-24 03:27:29 -06:00
|
|
|
LOG_DEBUG("STEP PC %08" PRIx32 "%s", address, !current ? "!" : "");
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-08-27 02:37:07 -05:00
|
|
|
|
2008-10-08 15:16:51 -05:00
|
|
|
/** \todo TODO: Thumb not supported here */
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-06-18 02:08:52 -05:00
|
|
|
uint32_t next_instruction;
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-11-24 03:27:29 -06:00
|
|
|
CHECK_RETVAL(arm11_read_memory_word(arm11, address, &next_instruction));
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2008-10-08 15:16:51 -05:00
|
|
|
/* skip over BKPT */
|
|
|
|
if ((next_instruction & 0xFFF00070) == 0xe1200070)
|
|
|
|
{
|
2009-11-24 03:27:29 -06:00
|
|
|
address = arm11_nextpc(arm11, 0, address + 4);
|
2009-04-28 02:33:50 -05:00
|
|
|
LOG_DEBUG("Skipping BKPT");
|
2008-10-08 15:16:51 -05:00
|
|
|
}
|
|
|
|
/* skip over Wait for interrupt / Standby */
|
|
|
|
/* mcr 15, 0, r?, cr7, cr0, {4} */
|
|
|
|
else if ((next_instruction & 0xFFFF0FFF) == 0xee070f90)
|
|
|
|
{
|
2009-11-24 03:27:29 -06:00
|
|
|
address = arm11_nextpc(arm11, 0, address + 4);
|
2009-04-28 02:33:50 -05:00
|
|
|
LOG_DEBUG("Skipping WFI");
|
2008-10-08 15:16:51 -05:00
|
|
|
}
|
|
|
|
/* ignore B to self */
|
|
|
|
else if ((next_instruction & 0xFEFFFFFF) == 0xeafffffe)
|
|
|
|
{
|
2009-04-28 02:33:50 -05:00
|
|
|
LOG_DEBUG("Not stepping jump to self");
|
2008-10-08 15:16:51 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-04-22 13:39:59 -05:00
|
|
|
/** \todo TODO: check if break-/watchpoints make any sense at all in combination
|
|
|
|
* with this. */
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-04-22 13:39:59 -05:00
|
|
|
/** \todo TODO: check if disabling IRQs might be a good idea here. Alternatively
|
|
|
|
* the VCR might be something worth looking into. */
|
2008-02-25 11:48:04 -06:00
|
|
|
|
|
|
|
|
2009-04-22 13:39:59 -05:00
|
|
|
/* Set up breakpoint for stepping */
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-11-13 10:39:54 -06:00
|
|
|
struct arm11_sc7_action brp[2];
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-04-22 13:39:59 -05:00
|
|
|
brp[0].write = 1;
|
|
|
|
brp[0].address = ARM11_SC7_BVR0;
|
|
|
|
brp[1].write = 1;
|
|
|
|
brp[1].address = ARM11_SC7_BCR0;
|
2009-08-27 05:37:01 -05:00
|
|
|
|
|
|
|
if (arm11_config_hardware_step)
|
|
|
|
{
|
2009-11-24 03:27:21 -06:00
|
|
|
/* Hardware single stepping ("instruction address
|
|
|
|
* mismatch") is used if enabled. It's not quite
|
|
|
|
* exactly "run one instruction"; "branch to here"
|
|
|
|
* loops won't break, neither will some other cases,
|
|
|
|
* but it's probably the best default.
|
|
|
|
*
|
|
|
|
* Hardware single stepping isn't supported on v6
|
|
|
|
* debug modules. ARM1176 and v7 can support it...
|
|
|
|
*
|
|
|
|
* FIXME Thumb stepping likely needs to use 0x03
|
|
|
|
* or 0xc0 byte masks, not 0x0f.
|
2009-08-27 05:37:01 -05:00
|
|
|
*/
|
2009-11-24 03:27:29 -06:00
|
|
|
brp[0].value = address;
|
2009-11-24 03:27:21 -06:00
|
|
|
brp[1].value = 0x1 | (3 << 1) | (0x0F << 5)
|
|
|
|
| (0 << 14) | (0 << 16) | (0 << 20)
|
|
|
|
| (2 << 21);
|
2009-08-27 05:37:01 -05:00
|
|
|
} else
|
|
|
|
{
|
2009-11-24 03:27:21 -06:00
|
|
|
/* Sets a breakpoint on the next PC, as calculated
|
|
|
|
* by instruction set simulation.
|
|
|
|
*
|
|
|
|
* REVISIT stepping Thumb on ARM1156 requires Thumb2
|
|
|
|
* support from the simulator.
|
2009-08-27 05:37:01 -05:00
|
|
|
*/
|
|
|
|
uint32_t next_pc;
|
|
|
|
int retval;
|
2009-11-24 03:27:21 -06:00
|
|
|
|
|
|
|
retval = arm_simulate_step(target, &next_pc);
|
2009-08-27 05:37:01 -05:00
|
|
|
if (retval != ERROR_OK)
|
|
|
|
return retval;
|
2009-09-21 13:40:55 -05:00
|
|
|
|
2009-08-27 05:37:01 -05:00
|
|
|
brp[0].value = next_pc;
|
2009-11-24 03:27:21 -06:00
|
|
|
brp[1].value = 0x1 | (3 << 1) | (0x0F << 5)
|
|
|
|
| (0 << 14) | (0 << 16) | (0 << 20)
|
|
|
|
| (0 << 21);
|
2009-08-27 05:37:01 -05:00
|
|
|
}
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-11-16 05:29:30 -06:00
|
|
|
CHECK_RETVAL(arm11_sc7_run(arm11, brp, ARRAY_SIZE(brp)));
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-04-22 13:39:59 -05:00
|
|
|
/* resume */
|
2008-02-25 11:48:04 -06:00
|
|
|
|
|
|
|
|
2009-04-22 13:39:59 -05:00
|
|
|
if (arm11_config_step_irq_enable)
|
2009-12-03 00:57:08 -06:00
|
|
|
/* this disable should be redundant ... */
|
2009-12-03 18:08:04 -06:00
|
|
|
arm11->dscr &= ~DSCR_INT_DIS;
|
2009-04-22 13:39:59 -05:00
|
|
|
else
|
2009-12-03 18:08:04 -06:00
|
|
|
arm11->dscr |= DSCR_INT_DIS;
|
2009-04-27 06:24:01 -05:00
|
|
|
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-12-01 23:47:45 -06:00
|
|
|
CHECK_RETVAL(arm11_leave_debug_state(arm11, handle_breakpoints));
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-04-22 13:39:59 -05:00
|
|
|
arm11_add_IR(arm11, ARM11_RESTART, TAP_IDLE);
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-04-28 02:29:18 -05:00
|
|
|
CHECK_RETVAL(jtag_execute_queue());
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-04-22 13:39:59 -05:00
|
|
|
/* wait for halt */
|
2009-10-07 07:05:37 -05:00
|
|
|
int i = 0;
|
2009-12-03 00:57:07 -06:00
|
|
|
|
2009-04-22 13:39:59 -05:00
|
|
|
while (1)
|
|
|
|
{
|
2009-12-03 18:08:04 -06:00
|
|
|
const uint32_t mask = DSCR_CORE_RESTARTED
|
|
|
|
| DSCR_CORE_HALTED;
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-12-03 00:57:08 -06:00
|
|
|
CHECK_RETVAL(arm11_read_DSCR(arm11));
|
|
|
|
LOG_DEBUG("DSCR %08x e", (unsigned) arm11->dscr);
|
2009-04-22 13:39:59 -05:00
|
|
|
|
2009-12-03 00:57:08 -06:00
|
|
|
if ((arm11->dscr & mask) == mask)
|
2009-04-22 13:39:59 -05:00
|
|
|
break;
|
2009-10-07 07:05:37 -05:00
|
|
|
|
|
|
|
long long then = 0;
|
|
|
|
if (i == 1000)
|
|
|
|
{
|
|
|
|
then = timeval_ms();
|
|
|
|
}
|
|
|
|
if (i >= 1000)
|
|
|
|
{
|
|
|
|
if ((timeval_ms()-then) > 1000)
|
|
|
|
{
|
|
|
|
LOG_WARNING("Timeout (1000ms) waiting for instructions to complete");
|
|
|
|
return ERROR_FAIL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
i++;
|
2009-04-22 13:39:59 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/* clear breakpoint */
|
|
|
|
arm11_sc7_clear_vbw(arm11);
|
|
|
|
|
|
|
|
/* save state */
|
2009-12-03 00:57:08 -06:00
|
|
|
CHECK_RETVAL(arm11_debug_entry(arm11));
|
2009-04-22 13:39:59 -05:00
|
|
|
|
2009-12-03 00:57:08 -06:00
|
|
|
/* restore default state */
|
2009-12-03 18:08:04 -06:00
|
|
|
arm11->dscr &= ~DSCR_INT_DIS;
|
2008-02-29 01:03:28 -06:00
|
|
|
|
2008-10-08 15:16:51 -05:00
|
|
|
}
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-12-03 18:08:04 -06:00
|
|
|
target->debug_reason = DBG_REASON_SINGLESTEP;
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-04-28 02:29:18 -05:00
|
|
|
CHECK_RETVAL(target_call_event_callbacks(target, TARGET_EVENT_HALTED));
|
2008-02-29 01:03:28 -06:00
|
|
|
|
2008-10-08 15:16:51 -05:00
|
|
|
return ERROR_OK;
|
2008-02-25 11:48:04 -06:00
|
|
|
}
|
|
|
|
|
2009-11-13 12:11:13 -06:00
|
|
|
static int arm11_assert_reset(struct target *target)
|
2008-02-25 11:48:04 -06:00
|
|
|
{
|
2009-10-14 04:14:04 -05:00
|
|
|
int retval;
|
2009-11-13 18:22:36 -06:00
|
|
|
struct arm11_common *arm11 = target_to_arm11(target);
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-12-03 00:57:08 -06:00
|
|
|
retval = arm11_check_init(arm11);
|
2009-10-14 04:14:04 -05:00
|
|
|
if (retval != ERROR_OK)
|
|
|
|
return retval;
|
|
|
|
|
|
|
|
target->state = TARGET_UNKNOWN;
|
|
|
|
|
|
|
|
/* we would very much like to reset into the halted, state,
|
|
|
|
* but resetting and halting is second best... */
|
2008-10-08 15:16:51 -05:00
|
|
|
if (target->reset_halt)
|
|
|
|
{
|
2009-04-28 02:29:18 -05:00
|
|
|
CHECK_RETVAL(target_halt(target));
|
2008-10-08 15:16:51 -05:00
|
|
|
}
|
2008-08-05 02:11:12 -05:00
|
|
|
|
2009-10-14 04:14:04 -05:00
|
|
|
|
|
|
|
/* srst is funny. We can not do *anything* else while it's asserted
|
|
|
|
* and it has unkonwn side effects. Make sure no other code runs
|
|
|
|
* meanwhile.
|
|
|
|
*
|
|
|
|
* Code below assumes srst:
|
|
|
|
*
|
|
|
|
* - Causes power-on-reset (but of what parts of the system?). Bug
|
|
|
|
* in arm11?
|
|
|
|
*
|
|
|
|
* - Messes us TAP state without asserting trst.
|
|
|
|
*
|
|
|
|
* - There is another bug in the arm11 core. When you generate an access to
|
|
|
|
* external logic (for example ddr controller via AHB bus) and that block
|
|
|
|
* is not configured (perhaps it is still held in reset), that transaction
|
|
|
|
* will never complete. This will hang arm11 core but it will also hang
|
|
|
|
* JTAG controller. Nothing, short of srst assertion will bring it out of
|
|
|
|
* this.
|
|
|
|
*
|
|
|
|
* Mysteries:
|
|
|
|
*
|
|
|
|
* - What should the PC be after an srst reset when starting in the halted
|
|
|
|
* state?
|
|
|
|
*/
|
|
|
|
|
|
|
|
jtag_add_reset(0, 1);
|
|
|
|
jtag_add_reset(0, 0);
|
|
|
|
|
|
|
|
/* How long do we have to wait? */
|
|
|
|
jtag_add_sleep(5000);
|
|
|
|
|
|
|
|
/* un-mess up TAP state */
|
|
|
|
jtag_add_tlr();
|
|
|
|
|
|
|
|
retval = jtag_execute_queue();
|
|
|
|
if (retval != ERROR_OK)
|
|
|
|
{
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2008-10-08 15:16:51 -05:00
|
|
|
return ERROR_OK;
|
2008-02-25 11:48:04 -06:00
|
|
|
}
|
|
|
|
|
2009-11-13 12:11:13 -06:00
|
|
|
static int arm11_deassert_reset(struct target *target)
|
2008-02-25 11:48:04 -06:00
|
|
|
{
|
2008-10-08 15:16:51 -05:00
|
|
|
return ERROR_OK;
|
2008-02-25 11:48:04 -06:00
|
|
|
}
|
|
|
|
|
2009-11-13 12:11:13 -06:00
|
|
|
static int arm11_soft_reset_halt(struct target *target)
|
2008-02-25 11:48:04 -06:00
|
|
|
{
|
2009-11-22 17:50:24 -06:00
|
|
|
LOG_WARNING("Not implemented: %s", __func__);
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-11-22 17:50:24 -06:00
|
|
|
return ERROR_FAIL;
|
2008-02-25 11:48:04 -06:00
|
|
|
}
|
|
|
|
|
2008-10-07 06:08:57 -05:00
|
|
|
/* target memory access
|
2009-04-22 13:39:59 -05:00
|
|
|
* size: 1 = byte (8bit), 2 = half-word (16bit), 4 = word (32bit)
|
|
|
|
* count: number of items of <size>
|
2009-10-12 07:21:38 -05:00
|
|
|
*
|
|
|
|
* arm11_config_memrw_no_increment - in the future we may want to be able
|
|
|
|
* to read/write a range of data to a "port". a "port" is an action on
|
|
|
|
* read memory address for some peripheral.
|
2009-04-22 13:39:59 -05:00
|
|
|
*/
|
2009-11-13 12:11:13 -06:00
|
|
|
static int arm11_read_memory_inner(struct target *target,
|
2009-11-06 05:36:46 -06:00
|
|
|
uint32_t address, uint32_t size, uint32_t count, uint8_t *buffer,
|
2009-10-12 07:21:38 -05:00
|
|
|
bool arm11_config_memrw_no_increment)
|
2008-02-25 11:48:04 -06:00
|
|
|
{
|
2009-06-18 02:08:52 -05:00
|
|
|
/** \todo TODO: check if buffer cast to uint32_t* and uint16_t* might cause alignment problems */
|
2009-10-09 03:00:05 -05:00
|
|
|
int retval;
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2008-10-08 15:16:51 -05:00
|
|
|
if (target->state != TARGET_HALTED)
|
|
|
|
{
|
2009-04-22 13:39:59 -05:00
|
|
|
LOG_WARNING("target was not halted");
|
|
|
|
return ERROR_TARGET_NOT_HALTED;
|
2008-10-08 15:16:51 -05:00
|
|
|
}
|
2008-03-08 11:28:28 -06:00
|
|
|
|
2009-06-20 22:14:58 -05:00
|
|
|
LOG_DEBUG("ADDR %08" PRIx32 " SIZE %08" PRIx32 " COUNT %08" PRIx32 "", address, size, count);
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-11-13 18:22:36 -06:00
|
|
|
struct arm11_common *arm11 = target_to_arm11(target);
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-10-09 03:00:05 -05:00
|
|
|
retval = arm11_run_instr_data_prepare(arm11);
|
|
|
|
if (retval != ERROR_OK)
|
|
|
|
return retval;
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2008-10-08 15:16:51 -05:00
|
|
|
/* MRC p14,0,r0,c0,c5,0 */
|
2009-10-09 03:00:05 -05:00
|
|
|
retval = arm11_run_instr_data_to_core1(arm11, 0xee100e15, address);
|
|
|
|
if (retval != ERROR_OK)
|
|
|
|
return retval;
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2008-10-08 15:16:51 -05:00
|
|
|
switch (size)
|
|
|
|
{
|
|
|
|
case 1:
|
2009-11-24 03:27:29 -06:00
|
|
|
arm11->arm.core_cache->reg_list[1].dirty = true;
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-05-09 02:36:19 -05:00
|
|
|
for (size_t i = 0; i < count; i++)
|
2009-04-22 13:39:59 -05:00
|
|
|
{
|
|
|
|
/* ldrb r1, [r0], #1 */
|
|
|
|
/* ldrb r1, [r0] */
|
|
|
|
arm11_run_instr_no_data1(arm11,
|
|
|
|
!arm11_config_memrw_no_increment ? 0xe4d01001 : 0xe5d01000);
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-06-18 02:08:52 -05:00
|
|
|
uint32_t res;
|
2009-04-22 13:39:59 -05:00
|
|
|
/* MCR p14,0,R1,c0,c5,0 */
|
|
|
|
arm11_run_instr_data_from_core(arm11, 0xEE001E15, &res, 1);
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-04-22 13:39:59 -05:00
|
|
|
*buffer++ = res;
|
2009-05-09 02:36:19 -05:00
|
|
|
}
|
2008-03-04 00:46:44 -06:00
|
|
|
|
2009-04-22 13:39:59 -05:00
|
|
|
break;
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2008-10-08 15:16:51 -05:00
|
|
|
case 2:
|
2009-04-22 13:39:59 -05:00
|
|
|
{
|
2009-11-24 03:27:29 -06:00
|
|
|
arm11->arm.core_cache->reg_list[1].dirty = true;
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-05-09 02:36:19 -05:00
|
|
|
for (size_t i = 0; i < count; i++)
|
2009-04-22 13:39:59 -05:00
|
|
|
{
|
|
|
|
/* ldrh r1, [r0], #2 */
|
|
|
|
arm11_run_instr_no_data1(arm11,
|
|
|
|
!arm11_config_memrw_no_increment ? 0xe0d010b2 : 0xe1d010b0);
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-06-18 02:08:52 -05:00
|
|
|
uint32_t res;
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-04-22 13:39:59 -05:00
|
|
|
/* MCR p14,0,R1,c0,c5,0 */
|
|
|
|
arm11_run_instr_data_from_core(arm11, 0xEE001E15, &res, 1);
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-06-18 02:07:59 -05:00
|
|
|
uint16_t svalue = res;
|
2009-08-06 14:52:56 -05:00
|
|
|
memcpy(buffer + i * sizeof(uint16_t), &svalue, sizeof(uint16_t));
|
2009-05-06 20:26:56 -05:00
|
|
|
}
|
2008-03-04 00:46:44 -06:00
|
|
|
|
2009-04-22 13:39:59 -05:00
|
|
|
break;
|
|
|
|
}
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2008-10-08 15:16:51 -05:00
|
|
|
case 4:
|
2009-05-06 20:26:56 -05:00
|
|
|
{
|
2009-06-18 02:08:52 -05:00
|
|
|
uint32_t instr = !arm11_config_memrw_no_increment ? 0xecb05e01 : 0xed905e00;
|
|
|
|
/** \todo TODO: buffer cast to uint32_t* causes alignment warnings */
|
|
|
|
uint32_t *words = (uint32_t *)buffer;
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-04-22 13:39:59 -05:00
|
|
|
/* LDC p14,c5,[R0],#4 */
|
|
|
|
/* LDC p14,c5,[R0] */
|
2009-05-06 20:26:56 -05:00
|
|
|
arm11_run_instr_data_from_core(arm11, instr, words, count);
|
2009-04-22 13:39:59 -05:00
|
|
|
break;
|
2009-05-06 20:26:56 -05:00
|
|
|
}
|
2008-10-08 15:16:51 -05:00
|
|
|
}
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-10-09 03:00:05 -05:00
|
|
|
return arm11_run_instr_data_finish(arm11);
|
2008-02-25 11:48:04 -06:00
|
|
|
}
|
|
|
|
|
2009-11-13 12:11:13 -06:00
|
|
|
static int arm11_read_memory(struct target *target, uint32_t address, uint32_t size, uint32_t count, uint8_t *buffer)
|
2009-10-12 07:21:38 -05:00
|
|
|
{
|
|
|
|
return arm11_read_memory_inner(target, address, size, count, buffer, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2009-11-27 20:40:37 -06:00
|
|
|
* no_increment - in the future we may want to be able
|
2009-10-12 07:21:38 -05:00
|
|
|
* to read/write a range of data to a "port". a "port" is an action on
|
|
|
|
* read memory address for some peripheral.
|
|
|
|
*/
|
2009-11-13 12:11:13 -06:00
|
|
|
static int arm11_write_memory_inner(struct target *target,
|
2009-11-27 20:40:37 -06:00
|
|
|
uint32_t address, uint32_t size,
|
|
|
|
uint32_t count, uint8_t *buffer,
|
|
|
|
bool no_increment)
|
2008-02-25 11:48:04 -06:00
|
|
|
{
|
2009-10-09 03:00:05 -05:00
|
|
|
int retval;
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2008-10-08 15:16:51 -05:00
|
|
|
if (target->state != TARGET_HALTED)
|
|
|
|
{
|
2009-04-22 13:39:59 -05:00
|
|
|
LOG_WARNING("target was not halted");
|
|
|
|
return ERROR_TARGET_NOT_HALTED;
|
2008-10-08 15:16:51 -05:00
|
|
|
}
|
2008-03-08 11:28:28 -06:00
|
|
|
|
2009-06-20 22:14:58 -05:00
|
|
|
LOG_DEBUG("ADDR %08" PRIx32 " SIZE %08" PRIx32 " COUNT %08" PRIx32 "", address, size, count);
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-11-13 18:22:36 -06:00
|
|
|
struct arm11_common *arm11 = target_to_arm11(target);
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-10-12 08:25:00 -05:00
|
|
|
retval = arm11_run_instr_data_prepare(arm11);
|
|
|
|
if (retval != ERROR_OK)
|
|
|
|
return retval;
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2008-10-08 15:16:51 -05:00
|
|
|
/* MRC p14,0,r0,c0,c5,0 */
|
2009-10-09 03:00:05 -05:00
|
|
|
retval = arm11_run_instr_data_to_core1(arm11, 0xee100e15, address);
|
|
|
|
if (retval != ERROR_OK)
|
|
|
|
return retval;
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-10-12 08:13:44 -05:00
|
|
|
/* burst writes are not used for single words as those may well be
|
|
|
|
* reset init script writes.
|
|
|
|
*
|
|
|
|
* The other advantage is that as burst writes are default, we'll
|
|
|
|
* now exercise both burst and non-burst code paths with the
|
|
|
|
* default settings, increasing code coverage.
|
|
|
|
*/
|
|
|
|
bool burst = arm11_config_memwrite_burst && (count > 1);
|
|
|
|
|
2008-10-08 15:16:51 -05:00
|
|
|
switch (size)
|
|
|
|
{
|
|
|
|
case 1:
|
2009-04-22 13:39:59 -05:00
|
|
|
{
|
2009-11-24 03:27:29 -06:00
|
|
|
arm11->arm.core_cache->reg_list[1].dirty = true;
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-05-09 02:36:19 -05:00
|
|
|
for (size_t i = 0; i < count; i++)
|
2009-04-22 13:39:59 -05:00
|
|
|
{
|
|
|
|
/* MRC p14,0,r1,c0,c5,0 */
|
2009-10-09 03:00:05 -05:00
|
|
|
retval = arm11_run_instr_data_to_core1(arm11, 0xee101e15, *buffer++);
|
|
|
|
if (retval != ERROR_OK)
|
|
|
|
return retval;
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-04-22 13:39:59 -05:00
|
|
|
/* strb r1, [r0], #1 */
|
|
|
|
/* strb r1, [r0] */
|
2009-10-09 03:00:05 -05:00
|
|
|
retval = arm11_run_instr_no_data1(arm11,
|
2009-11-27 20:40:37 -06:00
|
|
|
!no_increment
|
|
|
|
? 0xe4c01001
|
|
|
|
: 0xe5c01000);
|
2009-10-09 03:00:05 -05:00
|
|
|
if (retval != ERROR_OK)
|
|
|
|
return retval;
|
2009-05-09 02:36:19 -05:00
|
|
|
}
|
2008-03-04 00:46:44 -06:00
|
|
|
|
2009-04-22 13:39:59 -05:00
|
|
|
break;
|
|
|
|
}
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2008-10-08 15:16:51 -05:00
|
|
|
case 2:
|
2009-04-22 13:39:59 -05:00
|
|
|
{
|
2009-11-24 03:27:29 -06:00
|
|
|
arm11->arm.core_cache->reg_list[1].dirty = true;
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-05-09 02:36:19 -05:00
|
|
|
for (size_t i = 0; i < count; i++)
|
2009-04-22 13:39:59 -05:00
|
|
|
{
|
2009-06-18 02:07:59 -05:00
|
|
|
uint16_t value;
|
2009-08-06 14:52:56 -05:00
|
|
|
memcpy(&value, buffer + i * sizeof(uint16_t), sizeof(uint16_t));
|
2009-05-06 20:26:56 -05:00
|
|
|
|
2009-04-22 13:39:59 -05:00
|
|
|
/* MRC p14,0,r1,c0,c5,0 */
|
2009-10-09 03:00:05 -05:00
|
|
|
retval = arm11_run_instr_data_to_core1(arm11, 0xee101e15, value);
|
|
|
|
if (retval != ERROR_OK)
|
|
|
|
return retval;
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-04-22 13:39:59 -05:00
|
|
|
/* strh r1, [r0], #2 */
|
|
|
|
/* strh r1, [r0] */
|
2009-10-09 03:00:05 -05:00
|
|
|
retval = arm11_run_instr_no_data1(arm11,
|
2009-11-27 20:40:37 -06:00
|
|
|
!no_increment
|
|
|
|
? 0xe0c010b2
|
|
|
|
: 0xe1c010b0);
|
2009-10-09 03:00:05 -05:00
|
|
|
if (retval != ERROR_OK)
|
|
|
|
return retval;
|
2009-05-06 20:26:56 -05:00
|
|
|
}
|
2008-03-04 00:46:44 -06:00
|
|
|
|
2009-04-22 13:39:59 -05:00
|
|
|
break;
|
|
|
|
}
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-05-06 20:26:56 -05:00
|
|
|
case 4: {
|
2009-11-27 20:40:37 -06:00
|
|
|
uint32_t instr = !no_increment ? 0xeca05e01 : 0xed805e00;
|
2009-05-06 20:26:56 -05:00
|
|
|
|
2009-06-18 02:08:52 -05:00
|
|
|
/** \todo TODO: buffer cast to uint32_t* causes alignment warnings */
|
|
|
|
uint32_t *words = (uint32_t*)buffer;
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-10-12 08:13:44 -05:00
|
|
|
if (!burst)
|
2009-04-22 13:39:59 -05:00
|
|
|
{
|
|
|
|
/* STC p14,c5,[R0],#4 */
|
|
|
|
/* STC p14,c5,[R0]*/
|
2009-10-09 03:00:05 -05:00
|
|
|
retval = arm11_run_instr_data_to_core(arm11, instr, words, count);
|
|
|
|
if (retval != ERROR_OK)
|
|
|
|
return retval;
|
2009-04-22 13:39:59 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* STC p14,c5,[R0],#4 */
|
|
|
|
/* STC p14,c5,[R0]*/
|
2009-10-09 03:00:05 -05:00
|
|
|
retval = arm11_run_instr_data_to_core_noack(arm11, instr, words, count);
|
|
|
|
if (retval != ERROR_OK)
|
|
|
|
return retval;
|
2009-04-22 13:39:59 -05:00
|
|
|
}
|
2008-02-29 01:03:28 -06:00
|
|
|
|
2009-04-22 13:39:59 -05:00
|
|
|
break;
|
2008-10-08 15:16:51 -05:00
|
|
|
}
|
2009-05-06 20:26:56 -05:00
|
|
|
}
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2008-10-08 15:16:51 -05:00
|
|
|
/* r0 verification */
|
2009-11-27 20:40:37 -06:00
|
|
|
if (!no_increment)
|
2008-10-08 15:16:51 -05:00
|
|
|
{
|
2009-06-18 02:08:52 -05:00
|
|
|
uint32_t r0;
|
2008-02-29 01:03:28 -06:00
|
|
|
|
2009-04-22 13:39:59 -05:00
|
|
|
/* MCR p14,0,R0,c0,c5,0 */
|
2009-10-09 03:00:05 -05:00
|
|
|
retval = arm11_run_instr_data_from_core(arm11, 0xEE000E15, &r0, 1);
|
|
|
|
if (retval != ERROR_OK)
|
|
|
|
return retval;
|
2008-02-29 01:03:28 -06:00
|
|
|
|
2009-04-22 13:39:59 -05:00
|
|
|
if (address + size * count != r0)
|
|
|
|
{
|
2009-10-10 13:32:39 -05:00
|
|
|
LOG_ERROR("Data transfer failed. Expected end "
|
|
|
|
"address 0x%08x, got 0x%08x",
|
|
|
|
(unsigned) (address + size * count),
|
|
|
|
(unsigned) r0);
|
2008-02-29 01:03:28 -06:00
|
|
|
|
2009-10-12 08:13:44 -05:00
|
|
|
if (burst)
|
2009-04-22 13:39:59 -05:00
|
|
|
LOG_ERROR("use 'arm11 memwrite burst disable' to disable fast burst mode");
|
2008-02-29 01:03:28 -06:00
|
|
|
|
2009-04-22 13:39:59 -05:00
|
|
|
if (arm11_config_memwrite_error_fatal)
|
|
|
|
return ERROR_FAIL;
|
|
|
|
}
|
2008-02-29 01:03:28 -06:00
|
|
|
}
|
|
|
|
|
2009-10-09 03:00:05 -05:00
|
|
|
return arm11_run_instr_data_finish(arm11);
|
2008-02-25 11:48:04 -06:00
|
|
|
}
|
|
|
|
|
2009-11-13 12:11:13 -06:00
|
|
|
static int arm11_write_memory(struct target *target,
|
2009-11-27 20:40:37 -06:00
|
|
|
uint32_t address, uint32_t size,
|
|
|
|
uint32_t count, uint8_t *buffer)
|
2009-10-12 07:21:38 -05:00
|
|
|
{
|
2009-11-27 20:40:37 -06:00
|
|
|
/* pointer increment matters only for multi-unit writes ...
|
|
|
|
* not e.g. to a "reset the chip" controller.
|
|
|
|
*/
|
|
|
|
return arm11_write_memory_inner(target, address, size,
|
|
|
|
count, buffer, count == 1);
|
2009-10-12 07:21:38 -05:00
|
|
|
}
|
2008-02-25 11:48:04 -06:00
|
|
|
|
|
|
|
/* write target memory in multiples of 4 byte, optimized for writing large quantities of data */
|
2009-11-13 12:11:13 -06:00
|
|
|
static int arm11_bulk_write_memory(struct target *target,
|
2009-11-06 05:36:46 -06:00
|
|
|
uint32_t address, uint32_t count, uint8_t *buffer)
|
2008-02-25 11:48:04 -06:00
|
|
|
{
|
2008-10-08 15:16:51 -05:00
|
|
|
if (target->state != TARGET_HALTED)
|
|
|
|
{
|
2009-04-22 13:39:59 -05:00
|
|
|
LOG_WARNING("target was not halted");
|
|
|
|
return ERROR_TARGET_NOT_HALTED;
|
2008-10-08 15:16:51 -05:00
|
|
|
}
|
2008-03-08 11:28:28 -06:00
|
|
|
|
2008-10-08 15:16:51 -05:00
|
|
|
return arm11_write_memory(target, address, 4, count, buffer);
|
2008-02-25 11:48:04 -06:00
|
|
|
}
|
|
|
|
|
2008-10-07 06:08:57 -05:00
|
|
|
/* target break-/watchpoint control
|
2008-02-25 11:48:04 -06:00
|
|
|
* rw: 0 = write, 1 = read, 2 = access
|
|
|
|
*/
|
2009-11-13 12:11:13 -06:00
|
|
|
static int arm11_add_breakpoint(struct target *target,
|
2009-11-13 11:15:32 -06:00
|
|
|
struct breakpoint *breakpoint)
|
2008-02-25 11:48:04 -06:00
|
|
|
{
|
2009-11-13 18:22:36 -06:00
|
|
|
struct arm11_common *arm11 = target_to_arm11(target);
|
2008-02-29 01:03:28 -06:00
|
|
|
|
|
|
|
#if 0
|
2008-10-08 15:16:51 -05:00
|
|
|
if (breakpoint->type == BKPT_SOFT)
|
|
|
|
{
|
2009-04-22 13:39:59 -05:00
|
|
|
LOG_INFO("sw breakpoint requested, but software breakpoints not enabled");
|
|
|
|
return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
|
2008-10-08 15:16:51 -05:00
|
|
|
}
|
2008-02-29 01:03:28 -06:00
|
|
|
#endif
|
|
|
|
|
2008-10-08 15:16:51 -05:00
|
|
|
if (!arm11->free_brps)
|
|
|
|
{
|
2009-04-28 02:33:50 -05:00
|
|
|
LOG_DEBUG("no breakpoint unit available for hardware breakpoint");
|
2009-04-22 13:39:59 -05:00
|
|
|
return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
|
2008-10-08 15:16:51 -05:00
|
|
|
}
|
2008-02-29 01:03:28 -06:00
|
|
|
|
2008-10-08 15:16:51 -05:00
|
|
|
if (breakpoint->length != 4)
|
|
|
|
{
|
2009-04-28 02:33:50 -05:00
|
|
|
LOG_DEBUG("only breakpoints of four bytes length supported");
|
2009-04-22 13:39:59 -05:00
|
|
|
return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
|
2008-10-08 15:16:51 -05:00
|
|
|
}
|
2008-02-29 01:03:28 -06:00
|
|
|
|
2008-10-08 15:16:51 -05:00
|
|
|
arm11->free_brps--;
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2008-10-08 15:16:51 -05:00
|
|
|
return ERROR_OK;
|
2008-02-25 11:48:04 -06:00
|
|
|
}
|
|
|
|
|
2009-11-13 12:11:13 -06:00
|
|
|
static int arm11_remove_breakpoint(struct target *target,
|
2009-11-13 11:15:32 -06:00
|
|
|
struct breakpoint *breakpoint)
|
2008-02-25 11:48:04 -06:00
|
|
|
{
|
2009-11-13 18:22:36 -06:00
|
|
|
struct arm11_common *arm11 = target_to_arm11(target);
|
2008-10-07 06:08:57 -05:00
|
|
|
|
2008-10-08 15:16:51 -05:00
|
|
|
arm11->free_brps++;
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2008-10-08 15:16:51 -05:00
|
|
|
return ERROR_OK;
|
2008-02-25 11:48:04 -06:00
|
|
|
}
|
|
|
|
|
2009-11-13 12:11:13 -06:00
|
|
|
static int arm11_target_create(struct target *target, Jim_Interp *interp)
|
2008-02-25 11:48:04 -06:00
|
|
|
{
|
2009-11-22 17:50:24 -06:00
|
|
|
struct arm11_common *arm11;
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-06-23 17:42:03 -05:00
|
|
|
if (target->tap == NULL)
|
2008-11-19 02:22:47 -06:00
|
|
|
return ERROR_FAIL;
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2008-11-30 16:25:43 -06:00
|
|
|
if (target->tap->ir_length != 5)
|
2008-10-08 15:16:51 -05:00
|
|
|
{
|
2008-11-30 16:25:43 -06:00
|
|
|
LOG_ERROR("'target arm11' expects IR LENGTH = 5");
|
2008-08-19 04:31:51 -05:00
|
|
|
return ERROR_COMMAND_SYNTAX_ERROR;
|
2008-10-08 15:16:51 -05:00
|
|
|
}
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-11-22 17:50:24 -06:00
|
|
|
arm11 = calloc(1, sizeof *arm11);
|
|
|
|
if (!arm11)
|
|
|
|
return ERROR_FAIL;
|
|
|
|
|
2009-11-13 18:22:36 -06:00
|
|
|
armv4_5_init_arch_info(target, &arm11->arm);
|
|
|
|
|
|
|
|
arm11->jtag_info.tap = target->tap;
|
|
|
|
arm11->jtag_info.scann_size = 5;
|
|
|
|
arm11->jtag_info.scann_instr = ARM11_SCAN_N;
|
2009-12-04 20:57:30 -06:00
|
|
|
arm11->jtag_info.cur_scan_chain = ~0; /* invalid/unknown */
|
2009-11-13 18:22:36 -06:00
|
|
|
arm11->jtag_info.intest_instr = ARM11_INTEST;
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2008-10-08 15:16:51 -05:00
|
|
|
return ERROR_OK;
|
2008-02-25 11:48:04 -06:00
|
|
|
}
|
|
|
|
|
2009-11-13 15:25:47 -06:00
|
|
|
static int arm11_init_target(struct command_context *cmd_ctx,
|
2009-11-13 12:11:13 -06:00
|
|
|
struct target *target)
|
2008-07-04 02:20:43 -05:00
|
|
|
{
|
|
|
|
/* Initialize anything we can set up without talking to the target */
|
2009-12-03 00:57:08 -06:00
|
|
|
return ERROR_OK;
|
2008-07-04 02:20:43 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/* talk to the target and set things up */
|
2009-11-13 12:11:13 -06:00
|
|
|
static int arm11_examine(struct target *target)
|
2008-02-25 11:48:04 -06:00
|
|
|
{
|
2009-10-13 05:06:55 -05:00
|
|
|
int retval;
|
2009-11-18 15:22:27 -06:00
|
|
|
char *type;
|
2009-11-13 18:22:36 -06:00
|
|
|
struct arm11_common *arm11 = target_to_arm11(target);
|
2009-11-22 17:51:16 -06:00
|
|
|
uint32_t didr, device_id;
|
|
|
|
uint8_t implementor;
|
2008-02-25 11:48:04 -06:00
|
|
|
|
ARM11: partial support for standard ARM register interfaces.
This provides "standard" ARM register support -- with twenty or
more shadow registers on top of what this code now handles, but
properly associated with the various core modes -- parallel to
the current register code. That is, the current code is stilil
managing the "current" registers; the new code shadows them.
You can see all the registers with "arm reg", modify the shadows
like "r8_fiq" or "sp_abt" with "reg", and see them get properly
written back when you step. (Just don't do that with any of the
registers managed by the "old" code ...)
It also switches to using more standard code, relying on those
standard registers, in two places: (a) the poll status display,
which now shows core state (ARM/Thumb/...) and mode (Supervisor,
IRQ, etc); and (b) GDB register access.
So it's not a full migration, there are warts -- every place that
touches the old register cache is a potential bug -- but it's a
small more-or-less-comprehensible step that's even somewhat useful.
Later patches complete the migration.
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-24 03:27:16 -06:00
|
|
|
/* FIXME split into do-first-time and do-every-time logic ... */
|
|
|
|
|
2008-10-08 15:16:51 -05:00
|
|
|
/* check IDCODE */
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-04-22 13:39:59 -05:00
|
|
|
arm11_add_IR(arm11, ARM11_IDCODE, ARM11_TAP_DEFAULT);
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-11-13 05:28:03 -06:00
|
|
|
struct scan_field idcode_field;
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-11-22 17:51:16 -06:00
|
|
|
arm11_setup_field(arm11, 32, NULL, &device_id, &idcode_field);
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2008-12-13 00:25:50 -06:00
|
|
|
arm11_add_dr_scan_vc(1, &idcode_field, TAP_DRPAUSE);
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2008-10-08 15:16:51 -05:00
|
|
|
/* check DIDR */
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-04-22 13:39:59 -05:00
|
|
|
arm11_add_debug_SCAN_N(arm11, 0x00, ARM11_TAP_DEFAULT);
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-04-22 13:39:59 -05:00
|
|
|
arm11_add_IR(arm11, ARM11_INTEST, ARM11_TAP_DEFAULT);
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-11-13 05:28:03 -06:00
|
|
|
struct scan_field chain0_fields[2];
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-11-22 17:51:16 -06:00
|
|
|
arm11_setup_field(arm11, 32, NULL, &didr, chain0_fields + 0);
|
|
|
|
arm11_setup_field(arm11, 8, NULL, &implementor, chain0_fields + 1);
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-11-16 05:29:30 -06:00
|
|
|
arm11_add_dr_scan_vc(ARRAY_SIZE(chain0_fields), chain0_fields, TAP_IDLE);
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-04-28 02:29:18 -05:00
|
|
|
CHECK_RETVAL(jtag_execute_queue());
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-11-22 17:51:16 -06:00
|
|
|
switch (device_id & 0x0FFFF000)
|
2008-10-08 15:16:51 -05:00
|
|
|
{
|
2009-11-18 15:22:27 -06:00
|
|
|
case 0x07B36000:
|
|
|
|
type = "ARM1136";
|
|
|
|
break;
|
|
|
|
case 0x07B56000:
|
|
|
|
type = "ARM1156";
|
|
|
|
break;
|
|
|
|
case 0x07B76000:
|
|
|
|
arm11->arm.core_type = ARM_MODE_MON;
|
|
|
|
type = "ARM1176";
|
|
|
|
break;
|
2008-10-08 15:16:51 -05:00
|
|
|
default:
|
2008-08-19 04:31:51 -05:00
|
|
|
LOG_ERROR("'target arm11' expects IDCODE 0x*7B*7****");
|
|
|
|
return ERROR_FAIL;
|
2008-10-08 15:16:51 -05:00
|
|
|
}
|
2009-11-18 15:22:27 -06:00
|
|
|
LOG_INFO("found %s", type);
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-11-22 17:51:16 -06:00
|
|
|
/* unlikely this could ever fail, but ... */
|
|
|
|
switch ((didr >> 16) & 0x0F) {
|
|
|
|
case ARM11_DEBUG_V6:
|
|
|
|
case ARM11_DEBUG_V61: /* supports security extensions */
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
LOG_ERROR("Only ARM v6 and v6.1 debug supported.");
|
2009-04-22 13:39:59 -05:00
|
|
|
return ERROR_FAIL;
|
2008-10-08 15:16:51 -05:00
|
|
|
}
|
2008-02-29 01:03:28 -06:00
|
|
|
|
2009-11-22 17:51:16 -06:00
|
|
|
arm11->brp = ((didr >> 24) & 0x0F) + 1;
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2008-10-08 15:16:51 -05:00
|
|
|
/** \todo TODO: reserve one brp slot if we allow breakpoints during step */
|
|
|
|
arm11->free_brps = arm11->brp;
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-11-22 17:51:16 -06:00
|
|
|
LOG_DEBUG("IDCODE %08" PRIx32 " IMPLEMENTOR %02x DIDR %08" PRIx32,
|
|
|
|
device_id, implementor, didr);
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2008-10-08 15:16:51 -05:00
|
|
|
/* as a side-effect this reads DSCR and thus
|
|
|
|
* clears the ARM11_DSCR_STICKY_PRECISE_DATA_ABORT / Sticky Precise Data Abort Flag
|
|
|
|
* as suggested by the spec.
|
|
|
|
*/
|
2008-02-25 11:48:04 -06:00
|
|
|
|
2009-12-03 00:57:08 -06:00
|
|
|
retval = arm11_check_init(arm11);
|
2009-10-13 05:06:55 -05:00
|
|
|
if (retval != ERROR_OK)
|
|
|
|
return retval;
|
2008-02-25 11:48:04 -06:00
|
|
|
|
ARM11: partial support for standard ARM register interfaces.
This provides "standard" ARM register support -- with twenty or
more shadow registers on top of what this code now handles, but
properly associated with the various core modes -- parallel to
the current register code. That is, the current code is stilil
managing the "current" registers; the new code shadows them.
You can see all the registers with "arm reg", modify the shadows
like "r8_fiq" or "sp_abt" with "reg", and see them get properly
written back when you step. (Just don't do that with any of the
registers managed by the "old" code ...)
It also switches to using more standard code, relying on those
standard registers, in two places: (a) the poll status display,
which now shows core state (ARM/Thumb/...) and mode (Supervisor,
IRQ, etc); and (b) GDB register access.
So it's not a full migration, there are warts -- every place that
touches the old register cache is a potential bug -- but it's a
small more-or-less-comprehensible step that's even somewhat useful.
Later patches complete the migration.
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-24 03:27:16 -06:00
|
|
|
/* Build register cache "late", after target_init(), since we
|
|
|
|
* want to know if this core supports Secure Monitor mode.
|
|
|
|
*/
|
2009-12-03 00:57:07 -06:00
|
|
|
if (!target_was_examined(target))
|
|
|
|
retval = arm11_dpm_init(arm11, didr);
|
ARM11: partial support for standard ARM register interfaces.
This provides "standard" ARM register support -- with twenty or
more shadow registers on top of what this code now handles, but
properly associated with the various core modes -- parallel to
the current register code. That is, the current code is stilil
managing the "current" registers; the new code shadows them.
You can see all the registers with "arm reg", modify the shadows
like "r8_fiq" or "sp_abt" with "reg", and see them get properly
written back when you step. (Just don't do that with any of the
registers managed by the "old" code ...)
It also switches to using more standard code, relying on those
standard registers, in two places: (a) the poll status display,
which now shows core state (ARM/Thumb/...) and mode (Supervisor,
IRQ, etc); and (b) GDB register access.
So it's not a full migration, there are warts -- every place that
touches the old register cache is a potential bug -- but it's a
small more-or-less-comprehensible step that's even somewhat useful.
Later patches complete the migration.
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-24 03:27:16 -06:00
|
|
|
|
2009-11-13 18:58:14 -06:00
|
|
|
/* ETM on ARM11 still uses original scanchain 6 access mode */
|
|
|
|
if (arm11->arm.etm && !target_was_examined(target)) {
|
|
|
|
*register_get_last_cache_p(&target->reg_cache) =
|
|
|
|
etm_build_reg_cache(target, &arm11->jtag_info,
|
|
|
|
arm11->arm.etm);
|
|
|
|
retval = etm_setup(target);
|
|
|
|
}
|
|
|
|
|
2009-05-31 04:38:43 -05:00
|
|
|
target_set_examined(target);
|
2008-10-07 06:08:57 -05:00
|
|
|
|
2008-10-08 15:16:51 -05:00
|
|
|
return ERROR_OK;
|
2008-02-25 11:48:04 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-24 03:27:21 -06:00
|
|
|
/* FIXME all these BOOL_WRAPPER things should be modifying
|
|
|
|
* per-instance state, not shared state; ditto the vector
|
|
|
|
* catch register support. Scan chains with multiple cores
|
|
|
|
* should be able to say "work with this core like this,
|
|
|
|
* that core like that". Example, ARM11 MPCore ...
|
|
|
|
*/
|
|
|
|
|
2009-11-18 08:58:27 -06:00
|
|
|
#define ARM11_BOOL_WRAPPER(name, print_name) \
|
|
|
|
COMMAND_HANDLER(arm11_handle_bool_##name) \
|
|
|
|
{ \
|
|
|
|
return CALL_COMMAND_HANDLER(handle_command_parse_bool, \
|
|
|
|
&arm11_config_##name, print_name); \
|
|
|
|
}
|
2008-02-29 01:03:28 -06:00
|
|
|
|
2009-11-18 08:58:27 -06:00
|
|
|
ARM11_BOOL_WRAPPER(memwrite_burst, "memory write burst mode")
|
|
|
|
ARM11_BOOL_WRAPPER(memwrite_error_fatal, "fatal error mode for memory writes")
|
|
|
|
ARM11_BOOL_WRAPPER(step_irq_enable, "IRQs while stepping")
|
|
|
|
ARM11_BOOL_WRAPPER(hardware_step, "hardware single step")
|
2008-02-29 01:03:28 -06:00
|
|
|
|
2009-11-10 01:56:52 -06:00
|
|
|
COMMAND_HANDLER(arm11_handle_vcr)
|
2008-02-29 01:03:28 -06:00
|
|
|
{
|
2009-11-15 06:57:12 -06:00
|
|
|
switch (CMD_ARGC) {
|
2009-10-24 08:36:05 -05:00
|
|
|
case 0:
|
|
|
|
break;
|
|
|
|
case 1:
|
2009-11-15 10:15:59 -06:00
|
|
|
COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], arm11_vcr);
|
2009-11-06 02:16:39 -06:00
|
|
|
break;
|
2009-10-24 08:36:05 -05:00
|
|
|
default:
|
2009-04-22 13:39:59 -05:00
|
|
|
return ERROR_COMMAND_SYNTAX_ERROR;
|
2008-10-08 15:16:51 -05:00
|
|
|
}
|
2008-02-29 01:03:28 -06:00
|
|
|
|
2009-06-20 22:14:58 -05:00
|
|
|
LOG_INFO("VCR 0x%08" PRIx32 "", arm11_vcr);
|
2008-10-08 15:16:51 -05:00
|
|
|
return ERROR_OK;
|
2008-02-29 01:03:28 -06:00
|
|
|
}
|
|
|
|
|
2009-11-23 09:43:05 -06:00
|
|
|
static const struct command_registration arm11_mw_command_handlers[] = {
|
|
|
|
{
|
|
|
|
.name = "burst",
|
|
|
|
.handler = &arm11_handle_bool_memwrite_burst,
|
|
|
|
.mode = COMMAND_ANY,
|
|
|
|
.help = "Enable/Disable non-standard but fast burst mode"
|
|
|
|
" (default: enabled)",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "error_fatal",
|
|
|
|
.handler = &arm11_handle_bool_memwrite_error_fatal,
|
|
|
|
.mode = COMMAND_ANY,
|
|
|
|
.help = "Terminate program if transfer error was found"
|
|
|
|
" (default: enabled)",
|
|
|
|
},
|
|
|
|
COMMAND_REGISTRATION_DONE
|
|
|
|
};
|
|
|
|
static const struct command_registration arm11_any_command_handlers[] = {
|
|
|
|
{
|
|
|
|
/* "hardware_step" is only here to check if the default
|
|
|
|
* simulate + breakpoint implementation is broken.
|
|
|
|
* TEMPORARY! NOT DOCUMENTED! */
|
|
|
|
.name = "hardware_step",
|
|
|
|
.handler = &arm11_handle_bool_hardware_step,
|
|
|
|
.mode = COMMAND_ANY,
|
|
|
|
.help = "DEBUG ONLY - Hardware single stepping"
|
|
|
|
" (default: disabled)",
|
|
|
|
.usage = "(enable|disable)",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "memwrite",
|
|
|
|
.mode = COMMAND_ANY,
|
|
|
|
.help = "memwrite command group",
|
|
|
|
.chain = arm11_mw_command_handlers,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "step_irq_enable",
|
|
|
|
.handler = &arm11_handle_bool_step_irq_enable,
|
|
|
|
.mode = COMMAND_ANY,
|
|
|
|
.help = "Enable interrupts while stepping"
|
|
|
|
" (default: disabled)",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "vcr",
|
|
|
|
.handler = &arm11_handle_vcr,
|
|
|
|
.mode = COMMAND_ANY,
|
|
|
|
.help = "Control (Interrupt) Vector Catch Register",
|
|
|
|
},
|
|
|
|
COMMAND_REGISTRATION_DONE
|
|
|
|
};
|
|
|
|
static const struct command_registration arm11_command_handlers[] = {
|
2009-11-23 10:17:01 -06:00
|
|
|
{
|
|
|
|
.chain = arm_command_handlers,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.chain = etm_command_handlers,
|
|
|
|
},
|
2009-11-23 09:43:05 -06:00
|
|
|
{
|
|
|
|
.name = "arm11",
|
|
|
|
.mode = COMMAND_ANY,
|
|
|
|
.help = "ARM11 command group",
|
|
|
|
.chain = arm11_any_command_handlers,
|
|
|
|
},
|
|
|
|
COMMAND_REGISTRATION_DONE
|
|
|
|
};
|
|
|
|
|
2009-11-15 12:35:41 -06:00
|
|
|
/** Holds methods for ARM11xx targets. */
|
|
|
|
struct target_type arm11_target = {
|
|
|
|
.name = "arm11",
|
|
|
|
|
|
|
|
.poll = arm11_poll,
|
|
|
|
.arch_state = arm11_arch_state,
|
|
|
|
|
|
|
|
.target_request_data = arm11_target_request_data,
|
|
|
|
|
|
|
|
.halt = arm11_halt,
|
|
|
|
.resume = arm11_resume,
|
|
|
|
.step = arm11_step,
|
|
|
|
|
|
|
|
.assert_reset = arm11_assert_reset,
|
|
|
|
.deassert_reset = arm11_deassert_reset,
|
|
|
|
.soft_reset_halt = arm11_soft_reset_halt,
|
|
|
|
|
ARM11: partial support for standard ARM register interfaces.
This provides "standard" ARM register support -- with twenty or
more shadow registers on top of what this code now handles, but
properly associated with the various core modes -- parallel to
the current register code. That is, the current code is stilil
managing the "current" registers; the new code shadows them.
You can see all the registers with "arm reg", modify the shadows
like "r8_fiq" or "sp_abt" with "reg", and see them get properly
written back when you step. (Just don't do that with any of the
registers managed by the "old" code ...)
It also switches to using more standard code, relying on those
standard registers, in two places: (a) the poll status display,
which now shows core state (ARM/Thumb/...) and mode (Supervisor,
IRQ, etc); and (b) GDB register access.
So it's not a full migration, there are warts -- every place that
touches the old register cache is a potential bug -- but it's a
small more-or-less-comprehensible step that's even somewhat useful.
Later patches complete the migration.
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-24 03:27:16 -06:00
|
|
|
.get_gdb_reg_list = armv4_5_get_gdb_reg_list,
|
2009-11-15 12:35:41 -06:00
|
|
|
|
|
|
|
.read_memory = arm11_read_memory,
|
|
|
|
.write_memory = arm11_write_memory,
|
|
|
|
|
|
|
|
.bulk_write_memory = arm11_bulk_write_memory,
|
|
|
|
|
2009-11-15 12:35:47 -06:00
|
|
|
.checksum_memory = arm_checksum_memory,
|
|
|
|
.blank_check_memory = arm_blank_check_memory,
|
2009-11-15 12:35:41 -06:00
|
|
|
|
|
|
|
.add_breakpoint = arm11_add_breakpoint,
|
|
|
|
.remove_breakpoint = arm11_remove_breakpoint,
|
|
|
|
|
2009-11-24 03:27:24 -06:00
|
|
|
.run_algorithm = armv4_5_run_algorithm,
|
2009-11-15 12:35:41 -06:00
|
|
|
|
2009-11-23 10:17:01 -06:00
|
|
|
.commands = arm11_command_handlers,
|
2009-11-15 12:35:41 -06:00
|
|
|
.target_create = arm11_target_create,
|
|
|
|
.init_target = arm11_init_target,
|
|
|
|
.examine = arm11_examine,
|
|
|
|
};
|