@@ -986,7 +986,7 @@ static int examine_progbuf(struct target *target)
986
986
return ERROR_OK ;
987
987
}
988
988
989
- if (riscv013_reg_save (target , GDB_REGNO_S0 ) != ERROR_OK )
989
+ if (riscv013_reg_save_gpr (target , GDB_REGNO_S0 ) != ERROR_OK )
990
990
return ERROR_FAIL ;
991
991
992
992
struct riscv_program program ;
@@ -1318,7 +1318,7 @@ static int fpr_read_progbuf(struct target *target, uint64_t *value,
1318
1318
1319
1319
const unsigned int freg = number - GDB_REGNO_FPR0 ;
1320
1320
1321
- if (riscv013_reg_save (target , GDB_REGNO_S0 ) != ERROR_OK )
1321
+ if (riscv013_reg_save_gpr (target , GDB_REGNO_S0 ) != ERROR_OK )
1322
1322
return ERROR_FAIL ;
1323
1323
1324
1324
struct riscv_program program ;
@@ -1348,7 +1348,7 @@ static int csr_read_progbuf(struct target *target, uint64_t *value,
1348
1348
assert (target -> state == TARGET_HALTED );
1349
1349
assert (number >= GDB_REGNO_CSR0 && number <= GDB_REGNO_CSR4095 );
1350
1350
1351
- if (riscv013_reg_save (target , GDB_REGNO_S0 ) != ERROR_OK )
1351
+ if (riscv013_reg_save_gpr (target , GDB_REGNO_S0 ) != ERROR_OK )
1352
1352
return ERROR_FAIL ;
1353
1353
1354
1354
struct riscv_program program ;
@@ -1416,7 +1416,7 @@ static int fpr_write_progbuf(struct target *target, enum gdb_regno number,
1416
1416
assert (number >= GDB_REGNO_FPR0 && number <= GDB_REGNO_FPR31 );
1417
1417
const unsigned int freg = number - GDB_REGNO_FPR0 ;
1418
1418
1419
- if (riscv013_reg_save (target , GDB_REGNO_S0 ) != ERROR_OK )
1419
+ if (riscv013_reg_save_gpr (target , GDB_REGNO_S0 ) != ERROR_OK )
1420
1420
return ERROR_FAIL ;
1421
1421
1422
1422
struct riscv_program program ;
@@ -1446,11 +1446,11 @@ static int vtype_write_progbuf(struct target *target, riscv_reg_t value)
1446
1446
{
1447
1447
assert (target -> state == TARGET_HALTED );
1448
1448
1449
- if (riscv013_reg_save (target , GDB_REGNO_S0 ) != ERROR_OK )
1449
+ if (riscv013_reg_save_gpr (target , GDB_REGNO_S0 ) != ERROR_OK )
1450
1450
return ERROR_FAIL ;
1451
1451
if (register_write_abstract (target , GDB_REGNO_S0 , value ) != ERROR_OK )
1452
1452
return ERROR_FAIL ;
1453
- if (riscv013_reg_save (target , GDB_REGNO_S1 ) != ERROR_OK )
1453
+ if (riscv013_reg_save_gpr (target , GDB_REGNO_S1 ) != ERROR_OK )
1454
1454
return ERROR_FAIL ;
1455
1455
1456
1456
struct riscv_program program ;
@@ -1467,11 +1467,11 @@ static int vl_write_progbuf(struct target *target, riscv_reg_t value)
1467
1467
{
1468
1468
assert (target -> state == TARGET_HALTED );
1469
1469
1470
- if (riscv013_reg_save (target , GDB_REGNO_S0 ) != ERROR_OK )
1470
+ if (riscv013_reg_save_gpr (target , GDB_REGNO_S0 ) != ERROR_OK )
1471
1471
return ERROR_FAIL ;
1472
1472
if (register_write_abstract (target , GDB_REGNO_S0 , value ) != ERROR_OK )
1473
1473
return ERROR_FAIL ;
1474
- if (riscv013_reg_save (target , GDB_REGNO_S1 ) != ERROR_OK )
1474
+ if (riscv013_reg_save_gpr (target , GDB_REGNO_S1 ) != ERROR_OK )
1475
1475
return ERROR_FAIL ;
1476
1476
1477
1477
struct riscv_program program ;
@@ -1490,7 +1490,7 @@ static int csr_write_progbuf(struct target *target, enum gdb_regno number,
1490
1490
assert (target -> state == TARGET_HALTED );
1491
1491
assert (number >= GDB_REGNO_CSR0 && number <= GDB_REGNO_CSR4095 );
1492
1492
1493
- if (riscv013_reg_save (target , GDB_REGNO_S0 ) != ERROR_OK )
1493
+ if (riscv013_reg_save_gpr (target , GDB_REGNO_S0 ) != ERROR_OK )
1494
1494
return ERROR_FAIL ;
1495
1495
if (register_write_abstract (target , GDB_REGNO_S0 , value ) != ERROR_OK )
1496
1496
return ERROR_FAIL ;
@@ -2296,7 +2296,7 @@ int riscv013_get_register_buf(struct target *target, uint8_t *value,
2296
2296
& debug_vl , & debug_vsew ) != ERROR_OK )
2297
2297
return ERROR_FAIL ;
2298
2298
2299
- if (riscv013_reg_save (target , GDB_REGNO_S0 ) != ERROR_OK )
2299
+ if (riscv013_reg_save_gpr (target , GDB_REGNO_S0 ) != ERROR_OK )
2300
2300
return ERROR_FAIL ;
2301
2301
2302
2302
unsigned int vnum = regno - GDB_REGNO_V0 ;
@@ -2351,7 +2351,7 @@ int riscv013_set_register_buf(struct target *target, enum gdb_regno regno,
2351
2351
& debug_vl , & debug_vsew ) != ERROR_OK )
2352
2352
return ERROR_FAIL ;
2353
2353
2354
- if (riscv013_reg_save (target , GDB_REGNO_S0 ) != ERROR_OK )
2354
+ if (riscv013_reg_save_gpr (target , GDB_REGNO_S0 ) != ERROR_OK )
2355
2355
return ERROR_FAIL ;
2356
2356
2357
2357
unsigned int vnum = regno - GDB_REGNO_V0 ;
@@ -4278,11 +4278,11 @@ static int read_memory_progbuf_inner_fill_progbuf(struct target *target,
4278
4278
{
4279
4279
const bool is_repeated_read = increment == 0 ;
4280
4280
4281
- if (riscv013_reg_save (target , GDB_REGNO_S0 ) != ERROR_OK )
4281
+ if (riscv013_reg_save_gpr (target , GDB_REGNO_S0 ) != ERROR_OK )
4282
4282
return ERROR_FAIL ;
4283
- if (riscv013_reg_save (target , GDB_REGNO_S1 ) != ERROR_OK )
4283
+ if (riscv013_reg_save_gpr (target , GDB_REGNO_S1 ) != ERROR_OK )
4284
4284
return ERROR_FAIL ;
4285
- if (is_repeated_read && riscv013_reg_save (target , GDB_REGNO_A0 ) != ERROR_OK )
4285
+ if (is_repeated_read && riscv013_reg_save_gpr (target , GDB_REGNO_A0 ) != ERROR_OK )
4286
4286
return ERROR_FAIL ;
4287
4287
4288
4288
struct riscv_program program ;
@@ -4376,7 +4376,7 @@ read_memory_progbuf_inner_one(struct target *target, const riscv_mem_access_args
4376
4376
{
4377
4377
assert (riscv_mem_access_is_read (args ));
4378
4378
4379
- if (riscv013_reg_save (target , GDB_REGNO_S1 ) != ERROR_OK )
4379
+ if (riscv013_reg_save_gpr (target , GDB_REGNO_S1 ) != ERROR_OK )
4380
4380
return mem_access_result (MEM_ACCESS_SKIPPED_REG_SAVE_FAILED );
4381
4381
4382
4382
struct riscv_program program ;
@@ -4951,9 +4951,9 @@ static int write_memory_progbuf_try_to_write(struct target *target,
4951
4951
4952
4952
static int write_memory_progbuf_fill_progbuf (struct target * target , uint32_t size )
4953
4953
{
4954
- if (riscv013_reg_save (target , GDB_REGNO_S0 ) != ERROR_OK )
4954
+ if (riscv013_reg_save_gpr (target , GDB_REGNO_S0 ) != ERROR_OK )
4955
4955
return ERROR_FAIL ;
4956
- if (riscv013_reg_save (target , GDB_REGNO_S1 ) != ERROR_OK )
4956
+ if (riscv013_reg_save_gpr (target , GDB_REGNO_S1 ) != ERROR_OK )
4957
4957
return ERROR_FAIL ;
4958
4958
4959
4959
struct riscv_program program ;
@@ -5058,19 +5058,8 @@ struct target_type riscv013_target = {
5058
5058
int riscv013_get_register (struct target * target ,
5059
5059
riscv_reg_t * value , enum gdb_regno rid )
5060
5060
{
5061
- /* It would be beneficial to move this redirection to the
5062
- * version-independent section, but there is a conflict:
5063
- * `dcsr[5]` is `dcsr.v` in current spec, but it is `dcsr.debugint` in 0.11.
5064
- */
5065
- if (rid == GDB_REGNO_PRIV ) {
5066
- uint64_t dcsr ;
5067
- if (riscv_reg_get (target , & dcsr , GDB_REGNO_DCSR ) != ERROR_OK )
5068
- return ERROR_FAIL ;
5069
- * value = set_field (0 , VIRT_PRIV_V , get_field (dcsr , CSR_DCSR_V ));
5070
- * value = set_field (* value , VIRT_PRIV_PRV , get_field (dcsr , CSR_DCSR_PRV ));
5071
- return ERROR_OK ;
5072
- }
5073
-
5061
+ assert (rid != GDB_REGNO_PC && "'pc' should be read through 'dpc'" );
5062
+ assert (rid != GDB_REGNO_PRIV && "'priv' should be read through 'dcsr'" );
5074
5063
LOG_TARGET_DEBUG (target , "reading register %s" , riscv_reg_gdb_regno_name (target , rid ));
5075
5064
5076
5065
if (dm013_select_target (target ) != ERROR_OK )
@@ -5087,6 +5076,8 @@ int riscv013_get_register(struct target *target,
5087
5076
int riscv013_set_register (struct target * target , enum gdb_regno rid ,
5088
5077
riscv_reg_t value )
5089
5078
{
5079
+ assert (rid != GDB_REGNO_PC && "'pc' should be written through 'dpc'" );
5080
+ assert (rid != GDB_REGNO_PRIV && "'priv' should be written through 'dcsr'" );
5090
5081
LOG_TARGET_DEBUG (target , "writing 0x%" PRIx64 " to register %s" ,
5091
5082
value , riscv_reg_gdb_regno_name (target , rid ));
5092
5083
0 commit comments