smp_64.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 void *x86_cpu_to_apicid_ptr;
  24. extern u16 bios_cpu_apicid[];
  25. DECLARE_PER_CPU(cpumask_t, cpu_sibling_map);
  26. DECLARE_PER_CPU(cpumask_t, cpu_core_map);
  27. DECLARE_PER_CPU(u16, cpu_llc_id);
  28. DECLARE_PER_CPU(u16, x86_cpu_to_apicid);
  29. static inline int cpu_present_to_apicid(int mps_cpu)
  30. {
  31. if (mps_cpu < NR_CPUS)
  32. return (int)bios_cpu_apicid[mps_cpu];
  33. else
  34. return BAD_APICID;
  35. }
  36. #ifdef CONFIG_SMP
  37. #define SMP_TRAMPOLINE_BASE 0x6000
  38. extern int __cpu_disable(void);
  39. extern void __cpu_die(unsigned int cpu);
  40. extern void prefill_possible_map(void);
  41. extern unsigned __cpuinitdata disabled_cpus;
  42. #define raw_smp_processor_id() read_pda(cpunumber)
  43. #define cpu_physical_id(cpu) per_cpu(x86_cpu_to_apicid, cpu)
  44. #define stack_smp_processor_id() \
  45. ({ \
  46. struct thread_info *ti; \
  47. __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
  48. ti->cpu; \
  49. })
  50. /*
  51. * On x86 all CPUs are mapped 1:1 to the APIC space. This simplifies
  52. * scheduling and IPI sending and compresses data structures.
  53. */
  54. static inline int num_booting_cpus(void)
  55. {
  56. return cpus_weight(cpu_callout_map);
  57. }
  58. extern void smp_send_reschedule(int cpu);
  59. #else /* CONFIG_SMP */
  60. extern unsigned int boot_cpu_id;
  61. #define cpu_physical_id(cpu) boot_cpu_id
  62. #define stack_smp_processor_id() 0
  63. #endif /* !CONFIG_SMP */
  64. #define safe_smp_processor_id() smp_processor_id()
  65. static __inline int logical_smp_processor_id(void)
  66. {
  67. /* we don't want to mark this access volatile - bad code generation */
  68. return GET_APIC_LOGICAL_ID(*(u32 *)(APIC_BASE + APIC_LDR));
  69. }
  70. static inline int hard_smp_processor_id(void)
  71. {
  72. /* we don't want to mark this access volatile - bad code generation */
  73. return GET_APIC_ID(*(u32 *)(APIC_BASE + APIC_ID));
  74. }
  75. #endif