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
This commit is contained in:
parent
d26bc2118e
commit
7df526e317
@ -59,6 +59,13 @@ typedef struct {
|
||||
|
||||
static PITState *pit;
|
||||
|
||||
static struct _loaderparams {
|
||||
int ram_size;
|
||||
const char *kernel_filename;
|
||||
const char *kernel_cmdline;
|
||||
const char *initrd_filename;
|
||||
} loaderparams;
|
||||
|
||||
/* Malta FPGA */
|
||||
static void malta_fpga_update_display(void *opaque)
|
||||
{
|
||||
@ -534,8 +541,8 @@ static void write_bootloader (CPUState *env, unsigned long bios_offset, int64_t
|
||||
stl_raw(p++, 0x34a50000 | (ENVP_ADDR & 0xffff)); /* ori a1, a1, low(ENVP_ADDR) */
|
||||
stl_raw(p++, 0x3c060000 | (((ENVP_ADDR + 8) >> 16) & 0xffff)); /* lui a2, high(ENVP_ADDR + 8) */
|
||||
stl_raw(p++, 0x34c60000 | ((ENVP_ADDR + 8) & 0xffff)); /* ori a2, a2, low(ENVP_ADDR + 8) */
|
||||
stl_raw(p++, 0x3c070000 | (env->ram_size >> 16)); /* lui a3, high(env->ram_size) */
|
||||
stl_raw(p++, 0x34e70000 | (env->ram_size & 0xffff)); /* ori a3, a3, low(env->ram_size) */
|
||||
stl_raw(p++, 0x3c070000 | (loaderparams.ram_size >> 16)); /* lui a3, high(ram_size) */
|
||||
stl_raw(p++, 0x34e70000 | (loaderparams.ram_size & 0xffff)); /* ori a3, a3, low(ram_size) */
|
||||
|
||||
/* Load BAR registers as done by YAMON */
|
||||
stl_raw(p++, 0x3c09b400); /* lui t1, 0xb400 */
|
||||
@ -675,48 +682,48 @@ static int64_t load_kernel (CPUState *env)
|
||||
long initrd_size;
|
||||
ram_addr_t initrd_offset;
|
||||
|
||||
if (load_elf(env->kernel_filename, VIRT_TO_PHYS_ADDEND,
|
||||
if (load_elf(loaderparams.kernel_filename, VIRT_TO_PHYS_ADDEND,
|
||||
&kernel_entry, &kernel_low, &kernel_high) < 0) {
|
||||
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 > 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);
|
||||
}
|
||||
}
|
||||
|
||||
/* Store command line. */
|
||||
prom_set(index++, env->kernel_filename);
|
||||
prom_set(index++, loaderparams.kernel_filename);
|
||||
if (initrd_size > 0)
|
||||
prom_set(index++, "rd_start=0x" TARGET_FMT_lx " rd_size=%li %s",
|
||||
PHYS_TO_VIRT(initrd_offset), initrd_size,
|
||||
env->kernel_cmdline);
|
||||
loaderparams.kernel_cmdline);
|
||||
else
|
||||
prom_set(index++, env->kernel_cmdline);
|
||||
prom_set(index++, loaderparams.kernel_cmdline);
|
||||
|
||||
/* Setup minimum environment variables */
|
||||
prom_set(index++, "memsize");
|
||||
prom_set(index++, "%i", env->ram_size);
|
||||
prom_set(index++, "%i", loaderparams.ram_size);
|
||||
prom_set(index++, "modetty0");
|
||||
prom_set(index++, "38400n8r");
|
||||
prom_set(index++, NULL);
|
||||
@ -733,7 +740,7 @@ static void main_cpu_reset(void *opaque)
|
||||
/* The bootload does not need to be rewritten as it is located in a
|
||||
read only location. The kernel location and the arguments table
|
||||
location does not change. */
|
||||
if (env->kernel_filename) {
|
||||
if (loaderparams.kernel_filename) {
|
||||
env->CP0_Status &= ~((1 << CP0St_BEV) | (1 << CP0St_ERL));
|
||||
load_kernel (env);
|
||||
}
|
||||
@ -818,10 +825,10 @@ void mips_malta_init (int ram_size, int vga_ram_size, const char *boot_device,
|
||||
/* If a kernel image has been specified, write a small bootloader
|
||||
to the flash location. */
|
||||
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;
|
||||
kernel_entry = load_kernel(env);
|
||||
env->CP0_Status &= ~((1 << CP0St_BEV) | (1 << CP0St_ERL));
|
||||
write_bootloader(env, bios_offset, kernel_entry);
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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 */
|
||||
|
@ -456,11 +456,6 @@ struct CPUMIPSState {
|
||||
|
||||
CPU_COMMON
|
||||
|
||||
int ram_size;
|
||||
const char *kernel_filename;
|
||||
const char *kernel_cmdline;
|
||||
const char *initrd_filename;
|
||||
|
||||
mips_def_t *cpu_model;
|
||||
#ifndef CONFIG_USER_ONLY
|
||||
void *irq[8];
|
||||
|
Loading…
Reference in New Issue
Block a user