phytium_cpu.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * Copyright (c) 2006-2023, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Email: opensource_embedded@phytium.com.cn
  7. *
  8. * Change Logs:
  9. * Date Author Notes
  10. * 2022-10-26 huanghe first commit
  11. *
  12. */
  13. #ifndef __PHYTIUM_CPU_H__
  14. #define __PHYTIUM_CPU_H__
  15. #include <rthw.h>
  16. #include <rtthread.h>
  17. #include "fparameters.h"
  18. #define ARM_GIC_MAX_NR 1
  19. #if defined(TARGET_FT2000_4) || defined(TARGET_D2000)
  20. #define MAX_HANDLERS 160
  21. #endif
  22. #if defined(TARGET_E2000)
  23. #define MAX_HANDLERS 270
  24. #define ARM_GIC_CPU_NUM 4
  25. #endif
  26. #define GIC_IRQ_START 0
  27. #define GIC_ACK_INTID_MASK 0x000003ff
  28. rt_uint64_t get_main_cpu_affval(void);
  29. rt_inline rt_uint32_t platform_get_gic_dist_base(void)
  30. {
  31. return GICV3_DISTRIBUTOR_BASE_ADDR;
  32. }
  33. #if defined(TARGET_ARMV8_AARCH64)
  34. /* the basic constants and interfaces needed by gic */
  35. rt_inline rt_uint32_t platform_get_gic_redist_base(void)
  36. {
  37. extern int phytium_cpu_id(void);
  38. #if RT_CPUS_NR <= 2
  39. s32 cpu_offset = 0;
  40. #if defined(FT_GIC_REDISTRUBUTIOR_OFFSET)
  41. cpu_offset = FT_GIC_REDISTRUBUTIOR_OFFSET ;
  42. #endif
  43. #if defined(TARGET_E2000Q)
  44. u32 cpu_id = 0;
  45. cpu_id = phytium_cpu_id();
  46. switch (cpu_id)
  47. {
  48. case 0:
  49. case 1:
  50. cpu_offset = 2;
  51. break;
  52. case 2:
  53. case 3:
  54. cpu_offset = -2;
  55. default:
  56. break;
  57. }
  58. rt_kprintf("cpu_id is %d \r\n",cpu_id);
  59. #endif
  60. rt_kprintf("offset is %d\n", cpu_offset);
  61. return (GICV3_RD_BASE_ADDR + (cpu_offset) * GICV3_RD_OFFSET);
  62. #else
  63. return (GICV3_RD_BASE_ADDR);
  64. #endif
  65. }
  66. rt_inline rt_uint32_t platform_get_gic_cpu_base(void)
  67. {
  68. return 0U; /* unused in gicv3 */
  69. }
  70. #endif
  71. int phytium_cpu_id_mapping(int cpu_id);
  72. #endif // !