diff options
author | Blue Swirl <blauwirbel@gmail.com> | 2009-09-20 14:58:02 +0000 |
---|---|---|
committer | Blue Swirl <blauwirbel@gmail.com> | 2009-09-20 14:58:02 +0000 |
commit | ca20cf32ab3d945155141ef737f5d08ebb373e1d (patch) | |
tree | 45515350fdf7b5322658095beec591565a78506d /hw/ppc_newworld.c | |
parent | a333cd7166d12397635e16dcade28da5ba8ec7b3 (diff) |
Compile loader only once
Callers must pass ELF machine, byte swapping and symbol LSB clearing
information to ELF loader. A.out loader needs page size information, pass
that too as a parameter.
Extract prototypes to a separate file. Move loader.[ch] and elf_ops.h under hw.
Adjust callers. Also use target_phys_addr_t instead of target_ulong for
addresses: loader addresses aren't virtual.
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Diffstat (limited to 'hw/ppc_newworld.c')
-rw-r--r-- | hw/ppc_newworld.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/hw/ppc_newworld.c b/hw/ppc_newworld.c index 9a491eb7c6..6bd5234d8f 100644 --- a/hw/ppc_newworld.c +++ b/hw/ppc_newworld.c @@ -36,6 +36,8 @@ #include "escc.h" #include "openpic.h" #include "ide.h" +#include "loader.h" +#include "elf.h" #define MAX_IDE_BUS 2 #define VGA_BIOS_SIZE 65536 @@ -145,7 +147,8 @@ static void ppc_core99_init (ram_addr_t ram_size, /* Load OpenBIOS (ELF) */ if (filename) { - bios_size = load_elf(filename, 0, NULL, NULL, NULL); + bios_size = load_elf(filename, 0, NULL, NULL, NULL, 1, ELF_MACHINE, 0); + qemu_free(filename); } else { bios_size = -1; @@ -187,19 +190,28 @@ static void ppc_core99_init (ram_addr_t ram_size, if (linux_boot) { uint64_t lowaddr = 0; + int bswap_needed; + +#ifdef BSWAP_NEEDED + bswap_needed = 1; +#else + 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); + 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); + NULL, NULL, NULL, 1, ELF_MACHINE, 0); } if (kernel_size < 0) kernel_size = load_aout(kernel_filename, kernel_base, - ram_size - kernel_base); + ram_size - kernel_base, bswap_needed, + TARGET_PAGE_SIZE); if (kernel_size < 0) kernel_size = load_image_targphys(kernel_filename, kernel_base, |