loader: Implement .hex file loader

This patch adds Intel Hexadecimal Object File format support to the
generic loader device.  The file format specification is available here:
http://www.piclist.com/techref/fileext/hex/intel.htm

This file format is often used with microcontrollers such as the
micro:bit, Arduino, STM32, etc.  Users expect to be able to run .hex
files directly with without first converting them to ELF.  Most
micro:bit code is developed in web-based IDEs without direct user access
to binutils so it is important for QEMU to handle this file format
natively.

Signed-off-by: Su Hang <suhang16@mails.ucas.ac.cn>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Acked-by: Alistair Francis <alistair.francis@wdc.com>
Message-id: 20180814162739.11814-6-stefanha@redhat.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Su Hang 2018-08-16 14:05:28 +01:00 committed by Peter Maydell
parent e2336043cc
commit e4a25ed919
3 changed files with 265 additions and 0 deletions

View file

@ -28,6 +28,18 @@ ssize_t load_image_size(const char *filename, void *addr, size_t size);
int load_image_targphys_as(const char *filename,
hwaddr addr, uint64_t max_sz, AddressSpace *as);
/**load_targphys_hex_as:
* @filename: Path to the .hex file
* @entry: Store the entry point given by the .hex file
* @as: The AddressSpace to load the .hex file to. The value of
* address_space_memory is used if nothing is supplied here.
*
* Load a fixed .hex file into memory.
*
* Returns the size of the loaded .hex file on success, -1 otherwise.
*/
int load_targphys_hex_as(const char *filename, hwaddr *entry, AddressSpace *as);
/** load_image_targphys:
* Same as load_image_targphys_as(), but doesn't allow the caller to specify
* an AddressSpace.