ipack.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * QEMU IndustryPack emulation
  3. *
  4. * Copyright (C) 2012 Igalia, S.L.
  5. * Author: Alberto Garcia <agarcia@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 "qdev.h"
  13. typedef struct IPackBus IPackBus;
  14. #define TYPE_IPACK_BUS "IndustryPack"
  15. #define IPACK_BUS(obj) OBJECT_CHECK(IPackBus, (obj), TYPE_IPACK_BUS)
  16. struct IPackBus {
  17. BusState qbus;
  18. /* All fields are private */
  19. uint8_t n_slots;
  20. uint8_t free_slot;
  21. qemu_irq_handler set_irq;
  22. };
  23. typedef struct IPackDevice IPackDevice;
  24. typedef struct IPackDeviceClass IPackDeviceClass;
  25. #define TYPE_IPACK_DEVICE "ipack-device"
  26. #define IPACK_DEVICE(obj) \
  27. OBJECT_CHECK(IPackDevice, (obj), TYPE_IPACK_DEVICE)
  28. #define IPACK_DEVICE_CLASS(klass) \
  29. OBJECT_CLASS_CHECK(IPackDeviceClass, (klass), TYPE_IPACK_DEVICE)
  30. #define IPACK_DEVICE_GET_CLASS(obj) \
  31. OBJECT_GET_CLASS(IPackDeviceClass, (obj), TYPE_IPACK_DEVICE)
  32. struct IPackDeviceClass {
  33. DeviceClass parent_class;
  34. int (*init)(IPackDevice *dev);
  35. int (*exit)(IPackDevice *dev);
  36. uint16_t (*io_read)(IPackDevice *dev, uint8_t addr);
  37. void (*io_write)(IPackDevice *dev, uint8_t addr, uint16_t val);
  38. uint16_t (*id_read)(IPackDevice *dev, uint8_t addr);
  39. void (*id_write)(IPackDevice *dev, uint8_t addr, uint16_t val);
  40. uint16_t (*int_read)(IPackDevice *dev, uint8_t addr);
  41. void (*int_write)(IPackDevice *dev, uint8_t addr, uint16_t val);
  42. uint16_t (*mem_read16)(IPackDevice *dev, uint32_t addr);
  43. void (*mem_write16)(IPackDevice *dev, uint32_t addr, uint16_t val);
  44. uint8_t (*mem_read8)(IPackDevice *dev, uint32_t addr);
  45. void (*mem_write8)(IPackDevice *dev, uint32_t addr, uint8_t val);
  46. };
  47. struct IPackDevice {
  48. DeviceState qdev;
  49. int32_t slot;
  50. /* IRQ objects for the IndustryPack INT0# and INT1# */
  51. qemu_irq *irq;
  52. };
  53. extern const VMStateDescription vmstate_ipack_device;
  54. #define VMSTATE_IPACK_DEVICE(_field, _state) \
  55. VMSTATE_STRUCT(_field, _state, 1, vmstate_ipack_device, IPackDevice)
  56. IPackDevice *ipack_device_find(IPackBus *bus, int32_t slot);
  57. void ipack_bus_new_inplace(IPackBus *bus, DeviceState *parent,
  58. const char *name, uint8_t n_slots,
  59. qemu_irq_handler handler);
  60. #endif