smp.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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/config.h>
  8. #include <linux/kernel.h>
  9. #include <linux/threads.h>
  10. #include <linux/cpumask.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. /*
  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. static __inline int logical_smp_processor_id(void)
  71. {
  72. /* we don't want to mark this access volatile - bad code generation */
  73. return GET_APIC_LOGICAL_ID(*(unsigned long *)(APIC_BASE+APIC_LDR));
  74. }
  75. #endif
  76. extern int __cpu_disable(void);
  77. extern void __cpu_die(unsigned int cpu);
  78. #endif /* !__ASSEMBLY__ */
  79. #else /* CONFIG_SMP */
  80. #define cpu_physical_id(cpu) boot_cpu_physical_apicid
  81. #define NO_PROC_ID 0xFF /* No processor magic marker */
  82. #endif
  83. #endif