cpu.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * Copyright (c) 2006-2019, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. */
  9. #ifndef __RT_HW_CPU_H__
  10. #define __RT_HW_CPU_H__
  11. #include <rthw.h>
  12. #include <rtthread.h>
  13. #include <stdbool.h>
  14. #ifdef RT_USING_SMP
  15. struct cpu_ops_t
  16. {
  17. const char *method;
  18. int (*cpu_init)(rt_uint32_t id);
  19. int (*cpu_boot)(rt_uint32_t id);
  20. void (*cpu_shutdown)(void);
  21. };
  22. /**
  23. * Identifier to mark a wrong CPU MPID.
  24. * All elements in rt_cpu_mpidr_early[] should be initialized with this value
  25. */
  26. #define ID_ERROR __INT64_MAX__
  27. extern rt_uint64_t rt_cpu_mpidr_early[];
  28. extern struct dtb_node *_cpu_node[];
  29. #define cpuid_to_hwid(cpuid) \
  30. ((((cpuid) >= 0) && ((cpuid) < RT_CPUS_NR)) ? rt_cpu_mpidr_early[cpuid] : ID_ERROR)
  31. #define set_hwid(cpuid, hwid) \
  32. ((((cpuid) >= 0) && ((cpuid) < RT_CPUS_NR)) ? (rt_cpu_mpidr_early[cpuid] = (hwid)) : ID_ERROR)
  33. #define get_cpu_node(cpuid) \
  34. ((((cpuid) >= 0) && ((cpuid) < RT_CPUS_NR)) ? _cpu_node[cpuid] : NULL)
  35. #define set_cpu_node(cpuid, node) \
  36. ((((cpuid) >= 0) && ((cpuid) < RT_CPUS_NR)) ? (_cpu_node[cpuid] = node) : NULL)
  37. extern int rt_hw_cpu_init();
  38. extern int rt_hw_cpu_boot_secondary(int num_cpus, rt_uint64_t *cpu_hw_ids, struct cpu_ops_t *cpu_ops[]);
  39. extern void rt_hw_secondary_cpu_idle_exec(void);
  40. extern struct cpu_ops_t cpu_ops_psci;
  41. extern struct cpu_ops_t cpu_ops_spin_tbl;
  42. #endif /* RT_USING_SMP */
  43. extern void (*system_off)(void);
  44. #endif /* __RT_HW_CPU_H__ */