@@ -67,6 +67,8 @@ static int read_memory(struct target *target, target_addr_t address,
6767 uint32_t size , uint32_t count , uint8_t * buffer , uint32_t increment );
6868static int write_memory (struct target * target , target_addr_t address ,
6969 uint32_t size , uint32_t count , const uint8_t * buffer );
70+ static bool riscv013_get_impebreak (const struct target * target );
71+ static unsigned int riscv013_get_progbufsize (const struct target * target );
7072
7173typedef enum {
7274 HALT_GROUP ,
@@ -153,7 +155,9 @@ typedef struct {
153155 /* Number of abstract command data registers. */
154156 unsigned datacount ;
155157 /* Number of words in the Program Buffer. */
156- unsigned progbufsize ;
158+ unsigned int progbufsize ;
159+ /* Hart contains an implicit ebreak at the end of the program buffer. */
160+ bool impebreak ;
157161
158162 /* We cache the read-only bits of sbcs here. */
159163 uint32_t sbcs ;
@@ -1310,9 +1314,7 @@ static unsigned int register_size(struct target *target, enum gdb_regno number)
13101314static bool has_sufficient_progbuf (struct target * target , unsigned size )
13111315{
13121316 RISCV013_INFO (info );
1313- RISCV_INFO (r );
1314-
1315- return info -> progbufsize + r -> impebreak >= size ;
1317+ return info -> progbufsize + info -> impebreak >= size ;
13161318}
13171319
13181320/**
@@ -2037,14 +2039,13 @@ static int examine(struct target *target)
20372039 LOG_TARGET_INFO (target , "datacount=%d progbufsize=%d" ,
20382040 info -> datacount , info -> progbufsize );
20392041
2040- RISCV_INFO (r );
2041- r -> impebreak = get_field (dmstatus , DM_DMSTATUS_IMPEBREAK );
2042+ info -> impebreak = get_field (dmstatus , DM_DMSTATUS_IMPEBREAK );
20422043
20432044 if (!has_sufficient_progbuf (target , 2 )) {
20442045 LOG_TARGET_WARNING (target , "We won't be able to execute fence instructions on this "
20452046 "target. Memory may not always appear consistent. "
20462047 "(progbufsize=%d, impebreak=%d)" , info -> progbufsize ,
2047- r -> impebreak );
2048+ info -> impebreak );
20482049 }
20492050
20502051 if (info -> progbufsize < 4 && riscv_enable_virtual ) {
@@ -2060,6 +2061,8 @@ static int examine(struct target *target)
20602061 enum riscv_hart_state state_at_examine_start ;
20612062 if (riscv_get_hart_state (target , & state_at_examine_start ) != ERROR_OK )
20622063 return ERROR_FAIL ;
2064+
2065+ RISCV_INFO (r );
20632066 const bool hart_halted_at_examine_start = state_at_examine_start == RISCV_STATE_HALTED ;
20642067 if (!hart_halted_at_examine_start ) {
20652068 r -> prepped = true;
@@ -2073,10 +2076,6 @@ static int examine(struct target *target)
20732076 target -> state = TARGET_HALTED ;
20742077 target -> debug_reason = hart_halted_at_examine_start ? DBG_REASON_UNDEFINED : DBG_REASON_DBGRQ ;
20752078
2076- /* Without knowing anything else we can at least mess with the
2077- * program buffer. */
2078- r -> progbuf_size = info -> progbufsize ;
2079-
20802079 result = riscv013_reg_examine_all (target );
20812080 if (result != ERROR_OK )
20822081 return result ;
@@ -2817,6 +2816,8 @@ static int init_target(struct command_context *cmd_ctx,
28172816 generic_info -> read_memory = read_memory ;
28182817 generic_info -> data_bits = & riscv013_data_bits ;
28192818 generic_info -> print_info = & riscv013_print_info ;
2819+ generic_info -> get_impebreak = & riscv013_get_impebreak ;
2820+ generic_info -> get_progbufsize = & riscv013_get_progbufsize ;
28202821
28212822 generic_info -> handle_became_unavailable = & handle_became_unavailable ;
28222823 generic_info -> tick = & tick ;
@@ -4872,6 +4873,18 @@ static int write_memory(struct target *target, target_addr_t address,
48724873 return ret ;
48734874}
48744875
4876+ static bool riscv013_get_impebreak (const struct target * target )
4877+ {
4878+ RISCV013_INFO (r );
4879+ return r -> impebreak ;
4880+ }
4881+
4882+ static unsigned int riscv013_get_progbufsize (const struct target * target )
4883+ {
4884+ RISCV013_INFO (r );
4885+ return r -> progbufsize ;
4886+ }
4887+
48754888static int arch_state (struct target * target )
48764889{
48774890 return ERROR_OK ;
0 commit comments