cpu.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. struct cpu_ops_t
  15. {
  16. const char *method;
  17. int (*cpu_init)(rt_uint32_t id);
  18. int (*cpu_boot)(rt_uint32_t id);
  19. void (*cpu_shutdown)(void);
  20. };
  21. /**
  22. * Identifier to mark a wrong CPU MPID.
  23. * All elements in rt_cpu_mpidr_early[] should be initialized with this value
  24. */
  25. #define ID_ERROR __INT64_MAX__
  26. extern rt_uint64_t rt_cpu_mpidr_early[];
  27. extern struct dtb_node *_cpu_node[];
  28. #define cpuid_to_hwid(cpuid) \
  29. ((((cpuid) >= 0) && ((cpuid) < RT_CPUS_NR)) ? rt_cpu_mpidr_early[cpuid] : ID_ERROR)
  30. #define set_hwid(cpuid, hwid) \
  31. ((((cpuid) >= 0) && ((cpuid) < RT_CPUS_NR)) ? (rt_cpu_mpidr_early[cpuid] = (hwid)) : ID_ERROR)
  32. #define get_cpu_node(cpuid) \
  33. ((((cpuid) >= 0) && ((cpuid) < RT_CPUS_NR)) ? _cpu_node[cpuid] : NULL)
  34. #define set_cpu_node(cpuid, node) \
  35. ((((cpuid) >= 0) && ((cpuid) < RT_CPUS_NR)) ? (_cpu_node[cpuid] = node) : NULL)
  36. extern void rt_hw_cpu_shutdown(void);
  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 struct cpu_ops_t cpu_ops_psci;
  40. extern struct cpu_ops_t cpu_ops_spin_tbl;
  41. #endif /* __RT_HW_CPU_H__ */