smp.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. /*
  2. * smp.h: PowerPC-specific SMP code.
  3. *
  4. * Original was a copy of sparc smp.h. Now heavily modified
  5. * for PPC.
  6. *
  7. * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
  8. * Copyright (C) 1996-2001 Cort Dougan <cort@fsmlabs.com>
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License
  12. * as published by the Free Software Foundation; either version
  13. * 2 of the License, or (at your option) any later version.
  14. */
  15. #ifndef _ASM_POWERPC_SMP_H
  16. #define _ASM_POWERPC_SMP_H
  17. #ifdef __KERNEL__
  18. #include <linux/threads.h>
  19. #include <linux/cpumask.h>
  20. #include <linux/kernel.h>
  21. #ifndef __ASSEMBLY__
  22. #ifdef CONFIG_PPC64
  23. #include <asm/paca.h>
  24. #endif
  25. #include <asm/percpu.h>
  26. extern int boot_cpuid;
  27. extern int boot_cpu_count;
  28. extern void cpu_die(void);
  29. #ifdef CONFIG_SMP
  30. struct smp_ops_t {
  31. void (*message_pass)(int cpu, int msg);
  32. int (*probe)(void);
  33. int (*kick_cpu)(int nr);
  34. void (*setup_cpu)(int nr);
  35. void (*bringup_done)(void);
  36. void (*take_timebase)(void);
  37. void (*give_timebase)(void);
  38. int (*cpu_disable)(void);
  39. void (*cpu_die)(unsigned int nr);
  40. int (*cpu_bootable)(unsigned int nr);
  41. };
  42. extern void smp_send_debugger_break(void);
  43. extern void smp_message_recv(int);
  44. extern void start_secondary_resume(void);
  45. extern void __devinit smp_generic_give_timebase(void);
  46. extern void __devinit smp_generic_take_timebase(void);
  47. DECLARE_PER_CPU(unsigned int, cpu_pvr);
  48. #ifdef CONFIG_HOTPLUG_CPU
  49. extern void migrate_irqs(void);
  50. int generic_cpu_disable(void);
  51. void generic_cpu_die(unsigned int cpu);
  52. void generic_mach_cpu_die(void);
  53. void generic_set_cpu_dead(unsigned int cpu);
  54. #endif
  55. #ifdef CONFIG_PPC64
  56. #define raw_smp_processor_id() (local_paca->paca_index)
  57. #define hard_smp_processor_id() (get_paca()->hw_cpu_id)
  58. #else
  59. /* 32-bit */
  60. extern int smp_hw_index[];
  61. #define raw_smp_processor_id() (current_thread_info()->cpu)
  62. #define hard_smp_processor_id() (smp_hw_index[smp_processor_id()])
  63. static inline int get_hard_smp_processor_id(int cpu)
  64. {
  65. return smp_hw_index[cpu];
  66. }
  67. static inline void set_hard_smp_processor_id(int cpu, int phys)
  68. {
  69. smp_hw_index[cpu] = phys;
  70. }
  71. #endif
  72. DECLARE_PER_CPU(cpumask_var_t, cpu_sibling_map);
  73. DECLARE_PER_CPU(cpumask_var_t, cpu_core_map);
  74. static inline struct cpumask *cpu_sibling_mask(int cpu)
  75. {
  76. return per_cpu(cpu_sibling_map, cpu);
  77. }
  78. static inline struct cpumask *cpu_core_mask(int cpu)
  79. {
  80. return per_cpu(cpu_core_map, cpu);
  81. }
  82. extern int cpu_to_core_id(int cpu);
  83. /* Since OpenPIC has only 4 IPIs, we use slightly different message numbers.
  84. *
  85. * Make sure this matches openpic_request_IPIs in open_pic.c, or what shows up
  86. * in /proc/interrupts will be wrong!!! --Troy */
  87. #define PPC_MSG_CALL_FUNCTION 0
  88. #define PPC_MSG_RESCHEDULE 1
  89. #define PPC_MSG_CALL_FUNC_SINGLE 2
  90. #define PPC_MSG_DEBUGGER_BREAK 3
  91. /*
  92. * irq controllers that have dedicated ipis per message and don't
  93. * need additional code in the action handler may use this
  94. */
  95. extern int smp_request_message_ipi(int virq, int message);
  96. extern const char *smp_ipi_name[];
  97. void smp_init_iSeries(void);
  98. void smp_init_pSeries(void);
  99. void smp_init_cell(void);
  100. void smp_init_celleb(void);
  101. void smp_setup_cpu_maps(void);
  102. extern int __cpu_disable(void);
  103. extern void __cpu_die(unsigned int cpu);
  104. #else
  105. /* for UP */
  106. #define hard_smp_processor_id() get_hard_smp_processor_id(0)
  107. #define smp_setup_cpu_maps()
  108. #endif /* CONFIG_SMP */
  109. #ifdef CONFIG_PPC64
  110. static inline int get_hard_smp_processor_id(int cpu)
  111. {
  112. return paca[cpu].hw_cpu_id;
  113. }
  114. static inline void set_hard_smp_processor_id(int cpu, int phys)
  115. {
  116. paca[cpu].hw_cpu_id = phys;
  117. }
  118. extern void smp_release_cpus(void);
  119. #else
  120. /* 32-bit */
  121. #ifndef CONFIG_SMP
  122. extern int boot_cpuid_phys;
  123. static inline int get_hard_smp_processor_id(int cpu)
  124. {
  125. return boot_cpuid_phys;
  126. }
  127. static inline void set_hard_smp_processor_id(int cpu, int phys)
  128. {
  129. boot_cpuid_phys = phys;
  130. }
  131. #endif /* !CONFIG_SMP */
  132. #endif /* !CONFIG_PPC64 */
  133. extern int smt_enabled_at_boot;
  134. extern int smp_mpic_probe(void);
  135. extern void smp_mpic_setup_cpu(int cpu);
  136. extern int smp_generic_kick_cpu(int nr);
  137. extern void smp_generic_give_timebase(void);
  138. extern void smp_generic_take_timebase(void);
  139. extern struct smp_ops_t *smp_ops;
  140. extern void arch_send_call_function_single_ipi(int cpu);
  141. extern void arch_send_call_function_ipi_mask(const struct cpumask *mask);
  142. /* Definitions relative to the secondary CPU spin loop
  143. * and entry point. Not all of them exist on both 32 and
  144. * 64-bit but defining them all here doesn't harm
  145. */
  146. extern void generic_secondary_smp_init(void);
  147. extern void generic_secondary_thread_init(void);
  148. extern unsigned long __secondary_hold_spinloop;
  149. extern unsigned long __secondary_hold_acknowledge;
  150. extern char __secondary_hold;
  151. #endif /* __ASSEMBLY__ */
  152. #endif /* __KERNEL__ */
  153. #endif /* _ASM_POWERPC_SMP_H) */