mirror of https://gitee.com/openkylin/qemu.git
milkymist-softusb: convert to memory API
Reviewed-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Avi Kivity <avi@redhat.com>
This commit is contained in:
parent
906d23eb0d
commit
fcb9fc24c4
|
@ -49,6 +49,9 @@ struct MilkymistSoftUsbState {
|
||||||
HIDState hid_kbd;
|
HIDState hid_kbd;
|
||||||
HIDState hid_mouse;
|
HIDState hid_mouse;
|
||||||
|
|
||||||
|
MemoryRegion regs_region;
|
||||||
|
MemoryRegion pmem;
|
||||||
|
MemoryRegion dmem;
|
||||||
qemu_irq irq;
|
qemu_irq irq;
|
||||||
|
|
||||||
/* device properties */
|
/* device properties */
|
||||||
|
@ -68,7 +71,8 @@ struct MilkymistSoftUsbState {
|
||||||
};
|
};
|
||||||
typedef struct MilkymistSoftUsbState MilkymistSoftUsbState;
|
typedef struct MilkymistSoftUsbState MilkymistSoftUsbState;
|
||||||
|
|
||||||
static uint32_t softusb_read(void *opaque, target_phys_addr_t addr)
|
static uint64_t softusb_read(void *opaque, target_phys_addr_t addr,
|
||||||
|
unsigned size)
|
||||||
{
|
{
|
||||||
MilkymistSoftUsbState *s = opaque;
|
MilkymistSoftUsbState *s = opaque;
|
||||||
uint32_t r = 0;
|
uint32_t r = 0;
|
||||||
|
@ -91,7 +95,8 @@ static uint32_t softusb_read(void *opaque, target_phys_addr_t addr)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
softusb_write(void *opaque, target_phys_addr_t addr, uint32_t value)
|
softusb_write(void *opaque, target_phys_addr_t addr, uint64_t value,
|
||||||
|
unsigned size)
|
||||||
{
|
{
|
||||||
MilkymistSoftUsbState *s = opaque;
|
MilkymistSoftUsbState *s = opaque;
|
||||||
|
|
||||||
|
@ -110,16 +115,14 @@ softusb_write(void *opaque, target_phys_addr_t addr, uint32_t value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static CPUReadMemoryFunc * const softusb_read_fn[] = {
|
static const MemoryRegionOps softusb_mmio_ops = {
|
||||||
NULL,
|
.read = softusb_read,
|
||||||
NULL,
|
.write = softusb_write,
|
||||||
&softusb_read,
|
.endianness = DEVICE_NATIVE_ENDIAN,
|
||||||
};
|
.valid = {
|
||||||
|
.min_access_size = 4,
|
||||||
static CPUWriteMemoryFunc * const softusb_write_fn[] = {
|
.max_access_size = 4,
|
||||||
NULL,
|
},
|
||||||
NULL,
|
|
||||||
&softusb_write,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline void softusb_read_dmem(MilkymistSoftUsbState *s,
|
static inline void softusb_read_dmem(MilkymistSoftUsbState *s,
|
||||||
|
@ -256,23 +259,20 @@ static void milkymist_softusb_reset(DeviceState *d)
|
||||||
static int milkymist_softusb_init(SysBusDevice *dev)
|
static int milkymist_softusb_init(SysBusDevice *dev)
|
||||||
{
|
{
|
||||||
MilkymistSoftUsbState *s = FROM_SYSBUS(typeof(*s), dev);
|
MilkymistSoftUsbState *s = FROM_SYSBUS(typeof(*s), dev);
|
||||||
int softusb_regs;
|
|
||||||
ram_addr_t pmem_ram;
|
|
||||||
ram_addr_t dmem_ram;
|
|
||||||
|
|
||||||
sysbus_init_irq(dev, &s->irq);
|
sysbus_init_irq(dev, &s->irq);
|
||||||
|
|
||||||
softusb_regs = cpu_register_io_memory(softusb_read_fn, softusb_write_fn, s,
|
memory_region_init_io(&s->regs_region, &softusb_mmio_ops, s,
|
||||||
DEVICE_NATIVE_ENDIAN);
|
"milkymist-softusb", R_MAX * 4);
|
||||||
sysbus_init_mmio(dev, R_MAX * 4, softusb_regs);
|
sysbus_init_mmio_region(dev, &s->regs_region);
|
||||||
|
|
||||||
/* register pmem and dmem */
|
/* register pmem and dmem */
|
||||||
pmem_ram = qemu_ram_alloc(NULL, "milkymist_softusb.pmem", s->pmem_size);
|
memory_region_init_ram(&s->pmem, NULL, "milkymist_softusb.pmem",
|
||||||
cpu_register_physical_memory(s->pmem_base, s->pmem_size,
|
s->pmem_size);
|
||||||
pmem_ram | IO_MEM_RAM);
|
sysbus_add_memory(dev, s->pmem_base, &s->pmem);
|
||||||
dmem_ram = qemu_ram_alloc(NULL, "milkymist_softusb.dmem", s->dmem_size);
|
memory_region_init_ram(&s->dmem, NULL, "milkymist_softusb.dmem",
|
||||||
cpu_register_physical_memory(s->dmem_base, s->dmem_size,
|
s->dmem_size);
|
||||||
dmem_ram | IO_MEM_RAM);
|
sysbus_add_memory(dev, s->dmem_base, &s->dmem);
|
||||||
|
|
||||||
hid_init(&s->hid_kbd, HID_KEYBOARD, softusb_kbd_hid_datain);
|
hid_init(&s->hid_kbd, HID_KEYBOARD, softusb_kbd_hid_datain);
|
||||||
hid_init(&s->hid_mouse, HID_MOUSE, softusb_mouse_hid_datain);
|
hid_init(&s->hid_mouse, HID_MOUSE, softusb_mouse_hid_datain);
|
||||||
|
|
Loading…
Reference in New Issue