summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenoît Canet2011-11-24 14:31:14 +0100
committerAvi Kivity2011-11-28 14:38:42 +0100
commitc65fc1dff328f0964bf148efa3603c4992a609fc (patch)
tree2d60fda0ea8d2c83600f609fa8c2f9dbd9de1f2a
parentmcf_uart: convert to memory API (diff)
downloadqemu-c65fc1dff328f0964bf148efa3603c4992a609fc.tar.gz
qemu-c65fc1dff328f0964bf148efa3603c4992a609fc.tar.xz
qemu-c65fc1dff328f0964bf148efa3603c4992a609fc.zip
mcf_fec: convert to memory API
Signed-off-by: Benoît Canet <benoit.canet@gmail.com> Signed-off-by: Avi Kivity <avi@redhat.com>
-rw-r--r--hw/mcf.h3
-rw-r--r--hw/mcf5208.c3
-rw-r--r--hw/mcf_fec.c38
3 files changed, 23 insertions, 21 deletions
diff --git a/hw/mcf.h b/hw/mcf.h
index e2f6727c57..2f88ff0d4d 100644
--- a/hw/mcf.h
+++ b/hw/mcf.h
@@ -18,7 +18,8 @@ void mcf_uart_mm_init(struct MemoryRegion *sysmem,
qemu_irq *mcf_intc_init(target_phys_addr_t base, CPUState *env);
/* mcf_fec.c */
-void mcf_fec_init(NICInfo *nd, target_phys_addr_t base, qemu_irq *irq);
+void mcf_fec_init(struct MemoryRegion *sysmem, NICInfo *nd,
+ target_phys_addr_t base, qemu_irq *irq);
/* mcf5206.c */
qemu_irq *mcf5206_init(struct MemoryRegion *sysmem,
diff --git a/hw/mcf5208.c b/hw/mcf5208.c
index 0119430b29..e03d80b563 100644
--- a/hw/mcf5208.c
+++ b/hw/mcf5208.c
@@ -234,7 +234,8 @@ static void mcf5208evb_init(ram_addr_t ram_size,
exit(1);
}
if (nd_table[0].vlan)
- mcf_fec_init(&nd_table[0], 0xfc030000, pic + 36);
+ mcf_fec_init(address_space_mem, &nd_table[0],
+ 0xfc030000, pic + 36);
/* 0xfc000000 SCM. */
/* 0xfc004000 XBS. */
diff --git a/hw/mcf_fec.c b/hw/mcf_fec.c
index 42a5d77952..ae37bef0f0 100644
--- a/hw/mcf_fec.c
+++ b/hw/mcf_fec.c
@@ -10,6 +10,7 @@
#include "mcf.h"
/* For crc32 */
#include <zlib.h>
+#include "exec-memory.h"
//#define DEBUG_FEC 1
@@ -23,8 +24,9 @@ do { printf("mcf_fec: " fmt , ## __VA_ARGS__); } while (0)
#define FEC_MAX_FRAME_SIZE 2032
typedef struct {
+ MemoryRegion *sysmem;
+ MemoryRegion iomem;
qemu_irq *irq;
- int mmio_index;
NICState *nic;
NICConf conf;
uint32_t irq_state;
@@ -214,7 +216,8 @@ static void mcf_fec_reset(mcf_fec_state *s)
s->rfsr = 0x500;
}
-static uint32_t mcf_fec_read(void *opaque, target_phys_addr_t addr)
+static uint64_t mcf_fec_read(void *opaque, target_phys_addr_t addr,
+ unsigned size)
{
mcf_fec_state *s = (mcf_fec_state *)opaque;
switch (addr & 0x3ff) {
@@ -251,7 +254,8 @@ static uint32_t mcf_fec_read(void *opaque, target_phys_addr_t addr)
}
}
-static void mcf_fec_write(void *opaque, target_phys_addr_t addr, uint32_t value)
+static void mcf_fec_write(void *opaque, target_phys_addr_t addr,
+ uint64_t value, unsigned size)
{
mcf_fec_state *s = (mcf_fec_state *)opaque;
switch (addr & 0x3ff) {
@@ -429,23 +433,18 @@ static ssize_t mcf_fec_receive(VLANClientState *nc, const uint8_t *buf, size_t s
return size;
}
-static CPUReadMemoryFunc * const mcf_fec_readfn[] = {
- mcf_fec_read,
- mcf_fec_read,
- mcf_fec_read
-};
-
-static CPUWriteMemoryFunc * const mcf_fec_writefn[] = {
- mcf_fec_write,
- mcf_fec_write,
- mcf_fec_write
+static const MemoryRegionOps mcf_fec_ops = {
+ .read = mcf_fec_read,
+ .write = mcf_fec_write,
+ .endianness = DEVICE_NATIVE_ENDIAN,
};
static void mcf_fec_cleanup(VLANClientState *nc)
{
mcf_fec_state *s = DO_UPCAST(NICState, nc, nc)->opaque;
- cpu_unregister_io_memory(s->mmio_index);
+ memory_region_del_subregion(s->sysmem, &s->iomem);
+ memory_region_destroy(&s->iomem);
g_free(s);
}
@@ -458,18 +457,19 @@ static NetClientInfo net_mcf_fec_info = {
.cleanup = mcf_fec_cleanup,
};
-void mcf_fec_init(NICInfo *nd, target_phys_addr_t base, qemu_irq *irq)
+void mcf_fec_init(MemoryRegion *sysmem, NICInfo *nd,
+ target_phys_addr_t base, qemu_irq *irq)
{
mcf_fec_state *s;
qemu_check_nic_model(nd, "mcf_fec");
s = (mcf_fec_state *)g_malloc0(sizeof(mcf_fec_state));
+ s->sysmem = sysmem;
s->irq = irq;
- s->mmio_index = cpu_register_io_memory(mcf_fec_readfn,
- mcf_fec_writefn, s,
- DEVICE_NATIVE_ENDIAN);
- cpu_register_physical_memory(base, 0x400, s->mmio_index);
+
+ memory_region_init_io(&s->iomem, &mcf_fec_ops, s, "fec", 0x400);
+ memory_region_add_subregion(sysmem, base, &s->iomem);
s->conf.macaddr = nd->macaddr;
s->conf.vlan = nd->vlan;