mirror of
https://git.proxmox.com/git/qemu
synced 2025-08-06 10:35:20 +00:00
milkymist-uart: 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:
parent
7100453f2e
commit
5adb30d38b
@ -35,7 +35,9 @@ enum {
|
|||||||
|
|
||||||
struct MilkymistUartState {
|
struct MilkymistUartState {
|
||||||
SysBusDevice busdev;
|
SysBusDevice busdev;
|
||||||
|
MemoryRegion regs_region;
|
||||||
CharDriverState *chr;
|
CharDriverState *chr;
|
||||||
|
|
||||||
qemu_irq rx_irq;
|
qemu_irq rx_irq;
|
||||||
qemu_irq tx_irq;
|
qemu_irq tx_irq;
|
||||||
|
|
||||||
@ -43,7 +45,8 @@ struct MilkymistUartState {
|
|||||||
};
|
};
|
||||||
typedef struct MilkymistUartState MilkymistUartState;
|
typedef struct MilkymistUartState MilkymistUartState;
|
||||||
|
|
||||||
static uint32_t uart_read(void *opaque, target_phys_addr_t addr)
|
static uint64_t uart_read(void *opaque, target_phys_addr_t addr,
|
||||||
|
unsigned size)
|
||||||
{
|
{
|
||||||
MilkymistUartState *s = opaque;
|
MilkymistUartState *s = opaque;
|
||||||
uint32_t r = 0;
|
uint32_t r = 0;
|
||||||
@ -66,7 +69,8 @@ static uint32_t uart_read(void *opaque, target_phys_addr_t addr)
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void uart_write(void *opaque, target_phys_addr_t addr, uint32_t value)
|
static void uart_write(void *opaque, target_phys_addr_t addr, uint64_t value,
|
||||||
|
unsigned size)
|
||||||
{
|
{
|
||||||
MilkymistUartState *s = opaque;
|
MilkymistUartState *s = opaque;
|
||||||
unsigned char ch = value;
|
unsigned char ch = value;
|
||||||
@ -93,16 +97,14 @@ static void uart_write(void *opaque, target_phys_addr_t addr, uint32_t value)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static CPUReadMemoryFunc * const uart_read_fn[] = {
|
static const MemoryRegionOps uart_mmio_ops = {
|
||||||
NULL,
|
.read = uart_read,
|
||||||
NULL,
|
.write = uart_write,
|
||||||
&uart_read,
|
.valid = {
|
||||||
};
|
.min_access_size = 4,
|
||||||
|
.max_access_size = 4,
|
||||||
static CPUWriteMemoryFunc * const uart_write_fn[] = {
|
},
|
||||||
NULL,
|
.endianness = DEVICE_NATIVE_ENDIAN,
|
||||||
NULL,
|
|
||||||
&uart_write,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static void uart_rx(void *opaque, const uint8_t *buf, int size)
|
static void uart_rx(void *opaque, const uint8_t *buf, int size)
|
||||||
@ -136,14 +138,13 @@ static void milkymist_uart_reset(DeviceState *d)
|
|||||||
static int milkymist_uart_init(SysBusDevice *dev)
|
static int milkymist_uart_init(SysBusDevice *dev)
|
||||||
{
|
{
|
||||||
MilkymistUartState *s = FROM_SYSBUS(typeof(*s), dev);
|
MilkymistUartState *s = FROM_SYSBUS(typeof(*s), dev);
|
||||||
int uart_regs;
|
|
||||||
|
|
||||||
sysbus_init_irq(dev, &s->rx_irq);
|
sysbus_init_irq(dev, &s->rx_irq);
|
||||||
sysbus_init_irq(dev, &s->tx_irq);
|
sysbus_init_irq(dev, &s->tx_irq);
|
||||||
|
|
||||||
uart_regs = cpu_register_io_memory(uart_read_fn, uart_write_fn, s,
|
memory_region_init_io(&s->regs_region, &uart_mmio_ops, s,
|
||||||
DEVICE_NATIVE_ENDIAN);
|
"milkymist-uart", R_MAX * 4);
|
||||||
sysbus_init_mmio(dev, R_MAX * 4, uart_regs);
|
sysbus_init_mmio_region(dev, &s->regs_region);
|
||||||
|
|
||||||
s->chr = qdev_init_chardev(&dev->qdev);
|
s->chr = qdev_init_chardev(&dev->qdev);
|
||||||
if (s->chr) {
|
if (s->chr) {
|
||||||
|
Loading…
Reference in New Issue
Block a user