[S390] smp: rework sigp code
[linux-2.6/next.git] / arch / s390 / include / asm / sigp.h
blob8aa46ce4229c49dd397f4a7ebbe3e5c089d5e5f3
1 /*
2 * Routines and structures for signalling other processors.
4 * Copyright IBM Corp. 1999,2010
5 * Author(s): Denis Joseph Barrow,
6 * Martin Schwidefsky <schwidefsky@de.ibm.com>,
7 * Heiko Carstens <heiko.carstens@de.ibm.com>,
8 */
10 #ifndef __ASM_SIGP_H
11 #define __ASM_SIGP_H
13 #include <asm/system.h>
15 /* Get real cpu address from logical cpu number. */
16 extern unsigned short __cpu_logical_map[];
18 static inline int cpu_logical_map(int cpu)
20 #ifdef CONFIG_SMP
21 return __cpu_logical_map[cpu];
22 #else
23 return stap();
24 #endif
27 enum {
28 sigp_unassigned=0x0,
29 sigp_sense,
30 sigp_external_call,
31 sigp_emergency_signal,
32 sigp_start,
33 sigp_stop,
34 sigp_restart,
35 sigp_unassigned1,
36 sigp_unassigned2,
37 sigp_stop_and_store_status,
38 sigp_unassigned3,
39 sigp_initial_cpu_reset,
40 sigp_cpu_reset,
41 sigp_set_prefix,
42 sigp_store_status_at_address,
43 sigp_store_extended_status_at_address
46 enum {
47 sigp_order_code_accepted=0,
48 sigp_status_stored,
49 sigp_busy,
50 sigp_not_operational
54 * Definitions for external call.
56 enum {
57 ec_schedule = 0,
58 ec_call_function,
59 ec_call_function_single,
60 ec_bit_last
64 * Signal processor.
66 static inline int raw_sigp(u16 cpu, int order)
68 register unsigned long reg1 asm ("1") = 0;
69 int ccode;
71 asm volatile(
72 " sigp %1,%2,0(%3)\n"
73 " ipm %0\n"
74 " srl %0,28\n"
75 : "=d" (ccode)
76 : "d" (reg1), "d" (cpu),
77 "a" (order) : "cc" , "memory");
78 return ccode;
82 * Signal processor with parameter.
84 static inline int raw_sigp_p(u32 parameter, u16 cpu, int order)
86 register unsigned int reg1 asm ("1") = parameter;
87 int ccode;
89 asm volatile(
90 " sigp %1,%2,0(%3)\n"
91 " ipm %0\n"
92 " srl %0,28\n"
93 : "=d" (ccode)
94 : "d" (reg1), "d" (cpu),
95 "a" (order) : "cc" , "memory");
96 return ccode;
100 * Signal processor with parameter and return status.
102 static inline int raw_sigp_ps(u32 *status, u32 parm, u16 cpu, int order)
104 register unsigned int reg1 asm ("1") = parm;
105 int ccode;
107 asm volatile(
108 " sigp %1,%2,0(%3)\n"
109 " ipm %0\n"
110 " srl %0,28\n"
111 : "=d" (ccode), "+d" (reg1)
112 : "d" (cpu), "a" (order)
113 : "cc" , "memory");
114 *status = reg1;
115 return ccode;
118 static inline int sigp(int cpu, int order)
120 return raw_sigp(cpu_logical_map(cpu), order);
123 static inline int sigp_p(u32 parameter, int cpu, int order)
125 return raw_sigp_p(parameter, cpu_logical_map(cpu), order);
128 static inline int sigp_ps(u32 *status, u32 parm, int cpu, int order)
130 return raw_sigp_ps(status, parm, cpu_logical_map(cpu), order);
133 #endif /* __ASM_SIGP_H */