spapr_xive.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * QEMU PowerPC sPAPR XIVE interrupt controller model
  3. *
  4. * Copyright (c) 2017-2018, IBM Corporation.
  5. *
  6. * This code is licensed under the GPL version 2 or later. See the
  7. * COPYING file in the top-level directory.
  8. */
  9. #ifndef PPC_SPAPR_XIVE_H
  10. #define PPC_SPAPR_XIVE_H
  11. #include "hw/ppc/spapr_irq.h"
  12. #include "hw/ppc/xive.h"
  13. #define TYPE_SPAPR_XIVE "spapr-xive"
  14. #define SPAPR_XIVE(obj) OBJECT_CHECK(SpaprXive, (obj), TYPE_SPAPR_XIVE)
  15. #define SPAPR_XIVE_CLASS(klass) \
  16. OBJECT_CLASS_CHECK(SpaprXiveClass, (klass), TYPE_SPAPR_XIVE)
  17. #define SPAPR_XIVE_GET_CLASS(obj) \
  18. OBJECT_GET_CLASS(SpaprXiveClass, (obj), TYPE_SPAPR_XIVE)
  19. typedef struct SpaprXive {
  20. XiveRouter parent;
  21. /* Internal interrupt source for IPIs and virtual devices */
  22. XiveSource source;
  23. hwaddr vc_base;
  24. /* END ESB MMIOs */
  25. XiveENDSource end_source;
  26. hwaddr end_base;
  27. /* DT */
  28. gchar *nodename;
  29. /* Routing table */
  30. XiveEAS *eat;
  31. uint32_t nr_irqs;
  32. XiveEND *endt;
  33. uint32_t nr_ends;
  34. /* TIMA mapping address */
  35. hwaddr tm_base;
  36. MemoryRegion tm_mmio;
  37. /* KVM support */
  38. int fd;
  39. void *tm_mmap;
  40. MemoryRegion tm_mmio_kvm;
  41. VMChangeStateEntry *change;
  42. uint8_t hv_prio;
  43. } SpaprXive;
  44. typedef struct SpaprXiveClass {
  45. XiveRouterClass parent;
  46. DeviceRealize parent_realize;
  47. } SpaprXiveClass;
  48. /*
  49. * The sPAPR machine has a unique XIVE IC device. Assign a fixed value
  50. * to the controller block id value. It can nevertheless be changed
  51. * for testing purpose.
  52. */
  53. #define SPAPR_XIVE_BLOCK_ID 0x0
  54. struct SpaprMachineState;
  55. void spapr_xive_hcall_init(struct SpaprMachineState *spapr);
  56. void spapr_xive_mmio_set_enabled(SpaprXive *xive, bool enable);
  57. void spapr_xive_map_mmio(SpaprXive *xive);
  58. int spapr_xive_end_to_target(uint8_t end_blk, uint32_t end_idx,
  59. uint32_t *out_server, uint8_t *out_prio);
  60. /*
  61. * KVM XIVE device helpers
  62. */
  63. int kvmppc_xive_connect(SpaprInterruptController *intc, uint32_t nr_servers,
  64. Error **errp);
  65. void kvmppc_xive_disconnect(SpaprInterruptController *intc);
  66. void kvmppc_xive_reset(SpaprXive *xive, Error **errp);
  67. int kvmppc_xive_set_source_config(SpaprXive *xive, uint32_t lisn, XiveEAS *eas,
  68. Error **errp);
  69. void kvmppc_xive_sync_source(SpaprXive *xive, uint32_t lisn, Error **errp);
  70. uint64_t kvmppc_xive_esb_rw(XiveSource *xsrc, int srcno, uint32_t offset,
  71. uint64_t data, bool write);
  72. int kvmppc_xive_set_queue_config(SpaprXive *xive, uint8_t end_blk,
  73. uint32_t end_idx, XiveEND *end,
  74. Error **errp);
  75. int kvmppc_xive_get_queue_config(SpaprXive *xive, uint8_t end_blk,
  76. uint32_t end_idx, XiveEND *end,
  77. Error **errp);
  78. void kvmppc_xive_synchronize_state(SpaprXive *xive, Error **errp);
  79. int kvmppc_xive_pre_save(SpaprXive *xive);
  80. int kvmppc_xive_post_load(SpaprXive *xive, int version_id);
  81. #endif /* PPC_SPAPR_XIVE_H */