milkymist-memcard: convert to memory API

Signed-off-by: Michael Walle <michael@walle.cc>
Signed-off-by: Avi Kivity <avi@redhat.com>
This commit is contained in:
Michael Walle 2011-08-31 16:48:41 +02:00 committed by Avi Kivity
parent 321c17ae97
commit 8c85d15b3f

View File

@ -60,6 +60,7 @@ enum {
struct MilkymistMemcardState {
SysBusDevice busdev;
MemoryRegion regs_region;
SDState *card;
int command_write_ptr;
@ -116,7 +117,8 @@ static void memcard_sd_command(MilkymistMemcardState *s)
}
}
static uint32_t memcard_read(void *opaque, target_phys_addr_t addr)
static uint64_t memcard_read(void *opaque, target_phys_addr_t addr,
unsigned size)
{
MilkymistMemcardState *s = opaque;
uint32_t r = 0;
@ -164,7 +166,8 @@ static uint32_t memcard_read(void *opaque, target_phys_addr_t addr)
return r;
}
static void memcard_write(void *opaque, target_phys_addr_t addr, uint32_t value)
static void memcard_write(void *opaque, target_phys_addr_t addr, uint64_t value,
unsigned size)
{
MilkymistMemcardState *s = opaque;
@ -216,16 +219,14 @@ static void memcard_write(void *opaque, target_phys_addr_t addr, uint32_t value)
}
}
static CPUReadMemoryFunc * const memcard_read_fn[] = {
NULL,
NULL,
&memcard_read,
};
static CPUWriteMemoryFunc * const memcard_write_fn[] = {
NULL,
NULL,
&memcard_write,
static const MemoryRegionOps memcard_mmio_ops = {
.read = memcard_read,
.write = memcard_write,
.valid = {
.min_access_size = 4,
.max_access_size = 4,
},
.endianness = DEVICE_NATIVE_ENDIAN,
};
static void milkymist_memcard_reset(DeviceState *d)
@ -247,15 +248,14 @@ static int milkymist_memcard_init(SysBusDevice *dev)
{
MilkymistMemcardState *s = FROM_SYSBUS(typeof(*s), dev);
DriveInfo *dinfo;
int memcard_regs;
dinfo = drive_get_next(IF_SD);
s->card = sd_init(dinfo ? dinfo->bdrv : NULL, 0);
s->enabled = dinfo ? bdrv_is_inserted(dinfo->bdrv) : 0;
memcard_regs = cpu_register_io_memory(memcard_read_fn, memcard_write_fn, s,
DEVICE_NATIVE_ENDIAN);
sysbus_init_mmio(dev, R_MAX * 4, memcard_regs);
memory_region_init_io(&s->regs_region, &memcard_mmio_ops, s,
"milkymist-memcard", R_MAX * 4);
sysbus_init_mmio_region(dev, &s->regs_region);
return 0;
}