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,
H
Heiko Carstens 已提交
59
};
L
Linus Torvalds 已提交
60 61

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

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

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

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

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

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

H
Heiko Carstens 已提交
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
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 */