smp.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #ifndef __ASM_SH_SMP_H
  2. #define __ASM_SH_SMP_H
  3. #include <linux/bitops.h>
  4. #include <linux/cpumask.h>
  5. #include <asm/smp-ops.h>
  6. #ifdef CONFIG_SMP
  7. #include <linux/spinlock.h>
  8. #include <linux/atomic.h>
  9. #include <asm/current.h>
  10. #include <asm/percpu.h>
  11. #define raw_smp_processor_id() (current_thread_info()->cpu)
  12. /* Map from cpu id to sequential logical cpu number. */
  13. extern int __cpu_number_map[NR_CPUS];
  14. #define cpu_number_map(cpu) __cpu_number_map[cpu]
  15. /* The reverse map from sequential logical cpu number to cpu id. */
  16. extern int __cpu_logical_map[NR_CPUS];
  17. #define cpu_logical_map(cpu) __cpu_logical_map[cpu]
  18. enum {
  19. SMP_MSG_FUNCTION,
  20. SMP_MSG_RESCHEDULE,
  21. SMP_MSG_FUNCTION_SINGLE,
  22. SMP_MSG_TIMER,
  23. SMP_MSG_NR, /* must be last */
  24. };
  25. DECLARE_PER_CPU(int, cpu_state);
  26. void smp_message_recv(unsigned int msg);
  27. void arch_send_call_function_single_ipi(int cpu);
  28. void arch_send_call_function_ipi_mask(const struct cpumask *mask);
  29. void native_play_dead(void);
  30. void native_cpu_die(unsigned int cpu);
  31. int native_cpu_disable(unsigned int cpu);
  32. #ifdef CONFIG_HOTPLUG_CPU
  33. void play_dead_common(void);
  34. extern int __cpu_disable(void);
  35. static inline void __cpu_die(unsigned int cpu)
  36. {
  37. extern struct plat_smp_ops *mp_ops; /* private */
  38. mp_ops->cpu_die(cpu);
  39. }
  40. #endif
  41. static inline int hard_smp_processor_id(void)
  42. {
  43. extern struct plat_smp_ops *mp_ops; /* private */
  44. if (!mp_ops)
  45. return 0; /* boot CPU */
  46. return mp_ops->smp_processor_id();
  47. }
  48. struct of_cpu_method {
  49. const char *method;
  50. struct plat_smp_ops *ops;
  51. };
  52. #define CPU_METHOD_OF_DECLARE(name, _method, _ops) \
  53. static const struct of_cpu_method __cpu_method_of_table_##name \
  54. __used __section(__cpu_method_of_table) \
  55. = { .method = _method, .ops = _ops }
  56. #else
  57. #define hard_smp_processor_id() (0)
  58. #endif /* CONFIG_SMP */
  59. #endif /* __ASM_SH_SMP_H */