diff options
Diffstat (limited to 'include/hw')
-rw-r--r-- | include/hw/elf_ops.h | 4 | ||||
-rw-r--r-- | include/hw/loader.h | 17 |
2 files changed, 19 insertions, 2 deletions
diff --git a/include/hw/elf_ops.h b/include/hw/elf_ops.h index 81cecaf27e..74679ff8da 100644 --- a/include/hw/elf_ops.h +++ b/include/hw/elf_ops.h @@ -482,7 +482,9 @@ static int glue(load_elf, SZ)(const char *name, int fd, rom_add_elf_program(label, data, file_size, mem_size, addr, as); } else { - cpu_physical_memory_write(addr, data, file_size); + address_space_write(as ? as : &address_space_memory, + addr, MEMTXATTRS_UNSPECIFIED, + data, file_size); g_free(data); } } diff --git a/include/hw/loader.h b/include/hw/loader.h index 67a0af84ac..0a0ad808ea 100644 --- a/include/hw/loader.h +++ b/include/hw/loader.h @@ -11,7 +11,22 @@ * On error, errno is also set as appropriate. */ int64_t get_image_size(const char *filename); -int load_image(const char *filename, uint8_t *addr); /* deprecated */ +/** + * load_image_size: load an image file into specified buffer + * @filename: Path to the image file + * @addr: Buffer to load image into + * @size: Size of buffer in bytes + * + * Load an image file from disk into the specified buffer. + * If the image is larger than the specified buffer, only + * @size bytes are read (this is not considered an error). + * + * Prefer to use the GLib function g_file_get_contents() rather + * than a "get_image_size()/g_malloc()/load_image_size()" sequence. + * + * Returns the number of bytes read, or -1 on error. On error, + * errno is also set as appropriate. + */ ssize_t load_image_size(const char *filename, void *addr, size_t size); /**load_image_targphys_as: |