1
2
3
4
5
6
7
8
9
10
11#ifndef QEMU_IPACK_H
12#define QEMU_IPACK_H
13
14#include "hw/qdev-core.h"
15#include "qom/object.h"
16
17
18#define TYPE_IPACK_BUS "IndustryPack"
19OBJECT_DECLARE_SIMPLE_TYPE(IPackBus, IPACK_BUS)
20
21struct IPackBus {
22
23 BusState parent_obj;
24
25
26 uint8_t n_slots;
27 uint8_t free_slot;
28 qemu_irq_handler set_irq;
29};
30
31
32#define TYPE_IPACK_DEVICE "ipack-device"
33OBJECT_DECLARE_TYPE(IPackDevice, IPackDeviceClass,
34 IPACK_DEVICE)
35
36struct IPackDeviceClass {
37
38 DeviceClass parent_class;
39
40
41 DeviceRealize realize;
42 DeviceUnrealize unrealize;
43
44 uint16_t (*io_read)(IPackDevice *dev, uint8_t addr);
45 void (*io_write)(IPackDevice *dev, uint8_t addr, uint16_t val);
46
47 uint16_t (*id_read)(IPackDevice *dev, uint8_t addr);
48 void (*id_write)(IPackDevice *dev, uint8_t addr, uint16_t val);
49
50 uint16_t (*int_read)(IPackDevice *dev, uint8_t addr);
51 void (*int_write)(IPackDevice *dev, uint8_t addr, uint16_t val);
52
53 uint16_t (*mem_read16)(IPackDevice *dev, uint32_t addr);
54 void (*mem_write16)(IPackDevice *dev, uint32_t addr, uint16_t val);
55
56 uint8_t (*mem_read8)(IPackDevice *dev, uint32_t addr);
57 void (*mem_write8)(IPackDevice *dev, uint32_t addr, uint8_t val);
58};
59
60struct IPackDevice {
61
62 DeviceState parent_obj;
63
64
65 int32_t slot;
66
67 qemu_irq *irq;
68};
69
70extern const VMStateDescription vmstate_ipack_device;
71
72#define VMSTATE_IPACK_DEVICE(_field, _state) \
73 VMSTATE_STRUCT(_field, _state, 1, vmstate_ipack_device, IPackDevice)
74
75IPackDevice *ipack_device_find(IPackBus *bus, int32_t slot);
76void ipack_bus_init(IPackBus *bus, size_t bus_size,
77 DeviceState *parent,
78 uint8_t n_slots,
79 qemu_irq_handler handler);
80
81#endif
82