Provide fileio_mem() function

This commit is contained in:
Stefan Rueger
2024-06-16 17:53:43 +01:00
parent c235adf5c9
commit dfc22ea966
2 changed files with 16 additions and 6 deletions

View File

@@ -1547,6 +1547,17 @@ int fileio_fmt_autodetect(const char *fname) {
int fileio_mem(int op, const char *filename, FILEFMT format,
const AVRPART *p, const AVRMEM *mem, int size) {
if(size < 0 || op == FIO_READ || op == FIO_READ_FOR_VERIFY)
size = mem->size;
const Segment seg = {0, size};
return fileio_segments(op, filename, format, p, mem, 1, &seg);
}
int fileio(int op, const char *filename, FILEFMT format,
const AVRPART *p, const char *memstr, int size) {
@@ -1556,11 +1567,7 @@ int fileio(int op, const char *filename, FILEFMT format,
return -1;
}
if(size < 0 || op == FIO_READ || op == FIO_READ_FOR_VERIFY)
size = mem->size;
const Segment seg = {0, size};
return fileio_segments(op, filename, format, p, mem, 1, &seg);
return fileio_mem(op, filename, format, p, mem, size);
}

View File

@@ -479,7 +479,7 @@ typedef struct {
#define mem_is_in_flash(mem) (!!((mem)->type & MEM_IN_FLASH))
#define mem_is_a_fuse(mem) (!!((mem)->type & MEM_IS_A_FUSE))
#define mem_is_in_fuses(mem) (!!((mem)->type & (MEM_FUSES | MEM_IS_A_FUSE))) // If fuses exists, that is
#define mem_is_in_fuses(mem) (!!((mem)->type & (MEM_FUSES | MEM_IS_A_FUSE))) // If fuses exists!
#define mem_is_user_type(mem) (!!((mem)->type & MEM_USER_TYPE))
#define mem_is_in_sigrow(mem) (!!((mem)->type & MEM_IN_SIGROW)) // If sigrow exists, that is
#define mem_is_readonly(mem) (!!((mem)->type & MEM_READONLY))
@@ -1243,6 +1243,9 @@ int fileio_fmt_autodetect_fp(FILE *f);
int fileio_fmt_autodetect(const char *fname);
int fileio_mem(int oprwv, const char *filename, FILEFMT format,
const AVRPART *p, const AVRMEM *mem, int size);
int fileio(int oprwv, const char *filename, FILEFMT format,
const AVRPART *p, const char *memstr, int size);