11f9c4cfdSAndreas Färber /* 21f9c4cfdSAndreas Färber * QEMU IndustryPack emulation 31f9c4cfdSAndreas Färber * 41f9c4cfdSAndreas Färber * Copyright (C) 2012 Igalia, S.L. 5b996aed5SAlberto Garcia * Author: Alberto Garcia <berto@igalia.com> 61f9c4cfdSAndreas Färber * 71f9c4cfdSAndreas Färber * This code is licensed under the GNU GPL v2 or (at your option) any 81f9c4cfdSAndreas Färber * later version. 91f9c4cfdSAndreas Färber */ 101f9c4cfdSAndreas Färber 111f9c4cfdSAndreas Färber #ifndef QEMU_IPACK_H 121f9c4cfdSAndreas Färber #define QEMU_IPACK_H 131f9c4cfdSAndreas Färber 14a27bd6c7SMarkus Armbruster #include "hw/qdev-core.h" 15*db1015e9SEduardo Habkost #include "qom/object.h" 161f9c4cfdSAndreas Färber 171f9c4cfdSAndreas Färber typedef struct IPackBus IPackBus; 181f9c4cfdSAndreas Färber 191f9c4cfdSAndreas Färber #define TYPE_IPACK_BUS "IndustryPack" 201f9c4cfdSAndreas Färber #define IPACK_BUS(obj) OBJECT_CHECK(IPackBus, (obj), TYPE_IPACK_BUS) 211f9c4cfdSAndreas Färber 221f9c4cfdSAndreas Färber struct IPackBus { 231f9c4cfdSAndreas Färber /*< private >*/ 241f9c4cfdSAndreas Färber BusState parent_obj; 251f9c4cfdSAndreas Färber 261f9c4cfdSAndreas Färber /* All fields are private */ 271f9c4cfdSAndreas Färber uint8_t n_slots; 281f9c4cfdSAndreas Färber uint8_t free_slot; 291f9c4cfdSAndreas Färber qemu_irq_handler set_irq; 301f9c4cfdSAndreas Färber }; 311f9c4cfdSAndreas Färber 321f9c4cfdSAndreas Färber typedef struct IPackDevice IPackDevice; 331f9c4cfdSAndreas Färber typedef struct IPackDeviceClass IPackDeviceClass; 341f9c4cfdSAndreas Färber 351f9c4cfdSAndreas Färber #define TYPE_IPACK_DEVICE "ipack-device" 361f9c4cfdSAndreas Färber #define IPACK_DEVICE(obj) \ 371f9c4cfdSAndreas Färber OBJECT_CHECK(IPackDevice, (obj), TYPE_IPACK_DEVICE) 381f9c4cfdSAndreas Färber #define IPACK_DEVICE_CLASS(klass) \ 391f9c4cfdSAndreas Färber OBJECT_CLASS_CHECK(IPackDeviceClass, (klass), TYPE_IPACK_DEVICE) 401f9c4cfdSAndreas Färber #define IPACK_DEVICE_GET_CLASS(obj) \ 411f9c4cfdSAndreas Färber OBJECT_GET_CLASS(IPackDeviceClass, (obj), TYPE_IPACK_DEVICE) 421f9c4cfdSAndreas Färber 431f9c4cfdSAndreas Färber struct IPackDeviceClass { 441f9c4cfdSAndreas Färber /*< private >*/ 451f9c4cfdSAndreas Färber DeviceClass parent_class; 461f9c4cfdSAndreas Färber /*< public >*/ 471f9c4cfdSAndreas Färber 481f9c4cfdSAndreas Färber DeviceRealize realize; 491f9c4cfdSAndreas Färber DeviceUnrealize unrealize; 501f9c4cfdSAndreas Färber 511f9c4cfdSAndreas Färber uint16_t (*io_read)(IPackDevice *dev, uint8_t addr); 521f9c4cfdSAndreas Färber void (*io_write)(IPackDevice *dev, uint8_t addr, uint16_t val); 531f9c4cfdSAndreas Färber 541f9c4cfdSAndreas Färber uint16_t (*id_read)(IPackDevice *dev, uint8_t addr); 551f9c4cfdSAndreas Färber void (*id_write)(IPackDevice *dev, uint8_t addr, uint16_t val); 561f9c4cfdSAndreas Färber 571f9c4cfdSAndreas Färber uint16_t (*int_read)(IPackDevice *dev, uint8_t addr); 581f9c4cfdSAndreas Färber void (*int_write)(IPackDevice *dev, uint8_t addr, uint16_t val); 591f9c4cfdSAndreas Färber 601f9c4cfdSAndreas Färber uint16_t (*mem_read16)(IPackDevice *dev, uint32_t addr); 611f9c4cfdSAndreas Färber void (*mem_write16)(IPackDevice *dev, uint32_t addr, uint16_t val); 621f9c4cfdSAndreas Färber 631f9c4cfdSAndreas Färber uint8_t (*mem_read8)(IPackDevice *dev, uint32_t addr); 641f9c4cfdSAndreas Färber void (*mem_write8)(IPackDevice *dev, uint32_t addr, uint8_t val); 651f9c4cfdSAndreas Färber }; 661f9c4cfdSAndreas Färber 671f9c4cfdSAndreas Färber struct IPackDevice { 681f9c4cfdSAndreas Färber /*< private >*/ 691f9c4cfdSAndreas Färber DeviceState parent_obj; 701f9c4cfdSAndreas Färber /*< public >*/ 711f9c4cfdSAndreas Färber 721f9c4cfdSAndreas Färber int32_t slot; 731f9c4cfdSAndreas Färber /* IRQ objects for the IndustryPack INT0# and INT1# */ 741f9c4cfdSAndreas Färber qemu_irq *irq; 751f9c4cfdSAndreas Färber }; 761f9c4cfdSAndreas Färber 771f9c4cfdSAndreas Färber extern const VMStateDescription vmstate_ipack_device; 781f9c4cfdSAndreas Färber 791f9c4cfdSAndreas Färber #define VMSTATE_IPACK_DEVICE(_field, _state) \ 801f9c4cfdSAndreas Färber VMSTATE_STRUCT(_field, _state, 1, vmstate_ipack_device, IPackDevice) 811f9c4cfdSAndreas Färber 821f9c4cfdSAndreas Färber IPackDevice *ipack_device_find(IPackBus *bus, int32_t slot); 831f9c4cfdSAndreas Färber void ipack_bus_new_inplace(IPackBus *bus, size_t bus_size, 841f9c4cfdSAndreas Färber DeviceState *parent, 851f9c4cfdSAndreas Färber const char *name, uint8_t n_slots, 861f9c4cfdSAndreas Färber qemu_irq_handler handler); 871f9c4cfdSAndreas Färber 881f9c4cfdSAndreas Färber #endif 89