Remove needless debug handler state.

 - "handler_installed" became wrong as soon as the second TRST+SRST
   reset was issued ... so the handler was never reloaded after the
   reset removed it from the mini-icache.
   
   This fixes the bug where subsequent resets fail on PXA255 (if the
   first one even worked, which is uncommon).  I suspect other XScale
   chips should have had problems too...

 - "handler_running" was never tested; it's pointless.
  
Plus a related bugfix: invalidate OpenOCD's ARM register cache on reset.
It was no more valid than the XScale's mini-icache.  (Though ... such
invalidations might be better done in "SRST asserted" callbacks.)
---
Against current GIT tree.  I've cc'd the folk I know use xscales
with OpenOCD ... pxa270 and ixp425, which are second gen parts that
may be looser in how they handle the mini-icache, and certainly seem
to have differences in reset handling.

 src/target/xscale.c |   28 +++++++++++-----------------
 src/target/xscale.h |    2 --
 2 files changed, 11 insertions(+), 19 deletions(-)

--- a/src/target/xscale.c
+++ b/src/target/xscale.c
@@ -879,8 +879,6 @@ static int xscale_arch_state(struct targ
 static int xscale_poll(target_t *target)
 {
        int retval = ERROR_OK;
-       armv4_5_common_t *armv4_5 = target->arch_info;
-       xscale_common_t *xscale = armv4_5->arch_info;
 
        if ((target->state == TARGET_RUNNING) || (target->state == 
TARGET_DEBUG_RUNNING))
        {
@@ -889,8 +887,6 @@ static int xscale_poll(target_t *target)
                {
 
                        /* there's data to read from the tx register, we 
entered debug state */
-                       xscale->handler_running = 1;
-
                        target->state = TARGET_HALTED;
 
                        /* process debug entry, fetching current mode regs */
@@ -1354,8 +1350,6 @@ static int xscale_resume(struct target_s
 
        LOG_DEBUG("target resumed");
 
-       xscale->handler_running = 1;
-
        return ERROR_OK;
 }
 
@@ -1563,7 +1557,17 @@ static int xscale_deassert_reset(target_
                breakpoint = breakpoint->next;
        }
 
-       if (!xscale->handler_installed)
+       armv4_5_invalidate_core_regs(target);
+
+       /* FIXME mark hardware watchpoints got unset too.  Also,
+        * at least some of the XScale registers are invalid...
+        */
+
+       /*
+        * REVISIT:  *assumes* we had a SRST+TRST reset so the mini-icache
+        * contents got invalidated.  Safer to force that, so writing new
+        * contents can't ever fail..
+        */
        {
                uint32_t address;
                unsigned buf_cnt;
@@ -1588,10 +1592,6 @@ static int xscale_deassert_reset(target_
                 * it's using halt mode (not monitor mode), it runs in
                 * "Special Debug State" for access to registers, memory,
                 * coprocessors, trace data, etc.
-                *
-                * REVISIT:  *assumes* we've had a SRST+TRST reset so the
-                * mini-icache contents have been invalidated.  Safest to
-                * force that, so writing new contents is reliable...
                 */
                address = xscale->handler_address;
                for (unsigned binary_size = xscale_debug_handler_size;
@@ -1662,10 +1662,6 @@ static int xscale_deassert_reset(target_
                        xscale_resume(target, 1, 0x0, 1, 0);
                }
        }
-       else
-       {
-               jtag_add_reset(0, 0);
-       }
 
        return ERROR_OK;
 }
@@ -2956,8 +2952,6 @@ static int xscale_init_arch_info(target_
        }
 
        /* the debug handler isn't installed (and thus not running) at this 
time */
-       xscale->handler_installed = 0;
-       xscale->handler_running = 0;
        xscale->handler_address = 0xfe000800;
 
        /* clear the vectors we keep locally for reference */
--- a/src/target/xscale.h
+++ b/src/target/xscale.h
@@ -86,8 +86,6 @@ typedef struct xscale_common_s
        reg_cache_t *reg_cache;
 
        /* current state of the debug handler */
-       int handler_installed;
-       int handler_running;
        uint32_t handler_address;
 
        /* target-endian buffers with exception vectors */
_______________________________________________
Openocd-development mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/openocd-development

Reply via email to