smp.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. extern u8 apicid_2_node[];
  41. #ifdef CONFIG_HOTPLUG_CPU
  42. extern void cpu_exit_clear(void);
  43. extern void cpu_uninit(void);
  44. #endif
  45. /*
  46. * This function is needed by all SMP systems. It must _always_ be valid
  47. * from the initial startup. We map APIC_BASE very early in page_setup(),
  48. * so this is correct in the x86 case.
  49. */
  50. #define raw_smp_processor_id() (current_thread_info()->cpu)
  51. extern cpumask_t cpu_callout_map;
  52. extern cpumask_t cpu_callin_map;
  53. extern cpumask_t cpu_possible_map;
  54. /* We don't mark CPUs online until __cpu_up(), so we need another measure */
  55. static inline int num_booting_cpus(void)
  56. {
  57. return cpus_weight(cpu_callout_map);
  58. }
  59. #ifdef CONFIG_X86_LOCAL_APIC
  60. #ifdef APIC_DEFINITION
  61. extern int hard_smp_processor_id(void);
  62. #else
  63. #include <mach_apicdef.h>
  64. static inline int hard_smp_processor_id(void)
  65. {
  66. /* we don't want to mark this access volatile - bad code generation */
  67. return GET_APIC_ID(*(unsigned long *)(APIC_BASE+APIC_ID));
  68. }
  69. #endif
  70. #endif
  71. extern int __cpu_disable(void);
  72. extern void __cpu_die(unsigned int cpu);
  73. extern unsigned int num_processors;
  74. #endif /* !__ASSEMBLY__ */
  75. #else /* CONFIG_SMP */
  76. #define cpu_physical_id(cpu) boot_cpu_physical_apicid
  77. #define NO_PROC_ID 0xFF /* No processor magic marker */
  78. #endif
  79. #ifndef __ASSEMBLY__
  80. #ifdef CONFIG_X86_LOCAL_APIC
  81. static __inline int logical_smp_processor_id(void)
  82. {
  83. /* we don't want to mark this access volatile - bad code generation */
  84. return GET_APIC_LOGICAL_ID(*(unsigned long *)(APIC_BASE+APIC_LDR));
  85. }
  86. #endif
  87. #endif
  88. #endif