qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v3 1/2] fdc: fix relative seek
       [not found] <cover.1342446287.git.phrdina@redhat.com>
@ 2012-07-16 13:48 ` Pavel Hrdina
  2012-07-16 14:01   ` Kevin Wolf
  2012-07-16 13:48 ` [Qemu-devel] [PATCH v3 2/2] fdc-test: introduce test_relative_seek Pavel Hrdina
  1 sibling, 1 reply; 3+ messages in thread
From: Pavel Hrdina @ 2012-07-16 13:48 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, Pavel Hrdina

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
---
 hw/fdc.c |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/hw/fdc.c b/hw/fdc.c
index edf0706..9f84931 100644
--- a/hw/fdc.c
+++ b/hw/fdc.c
@@ -1695,7 +1695,7 @@ static void fdctrl_handle_drive_specification_command(FDCtrl *fdctrl, int direct
     }
 }
 
-static void fdctrl_handle_relative_seek_out(FDCtrl *fdctrl, int direction)
+static void fdctrl_handle_relative_seek_in(FDCtrl *fdctrl, int direction)
 {
     FDrive *cur_drv;
 
@@ -1705,14 +1705,15 @@ static void fdctrl_handle_relative_seek_out(FDCtrl *fdctrl, int direction)
         fd_seek(cur_drv, cur_drv->head, cur_drv->max_track - 1,
                 cur_drv->sect, 1);
     } else {
-        fd_seek(cur_drv, cur_drv->head, fdctrl->fifo[2], cur_drv->sect, 1);
+        fd_seek(cur_drv, cur_drv->head,
+                cur_drv->track + fdctrl->fifo[2], cur_drv->sect, 1);
     }
     fdctrl_reset_fifo(fdctrl);
     /* Raise Interrupt */
     fdctrl_raise_irq(fdctrl, FD_SR0_SEEK);
 }
 
-static void fdctrl_handle_relative_seek_in(FDCtrl *fdctrl, int direction)
+static void fdctrl_handle_relative_seek_out(FDCtrl *fdctrl, int direction)
 {
     FDrive *cur_drv;
 
@@ -1721,7 +1722,8 @@ static void fdctrl_handle_relative_seek_in(FDCtrl *fdctrl, int direction)
     if (fdctrl->fifo[2] > cur_drv->track) {
         fd_seek(cur_drv, cur_drv->head, 0, cur_drv->sect, 1);
     } else {
-        fd_seek(cur_drv, cur_drv->head, fdctrl->fifo[2], cur_drv->sect, 1);
+        fd_seek(cur_drv, cur_drv->head,
+                cur_drv->track - fdctrl->fifo[2], cur_drv->sect, 1);
     }
     fdctrl_reset_fifo(fdctrl);
     /* Raise Interrupt */
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [Qemu-devel] [PATCH v3 2/2] fdc-test: introduce test_relative_seek
       [not found] <cover.1342446287.git.phrdina@redhat.com>
  2012-07-16 13:48 ` [Qemu-devel] [PATCH v3 1/2] fdc: fix relative seek Pavel Hrdina
@ 2012-07-16 13:48 ` Pavel Hrdina
  1 sibling, 0 replies; 3+ messages in thread
From: Pavel Hrdina @ 2012-07-16 13:48 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, Pavel Hrdina

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
---
 tests/fdc-test.c |   46 +++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 41 insertions(+), 5 deletions(-)

diff --git a/tests/fdc-test.c b/tests/fdc-test.c
index 585fb0e..10d11a4 100644
--- a/tests/fdc-test.c
+++ b/tests/fdc-test.c
@@ -47,9 +47,11 @@ enum {
 };
 
 enum {
-    CMD_SENSE_INT   = 0x08,
-    CMD_SEEK        = 0x0f,
-    CMD_READ        = 0xe6,
+    CMD_SENSE_INT           = 0x08,
+    CMD_SEEK                = 0x0f,
+    CMD_READ                = 0xe6,
+    CMD_RELATIVE_SEEK_OUT   = 0x8f,
+    CMD_RELATIVE_SEEK_IN    = 0xcf,
 };
 
 enum {
@@ -91,13 +93,17 @@ static uint8_t floppy_recv(void)
     return inb(FLOPPY_BASE + reg_fifo);
 }
 
-static void ack_irq(void)
+static uint8_t ack_irq(void)
 {
+    uint8_t ret;
+
     g_assert(get_irq(FLOPPY_IRQ));
     floppy_send(CMD_SENSE_INT);
     floppy_recv();
-    floppy_recv();
+    ret = floppy_recv();
     g_assert(!get_irq(FLOPPY_IRQ));
+
+    return ret;
 }
 
 static uint8_t send_read_command(void)
@@ -281,6 +287,35 @@ static void test_sense_interrupt(void)
     floppy_recv();
 }
 
+static void test_relative_seek(void)
+{
+    uint8_t drive = 0;
+    uint8_t head = 0;
+    uint8_t cyl = 1;
+    uint8_t ret;
+
+    /* Send seek to track 0 */
+    send_step_pulse(0);
+
+    /* Send relative seek to increase track by 1 */
+    floppy_send(CMD_RELATIVE_SEEK_IN);
+    floppy_send(head << 2 | drive);
+    g_assert(!get_irq(FLOPPY_IRQ));
+    floppy_send(cyl);
+
+    ret = ack_irq();
+    g_assert(ret == 1);
+
+    /* Send relative seek to decrease track by 1 */
+    floppy_send(CMD_RELATIVE_SEEK_OUT);
+    floppy_send(head << 2 | drive);
+    g_assert(!get_irq(FLOPPY_IRQ));
+    floppy_send(cyl);
+
+    ret = ack_irq();
+    g_assert(ret == 0);
+}
+
 /* success if no crash or abort */
 static void fuzz_registers(void)
 {
@@ -329,6 +364,7 @@ int main(int argc, char **argv)
     qtest_add_func("/fdc/read_without_media", test_read_without_media);
     qtest_add_func("/fdc/media_change", test_media_change);
     qtest_add_func("/fdc/sense_interrupt", test_sense_interrupt);
+    qtest_add_func("/fdc/relative_seek", test_relative_seek);
     qtest_add_func("/fdc/fuzz-registers", fuzz_registers);
 
     ret = g_test_run();
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH v3 1/2] fdc: fix relative seek
  2012-07-16 13:48 ` [Qemu-devel] [PATCH v3 1/2] fdc: fix relative seek Pavel Hrdina
@ 2012-07-16 14:01   ` Kevin Wolf
  0 siblings, 0 replies; 3+ messages in thread
From: Kevin Wolf @ 2012-07-16 14:01 UTC (permalink / raw)
  To: Pavel Hrdina; +Cc: qemu-devel

Am 16.07.2012 15:48, schrieb Pavel Hrdina:
> Signed-off-by: Pavel Hrdina <phrdina@redhat.com>

Thanks, applied both to the block branch.

Kevin

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-07-16 14:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <cover.1342446287.git.phrdina@redhat.com>
2012-07-16 13:48 ` [Qemu-devel] [PATCH v3 1/2] fdc: fix relative seek Pavel Hrdina
2012-07-16 14:01   ` Kevin Wolf
2012-07-16 13:48 ` [Qemu-devel] [PATCH v3 2/2] fdc-test: introduce test_relative_seek Pavel Hrdina

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).