mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-11 03:24:58 -06:00
grlib_apbuart: convert to memory API
Signed-off-by: Avi Kivity <avi@redhat.com>
This commit is contained in:
parent
4f5c947982
commit
6281f7d11f
1 changed files with 15 additions and 15 deletions
|
@ -67,7 +67,7 @@
|
||||||
|
|
||||||
typedef struct UART {
|
typedef struct UART {
|
||||||
SysBusDevice busdev;
|
SysBusDevice busdev;
|
||||||
|
MemoryRegion iomem;
|
||||||
qemu_irq irq;
|
qemu_irq irq;
|
||||||
|
|
||||||
CharDriverState *chr;
|
CharDriverState *chr;
|
||||||
|
@ -103,7 +103,8 @@ static void grlib_apbuart_event(void *opaque, int event)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
grlib_apbuart_writel(void *opaque, target_phys_addr_t addr, uint32_t value)
|
grlib_apbuart_write(void *opaque, target_phys_addr_t addr,
|
||||||
|
uint64_t value, unsigned size)
|
||||||
{
|
{
|
||||||
UART *uart = opaque;
|
UART *uart = opaque;
|
||||||
unsigned char c = 0;
|
unsigned char c = 0;
|
||||||
|
@ -136,18 +137,21 @@ grlib_apbuart_writel(void *opaque, target_phys_addr_t addr, uint32_t value)
|
||||||
trace_grlib_apbuart_writel_unknown(addr, value);
|
trace_grlib_apbuart_writel_unknown(addr, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
static CPUReadMemoryFunc * const grlib_apbuart_read[] = {
|
static bool grlib_apbuart_accepts(void *opaque, target_phys_addr_t addr,
|
||||||
NULL, NULL, NULL,
|
unsigned size, bool is_write)
|
||||||
};
|
{
|
||||||
|
return is_write && size == 4;
|
||||||
|
}
|
||||||
|
|
||||||
static CPUWriteMemoryFunc * const grlib_apbuart_write[] = {
|
static const MemoryRegionOps grlib_apbuart_ops = {
|
||||||
NULL, NULL, grlib_apbuart_writel,
|
.write = grlib_apbuart_write,
|
||||||
|
.valid.accepts = grlib_apbuart_accepts,
|
||||||
|
.endianness = DEVICE_NATIVE_ENDIAN,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int grlib_apbuart_init(SysBusDevice *dev)
|
static int grlib_apbuart_init(SysBusDevice *dev)
|
||||||
{
|
{
|
||||||
UART *uart = FROM_SYSBUS(typeof(*uart), dev);
|
UART *uart = FROM_SYSBUS(typeof(*uart), dev);
|
||||||
int uart_regs = 0;
|
|
||||||
|
|
||||||
qemu_chr_add_handlers(uart->chr,
|
qemu_chr_add_handlers(uart->chr,
|
||||||
grlib_apbuart_can_receive,
|
grlib_apbuart_can_receive,
|
||||||
|
@ -157,14 +161,10 @@ static int grlib_apbuart_init(SysBusDevice *dev)
|
||||||
|
|
||||||
sysbus_init_irq(dev, &uart->irq);
|
sysbus_init_irq(dev, &uart->irq);
|
||||||
|
|
||||||
uart_regs = cpu_register_io_memory(grlib_apbuart_read,
|
memory_region_init_io(&uart->iomem, &grlib_apbuart_ops, uart,
|
||||||
grlib_apbuart_write,
|
"uart", UART_REG_SIZE);
|
||||||
uart, DEVICE_NATIVE_ENDIAN);
|
|
||||||
if (uart_regs < 0) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
sysbus_init_mmio(dev, UART_REG_SIZE, uart_regs);
|
sysbus_init_mmio_region(dev, &uart->iomem);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue