virt.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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-02-17 GuEe-GUI the first version
  9. */
  10. #ifndef VIRT_H__
  11. #define VIRT_H__
  12. #include <rtdef.h>
  13. /* UART */
  14. #define PL011_UART0_BASE 0x09000000
  15. #define PL011_UART0_SIZE 0x00001000
  16. #define PL011_UART0_IRQNUM (32 + 1)
  17. /* RTC */
  18. #define PL031_RTC_BASE 0x9010000
  19. #define PL031_RTC_SIZE 0x00001000
  20. #define PL031_RTC_IRQNUM (32 + 2)
  21. /* VirtIO */
  22. #define VIRTIO_MMIO_BASE 0x0a000000
  23. #define VIRTIO_MMIO_SIZE 0x00000200
  24. #define VIRTIO_MAX_NR 32
  25. #define VIRTIO_IRQ_BASE (32 + 16)
  26. #define VIRTIO_VENDOR_ID 0x554d4551 /* "QEMU" */
  27. /* GIC */
  28. #define MAX_HANDLERS 96
  29. #define GIC_IRQ_START 0
  30. #define ARM_GIC_NR_IRQS 96
  31. #define ARM_GIC_MAX_NR 1
  32. #define IRQ_ARM_IPI_KICK 0
  33. #define IRQ_ARM_IPI_CALL 1
  34. /* GICv2 */
  35. #define GIC_PL390_DISTRIBUTOR_PPTR 0x08000000
  36. #define GIC_PL390_CONTROLLER_PPTR 0x08010000
  37. /* GICv3 */
  38. #define GIC_PL500_DISTRIBUTOR_PPTR GIC_PL390_DISTRIBUTOR_PPTR
  39. #define GIC_PL500_REDISTRIBUTOR_PPTR 0x080a0000
  40. #define GIC_PL500_CONTROLLER_PPTR GIC_PL390_CONTROLLER_PPTR
  41. #define GIC_PL500_ITS_PPTR 0x08080000
  42. /* the basic constants and interfaces needed by gic */
  43. rt_inline rt_uint32_t platform_get_gic_dist_base(void)
  44. {
  45. #ifdef BSP_USING_GICV2
  46. return GIC_PL390_DISTRIBUTOR_PPTR;
  47. #else
  48. return GIC_PL500_DISTRIBUTOR_PPTR;
  49. #endif
  50. }
  51. rt_inline rt_uint32_t platform_get_gic_redist_base(void)
  52. {
  53. return GIC_PL500_REDISTRIBUTOR_PPTR;
  54. }
  55. rt_inline rt_uint32_t platform_get_gic_cpu_base(void)
  56. {
  57. #ifdef BSP_USING_GICV2
  58. return GIC_PL390_CONTROLLER_PPTR;
  59. #else
  60. return GIC_PL500_CONTROLLER_PPTR;
  61. #endif
  62. }
  63. rt_inline rt_uint32_t platform_get_gic_its_base(void)
  64. {
  65. return GIC_PL500_ITS_PPTR;
  66. }
  67. #endif