1 /* smp.h: Sparc specific SMP stuff.
3 * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
9 #include <linux/config.h>
10 #include <linux/threads.h>
12 #include <asm/btfixup.h>
15 /* PROM provided per-processor information we need
16 * to start them all up.
23 extern int linux_num_cpus; /* number of CPUs probed */
25 #endif /* !(__ASSEMBLY__) */
31 #include <asm/ptrace.h>
34 extern struct prom_cpuinfo linux_cpus[NR_CPUS];
36 /* Per processor Sparc parameters we need. */
38 struct cpuinfo_sparc {
39 unsigned long udelay_val; /* that's it */
44 extern struct cpuinfo_sparc cpu_data[NR_CPUS];
45 extern unsigned long cpu_offset[NR_CPUS];
48 * Private routines/data
51 extern int smp_found_cpus;
52 extern unsigned char boot_cpu_id;
53 extern unsigned long cpu_present_map;
54 #define cpu_online_map cpu_present_map
56 typedef void (*smpfunc_t)(unsigned long, unsigned long, unsigned long,
57 unsigned long, unsigned long);
60 * General functions that each host system must provide.
63 void sun4m_init_smp(void);
64 void sun4d_init_smp(void);
66 void smp_callin(void);
67 void smp_boot_cpus(void);
68 void smp_store_cpu_info(int);
71 void smp_bogo_info(struct seq_file *);
72 void smp_info(struct seq_file *);
74 BTFIXUPDEF_CALL(void, smp_cross_call, smpfunc_t, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long)
75 BTFIXUPDEF_CALL(void, smp_message_pass, int, int, unsigned long, int)
76 BTFIXUPDEF_CALL(int, __smp_processor_id, void)
77 BTFIXUPDEF_BLACKBOX(smp_processor_id)
78 BTFIXUPDEF_BLACKBOX(load_current)
80 #define smp_cross_call(func,arg1,arg2,arg3,arg4,arg5) BTFIXUP_CALL(smp_cross_call)(func,arg1,arg2,arg3,arg4,arg5)
81 #define smp_message_pass(target,msg,data,wait) BTFIXUP_CALL(smp_message_pass)(target,msg,data,wait)
83 extern __inline__ void xc0(smpfunc_t func) { smp_cross_call(func, 0, 0, 0, 0, 0); }
84 extern __inline__ void xc1(smpfunc_t func, unsigned long arg1)
85 { smp_cross_call(func, arg1, 0, 0, 0, 0); }
86 extern __inline__ void xc2(smpfunc_t func, unsigned long arg1, unsigned long arg2)
87 { smp_cross_call(func, arg1, arg2, 0, 0, 0); }
88 extern __inline__ void xc3(smpfunc_t func, unsigned long arg1, unsigned long arg2,
90 { smp_cross_call(func, arg1, arg2, arg3, 0, 0); }
91 extern __inline__ void xc4(smpfunc_t func, unsigned long arg1, unsigned long arg2,
92 unsigned long arg3, unsigned long arg4)
93 { smp_cross_call(func, arg1, arg2, arg3, arg4, 0); }
94 extern __inline__ void xc5(smpfunc_t func, unsigned long arg1, unsigned long arg2,
95 unsigned long arg3, unsigned long arg4, unsigned long arg5)
96 { smp_cross_call(func, arg1, arg2, arg3, arg4, arg5); }
98 extern __inline__ int smp_call_function(void (*func)(void *info), void *info, int nonatomic, int wait)
100 xc1((smpfunc_t)func, (unsigned long)info);
104 extern __volatile__ int __cpu_number_map[NR_CPUS];
105 extern __volatile__ int __cpu_logical_map[NR_CPUS];
106 extern unsigned long smp_proc_in_lock[NR_CPUS];
108 extern __inline__ int cpu_logical_map(int cpu)
110 return __cpu_logical_map[cpu];
112 extern __inline__ int cpu_number_map(int cpu)
114 return __cpu_number_map[cpu];
117 extern __inline__ int hard_smp4m_processor_id(void)
121 __asm__ __volatile__("rd %%tbr, %0\n\t"
123 "and %0, 3, %0\n\t" :
128 extern __inline__ int hard_smp4d_processor_id(void)
132 __asm__ __volatile__("lda [%%g0] %1, %0\n\t" :
133 "=&r" (cpuid) : "i" (ASI_M_VIKING_TMP1));
138 extern __inline__ int hard_smp_processor_id(void)
143 __asm__ __volatile__("rd %%tbr, %0\n\t"
145 "and %0, 3, %0\n\t" :
148 __asm__ __volatile__("lda [%g0] ASI_M_VIKING_TMP1, %0\n\t"
151 See btfixup.h and btfixupprep.c to understand how a blackbox works.
153 __asm__ __volatile__("sethi %%hi(___b_smp_processor_id), %0\n\t"
154 "sethi %%hi(boot_cpu_id), %0\n\t"
155 "ldub [%0 + %%lo(boot_cpu_id)], %0\n\t" :
160 extern __inline__ int hard_smp_processor_id(void)
164 __asm__ __volatile__("mov %%o7, %%g1\n\t"
165 "call ___f___smp_processor_id\n\t"
167 "mov %%g2, %0\n\t" : "=r"(cpuid) : : "g1", "g2");
172 #define smp_processor_id() hard_smp_processor_id()
173 /* XXX We really need to implement this now. -DaveM */
174 extern __inline__ void smp_send_reschedule(int cpu) { }
175 extern __inline__ void smp_send_stop(void) { }
177 #endif /* !(__ASSEMBLY__) */
179 /* Sparc specific messages. */
180 #define MSG_CROSS_CALL 0x0005 /* run func on cpus */
182 /* Empirical PROM processor mailbox constants. If the per-cpu mailbox
183 * contains something other than one of these then the ipi is from
184 * Linux's active_kernel_processor. This facility exists so that
185 * the boot monitor can capture all the other cpus when one catches
186 * a watchdog reset or the user enters the monitor using L1-A keys.
188 #define MBOX_STOPCPU 0xFB
189 #define MBOX_IDLECPU 0xFC
190 #define MBOX_IDLECPU2 0xFD
191 #define MBOX_STOPCPU2 0xFE
193 #define PROC_CHANGE_PENALTY 15
195 #endif /* !(CONFIG_SMP) */
197 #define NO_PROC_ID 0xFF
199 #endif /* !(_SPARC_SMP_H) */