From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1CGZ8C-0001ZE-O9 for qemu-devel@nongnu.org; Sun, 10 Oct 2004 04:32:41 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1CGZ87-0001Xt-G9 for qemu-devel@nongnu.org; Sun, 10 Oct 2004 04:32:36 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CGZ86-0001Xl-Qw for qemu-devel@nongnu.org; Sun, 10 Oct 2004 04:32:35 -0400 Received: from [80.91.229.2] (helo=main.gmane.org) by monty-python.gnu.org with esmtp (Exim 4.34) id 1CGZ11-00042d-Hh for qemu-devel@nongnu.org; Sun, 10 Oct 2004 04:25:15 -0400 Received: from list by main.gmane.org with local (Exim 3.35 #1 (Debian)) id 1CGZ10-0005oj-00 for ; Sun, 10 Oct 2004 10:25:14 +0200 Received: from 203.7.227.188 ([203.7.227.188]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 10 Oct 2004 10:25:14 +0200 Received: from wildfire by 203.7.227.188 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 10 Oct 2004 10:25:14 +0200 From: Anand Kumria Date: Sun, 10 Oct 2004 18:31:28 +1000 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Sender: news Subject: [Qemu-devel] change boot device in monitor Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org 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,