1ca20cf32SBlue Swirl #ifndef LOADER_H 2ca20cf32SBlue Swirl #define LOADER_H 3a88b362cSLaszlo Ersek #include "hw/nvram/fw_cfg.h" 4ca20cf32SBlue Swirl 5ca20cf32SBlue Swirl /* loader.c */ 6a1483f88SMichael S. Tsirkin /** 7a1483f88SMichael S. Tsirkin * get_image_size: retrieve size of an image file 8a1483f88SMichael S. Tsirkin * @filename: Path to the image file 9a1483f88SMichael S. Tsirkin * 10a1483f88SMichael S. Tsirkin * Returns the size of the image file on success, -1 otherwise. 11a1483f88SMichael S. Tsirkin * On error, errno is also set as appropriate. 12a1483f88SMichael S. Tsirkin */ 13f3839fdaSLi Zhijian int64_t get_image_size(const char *filename); 1406192329SPeter Maydell /** 1506192329SPeter Maydell * load_image_size: load an image file into specified buffer 1606192329SPeter Maydell * @filename: Path to the image file 1706192329SPeter Maydell * @addr: Buffer to load image into 1806192329SPeter Maydell * @size: Size of buffer in bytes 1906192329SPeter Maydell * 2006192329SPeter Maydell * Load an image file from disk into the specified buffer. 2106192329SPeter Maydell * If the image is larger than the specified buffer, only 2206192329SPeter Maydell * @size bytes are read (this is not considered an error). 2306192329SPeter Maydell * 2406192329SPeter Maydell * Prefer to use the GLib function g_file_get_contents() rather 2506192329SPeter Maydell * than a "get_image_size()/g_malloc()/load_image_size()" sequence. 2606192329SPeter Maydell * 2706192329SPeter Maydell * Returns the number of bytes read, or -1 on error. On error, 2806192329SPeter Maydell * errno is also set as appropriate. 2906192329SPeter Maydell */ 30ea87616dSBenjamin Herrenschmidt ssize_t load_image_size(const char *filename, void *addr, size_t size); 3193ffc7c7SAlistair Francis 3293ffc7c7SAlistair Francis /**load_image_targphys_as: 3393ffc7c7SAlistair Francis * @filename: Path to the image file 3493ffc7c7SAlistair Francis * @addr: Address to load the image to 3593ffc7c7SAlistair Francis * @max_sz: The maximum size of the image to load 3693ffc7c7SAlistair Francis * @as: The AddressSpace to load the ELF to. The value of address_space_memory 3793ffc7c7SAlistair Francis * is used if nothing is supplied here. 3893ffc7c7SAlistair Francis * 3993ffc7c7SAlistair Francis * Load a fixed image into memory. 4093ffc7c7SAlistair Francis * 4193ffc7c7SAlistair Francis * Returns the size of the loaded image on success, -1 otherwise. 4293ffc7c7SAlistair Francis */ 43*af975131SJamie Iles ssize_t load_image_targphys_as(const char *filename, 4493ffc7c7SAlistair Francis hwaddr addr, uint64_t max_sz, AddressSpace *as); 4593ffc7c7SAlistair Francis 46e4a25ed9SSu Hang /**load_targphys_hex_as: 47e4a25ed9SSu Hang * @filename: Path to the .hex file 48e4a25ed9SSu Hang * @entry: Store the entry point given by the .hex file 49e4a25ed9SSu Hang * @as: The AddressSpace to load the .hex file to. The value of 50e4a25ed9SSu Hang * address_space_memory is used if nothing is supplied here. 51e4a25ed9SSu Hang * 52e4a25ed9SSu Hang * Load a fixed .hex file into memory. 53e4a25ed9SSu Hang * 54e4a25ed9SSu Hang * Returns the size of the loaded .hex file on success, -1 otherwise. 55e4a25ed9SSu Hang */ 56*af975131SJamie Iles ssize_t load_targphys_hex_as(const char *filename, hwaddr *entry, 57*af975131SJamie Iles AddressSpace *as); 58e4a25ed9SSu Hang 5993ffc7c7SAlistair Francis /** load_image_targphys: 6093ffc7c7SAlistair Francis * Same as load_image_targphys_as(), but doesn't allow the caller to specify 6193ffc7c7SAlistair Francis * an AddressSpace. 6293ffc7c7SAlistair Francis */ 63*af975131SJamie Iles ssize_t load_image_targphys(const char *filename, hwaddr, 6480a2ba3dSMark Langsdorf uint64_t max_sz); 6593ffc7c7SAlistair Francis 6676151cacSPeter Maydell /** 6776151cacSPeter Maydell * load_image_mr: load an image into a memory region 6876151cacSPeter Maydell * @filename: Path to the image file 6976151cacSPeter Maydell * @mr: Memory Region to load into 7076151cacSPeter Maydell * 7176151cacSPeter Maydell * Load the specified file into the memory region. 7276151cacSPeter Maydell * The file loaded is registered as a ROM, so its contents will be 7376151cacSPeter Maydell * reinstated whenever the system is reset. 7476151cacSPeter Maydell * If the file is larger than the memory region's size the call will fail. 7576151cacSPeter Maydell * Returns -1 on failure, or the size of the file. 7676151cacSPeter Maydell */ 77*af975131SJamie Iles ssize_t load_image_mr(const char *filename, MemoryRegion *mr); 787d48a0f7SLaszlo Ersek 797d48a0f7SLaszlo Ersek /* This is the limit on the maximum uncompressed image size that 807d48a0f7SLaszlo Ersek * load_image_gzipped_buffer() and load_image_gzipped() will read. It prevents 817d48a0f7SLaszlo Ersek * g_malloc() in those functions from allocating a huge amount of memory. 827d48a0f7SLaszlo Ersek */ 837d48a0f7SLaszlo Ersek #define LOAD_IMAGE_MAX_GUNZIP_BYTES (256 << 20) 847d48a0f7SLaszlo Ersek 85*af975131SJamie Iles ssize_t load_image_gzipped_buffer(const char *filename, uint64_t max_sz, 867d48a0f7SLaszlo Ersek uint8_t **buffer); 87*af975131SJamie Iles ssize_t load_image_gzipped(const char *filename, hwaddr addr, uint64_t max_sz); 8818674b26SAlexey Kardashevskiy 8918674b26SAlexey Kardashevskiy #define ELF_LOAD_FAILED -1 9018674b26SAlexey Kardashevskiy #define ELF_LOAD_NOT_ELF -2 9118674b26SAlexey Kardashevskiy #define ELF_LOAD_WRONG_ARCH -3 9218674b26SAlexey Kardashevskiy #define ELF_LOAD_WRONG_ENDIAN -4 9341a26351SStefano Garzarella #define ELF_LOAD_TOO_BIG -5 948975eb89SLuc Michel const char *load_elf_strerror(ssize_t error); 95140b7ce5SPeter Crosthwaite 96a2480ffaSMichael Clark /** load_elf_ram_sym: 97140b7ce5SPeter Crosthwaite * @filename: Path of ELF file 984366e1dbSLiam Merwick * @elf_note_fn: optional function to parse ELF Note type 994366e1dbSLiam Merwick * passed via @translate_opaque 100140b7ce5SPeter Crosthwaite * @translate_fn: optional function to translate load addresses 101140b7ce5SPeter Crosthwaite * @translate_opaque: opaque data passed to @translate_fn 102140b7ce5SPeter Crosthwaite * @pentry: Populated with program entry point. Ignored if NULL. 103140b7ce5SPeter Crosthwaite * @lowaddr: Populated with lowest loaded address. Ignored if NULL. 104140b7ce5SPeter Crosthwaite * @highaddr: Populated with highest loaded address. Ignored if NULL. 1056cdda0ffSAleksandar Markovic * @pflags: Populated with ELF processor-specific flags. Ignore if NULL. 106140b7ce5SPeter Crosthwaite * @bigendian: Expected ELF endianness. 0 for LE otherwise BE 107140b7ce5SPeter Crosthwaite * @elf_machine: Expected ELF machine type 108140b7ce5SPeter Crosthwaite * @clear_lsb: Set to mask off LSB of addresses (Some architectures use 109140b7ce5SPeter Crosthwaite * this for non-address data) 1107ef295eaSPeter Crosthwaite * @data_swab: Set to order of byte swapping for data. 0 for no swap, 1 1117ef295eaSPeter Crosthwaite * for swapping bytes within halfwords, 2 for bytes within 1127ef295eaSPeter Crosthwaite * words and 3 for within doublewords. 11370bb1d16SAlistair Francis * @as: The AddressSpace to load the ELF to. The value of address_space_memory 11470bb1d16SAlistair Francis * is used if nothing is supplied here. 11534f1b23fSFarhan Ali * @load_rom : Load ELF binary as ROM 116a2480ffaSMichael Clark * @sym_cb: Callback function for symbol table entries 117140b7ce5SPeter Crosthwaite * 118140b7ce5SPeter Crosthwaite * Load an ELF file's contents to the emulated system's address space. 119140b7ce5SPeter Crosthwaite * Clients may optionally specify a callback to perform address 120140b7ce5SPeter Crosthwaite * translations. @pentry, @lowaddr and @highaddr are optional pointers 121140b7ce5SPeter Crosthwaite * which will be populated with various load information. @bigendian and 122140b7ce5SPeter Crosthwaite * @elf_machine give the expected endianness and machine for the ELF the 123140b7ce5SPeter Crosthwaite * load will fail if the target ELF does not match. Some architectures 124140b7ce5SPeter Crosthwaite * have some architecture-specific behaviours that come into effect when 125140b7ce5SPeter Crosthwaite * their particular values for @elf_machine are set. 1268cf6e9daSAlistair Francis * If @elf_machine is EM_NONE then the machine type will be read from the 1278cf6e9daSAlistair Francis * ELF header and no checks will be carried out against the machine type. 128140b7ce5SPeter Crosthwaite */ 129a2480ffaSMichael Clark typedef void (*symbol_fn_t)(const char *st_name, int st_info, 130a2480ffaSMichael Clark uint64_t st_value, uint64_t st_size); 131a2480ffaSMichael Clark 1328975eb89SLuc Michel ssize_t load_elf_ram_sym(const char *filename, 1334366e1dbSLiam Merwick uint64_t (*elf_note_fn)(void *, void *, bool), 134a2480ffaSMichael Clark uint64_t (*translate_fn)(void *, uint64_t), 135a2480ffaSMichael Clark void *translate_opaque, uint64_t *pentry, 1368975eb89SLuc Michel uint64_t *lowaddr, uint64_t *highaddr, 1378975eb89SLuc Michel uint32_t *pflags, int big_endian, int elf_machine, 1386cdda0ffSAleksandar Markovic int clear_lsb, int data_swab, 139a2480ffaSMichael Clark AddressSpace *as, bool load_rom, symbol_fn_t sym_cb); 140a2480ffaSMichael Clark 141a2480ffaSMichael Clark /** load_elf_ram: 142a2480ffaSMichael Clark * Same as load_elf_ram_sym(), but doesn't allow the caller to specify a 143a2480ffaSMichael Clark * symbol callback function 144a2480ffaSMichael Clark */ 1458975eb89SLuc Michel ssize_t load_elf_ram(const char *filename, 1464366e1dbSLiam Merwick uint64_t (*elf_note_fn)(void *, void *, bool), 14734f1b23fSFarhan Ali uint64_t (*translate_fn)(void *, uint64_t), 1488975eb89SLuc Michel void *translate_opaque, uint64_t *pentry, 1498975eb89SLuc Michel uint64_t *lowaddr, uint64_t *highaddr, uint32_t *pflags, 1508975eb89SLuc Michel int big_endian, int elf_machine, int clear_lsb, 1518975eb89SLuc Michel int data_swab, AddressSpace *as, bool load_rom); 15234f1b23fSFarhan Ali 15334f1b23fSFarhan Ali /** load_elf_as: 15434f1b23fSFarhan Ali * Same as load_elf_ram(), but always loads the elf as ROM 15534f1b23fSFarhan Ali */ 1568975eb89SLuc Michel ssize_t load_elf_as(const char *filename, 1574366e1dbSLiam Merwick uint64_t (*elf_note_fn)(void *, void *, bool), 15870bb1d16SAlistair Francis uint64_t (*translate_fn)(void *, uint64_t), 15970bb1d16SAlistair Francis void *translate_opaque, uint64_t *pentry, uint64_t *lowaddr, 1606cdda0ffSAleksandar Markovic uint64_t *highaddr, uint32_t *pflags, int big_endian, 1616cdda0ffSAleksandar Markovic int elf_machine, int clear_lsb, int data_swab, 1626cdda0ffSAleksandar Markovic AddressSpace *as); 163140b7ce5SPeter Crosthwaite 16470bb1d16SAlistair Francis /** load_elf: 16570bb1d16SAlistair Francis * Same as load_elf_as(), but doesn't allow the caller to specify an 16670bb1d16SAlistair Francis * AddressSpace. 16770bb1d16SAlistair Francis */ 1688975eb89SLuc Michel ssize_t load_elf(const char *filename, 1694366e1dbSLiam Merwick uint64_t (*elf_note_fn)(void *, void *, bool), 1704366e1dbSLiam Merwick uint64_t (*translate_fn)(void *, uint64_t), 171409dbce5SAurelien Jarno void *translate_opaque, uint64_t *pentry, uint64_t *lowaddr, 1726cdda0ffSAleksandar Markovic uint64_t *highaddr, uint32_t *pflags, int big_endian, 1736cdda0ffSAleksandar Markovic int elf_machine, int clear_lsb, int data_swab); 17404ae712aSPeter Crosthwaite 17504ae712aSPeter Crosthwaite /** load_elf_hdr: 17604ae712aSPeter Crosthwaite * @filename: Path of ELF file 17704ae712aSPeter Crosthwaite * @hdr: Buffer to populate with header data. Header data will not be 17804ae712aSPeter Crosthwaite * filled if set to NULL. 17904ae712aSPeter Crosthwaite * @is64: Set to true if the ELF is 64bit. Ignored if set to NULL 18004ae712aSPeter Crosthwaite * @errp: Populated with an error in failure cases 18104ae712aSPeter Crosthwaite * 18204ae712aSPeter Crosthwaite * Inspect an ELF file's header. Read its full header contents into a 18304ae712aSPeter Crosthwaite * buffer and/or determine if the ELF is 64bit. 18404ae712aSPeter Crosthwaite */ 18504ae712aSPeter Crosthwaite void load_elf_hdr(const char *filename, void *hdr, bool *is64, Error **errp); 18604ae712aSPeter Crosthwaite 187*af975131SJamie Iles ssize_t load_aout(const char *filename, hwaddr addr, int max_sz, 188a8170e5eSAvi Kivity int bswap_needed, hwaddr target_page_size); 1895e774eb3SAlistair Francis 190f831f955SNick Hudson #define LOAD_UIMAGE_LOADADDR_INVALID (-1) 191f831f955SNick Hudson 1925e774eb3SAlistair Francis /** load_uimage_as: 1935e774eb3SAlistair Francis * @filename: Path of uimage file 1945e774eb3SAlistair Francis * @ep: Populated with program entry point. Ignored if NULL. 195f831f955SNick Hudson * @loadaddr: load address if none specified in the image or when loading a 196f831f955SNick Hudson * ramdisk. Populated with the load address. Ignored if NULL or 197f831f955SNick Hudson * LOAD_UIMAGE_LOADADDR_INVALID (images which do not specify a load 198f831f955SNick Hudson * address will not be loadable). 1995e774eb3SAlistair Francis * @is_linux: Is set to true if the image loaded is Linux. Ignored if NULL. 2005e774eb3SAlistair Francis * @translate_fn: optional function to translate load addresses 2015e774eb3SAlistair Francis * @translate_opaque: opaque data passed to @translate_fn 2025e774eb3SAlistair Francis * @as: The AddressSpace to load the ELF to. The value of address_space_memory 2035e774eb3SAlistair Francis * is used if nothing is supplied here. 2045e774eb3SAlistair Francis * 2055e774eb3SAlistair Francis * Loads a u-boot image into memory. 2065e774eb3SAlistair Francis * 2075e774eb3SAlistair Francis * Returns the size of the loaded image on success, -1 otherwise. 2085e774eb3SAlistair Francis */ 209*af975131SJamie Iles ssize_t load_uimage_as(const char *filename, hwaddr *ep, 2105e774eb3SAlistair Francis hwaddr *loadaddr, int *is_linux, 2115e774eb3SAlistair Francis uint64_t (*translate_fn)(void *, uint64_t), 2125e774eb3SAlistair Francis void *translate_opaque, AddressSpace *as); 2135e774eb3SAlistair Francis 2145e774eb3SAlistair Francis /** load_uimage: 2155e774eb3SAlistair Francis * Same as load_uimage_as(), but doesn't allow the caller to specify an 2165e774eb3SAlistair Francis * AddressSpace. 2175e774eb3SAlistair Francis */ 218*af975131SJamie Iles ssize_t load_uimage(const char *filename, hwaddr *ep, 21925bda50aSMax Filippov hwaddr *loadaddr, int *is_linux, 22025bda50aSMax Filippov uint64_t (*translate_fn)(void *, uint64_t), 22125bda50aSMax Filippov void *translate_opaque); 222ca20cf32SBlue Swirl 22384aee0deSSoren Brinkmann /** 22497df5feeSPeter Maydell * load_ramdisk_as: 22584aee0deSSoren Brinkmann * @filename: Path to the ramdisk image 22684aee0deSSoren Brinkmann * @addr: Memory address to load the ramdisk to 22784aee0deSSoren Brinkmann * @max_sz: Maximum allowed ramdisk size (for non-u-boot ramdisks) 22897df5feeSPeter Maydell * @as: The AddressSpace to load the ELF to. The value of address_space_memory 22997df5feeSPeter Maydell * is used if nothing is supplied here. 23084aee0deSSoren Brinkmann * 23184aee0deSSoren Brinkmann * Load a ramdisk image with U-Boot header to the specified memory 23284aee0deSSoren Brinkmann * address. 23384aee0deSSoren Brinkmann * 23484aee0deSSoren Brinkmann * Returns the size of the loaded image on success, -1 otherwise. 23584aee0deSSoren Brinkmann */ 236*af975131SJamie Iles ssize_t load_ramdisk_as(const char *filename, hwaddr addr, uint64_t max_sz, 23797df5feeSPeter Maydell AddressSpace *as); 23897df5feeSPeter Maydell 23997df5feeSPeter Maydell /** 24097df5feeSPeter Maydell * load_ramdisk: 24197df5feeSPeter Maydell * Same as load_ramdisk_as(), but doesn't allow the caller to specify 24297df5feeSPeter Maydell * an AddressSpace. 24397df5feeSPeter Maydell */ 244*af975131SJamie Iles ssize_t load_ramdisk(const char *filename, hwaddr addr, uint64_t max_sz); 24584aee0deSSoren Brinkmann 24651b58561SPaul Burton ssize_t gunzip(void *dst, size_t dstlen, uint8_t *src, size_t srclen); 24751b58561SPaul Burton 248725e14e9SMarkus Armbruster ssize_t read_targphys(const char *name, 249a8170e5eSAvi Kivity int fd, hwaddr dst_addr, size_t nbytes); 2503c178e72SGerd Hoffmann void pstrcpy_targphys(const char *name, 251a8170e5eSAvi Kivity hwaddr dest, int buf_size, 252ca20cf32SBlue Swirl const char *source); 25345a50b16SGerd Hoffmann 254ac41881bSMichael S. Tsirkin extern bool option_rom_has_mr; 25598bc3ab0SMichael S. Tsirkin extern bool rom_file_has_mr; 256bdb5ee30SGerd Hoffmann 257*af975131SJamie Iles ssize_t rom_add_file(const char *file, const char *fw_dir, 258ac41881bSMichael S. Tsirkin hwaddr addr, int32_t bootindex, 2593e76099aSAlistair Francis bool option_rom, MemoryRegion *mr, AddressSpace *as); 260339240b5SPaolo Bonzini MemoryRegion *rom_add_blob(const char *name, const void *blob, size_t len, 261339240b5SPaolo Bonzini size_t max_len, hwaddr addr, 262339240b5SPaolo Bonzini const char *fw_file_name, 2636f6f4aecSMarc-André Lureau FWCfgCallback fw_callback, 264baf2d5bfSMichael S. Tsirkin void *callback_opaque, AddressSpace *as, 265baf2d5bfSMichael S. Tsirkin bool read_only); 266fef28891SStefano Garzarella int rom_add_elf_program(const char *name, GMappedFile *mapped_file, void *data, 267fef28891SStefano Garzarella size_t datasize, size_t romsize, hwaddr addr, 268fef28891SStefano Garzarella AddressSpace *as); 2696b3f7f63SEric Auger int rom_check_and_register_reset(void); 270a88b362cSLaszlo Ersek void rom_set_fw(FWCfgState *f); 271bab47d9aSGerd Hoffmann void rom_set_order_override(int order); 272bab47d9aSGerd Hoffmann void rom_reset_order_override(void); 273e2336043SStefan Hajnoczi 274e2336043SStefan Hajnoczi /** 275e2336043SStefan Hajnoczi * rom_transaction_begin: 276e2336043SStefan Hajnoczi * 277e2336043SStefan Hajnoczi * Call this before of a series of rom_add_*() calls. Call 278e2336043SStefan Hajnoczi * rom_transaction_end() afterwards to commit or abort. These functions are 279e2336043SStefan Hajnoczi * useful for undoing a series of rom_add_*() calls if image file loading fails 280e2336043SStefan Hajnoczi * partway through. 281e2336043SStefan Hajnoczi */ 282e2336043SStefan Hajnoczi void rom_transaction_begin(void); 283e2336043SStefan Hajnoczi 284e2336043SStefan Hajnoczi /** 285e2336043SStefan Hajnoczi * rom_transaction_end: 286e2336043SStefan Hajnoczi * @commit: true to commit added roms, false to drop added roms 287e2336043SStefan Hajnoczi * 288e2336043SStefan Hajnoczi * Call this after a series of rom_add_*() calls. See rom_transaction_begin(). 289e2336043SStefan Hajnoczi */ 290e2336043SStefan Hajnoczi void rom_transaction_end(bool commit); 291e2336043SStefan Hajnoczi 292a8170e5eSAvi Kivity int rom_copy(uint8_t *dest, hwaddr addr, size_t size); 2930f0f8b61SThomas Huth void *rom_ptr(hwaddr addr, size_t size); 2941228c459SPeter Maydell /** 2951228c459SPeter Maydell * rom_ptr_for_as: Return a pointer to ROM blob data for the address 2961228c459SPeter Maydell * @as: AddressSpace to look for the ROM blob in 2971228c459SPeter Maydell * @addr: Address within @as 2981228c459SPeter Maydell * @size: size of data required in bytes 2991228c459SPeter Maydell * 3001228c459SPeter Maydell * Returns: pointer into the data which backs the matching ROM blob, 3011228c459SPeter Maydell * or NULL if no blob covers the address range. 3021228c459SPeter Maydell * 3031228c459SPeter Maydell * This function looks for a ROM blob which covers the specified range 3041228c459SPeter Maydell * of bytes of length @size starting at @addr within the address space 3051228c459SPeter Maydell * @as. This is useful for code which runs as part of board 3061228c459SPeter Maydell * initialization or CPU reset which wants to read data that is part 3071228c459SPeter Maydell * of a user-supplied guest image or other guest memory contents, but 3081228c459SPeter Maydell * which runs before the ROM loader's reset function has copied the 3091228c459SPeter Maydell * blobs into guest memory. 3101228c459SPeter Maydell * 3111228c459SPeter Maydell * rom_ptr_for_as() will look not just for blobs loaded directly to 3121228c459SPeter Maydell * the specified address, but also for blobs which were loaded to an 3131228c459SPeter Maydell * alias of the region at a different location in the AddressSpace. 3141228c459SPeter Maydell * In other words, if a machine model has RAM at address 0x0000_0000 3151228c459SPeter Maydell * which is aliased to also appear at 0x1000_0000, rom_ptr_for_as() 3161228c459SPeter Maydell * will return the correct data whether the guest image was linked and 3171228c459SPeter Maydell * loaded at 0x0000_0000 or 0x1000_0000. Contrast rom_ptr(), which 3181228c459SPeter Maydell * will only return data if the image load address is an exact match 3191228c459SPeter Maydell * with the queried address. 3201228c459SPeter Maydell * 3211228c459SPeter Maydell * New code should prefer to use rom_ptr_for_as() instead of 3221228c459SPeter Maydell * rom_ptr(). 3231228c459SPeter Maydell */ 3241228c459SPeter Maydell void *rom_ptr_for_as(AddressSpace *as, hwaddr addr, size_t size); 3251ce6be24SMarkus Armbruster void hmp_info_roms(Monitor *mon, const QDict *qdict); 32645a50b16SGerd Hoffmann 3272e55e842SGleb Natapov #define rom_add_file_fixed(_f, _a, _i) \ 3283e76099aSAlistair Francis rom_add_file(_f, NULL, _a, _i, false, NULL, NULL) 32945a50b16SGerd Hoffmann #define rom_add_blob_fixed(_f, _b, _l, _a) \ 330baf2d5bfSMichael S. Tsirkin rom_add_blob(_f, _b, _l, _l, _a, NULL, NULL, NULL, NULL, true) 33176151cacSPeter Maydell #define rom_add_file_mr(_f, _mr, _i) \ 3323e76099aSAlistair Francis rom_add_file(_f, NULL, 0, _i, false, _mr, NULL) 3333e76099aSAlistair Francis #define rom_add_file_as(_f, _as, _i) \ 3343e76099aSAlistair Francis rom_add_file(_f, NULL, 0, _i, false, NULL, _as) 33593ffc7c7SAlistair Francis #define rom_add_file_fixed_as(_f, _a, _i, _as) \ 33693ffc7c7SAlistair Francis rom_add_file(_f, NULL, _a, _i, false, NULL, _as) 3375e774eb3SAlistair Francis #define rom_add_blob_fixed_as(_f, _b, _l, _a, _as) \ 338baf2d5bfSMichael S. Tsirkin rom_add_blob(_f, _b, _l, _l, _a, NULL, NULL, NULL, _as, true) 33945a50b16SGerd Hoffmann 340*af975131SJamie Iles ssize_t rom_add_vga(const char *file); 341*af975131SJamie Iles ssize_t rom_add_option(const char *file, int32_t bootindex); 34245a50b16SGerd Hoffmann 34351b58561SPaul Burton /* This is the usual maximum in uboot, so if a uImage overflows this, it would 34451b58561SPaul Burton * overflow on real hardware too. */ 34551b58561SPaul Burton #define UBOOT_MAX_GUNZIP_BYTES (64 << 20) 34651b58561SPaul Burton 3475fc983afSAlex Bennée typedef struct RomGap { 3485fc983afSAlex Bennée hwaddr base; 3495fc983afSAlex Bennée size_t size; 3505fc983afSAlex Bennée } RomGap; 3515fc983afSAlex Bennée 3525fc983afSAlex Bennée /** 3535fc983afSAlex Bennée * rom_find_largest_gap_between: return largest gap between ROMs in given range 3545fc983afSAlex Bennée * 3555fc983afSAlex Bennée * Given a range of addresses, this function finds the largest 3565fc983afSAlex Bennée * contiguous subrange which has no ROMs loaded to it. That is, 3575fc983afSAlex Bennée * it finds the biggest gap which is free for use for other things. 3585fc983afSAlex Bennée */ 3595fc983afSAlex Bennée RomGap rom_find_largest_gap_between(hwaddr base, size_t size); 3605fc983afSAlex Bennée 361ca20cf32SBlue Swirl #endif 362