Make avr_mem_exclude() a libavrdude function

This commit is contained in:
Stefan Rueger
2024-08-06 21:02:49 +01:00
parent 8e10196efd
commit 00edcd220e
3 changed files with 9 additions and 7 deletions

View File

@@ -1599,6 +1599,12 @@ Memtable avr_mem_order[100] = {
{"sib", MEM_SIB | MEM_READONLY},
};
// Whether a memory is an exception that shouldn't be there for this particular i/face
int avr_mem_exclude(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *mem) {
return // Classic part usersig memories cannot be read/written using ISP
mem_is_usersig(mem) && (p->prog_modes&PM_Classic) && (pgm->prog_modes&p->prog_modes&PM_ISP);
}
int avr_get_mem_type(const char *str) {
for(size_t i=0; i < sizeof avr_mem_order/sizeof *avr_mem_order; i++) {
if(avr_mem_order[i].str && str_eq(avr_mem_order[i].str, str))

View File

@@ -1144,6 +1144,8 @@ int avr_get_cycle_count(const PROGRAMMER *pgm, const AVRPART *p, int *cycles);
int avr_put_cycle_count(const PROGRAMMER *pgm, const AVRPART *p, int cycles);
int avr_mem_exclude(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *mem);
int avr_get_mem_type(const char *str);
int avr_mem_is_flash_type(const AVRMEM *mem);

View File

@@ -269,15 +269,9 @@ static void ioerror(const char *iotype, const UPDATE *upd) {
msg_ext_error("\n");
}
// Whether a memory is an exception that shouldn't be included
static int exclude(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *mem) {
return // Classic part usersig memories cannot be read/written using ISP
mem_is_usersig(mem) && (p->prog_modes&PM_Classic) && (pgm->prog_modes&p->prog_modes&PM_ISP);
}
// Whether a memory should be returned for ALL: exclude IO/SRAM
static int is_interesting_mem(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *mem) {
return !mem_is_io(mem) && !mem_is_sram(mem) && !(pgm && exclude(pgm, p, mem));
return !mem_is_io(mem) && !mem_is_sram(mem) && !(pgm && avr_mem_exclude(pgm, p, mem));
}
// Whether a memory should be backup-ed: exclude sub-memories