smp_64.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. #ifndef __ASM_SMP_H
  2. #define __ASM_SMP_H
  3. #include <linux/cpumask.h>
  4. #include <linux/init.h>
  5. /*
  6. * We need the APIC definitions automatically as part of 'smp.h'
  7. */
  8. #include <asm/apic.h>
  9. #include <asm/io_apic.h>
  10. #include <asm/mpspec.h>
  11. #include <asm/pda.h>
  12. #include <asm/thread_info.h>
  13. extern cpumask_t cpu_callout_map;
  14. extern cpumask_t cpu_initialized;
  15. extern int smp_num_siblings;
  16. extern unsigned int num_processors;
  17. extern void smp_alloc_memory(void);
  18. extern void lock_ipi_call_lock(void);
  19. extern void unlock_ipi_call_lock(void);
  20. extern int smp_call_function_mask(cpumask_t mask, void (*func)(void *),
  21. void *info, int wait);
  22. extern u16 __initdata x86_cpu_to_apicid_init[];
  23. extern u16 __initdata x86_bios_cpu_apicid_init[];
  24. extern void *x86_cpu_to_apicid_early_ptr;
  25. extern void *x86_bios_cpu_apicid_early_ptr;
  26. DECLARE_PER_CPU(cpumask_t, cpu_sibling_map);
  27. DECLARE_PER_CPU(cpumask_t, cpu_core_map);
  28. DECLARE_PER_CPU(u16, cpu_llc_id);
  29. DECLARE_PER_CPU(u16, x86_cpu_to_apicid);
  30. DECLARE_PER_CPU(u16, x86_bios_cpu_apicid);
  31. static inline int cpu_present_to_apicid(int mps_cpu)
  32. {
  33. if (cpu_present(mps_cpu))
  34. return (int)per_cpu(x86_bios_cpu_apicid, mps_cpu);
  35. else
  36. return BAD_APICID;
  37. }
  38. #ifdef CONFIG_SMP
  39. #define SMP_TRAMPOLINE_BASE 0x6000
  40. extern int __cpu_disable(void);
  41. extern void __cpu_die(unsigned int cpu);
  42. extern void prefill_possible_map(void);
  43. extern unsigned __cpuinitdata disabled_cpus;
  44. #define raw_smp_processor_id() read_pda(cpunumber)
  45. #define cpu_physical_id(cpu) per_cpu(x86_cpu_to_apicid, cpu)
  46. #define stack_smp_processor_id() \
  47. ({ \
  48. struct thread_info *ti; \
  49. __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
  50. ti->cpu; \
  51. })
  52. /*
  53. * On x86 all CPUs are mapped 1:1 to the APIC space. This simplifies
  54. * scheduling and IPI sending and compresses data structures.
  55. */
  56. static inline int num_booting_cpus(void)
  57. {
  58. return cpus_weight(cpu_callout_map);
  59. }
  60. extern void smp_send_reschedule(int cpu);
  61. #else /* CONFIG_SMP */
  62. extern unsigned int boot_cpu_id;
  63. #define cpu_physical_id(cpu) boot_cpu_id
  64. #define stack_smp_processor_id() 0
  65. #endif /* !CONFIG_SMP */
  66. #define safe_smp_processor_id() smp_processor_id()
  67. static __inline int logical_smp_processor_id(void)
  68. {
  69. /* we don't want to mark this access volatile - bad code generation */
  70. return GET_APIC_LOGICAL_ID(*(u32 *)(APIC_BASE + APIC_LDR));
  71. }
  72. static inline int hard_smp_processor_id(void)
  73. {
  74. /* we don't want to mark this access volatile - bad code generation */
  75. return GET_APIC_ID(*(u32 *)(APIC_BASE + APIC_ID));
  76. }
  77. #endif