From patchwork Wed Nov 14 18:47:19 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 199009 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id B2B262C0092 for ; Thu, 15 Nov 2012 07:16:27 +1100 (EST) Received: from localhost ([::1]:41645 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TYi15-0001ww-4l for incoming@patchwork.ozlabs.org; Wed, 14 Nov 2012 13:48:51 -0500 Received: from eggs.gnu.org ([208.118.235.92]:60027) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TYi0H-0000Ss-MW for qemu-devel@nongnu.org; Wed, 14 Nov 2012 13:48:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TYi0E-0000Xy-HC for qemu-devel@nongnu.org; Wed, 14 Nov 2012 13:48:01 -0500 Received: from mx1.redhat.com ([209.132.183.28]:48073) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TYi0E-0000Xn-9M for qemu-devel@nongnu.org; Wed, 14 Nov 2012 13:47:58 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qAEIluoJ011586 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 14 Nov 2012 13:47:56 -0500 Received: from dhcp-5-188.str.redhat.com (vpn1-4-191.ams2.redhat.com [10.36.4.191]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id qAEIlTlU028359; Wed, 14 Nov 2012 13:47:55 -0500 From: Kevin Wolf To: anthony@codemonkey.ws Date: Wed, 14 Nov 2012 19:47:19 +0100 Message-Id: <1352918847-3696-19-git-send-email-kwolf@redhat.com> In-Reply-To: <1352918847-3696-1-git-send-email-kwolf@redhat.com> References: <1352918847-3696-1-git-send-email-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-MIME-Autoconverted: from 8bit to quoted-printable by mx1.redhat.com id qAEIluoJ011586 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 18/26] fdc-test: Check READ ID X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org ST0 shouldn't include 0x20 (FD_SR0_SEEK) after READ ID. Signed-off-by: Kevin Wolf Tested-by: Hervé Poussineau --- tests/fdc-test.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 66 insertions(+), 0 deletions(-) diff --git a/tests/fdc-test.c b/tests/fdc-test.c index 1156112..e8ce686 100644 --- a/tests/fdc-test.c +++ b/tests/fdc-test.c @@ -48,6 +48,7 @@ enum { enum { CMD_SENSE_INT = 0x08, + CMD_READ_ID = 0x0a, CMD_SEEK = 0x0f, CMD_READ = 0xe6, CMD_RELATIVE_SEEK_OUT = 0x8f, @@ -392,6 +393,70 @@ static void test_relative_seek(void) g_assert(pcn == 0); } +static void test_read_id(void) +{ + uint8_t drive = 0; + uint8_t head = 0; + uint8_t cyl; + uint8_t st0; + + /* Seek to track 0 and check with READ ID */ + send_seek(0); + + floppy_send(CMD_READ_ID); + g_assert(!get_irq(FLOPPY_IRQ)); + floppy_send(head << 2 | drive); + + while (!get_irq(FLOPPY_IRQ)) { + /* qemu involves a timer with READ ID... */ + clock_step(1000000000LL / 50); + } + + st0 = floppy_recv(); + floppy_recv(); + floppy_recv(); + cyl = floppy_recv(); + head = floppy_recv(); + floppy_recv(); + floppy_recv(); + + g_assert_cmpint(cyl, ==, 0); + g_assert_cmpint(head, ==, 0); + g_assert_cmpint(st0, ==, head << 2); + + /* Seek to track 8 on head 1 and check with READ ID */ + head = 1; + cyl = 8; + + floppy_send(CMD_SEEK); + floppy_send(head << 2 | drive); + g_assert(!get_irq(FLOPPY_IRQ)); + floppy_send(cyl); + g_assert(get_irq(FLOPPY_IRQ)); + ack_irq(NULL); + + floppy_send(CMD_READ_ID); + g_assert(!get_irq(FLOPPY_IRQ)); + floppy_send(head << 2 | drive); + + while (!get_irq(FLOPPY_IRQ)) { + /* qemu involves a timer with READ ID... */ + clock_step(1000000000LL / 50); + } + + st0 = floppy_recv(); + floppy_recv(); + floppy_recv(); + cyl = floppy_recv(); + head = floppy_recv(); + floppy_recv(); + floppy_recv(); + + g_assert_cmpint(cyl, ==, 8); + g_assert_cmpint(head, ==, 1); + g_assert_cmpint(st0, ==, head << 2); +} + static void test_read_no_dma_1(void) { uint8_t ret; @@ -471,6 +536,7 @@ int main(int argc, char **argv) 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/read_id", test_read_id); qtest_add_func("/fdc/media_insert", test_media_insert); qtest_add_func("/fdc/read_no_dma_1", test_read_no_dma_1); qtest_add_func("/fdc/read_no_dma_18", test_read_no_dma_18);