* [Qemu-devel] [PATCH v4 00/11] Misc fixes for floppy emulation
@ 2012-02-06 21:29 Hervé Poussineau
2012-02-06 21:29 ` [Qemu-devel] [PATCH v4 01/11] fdc: take side count into account Hervé Poussineau
` (12 more replies)
0 siblings, 13 replies; 18+ messages in thread
From: Hervé Poussineau @ 2012-02-06 21:29 UTC (permalink / raw)
To: qemu-devel; +Cc: Kevin Wolf, Hervé Poussineau
Here are misc fixes done by VirtualBox team.
With these patches, floppy emulation is now good enough to run Xenix.
Changes v3->v4:
- added pc-1.1 machine type
- disable media transfer rate check on older machine types
- save/restore media transfer rate when media transfer rate check enabled
Changes v2->v3:
- removed patch changing controller stepping to 0
- fixed out of bound access after bad seek command
Changes v1->v2:
- updated commit messages
- added missing 'break' and braces
Hervé Poussineau (11):
fdc: take side count into account
fdc: set busy bit when starting a command
fdc: most control commands do not generate interrupts
fdc: handle read-only floppies (abort early on write commands)
fdc: add CCR (Configuration Control Register) write register
block: add a transfer rate for floppy types
pc: add 1.1 machine type
fdc: add a 'check media rate' property. Not used yet
fdc: check if media rate is correct before doing any transfer
fdc: fix seek command, which shouldn't check tracks
fdc: DIR (Digital Input Register) should return status of current
drive...
block.c | 74 ++++++++++++++++--------------
block.h | 10 ++++-
hw/fdc.c | 142 +++++++++++++++++++++++++++++++++++++++++++++++-----------
hw/pc.c | 3 +-
hw/pc_piix.c | 47 +++++++++++++++++++-
5 files changed, 211 insertions(+), 65 deletions(-)
--
1.7.8.3
^ permalink raw reply [flat|nested] 18+ messages in thread
* [Qemu-devel] [PATCH v4 01/11] fdc: take side count into account
2012-02-06 21:29 [Qemu-devel] [PATCH v4 00/11] Misc fixes for floppy emulation Hervé Poussineau
@ 2012-02-06 21:29 ` Hervé Poussineau
2012-02-06 21:29 ` [Qemu-devel] [PATCH v4 02/11] fdc: set busy bit when starting a command Hervé Poussineau
` (11 subsequent siblings)
12 siblings, 0 replies; 18+ messages in thread
From: Hervé Poussineau @ 2012-02-06 21:29 UTC (permalink / raw)
To: qemu-devel; +Cc: Kevin Wolf, Hervé Poussineau
Floppies can be simple or double-sided. However, current code
was only taking the common case into account (ie 2 sides).
This repairs single-sided floppies, which where totally broken
before this patch : for track > 0, wrong sector number was
calculated, and data was read/written at wrong place on
underlying device.
Fortunately, only some 360 kB floppies are single-sided, so
this bug was probably not seen much.
Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
---
hw/fdc.c | 17 +++++++++++------
1 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/hw/fdc.c b/hw/fdc.c
index f575a2c..cd479f0 100644
--- a/hw/fdc.c
+++ b/hw/fdc.c
@@ -95,16 +95,19 @@ static void fd_init(FDrive *drv)
drv->max_track = 0;
}
+#define NUM_SIDES(drv) ((drv)->flags & FDISK_DBL_SIDES ? 2 : 1)
+
static int fd_sector_calc(uint8_t head, uint8_t track, uint8_t sect,
- uint8_t last_sect)
+ uint8_t last_sect, uint8_t num_sides)
{
- return (((track * 2) + head) * last_sect) + sect - 1;
+ return (((track * num_sides) + head) * last_sect) + sect - 1;
}
/* Returns current position, in sectors, for given drive */
static int fd_sector(FDrive *drv)
{
- return fd_sector_calc(drv->head, drv->track, drv->sect, drv->last_sect);
+ return fd_sector_calc(drv->head, drv->track, drv->sect, drv->last_sect,
+ NUM_SIDES(drv));
}
/* Seek to a new position:
@@ -135,7 +138,7 @@ static int fd_seek(FDrive *drv, uint8_t head, uint8_t track, uint8_t sect,
drv->max_track, drv->last_sect);
return 3;
}
- sector = fd_sector_calc(head, track, sect, drv->last_sect);
+ sector = fd_sector_calc(head, track, sect, drv->last_sect, NUM_SIDES(drv));
ret = 0;
if (sector != fd_sector(drv)) {
#if 0
@@ -1019,7 +1022,8 @@ static void fdctrl_start_transfer(FDCtrl *fdctrl, int direction)
ks = fdctrl->fifo[4];
FLOPPY_DPRINTF("Start transfer at %d %d %02x %02x (%d)\n",
GET_CUR_DRV(fdctrl), kh, kt, ks,
- fd_sector_calc(kh, kt, ks, cur_drv->last_sect));
+ fd_sector_calc(kh, kt, ks, cur_drv->last_sect,
+ NUM_SIDES(cur_drv)));
switch (fd_seek(cur_drv, kh, kt, ks, fdctrl->config & FD_CONFIG_EIS)) {
case 2:
/* sect too big */
@@ -1289,7 +1293,8 @@ static void fdctrl_format_sector(FDCtrl *fdctrl)
ks = fdctrl->fifo[8];
FLOPPY_DPRINTF("format sector at %d %d %02x %02x (%d)\n",
GET_CUR_DRV(fdctrl), kh, kt, ks,
- fd_sector_calc(kh, kt, ks, cur_drv->last_sect));
+ fd_sector_calc(kh, kt, ks, cur_drv->last_sect,
+ NUM_SIDES(cur_drv)));
switch (fd_seek(cur_drv, kh, kt, ks, fdctrl->config & FD_CONFIG_EIS)) {
case 2:
/* sect too big */
--
1.7.8.3
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [Qemu-devel] [PATCH v4 02/11] fdc: set busy bit when starting a command
2012-02-06 21:29 [Qemu-devel] [PATCH v4 00/11] Misc fixes for floppy emulation Hervé Poussineau
2012-02-06 21:29 ` [Qemu-devel] [PATCH v4 01/11] fdc: take side count into account Hervé Poussineau
@ 2012-02-06 21:29 ` Hervé Poussineau
2012-02-06 21:29 ` [Qemu-devel] [PATCH v4 03/11] fdc: most control commands do not generate interrupts Hervé Poussineau
` (10 subsequent siblings)
12 siblings, 0 replies; 18+ messages in thread
From: Hervé Poussineau @ 2012-02-06 21:29 UTC (permalink / raw)
To: qemu-devel; +Cc: Kevin Wolf, Hervé Poussineau
This bit must be active while a command is currently executed.
Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
---
hw/fdc.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/hw/fdc.c b/hw/fdc.c
index cd479f0..34ea830 100644
--- a/hw/fdc.c
+++ b/hw/fdc.c
@@ -1446,7 +1446,6 @@ static void fdctrl_handle_readid(FDCtrl *fdctrl, int direction)
{
FDrive *cur_drv = get_cur_drv(fdctrl);
- /* XXX: should set main status register to busy */
cur_drv->head = (fdctrl->fifo[1] >> 2) & 1;
qemu_mod_timer(fdctrl->result_timer,
qemu_get_clock_ns(vm_clock) + (get_ticks_per_sec() / 50));
@@ -1734,6 +1733,7 @@ static void fdctrl_write_data(FDCtrl *fdctrl, uint32_t value)
pos = command_to_handler[value & 0xff];
FLOPPY_DPRINTF("%s command\n", handlers[pos].name);
fdctrl->data_len = handlers[pos].parameters + 1;
+ fdctrl->msr |= FD_MSR_CMDBUSY;
}
FLOPPY_DPRINTF("%s: %02x\n", __func__, value);
--
1.7.8.3
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [Qemu-devel] [PATCH v4 03/11] fdc: most control commands do not generate interrupts
2012-02-06 21:29 [Qemu-devel] [PATCH v4 00/11] Misc fixes for floppy emulation Hervé Poussineau
2012-02-06 21:29 ` [Qemu-devel] [PATCH v4 01/11] fdc: take side count into account Hervé Poussineau
2012-02-06 21:29 ` [Qemu-devel] [PATCH v4 02/11] fdc: set busy bit when starting a command Hervé Poussineau
@ 2012-02-06 21:29 ` Hervé Poussineau
2012-02-06 21:29 ` [Qemu-devel] [PATCH v4 04/11] fdc: handle read-only floppies (abort early on write commands) Hervé Poussineau
` (9 subsequent siblings)
12 siblings, 0 replies; 18+ messages in thread
From: Hervé Poussineau @ 2012-02-06 21:29 UTC (permalink / raw)
To: qemu-devel; +Cc: Kevin Wolf, Hervé Poussineau
In fact, only three control commands generate an interrupt:
read_id, recalibrate and seek
Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
---
hw/fdc.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/hw/fdc.c b/hw/fdc.c
index 34ea830..49b8c97 100644
--- a/hw/fdc.c
+++ b/hw/fdc.c
@@ -1348,7 +1348,7 @@ static void fdctrl_handle_lock(FDCtrl *fdctrl, int direction)
{
fdctrl->lock = (fdctrl->fifo[0] & 0x80) ? 1 : 0;
fdctrl->fifo[0] = fdctrl->lock << 4;
- fdctrl_set_fifo(fdctrl, 1, fdctrl->lock);
+ fdctrl_set_fifo(fdctrl, 1, 0);
}
static void fdctrl_handle_dumpreg(FDCtrl *fdctrl, int direction)
@@ -1380,7 +1380,7 @@ static void fdctrl_handle_version(FDCtrl *fdctrl, int direction)
{
/* Controller's version */
fdctrl->fifo[0] = fdctrl->version;
- fdctrl_set_fifo(fdctrl, 1, 1);
+ fdctrl_set_fifo(fdctrl, 1, 0);
}
static void fdctrl_handle_partid(FDCtrl *fdctrl, int direction)
@@ -1439,7 +1439,7 @@ static void fdctrl_handle_save(FDCtrl *fdctrl, int direction)
fdctrl->fifo[12] = fdctrl->pwrd;
fdctrl->fifo[13] = 0;
fdctrl->fifo[14] = 0;
- fdctrl_set_fifo(fdctrl, 15, 1);
+ fdctrl_set_fifo(fdctrl, 15, 0);
}
static void fdctrl_handle_readid(FDCtrl *fdctrl, int direction)
@@ -1580,7 +1580,7 @@ static void fdctrl_handle_powerdown_mode(FDCtrl *fdctrl, int direction)
{
fdctrl->pwrd = fdctrl->fifo[1];
fdctrl->fifo[0] = fdctrl->fifo[1];
- fdctrl_set_fifo(fdctrl, 1, 1);
+ fdctrl_set_fifo(fdctrl, 1, 0);
}
static void fdctrl_handle_option(FDCtrl *fdctrl, int direction)
@@ -1599,7 +1599,7 @@ static void fdctrl_handle_drive_specification_command(FDCtrl *fdctrl, int direct
fdctrl->fifo[0] = fdctrl->fifo[1];
fdctrl->fifo[2] = 0;
fdctrl->fifo[3] = 0;
- fdctrl_set_fifo(fdctrl, 4, 1);
+ fdctrl_set_fifo(fdctrl, 4, 0);
} else {
fdctrl_reset_fifo(fdctrl);
}
@@ -1607,7 +1607,7 @@ static void fdctrl_handle_drive_specification_command(FDCtrl *fdctrl, int direct
/* ERROR */
fdctrl->fifo[0] = 0x80 |
(cur_drv->head << 2) | GET_CUR_DRV(fdctrl);
- fdctrl_set_fifo(fdctrl, 1, 1);
+ fdctrl_set_fifo(fdctrl, 1, 0);
}
}
--
1.7.8.3
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [Qemu-devel] [PATCH v4 04/11] fdc: handle read-only floppies (abort early on write commands)
2012-02-06 21:29 [Qemu-devel] [PATCH v4 00/11] Misc fixes for floppy emulation Hervé Poussineau
` (2 preceding siblings ...)
2012-02-06 21:29 ` [Qemu-devel] [PATCH v4 03/11] fdc: most control commands do not generate interrupts Hervé Poussineau
@ 2012-02-06 21:29 ` Hervé Poussineau
2012-02-06 21:29 ` [Qemu-devel] [PATCH v4 05/11] fdc: add CCR (Configuration Control Register) write register Hervé Poussineau
` (8 subsequent siblings)
12 siblings, 0 replies; 18+ messages in thread
From: Hervé Poussineau @ 2012-02-06 21:29 UTC (permalink / raw)
To: qemu-devel; +Cc: Kevin Wolf, Hervé Poussineau
A real floppy doesn't attempt to write to read-only media either.
Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
---
hw/fdc.c | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/hw/fdc.c b/hw/fdc.c
index 49b8c97..060ca84 100644
--- a/hw/fdc.c
+++ b/hw/fdc.c
@@ -300,6 +300,7 @@ enum {
};
enum {
+ FD_SR1_NW = 0x02, /* Not writable */
FD_SR1_EC = 0x80, /* End of cylinder */
};
@@ -1179,6 +1180,16 @@ static int fdctrl_transfer_handler (void *opaque, int nchan,
break;
case FD_DIR_WRITE:
/* WRITE commands */
+ if (cur_drv->ro) {
+ /* Handle readonly medium early, no need to do DMA, touch the
+ * LED or attempt any writes. A real floppy doesn't attempt
+ * to write to readonly media either. */
+ fdctrl_stop_transfer(fdctrl,
+ FD_SR0_ABNTERM | FD_SR0_SEEK, FD_SR1_NW,
+ 0x00);
+ goto transfer_error;
+ }
+
DMA_read_memory (nchan, fdctrl->fifo + rel_pos,
fdctrl->data_pos, len);
if (bdrv_write(cur_drv->bs, fd_sector(cur_drv),
--
1.7.8.3
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [Qemu-devel] [PATCH v4 05/11] fdc: add CCR (Configuration Control Register) write register
2012-02-06 21:29 [Qemu-devel] [PATCH v4 00/11] Misc fixes for floppy emulation Hervé Poussineau
` (3 preceding siblings ...)
2012-02-06 21:29 ` [Qemu-devel] [PATCH v4 04/11] fdc: handle read-only floppies (abort early on write commands) Hervé Poussineau
@ 2012-02-06 21:29 ` Hervé Poussineau
2012-02-06 21:29 ` [Qemu-devel] [PATCH v4 06/11] block: add a transfer rate for floppy types Hervé Poussineau
` (7 subsequent siblings)
12 siblings, 0 replies; 18+ messages in thread
From: Hervé Poussineau @ 2012-02-06 21:29 UTC (permalink / raw)
To: qemu-devel; +Cc: Kevin Wolf, Hervé Poussineau
DIR and CCR registers share the same address ; DIR is read-only
while CCR is write-only
CCR register is used to change media transfer rate, which will be
checked in following changes.
Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
---
hw/fdc.c | 22 ++++++++++++++++++++++
1 files changed, 22 insertions(+), 0 deletions(-)
diff --git a/hw/fdc.c b/hw/fdc.c
index 060ca84..2bad97b 100644
--- a/hw/fdc.c
+++ b/hw/fdc.c
@@ -224,6 +224,7 @@ static void fdctrl_write_rate(FDCtrl *fdctrl, uint32_t value);
static uint32_t fdctrl_read_data(FDCtrl *fdctrl);
static void fdctrl_write_data(FDCtrl *fdctrl, uint32_t value);
static uint32_t fdctrl_read_dir(FDCtrl *fdctrl);
+static void fdctrl_write_ccr(FDCtrl *fdctrl, uint32_t value);
enum {
FD_DIR_WRITE = 0,
@@ -248,6 +249,7 @@ enum {
FD_REG_DSR = 0x04,
FD_REG_FIFO = 0x05,
FD_REG_DIR = 0x07,
+ FD_REG_CCR = 0x07,
};
enum {
@@ -491,6 +493,9 @@ static void fdctrl_write (void *opaque, uint32_t reg, uint32_t value)
case FD_REG_FIFO:
fdctrl_write_data(fdctrl, value);
break;
+ case FD_REG_CCR:
+ fdctrl_write_ccr(fdctrl, value);
+ break;
default:
break;
}
@@ -881,6 +886,23 @@ static void fdctrl_write_rate(FDCtrl *fdctrl, uint32_t value)
fdctrl->dsr = value;
}
+/* Configuration control register: 0x07 (write) */
+static void fdctrl_write_ccr(FDCtrl *fdctrl, uint32_t value)
+{
+ /* Reset mode */
+ if (!(fdctrl->dor & FD_DOR_nRESET)) {
+ FLOPPY_DPRINTF("Floppy controller in RESET state !\n");
+ return;
+ }
+ FLOPPY_DPRINTF("configuration control register set to 0x%02x\n", value);
+
+ /* Only the rate selection bits used in AT mode, and we
+ * store those in the DSR.
+ */
+ fdctrl->dsr = (fdctrl->dsr & ~FD_DSR_DRATEMASK) |
+ (value & FD_DSR_DRATEMASK);
+}
+
static int fdctrl_media_changed(FDrive *drv)
{
int ret;
--
1.7.8.3
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [Qemu-devel] [PATCH v4 06/11] block: add a transfer rate for floppy types
2012-02-06 21:29 [Qemu-devel] [PATCH v4 00/11] Misc fixes for floppy emulation Hervé Poussineau
` (4 preceding siblings ...)
2012-02-06 21:29 ` [Qemu-devel] [PATCH v4 05/11] fdc: add CCR (Configuration Control Register) write register Hervé Poussineau
@ 2012-02-06 21:29 ` Hervé Poussineau
2012-02-06 21:29 ` [Qemu-devel] [PATCH v4 07/11] pc: add 1.1 machine type Hervé Poussineau
` (6 subsequent siblings)
12 siblings, 0 replies; 18+ messages in thread
From: Hervé Poussineau @ 2012-02-06 21:29 UTC (permalink / raw)
To: qemu-devel; +Cc: Kevin Wolf, Hervé Poussineau
Floppies must be read at a specific transfer rate, depending of its own format.
Update floppy description table to include required transfer rate.
Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
---
block.c | 74 ++++++++++++++++++++++++++++++++-----------------------------
block.h | 10 +++++++-
hw/fdc.c | 3 +-
hw/pc.c | 3 +-
4 files changed, 52 insertions(+), 38 deletions(-)
diff --git a/block.c b/block.c
index 3621d11..e857d52 100644
--- a/block.c
+++ b/block.c
@@ -1915,58 +1915,60 @@ typedef struct FDFormat {
uint8_t last_sect;
uint8_t max_track;
uint8_t max_head;
+ FDriveRate rate;
} FDFormat;
static const FDFormat fd_formats[] = {
/* First entry is default format */
/* 1.44 MB 3"1/2 floppy disks */
- { FDRIVE_DRV_144, 18, 80, 1, },
- { FDRIVE_DRV_144, 20, 80, 1, },
- { FDRIVE_DRV_144, 21, 80, 1, },
- { FDRIVE_DRV_144, 21, 82, 1, },
- { FDRIVE_DRV_144, 21, 83, 1, },
- { FDRIVE_DRV_144, 22, 80, 1, },
- { FDRIVE_DRV_144, 23, 80, 1, },
- { FDRIVE_DRV_144, 24, 80, 1, },
+ { FDRIVE_DRV_144, 18, 80, 1, FDRIVE_RATE_500K, },
+ { FDRIVE_DRV_144, 20, 80, 1, FDRIVE_RATE_500K, },
+ { FDRIVE_DRV_144, 21, 80, 1, FDRIVE_RATE_500K, },
+ { FDRIVE_DRV_144, 21, 82, 1, FDRIVE_RATE_500K, },
+ { FDRIVE_DRV_144, 21, 83, 1, FDRIVE_RATE_500K, },
+ { FDRIVE_DRV_144, 22, 80, 1, FDRIVE_RATE_500K, },
+ { FDRIVE_DRV_144, 23, 80, 1, FDRIVE_RATE_500K },
+ { FDRIVE_DRV_144, 24, 80, 1, FDRIVE_RATE_500K, },
/* 2.88 MB 3"1/2 floppy disks */
- { FDRIVE_DRV_288, 36, 80, 1, },
- { FDRIVE_DRV_288, 39, 80, 1, },
- { FDRIVE_DRV_288, 40, 80, 1, },
- { FDRIVE_DRV_288, 44, 80, 1, },
- { FDRIVE_DRV_288, 48, 80, 1, },
+ { FDRIVE_DRV_288, 36, 80, 1, FDRIVE_RATE_1M, },
+ { FDRIVE_DRV_288, 39, 80, 1, FDRIVE_RATE_1M, },
+ { FDRIVE_DRV_288, 40, 80, 1, FDRIVE_RATE_1M, },
+ { FDRIVE_DRV_288, 44, 80, 1, FDRIVE_RATE_1M, },
+ { FDRIVE_DRV_288, 48, 80, 1, FDRIVE_RATE_1M, },
/* 720 kB 3"1/2 floppy disks */
- { FDRIVE_DRV_144, 9, 80, 1, },
- { FDRIVE_DRV_144, 10, 80, 1, },
- { FDRIVE_DRV_144, 10, 82, 1, },
- { FDRIVE_DRV_144, 10, 83, 1, },
- { FDRIVE_DRV_144, 13, 80, 1, },
- { FDRIVE_DRV_144, 14, 80, 1, },
+ { FDRIVE_DRV_144, 9, 80, 1, FDRIVE_RATE_250K, },
+ { FDRIVE_DRV_144, 10, 80, 1, FDRIVE_RATE_250K, },
+ { FDRIVE_DRV_144, 10, 82, 1, FDRIVE_RATE_250K, },
+ { FDRIVE_DRV_144, 10, 83, 1, FDRIVE_RATE_250K, },
+ { FDRIVE_DRV_144, 13, 80, 1, FDRIVE_RATE_250K, },
+ { FDRIVE_DRV_144, 14, 80, 1, FDRIVE_RATE_250K, },
/* 1.2 MB 5"1/4 floppy disks */
- { FDRIVE_DRV_120, 15, 80, 1, },
- { FDRIVE_DRV_120, 18, 80, 1, },
- { FDRIVE_DRV_120, 18, 82, 1, },
- { FDRIVE_DRV_120, 18, 83, 1, },
- { FDRIVE_DRV_120, 20, 80, 1, },
+ { FDRIVE_DRV_120, 15, 80, 1, FDRIVE_RATE_500K, },
+ { FDRIVE_DRV_120, 18, 80, 1, FDRIVE_RATE_500K, },
+ { FDRIVE_DRV_120, 18, 82, 1, FDRIVE_RATE_500K, },
+ { FDRIVE_DRV_120, 18, 83, 1, FDRIVE_RATE_500K, },
+ { FDRIVE_DRV_120, 20, 80, 1, FDRIVE_RATE_500K, },
/* 720 kB 5"1/4 floppy disks */
- { FDRIVE_DRV_120, 9, 80, 1, },
- { FDRIVE_DRV_120, 11, 80, 1, },
+ { FDRIVE_DRV_120, 9, 80, 1, FDRIVE_RATE_250K, },
+ { FDRIVE_DRV_120, 11, 80, 1, FDRIVE_RATE_250K, },
/* 360 kB 5"1/4 floppy disks */
- { FDRIVE_DRV_120, 9, 40, 1, },
- { FDRIVE_DRV_120, 9, 40, 0, },
- { FDRIVE_DRV_120, 10, 41, 1, },
- { FDRIVE_DRV_120, 10, 42, 1, },
+ { FDRIVE_DRV_120, 9, 40, 1, FDRIVE_RATE_300K, },
+ { FDRIVE_DRV_120, 9, 40, 0, FDRIVE_RATE_300K, },
+ { FDRIVE_DRV_120, 10, 41, 1, FDRIVE_RATE_300K, },
+ { FDRIVE_DRV_120, 10, 42, 1, FDRIVE_RATE_300K, },
/* 320 kB 5"1/4 floppy disks */
- { FDRIVE_DRV_120, 8, 40, 1, },
- { FDRIVE_DRV_120, 8, 40, 0, },
+ { FDRIVE_DRV_120, 8, 40, 1, FDRIVE_RATE_250K, },
+ { FDRIVE_DRV_120, 8, 40, 0, FDRIVE_RATE_250K, },
/* 360 kB must match 5"1/4 better than 3"1/2... */
- { FDRIVE_DRV_144, 9, 80, 0, },
+ { FDRIVE_DRV_144, 9, 80, 0, FDRIVE_RATE_250K, },
/* end */
- { FDRIVE_DRV_NONE, -1, -1, 0, },
+ { FDRIVE_DRV_NONE, -1, -1, 0, 0, },
};
void bdrv_get_floppy_geometry_hint(BlockDriverState *bs, int *nb_heads,
int *max_track, int *last_sect,
- FDriveType drive_in, FDriveType *drive)
+ FDriveType drive_in, FDriveType *drive,
+ FDriveRate *rate)
{
const FDFormat *parse;
uint64_t nb_sectors, size;
@@ -1975,6 +1977,7 @@ void bdrv_get_floppy_geometry_hint(BlockDriverState *bs, int *nb_heads,
bdrv_get_geometry_hint(bs, nb_heads, max_track, last_sect);
if (*nb_heads != 0 && *max_track != 0 && *last_sect != 0) {
/* User defined disk */
+ *rate = FDRIVE_RATE_500K;
} else {
bdrv_get_geometry(bs, &nb_sectors);
match = -1;
@@ -2009,6 +2012,7 @@ void bdrv_get_floppy_geometry_hint(BlockDriverState *bs, int *nb_heads,
*max_track = parse->max_track;
*last_sect = parse->last_sect;
*drive = parse->drive;
+ *rate = parse->rate;
}
}
diff --git a/block.h b/block.h
index cae289b..a7bf2e8 100644
--- a/block.h
+++ b/block.h
@@ -244,9 +244,17 @@ typedef enum FDriveType {
FDRIVE_DRV_NONE = 0x03, /* No drive connected */
} FDriveType;
+typedef enum FDriveRate {
+ FDRIVE_RATE_500K = 0x00, /* 500 Kbps */
+ FDRIVE_RATE_300K = 0x01, /* 300 Kbps */
+ FDRIVE_RATE_250K = 0x02, /* 250 Kbps */
+ FDRIVE_RATE_1M = 0x03, /* 1 Mbps */
+} FDriveRate;
+
void bdrv_get_floppy_geometry_hint(BlockDriverState *bs, int *nb_heads,
int *max_track, int *last_sect,
- FDriveType drive_in, FDriveType *drive);
+ FDriveType drive_in, FDriveType *drive,
+ FDriveRate *rate);
int bdrv_get_translation_hint(BlockDriverState *bs);
void bdrv_set_on_error(BlockDriverState *bs, BlockErrorAction on_read_error,
BlockErrorAction on_write_error);
diff --git a/hw/fdc.c b/hw/fdc.c
index 2bad97b..7c675f6 100644
--- a/hw/fdc.c
+++ b/hw/fdc.c
@@ -172,12 +172,13 @@ static void fd_revalidate(FDrive *drv)
{
int nb_heads, max_track, last_sect, ro;
FDriveType drive;
+ FDriveRate rate;
FLOPPY_DPRINTF("revalidate\n");
if (drv->bs != NULL && bdrv_is_inserted(drv->bs)) {
ro = bdrv_is_read_only(drv->bs);
bdrv_get_floppy_geometry_hint(drv->bs, &nb_heads, &max_track,
- &last_sect, drv->drive, &drive);
+ &last_sect, drv->drive, &drive, &rate);
if (nb_heads != 0 && max_track != 0 && last_sect != 0) {
FLOPPY_DPRINTF("User defined disk (%d %d %d)",
nb_heads - 1, max_track, last_sect);
diff --git a/hw/pc.c b/hw/pc.c
index 7f3aa65..b28a942 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -337,6 +337,7 @@ void pc_cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size,
{
int val, nb, nb_heads, max_track, last_sect, i;
FDriveType fd_type[2] = { FDRIVE_DRV_NONE, FDRIVE_DRV_NONE };
+ FDriveRate rate;
BlockDriverState *fd[MAX_FD];
static pc_cmos_init_late_arg arg;
@@ -385,7 +386,7 @@ void pc_cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size,
if (fd[i] && bdrv_is_inserted(fd[i])) {
bdrv_get_floppy_geometry_hint(fd[i], &nb_heads, &max_track,
&last_sect, FDRIVE_DRV_NONE,
- &fd_type[i]);
+ &fd_type[i], &rate);
}
}
}
--
1.7.8.3
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [Qemu-devel] [PATCH v4 07/11] pc: add 1.1 machine type
2012-02-06 21:29 [Qemu-devel] [PATCH v4 00/11] Misc fixes for floppy emulation Hervé Poussineau
` (5 preceding siblings ...)
2012-02-06 21:29 ` [Qemu-devel] [PATCH v4 06/11] block: add a transfer rate for floppy types Hervé Poussineau
@ 2012-02-06 21:29 ` Hervé Poussineau
2012-02-14 15:11 ` Kevin Wolf
2012-02-06 21:29 ` [Qemu-devel] [PATCH v4 08/11] fdc: add a 'check media rate' property. Not used yet Hervé Poussineau
` (5 subsequent siblings)
12 siblings, 1 reply; 18+ messages in thread
From: Hervé Poussineau @ 2012-02-06 21:29 UTC (permalink / raw)
To: qemu-devel; +Cc: Kevin Wolf, Hervé Poussineau
Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
---
hw/pc_piix.c | 11 ++++++++++-
1 files changed, 10 insertions(+), 1 deletions(-)
diff --git a/hw/pc_piix.c b/hw/pc_piix.c
index c06f1b5..400c6b6 100644
--- a/hw/pc_piix.c
+++ b/hw/pc_piix.c
@@ -371,9 +371,17 @@ static void pc_xen_hvm_init(ram_addr_t ram_size,
}
#endif
+static QEMUMachine pc_machine_v1_1 = {
+ .name = "pc-1.1",
+ .alias = "pc",
+ .desc = "Standard PC",
+ .init = pc_init_pci,
+ .max_cpus = 255,
+ .is_default = 1,
+};
+
static QEMUMachine pc_machine_v1_0 = {
.name = "pc-1.0",
- .alias = "pc",
.desc = "Standard PC",
.init = pc_init_pci,
.max_cpus = 255,
@@ -670,6 +678,7 @@ static QEMUMachine xenfv_machine = {
static void pc_machine_init(void)
{
+ qemu_register_machine(&pc_machine_v1_1);
qemu_register_machine(&pc_machine_v1_0);
qemu_register_machine(&pc_machine_v0_15);
qemu_register_machine(&pc_machine_v0_14);
--
1.7.8.3
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [Qemu-devel] [PATCH v4 08/11] fdc: add a 'check media rate' property. Not used yet
2012-02-06 21:29 [Qemu-devel] [PATCH v4 00/11] Misc fixes for floppy emulation Hervé Poussineau
` (6 preceding siblings ...)
2012-02-06 21:29 ` [Qemu-devel] [PATCH v4 07/11] pc: add 1.1 machine type Hervé Poussineau
@ 2012-02-06 21:29 ` Hervé Poussineau
2012-02-06 21:29 ` [Qemu-devel] [PATCH v4 09/11] fdc: check if media rate is correct before doing any transfer Hervé Poussineau
` (4 subsequent siblings)
12 siblings, 0 replies; 18+ messages in thread
From: Hervé Poussineau @ 2012-02-06 21:29 UTC (permalink / raw)
To: qemu-devel; +Cc: Kevin Wolf, Hervé Poussineau
Set it to true for current Qemu versions, and false for previous ones
Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
---
hw/fdc.c | 3 +++
hw/pc_piix.c | 36 ++++++++++++++++++++++++++++++++++++
2 files changed, 39 insertions(+), 0 deletions(-)
diff --git a/hw/fdc.c b/hw/fdc.c
index 7c675f6..af007ae 100644
--- a/hw/fdc.c
+++ b/hw/fdc.c
@@ -420,6 +420,7 @@ struct FDCtrl {
int sun4m;
FDrive drives[MAX_FD];
int reset_sensei;
+ uint32_t check_media_rate;
/* Timers state */
uint8_t timer0;
uint8_t timer1;
@@ -2003,6 +2004,8 @@ static Property isa_fdc_properties[] = {
DEFINE_PROP_DRIVE("driveB", FDCtrlISABus, state.drives[1].bs),
DEFINE_PROP_INT32("bootindexA", FDCtrlISABus, bootindexA, -1),
DEFINE_PROP_INT32("bootindexB", FDCtrlISABus, bootindexB, -1),
+ DEFINE_PROP_BIT("check_media_rate", FDCtrlISABus, state.check_media_rate,
+ 0, true),
DEFINE_PROP_END_OF_LIST(),
};
diff --git a/hw/pc_piix.c b/hw/pc_piix.c
index 400c6b6..baaecd9 100644
--- a/hw/pc_piix.c
+++ b/hw/pc_piix.c
@@ -386,6 +386,14 @@ static QEMUMachine pc_machine_v1_0 = {
.init = pc_init_pci,
.max_cpus = 255,
.is_default = 1,
+ .compat_props = (GlobalProperty[]) {
+ {
+ .driver = "isa-fdc",
+ .property = "check_media_rate",
+ .value = "off",
+ },
+ { /* end of list */ }
+ },
};
static QEMUMachine pc_machine_v0_15 = {
@@ -394,6 +402,14 @@ static QEMUMachine pc_machine_v0_15 = {
.init = pc_init_pci,
.max_cpus = 255,
.is_default = 1,
+ .compat_props = (GlobalProperty[]) {
+ {
+ .driver = "isa-fdc",
+ .property = "check_media_rate",
+ .value = "off",
+ },
+ { /* end of list */ }
+ },
};
static QEMUMachine pc_machine_v0_14 = {
@@ -426,6 +442,10 @@ static QEMUMachine pc_machine_v0_14 = {
.driver = "virtio-balloon-pci",
.property = "event_idx",
.value = "off",
+ },{
+ .driver = "isa-fdc",
+ .property = "check_media_rate",
+ .value = "off",
},
{ /* end of list */ }
},
@@ -473,6 +493,10 @@ static QEMUMachine pc_machine_v0_13 = {
.driver = "AC97",
.property = "use_broken_id",
.value = stringify(1),
+ },{
+ .driver = "isa-fdc",
+ .property = "check_media_rate",
+ .value = "off",
},
{ /* end of list */ }
},
@@ -524,6 +548,10 @@ static QEMUMachine pc_machine_v0_12 = {
.driver = "AC97",
.property = "use_broken_id",
.value = stringify(1),
+ },{
+ .driver = "isa-fdc",
+ .property = "check_media_rate",
+ .value = "off",
},
{ /* end of list */ }
}
@@ -583,6 +611,10 @@ static QEMUMachine pc_machine_v0_11 = {
.driver = "AC97",
.property = "use_broken_id",
.value = stringify(1),
+ },{
+ .driver = "isa-fdc",
+ .property = "check_media_rate",
+ .value = "off",
},
{ /* end of list */ }
}
@@ -654,6 +686,10 @@ static QEMUMachine pc_machine_v0_10 = {
.driver = "AC97",
.property = "use_broken_id",
.value = stringify(1),
+ },{
+ .driver = "isa-fdc",
+ .property = "check_media_rate",
+ .value = "off",
},
{ /* end of list */ }
},
--
1.7.8.3
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [Qemu-devel] [PATCH v4 09/11] fdc: check if media rate is correct before doing any transfer
2012-02-06 21:29 [Qemu-devel] [PATCH v4 00/11] Misc fixes for floppy emulation Hervé Poussineau
` (7 preceding siblings ...)
2012-02-06 21:29 ` [Qemu-devel] [PATCH v4 08/11] fdc: add a 'check media rate' property. Not used yet Hervé Poussineau
@ 2012-02-06 21:29 ` Hervé Poussineau
2012-02-14 15:16 ` Kevin Wolf
2012-02-06 21:29 ` [Qemu-devel] [PATCH v4 10/11] fdc: fix seek command, which shouldn't check tracks Hervé Poussineau
` (3 subsequent siblings)
12 siblings, 1 reply; 18+ messages in thread
From: Hervé Poussineau @ 2012-02-06 21:29 UTC (permalink / raw)
To: qemu-devel; +Cc: Kevin Wolf, Hervé Poussineau
The programmed rate has to be the same as the required rate for the
floppy format ; if that's not the case, the transfer should abort.
This check can be disabled by using the 'check_media_rate' property.
Save media rate value only if media rate check is enabled.
Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
---
hw/fdc.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 50 insertions(+), 3 deletions(-)
diff --git a/hw/fdc.c b/hw/fdc.c
index af007ae..d2a22fa 100644
--- a/hw/fdc.c
+++ b/hw/fdc.c
@@ -62,12 +62,15 @@
#define FD_SECTOR_SC 2 /* Sector size code */
#define FD_RESET_SENSEI_COUNT 4 /* Number of sense interrupts on RESET */
+typedef struct FDCtrl FDCtrl;
+
/* Floppy disk drive emulation */
typedef enum FDiskFlags {
FDISK_DBL_SIDES = 0x01,
} FDiskFlags;
typedef struct FDrive {
+ FDCtrl *fdctrl;
BlockDriverState *bs;
/* Drive status */
FDriveType drive;
@@ -83,6 +86,7 @@ typedef struct FDrive {
uint16_t bps; /* Bytes per sector */
uint8_t ro; /* Is read-only */
uint8_t media_changed; /* Is media changed */
+ uint8_t media_rate; /* Data rate of medium */
} FDrive;
static void fd_init(FDrive *drv)
@@ -195,6 +199,7 @@ static void fd_revalidate(FDrive *drv)
drv->last_sect = last_sect;
drv->ro = ro;
drv->drive = drive;
+ drv->media_rate = rate;
} else {
FLOPPY_DPRINTF("No disk in drive\n");
drv->last_sect = 0;
@@ -206,8 +211,6 @@ static void fd_revalidate(FDrive *drv)
/********************************************************/
/* Intel 82078 floppy disk controller emulation */
-typedef struct FDCtrl FDCtrl;
-
static void fdctrl_reset(FDCtrl *fdctrl, int do_irq);
static void fdctrl_reset_fifo(FDCtrl *fdctrl);
static int fdctrl_transfer_handler (void *opaque, int nchan,
@@ -303,6 +306,7 @@ enum {
};
enum {
+ FD_SR1_MA = 0x01, /* Missing address mark */
FD_SR1_NW = 0x02, /* Not writable */
FD_SR1_EC = 0x80, /* End of cylinder */
};
@@ -549,6 +553,24 @@ static const VMStateDescription vmstate_fdrive_media_changed = {
}
};
+static bool fdrive_media_rate_needed(void *opaque)
+{
+ FDrive *drive = opaque;
+
+ return drive->fdctrl->check_media_rate;
+}
+
+static const VMStateDescription vmstate_fdrive_media_rate = {
+ .name = "fdrive/media_rate",
+ .version_id = 1,
+ .minimum_version_id = 1,
+ .minimum_version_id_old = 1,
+ .fields = (VMStateField[]) {
+ VMSTATE_UINT8(media_rate, FDrive),
+ VMSTATE_END_OF_LIST()
+ }
+};
+
static const VMStateDescription vmstate_fdrive = {
.name = "fdrive",
.version_id = 1,
@@ -565,6 +587,9 @@ static const VMStateDescription vmstate_fdrive = {
.vmsd = &vmstate_fdrive_media_changed,
.needed = &fdrive_media_changed_needed,
} , {
+ .vmsd = &vmstate_fdrive_media_rate,
+ .needed = &fdrive_media_rate_needed,
+ } , {
/* empty */
}
}
@@ -1078,6 +1103,19 @@ static void fdctrl_start_transfer(FDCtrl *fdctrl, int direction)
break;
}
+ /* Check the data rate. If the programmed data rate does not match
+ * the currently inserted medium, the operation has to fail. */
+ if (fdctrl->check_media_rate &&
+ (fdctrl->dsr & FD_DSR_DRATEMASK) != cur_drv->media_rate) {
+ FLOPPY_DPRINTF("data rate mismatch (fdc=%d, media=%d)\n",
+ fdctrl->dsr & FD_DSR_DRATEMASK, cur_drv->media_rate);
+ fdctrl_stop_transfer(fdctrl, FD_SR0_ABNTERM, FD_SR1_MA, 0x00);
+ fdctrl->fifo[3] = kt;
+ fdctrl->fifo[4] = kh;
+ fdctrl->fifo[5] = ks;
+ return;
+ }
+
/* Set the FIFO state */
fdctrl->data_dir = direction;
fdctrl->data_pos = 0;
@@ -1800,7 +1838,15 @@ static void fdctrl_result_timer(void *opaque)
if (cur_drv->last_sect != 0) {
cur_drv->sect = (cur_drv->sect % cur_drv->last_sect) + 1;
}
- fdctrl_stop_transfer(fdctrl, 0x00, 0x00, 0x00);
+ /* READ_ID can't automatically succeed! */
+ if (fdctrl->check_media_rate &&
+ (fdctrl->dsr & FD_DSR_DRATEMASK) != cur_drv->media_rate) {
+ FLOPPY_DPRINTF("read id rate mismatch (fdc=%d, media=%d)\n",
+ fdctrl->dsr & FD_DSR_DRATEMASK, cur_drv->media_rate);
+ fdctrl_stop_transfer(fdctrl, FD_SR0_ABNTERM, FD_SR1_MA, 0x00);
+ } else {
+ fdctrl_stop_transfer(fdctrl, 0x00, 0x00, 0x00);
+ }
}
static void fdctrl_change_cb(void *opaque, bool load)
@@ -1822,6 +1868,7 @@ static int fdctrl_connect_drives(FDCtrl *fdctrl)
for (i = 0; i < MAX_FD; i++) {
drive = &fdctrl->drives[i];
+ drive->fdctrl = fdctrl;
if (drive->bs) {
if (bdrv_get_on_error(drive->bs, 0) != BLOCK_ERR_STOP_ENOSPC) {
--
1.7.8.3
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [Qemu-devel] [PATCH v4 10/11] fdc: fix seek command, which shouldn't check tracks
2012-02-06 21:29 [Qemu-devel] [PATCH v4 00/11] Misc fixes for floppy emulation Hervé Poussineau
` (8 preceding siblings ...)
2012-02-06 21:29 ` [Qemu-devel] [PATCH v4 09/11] fdc: check if media rate is correct before doing any transfer Hervé Poussineau
@ 2012-02-06 21:29 ` Hervé Poussineau
2012-02-06 21:29 ` [Qemu-devel] [PATCH v4 11/11] fdc: DIR (Digital Input Register) should return status of current drive Hervé Poussineau
` (2 subsequent siblings)
12 siblings, 0 replies; 18+ messages in thread
From: Hervé Poussineau @ 2012-02-06 21:29 UTC (permalink / raw)
To: qemu-devel; +Cc: Kevin Wolf, Hervé Poussineau
The seek command just sends step pulses to the drive and doesn't care if
there is a medium inserted of if it is banging the head against the drive.
Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
---
hw/fdc.c | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/hw/fdc.c b/hw/fdc.c
index d2a22fa..1928284 100644
--- a/hw/fdc.c
+++ b/hw/fdc.c
@@ -1622,13 +1622,16 @@ static void fdctrl_handle_seek(FDCtrl *fdctrl, int direction)
SET_CUR_DRV(fdctrl, fdctrl->fifo[1] & FD_DOR_SELMASK);
cur_drv = get_cur_drv(fdctrl);
fdctrl_reset_fifo(fdctrl);
+ /* The seek command just sends step pulses to the drive and doesn't care if
+ * there is a medium inserted of if it's banging the head against the drive.
+ */
if (fdctrl->fifo[2] > cur_drv->max_track) {
- fdctrl_raise_irq(fdctrl, FD_SR0_ABNTERM | FD_SR0_SEEK);
+ cur_drv->track = cur_drv->max_track;
} else {
cur_drv->track = fdctrl->fifo[2];
- /* Raise Interrupt */
- fdctrl_raise_irq(fdctrl, FD_SR0_SEEK);
}
+ /* Raise Interrupt */
+ fdctrl_raise_irq(fdctrl, FD_SR0_SEEK);
}
static void fdctrl_handle_perpendicular_mode(FDCtrl *fdctrl, int direction)
--
1.7.8.3
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [Qemu-devel] [PATCH v4 11/11] fdc: DIR (Digital Input Register) should return status of current drive...
2012-02-06 21:29 [Qemu-devel] [PATCH v4 00/11] Misc fixes for floppy emulation Hervé Poussineau
` (9 preceding siblings ...)
2012-02-06 21:29 ` [Qemu-devel] [PATCH v4 10/11] fdc: fix seek command, which shouldn't check tracks Hervé Poussineau
@ 2012-02-06 21:29 ` Hervé Poussineau
2012-02-14 12:31 ` [Qemu-devel] [PATCH v4 00/11] Misc fixes for floppy emulation Hervé Poussineau
2012-02-14 15:27 ` Kevin Wolf
12 siblings, 0 replies; 18+ messages in thread
From: Hervé Poussineau @ 2012-02-06 21:29 UTC (permalink / raw)
To: qemu-devel; +Cc: Kevin Wolf, Hervé Poussineau
Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
---
hw/fdc.c | 10 +++-------
1 files changed, 3 insertions(+), 7 deletions(-)
diff --git a/hw/fdc.c b/hw/fdc.c
index 1928284..cc2813f 100644
--- a/hw/fdc.c
+++ b/hw/fdc.c
@@ -216,6 +216,7 @@ static void fdctrl_reset_fifo(FDCtrl *fdctrl);
static int fdctrl_transfer_handler (void *opaque, int nchan,
int dma_pos, int dma_len);
static void fdctrl_raise_irq(FDCtrl *fdctrl, uint8_t status0);
+static FDrive *get_cur_drv(FDCtrl *fdctrl);
static uint32_t fdctrl_read_statusA(FDCtrl *fdctrl);
static uint32_t fdctrl_read_statusB(FDCtrl *fdctrl);
@@ -956,14 +957,9 @@ static uint32_t fdctrl_read_dir(FDCtrl *fdctrl)
{
uint32_t retval = 0;
- if (fdctrl_media_changed(drv0(fdctrl))
- || fdctrl_media_changed(drv1(fdctrl))
-#if MAX_FD == 4
- || fdctrl_media_changed(drv2(fdctrl))
- || fdctrl_media_changed(drv3(fdctrl))
-#endif
- )
+ if (fdctrl_media_changed(get_cur_drv(fdctrl))) {
retval |= FD_DIR_DSKCHG;
+ }
if (retval != 0) {
FLOPPY_DPRINTF("Floppy digital input register: 0x%02x\n", retval);
}
--
1.7.8.3
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [Qemu-devel] [PATCH v4 00/11] Misc fixes for floppy emulation
2012-02-06 21:29 [Qemu-devel] [PATCH v4 00/11] Misc fixes for floppy emulation Hervé Poussineau
` (10 preceding siblings ...)
2012-02-06 21:29 ` [Qemu-devel] [PATCH v4 11/11] fdc: DIR (Digital Input Register) should return status of current drive Hervé Poussineau
@ 2012-02-14 12:31 ` Hervé Poussineau
2012-02-14 15:27 ` Kevin Wolf
12 siblings, 0 replies; 18+ messages in thread
From: Hervé Poussineau @ 2012-02-14 12:31 UTC (permalink / raw)
To: qemu-devel; +Cc: Kevin Wolf
Hervé Poussineau a écrit :
> Here are misc fixes done by VirtualBox team.
> With these patches, floppy emulation is now good enough to run Xenix.
>
> Changes v3->v4:
> - added pc-1.1 machine type
> - disable media transfer rate check on older machine types
> - save/restore media transfer rate when media transfer rate check enabled
>
> Changes v2->v3:
> - removed patch changing controller stepping to 0
> - fixed out of bound access after bad seek command
>
> Changes v1->v2:
> - updated commit messages
> - added missing 'break' and braces
>
> Hervé Poussineau (11):
> fdc: take side count into account
> fdc: set busy bit when starting a command
> fdc: most control commands do not generate interrupts
> fdc: handle read-only floppies (abort early on write commands)
> fdc: add CCR (Configuration Control Register) write register
> block: add a transfer rate for floppy types
> pc: add 1.1 machine type
> fdc: add a 'check media rate' property. Not used yet
> fdc: check if media rate is correct before doing any transfer
> fdc: fix seek command, which shouldn't check tracks
> fdc: DIR (Digital Input Register) should return status of current
> drive...
>
> block.c | 74 ++++++++++++++++--------------
> block.h | 10 ++++-
> hw/fdc.c | 142 +++++++++++++++++++++++++++++++++++++++++++++++-----------
> hw/pc.c | 3 +-
> hw/pc_piix.c | 47 +++++++++++++++++++-
> 5 files changed, 211 insertions(+), 65 deletions(-)
>
Ping.
Hervé
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [Qemu-devel] [PATCH v4 07/11] pc: add 1.1 machine type
2012-02-06 21:29 ` [Qemu-devel] [PATCH v4 07/11] pc: add 1.1 machine type Hervé Poussineau
@ 2012-02-14 15:11 ` Kevin Wolf
0 siblings, 0 replies; 18+ messages in thread
From: Kevin Wolf @ 2012-02-14 15:11 UTC (permalink / raw)
To: Hervé Poussineau; +Cc: qemu-devel
Am 06.02.2012 22:29, schrieb Hervé Poussineau:
>
> Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
> ---
> hw/pc_piix.c | 11 ++++++++++-
> 1 files changed, 10 insertions(+), 1 deletions(-)
>
> diff --git a/hw/pc_piix.c b/hw/pc_piix.c
> index c06f1b5..400c6b6 100644
> --- a/hw/pc_piix.c
> +++ b/hw/pc_piix.c
> @@ -371,9 +371,17 @@ static void pc_xen_hvm_init(ram_addr_t ram_size,
> }
> #endif
>
> +static QEMUMachine pc_machine_v1_1 = {
> + .name = "pc-1.1",
> + .alias = "pc",
> + .desc = "Standard PC",
> + .init = pc_init_pci,
> + .max_cpus = 255,
> + .is_default = 1,
> +};
Now we have three defaults. :-)
I'll apply this anyway because we already do have two of them and three
doesn't really make it worse, but a patch on top would be good.
Kevin
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [Qemu-devel] [PATCH v4 09/11] fdc: check if media rate is correct before doing any transfer
2012-02-06 21:29 ` [Qemu-devel] [PATCH v4 09/11] fdc: check if media rate is correct before doing any transfer Hervé Poussineau
@ 2012-02-14 15:16 ` Kevin Wolf
2012-02-14 15:28 ` Paolo Bonzini
0 siblings, 1 reply; 18+ messages in thread
From: Kevin Wolf @ 2012-02-14 15:16 UTC (permalink / raw)
To: Hervé Poussineau; +Cc: Paolo Bonzini, qemu-devel, Juan Quintela
Am 06.02.2012 22:29, schrieb Hervé Poussineau:
> The programmed rate has to be the same as the required rate for the
> floppy format ; if that's not the case, the transfer should abort.
> This check can be disabled by using the 'check_media_rate' property.
>
> Save media rate value only if media rate check is enabled.
>
> Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
> ---
> hw/fdc.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++---
> 1 files changed, 50 insertions(+), 3 deletions(-)
>
> diff --git a/hw/fdc.c b/hw/fdc.c
> index af007ae..d2a22fa 100644
> --- a/hw/fdc.c
> +++ b/hw/fdc.c
> @@ -62,12 +62,15 @@
> #define FD_SECTOR_SC 2 /* Sector size code */
> #define FD_RESET_SENSEI_COUNT 4 /* Number of sense interrupts on RESET */
>
> +typedef struct FDCtrl FDCtrl;
> +
> /* Floppy disk drive emulation */
> typedef enum FDiskFlags {
> FDISK_DBL_SIDES = 0x01,
> } FDiskFlags;
>
> typedef struct FDrive {
> + FDCtrl *fdctrl;
> BlockDriverState *bs;
> /* Drive status */
> FDriveType drive;
> @@ -83,6 +86,7 @@ typedef struct FDrive {
> uint16_t bps; /* Bytes per sector */
> uint8_t ro; /* Is read-only */
> uint8_t media_changed; /* Is media changed */
> + uint8_t media_rate; /* Data rate of medium */
> } FDrive;
>
> static void fd_init(FDrive *drv)
> @@ -195,6 +199,7 @@ static void fd_revalidate(FDrive *drv)
> drv->last_sect = last_sect;
> drv->ro = ro;
> drv->drive = drive;
> + drv->media_rate = rate;
> } else {
> FLOPPY_DPRINTF("No disk in drive\n");
> drv->last_sect = 0;
> @@ -206,8 +211,6 @@ static void fd_revalidate(FDrive *drv)
> /********************************************************/
> /* Intel 82078 floppy disk controller emulation */
>
> -typedef struct FDCtrl FDCtrl;
> -
> static void fdctrl_reset(FDCtrl *fdctrl, int do_irq);
> static void fdctrl_reset_fifo(FDCtrl *fdctrl);
> static int fdctrl_transfer_handler (void *opaque, int nchan,
> @@ -303,6 +306,7 @@ enum {
> };
>
> enum {
> + FD_SR1_MA = 0x01, /* Missing address mark */
> FD_SR1_NW = 0x02, /* Not writable */
> FD_SR1_EC = 0x80, /* End of cylinder */
> };
> @@ -549,6 +553,24 @@ static const VMStateDescription vmstate_fdrive_media_changed = {
> }
> };
>
> +static bool fdrive_media_rate_needed(void *opaque)
> +{
> + FDrive *drive = opaque;
> +
> + return drive->fdctrl->check_media_rate;
> +}
> +
> +static const VMStateDescription vmstate_fdrive_media_rate = {
> + .name = "fdrive/media_rate",
> + .version_id = 1,
> + .minimum_version_id = 1,
> + .minimum_version_id_old = 1,
> + .fields = (VMStateField[]) {
> + VMSTATE_UINT8(media_rate, FDrive),
> + VMSTATE_END_OF_LIST()
> + }
> +};
Juan, Paolo, this is a subsection in a struct array. Does this work
meanwhile or is it still broken?
Kevin
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [Qemu-devel] [PATCH v4 00/11] Misc fixes for floppy emulation
2012-02-06 21:29 [Qemu-devel] [PATCH v4 00/11] Misc fixes for floppy emulation Hervé Poussineau
` (11 preceding siblings ...)
2012-02-14 12:31 ` [Qemu-devel] [PATCH v4 00/11] Misc fixes for floppy emulation Hervé Poussineau
@ 2012-02-14 15:27 ` Kevin Wolf
12 siblings, 0 replies; 18+ messages in thread
From: Kevin Wolf @ 2012-02-14 15:27 UTC (permalink / raw)
To: Hervé Poussineau; +Cc: qemu-devel
Am 06.02.2012 22:29, schrieb Hervé Poussineau:
> Here are misc fixes done by VirtualBox team.
> With these patches, floppy emulation is now good enough to run Xenix.
>
> Changes v3->v4:
> - added pc-1.1 machine type
> - disable media transfer rate check on older machine types
> - save/restore media transfer rate when media transfer rate check enabled
>
> Changes v2->v3:
> - removed patch changing controller stepping to 0
> - fixed out of bound access after bad seek command
>
> Changes v1->v2:
> - updated commit messages
> - added missing 'break' and braces
>
> Hervé Poussineau (11):
> fdc: take side count into account
> fdc: set busy bit when starting a command
> fdc: most control commands do not generate interrupts
> fdc: handle read-only floppies (abort early on write commands)
> fdc: add CCR (Configuration Control Register) write register
> block: add a transfer rate for floppy types
> pc: add 1.1 machine type
> fdc: add a 'check media rate' property. Not used yet
> fdc: check if media rate is correct before doing any transfer
> fdc: fix seek command, which shouldn't check tracks
> fdc: DIR (Digital Input Register) should return status of current
> drive...
>
> block.c | 74 ++++++++++++++++--------------
> block.h | 10 ++++-
> hw/fdc.c | 142 +++++++++++++++++++++++++++++++++++++++++++++++-----------
> hw/pc.c | 3 +-
> hw/pc_piix.c | 47 +++++++++++++++++++-
> 5 files changed, 211 insertions(+), 65 deletions(-)
Thanks. I applied patches 1-5, 10 and 11 to the block branch, i.e.
leaving out the transfer rate stuff. I believe this is fairly
independent so it makes sense to apply the rest of the series without
it, but if you think I should dequeue all of the patches, let me know.
The main reason for not applying 6-9 is that I think migration is
broken, but I'll wait for Juan and/or Paolo to confirm. If a respin is
required, you can also fix the three default machine types.
Kevin
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [Qemu-devel] [PATCH v4 09/11] fdc: check if media rate is correct before doing any transfer
2012-02-14 15:16 ` Kevin Wolf
@ 2012-02-14 15:28 ` Paolo Bonzini
2012-02-14 15:34 ` Kevin Wolf
0 siblings, 1 reply; 18+ messages in thread
From: Paolo Bonzini @ 2012-02-14 15:28 UTC (permalink / raw)
To: Kevin Wolf; +Cc: Hervé Poussineau, qemu-devel, Juan Quintela
On 02/14/2012 04:16 PM, Kevin Wolf wrote:
> Juan, Paolo, this is a subsection in a struct array. Does this work
> meanwhile or is it still broken?
Juan fixed it.
Paolo
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [Qemu-devel] [PATCH v4 09/11] fdc: check if media rate is correct before doing any transfer
2012-02-14 15:28 ` Paolo Bonzini
@ 2012-02-14 15:34 ` Kevin Wolf
0 siblings, 0 replies; 18+ messages in thread
From: Kevin Wolf @ 2012-02-14 15:34 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: Hervé Poussineau, qemu-devel, Juan Quintela
Am 14.02.2012 16:28, schrieb Paolo Bonzini:
> On 02/14/2012 04:16 PM, Kevin Wolf wrote:
>> Juan, Paolo, this is a subsection in a struct array. Does this work
>> meanwhile or is it still broken?
>
> Juan fixed it.
Oh, cool. :-)
Then I'll apply the other four patches as well.
Kevin
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2012-02-14 15:31 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-06 21:29 [Qemu-devel] [PATCH v4 00/11] Misc fixes for floppy emulation Hervé Poussineau
2012-02-06 21:29 ` [Qemu-devel] [PATCH v4 01/11] fdc: take side count into account Hervé Poussineau
2012-02-06 21:29 ` [Qemu-devel] [PATCH v4 02/11] fdc: set busy bit when starting a command Hervé Poussineau
2012-02-06 21:29 ` [Qemu-devel] [PATCH v4 03/11] fdc: most control commands do not generate interrupts Hervé Poussineau
2012-02-06 21:29 ` [Qemu-devel] [PATCH v4 04/11] fdc: handle read-only floppies (abort early on write commands) Hervé Poussineau
2012-02-06 21:29 ` [Qemu-devel] [PATCH v4 05/11] fdc: add CCR (Configuration Control Register) write register Hervé Poussineau
2012-02-06 21:29 ` [Qemu-devel] [PATCH v4 06/11] block: add a transfer rate for floppy types Hervé Poussineau
2012-02-06 21:29 ` [Qemu-devel] [PATCH v4 07/11] pc: add 1.1 machine type Hervé Poussineau
2012-02-14 15:11 ` Kevin Wolf
2012-02-06 21:29 ` [Qemu-devel] [PATCH v4 08/11] fdc: add a 'check media rate' property. Not used yet Hervé Poussineau
2012-02-06 21:29 ` [Qemu-devel] [PATCH v4 09/11] fdc: check if media rate is correct before doing any transfer Hervé Poussineau
2012-02-14 15:16 ` Kevin Wolf
2012-02-14 15:28 ` Paolo Bonzini
2012-02-14 15:34 ` Kevin Wolf
2012-02-06 21:29 ` [Qemu-devel] [PATCH v4 10/11] fdc: fix seek command, which shouldn't check tracks Hervé Poussineau
2012-02-06 21:29 ` [Qemu-devel] [PATCH v4 11/11] fdc: DIR (Digital Input Register) should return status of current drive Hervé Poussineau
2012-02-14 12:31 ` [Qemu-devel] [PATCH v4 00/11] Misc fixes for floppy emulation Hervé Poussineau
2012-02-14 15:27 ` Kevin Wolf
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).