diff options
author | ths <ths@c046a42c-6fe2-441c-8c8c-71466251a162> | 2007-11-09 17:52:11 +0000 |
---|---|---|
committer | ths <ths@c046a42c-6fe2-441c-8c8c-71466251a162> | 2007-11-09 17:52:11 +0000 |
commit | 7df526e317fe4c193589bfdf2ee06255325344cc (patch) | |
tree | 524b424b4ccfedd104944a325218e1737ea5da67 /hw/mips_mipssim.c | |
parent | d26bc2118e99702eb8c1bb240786bcadd7fa21ac (diff) |
Move kernel loader parameters from the cpu state to being board specific.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3557 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'hw/mips_mipssim.c')
-rw-r--r-- | hw/mips_mipssim.c | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/hw/mips_mipssim.c b/hw/mips_mipssim.c index 11bad59700..08e4b0b018 100644 --- a/hw/mips_mipssim.c +++ b/hw/mips_mipssim.c @@ -40,6 +40,13 @@ #define VIRT_TO_PHYS_ADDEND (-((int64_t)(int32_t)0x80000000)) +static struct _loaderparams { + int ram_size; + const char *kernel_filename; + const char *kernel_cmdline; + const char *initrd_filename; +} loaderparams; + static void load_kernel (CPUState *env) { int64_t entry, kernel_low, kernel_high; @@ -47,7 +54,7 @@ static void load_kernel (CPUState *env) long initrd_size; ram_addr_t initrd_offset; - kernel_size = load_elf(env->kernel_filename, VIRT_TO_PHYS_ADDEND, + kernel_size = load_elf(loaderparams.kernel_filename, VIRT_TO_PHYS_ADDEND, &entry, &kernel_low, &kernel_high); if (kernel_size >= 0) { if ((entry & ~0x7fffffffULL) == 0x80000000) @@ -55,29 +62,29 @@ static void load_kernel (CPUState *env) env->PC[env->current_tc] = entry; } else { fprintf(stderr, "qemu: could not load kernel '%s'\n", - env->kernel_filename); + loaderparams.kernel_filename); exit(1); } /* load initrd */ initrd_size = 0; initrd_offset = 0; - if (env->initrd_filename) { - initrd_size = get_image_size (env->initrd_filename); + if (loaderparams.initrd_filename) { + initrd_size = get_image_size (loaderparams.initrd_filename); if (initrd_size > 0) { initrd_offset = (kernel_high + ~TARGET_PAGE_MASK) & TARGET_PAGE_MASK; - if (initrd_offset + initrd_size > env->ram_size) { + if (initrd_offset + initrd_size > loaderparams.ram_size) { fprintf(stderr, "qemu: memory too small for initial ram disk '%s'\n", - env->initrd_filename); + loaderparams.initrd_filename); exit(1); } - initrd_size = load_image(env->initrd_filename, + initrd_size = load_image(loaderparams.initrd_filename, phys_ram_base + initrd_offset); } if (initrd_size == (target_ulong) -1) { fprintf(stderr, "qemu: could not load initial ram disk '%s'\n", - env->initrd_filename); + loaderparams.initrd_filename); exit(1); } } @@ -89,7 +96,7 @@ static void main_cpu_reset(void *opaque) cpu_reset(env); cpu_mips_register(env, NULL); - if (env->kernel_filename) + if (loaderparams.kernel_filename) load_kernel (env); } @@ -144,10 +151,10 @@ mips_mipssim_init (int ram_size, int vga_ram_size, const char *boot_device, } if (kernel_filename) { - env->ram_size = ram_size; - env->kernel_filename = kernel_filename; - env->kernel_cmdline = kernel_cmdline; - env->initrd_filename = initrd_filename; + loaderparams.ram_size = ram_size; + loaderparams.kernel_filename = kernel_filename; + loaderparams.kernel_cmdline = kernel_cmdline; + loaderparams.initrd_filename = initrd_filename; load_kernel(env); } |