smp_64.h 1.7 KB

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