xscale: always reload handler after reset
authorDavid Brownell <dbrownell@users.sourceforge.net>
Sun, 25 Oct 2009 20:06:47 +0000 (13:06 -0700)
committerDavid Brownell <dbrownell@users.sourceforge.net>
Sun, 25 Oct 2009 20:06:47 +0000 (13:06 -0700)
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).  Other XScale chips
   would have problems too; PXA270 seems to have, IXP425 maybe not.

 - "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.)

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
src/target/xscale.c
src/target/xscale.h

index 640eb01b6712531ff41f5851cf4c8b4077a112bb..ee9d88d6463f14b3aed92e74fe49ae6e4e13e8aa 100644 (file)
@@ -890,8 +890,6 @@ static int xscale_arch_state(struct target_s *target)
 static int xscale_poll(target_t *target)
 {
        int retval = ERROR_OK;
 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))
        {
 
        if ((target->state == TARGET_RUNNING) || (target->state == TARGET_DEBUG_RUNNING))
        {
@@ -900,8 +898,6 @@ static int xscale_poll(target_t *target)
                {
 
                        /* there's data to read from the tx register, we entered debug state */
                {
 
                        /* 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 */
                        target->state = TARGET_HALTED;
 
                        /* process debug entry, fetching current mode regs */
@@ -1365,8 +1361,6 @@ static int xscale_resume(struct target_s *target, int current,
 
        LOG_DEBUG("target resumed");
 
 
        LOG_DEBUG("target resumed");
 
-       xscale->handler_running = 1;
-
        return ERROR_OK;
 }
 
        return ERROR_OK;
 }
 
@@ -1574,7 +1568,17 @@ static int xscale_deassert_reset(target_t *target)
                breakpoint = breakpoint->next;
        }
 
                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;
        {
                uint32_t address;
                unsigned buf_cnt;
@@ -1599,10 +1603,6 @@ static int xscale_deassert_reset(target_t *target)
                 * it's using halt mode (not monitor mode), it runs in
                 * "Special Debug State" for access to registers, memory,
                 * coprocessors, trace data, etc.
                 * 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 = sizeof xscale_debug_handler - 1;
                 */
                address = xscale->handler_address;
                for (unsigned binary_size = sizeof xscale_debug_handler - 1;
@@ -1673,10 +1673,6 @@ static int xscale_deassert_reset(target_t *target)
                        xscale_resume(target, 1, 0x0, 1, 0);
                }
        }
                        xscale_resume(target, 1, 0x0, 1, 0);
                }
        }
-       else
-       {
-               jtag_add_reset(0, 0);
-       }
 
        return ERROR_OK;
 }
 
        return ERROR_OK;
 }
@@ -2967,8 +2963,6 @@ static int xscale_init_arch_info(target_t *target,
        }
 
        /* the debug handler isn't installed (and thus not running) at this time */
        }
 
        /* 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 */
        xscale->handler_address = 0xfe000800;
 
        /* clear the vectors we keep locally for reference */
index a5d83ee675c7a4aafe3385ac3ff1d08d1497e8d9..4b34cf88b72ebf5506a11a7ac39e145ba915c6e8 100644 (file)
@@ -86,8 +86,6 @@ typedef struct xscale_common_s
        reg_cache_t *reg_cache;
 
        /* current state of the debug handler */
        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 */
        uint32_t handler_address;
 
        /* target-endian buffers with exception vectors */

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)