18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/* smp.h: Sparc specific SMP stuff.
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
58c2ecf20Sopenharmony_ci */
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci#ifndef _SPARC_SMP_H
88c2ecf20Sopenharmony_ci#define _SPARC_SMP_H
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#include <linux/threads.h>
118c2ecf20Sopenharmony_ci#include <asm/head.h>
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci#include <linux/cpumask.h>
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci#endif /* __ASSEMBLY__ */
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci#ifdef CONFIG_SMP
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci#include <asm/ptrace.h>
248c2ecf20Sopenharmony_ci#include <asm/asi.h>
258c2ecf20Sopenharmony_ci#include <linux/atomic.h>
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci/*
288c2ecf20Sopenharmony_ci *	Private routines/data
298c2ecf20Sopenharmony_ci */
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_ciextern unsigned char boot_cpu_id;
328c2ecf20Sopenharmony_ciextern volatile unsigned long cpu_callin_map[NR_CPUS];
338c2ecf20Sopenharmony_ciextern cpumask_t smp_commenced_mask;
348c2ecf20Sopenharmony_ciextern struct linux_prom_registers smp_penguin_ctable;
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_citypedef void (*smpfunc_t)(unsigned long, unsigned long, unsigned long,
378c2ecf20Sopenharmony_ci		       unsigned long, unsigned long);
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_civoid cpu_panic(void);
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ci/*
428c2ecf20Sopenharmony_ci *	General functions that each host system must provide.
438c2ecf20Sopenharmony_ci */
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_civoid sun4m_init_smp(void);
468c2ecf20Sopenharmony_civoid sun4d_init_smp(void);
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_civoid smp_callin(void);
498c2ecf20Sopenharmony_civoid smp_store_cpu_info(int);
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_civoid smp_resched_interrupt(void);
528c2ecf20Sopenharmony_civoid smp_call_function_single_interrupt(void);
538c2ecf20Sopenharmony_civoid smp_call_function_interrupt(void);
548c2ecf20Sopenharmony_ci
558c2ecf20Sopenharmony_cistruct seq_file;
568c2ecf20Sopenharmony_civoid smp_bogo(struct seq_file *);
578c2ecf20Sopenharmony_civoid smp_info(struct seq_file *);
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_cistruct sparc32_ipi_ops {
608c2ecf20Sopenharmony_ci	void (*cross_call)(smpfunc_t func, cpumask_t mask, unsigned long arg1,
618c2ecf20Sopenharmony_ci			   unsigned long arg2, unsigned long arg3,
628c2ecf20Sopenharmony_ci			   unsigned long arg4);
638c2ecf20Sopenharmony_ci	void (*resched)(int cpu);
648c2ecf20Sopenharmony_ci	void (*single)(int cpu);
658c2ecf20Sopenharmony_ci	void (*mask_one)(int cpu);
668c2ecf20Sopenharmony_ci};
678c2ecf20Sopenharmony_ciextern const struct sparc32_ipi_ops *sparc32_ipi_ops;
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_cistatic inline void xc0(smpfunc_t func)
708c2ecf20Sopenharmony_ci{
718c2ecf20Sopenharmony_ci	sparc32_ipi_ops->cross_call(func, *cpu_online_mask, 0, 0, 0, 0);
728c2ecf20Sopenharmony_ci}
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_cistatic inline void xc1(smpfunc_t func, unsigned long arg1)
758c2ecf20Sopenharmony_ci{
768c2ecf20Sopenharmony_ci	sparc32_ipi_ops->cross_call(func, *cpu_online_mask, arg1, 0, 0, 0);
778c2ecf20Sopenharmony_ci}
788c2ecf20Sopenharmony_cistatic inline void xc2(smpfunc_t func, unsigned long arg1, unsigned long arg2)
798c2ecf20Sopenharmony_ci{
808c2ecf20Sopenharmony_ci	sparc32_ipi_ops->cross_call(func, *cpu_online_mask, arg1, arg2, 0, 0);
818c2ecf20Sopenharmony_ci}
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_cistatic inline void xc3(smpfunc_t func, unsigned long arg1, unsigned long arg2,
848c2ecf20Sopenharmony_ci		       unsigned long arg3)
858c2ecf20Sopenharmony_ci{
868c2ecf20Sopenharmony_ci	sparc32_ipi_ops->cross_call(func, *cpu_online_mask,
878c2ecf20Sopenharmony_ci				    arg1, arg2, arg3, 0);
888c2ecf20Sopenharmony_ci}
898c2ecf20Sopenharmony_ci
908c2ecf20Sopenharmony_cistatic inline void xc4(smpfunc_t func, unsigned long arg1, unsigned long arg2,
918c2ecf20Sopenharmony_ci		       unsigned long arg3, unsigned long arg4)
928c2ecf20Sopenharmony_ci{
938c2ecf20Sopenharmony_ci	sparc32_ipi_ops->cross_call(func, *cpu_online_mask,
948c2ecf20Sopenharmony_ci				    arg1, arg2, arg3, arg4);
958c2ecf20Sopenharmony_ci}
968c2ecf20Sopenharmony_ci
978c2ecf20Sopenharmony_civoid arch_send_call_function_single_ipi(int cpu);
988c2ecf20Sopenharmony_civoid arch_send_call_function_ipi_mask(const struct cpumask *mask);
998c2ecf20Sopenharmony_ci
1008c2ecf20Sopenharmony_cistatic inline int cpu_logical_map(int cpu)
1018c2ecf20Sopenharmony_ci{
1028c2ecf20Sopenharmony_ci	return cpu;
1038c2ecf20Sopenharmony_ci}
1048c2ecf20Sopenharmony_ci
1058c2ecf20Sopenharmony_ciint hard_smp_processor_id(void);
1068c2ecf20Sopenharmony_ci
1078c2ecf20Sopenharmony_ci#define raw_smp_processor_id()		(current_thread_info()->cpu)
1088c2ecf20Sopenharmony_ci
1098c2ecf20Sopenharmony_civoid smp_setup_cpu_possible_map(void);
1108c2ecf20Sopenharmony_ci
1118c2ecf20Sopenharmony_ci#endif /* !(__ASSEMBLY__) */
1128c2ecf20Sopenharmony_ci
1138c2ecf20Sopenharmony_ci/* Sparc specific messages. */
1148c2ecf20Sopenharmony_ci#define MSG_CROSS_CALL         0x0005       /* run func on cpus */
1158c2ecf20Sopenharmony_ci
1168c2ecf20Sopenharmony_ci/* Empirical PROM processor mailbox constants.  If the per-cpu mailbox
1178c2ecf20Sopenharmony_ci * contains something other than one of these then the ipi is from
1188c2ecf20Sopenharmony_ci * Linux's active_kernel_processor.  This facility exists so that
1198c2ecf20Sopenharmony_ci * the boot monitor can capture all the other cpus when one catches
1208c2ecf20Sopenharmony_ci * a watchdog reset or the user enters the monitor using L1-A keys.
1218c2ecf20Sopenharmony_ci */
1228c2ecf20Sopenharmony_ci#define MBOX_STOPCPU          0xFB
1238c2ecf20Sopenharmony_ci#define MBOX_IDLECPU          0xFC
1248c2ecf20Sopenharmony_ci#define MBOX_IDLECPU2         0xFD
1258c2ecf20Sopenharmony_ci#define MBOX_STOPCPU2         0xFE
1268c2ecf20Sopenharmony_ci
1278c2ecf20Sopenharmony_ci#else /* SMP */
1288c2ecf20Sopenharmony_ci
1298c2ecf20Sopenharmony_ci#define hard_smp_processor_id()		0
1308c2ecf20Sopenharmony_ci#define smp_setup_cpu_possible_map() do { } while (0)
1318c2ecf20Sopenharmony_ci
1328c2ecf20Sopenharmony_ci#endif /* !(SMP) */
1338c2ecf20Sopenharmony_ci#endif /* !(_SPARC_SMP_H) */
134