virt.h 2.3 KB

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