[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] change boot device in monitor
From: |
Anand Kumria |
Subject: |
[Qemu-devel] change boot device in monitor |
Date: |
Sun, 10 Oct 2004 18:31:28 +1000 |
User-agent: |
Pan/0.14.2.91 (As She Crawled Across the Table (Debian GNU/Linux)) |
Hi,
Attached is a patch which allows you to change the boot device in the
monitor. The change won't take affect until the next 'system_reset' but
I've found it useful as I can specify a floppy, hard disk and cdrom and
switch between booting them without exiting.
This is against current CVS - I've only tested this on x86 but I've put in
what I think are the right hooks for PPC and Sparc. When looking at this,
I was thinking that a struct vm_state might be useful.
As I'm now going to be working on a way to modify the memory amount within
the monitor. The struct_vm would basically be the what is used for
savevm/loadvm. Thoughts?
Regards,
Anand
diff -x qemu.pod -X dont-diff -urN upstream/hw/pc.c my-chg-boot/hw/pc.c
--- upstream/hw/pc.c 2004-10-10 02:47:59.000000000 +1000
+++ my-chg-boot/hw/pc.c 2004-10-10 17:02:39.000000000 +1000
@@ -101,6 +101,26 @@
return val;
}
+
+void boot_device_set(int boot_device)
+{
+ RTCState *s = rtc_state;
+
+ switch(boot_device) {
+ case 'a':
+ case 'b':
+ rtc_set_memory(s, 0x3d, 0x01); /* floppy boot */
+ 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;
+ }
+}
+
static void cmos_init_hd(int type_ofs, int info_ofs, BlockDriverState *hd)
{
RTCState *s = rtc_state;
@@ -163,21 +183,9 @@
val = 65535;
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 */
- 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;
- }
-
+
+ boot_device_set(boot_device);
+
/* floppy type */
fd0 = fdctrl_get_drive_type(floppy_controller, 0);
diff -x qemu.pod -X dont-diff -urN upstream/hw/ppc.c my-chg-boot/hw/ppc.c
--- upstream/hw/ppc.c 2004-06-22 02:53:42.000000000 +1000
+++ my-chg-boot/hw/ppc.c 2004-10-10 15:12:50.000000000 +1000
@@ -398,6 +398,11 @@
return crc;
}
+static void boot_device_set(m48t59_t *nvram, int boot_device)
+{
+ NVRAM_set_byte(nvram, 0x34, boot_device);
+}
+
#define CMDLINE_ADDR 0x017ff000
int PPC_NVRAM_set_params (m48t59_t *nvram, uint16_t NVRAM_size,
@@ -417,7 +422,7 @@
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);
+ boot_device_set(nvram, boot_device);
NVRAM_set_lword(nvram, 0x38, kernel_image);
NVRAM_set_lword(nvram, 0x3C, kernel_size);
if (cmdline) {
diff -x qemu.pod -X dont-diff -urN upstream/monitor.c my-chg-boot/monitor.c
--- upstream/monitor.c 2004-10-10 04:08:01.000000000 +1000
+++ my-chg-boot/monitor.c 2004-10-10 17:00:50.000000000 +1000
@@ -173,6 +173,28 @@
}
}
+static void do_boot(const char *boot_from)
+{
+ switch(boot_from[0]) {
+ case 'a':
+ case 'b':
+ case 'c':
+ case 'd':
+#ifdef TARGET_PPC
+ term_printf("not implemented for PPC\n");
+#elif TARGET_SPARC
+ term_printf("not implemented for Sparc\n");
+#else
+ boot_device_set(boot_from[0]);
+#endif
+ break;
+ default:
+ term_printf("boot device must be one of: a, b, c or d\n");
+ break;
+ }
+
+}
+
static void do_info(const char *item)
{
term_cmd_t *cmd;
@@ -821,6 +843,8 @@
static term_cmd_t term_cmds[] = {
{ "help|?", "s?", do_help,
"[cmd]", "show the help" },
+ { "boot", "s", do_boot,
+ "device", "change the boot device (takes affect next system_reset)" },
{ "commit", "", do_commit,
"", "commit changes to the disk images (if -snapshot is used)" },
{ "info", "s?", do_info,
diff -x qemu.pod -X dont-diff -urN upstream/vl.h my-chg-boot/vl.h
--- upstream/vl.h 2004-10-05 07:23:09.000000000 +1000
+++ my-chg-boot/vl.h 2004-10-10 16:27:42.000000000 +1000
@@ -638,7 +638,16 @@
int pit_get_gate(PITState *pit, int channel);
int pit_get_out(PITState *pit, int channel, int64_t current_time);
+/* pc.c and ppc.c */
+#ifdef TARGET_PPC
+#include "hw/m48t59.h"
+void boot_device_set(m48t59_t *nvram, int boot_device);
+#else /* TARGET_PC */
+void boot_device_set(int boot_device);
+#endif
+
/* pc.c */
+
void pc_init(int ram_size, int vga_ram_size, int boot_device,
DisplayState *ds, const char **fd_filename, int snapshot,
const char *kernel_filename, const char *kernel_cmdline,
- [Qemu-devel] change boot device in monitor,
Anand Kumria <=