@@ -131,6 +131,20 @@ static inline uint32_t flash_address(struct flash_bank *bank, int sector, uint32
131131 }
132132}
133133
134+ static int cfi_target_write_memory (struct target * target , target_addr_t addr ,
135+ uint32_t size , uint32_t count ,
136+ const uint8_t * buffer )
137+ {
138+ return target_write_memory (target , addr , size , count , buffer );
139+ }
140+
141+ static int cfi_target_read_memory (struct target * target , target_addr_t addr ,
142+ uint32_t size , uint32_t count ,
143+ uint8_t * buffer )
144+ {
145+ return target_read_memory (target , addr , size , count , buffer );
146+ }
147+
134148static void cfi_command (struct flash_bank * bank , uint8_t cmd , uint8_t * cmd_buf )
135149{
136150 int i ;
@@ -156,7 +170,7 @@ static int cfi_send_command(struct flash_bank *bank, uint8_t cmd, uint32_t addre
156170 uint8_t command [CFI_MAX_BUS_WIDTH ];
157171
158172 cfi_command (bank , cmd , command );
159- return target_write_memory (bank -> target , address , bank -> bus_width , 1 , command );
173+ return cfi_target_write_memory (bank -> target , address , bank -> bus_width , 1 , command );
160174}
161175
162176/* read unsigned 8-bit value from the bank
@@ -170,7 +184,7 @@ static int cfi_query_u8(struct flash_bank *bank, int sector, uint32_t offset, ui
170184 uint8_t data [CFI_MAX_BUS_WIDTH ];
171185
172186 int retval ;
173- retval = target_read_memory (target , flash_address (bank , sector , offset ),
187+ retval = cfi_target_read_memory (target , flash_address (bank , sector , offset ),
174188 bank -> bus_width , 1 , data );
175189 if (retval != ERROR_OK )
176190 return retval ;
@@ -195,7 +209,7 @@ static int cfi_get_u8(struct flash_bank *bank, int sector, uint32_t offset, uint
195209 int i ;
196210
197211 int retval ;
198- retval = target_read_memory (target , flash_address (bank , sector , offset ),
212+ retval = cfi_target_read_memory (target , flash_address (bank , sector , offset ),
199213 bank -> bus_width , 1 , data );
200214 if (retval != ERROR_OK )
201215 return retval ;
@@ -225,13 +239,13 @@ static int cfi_query_u16(struct flash_bank *bank, int sector, uint32_t offset, u
225239 if (cfi_info -> x16_as_x8 ) {
226240 uint8_t i ;
227241 for (i = 0 ; i < 2 ; i ++ ) {
228- retval = target_read_memory (target , flash_address (bank , sector , offset + i ),
242+ retval = cfi_target_read_memory (target , flash_address (bank , sector , offset + i ),
229243 bank -> bus_width , 1 , & data [i * bank -> bus_width ]);
230244 if (retval != ERROR_OK )
231245 return retval ;
232246 }
233247 } else {
234- retval = target_read_memory (target , flash_address (bank , sector , offset ),
248+ retval = cfi_target_read_memory (target , flash_address (bank , sector , offset ),
235249 bank -> bus_width , 2 , data );
236250 if (retval != ERROR_OK )
237251 return retval ;
@@ -255,13 +269,13 @@ static int cfi_query_u32(struct flash_bank *bank, int sector, uint32_t offset, u
255269 if (cfi_info -> x16_as_x8 ) {
256270 uint8_t i ;
257271 for (i = 0 ; i < 4 ; i ++ ) {
258- retval = target_read_memory (target , flash_address (bank , sector , offset + i ),
272+ retval = cfi_target_read_memory (target , flash_address (bank , sector , offset + i ),
259273 bank -> bus_width , 1 , & data [i * bank -> bus_width ]);
260274 if (retval != ERROR_OK )
261275 return retval ;
262276 }
263277 } else {
264- retval = target_read_memory (target , flash_address (bank , sector , offset ),
278+ retval = cfi_target_read_memory (target , flash_address (bank , sector , offset ),
265279 bank -> bus_width , 4 , data );
266280 if (retval != ERROR_OK )
267281 return retval ;
@@ -1997,7 +2011,7 @@ static int cfi_intel_write_word(struct flash_bank *bank, uint8_t *word, uint32_t
19972011 if (retval != ERROR_OK )
19982012 return retval ;
19992013
2000- retval = target_write_memory (target , address , bank -> bus_width , 1 , word );
2014+ retval = cfi_target_write_memory (target , address , bank -> bus_width , 1 , word );
20012015 if (retval != ERROR_OK )
20022016 return retval ;
20032017
@@ -2078,7 +2092,7 @@ static int cfi_intel_write_words(struct flash_bank *bank, const uint8_t *word,
20782092 if (retval != ERROR_OK )
20792093 return retval ;
20802094
2081- retval = target_write_memory (target , address , bank -> bus_width , bufferwsize , word );
2095+ retval = cfi_target_write_memory (target , address , bank -> bus_width , bufferwsize , word );
20822096 if (retval != ERROR_OK )
20832097 return retval ;
20842098
@@ -2119,7 +2133,7 @@ static int cfi_spansion_write_word(struct flash_bank *bank, uint8_t *word, uint3
21192133 if (retval != ERROR_OK )
21202134 return retval ;
21212135
2122- retval = target_write_memory (target , address , bank -> bus_width , 1 , word );
2136+ retval = cfi_target_write_memory (target , address , bank -> bus_width , 1 , word );
21232137 if (retval != ERROR_OK )
21242138 return retval ;
21252139
@@ -2181,7 +2195,7 @@ static int cfi_spansion_write_words(struct flash_bank *bank, const uint8_t *word
21812195 if (retval != ERROR_OK )
21822196 return retval ;
21832197
2184- retval = target_write_memory (target , address , bank -> bus_width , bufferwsize , word );
2198+ retval = cfi_target_write_memory (target , address , bank -> bus_width , bufferwsize , word );
21852199 if (retval != ERROR_OK )
21862200 return retval ;
21872201
@@ -2283,7 +2297,7 @@ static int cfi_read(struct flash_bank *bank, uint8_t *buffer, uint32_t offset, u
22832297 LOG_INFO ("Fixup %d unaligned read head bytes" , align );
22842298
22852299 /* read a complete word from flash */
2286- retval = target_read_memory (target , read_p , bank -> bus_width , 1 , current_word );
2300+ retval = cfi_target_read_memory (target , read_p , bank -> bus_width , 1 , current_word );
22872301 if (retval != ERROR_OK )
22882302 return retval ;
22892303
@@ -2296,7 +2310,7 @@ static int cfi_read(struct flash_bank *bank, uint8_t *buffer, uint32_t offset, u
22962310
22972311 align = count / bank -> bus_width ;
22982312 if (align ) {
2299- retval = target_read_memory (target , read_p , bank -> bus_width , align , buffer );
2313+ retval = cfi_target_read_memory (target , read_p , bank -> bus_width , align , buffer );
23002314 if (retval != ERROR_OK )
23012315 return retval ;
23022316
@@ -2309,7 +2323,7 @@ static int cfi_read(struct flash_bank *bank, uint8_t *buffer, uint32_t offset, u
23092323 LOG_INFO ("Fixup %" PRIu32 " unaligned read tail bytes" , count );
23102324
23112325 /* read a complete word from flash */
2312- retval = target_read_memory (target , read_p , bank -> bus_width , 1 , current_word );
2326+ retval = cfi_target_read_memory (target , read_p , bank -> bus_width , 1 , current_word );
23132327 if (retval != ERROR_OK )
23142328 return retval ;
23152329
@@ -2354,7 +2368,7 @@ static int cfi_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t of
23542368 LOG_INFO ("Fixup %d unaligned head bytes" , align );
23552369
23562370 /* read a complete word from flash */
2357- retval = target_read_memory (target , write_p , bank -> bus_width , 1 , current_word );
2371+ retval = cfi_target_read_memory (target , write_p , bank -> bus_width , 1 , current_word );
23582372 if (retval != ERROR_OK )
23592373 return retval ;
23602374
@@ -2474,7 +2488,7 @@ static int cfi_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t of
24742488 LOG_INFO ("Fixup %" PRId32 " unaligned tail bytes" , count );
24752489
24762490 /* read a complete word from flash */
2477- retval = target_read_memory (target , write_p , bank -> bus_width , 1 , current_word );
2491+ retval = cfi_target_read_memory (target , write_p , bank -> bus_width , 1 , current_word );
24782492 if (retval != ERROR_OK )
24792493 return retval ;
24802494
@@ -2624,11 +2638,11 @@ static int cfi_probe(struct flash_bank *bank)
26242638 if (retval != ERROR_OK )
26252639 return retval ;
26262640
2627- retval = target_read_memory (target , flash_address (bank , 0 , 0x00 ),
2641+ retval = cfi_target_read_memory (target , flash_address (bank , 0 , 0x00 ),
26282642 bank -> bus_width , 1 , value_buf0 );
26292643 if (retval != ERROR_OK )
26302644 return retval ;
2631- retval = target_read_memory (target , flash_address (bank , 0 , 0x01 ),
2645+ retval = cfi_target_read_memory (target , flash_address (bank , 0 , 0x01 ),
26322646 bank -> bus_width , 1 , value_buf1 );
26332647 if (retval != ERROR_OK )
26342648 return retval ;
0 commit comments