cpu.h 1.1 KB

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