smp.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. #ifndef __ASM_SMP_H
  2. #define __ASM_SMP_H
  3. /*
  4. * We need the APIC definitions automatically as part of 'smp.h'
  5. */
  6. #ifndef __ASSEMBLY__
  7. #include <linux/kernel.h>
  8. #include <linux/threads.h>
  9. #include <linux/cpumask.h>
  10. #endif
  11. #ifdef CONFIG_X86_LOCAL_APIC
  12. #ifndef __ASSEMBLY__
  13. #include <asm/fixmap.h>
  14. #include <asm/bitops.h>
  15. #include <asm/mpspec.h>
  16. #ifdef CONFIG_X86_IO_APIC
  17. #include <asm/io_apic.h>
  18. #endif
  19. #include <asm/apic.h>
  20. #endif
  21. #endif
  22. #define BAD_APICID 0xFFu
  23. #ifdef CONFIG_SMP
  24. #ifndef __ASSEMBLY__
  25. /*
  26. * Private routines/data
  27. */
  28. extern void smp_alloc_memory(void);
  29. extern int pic_mode;
  30. extern int smp_num_siblings;
  31. extern cpumask_t cpu_sibling_map[];
  32. extern cpumask_t cpu_core_map[];
  33. extern void (*mtrr_hook) (void);
  34. extern void zap_low_mappings (void);
  35. extern void lock_ipi_call_lock(void);
  36. extern void unlock_ipi_call_lock(void);
  37. #define MAX_APICID 256
  38. extern u8 x86_cpu_to_apicid[];
  39. #define cpu_physical_id(cpu) x86_cpu_to_apicid[cpu]
  40. #ifdef CONFIG_HOTPLUG_CPU
  41. extern void cpu_exit_clear(void);
  42. extern void cpu_uninit(void);
  43. #endif
  44. /*
  45. * This function is needed by all SMP systems. It must _always_ be valid
  46. * from the initial startup. We map APIC_BASE very early in page_setup(),
  47. * so this is correct in the x86 case.
  48. */
  49. #define raw_smp_processor_id() (current_thread_info()->cpu)
  50. extern cpumask_t cpu_callout_map;
  51. extern cpumask_t cpu_callin_map;
  52. extern cpumask_t cpu_possible_map;
  53. /* We don't mark CPUs online until __cpu_up(), so we need another measure */
  54. static inline int num_booting_cpus(void)
  55. {
  56. return cpus_weight(cpu_callout_map);
  57. }
  58. #ifdef CONFIG_X86_LOCAL_APIC
  59. #ifdef APIC_DEFINITION
  60. extern int hard_smp_processor_id(void);
  61. #else
  62. #include <mach_apicdef.h>
  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(*(unsigned long *)(APIC_BASE+APIC_ID));
  67. }
  68. #endif
  69. #endif
  70. extern int __cpu_disable(void);
  71. extern void __cpu_die(unsigned int cpu);
  72. extern unsigned int num_processors;
  73. #endif /* !__ASSEMBLY__ */
  74. #else /* CONFIG_SMP */
  75. #define cpu_physical_id(cpu) boot_cpu_physical_apicid
  76. #define NO_PROC_ID 0xFF /* No processor magic marker */
  77. #endif
  78. #ifndef __ASSEMBLY__
  79. #ifdef CONFIG_X86_LOCAL_APIC
  80. static __inline int logical_smp_processor_id(void)
  81. {
  82. /* we don't want to mark this access volatile - bad code generation */
  83. return GET_APIC_LOGICAL_ID(*(unsigned long *)(APIC_BASE+APIC_LDR));
  84. }
  85. #endif
  86. #endif
  87. #endif