warnings: fix alignment warnings
[openocd.git] / src / target / arm_adi_v5.c
index 9a33d820131500b7d626d81d6911436f2eee2d91..34147967a7feda7fa526e670ba7b5c05a59f395e 100644 (file)
@@ -316,12 +316,12 @@ int mem_ap_write_buf_u32(struct adiv5_dap *dap, uint8_t *buffer, int count, uint
                for (writecount = 0; writecount < blocksize; writecount++)
                {
                        retval = dap_queue_ap_write(dap, AP_REG_DRW,
-                               *(uint32_t *) (buffer + 4 * writecount));
+                               *(uint32_t *) ((void *) (buffer + 4 * writecount)));
                        if (retval != ERROR_OK)
                                break;
                }
 
-               if (dap_run(dap) == ERROR_OK)
+               if ((retval = dap_run(dap)) == ERROR_OK)
                {
                        wcount = wcount - blocksize;
                        address = address + 4 * blocksize;
@@ -335,8 +335,7 @@ int mem_ap_write_buf_u32(struct adiv5_dap *dap, uint8_t *buffer, int count, uint
                if (errorcount > 1)
                {
                        LOG_WARNING("Block write error address 0x%" PRIx32 ", wcount 0x%x", address, wcount);
-                       /* REVISIT return the *actual* fault code */
-                       return ERROR_JTAG_DEVICE_ERROR;
+                       return retval;
                }
        }
 
@@ -376,13 +375,14 @@ static int mem_ap_write_buf_packed_u16(struct adiv5_dap *dap,
 
                        if (nbytes < 4)
                        {
-                               if (mem_ap_write_buf_u16(dap, buffer,
-                                               nbytes, address) != ERROR_OK)
+                               retval = mem_ap_write_buf_u16(dap, buffer,
+                                               nbytes, address);
+                               if (retval != ERROR_OK)
                                {
                                        LOG_WARNING("Block write error address "
                                                "0x%" PRIx32 ", count 0x%x",
                                                address, count);
-                                       return ERROR_JTAG_DEVICE_ERROR;
+                                       return retval;
                                }
 
                                address += nbytes >> 1;
@@ -405,13 +405,12 @@ static int mem_ap_write_buf_packed_u16(struct adiv5_dap *dap,
                                if (retval != ERROR_OK)
                                        break;
 
-                               if (dap_run(dap) != ERROR_OK)
+                               if ((retval = dap_run(dap)) != ERROR_OK)
                                {
                                        LOG_WARNING("Block write error address "
                                                "0x%" PRIx32 ", count 0x%x",
                                                address, count);
-                                       /* REVISIT return *actual* fault code */
-                                       return ERROR_JTAG_DEVICE_ERROR;
+                                       return retval;
                                }
                        }
 
@@ -485,12 +484,13 @@ static int mem_ap_write_buf_packed_u8(struct adiv5_dap *dap,
 
                        if (nbytes < 4)
                        {
-                               if (mem_ap_write_buf_u8(dap, buffer, nbytes, address) != ERROR_OK)
+                               retval = mem_ap_write_buf_u8(dap, buffer, nbytes, address);
+                               if (retval != ERROR_OK)
                                {
                                        LOG_WARNING("Block write error address "
                                                "0x%" PRIx32 ", count 0x%x",
                                                address, count);
-                                       return ERROR_JTAG_DEVICE_ERROR;
+                                       return retval;
                                }
 
                                address += nbytes;
@@ -513,13 +513,12 @@ static int mem_ap_write_buf_packed_u8(struct adiv5_dap *dap,
                                if (retval != ERROR_OK)
                                        break;
 
-                               if (dap_run(dap) != ERROR_OK)
+                               if ((retval = dap_run(dap)) != ERROR_OK)
                                {
                                        LOG_WARNING("Block write error address "
                                                "0x%" PRIx32 ", count 0x%x",
                                                address, count);
-                                       /* REVISIT return *actual* fault code */
-                                       return ERROR_JTAG_DEVICE_ERROR;
+                                       return retval;
                                }
                        }
 
@@ -710,11 +709,12 @@ static int mem_ap_read_buf_packed_u16(struct adiv5_dap *dap,
                do
                {
                        retval = dap_queue_ap_read(dap, AP_REG_DRW, &invalue);
-                       if (dap_run(dap) != ERROR_OK)
+                       if (retval != ERROR_OK)
+                               return retval;
+                       if ((retval = dap_run(dap)) != ERROR_OK)
                        {
                                LOG_WARNING("Block read error address 0x%" PRIx32 ", count 0x%x", address, count);
-                               /* REVISIT return the *actual* fault code */
-                               return ERROR_JTAG_DEVICE_ERROR;
+                               return retval;
                        }
 
                        nbytes = MIN((readcount << 1), 4);
@@ -819,11 +819,12 @@ static int mem_ap_read_buf_packed_u8(struct adiv5_dap *dap,
                do
                {
                        retval = dap_queue_ap_read(dap, AP_REG_DRW, &invalue);
-                       if (dap_run(dap) != ERROR_OK)
+                       if (retval != ERROR_OK)
+                               return retval;
+                       if ((retval = dap_run(dap)) != ERROR_OK)
                        {
                                LOG_WARNING("Block read error address 0x%" PRIx32 ", count 0x%x", address, count);
-                               /* REVISIT return the *actual* fault code */
-                               return ERROR_JTAG_DEVICE_ERROR;
+                               return retval;
                        }
 
                        nbytes = MIN(readcount, 4);
@@ -991,7 +992,11 @@ int ahbap_debugport_init(struct adiv5_dap *dap)
         * place to scan the table and do any topology detection?
         */
        retval = dap_queue_ap_read(dap, AP_REG_IDR, &idreg);
+       if (retval != ERROR_OK)
+               return retval;
        retval = dap_queue_ap_read(dap, AP_REG_BASE, &romaddr);
+       if (retval != ERROR_OK)
+               return retval;
 
        if ((retval = dap_run(dap)) != ERROR_OK)
                return retval;
@@ -1037,7 +1042,11 @@ static int dap_info_command(struct command_context *cmd_ctx,
        apselold = dap->apsel;
        dap_ap_select(dap, apsel);
        retval = dap_queue_ap_read(dap, AP_REG_BASE, &dbgbase);
+       if (retval != ERROR_OK)
+               return retval;
        retval = dap_queue_ap_read(dap, AP_REG_IDR, &apid);
+       if (retval != ERROR_OK)
+               return retval;
        retval = dap_run(dap);
        if (retval != ERROR_OK)
                return retval;
@@ -1088,11 +1097,21 @@ static int dap_info_command(struct command_context *cmd_ctx,
                        command_print(cmd_ctx, "\tROM table in legacy format");
 
                /* Now we read ROM table ID registers, ref. ARM IHI 0029B sec  */
-               mem_ap_read_u32(dap, (dbgbase&0xFFFFF000) | 0xFF0, &cid0);
-               mem_ap_read_u32(dap, (dbgbase&0xFFFFF000) | 0xFF4, &cid1);
-               mem_ap_read_u32(dap, (dbgbase&0xFFFFF000) | 0xFF8, &cid2);
-               mem_ap_read_u32(dap, (dbgbase&0xFFFFF000) | 0xFFC, &cid3);
-               mem_ap_read_u32(dap, (dbgbase&0xFFFFF000) | 0xFCC, &memtype);
+               retval = mem_ap_read_u32(dap, (dbgbase&0xFFFFF000) | 0xFF0, &cid0);
+               if (retval != ERROR_OK)
+                       return retval;
+               retval = mem_ap_read_u32(dap, (dbgbase&0xFFFFF000) | 0xFF4, &cid1);
+               if (retval != ERROR_OK)
+                       return retval;
+               retval = mem_ap_read_u32(dap, (dbgbase&0xFFFFF000) | 0xFF8, &cid2);
+               if (retval != ERROR_OK)
+                       return retval;
+               retval = mem_ap_read_u32(dap, (dbgbase&0xFFFFF000) | 0xFFC, &cid3);
+               if (retval != ERROR_OK)
+                       return retval;
+               retval = mem_ap_read_u32(dap, (dbgbase&0xFFFFF000) | 0xFCC, &memtype);
+               if (retval != ERROR_OK)
+                       return retval;
                retval = dap_run(dap);
                if (retval != ERROR_OK)
                        return retval;
@@ -1114,7 +1133,9 @@ static int dap_info_command(struct command_context *cmd_ctx,
                entry_offset = 0;
                do
                {
-                       mem_ap_read_atomic_u32(dap, (dbgbase&0xFFFFF000) | entry_offset, &romentry);
+                       retval = mem_ap_read_atomic_u32(dap, (dbgbase&0xFFFFF000) | entry_offset, &romentry);
+                       if (retval != ERROR_OK)
+                               return retval;
                        command_print(cmd_ctx, "\tROMTABLE[0x%x] = 0x%" PRIx32 "",entry_offset,romentry);
                        if (romentry&0x01)
                        {
@@ -1130,33 +1151,51 @@ static int dap_info_command(struct command_context *cmd_ctx,
                                /* IDs are in last 4K section */
 
 
-                               mem_ap_read_atomic_u32(dap,
+                               retval = mem_ap_read_atomic_u32(dap,
                                        component_base + 0xFE0, &c_pid0);
+                               if (retval != ERROR_OK)
+                                       return retval;
                                c_pid0 &= 0xff;
-                               mem_ap_read_atomic_u32(dap,
+                               retval = mem_ap_read_atomic_u32(dap,
                                        component_base + 0xFE4, &c_pid1);
+                               if (retval != ERROR_OK)
+                                       return retval;
                                c_pid1 &= 0xff;
-                               mem_ap_read_atomic_u32(dap,
+                               retval = mem_ap_read_atomic_u32(dap,
                                        component_base + 0xFE8, &c_pid2);
+                               if (retval != ERROR_OK)
+                                       return retval;
                                c_pid2 &= 0xff;
-                               mem_ap_read_atomic_u32(dap,
+                               retval = mem_ap_read_atomic_u32(dap,
                                        component_base + 0xFEC, &c_pid3);
+                               if (retval != ERROR_OK)
+                                       return retval;
                                c_pid3 &= 0xff;
-                               mem_ap_read_atomic_u32(dap,
+                               retval = mem_ap_read_atomic_u32(dap,
                                        component_base + 0xFD0, &c_pid4);
+                               if (retval != ERROR_OK)
+                                       return retval;
                                c_pid4 &= 0xff;
 
-                               mem_ap_read_atomic_u32(dap,
+                               retval = mem_ap_read_atomic_u32(dap,
                                        component_base + 0xFF0, &c_cid0);
+                               if (retval != ERROR_OK)
+                                       return retval;
                                c_cid0 &= 0xff;
-                               mem_ap_read_atomic_u32(dap,
+                               retval = mem_ap_read_atomic_u32(dap,
                                        component_base + 0xFF4, &c_cid1);
+                               if (retval != ERROR_OK)
+                                       return retval;
                                c_cid1 &= 0xff;
-                               mem_ap_read_atomic_u32(dap,
+                               retval = mem_ap_read_atomic_u32(dap,
                                        component_base + 0xFF8, &c_cid2);
+                               if (retval != ERROR_OK)
+                                       return retval;
                                c_cid2 &= 0xff;
-                               mem_ap_read_atomic_u32(dap,
+                               retval = mem_ap_read_atomic_u32(dap,
                                        component_base + 0xFFC, &c_cid3);
+                               if (retval != ERROR_OK)
+                                       return retval;
                                c_cid3 &= 0xff;
 
 
@@ -1177,9 +1216,11 @@ static int dap_info_command(struct command_context *cmd_ctx,
                                        unsigned minor;
                                        char *major = "Reserved", *subtype = "Reserved";
 
-                                       mem_ap_read_atomic_u32(dap,
+                                       retval = mem_ap_read_atomic_u32(dap,
                                                        (component_base & 0xfffff000) | 0xfcc,
                                                        &devtype);
+                                       if (retval != ERROR_OK)
+                                               return retval;
                                        minor = (devtype >> 4) & 0x0f;
                                        switch (devtype & 0x0f) {
                                        case 0:
@@ -1456,6 +1497,8 @@ COMMAND_HANDLER(dap_baseaddr_command)
         * use the ID register to verify it's a MEM-AP.
         */
        retval = dap_queue_ap_read(dap, AP_REG_BASE, &baseaddr);
+       if (retval != ERROR_OK)
+               return retval;
        retval = dap_run(dap);
        if (retval != ERROR_OK)
                return retval;
@@ -1519,6 +1562,8 @@ COMMAND_HANDLER(dap_apsel_command)
 
        dap_ap_select(dap, apsel);
        retval = dap_queue_ap_read(dap, AP_REG_IDR, &apid);
+       if (retval != ERROR_OK)
+               return retval;
        retval = dap_run(dap);
        if (retval != ERROR_OK)
                return retval;
@@ -1557,6 +1602,8 @@ COMMAND_HANDLER(dap_apid_command)
                dap_ap_select(dap, apsel);
 
        retval = dap_queue_ap_read(dap, AP_REG_IDR, &apid);
+       if (retval != ERROR_OK)
+               return retval;
        retval = dap_run(dap);
        if (retval != ERROR_OK)
                return retval;

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)