From: "J. Mayer" <l_indien@magic.fr>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [ADD] floppy disk emulation
Date: 18 Nov 2003 08:38:25 +0100 [thread overview]
Message-ID: <1069141105.13658.2196.camel@rapid> (raw)
In-Reply-To: <1069140120.13658.2160.camel@rapid>
vl.c.diff
Add helper to register floppy drives in CMOS memory.
Make qemu able to boot from floppy
Add floppy init.
diff -urNbB -x CVS qemu-current/vl.c qemu/vl.c
--- qemu-current/vl.c Tue Nov 18 06:51:10 2003
+++ qemu/vl.c Tue Nov 18 02:19:33 2003
@@ -49,6 +50,8 @@
#include "thunk.h"
#include "vl.h"
+
+#define USE_FLOPPY
#define DEFAULT_NETWORK_SCRIPT "/etc/qemu-ifup"
#define BIOS_FILENAME "bios.bin"
@@ -210,7 +217,7 @@
CPUX86State *cpu_single_env;
IOPortReadFunc *ioport_read_table[3][MAX_IOPORTS];
IOPortWriteFunc *ioport_write_table[3][MAX_IOPORTS];
-BlockDriverState *bs_table[MAX_DISKS];
+BlockDriverState *bs_table[MAX_DISKS], *fd_table[MAX_FD];
int vga_ram_size;
static DisplayState display_state;
int nographic;
@@ -577,9 +584,12 @@
cmos_data[0x35] = val >> 8;
switch(boot_device) {
+#ifdef USE_FLOPPY
case 'a':
+ case 'b':
cmos_data[0x3d] = 0x01; /* floppy boot */
break;
+#endif
default:
case 'c':
cmos_data[0x3d] = 0x02; /* hard drive boot */
@@ -593,6 +603,57 @@
register_ioport_read(0x70, 2, cmos_ioport_read, 1);
}
+#ifdef USE_FLOPPY
+void cmos_register_fd (uint8_t fd0, uint8_t fd1)
+{
+ int nb = 0;
+
+ cmos_data[0x10] = 0;
+ switch (fd0) {
+ case 0:
+ /* 1.44 Mb 3"5 drive */
+ cmos_data[0x10] |= 0x40;
+ break;
+ case 1:
+ /* 2.88 Mb 3"5 drive */
+ cmos_data[0x10] |= 0x60;
+ break;
+ case 2:
+ /* 1.2 Mb 5"5 drive */
+ cmos_data[0x10] |= 0x20;
+ break;
+ }
+ switch (fd1) {
+ case 0:
+ /* 1.44 Mb 3"5 drive */
+ cmos_data[0x10] |= 0x04;
+ break;
+ case 1:
+ /* 2.88 Mb 3"5 drive */
+ cmos_data[0x10] |= 0x06;
+ break;
+ case 2:
+ /* 1.2 Mb 5"5 drive */
+ cmos_data[0x10] |= 0x02;
+ break;
+ }
+ if (fd0 < 3)
+ nb++;
+ if (fd1 < 3)
+ nb++;
+ switch (nb) {
+ case 0:
+ break;
+ case 1:
+ cmos_data[REG_EQUIPMENT_BYTE] |= 0x01; /* 1 drive, ready for boot */
+ break;
+ case 2:
+ cmos_data[REG_EQUIPMENT_BYTE] |= 0x41; /* 2 drives, ready for boot */
+ break;
+ }
+}
+#endif
+
/***********************************************************/
/* 8259 pic emulation */
@@ -1952,6 +2127,26 @@
}
/***********************************************************/
+/* PC floppy disk controler emulation glue */
+#define PC_FDC_DMA 0x2
+#define PC_FDC_IRQ 0x6
+#define PC_FDC_BASE 0x3F0
+
+static void fdctrl_register (unsigned char **disknames, int ro,
+ char boot_device)
+{
+#ifdef USE_FLOPPY
+ int i;
+
+ fdctrl_init(PC_FDC_IRQ, PC_FDC_DMA, 0, PC_FDC_BASE, boot_device);
+ for (i = 0; i < MAX_FD; i++) {
+ if (disknames[i] != NULL)
+ fdctrl_disk_change(i, disknames[i], ro);
+ }
+#endif
+}
+
+/***********************************************************/
/* keyboard emulation */
/* Keyboard Controller Commands */
@@ -2853,6 +3053,8 @@
"'disk_image' is a raw hard image image for IDE hard disk 0\n"
"\n"
"Standard options:\n"
+ "-fda file use 'file' as floppy disk 0 image\n"
+ "-fdb file use 'file' as floppy disk 1 image\n"
"-hda/-hdb file use 'file' as IDE hard disk 0/1 image\n"
"-hdc/-hdd file use 'file' as IDE hard disk 2/3 image\n"
"-cdrom file use 'file' as IDE cdrom 2 image\n"
@@ -2907,6 +3109,8 @@
{ "hdd", 1, NULL, 0, },
{ "cdrom", 1, NULL, 0, },
{ "boot", 1, NULL, 0, },
+ { "fda", 1, NULL, 0, },
+ { "fdb", 1, NULL, 0, },
{ NULL, 0, NULL, 0 },
};
@@ -2931,13 +3135,15 @@
struct itimerval itv;
CPUX86State *env;
const char *initrd_filename;
- const char *hd_filename[MAX_DISKS];
+ const char *hd_filename[MAX_DISKS], *fd_filename[MAX_FD];
const char *kernel_filename, *kernel_cmdline;
DisplayState *ds = &display_state;
/* we never want that malloc() uses mmap() */
mallopt(M_MMAP_THRESHOLD, 4096 * 1024);
initrd_filename = NULL;
+ for(i = 0; i < MAX_FD; i++)
+ fd_filename[i] = NULL;
for(i = 0; i < MAX_DISKS; i++)
hd_filename[i] = NULL;
phys_ram_size = 32 * 1024 * 1024;
@@ -3012,11 +3218,18 @@
break;
case 12:
boot_device = optarg[0];
- if (boot_device != 'c' && boot_device != 'd') {
+ if (boot_device != 'a' && boot_device != 'b' &&
+ boot_device != 'c' && boot_device != 'd') {
fprintf(stderr, "qemu: invalid boot device '%c'\n", boot_device);
exit(1);
}
break;
+ case 13:
+ fd_filename[0] = optarg;
+ break;
+ case 14:
+ fd_filename[1] = optarg;
+ break;
}
break;
case 'h':
@@ -3056,7 +3269,8 @@
linux_boot = (kernel_filename != NULL);
- if (!linux_boot && hd_filename[0] == '\0' && hd_filename[2] == '\0')
+ if (!linux_boot && hd_filename[0] == '\0' && hd_filename[2] == '\0' &&
+ fd_filename[0] == '\0')
help();
/* boot to cd by default if no hard disk */
@@ -3268,7 +3482,8 @@
AUD_init();
DMA_init();
SB16_init();
+ fdctrl_register((unsigned char **)fd_filename, snapshot, boot_device);
/* setup cpu signal handlers for MMU / self modifying code handling */
sigfillset(&act.sa_mask);
act.sa_flags = SA_SIGINFO;
next prev parent reply other threads:[~2003-11-18 8:35 UTC|newest]
Thread overview: 65+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-11-17 9:51 [Qemu-devel] new knoppix SegFault Jens Arm
2003-11-18 7:15 ` [Qemu-devel] [PATCH] Fixes for qemu J. Mayer
2003-11-18 7:30 ` J. Mayer
2003-11-18 7:31 ` Chad Page
2003-11-18 7:32 ` J. Mayer
2003-11-18 7:33 ` J. Mayer
2003-11-18 7:34 ` J. Mayer
2003-11-18 8:24 ` J. Mayer
2003-11-18 7:22 ` [Qemu-devel] [ADD] floppy disk emulation J. Mayer
2003-11-18 7:37 ` J. Mayer
2003-11-18 7:38 ` J. Mayer [this message]
2003-11-18 7:39 ` J. Mayer
2003-11-18 7:39 ` J. Mayer
2003-11-18 8:24 ` J. Mayer
2003-11-18 7:28 ` [Qemu-devel] [ADD] PPC processor emulation J. Mayer
2003-11-18 7:43 ` J. Mayer
2003-11-18 7:43 ` J. Mayer
2003-11-18 7:44 ` J. Mayer
2003-11-18 7:45 ` J. Mayer
2003-11-18 7:45 ` J. Mayer
2003-11-18 7:46 ` J. Mayer
2003-11-18 7:46 ` J. Mayer
2003-11-18 7:48 ` J. Mayer
2003-11-18 7:48 ` J. Mayer
2003-11-18 7:49 ` J. Mayer
2003-11-18 7:50 ` J. Mayer
2003-11-18 7:50 ` J. Mayer
2003-11-18 7:51 ` J. Mayer
2003-11-18 7:53 ` J. Mayer
2003-11-18 7:54 ` J. Mayer
2003-11-18 7:55 ` J. Mayer
2003-11-18 7:56 ` J. Mayer
2003-11-18 7:56 ` J. Mayer
2003-11-18 7:57 ` J. Mayer
2003-11-18 7:58 ` J. Mayer
2003-11-18 7:59 ` J. Mayer
2003-11-18 7:59 ` J. Mayer
2003-11-18 8:00 ` J. Mayer
2003-11-18 8:02 ` [Qemu-devel] [ADD] tests for PPC target J. Mayer
2003-11-18 8:06 ` J. Mayer
2003-11-18 8:08 ` J. Mayer
2003-11-18 8:08 ` J. Mayer
2003-11-18 8:09 ` J. Mayer
2003-11-18 8:10 ` J. Mayer
2003-11-18 8:25 ` J. Mayer
2003-11-18 8:24 ` [Qemu-devel] [ADD] PPC processor emulation J. Mayer
2003-11-18 9:37 ` Gwenole Beauchesne
2003-11-18 10:37 ` J. Mayer
2003-11-18 11:39 ` Raymond W. Lucke IV
2003-11-18 12:13 ` J. Mayer
2003-11-18 20:24 ` Raymond W. Lucke IV
2003-11-18 20:44 ` Jocelyn Mayer
2003-11-18 21:48 ` Chad Page
2003-11-18 22:50 ` J. Mayer
2003-11-19 1:11 ` Benjamin Herrenschmidt
2003-11-19 15:35 ` Jocelyn Mayer
2003-11-18 12:24 ` Gwenole Beauchesne
2003-11-18 12:57 ` Johan Rydberg
2003-11-18 14:52 ` Gwenole Beauchesne
2003-11-18 14:59 ` Jocelyn Mayer
2003-11-18 7:29 ` [Qemu-devel] [PATCH] Term prompt for qemu J. Mayer
2003-11-18 8:11 ` J. Mayer
2003-11-18 8:11 ` J. Mayer
2003-11-18 8:13 ` J. Mayer
2003-11-18 8:25 ` J. Mayer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1069141105.13658.2196.camel@rapid \
--to=l_indien@magic.fr \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).