plic.h 1.6 KB

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