Revision 99a0949b hw/loader.c
b/hw/loader.c | ||
---|---|---|
81 | 81 |
} |
82 | 82 |
|
83 | 83 |
/* return the amount read, just like fread. 0 may mean error or eof */ |
84 |
int fread_targphys(target_phys_addr_t dst_addr, size_t nbytes, FILE *f)
|
|
84 |
int fread_targphys(a_target_phys_addr dst_addr, size_t nbytes, FILE *f)
|
|
85 | 85 |
{ |
86 | 86 |
uint8_t buf[4096]; |
87 |
target_phys_addr_t dst_begin = dst_addr;
|
|
87 |
a_target_phys_addr dst_begin = dst_addr;
|
|
88 | 88 |
size_t want, did; |
89 | 89 |
|
90 | 90 |
while (nbytes) { |
... | ... | |
101 | 101 |
} |
102 | 102 |
|
103 | 103 |
/* returns 0 on error, 1 if ok */ |
104 |
int fread_targphys_ok(target_phys_addr_t dst_addr, size_t nbytes, FILE *f)
|
|
104 |
int fread_targphys_ok(a_target_phys_addr dst_addr, size_t nbytes, FILE *f)
|
|
105 | 105 |
{ |
106 | 106 |
return fread_targphys(dst_addr, nbytes, f) == nbytes; |
107 | 107 |
} |
108 | 108 |
|
109 | 109 |
/* read()-like version */ |
110 |
int read_targphys(int fd, target_phys_addr_t dst_addr, size_t nbytes)
|
|
110 |
int read_targphys(int fd, a_target_phys_addr dst_addr, size_t nbytes)
|
|
111 | 111 |
{ |
112 | 112 |
uint8_t buf[4096]; |
113 |
target_phys_addr_t dst_begin = dst_addr;
|
|
113 |
a_target_phys_addr dst_begin = dst_addr;
|
|
114 | 114 |
size_t want, did; |
115 | 115 |
|
116 | 116 |
while (nbytes) { |
... | ... | |
127 | 127 |
|
128 | 128 |
/* return the size or -1 if error */ |
129 | 129 |
int load_image_targphys(const char *filename, |
130 |
target_phys_addr_t addr, int max_sz)
|
|
130 |
a_target_phys_addr addr, int max_sz)
|
|
131 | 131 |
{ |
132 | 132 |
FILE *f; |
133 | 133 |
size_t got; |
... | ... | |
142 | 142 |
return got; |
143 | 143 |
} |
144 | 144 |
|
145 |
void pstrcpy_targphys(target_phys_addr_t dest, int buf_size,
|
|
145 |
void pstrcpy_targphys(a_target_phys_addr dest, int buf_size,
|
|
146 | 146 |
const char *source) |
147 | 147 |
{ |
148 | 148 |
static const uint8_t nul_byte = 0; |
... | ... | |
204 | 204 |
: (_N_SEGMENT_ROUND (_N_TXTENDADDR(x, target_page_size), target_page_size))) |
205 | 205 |
|
206 | 206 |
|
207 |
int load_aout(const char *filename, target_phys_addr_t addr, int max_sz,
|
|
208 |
int bswap_needed, target_phys_addr_t target_page_size)
|
|
207 |
int load_aout(const char *filename, a_target_phys_addr addr, int max_sz,
|
|
208 |
int bswap_needed, a_target_phys_addr target_page_size)
|
|
209 | 209 |
{ |
210 | 210 |
int fd, size, ret; |
211 | 211 |
struct exec e; |
... | ... | |
358 | 358 |
return -1; |
359 | 359 |
} |
360 | 360 |
|
361 |
static void bswap_uboot_header(uboot_image_header_t *hdr)
|
|
361 |
static void bswap_uboot_header(an_uboot_image_header *hdr)
|
|
362 | 362 |
{ |
363 | 363 |
#ifndef HOST_WORDS_BIGENDIAN |
364 | 364 |
bswap32s(&hdr->ih_magic); |
... | ... | |
457 | 457 |
} |
458 | 458 |
|
459 | 459 |
/* Load a U-Boot image. */ |
460 |
int load_uimage(const char *filename, target_phys_addr_t *ep,
|
|
461 |
target_phys_addr_t *loadaddr, int *is_linux)
|
|
460 |
int load_uimage(const char *filename, a_target_phys_addr *ep,
|
|
461 |
a_target_phys_addr *loadaddr, int *is_linux)
|
|
462 | 462 |
{ |
463 | 463 |
int fd; |
464 | 464 |
int size; |
465 |
uboot_image_header_t h;
|
|
466 |
uboot_image_header_t *hdr = &h;
|
|
465 |
an_uboot_image_header h;
|
|
466 |
an_uboot_image_header *hdr = &h;
|
|
467 | 467 |
uint8_t *data = NULL; |
468 | 468 |
int ret = -1; |
469 | 469 |
|
... | ... | |
471 | 471 |
if (fd < 0) |
472 | 472 |
return -1; |
473 | 473 |
|
474 |
size = read(fd, hdr, sizeof(uboot_image_header_t));
|
|
474 |
size = read(fd, hdr, sizeof(an_uboot_image_header));
|
|
475 | 475 |
if (size < 0) |
476 | 476 |
goto out; |
477 | 477 |
|
Also available in: Unified diff