Make -kernel flag optional on ARM.
PATCH 1/1 Make -kernel flag optional on ARM.
Sometimes we want to boot the system via firmware instead of loading a kernel into ram with the -kernel parameter. This patch makes the -kernel parameter optional so that a bios image provided by the -pflash flag will be executed.
For example:
qemu-system-arm -M vexpress-a15 -pflash <filename>
Note: Currently the file must be at least the size of the emulated flash device (64M) otherwise QEMU will silently not use the data. This will be fixed in a separate patch
This is part of the larger solution. For this to work it requires the platform to have flash mapped or aliased to address 0 so that there is some code for the emulator to execute.
---
hw/arm/boot.c | 47 ++++++++++++++++++++++------------------------- 1 file changed, 22 insertions(+), 25 deletions(-)
hw/arm/boot.c +22 -25
@@ -361,12 +361,6 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info)int big_endian;QemuOpts *machine_opts; -/* Load the kernel. */ -if (!info->kernel_filename) { -fprintf (stderr,"Kernel image must be specified\n" ); -exit (1 ); - } - machine_opts =qemu_opts_find (qemu_find_opts ("machine" ),0 );if (machine_opts) { info->dtb_filename =qemu_opt_get (machine_opts,"dtb" );
@@ -403,26 +397,29 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info) info->initrd_start = info->loader_start +MIN (info->ram_size /2 ,128 *1024 *1024 ); -/* Assume that raw images are linux kernels, and ELF images are not. */ - kernel_size =load_elf (info->kernel_filename,NULL ,NULL , &elf_entry, -NULL ,NULL , big_endian,ELF_MACHINE ,1 ); - entry = elf_entry; -if (kernel_size <0 ) { - kernel_size =load_uimage (info->kernel_filename, &entry,NULL , - &is_linux); - } -if (kernel_size <0 ) { - entry = info->loader_start +KERNEL_LOAD_ADDR ; - kernel_size =load_image_targphys (info->kernel_filename, entry, - info->ram_size -KERNEL_LOAD_ADDR ); - is_linux =1 ; - } -if (kernel_size <0 ) { -fprintf (stderr,"qemu: could not load kernel '%s'\n" , - info->kernel_filename); -exit (1 ); +if (info->kernel_filename) { +/* Assume that raw images are linux kernels, and ELF images are not. */ + kernel_size =load_elf (info->kernel_filename,NULL ,NULL , &elf_entry, +NULL ,NULL , big_endian,ELF_MACHINE ,1 ); + entry = elf_entry; +if (kernel_size <0 ) { + kernel_size =load_uimage (info->kernel_filename, &entry,NULL , + &is_linux); + } +if (kernel_size <0 ) { + entry = info->loader_start +KERNEL_LOAD_ADDR ; + kernel_size =load_image_targphys (info->kernel_filename, entry, + info->ram_size -KERNEL_LOAD_ADDR ); + is_linux =1 ; + } +if (kernel_size <0 ) { +fprintf (stderr,"qemu: could not load kernel '%s'\n" , + info->kernel_filename); +exit (1 ); + } + info->entry = entry; } - info->entry = entry; +if (is_linux) {if (info->initrd_filename) { initrd_size = load_image_targphys(info->initrd_filename,
Signature · 1 line
1.8.1.2
Quoted 8 lines · Grant Likely
Sometimes we want to boot the system via firmware instead of loading a kernel into ram with the -kernel parameter. This patch makes the -kernel parameter optional so that a bios image provided by the -pflash flag will be executed.
For example:
qemu-system-arm -M vexpress-a15 -pflash <filename>
Quoted 7 lines
Note: Currently the file must be at least the size of the emulated flash device (64M) otherwise QEMU will silently not use the data. This will be fixed in a separate patch
This is part of the larger solution. For this to work it requires the platform to have flash mapped or aliased to address 0 so that there is some code for the emulator to execute.
That patch is already on list :-)
Quoted 13 lines
Signed-off-by Grant Likely <[email protected]>Cc Peter Maydell <[email protected]>---
hw/arm/boot.c | 47 ++++++++++++++++++++++------------------------- 1 file changed, 22 insertions(+), 25 deletions(-)hw/arm/boot.c +0
-0
hw/arm/boot.c void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info) · line 368
Quoted 8 lines
hw/arm/boot.c +0
-5@@ -361,12 +361,6 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info)int big_endian;QemuOpts *machine_opts; -/* Load the kernel. */ -if (!info->kernel_filename) { -fprintf (stderr,"Kernel image must be specified\n" ); -exit (1 ); - }
Why can't we just return from the function here? If we don't have a kernel we can assume we don't have a dtb or an initrd either. I don't think we want to do any of the other weird stuff with setting up a reset handler or boot pen for the secondary CPUs either -- we should just assume the bootrom image in the flash handles this.
thanks
-- PMM
Quoted 13 lines · Peter Maydell
Quoted 12 lines · Grant Likely
Sometimes we want to boot the system via firmware instead of loading a kernel into ram with the -kernel parameter. This patch makes the -kernel parameter optional so that a bios image provided by the -pflash flag will be executed.
For example:
qemu-system-arm -M vexpress-a15 -pflash <filename>Note: Currently the file must be at least the size of the emulated flash device (64M) otherwise QEMU will silently not use the data. This will be fixed in a separate patch
Quoted 5 lines
Quoted 3 lines
This is part of the larger solution. For this to work it requires the platform to have flash mapped or aliased to address 0 so that there is some code for the emulator to execute.
That patch is already on list :-)
Heh, I wrote the above before grabbing and testing your patch.
Quoted 8 lines
Quoted 8 lines
hw/arm/boot.c +0
-0@@ -361,12 +361,6 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info)int big_endian;QemuOpts *machine_opts;
Quoted 12 lines
hw/arm/boot.c void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info) · line 368
Quoted 5 lines
hw/arm/boot.c +0
-5-/* Load the kernel. */ -if (!info->kernel_filename) { -fprintf (stderr,"Kernel image must be specified\n" ); -exit (1 ); - }Why can't we just return from the function here? If we don't have a kernel we can assume we don't have a dtb or an initrd either. I don't think we want to do any of the other weird stuff with setting up a reset handler or boot pen for the secondary CPUs either -- we should just assume the bootrom image in the flash handles this.
I've just tested this, and you're right. I assumed that some of the other stuff would be necessary, but it does work just fine to return. Second version of the patch posted now.
g.