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/ppc_oldworld.c | |
parent | cb66ffcf9e298dc1bfc11682172ff9472bcd4495 (diff) | |
download | qemu-409dbce54b57b85bd229174da86d77ca08508508.zip qemu-409dbce54b57b85bd229174da86d77ca08508508.tar.gz qemu-409dbce54b57b85bd229174da86d77ca08508508.tar.bz2 |
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/ppc_oldworld.c')
-rw-r--r-- | hw/ppc_oldworld.c | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/hw/ppc_oldworld.c b/hw/ppc_oldworld.c index 93c95ba..bdc5bcd 100644 --- a/hw/ppc_oldworld.c +++ b/hw/ppc_oldworld.c @@ -122,6 +122,12 @@ static int fw_cfg_boot_set(void *opaque, const char *boot_device) return 0; } + +static uint64_t translate_kernel_address(void *opaque, uint64_t addr) +{ + return (addr & 0x0fffffff) + KERNEL_LOAD_ADDR; +} + static void ppc_heathrow_init (ram_addr_t ram_size, const char *boot_device, const char *kernel_filename, @@ -185,8 +191,8 @@ static void ppc_heathrow_init (ram_addr_t ram_size, /* Load OpenBIOS (ELF) */ if (filename) { - bios_size = load_elf(filename, 0, NULL, NULL, NULL, - 1, ELF_MACHINE, 0); + bios_size = load_elf(filename, 0, NULL, NULL, NULL, NULL, + 1, ELF_MACHINE, 0); qemu_free(filename); } else { bios_size = -1; @@ -236,15 +242,8 @@ static void ppc_heathrow_init (ram_addr_t ram_size, bswap_needed = 0; #endif kernel_base = KERNEL_LOAD_ADDR; - /* Now we can load the kernel. The first step tries to load the kernel - supposing PhysAddr = 0x00000000. If that was wrong the kernel is - loaded again, the new PhysAddr being computed from lowaddr. */ - kernel_size = load_elf(kernel_filename, kernel_base, NULL, &lowaddr, NULL, - 1, ELF_MACHINE, 0); - if (kernel_size > 0 && lowaddr != KERNEL_LOAD_ADDR) { - kernel_size = load_elf(kernel_filename, (2 * kernel_base) - lowaddr, - NULL, NULL, NULL, 1, ELF_MACHINE, 0); - } + kernel_size = load_elf(kernel_filename, translate_kernel_address, NULL, + NULL, &lowaddr, NULL, 1, ELF_MACHINE, 0); if (kernel_size < 0) kernel_size = load_aout(kernel_filename, kernel_base, ram_size - kernel_base, bswap_needed, |