Set boot sequence from command line (Dan Kenigsberg).


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3497 c046a42c-6fe2-441c-8c8c-71466251a162
diff --git a/hw/an5206.c b/hw/an5206.c
index 94ecccb..d9931df 100644
--- a/hw/an5206.c
+++ b/hw/an5206.c
@@ -27,7 +27,7 @@
 
 /* Board init.  */
 
-static void an5206_init(int ram_size, int vga_ram_size, int boot_device,
+static void an5206_init(int ram_size, int vga_ram_size, const char *boot_device,
                      DisplayState *ds, const char **fd_filename, int snapshot,
                      const char *kernel_filename, const char *kernel_cmdline,
                      const char *initrd_filename, const char *cpu_model)
diff --git a/hw/etraxfs.c b/hw/etraxfs.c
index cf0f384..6697c7d 100644
--- a/hw/etraxfs.c
+++ b/hw/etraxfs.c
@@ -107,7 +107,7 @@
 }
 
 static
-void bareetraxfs_init (int ram_size, int vga_ram_size, int boot_device,
+void bareetraxfs_init (int ram_size, int vga_ram_size, const char *boot_device,
                        DisplayState *ds, const char **fd_filename, int snapshot,
                        const char *kernel_filename, const char *kernel_cmdline,
                        const char *initrd_filename, const char *cpu_model)
diff --git a/hw/integratorcp.c b/hw/integratorcp.c
index 83c6208..5d2c651 100644
--- a/hw/integratorcp.c
+++ b/hw/integratorcp.c
@@ -462,8 +462,9 @@
 
 /* Board init.  */
 
-static void integratorcp_init(int ram_size, int vga_ram_size, int boot_device,
-                     DisplayState *ds, const char **fd_filename, int snapshot,
+static void integratorcp_init(int ram_size, int vga_ram_size,
+                     const char *boot_device, DisplayState *ds,
+                     const char **fd_filename, int snapshot,
                      const char *kernel_filename, const char *kernel_cmdline,
                      const char *initrd_filename, const char *cpu_model)
 {
diff --git a/hw/mcf5208.c b/hw/mcf5208.c
index 993a686..bcb1c80 100644
--- a/hw/mcf5208.c
+++ b/hw/mcf5208.c
@@ -197,8 +197,9 @@
     }
 }
 
-static void mcf5208evb_init(int ram_size, int vga_ram_size, int boot_device,
-                     DisplayState *ds, const char **fd_filename, int snapshot,
+static void mcf5208evb_init(int ram_size, int vga_ram_size,
+                     const char *boot_device, DisplayState *ds,
+                     const char **fd_filename, int snapshot,
                      const char *kernel_filename, const char *kernel_cmdline,
                      const char *initrd_filename, const char *cpu_model)
 {
diff --git a/hw/mips_malta.c b/hw/mips_malta.c
index 6f0edf9..9d099a0 100644
--- a/hw/mips_malta.c
+++ b/hw/mips_malta.c
@@ -740,7 +740,7 @@
 }
 
 static
-void mips_malta_init (int ram_size, int vga_ram_size, int boot_device,
+void mips_malta_init (int ram_size, int vga_ram_size, const char *boot_device,
                       DisplayState *ds, const char **fd_filename, int snapshot,
                       const char *kernel_filename, const char *kernel_cmdline,
                       const char *initrd_filename, const char *cpu_model)
diff --git a/hw/mips_mipssim.c b/hw/mips_mipssim.c
index b7b834f..0a2e456 100644
--- a/hw/mips_mipssim.c
+++ b/hw/mips_mipssim.c
@@ -74,7 +74,7 @@
 }
 
 static void
-mips_mipssim_init (int ram_size, int vga_ram_size, int boot_device,
+mips_mipssim_init (int ram_size, int vga_ram_size, const char *boot_device,
                    DisplayState *ds, const char **fd_filename, int snapshot,
                    const char *kernel_filename, const char *kernel_cmdline,
                    const char *initrd_filename, const char *cpu_model)
diff --git a/hw/mips_pica61.c b/hw/mips_pica61.c
index 9584046..d79f7be 100644
--- a/hw/mips_pica61.c
+++ b/hw/mips_pica61.c
@@ -55,7 +55,7 @@
 }
 
 static
-void mips_pica61_init (int ram_size, int vga_ram_size, int boot_device,
+void mips_pica61_init (int ram_size, int vga_ram_size, const char *boot_device,
                     DisplayState *ds, const char **fd_filename, int snapshot,
                     const char *kernel_filename, const char *kernel_cmdline,
                     const char *initrd_filename, const char *cpu_model)
diff --git a/hw/mips_r4k.c b/hw/mips_r4k.c
index ce7aaff..dfcf867 100644
--- a/hw/mips_r4k.c
+++ b/hw/mips_r4k.c
@@ -137,7 +137,7 @@
 }
 
 static
-void mips_r4k_init (int ram_size, int vga_ram_size, int boot_device,
+void mips_r4k_init (int ram_size, int vga_ram_size, const char *boot_device,
                     DisplayState *ds, const char **fd_filename, int snapshot,
                     const char *kernel_filename, const char *kernel_cmdline,
                     const char *initrd_filename, const char *cpu_model)
diff --git a/hw/palm.c b/hw/palm.c
index a6c9f7d..c21b44a 100644
--- a/hw/palm.c
+++ b/hw/palm.c
@@ -115,8 +115,9 @@
                         !(keycode & 0x80));
 }
 
-static void palmte_init(int ram_size, int vga_ram_size, int boot_device,
-                DisplayState *ds, const char **fd_filename, int snapshot,
+static void palmte_init(int ram_size, int vga_ram_size,
+                const char *boot_device, DisplayState *ds,
+                const char **fd_filename, int snapshot,
                 const char *kernel_filename, const char *kernel_cmdline,
                 const char *initrd_filename, const char *cpu_model)
 {
diff --git a/hw/pc.c b/hw/pc.c
index c561cbf..8a1c577 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -152,8 +152,25 @@
     rtc_set_memory(s, info_ofs + 8, sectors);
 }
 
+/* convert boot_device letter to something recognizable by the bios */
+static int boot_device2nibble(char boot_device)
+{
+    switch(boot_device) {
+    case 'a':
+    case 'b':
+        return 0x01; /* floppy boot */
+    case 'c':
+        return 0x02; /* hard drive boot */
+    case 'd':
+        return 0x03; /* CD-ROM boot */
+    case 'n':
+        return 0x04; /* Network boot */
+    }
+    return 0;
+}
+
 /* hd_table must contain 4 block drivers */
-static void cmos_init(int ram_size, int boot_device, BlockDriverState **hd_table)
+static void cmos_init(int ram_size, const char *boot_device, BlockDriverState **hd_table)
 {
     RTCState *s = rtc_state;
     int val;
@@ -184,24 +201,12 @@
     rtc_set_memory(s, 0x34, val);
     rtc_set_memory(s, 0x35, val >> 8);
 
-    switch(boot_device) {
-    case 'a':
-    case 'b':
-        rtc_set_memory(s, 0x3d, 0x01); /* floppy boot */
-        if (!fd_bootchk)
-            rtc_set_memory(s, 0x38, 0x01); /* disable signature check */
-        break;
-    default:
-    case 'c':
-        rtc_set_memory(s, 0x3d, 0x02); /* hard drive boot */
-        break;
-    case 'd':
-        rtc_set_memory(s, 0x3d, 0x03); /* CD-ROM boot */
-        break;
-    case 'n':
-        rtc_set_memory(s, 0x3d, 0x04); /* Network boot */
-        break;
-    }
+    /* set boot devices, and disable floppy signature check if requested */
+    rtc_set_memory(s, 0x3d,
+            boot_device2nibble(boot_device[1]) << 4 |
+            boot_device2nibble(boot_device[0]) );
+    rtc_set_memory(s, 0x38,
+            boot_device2nibble(boot_device[2]) << 4 | (fd_bootchk ?  0x0 : 0x1));
 
     /* floppy type */
 
@@ -663,7 +668,7 @@
 }
 
 /* PC hardware initialisation */
-static void pc_init1(int ram_size, int vga_ram_size, int boot_device,
+static void pc_init1(int ram_size, int vga_ram_size, const char *boot_device,
                      DisplayState *ds, const char **fd_filename, int snapshot,
                      const char *kernel_filename, const char *kernel_cmdline,
                      const char *initrd_filename,
@@ -940,7 +945,7 @@
 #endif
 }
 
-static void pc_init_pci(int ram_size, int vga_ram_size, int boot_device,
+static void pc_init_pci(int ram_size, int vga_ram_size, const char *boot_device,
                         DisplayState *ds, const char **fd_filename,
                         int snapshot,
                         const char *kernel_filename,
@@ -954,7 +959,7 @@
              initrd_filename, 1);
 }
 
-static void pc_init_isa(int ram_size, int vga_ram_size, int boot_device,
+static void pc_init_isa(int ram_size, int vga_ram_size, const char *boot_device,
                         DisplayState *ds, const char **fd_filename,
                         int snapshot,
                         const char *kernel_filename,
diff --git a/hw/ppc405_boards.c b/hw/ppc405_boards.c
index 8c00148..ab13441 100644
--- a/hw/ppc405_boards.c
+++ b/hw/ppc405_boards.c
@@ -171,9 +171,9 @@
     }
 }
 
-static void ref405ep_init (int ram_size, int vga_ram_size, int boot_device,
-                           DisplayState *ds, const char **fd_filename,
-                           int snapshot,
+static void ref405ep_init (int ram_size, int vga_ram_size,
+                           const char *boot_device, DisplayState *ds,
+                           const char **fd_filename, int snapshot,
                            const char *kernel_filename,
                            const char *kernel_cmdline,
                            const char *initrd_filename,
@@ -191,6 +191,7 @@
     target_ulong kernel_base, kernel_size, initrd_base, initrd_size;
     int linux_boot;
     int fl_idx, fl_sectors, len;
+    int ppc_boot_device = boot_device[0];
 
     /* XXX: fix this */
     ram_bases[0] = 0x00000000;
@@ -322,7 +323,7 @@
         }
         env->gpr[4] = initrd_base;
         env->gpr[5] = initrd_size;
-        boot_device = 'm';
+        ppc_boot_device = 'm';
         if (kernel_cmdline != NULL) {
             len = strlen(kernel_cmdline);
             bdloc -= ((len + 255) & ~255);
@@ -496,9 +497,9 @@
     }
 }
 
-static void taihu_405ep_init(int ram_size, int vga_ram_size, int boot_device,
-                             DisplayState *ds, const char **fd_filename,
-                             int snapshot,
+static void taihu_405ep_init(int ram_size, int vga_ram_size,
+                             const char *boot_device, DisplayState *ds,
+                             const char **fd_filename, int snapshot,
                              const char *kernel_filename,
                              const char *kernel_cmdline,
                              const char *initrd_filename,
@@ -513,6 +514,7 @@
     target_ulong kernel_base, kernel_size, initrd_base, initrd_size;
     int linux_boot;
     int fl_idx, fl_sectors;
+    int ppc_boot_device = boot_device[0];
 
     /* RAM is soldered to the board so the size cannot be changed */
     ram_bases[0] = 0x00000000;
@@ -615,7 +617,7 @@
             initrd_base = 0;
             initrd_size = 0;
         }
-        boot_device = 'm';
+        ppc_boot_device = 'm';
     } else {
         kernel_base = 0;
         kernel_size = 0;
diff --git a/hw/ppc_chrp.c b/hw/ppc_chrp.c
index b97f99f..daa99d5 100644
--- a/hw/ppc_chrp.c
+++ b/hw/ppc_chrp.c
@@ -48,9 +48,9 @@
 };
 
 /* PowerPC Mac99 hardware initialisation */
-static void ppc_core99_init (int ram_size, int vga_ram_size, int boot_device,
-                             DisplayState *ds, const char **fd_filename,
-                             int snapshot,
+static void ppc_core99_init (int ram_size, int vga_ram_size,
+                             const char *boot_device, DisplayState *ds,
+                             const char **fd_filename, int snapshot,
                              const char *kernel_filename,
                              const char *kernel_cmdline,
                              const char *initrd_filename,
@@ -75,6 +75,7 @@
     qemu_irq *dummy_irq;
     int pic_mem_index, dbdma_mem_index, cuda_mem_index;
     int ide_mem_index[2];
+    int ppc_boot_device = boot_device[0];
 
     linux_boot = (kernel_filename != NULL);
 
@@ -171,7 +172,7 @@
             initrd_base = 0;
             initrd_size = 0;
         }
-        boot_device = 'm';
+        ppc_boot_device = 'm';
     } else {
         kernel_base = 0;
         kernel_size = 0;
@@ -285,8 +286,8 @@
     nvram.read_fn = &m48t59_read;
     nvram.write_fn = &m48t59_write;
 #endif
-    PPC_NVRAM_set_params(&nvram, NVRAM_SIZE, "MAC99", ram_size, boot_device,
-                         kernel_base, kernel_size,
+    PPC_NVRAM_set_params(&nvram, NVRAM_SIZE, "MAC99", ram_size,
+                         ppc_boot_device, kernel_base, kernel_size,
                          kernel_cmdline,
                          initrd_base, initrd_size,
                          /* XXX: need an option to load a NVRAM image */
diff --git a/hw/ppc_oldworld.c b/hw/ppc_oldworld.c
index 946ebd1..7a08505 100644
--- a/hw/ppc_oldworld.c
+++ b/hw/ppc_oldworld.c
@@ -92,9 +92,9 @@
     return 1; /* osi_call handled */
 }
 
-static void ppc_heathrow_init (int ram_size, int vga_ram_size, int boot_device,
-                               DisplayState *ds, const char **fd_filename,
-                               int snapshot,
+static void ppc_heathrow_init (int ram_size, int vga_ram_size,
+                               const char *boot_device, DisplayState *ds,
+                               const char **fd_filename, int snapshot,
                                const char *kernel_filename,
                                const char *kernel_cmdline,
                                const char *initrd_filename,
@@ -114,6 +114,7 @@
     int vga_bios_size, bios_size;
     qemu_irq *dummy_irq;
     int pic_mem_index, nvram_mem_index, dbdma_mem_index, cuda_mem_index;
+    int ppc_boot_device = boot_device[0];
 
     linux_boot = (kernel_filename != NULL);
 
@@ -208,7 +209,7 @@
             initrd_base = 0;
             initrd_size = 0;
         }
-        boot_device = 'm';
+        ppc_boot_device = 'm';
     } else {
         kernel_base = 0;
         kernel_size = 0;
@@ -289,8 +290,8 @@
     nvram.opaque = m48t59;
     nvram.read_fn = &m48t59_read;
     nvram.write_fn = &m48t59_write;
-    PPC_NVRAM_set_params(&nvram, NVRAM_SIZE, "HEATHROW", ram_size, boot_device,
-                         kernel_base, kernel_size,
+    PPC_NVRAM_set_params(&nvram, NVRAM_SIZE, "HEATHROW", ram_size,
+                         ppc_boot_device, kernel_base, kernel_size,
                          kernel_cmdline,
                          initrd_base, initrd_size,
                          /* XXX: need an option to load a NVRAM image */
diff --git a/hw/ppc_prep.c b/hw/ppc_prep.c
index 49b3632..c557f87 100644
--- a/hw/ppc_prep.c
+++ b/hw/ppc_prep.c
@@ -521,7 +521,7 @@
 #define NVRAM_SIZE        0x2000
 
 /* PowerPC PREP hardware initialisation */
-static void ppc_prep_init (int ram_size, int vga_ram_size, int boot_device,
+static void ppc_prep_init (int ram_size, int vga_ram_size, const char *boot_device,
                            DisplayState *ds, const char **fd_filename,
                            int snapshot, const char *kernel_filename,
                            const char *kernel_cmdline,
@@ -539,6 +539,7 @@
     ppc_def_t *def;
     PCIBus *pci_bus;
     qemu_irq *i8259;
+    int ppc_boot_device = boot_device[0];
 
     sysctrl = qemu_mallocz(sizeof(sysctrl_t));
     if (sysctrl == NULL)
@@ -607,7 +608,7 @@
             initrd_base = 0;
             initrd_size = 0;
         }
-        boot_device = 'm';
+        ppc_boot_device = 'm';
     } else {
         kernel_base = 0;
         kernel_size = 0;
@@ -695,7 +696,7 @@
     nvram.opaque = m48t59;
     nvram.read_fn = &m48t59_read;
     nvram.write_fn = &m48t59_write;
-    PPC_NVRAM_set_params(&nvram, NVRAM_SIZE, "PREP", ram_size, boot_device,
+    PPC_NVRAM_set_params(&nvram, NVRAM_SIZE, "PREP", ram_size, ppc_boot_device,
                          kernel_base, kernel_size,
                          kernel_cmdline,
                          initrd_base, initrd_size,
diff --git a/hw/r2d.c b/hw/r2d.c
index 33d03cb..fa35051 100644
--- a/hw/r2d.c
+++ b/hw/r2d.c
@@ -27,7 +27,7 @@
 #define SDRAM_BASE 0x0c000000 /* Physical location of SDRAM: Area 3 */
 #define SDRAM_SIZE 0x04000000
 
-void r2d_init(int ram_size, int vga_ram_size, int boot_device,
+static void r2d_init(int ram_size, int vga_ram_size, const char *boot_device,
 	      DisplayState * ds, const char **fd_filename, int snapshot,
 	      const char *kernel_filename, const char *kernel_cmdline,
 	      const char *initrd_filename, const char *cpu_model)
diff --git a/hw/realview.c b/hw/realview.c
index 375f78a..b2f4ff2 100644
--- a/hw/realview.c
+++ b/hw/realview.c
@@ -12,8 +12,9 @@
 
 /* Board init.  */
 
-static void realview_init(int ram_size, int vga_ram_size, int boot_device,
-                     DisplayState *ds, const char **fd_filename, int snapshot,
+static void realview_init(int ram_size, int vga_ram_size,
+                     const char *boot_device, DisplayState *ds,
+                     const char **fd_filename, int snapshot,
                      const char *kernel_filename, const char *kernel_cmdline,
                      const char *initrd_filename, const char *cpu_model)
 {
diff --git a/hw/shix.c b/hw/shix.c
index 884178e..e65427a 100644
--- a/hw/shix.c
+++ b/hw/shix.c
@@ -62,7 +62,7 @@
     /* XXXXX */
 }
 
-void shix_init(int ram_size, int vga_ram_size, int boot_device,
+static void shix_init(int ram_size, int vga_ram_size, const char *boot_device,
 	       DisplayState * ds, const char **fd_filename, int snapshot,
 	       const char *kernel_filename, const char *kernel_cmdline,
 	       const char *initrd_filename, const char *cpu_model)
diff --git a/hw/spitz.c b/hw/spitz.c
index aca244e..68bba18 100644
--- a/hw/spitz.c
+++ b/hw/spitz.c
@@ -1228,8 +1228,9 @@
     sl_bootparam_write(SL_PXA_PARAM_BASE - PXA2XX_SDRAM_BASE);
 }
 
-static void spitz_init(int ram_size, int vga_ram_size, int boot_device,
-                DisplayState *ds, const char **fd_filename, int snapshot,
+static void spitz_init(int ram_size, int vga_ram_size,
+                const char *boot_device, DisplayState *ds,
+                const char **fd_filename, int snapshot,
                 const char *kernel_filename, const char *kernel_cmdline,
                 const char *initrd_filename, const char *cpu_model)
 {
@@ -1237,8 +1238,9 @@
                 kernel_cmdline, initrd_filename, cpu_model, spitz, 0x2c9);
 }
 
-static void borzoi_init(int ram_size, int vga_ram_size, int boot_device,
-                DisplayState *ds, const char **fd_filename, int snapshot,
+static void borzoi_init(int ram_size, int vga_ram_size,
+                const char *boot_device, DisplayState *ds,
+                const char **fd_filename, int snapshot,
                 const char *kernel_filename, const char *kernel_cmdline,
                 const char *initrd_filename, const char *cpu_model)
 {
@@ -1246,8 +1248,9 @@
                 kernel_cmdline, initrd_filename, cpu_model, borzoi, 0x33f);
 }
 
-static void akita_init(int ram_size, int vga_ram_size, int boot_device,
-                DisplayState *ds, const char **fd_filename, int snapshot,
+static void akita_init(int ram_size, int vga_ram_size,
+                const char *boot_device, DisplayState *ds,
+                const char **fd_filename, int snapshot,
                 const char *kernel_filename, const char *kernel_cmdline,
                 const char *initrd_filename, const char *cpu_model)
 {
@@ -1255,8 +1258,9 @@
                 kernel_cmdline, initrd_filename, cpu_model, akita, 0x2e8);
 }
 
-static void terrier_init(int ram_size, int vga_ram_size, int boot_device,
-                DisplayState *ds, const char **fd_filename, int snapshot,
+static void terrier_init(int ram_size, int vga_ram_size,
+                const char *boot_device, DisplayState *ds,
+                const char **fd_filename, int snapshot,
                 const char *kernel_filename, const char *kernel_cmdline,
                 const char *initrd_filename, const char *cpu_model)
 {
diff --git a/hw/sun4m.c b/hw/sun4m.c
index a12aec9..b332802 100644
--- a/hw/sun4m.c
+++ b/hw/sun4m.c
@@ -158,7 +158,7 @@
 extern int nographic;
 
 static void nvram_init(m48t59_t *nvram, uint8_t *macaddr, const char *cmdline,
-                       int boot_device, uint32_t RAM_size,
+                       const char *boot_device, uint32_t RAM_size,
                        uint32_t kernel_size,
                        int width, int height, int depth,
                        int machine_id)
@@ -175,7 +175,7 @@
     m48t59_write(nvram, 0x2E, 0);
     m48t59_write(nvram, 0x2F, nographic & 0xff);
     nvram_set_lword(nvram,  0x30, RAM_size);
-    m48t59_write(nvram, 0x34, boot_device & 0xff);
+    m48t59_write(nvram, 0x34, boot_device[0] & 0xff);
     nvram_set_lword(nvram,  0x38, KERNEL_LOAD_ADDR);
     nvram_set_lword(nvram,  0x3C, kernel_size);
     if (cmdline) {
@@ -408,7 +408,8 @@
     return nvram;
 }
 
-static void sun4m_load_kernel(long vram_size, int RAM_size, int boot_device,
+static void sun4m_load_kernel(long vram_size, int RAM_size,
+                              const char *boot_device,
                               const char *kernel_filename,
                               const char *kernel_cmdline,
                               const char *initrd_filename,
@@ -548,7 +549,7 @@
     },
 };
 
-static void sun4m_common_init(int RAM_size, int boot_device, DisplayState *ds,
+static void sun4m_common_init(int RAM_size, const char *boot_device, DisplayState *ds,
                               const char *kernel_filename, const char *kernel_cmdline,
                               const char *initrd_filename, const char *cpu_model,
                               unsigned int machine, int max_ram)
@@ -569,7 +570,7 @@
 }
 
 /* SPARCstation 5 hardware initialisation */
-static void ss5_init(int RAM_size, int vga_ram_size, int boot_device,
+static void ss5_init(int RAM_size, int vga_ram_size, const char *boot_device,
                        DisplayState *ds, const char **fd_filename, int snapshot,
                        const char *kernel_filename, const char *kernel_cmdline,
                        const char *initrd_filename, const char *cpu_model)
@@ -582,7 +583,7 @@
 }
 
 /* SPARCstation 10 hardware initialisation */
-static void ss10_init(int RAM_size, int vga_ram_size, int boot_device,
+static void ss10_init(int RAM_size, int vga_ram_size, const char *boot_device,
                             DisplayState *ds, const char **fd_filename, int snapshot,
                             const char *kernel_filename, const char *kernel_cmdline,
                             const char *initrd_filename, const char *cpu_model)
diff --git a/hw/sun4u.c b/hw/sun4u.c
index bac0ebf..317ba74 100644
--- a/hw/sun4u.c
+++ b/hw/sun4u.c
@@ -331,7 +331,7 @@
 static fdctrl_t *floppy_controller;
 
 /* Sun4u hardware initialisation */
-static void sun4u_init(int ram_size, int vga_ram_size, int boot_device,
+static void sun4u_init(int ram_size, int vga_ram_size, const char *boot_device,
              DisplayState *ds, const char **fd_filename, int snapshot,
              const char *kernel_filename, const char *kernel_cmdline,
              const char *initrd_filename, const char *cpu_model)
@@ -456,7 +456,7 @@
     i8042_init(NULL/*1*/, NULL/*12*/, 0x60);
     floppy_controller = fdctrl_init(NULL/*6*/, 2, 0, 0x3f0, fd_table);
     nvram = m48t59_init(NULL/*8*/, 0, 0x0074, NVRAM_SIZE, 59);
-    sun4u_NVRAM_set_params(nvram, NVRAM_SIZE, "Sun4u", ram_size, boot_device,
+    sun4u_NVRAM_set_params(nvram, NVRAM_SIZE, "Sun4u", ram_size, boot_device[0],
                          KERNEL_LOAD_ADDR, kernel_size,
                          kernel_cmdline,
                          INITRD_LOAD_ADDR, initrd_size,
diff --git a/hw/versatilepb.c b/hw/versatilepb.c
index 2e3dedd..31d58ef 100644
--- a/hw/versatilepb.c
+++ b/hw/versatilepb.c
@@ -151,8 +151,9 @@
    peripherans and expansion busses.  For now we emulate a subset of the
    PB peripherals and just change the board ID.  */
 
-static void versatile_init(int ram_size, int vga_ram_size, int boot_device,
-                     DisplayState *ds, const char **fd_filename, int snapshot,
+static void versatile_init(int ram_size, int vga_ram_size,
+                     const char *boot_device, DisplayState *ds,
+                     const char **fd_filename, int snapshot,
                      const char *kernel_filename, const char *kernel_cmdline,
                      const char *initrd_filename, const char *cpu_model,
                      int board_id)
@@ -266,7 +267,7 @@
                     initrd_filename, board_id, 0x0);
 }
 
-static void vpb_init(int ram_size, int vga_ram_size, int boot_device,
+static void vpb_init(int ram_size, int vga_ram_size, const char *boot_device,
                      DisplayState *ds, const char **fd_filename, int snapshot,
                      const char *kernel_filename, const char *kernel_cmdline,
                      const char *initrd_filename, const char *cpu_model)
@@ -277,7 +278,7 @@
                    initrd_filename, cpu_model, 0x183);
 }
 
-static void vab_init(int ram_size, int vga_ram_size, int boot_device,
+static void vab_init(int ram_size, int vga_ram_size, const char *boot_device,
                      DisplayState *ds, const char **fd_filename, int snapshot,
                      const char *kernel_filename, const char *kernel_cmdline,
                      const char *initrd_filename, const char *cpu_model)
diff --git a/vl.c b/vl.c
index f9500a9..73a22da 100644
--- a/vl.c
+++ b/vl.c
@@ -162,7 +162,12 @@
 int nographic;
 const char* keyboard_layout = NULL;
 int64_t ticks_per_sec;
-int boot_device = 'c';
+#if defined(TARGET_I386)
+#define MAX_BOOT_DEVICES 3
+#else
+#define MAX_BOOT_DEVICES 1
+#endif
+static char boot_device[MAX_BOOT_DEVICES + 1];
 int ram_size;
 int pit_min_timer_count = 0;
 int nb_nics;
@@ -7810,14 +7815,19 @@
                 }
                 break;
             case QEMU_OPTION_boot:
-                boot_device = optarg[0];
-                if (boot_device != 'a' &&
+                if (strlen(optarg) > MAX_BOOT_DEVICES) {
+                    fprintf(stderr, "qemu: too many boot devices\n");
+                    exit(1);
+                }
+                strncpy(boot_device, optarg, MAX_BOOT_DEVICES);
 #if defined(TARGET_SPARC) || defined(TARGET_I386)
-		    // Network boot
-		    boot_device != 'n' &&
+#define BOOTCHARS "acdn"
+#else
+#define BOOTCHARS "acd"
 #endif
-                    boot_device != 'c' && boot_device != 'd') {
-                    fprintf(stderr, "qemu: invalid boot device '%c'\n", boot_device);
+                if (strlen(boot_device) != strspn(boot_device, BOOTCHARS)) {
+                    fprintf(stderr, "qemu: invalid boot device "
+                                    "sequence '%s'\n", boot_device);
                     exit(1);
                 }
                 break;
@@ -8168,20 +8178,22 @@
     linux_boot = (kernel_filename != NULL);
 
     if (!linux_boot &&
-        boot_device != 'n' &&
+        (!strchr(boot_device, 'n')) &&
         hd_filename[0] == '\0' &&
         (cdrom_index >= 0 && hd_filename[cdrom_index] == '\0') &&
         fd_filename[0] == '\0')
         help(1);
 
     /* boot to floppy or the default cd if no hard disk defined yet */
-    if (hd_filename[0] == '\0' && boot_device == 'c') {
-        if (fd_filename[0] != '\0')
-            boot_device = 'a';
+    if (!boot_device[0]) {
+        if (hd_filename[0] != '\0')
+            boot_device[0] = 'c';
+        else if (fd_filename[0] != '\0')
+            boot_device[0] = 'a';
         else
-            boot_device = 'd';
+            boot_device[0] = 'd';
+        boot_device[1] = 0;
     }
-
     setvbuf(stdout, NULL, _IOLBF, 0);
 
     init_timers();
@@ -8220,7 +8232,7 @@
     }
 
 #ifdef TARGET_I386
-    if (boot_device == 'n') {
+    if (strchr(boot_device, 'n')) {
 	for (i = 0; i < nb_nics; i++) {
 	    const char *model = nd_table[i].model;
 	    char buf[1024];
diff --git a/vl.h b/vl.h
index 90fdcf9..2ef8886 100644
--- a/vl.h
+++ b/vl.h
@@ -731,7 +731,7 @@
 #ifndef QEMU_TOOL
 
 typedef void QEMUMachineInitFunc(int ram_size, int vga_ram_size,
-                                 int boot_device,
+                                 const char *boot_device,
              DisplayState *ds, const char **fd_filename, int snapshot,
              const char *kernel_filename, const char *kernel_cmdline,
              const char *initrd_filename, const char *cpu_model);