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> |
| 25 | #include <asm/atomic.h> |
| 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 | |
| 53 | struct seq_file; |
| 54 | void smp_bogo(struct seq_file *); |
| 55 | void smp_info(struct seq_file *); |
| 56 | |
David S. Miller | 66e4f8c | 2008-08-27 20:03:22 -0700 | [diff] [blame] | 57 | BTFIXUPDEF_CALL(void, smp_cross_call, smpfunc_t, cpumask_t, unsigned long, unsigned long, unsigned long, unsigned long) |
Sam Ravnborg | f5e706a | 2008-07-17 21:55:51 -0700 | [diff] [blame] | 58 | BTFIXUPDEF_CALL(int, __hard_smp_processor_id, void) |
| 59 | BTFIXUPDEF_BLACKBOX(hard_smp_processor_id) |
| 60 | BTFIXUPDEF_BLACKBOX(load_current) |
| 61 | |
David S. Miller | 66e4f8c | 2008-08-27 20:03:22 -0700 | [diff] [blame] | 62 | #define smp_cross_call(func,mask,arg1,arg2,arg3,arg4) BTFIXUP_CALL(smp_cross_call)(func,mask,arg1,arg2,arg3,arg4) |
Sam Ravnborg | f5e706a | 2008-07-17 21:55:51 -0700 | [diff] [blame] | 63 | |
David S. Miller | 66e4f8c | 2008-08-27 20:03:22 -0700 | [diff] [blame] | 64 | static inline void xc0(smpfunc_t func) { smp_cross_call(func, cpu_online_map, 0, 0, 0, 0); } |
Sam Ravnborg | f5e706a | 2008-07-17 21:55:51 -0700 | [diff] [blame] | 65 | static inline void xc1(smpfunc_t func, unsigned long arg1) |
David S. Miller | 66e4f8c | 2008-08-27 20:03:22 -0700 | [diff] [blame] | 66 | { smp_cross_call(func, cpu_online_map, arg1, 0, 0, 0); } |
Sam Ravnborg | f5e706a | 2008-07-17 21:55:51 -0700 | [diff] [blame] | 67 | static inline void xc2(smpfunc_t func, unsigned long arg1, unsigned long arg2) |
David S. Miller | 66e4f8c | 2008-08-27 20:03:22 -0700 | [diff] [blame] | 68 | { smp_cross_call(func, cpu_online_map, arg1, arg2, 0, 0); } |
Sam Ravnborg | f5e706a | 2008-07-17 21:55:51 -0700 | [diff] [blame] | 69 | static inline void xc3(smpfunc_t func, unsigned long arg1, unsigned long arg2, |
| 70 | unsigned long arg3) |
David S. Miller | 66e4f8c | 2008-08-27 20:03:22 -0700 | [diff] [blame] | 71 | { smp_cross_call(func, cpu_online_map, arg1, arg2, arg3, 0); } |
Sam Ravnborg | f5e706a | 2008-07-17 21:55:51 -0700 | [diff] [blame] | 72 | static inline void xc4(smpfunc_t func, unsigned long arg1, unsigned long arg2, |
| 73 | unsigned long arg3, unsigned long arg4) |
David S. Miller | 66e4f8c | 2008-08-27 20:03:22 -0700 | [diff] [blame] | 74 | { smp_cross_call(func, cpu_online_map, arg1, arg2, arg3, arg4); } |
Sam Ravnborg | f5e706a | 2008-07-17 21:55:51 -0700 | [diff] [blame] | 75 | |
| 76 | static inline int smp_call_function(void (*func)(void *info), void *info, int wait) |
| 77 | { |
| 78 | xc1((smpfunc_t)func, (unsigned long)info); |
| 79 | return 0; |
| 80 | } |
| 81 | |
David S. Miller | 66e4f8c | 2008-08-27 20:03:22 -0700 | [diff] [blame] | 82 | static inline int smp_call_function_single(int cpuid, void (*func) (void *info), |
| 83 | void *info, int wait) |
| 84 | { |
| 85 | smp_cross_call((smpfunc_t)func, cpumask_of_cpu(cpuid), |
| 86 | (unsigned long) info, 0, 0, 0); |
| 87 | return 0; |
| 88 | } |
| 89 | |
Sam Ravnborg | f5e706a | 2008-07-17 21:55:51 -0700 | [diff] [blame] | 90 | static inline int cpu_logical_map(int cpu) |
| 91 | { |
| 92 | return cpu; |
| 93 | } |
| 94 | |
| 95 | static inline int hard_smp4m_processor_id(void) |
| 96 | { |
| 97 | int cpuid; |
| 98 | |
| 99 | __asm__ __volatile__("rd %%tbr, %0\n\t" |
| 100 | "srl %0, 12, %0\n\t" |
| 101 | "and %0, 3, %0\n\t" : |
| 102 | "=&r" (cpuid)); |
| 103 | return cpuid; |
| 104 | } |
| 105 | |
| 106 | static inline int hard_smp4d_processor_id(void) |
| 107 | { |
| 108 | int cpuid; |
| 109 | |
| 110 | __asm__ __volatile__("lda [%%g0] %1, %0\n\t" : |
| 111 | "=&r" (cpuid) : "i" (ASI_M_VIKING_TMP1)); |
| 112 | return cpuid; |
| 113 | } |
| 114 | |
Konrad Eisele | 8401707 | 2009-08-31 22:08:13 +0000 | [diff] [blame] | 115 | extern inline int hard_smpleon_processor_id(void) |
| 116 | { |
| 117 | int cpuid; |
| 118 | __asm__ __volatile__("rd %%asr17,%0\n\t" |
| 119 | "srl %0,28,%0" : |
| 120 | "=&r" (cpuid) : ); |
| 121 | return cpuid; |
| 122 | } |
| 123 | |
Sam Ravnborg | f5e706a | 2008-07-17 21:55:51 -0700 | [diff] [blame] | 124 | #ifndef MODULE |
| 125 | static inline int hard_smp_processor_id(void) |
| 126 | { |
| 127 | int cpuid; |
| 128 | |
| 129 | /* Black box - sun4m |
| 130 | __asm__ __volatile__("rd %%tbr, %0\n\t" |
| 131 | "srl %0, 12, %0\n\t" |
| 132 | "and %0, 3, %0\n\t" : |
| 133 | "=&r" (cpuid)); |
| 134 | - sun4d |
| 135 | __asm__ __volatile__("lda [%g0] ASI_M_VIKING_TMP1, %0\n\t" |
| 136 | "nop; nop" : |
| 137 | "=&r" (cpuid)); |
| 138 | See btfixup.h and btfixupprep.c to understand how a blackbox works. |
| 139 | */ |
| 140 | __asm__ __volatile__("sethi %%hi(___b_hard_smp_processor_id), %0\n\t" |
| 141 | "sethi %%hi(boot_cpu_id), %0\n\t" |
| 142 | "ldub [%0 + %%lo(boot_cpu_id)], %0\n\t" : |
| 143 | "=&r" (cpuid)); |
| 144 | return cpuid; |
| 145 | } |
| 146 | #else |
| 147 | static inline int hard_smp_processor_id(void) |
| 148 | { |
| 149 | int cpuid; |
| 150 | |
| 151 | __asm__ __volatile__("mov %%o7, %%g1\n\t" |
| 152 | "call ___f___hard_smp_processor_id\n\t" |
| 153 | " nop\n\t" |
| 154 | "mov %%g2, %0\n\t" : "=r"(cpuid) : : "g1", "g2"); |
| 155 | return cpuid; |
| 156 | } |
| 157 | #endif |
| 158 | |
| 159 | #define raw_smp_processor_id() (current_thread_info()->cpu) |
| 160 | |
| 161 | #define prof_multiplier(__cpu) cpu_data(__cpu).multiplier |
| 162 | #define prof_counter(__cpu) cpu_data(__cpu).counter |
| 163 | |
| 164 | void smp_setup_cpu_possible_map(void); |
| 165 | |
| 166 | #endif /* !(__ASSEMBLY__) */ |
| 167 | |
| 168 | /* Sparc specific messages. */ |
| 169 | #define MSG_CROSS_CALL 0x0005 /* run func on cpus */ |
| 170 | |
| 171 | /* Empirical PROM processor mailbox constants. If the per-cpu mailbox |
| 172 | * contains something other than one of these then the ipi is from |
| 173 | * Linux's active_kernel_processor. This facility exists so that |
| 174 | * the boot monitor can capture all the other cpus when one catches |
| 175 | * a watchdog reset or the user enters the monitor using L1-A keys. |
| 176 | */ |
| 177 | #define MBOX_STOPCPU 0xFB |
| 178 | #define MBOX_IDLECPU 0xFC |
| 179 | #define MBOX_IDLECPU2 0xFD |
| 180 | #define MBOX_STOPCPU2 0xFE |
| 181 | |
| 182 | #else /* SMP */ |
| 183 | |
| 184 | #define hard_smp_processor_id() 0 |
| 185 | #define smp_setup_cpu_possible_map() do { } while (0) |
| 186 | |
| 187 | #endif /* !(SMP) */ |
Sam Ravnborg | f5e706a | 2008-07-17 21:55:51 -0700 | [diff] [blame] | 188 | #endif /* !(_SPARC_SMP_H) */ |