From nobody Mon May 6 04:28:53 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.zohomail.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 1528392507203677.278260592534; Thu, 7 Jun 2018 10:28:27 -0700 (PDT) Received: from localhost ([::1]:59454 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQyi2-0003A8-Es for importer@patchew.org; Thu, 07 Jun 2018 13:28:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35228) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQyY2-0002T8-FT for qemu-devel@nongnu.org; Thu, 07 Jun 2018 13:18:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fQyY0-0001kq-J0 for qemu-devel@nongnu.org; Thu, 07 Jun 2018 13:18:06 -0400 Received: from chuckie.co.uk ([82.165.15.123]:44750 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 1fQyY0-0001kG-CH; Thu, 07 Jun 2018 13:18:04 -0400 Received: from [46.233.90.41] (helo=kentang.lan) by s16892447.onlinehome-server.info with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1fQyYD-0007OG-0d; Thu, 07 Jun 2018 18:18:17 +0100 From: Mark Cave-Ayland To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org, david@gibson.dropbear.id.au Date: Thu, 7 Jun 2018 18:17:48 +0100 Message-Id: <20180607171751.11510-2-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180607171751.11510-1-mark.cave-ayland@ilande.co.uk> References: <20180607171751.11510-1-mark.cave-ayland@ilande.co.uk> X-SA-Exim-Connect-IP: 46.233.90.41 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] [PATCH 1/4] mos6522: fix vmstate_mos6522_timer version in vmstate_mos6522 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" This was accidentally introduced when extracting the 6522 VIA functionality from the CUDA device, and prevents loadvm from completing successfully. Signed-off-by: Mark Cave-Ayland --- hw/misc/mos6522.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/misc/mos6522.c b/hw/misc/mos6522.c index 6163cea6ab..dd56c796e4 100644 --- a/hw/misc/mos6522.c +++ b/hw/misc/mos6522.c @@ -405,7 +405,7 @@ static const VMStateDescription vmstate_mos6522 =3D { VMSTATE_UINT8(ifr, MOS6522State), VMSTATE_UINT8(ier, MOS6522State), VMSTATE_UINT8(anh, MOS6522State), - VMSTATE_STRUCT_ARRAY(timers, MOS6522State, 2, 1, + VMSTATE_STRUCT_ARRAY(timers, MOS6522State, 2, 0, vmstate_mos6522_timer, MOS6522Timer), VMSTATE_END_OF_LIST() } --=20 2.11.0 From nobody Mon May 6 04:28:53 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.zohomail.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 1528392923383641.8146539573901; Thu, 7 Jun 2018 10:35:23 -0700 (PDT) Received: from localhost ([::1]:59493 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQyok-0003jC-K5 for importer@patchew.org; Thu, 07 Jun 2018 13:35:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35268) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQyY4-0002V2-E6 for qemu-devel@nongnu.org; Thu, 07 Jun 2018 13:18:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fQyY2-0001mF-QF for qemu-devel@nongnu.org; Thu, 07 Jun 2018 13:18:08 -0400 Received: from chuckie.co.uk ([82.165.15.123]:44754 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 1fQyY2-0001lS-Gq; Thu, 07 Jun 2018 13:18:06 -0400 Received: from [46.233.90.41] (helo=kentang.lan) by s16892447.onlinehome-server.info with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1fQyYE-0007OG-D8; Thu, 07 Jun 2018 18:18:20 +0100 From: Mark Cave-Ayland To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org, david@gibson.dropbear.id.au Date: Thu, 7 Jun 2018 18:17:49 +0100 Message-Id: <20180607171751.11510-3-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180607171751.11510-1-mark.cave-ayland@ilande.co.uk> References: <20180607171751.11510-1-mark.cave-ayland@ilande.co.uk> X-SA-Exim-Connect-IP: 46.233.90.41 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] [PATCH 2/4] cuda: embed mos6522_cuda device directly rather than using QOM object link 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" Examining the migration stream it can be seen that the mos6522 device state= is being stored separately rather than as part of the CUDA device which is incorrect (and likely to cause issues if another mos6522 device is added to the machine). Resolve this by embedding the mos6522_cuda device directly within the CUDA device rather than using a QOM object link to reference the device separate= ly. Note that we also bump the version in vmstate_cuda to reflect this change: = this isn't particularly important for the moment as the Mac machine migration is= n't 100% reliable due to issues migrating the timebase under TCG. Signed-off-by: Mark Cave-Ayland --- hw/misc/macio/cuda.c | 44 ++++++++++++++++++----------------------= ---- hw/misc/mos6522.c | 2 +- include/hw/misc/macio/cuda.h | 27 ++++++++++++--------------- include/hw/misc/mos6522.h | 2 ++ 4 files changed, 33 insertions(+), 42 deletions(-) diff --git a/hw/misc/macio/cuda.c b/hw/misc/macio/cuda.c index bd9b862034..8aba2e63ec 100644 --- a/hw/misc/macio/cuda.c +++ b/hw/misc/macio/cuda.c @@ -65,7 +65,7 @@ static void cuda_receive_packet_from_host(CUDAState *s, static uint64_t cuda_get_counter_value(MOS6522State *s, MOS6522Timer *ti) { MOS6522CUDAState *mcs =3D container_of(s, MOS6522CUDAState, parent_obj= ); - CUDAState *cs =3D mcs->cuda; + CUDAState *cs =3D container_of(mcs, CUDAState, mos6522_cuda); =20 /* Reverse of the tb calculation algorithm that Mac OS X uses on bootu= p */ uint64_t tb_diff =3D muldiv64(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL), @@ -78,7 +78,7 @@ static uint64_t cuda_get_counter_value(MOS6522State *s, M= OS6522Timer *ti) static uint64_t cuda_get_load_time(MOS6522State *s, MOS6522Timer *ti) { MOS6522CUDAState *mcs =3D container_of(s, MOS6522CUDAState, parent_obj= ); - CUDAState *cs =3D mcs->cuda; + CUDAState *cs =3D container_of(mcs, CUDAState, mos6522_cuda); =20 uint64_t load_time =3D muldiv64(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL), cs->tb_frequency, NANOSECONDS_PER_SECOND= ); @@ -88,7 +88,7 @@ static uint64_t cuda_get_load_time(MOS6522State *s, MOS65= 22Timer *ti) static void cuda_set_sr_int(void *opaque) { CUDAState *s =3D opaque; - MOS6522CUDAState *mcs =3D s->mos6522_cuda; + MOS6522CUDAState *mcs =3D &s->mos6522_cuda; MOS6522State *ms =3D MOS6522(mcs); MOS6522DeviceClass *mdc =3D MOS6522_DEVICE_GET_CLASS(ms); =20 @@ -97,7 +97,7 @@ static void cuda_set_sr_int(void *opaque) =20 static void cuda_delay_set_sr_int(CUDAState *s) { - MOS6522CUDAState *mcs =3D s->mos6522_cuda; + MOS6522CUDAState *mcs =3D &s->mos6522_cuda; MOS6522State *ms =3D MOS6522(mcs); MOS6522DeviceClass *mdc =3D MOS6522_DEVICE_GET_CLASS(ms); int64_t expire; @@ -117,7 +117,7 @@ static void cuda_delay_set_sr_int(CUDAState *s) /* NOTE: TIP and TREQ are negated */ static void cuda_update(CUDAState *s) { - MOS6522CUDAState *mcs =3D s->mos6522_cuda; + MOS6522CUDAState *mcs =3D &s->mos6522_cuda; MOS6522State *ms =3D MOS6522(mcs); int packet_received, len; =20 @@ -462,7 +462,7 @@ static void cuda_receive_packet_from_host(CUDAState *s, static uint64_t mos6522_cuda_read(void *opaque, hwaddr addr, unsigned size) { CUDAState *s =3D opaque; - MOS6522CUDAState *mcs =3D s->mos6522_cuda; + MOS6522CUDAState *mcs =3D &s->mos6522_cuda; MOS6522State *ms =3D MOS6522(mcs); =20 addr =3D (addr >> 9) & 0xf; @@ -473,7 +473,7 @@ static void mos6522_cuda_write(void *opaque, hwaddr add= r, uint64_t val, unsigned size) { CUDAState *s =3D opaque; - MOS6522CUDAState *mcs =3D s->mos6522_cuda; + MOS6522CUDAState *mcs =3D &s->mos6522_cuda; MOS6522State *ms =3D MOS6522(mcs); =20 addr =3D (addr >> 9) & 0xf; @@ -492,9 +492,11 @@ static const MemoryRegionOps mos6522_cuda_ops =3D { =20 static const VMStateDescription vmstate_cuda =3D { .name =3D "cuda", - .version_id =3D 4, - .minimum_version_id =3D 4, + .version_id =3D 5, + .minimum_version_id =3D 5, .fields =3D (VMStateField[]) { + VMSTATE_STRUCT(mos6522_cuda.parent_obj, CUDAState, 0, vmstate_mos6= 522, + MOS6522State), VMSTATE_UINT8(last_b, CUDAState), VMSTATE_UINT8(last_acr, CUDAState), VMSTATE_INT32(data_in_size, CUDAState), @@ -530,12 +532,8 @@ static void cuda_realize(DeviceState *dev, Error **err= p) DeviceState *d; struct tm tm; =20 - d =3D qdev_create(NULL, TYPE_MOS6522_CUDA); - object_property_set_link(OBJECT(d), OBJECT(s), "cuda", errp); - qdev_init_nofail(d); - s->mos6522_cuda =3D MOS6522_CUDA(d); - /* Pass IRQ from 6522 */ + d =3D DEVICE(&s->mos6522_cuda); ms =3D MOS6522(d); sbd =3D SYS_BUS_DEVICE(s); sysbus_pass_irq(sbd, SYS_BUS_DEVICE(ms)); @@ -556,6 +554,10 @@ static void cuda_init(Object *obj) CUDAState *s =3D CUDA(obj); SysBusDevice *sbd =3D SYS_BUS_DEVICE(obj); =20 + object_initialize(&s->mos6522_cuda, sizeof(s->mos6522_cuda), + TYPE_MOS6522_CUDA); + qdev_set_parent_bus(DEVICE(&s->mos6522_cuda), sysbus_get_default()); + memory_region_init_io(&s->mem, obj, &mos6522_cuda_ops, s, "cuda", 0x20= 00); sysbus_init_mmio(sbd, &s->mem); =20 @@ -590,8 +592,9 @@ static const TypeInfo cuda_type_info =3D { static void mos6522_cuda_portB_write(MOS6522State *s) { MOS6522CUDAState *mcs =3D container_of(s, MOS6522CUDAState, parent_obj= ); + CUDAState *cs =3D container_of(mcs, CUDAState, mos6522_cuda); =20 - cuda_update(mcs->cuda); + cuda_update(cs); } =20 static void mos6522_cuda_realize(DeviceState *dev, Error **errp) @@ -605,16 +608,6 @@ static void mos6522_cuda_realize(DeviceState *dev, Err= or **errp) ms->timers[1].frequency =3D (SCALE_US * 6000) / 4700; } =20 -static void mos6522_cuda_init(Object *obj) -{ - MOS6522CUDAState *s =3D MOS6522_CUDA(obj); - - object_property_add_link(obj, "cuda", TYPE_CUDA, - (Object **) &s->cuda, - qdev_prop_allow_set_link_before_realize, - 0, NULL); -} - static void mos6522_cuda_class_init(ObjectClass *oc, void *data) { DeviceClass *dc =3D DEVICE_CLASS(oc); @@ -632,7 +625,6 @@ static const TypeInfo mos6522_cuda_type_info =3D { .name =3D TYPE_MOS6522_CUDA, .parent =3D TYPE_MOS6522, .instance_size =3D sizeof(MOS6522CUDAState), - .instance_init =3D mos6522_cuda_init, .class_init =3D mos6522_cuda_class_init, }; =20 diff --git a/hw/misc/mos6522.c b/hw/misc/mos6522.c index dd56c796e4..facdaed5d5 100644 --- a/hw/misc/mos6522.c +++ b/hw/misc/mos6522.c @@ -390,7 +390,7 @@ static const VMStateDescription vmstate_mos6522_timer = =3D { } }; =20 -static const VMStateDescription vmstate_mos6522 =3D { +const VMStateDescription vmstate_mos6522 =3D { .name =3D "mos6522", .version_id =3D 0, .minimum_version_id =3D 0, diff --git a/include/hw/misc/macio/cuda.h b/include/hw/misc/macio/cuda.h index 494b709579..7dad469142 100644 --- a/include/hw/misc/macio/cuda.h +++ b/include/hw/misc/macio/cuda.h @@ -54,12 +54,21 @@ #define CUDA_TIMER_TICKLE 0x24 #define CUDA_COMBINED_FORMAT_IIC 0x25 =20 + +/* MOS6522 CUDA */ +typedef struct MOS6522CUDAState { + /*< private >*/ + MOS6522State parent_obj; +} MOS6522CUDAState; + +#define TYPE_MOS6522_CUDA "mos6522-cuda" +#define MOS6522_CUDA(obj) OBJECT_CHECK(MOS6522CUDAState, (obj), \ + TYPE_MOS6522_CUDA) + /* Cuda */ #define TYPE_CUDA "cuda" #define CUDA(obj) OBJECT_CHECK(CUDAState, (obj), TYPE_CUDA) =20 -typedef struct MOS6522CUDAState MOS6522CUDAState; - typedef struct CUDAState { /*< private >*/ SysBusDevice parent_obj; @@ -67,7 +76,7 @@ typedef struct CUDAState { MemoryRegion mem; =20 ADBBusState adb_bus; - MOS6522CUDAState *mos6522_cuda; + MOS6522CUDAState mos6522_cuda; =20 uint32_t tick_offset; uint64_t tb_frequency; @@ -92,16 +101,4 @@ typedef struct CUDAState { QEMUTimer *adb_poll_timer; } CUDAState; =20 -/* MOS6522 CUDA */ -struct MOS6522CUDAState { - /*< private >*/ - MOS6522State parent_obj; - - CUDAState *cuda; -}; - -#define TYPE_MOS6522_CUDA "mos6522-cuda" -#define MOS6522_CUDA(obj) OBJECT_CHECK(MOS6522CUDAState, (obj), \ - TYPE_MOS6522_CUDA) - #endif /* CUDA_H */ diff --git a/include/hw/misc/mos6522.h b/include/hw/misc/mos6522.h index a53c161b00..cb0fd7db78 100644 --- a/include/hw/misc/mos6522.h +++ b/include/hw/misc/mos6522.h @@ -146,6 +146,8 @@ typedef struct MOS6522DeviceClass { #define MOS6522_DEVICE_GET_CLASS(obj) \ OBJECT_GET_CLASS(MOS6522DeviceClass, (obj), TYPE_MOS6522) =20 +extern const VMStateDescription vmstate_mos6522; + uint64_t mos6522_read(void *opaque, hwaddr addr, unsigned size); void mos6522_write(void *opaque, hwaddr addr, uint64_t val, unsigned size); =20 --=20 2.11.0 From nobody Mon May 6 04:28:53 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.zohomail.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 1528392796825660.8433845114397; Thu, 7 Jun 2018 10:33:16 -0700 (PDT) Received: from localhost ([::1]:59485 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQymi-0001YT-4M for importer@patchew.org; Thu, 07 Jun 2018 13:33:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35293) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQyY5-0002WP-H6 for qemu-devel@nongnu.org; Thu, 07 Jun 2018 13:18:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fQyY4-0001nW-H8 for qemu-devel@nongnu.org; Thu, 07 Jun 2018 13:18:09 -0400 Received: from chuckie.co.uk ([82.165.15.123]:44756 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 1fQyY4-0001my-Ap; Thu, 07 Jun 2018 13:18:08 -0400 Received: from [46.233.90.41] (helo=kentang.lan) by s16892447.onlinehome-server.info with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1fQyYG-0007OG-Oz; Thu, 07 Jun 2018 18:18:22 +0100 From: Mark Cave-Ayland To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org, david@gibson.dropbear.id.au Date: Thu, 7 Jun 2018 18:17:50 +0100 Message-Id: <20180607171751.11510-4-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180607171751.11510-1-mark.cave-ayland@ilande.co.uk> References: <20180607171751.11510-1-mark.cave-ayland@ilande.co.uk> X-SA-Exim-Connect-IP: 46.233.90.41 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] [PATCH 3/4] mos6522: move timer frequency initialisation to mos6522_reset 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 6522 VIA timer frequency cannot be set by altering registers within the device itself and hence it is a fixed property of the machine. Move the initialisation of the timer frequency to the mos6522 reset function and ensure that any subclasses always call the parent reset function so that it isn't required to store the timer frequency within vmstate_mos6522_timer itself. By moving the frequency initialisation to the device reset function then we find that the realize function for both mos6522 and mos6522_cuda becomes obsolete and can simply be removed. Signed-off-by: Mark Cave-Ayland --- hw/misc/macio/cuda.c | 6 +++--- hw/misc/mos6522.c | 13 +++---------- include/hw/misc/mos6522.h | 2 +- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/hw/misc/macio/cuda.c b/hw/misc/macio/cuda.c index 8aba2e63ec..9651ed9744 100644 --- a/hw/misc/macio/cuda.c +++ b/hw/misc/macio/cuda.c @@ -597,12 +597,12 @@ static void mos6522_cuda_portB_write(MOS6522State *s) cuda_update(cs); } =20 -static void mos6522_cuda_realize(DeviceState *dev, Error **errp) +static void mos6522_cuda_reset(DeviceState *dev) { MOS6522State *ms =3D MOS6522(dev); MOS6522DeviceClass *mdc =3D MOS6522_DEVICE_GET_CLASS(ms); =20 - mdc->parent_realize(dev, errp); + mdc->parent_reset(dev); =20 ms->timers[0].frequency =3D CUDA_TIMER_FREQ; ms->timers[1].frequency =3D (SCALE_US * 6000) / 4700; @@ -613,7 +613,7 @@ static void mos6522_cuda_class_init(ObjectClass *oc, vo= id *data) DeviceClass *dc =3D DEVICE_CLASS(oc); MOS6522DeviceClass *mdc =3D MOS6522_DEVICE_CLASS(oc); =20 - dc->realize =3D mos6522_cuda_realize; + dc->reset =3D mos6522_cuda_reset; mdc->portB_write =3D mos6522_cuda_portB_write; mdc->get_timer1_counter_value =3D cuda_get_counter_value; mdc->get_timer2_counter_value =3D cuda_get_counter_value; diff --git a/hw/misc/mos6522.c b/hw/misc/mos6522.c index facdaed5d5..d0a0c9e5d9 100644 --- a/hw/misc/mos6522.c +++ b/hw/misc/mos6522.c @@ -427,18 +427,12 @@ static void mos6522_reset(DeviceState *dev) /* s->ier =3D T1_INT | SR_INT; */ s->anh =3D 0; =20 + s->timers[0].frequency =3D s->frequency; s->timers[0].latch =3D 0xffff; set_counter(s, &s->timers[0], 0xffff); =20 - s->timers[1].latch =3D 0xffff; -} - -static void mos6522_realize(DeviceState *dev, Error **errp) -{ - MOS6522State *s =3D MOS6522(dev); - - s->timers[0].frequency =3D s->frequency; s->timers[1].frequency =3D s->frequency; + s->timers[1].latch =3D 0xffff; } =20 static void mos6522_init(Object *obj) @@ -469,11 +463,10 @@ static void mos6522_class_init(ObjectClass *oc, void = *data) DeviceClass *dc =3D DEVICE_CLASS(oc); MOS6522DeviceClass *mdc =3D MOS6522_DEVICE_CLASS(oc); =20 - dc->realize =3D mos6522_realize; dc->reset =3D mos6522_reset; dc->vmsd =3D &vmstate_mos6522; dc->props =3D mos6522_properties; - mdc->parent_realize =3D dc->realize; + mdc->parent_reset =3D dc->reset; mdc->set_sr_int =3D mos6522_set_sr_int; mdc->portB_write =3D mos6522_portB_write; mdc->portA_write =3D mos6522_portA_write; diff --git a/include/hw/misc/mos6522.h b/include/hw/misc/mos6522.h index cb0fd7db78..f52b41920b 100644 --- a/include/hw/misc/mos6522.h +++ b/include/hw/misc/mos6522.h @@ -130,7 +130,7 @@ typedef struct MOS6522State { typedef struct MOS6522DeviceClass { DeviceClass parent_class; =20 - DeviceRealize parent_realize; + DeviceReset parent_reset; void (*set_sr_int)(MOS6522State *dev); void (*portB_write)(MOS6522State *dev); void (*portA_write)(MOS6522State *dev); --=20 2.11.0 From nobody Mon May 6 04:28:53 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.zohomail.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 152839305055966.44263270305532; Thu, 7 Jun 2018 10:37:30 -0700 (PDT) Received: from localhost ([::1]:59504 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQyqe-0005OM-OA for importer@patchew.org; Thu, 07 Jun 2018 13:37:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35325) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQyY7-0002ZE-MM for qemu-devel@nongnu.org; Thu, 07 Jun 2018 13:18:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fQyY6-0001pM-KC for qemu-devel@nongnu.org; Thu, 07 Jun 2018 13:18:11 -0400 Received: from chuckie.co.uk ([82.165.15.123]:44760 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 1fQyY6-0001oZ-Dk; Thu, 07 Jun 2018 13:18:10 -0400 Received: from [46.233.90.41] (helo=kentang.lan) by s16892447.onlinehome-server.info with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1fQyYI-0007OG-Fo; Thu, 07 Jun 2018 18:18:24 +0100 From: Mark Cave-Ayland To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org, david@gibson.dropbear.id.au Date: Thu, 7 Jun 2018 18:17:51 +0100 Message-Id: <20180607171751.11510-5-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180607171751.11510-1-mark.cave-ayland@ilande.co.uk> References: <20180607171751.11510-1-mark.cave-ayland@ilande.co.uk> X-SA-Exim-Connect-IP: 46.233.90.41 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] [PATCH 4/4] mos6522: convert VMSTATE_TIMER_PTR_TEST to VMSTATE_TIMER_PTR 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 timers are configured in the mos6522 init function and therefore will always exist, so the function can never return false. Peter also pointed out that this is the only remaining user of VMSTATE_TIMER_PTR_TEST in the codebase, so we might as well just convert it over to VMSTATE_TIMER_PTR and remove mos6522_timer_exist() as it is no longer required. Signed-off-by: Mark Cave-Ayland Reviewed-by: Peter Maydell --- hw/misc/mos6522.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/hw/misc/mos6522.c b/hw/misc/mos6522.c index d0a0c9e5d9..e9b686ac92 100644 --- a/hw/misc/mos6522.c +++ b/hw/misc/mos6522.c @@ -369,13 +369,6 @@ static const MemoryRegionOps mos6522_ops =3D { }, }; =20 -static bool mos6522_timer_exist(void *opaque, int version_id) -{ - MOS6522Timer *s =3D opaque; - - return s->timer !=3D NULL; -} - static const VMStateDescription vmstate_mos6522_timer =3D { .name =3D "mos6522_timer", .version_id =3D 0, @@ -385,7 +378,7 @@ static const VMStateDescription vmstate_mos6522_timer = =3D { VMSTATE_UINT16(counter_value, MOS6522Timer), VMSTATE_INT64(load_time, MOS6522Timer), VMSTATE_INT64(next_irq_time, MOS6522Timer), - VMSTATE_TIMER_PTR_TEST(timer, MOS6522Timer, mos6522_timer_exist), + VMSTATE_TIMER_PTR(timer, MOS6522Timer), VMSTATE_END_OF_LIST() } }; --=20 2.11.0