This is an automated email from Gerrit.

"Bernhard Rosenkränzer <b...@baylibre.com>" just uploaded a new patch set to 
Gerrit, which you can find at https://review.openocd.org/c/openocd/+/8291

-- gerrit

commit 3ac703659d5a107f1f40384513aa7075457ff5b3
Author: Bernhard Rosenkränzer <b...@baylibre.com>
Date:   Mon May 20 01:05:51 2024 +0200

    target/riscv: Implement read_memory without auto-increment
    
    Adjust the riscv internal read_memory to use the same parameters as
    generic target read_memory, implement non-autoincrement for riscv-013.
    
    This is the 4th in a series of 4 patches replacing
    https://review.openocd.org/c/openocd/+/8259
    
    Change-Id: Ic602656f120006c40aec8d932ff0d130b85ab1f6
    Signed-off-by: Bernhard Rosenkränzer <b...@baylibre.com>
    Cc: Antonio Borneo <borneo.anto...@gmail.com>

diff --git a/src/target/riscv/riscv-011.c b/src/target/riscv/riscv-011.c
index 1fe79f1c03..583114c24a 100644
--- a/src/target/riscv/riscv-011.c
+++ b/src/target/riscv/riscv-011.c
@@ -1985,12 +1985,10 @@ static int deassert_reset(struct target *target)
 }
 
 static int read_memory(struct target *target, target_addr_t address,
-               uint32_t size, uint32_t count, uint8_t *buffer, uint32_t 
increment)
+               uint32_t size, uint32_t count, uint8_t *buffer, bool 
addr_autoincr)
 {
-       if (increment != size) {
-               LOG_ERROR("read_memory with custom increment not implemented");
-               return ERROR_NOT_IMPLEMENTED;
-       }
+       if (!addr_autoincr)
+               return ERROR_TARGET_NOAUTOINCR_NOT_SUPPORTED;
 
        jtag_add_ir_scan(target->tap, &select_dbus, TAP_IDLE);
 
diff --git a/src/target/riscv/riscv-013.c b/src/target/riscv/riscv-013.c
index 666174a020..d41a6a7323 100644
--- a/src/target/riscv/riscv-013.c
+++ b/src/target/riscv/riscv-013.c
@@ -62,7 +62,7 @@ static int register_read_direct(struct target *target, 
uint64_t *value, uint32_t
 static int register_write_direct(struct target *target, unsigned number,
                uint64_t value);
 static int read_memory(struct target *target, target_addr_t address,
-               uint32_t size, uint32_t count, uint8_t *buffer, uint32_t 
increment);
+               uint32_t size, uint32_t count, uint8_t *buffer, bool 
addr_autoincr);
 static int write_memory(struct target *target, target_addr_t address,
                uint32_t size, uint32_t count, const uint8_t *buffer, bool 
addr_autoincr);
 
@@ -1222,7 +1222,7 @@ static int scratch_read64(struct target *target, 
scratch_mem_t *scratch,
                case SPACE_DMI_RAM:
                        {
                                uint8_t buffer[8] = {0};
-                               if (read_memory(target, scratch->debug_address, 
4, 2, buffer, 4) != ERROR_OK)
+                               if (read_memory(target, scratch->debug_address, 
4, 2, buffer, ADDR_AUTOINCR) != ERROR_OK)
                                        return ERROR_FAIL;
                                *value = buffer[0] |
                                        (((uint64_t) buffer[1]) << 8) |
@@ -3530,7 +3530,7 @@ static int read_memory_progbuf(struct target *target, 
target_addr_t address,
 }
 
 static int read_memory(struct target *target, target_addr_t address,
-               uint32_t size, uint32_t count, uint8_t *buffer, uint32_t 
increment)
+               uint32_t size, uint32_t count, uint8_t *buffer, bool 
addr_autoincr)
 {
        if (count == 0)
                return ERROR_OK;
@@ -3555,26 +3555,26 @@ static int read_memory(struct target *target, 
target_addr_t address,
                        if (mem_should_skip_progbuf(target, address, size, 
true, &progbuf_result))
                                continue;
 
-                       ret = read_memory_progbuf(target, address, size, count, 
buffer, increment);
+                       ret = read_memory_progbuf(target, address, size, count, 
buffer, addr_autoincr ? size : 0);
 
                        if (ret != ERROR_OK)
                                progbuf_result = "failed";
                } else if (method == RISCV_MEM_ACCESS_SYSBUS) {
-                       if (mem_should_skip_sysbus(target, address, size, 
increment, true, &sysbus_result))
+                       if (mem_should_skip_sysbus(target, address, size, 
addr_autoincr ? size : 0, true, &sysbus_result))
                                continue;
 
                        if (get_field(info->sbcs, DM_SBCS_SBVERSION) == 0)
-                               ret = read_memory_bus_v0(target, address, size, 
count, buffer, increment);
+                               ret = read_memory_bus_v0(target, address, size, 
count, buffer, addr_autoincr ? size : 0);
                        else if (get_field(info->sbcs, DM_SBCS_SBVERSION) == 1)
-                               ret = read_memory_bus_v1(target, address, size, 
count, buffer, increment);
+                               ret = read_memory_bus_v1(target, address, size, 
count, buffer, addr_autoincr ? size : 0);
 
                        if (ret != ERROR_OK)
                                sysbus_result = "failed";
                } else if (method == RISCV_MEM_ACCESS_ABSTRACT) {
-                       if (mem_should_skip_abstract(target, address, size, 
increment, true, &abstract_result))
+                       if (mem_should_skip_abstract(target, address, size, 
addr_autoincr ? size : 0, true, &abstract_result))
                                continue;
 
-                       ret = read_memory_abstract(target, address, size, 
count, buffer, increment);
+                       ret = read_memory_abstract(target, address, size, 
count, buffer, addr_autoincr ? size : 0);
 
                        if (ret != ERROR_OK)
                                abstract_result = "failed";
diff --git a/src/target/riscv/riscv.c b/src/target/riscv/riscv.c
index a3f2848212..a9332ff547 100644
--- a/src/target/riscv/riscv.c
+++ b/src/target/riscv/riscv.c
@@ -1627,7 +1627,7 @@ static int riscv_address_translate(struct target *target,
                uint8_t buffer[8];
                assert(info->pte_shift <= 3);
                int retval = r->read_memory(target, pte_address,
-                               4, (1 << info->pte_shift) / 4, buffer, 4);
+                               4, (1 << info->pte_shift) / 4, buffer, 
ADDR_AUTOINCR);
                if (retval != ERROR_OK)
                        return ERROR_FAIL;
 
@@ -1696,15 +1696,12 @@ static int riscv_read_phys_memory(struct target 
*target, target_addr_t phys_addr
        RISCV_INFO(r);
        if (riscv_select_current_hart(target) != ERROR_OK)
                return ERROR_FAIL;
-       return r->read_memory(target, phys_address, size, count, buffer, size);
+       return r->read_memory(target, phys_address, size, count, buffer, 
ADDR_AUTOINCR);
 }
 
 static int riscv_read_memory(struct target *target, target_addr_t address,
                uint32_t size, uint32_t count, uint8_t *buffer, bool 
addr_autoincr)
 {
-       if (addr_autoincr == ADDR_NO_AUTOINCR)
-               return ERROR_TARGET_NOAUTOINCR_NOT_SUPPORTED;
-
        if (count == 0) {
                LOG_WARNING("0-length read from 0x%" TARGET_PRIxADDR, address);
                return ERROR_OK;
@@ -1718,7 +1715,7 @@ static int riscv_read_memory(struct target *target, 
target_addr_t address,
                address = physical_addr;
 
        RISCV_INFO(r);
-       return r->read_memory(target, address, size, count, buffer, size);
+       return r->read_memory(target, address, size, count, buffer, 
addr_autoincr);
 }
 
 static int riscv_write_phys_memory(struct target *target, target_addr_t 
phys_address,
diff --git a/src/target/riscv/riscv.h b/src/target/riscv/riscv.h
index aba0864e6d..4a7183f773 100644
--- a/src/target/riscv/riscv.h
+++ b/src/target/riscv/riscv.h
@@ -180,7 +180,7 @@ struct riscv_info {
                                                 int64_t until_ms);
 
        int (*read_memory)(struct target *target, target_addr_t address,
-                       uint32_t size, uint32_t count, uint8_t *buffer, 
uint32_t increment);
+                       uint32_t size, uint32_t count, uint8_t *buffer, bool 
addr_autoincr);
 
        /* How many harts are attached to the DM that this target is attached 
to? */
        int (*hart_count)(struct target *target);

-- 

Reply via email to