FLASH/NOR: Remove useless file stellaris.h
[openocd.git] / src / target / arm_semihosting.c
index 2f50a4a6591a2e6c8d55214a63752eec10e3f415..a247cc88839a4671f7e8bf0eb0d3b6273eed83af 100644 (file)
@@ -68,16 +68,9 @@ static int do_semihosting(struct target *target)
        struct arm *arm = target_to_arm(target);
        uint32_t r0 = buf_get_u32(arm->core_cache->reg_list[0].value, 0, 32);
        uint32_t r1 = buf_get_u32(arm->core_cache->reg_list[1].value, 0, 32);
-       uint32_t lr, spsr;
        uint8_t params[16];
        int retval, result;
 
-       if (is_arm7_9(target_to_arm7_9(target)))
-       {
-               lr = buf_get_u32(ARMV4_5_CORE_REG_MODE(arm->core_cache, ARM_MODE_SVC, 14).value, 0, 32);
-               spsr = buf_get_u32(arm->spsr->value, 0, 32);;
-       }
-
        /*
         * TODO: lots of security issues are not considered yet, such as:
         * - no validation on target provided file descriptors
@@ -396,22 +389,35 @@ static int do_semihosting(struct target *target)
 
        /* resume execution to the original mode */
 
+       /* REVISIT this looks wrong ... ARM11 and Cortex-A8
+        * should work this way at least sometimes.
+        */
        if (is_arm7_9(target_to_arm7_9(target)))
        {
+               uint32_t spsr;
+
                /* return value in R0 */
                buf_set_u32(arm->core_cache->reg_list[0].value, 0, 32, result);
                arm->core_cache->reg_list[0].dirty = 1;
 
                /* LR --> PC */
-               buf_set_u32(arm->core_cache->reg_list[15].value, 0, 32, lr);
+               buf_set_u32(arm->core_cache->reg_list[15].value, 0, 32,
+                       buf_get_u32(arm_reg_current(arm,14)->value, 0, 32));
                arm->core_cache->reg_list[15].dirty = 1;
 
                /* saved PSR --> current PSR */
+               spsr = buf_get_u32(arm->spsr->value, 0, 32);
+
+               /* REVISIT should this be arm_set_cpsr(arm, spsr)
+                * instead of a partially unrolled version?
+                */
+
                buf_set_u32(arm->cpsr->value, 0, 32, spsr);
                arm->cpsr->dirty = 1;
                arm->core_mode = spsr & 0x1f;
                if (spsr & 0x20)
                        arm->core_state = ARM_STATE_THUMB;
+
        }
        else
        {

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)