1 #ifndef QEMU_HW_MILKYMIST_H
2 #define QEMU_HW_MILKYMIST_H
7 static inline DeviceState
*milkymist_uart_create(hwaddr base
,
12 dev
= qdev_create(NULL
, "milkymist-uart");
13 qdev_init_nofail(dev
);
14 sysbus_mmio_map(SYS_BUS_DEVICE(dev
), 0, base
);
15 sysbus_connect_irq(SYS_BUS_DEVICE(dev
), 0, irq
);
20 static inline DeviceState
*milkymist_hpdmc_create(hwaddr base
)
24 dev
= qdev_create(NULL
, "milkymist-hpdmc");
25 qdev_init_nofail(dev
);
26 sysbus_mmio_map(SYS_BUS_DEVICE(dev
), 0, base
);
31 static inline DeviceState
*milkymist_memcard_create(hwaddr base
)
35 dev
= qdev_create(NULL
, "milkymist-memcard");
36 qdev_init_nofail(dev
);
37 sysbus_mmio_map(SYS_BUS_DEVICE(dev
), 0, base
);
42 static inline DeviceState
*milkymist_vgafb_create(hwaddr base
,
43 uint32_t fb_offset
, uint32_t fb_mask
)
47 dev
= qdev_create(NULL
, "milkymist-vgafb");
48 qdev_prop_set_uint32(dev
, "fb_offset", fb_offset
);
49 qdev_prop_set_uint32(dev
, "fb_mask", fb_mask
);
50 qdev_init_nofail(dev
);
51 sysbus_mmio_map(SYS_BUS_DEVICE(dev
), 0, base
);
56 static inline DeviceState
*milkymist_sysctl_create(hwaddr base
,
57 qemu_irq gpio_irq
, qemu_irq timer0_irq
, qemu_irq timer1_irq
,
58 uint32_t freq_hz
, uint32_t system_id
, uint32_t capabilities
,
59 uint32_t gpio_strappings
)
63 dev
= qdev_create(NULL
, "milkymist-sysctl");
64 qdev_prop_set_uint32(dev
, "frequency", freq_hz
);
65 qdev_prop_set_uint32(dev
, "systemid", system_id
);
66 qdev_prop_set_uint32(dev
, "capabilities", capabilities
);
67 qdev_prop_set_uint32(dev
, "gpio_strappings", gpio_strappings
);
68 qdev_init_nofail(dev
);
69 sysbus_mmio_map(SYS_BUS_DEVICE(dev
), 0, base
);
70 sysbus_connect_irq(SYS_BUS_DEVICE(dev
), 0, gpio_irq
);
71 sysbus_connect_irq(SYS_BUS_DEVICE(dev
), 1, timer0_irq
);
72 sysbus_connect_irq(SYS_BUS_DEVICE(dev
), 2, timer1_irq
);
77 static inline DeviceState
*milkymist_pfpu_create(hwaddr base
,
82 dev
= qdev_create(NULL
, "milkymist-pfpu");
83 qdev_init_nofail(dev
);
84 sysbus_mmio_map(SYS_BUS_DEVICE(dev
), 0, base
);
85 sysbus_connect_irq(SYS_BUS_DEVICE(dev
), 0, irq
);
92 #include <epoxy/glx.h>
93 static const int glx_fbconfig_attr
[] = {
101 static inline DeviceState
*milkymist_tmu2_create(hwaddr base
,
107 GLXFBConfig
*configs
;
109 int ver_major
, ver_minor
;
111 if (display_type
== DT_NOGRAPHIC
) {
115 /* check that GLX will work */
116 d
= XOpenDisplay(NULL
);
121 if (!glXQueryVersion(d
, &ver_major
, &ver_minor
)) {
122 /* Yeah, sometimes getting the GLX version can fail.
123 * Isn't X beautiful? */
128 if ((ver_major
< 1) || ((ver_major
== 1) && (ver_minor
< 3))) {
129 printf("Your GLX version is %d.%d,"
130 "but TMU emulation needs at least 1.3. TMU disabled.\n",
131 ver_major
, ver_minor
);
136 configs
= glXChooseFBConfig(d
, 0, glx_fbconfig_attr
, &nelements
);
137 if (configs
== NULL
) {
145 dev
= qdev_create(NULL
, "milkymist-tmu2");
146 qdev_init_nofail(dev
);
147 sysbus_mmio_map(SYS_BUS_DEVICE(dev
), 0, base
);
148 sysbus_connect_irq(SYS_BUS_DEVICE(dev
), 0, irq
);
156 static inline DeviceState
*milkymist_ac97_create(hwaddr base
,
157 qemu_irq crrequest_irq
, qemu_irq crreply_irq
, qemu_irq dmar_irq
,
162 dev
= qdev_create(NULL
, "milkymist-ac97");
163 qdev_init_nofail(dev
);
164 sysbus_mmio_map(SYS_BUS_DEVICE(dev
), 0, base
);
165 sysbus_connect_irq(SYS_BUS_DEVICE(dev
), 0, crrequest_irq
);
166 sysbus_connect_irq(SYS_BUS_DEVICE(dev
), 1, crreply_irq
);
167 sysbus_connect_irq(SYS_BUS_DEVICE(dev
), 2, dmar_irq
);
168 sysbus_connect_irq(SYS_BUS_DEVICE(dev
), 3, dmaw_irq
);
173 static inline DeviceState
*milkymist_minimac2_create(hwaddr base
,
174 hwaddr buffers_base
, qemu_irq rx_irq
, qemu_irq tx_irq
)
178 qemu_check_nic_model(&nd_table
[0], "minimac2");
179 dev
= qdev_create(NULL
, "milkymist-minimac2");
180 qdev_set_nic_properties(dev
, &nd_table
[0]);
181 qdev_init_nofail(dev
);
182 sysbus_mmio_map(SYS_BUS_DEVICE(dev
), 0, base
);
183 sysbus_mmio_map(SYS_BUS_DEVICE(dev
), 1, buffers_base
);
184 sysbus_connect_irq(SYS_BUS_DEVICE(dev
), 0, rx_irq
);
185 sysbus_connect_irq(SYS_BUS_DEVICE(dev
), 1, tx_irq
);
190 static inline DeviceState
*milkymist_softusb_create(hwaddr base
,
191 qemu_irq irq
, uint32_t pmem_base
, uint32_t pmem_size
,
192 uint32_t dmem_base
, uint32_t dmem_size
)
196 dev
= qdev_create(NULL
, "milkymist-softusb");
197 qdev_prop_set_uint32(dev
, "pmem_size", pmem_size
);
198 qdev_prop_set_uint32(dev
, "dmem_size", dmem_size
);
199 qdev_init_nofail(dev
);
200 sysbus_mmio_map(SYS_BUS_DEVICE(dev
), 0, base
);
201 sysbus_mmio_map(SYS_BUS_DEVICE(dev
), 1, pmem_base
);
202 sysbus_mmio_map(SYS_BUS_DEVICE(dev
), 2, dmem_base
);
203 sysbus_connect_irq(SYS_BUS_DEVICE(dev
), 0, irq
);
208 #endif /* QEMU_HW_MILKYMIST_H */