sigp.h 2.5 KB
Newer Older
L
Linus Torvalds 已提交
1
/*
H
Heiko Carstens 已提交
2
 *  Routines and structures for signalling other processors.
L
Linus Torvalds 已提交
3
 *
H
Heiko Carstens 已提交
4 5 6 7
 *    Copyright IBM Corp. 1999,2010
 *    Author(s): Denis Joseph Barrow,
 *		 Martin Schwidefsky <schwidefsky@de.ibm.com>,
 *		 Heiko Carstens <heiko.carstens@de.ibm.com>,
L
Linus Torvalds 已提交
8 9
 */

H
Heiko Carstens 已提交
10 11
#ifndef __ASM_SIGP_H
#define __ASM_SIGP_H
L
Linus Torvalds 已提交
12

13
#include <asm/system.h>
L
Linus Torvalds 已提交
14

H
Heiko Carstens 已提交
15 16
/* Get real cpu address from logical cpu number. */
extern unsigned short __cpu_logical_map[];
L
Linus Torvalds 已提交
17

18 19 20 21 22 23 24 25 26
static inline int cpu_logical_map(int cpu)
{
#ifdef CONFIG_SMP
	return __cpu_logical_map[cpu];
#else
	return stap();
#endif
}

H
Heiko Carstens 已提交
27
enum {
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
	sigp_sense = 1,
	sigp_external_call = 2,
	sigp_emergency_signal = 3,
	sigp_start = 4,
	sigp_stop = 5,
	sigp_restart = 6,
	sigp_stop_and_store_status = 9,
	sigp_initial_cpu_reset = 11,
	sigp_cpu_reset = 12,
	sigp_set_prefix = 13,
	sigp_store_status_at_address = 14,
	sigp_store_extended_status_at_address = 15,
	sigp_set_architecture = 18,
	sigp_conditional_emergency_signal = 19,
	sigp_sense_running = 21,
H
Heiko Carstens 已提交
43
};
L
Linus Torvalds 已提交
44

H
Heiko Carstens 已提交
45
enum {
46 47 48 49
	sigp_order_code_accepted = 0,
	sigp_status_stored = 1,
	sigp_busy = 2,
	sigp_not_operational = 3,
H
Heiko Carstens 已提交
50
};
L
Linus Torvalds 已提交
51 52

/*
H
Heiko Carstens 已提交
53
 * Definitions for external call.
L
Linus Torvalds 已提交
54
 */
H
Heiko Carstens 已提交
55 56
enum {
	ec_schedule = 0,
L
Linus Torvalds 已提交
57
	ec_call_function,
58
	ec_call_function_single,
59
	ec_stop_cpu,
H
Heiko Carstens 已提交
60
};
L
Linus Torvalds 已提交
61 62

/*
H
Heiko Carstens 已提交
63
 * Signal processor.
L
Linus Torvalds 已提交
64
 */
H
Heiko Carstens 已提交
65
static inline int raw_sigp(u16 cpu, int order)
L
Linus Torvalds 已提交
66
{
67
	register unsigned long reg1 asm ("1") = 0;
H
Heiko Carstens 已提交
68
	int ccode;
L
Linus Torvalds 已提交
69

70 71 72 73 74
	asm volatile(
		"	sigp	%1,%2,0(%3)\n"
		"	ipm	%0\n"
		"	srl	%0,28\n"
		:	"=d"	(ccode)
H
Heiko Carstens 已提交
75 76
		: "d" (reg1), "d" (cpu),
		  "a" (order) : "cc" , "memory");
L
Linus Torvalds 已提交
77 78 79 80
	return ccode;
}

/*
H
Heiko Carstens 已提交
81
 * Signal processor with parameter.
L
Linus Torvalds 已提交
82
 */
H
Heiko Carstens 已提交
83
static inline int raw_sigp_p(u32 parameter, u16 cpu, int order)
L
Linus Torvalds 已提交
84
{
85
	register unsigned int reg1 asm ("1") = parameter;
H
Heiko Carstens 已提交
86
	int ccode;
87 88 89 90 91

	asm volatile(
		"	sigp	%1,%2,0(%3)\n"
		"	ipm	%0\n"
		"	srl	%0,28\n"
L
Linus Torvalds 已提交
92
		: "=d" (ccode)
H
Heiko Carstens 已提交
93 94
		: "d" (reg1), "d" (cpu),
		  "a" (order) : "cc" , "memory");
L
Linus Torvalds 已提交
95 96 97 98
	return ccode;
}

/*
H
Heiko Carstens 已提交
99
 * Signal processor with parameter and return status.
L
Linus Torvalds 已提交
100
 */
H
Heiko Carstens 已提交
101
static inline int raw_sigp_ps(u32 *status, u32 parm, u16 cpu, int order)
L
Linus Torvalds 已提交
102
{
H
Heiko Carstens 已提交
103 104
	register unsigned int reg1 asm ("1") = parm;
	int ccode;
105 106 107 108 109 110

	asm volatile(
		"	sigp	%1,%2,0(%3)\n"
		"	ipm	%0\n"
		"	srl	%0,28\n"
		: "=d" (ccode), "+d" (reg1)
H
Heiko Carstens 已提交
111
		: "d" (cpu), "a" (order)
112
		: "cc" , "memory");
H
Heiko Carstens 已提交
113
	*status = reg1;
114
	return ccode;
L
Linus Torvalds 已提交
115 116
}

H
Heiko Carstens 已提交
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
static inline int sigp(int cpu, int order)
{
	return raw_sigp(cpu_logical_map(cpu), order);
}

static inline int sigp_p(u32 parameter, int cpu, int order)
{
	return raw_sigp_p(parameter, cpu_logical_map(cpu), order);
}

static inline int sigp_ps(u32 *status, u32 parm, int cpu, int order)
{
	return raw_sigp_ps(status, parm, cpu_logical_map(cpu), order);
}

#endif /* __ASM_SIGP_H */