#include "uboot_image.h"
#include "loader.h"
#include "fw_cfg.h"
+#include "memory.h"
+#include "exec-memory.h"
#include <zlib.h>
}
/* read()-like version */
-int read_targphys(const char *name,
- int fd, target_phys_addr_t dst_addr, size_t nbytes)
+ssize_t read_targphys(const char *name,
+ int fd, target_phys_addr_t dst_addr, size_t nbytes)
{
uint8_t *buf;
- size_t did;
+ ssize_t did;
buf = g_malloc(nbytes);
did = read(fd, buf, nbytes);
/* return the size or -1 if error */
int load_image_targphys(const char *filename,
- target_phys_addr_t addr, int max_sz)
+ target_phys_addr_t addr, uint64_t max_sz)
{
int size;
size = get_image_size(filename);
- if (size > 0)
+ if (size > max_sz) {
+ return -1;
+ }
+ if (size > 0) {
rom_add_file_fixed(filename, addr, -1);
+ }
return size;
}
int load_aout(const char *filename, target_phys_addr_t addr, int max_sz,
int bswap_needed, target_phys_addr_t target_page_size)
{
- int fd, size, ret;
+ int fd;
+ ssize_t size, ret;
struct exec e;
uint32_t magic;
#define DEFLATED 8
-/* This is the maximum in uboot, so if a uImage overflows this, it would
+/* This is the usual maximum in uboot, so if a uImage overflows this, it would
* overflow on real hardware too. */
-#define UBOOT_MAX_GUNZIP_BYTES 0x800000
+#define UBOOT_MAX_GUNZIP_BYTES (64 << 20)
static ssize_t gunzip(void *dst, size_t dstlen, uint8_t *src,
size_t srclen)
int rom_load_all(void)
{
target_phys_addr_t addr = 0;
- int memtype;
+ MemoryRegionSection section;
Rom *rom;
QTAILQ_FOREACH(rom, &roms, next) {
}
addr = rom->addr;
addr += rom->romsize;
- memtype = cpu_get_physical_page_desc(rom->addr) & (3 << IO_MEM_SHIFT);
- if (memtype == IO_MEM_ROM)
- rom->isrom = 1;
+ section = memory_region_find(get_system_memory(), rom->addr, 1);
+ rom->isrom = section.size && memory_region_is_rom(section.mr);
}
qemu_register_reset(rom_reset, NULL);
roms_loaded = 1;