* [Qemu-devel] [Patch] set boot sequence from command line
@ 2007-10-24 8:46 Dan Kenigsberg
2007-10-24 21:17 ` Laurent Vivier
` (3 more replies)
0 siblings, 4 replies; 8+ messages in thread
From: Dan Kenigsberg @ 2007-10-24 8:46 UTC (permalink / raw)
To: qemu-devel
Real PCs try to boot from a CD, then try the hard drive, and finally go
to the network. And they let their owner change that order.
This patch lets Qemu do the same with "-boot dcn".
I'll be happy to hear comments about it,
Dan.
diff --git a/hw/an5206.c b/hw/an5206.c
index 94ecccb..2134184 100644
--- a/hw/an5206.c
+++ b/hw/an5206.c
@@ -27,7 +27,7 @@ void DMA_run (void)
/* 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, 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..19689ba 100644
--- a/hw/mcf5208.c
+++ b/hw/mcf5208.c
@@ -197,7 +197,7 @@ static void mcf5208_sys_init(qemu_irq *pic)
}
}
-static void mcf5208evb_init(int ram_size, int vga_ram_size, int boot_device,
+static void mcf5208evb_init(int ram_size, int vga_ram_size, 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 623fcd6..971ff37 100644
--- a/hw/palm.c
+++ b/hw/palm.c
@@ -61,7 +61,7 @@ static void palmte_microwire_setup(struct omap_mpu_state_s *cpu)
{
}
-static void palmte_init(int ram_size, int vga_ram_size, int boot_device,
+static void palmte_init(int ram_size, int vga_ram_size, 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 a0c824f..3c552ff 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -152,8 +152,25 @@ static void cmos_init_hd(int type_ofs, int info_ofs, BlockDriverState *hd)
rtc_set_memory(s, info_ofs + 8, sectors);
}
+/* convert boot_device letter to something recognizable by the bios */
+static int boot_device2nible(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, char *boot_device, BlockDriverState **hd_table)
{
RTCState *s = rtc_state;
int val;
@@ -184,24 +201,12 @@ static void cmos_init(int ram_size, int boot_device, BlockDriverState **hd_table
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_device2nible(boot_device[1]) << 4 |
+ boot_device2nible(boot_device[0]) );
+ rtc_set_memory(s, 0x38,
+ boot_device2nible(boot_device[2]) << 4 | (fd_bootchk ? 0x0 : 0x1));
/* floppy type */
@@ -663,7 +668,7 @@ static void pc_init_ne2k_isa(NICInfo *nd, qemu_irq *pic)
}
/* 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, char *boot_device,
DisplayState *ds, const char **fd_filename, int snapshot,
const char *kernel_filename, const char *kernel_cmdline,
const char *initrd_filename,
@@ -947,7 +952,7 @@ static void pc_init1(int ram_size, int vga_ram_size, int boot_device,
#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, char *boot_device,
DisplayState *ds, const char **fd_filename,
int snapshot,
const char *kernel_filename,
@@ -961,7 +966,7 @@ static void pc_init_pci(int ram_size, int vga_ram_size, int boot_device,
initrd_filename, 1, cpu_model);
}
-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, char *boot_device,
DisplayState *ds, const char **fd_filename,
int snapshot,
const char *kernel_filename,
diff --git a/hw/ppc.c b/hw/ppc.c
index 742d3de..d1bc943 100644
--- a/hw/ppc.c
+++ b/hw/ppc.c
@@ -1347,7 +1347,7 @@ uint16_t NVRAM_compute_crc (m48t59_t *nvram, uint32_t start, uint32_t count)
int PPC_NVRAM_set_params (m48t59_t *nvram, uint16_t NVRAM_size,
const unsigned char *arch,
- uint32_t RAM_size, int boot_device,
+ uint32_t RAM_size, char *boot_device,
uint32_t kernel_image, uint32_t kernel_size,
const char *cmdline,
uint32_t initrd_image, uint32_t initrd_size,
@@ -1362,7 +1362,7 @@ int PPC_NVRAM_set_params (m48t59_t *nvram, uint16_t NVRAM_size,
NVRAM_set_word(nvram, 0x14, NVRAM_size);
NVRAM_set_string(nvram, 0x20, arch, 16);
NVRAM_set_lword(nvram, 0x30, RAM_size);
- NVRAM_set_byte(nvram, 0x34, boot_device);
+ NVRAM_set_byte(nvram, 0x34, boot_device[0]);
NVRAM_set_lword(nvram, 0x38, kernel_image);
NVRAM_set_lword(nvram, 0x3C, kernel_size);
if (cmdline) {
diff --git a/hw/ppc_chrp.c b/hw/ppc_chrp.c
index f53c85b..64c0fd1 100644
--- a/hw/ppc_chrp.c
+++ b/hw/ppc_chrp.c
@@ -300,7 +300,7 @@ void pmac_format_nvram_partition (uint8_t *buf, int len)
}
/* PowerPC CHRP hardware initialisation */
-static void ppc_chrp_init (int ram_size, int vga_ram_size, int boot_device,
+static void ppc_chrp_init (int ram_size, int vga_ram_size, char *boot_device,
DisplayState *ds, const char **fd_filename,
int snapshot,
const char *kernel_filename,
@@ -405,7 +405,7 @@ static void ppc_chrp_init (int ram_size, int vga_ram_size, int boot_device,
initrd_base = 0;
initrd_size = 0;
}
- boot_device = 'm';
+ boot_device[0] = 'm';
} else {
kernel_base = 0;
kernel_size = 0;
@@ -571,7 +571,7 @@ static void ppc_chrp_init (int ram_size, int vga_ram_size, int boot_device,
register_ioport_write(0x0F00, 4, 1, &PPC_debug_write, NULL);
}
-static void ppc_core99_init (int ram_size, int vga_ram_size, int boot_device,
+static void ppc_core99_init (int ram_size, int vga_ram_size, char *boot_device,
DisplayState *ds, const char **fd_filename,
int snapshot,
const char *kernel_filename,
@@ -585,7 +585,7 @@ static void ppc_core99_init (int ram_size, int vga_ram_size, int boot_device,
initrd_filename, cpu_model, 0);
}
-static void ppc_heathrow_init (int ram_size, int vga_ram_size, int boot_device,
+static void ppc_heathrow_init (int ram_size, int vga_ram_size, char *boot_device,
DisplayState *ds, const char **fd_filename,
int snapshot,
const char *kernel_filename,
diff --git a/hw/ppc_prep.c b/hw/ppc_prep.c
index 2c4b242..96bfde5 100644
--- a/hw/ppc_prep.c
+++ b/hw/ppc_prep.c
@@ -518,7 +518,7 @@ CPUReadMemoryFunc *PPC_prep_io_read[] = {
#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, char *boot_device,
DisplayState *ds, const char **fd_filename,
int snapshot, const char *kernel_filename,
const char *kernel_cmdline,
@@ -600,7 +600,7 @@ static void ppc_prep_init (int ram_size, int vga_ram_size, int boot_device,
initrd_base = 0;
initrd_size = 0;
}
- boot_device = 'm';
+ boot_device[0] = 'm';
} else {
kernel_base = 0;
kernel_size = 0;
diff --git a/hw/realview.c b/hw/realview.c
index 375f78a..3acc96f 100644
--- a/hw/realview.c
+++ b/hw/realview.c
@@ -12,7 +12,7 @@
/* Board init. */
-static void realview_init(int ram_size, int vga_ram_size, int boot_device,
+static void realview_init(int ram_size, int vga_ram_size, 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..7481eef 100644
--- a/hw/sun4m.c
+++ b/hw/sun4m.c
@@ -158,7 +158,7 @@ static void nvram_finish_partition (m48t59_t *nvram, uint32_t start,
extern int nographic;
static void nvram_init(m48t59_t *nvram, uint8_t *macaddr, const char *cmdline,
- int boot_device, uint32_t RAM_size,
+ char *boot_device, uint32_t RAM_size,
uint32_t kernel_size,
int width, int height, int depth,
int machine_id)
@@ -175,7 +175,7 @@ static void nvram_init(m48t59_t *nvram, uint8_t *macaddr, const char *cmdline,
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,7 @@ static void *sun4m_hw_init(const struct hwdef *hwdef, int RAM_size,
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, char *boot_device,
const char *kernel_filename,
const char *kernel_cmdline,
const char *initrd_filename,
@@ -548,7 +548,7 @@ static const struct hwdef hwdefs[] = {
},
};
-static void sun4m_common_init(int RAM_size, int boot_device, DisplayState *ds,
+static void sun4m_common_init(int RAM_size, 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 +569,7 @@ static void sun4m_common_init(int RAM_size, int boot_device, DisplayState *ds,
}
/* 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, 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 +582,7 @@ static void ss5_init(int RAM_size, int vga_ram_size, int boot_device,
}
/* 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, 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..2c1b598 100644
--- a/hw/sun4u.c
+++ b/hw/sun4u.c
@@ -203,7 +203,7 @@ extern int nographic;
int sun4u_NVRAM_set_params (m48t59_t *nvram, uint16_t NVRAM_size,
const unsigned char *arch,
- uint32_t RAM_size, int boot_device,
+ uint32_t RAM_size, char *boot_device,
uint32_t kernel_image, uint32_t kernel_size,
const char *cmdline,
uint32_t initrd_image, uint32_t initrd_size,
@@ -221,7 +221,7 @@ int sun4u_NVRAM_set_params (m48t59_t *nvram, uint16_t NVRAM_size,
NVRAM_set_string(nvram, 0x20, arch, 16);
NVRAM_set_byte(nvram, 0x2f, nographic & 0xff);
NVRAM_set_lword(nvram, 0x30, RAM_size);
- NVRAM_set_byte(nvram, 0x34, boot_device);
+ NVRAM_set_byte(nvram, 0x34, boot_device[0]);
NVRAM_set_lword(nvram, 0x38, kernel_image);
NVRAM_set_lword(nvram, 0x3C, kernel_size);
if (cmdline) {
@@ -331,7 +331,7 @@ static const int parallel_irq[MAX_PARALLEL_PORTS] = { 7, 7, 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, 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 6d8fe35..be0e06a 100644
--- a/vl.c
+++ b/vl.c
@@ -161,7 +161,7 @@ static DisplayState display_state;
int nographic;
const char* keyboard_layout = NULL;
int64_t ticks_per_sec;
-int boot_device = 'c';
+static char *boot_device;
int ram_size;
int pit_min_timer_count = 0;
int nb_nics;
@@ -7788,14 +7788,19 @@ int main(int argc, char **argv)
}
break;
case QEMU_OPTION_boot:
- boot_device = optarg[0];
- if (boot_device != 'a' &&
+ if (strlen(optarg) > 3) {
+ fprintf(stderr, "qemu: too many boot devices\n");
+ exit(1);
+ }
+ boot_device = strdup(optarg);
+ if (!strchr(boot_device, 'a') &&
#if defined(TARGET_SPARC) || defined(TARGET_I386)
// Network boot
- boot_device != 'n' &&
+ !strchr(boot_device, 'n') &&
#endif
- boot_device != 'c' && boot_device != 'd') {
- fprintf(stderr, "qemu: invalid boot device '%c'\n", boot_device);
+ !strchr(boot_device, 'c') &&
+ !strchr(boot_device, 'd')) {
+ fprintf(stderr, "qemu: invalid boot device sequence '%s'\n", boot_device);
exit(1);
}
break;
@@ -8146,20 +8151,21 @@ int main(int argc, char **argv)
linux_boot = (kernel_filename != NULL);
if (!linux_boot &&
- boot_device != 'n' &&
+ (!boot_device || !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) {
+ if (hd_filename[0] != '\0')
+ boot_device = "c";
+ else if (fd_filename[0] != '\0')
+ boot_device = "a";
else
- boot_device = 'd';
+ boot_device = "d";
}
-
setvbuf(stdout, NULL, _IOLBF, 0);
init_timers();
@@ -8198,7 +8204,7 @@ int main(int argc, char **argv)
}
#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 adf6004..4751f2f 100644
--- a/vl.h
+++ b/vl.h
@@ -725,7 +725,7 @@ void path_combine(char *dest, int dest_size,
#ifndef QEMU_TOOL
typedef void QEMUMachineInitFunc(int ram_size, int vga_ram_size,
- int boot_device,
+ 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);
@@ -1339,7 +1339,7 @@ void NVRAM_set_crc (m48t59_t *nvram, uint32_t addr,
uint32_t start, uint32_t count);
int PPC_NVRAM_set_params (m48t59_t *nvram, uint16_t NVRAM_size,
const unsigned char *arch,
- uint32_t RAM_size, int boot_device,
+ uint32_t RAM_size, char *boot_device,
uint32_t kernel_image, uint32_t kernel_size,
const char *cmdline,
uint32_t initrd_image, uint32_t initrd_size,
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [Patch] set boot sequence from command line
2007-10-24 8:46 [Qemu-devel] [Patch] set boot sequence from command line Dan Kenigsberg
@ 2007-10-24 21:17 ` Laurent Vivier
2007-10-24 21:41 ` Anthony Liguori
` (2 subsequent siblings)
3 siblings, 0 replies; 8+ messages in thread
From: Laurent Vivier @ 2007-10-24 21:17 UTC (permalink / raw)
To: qemu-devel
Dan Kenigsberg a écrit :
> Real PCs try to boot from a CD, then try the hard drive, and finally go
> to the network. And they let their owner change that order.
> This patch lets Qemu do the same with "-boot dcn".
>
> I'll be happy to hear comments about it,
Personally, I think it's a very good idea.
Laurent
--
---------------- Laurent.Vivier@bull.net -----------------
"Given enough eyeballs, all bugs are shallow" E. S. Raymond
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [Patch] set boot sequence from command line
2007-10-24 8:46 [Qemu-devel] [Patch] set boot sequence from command line Dan Kenigsberg
2007-10-24 21:17 ` Laurent Vivier
@ 2007-10-24 21:41 ` Anthony Liguori
2007-10-24 21:46 ` Daniel P. Berrange
2007-10-24 21:59 ` andrzej zaborowski
2007-10-25 8:49 ` Bernhard Kauer
3 siblings, 1 reply; 8+ messages in thread
From: Anthony Liguori @ 2007-10-24 21:41 UTC (permalink / raw)
To: qemu-devel
Dan Kenigsberg wrote:
> Real PCs try to boot from a CD, then try the hard drive, and finally go
> to the network. And they let their owner change that order.
> This patch lets Qemu do the same with "-boot dcn".
>
> I'll be happy to hear comments about it,
>
Looks good to me. I wrote a very similar patch recently but haven't
gotten around to submitting it. I'm very eager to see this included!
Regards,
Anthony Liguori
> Dan.
>
> diff --git a/hw/an5206.c b/hw/an5206.c
> index 94ecccb..2134184 100644
> --- a/hw/an5206.c
> +++ b/hw/an5206.c
> @@ -27,7 +27,7 @@ void DMA_run (void)
>
> /* 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, 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..19689ba 100644
> --- a/hw/mcf5208.c
> +++ b/hw/mcf5208.c
> @@ -197,7 +197,7 @@ static void mcf5208_sys_init(qemu_irq *pic)
> }
> }
>
> -static void mcf5208evb_init(int ram_size, int vga_ram_size, int boot_device,
> +static void mcf5208evb_init(int ram_size, int vga_ram_size, 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 623fcd6..971ff37 100644
> --- a/hw/palm.c
> +++ b/hw/palm.c
> @@ -61,7 +61,7 @@ static void palmte_microwire_setup(struct omap_mpu_state_s *cpu)
> {
> }
>
> -static void palmte_init(int ram_size, int vga_ram_size, int boot_device,
> +static void palmte_init(int ram_size, int vga_ram_size, 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 a0c824f..3c552ff 100644
> --- a/hw/pc.c
> +++ b/hw/pc.c
> @@ -152,8 +152,25 @@ static void cmos_init_hd(int type_ofs, int info_ofs, BlockDriverState *hd)
> rtc_set_memory(s, info_ofs + 8, sectors);
> }
>
> +/* convert boot_device letter to something recognizable by the bios */
> +static int boot_device2nible(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, char *boot_device, BlockDriverState **hd_table)
> {
> RTCState *s = rtc_state;
> int val;
> @@ -184,24 +201,12 @@ static void cmos_init(int ram_size, int boot_device, BlockDriverState **hd_table
> 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_device2nible(boot_device[1]) << 4 |
> + boot_device2nible(boot_device[0]) );
> + rtc_set_memory(s, 0x38,
> + boot_device2nible(boot_device[2]) << 4 | (fd_bootchk ? 0x0 : 0x1));
>
> /* floppy type */
>
> @@ -663,7 +668,7 @@ static void pc_init_ne2k_isa(NICInfo *nd, qemu_irq *pic)
> }
>
> /* 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, char *boot_device,
> DisplayState *ds, const char **fd_filename, int snapshot,
> const char *kernel_filename, const char *kernel_cmdline,
> const char *initrd_filename,
> @@ -947,7 +952,7 @@ static void pc_init1(int ram_size, int vga_ram_size, int boot_device,
> #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, char *boot_device,
> DisplayState *ds, const char **fd_filename,
> int snapshot,
> const char *kernel_filename,
> @@ -961,7 +966,7 @@ static void pc_init_pci(int ram_size, int vga_ram_size, int boot_device,
> initrd_filename, 1, cpu_model);
> }
>
> -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, char *boot_device,
> DisplayState *ds, const char **fd_filename,
> int snapshot,
> const char *kernel_filename,
> diff --git a/hw/ppc.c b/hw/ppc.c
> index 742d3de..d1bc943 100644
> --- a/hw/ppc.c
> +++ b/hw/ppc.c
> @@ -1347,7 +1347,7 @@ uint16_t NVRAM_compute_crc (m48t59_t *nvram, uint32_t start, uint32_t count)
>
> int PPC_NVRAM_set_params (m48t59_t *nvram, uint16_t NVRAM_size,
> const unsigned char *arch,
> - uint32_t RAM_size, int boot_device,
> + uint32_t RAM_size, char *boot_device,
> uint32_t kernel_image, uint32_t kernel_size,
> const char *cmdline,
> uint32_t initrd_image, uint32_t initrd_size,
> @@ -1362,7 +1362,7 @@ int PPC_NVRAM_set_params (m48t59_t *nvram, uint16_t NVRAM_size,
> NVRAM_set_word(nvram, 0x14, NVRAM_size);
> NVRAM_set_string(nvram, 0x20, arch, 16);
> NVRAM_set_lword(nvram, 0x30, RAM_size);
> - NVRAM_set_byte(nvram, 0x34, boot_device);
> + NVRAM_set_byte(nvram, 0x34, boot_device[0]);
> NVRAM_set_lword(nvram, 0x38, kernel_image);
> NVRAM_set_lword(nvram, 0x3C, kernel_size);
> if (cmdline) {
> diff --git a/hw/ppc_chrp.c b/hw/ppc_chrp.c
> index f53c85b..64c0fd1 100644
> --- a/hw/ppc_chrp.c
> +++ b/hw/ppc_chrp.c
> @@ -300,7 +300,7 @@ void pmac_format_nvram_partition (uint8_t *buf, int len)
> }
>
> /* PowerPC CHRP hardware initialisation */
> -static void ppc_chrp_init (int ram_size, int vga_ram_size, int boot_device,
> +static void ppc_chrp_init (int ram_size, int vga_ram_size, char *boot_device,
> DisplayState *ds, const char **fd_filename,
> int snapshot,
> const char *kernel_filename,
> @@ -405,7 +405,7 @@ static void ppc_chrp_init (int ram_size, int vga_ram_size, int boot_device,
> initrd_base = 0;
> initrd_size = 0;
> }
> - boot_device = 'm';
> + boot_device[0] = 'm';
> } else {
> kernel_base = 0;
> kernel_size = 0;
> @@ -571,7 +571,7 @@ static void ppc_chrp_init (int ram_size, int vga_ram_size, int boot_device,
> register_ioport_write(0x0F00, 4, 1, &PPC_debug_write, NULL);
> }
>
> -static void ppc_core99_init (int ram_size, int vga_ram_size, int boot_device,
> +static void ppc_core99_init (int ram_size, int vga_ram_size, char *boot_device,
> DisplayState *ds, const char **fd_filename,
> int snapshot,
> const char *kernel_filename,
> @@ -585,7 +585,7 @@ static void ppc_core99_init (int ram_size, int vga_ram_size, int boot_device,
> initrd_filename, cpu_model, 0);
> }
>
> -static void ppc_heathrow_init (int ram_size, int vga_ram_size, int boot_device,
> +static void ppc_heathrow_init (int ram_size, int vga_ram_size, char *boot_device,
> DisplayState *ds, const char **fd_filename,
> int snapshot,
> const char *kernel_filename,
> diff --git a/hw/ppc_prep.c b/hw/ppc_prep.c
> index 2c4b242..96bfde5 100644
> --- a/hw/ppc_prep.c
> +++ b/hw/ppc_prep.c
> @@ -518,7 +518,7 @@ CPUReadMemoryFunc *PPC_prep_io_read[] = {
> #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, char *boot_device,
> DisplayState *ds, const char **fd_filename,
> int snapshot, const char *kernel_filename,
> const char *kernel_cmdline,
> @@ -600,7 +600,7 @@ static void ppc_prep_init (int ram_size, int vga_ram_size, int boot_device,
> initrd_base = 0;
> initrd_size = 0;
> }
> - boot_device = 'm';
> + boot_device[0] = 'm';
> } else {
> kernel_base = 0;
> kernel_size = 0;
> diff --git a/hw/realview.c b/hw/realview.c
> index 375f78a..3acc96f 100644
> --- a/hw/realview.c
> +++ b/hw/realview.c
> @@ -12,7 +12,7 @@
>
> /* Board init. */
>
> -static void realview_init(int ram_size, int vga_ram_size, int boot_device,
> +static void realview_init(int ram_size, int vga_ram_size, 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..7481eef 100644
> --- a/hw/sun4m.c
> +++ b/hw/sun4m.c
> @@ -158,7 +158,7 @@ static void nvram_finish_partition (m48t59_t *nvram, uint32_t start,
> extern int nographic;
>
> static void nvram_init(m48t59_t *nvram, uint8_t *macaddr, const char *cmdline,
> - int boot_device, uint32_t RAM_size,
> + char *boot_device, uint32_t RAM_size,
> uint32_t kernel_size,
> int width, int height, int depth,
> int machine_id)
> @@ -175,7 +175,7 @@ static void nvram_init(m48t59_t *nvram, uint8_t *macaddr, const char *cmdline,
> 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,7 @@ static void *sun4m_hw_init(const struct hwdef *hwdef, int RAM_size,
> 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, char *boot_device,
> const char *kernel_filename,
> const char *kernel_cmdline,
> const char *initrd_filename,
> @@ -548,7 +548,7 @@ static const struct hwdef hwdefs[] = {
> },
> };
>
> -static void sun4m_common_init(int RAM_size, int boot_device, DisplayState *ds,
> +static void sun4m_common_init(int RAM_size, 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 +569,7 @@ static void sun4m_common_init(int RAM_size, int boot_device, DisplayState *ds,
> }
>
> /* 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, 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 +582,7 @@ static void ss5_init(int RAM_size, int vga_ram_size, int boot_device,
> }
>
> /* 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, 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..2c1b598 100644
> --- a/hw/sun4u.c
> +++ b/hw/sun4u.c
> @@ -203,7 +203,7 @@ extern int nographic;
>
> int sun4u_NVRAM_set_params (m48t59_t *nvram, uint16_t NVRAM_size,
> const unsigned char *arch,
> - uint32_t RAM_size, int boot_device,
> + uint32_t RAM_size, char *boot_device,
> uint32_t kernel_image, uint32_t kernel_size,
> const char *cmdline,
> uint32_t initrd_image, uint32_t initrd_size,
> @@ -221,7 +221,7 @@ int sun4u_NVRAM_set_params (m48t59_t *nvram, uint16_t NVRAM_size,
> NVRAM_set_string(nvram, 0x20, arch, 16);
> NVRAM_set_byte(nvram, 0x2f, nographic & 0xff);
> NVRAM_set_lword(nvram, 0x30, RAM_size);
> - NVRAM_set_byte(nvram, 0x34, boot_device);
> + NVRAM_set_byte(nvram, 0x34, boot_device[0]);
> NVRAM_set_lword(nvram, 0x38, kernel_image);
> NVRAM_set_lword(nvram, 0x3C, kernel_size);
> if (cmdline) {
> @@ -331,7 +331,7 @@ static const int parallel_irq[MAX_PARALLEL_PORTS] = { 7, 7, 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, 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 6d8fe35..be0e06a 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -161,7 +161,7 @@ static DisplayState display_state;
> int nographic;
> const char* keyboard_layout = NULL;
> int64_t ticks_per_sec;
> -int boot_device = 'c';
> +static char *boot_device;
> int ram_size;
> int pit_min_timer_count = 0;
> int nb_nics;
> @@ -7788,14 +7788,19 @@ int main(int argc, char **argv)
> }
> break;
> case QEMU_OPTION_boot:
> - boot_device = optarg[0];
> - if (boot_device != 'a' &&
> + if (strlen(optarg) > 3) {
> + fprintf(stderr, "qemu: too many boot devices\n");
> + exit(1);
> + }
> + boot_device = strdup(optarg);
> + if (!strchr(boot_device, 'a') &&
> #if defined(TARGET_SPARC) || defined(TARGET_I386)
> // Network boot
> - boot_device != 'n' &&
> + !strchr(boot_device, 'n') &&
> #endif
> - boot_device != 'c' && boot_device != 'd') {
> - fprintf(stderr, "qemu: invalid boot device '%c'\n", boot_device);
> + !strchr(boot_device, 'c') &&
> + !strchr(boot_device, 'd')) {
> + fprintf(stderr, "qemu: invalid boot device sequence '%s'\n", boot_device);
> exit(1);
> }
> break;
> @@ -8146,20 +8151,21 @@ int main(int argc, char **argv)
> linux_boot = (kernel_filename != NULL);
>
> if (!linux_boot &&
> - boot_device != 'n' &&
> + (!boot_device || !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) {
> + if (hd_filename[0] != '\0')
> + boot_device = "c";
> + else if (fd_filename[0] != '\0')
> + boot_device = "a";
> else
> - boot_device = 'd';
> + boot_device = "d";
> }
> -
> setvbuf(stdout, NULL, _IOLBF, 0);
>
> init_timers();
> @@ -8198,7 +8204,7 @@ int main(int argc, char **argv)
> }
>
> #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 adf6004..4751f2f 100644
> --- a/vl.h
> +++ b/vl.h
> @@ -725,7 +725,7 @@ void path_combine(char *dest, int dest_size,
> #ifndef QEMU_TOOL
>
> typedef void QEMUMachineInitFunc(int ram_size, int vga_ram_size,
> - int boot_device,
> + 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);
> @@ -1339,7 +1339,7 @@ void NVRAM_set_crc (m48t59_t *nvram, uint32_t addr,
> uint32_t start, uint32_t count);
> int PPC_NVRAM_set_params (m48t59_t *nvram, uint16_t NVRAM_size,
> const unsigned char *arch,
> - uint32_t RAM_size, int boot_device,
> + uint32_t RAM_size, char *boot_device,
> uint32_t kernel_image, uint32_t kernel_size,
> const char *cmdline,
> uint32_t initrd_image, uint32_t initrd_size,
>
>
>
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [Patch] set boot sequence from command line
2007-10-24 21:41 ` Anthony Liguori
@ 2007-10-24 21:46 ` Daniel P. Berrange
0 siblings, 0 replies; 8+ messages in thread
From: Daniel P. Berrange @ 2007-10-24 21:46 UTC (permalink / raw)
To: qemu-devel
On Wed, Oct 24, 2007 at 04:41:20PM -0500, Anthony Liguori wrote:
> Dan Kenigsberg wrote:
> >Real PCs try to boot from a CD, then try the hard drive, and finally go
> >to the network. And they let their owner change that order.
> >This patch lets Qemu do the same with "-boot dcn".
> >
> >I'll be happy to hear comments about it,
> >
>
> Looks good to me. I wrote a very similar patch recently but haven't
> gotten around to submitting it. I'm very eager to see this included!
A more or less identical patch to this has been in Xen's fork of QEMU for
quite a while & works nicely, so it'd definitely be good to have this in
the main QEMU codebase.
Dan.
--
|=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=|
|=- Perl modules: http://search.cpan.org/~danberr/ -=|
|=- Projects: http://freshmeat.net/~danielpb/ -=|
|=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [Patch] set boot sequence from command line
2007-10-24 8:46 [Qemu-devel] [Patch] set boot sequence from command line Dan Kenigsberg
2007-10-24 21:17 ` Laurent Vivier
2007-10-24 21:41 ` Anthony Liguori
@ 2007-10-24 21:59 ` andrzej zaborowski
2007-10-24 22:15 ` J. Mayer
2007-10-25 8:49 ` Bernhard Kauer
3 siblings, 1 reply; 8+ messages in thread
From: andrzej zaborowski @ 2007-10-24 21:59 UTC (permalink / raw)
To: qemu-devel
On 24/10/2007, Dan Kenigsberg <danken@qumranet.com> wrote:
> Real PCs try to boot from a CD, then try the hard drive, and finally go
> to the network. And they let their owner change that order.
With the difference that on real PCs this is controlled by the BIOS
menu rather than a hardware switch, but the latter seems more
convenient for qemu.
> This patch lets Qemu do the same with "-boot dcn".
>
> I'll be happy to hear comments about it,
>
> Dan.
>
> diff --git a/hw/an5206.c b/hw/an5206.c
> index 94ecccb..2134184 100644
> --- a/hw/an5206.c
> +++ b/hw/an5206.c
> @@ -27,7 +27,7 @@ void DMA_run (void)
>
> /* 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, 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)
BTW, it may be a good idea to pass all these values (maybe except ds)
as a single struct, for purely practical reasons.
Regards
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [Patch] set boot sequence from command line
2007-10-24 21:59 ` andrzej zaborowski
@ 2007-10-24 22:15 ` J. Mayer
0 siblings, 0 replies; 8+ messages in thread
From: J. Mayer @ 2007-10-24 22:15 UTC (permalink / raw)
To: qemu-devel
On Wed, 2007-10-24 at 23:59 +0200, andrzej zaborowski wrote:
> On 24/10/2007, Dan Kenigsberg <danken@qumranet.com> wrote:
> > Real PCs try to boot from a CD, then try the hard drive, and finally go
> > to the network. And they let their owner change that order.
>
> With the difference that on real PCs this is controlled by the BIOS
> menu rather than a hardware switch, but the latter seems more
> convenient for qemu.
>
> > This patch lets Qemu do the same with "-boot dcn".
> >
> > I'll be happy to hear comments about it,
> >
> > Dan.
> >
> > diff --git a/hw/an5206.c b/hw/an5206.c
> > index 94ecccb..2134184 100644
> > --- a/hw/an5206.c
> > +++ b/hw/an5206.c
> > @@ -27,7 +27,7 @@ void DMA_run (void)
> >
> > /* 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, 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)
>
> BTW, it may be a good idea to pass all these values (maybe except ds)
> as a single struct, for purely practical reasons.
> Regards
Maybe the use of several structure may be better:
- one could be used to describe the kernel boot (with kernel_filename,
kernel_cmdline, initrd_filename) and could be NULL
- one for the hardware emulation parameters (ram_size, vga_ram_sze,
cpu_model)
- one for the emulation parameters if needed (snapshot, ds...)
...
It may be more consistent than use a single structure melting misc stuff
that are not directly related.
One remark about the submited patch:
why are the boot order table limited to 3 elements ? There are at least
4 choices available today (floppy, disk, CDROM, network) and maybe more
in the future for some architecture (refering to the curently emulated
hardware: 2 floppies, 4 IDE devices, <n> network devices, SCSI
storages, ...).
I guess it's not a so good idea to override the boot_device table in the
machine init routines. Imho, it would better be passed as a const char *
argument. For the PowerPC part, there could be a local int boot_device
variable that would be initialized to the first argument of the table.
And this would not change the NVRAM initialisation API: if this API need
to support more than one boot device in the future, it will have to be
completelly reworked (for other reasons too), then I would suggest to be
conservative and do not change this API at all.
--
J. Mayer <l_indien@magic.fr>
Never organized
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [Patch] set boot sequence from command line
2007-10-24 8:46 [Qemu-devel] [Patch] set boot sequence from command line Dan Kenigsberg
` (2 preceding siblings ...)
2007-10-24 21:59 ` andrzej zaborowski
@ 2007-10-25 8:49 ` Bernhard Kauer
2007-10-25 9:35 ` [Qemu-devel] [Patch] set boot sequence from command line - Take 2 Dan Kenigsberg
3 siblings, 1 reply; 8+ messages in thread
From: Bernhard Kauer @ 2007-10-25 8:49 UTC (permalink / raw)
To: qemu-devel
It is perhaps not the best idea to read behind the
end of the boot_device string. It would be safer to
declare boot_device as 'static char boot_device[4]'
and use a strncpy.
Bernhard
> diff --git a/hw/pc.c b/hw/pc.c
> index a0c824f..3c552ff 100644
> --- a/hw/pc.c
> +++ b/hw/pc.c
> + /* set boot devices, and disable floppy signature check if requested */
> + rtc_set_memory(s, 0x3d,
> + boot_device2nible(boot_device[1]) << 4 |
> + boot_device2nible(boot_device[0]) );
> + rtc_set_memory(s, 0x38,
> + boot_device2nible(boot_device[2]) << 4 | (fd_bootchk ? 0x0 : 0x1));
>
> /* floppy type */
> diff --git a/vl.c b/vl.c
> index 6d8fe35..be0e06a 100644
> --- a/vl.c
> +++ b/vl.c
> + if (strlen(optarg) > 3) {
> + fprintf(stderr, "qemu: too many boot devices\n");
> + exit(1);
> + }
> + boot_device = strdup(optarg);
> + if (!strchr(boot_device, 'a') &&
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [Patch] set boot sequence from command line - Take 2
2007-10-25 8:49 ` Bernhard Kauer
@ 2007-10-25 9:35 ` Dan Kenigsberg
0 siblings, 0 replies; 8+ messages in thread
From: Dan Kenigsberg @ 2007-10-25 9:35 UTC (permalink / raw)
To: qemu-devel
On Thu, Oct 25, 2007 at 10:49:25AM +0200, Bernhard Kauer wrote:
> It is perhaps not the best idea to read behind the
> end of the boot_device string. It would be safer to
> declare boot_device as 'static char boot_device[4]'
> and use a strncpy.
>
>
> Bernhard
>
Thanks for the good catch! (and to others who commented)
In this "take" has the following changes:
1. QEMUMachineInitFunc uses const char *boot_device
2. correct spelling of `nibble'
3. avoid touching PPC_NVRAM_set_params() API needlessly
4. allocate boot_device statically
5. define MAX_BOOT_DEVICES clearly according to the TARGET. Only three
devices are supoorted by the i386 bios
6. reject the boot string if it includes a single unrecognized letter
Dan.
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 @@ void DMA_run (void)
/* 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/mcf5208.c b/hw/mcf5208.c
index 993a686..8c4181b 100644
--- a/hw/mcf5208.c
+++ b/hw/mcf5208.c
@@ -197,7 +197,7 @@ static void mcf5208_sys_init(qemu_irq *pic)
}
}
-static void mcf5208evb_init(int ram_size, int vga_ram_size, int boot_device,
+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/palm.c b/hw/palm.c
index 623fcd6..3101e9e 100644
--- a/hw/palm.c
+++ b/hw/palm.c
@@ -61,7 +61,7 @@ static void palmte_microwire_setup(struct omap_mpu_state_s *cpu)
{
}
-static void palmte_init(int ram_size, int vga_ram_size, int boot_device,
+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 a0c824f..3e4e06a 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -152,8 +152,25 @@ static void cmos_init_hd(int type_ofs, int info_ofs, BlockDriverState *hd)
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 @@ static void cmos_init(int ram_size, int boot_device, BlockDriverState **hd_table
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 @@ static void pc_init_ne2k_isa(NICInfo *nd, qemu_irq *pic)
}
/* 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,
@@ -947,7 +952,7 @@ static void pc_init1(int ram_size, int vga_ram_size, int boot_device,
#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,
@@ -961,7 +966,7 @@ static void pc_init_pci(int ram_size, int vga_ram_size, int boot_device,
initrd_filename, 1, cpu_model);
}
-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/ppc_chrp.c b/hw/ppc_chrp.c
index f53c85b..6fbde7f 100644
--- a/hw/ppc_chrp.c
+++ b/hw/ppc_chrp.c
@@ -300,7 +300,7 @@ void pmac_format_nvram_partition (uint8_t *buf, int len)
}
/* PowerPC CHRP hardware initialisation */
-static void ppc_chrp_init (int ram_size, int vga_ram_size, int boot_device,
+static void ppc_chrp_init (int ram_size, int vga_ram_size, const char *boot_device,
DisplayState *ds, const char **fd_filename,
int snapshot,
const char *kernel_filename,
@@ -322,6 +322,7 @@ static void ppc_chrp_init (int ram_size, int vga_ram_size, int boot_device,
const char *arch_name;
int vga_bios_size, bios_size;
qemu_irq *dummy_irq;
+ int ppc_boot_device = boot_device[0];
linux_boot = (kernel_filename != NULL);
@@ -405,7 +406,7 @@ static void ppc_chrp_init (int ram_size, int vga_ram_size, int boot_device,
initrd_base = 0;
initrd_size = 0;
}
- boot_device = 'm';
+ ppc_boot_device = 'm';
} else {
kernel_base = 0;
kernel_size = 0;
@@ -558,7 +559,7 @@ static void ppc_chrp_init (int ram_size, int vga_ram_size, int boot_device,
if (graphic_depth != 15 && graphic_depth != 32 && graphic_depth != 8)
graphic_depth = 15;
- PPC_NVRAM_set_params(nvram, NVRAM_SIZE, arch_name, ram_size, boot_device,
+ PPC_NVRAM_set_params(nvram, NVRAM_SIZE, arch_name, ram_size, ppc_boot_device,
kernel_base, kernel_size,
kernel_cmdline,
initrd_base, initrd_size,
@@ -571,7 +572,7 @@ static void ppc_chrp_init (int ram_size, int vga_ram_size, int boot_device,
register_ioport_write(0x0F00, 4, 1, &PPC_debug_write, NULL);
}
-static void ppc_core99_init (int ram_size, int vga_ram_size, int boot_device,
+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,
@@ -585,7 +586,7 @@ static void ppc_core99_init (int ram_size, int vga_ram_size, int boot_device,
initrd_filename, cpu_model, 0);
}
-static void ppc_heathrow_init (int ram_size, int vga_ram_size, int boot_device,
+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,
diff --git a/hw/ppc_prep.c b/hw/ppc_prep.c
index 2c4b242..7a92edf 100644
--- a/hw/ppc_prep.c
+++ b/hw/ppc_prep.c
@@ -518,7 +518,7 @@ CPUReadMemoryFunc *PPC_prep_io_read[] = {
#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,
@@ -535,6 +535,7 @@ static void ppc_prep_init (int ram_size, int vga_ram_size, int boot_device,
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)
@@ -600,7 +601,7 @@ static void ppc_prep_init (int ram_size, int vga_ram_size, int boot_device,
initrd_base = 0;
initrd_size = 0;
}
- boot_device = 'm';
+ ppc_boot_device = 'm';
} else {
kernel_base = 0;
kernel_size = 0;
@@ -689,7 +690,7 @@ static void ppc_prep_init (int ram_size, int vga_ram_size, int boot_device,
sysctrl->nvram = nvram;
/* Initialise NVRAM */
- 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/realview.c b/hw/realview.c
index 375f78a..9582c92 100644
--- a/hw/realview.c
+++ b/hw/realview.c
@@ -12,7 +12,7 @@
/* Board init. */
-static void realview_init(int ram_size, int vga_ram_size, int boot_device,
+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/sun4m.c b/hw/sun4m.c
index a12aec9..e5511cd 100644
--- a/hw/sun4m.c
+++ b/hw/sun4m.c
@@ -158,7 +158,7 @@ static void nvram_finish_partition (m48t59_t *nvram, uint32_t start,
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 @@ static void nvram_init(m48t59_t *nvram, uint8_t *macaddr, const char *cmdline,
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,7 @@ static void *sun4m_hw_init(const struct hwdef *hwdef, int RAM_size,
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 +548,7 @@ static const struct hwdef hwdefs[] = {
},
};
-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 +569,7 @@ static void sun4m_common_init(int RAM_size, int boot_device, DisplayState *ds,
}
/* 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 +582,7 @@ static void ss5_init(int RAM_size, int vga_ram_size, int boot_device,
}
/* 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 const int parallel_irq[MAX_PARALLEL_PORTS] = { 7, 7, 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 @@ static void sun4u_init(int ram_size, int vga_ram_size, int boot_device,
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/vl.c b/vl.c
index 6d8fe35..9a34490 100644
--- a/vl.c
+++ b/vl.c
@@ -161,7 +161,12 @@ static DisplayState display_state;
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;
@@ -7788,14 +7793,18 @@ int main(int argc, char **argv)
}
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;
@@ -8146,20 +8155,22 @@ int main(int argc, char **argv)
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();
@@ -8198,7 +8209,7 @@ int main(int argc, char **argv)
}
#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 adf6004..390d221 100644
--- a/vl.h
+++ b/vl.h
@@ -725,7 +725,7 @@ void path_combine(char *dest, int dest_size,
#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);
^ permalink raw reply related [flat|nested] 8+ messages in thread
end of thread, other threads:[~2007-10-25 9:35 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-24 8:46 [Qemu-devel] [Patch] set boot sequence from command line Dan Kenigsberg
2007-10-24 21:17 ` Laurent Vivier
2007-10-24 21:41 ` Anthony Liguori
2007-10-24 21:46 ` Daniel P. Berrange
2007-10-24 21:59 ` andrzej zaborowski
2007-10-24 22:15 ` J. Mayer
2007-10-25 8:49 ` Bernhard Kauer
2007-10-25 9:35 ` [Qemu-devel] [Patch] set boot sequence from command line - Take 2 Dan Kenigsberg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).