From: "Benoît Canet" <benoit.canet@gmail.com>
To: qemu-devel@nongnu.org
Cc: blauwirbel@gmail.com, "Benoît Canet" <benoit.canet@gmail.com>,
avi@redhat.com
Subject: [Qemu-devel] [PATCH 12/14] slavio_timer: convert to memory API
Date: Tue, 15 Nov 2011 12:14:02 +0100 [thread overview]
Message-ID: <1321355644-1982-13-git-send-email-benoit.canet@gmail.com> (raw)
In-Reply-To: <1321355644-1982-1-git-send-email-benoit.canet@gmail.com>
Signed-off-by: Benoit Canet <benoit.canet@gmail.com>
---
hw/slavio_timer.c | 41 ++++++++++++++++++++---------------------
1 files changed, 20 insertions(+), 21 deletions(-)
diff --git a/hw/slavio_timer.c b/hw/slavio_timer.c
index 84449ba..c23f990 100644
--- a/hw/slavio_timer.c
+++ b/hw/slavio_timer.c
@@ -61,6 +61,7 @@ typedef struct SLAVIO_TIMERState {
} SLAVIO_TIMERState;
typedef struct TimerContext {
+ MemoryRegion iomem;
SLAVIO_TIMERState *s;
unsigned int timer_index; /* 0 for system, 1 ... MAX_CPUS for CPU timers */
} TimerContext;
@@ -128,7 +129,8 @@ static void slavio_timer_irq(void *opaque)
}
}
-static uint32_t slavio_timer_mem_readl(void *opaque, target_phys_addr_t addr)
+static uint64_t slavio_timer_mem_readl(void *opaque, target_phys_addr_t addr,
+ unsigned size)
{
TimerContext *tc = opaque;
SLAVIO_TIMERState *s = tc->s;
@@ -188,7 +190,7 @@ static uint32_t slavio_timer_mem_readl(void *opaque, target_phys_addr_t addr)
}
static void slavio_timer_mem_writel(void *opaque, target_phys_addr_t addr,
- uint32_t val)
+ uint64_t val, unsigned size)
{
TimerContext *tc = opaque;
SLAVIO_TIMERState *s = tc->s;
@@ -311,16 +313,14 @@ static void slavio_timer_mem_writel(void *opaque, target_phys_addr_t addr,
}
}
-static CPUReadMemoryFunc * const slavio_timer_mem_read[3] = {
- NULL,
- NULL,
- slavio_timer_mem_readl,
-};
-
-static CPUWriteMemoryFunc * const slavio_timer_mem_write[3] = {
- NULL,
- NULL,
- slavio_timer_mem_writel,
+static const MemoryRegionOps slavio_timer_mem_ops = {
+ .read = slavio_timer_mem_readl,
+ .write = slavio_timer_mem_writel,
+ .endianness = DEVICE_NATIVE_ENDIAN,
+ .valid = {
+ .min_access_size = 4,
+ .max_access_size = 4,
+ },
};
static const VMStateDescription vmstate_timer = {
@@ -374,13 +374,15 @@ static void slavio_timer_reset(DeviceState *d)
static int slavio_timer_init1(SysBusDevice *dev)
{
- int io;
SLAVIO_TIMERState *s = FROM_SYSBUS(SLAVIO_TIMERState, dev);
QEMUBH *bh;
unsigned int i;
TimerContext *tc;
for (i = 0; i <= MAX_CPUS; i++) {
+ uint64_t size;
+ char timer_name[20];
+
tc = g_malloc0(sizeof(TimerContext));
tc->s = s;
tc->timer_index = i;
@@ -389,14 +391,11 @@ static int slavio_timer_init1(SysBusDevice *dev)
s->cputimer[i].timer = ptimer_init(bh);
ptimer_set_period(s->cputimer[i].timer, TIMER_PERIOD);
- io = cpu_register_io_memory(slavio_timer_mem_read,
- slavio_timer_mem_write, tc,
- DEVICE_NATIVE_ENDIAN);
- if (i == 0) {
- sysbus_init_mmio(dev, SYS_TIMER_SIZE, io);
- } else {
- sysbus_init_mmio(dev, CPU_TIMER_SIZE, io);
- }
+ size = i == 0 ? SYS_TIMER_SIZE : CPU_TIMER_SIZE;
+ snprintf(timer_name, sizeof(timer_name), "timer-%i", i);
+ memory_region_init_io(&tc->iomem, &slavio_timer_mem_ops, tc,
+ timer_name, size);
+ sysbus_init_mmio_region(dev, &tc->iomem);
sysbus_init_irq(dev, &s->cputimer[i].irq);
}
--
1.7.5.4
next prev parent reply other threads:[~2011-11-15 11:14 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-15 11:13 [Qemu-devel] [PATCH 00/14] Convert Sun devices to memory API Benoît Canet
2011-11-15 11:13 ` [Qemu-devel] [PATCH 01/14] slavio_misc: convert apc " Benoît Canet
2011-11-15 11:13 ` [Qemu-devel] [PATCH 02/14] slavio_misc: convert configuration " Benoît Canet
2011-11-15 11:13 ` [Qemu-devel] [PATCH 03/14] slavio_misc: convert diagnostic " Benoît Canet
2011-11-15 11:13 ` [Qemu-devel] [PATCH 04/14] slavio_misc: convert modem " Benoît Canet
2011-11-15 11:13 ` [Qemu-devel] [PATCH 05/14] slavio_misc: convert leds " Benoît Canet
2011-11-15 11:13 ` [Qemu-devel] [PATCH 06/14] slavio_misc: convert system control " Benoît Canet
2011-11-15 11:13 ` [Qemu-devel] [PATCH 07/14] slavio_misc: convert aux1 " Benoît Canet
2011-11-15 11:13 ` [Qemu-devel] [PATCH 08/14] slavio_misc: convert aux2 " Benoît Canet
2011-11-15 11:13 ` [Qemu-devel] [PATCH 09/14] slavio_intctl: convert master interrupt controller " Benoît Canet
2011-11-15 11:14 ` [Qemu-devel] [PATCH 10/14] slavio_intctl: convert slaves interrupt controllers " Benoît Canet
2011-11-15 11:14 ` [Qemu-devel] [PATCH 11/14] sun4c_intctl: convert " Benoît Canet
2011-11-15 11:14 ` Benoît Canet [this message]
2011-11-15 11:14 ` [Qemu-devel] [PATCH 13/14] sun4m_iommu: " Benoît Canet
2011-11-15 11:14 ` [Qemu-devel] [PATCH 14/14] esp: Fix memory API conversion Benoît Canet
2011-11-15 12:20 ` [Qemu-devel] [PATCH 00/14] Convert Sun devices to memory API Avi Kivity
2011-11-15 15:22 ` Benoît Canet
2011-11-15 17:48 ` Avi Kivity
2011-11-15 20:03 ` Benoît Canet
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1321355644-1982-13-git-send-email-benoit.canet@gmail.com \
--to=benoit.canet@gmail.com \
--cc=avi@redhat.com \
--cc=blauwirbel@gmail.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.