smp_64.h 2.1 KB

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