Skip to content

Commit

Permalink
Merge pull request #1571 from stefanrueger/sram
Browse files Browse the repository at this point in the history
Add memory sram and remove memory data
  • Loading branch information
stefanrueger authored Nov 22, 2023
2 parents c394fcf + a3a1871 commit 6df3f98
Show file tree
Hide file tree
Showing 11 changed files with 1,014 additions and 38 deletions.
35 changes: 34 additions & 1 deletion src/avr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1528,8 +1528,8 @@ memtable_t avr_mem_order[100] = {
{"bootrow", MEM_BOOTROW | MEM_USER_TYPE},
{"usersig", MEM_USERROW | MEM_USER_TYPE},
{"userrow", MEM_USERROW | MEM_USER_TYPE},
{"data", MEM_SRAM},
{"io", MEM_IO},
{"sram", MEM_SRAM},
{"sib", MEM_SIB | MEM_READONLY},
};

Expand Down Expand Up @@ -1559,6 +1559,39 @@ int avr_mem_is_usersig_type(const AVRMEM *mem) {
return mem_is_user_type(mem);
}

static int mem_group(AVRMEM *mem) {
return
!mem? -1:
mem_is_eeprom(mem)? 0:
mem_is_in_flash(mem)? 1:
mem_is_in_fuses(mem)? 2:
mem_is_lock(mem)? 3:
mem_is_in_sigrow(mem)? 4:
mem_is_user_type(mem)? 5:
mem_is_io(mem)? 6:
mem_is_sram(mem)? 7:
mem_is_sib(mem)? 8: 9;
}

// Return sort order of memories
int avr_mem_cmp(void *mem1, void *mem2) {
AVRMEM *m1 = mem1, *m2 = mem2;

int diff = mem_group(m1) - mem_group(m2); // First sort by group
if(diff)
return diff;
if(!m1) // Sanity, if called with NULL pointers
return 0;
diff = m1->offset - m2->offset; // Sort by offset within each group
if(diff)
return diff;
diff = m2->size - m1->size; // Sic: larger size is listed first, eg, fuses before fuse0
if(diff)
return diff;
return strcmp(m1->desc, m2->desc);
}


int avr_mem_is_known(const char *str) {
if(str && *str)
for(size_t i=0; i < sizeof avr_mem_order/sizeof *avr_mem_order; i++)
Expand Down
Loading

0 comments on commit 6df3f98

Please sign in to comment.