smp_64.h 2.2 KB

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