eccmemctl: convert to memory API

Signed-off-by: Avi Kivity <avi@redhat.com>
This commit is contained in:
Avi Kivity 2011-11-14 11:17:21 +02:00
parent b0a941b02a
commit 7ef57cca57
1 changed files with 30 additions and 33 deletions

View File

@ -122,13 +122,15 @@
typedef struct ECCState { typedef struct ECCState {
SysBusDevice busdev; SysBusDevice busdev;
MemoryRegion iomem, iomem_diag;
qemu_irq irq; qemu_irq irq;
uint32_t regs[ECC_NREGS]; uint32_t regs[ECC_NREGS];
uint8_t diag[ECC_DIAG_SIZE]; uint8_t diag[ECC_DIAG_SIZE];
uint32_t version; uint32_t version;
} ECCState; } ECCState;
static void ecc_mem_writel(void *opaque, target_phys_addr_t addr, uint32_t val) static void ecc_mem_write(void *opaque, target_phys_addr_t addr, uint64_t val,
unsigned size)
{ {
ECCState *s = opaque; ECCState *s = opaque;
@ -170,7 +172,8 @@ static void ecc_mem_writel(void *opaque, target_phys_addr_t addr, uint32_t val)
} }
} }
static uint32_t ecc_mem_readl(void *opaque, target_phys_addr_t addr) static uint64_t ecc_mem_read(void *opaque, target_phys_addr_t addr,
unsigned size)
{ {
ECCState *s = opaque; ECCState *s = opaque;
uint32_t ret = 0; uint32_t ret = 0;
@ -216,20 +219,18 @@ static uint32_t ecc_mem_readl(void *opaque, target_phys_addr_t addr)
return ret; return ret;
} }
static CPUReadMemoryFunc * const ecc_mem_read[3] = { static const MemoryRegionOps ecc_mem_ops = {
NULL, .read = ecc_mem_read,
NULL, .write = ecc_mem_write,
ecc_mem_readl, .endianness = DEVICE_NATIVE_ENDIAN,
.valid = {
.min_access_size = 4,
.max_access_size = 4,
},
}; };
static CPUWriteMemoryFunc * const ecc_mem_write[3] = { static void ecc_diag_mem_write(void *opaque, target_phys_addr_t addr,
NULL, uint64_t val, unsigned size)
NULL,
ecc_mem_writel,
};
static void ecc_diag_mem_writeb(void *opaque, target_phys_addr_t addr,
uint32_t val)
{ {
ECCState *s = opaque; ECCState *s = opaque;
@ -237,7 +238,8 @@ static void ecc_diag_mem_writeb(void *opaque, target_phys_addr_t addr,
s->diag[addr & ECC_DIAG_MASK] = val; s->diag[addr & ECC_DIAG_MASK] = val;
} }
static uint32_t ecc_diag_mem_readb(void *opaque, target_phys_addr_t addr) static uint64_t ecc_diag_mem_read(void *opaque, target_phys_addr_t addr,
unsigned size)
{ {
ECCState *s = opaque; ECCState *s = opaque;
uint32_t ret = s->diag[(int)addr]; uint32_t ret = s->diag[(int)addr];
@ -246,16 +248,14 @@ static uint32_t ecc_diag_mem_readb(void *opaque, target_phys_addr_t addr)
return ret; return ret;
} }
static CPUReadMemoryFunc * const ecc_diag_mem_read[3] = { static const MemoryRegionOps ecc_diag_mem_ops = {
ecc_diag_mem_readb, .read = ecc_diag_mem_read,
NULL, .write = ecc_diag_mem_write,
NULL, .endianness = DEVICE_NATIVE_ENDIAN,
}; .valid = {
.min_access_size = 1,
static CPUWriteMemoryFunc * const ecc_diag_mem_write[3] = { .max_access_size = 1,
ecc_diag_mem_writeb, },
NULL,
NULL,
}; };
static const VMStateDescription vmstate_ecc = { static const VMStateDescription vmstate_ecc = {
@ -292,20 +292,17 @@ static void ecc_reset(DeviceState *d)
static int ecc_init1(SysBusDevice *dev) static int ecc_init1(SysBusDevice *dev)
{ {
int ecc_io_memory;
ECCState *s = FROM_SYSBUS(ECCState, dev); ECCState *s = FROM_SYSBUS(ECCState, dev);
sysbus_init_irq(dev, &s->irq); sysbus_init_irq(dev, &s->irq);
s->regs[0] = s->version; s->regs[0] = s->version;
ecc_io_memory = cpu_register_io_memory(ecc_mem_read, ecc_mem_write, s, memory_region_init_io(&s->iomem, &ecc_mem_ops, s, "ecc", ECC_SIZE);
DEVICE_NATIVE_ENDIAN); sysbus_init_mmio_region(dev, &s->iomem);
sysbus_init_mmio(dev, ECC_SIZE, ecc_io_memory);
if (s->version == ECC_MCC) { // SS-600MP only if (s->version == ECC_MCC) { // SS-600MP only
ecc_io_memory = cpu_register_io_memory(ecc_diag_mem_read, memory_region_init_io(&s->iomem_diag, &ecc_diag_mem_ops, s,
ecc_diag_mem_write, s, "ecc.diag", ECC_DIAG_SIZE);
DEVICE_NATIVE_ENDIAN); sysbus_init_mmio_region(dev, &s->iomem_diag);
sysbus_init_mmio(dev, ECC_DIAG_SIZE, ecc_io_memory);
} }
return 0; return 0;