plic.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * Copyright (c) 2006-2023, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2021-10-19 JasonHu first version
  9. * 2023-04-22 flyingcys add C906_PLIC_PHY_ADDR macro judge
  10. */
  11. #ifndef __RISCV64_PLIC_H__
  12. #define __RISCV64_PLIC_H__
  13. #include <rt_interrupt.h>
  14. #ifndef C906_PLIC_PHY_ADDR
  15. #define C906_PLIC_PHY_ADDR (0x10000000)
  16. #endif
  17. #define C906_PLIC_NR_EXT_IRQS (IRQ_MAX_NR)
  18. #define C906_NR_CPUS (NR_CPUS)
  19. /* M and S mode context. */
  20. #define C906_NR_CONTEXT (2)
  21. #define MAX_DEVICES 1024
  22. #define MAX_CONTEXTS 15872
  23. /*
  24. * Each interrupt source has a priority register associated with it.
  25. * We always hardwire it to one in Linux.
  26. */
  27. #define PRIORITY_BASE 0
  28. #define PRIORITY_PER_ID 4
  29. /*
  30. * Each hart context has a vector of interrupt enable bits associated with it.
  31. * There's one bit for each interrupt source.
  32. */
  33. #define ENABLE_BASE 0x2000
  34. #define ENABLE_PER_HART 0x80
  35. /*
  36. * Each hart context has a set of control registers associated with it. Right
  37. * now there's only two: a source priority threshold over which the hart will
  38. * take an interrupt, and a register to claim interrupts.
  39. */
  40. #define CONTEXT_BASE 0x200000
  41. #define CONTEXT_PER_HART 0x1000
  42. #define CONTEXT_THRESHOLD 0x00
  43. #define CONTEXT_CLAIM 0x04
  44. void plic_init(void);
  45. void plic_enable_irq(int irqno);
  46. void plic_disable_irq(int irqno);
  47. // tell PLIC that we've served this IRQ
  48. void plic_complete(int irq);
  49. void plic_handle_irq(void);
  50. #endif