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*db1015e9SEduardo Habkost #include "qom/object.h" 169c16fa79SAlberto Garcia 179c16fa79SAlberto Garcia typedef struct IPackBus IPackBus; 189c16fa79SAlberto Garcia 199c16fa79SAlberto Garcia #define TYPE_IPACK_BUS "IndustryPack" 209c16fa79SAlberto Garcia #define IPACK_BUS(obj) OBJECT_CHECK(IPackBus, (obj), TYPE_IPACK_BUS) 219c16fa79SAlberto Garcia 229c16fa79SAlberto Garcia struct IPackBus { 23a21ac343SAndreas Färber /*< private >*/ 24a21ac343SAndreas Färber BusState parent_obj; 25a21ac343SAndreas Färber 269c16fa79SAlberto Garcia /* All fields are private */ 279c16fa79SAlberto Garcia uint8_t n_slots; 289c16fa79SAlberto Garcia uint8_t free_slot; 299c16fa79SAlberto Garcia qemu_irq_handler set_irq; 309c16fa79SAlberto Garcia }; 319c16fa79SAlberto Garcia 329c16fa79SAlberto Garcia typedef struct IPackDevice IPackDevice; 339c16fa79SAlberto Garcia typedef struct IPackDeviceClass IPackDeviceClass; 349c16fa79SAlberto Garcia 359c16fa79SAlberto Garcia #define TYPE_IPACK_DEVICE "ipack-device" 369c16fa79SAlberto Garcia #define IPACK_DEVICE(obj) \ 379c16fa79SAlberto Garcia OBJECT_CHECK(IPackDevice, (obj), TYPE_IPACK_DEVICE) 389c16fa79SAlberto Garcia #define IPACK_DEVICE_CLASS(klass) \ 399c16fa79SAlberto Garcia OBJECT_CLASS_CHECK(IPackDeviceClass, (klass), TYPE_IPACK_DEVICE) 409c16fa79SAlberto Garcia #define IPACK_DEVICE_GET_CLASS(obj) \ 419c16fa79SAlberto Garcia OBJECT_GET_CLASS(IPackDeviceClass, (obj), TYPE_IPACK_DEVICE) 429c16fa79SAlberto Garcia 439c16fa79SAlberto Garcia struct IPackDeviceClass { 445c570902SAndreas Färber /*< private >*/ 459c16fa79SAlberto Garcia DeviceClass parent_class; 465c570902SAndreas Färber /*< public >*/ 479c16fa79SAlberto Garcia 485c570902SAndreas Färber DeviceRealize realize; 495c570902SAndreas Färber DeviceUnrealize unrealize; 509c16fa79SAlberto Garcia 519c16fa79SAlberto Garcia uint16_t (*io_read)(IPackDevice *dev, uint8_t addr); 529c16fa79SAlberto Garcia void (*io_write)(IPackDevice *dev, uint8_t addr, uint16_t val); 539c16fa79SAlberto Garcia 549c16fa79SAlberto Garcia uint16_t (*id_read)(IPackDevice *dev, uint8_t addr); 559c16fa79SAlberto Garcia void (*id_write)(IPackDevice *dev, uint8_t addr, uint16_t val); 569c16fa79SAlberto Garcia 579c16fa79SAlberto Garcia uint16_t (*int_read)(IPackDevice *dev, uint8_t addr); 589c16fa79SAlberto Garcia void (*int_write)(IPackDevice *dev, uint8_t addr, uint16_t val); 599c16fa79SAlberto Garcia 609c16fa79SAlberto Garcia uint16_t (*mem_read16)(IPackDevice *dev, uint32_t addr); 619c16fa79SAlberto Garcia void (*mem_write16)(IPackDevice *dev, uint32_t addr, uint16_t val); 629c16fa79SAlberto Garcia 639c16fa79SAlberto Garcia uint8_t (*mem_read8)(IPackDevice *dev, uint32_t addr); 649c16fa79SAlberto Garcia void (*mem_write8)(IPackDevice *dev, uint32_t addr, uint8_t val); 659c16fa79SAlberto Garcia }; 669c16fa79SAlberto Garcia 679c16fa79SAlberto Garcia struct IPackDevice { 68227d3272SAndreas Färber /*< private >*/ 69227d3272SAndreas Färber DeviceState parent_obj; 70227d3272SAndreas Färber /*< public >*/ 71227d3272SAndreas Färber 729c16fa79SAlberto Garcia int32_t slot; 739c16fa79SAlberto Garcia /* IRQ objects for the IndustryPack INT0# and INT1# */ 749c16fa79SAlberto Garcia qemu_irq *irq; 759c16fa79SAlberto Garcia }; 769c16fa79SAlberto Garcia 779c16fa79SAlberto Garcia extern const VMStateDescription vmstate_ipack_device; 789c16fa79SAlberto Garcia 799c16fa79SAlberto Garcia #define VMSTATE_IPACK_DEVICE(_field, _state) \ 809c16fa79SAlberto Garcia VMSTATE_STRUCT(_field, _state, 1, vmstate_ipack_device, IPackDevice) 819c16fa79SAlberto Garcia 829c16fa79SAlberto Garcia IPackDevice *ipack_device_find(IPackBus *bus, int32_t slot); 8377cbb28aSAndreas Färber void ipack_bus_new_inplace(IPackBus *bus, size_t bus_size, 8477cbb28aSAndreas Färber DeviceState *parent, 859c16fa79SAlberto Garcia const char *name, uint8_t n_slots, 869c16fa79SAlberto Garcia qemu_irq_handler handler); 879c16fa79SAlberto Garcia 889c16fa79SAlberto Garcia #endif 89