smp_32.h 5.1 KB

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