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 14*a27bd6c7SMarkus Armbruster #include "hw/qdev-core.h" 151f9c4cfdSAndreas Färber 161f9c4cfdSAndreas Färber typedef struct IPackBus IPackBus; 171f9c4cfdSAndreas Färber 181f9c4cfdSAndreas Färber #define TYPE_IPACK_BUS "IndustryPack" 191f9c4cfdSAndreas Färber #define IPACK_BUS(obj) OBJECT_CHECK(IPackBus, (obj), TYPE_IPACK_BUS) 201f9c4cfdSAndreas Färber 211f9c4cfdSAndreas Färber struct IPackBus { 221f9c4cfdSAndreas Färber /*< private >*/ 231f9c4cfdSAndreas Färber BusState parent_obj; 241f9c4cfdSAndreas Färber 251f9c4cfdSAndreas Färber /* All fields are private */ 261f9c4cfdSAndreas Färber uint8_t n_slots; 271f9c4cfdSAndreas Färber uint8_t free_slot; 281f9c4cfdSAndreas Färber qemu_irq_handler set_irq; 291f9c4cfdSAndreas Färber }; 301f9c4cfdSAndreas Färber 311f9c4cfdSAndreas Färber typedef struct IPackDevice IPackDevice; 321f9c4cfdSAndreas Färber typedef struct IPackDeviceClass IPackDeviceClass; 331f9c4cfdSAndreas Färber 341f9c4cfdSAndreas Färber #define TYPE_IPACK_DEVICE "ipack-device" 351f9c4cfdSAndreas Färber #define IPACK_DEVICE(obj) \ 361f9c4cfdSAndreas Färber OBJECT_CHECK(IPackDevice, (obj), TYPE_IPACK_DEVICE) 371f9c4cfdSAndreas Färber #define IPACK_DEVICE_CLASS(klass) \ 381f9c4cfdSAndreas Färber OBJECT_CLASS_CHECK(IPackDeviceClass, (klass), TYPE_IPACK_DEVICE) 391f9c4cfdSAndreas Färber #define IPACK_DEVICE_GET_CLASS(obj) \ 401f9c4cfdSAndreas Färber OBJECT_GET_CLASS(IPackDeviceClass, (obj), TYPE_IPACK_DEVICE) 411f9c4cfdSAndreas Färber 421f9c4cfdSAndreas Färber struct IPackDeviceClass { 431f9c4cfdSAndreas Färber /*< private >*/ 441f9c4cfdSAndreas Färber DeviceClass parent_class; 451f9c4cfdSAndreas Färber /*< public >*/ 461f9c4cfdSAndreas Färber 471f9c4cfdSAndreas Färber DeviceRealize realize; 481f9c4cfdSAndreas Färber DeviceUnrealize unrealize; 491f9c4cfdSAndreas Färber 501f9c4cfdSAndreas Färber uint16_t (*io_read)(IPackDevice *dev, uint8_t addr); 511f9c4cfdSAndreas Färber void (*io_write)(IPackDevice *dev, uint8_t addr, uint16_t val); 521f9c4cfdSAndreas Färber 531f9c4cfdSAndreas Färber uint16_t (*id_read)(IPackDevice *dev, uint8_t addr); 541f9c4cfdSAndreas Färber void (*id_write)(IPackDevice *dev, uint8_t addr, uint16_t val); 551f9c4cfdSAndreas Färber 561f9c4cfdSAndreas Färber uint16_t (*int_read)(IPackDevice *dev, uint8_t addr); 571f9c4cfdSAndreas Färber void (*int_write)(IPackDevice *dev, uint8_t addr, uint16_t val); 581f9c4cfdSAndreas Färber 591f9c4cfdSAndreas Färber uint16_t (*mem_read16)(IPackDevice *dev, uint32_t addr); 601f9c4cfdSAndreas Färber void (*mem_write16)(IPackDevice *dev, uint32_t addr, uint16_t val); 611f9c4cfdSAndreas Färber 621f9c4cfdSAndreas Färber uint8_t (*mem_read8)(IPackDevice *dev, uint32_t addr); 631f9c4cfdSAndreas Färber void (*mem_write8)(IPackDevice *dev, uint32_t addr, uint8_t val); 641f9c4cfdSAndreas Färber }; 651f9c4cfdSAndreas Färber 661f9c4cfdSAndreas Färber struct IPackDevice { 671f9c4cfdSAndreas Färber /*< private >*/ 681f9c4cfdSAndreas Färber DeviceState parent_obj; 691f9c4cfdSAndreas Färber /*< public >*/ 701f9c4cfdSAndreas Färber 711f9c4cfdSAndreas Färber int32_t slot; 721f9c4cfdSAndreas Färber /* IRQ objects for the IndustryPack INT0# and INT1# */ 731f9c4cfdSAndreas Färber qemu_irq *irq; 741f9c4cfdSAndreas Färber }; 751f9c4cfdSAndreas Färber 761f9c4cfdSAndreas Färber extern const VMStateDescription vmstate_ipack_device; 771f9c4cfdSAndreas Färber 781f9c4cfdSAndreas Färber #define VMSTATE_IPACK_DEVICE(_field, _state) \ 791f9c4cfdSAndreas Färber VMSTATE_STRUCT(_field, _state, 1, vmstate_ipack_device, IPackDevice) 801f9c4cfdSAndreas Färber 811f9c4cfdSAndreas Färber IPackDevice *ipack_device_find(IPackBus *bus, int32_t slot); 821f9c4cfdSAndreas Färber void ipack_bus_new_inplace(IPackBus *bus, size_t bus_size, 831f9c4cfdSAndreas Färber DeviceState *parent, 841f9c4cfdSAndreas Färber const char *name, uint8_t n_slots, 851f9c4cfdSAndreas Färber qemu_irq_handler handler); 861f9c4cfdSAndreas Färber 871f9c4cfdSAndreas Färber #endif 88