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 */ 43af975131SJamie 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 */ 56af975131SJamie Iles ssize_t load_targphys_hex_as(const char *filename, hwaddr *entry, 57af975131SJamie 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 */ 63af975131SJamie 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 */ 77af975131SJamie 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 80a376a8d5SAni Sinha * load_image_gzipped_buffer() 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 85af975131SJamie Iles ssize_t load_image_gzipped_buffer(const char *filename, uint64_t max_sz, 867d48a0f7SLaszlo Ersek uint8_t **buffer); 87ff114228SArd Biesheuvel /** 88ff114228SArd Biesheuvel * unpack_efi_zboot_image: 89ff114228SArd Biesheuvel * @buffer: pointer to a variable holding the address of a buffer containing the 90ff114228SArd Biesheuvel * image 91ff114228SArd Biesheuvel * @size: pointer to a variable holding the size of the buffer 92ff114228SArd Biesheuvel * 93ff114228SArd Biesheuvel * Check whether the buffer contains a EFI zboot image, and if it does, extract 94ff114228SArd Biesheuvel * the compressed payload and decompress it into a new buffer. If successful, 95ff114228SArd Biesheuvel * the old buffer is freed, and the *buffer and size variables pointed to by the 96ff114228SArd Biesheuvel * function arguments are updated to refer to the newly populated buffer. 97ff114228SArd Biesheuvel * 98ff114228SArd Biesheuvel * Returns 0 if the image could not be identified as a EFI zboot image. 99ff114228SArd Biesheuvel * Returns -1 if the buffer contents were identified as a EFI zboot image, but 100ff114228SArd Biesheuvel * unpacking failed for any reason. 101ff114228SArd Biesheuvel * Returns the size of the decompressed payload if decompression was performed 102ff114228SArd Biesheuvel * successfully. 103ff114228SArd Biesheuvel */ 104e3526d0fSJiaxun Yang ssize_t unpack_efi_zboot_image(uint8_t **buffer, ssize_t *size); 105ff114228SArd Biesheuvel 10618674b26SAlexey Kardashevskiy #define ELF_LOAD_FAILED -1 10718674b26SAlexey Kardashevskiy #define ELF_LOAD_NOT_ELF -2 10818674b26SAlexey Kardashevskiy #define ELF_LOAD_WRONG_ARCH -3 10918674b26SAlexey Kardashevskiy #define ELF_LOAD_WRONG_ENDIAN -4 11041a26351SStefano Garzarella #define ELF_LOAD_TOO_BIG -5 1118975eb89SLuc Michel const char *load_elf_strerror(ssize_t error); 112140b7ce5SPeter Crosthwaite 113a2480ffaSMichael Clark /** load_elf_ram_sym: 114140b7ce5SPeter Crosthwaite * @filename: Path of ELF file 1154366e1dbSLiam Merwick * @elf_note_fn: optional function to parse ELF Note type 1164366e1dbSLiam Merwick * passed via @translate_opaque 117140b7ce5SPeter Crosthwaite * @translate_fn: optional function to translate load addresses 118140b7ce5SPeter Crosthwaite * @translate_opaque: opaque data passed to @translate_fn 119140b7ce5SPeter Crosthwaite * @pentry: Populated with program entry point. Ignored if NULL. 120140b7ce5SPeter Crosthwaite * @lowaddr: Populated with lowest loaded address. Ignored if NULL. 121140b7ce5SPeter Crosthwaite * @highaddr: Populated with highest loaded address. Ignored if NULL. 1226cdda0ffSAleksandar Markovic * @pflags: Populated with ELF processor-specific flags. Ignore if NULL. 1233cd6dbceSPhilippe Mathieu-Daudé * @elf_data_order: Expected ELF endianness (ELFDATA2LSB or ELFDATA2MSB). 124140b7ce5SPeter Crosthwaite * @elf_machine: Expected ELF machine type 125140b7ce5SPeter Crosthwaite * @clear_lsb: Set to mask off LSB of addresses (Some architectures use 126140b7ce5SPeter Crosthwaite * this for non-address data) 1277ef295eaSPeter Crosthwaite * @data_swab: Set to order of byte swapping for data. 0 for no swap, 1 1287ef295eaSPeter Crosthwaite * for swapping bytes within halfwords, 2 for bytes within 1297ef295eaSPeter Crosthwaite * words and 3 for within doublewords. 13070bb1d16SAlistair Francis * @as: The AddressSpace to load the ELF to. The value of address_space_memory 13170bb1d16SAlistair Francis * is used if nothing is supplied here. 13234f1b23fSFarhan Ali * @load_rom : Load ELF binary as ROM 133a2480ffaSMichael Clark * @sym_cb: Callback function for symbol table entries 134140b7ce5SPeter Crosthwaite * 135140b7ce5SPeter Crosthwaite * Load an ELF file's contents to the emulated system's address space. 136140b7ce5SPeter Crosthwaite * Clients may optionally specify a callback to perform address 137140b7ce5SPeter Crosthwaite * translations. @pentry, @lowaddr and @highaddr are optional pointers 138140b7ce5SPeter Crosthwaite * which will be populated with various load information. @bigendian and 139140b7ce5SPeter Crosthwaite * @elf_machine give the expected endianness and machine for the ELF the 140140b7ce5SPeter Crosthwaite * load will fail if the target ELF does not match. Some architectures 141140b7ce5SPeter Crosthwaite * have some architecture-specific behaviours that come into effect when 142140b7ce5SPeter Crosthwaite * their particular values for @elf_machine are set. 1438cf6e9daSAlistair Francis * If @elf_machine is EM_NONE then the machine type will be read from the 1448cf6e9daSAlistair Francis * ELF header and no checks will be carried out against the machine type. 145140b7ce5SPeter Crosthwaite */ 146a2480ffaSMichael Clark typedef void (*symbol_fn_t)(const char *st_name, int st_info, 147a2480ffaSMichael Clark uint64_t st_value, uint64_t st_size); 148a2480ffaSMichael Clark 1498975eb89SLuc Michel ssize_t load_elf_ram_sym(const char *filename, 1504366e1dbSLiam Merwick uint64_t (*elf_note_fn)(void *, void *, bool), 151a2480ffaSMichael Clark uint64_t (*translate_fn)(void *, uint64_t), 152a2480ffaSMichael Clark void *translate_opaque, uint64_t *pentry, 1538975eb89SLuc Michel uint64_t *lowaddr, uint64_t *highaddr, 1543cd6dbceSPhilippe Mathieu-Daudé uint32_t *pflags, int elf_data_order, int elf_machine, 1556cdda0ffSAleksandar Markovic int clear_lsb, int data_swab, 156a2480ffaSMichael Clark AddressSpace *as, bool load_rom, symbol_fn_t sym_cb); 157a2480ffaSMichael Clark 15834f1b23fSFarhan Ali /** load_elf_as: 159ff12b602SPhilippe Mathieu-Daudé * Same as load_elf_ram_sym(), but always loads the elf as ROM 16034f1b23fSFarhan Ali */ 1618975eb89SLuc Michel ssize_t load_elf_as(const char *filename, 1624366e1dbSLiam Merwick uint64_t (*elf_note_fn)(void *, void *, bool), 16370bb1d16SAlistair Francis uint64_t (*translate_fn)(void *, uint64_t), 16470bb1d16SAlistair Francis void *translate_opaque, uint64_t *pentry, uint64_t *lowaddr, 16590f5c86aSPhilippe Mathieu-Daudé uint64_t *highaddr, uint32_t *pflags, int elf_data_order, 1666cdda0ffSAleksandar Markovic int elf_machine, int clear_lsb, int data_swab, 1676cdda0ffSAleksandar Markovic AddressSpace *as); 168140b7ce5SPeter Crosthwaite 16970bb1d16SAlistair Francis /** load_elf: 17070bb1d16SAlistair Francis * Same as load_elf_as(), but doesn't allow the caller to specify an 17170bb1d16SAlistair Francis * AddressSpace. 17270bb1d16SAlistair Francis */ 1738975eb89SLuc Michel ssize_t load_elf(const char *filename, 1744366e1dbSLiam Merwick uint64_t (*elf_note_fn)(void *, void *, bool), 1754366e1dbSLiam Merwick uint64_t (*translate_fn)(void *, uint64_t), 176409dbce5SAurelien Jarno void *translate_opaque, uint64_t *pentry, uint64_t *lowaddr, 177adc1a4a2SPhilippe Mathieu-Daudé uint64_t *highaddr, uint32_t *pflags, int elf_data_order, 1786cdda0ffSAleksandar Markovic int elf_machine, int clear_lsb, int data_swab); 17904ae712aSPeter Crosthwaite 18004ae712aSPeter Crosthwaite /** load_elf_hdr: 18104ae712aSPeter Crosthwaite * @filename: Path of ELF file 18204ae712aSPeter Crosthwaite * @hdr: Buffer to populate with header data. Header data will not be 18304ae712aSPeter Crosthwaite * filled if set to NULL. 18404ae712aSPeter Crosthwaite * @is64: Set to true if the ELF is 64bit. Ignored if set to NULL 18504ae712aSPeter Crosthwaite * @errp: Populated with an error in failure cases 18604ae712aSPeter Crosthwaite * 18704ae712aSPeter Crosthwaite * Inspect an ELF file's header. Read its full header contents into a 18804ae712aSPeter Crosthwaite * buffer and/or determine if the ELF is 64bit. 18904ae712aSPeter Crosthwaite */ 19004ae712aSPeter Crosthwaite void load_elf_hdr(const char *filename, void *hdr, bool *is64, Error **errp); 19104ae712aSPeter Crosthwaite 192af975131SJamie Iles ssize_t load_aout(const char *filename, hwaddr addr, int max_sz, 193*134ab17fSPaolo Bonzini bool big_endian, hwaddr target_page_size); 1945e774eb3SAlistair Francis 195f831f955SNick Hudson #define LOAD_UIMAGE_LOADADDR_INVALID (-1) 196f831f955SNick Hudson 1975e774eb3SAlistair Francis /** load_uimage_as: 1985e774eb3SAlistair Francis * @filename: Path of uimage file 1995e774eb3SAlistair Francis * @ep: Populated with program entry point. Ignored if NULL. 200f831f955SNick Hudson * @loadaddr: load address if none specified in the image or when loading a 201f831f955SNick Hudson * ramdisk. Populated with the load address. Ignored if NULL or 202f831f955SNick Hudson * LOAD_UIMAGE_LOADADDR_INVALID (images which do not specify a load 203f831f955SNick Hudson * address will not be loadable). 2045e774eb3SAlistair Francis * @is_linux: Is set to true if the image loaded is Linux. Ignored if NULL. 2055e774eb3SAlistair Francis * @translate_fn: optional function to translate load addresses 2065e774eb3SAlistair Francis * @translate_opaque: opaque data passed to @translate_fn 2075e774eb3SAlistair Francis * @as: The AddressSpace to load the ELF to. The value of address_space_memory 2085e774eb3SAlistair Francis * is used if nothing is supplied here. 2095e774eb3SAlistair Francis * 2105e774eb3SAlistair Francis * Loads a u-boot image into memory. 2115e774eb3SAlistair Francis * 2125e774eb3SAlistair Francis * Returns the size of the loaded image on success, -1 otherwise. 2135e774eb3SAlistair Francis */ 214af975131SJamie Iles ssize_t load_uimage_as(const char *filename, hwaddr *ep, 2155e774eb3SAlistair Francis hwaddr *loadaddr, int *is_linux, 2165e774eb3SAlistair Francis uint64_t (*translate_fn)(void *, uint64_t), 2175e774eb3SAlistair Francis void *translate_opaque, AddressSpace *as); 2185e774eb3SAlistair Francis 2195e774eb3SAlistair Francis /** load_uimage: 2205e774eb3SAlistair Francis * Same as load_uimage_as(), but doesn't allow the caller to specify an 2215e774eb3SAlistair Francis * AddressSpace. 2225e774eb3SAlistair Francis */ 223af975131SJamie Iles ssize_t load_uimage(const char *filename, hwaddr *ep, 22425bda50aSMax Filippov hwaddr *loadaddr, int *is_linux, 22525bda50aSMax Filippov uint64_t (*translate_fn)(void *, uint64_t), 22625bda50aSMax Filippov void *translate_opaque); 227ca20cf32SBlue Swirl 22884aee0deSSoren Brinkmann /** 22997df5feeSPeter Maydell * load_ramdisk_as: 23084aee0deSSoren Brinkmann * @filename: Path to the ramdisk image 23184aee0deSSoren Brinkmann * @addr: Memory address to load the ramdisk to 23284aee0deSSoren Brinkmann * @max_sz: Maximum allowed ramdisk size (for non-u-boot ramdisks) 23397df5feeSPeter Maydell * @as: The AddressSpace to load the ELF to. The value of address_space_memory 23497df5feeSPeter Maydell * is used if nothing is supplied here. 23584aee0deSSoren Brinkmann * 23684aee0deSSoren Brinkmann * Load a ramdisk image with U-Boot header to the specified memory 23784aee0deSSoren Brinkmann * address. 23884aee0deSSoren Brinkmann * 23984aee0deSSoren Brinkmann * Returns the size of the loaded image on success, -1 otherwise. 24084aee0deSSoren Brinkmann */ 241af975131SJamie Iles ssize_t load_ramdisk_as(const char *filename, hwaddr addr, uint64_t max_sz, 24297df5feeSPeter Maydell AddressSpace *as); 24397df5feeSPeter Maydell 24497df5feeSPeter Maydell /** 24597df5feeSPeter Maydell * load_ramdisk: 24697df5feeSPeter Maydell * Same as load_ramdisk_as(), but doesn't allow the caller to specify 24797df5feeSPeter Maydell * an AddressSpace. 24897df5feeSPeter Maydell */ 249af975131SJamie Iles ssize_t load_ramdisk(const char *filename, hwaddr addr, uint64_t max_sz); 25084aee0deSSoren Brinkmann 25151b58561SPaul Burton ssize_t gunzip(void *dst, size_t dstlen, uint8_t *src, size_t srclen); 25251b58561SPaul Burton 253725e14e9SMarkus Armbruster ssize_t read_targphys(const char *name, 254a8170e5eSAvi Kivity int fd, hwaddr dst_addr, size_t nbytes); 2553c178e72SGerd Hoffmann void pstrcpy_targphys(const char *name, 256a8170e5eSAvi Kivity hwaddr dest, int buf_size, 257ca20cf32SBlue Swirl const char *source); 25845a50b16SGerd Hoffmann 259af975131SJamie Iles ssize_t rom_add_file(const char *file, const char *fw_dir, 260ac41881bSMichael S. Tsirkin hwaddr addr, int32_t bootindex, 261e265ee43SPhilippe Mathieu-Daudé bool has_option_rom, MemoryRegion *mr, AddressSpace *as); 262339240b5SPaolo Bonzini MemoryRegion *rom_add_blob(const char *name, const void *blob, size_t len, 263339240b5SPaolo Bonzini size_t max_len, hwaddr addr, 264339240b5SPaolo Bonzini const char *fw_file_name, 2656f6f4aecSMarc-André Lureau FWCfgCallback fw_callback, 266baf2d5bfSMichael S. Tsirkin void *callback_opaque, AddressSpace *as, 267baf2d5bfSMichael S. Tsirkin bool read_only); 268fef28891SStefano Garzarella int rom_add_elf_program(const char *name, GMappedFile *mapped_file, void *data, 269fef28891SStefano Garzarella size_t datasize, size_t romsize, hwaddr addr, 270fef28891SStefano Garzarella AddressSpace *as); 2716b3f7f63SEric Auger int rom_check_and_register_reset(void); 272a88b362cSLaszlo Ersek void rom_set_fw(FWCfgState *f); 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); 32545a50b16SGerd Hoffmann 3262e55e842SGleb Natapov #define rom_add_file_fixed(_f, _a, _i) \ 3273e76099aSAlistair Francis rom_add_file(_f, NULL, _a, _i, false, NULL, NULL) 32845a50b16SGerd Hoffmann #define rom_add_blob_fixed(_f, _b, _l, _a) \ 329baf2d5bfSMichael S. Tsirkin rom_add_blob(_f, _b, _l, _l, _a, NULL, NULL, NULL, NULL, true) 33076151cacSPeter Maydell #define rom_add_file_mr(_f, _mr, _i) \ 3313e76099aSAlistair Francis rom_add_file(_f, NULL, 0, _i, false, _mr, NULL) 3323e76099aSAlistair Francis #define rom_add_file_as(_f, _as, _i) \ 3333e76099aSAlistair Francis rom_add_file(_f, NULL, 0, _i, false, NULL, _as) 33493ffc7c7SAlistair Francis #define rom_add_file_fixed_as(_f, _a, _i, _as) \ 33593ffc7c7SAlistair Francis rom_add_file(_f, NULL, _a, _i, false, NULL, _as) 3365e774eb3SAlistair Francis #define rom_add_blob_fixed_as(_f, _b, _l, _a, _as) \ 337baf2d5bfSMichael S. Tsirkin rom_add_blob(_f, _b, _l, _l, _a, NULL, NULL, NULL, _as, true) 33845a50b16SGerd Hoffmann 339af975131SJamie Iles ssize_t rom_add_vga(const char *file); 340af975131SJamie Iles ssize_t rom_add_option(const char *file, int32_t bootindex); 34145a50b16SGerd Hoffmann 34251b58561SPaul Burton /* This is the usual maximum in uboot, so if a uImage overflows this, it would 34351b58561SPaul Burton * overflow on real hardware too. */ 34451b58561SPaul Burton #define UBOOT_MAX_GUNZIP_BYTES (64 << 20) 34551b58561SPaul Burton 3465fc983afSAlex Bennée typedef struct RomGap { 3475fc983afSAlex Bennée hwaddr base; 3485fc983afSAlex Bennée size_t size; 3495fc983afSAlex Bennée } RomGap; 3505fc983afSAlex Bennée 3515fc983afSAlex Bennée /** 3525fc983afSAlex Bennée * rom_find_largest_gap_between: return largest gap between ROMs in given range 3535fc983afSAlex Bennée * 3545fc983afSAlex Bennée * Given a range of addresses, this function finds the largest 3555fc983afSAlex Bennée * contiguous subrange which has no ROMs loaded to it. That is, 3565fc983afSAlex Bennée * it finds the biggest gap which is free for use for other things. 3575fc983afSAlex Bennée */ 3585fc983afSAlex Bennée RomGap rom_find_largest_gap_between(hwaddr base, size_t size); 3595fc983afSAlex Bennée 360ca20cf32SBlue Swirl #endif 361