@@ -68,6 +68,8 @@ static int read_memory(struct target *target, target_addr_t address,
6868 uint32_t size , uint32_t count , uint8_t * buffer , uint32_t increment );
6969static int write_memory (struct target * target , target_addr_t address ,
7070 uint32_t size , uint32_t count , const uint8_t * buffer );
71+ static bool riscv013_get_impebreak (const struct target * target );
72+ static unsigned int riscv013_get_progbufsize (const struct target * target );
7173
7274typedef enum {
7375 HALT_GROUP ,
@@ -154,7 +156,9 @@ typedef struct {
154156 /* Number of abstract command data registers. */
155157 unsigned datacount ;
156158 /* Number of words in the Program Buffer. */
157- unsigned progbufsize ;
159+ unsigned int progbufsize ;
160+ /* Hart contains an implicit ebreak at the end of the program buffer. */
161+ bool impebreak ;
158162
159163 /* We cache the read-only bits of sbcs here. */
160164 uint32_t sbcs ;
@@ -1311,9 +1315,7 @@ static unsigned int register_size(struct target *target, enum gdb_regno number)
13111315static bool has_sufficient_progbuf (struct target * target , unsigned size )
13121316{
13131317 RISCV013_INFO (info );
1314- RISCV_INFO (r );
1315-
1316- return info -> progbufsize + r -> impebreak >= size ;
1318+ return info -> progbufsize + info -> impebreak >= size ;
13171319}
13181320
13191321/**
@@ -2038,14 +2040,13 @@ static int examine(struct target *target)
20382040 LOG_TARGET_INFO (target , "datacount=%d progbufsize=%d" ,
20392041 info -> datacount , info -> progbufsize );
20402042
2041- RISCV_INFO (r );
2042- r -> impebreak = get_field (dmstatus , DM_DMSTATUS_IMPEBREAK );
2043+ info -> impebreak = get_field (dmstatus , DM_DMSTATUS_IMPEBREAK );
20432044
20442045 if (!has_sufficient_progbuf (target , 2 )) {
20452046 LOG_TARGET_WARNING (target , "We won't be able to execute fence instructions on this "
20462047 "target. Memory may not always appear consistent. "
20472048 "(progbufsize=%d, impebreak=%d)" , info -> progbufsize ,
2048- r -> impebreak );
2049+ info -> impebreak );
20492050 }
20502051
20512052 if (info -> progbufsize < 4 && riscv_enable_virtual ) {
@@ -2061,6 +2062,8 @@ static int examine(struct target *target)
20612062 enum riscv_hart_state state_at_examine_start ;
20622063 if (riscv_get_hart_state (target , & state_at_examine_start ) != ERROR_OK )
20632064 return ERROR_FAIL ;
2065+
2066+ RISCV_INFO (r );
20642067 const bool hart_halted_at_examine_start = state_at_examine_start == RISCV_STATE_HALTED ;
20652068 if (!hart_halted_at_examine_start ) {
20662069 r -> prepped = true;
@@ -2074,10 +2077,6 @@ static int examine(struct target *target)
20742077 target -> state = TARGET_HALTED ;
20752078 target -> debug_reason = hart_halted_at_examine_start ? DBG_REASON_UNDEFINED : DBG_REASON_DBGRQ ;
20762079
2077- /* Without knowing anything else we can at least mess with the
2078- * program buffer. */
2079- r -> progbuf_size = info -> progbufsize ;
2080-
20812080 result = riscv013_reg_examine_all (target );
20822081 if (result != ERROR_OK )
20832082 return result ;
@@ -2818,6 +2817,8 @@ static int init_target(struct command_context *cmd_ctx,
28182817 generic_info -> read_memory = read_memory ;
28192818 generic_info -> data_bits = & riscv013_data_bits ;
28202819 generic_info -> print_info = & riscv013_print_info ;
2820+ generic_info -> get_impebreak = & riscv013_get_impebreak ;
2821+ generic_info -> get_progbufsize = & riscv013_get_progbufsize ;
28212822
28222823 generic_info -> handle_became_unavailable = & handle_became_unavailable ;
28232824 generic_info -> tick = & tick ;
@@ -4875,6 +4876,18 @@ static int write_memory(struct target *target, target_addr_t address,
48754876 return ret ;
48764877}
48774878
4879+ static bool riscv013_get_impebreak (const struct target * target )
4880+ {
4881+ RISCV013_INFO (r );
4882+ return r -> impebreak ;
4883+ }
4884+
4885+ static unsigned int riscv013_get_progbufsize (const struct target * target )
4886+ {
4887+ RISCV013_INFO (r );
4888+ return r -> progbufsize ;
4889+ }
4890+
48784891static int arch_state (struct target * target )
48794892{
48804893 return ERROR_OK ;
0 commit comments