smp_32.h 4.3 KB

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