r2d: convert to memory API
Signed-off-by: Avi Kivity <avi@redhat.com>
This commit is contained in:
parent
2646c133b5
commit
5dea2efb3b
35
hw/r2d.c
35
hw/r2d.c
@ -82,6 +82,7 @@ typedef struct {
|
|||||||
|
|
||||||
/* output pin */
|
/* output pin */
|
||||||
qemu_irq irl;
|
qemu_irq irl;
|
||||||
|
MemoryRegion iomem;
|
||||||
} r2d_fpga_t;
|
} r2d_fpga_t;
|
||||||
|
|
||||||
enum r2d_fpga_irq {
|
enum r2d_fpga_irq {
|
||||||
@ -168,31 +169,25 @@ r2d_fpga_write(void *opaque, target_phys_addr_t addr, uint32_t value)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static CPUReadMemoryFunc * const r2d_fpga_readfn[] = {
|
static const MemoryRegionOps r2d_fpga_ops = {
|
||||||
r2d_fpga_read,
|
.old_mmio = {
|
||||||
r2d_fpga_read,
|
.read = { r2d_fpga_read, r2d_fpga_read, NULL, },
|
||||||
NULL,
|
.write = { r2d_fpga_write, r2d_fpga_write, NULL, },
|
||||||
|
},
|
||||||
|
.endianness = DEVICE_NATIVE_ENDIAN,
|
||||||
};
|
};
|
||||||
|
|
||||||
static CPUWriteMemoryFunc * const r2d_fpga_writefn[] = {
|
static qemu_irq *r2d_fpga_init(MemoryRegion *sysmem,
|
||||||
r2d_fpga_write,
|
target_phys_addr_t base, qemu_irq irl)
|
||||||
r2d_fpga_write,
|
|
||||||
NULL,
|
|
||||||
};
|
|
||||||
|
|
||||||
static qemu_irq *r2d_fpga_init(target_phys_addr_t base, qemu_irq irl)
|
|
||||||
{
|
{
|
||||||
int iomemtype;
|
|
||||||
r2d_fpga_t *s;
|
r2d_fpga_t *s;
|
||||||
|
|
||||||
s = g_malloc0(sizeof(r2d_fpga_t));
|
s = g_malloc0(sizeof(r2d_fpga_t));
|
||||||
|
|
||||||
s->irl = irl;
|
s->irl = irl;
|
||||||
|
|
||||||
iomemtype = cpu_register_io_memory(r2d_fpga_readfn,
|
memory_region_init_io(&s->iomem, &r2d_fpga_ops, s, "r2d-fpga", 0x40);
|
||||||
r2d_fpga_writefn, s,
|
memory_region_add_subregion(sysmem, base, &s->iomem);
|
||||||
DEVICE_NATIVE_ENDIAN);
|
|
||||||
cpu_register_physical_memory(base, 0x40, iomemtype);
|
|
||||||
return qemu_allocate_irqs(r2d_fpga_irq_set, s, NR_IRQS);
|
return qemu_allocate_irqs(r2d_fpga_irq_set, s, NR_IRQS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -232,7 +227,7 @@ static void r2d_init(ram_addr_t ram_size,
|
|||||||
CPUState *env;
|
CPUState *env;
|
||||||
ResetData *reset_info;
|
ResetData *reset_info;
|
||||||
struct SH7750State *s;
|
struct SH7750State *s;
|
||||||
ram_addr_t sdram_addr;
|
MemoryRegion *sdram = g_new(MemoryRegion, 1);
|
||||||
qemu_irq *irq;
|
qemu_irq *irq;
|
||||||
DriveInfo *dinfo;
|
DriveInfo *dinfo;
|
||||||
int i;
|
int i;
|
||||||
@ -252,11 +247,11 @@ static void r2d_init(ram_addr_t ram_size,
|
|||||||
qemu_register_reset(main_cpu_reset, reset_info);
|
qemu_register_reset(main_cpu_reset, reset_info);
|
||||||
|
|
||||||
/* Allocate memory space */
|
/* Allocate memory space */
|
||||||
sdram_addr = qemu_ram_alloc(NULL, "r2d.sdram", SDRAM_SIZE);
|
memory_region_init_ram(sdram, NULL, "r2d.sdram", SDRAM_SIZE);
|
||||||
cpu_register_physical_memory(SDRAM_BASE, SDRAM_SIZE, sdram_addr);
|
memory_region_add_subregion(address_space_mem, SDRAM_BASE, sdram);
|
||||||
/* Register peripherals */
|
/* Register peripherals */
|
||||||
s = sh7750_init(env);
|
s = sh7750_init(env);
|
||||||
irq = r2d_fpga_init(0x04000000, sh7750_irl(s));
|
irq = r2d_fpga_init(address_space_mem, 0x04000000, sh7750_irl(s));
|
||||||
sysbus_create_varargs("sh_pci", 0x1e200000, irq[PCI_INTA], irq[PCI_INTB],
|
sysbus_create_varargs("sh_pci", 0x1e200000, irq[PCI_INTA], irq[PCI_INTB],
|
||||||
irq[PCI_INTC], irq[PCI_INTD], NULL);
|
irq[PCI_INTC], irq[PCI_INTD], NULL);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user