virt.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. /* GPIO */
  22. #define PL061_GPIO_BASE 0x09030000
  23. #define PL061_GPIO_SIZE 0x00001000
  24. #define PL061_GPIO_IRQNUM (32 + 7)
  25. /* VirtIO */
  26. #define VIRTIO_MMIO_BASE 0x0a000000
  27. #define VIRTIO_MMIO_SIZE 0x00000200
  28. #define VIRTIO_MAX_NR 32
  29. #define VIRTIO_IRQ_BASE (32 + 16)
  30. #define VIRTIO_VENDOR_ID 0x554d4551 /* "QEMU" */
  31. /* GIC */
  32. #define MAX_HANDLERS 96
  33. #define GIC_IRQ_START 0
  34. #define ARM_GIC_NR_IRQS 96
  35. #define ARM_GIC_MAX_NR 1
  36. #define IRQ_ARM_IPI_KICK 0
  37. #define IRQ_ARM_IPI_CALL 1
  38. /* GICv2 */
  39. #define GIC_PL390_DISTRIBUTOR_PPTR 0x08000000
  40. #define GIC_PL390_CONTROLLER_PPTR 0x08010000
  41. /* GICv3 */
  42. #define GIC_PL500_DISTRIBUTOR_PPTR GIC_PL390_DISTRIBUTOR_PPTR
  43. #define GIC_PL500_REDISTRIBUTOR_PPTR 0x080a0000
  44. #define GIC_PL500_CONTROLLER_PPTR GIC_PL390_CONTROLLER_PPTR
  45. #define GIC_PL500_ITS_PPTR 0x08080000
  46. /* the basic constants and interfaces needed by gic */
  47. rt_inline rt_uint32_t platform_get_gic_dist_base(void)
  48. {
  49. #ifdef BSP_USING_GICV2
  50. return GIC_PL390_DISTRIBUTOR_PPTR;
  51. #else
  52. return GIC_PL500_DISTRIBUTOR_PPTR;
  53. #endif
  54. }
  55. rt_inline rt_uint32_t platform_get_gic_redist_base(void)
  56. {
  57. return GIC_PL500_REDISTRIBUTOR_PPTR;
  58. }
  59. rt_inline rt_uint32_t platform_get_gic_cpu_base(void)
  60. {
  61. #ifdef BSP_USING_GICV2
  62. return GIC_PL390_CONTROLLER_PPTR;
  63. #else
  64. return GIC_PL500_CONTROLLER_PPTR;
  65. #endif
  66. }
  67. rt_inline rt_uint32_t platform_get_gic_its_base(void)
  68. {
  69. return GIC_PL500_ITS_PPTR;
  70. }
  71. #endif