ipack.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * QEMU IndustryPack emulation
  3. *
  4. * Copyright (C) 2012 Igalia, S.L.
  5. * Author: Alberto Garcia <berto@igalia.com>
  6. *
  7. * This code is licensed under the GNU GPL v2 or (at your option) any
  8. * later version.
  9. */
  10. #ifndef QEMU_IPACK_H
  11. #define QEMU_IPACK_H
  12. #include "hw/qdev-core.h"
  13. #include "hw/irq.h"
  14. #include "qom/object.h"
  15. #define TYPE_IPACK_BUS "IndustryPack"
  16. OBJECT_DECLARE_SIMPLE_TYPE(IPackBus, IPACK_BUS)
  17. struct IPackBus {
  18. BusState parent_obj;
  19. uint8_t n_slots;
  20. uint8_t free_slot;
  21. qemu_irq_handler set_irq;
  22. };
  23. #define TYPE_IPACK_DEVICE "ipack-device"
  24. OBJECT_DECLARE_TYPE(IPackDevice, IPackDeviceClass,
  25. IPACK_DEVICE)
  26. struct IPackDeviceClass {
  27. /*< private >*/
  28. DeviceClass parent_class;
  29. /*< public >*/
  30. DeviceRealize realize;
  31. DeviceUnrealize unrealize;
  32. uint16_t (*io_read)(IPackDevice *dev, uint8_t addr);
  33. void (*io_write)(IPackDevice *dev, uint8_t addr, uint16_t val);
  34. uint16_t (*id_read)(IPackDevice *dev, uint8_t addr);
  35. void (*id_write)(IPackDevice *dev, uint8_t addr, uint16_t val);
  36. uint16_t (*int_read)(IPackDevice *dev, uint8_t addr);
  37. void (*int_write)(IPackDevice *dev, uint8_t addr, uint16_t val);
  38. uint16_t (*mem_read16)(IPackDevice *dev, uint32_t addr);
  39. void (*mem_write16)(IPackDevice *dev, uint32_t addr, uint16_t val);
  40. uint8_t (*mem_read8)(IPackDevice *dev, uint32_t addr);
  41. void (*mem_write8)(IPackDevice *dev, uint32_t addr, uint8_t val);
  42. };
  43. struct IPackDevice {
  44. DeviceState parent_obj;
  45. int32_t slot;
  46. /* IRQ objects for the IndustryPack INT0# and INT1# */
  47. IRQState irq[2];
  48. };
  49. extern const VMStateDescription vmstate_ipack_device;
  50. #define VMSTATE_IPACK_DEVICE(_field, _state) \
  51. VMSTATE_STRUCT(_field, _state, 1, vmstate_ipack_device, IPackDevice)
  52. IPackDevice *ipack_device_find(IPackBus *bus, int32_t slot);
  53. void ipack_bus_init(IPackBus *bus, size_t bus_size,
  54. DeviceState *parent,
  55. uint8_t n_slots,
  56. qemu_irq_handler handler);
  57. #endif