smp_32.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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_callin_map;
  17. extern void (*mtrr_hook) (void);
  18. extern void zap_low_mappings (void);
  19. extern u8 __initdata x86_cpu_to_apicid_init[];
  20. extern void *x86_cpu_to_apicid_early_ptr;
  21. DECLARE_PER_CPU(cpumask_t, cpu_sibling_map);
  22. DECLARE_PER_CPU(cpumask_t, cpu_core_map);
  23. DECLARE_PER_CPU(u8, cpu_llc_id);
  24. DECLARE_PER_CPU(u8, x86_cpu_to_apicid);
  25. #ifdef CONFIG_HOTPLUG_CPU
  26. extern void cpu_exit_clear(void);
  27. extern void cpu_uninit(void);
  28. extern void remove_siblinginfo(int cpu);
  29. #endif
  30. /* Globals due to paravirt */
  31. extern void set_cpu_sibling_map(int cpu);
  32. #ifdef CONFIG_SMP
  33. static inline void smp_prepare_boot_cpu(void)
  34. {
  35. smp_ops.smp_prepare_boot_cpu();
  36. }
  37. static inline void smp_prepare_cpus(unsigned int max_cpus)
  38. {
  39. smp_ops.smp_prepare_cpus(max_cpus);
  40. }
  41. static inline int __cpu_up(unsigned int cpu)
  42. {
  43. return smp_ops.cpu_up(cpu);
  44. }
  45. static inline void smp_cpus_done(unsigned int max_cpus)
  46. {
  47. smp_ops.smp_cpus_done(max_cpus);
  48. }
  49. static inline void smp_send_stop(void)
  50. {
  51. smp_ops.smp_send_stop();
  52. }
  53. void native_smp_prepare_boot_cpu(void);
  54. void native_smp_prepare_cpus(unsigned int max_cpus);
  55. int native_cpu_up(unsigned int cpunum);
  56. void native_smp_cpus_done(unsigned int max_cpus);
  57. #ifndef CONFIG_PARAVIRT
  58. #define startup_ipi_hook(phys_apicid, start_eip, start_esp) do { } while (0)
  59. #endif
  60. extern int __cpu_disable(void);
  61. extern void __cpu_die(unsigned int cpu);
  62. /*
  63. * This function is needed by all SMP systems. It must _always_ be valid
  64. * from the initial startup. We map APIC_BASE very early in page_setup(),
  65. * so this is correct in the x86 case.
  66. */
  67. DECLARE_PER_CPU(int, cpu_number);
  68. #define raw_smp_processor_id() (x86_read_percpu(cpu_number))
  69. #define cpu_physical_id(cpu) per_cpu(x86_cpu_to_apicid, cpu)
  70. extern int safe_smp_processor_id(void);
  71. void __cpuinit smp_store_cpu_info(int id);
  72. /* We don't mark CPUs online until __cpu_up(), so we need another measure */
  73. static inline int num_booting_cpus(void)
  74. {
  75. return cpus_weight(cpu_callout_map);
  76. }
  77. #else /* CONFIG_SMP */
  78. #define safe_smp_processor_id() 0
  79. #define cpu_physical_id(cpu) boot_cpu_physical_apicid
  80. #endif /* !CONFIG_SMP */
  81. #ifdef CONFIG_X86_LOCAL_APIC
  82. static __inline int logical_smp_processor_id(void)
  83. {
  84. /* we don't want to mark this access volatile - bad code generation */
  85. return GET_APIC_LOGICAL_ID(*(u32 *)(APIC_BASE + APIC_LDR));
  86. }
  87. # ifdef APIC_DEFINITION
  88. extern int hard_smp_processor_id(void);
  89. # else
  90. # include <mach_apicdef.h>
  91. static inline int hard_smp_processor_id(void)
  92. {
  93. /* we don't want to mark this access volatile - bad code generation */
  94. return GET_APIC_ID(*(u32 *)(APIC_BASE + APIC_ID));
  95. }
  96. # endif /* APIC_DEFINITION */
  97. #else /* CONFIG_X86_LOCAL_APIC */
  98. # ifndef CONFIG_SMP
  99. # define hard_smp_processor_id() 0
  100. # endif
  101. #endif /* CONFIG_X86_LOCAL_APIC */
  102. #endif /* !ASSEMBLY */
  103. #endif