From patchwork Tue Jan 26 13:50:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 8122871 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 13AF6BEEE5 for ; Tue, 26 Jan 2016 14:06:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 610B22025A for ; Tue, 26 Jan 2016 14:06:36 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6FDA120259 for ; Tue, 26 Jan 2016 14:06:35 +0000 (UTC) Received: from localhost ([::1]:44094 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aO4GQ-0003jr-Pj for patchwork-qemu-devel@patchwork.kernel.org; Tue, 26 Jan 2016 09:06:34 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36039) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aO40z-0005eu-MZ for qemu-devel@nongnu.org; Tue, 26 Jan 2016 08:50:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aO40w-0004rm-W4 for qemu-devel@nongnu.org; Tue, 26 Jan 2016 08:50:37 -0500 Received: from mx1.redhat.com ([209.132.183.28]:50461) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aO40w-0004rT-Qj for qemu-devel@nongnu.org; Tue, 26 Jan 2016 08:50:34 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 6A015A7561; Tue, 26 Jan 2016 13:50:34 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.34.112.60]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u0QDoUPd030289; Tue, 26 Jan 2016 08:50:33 -0500 From: Igor Mammedov To: qemu-devel@nongnu.org Date: Tue, 26 Jan 2016 14:50:24 +0100 Message-Id: <1453816225-139685-3-git-send-email-imammedo@redhat.com> In-Reply-To: <1453816225-139685-1-git-send-email-imammedo@redhat.com> References: <1453816225-139685-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: jsnow@redhat.com, rkagan@virtuozzo.com, mst@redhat.com Subject: [Qemu-devel] [PATCH v7 2/3] expose floppy drive geometry and CMOS type 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Roman Kagan Make it possible to query the geometry and the CMOS type of a floppy drive outside of the respective source files. It will be useful, in particular, when dynamically building ACPI tables, and will allow to properly populate the corresponding ACPI objects and thus enable BIOS-less systems to access the floppy drives. Signed-off-by: Roman Kagan Signed-off-by: Igor Mammedov Reviewed-by: John Snow --- hw/block/fdc.c | 11 +++++++++++ hw/i386/pc.c | 2 +- include/hw/block/fdc.h | 2 ++ include/hw/i386/pc.h | 1 + 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/hw/block/fdc.c b/hw/block/fdc.c index e3b0e1e..c9d7001 100644 --- a/hw/block/fdc.c +++ b/hw/block/fdc.c @@ -2518,6 +2518,17 @@ FloppyDriveType isa_fdc_get_drive_type(ISADevice *fdc, int i) return isa->state.drives[i].drive; } +void isa_fdc_get_drive_geometry(ISADevice *fdc, int i, uint8_t *cylinders, + uint8_t *heads, uint8_t *sectors) +{ + FDCtrlISABus *isa = ISA_FDC(fdc); + FDrive *drv = &isa->state.drives[i]; + + *cylinders = drv->max_track; + *heads = (drv->flags & FDISK_DBL_SIDES) ? 2 : 1; + *sectors = drv->last_sect; +} + static const VMStateDescription vmstate_isa_fdc ={ .name = "fdc", .version_id = 2, diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 78cf8fa..ccd7f39 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -199,7 +199,7 @@ static void pic_irq_request(void *opaque, int irq, int level) #define REG_EQUIPMENT_BYTE 0x14 -static int cmos_get_fd_drive_type(FloppyDriveType fd0) +int cmos_get_fd_drive_type(FloppyDriveType fd0) { int val; diff --git a/include/hw/block/fdc.h b/include/hw/block/fdc.h index adce14f..d87859e 100644 --- a/include/hw/block/fdc.h +++ b/include/hw/block/fdc.h @@ -15,5 +15,7 @@ void sun4m_fdctrl_init(qemu_irq irq, hwaddr io_base, DriveInfo **fds, qemu_irq *fdc_tc); FloppyDriveType isa_fdc_get_drive_type(ISADevice *fdc, int i); +void isa_fdc_get_drive_geometry(ISADevice *fdc, int i, uint8_t *cylinders, + uint8_t *heads, uint8_t *sectors); #endif diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 65e8f24..ad59453 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -271,6 +271,7 @@ typedef void (*cpu_set_smm_t)(int smm, void *arg); void ioapic_init_gsi(GSIState *gsi_state, const char *parent_name); ISADevice *pc_find_fdc0(void); +int cmos_get_fd_drive_type(FloppyDriveType fd0); /* acpi_piix.c */