Skip to contentSkip to conversation

make -kernel optional for all ARM boards

PATCH Applied Peter Maydell 2 participants 4 messages Sep 24, 2013 – Sep 30, 2013

lore
Share & tools
lore
#0 lore raw

cover make -kernel optional for all ARM boards

Make -kernel optional for all ARM boards, by allowing arm_load_kernel() to return without doing anything if no kernel filename was provided. In this case we will start execution at address zero (as the hardware does). This allows the user to provide a flash image or similar on some boards; in particular it's possible to run a UEFI image on the versatile express boards.

The second patch tidies up a few boards which had already effectively provided this flexibility at the board level.

Peter Maydell (2):
hw/arm/boot: Make user not specifying a kernel not an error hw/arm: Tidy up conditional calls to arm_load_kernel

 hw/arm/boot.c     |  6 ++++--
 hw/arm/omap_sx1.c | 10 ++++------
 hw/arm/palm.c     | 10 ++++------
 hw/arm/z2.c       | 12 +++++-------
 4 files changed, 17 insertions(+), 21 deletions(-)
Signature · 1 line
1.7.11.4
#1 lore raw

PATCH 1/2 hw/arm/boot: Make user not specifying a kernel not an error

Typically ARM boards will have some kind of flash which might contain a boot ROM; it's therefore a valid use case to provide only an image for the boot ROM and not require QEMU's internal boot loader at all. Remove the fatal error if -kernel isn't specified.

---
 hw/arm/boot.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
hw/arm/boot.c +4 -2
index 1e313af..583ec79 100644
@@ -354,8 +354,10 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info)
 
     /* Load the kernel.  */
     if (!info->kernel_filename) {
-        fprintf(stderr, "Kernel image must be specified\n");
-        exit(1);
+        /* If no kernel specified, do nothing; we will start from address 0
+         * (typically a boot ROM image) in the same way as hardware.
+         */
+        return;
     }
 
     info->dtb_filename = qemu_opt_get(qemu_get_machine_opts(), "dtb");
Signature · 1 line
1.7.11.4
#2 lore raw

PATCH 2/2 hw/arm: Tidy up conditional calls to arm_load_kernel

In reply to Peter Maydell

Now that arm_load_kernel doesn't insist on a kernel filename being present, we can remove some unnecessary conditionals in board models.

---
 hw/arm/omap_sx1.c | 10 ++++------
 hw/arm/palm.c     | 10 ++++------
 hw/arm/z2.c       | 12 +++++-------
 3 files changed, 13 insertions(+), 19 deletions(-)
hw/arm/omap_sx1.c +4 -6
index b0f8664..03b3816 100644
@@ -194,12 +194,10 @@ static void sx1_init(QEMUMachineInitArgs *args, const int version)
     }
 
     /* Load the kernel.  */
-    if (args->kernel_filename) {
-        sx1_binfo.kernel_filename = args->kernel_filename;
-        sx1_binfo.kernel_cmdline = args->kernel_cmdline;
-        sx1_binfo.initrd_filename = args->initrd_filename;
-        arm_load_kernel(mpu->cpu, &sx1_binfo);
-    }
+    sx1_binfo.kernel_filename = args->kernel_filename;
+    sx1_binfo.kernel_cmdline = args->kernel_cmdline;
+    sx1_binfo.initrd_filename = args->initrd_filename;
+    arm_load_kernel(mpu->cpu, &sx1_binfo);
 
     /* TODO: fix next line */
     //~ qemu_console_resize(ds, 640, 480);
hw/arm/palm.c +4 -6
index 3e39044..0b72bbe 100644
@@ -261,12 +261,10 @@ static void palmte_init(QEMUMachineInitArgs *args)
     }
 
     /* Load the kernel.  */
-    if (kernel_filename) {
-        palmte_binfo.kernel_filename = kernel_filename;
-        palmte_binfo.kernel_cmdline = kernel_cmdline;
-        palmte_binfo.initrd_filename = initrd_filename;
-        arm_load_kernel(mpu->cpu, &palmte_binfo);
-    }
+    palmte_binfo.kernel_filename = kernel_filename;
+    palmte_binfo.kernel_cmdline = kernel_cmdline;
+    palmte_binfo.initrd_filename = initrd_filename;
+    arm_load_kernel(mpu->cpu, &palmte_binfo);
 }
 
 static QEMUMachine palmte_machine = {
hw/arm/z2.c +5 -7
index 2e0d5d4..a00fcc0 100644
@@ -360,13 +360,11 @@ static void z2_init(QEMUMachineInitArgs *args)
     qdev_connect_gpio_out(mpu->gpio, Z2_GPIO_LCD_CS,
         qemu_allocate_irqs(z2_lcd_cs, z2_lcd, 1)[0]);
 
-    if (kernel_filename) {
-        z2_binfo.kernel_filename = kernel_filename;
-        z2_binfo.kernel_cmdline = kernel_cmdline;
-        z2_binfo.initrd_filename = initrd_filename;
-        z2_binfo.board_id = 0x6dd;
-        arm_load_kernel(mpu->cpu, &z2_binfo);
-    }
+    z2_binfo.kernel_filename = kernel_filename;
+    z2_binfo.kernel_cmdline = kernel_cmdline;
+    z2_binfo.initrd_filename = initrd_filename;
+    z2_binfo.board_id = 0x6dd;
+    arm_load_kernel(mpu->cpu, &z2_binfo);
 }
 
 static QEMUMachine z2_machine = {
Signature · 1 line
1.7.11.4
#3 lore raw
In reply to Peter Maydell

Am 24.09.2013 02:01, schrieb Peter Maydell:

Quoted 8 lines

Make -kernel optional for all ARM boards, by allowing arm_load_kernel() to return without doing anything if no kernel filename was provided. In this case we will start execution at address zero (as the hardware does). This allows the user to provide a flash image or similar on some boards; in particular it's possible to run a UEFI image on the versatile express boards.

Quoted 6 lines

The second patch tidies up a few boards which had already effectively provided this flexibility at the board level.

Peter Maydell (2):
hw/arm/boot: Make user not specifying a kernel not an error hw/arm: Tidy up conditional calls to arm_load_kernel

Thanks, applied to qom-next:
https://github.com/afaerber/qemu-cpu/commits/qom-next

Andreas

Quoted 7 lines
 hw/arm/boot.c     |  6 ++++--
 hw/arm/omap_sx1.c | 10 ++++------
 hw/arm/palm.c     | 10 ++++------
 hw/arm/z2.c       | 12 +++++-------
 4 files changed, 17 insertions(+), 21 deletions(-)
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg