mirror of https://github.com/xemu-project/xemu.git
lm32_sys: convert to memory API
Signed-off-by: Benoît Canet <benoit.canet@gmail.com> Signed-off-by: Avi Kivity <avi@redhat.com>
This commit is contained in:
parent
5f2be17af1
commit
0aa27efa93
|
@ -47,6 +47,7 @@ enum {
|
||||||
|
|
||||||
struct LM32SysState {
|
struct LM32SysState {
|
||||||
SysBusDevice busdev;
|
SysBusDevice busdev;
|
||||||
|
MemoryRegion iomem;
|
||||||
uint32_t base;
|
uint32_t base;
|
||||||
uint32_t regs[R_MAX];
|
uint32_t regs[R_MAX];
|
||||||
uint8_t testname[MAX_TESTNAME_LEN];
|
uint8_t testname[MAX_TESTNAME_LEN];
|
||||||
|
@ -60,7 +61,8 @@ static void copy_testname(LM32SysState *s)
|
||||||
s->testname[MAX_TESTNAME_LEN - 1] = '\0';
|
s->testname[MAX_TESTNAME_LEN - 1] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sys_write(void *opaque, target_phys_addr_t addr, uint32_t value)
|
static void sys_write(void *opaque, target_phys_addr_t addr,
|
||||||
|
uint64_t value, unsigned size)
|
||||||
{
|
{
|
||||||
LM32SysState *s = opaque;
|
LM32SysState *s = opaque;
|
||||||
char *testname;
|
char *testname;
|
||||||
|
@ -89,16 +91,16 @@ static void sys_write(void *opaque, target_phys_addr_t addr, uint32_t value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static CPUReadMemoryFunc * const sys_read_fn[] = {
|
static bool sys_ops_accepts(void *opaque, target_phys_addr_t addr,
|
||||||
NULL,
|
unsigned size, bool is_write)
|
||||||
NULL,
|
{
|
||||||
NULL,
|
return is_write && size == 4;
|
||||||
};
|
}
|
||||||
|
|
||||||
static CPUWriteMemoryFunc * const sys_write_fn[] = {
|
static const MemoryRegionOps sys_ops = {
|
||||||
NULL,
|
.write = sys_write,
|
||||||
NULL,
|
.valid.accepts = sys_ops_accepts,
|
||||||
&sys_write,
|
.endianness = DEVICE_NATIVE_ENDIAN,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void sys_reset(DeviceState *d)
|
static void sys_reset(DeviceState *d)
|
||||||
|
@ -115,11 +117,9 @@ static void sys_reset(DeviceState *d)
|
||||||
static int lm32_sys_init(SysBusDevice *dev)
|
static int lm32_sys_init(SysBusDevice *dev)
|
||||||
{
|
{
|
||||||
LM32SysState *s = FROM_SYSBUS(typeof(*s), dev);
|
LM32SysState *s = FROM_SYSBUS(typeof(*s), dev);
|
||||||
int sys_regs;
|
|
||||||
|
|
||||||
sys_regs = cpu_register_io_memory(sys_read_fn, sys_write_fn, s,
|
memory_region_init_io(&s->iomem, &sys_ops , s, "sys", R_MAX * 4);
|
||||||
DEVICE_NATIVE_ENDIAN);
|
sysbus_init_mmio_region(dev, &s->iomem);
|
||||||
sysbus_init_mmio(dev, R_MAX * 4, sys_regs);
|
|
||||||
|
|
||||||
/* Note: This device is not created in the board initialization,
|
/* Note: This device is not created in the board initialization,
|
||||||
* instead it has to be added with the -device parameter. Therefore,
|
* instead it has to be added with the -device parameter. Therefore,
|
||||||
|
|
Loading…
Reference in New Issue