smp_64.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. #ifdef CONFIG_SMP
  18. #define raw_smp_processor_id() read_pda(cpunumber)
  19. #define stack_smp_processor_id() \
  20. ({ \
  21. struct thread_info *ti; \
  22. asm("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
  23. ti->cpu; \
  24. })
  25. /*
  26. * On x86 all CPUs are mapped 1:1 to the APIC space. This simplifies
  27. * scheduling and IPI sending and compresses data structures.
  28. */
  29. static inline int num_booting_cpus(void)
  30. {
  31. return cpus_weight(cpu_callout_map);
  32. }
  33. #else /* CONFIG_SMP */
  34. #define stack_smp_processor_id() 0
  35. #endif /* !CONFIG_SMP */
  36. #define safe_smp_processor_id() smp_processor_id()
  37. #ifdef CONFIG_X86_LOCAL_APIC
  38. static inline int logical_smp_processor_id(void)
  39. {
  40. /* we don't want to mark this access volatile - bad code generation */
  41. return GET_APIC_LOGICAL_ID(*(u32 *)(APIC_BASE + APIC_LDR));
  42. }
  43. # ifdef APIC_DEFINITION
  44. extern int hard_smp_processor_id(void);
  45. # else
  46. # include <mach_apicdef.h>
  47. static inline int hard_smp_processor_id(void)
  48. {
  49. /* we don't want to mark this access volatile - bad code generation */
  50. return GET_APIC_ID(*(u32 *)(APIC_BASE + APIC_ID));
  51. }
  52. # endif /* APIC_DEFINITION */
  53. #else /* CONFIG_X86_LOCAL_APIC */
  54. # ifndef CONFIG_SMP
  55. # define hard_smp_processor_id() 0
  56. # endif
  57. #endif /* CONFIG_X86_LOCAL_APIC */
  58. #endif