stlink: update to use ERROR_COMMAND_SYNTAX_ERROR
[openocd.git] / src / target / xscale.c
index 32c656bba721d368c387ed4d0ab6575c12246608..46ed8a947ad16adc16b5a2585b39c6c40be6bc57 100644 (file)
@@ -250,7 +250,7 @@ static void xscale_getbuf(jtag_callback_data_t arg)
 static int xscale_receive(struct target *target, uint32_t *buffer, int num_words)
 {
        if (num_words == 0)
-               return ERROR_INVALID_ARGUMENTS;
+               return ERROR_COMMAND_SYNTAX_ERROR;
 
        struct xscale_common *xscale = target_to_xscale(target);
        int retval = ERROR_OK;
@@ -273,12 +273,16 @@ static int xscale_receive(struct target *target, uint32_t *buffer, int num_words
        memset(&fields, 0, sizeof fields);
 
        fields[0].num_bits = 3;
+       uint8_t tmp;
+       fields[0].in_value = &tmp;
        fields[0].check_value = &field0_check_value;
        fields[0].check_mask = &field0_check_mask;
 
        fields[1].num_bits = 32;
 
        fields[2].num_bits = 1;
+       uint8_t tmp2;
+       fields[2].in_value = &tmp2;
        fields[2].check_value = &field2_check_value;
        fields[2].check_mask = &field2_check_mask;
 
@@ -317,7 +321,7 @@ static int xscale_receive(struct target *target, uint32_t *buffer, int num_words
                /* examine results */
                for (i = words_done; i < num_words; i++)
                {
-                       if (!(field0[0] & 1))
+                       if (!(field0[i] & 1))
                        {
                                /* move backwards if necessary */
                                int j;
@@ -528,7 +532,7 @@ static int xscale_write_rx(struct target *target)
 }
 
 /* send count elements of size byte to the debug handler */
-static int xscale_send(struct target *target, uint8_t *buffer, int count, int size)
+static int xscale_send(struct target *target, const uint8_t *buffer, int count, int size)
 {
        struct xscale_common *xscale = target_to_xscale(target);
        uint32_t t[3];
@@ -573,7 +577,7 @@ static int xscale_send(struct target *target, uint8_t *buffer, int count, int si
                        break;
                default:
                        LOG_ERROR("BUG: size neither 4, 2 nor 1");
-                       return ERROR_INVALID_ARGUMENTS;
+                       return ERROR_COMMAND_SYNTAX_ERROR;
                }
                jtag_add_dr_out(target->tap,
                                3,
@@ -836,7 +840,7 @@ static int xscale_arch_state(struct target *target)
        if (armv4_5->common_magic != ARM_COMMON_MAGIC)
        {
                LOG_ERROR("BUG: called for a non-ARMv4/5 target");
-               return ERROR_INVALID_ARGUMENTS;
+               return ERROR_COMMAND_SYNTAX_ERROR;
        }
 
        arm_arch_state(target);
@@ -1180,7 +1184,6 @@ static int xscale_resume(struct target *target, int current,
 {
        struct xscale_common *xscale = target_to_xscale(target);
        struct arm *armv4_5 = &xscale->armv4_5_common;
-       struct breakpoint *breakpoint = target->breakpoints;
        uint32_t current_pc;
        int retval;
        int i;
@@ -1218,6 +1221,7 @@ static int xscale_resume(struct target *target, int current,
        /* the front-end may request us not to handle breakpoints */
        if (handle_breakpoints)
        {
+               struct breakpoint *breakpoint;
                breakpoint = breakpoint_find(target,
                                buf_get_u32(armv4_5->pc->value, 0, 32));
                if (breakpoint != NULL)
@@ -1242,6 +1246,8 @@ static int xscale_resume(struct target *target, int current,
 
                        /* restore banked registers */
                        retval = xscale_restore_banked(target);
+                       if (retval != ERROR_OK)
+                               return retval;
 
                        /* send resume request */
                        xscale_send_u32(target, 0x30);
@@ -1289,6 +1295,8 @@ static int xscale_resume(struct target *target, int current,
 
        /* restore banked registers */
        retval = xscale_restore_banked(target);
+       if (retval != ERROR_OK)
+               return retval;
 
        /* send resume request (command 0x30 or 0x31)
         * clean the trace buffer if it is to be enabled (0x62) */
@@ -1462,6 +1470,7 @@ static int xscale_step(struct target *target, int current,
                if ((retval = arm_simulate_step(target, NULL)) != ERROR_OK)
                        return retval;
                current_pc = buf_get_u32(armv4_5->pc->value, 0, 32);
+               LOG_DEBUG("current pc %" PRIx32, current_pc);
 
                target->debug_reason = DBG_REASON_SINGLESTEP;
                target_call_event_callbacks(target, TARGET_EVENT_HALTED);
@@ -1480,6 +1489,8 @@ static int xscale_step(struct target *target, int current,
        }
 
        retval = xscale_step_inner(target, current, address, handle_breakpoints);
+       if (retval != ERROR_OK)
+               return retval;
 
        if (breakpoint)
        {
@@ -1860,7 +1871,7 @@ static int xscale_read_memory(struct target *target, uint32_t address,
 
        /* sanitize arguments */
        if (((size != 4) && (size != 2) && (size != 1)) || (count == 0) || !(buffer))
-               return ERROR_INVALID_ARGUMENTS;
+               return ERROR_COMMAND_SYNTAX_ERROR;
 
        if (((size == 4) && (address & 0x3u)) || ((size == 2) && (address & 0x1u)))
                return ERROR_TARGET_UNALIGNED_ACCESS;
@@ -1900,7 +1911,7 @@ static int xscale_read_memory(struct target *target, uint32_t address,
                                break;
                        default:
                                LOG_ERROR("invalid read size");
-                               return ERROR_INVALID_ARGUMENTS;
+                               return ERROR_COMMAND_SYNTAX_ERROR;
                }
        }
 
@@ -1937,7 +1948,7 @@ static int xscale_read_phys_memory(struct target *target, uint32_t address,
 }
 
 static int xscale_write_memory(struct target *target, uint32_t address,
-               uint32_t size, uint32_t count, uint8_t *buffer)
+               uint32_t size, uint32_t count, const uint8_t *buffer)
 {
        struct xscale_common *xscale = target_to_xscale(target);
        int retval;
@@ -1952,7 +1963,7 @@ static int xscale_write_memory(struct target *target, uint32_t address,
 
        /* sanitize arguments */
        if (((size != 4) && (size != 2) && (size != 1)) || (count == 0) || !(buffer))
-               return ERROR_INVALID_ARGUMENTS;
+               return ERROR_COMMAND_SYNTAX_ERROR;
 
        if (((size == 4) && (address & 0x3u)) || ((size == 2) && (address & 0x1u)))
                return ERROR_TARGET_UNALIGNED_ACCESS;
@@ -2016,13 +2027,13 @@ static int xscale_write_memory(struct target *target, uint32_t address,
 }
 
 static int xscale_write_phys_memory(struct target *target, uint32_t address,
-               uint32_t size, uint32_t count, uint8_t *buffer)
+               uint32_t size, uint32_t count, const uint8_t *buffer)
 {
        struct xscale_common *xscale = target_to_xscale(target);
 
        /* with MMU inactive, there are only physical addresses */
        if (!xscale->armv4_5_mmu.mmu_enabled)
-               return xscale_read_memory(target, address, size, count, buffer);
+               return xscale_write_memory(target, address, size, count, buffer);
 
        /** \todo: provide a non-stub implementation of this routine. */
        LOG_ERROR("%s: %s is not implemented.  Disable MMU?",
@@ -2031,7 +2042,7 @@ static int xscale_write_phys_memory(struct target *target, uint32_t address,
 }
 
 static int xscale_bulk_write_memory(struct target *target, uint32_t address,
-               uint32_t count, uint8_t *buffer)
+               uint32_t count, const uint8_t *buffer)
 {
        return xscale_write_memory(target, address, 4, count, buffer);
 }
@@ -2753,7 +2764,7 @@ static int xscale_read_instruction(struct target *target, uint32_t pc,
                        pc - xscale->trace.image->sections[section].base_address,
                        4, buf, &size_read)) != ERROR_OK)
                {
-                       LOG_ERROR("error while reading instruction: %i", retval);
+                       LOG_ERROR("error while reading instruction");
                        return ERROR_TRACE_INSTRUCTION_UNAVAILABLE;
                }
                opcode = target_buffer_get_u32(target, buf);
@@ -2766,7 +2777,7 @@ static int xscale_read_instruction(struct target *target, uint32_t pc,
                        pc - xscale->trace.image->sections[section].base_address,
                        2, buf, &size_read)) != ERROR_OK)
                {
-                       LOG_ERROR("error while reading instruction: %i", retval);
+                       LOG_ERROR("error while reading instruction");
                        return ERROR_TRACE_INSTRUCTION_UNAVAILABLE;
                }
                opcode = target_buffer_get_u16(target, buf);
@@ -3502,7 +3513,7 @@ COMMAND_HANDLER(xscale_handle_trace_buffer_command)
           else if (strcmp("disable", CMD_ARGV[0]) == 0)
                  xscale->trace.mode = XSCALE_TRACE_DISABLED;
           else
-                 return ERROR_INVALID_ARGUMENTS;
+                 return ERROR_COMMAND_SYNTAX_ERROR;
        }
 
        if (CMD_ARGC >= 2 && xscale->trace.mode != XSCALE_TRACE_DISABLED)
@@ -3516,7 +3527,7 @@ COMMAND_HANDLER(xscale_handle_trace_buffer_command)
                  {
                         command_print(CMD_CTX, "fill buffer count must be > 0");
                         xscale->trace.mode = XSCALE_TRACE_DISABLED;
-                        return ERROR_INVALID_ARGUMENTS;
+                        return ERROR_COMMAND_SYNTAX_ERROR;
                  }
                  xscale->trace.buffer_fill = buffcount;
                  xscale->trace.mode = XSCALE_TRACE_FILL;
@@ -3526,7 +3537,7 @@ COMMAND_HANDLER(xscale_handle_trace_buffer_command)
           else
           {
                  xscale->trace.mode = XSCALE_TRACE_DISABLED;
-                 return ERROR_INVALID_ARGUMENTS;
+                 return ERROR_COMMAND_SYNTAX_ERROR;
           }
        }
        
@@ -3719,7 +3730,7 @@ COMMAND_HANDLER(xscale_handle_cp15)
                        break;
                default:
                        command_print(CMD_CTX, "invalid register number");
-                       return ERROR_INVALID_ARGUMENTS;
+                       return ERROR_COMMAND_SYNTAX_ERROR;
                }
                reg = &xscale->reg_cache->reg_list[reg_no];
 

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)