smp.h 2.6 KB

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