25 |
* SUCH DAMAGE. |
* SUCH DAMAGE. |
26 |
* |
* |
27 |
* |
* |
28 |
* $Id: file.c,v 1.131 2006/03/30 19:36:03 debug Exp $ |
* $Id: file.c,v 1.132 2006/07/09 05:51:28 debug Exp $ |
29 |
* |
* |
30 |
* This file contains functions which load executable images into (emulated) |
* This file contains functions which load executable images into (emulated) |
31 |
* memory. File formats recognized so far are: |
* memory. File formats recognized so far are: |
1164 |
{ |
{ |
1165 |
FILE *f; |
FILE *f; |
1166 |
int len; |
int len; |
1167 |
unsigned char buf[4096]; |
unsigned char buf[16384]; |
1168 |
uint64_t entry, loadaddr, vaddr, skip = 0; |
uint64_t entry, loadaddr, vaddr, skip = 0; |
1169 |
char *p, *p2; |
char *p, *p2; |
1170 |
|
|
1201 |
|
|
1202 |
/* Load file contents: */ |
/* Load file contents: */ |
1203 |
while (!feof(f)) { |
while (!feof(f)) { |
1204 |
len = fread(buf, 1, sizeof(buf), f); |
size_t to_read = sizeof(buf); |
1205 |
|
|
1206 |
|
/* If vaddr isn't buf-size aligned, then start with a |
1207 |
|
smaller buffer: */ |
1208 |
|
if (vaddr & (sizeof(buf) - 1)) |
1209 |
|
to_read = sizeof(buf) - (vaddr & (sizeof(buf)-1)); |
1210 |
|
|
1211 |
|
len = fread(buf, 1, to_read, f); |
1212 |
|
|
1213 |
if (len > 0) |
if (len > 0) |
1214 |
m->cpus[0]->memory_rw(m->cpus[0], mem, vaddr, &buf[0], |
m->cpus[0]->memory_rw(m->cpus[0], mem, vaddr, &buf[0], |