diff options
-rwxr-xr-x | nios-sim | bin | 124940 -> 0 bytes | |||
-rw-r--r-- | srec.c | 12 |
2 files changed, 6 insertions, 6 deletions
diff --git a/nios-sim b/nios-sim Binary files differdeleted file mode 100755 index 2ff346d..0000000 --- a/nios-sim +++ /dev/null @@ -56,11 +56,10 @@ err_out: } static int srec_load_S3(char *buf, size_t data_count, - uint32_t start_addr, uint8_t *mem_base, size_t mem_size) + off_t offset, uint8_t *mem_base, size_t mem_size) { size_t i; uint32_t *base = (uint32_t *) mem_base; - off_t offset = 0; for (i = 0; i < data_count; i += 4) { uint32_t tmp; @@ -72,12 +71,13 @@ static int srec_load_S3(char *buf, size_t data_count, /* SREC is Big Endian, NiosII is Little Endian */ tmp = bswap_32(tmp); - if (offset + i > mem_size - 1) { + if (offset + i >= mem_size) { err("Image file too large for allocated memory of %zu bytes\n", mem_size); return -1; } + /* Store in memory */ - base[offset + i] = tmp; + base[offset / 4 + i] = tmp; } return 0; @@ -101,7 +101,7 @@ static int srec_handle_line(char *buf, size_t len, uint8_t *mem_base, size_t mem switch (buf[1]) { case '0': - dbg("handling S0\n"); + /* Ignore */ break; case '1': dbg("handling S1\n"); @@ -144,7 +144,7 @@ static int srec_handle_line(char *buf, size_t len, uint8_t *mem_base, size_t mem return 0; } -int srec_load(FILE *fp, const char *name, uint8_t *mem_base, size_t mem_size) +int srec_load(FILE *fp, const char *name __unused, uint8_t *mem_base, size_t mem_size) { ssize_t len; int ret = 0; |