phytium_cpu.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * Copyright (c) 2006-2021, 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. #define MAX_HANDLERS 160
  20. #define GIC_IRQ_START 0
  21. #define GIC_ACK_INTID_MASK 0x000003ff
  22. rt_uint64_t get_main_cpu_affval(void);
  23. rt_inline rt_uint32_t platform_get_gic_dist_base(void)
  24. {
  25. return GICV3_DISTRIBUTOR_BASEADDRESS;
  26. }
  27. #if defined(TARGET_ARMV8_AARCH64)
  28. /* the basic constants and interfaces needed by gic */
  29. rt_inline rt_uint32_t platform_get_gic_redist_base(void)
  30. {
  31. extern int phytium_cpu_id(void);
  32. s32 cpu_offset = 0;
  33. #if defined(FT_GIC_REDISTRUBUTIOR_OFFSET)
  34. cpu_offset = FT_GIC_REDISTRUBUTIOR_OFFSET ;
  35. #endif
  36. #if defined(TARGET_E2000Q)
  37. u32 cpu_id = 0;
  38. cpu_id = phytium_cpu_id();
  39. switch (cpu_id)
  40. {
  41. case 0:
  42. case 1:
  43. cpu_offset = 2;
  44. break;
  45. case 2:
  46. case 3:
  47. cpu_offset = -2;
  48. default:
  49. break;
  50. }
  51. #endif
  52. rt_kprintf("offset is %x\n", cpu_offset);
  53. return (GICV3_RD_BASEADDRESS + (cpu_offset) * GICV3_RD_OFFSET);
  54. }
  55. rt_inline rt_uint32_t platform_get_gic_cpu_base(void)
  56. {
  57. return 0U; /* unused in gicv3 */
  58. }
  59. #endif
  60. int phytium_cpu_id_mapping(int cpu_id);
  61. #endif // !