aboutsummaryrefslogtreecommitdiff
path: root/hw/mips_r4k.c
diff options
context:
space:
mode:
Diffstat (limited to 'hw/mips_r4k.c')
-rw-r--r--hw/mips_r4k.c48
1 files changed, 26 insertions, 22 deletions
diff --git a/hw/mips_r4k.c b/hw/mips_r4k.c
index dfcf867582..e4817e6b7f 100644
--- a/hw/mips_r4k.c
+++ b/hw/mips_r4k.c
@@ -36,6 +36,13 @@ static PITState *pit; /* PIT i8254 */
/*i8254 PIT is attached to the IRQ0 at PIC i8259 */
+static struct _loaderparams {
+ int ram_size;
+ const char *kernel_filename;
+ const char *kernel_cmdline;
+ const char *initrd_filename;
+} loaderparams;
+
static void mips_qemu_writel (void *opaque, target_phys_addr_t addr,
uint32_t val)
{
@@ -64,16 +71,13 @@ static CPUReadMemoryFunc *mips_qemu_read[] = {
static int mips_qemu_iomemtype = 0;
-static void load_kernel (CPUState *env, int ram_size,
- const char *kernel_filename,
- const char *kernel_cmdline,
- const char *initrd_filename)
+static void load_kernel (CPUState *env)
{
int64_t entry, kernel_low, kernel_high;
long kernel_size, initrd_size;
ram_addr_t initrd_offset;
- kernel_size = load_elf(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)
@@ -81,29 +85,29 @@ static void load_kernel (CPUState *env, int ram_size,
env->PC[env->current_tc] = entry;
} else {
fprintf(stderr, "qemu: could not load kernel '%s'\n",
- kernel_filename);
+ loaderparams.kernel_filename);
exit(1);
}
/* load initrd */
initrd_size = 0;
initrd_offset = 0;
- if (initrd_filename) {
- initrd_size = get_image_size (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 > ram_size) {
fprintf(stderr,
"qemu: memory too small for initial ram disk '%s'\n",
- initrd_filename);
+ loaderparams.initrd_filename);
exit(1);
}
- initrd_size = load_image(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",
- initrd_filename);
+ loaderparams.initrd_filename);
exit(1);
}
}
@@ -115,10 +119,12 @@ static void load_kernel (CPUState *env, int ram_size,
"rd_start=0x" TARGET_FMT_lx " rd_size=%li ",
PHYS_TO_VIRT((uint32_t)initrd_offset),
initrd_size);
- strcpy (phys_ram_base + (16 << 20) - 256 + ret, kernel_cmdline);
+ strcpy (phys_ram_base + (16 << 20) - 256 + ret,
+ loaderparams.kernel_cmdline);
}
else {
- strcpy (phys_ram_base + (16 << 20) - 256, kernel_cmdline);
+ strcpy (phys_ram_base + (16 << 20) - 256,
+ loaderparams.kernel_cmdline);
}
*(int32_t *)(phys_ram_base + (16 << 20) - 260) = tswap32 (0x12345678);
@@ -131,9 +137,8 @@ static void main_cpu_reset(void *opaque)
cpu_reset(env);
cpu_mips_register(env, NULL);
- if (env->kernel_filename)
- load_kernel (env, env->ram_size, env->kernel_filename,
- env->kernel_cmdline, env->initrd_filename);
+ if (loaderparams.kernel_filename)
+ load_kernel (env);
}
static
@@ -194,12 +199,11 @@ void mips_r4k_init (int ram_size, int vga_ram_size, const char *boot_device,
}
if (kernel_filename) {
- load_kernel (env, ram_size, kernel_filename, kernel_cmdline,
- initrd_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);
}
/* Init CPU internal devices */