Merge pull request #812 from XuHangHub/riscv
target/riscv: fix the bug of using S2 register in read_memory_progbuf
This commit is contained in:
commit
750f7b4bc3
|
@ -3196,7 +3196,7 @@ static int read_memory_progbuf_inner(struct target *target, target_addr_t addres
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
if (increment == 0 &&
|
if (increment == 0 &&
|
||||||
register_write_direct(target, GDB_REGNO_S2, 0) != ERROR_OK)
|
register_write_direct(target, GDB_REGNO_A0, 0) != ERROR_OK)
|
||||||
return ERROR_FAIL;
|
return ERROR_FAIL;
|
||||||
|
|
||||||
uint32_t command = access_register_command(target, GDB_REGNO_S1,
|
uint32_t command = access_register_command(target, GDB_REGNO_S1,
|
||||||
|
@ -3298,7 +3298,7 @@ static int read_memory_progbuf_inner(struct target *target, target_addr_t addres
|
||||||
/* See how far we got, clobbering dmi_data0. */
|
/* See how far we got, clobbering dmi_data0. */
|
||||||
if (increment == 0) {
|
if (increment == 0) {
|
||||||
uint64_t counter;
|
uint64_t counter;
|
||||||
result = register_read_direct(target, &counter, GDB_REGNO_S2);
|
result = register_read_direct(target, &counter, GDB_REGNO_A0);
|
||||||
next_index = counter;
|
next_index = counter;
|
||||||
} else {
|
} else {
|
||||||
uint64_t next_read_addr;
|
uint64_t next_read_addr;
|
||||||
|
@ -3523,13 +3523,13 @@ static int read_memory_progbuf(struct target *target, target_addr_t address,
|
||||||
|
|
||||||
/* s0 holds the next address to read from
|
/* s0 holds the next address to read from
|
||||||
* s1 holds the next data value read
|
* s1 holds the next data value read
|
||||||
* s2 is a counter in case increment is 0
|
* a0 is a counter in case increment is 0
|
||||||
*/
|
*/
|
||||||
if (riscv_save_register(target, GDB_REGNO_S0) != ERROR_OK)
|
if (riscv_save_register(target, GDB_REGNO_S0) != ERROR_OK)
|
||||||
return ERROR_FAIL;
|
return ERROR_FAIL;
|
||||||
if (riscv_save_register(target, GDB_REGNO_S1) != ERROR_OK)
|
if (riscv_save_register(target, GDB_REGNO_S1) != ERROR_OK)
|
||||||
return ERROR_FAIL;
|
return ERROR_FAIL;
|
||||||
if (increment == 0 && riscv_save_register(target, GDB_REGNO_S2) != ERROR_OK)
|
if (increment == 0 && riscv_save_register(target, GDB_REGNO_A0) != ERROR_OK)
|
||||||
return ERROR_FAIL;
|
return ERROR_FAIL;
|
||||||
|
|
||||||
/* Write the program (load, increment) */
|
/* Write the program (load, increment) */
|
||||||
|
@ -3559,7 +3559,7 @@ static int read_memory_progbuf(struct target *target, target_addr_t address,
|
||||||
if (riscv_enable_virtual && has_sufficient_progbuf(target, 5) && get_field(mstatus, MSTATUS_MPRV))
|
if (riscv_enable_virtual && has_sufficient_progbuf(target, 5) && get_field(mstatus, MSTATUS_MPRV))
|
||||||
riscv_program_csrrci(&program, GDB_REGNO_ZERO, CSR_DCSR_MPRVEN, GDB_REGNO_DCSR);
|
riscv_program_csrrci(&program, GDB_REGNO_ZERO, CSR_DCSR_MPRVEN, GDB_REGNO_DCSR);
|
||||||
if (increment == 0)
|
if (increment == 0)
|
||||||
riscv_program_addi(&program, GDB_REGNO_S2, GDB_REGNO_S2, 1);
|
riscv_program_addi(&program, GDB_REGNO_A0, GDB_REGNO_A0, 1);
|
||||||
else
|
else
|
||||||
riscv_program_addi(&program, GDB_REGNO_S0, GDB_REGNO_S0, increment);
|
riscv_program_addi(&program, GDB_REGNO_S0, GDB_REGNO_S0, increment);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue