@@ -988,7 +988,7 @@ static int examine_progbuf(struct target *target)
988
988
return ERROR_OK ;
989
989
}
990
990
991
- if (riscv013_reg_save (target , GDB_REGNO_S0 ) != ERROR_OK )
991
+ if (riscv013_reg_save_gpr (target , GDB_REGNO_S0 ) != ERROR_OK )
992
992
return ERROR_FAIL ;
993
993
994
994
struct riscv_program program ;
@@ -1320,7 +1320,7 @@ static int fpr_read_progbuf(struct target *target, uint64_t *value,
1320
1320
1321
1321
const unsigned int freg = number - GDB_REGNO_FPR0 ;
1322
1322
1323
- if (riscv013_reg_save (target , GDB_REGNO_S0 ) != ERROR_OK )
1323
+ if (riscv013_reg_save_gpr (target , GDB_REGNO_S0 ) != ERROR_OK )
1324
1324
return ERROR_FAIL ;
1325
1325
1326
1326
struct riscv_program program ;
@@ -1350,7 +1350,7 @@ static int csr_read_progbuf(struct target *target, uint64_t *value,
1350
1350
assert (target -> state == TARGET_HALTED );
1351
1351
assert (number >= GDB_REGNO_CSR0 && number <= GDB_REGNO_CSR4095 );
1352
1352
1353
- if (riscv013_reg_save (target , GDB_REGNO_S0 ) != ERROR_OK )
1353
+ if (riscv013_reg_save_gpr (target , GDB_REGNO_S0 ) != ERROR_OK )
1354
1354
return ERROR_FAIL ;
1355
1355
1356
1356
struct riscv_program program ;
@@ -1418,7 +1418,7 @@ static int fpr_write_progbuf(struct target *target, enum gdb_regno number,
1418
1418
assert (number >= GDB_REGNO_FPR0 && number <= GDB_REGNO_FPR31 );
1419
1419
const unsigned int freg = number - GDB_REGNO_FPR0 ;
1420
1420
1421
- if (riscv013_reg_save (target , GDB_REGNO_S0 ) != ERROR_OK )
1421
+ if (riscv013_reg_save_gpr (target , GDB_REGNO_S0 ) != ERROR_OK )
1422
1422
return ERROR_FAIL ;
1423
1423
1424
1424
struct riscv_program program ;
@@ -1448,11 +1448,11 @@ static int vtype_write_progbuf(struct target *target, riscv_reg_t value)
1448
1448
{
1449
1449
assert (target -> state == TARGET_HALTED );
1450
1450
1451
- if (riscv013_reg_save (target , GDB_REGNO_S0 ) != ERROR_OK )
1451
+ if (riscv013_reg_save_gpr (target , GDB_REGNO_S0 ) != ERROR_OK )
1452
1452
return ERROR_FAIL ;
1453
1453
if (register_write_abstract (target , GDB_REGNO_S0 , value ) != ERROR_OK )
1454
1454
return ERROR_FAIL ;
1455
- if (riscv013_reg_save (target , GDB_REGNO_S1 ) != ERROR_OK )
1455
+ if (riscv013_reg_save_gpr (target , GDB_REGNO_S1 ) != ERROR_OK )
1456
1456
return ERROR_FAIL ;
1457
1457
1458
1458
struct riscv_program program ;
@@ -1469,11 +1469,11 @@ static int vl_write_progbuf(struct target *target, riscv_reg_t value)
1469
1469
{
1470
1470
assert (target -> state == TARGET_HALTED );
1471
1471
1472
- if (riscv013_reg_save (target , GDB_REGNO_S0 ) != ERROR_OK )
1472
+ if (riscv013_reg_save_gpr (target , GDB_REGNO_S0 ) != ERROR_OK )
1473
1473
return ERROR_FAIL ;
1474
1474
if (register_write_abstract (target , GDB_REGNO_S0 , value ) != ERROR_OK )
1475
1475
return ERROR_FAIL ;
1476
- if (riscv013_reg_save (target , GDB_REGNO_S1 ) != ERROR_OK )
1476
+ if (riscv013_reg_save_gpr (target , GDB_REGNO_S1 ) != ERROR_OK )
1477
1477
return ERROR_FAIL ;
1478
1478
1479
1479
struct riscv_program program ;
@@ -1492,7 +1492,7 @@ static int csr_write_progbuf(struct target *target, enum gdb_regno number,
1492
1492
assert (target -> state == TARGET_HALTED );
1493
1493
assert (number >= GDB_REGNO_CSR0 && number <= GDB_REGNO_CSR4095 );
1494
1494
1495
- if (riscv013_reg_save (target , GDB_REGNO_S0 ) != ERROR_OK )
1495
+ if (riscv013_reg_save_gpr (target , GDB_REGNO_S0 ) != ERROR_OK )
1496
1496
return ERROR_FAIL ;
1497
1497
if (register_write_abstract (target , GDB_REGNO_S0 , value ) != ERROR_OK )
1498
1498
return ERROR_FAIL ;
@@ -2298,7 +2298,7 @@ int riscv013_get_register_buf(struct target *target, uint8_t *value,
2298
2298
& debug_vl , & debug_vsew ) != ERROR_OK )
2299
2299
return ERROR_FAIL ;
2300
2300
2301
- if (riscv013_reg_save (target , GDB_REGNO_S0 ) != ERROR_OK )
2301
+ if (riscv013_reg_save_gpr (target , GDB_REGNO_S0 ) != ERROR_OK )
2302
2302
return ERROR_FAIL ;
2303
2303
2304
2304
unsigned int vnum = regno - GDB_REGNO_V0 ;
@@ -2353,7 +2353,7 @@ int riscv013_set_register_buf(struct target *target, enum gdb_regno regno,
2353
2353
& debug_vl , & debug_vsew ) != ERROR_OK )
2354
2354
return ERROR_FAIL ;
2355
2355
2356
- if (riscv013_reg_save (target , GDB_REGNO_S0 ) != ERROR_OK )
2356
+ if (riscv013_reg_save_gpr (target , GDB_REGNO_S0 ) != ERROR_OK )
2357
2357
return ERROR_FAIL ;
2358
2358
2359
2359
unsigned int vnum = regno - GDB_REGNO_V0 ;
@@ -4242,11 +4242,11 @@ static int read_memory_progbuf_inner_fill_progbuf(struct target *target,
4242
4242
{
4243
4243
const bool is_repeated_read = increment == 0 ;
4244
4244
4245
- if (riscv013_reg_save (target , GDB_REGNO_S0 ) != ERROR_OK )
4245
+ if (riscv013_reg_save_gpr (target , GDB_REGNO_S0 ) != ERROR_OK )
4246
4246
return ERROR_FAIL ;
4247
- if (riscv013_reg_save (target , GDB_REGNO_S1 ) != ERROR_OK )
4247
+ if (riscv013_reg_save_gpr (target , GDB_REGNO_S1 ) != ERROR_OK )
4248
4248
return ERROR_FAIL ;
4249
- if (is_repeated_read && riscv013_reg_save (target , GDB_REGNO_A0 ) != ERROR_OK )
4249
+ if (is_repeated_read && riscv013_reg_save_gpr (target , GDB_REGNO_A0 ) != ERROR_OK )
4250
4250
return ERROR_FAIL ;
4251
4251
4252
4252
struct riscv_program program ;
@@ -4338,7 +4338,7 @@ static int read_memory_progbuf_inner_one(struct target *target, const riscv_mem_
4338
4338
{
4339
4339
assert (riscv_mem_access_is_read (args ));
4340
4340
4341
- if (riscv013_reg_save (target , GDB_REGNO_S1 ) != ERROR_OK )
4341
+ if (riscv013_reg_save_gpr (target , GDB_REGNO_S1 ) != ERROR_OK )
4342
4342
return ERROR_FAIL ;
4343
4343
4344
4344
struct riscv_program program ;
@@ -4861,9 +4861,9 @@ static int write_memory_progbuf_try_to_write(struct target *target,
4861
4861
4862
4862
static int write_memory_progbuf_fill_progbuf (struct target * target , uint32_t size )
4863
4863
{
4864
- if (riscv013_reg_save (target , GDB_REGNO_S0 ) != ERROR_OK )
4864
+ if (riscv013_reg_save_gpr (target , GDB_REGNO_S0 ) != ERROR_OK )
4865
4865
return ERROR_FAIL ;
4866
- if (riscv013_reg_save (target , GDB_REGNO_S1 ) != ERROR_OK )
4866
+ if (riscv013_reg_save_gpr (target , GDB_REGNO_S1 ) != ERROR_OK )
4867
4867
return ERROR_FAIL ;
4868
4868
4869
4869
struct riscv_program program ;
@@ -5067,19 +5067,8 @@ struct target_type riscv013_target = {
5067
5067
int riscv013_get_register (struct target * target ,
5068
5068
riscv_reg_t * value , enum gdb_regno rid )
5069
5069
{
5070
- /* It would be beneficial to move this redirection to the
5071
- * version-independent section, but there is a conflict:
5072
- * `dcsr[5]` is `dcsr.v` in current spec, but it is `dcsr.debugint` in 0.11.
5073
- */
5074
- if (rid == GDB_REGNO_PRIV ) {
5075
- uint64_t dcsr ;
5076
- if (riscv_reg_get (target , & dcsr , GDB_REGNO_DCSR ) != ERROR_OK )
5077
- return ERROR_FAIL ;
5078
- * value = set_field (0 , VIRT_PRIV_V , get_field (dcsr , CSR_DCSR_V ));
5079
- * value = set_field (* value , VIRT_PRIV_PRV , get_field (dcsr , CSR_DCSR_PRV ));
5080
- return ERROR_OK ;
5081
- }
5082
-
5070
+ assert (rid != GDB_REGNO_PC && "'pc' should be read through 'dpc'" );
5071
+ assert (rid != GDB_REGNO_PRIV && "'priv' should be read through 'dcsr'" );
5083
5072
LOG_TARGET_DEBUG (target , "reading register %s" , riscv_reg_gdb_regno_name (target , rid ));
5084
5073
5085
5074
if (dm013_select_target (target ) != ERROR_OK )
@@ -5096,6 +5085,8 @@ int riscv013_get_register(struct target *target,
5096
5085
int riscv013_set_register (struct target * target , enum gdb_regno rid ,
5097
5086
riscv_reg_t value )
5098
5087
{
5088
+ assert (rid != GDB_REGNO_PC && "'pc' should be written through 'dpc'" );
5089
+ assert (rid != GDB_REGNO_PRIV && "'priv' should be written through 'dcsr'" );
5099
5090
LOG_TARGET_DEBUG (target , "writing 0x%" PRIx64 " to register %s" ,
5100
5091
value , riscv_reg_gdb_regno_name (target , rid ));
5101
5092
0 commit comments