virt.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. #include <ioremap.h>
  14. #ifdef RT_USING_SMART
  15. #include <mmu.h>
  16. #endif
  17. #define __REG32(x) (*((volatile unsigned int *)(x)))
  18. #define __REG16(x) (*((volatile unsigned short *)(x)))
  19. /* UART */
  20. #define PL011_UART0_BASE 0x09000000
  21. #define PL011_UART0_SIZE 0x00001000
  22. #define PL011_UART0_IRQNUM (32 + 1)
  23. /* RTC */
  24. #define PL031_RTC_BASE 0x9010000
  25. #define PL031_RTC_SIZE 0x00001000
  26. #define PL031_RTC_IRQNUM (32 + 2)
  27. /* GPIO */
  28. #define PL061_GPIO_BASE 0x09030000
  29. #define PL061_GPIO_SIZE 0x00001000
  30. #define PL061_GPIO_IRQNUM (32 + 7)
  31. /* VirtIO */
  32. #define VIRTIO_MMIO_BASE 0x0a000000
  33. #define VIRTIO_MMIO_SIZE 0x00000200
  34. #define VIRTIO_MAX_NR 32
  35. #define VIRTIO_IRQ_BASE (32 + 16)
  36. #define VIRTIO_VENDOR_ID 0x554d4551 /* "QEMU" */
  37. /* GIC */
  38. #define MAX_HANDLERS 96
  39. #define GIC_IRQ_START 0
  40. #define ARM_GIC_NR_IRQS 96
  41. #define ARM_GIC_MAX_NR 1
  42. #define IRQ_ARM_IPI_KICK 0
  43. #define IRQ_ARM_IPI_CALL 1
  44. /* GICv2 */
  45. #define GIC_PL390_DISTRIBUTOR_PPTR 0x08000000
  46. #define GIC_PL390_CONTROLLER_PPTR 0x08010000
  47. #define GIC_PL390_HYPERVISOR_BASE 0x08030000
  48. #define GIC_PL390_VIRTUAL_CPU_BASE 0x08040000
  49. /* GICv3 */
  50. #define GIC_PL500_DISTRIBUTOR_PPTR GIC_PL390_DISTRIBUTOR_PPTR
  51. #define GIC_PL500_REDISTRIBUTOR_PPTR 0x080a0000
  52. #define GIC_PL500_CONTROLLER_PPTR GIC_PL390_CONTROLLER_PPTR
  53. #define GIC_PL500_ITS_PPTR 0x08080000
  54. /* the basic constants and interfaces needed by gic */
  55. rt_inline rt_ubase_t platform_get_gic_dist_base(void)
  56. {
  57. #ifdef BSP_USING_GICV2
  58. return GIC_PL390_DISTRIBUTOR_PPTR;
  59. #else
  60. return GIC_PL500_DISTRIBUTOR_PPTR;
  61. #endif
  62. }
  63. rt_inline rt_ubase_t platform_get_gic_redist_base(void)
  64. {
  65. return GIC_PL500_REDISTRIBUTOR_PPTR;
  66. }
  67. rt_inline rt_ubase_t platform_get_gic_cpu_base(void)
  68. {
  69. #ifdef BSP_USING_GICV2
  70. return GIC_PL390_CONTROLLER_PPTR;
  71. #else
  72. return GIC_PL500_CONTROLLER_PPTR;
  73. #endif
  74. }
  75. rt_inline rt_ubase_t platform_get_gic_its_base(void)
  76. {
  77. return GIC_PL500_ITS_PPTR;
  78. }
  79. #endif