smp_64.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. extern void prefill_possible_map(void);
  37. extern unsigned __cpuinitdata disabled_cpus;
  38. #define raw_smp_processor_id() read_pda(cpunumber)
  39. #define cpu_physical_id(cpu) per_cpu(x86_cpu_to_apicid, cpu)
  40. #define stack_smp_processor_id() \
  41. ({ \
  42. struct thread_info *ti; \
  43. __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
  44. ti->cpu; \
  45. })
  46. /*
  47. * On x86 all CPUs are mapped 1:1 to the APIC space. This simplifies
  48. * scheduling and IPI sending and compresses data structures.
  49. */
  50. static inline int num_booting_cpus(void)
  51. {
  52. return cpus_weight(cpu_callout_map);
  53. }
  54. extern void smp_send_reschedule(int cpu);
  55. #else /* CONFIG_SMP */
  56. extern unsigned int boot_cpu_id;
  57. #define cpu_physical_id(cpu) boot_cpu_id
  58. #define stack_smp_processor_id() 0
  59. #endif /* !CONFIG_SMP */
  60. #define safe_smp_processor_id() smp_processor_id()
  61. static __inline int logical_smp_processor_id(void)
  62. {
  63. /* we don't want to mark this access volatile - bad code generation */
  64. return GET_APIC_LOGICAL_ID(*(u32 *)(APIC_BASE + APIC_LDR));
  65. }
  66. static inline int hard_smp_processor_id(void)
  67. {
  68. /* we don't want to mark this access volatile - bad code generation */
  69. return GET_APIC_ID(*(u32 *)(APIC_BASE + APIC_ID));
  70. }
  71. #endif