1313#include "config.h"
1414#endif
1515
16+ #include "riscv-011.h"
17+
1618#include "target/target.h"
1719#include "target/algorithm.h"
1820#include "target/target_type.h"
2224#include "target/breakpoints.h"
2325#include "helper/time_support.h"
2426#include "riscv.h"
27+ #include "riscv_reg.h"
28+ #include "riscv-011_reg.h"
2529#include "asm.h"
2630#include "gdb_regs.h"
2731#include "field_helpers.h"
@@ -210,8 +214,6 @@ typedef struct {
210214
211215static int poll_target (struct target * target , bool announce );
212216static int riscv011_poll (struct target * target );
213- static int get_register (struct target * target , riscv_reg_t * value ,
214- enum gdb_regno regid );
215217
216218/*** Utility functions. ***/
217219
@@ -1045,7 +1047,7 @@ static int read_remote_csr(struct target *target, uint64_t *value, uint32_t csr)
10451047 uint32_t exception = cache_get32 (target , info -> dramsize - 1 );
10461048 if (exception ) {
10471049 LOG_WARNING ("Got exception 0x%x when reading %s" , exception ,
1048- gdb_regno_name (target , GDB_REGNO_CSR0 + csr ));
1050+ riscv_reg_gdb_regno_name (target , GDB_REGNO_CSR0 + csr ));
10491051 * value = ~0 ;
10501052 return ERROR_FAIL ;
10511053 }
@@ -1111,7 +1113,7 @@ static int execute_resume(struct target *target, bool step)
11111113
11121114 LOG_DEBUG ("step=%d" , step );
11131115
1114- if (riscv_flush_registers (target ) != ERROR_OK )
1116+ if (riscv_reg_flush_all (target ) != ERROR_OK )
11151117 return ERROR_FAIL ;
11161118
11171119 maybe_write_tselect (target );
@@ -1225,7 +1227,7 @@ static int update_mstatus_actual(struct target *target)
12251227 /* Force reading the register. In that process mstatus_actual will be
12261228 * updated. */
12271229 riscv_reg_t mstatus ;
1228- return get_register (target , & mstatus , GDB_REGNO_MSTATUS );
1230+ return riscv011_get_register (target , & mstatus , GDB_REGNO_MSTATUS );
12291231}
12301232
12311233/*** OpenOCD target functions. ***/
@@ -1247,7 +1249,7 @@ static int register_read(struct target *target, riscv_reg_t *value, int regnum)
12471249
12481250 uint32_t exception = cache_get32 (target , info -> dramsize - 1 );
12491251 if (exception ) {
1250- LOG_WARNING ("Got exception 0x%x when reading %s" , exception , gdb_regno_name (target , regnum ));
1252+ LOG_WARNING ("Got exception 0x%x when reading %s" , exception , riscv_reg_gdb_regno_name (target , regnum ));
12511253 * value = ~0 ;
12521254 return ERROR_FAIL ;
12531255 }
@@ -1322,14 +1324,14 @@ static int register_write(struct target *target, unsigned int number,
13221324 uint32_t exception = cache_get32 (target , info -> dramsize - 1 );
13231325 if (exception ) {
13241326 LOG_WARNING ("Got exception 0x%x when writing %s" , exception ,
1325- gdb_regno_name (target , number ));
1327+ riscv_reg_gdb_regno_name (target , number ));
13261328 return ERROR_FAIL ;
13271329 }
13281330
13291331 return ERROR_OK ;
13301332}
13311333
1332- static int get_register (struct target * target , riscv_reg_t * value ,
1334+ int riscv011_get_register (struct target * target , riscv_reg_t * value ,
13331335 enum gdb_regno regid )
13341336{
13351337 riscv011_info_t * info = get_info (target );
@@ -1377,7 +1379,7 @@ static int get_register(struct target *target, riscv_reg_t *value,
13771379
13781380/* This function is intended to handle accesses to registers through register
13791381 * cache. */
1380- static int set_register (struct target * target , enum gdb_regno regid ,
1382+ int riscv011_set_register (struct target * target , enum gdb_regno regid ,
13811383 riscv_reg_t value )
13821384{
13831385 assert (target -> reg_cache );
@@ -1595,7 +1597,7 @@ static int examine(struct target *target)
15951597 }
15961598
15971599 /* Update register list to match discovered XLEN/supported extensions. */
1598- riscv_init_registers (target );
1600+ riscv011_reg_init_all (target );
15991601
16001602 info -> never_halted = true;
16011603
@@ -2391,8 +2393,6 @@ static int init_target(struct command_context *cmd_ctx,
23912393{
23922394 LOG_DEBUG ("init" );
23932395 RISCV_INFO (generic_info );
2394- generic_info -> get_register = get_register ;
2395- generic_info -> set_register = set_register ;
23962396 generic_info -> read_memory = read_memory ;
23972397 generic_info -> authdata_read = & riscv011_authdata_read ;
23982398 generic_info -> authdata_write = & riscv011_authdata_write ;
@@ -2404,7 +2404,7 @@ static int init_target(struct command_context *cmd_ctx,
24042404
24052405 /* Assume 32-bit until we discover the real value in examine(). */
24062406 generic_info -> xlen = 32 ;
2407- riscv_init_registers (target );
2407+ riscv011_reg_init_all (target );
24082408
24092409 return ERROR_OK ;
24102410}
0 commit comments