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 {
L
Linus Torvalds 已提交
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
	sigp_unassigned=0x0,
	sigp_sense,
	sigp_external_call,
	sigp_emergency_signal,
	sigp_start,
	sigp_stop,
	sigp_restart,
	sigp_unassigned1,
	sigp_unassigned2,
	sigp_stop_and_store_status,
	sigp_unassigned3,
	sigp_initial_cpu_reset,
	sigp_cpu_reset,
	sigp_set_prefix,
	sigp_store_status_at_address,
	sigp_store_extended_status_at_address
H
Heiko Carstens 已提交
44
};
L
Linus Torvalds 已提交
45

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

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

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

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

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

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

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

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

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