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" 15db1015e9SEduardo Habkost #include "qom/object.h" 169c16fa79SAlberto Garcia 179c16fa79SAlberto Garcia 189c16fa79SAlberto Garcia #define TYPE_IPACK_BUS "IndustryPack" 19*8063396bSEduardo Habkost OBJECT_DECLARE_SIMPLE_TYPE(IPackBus, IPACK_BUS) 209c16fa79SAlberto Garcia 219c16fa79SAlberto Garcia struct IPackBus { 22a21ac343SAndreas Färber /*< private >*/ 23a21ac343SAndreas Färber BusState parent_obj; 24a21ac343SAndreas Färber 259c16fa79SAlberto Garcia /* All fields are private */ 269c16fa79SAlberto Garcia uint8_t n_slots; 279c16fa79SAlberto Garcia uint8_t free_slot; 289c16fa79SAlberto Garcia qemu_irq_handler set_irq; 299c16fa79SAlberto Garcia }; 309c16fa79SAlberto Garcia 319c16fa79SAlberto Garcia 329c16fa79SAlberto Garcia #define TYPE_IPACK_DEVICE "ipack-device" 33c821774aSEduardo Habkost OBJECT_DECLARE_TYPE(IPackDevice, IPackDeviceClass, 3430b5707cSEduardo Habkost IPACK_DEVICE) 359c16fa79SAlberto Garcia 369c16fa79SAlberto Garcia struct IPackDeviceClass { 375c570902SAndreas Färber /*< private >*/ 389c16fa79SAlberto Garcia DeviceClass parent_class; 395c570902SAndreas Färber /*< public >*/ 409c16fa79SAlberto Garcia 415c570902SAndreas Färber DeviceRealize realize; 425c570902SAndreas Färber DeviceUnrealize unrealize; 439c16fa79SAlberto Garcia 449c16fa79SAlberto Garcia uint16_t (*io_read)(IPackDevice *dev, uint8_t addr); 459c16fa79SAlberto Garcia void (*io_write)(IPackDevice *dev, uint8_t addr, uint16_t val); 469c16fa79SAlberto Garcia 479c16fa79SAlberto Garcia uint16_t (*id_read)(IPackDevice *dev, uint8_t addr); 489c16fa79SAlberto Garcia void (*id_write)(IPackDevice *dev, uint8_t addr, uint16_t val); 499c16fa79SAlberto Garcia 509c16fa79SAlberto Garcia uint16_t (*int_read)(IPackDevice *dev, uint8_t addr); 519c16fa79SAlberto Garcia void (*int_write)(IPackDevice *dev, uint8_t addr, uint16_t val); 529c16fa79SAlberto Garcia 539c16fa79SAlberto Garcia uint16_t (*mem_read16)(IPackDevice *dev, uint32_t addr); 549c16fa79SAlberto Garcia void (*mem_write16)(IPackDevice *dev, uint32_t addr, uint16_t val); 559c16fa79SAlberto Garcia 569c16fa79SAlberto Garcia uint8_t (*mem_read8)(IPackDevice *dev, uint32_t addr); 579c16fa79SAlberto Garcia void (*mem_write8)(IPackDevice *dev, uint32_t addr, uint8_t val); 589c16fa79SAlberto Garcia }; 599c16fa79SAlberto Garcia 609c16fa79SAlberto Garcia struct IPackDevice { 61227d3272SAndreas Färber /*< private >*/ 62227d3272SAndreas Färber DeviceState parent_obj; 63227d3272SAndreas Färber /*< public >*/ 64227d3272SAndreas Färber 659c16fa79SAlberto Garcia int32_t slot; 669c16fa79SAlberto Garcia /* IRQ objects for the IndustryPack INT0# and INT1# */ 679c16fa79SAlberto Garcia qemu_irq *irq; 689c16fa79SAlberto Garcia }; 699c16fa79SAlberto Garcia 709c16fa79SAlberto Garcia extern const VMStateDescription vmstate_ipack_device; 719c16fa79SAlberto Garcia 729c16fa79SAlberto Garcia #define VMSTATE_IPACK_DEVICE(_field, _state) \ 739c16fa79SAlberto Garcia VMSTATE_STRUCT(_field, _state, 1, vmstate_ipack_device, IPackDevice) 749c16fa79SAlberto Garcia 759c16fa79SAlberto Garcia IPackDevice *ipack_device_find(IPackBus *bus, int32_t slot); 7677cbb28aSAndreas Färber void ipack_bus_new_inplace(IPackBus *bus, size_t bus_size, 7777cbb28aSAndreas Färber DeviceState *parent, 789c16fa79SAlberto Garcia const char *name, uint8_t n_slots, 799c16fa79SAlberto Garcia qemu_irq_handler handler); 809c16fa79SAlberto Garcia 819c16fa79SAlberto Garcia #endif 82