[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [PULL 20/33] mos6522: move timer frequency initialisation to
From: |
David Gibson |
Subject: |
[Qemu-ppc] [PULL 20/33] mos6522: move timer frequency initialisation to mos6522_reset |
Date: |
Tue, 12 Jun 2018 16:44:50 +1000 |
From: Mark Cave-Ayland <address@hidden>
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 <address@hidden>
Signed-off-by: David Gibson <address@hidden>
---
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);
}
-static void mos6522_cuda_realize(DeviceState *dev, Error **errp)
+static void mos6522_cuda_reset(DeviceState *dev)
{
MOS6522State *ms = MOS6522(dev);
MOS6522DeviceClass *mdc = MOS6522_DEVICE_GET_CLASS(ms);
- mdc->parent_realize(dev, errp);
+ mdc->parent_reset(dev);
ms->timers[0].frequency = CUDA_TIMER_FREQ;
ms->timers[1].frequency = (SCALE_US * 6000) / 4700;
@@ -613,7 +613,7 @@ static void mos6522_cuda_class_init(ObjectClass *oc, void
*data)
DeviceClass *dc = DEVICE_CLASS(oc);
MOS6522DeviceClass *mdc = MOS6522_DEVICE_CLASS(oc);
- dc->realize = mos6522_cuda_realize;
+ dc->reset = mos6522_cuda_reset;
mdc->portB_write = mos6522_cuda_portB_write;
mdc->get_timer1_counter_value = cuda_get_counter_value;
mdc->get_timer2_counter_value = cuda_get_counter_value;
diff --git a/hw/misc/mos6522.c b/hw/misc/mos6522.c
index 524a250329..2f58b9707f 100644
--- a/hw/misc/mos6522.c
+++ b/hw/misc/mos6522.c
@@ -427,18 +427,12 @@ static void mos6522_reset(DeviceState *dev)
/* s->ier = T1_INT | SR_INT; */
s->anh = 0;
+ s->timers[0].frequency = s->frequency;
s->timers[0].latch = 0xffff;
set_counter(s, &s->timers[0], 0xffff);
- s->timers[1].latch = 0xffff;
-}
-
-static void mos6522_realize(DeviceState *dev, Error **errp)
-{
- MOS6522State *s = MOS6522(dev);
-
- s->timers[0].frequency = s->frequency;
s->timers[1].frequency = s->frequency;
+ s->timers[1].latch = 0xffff;
}
static void mos6522_init(Object *obj)
@@ -469,11 +463,10 @@ static void mos6522_class_init(ObjectClass *oc, void
*data)
DeviceClass *dc = DEVICE_CLASS(oc);
MOS6522DeviceClass *mdc = MOS6522_DEVICE_CLASS(oc);
- dc->realize = mos6522_realize;
dc->reset = mos6522_reset;
dc->vmsd = &vmstate_mos6522;
dc->props = mos6522_properties;
- mdc->parent_realize = dc->realize;
+ mdc->parent_reset = dc->reset;
mdc->set_sr_int = mos6522_set_sr_int;
mdc->portB_write = mos6522_portB_write;
mdc->portA_write = 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;
- DeviceRealize parent_realize;
+ DeviceReset parent_reset;
void (*set_sr_int)(MOS6522State *dev);
void (*portB_write)(MOS6522State *dev);
void (*portA_write)(MOS6522State *dev);
--
2.17.1
- [Qemu-ppc] [PULL 13/33] MAINTAINERS: Add entries for the MOS6522 VIA device, (continued)
- [Qemu-ppc] [PULL 13/33] MAINTAINERS: Add entries for the MOS6522 VIA device, David Gibson, 2018/06/12
- [Qemu-ppc] [PULL 09/33] target/ppc: Allow privileged access to SPR_PCR, David Gibson, 2018/06/12
- [Qemu-ppc] [PULL 04/33] hw/ppc/spapr_drc: Replace error_setg(&error_abort) by error_report() + abort(), David Gibson, 2018/06/12
- [Qemu-ppc] [PULL 06/33] 40p: remove pci_allow_0_address = true from 40p machine class, David Gibson, 2018/06/12
- [Qemu-ppc] [PULL 05/33] target/ppc: Use proper logging function for possible guest errors, David Gibson, 2018/06/12
- [Qemu-ppc] [PULL 08/33] target/ppc: Factor out the parsing in kvmppc_get_cpu_characteristics(), David Gibson, 2018/06/12
- [Qemu-ppc] [PULL 16/33] ppc: remove obsolete macio_init() definition from mac.h, David Gibson, 2018/06/12
- [Qemu-ppc] [PULL 15/33] ppc: remove obsolete pci_pmac_init() definitions from mac.h, David Gibson, 2018/06/12
- [Qemu-ppc] [PULL 17/33] ppc: add missing FW_CFG_PPC_NVRAM_FLAT definition, David Gibson, 2018/06/12
- [Qemu-ppc] [PULL 14/33] hw/misc/mos6522: Add trailing '\n' to qemu_log() calls, David Gibson, 2018/06/12
- [Qemu-ppc] [PULL 20/33] mos6522: move timer frequency initialisation to mos6522_reset,
David Gibson <=
- [Qemu-ppc] [PULL 12/33] MAINTAINERS: Add an entry for the MacIO device headers, David Gibson, 2018/06/12
- [Qemu-ppc] [PULL 19/33] cuda: embed mos6522_cuda device directly rather than using QOM object link, David Gibson, 2018/06/12
- [Qemu-ppc] [PULL 22/33] target/ppc: extend eieio for POWER9, David Gibson, 2018/06/12
- [Qemu-ppc] [PULL 18/33] mos6522: fix vmstate_mos6522_timer version in vmstate_mos6522, David Gibson, 2018/06/12
- [Qemu-ppc] [PULL 29/33] spapr: handle pc-dimm unplug via hotplug handler chain, David Gibson, 2018/06/12
- [Qemu-ppc] [PULL 30/33] spapr: handle cpu core unplug via hotplug handler chain, David Gibson, 2018/06/12
- [Qemu-ppc] [PULL 31/33] ppc/pnv: fix LPC HC firmware address space, David Gibson, 2018/06/12
- [Qemu-ppc] [PULL 21/33] mos6522: convert VMSTATE_TIMER_PTR_TEST to VMSTATE_TIMER_PTR, David Gibson, 2018/06/12
- [Qemu-ppc] [PULL 26/33] spapr: move lookup of the node into spapr_memory_plug(), David Gibson, 2018/06/12
- [Qemu-ppc] [PULL 33/33] spapr_pci: Remove unhelpful pagesize warning, David Gibson, 2018/06/12