From nobody Tue Feb 10 02:43:48 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 1520549506929249.1217118319646; Thu, 8 Mar 2018 14:51:46 -0800 (PST) Received: from localhost ([::1]:42284 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eu4O1-0007eZ-Vp for importer@patchew.org; Thu, 08 Mar 2018 17:51:46 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56550) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eu4D0-00076C-GG for qemu-devel@nongnu.org; Thu, 08 Mar 2018 17:40:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eu4Cy-00049E-TH for qemu-devel@nongnu.org; Thu, 08 Mar 2018 17:40:22 -0500 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]:34431) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eu4Cy-00048b-KP; Thu, 08 Mar 2018 17:40:20 -0500 Received: by mail-wr0-x241.google.com with SMTP id o8so7270275wra.1; Thu, 08 Mar 2018 14:40:20 -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.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Mar 2018 14:40:18 -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=kkjbgdCAnmVHSSBjEW5AvUopJQQo3bqo+13aGn3TN7I=; b=DBTQwwpjoHOA4i0lz2SNEr3M/0GqujKfpWcEE6aYDO/CpESHILURmvOiHXobTsBlOa eIGJotDxdWz6SuNxe7tWTC9M591B2OzkFW/MkREMqQ0PySjHkvjHk2ZnYzHNHympywuD XEtmbr5Yfh4P4NQ7laNhvN0bfv17vY5fE8Wi0O7loaOuYgpdHOLpj3CnyJWOM61idlHP n2tKWPF0kmegWUr7uytyHaMEG2cemOs9oIxGwLfJ6usKVKafYQ7KuVr89m4EaKa5hdQd d3+uw11uoDDnmZbqxaGEYVoaorU9usihvxBZz9FMwekVYxF3KsPiSG+fQDEolai7C8hn jA+g== 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=kkjbgdCAnmVHSSBjEW5AvUopJQQo3bqo+13aGn3TN7I=; b=DtK077GwRqGy0R8FhUdlU7z7gEKwM0PLeAwwVRrq8uCI1gwqvlk5DV7YBxzlAzeesZ chzX4JHYOfTZ61bdfnrvCssNqAuxQHlje7UL//Zx1Y9uyVWzzN25oOzSLjCuLCXqiE8T eDBhBO15XiTP8410uoF7wY6U8KLTC1VUkU7M+9RJYidAjpo+/ujmxuLLhpKf8qofqLji t3JdILcWOiRoUow1d3aPQkiVkMmc7bAU78JqKjvaNmsGdNpJqDCfVSPW6XpaDgAy8nCP kqnw1XoGIWLLSdlpKuKfsHYPKwhVZ6blJL7LfFbrRT1lXoS5+FoKDPyUK6Rpw0TdTuV7 sHVQ== X-Gm-Message-State: APf1xPAdpKU7DVZLvjslSR5HriAXWQCAitdhDyOEJW6oBAiu8c+F8V/c RbTmtU+XXH6EaS38TNEJby0= X-Google-Smtp-Source: AG47ELvcuRU48X2XLsgrbebQUzH28aCUJvCc7mPzVh0vLqKsapgETbuyqYI8tUJuGeWzJmxNX/1d7w== X-Received: by 10.223.163.222 with SMTP id m30mr25740264wrb.30.1520548819573; Thu, 08 Mar 2018 14:40:19 -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:35 +0100 Message-Id: <20180308223946.26784-15-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::241 Subject: [Qemu-devel] [PATCH 14/25] hw/isa/superio: Factor out the IDE 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/superio.h | 2 ++ hw/isa/isa-superio.c | 22 ++++++++++++++++++++++ hw/isa/pc87312.c | 36 ++++++++++++++++++++---------------- hw/isa/trace-events | 2 +- 4 files changed, 45 insertions(+), 17 deletions(-) diff --git a/include/hw/isa/superio.h b/include/hw/isa/superio.h index 2fc33bf3d3..3dd5448f8c 100644 --- a/include/hw/isa/superio.h +++ b/include/hw/isa/superio.h @@ -31,6 +31,7 @@ typedef struct ISASuperIODevice { ISADevice *serial[MAX_SERIAL_PORTS]; ISADevice *floppy; ISADevice *kbc; + ISADevice *ide; } ISASuperIODevice; =20 typedef struct ISASuperIOFuncs { @@ -50,6 +51,7 @@ typedef struct ISASuperIOClass { ISASuperIOFuncs parallel; ISASuperIOFuncs serial; ISASuperIOFuncs floppy; + ISASuperIOFuncs ide; } ISASuperIOClass; =20 #endif /* HW_ISA_SUPERIO_H */ diff --git a/hw/isa/isa-superio.c b/hw/isa/isa-superio.c index 041b47bdbf..f98711beff 100644 --- a/hw/isa/isa-superio.c +++ b/hw/isa/isa-superio.c @@ -146,6 +146,28 @@ static void isa_superio_realize(DeviceState *dev, Erro= r **errp) =20 /* Keyboard, mouse */ sio->kbc =3D isa_create_simple(bus, TYPE_I8042); + + /* IDE */ + if (k->ide.count && (!k->ide.is_enabled || k->ide.is_enabled(sio, 0)))= { + isa =3D isa_create(bus, "isa-ide"); + d =3D DEVICE(isa); + if (k->ide.get_iobase) { + qdev_prop_set_uint32(d, "iobase", k->ide.get_iobase(sio, 0)); + } + if (k->ide.get_iobase) { + qdev_prop_set_uint32(d, "iobase2", k->ide.get_iobase(sio, 1)); + } + if (k->ide.get_irq) { + qdev_prop_set_uint32(d, "irq", k->ide.get_irq(sio, 0)); + } + qdev_init_nofail(d); + sio->ide =3D isa; + trace_superio_create_ide(0, + k->ide.get_iobase ? + k->ide.get_iobase(sio, 0) : -1, + k->ide.get_irq ? + k->ide.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 a1845a91c3..5cf64505fe 100644 --- a/hw/isa/pc87312.c +++ b/hw/isa/pc87312.c @@ -150,16 +150,28 @@ static unsigned int get_fdc_irq(ISASuperIODevice *sio= , uint8_t index) =20 /* IDE controller */ =20 -static inline bool is_ide_enabled(PC87312State *s) +static bool is_ide_enabled(ISASuperIODevice *sio, uint8_t index) { + PC87312State *s =3D PC87312(sio); + return s->regs[REG_FER] & FER_IDE_EN; } =20 -static inline uint16_t get_ide_iobase(PC87312State *s) +static uint16_t get_ide_iobase(ISASuperIODevice *sio, uint8_t index) { + PC87312State *s =3D PC87312(sio); + + if (index =3D=3D 1) { + return get_ide_iobase(sio, 0) + 0x206; + } return (s->regs[REG_FER] & FER_IDE_ADDR) ? 0x170 : 0x1f0; } =20 +static unsigned int get_ide_irq(ISASuperIODevice *sio, uint8_t index) +{ + assert(index =3D=3D 0); + return 14; +} =20 static void reconfigure_devices(PC87312State *s) { @@ -277,14 +289,11 @@ static void pc87312_reset(DeviceState *d) static void pc87312_realize(DeviceState *dev, Error **errp) { PC87312State *s; - DeviceState *d; ISADevice *isa; - ISABus *bus; Error *local_err =3D NULL; =20 s =3D PC87312(dev); isa =3D ISA_DEVICE(dev); - bus =3D isa_bus_from_device(isa); isa_register_ioport(isa, &s->io, s->iobase); pc87312_hard_reset(s); =20 @@ -293,17 +302,6 @@ static void pc87312_realize(DeviceState *dev, Error **= errp) error_propagate(errp, local_err); return; } - - if (is_ide_enabled(s)) { - isa =3D isa_create(bus, "isa-ide"); - d =3D DEVICE(isa); - qdev_prop_set_uint32(d, "iobase", get_ide_iobase(s)); - qdev_prop_set_uint32(d, "iobase2", get_ide_iobase(s) + 0x206); - qdev_prop_set_uint32(d, "irq", 14); - qdev_init_nofail(d); - s->ide.dev =3D isa; - trace_pc87312_info_ide(get_ide_iobase(s)); - } } =20 static void pc87312_initfn(Object *obj) @@ -361,6 +359,12 @@ static void pc87312_class_init(ObjectClass *klass, voi= d *data) .get_iobase =3D get_fdc_iobase, .get_irq =3D get_fdc_irq, }; + sc->ide =3D (ISASuperIOFuncs){ + .count =3D 1, + .is_enabled =3D is_ide_enabled, + .get_iobase =3D get_ide_iobase, + .get_irq =3D get_ide_irq, + }; } =20 static const TypeInfo pc87312_type_info =3D { diff --git a/hw/isa/trace-events b/hw/isa/trace-events index 8d9900882f..80ac6175d6 100644 --- a/hw/isa/trace-events +++ b/hw/isa/trace-events @@ -4,8 +4,8 @@ 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" +superio_create_ide(int id, uint16_t base, unsigned int irq) "id=3D%d, base= 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_ide(uint32_t base) "base 0x%x" --=20 2.16.2