ft2004.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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-04-29 Carl the first version
  9. *
  10. */
  11. #include <rtthread.h>
  12. #include "ft2004.h"
  13. #include "gicv3.h"
  14. rt_uint64_t get_main_cpu_affval(void)
  15. {
  16. return 0;
  17. }
  18. rt_uint32_t arm_gic_cpumask_to_affval(rt_uint32_t *cpu_mask, rt_uint32_t *cluster_id, rt_uint32_t *target_list)
  19. {
  20. if (*cpu_mask == 0)
  21. {
  22. return 0;
  23. }
  24. *target_list = 0;
  25. *cluster_id = 0;
  26. if (*cpu_mask & 0x3)
  27. {
  28. if ((*cpu_mask & 0x3) == 0x3)
  29. {
  30. *target_list = 3;
  31. }
  32. else if ((*cpu_mask & 0x1))
  33. {
  34. *target_list = 1;
  35. }
  36. else
  37. {
  38. *target_list = 2;
  39. }
  40. *cpu_mask &= ~0x3;
  41. }
  42. else if (*cpu_mask & 0xc)
  43. {
  44. *cluster_id = 0x100;
  45. if ((*cpu_mask & 0xc) == 0xc)
  46. {
  47. *target_list = 3;
  48. }
  49. else if ((*cpu_mask & 0x4))
  50. {
  51. *target_list = 1;
  52. }
  53. else
  54. {
  55. *target_list = 2;
  56. }
  57. *cpu_mask &= ~0xc;
  58. }
  59. else
  60. {
  61. *cpu_mask = 0;
  62. return 0;
  63. }
  64. return 1;
  65. }
  66. #ifdef RT_USING_SMP
  67. void send_core_isg(void)
  68. {
  69. for (rt_size_t i = 0; i <= 0xf; i++)
  70. {
  71. /* code */
  72. rt_kprintf("i %x \r\n", i);
  73. arm_gic_send_affinity_sgi(0, 0, i, 0);
  74. rt_thread_mdelay(100);
  75. }
  76. }
  77. MSH_CMD_EXPORT(send_core_isg, send_core_isg);
  78. #endif