smp.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. /* smp.h: Sparc specific SMP stuff.
  2. *
  3. * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
  4. */
  5. #ifndef _SPARC_SMP_H
  6. #define _SPARC_SMP_H
  7. #include <linux/config.h>
  8. #include <linux/threads.h>
  9. #include <asm/head.h>
  10. #include <asm/btfixup.h>
  11. #ifndef __ASSEMBLY__
  12. #include <linux/cpumask.h>
  13. #endif /* __ASSEMBLY__ */
  14. #ifdef CONFIG_SMP
  15. #ifndef __ASSEMBLY__
  16. #include <asm/ptrace.h>
  17. #include <asm/asi.h>
  18. #include <asm/atomic.h>
  19. /*
  20. * Private routines/data
  21. */
  22. extern unsigned char boot_cpu_id;
  23. extern cpumask_t phys_cpu_present_map;
  24. #define cpu_possible_map phys_cpu_present_map
  25. typedef void (*smpfunc_t)(unsigned long, unsigned long, unsigned long,
  26. unsigned long, unsigned long);
  27. /*
  28. * General functions that each host system must provide.
  29. */
  30. void sun4m_init_smp(void);
  31. void sun4d_init_smp(void);
  32. void smp_callin(void);
  33. void smp_boot_cpus(void);
  34. void smp_store_cpu_info(int);
  35. struct seq_file;
  36. void smp_bogo(struct seq_file *);
  37. void smp_info(struct seq_file *);
  38. BTFIXUPDEF_CALL(void, smp_cross_call, smpfunc_t, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long)
  39. BTFIXUPDEF_CALL(void, smp_message_pass, int, int, unsigned long, int)
  40. BTFIXUPDEF_CALL(int, __hard_smp_processor_id, void)
  41. BTFIXUPDEF_BLACKBOX(hard_smp_processor_id)
  42. BTFIXUPDEF_BLACKBOX(load_current)
  43. #define smp_cross_call(func,arg1,arg2,arg3,arg4,arg5) BTFIXUP_CALL(smp_cross_call)(func,arg1,arg2,arg3,arg4,arg5)
  44. #define smp_message_pass(target,msg,data,wait) BTFIXUP_CALL(smp_message_pass)(target,msg,data,wait)
  45. static inline void xc0(smpfunc_t func) { smp_cross_call(func, 0, 0, 0, 0, 0); }
  46. static inline void xc1(smpfunc_t func, unsigned long arg1)
  47. { smp_cross_call(func, arg1, 0, 0, 0, 0); }
  48. static inline void xc2(smpfunc_t func, unsigned long arg1, unsigned long arg2)
  49. { smp_cross_call(func, arg1, arg2, 0, 0, 0); }
  50. static inline void xc3(smpfunc_t func, unsigned long arg1, unsigned long arg2,
  51. unsigned long arg3)
  52. { smp_cross_call(func, arg1, arg2, arg3, 0, 0); }
  53. static inline void xc4(smpfunc_t func, unsigned long arg1, unsigned long arg2,
  54. unsigned long arg3, unsigned long arg4)
  55. { smp_cross_call(func, arg1, arg2, arg3, arg4, 0); }
  56. static inline void xc5(smpfunc_t func, unsigned long arg1, unsigned long arg2,
  57. unsigned long arg3, unsigned long arg4, unsigned long arg5)
  58. { smp_cross_call(func, arg1, arg2, arg3, arg4, arg5); }
  59. static inline int smp_call_function(void (*func)(void *info), void *info, int nonatomic, int wait)
  60. {
  61. xc1((smpfunc_t)func, (unsigned long)info);
  62. return 0;
  63. }
  64. extern __volatile__ int __cpu_number_map[NR_CPUS];
  65. extern __volatile__ int __cpu_logical_map[NR_CPUS];
  66. static inline int cpu_logical_map(int cpu)
  67. {
  68. return __cpu_logical_map[cpu];
  69. }
  70. static inline int cpu_number_map(int cpu)
  71. {
  72. return __cpu_number_map[cpu];
  73. }
  74. static inline int hard_smp4m_processor_id(void)
  75. {
  76. int cpuid;
  77. __asm__ __volatile__("rd %%tbr, %0\n\t"
  78. "srl %0, 12, %0\n\t"
  79. "and %0, 3, %0\n\t" :
  80. "=&r" (cpuid));
  81. return cpuid;
  82. }
  83. static inline int hard_smp4d_processor_id(void)
  84. {
  85. int cpuid;
  86. __asm__ __volatile__("lda [%%g0] %1, %0\n\t" :
  87. "=&r" (cpuid) : "i" (ASI_M_VIKING_TMP1));
  88. return cpuid;
  89. }
  90. #ifndef MODULE
  91. static inline int hard_smp_processor_id(void)
  92. {
  93. int cpuid;
  94. /* Black box - sun4m
  95. __asm__ __volatile__("rd %%tbr, %0\n\t"
  96. "srl %0, 12, %0\n\t"
  97. "and %0, 3, %0\n\t" :
  98. "=&r" (cpuid));
  99. - sun4d
  100. __asm__ __volatile__("lda [%g0] ASI_M_VIKING_TMP1, %0\n\t"
  101. "nop; nop" :
  102. "=&r" (cpuid));
  103. See btfixup.h and btfixupprep.c to understand how a blackbox works.
  104. */
  105. __asm__ __volatile__("sethi %%hi(___b_hard_smp_processor_id), %0\n\t"
  106. "sethi %%hi(boot_cpu_id), %0\n\t"
  107. "ldub [%0 + %%lo(boot_cpu_id)], %0\n\t" :
  108. "=&r" (cpuid));
  109. return cpuid;
  110. }
  111. #else
  112. static inline int hard_smp_processor_id(void)
  113. {
  114. int cpuid;
  115. __asm__ __volatile__("mov %%o7, %%g1\n\t"
  116. "call ___f___hard_smp_processor_id\n\t"
  117. " nop\n\t"
  118. "mov %%g2, %0\n\t" : "=r"(cpuid) : : "g1", "g2");
  119. return cpuid;
  120. }
  121. #endif
  122. #define raw_smp_processor_id() (current_thread_info()->cpu)
  123. #define prof_multiplier(__cpu) cpu_data(__cpu).multiplier
  124. #define prof_counter(__cpu) cpu_data(__cpu).counter
  125. #endif /* !(__ASSEMBLY__) */
  126. /* Sparc specific messages. */
  127. #define MSG_CROSS_CALL 0x0005 /* run func on cpus */
  128. /* Empirical PROM processor mailbox constants. If the per-cpu mailbox
  129. * contains something other than one of these then the ipi is from
  130. * Linux's active_kernel_processor. This facility exists so that
  131. * the boot monitor can capture all the other cpus when one catches
  132. * a watchdog reset or the user enters the monitor using L1-A keys.
  133. */
  134. #define MBOX_STOPCPU 0xFB
  135. #define MBOX_IDLECPU 0xFC
  136. #define MBOX_IDLECPU2 0xFD
  137. #define MBOX_STOPCPU2 0xFE
  138. #endif /* SMP */
  139. #define NO_PROC_ID 0xFF
  140. #endif /* !(_SPARC_SMP_H) */