smp_32.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. #ifndef __ASM_SMP_H
  2. #define __ASM_SMP_H
  3. #ifndef __ASSEMBLY__
  4. #include <linux/cpumask.h>
  5. #include <linux/init.h>
  6. /*
  7. * We need the APIC definitions automatically as part of 'smp.h'
  8. */
  9. #ifdef CONFIG_X86_LOCAL_APIC
  10. # include <asm/mpspec.h>
  11. # include <asm/apic.h>
  12. # ifdef CONFIG_X86_IO_APIC
  13. # include <asm/io_apic.h>
  14. # endif
  15. #endif
  16. extern cpumask_t cpu_callout_map;
  17. extern cpumask_t cpu_callin_map;
  18. extern int smp_num_siblings;
  19. extern unsigned int num_processors;
  20. extern void (*mtrr_hook) (void);
  21. extern void zap_low_mappings (void);
  22. extern u8 __initdata x86_cpu_to_apicid_init[];
  23. extern void *x86_cpu_to_apicid_early_ptr;
  24. DECLARE_PER_CPU(cpumask_t, cpu_sibling_map);
  25. DECLARE_PER_CPU(cpumask_t, cpu_core_map);
  26. DECLARE_PER_CPU(u8, cpu_llc_id);
  27. DECLARE_PER_CPU(u8, x86_cpu_to_apicid);
  28. #ifdef CONFIG_HOTPLUG_CPU
  29. extern void cpu_exit_clear(void);
  30. extern void cpu_uninit(void);
  31. extern void remove_siblinginfo(int cpu);
  32. #endif
  33. /* Globals due to paravirt */
  34. extern void set_cpu_sibling_map(int cpu);
  35. struct smp_ops
  36. {
  37. void (*smp_prepare_boot_cpu)(void);
  38. void (*smp_prepare_cpus)(unsigned max_cpus);
  39. int (*cpu_up)(unsigned cpu);
  40. void (*smp_cpus_done)(unsigned max_cpus);
  41. void (*smp_send_stop)(void);
  42. void (*smp_send_reschedule)(int cpu);
  43. int (*smp_call_function_mask)(cpumask_t mask,
  44. void (*func)(void *info), void *info,
  45. int wait);
  46. };
  47. #ifdef CONFIG_SMP
  48. extern struct smp_ops smp_ops;
  49. static inline void smp_prepare_boot_cpu(void)
  50. {
  51. smp_ops.smp_prepare_boot_cpu();
  52. }
  53. static inline void smp_prepare_cpus(unsigned int max_cpus)
  54. {
  55. smp_ops.smp_prepare_cpus(max_cpus);
  56. }
  57. static inline int __cpu_up(unsigned int cpu)
  58. {
  59. return smp_ops.cpu_up(cpu);
  60. }
  61. static inline void smp_cpus_done(unsigned int max_cpus)
  62. {
  63. smp_ops.smp_cpus_done(max_cpus);
  64. }
  65. static inline void smp_send_stop(void)
  66. {
  67. smp_ops.smp_send_stop();
  68. }
  69. static inline void smp_send_reschedule(int cpu)
  70. {
  71. smp_ops.smp_send_reschedule(cpu);
  72. }
  73. static inline int smp_call_function_mask(cpumask_t mask,
  74. void (*func) (void *info), void *info,
  75. int wait)
  76. {
  77. return smp_ops.smp_call_function_mask(mask, func, info, wait);
  78. }
  79. void native_smp_prepare_boot_cpu(void);
  80. void native_smp_prepare_cpus(unsigned int max_cpus);
  81. int native_cpu_up(unsigned int cpunum);
  82. void native_smp_cpus_done(unsigned int max_cpus);
  83. #ifndef CONFIG_PARAVIRT
  84. #define startup_ipi_hook(phys_apicid, start_eip, start_esp) do { } while (0)
  85. #endif
  86. extern int __cpu_disable(void);
  87. extern void __cpu_die(unsigned int cpu);
  88. /*
  89. * This function is needed by all SMP systems. It must _always_ be valid
  90. * from the initial startup. We map APIC_BASE very early in page_setup(),
  91. * so this is correct in the x86 case.
  92. */
  93. DECLARE_PER_CPU(int, cpu_number);
  94. #define raw_smp_processor_id() (x86_read_percpu(cpu_number))
  95. #define cpu_physical_id(cpu) per_cpu(x86_cpu_to_apicid, cpu)
  96. extern int safe_smp_processor_id(void);
  97. void __cpuinit smp_store_cpu_info(int id);
  98. /* We don't mark CPUs online until __cpu_up(), so we need another measure */
  99. static inline int num_booting_cpus(void)
  100. {
  101. return cpus_weight(cpu_callout_map);
  102. }
  103. #else /* CONFIG_SMP */
  104. #define safe_smp_processor_id() 0
  105. #define cpu_physical_id(cpu) boot_cpu_physical_apicid
  106. #endif /* !CONFIG_SMP */
  107. #ifdef CONFIG_X86_LOCAL_APIC
  108. static __inline int logical_smp_processor_id(void)
  109. {
  110. /* we don't want to mark this access volatile - bad code generation */
  111. return GET_APIC_LOGICAL_ID(*(u32 *)(APIC_BASE + APIC_LDR));
  112. }
  113. # ifdef APIC_DEFINITION
  114. extern int hard_smp_processor_id(void);
  115. # else
  116. # include <mach_apicdef.h>
  117. static inline int hard_smp_processor_id(void)
  118. {
  119. /* we don't want to mark this access volatile - bad code generation */
  120. return GET_APIC_ID(*(u32 *)(APIC_BASE + APIC_ID));
  121. }
  122. # endif /* APIC_DEFINITION */
  123. #else /* CONFIG_X86_LOCAL_APIC */
  124. # ifndef CONFIG_SMP
  125. # define hard_smp_processor_id() 0
  126. # endif
  127. #endif /* CONFIG_X86_LOCAL_APIC */
  128. #endif /* !ASSEMBLY */
  129. #endif