phytium_cpu.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. #endif
  25. #define GIC_IRQ_START 0
  26. #define GIC_ACK_INTID_MASK 0x000003ff
  27. rt_uint64_t get_main_cpu_affval(void);
  28. rt_inline rt_uint32_t platform_get_gic_dist_base(void)
  29. {
  30. return GICV3_DISTRIBUTOR_BASE_ADDR;
  31. }
  32. #if defined(TARGET_ARMV8_AARCH64)
  33. /* the basic constants and interfaces needed by gic */
  34. rt_inline rt_uint32_t platform_get_gic_redist_base(void)
  35. {
  36. extern int phytium_cpu_id(void);
  37. #if RT_CPUS_NR <= 2
  38. s32 cpu_offset = 0;
  39. #if defined(FT_GIC_REDISTRUBUTIOR_OFFSET)
  40. cpu_offset = FT_GIC_REDISTRUBUTIOR_OFFSET ;
  41. #endif
  42. #if defined(TARGET_E2000Q) || defined(TARGET_PHYTIUMPI)
  43. u32 cpu_id = 0;
  44. cpu_id = phytium_cpu_id();
  45. switch (cpu_id)
  46. {
  47. case 0:
  48. case 1:
  49. cpu_offset = 2;
  50. break;
  51. case 2:
  52. case 3:
  53. cpu_offset = -2;
  54. default:
  55. break;
  56. }
  57. rt_kprintf("cpu_id is %d \r\n", cpu_id);
  58. #endif
  59. rt_kprintf("offset is %d\n", cpu_offset);
  60. return (GICV3_RD_BASE_ADDR + (cpu_offset) * GICV3_RD_OFFSET);
  61. #else
  62. return (GICV3_RD_BASE_ADDR);
  63. #endif
  64. }
  65. rt_inline rt_uint32_t platform_get_gic_cpu_base(void)
  66. {
  67. return 0U; /* unused in gicv3 */
  68. }
  69. #endif
  70. int phytium_cpu_id_mapping(int cpu_id);
  71. #endif // !