xref: /qemu/include/hw/ipack/ipack.h (revision f65f326113ecdfbe4479e9fe607da9f18aec2fd3)
19c16fa79SAlberto Garcia /*
29c16fa79SAlberto Garcia  * QEMU IndustryPack emulation
39c16fa79SAlberto Garcia  *
49c16fa79SAlberto Garcia  * Copyright (C) 2012 Igalia, S.L.
5b996aed5SAlberto Garcia  * Author: Alberto Garcia <berto@igalia.com>
69c16fa79SAlberto Garcia  *
79c16fa79SAlberto Garcia  * This code is licensed under the GNU GPL v2 or (at your option) any
89c16fa79SAlberto Garcia  * later version.
99c16fa79SAlberto Garcia  */
109c16fa79SAlberto Garcia 
119c16fa79SAlberto Garcia #ifndef QEMU_IPACK_H
129c16fa79SAlberto Garcia #define QEMU_IPACK_H
139c16fa79SAlberto Garcia 
14a27bd6c7SMarkus Armbruster #include "hw/qdev-core.h"
15*d50280afSPhilippe Mathieu-Daudé #include "hw/irq.h"
16db1015e9SEduardo Habkost #include "qom/object.h"
179c16fa79SAlberto Garcia 
189c16fa79SAlberto Garcia 
199c16fa79SAlberto Garcia #define TYPE_IPACK_BUS "IndustryPack"
208063396bSEduardo Habkost OBJECT_DECLARE_SIMPLE_TYPE(IPackBus, IPACK_BUS)
219c16fa79SAlberto Garcia 
229c16fa79SAlberto Garcia struct IPackBus {
23a21ac343SAndreas Färber     BusState parent_obj;
24a21ac343SAndreas Färber 
259c16fa79SAlberto Garcia     uint8_t n_slots;
269c16fa79SAlberto Garcia     uint8_t free_slot;
279c16fa79SAlberto Garcia     qemu_irq_handler set_irq;
289c16fa79SAlberto Garcia };
299c16fa79SAlberto Garcia 
309c16fa79SAlberto Garcia 
319c16fa79SAlberto Garcia #define TYPE_IPACK_DEVICE "ipack-device"
32c821774aSEduardo Habkost OBJECT_DECLARE_TYPE(IPackDevice, IPackDeviceClass,
3330b5707cSEduardo Habkost                     IPACK_DEVICE)
349c16fa79SAlberto Garcia 
359c16fa79SAlberto Garcia struct IPackDeviceClass {
365c570902SAndreas Färber     /*< private >*/
379c16fa79SAlberto Garcia     DeviceClass parent_class;
385c570902SAndreas Färber     /*< public >*/
399c16fa79SAlberto Garcia 
405c570902SAndreas Färber     DeviceRealize realize;
415c570902SAndreas Färber     DeviceUnrealize unrealize;
429c16fa79SAlberto Garcia 
439c16fa79SAlberto Garcia     uint16_t (*io_read)(IPackDevice *dev, uint8_t addr);
449c16fa79SAlberto Garcia     void (*io_write)(IPackDevice *dev, uint8_t addr, uint16_t val);
459c16fa79SAlberto Garcia 
469c16fa79SAlberto Garcia     uint16_t (*id_read)(IPackDevice *dev, uint8_t addr);
479c16fa79SAlberto Garcia     void (*id_write)(IPackDevice *dev, uint8_t addr, uint16_t val);
489c16fa79SAlberto Garcia 
499c16fa79SAlberto Garcia     uint16_t (*int_read)(IPackDevice *dev, uint8_t addr);
509c16fa79SAlberto Garcia     void (*int_write)(IPackDevice *dev, uint8_t addr, uint16_t val);
519c16fa79SAlberto Garcia 
529c16fa79SAlberto Garcia     uint16_t (*mem_read16)(IPackDevice *dev, uint32_t addr);
539c16fa79SAlberto Garcia     void (*mem_write16)(IPackDevice *dev, uint32_t addr, uint16_t val);
549c16fa79SAlberto Garcia 
559c16fa79SAlberto Garcia     uint8_t (*mem_read8)(IPackDevice *dev, uint32_t addr);
569c16fa79SAlberto Garcia     void (*mem_write8)(IPackDevice *dev, uint32_t addr, uint8_t val);
579c16fa79SAlberto Garcia };
589c16fa79SAlberto Garcia 
599c16fa79SAlberto Garcia struct IPackDevice {
60227d3272SAndreas Färber     DeviceState parent_obj;
61227d3272SAndreas Färber 
629c16fa79SAlberto Garcia     int32_t slot;
639c16fa79SAlberto Garcia     /* IRQ objects for the IndustryPack INT0# and INT1# */
64*d50280afSPhilippe Mathieu-Daudé     IRQState irq[2];
659c16fa79SAlberto Garcia };
669c16fa79SAlberto Garcia 
679c16fa79SAlberto Garcia extern const VMStateDescription vmstate_ipack_device;
689c16fa79SAlberto Garcia 
699c16fa79SAlberto Garcia #define VMSTATE_IPACK_DEVICE(_field, _state)                            \
709c16fa79SAlberto Garcia     VMSTATE_STRUCT(_field, _state, 1, vmstate_ipack_device, IPackDevice)
719c16fa79SAlberto Garcia 
729c16fa79SAlberto Garcia IPackDevice *ipack_device_find(IPackBus *bus, int32_t slot);
7343417c0cSPeter Maydell void ipack_bus_init(IPackBus *bus, size_t bus_size,
7477cbb28aSAndreas Färber                     DeviceState *parent,
7543417c0cSPeter Maydell                     uint8_t n_slots,
769c16fa79SAlberto Garcia                     qemu_irq_handler handler);
779c16fa79SAlberto Garcia 
789c16fa79SAlberto Garcia #endif
79