From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:43572) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sr3h3-0001A2-6K for qemu-devel@nongnu.org; Tue, 17 Jul 2012 05:03:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sr3gy-0003OQ-8Y for qemu-devel@nongnu.org; Tue, 17 Jul 2012 05:03:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50346) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sr3gy-0003OB-0V for qemu-devel@nongnu.org; Tue, 17 Jul 2012 05:03:40 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q6H93c4q027681 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 17 Jul 2012 05:03:38 -0400 Message-ID: <50052A68.4060001@redhat.com> Date: Tue, 17 Jul 2012 11:03:36 +0200 From: Pavel Hrdina MIME-Version: 1.0 References: <1342449360-15227-1-git-send-email-kwolf@redhat.com> <1342449360-15227-3-git-send-email-kwolf@redhat.com> In-Reply-To: <1342449360-15227-3-git-send-email-kwolf@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 2/2] fdc-test: Check RELATIVE SEEK beyond track 0/80 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: qemu-devel@nongnu.org On 07/16/2012 04:36 PM, Kevin Wolf wrote: > TODO This needs to be checked against a real drive > > Signed-off-by: Kevin Wolf > --- > tests/fdc-test.c | 48 +++++++++++++++++++++++++++++++++++++----------- > 1 files changed, 37 insertions(+), 11 deletions(-) > > diff --git a/tests/fdc-test.c b/tests/fdc-test.c > index fa74411..56e745a 100644 > --- a/tests/fdc-test.c > +++ b/tests/fdc-test.c > @@ -94,13 +94,17 @@ static uint8_t floppy_recv(void) > } > > /* pcn: Present Cylinder Number */ > -static void ack_irq(uint8_t *pcn) > +static void ack_irq(uint8_t *st0, uint8_t *pcn) > { > uint8_t ret; > > g_assert(get_irq(FLOPPY_IRQ)); > floppy_send(CMD_SENSE_INT); > - floppy_recv(); > + > + ret = floppy_recv(); > + if (st0 != NULL) { > + *st0 = ret; > + } > > ret = floppy_recv(); > if (pcn != NULL) { > @@ -175,7 +179,7 @@ static void send_seek(int cyl) > floppy_send(head << 2 | drive); > g_assert(!get_irq(FLOPPY_IRQ)); > floppy_send(cyl); > - ack_irq(NULL); > + ack_irq(NULL, NULL); > } > > static uint8_t cmos_read(uint8_t reg) > @@ -295,29 +299,51 @@ static void test_relative_seek(void) > { > uint8_t drive = 0; > uint8_t head = 0; > - uint8_t cyl = 1; > uint8_t pcn; > + uint8_t st0; > > /* Send seek to track 0 */ > send_seek(0); > > - /* Send relative seek to increase track by 1 */ > + /* Send relative seek to increase track by 3 */ > floppy_send(CMD_RELATIVE_SEEK_IN); > floppy_send(head << 2 | drive); > g_assert(!get_irq(FLOPPY_IRQ)); > - floppy_send(cyl); > + floppy_send(3); > > - ack_irq(&pcn); > - g_assert(pcn == 1); > + ack_irq(&st0, &pcn); > + g_assert_cmpint(pcn, ==, 3); > + g_assert_cmpint(st0, ==, 0x20); > > /* 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); > + floppy_send(1); > + > + ack_irq(&st0, &pcn); > + g_assert_cmpint(pcn, ==, 2); > + g_assert_cmpint(st0, ==, 0x20); > + > + /* Send relative seek to beyond track 0 */ > + floppy_send(CMD_RELATIVE_SEEK_OUT); > + floppy_send(head << 2 | drive); > + g_assert(!get_irq(FLOPPY_IRQ)); > + floppy_send(42); > + > + ack_irq(&st0, &pcn); > + g_assert_cmpint(pcn, ==, 0); > + g_assert_cmpint(st0, ==, 0x70); > + > + /* Send try relative seek to beyond track 80 */ > + floppy_send(CMD_RELATIVE_SEEK_IN); > + floppy_send(head << 2 | drive); > + g_assert(!get_irq(FLOPPY_IRQ)); > + floppy_send(200); > > - ack_irq(&pcn); > - g_assert(pcn == 0); > + ack_irq(&st0, &pcn); > + g_assert_cmpint(pcn, ==, 79); > + g_assert_cmpint(st0, ==, 0x50); > } > > /* success if no crash or abort */ I tested it on the real floppy and the behavior is more complicated. Let's say that we start on the track 0 and the floppy media has 80 tracks. You send the "relative_seek_in" by 1 end the result is st0: 0x20 rcn: 1. Then you issue the "read_id" command and you get st0: 0x00 st1: 0x00 pcn: 1. Then you send the "relative_seek_in" by 100 and the result is st0: 0x20 rcn: 101 but "read_id" returns st0: 0x40 st1: 0x01 pcn: 0. This probably means, that you are out of available tracks. Then you send the "relative_seek_out" by 100 and the result is st: 0x70 rcn: 20 but "read_id" returns st0: 0x00 st1: 0x00 pcn: 0. You return reading heads to the track 0, but the "relative_seek_out" returns that you are on the relative track 20. To get the floppy drive fully working, you have to send the "seek" to the track 0. If you don't do it, every seek to different track then the track 0 will always seek to the track 0 and set rcn to track what you want. In this "buggy" state only the "relative_seek" will change the real track. The command "read_id" returns the real position of the reading heads. For example: Now you send "seek" to track 2 and you get st0: 0x20 pcn: 2 but if you send "read_id" the result is st0: 0x00 st1: 0x00 pcn: 0 Pavel