sifive_plic.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * SiFive PLIC (Platform Level Interrupt Controller) interface
  3. *
  4. * Copyright (c) 2017 SiFive, Inc.
  5. *
  6. * This provides a RISC-V PLIC device
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms and conditions of the GNU General Public License,
  10. * version 2 or later, as published by the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope it will be useful, but WITHOUT
  13. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  15. * more details.
  16. *
  17. * You should have received a copy of the GNU General Public License along with
  18. * this program. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. #ifndef HW_SIFIVE_PLIC_H
  21. #define HW_SIFIVE_PLIC_H
  22. #include "hw/sysbus.h"
  23. #include "qom/object.h"
  24. #define TYPE_SIFIVE_PLIC "riscv.sifive.plic"
  25. typedef struct SiFivePLICState SiFivePLICState;
  26. DECLARE_INSTANCE_CHECKER(SiFivePLICState, SIFIVE_PLIC,
  27. TYPE_SIFIVE_PLIC)
  28. typedef enum PLICMode {
  29. PLICMode_U,
  30. PLICMode_S,
  31. PLICMode_M
  32. } PLICMode;
  33. typedef struct PLICAddr {
  34. uint32_t addrid;
  35. uint32_t hartid;
  36. PLICMode mode;
  37. } PLICAddr;
  38. struct SiFivePLICState {
  39. /*< private >*/
  40. SysBusDevice parent_obj;
  41. /*< public >*/
  42. MemoryRegion mmio;
  43. uint32_t num_addrs;
  44. uint32_t num_harts;
  45. uint32_t bitfield_words;
  46. uint32_t num_enables;
  47. PLICAddr *addr_config;
  48. uint32_t *source_priority;
  49. uint32_t *target_priority;
  50. uint32_t *pending;
  51. uint32_t *claimed;
  52. uint32_t *enable;
  53. /* config */
  54. char *hart_config;
  55. uint32_t hartid_base;
  56. uint32_t num_sources;
  57. uint32_t num_priorities;
  58. uint32_t priority_base;
  59. uint32_t pending_base;
  60. uint32_t enable_base;
  61. uint32_t enable_stride;
  62. uint32_t context_base;
  63. uint32_t context_stride;
  64. uint32_t aperture_size;
  65. qemu_irq *m_external_irqs;
  66. qemu_irq *s_external_irqs;
  67. };
  68. DeviceState *sifive_plic_create(hwaddr addr, char *hart_config,
  69. uint32_t num_harts,
  70. uint32_t hartid_base, uint32_t num_sources,
  71. uint32_t num_priorities, uint32_t priority_base,
  72. uint32_t pending_base, uint32_t enable_base,
  73. uint32_t enable_stride, uint32_t context_base,
  74. uint32_t context_stride, uint32_t aperture_size);
  75. #endif