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 14*a27bd6c7SMarkus Armbruster #include "hw/qdev-core.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 { 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 typedef struct IPackDevice IPackDevice; 329c16fa79SAlberto Garcia typedef struct IPackDeviceClass IPackDeviceClass; 339c16fa79SAlberto Garcia 349c16fa79SAlberto Garcia #define TYPE_IPACK_DEVICE "ipack-device" 359c16fa79SAlberto Garcia #define IPACK_DEVICE(obj) \ 369c16fa79SAlberto Garcia OBJECT_CHECK(IPackDevice, (obj), TYPE_IPACK_DEVICE) 379c16fa79SAlberto Garcia #define IPACK_DEVICE_CLASS(klass) \ 389c16fa79SAlberto Garcia OBJECT_CLASS_CHECK(IPackDeviceClass, (klass), TYPE_IPACK_DEVICE) 399c16fa79SAlberto Garcia #define IPACK_DEVICE_GET_CLASS(obj) \ 409c16fa79SAlberto Garcia OBJECT_GET_CLASS(IPackDeviceClass, (obj), TYPE_IPACK_DEVICE) 419c16fa79SAlberto Garcia 429c16fa79SAlberto Garcia struct IPackDeviceClass { 435c570902SAndreas Färber /*< private >*/ 449c16fa79SAlberto Garcia DeviceClass parent_class; 455c570902SAndreas Färber /*< public >*/ 469c16fa79SAlberto Garcia 475c570902SAndreas Färber DeviceRealize realize; 485c570902SAndreas Färber DeviceUnrealize unrealize; 499c16fa79SAlberto Garcia 509c16fa79SAlberto Garcia uint16_t (*io_read)(IPackDevice *dev, uint8_t addr); 519c16fa79SAlberto Garcia void (*io_write)(IPackDevice *dev, uint8_t addr, uint16_t val); 529c16fa79SAlberto Garcia 539c16fa79SAlberto Garcia uint16_t (*id_read)(IPackDevice *dev, uint8_t addr); 549c16fa79SAlberto Garcia void (*id_write)(IPackDevice *dev, uint8_t addr, uint16_t val); 559c16fa79SAlberto Garcia 569c16fa79SAlberto Garcia uint16_t (*int_read)(IPackDevice *dev, uint8_t addr); 579c16fa79SAlberto Garcia void (*int_write)(IPackDevice *dev, uint8_t addr, uint16_t val); 589c16fa79SAlberto Garcia 599c16fa79SAlberto Garcia uint16_t (*mem_read16)(IPackDevice *dev, uint32_t addr); 609c16fa79SAlberto Garcia void (*mem_write16)(IPackDevice *dev, uint32_t addr, uint16_t val); 619c16fa79SAlberto Garcia 629c16fa79SAlberto Garcia uint8_t (*mem_read8)(IPackDevice *dev, uint32_t addr); 639c16fa79SAlberto Garcia void (*mem_write8)(IPackDevice *dev, uint32_t addr, uint8_t val); 649c16fa79SAlberto Garcia }; 659c16fa79SAlberto Garcia 669c16fa79SAlberto Garcia struct IPackDevice { 67227d3272SAndreas Färber /*< private >*/ 68227d3272SAndreas Färber DeviceState parent_obj; 69227d3272SAndreas Färber /*< public >*/ 70227d3272SAndreas Färber 719c16fa79SAlberto Garcia int32_t slot; 729c16fa79SAlberto Garcia /* IRQ objects for the IndustryPack INT0# and INT1# */ 739c16fa79SAlberto Garcia qemu_irq *irq; 749c16fa79SAlberto Garcia }; 759c16fa79SAlberto Garcia 769c16fa79SAlberto Garcia extern const VMStateDescription vmstate_ipack_device; 779c16fa79SAlberto Garcia 789c16fa79SAlberto Garcia #define VMSTATE_IPACK_DEVICE(_field, _state) \ 799c16fa79SAlberto Garcia VMSTATE_STRUCT(_field, _state, 1, vmstate_ipack_device, IPackDevice) 809c16fa79SAlberto Garcia 819c16fa79SAlberto Garcia IPackDevice *ipack_device_find(IPackBus *bus, int32_t slot); 8277cbb28aSAndreas Färber void ipack_bus_new_inplace(IPackBus *bus, size_t bus_size, 8377cbb28aSAndreas Färber DeviceState *parent, 849c16fa79SAlberto Garcia const char *name, uint8_t n_slots, 859c16fa79SAlberto Garcia qemu_irq_handler handler); 869c16fa79SAlberto Garcia 879c16fa79SAlberto Garcia #endif 88