virt.h 2.3 KB

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