xref: /openbmc/qemu/include/hw/ipack/ipack.h (revision a68694cd)
1 /*
2  * QEMU IndustryPack emulation
3  *
4  * Copyright (C) 2012 Igalia, S.L.
5  * Author: Alberto Garcia <berto@igalia.com>
6  *
7  * This code is licensed under the GNU GPL v2 or (at your option) any
8  * later version.
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 typedef struct IPackBus IPackBus;
18 
19 #define TYPE_IPACK_BUS "IndustryPack"
20 DECLARE_INSTANCE_CHECKER(IPackBus, IPACK_BUS,
21                          TYPE_IPACK_BUS)
22 
23 struct IPackBus {
24     /*< private >*/
25     BusState parent_obj;
26 
27     /* All fields are private */
28     uint8_t n_slots;
29     uint8_t free_slot;
30     qemu_irq_handler set_irq;
31 };
32 
33 
34 #define TYPE_IPACK_DEVICE "ipack-device"
35 OBJECT_DECLARE_TYPE(IPackDevice, IPackDeviceClass,
36                     ipack_device, IPACK_DEVICE)
37 
38 struct IPackDeviceClass {
39     /*< private >*/
40     DeviceClass parent_class;
41     /*< public >*/
42 
43     DeviceRealize realize;
44     DeviceUnrealize unrealize;
45 
46     uint16_t (*io_read)(IPackDevice *dev, uint8_t addr);
47     void (*io_write)(IPackDevice *dev, uint8_t addr, uint16_t val);
48 
49     uint16_t (*id_read)(IPackDevice *dev, uint8_t addr);
50     void (*id_write)(IPackDevice *dev, uint8_t addr, uint16_t val);
51 
52     uint16_t (*int_read)(IPackDevice *dev, uint8_t addr);
53     void (*int_write)(IPackDevice *dev, uint8_t addr, uint16_t val);
54 
55     uint16_t (*mem_read16)(IPackDevice *dev, uint32_t addr);
56     void (*mem_write16)(IPackDevice *dev, uint32_t addr, uint16_t val);
57 
58     uint8_t (*mem_read8)(IPackDevice *dev, uint32_t addr);
59     void (*mem_write8)(IPackDevice *dev, uint32_t addr, uint8_t val);
60 };
61 
62 struct IPackDevice {
63     /*< private >*/
64     DeviceState parent_obj;
65     /*< public >*/
66 
67     int32_t slot;
68     /* IRQ objects for the IndustryPack INT0# and INT1# */
69     qemu_irq *irq;
70 };
71 
72 extern const VMStateDescription vmstate_ipack_device;
73 
74 #define VMSTATE_IPACK_DEVICE(_field, _state)                            \
75     VMSTATE_STRUCT(_field, _state, 1, vmstate_ipack_device, IPackDevice)
76 
77 IPackDevice *ipack_device_find(IPackBus *bus, int32_t slot);
78 void ipack_bus_new_inplace(IPackBus *bus, size_t bus_size,
79                            DeviceState *parent,
80                            const char *name, uint8_t n_slots,
81                            qemu_irq_handler handler);
82 
83 #endif
84