Sam Ravnborg | f5e706a | 2008-07-17 21:55:51 -0700 | [diff] [blame] | 1 | /* smp.h: Sparc specific SMP stuff. |
| 2 | * |
| 3 | * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu) |
| 4 | */ |
| 5 | |
| 6 | #ifndef _SPARC_SMP_H |
| 7 | #define _SPARC_SMP_H |
| 8 | |
| 9 | #include <linux/threads.h> |
| 10 | #include <asm/head.h> |
| 11 | #include <asm/btfixup.h> |
| 12 | |
| 13 | #ifndef __ASSEMBLY__ |
| 14 | |
| 15 | #include <linux/cpumask.h> |
| 16 | |
| 17 | #endif /* __ASSEMBLY__ */ |
| 18 | |
| 19 | #ifdef CONFIG_SMP |
| 20 | |
| 21 | #ifndef __ASSEMBLY__ |
| 22 | |
| 23 | #include <asm/ptrace.h> |
| 24 | #include <asm/asi.h> |
Arun Sharma | 60063497 | 2011-07-26 16:09:06 -0700 | [diff] [blame] | 25 | #include <linux/atomic.h> |
Sam Ravnborg | f5e706a | 2008-07-17 21:55:51 -0700 | [diff] [blame] | 26 | |
| 27 | /* |
| 28 | * Private routines/data |
| 29 | */ |
| 30 | |
| 31 | extern unsigned char boot_cpu_id; |
Sam Ravnborg | b7afdb7 | 2011-01-28 22:08:18 +0000 | [diff] [blame] | 32 | extern volatile unsigned long cpu_callin_map[NR_CPUS]; |
| 33 | extern cpumask_t smp_commenced_mask; |
| 34 | extern struct linux_prom_registers smp_penguin_ctable; |
Sam Ravnborg | f5e706a | 2008-07-17 21:55:51 -0700 | [diff] [blame] | 35 | |
| 36 | typedef void (*smpfunc_t)(unsigned long, unsigned long, unsigned long, |
| 37 | unsigned long, unsigned long); |
| 38 | |
Sam Ravnborg | b7afdb7 | 2011-01-28 22:08:18 +0000 | [diff] [blame] | 39 | void cpu_panic(void); |
| 40 | extern void smp4m_irq_rotate(int cpu); |
| 41 | |
Sam Ravnborg | f5e706a | 2008-07-17 21:55:51 -0700 | [diff] [blame] | 42 | /* |
| 43 | * General functions that each host system must provide. |
| 44 | */ |
| 45 | |
| 46 | void sun4m_init_smp(void); |
| 47 | void sun4d_init_smp(void); |
| 48 | |
| 49 | void smp_callin(void); |
| 50 | void smp_boot_cpus(void); |
| 51 | void smp_store_cpu_info(int); |
| 52 | |
Daniel Hellstrom | d6d0481 | 2011-05-02 00:08:51 +0000 | [diff] [blame] | 53 | void smp_resched_interrupt(void); |
| 54 | void smp_call_function_single_interrupt(void); |
| 55 | void smp_call_function_interrupt(void); |
| 56 | |
Sam Ravnborg | f5e706a | 2008-07-17 21:55:51 -0700 | [diff] [blame] | 57 | struct seq_file; |
| 58 | void smp_bogo(struct seq_file *); |
| 59 | void smp_info(struct seq_file *); |
| 60 | |
Sam Ravnborg | 4ba22b1 | 2012-05-14 15:14:36 +0200 | [diff] [blame^] | 61 | struct sparc32_ipi_ops { |
| 62 | void (*cross_call)(smpfunc_t func, cpumask_t mask, unsigned long arg1, |
| 63 | unsigned long arg2, unsigned long arg3, |
| 64 | unsigned long arg4); |
| 65 | void (*resched)(int cpu); |
| 66 | void (*single)(int cpu); |
| 67 | void (*mask_one)(int cpu); |
| 68 | }; |
| 69 | extern const struct sparc32_ipi_ops *sparc32_ipi_ops; |
Sam Ravnborg | f5e706a | 2008-07-17 21:55:51 -0700 | [diff] [blame] | 70 | |
Sam Ravnborg | 4ba22b1 | 2012-05-14 15:14:36 +0200 | [diff] [blame^] | 71 | static inline void xc0(smpfunc_t func) |
| 72 | { |
| 73 | sparc32_ipi_ops->cross_call(func, *cpu_online_mask, 0, 0, 0, 0); |
| 74 | } |
Sam Ravnborg | f5e706a | 2008-07-17 21:55:51 -0700 | [diff] [blame] | 75 | |
Sam Ravnborg | f5e706a | 2008-07-17 21:55:51 -0700 | [diff] [blame] | 76 | static inline void xc1(smpfunc_t func, unsigned long arg1) |
Sam Ravnborg | 4ba22b1 | 2012-05-14 15:14:36 +0200 | [diff] [blame^] | 77 | { |
| 78 | sparc32_ipi_ops->cross_call(func, *cpu_online_mask, arg1, 0, 0, 0); |
| 79 | } |
Sam Ravnborg | f5e706a | 2008-07-17 21:55:51 -0700 | [diff] [blame] | 80 | static inline void xc2(smpfunc_t func, unsigned long arg1, unsigned long arg2) |
Sam Ravnborg | 4ba22b1 | 2012-05-14 15:14:36 +0200 | [diff] [blame^] | 81 | { |
| 82 | sparc32_ipi_ops->cross_call(func, *cpu_online_mask, arg1, arg2, 0, 0); |
| 83 | } |
| 84 | |
Sam Ravnborg | f5e706a | 2008-07-17 21:55:51 -0700 | [diff] [blame] | 85 | static inline void xc3(smpfunc_t func, unsigned long arg1, unsigned long arg2, |
Sam Ravnborg | 4ba22b1 | 2012-05-14 15:14:36 +0200 | [diff] [blame^] | 86 | unsigned long arg3) |
| 87 | { |
| 88 | sparc32_ipi_ops->cross_call(func, *cpu_online_mask, |
| 89 | arg1, arg2, arg3, 0); |
| 90 | } |
| 91 | |
Sam Ravnborg | f5e706a | 2008-07-17 21:55:51 -0700 | [diff] [blame] | 92 | static inline void xc4(smpfunc_t func, unsigned long arg1, unsigned long arg2, |
Sam Ravnborg | 4ba22b1 | 2012-05-14 15:14:36 +0200 | [diff] [blame^] | 93 | unsigned long arg3, unsigned long arg4) |
| 94 | { |
| 95 | sparc32_ipi_ops->cross_call(func, *cpu_online_mask, |
| 96 | arg1, arg2, arg3, arg4); |
| 97 | } |
Sam Ravnborg | f5e706a | 2008-07-17 21:55:51 -0700 | [diff] [blame] | 98 | |
Daniel Hellstrom | d6d0481 | 2011-05-02 00:08:51 +0000 | [diff] [blame] | 99 | extern void arch_send_call_function_single_ipi(int cpu); |
| 100 | extern void arch_send_call_function_ipi_mask(const struct cpumask *mask); |
David S. Miller | 66e4f8c | 2008-08-27 20:03:22 -0700 | [diff] [blame] | 101 | |
Sam Ravnborg | f5e706a | 2008-07-17 21:55:51 -0700 | [diff] [blame] | 102 | static inline int cpu_logical_map(int cpu) |
| 103 | { |
| 104 | return cpu; |
| 105 | } |
| 106 | |
| 107 | static inline int hard_smp4m_processor_id(void) |
| 108 | { |
| 109 | int cpuid; |
| 110 | |
| 111 | __asm__ __volatile__("rd %%tbr, %0\n\t" |
| 112 | "srl %0, 12, %0\n\t" |
| 113 | "and %0, 3, %0\n\t" : |
| 114 | "=&r" (cpuid)); |
| 115 | return cpuid; |
| 116 | } |
| 117 | |
| 118 | static inline int hard_smp4d_processor_id(void) |
| 119 | { |
| 120 | int cpuid; |
| 121 | |
| 122 | __asm__ __volatile__("lda [%%g0] %1, %0\n\t" : |
| 123 | "=&r" (cpuid) : "i" (ASI_M_VIKING_TMP1)); |
| 124 | return cpuid; |
| 125 | } |
| 126 | |
Konrad Eisele | 8401707 | 2009-08-31 22:08:13 +0000 | [diff] [blame] | 127 | extern inline int hard_smpleon_processor_id(void) |
| 128 | { |
| 129 | int cpuid; |
| 130 | __asm__ __volatile__("rd %%asr17,%0\n\t" |
| 131 | "srl %0,28,%0" : |
| 132 | "=&r" (cpuid) : ); |
| 133 | return cpuid; |
| 134 | } |
| 135 | |
David S. Miller | c68e5d3 | 2012-05-13 23:09:04 -0700 | [diff] [blame] | 136 | extern int hard_smp_processor_id(void); |
Sam Ravnborg | f5e706a | 2008-07-17 21:55:51 -0700 | [diff] [blame] | 137 | |
| 138 | #define raw_smp_processor_id() (current_thread_info()->cpu) |
| 139 | |
| 140 | #define prof_multiplier(__cpu) cpu_data(__cpu).multiplier |
| 141 | #define prof_counter(__cpu) cpu_data(__cpu).counter |
| 142 | |
| 143 | void smp_setup_cpu_possible_map(void); |
| 144 | |
| 145 | #endif /* !(__ASSEMBLY__) */ |
| 146 | |
| 147 | /* Sparc specific messages. */ |
| 148 | #define MSG_CROSS_CALL 0x0005 /* run func on cpus */ |
| 149 | |
| 150 | /* Empirical PROM processor mailbox constants. If the per-cpu mailbox |
| 151 | * contains something other than one of these then the ipi is from |
| 152 | * Linux's active_kernel_processor. This facility exists so that |
| 153 | * the boot monitor can capture all the other cpus when one catches |
| 154 | * a watchdog reset or the user enters the monitor using L1-A keys. |
| 155 | */ |
| 156 | #define MBOX_STOPCPU 0xFB |
| 157 | #define MBOX_IDLECPU 0xFC |
| 158 | #define MBOX_IDLECPU2 0xFD |
| 159 | #define MBOX_STOPCPU2 0xFE |
| 160 | |
| 161 | #else /* SMP */ |
| 162 | |
| 163 | #define hard_smp_processor_id() 0 |
| 164 | #define smp_setup_cpu_possible_map() do { } while (0) |
| 165 | |
| 166 | #endif /* !(SMP) */ |
Sam Ravnborg | f5e706a | 2008-07-17 21:55:51 -0700 | [diff] [blame] | 167 | #endif /* !(_SPARC_SMP_H) */ |