diff options
author | Aurelien Jarno <aurelien@aurel32.net> | 2010-03-14 21:20:59 +0100 |
---|---|---|
committer | Aurelien Jarno <aurelien@aurel32.net> | 2010-03-16 08:38:05 +0100 |
commit | 409dbce54b57b85bd229174da86d77ca08508508 (patch) | |
tree | 61aaddb4700595752b34e01db383074463336329 /hw/sun4u.c | |
parent | cb66ffcf9e298dc1bfc11682172ff9472bcd4495 (diff) |
load_elf: replace the address addend by a translation function
A few machines need to translate the ELF header addresses into physical
addresses. Currently the only possibility is to add a value to the
addresses.
This patch replaces the addend argument by and a translation function
and an opaque passed to the function. A NULL function does not translate
the address.
The patch also convert all machines that have an addend, simplify the
PowerPC kernel loading and fix the MIPS kernel loading using this new
feature. Other machines may benefit from this feature.
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Diffstat (limited to 'hw/sun4u.c')
-rw-r--r-- | hw/sun4u.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/hw/sun4u.c b/hw/sun4u.c index f339df38d1..666383607f 100644 --- a/hw/sun4u.c +++ b/hw/sun4u.c @@ -189,8 +189,8 @@ static unsigned long sun4u_load_kernel(const char *kernel_filename, #else bswap_needed = 0; #endif - kernel_size = load_elf(kernel_filename, 0, NULL, NULL, NULL, - 1, ELF_MACHINE, 0); + kernel_size = load_elf(kernel_filename, NULL, NULL, NULL, + NULL, NULL, 1, ELF_MACHINE, 0); if (kernel_size < 0) kernel_size = load_aout(kernel_filename, KERNEL_LOAD_ADDR, RAM_size - KERNEL_LOAD_ADDR, bswap_needed, @@ -580,6 +580,12 @@ static void pci_ebus_register(void) device_init(pci_ebus_register); +static uint64_t translate_prom_address(void *opaque, uint64_t addr) +{ + target_phys_addr_t *base_addr = (target_phys_addr_t *)opaque; + return addr + *base_addr - PROM_VADDR; +} + /* Boot PROM (OpenBIOS) */ static void prom_init(target_phys_addr_t addr, const char *bios_name) { @@ -600,8 +606,8 @@ static void prom_init(target_phys_addr_t addr, const char *bios_name) } filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); if (filename) { - ret = load_elf(filename, addr - PROM_VADDR, NULL, NULL, NULL, - 1, ELF_MACHINE, 0); + ret = load_elf(filename, translate_prom_address, &addr, + NULL, NULL, NULL, 1, ELF_MACHINE, 0); if (ret < 0 || ret > PROM_SIZE_MAX) { ret = load_image_targphys(filename, addr, PROM_SIZE_MAX); } |