From nobody Mon May 6 17:02:00 2024 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.zoho.com; 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 1497773077616837.4987203139822; Sun, 18 Jun 2017 01:04:37 -0700 (PDT) Received: from localhost ([::1]:37476 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dMVCF-0007bt-9C for importer@patchew.org; Sun, 18 Jun 2017 04:04:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44941) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dMVAG-0005wx-KR for qemu-devel@nongnu.org; Sun, 18 Jun 2017 04:02:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dMVAB-0006TR-K5 for qemu-devel@nongnu.org; Sun, 18 Jun 2017 04:02:32 -0400 Received: from chuckie.co.uk ([82.165.15.123]:56430 helo=s16892447.onlinehome-server.info) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dMVAB-0006Sn-D0 for qemu-devel@nongnu.org; Sun, 18 Jun 2017 04:02:27 -0400 Received: from host86-175-243-153.range86-175.btcentralplus.com ([86.175.243.153] helo=kentang.home) by s16892447.onlinehome-server.info with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1dMVA8-0006ld-Tr; Sun, 18 Jun 2017 09:02:26 +0100 From: Mark Cave-Ayland To: qemu-devel@nongnu.org, lersek@redhat.com, somlo@cmu.edu, ehabkost@redhat.com, mst@redhat.com, pbonzini@redhat.com, rjones@redhat.com, imammedo@redhat.com, peter.maydell@linaro.org Date: Sun, 18 Jun 2017 09:02:10 +0100 Message-Id: <1497772934-15561-2-git-send-email-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1497772934-15561-1-git-send-email-mark.cave-ayland@ilande.co.uk> References: <1497772934-15561-1-git-send-email-mark.cave-ayland@ilande.co.uk> X-SA-Exim-Connect-IP: 86.175.243.153 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk X-SA-Exim-Version: 4.2.1 (built Sun, 08 Jan 2012 02:45:44 +0000) X-SA-Exim-Scanned: Yes (on s16892447.onlinehome-server.info) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 82.165.15.123 Subject: [Qemu-devel] [PATCHv5 1/5] fw_cfg: don't map the fw_cfg IO ports in fw_cfg_io_realize() 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" As indicated by Laszlo it is a QOM bug for the realize() method to actually map the device. Set up the IO regions within fw_cfg_io_realize() and defer the mapping with sysbus_add_io() to the caller, as already done in fw_cfg_init_mem_wide(). This makes the iobase and dma_iobase properties now obsolete so they can be removed. Signed-off-by: Mark Cave-Ayland Reviewed-by: Laszlo Ersek --- hw/nvram/fw_cfg.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index 316fca9..4e4f71a 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -96,7 +96,6 @@ struct FWCfgIoState { /*< public >*/ =20 MemoryRegion comb_iomem; - uint32_t iobase, dma_iobase; }; =20 struct FWCfgMemState { @@ -936,24 +935,30 @@ FWCfgState *fw_cfg_init_io_dma(uint32_t iobase, uint3= 2_t dma_iobase, AddressSpace *dma_as) { DeviceState *dev; + SysBusDevice *sbd; + FWCfgIoState *ios; FWCfgState *s; uint32_t version =3D FW_CFG_VERSION; bool dma_requested =3D dma_iobase && dma_as; =20 dev =3D qdev_create(NULL, TYPE_FW_CFG_IO); - qdev_prop_set_uint32(dev, "iobase", iobase); - qdev_prop_set_uint32(dev, "dma_iobase", dma_iobase); if (!dma_requested) { qdev_prop_set_bit(dev, "dma_enabled", false); } =20 fw_cfg_init1(dev); + + sbd =3D SYS_BUS_DEVICE(dev); + ios =3D FW_CFG_IO(dev); + sysbus_add_io(sbd, iobase, &ios->comb_iomem); + s =3D FW_CFG(dev); =20 if (s->dma_enabled) { /* 64 bits for the address field */ s->dma_as =3D dma_as; s->dma_addr =3D 0; + sysbus_add_io(sbd, dma_iobase, &s->dma_iomem); =20 version |=3D FW_CFG_VERSION_DMA; } @@ -1059,8 +1064,6 @@ static void fw_cfg_file_slots_allocate(FWCfgState *s,= Error **errp) } =20 static Property fw_cfg_io_properties[] =3D { - DEFINE_PROP_UINT32("iobase", FWCfgIoState, iobase, -1), - DEFINE_PROP_UINT32("dma_iobase", FWCfgIoState, dma_iobase, -1), DEFINE_PROP_BOOL("dma_enabled", FWCfgIoState, parent_obj.dma_enabled, true), DEFINE_PROP_UINT16("x-file-slots", FWCfgIoState, parent_obj.file_slots, @@ -1071,7 +1074,6 @@ static Property fw_cfg_io_properties[] =3D { static void fw_cfg_io_realize(DeviceState *dev, Error **errp) { FWCfgIoState *s =3D FW_CFG_IO(dev); - SysBusDevice *sbd =3D SYS_BUS_DEVICE(dev); Error *local_err =3D NULL; =20 fw_cfg_file_slots_allocate(FW_CFG(s), &local_err); @@ -1085,13 +1087,11 @@ static void fw_cfg_io_realize(DeviceState *dev, Err= or **errp) * of the i/o region used is FW_CFG_CTL_SIZE */ memory_region_init_io(&s->comb_iomem, OBJECT(s), &fw_cfg_comb_mem_ops, FW_CFG(s), "fwcfg", FW_CFG_CTL_SIZE); - sysbus_add_io(sbd, s->iobase, &s->comb_iomem); =20 if (FW_CFG(s)->dma_enabled) { memory_region_init_io(&FW_CFG(s)->dma_iomem, OBJECT(s), &fw_cfg_dma_mem_ops, FW_CFG(s), "fwcfg.dma", sizeof(dma_addr_t)); - sysbus_add_io(sbd, s->dma_iobase, &FW_CFG(s)->dma_iomem); } } =20 --=20 1.7.10.4 From nobody Mon May 6 17:02:00 2024 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.zoho.com; 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 1497773077477650.88790916485; Sun, 18 Jun 2017 01:04:37 -0700 (PDT) Received: from localhost ([::1]:37477 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dMVCG-0007co-4G for importer@patchew.org; Sun, 18 Jun 2017 04:04:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44943) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dMVAG-0005wz-KW for qemu-devel@nongnu.org; Sun, 18 Jun 2017 04:02:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dMVAC-0006U4-S5 for qemu-devel@nongnu.org; Sun, 18 Jun 2017 04:02:32 -0400 Received: from chuckie.co.uk ([82.165.15.123]:56436 helo=s16892447.onlinehome-server.info) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dMVAC-0006Tk-L8 for qemu-devel@nongnu.org; Sun, 18 Jun 2017 04:02:28 -0400 Received: from host86-175-243-153.range86-175.btcentralplus.com ([86.175.243.153] helo=kentang.home) by s16892447.onlinehome-server.info with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1dMVAA-0006ld-DN; Sun, 18 Jun 2017 09:02:27 +0100 From: Mark Cave-Ayland To: qemu-devel@nongnu.org, lersek@redhat.com, somlo@cmu.edu, ehabkost@redhat.com, mst@redhat.com, pbonzini@redhat.com, rjones@redhat.com, imammedo@redhat.com, peter.maydell@linaro.org Date: Sun, 18 Jun 2017 09:02:11 +0100 Message-Id: <1497772934-15561-3-git-send-email-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1497772934-15561-1-git-send-email-mark.cave-ayland@ilande.co.uk> References: <1497772934-15561-1-git-send-email-mark.cave-ayland@ilande.co.uk> X-SA-Exim-Connect-IP: 86.175.243.153 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk X-SA-Exim-Version: 4.2.1 (built Sun, 08 Jan 2012 02:45:44 +0000) X-SA-Exim-Scanned: Yes (on s16892447.onlinehome-server.info) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 82.165.15.123 Subject: [Qemu-devel] [PATCHv5 2/5] fw_cfg: move setting of FW_CFG_VERSION_DMA bit to fw_cfg_init1() 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The setting of the FW_CFG_VERSION_DMA bit is the same across both the TYPE_FW_CFG_MEM and TYPE_FW_CFG_IO devices, so unify the logic in fw_cfg_init1(). Signed-off-by: Mark Cave-Ayland Reviewed-by: Laszlo Ersek --- hw/nvram/fw_cfg.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index 4e4f71a..99bdbc2 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -913,6 +913,7 @@ static void fw_cfg_init1(DeviceState *dev) { FWCfgState *s =3D FW_CFG(dev); MachineState *machine =3D MACHINE(qdev_get_machine()); + uint32_t version =3D FW_CFG_VERSION; =20 assert(!object_resolve_path(FW_CFG_PATH, NULL)); =20 @@ -927,6 +928,12 @@ static void fw_cfg_init1(DeviceState *dev) fw_cfg_bootsplash(s); fw_cfg_reboot(s); =20 + if (s->dma_enabled) { + version |=3D FW_CFG_VERSION_DMA; + } + + fw_cfg_add_i32(s, FW_CFG_ID, version); + s->machine_ready.notify =3D fw_cfg_machine_ready; qemu_add_machine_init_done_notifier(&s->machine_ready); } @@ -938,7 +945,6 @@ FWCfgState *fw_cfg_init_io_dma(uint32_t iobase, uint32_= t dma_iobase, SysBusDevice *sbd; FWCfgIoState *ios; FWCfgState *s; - uint32_t version =3D FW_CFG_VERSION; bool dma_requested =3D dma_iobase && dma_as; =20 dev =3D qdev_create(NULL, TYPE_FW_CFG_IO); @@ -959,12 +965,8 @@ FWCfgState *fw_cfg_init_io_dma(uint32_t iobase, uint32= _t dma_iobase, s->dma_as =3D dma_as; s->dma_addr =3D 0; sysbus_add_io(sbd, dma_iobase, &s->dma_iomem); - - version |=3D FW_CFG_VERSION_DMA; } =20 - fw_cfg_add_i32(s, FW_CFG_ID, version); - return s; } =20 @@ -980,7 +982,6 @@ FWCfgState *fw_cfg_init_mem_wide(hwaddr ctl_addr, DeviceState *dev; SysBusDevice *sbd; FWCfgState *s; - uint32_t version =3D FW_CFG_VERSION; bool dma_requested =3D dma_addr && dma_as; =20 dev =3D qdev_create(NULL, TYPE_FW_CFG_MEM); @@ -1001,11 +1002,8 @@ FWCfgState *fw_cfg_init_mem_wide(hwaddr ctl_addr, s->dma_as =3D dma_as; s->dma_addr =3D 0; sysbus_mmio_map(sbd, 2, dma_addr); - version |=3D FW_CFG_VERSION_DMA; } =20 - fw_cfg_add_i32(s, FW_CFG_ID, version); - return s; } =20 --=20 1.7.10.4 From nobody Mon May 6 17:02:00 2024 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.zoho.com; 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 1497773074650866.3041870123056; Sun, 18 Jun 2017 01:04:34 -0700 (PDT) Received: from localhost ([::1]:37475 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dMVCC-0007Zr-Uh for importer@patchew.org; Sun, 18 Jun 2017 04:04:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44942) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dMVAG-0005wy-KT for qemu-devel@nongnu.org; Sun, 18 Jun 2017 04:02:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dMVAE-0006Uv-LK for qemu-devel@nongnu.org; Sun, 18 Jun 2017 04:02:32 -0400 Received: from chuckie.co.uk ([82.165.15.123]:56442 helo=s16892447.onlinehome-server.info) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dMVAE-0006UH-El for qemu-devel@nongnu.org; Sun, 18 Jun 2017 04:02:30 -0400 Received: from host86-175-243-153.range86-175.btcentralplus.com ([86.175.243.153] helo=kentang.home) by s16892447.onlinehome-server.info with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1dMVAB-0006ld-Qd; Sun, 18 Jun 2017 09:02:28 +0100 From: Mark Cave-Ayland To: qemu-devel@nongnu.org, lersek@redhat.com, somlo@cmu.edu, ehabkost@redhat.com, mst@redhat.com, pbonzini@redhat.com, rjones@redhat.com, imammedo@redhat.com, peter.maydell@linaro.org Date: Sun, 18 Jun 2017 09:02:12 +0100 Message-Id: <1497772934-15561-4-git-send-email-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1497772934-15561-1-git-send-email-mark.cave-ayland@ilande.co.uk> References: <1497772934-15561-1-git-send-email-mark.cave-ayland@ilande.co.uk> X-SA-Exim-Connect-IP: 86.175.243.153 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk X-SA-Exim-Version: 4.2.1 (built Sun, 08 Jan 2012 02:45:44 +0000) X-SA-Exim-Scanned: Yes (on s16892447.onlinehome-server.info) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 82.165.15.123 Subject: [Qemu-devel] [PATCHv5 3/5] fw_cfg: move assert() and linking of fw_cfg device to the machine into instance_init() 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" In preparation for calling fw_cfg_init1() during realize rather than during init, move the assert() checking for existing fw_cfg devices and the linking of the device to the machine with object_property_add_child() to a new fw_cfg instance_init() function. This guarantees that we will still assert() correctly if more than one fw_c= fg device is instantiated by accident. Signed-off-by: Mark Cave-Ayland Reviewed-by: Laszlo Ersek --- hw/nvram/fw_cfg.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index 99bdbc2..af45012 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -915,10 +915,6 @@ static void fw_cfg_init1(DeviceState *dev) MachineState *machine =3D MACHINE(qdev_get_machine()); uint32_t version =3D FW_CFG_VERSION; =20 - assert(!object_resolve_path(FW_CFG_PATH, NULL)); - - object_property_add_child(OBJECT(machine), FW_CFG_NAME, OBJECT(s), NUL= L); - qdev_init_nofail(dev); =20 fw_cfg_add_bytes(s, FW_CFG_SIGNATURE, (char *)"QEMU", 4); @@ -1020,6 +1016,15 @@ FWCfgState *fw_cfg_find(void) return FW_CFG(object_resolve_path(FW_CFG_PATH, NULL)); } =20 +static void fw_cfg_init(Object *obj) +{ + MachineState *machine =3D MACHINE(qdev_get_machine()); + + assert(!object_resolve_path(FW_CFG_PATH, NULL)); + + object_property_add_child(OBJECT(machine), FW_CFG_NAME, obj, NULL); +} + static void fw_cfg_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); @@ -1033,6 +1038,7 @@ static const TypeInfo fw_cfg_info =3D { .parent =3D TYPE_SYS_BUS_DEVICE, .abstract =3D true, .instance_size =3D sizeof(FWCfgState), + .instance_init =3D fw_cfg_init, .class_init =3D fw_cfg_class_init, }; =20 --=20 1.7.10.4 From nobody Mon May 6 17:02:00 2024 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.zoho.com; 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 1497773196331321.429281076184; Sun, 18 Jun 2017 01:06:36 -0700 (PDT) Received: from localhost ([::1]:37488 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dMVEB-0000lC-26 for importer@patchew.org; Sun, 18 Jun 2017 04:06:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44963) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dMVAH-0005xU-Ba for qemu-devel@nongnu.org; Sun, 18 Jun 2017 04:02:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dMVAG-0006VY-Hz for qemu-devel@nongnu.org; Sun, 18 Jun 2017 04:02:33 -0400 Received: from chuckie.co.uk ([82.165.15.123]:56446 helo=s16892447.onlinehome-server.info) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dMVAG-0006VG-BC for qemu-devel@nongnu.org; Sun, 18 Jun 2017 04:02:32 -0400 Received: from host86-175-243-153.range86-175.btcentralplus.com ([86.175.243.153] helo=kentang.home) by s16892447.onlinehome-server.info with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1dMVAD-0006ld-AY; Sun, 18 Jun 2017 09:02:31 +0100 From: Mark Cave-Ayland To: qemu-devel@nongnu.org, lersek@redhat.com, somlo@cmu.edu, ehabkost@redhat.com, mst@redhat.com, pbonzini@redhat.com, rjones@redhat.com, imammedo@redhat.com, peter.maydell@linaro.org Date: Sun, 18 Jun 2017 09:02:13 +0100 Message-Id: <1497772934-15561-5-git-send-email-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1497772934-15561-1-git-send-email-mark.cave-ayland@ilande.co.uk> References: <1497772934-15561-1-git-send-email-mark.cave-ayland@ilande.co.uk> X-SA-Exim-Connect-IP: 86.175.243.153 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk X-SA-Exim-Version: 4.2.1 (built Sun, 08 Jan 2012 02:45:44 +0000) X-SA-Exim-Scanned: Yes (on s16892447.onlinehome-server.info) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 82.165.15.123 Subject: [Qemu-devel] [PATCHv5 4/5] fw_cfg: move qdev_init_nofail() from fw_cfg_init1() to callers 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" When looking to instantiate a TYPE_FW_CFG_MEM or TYPE_FW_CFG_IO device to be able to wire it up differently, it is much more convenient for the caller to instantiate the device and have the fw_cfg default files already preloaded during realize. Move fw_cfg_init1() to the end of both the fw_cfg_mem_realize() and fw_cfg_io_realize() functions so it no longer needs to be called manually when instantiating the device, and also rename it to fw_cfg_common_realize() which better describes its new purpose. Signed-off-by: Mark Cave-Ayland Reviewed-by: Laszlo Ersek --- hw/nvram/fw_cfg.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index af45012..df99903 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -909,14 +909,12 @@ static void fw_cfg_machine_ready(struct Notifier *n, = void *data) =20 =20 =20 -static void fw_cfg_init1(DeviceState *dev) +static void fw_cfg_common_realize(DeviceState *dev) { FWCfgState *s =3D FW_CFG(dev); MachineState *machine =3D MACHINE(qdev_get_machine()); uint32_t version =3D FW_CFG_VERSION; =20 - qdev_init_nofail(dev); - fw_cfg_add_bytes(s, FW_CFG_SIGNATURE, (char *)"QEMU", 4); fw_cfg_add_bytes(s, FW_CFG_UUID, &qemu_uuid, 16); fw_cfg_add_i16(s, FW_CFG_NOGRAPHIC, (uint16_t)!machine->enable_graphic= s); @@ -948,7 +946,7 @@ FWCfgState *fw_cfg_init_io_dma(uint32_t iobase, uint32_= t dma_iobase, qdev_prop_set_bit(dev, "dma_enabled", false); } =20 - fw_cfg_init1(dev); + qdev_init_nofail(dev); =20 sbd =3D SYS_BUS_DEVICE(dev); ios =3D FW_CFG_IO(dev); @@ -986,7 +984,7 @@ FWCfgState *fw_cfg_init_mem_wide(hwaddr ctl_addr, qdev_prop_set_bit(dev, "dma_enabled", false); } =20 - fw_cfg_init1(dev); + qdev_init_nofail(dev); =20 sbd =3D SYS_BUS_DEVICE(dev); sysbus_mmio_map(sbd, 0, ctl_addr); @@ -1097,6 +1095,8 @@ static void fw_cfg_io_realize(DeviceState *dev, Error= **errp) &fw_cfg_dma_mem_ops, FW_CFG(s), "fwcfg.dma", sizeof(dma_addr_t)); } + + fw_cfg_common_realize(dev); } =20 static void fw_cfg_io_class_init(ObjectClass *klass, void *data) @@ -1163,6 +1163,8 @@ static void fw_cfg_mem_realize(DeviceState *dev, Erro= r **errp) sizeof(dma_addr_t)); sysbus_init_mmio(sbd, &FW_CFG(s)->dma_iomem); } + + fw_cfg_common_realize(dev); } =20 static void fw_cfg_mem_class_init(ObjectClass *klass, void *data) --=20 1.7.10.4 From nobody Mon May 6 17:02:00 2024 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.zoho.com; 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 1497773263217565.8911883293056; Sun, 18 Jun 2017 01:07:43 -0700 (PDT) Received: from localhost ([::1]:37492 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dMVFE-0001yZ-8C for importer@patchew.org; Sun, 18 Jun 2017 04:07:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44978) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dMVAJ-0005yt-Hm for qemu-devel@nongnu.org; Sun, 18 Jun 2017 04:02:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dMVAI-0006XU-G7 for qemu-devel@nongnu.org; Sun, 18 Jun 2017 04:02:35 -0400 Received: from chuckie.co.uk ([82.165.15.123]:56452 helo=s16892447.onlinehome-server.info) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dMVAI-0006Wl-8V for qemu-devel@nongnu.org; Sun, 18 Jun 2017 04:02:34 -0400 Received: from host86-175-243-153.range86-175.btcentralplus.com ([86.175.243.153] helo=kentang.home) by s16892447.onlinehome-server.info with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1dMVAF-0006ld-Ha; Sun, 18 Jun 2017 09:02:33 +0100 From: Mark Cave-Ayland To: qemu-devel@nongnu.org, lersek@redhat.com, somlo@cmu.edu, ehabkost@redhat.com, mst@redhat.com, pbonzini@redhat.com, rjones@redhat.com, imammedo@redhat.com, peter.maydell@linaro.org Date: Sun, 18 Jun 2017 09:02:14 +0100 Message-Id: <1497772934-15561-6-git-send-email-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1497772934-15561-1-git-send-email-mark.cave-ayland@ilande.co.uk> References: <1497772934-15561-1-git-send-email-mark.cave-ayland@ilande.co.uk> X-SA-Exim-Connect-IP: 86.175.243.153 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk X-SA-Exim-Version: 4.2.1 (built Sun, 08 Jan 2012 02:45:44 +0000) X-SA-Exim-Scanned: Yes (on s16892447.onlinehome-server.info) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 82.165.15.123 Subject: [Qemu-devel] [PATCHv5 5/5] fw_cfg: move QOM type defines and fw_cfg types into fw_cfg.h 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" By exposing FWCfgIoState and FWCfgMemState internals we allow the possibili= ty for the internal MemoryRegion fields to be mapped by name for boards that w= ish to wire up the fw_cfg device themselves. An additional minor tidy-up is that the FWCfgEntry typedef is moved from the struct definitions in fw_cfg.h to typedefs.h along with the others. Signed-off-by: Mark Cave-Ayland Reviewed-by: Laszlo Ersek Tested-by: Laszlo Ersek --- hw/nvram/fw_cfg.c | 55 ------------------------------------------ include/hw/nvram/fw_cfg.h | 58 +++++++++++++++++++++++++++++++++++++++++= ++++ include/qemu/typedefs.h | 1 + 3 files changed, 59 insertions(+), 55 deletions(-) diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index df99903..00771c9 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -40,14 +40,6 @@ #define FW_CFG_NAME "fw_cfg" #define FW_CFG_PATH "/machine/" FW_CFG_NAME =20 -#define TYPE_FW_CFG "fw_cfg" -#define TYPE_FW_CFG_IO "fw_cfg_io" -#define TYPE_FW_CFG_MEM "fw_cfg_mem" - -#define FW_CFG(obj) OBJECT_CHECK(FWCfgState, (obj), TYPE_FW_CFG) -#define FW_CFG_IO(obj) OBJECT_CHECK(FWCfgIoState, (obj), TYPE_FW_CFG_IO) -#define FW_CFG_MEM(obj) OBJECT_CHECK(FWCfgMemState, (obj), TYPE_FW_CFG_MEM) - /* FW_CFG_VERSION bits */ #define FW_CFG_VERSION 0x01 #define FW_CFG_VERSION_DMA 0x02 @@ -61,53 +53,6 @@ =20 #define FW_CFG_DMA_SIGNATURE 0x51454d5520434647ULL /* "QEMU CFG" */ =20 -typedef struct FWCfgEntry { - uint32_t len; - bool allow_write; - uint8_t *data; - void *callback_opaque; - FWCfgReadCallback read_callback; -} FWCfgEntry; - -struct FWCfgState { - /*< private >*/ - SysBusDevice parent_obj; - /*< public >*/ - - uint16_t file_slots; - FWCfgEntry *entries[2]; - int *entry_order; - FWCfgFiles *files; - uint16_t cur_entry; - uint32_t cur_offset; - Notifier machine_ready; - - int fw_cfg_order_override; - - bool dma_enabled; - dma_addr_t dma_addr; - AddressSpace *dma_as; - MemoryRegion dma_iomem; -}; - -struct FWCfgIoState { - /*< private >*/ - FWCfgState parent_obj; - /*< public >*/ - - MemoryRegion comb_iomem; -}; - -struct FWCfgMemState { - /*< private >*/ - FWCfgState parent_obj; - /*< public >*/ - - MemoryRegion ctl_iomem, data_iomem; - uint32_t data_width; - MemoryRegionOps wide_data_ops; -}; - #define JPG_FILE 0 #define BMP_FILE 1 =20 diff --git a/include/hw/nvram/fw_cfg.h b/include/hw/nvram/fw_cfg.h index b980cba..b0511b9 100644 --- a/include/hw/nvram/fw_cfg.h +++ b/include/hw/nvram/fw_cfg.h @@ -1,8 +1,19 @@ #ifndef FW_CFG_H #define FW_CFG_H =20 +#include "qemu/typedefs.h" #include "exec/hwaddr.h" #include "hw/nvram/fw_cfg_keys.h" +#include "hw/sysbus.h" +#include "sysemu/dma.h" + +#define TYPE_FW_CFG "fw_cfg" +#define TYPE_FW_CFG_IO "fw_cfg_io" +#define TYPE_FW_CFG_MEM "fw_cfg_mem" + +#define FW_CFG(obj) OBJECT_CHECK(FWCfgState, (obj), TYPE_FW_CFG) +#define FW_CFG_IO(obj) OBJECT_CHECK(FWCfgIoState, (obj), TYPE_FW_CFG_IO) +#define FW_CFG_MEM(obj) OBJECT_CHECK(FWCfgMemState, (obj), TYPE_FW_CFG_MEM) =20 typedef struct FWCfgFile { uint32_t size; /* file size */ @@ -35,6 +46,53 @@ typedef struct FWCfgDmaAccess { =20 typedef void (*FWCfgReadCallback)(void *opaque); =20 +struct FWCfgEntry { + uint32_t len; + bool allow_write; + uint8_t *data; + void *callback_opaque; + FWCfgReadCallback read_callback; +}; + +struct FWCfgState { + /*< private >*/ + SysBusDevice parent_obj; + /*< public >*/ + + uint16_t file_slots; + FWCfgEntry *entries[2]; + int *entry_order; + FWCfgFiles *files; + uint16_t cur_entry; + uint32_t cur_offset; + Notifier machine_ready; + + int fw_cfg_order_override; + + bool dma_enabled; + dma_addr_t dma_addr; + AddressSpace *dma_as; + MemoryRegion dma_iomem; +}; + +struct FWCfgIoState { + /*< private >*/ + FWCfgState parent_obj; + /*< public >*/ + + MemoryRegion comb_iomem; +}; + +struct FWCfgMemState { + /*< private >*/ + FWCfgState parent_obj; + /*< public >*/ + + MemoryRegion ctl_iomem, data_iomem; + uint32_t data_width; + MemoryRegionOps wide_data_ops; +}; + /** * fw_cfg_add_bytes: * @s: fw_cfg device being modified diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h index f745d5f..2db2918 100644 --- a/include/qemu/typedefs.h +++ b/include/qemu/typedefs.h @@ -30,6 +30,7 @@ typedef struct DisplaySurface DisplaySurface; typedef struct DriveInfo DriveInfo; typedef struct Error Error; typedef struct EventNotifier EventNotifier; +typedef struct FWCfgEntry FWCfgEntry; typedef struct FWCfgIoState FWCfgIoState; typedef struct FWCfgMemState FWCfgMemState; typedef struct FWCfgState FWCfgState; --=20 1.7.10.4