hw/riscv: Move sifive_plic model to hw/intc
[qemu/ar7.git] / hw / lm32 / lm32.h
blob7b4f6255b91167adb6221f1646715d8c41460ffb
1 #ifndef HW_LM32_H
2 #define HW_LM32_H
4 #include "hw/char/lm32_juart.h"
5 #include "hw/qdev-properties.h"
6 #include "qapi/error.h"
8 static inline DeviceState *lm32_pic_init(qemu_irq cpu_irq)
10 DeviceState *dev;
11 SysBusDevice *d;
13 dev = qdev_new("lm32-pic");
14 d = SYS_BUS_DEVICE(dev);
15 sysbus_realize_and_unref(d, &error_fatal);
16 sysbus_connect_irq(d, 0, cpu_irq);
18 return dev;
21 static inline DeviceState *lm32_juart_init(Chardev *chr)
23 DeviceState *dev;
25 dev = qdev_new(TYPE_LM32_JUART);
26 qdev_prop_set_chr(dev, "chardev", chr);
27 sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
29 return dev;
32 static inline DeviceState *lm32_uart_create(hwaddr addr,
33 qemu_irq irq,
34 Chardev *chr)
36 DeviceState *dev;
37 SysBusDevice *s;
39 dev = qdev_new("lm32-uart");
40 s = SYS_BUS_DEVICE(dev);
41 qdev_prop_set_chr(dev, "chardev", chr);
42 sysbus_realize_and_unref(s, &error_fatal);
43 sysbus_mmio_map(s, 0, addr);
44 sysbus_connect_irq(s, 0, irq);
45 return dev;
48 #endif