diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2018-12-16 16:32:42 +0000 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2018-12-16 16:32:43 +0000 |
commit | b019f5e5375224a003f260c89d424fea7767b7fc (patch) | |
tree | d57c8a5643f4ef8d7df6a292a00b2d9dc32e0be6 /include | |
parent | 58b1f0f21edcab13f78a376b1d90267626be1275 (diff) | |
parent | bbac02f1e8edfd0663543f6fdad1e7094d860b29 (diff) |
Merge remote-tracking branch 'remotes/pmaydell/tags/pull-misc-20181214' into staging
miscellaneous patches:
* checkpatch.pl: Enforce multiline comment syntax
* Rename cpu_physical_memory_write_rom() to address_space_write_rom()
* disas, monitor, elf_ops: Use address_space_read() to read memory
* Remove load_image() in favour of load_image_size()
* Fix some minor memory leaks in arm boards/devices
* virt: fix broken indentation
# gpg: Signature made Fri 14 Dec 2018 14:41:20 GMT
# gpg: using RSA key 3C2525ED14360CDE
# gpg: Good signature from "Peter Maydell <peter.maydell@linaro.org>"
# gpg: aka "Peter Maydell <pmaydell@gmail.com>"
# gpg: aka "Peter Maydell <pmaydell@chiark.greenend.org.uk>"
# Primary key fingerprint: E1A5 C593 CD41 9DE2 8E83 15CF 3C25 25ED 1436 0CDE
* remotes/pmaydell/tags/pull-misc-20181214: (22 commits)
virt: Fix broken indentation
target/arm: Create timers in realize, not init
tests/test-arm-mptimer: Don't leak string memory
hw/sd/sdhci: Don't leak memory region in sdhci_sysbus_realize()
hw/arm/mps2-tz.c: Free mscname string in make_dma()
target/arm: Free name string in ARMCPRegInfo hashtable entries
include/hw/loader.h: Document load_image_size()
hw/core/loader.c: Remove load_image()
device_tree.c: Don't use load_image()
hw/block/tc58128.c: Don't use load_image()
hw/i386/multiboot.c: Don't use load_image()
hw/i386/pc.c: Don't use load_image()
hw/pci/pci.c: Don't use load_image()
hw/smbios/smbios.c: Don't use load_image()
hw/ppc/ppc405_boards: Don't use load_image()
hw/ppc/mac_newworld, mac_oldworld: Don't use load_image()
elf_ops.h: Use address_space_write() to write memory
monitor: Use address_space_read() to read memory
disas.c: Use address_space_read() to read memory
Rename cpu_physical_memory_write_rom() to address_space_write_rom()
...
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/exec/cpu-common.h | 2 | ||||
-rw-r--r-- | include/exec/memory.h | 26 | ||||
-rw-r--r-- | include/hw/elf_ops.h | 4 | ||||
-rw-r--r-- | include/hw/loader.h | 17 |
4 files changed, 45 insertions, 4 deletions
diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h index 18b40d6145..2ad2d6d86b 100644 --- a/include/exec/cpu-common.h +++ b/include/exec/cpu-common.h @@ -111,8 +111,6 @@ bool cpu_physical_memory_is_io(hwaddr phys_addr); */ void qemu_flush_coalesced_mmio_buffer(void); -void cpu_physical_memory_write_rom(AddressSpace *as, hwaddr addr, - const uint8_t *buf, int len); void cpu_flush_icache_range(hwaddr start, int len); extern struct MemoryRegion io_mem_rom; diff --git a/include/exec/memory.h b/include/exec/memory.h index 8e61450de3..ffd23ed8d8 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -1792,6 +1792,32 @@ MemTxResult address_space_write(AddressSpace *as, hwaddr addr, MemTxAttrs attrs, const uint8_t *buf, int len); +/** + * address_space_write_rom: write to address space, including ROM. + * + * This function writes to the specified address space, but will + * write data to both ROM and RAM. This is used for non-guest + * writes like writes from the gdb debug stub or initial loading + * of ROM contents. + * + * Note that portions of the write which attempt to write data to + * a device will be silently ignored -- only real RAM and ROM will + * be written to. + * + * Return a MemTxResult indicating whether the operation succeeded + * or failed (eg unassigned memory, device rejected the transaction, + * IOMMU fault). + * + * @as: #AddressSpace to be accessed + * @addr: address within that address space + * @attrs: memory transaction attributes + * @buf: buffer with the data transferred + * @len: the number of bytes to write + */ +MemTxResult address_space_write_rom(AddressSpace *as, hwaddr addr, + MemTxAttrs attrs, + const uint8_t *buf, int len); + /* address_space_ld*: load from an address space * address_space_st*: store to an address space * 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: |