xref: /qemu/include/hw/ipack/ipack.h (revision 83c9f4ca794ec3b6fa7e5a5bb055d378916503e0)
19c16fa79SAlberto Garcia /*
29c16fa79SAlberto Garcia  * QEMU IndustryPack emulation
39c16fa79SAlberto Garcia  *
49c16fa79SAlberto Garcia  * Copyright (C) 2012 Igalia, S.L.
59c16fa79SAlberto Garcia  * Author: Alberto Garcia <agarcia@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 
14*83c9f4caSPaolo Bonzini #include "hw/qdev.h"
159c16fa79SAlberto Garcia 
169c16fa79SAlberto Garcia typedef struct IPackBus IPackBus;
179c16fa79SAlberto Garcia 
189c16fa79SAlberto Garcia #define TYPE_IPACK_BUS "IndustryPack"
199c16fa79SAlberto Garcia #define IPACK_BUS(obj) OBJECT_CHECK(IPackBus, (obj), TYPE_IPACK_BUS)
209c16fa79SAlberto Garcia 
219c16fa79SAlberto Garcia struct IPackBus {
229c16fa79SAlberto Garcia     BusState qbus;
239c16fa79SAlberto Garcia     /* All fields are private */
249c16fa79SAlberto Garcia     uint8_t n_slots;
259c16fa79SAlberto Garcia     uint8_t free_slot;
269c16fa79SAlberto Garcia     qemu_irq_handler set_irq;
279c16fa79SAlberto Garcia };
289c16fa79SAlberto Garcia 
299c16fa79SAlberto Garcia typedef struct IPackDevice IPackDevice;
309c16fa79SAlberto Garcia typedef struct IPackDeviceClass IPackDeviceClass;
319c16fa79SAlberto Garcia 
329c16fa79SAlberto Garcia #define TYPE_IPACK_DEVICE "ipack-device"
339c16fa79SAlberto Garcia #define IPACK_DEVICE(obj) \
349c16fa79SAlberto Garcia      OBJECT_CHECK(IPackDevice, (obj), TYPE_IPACK_DEVICE)
359c16fa79SAlberto Garcia #define IPACK_DEVICE_CLASS(klass)                                        \
369c16fa79SAlberto Garcia      OBJECT_CLASS_CHECK(IPackDeviceClass, (klass), TYPE_IPACK_DEVICE)
379c16fa79SAlberto Garcia #define IPACK_DEVICE_GET_CLASS(obj) \
389c16fa79SAlberto Garcia      OBJECT_GET_CLASS(IPackDeviceClass, (obj), TYPE_IPACK_DEVICE)
399c16fa79SAlberto Garcia 
409c16fa79SAlberto Garcia struct IPackDeviceClass {
419c16fa79SAlberto Garcia     DeviceClass parent_class;
429c16fa79SAlberto Garcia 
439c16fa79SAlberto Garcia     int (*init)(IPackDevice *dev);
449c16fa79SAlberto Garcia     int (*exit)(IPackDevice *dev);
459c16fa79SAlberto Garcia 
469c16fa79SAlberto Garcia     uint16_t (*io_read)(IPackDevice *dev, uint8_t addr);
479c16fa79SAlberto Garcia     void (*io_write)(IPackDevice *dev, uint8_t addr, uint16_t val);
489c16fa79SAlberto Garcia 
499c16fa79SAlberto Garcia     uint16_t (*id_read)(IPackDevice *dev, uint8_t addr);
509c16fa79SAlberto Garcia     void (*id_write)(IPackDevice *dev, uint8_t addr, uint16_t val);
519c16fa79SAlberto Garcia 
529c16fa79SAlberto Garcia     uint16_t (*int_read)(IPackDevice *dev, uint8_t addr);
539c16fa79SAlberto Garcia     void (*int_write)(IPackDevice *dev, uint8_t addr, uint16_t val);
549c16fa79SAlberto Garcia 
559c16fa79SAlberto Garcia     uint16_t (*mem_read16)(IPackDevice *dev, uint32_t addr);
569c16fa79SAlberto Garcia     void (*mem_write16)(IPackDevice *dev, uint32_t addr, uint16_t val);
579c16fa79SAlberto Garcia 
589c16fa79SAlberto Garcia     uint8_t (*mem_read8)(IPackDevice *dev, uint32_t addr);
599c16fa79SAlberto Garcia     void (*mem_write8)(IPackDevice *dev, uint32_t addr, uint8_t val);
609c16fa79SAlberto Garcia };
619c16fa79SAlberto Garcia 
629c16fa79SAlberto Garcia struct IPackDevice {
639c16fa79SAlberto Garcia     DeviceState qdev;
649c16fa79SAlberto Garcia     int32_t slot;
659c16fa79SAlberto Garcia     /* IRQ objects for the IndustryPack INT0# and INT1# */
669c16fa79SAlberto Garcia     qemu_irq *irq;
679c16fa79SAlberto Garcia };
689c16fa79SAlberto Garcia 
699c16fa79SAlberto Garcia extern const VMStateDescription vmstate_ipack_device;
709c16fa79SAlberto Garcia 
719c16fa79SAlberto Garcia #define VMSTATE_IPACK_DEVICE(_field, _state)                            \
729c16fa79SAlberto Garcia     VMSTATE_STRUCT(_field, _state, 1, vmstate_ipack_device, IPackDevice)
739c16fa79SAlberto Garcia 
749c16fa79SAlberto Garcia IPackDevice *ipack_device_find(IPackBus *bus, int32_t slot);
759c16fa79SAlberto Garcia void ipack_bus_new_inplace(IPackBus *bus, DeviceState *parent,
769c16fa79SAlberto Garcia                            const char *name, uint8_t n_slots,
779c16fa79SAlberto Garcia                            qemu_irq_handler handler);
789c16fa79SAlberto Garcia 
799c16fa79SAlberto Garcia #endif
80