parameters.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. #include "rtconfig.h"
  14. #include <rtthread.h>
  15. #include "fcpu_info.h"
  16. #include "fparameters.h"
  17. u32 GetCpuMaskToAffval(u32 *cpu_mask, u32 *cluster_id, u32 *target_list)
  18. {
  19. if (*cpu_mask == 0)
  20. {
  21. return 0;
  22. }
  23. *target_list = 0;
  24. *cluster_id = 0;
  25. if (*cpu_mask & 0x3)
  26. {
  27. if ((*cpu_mask & 0x3) == 0x3)
  28. {
  29. *target_list = 3;
  30. }
  31. else if ((*cpu_mask & 0x1))
  32. {
  33. *target_list = 1;
  34. }
  35. else
  36. {
  37. *target_list = 2;
  38. }
  39. *cpu_mask &= ~0x3;
  40. }
  41. else if (*cpu_mask & 0xc)
  42. {
  43. *cluster_id = 0x100;
  44. if ((*cpu_mask & 0xc) == 0xc)
  45. {
  46. *target_list = 3;
  47. }
  48. else if ((*cpu_mask & 0x4))
  49. {
  50. *target_list = 1;
  51. }
  52. else
  53. {
  54. *target_list = 2;
  55. }
  56. *cpu_mask &= ~0xc;
  57. }
  58. else
  59. {
  60. *cpu_mask = 0;
  61. return 0;
  62. }
  63. return 1;
  64. }