From nobody Tue Feb 10 05:10:18 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1520549874732939.7326177558533; Thu, 8 Mar 2018 14:57:54 -0800 (PST) Received: from localhost ([::1]:42320 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eu4Tx-0004gw-TP for importer@patchew.org; Thu, 08 Mar 2018 17:57:53 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56493) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eu4Cw-000716-N9 for qemu-devel@nongnu.org; Thu, 08 Mar 2018 17:40:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eu4Cv-00045X-Bj for qemu-devel@nongnu.org; Thu, 08 Mar 2018 17:40:18 -0500 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]:40657) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eu4Cv-00044S-1p; Thu, 08 Mar 2018 17:40:17 -0500 Received: by mail-wr0-x242.google.com with SMTP id o76so7248176wrb.7; Thu, 08 Mar 2018 14:40:16 -0800 (PST) Received: from x1.local (ABayonne-654-1-76-150.w86-222.abo.wanadoo.fr. [86.222.219.150]) by smtp.gmail.com with ESMTPSA id x190sm19315070wme.27.2018.03.08.14.40.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Mar 2018 14:40:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=S/s1zVzCDRtP4IX91qkMGKGPLN8yzrYYdxfr8vZ4n3Y=; b=IMgRaM0UP5q9rO1c+c5y3P8enWoI/IZMOhjZA2b9oxRlZq1CNQBXrHXyjUsmCPdb1l ZQDu4dv8nBDsmCyMkyGvAXiRZT45uxQOXPimsj/iNtf+SptKP2bxkX1WdDYaD+zSDtpV tAy8LTpajd/77eNZlz5VA9b28jvZJjNPOC+S1oVRppE4uibgmYKiZ34tPmk7pGRUv8IV F5OngYppmUP3cHdmkLIPlvXZVO8iO7WkUnJfiwpD8sBBnzy/kZEoSiKDyQYalTIKp2Db +yXZNPfORk6ywPA/Krv9wZXqs8pirlvWKNzgo8j+HYg7FxBBSMNDE+A+cWK0vYdo3vpn Vk8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=S/s1zVzCDRtP4IX91qkMGKGPLN8yzrYYdxfr8vZ4n3Y=; b=I736d+pTINRdjLj9YZC0N3mkBSXzq1nrmjforJP0utnXDeMNa/fscl7XwrPoN5Z9Sv +UMcPbsuUVp5CNYIPDVFG68WuTq8KhAb+6rRsIDMD7jZ6vFpV3i/Rwv/RPIwqv0Dj3bQ FZ+qb/afFGyVC9lSUDCdgA3uDJ4t9idMOQEmXMQcyQDBRQoYICh2X8F1/96JZTkoQdba gg5fkl792uIRKTNaEhcjCFtG640ag4qq6o2LEtg+G/cBFQqR+0WMyqngAqQ8Sq6Z+7b0 bSww9+6RlkJrCUSdDKsQVXiJUhxgxdGk+Rnd5gqj3kfYi08KE0N3eFFKLtPtLyxh9sdb QhgQ== X-Gm-Message-State: APf1xPBp5ELmtGvrx6AtdVD2zPiDXG1DM6xZ9QCARiIhVahGR/SQQEyq IOfp4YdxMSpkRlD9PkanPhOoaCt2 X-Google-Smtp-Source: AG47ELsezNah9Ml9Xq1Gv3INEHXf2RhLjjrSGinAgriX2sy6QlUrl+8W3RwSG2g/UJ98Wu2D9HT94A== X-Received: by 10.223.135.232 with SMTP id c37mr22669046wrc.168.1520548815966; Thu, 08 Mar 2018 14:40:15 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: "Michael S . Tsirkin" , Paolo Bonzini , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Marcel Apfelbaum , Aurelien Jarno , Mark Cave-Ayland , Alexey Kardashevskiy , Thomas Huth Date: Thu, 8 Mar 2018 23:39:33 +0100 Message-Id: <20180308223946.26784-13-f4bug@amsat.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180308223946.26784-1-f4bug@amsat.org> References: <20180308223946.26784-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::242 Subject: [Qemu-devel] [PATCH 12/25] hw/isa/superio: Factor out the floppy disc controller code from pc87312.c X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org, "open list:PReP" , Guan Xuetao , Yongbok Kim , Artyom Tarasenko , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/isa/pc87312.h | 4 ---- include/hw/isa/superio.h | 2 ++ hw/isa/isa-superio.c | 36 ++++++++++++++++++++++++++++++++++++ hw/isa/pc87312.c | 46 +++++++++++++++++++-------------------------= -- hw/isa/trace-events | 2 +- 5 files changed, 58 insertions(+), 32 deletions(-) diff --git a/include/hw/isa/pc87312.h b/include/hw/isa/pc87312.h index 1480615a2c..e16263d4b1 100644 --- a/include/hw/isa/pc87312.h +++ b/include/hw/isa/pc87312.h @@ -39,10 +39,6 @@ typedef struct PC87312State { uint16_t iobase; uint8_t config; /* initial configuration */ =20 - struct { - ISADevice *dev; - } fdc; - struct { ISADevice *dev; } ide; diff --git a/include/hw/isa/superio.h b/include/hw/isa/superio.h index 0b516721c3..e8007b9eee 100644 --- a/include/hw/isa/superio.h +++ b/include/hw/isa/superio.h @@ -29,6 +29,7 @@ typedef struct ISASuperIODevice { =20 ISADevice *parallel[MAX_PARALLEL_PORTS]; ISADevice *serial[MAX_SERIAL_PORTS]; + ISADevice *floppy; } ISASuperIODevice; =20 typedef struct ISASuperIOFuncs { @@ -47,6 +48,7 @@ typedef struct ISASuperIOClass { =20 ISASuperIOFuncs parallel; ISASuperIOFuncs serial; + ISASuperIOFuncs floppy; } ISASuperIOClass; =20 #endif /* HW_ISA_SUPERIO_H */ diff --git a/hw/isa/isa-superio.c b/hw/isa/isa-superio.c index 6962421aad..4b5e280b38 100644 --- a/hw/isa/isa-superio.c +++ b/hw/isa/isa-superio.c @@ -11,7 +11,10 @@ */ #include "qemu/osdep.h" #include "qemu/error-report.h" +#include "qapi/error.h" #include "sysemu/sysemu.h" +#include "sysemu/block-backend.h" +#include "sysemu/blockdev.h" #include "chardev/char.h" #include "hw/isa/superio.h" #include "hw/char/serial.h" @@ -25,6 +28,7 @@ static void isa_superio_realize(DeviceState *dev, Error *= *errp) ISADevice *isa; DeviceState *d; Chardev *chr; + DriveInfo *drive; char *name; int i; =20 @@ -107,6 +111,38 @@ static void isa_superio_realize(DeviceState *dev, Erro= r **errp) g_free(name); } } + + /* Floppy disc */ + if (!k->floppy.is_enabled || k->floppy.is_enabled(sio, 0)) { + isa =3D isa_create(bus, "isa-fdc"); + d =3D DEVICE(isa); + if (k->floppy.get_iobase) { + qdev_prop_set_uint32(d, "iobase", k->floppy.get_iobase(sio, 0)= ); + } + if (k->floppy.get_irq) { + qdev_prop_set_uint32(d, "irq", k->floppy.get_irq(sio, 0)); + } + /* FIXME use a qdev drive property instead of drive_get() */ + drive =3D drive_get(IF_FLOPPY, 0, 0); + if (drive !=3D NULL) { + qdev_prop_set_drive(d, "driveA", blk_by_legacy_dinfo(drive), + &error_fatal); + } + /* FIXME use a qdev drive property instead of drive_get() */ + drive =3D drive_get(IF_FLOPPY, 0, 1); + if (drive !=3D NULL) { + qdev_prop_set_drive(d, "driveB", blk_by_legacy_dinfo(drive), + &error_fatal); + } + qdev_init_nofail(d); + sio->floppy =3D isa; + trace_superio_create_floppy(0, + k->floppy.get_iobase ? + k->floppy.get_iobase(sio, 0) : -1, + k->floppy.get_irq ? + k->floppy.get_irq(sio, 0) : -1); + } + } =20 static void isa_superio_class_init(ObjectClass *oc, void *data) diff --git a/hw/isa/pc87312.c b/hw/isa/pc87312.c index c2837bca43..a1845a91c3 100644 --- a/hw/isa/pc87312.c +++ b/hw/isa/pc87312.c @@ -27,8 +27,6 @@ #include "hw/isa/pc87312.h" #include "qapi/error.h" #include "qemu/error-report.h" -#include "sysemu/block-backend.h" -#include "sysemu/blockdev.h" #include "trace.h" =20 =20 @@ -129,16 +127,26 @@ static bool is_uart_enabled(ISASuperIODevice *sio, ui= nt8_t i) =20 /* Floppy controller */ =20 -static inline bool is_fdc_enabled(PC87312State *s) +static bool is_fdc_enabled(ISASuperIODevice *sio, uint8_t index) { + PC87312State *s =3D PC87312(sio); + assert(!index); return s->regs[REG_FER] & FER_FDC_EN; } =20 -static inline uint16_t get_fdc_iobase(PC87312State *s) +static uint16_t get_fdc_iobase(ISASuperIODevice *sio, uint8_t index) { + PC87312State *s =3D PC87312(sio); + assert(!index); return (s->regs[REG_FER] & FER_FDC_ADDR) ? 0x370 : 0x3f0; } =20 +static unsigned int get_fdc_irq(ISASuperIODevice *sio, uint8_t index) +{ + assert(!index); + return 6; +} + =20 /* IDE controller */ =20 @@ -272,7 +280,6 @@ static void pc87312_realize(DeviceState *dev, Error **e= rrp) DeviceState *d; ISADevice *isa; ISABus *bus; - DriveInfo *drive; Error *local_err =3D NULL; =20 s =3D PC87312(dev); @@ -287,28 +294,6 @@ static void pc87312_realize(DeviceState *dev, Error **= errp) return; } =20 - if (is_fdc_enabled(s)) { - isa =3D isa_create(bus, "isa-fdc"); - d =3D DEVICE(isa); - qdev_prop_set_uint32(d, "iobase", get_fdc_iobase(s)); - qdev_prop_set_uint32(d, "irq", 6); - /* FIXME use a qdev drive property instead of drive_get() */ - drive =3D drive_get(IF_FLOPPY, 0, 0); - if (drive !=3D NULL) { - qdev_prop_set_drive(d, "driveA", blk_by_legacy_dinfo(drive), - &error_fatal); - } - /* FIXME use a qdev drive property instead of drive_get() */ - drive =3D drive_get(IF_FLOPPY, 0, 1); - if (drive !=3D NULL) { - qdev_prop_set_drive(d, "driveB", blk_by_legacy_dinfo(drive), - &error_fatal); - } - qdev_init_nofail(d); - s->fdc.dev =3D isa; - trace_pc87312_info_floppy(get_fdc_iobase(s)); - } - if (is_ide_enabled(s)) { isa =3D isa_create(bus, "isa-ide"); d =3D DEVICE(isa); @@ -370,6 +355,12 @@ static void pc87312_class_init(ObjectClass *klass, voi= d *data) .get_iobase =3D get_uart_iobase, .get_irq =3D get_uart_irq, }; + sc->floppy =3D (ISASuperIOFuncs){ + .count =3D 1, + .is_enabled =3D is_fdc_enabled, + .get_iobase =3D get_fdc_iobase, + .get_irq =3D get_fdc_irq, + }; } =20 static const TypeInfo pc87312_type_info =3D { @@ -378,6 +369,7 @@ static const TypeInfo pc87312_type_info =3D { .instance_size =3D sizeof(PC87312State), .instance_init =3D pc87312_initfn, .class_init =3D pc87312_class_init, + /* FIXME use a qdev drive property instead of drive_get() */ }; =20 static void pc87312_register_types(void) diff --git a/hw/isa/trace-events b/hw/isa/trace-events index c78dd6c353..8d9900882f 100644 --- a/hw/isa/trace-events +++ b/hw/isa/trace-events @@ -3,9 +3,9 @@ # hw/isa/isa-superio.c superio_create_parallel(int id, uint16_t base, unsigned int irq) "id=3D%d,= base 0x%03x, irq %u" superio_create_serial(int id, uint16_t base, unsigned int irq) "id=3D%d, b= ase 0x%03x, irq %u" +superio_create_floppy(int id, uint16_t base, unsigned int irq) "id=3D%d, b= ase 0x%03x, irq %u" =20 # hw/isa/pc87312.c pc87312_io_read(uint32_t addr, uint32_t val) "read addr=3D0x%x val=3D0x%x" pc87312_io_write(uint32_t addr, uint32_t val) "write addr=3D0x%x val=3D0x%= x" -pc87312_info_floppy(uint32_t base) "base 0x%x" pc87312_info_ide(uint32_t base) "base 0x%x" --=20 2.16.2