smp.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. #ifndef _ASM_X86_SMP_H_
  2. #define _ASM_X86_SMP_H_
  3. #ifndef __ASSEMBLY__
  4. #include <linux/cpumask.h>
  5. #include <linux/init.h>
  6. #include <asm/percpu.h>
  7. extern cpumask_t cpu_callout_map;
  8. extern int smp_num_siblings;
  9. extern unsigned int num_processors;
  10. extern cpumask_t cpu_initialized;
  11. extern u16 x86_cpu_to_apicid_init[];
  12. extern u16 x86_bios_cpu_apicid_init[];
  13. extern void *x86_cpu_to_apicid_early_ptr;
  14. extern void *x86_bios_cpu_apicid_early_ptr;
  15. DECLARE_PER_CPU(cpumask_t, cpu_sibling_map);
  16. DECLARE_PER_CPU(cpumask_t, cpu_core_map);
  17. DECLARE_PER_CPU(u16, cpu_llc_id);
  18. DECLARE_PER_CPU(u16, x86_cpu_to_apicid);
  19. DECLARE_PER_CPU(u16, x86_bios_cpu_apicid);
  20. /*
  21. * Trampoline 80x86 program as an array.
  22. */
  23. extern const unsigned char trampoline_data [];
  24. extern const unsigned char trampoline_end [];
  25. extern unsigned char *trampoline_base;
  26. /* Static state in head.S used to set up a CPU */
  27. extern struct {
  28. void *sp;
  29. unsigned short ss;
  30. } stack_start;
  31. extern unsigned long init_rsp;
  32. extern unsigned long initial_code;
  33. struct smp_ops {
  34. void (*smp_prepare_boot_cpu)(void);
  35. void (*smp_prepare_cpus)(unsigned max_cpus);
  36. int (*cpu_up)(unsigned cpu);
  37. void (*smp_cpus_done)(unsigned max_cpus);
  38. void (*smp_send_stop)(void);
  39. void (*smp_send_reschedule)(int cpu);
  40. int (*smp_call_function_mask)(cpumask_t mask,
  41. void (*func)(void *info), void *info,
  42. int wait);
  43. };
  44. /* Globals due to paravirt */
  45. extern void set_cpu_sibling_map(int cpu);
  46. #ifdef CONFIG_SMP
  47. #ifndef CONFIG_PARAVIRT
  48. #define startup_ipi_hook(phys_apicid, start_eip, start_esp) do { } while (0)
  49. #endif
  50. extern struct smp_ops smp_ops;
  51. static inline void smp_send_stop(void)
  52. {
  53. smp_ops.smp_send_stop();
  54. }
  55. static inline void smp_prepare_boot_cpu(void)
  56. {
  57. smp_ops.smp_prepare_boot_cpu();
  58. }
  59. static inline void smp_prepare_cpus(unsigned int max_cpus)
  60. {
  61. smp_ops.smp_prepare_cpus(max_cpus);
  62. }
  63. static inline void smp_cpus_done(unsigned int max_cpus)
  64. {
  65. smp_ops.smp_cpus_done(max_cpus);
  66. }
  67. static inline int __cpu_up(unsigned int cpu)
  68. {
  69. return smp_ops.cpu_up(cpu);
  70. }
  71. static inline void smp_send_reschedule(int cpu)
  72. {
  73. smp_ops.smp_send_reschedule(cpu);
  74. }
  75. static inline int smp_call_function_mask(cpumask_t mask,
  76. void (*func) (void *info), void *info,
  77. int wait)
  78. {
  79. return smp_ops.smp_call_function_mask(mask, func, info, wait);
  80. }
  81. void native_smp_prepare_boot_cpu(void);
  82. void native_smp_prepare_cpus(unsigned int max_cpus);
  83. void native_smp_cpus_done(unsigned int max_cpus);
  84. int native_cpu_up(unsigned int cpunum);
  85. extern int __cpu_disable(void);
  86. extern void __cpu_die(unsigned int cpu);
  87. extern unsigned disabled_cpus;
  88. extern void prefill_possible_map(void);
  89. #define SMP_TRAMPOLINE_BASE 0x6000
  90. extern unsigned long setup_trampoline(void);
  91. void smp_store_cpu_info(int id);
  92. #define cpu_physical_id(cpu) per_cpu(x86_cpu_to_apicid, cpu)
  93. #else
  94. #define cpu_physical_id(cpu) boot_cpu_physical_apicid
  95. #endif
  96. #ifdef CONFIG_X86_32
  97. # include "smp_32.h"
  98. #else
  99. # include "smp_64.h"
  100. #endif
  101. #ifdef CONFIG_X86_LOCAL_APIC
  102. static inline int logical_smp_processor_id(void)
  103. {
  104. /* we don't want to mark this access volatile - bad code generation */
  105. return GET_APIC_LOGICAL_ID(*(u32 *)(APIC_BASE + APIC_LDR));
  106. }
  107. # ifdef APIC_DEFINITION
  108. extern int hard_smp_processor_id(void);
  109. # else
  110. # include <mach_apicdef.h>
  111. static inline int hard_smp_processor_id(void)
  112. {
  113. /* we don't want to mark this access volatile - bad code generation */
  114. return GET_APIC_ID(*(u32 *)(APIC_BASE + APIC_ID));
  115. }
  116. # endif /* APIC_DEFINITION */
  117. #else /* CONFIG_X86_LOCAL_APIC */
  118. # ifndef CONFIG_SMP
  119. # define hard_smp_processor_id() 0
  120. # endif
  121. #endif /* CONFIG_X86_LOCAL_APIC */
  122. #ifdef CONFIG_HOTPLUG_CPU
  123. extern void cpu_exit_clear(void);
  124. extern void cpu_uninit(void);
  125. extern void remove_siblinginfo(int cpu);
  126. #endif
  127. extern void smp_alloc_memory(void);
  128. extern void lock_ipi_call_lock(void);
  129. extern void unlock_ipi_call_lock(void);
  130. #endif /* __ASSEMBLY__ */
  131. #endif