From patchwork Tue Dec 22 17:41:25 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?5q2m55SwID0/SVNPLTIwMjItSlA/Qj9JQnNrUWoxVFRHa2JLRUk9Pz0=?= X-Patchwork-Id: 41634 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 86B9BB7BC5 for ; Wed, 23 Dec 2009 05:18:27 +1100 (EST) Received: from localhost ([127.0.0.1]:42208 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NN9J7-0002au-Dt for incoming@patchwork.ozlabs.org; Tue, 22 Dec 2009 13:18:05 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NN8nW-0000Id-Mx for qemu-devel@nongnu.org; Tue, 22 Dec 2009 12:45:26 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NN8nR-0000H5-15 for qemu-devel@nongnu.org; Tue, 22 Dec 2009 12:45:26 -0500 Received: from [199.232.76.173] (port=55246 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NN8nQ-0000Gu-C5 for qemu-devel@nongnu.org; Tue, 22 Dec 2009 12:45:20 -0500 Received: from smtp-vip.mem.interq.net ([210.157.1.50]:22975 helo=smtp01.mem.internal-gmo) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NN8nD-0002Fz-Es for qemu-devel@nongnu.org; Tue, 22 Dec 2009 12:45:20 -0500 Received: (from root@localhost) by smtp01.mem.internal-gmo (8.13.8/8.12.6) id nBMHj055021956 for qemu-devel@nongnu.org; Wed, 23 Dec 2009 02:45:00 +0900 (JST) Received: (from root@localhost) by smtp01.mem.internal-gmo (8.13.8/8.12.6) id nBMHgJU1021848 for qemu-devel@nongnu.org; Wed, 23 Dec 2009 02:42:19 +0900 (JST) Received: from YOUR-BD18D6DD63.m1.interq.or.jp (ntymns039132.ymns.nt.ftth.ppp.infoweb.ne.jp [121.92.167.132]) by smtp01.mem.internal-gmo with ESMTP id nBMHgGgR021741 for ; (me101664 for with PLAIN) Wed, 23 Dec 2009 02:42:19 +0900 (JST) Message-Id: <200912221741.AA00220@YOUR-BD18D6DD63.m1.interq.or.jp> From: "TAKEDA, toshiya" Date: Wed, 23 Dec 2009 02:41:25 +0900 To: qemu-devel MIME-Version: 1.0 X-Mailer: AL-Mail32 Version 1.13 X-detected-operating-system: by monty-python.gnu.org: Solaris 10 (beta) Subject: [Qemu-devel] [PATCH V4 17/18] ide: support CHS mode X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: TAKEDA, toshiya --- hw/ide/core.c | 13 +++++++++++-- hw/ide/internal.h | 1 + 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/hw/ide/core.c b/hw/ide/core.c index 76c3820..4c77415 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -1801,8 +1801,10 @@ void ide_ioport_write(void *opaque, uint32_t addr, uint32_t val) break; case 6: /* FIXME: HOB readback uses bit 7 */ - bus->ifs[0].select = (val & ~0x10) | 0xa0; - bus->ifs[1].select = (val | 0x10) | 0xa0; + bus->ifs[0].select = (val & ~0x10) | + (bus->ifs[0].support_chs ? 0x80 : 0xa0); + bus->ifs[1].select = (val | 0x10) | + (bus->ifs[1].support_chs ? 0x80 : 0xa0); /* select drive */ bus->unit = (val >> 4) & 1; break; @@ -1839,6 +1841,13 @@ void ide_ioport_write(void *opaque, uint32_t addr, uint32_t val) ide_set_irq(s->bus); break; case WIN_SPECIFY: + if (s->support_chs && !(s->select & 0x40)) { + uint64_t sectors; + bdrv_get_geometry(s->bs, §ors); + s->heads = (s->select & 0xf) + 1; + s->sectors = s->nsector; + s->cylinders = sectors / (s->heads * s->sectors); + } case WIN_RECAL: s->error = 0; s->status = READY_STAT | SEEK_STAT; diff --git a/hw/ide/internal.h b/hw/ide/internal.h index eb5b404..bf26c52 100644 --- a/hw/ide/internal.h +++ b/hw/ide/internal.h @@ -396,6 +396,7 @@ struct IDEState { /* set for lba48 access */ uint8_t lba48; + uint8_t support_chs; BlockDriverState *bs; /* ATAPI specific */ uint8_t sense_key;