1
2
3
4
5
6
7
8
9
10
11
12
13
14
15#ifndef HW_PL011_H
16#define HW_PL011_H
17
18#include "hw/qdev-properties.h"
19#include "hw/sysbus.h"
20#include "chardev/char-fe.h"
21
22#define TYPE_PL011 "pl011"
23#define PL011(obj) OBJECT_CHECK(PL011State, (obj), TYPE_PL011)
24
25
26#define TYPE_PL011_LUMINARY "pl011_luminary"
27
28typedef struct PL011State {
29 SysBusDevice parent_obj;
30
31 MemoryRegion iomem;
32 uint32_t readbuff;
33 uint32_t flags;
34 uint32_t lcr;
35 uint32_t rsr;
36 uint32_t cr;
37 uint32_t dmacr;
38 uint32_t int_enabled;
39 uint32_t int_level;
40 uint32_t read_fifo[16];
41 uint32_t ilpr;
42 uint32_t ibrd;
43 uint32_t fbrd;
44 uint32_t ifl;
45 int read_pos;
46 int read_count;
47 int read_trigger;
48 CharBackend chr;
49 qemu_irq irq[6];
50 const unsigned char *id;
51} PL011State;
52
53static inline DeviceState *pl011_create(hwaddr addr,
54 qemu_irq irq,
55 Chardev *chr)
56{
57 DeviceState *dev;
58 SysBusDevice *s;
59
60 dev = qdev_create(NULL, "pl011");
61 s = SYS_BUS_DEVICE(dev);
62 qdev_prop_set_chr(dev, "chardev", chr);
63 qdev_init_nofail(dev);
64 sysbus_mmio_map(s, 0, addr);
65 sysbus_connect_irq(s, 0, irq);
66
67 return dev;
68}
69
70static inline DeviceState *pl011_luminary_create(hwaddr addr,
71 qemu_irq irq,
72 Chardev *chr)
73{
74 DeviceState *dev;
75 SysBusDevice *s;
76
77 dev = qdev_create(NULL, "pl011_luminary");
78 s = SYS_BUS_DEVICE(dev);
79 qdev_prop_set_chr(dev, "chardev", chr);
80 qdev_init_nofail(dev);
81 sysbus_mmio_map(s, 0, addr);
82 sysbus_connect_irq(s, 0, irq);
83
84 return dev;
85}
86
87#endif
88