loader.h revision 1365eb2b35736211464f313616e32f25569e5107
1#ifndef LOADER_H 2#define LOADER_H 3 4#include "cpu.h" 5#include "qapi/qmp/qdict.h" 6#include "hw/nvram/fw_cfg.h" 7 8/* loader.c */ 9int get_image_size(const char *filename); 10int load_image(const char *filename, uint8_t *addr); /* deprecated */ 11int load_image_targphys(const char *filename, hwaddr, 12 uint64_t max_sz); 13int load_elf(const char *filename, int64_t address_offset, 14 uint64_t *pentry, uint64_t *lowaddr, uint64_t *highaddr); 15int load_aout(const char *filename, hwaddr addr, int max_sz); 16int load_uimage(const char *filename, target_ulong *ep, target_ulong *loadaddr, 17 int *is_linux); 18 19/** 20 * load_ramdisk: 21 * @filename: Path to the ramdisk image 22 * @addr: Memory address to load the ramdisk to 23 * @max_sz: Maximum allowed ramdisk size (for non-u-boot ramdisks) 24 * 25 * Load a ramdisk image with U-Boot header to the specified memory 26 * address. 27 * 28 * Returns the size of the loaded image on success, -1 otherwise. 29 */ 30int load_ramdisk(const char *filename, hwaddr addr, uint64_t max_sz); 31 32int fread_targphys_ok(hwaddr dst_addr, size_t nbytes, FILE *f); 33 34ssize_t read_targphys(const char *name, 35 int fd, hwaddr dst_addr, size_t nbytes); 36void pstrcpy_targphys(const char *name, 37 hwaddr dest, int buf_size, 38 const char *source); 39 40#ifndef CONFIG_ANDROID // TODO(digit) 41extern bool rom_file_in_ram; 42 43int rom_add_file(const char *file, const char *fw_dir, 44 hwaddr addr, int32_t bootindex); 45void *rom_add_blob(const char *name, const void *blob, size_t len, 46 hwaddr addr, const char *fw_file_name, 47 FWCfgReadCallback fw_callback, void *callback_opaque); 48int rom_add_elf_program(const char *name, void *data, size_t datasize, 49 size_t romsize, hwaddr addr); 50int rom_load_all(void); 51void rom_load_done(void); 52void rom_set_fw(FWCfgState *f); 53int rom_copy(uint8_t *dest, hwaddr addr, size_t size); 54void *rom_ptr(hwaddr addr); 55void do_info_roms(Monitor *mon, const QDict *qdict); 56 57#define rom_add_file_fixed(_f, _a, _i) \ 58 rom_add_file(_f, NULL, _a, _i) 59#define rom_add_blob_fixed(_f, _b, _l, _a) \ 60 rom_add_blob(_f, _b, _l, _a, NULL, NULL, NULL) 61 62#define PC_ROM_MIN_VGA 0xc0000 63#define PC_ROM_MIN_OPTION 0xc8000 64#define PC_ROM_MAX 0xe0000 65#define PC_ROM_ALIGN 0x800 66#define PC_ROM_SIZE (PC_ROM_MAX - PC_ROM_MIN_VGA) 67 68int rom_add_vga(const char *file); 69int rom_add_option(const char *file, int32_t bootindex); 70#endif // !CONFIG_ANDROID 71 72#endif 73