smp.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. #ifndef _ASM_M32R_SMP_H
  2. #define _ASM_M32R_SMP_H
  3. #ifdef CONFIG_SMP
  4. #ifndef __ASSEMBLY__
  5. #include <linux/cpumask.h>
  6. #include <linux/spinlock.h>
  7. #include <linux/threads.h>
  8. #include <asm/m32r.h>
  9. #define PHYSID_ARRAY_SIZE 1
  10. struct physid_mask
  11. {
  12. unsigned long mask[PHYSID_ARRAY_SIZE];
  13. };
  14. typedef struct physid_mask physid_mask_t;
  15. #define physid_set(physid, map) set_bit(physid, (map).mask)
  16. #define physid_clear(physid, map) clear_bit(physid, (map).mask)
  17. #define physid_isset(physid, map) test_bit(physid, (map).mask)
  18. #define physid_test_and_set(physid, map) test_and_set_bit(physid, (map).mask)
  19. #define physids_and(dst, src1, src2) bitmap_and((dst).mask, (src1).mask, (src2).mask, MAX_APICS)
  20. #define physids_or(dst, src1, src2) bitmap_or((dst).mask, (src1).mask, (src2).mask, MAX_APICS)
  21. #define physids_clear(map) bitmap_zero((map).mask, MAX_APICS)
  22. #define physids_complement(dst, src) bitmap_complement((dst).mask,(src).mask, MAX_APICS)
  23. #define physids_empty(map) bitmap_empty((map).mask, MAX_APICS)
  24. #define physids_equal(map1, map2) bitmap_equal((map1).mask, (map2).mask, MAX_APICS)
  25. #define physids_weight(map) bitmap_weight((map).mask, MAX_APICS)
  26. #define physids_shift_right(d, s, n) bitmap_shift_right((d).mask, (s).mask, n, MAX_APICS)
  27. #define physids_shift_left(d, s, n) bitmap_shift_left((d).mask, (s).mask, n, MAX_APICS)
  28. #define physids_coerce(map) ((map).mask[0])
  29. #define physids_promote(physids) \
  30. ({ \
  31. physid_mask_t __physid_mask = PHYSID_MASK_NONE; \
  32. __physid_mask.mask[0] = physids; \
  33. __physid_mask; \
  34. })
  35. #define physid_mask_of_physid(physid) \
  36. ({ \
  37. physid_mask_t __physid_mask = PHYSID_MASK_NONE; \
  38. physid_set(physid, __physid_mask); \
  39. __physid_mask; \
  40. })
  41. #define PHYSID_MASK_ALL { {[0 ... PHYSID_ARRAY_SIZE-1] = ~0UL} }
  42. #define PHYSID_MASK_NONE { {[0 ... PHYSID_ARRAY_SIZE-1] = 0UL} }
  43. extern physid_mask_t phys_cpu_present_map;
  44. /*
  45. * Some lowlevel functions might want to know about
  46. * the real CPU ID <-> CPU # mapping.
  47. */
  48. extern volatile int cpu_2_physid[NR_CPUS];
  49. #define cpu_to_physid(cpu_id) cpu_2_physid[cpu_id]
  50. #define raw_smp_processor_id() (current_thread_info()->cpu)
  51. extern cpumask_t cpu_callout_map;
  52. static __inline__ int hard_smp_processor_id(void)
  53. {
  54. return (int)*(volatile long *)M32R_CPUID_PORTL;
  55. }
  56. static __inline__ int cpu_logical_map(int cpu)
  57. {
  58. return cpu;
  59. }
  60. static __inline__ int cpu_number_map(int cpu)
  61. {
  62. return cpu;
  63. }
  64. static __inline__ unsigned int num_booting_cpus(void)
  65. {
  66. return cpumask_weight(&cpu_callout_map);
  67. }
  68. extern void smp_send_timer(void);
  69. extern unsigned long send_IPI_mask_phys(const cpumask_t*, int, int);
  70. extern void arch_send_call_function_single_ipi(int cpu);
  71. extern void arch_send_call_function_ipi_mask(const struct cpumask *mask);
  72. #endif /* not __ASSEMBLY__ */
  73. #define NO_PROC_ID (0xff) /* No processor magic marker */
  74. /*
  75. * M32R-mp IPI
  76. */
  77. #define RESCHEDULE_IPI (M32R_IRQ_IPI0-M32R_IRQ_IPI0)
  78. #define INVALIDATE_TLB_IPI (M32R_IRQ_IPI1-M32R_IRQ_IPI0)
  79. #define CALL_FUNCTION_IPI (M32R_IRQ_IPI2-M32R_IRQ_IPI0)
  80. #define LOCAL_TIMER_IPI (M32R_IRQ_IPI3-M32R_IRQ_IPI0)
  81. #define INVALIDATE_CACHE_IPI (M32R_IRQ_IPI4-M32R_IRQ_IPI0)
  82. #define CPU_BOOT_IPI (M32R_IRQ_IPI5-M32R_IRQ_IPI0)
  83. #define CALL_FUNC_SINGLE_IPI (M32R_IRQ_IPI6-M32R_IRQ_IPI0)
  84. #define IPI_SHIFT (0)
  85. #define NR_IPIS (8)
  86. #else /* CONFIG_SMP */
  87. #define hard_smp_processor_id() 0
  88. #endif /* CONFIG_SMP */
  89. #endif /* _ASM_M32R_SMP_H */