mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 00:03:54 -06:00
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>
This commit is contained in:
parent
cb66ffcf9e
commit
409dbce54b
24 changed files with 159 additions and 101 deletions
|
@ -21,10 +21,6 @@
|
|||
#include "loader.h"
|
||||
#include "elf.h"
|
||||
|
||||
#define PHYS_TO_VIRT(x) ((x) | ~(target_ulong)0x7fffffff)
|
||||
|
||||
#define VIRT_TO_PHYS_ADDEND (-((int64_t)(int32_t)0x80000000))
|
||||
|
||||
#define MAX_IDE_BUS 2
|
||||
|
||||
static const int ide_iobase[2] = { 0x1f0, 0x170 };
|
||||
|
@ -77,7 +73,7 @@ typedef struct ResetData {
|
|||
|
||||
static int64_t load_kernel(void)
|
||||
{
|
||||
int64_t entry, kernel_low, kernel_high;
|
||||
int64_t entry, kernel_high;
|
||||
long kernel_size, initrd_size, params_size;
|
||||
ram_addr_t initrd_offset;
|
||||
uint32_t *params_buf;
|
||||
|
@ -88,9 +84,10 @@ static int64_t load_kernel(void)
|
|||
#else
|
||||
big_endian = 0;
|
||||
#endif
|
||||
kernel_size = load_elf(loaderparams.kernel_filename, VIRT_TO_PHYS_ADDEND,
|
||||
(uint64_t *)&entry, (uint64_t *)&kernel_low,
|
||||
(uint64_t *)&kernel_high, big_endian, ELF_MACHINE, 1);
|
||||
kernel_size = load_elf(loaderparams.kernel_filename, cpu_mips_kseg0_to_phys,
|
||||
NULL, (uint64_t *)&entry, NULL,
|
||||
(uint64_t *)&kernel_high, big_endian,
|
||||
ELF_MACHINE, 1);
|
||||
if (kernel_size >= 0) {
|
||||
if ((entry & ~0x7fffffffULL) == 0x80000000)
|
||||
entry = (int32_t)entry;
|
||||
|
@ -132,8 +129,8 @@ static int64_t load_kernel(void)
|
|||
params_buf[1] = tswap32(0x12345678);
|
||||
|
||||
if (initrd_size > 0) {
|
||||
snprintf((char *)params_buf + 8, 256, "rd_start=0x" TARGET_FMT_lx " rd_size=%li %s",
|
||||
PHYS_TO_VIRT((uint32_t)initrd_offset),
|
||||
snprintf((char *)params_buf + 8, 256, "rd_start=0x%" PRIx64 " rd_size=%li %s",
|
||||
cpu_mips_phys_to_kseg0(NULL, initrd_offset),
|
||||
initrd_size, loaderparams.kernel_cmdline);
|
||||
} else {
|
||||
snprintf((char *)params_buf + 8, 256, "%s", loaderparams.kernel_cmdline);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue