cleanup
[linux-2.4.git] / include / asm-s390x / sigp.h
1 /*
2  *  include/asm-s390/sigp.h
3  *
4  *  S390 version
5  *    Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
6  *    Author(s): Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com),
7  *               Martin Schwidefsky (schwidefsky@de.ibm.com)
8  *
9  *  sigp.h by D.J. Barrow (c) IBM 1999
10  *  contains routines / structures for signalling other S/390 processors in an
11  *  SMP configuration.
12  */
13
14 #ifndef __SIGP__
15 #define __SIGP__
16
17 #include <asm/ptrace.h>
18 #include <asm/atomic.h>
19
20 /* get real cpu address from logical cpu number */
21 extern volatile int __cpu_logical_map[];
22
23 typedef enum
24 {
25         sigp_unassigned=0x0,
26         sigp_sense,
27         sigp_external_call,
28         sigp_emergency_signal,
29         sigp_start,
30         sigp_stop,
31         sigp_restart,
32         sigp_unassigned1,
33         sigp_unassigned2,
34         sigp_stop_and_store_status,
35         sigp_unassigned3,
36         sigp_initial_cpu_reset,
37         sigp_cpu_reset,
38         sigp_set_prefix,
39         sigp_store_status_at_address,
40         sigp_store_extended_status_at_address
41 } sigp_order_code;
42
43 typedef __u32 sigp_status_word;
44
45 typedef enum
46 {
47         sigp_order_code_accepted=0,
48         sigp_status_stored,
49         sigp_busy,
50         sigp_not_operational
51 } sigp_ccode;
52
53
54 /*
55  * Definitions for the external call
56  */
57
58 /* 'Bit' signals, asynchronous */
59 typedef enum
60 {
61         ec_schedule=0,
62         ec_call_function,
63         ec_bit_last
64 } ec_bit_sig;
65
66
67 /*
68  * Signal processor
69  */
70 extern __inline__ sigp_ccode
71 signal_processor(__u16 cpu_addr, sigp_order_code order_code)
72 {
73         sigp_ccode ccode;
74
75         __asm__ __volatile__(
76                 "    sgr    1,1\n"        /* parameter=0 in gpr 1 */
77                 "    sigp   1,%1,0(%2)\n"
78                 "    ipm    %0\n"
79                 "    srl    %0,28"
80                 : "=d" (ccode)
81                 : "d" (__cpu_logical_map[cpu_addr]), "a" (order_code)
82                 : "cc" , "memory", "1" );
83         return ccode;
84 }
85
86 /*
87  * Signal processor with parameter
88  */
89 extern __inline__ sigp_ccode
90 signal_processor_p(__u64 parameter,__u16 cpu_addr,sigp_order_code order_code)
91 {
92         sigp_ccode ccode;
93         
94         __asm__ __volatile__(
95                 "    lgr    1,%1\n"       /* parameter in gpr 1 */
96                 "    sigp   1,%2,0(%3)\n"
97                 "    ipm    %0\n"
98                 "    srl    %0,28\n"
99                 : "=d" (ccode)
100                 : "d" (parameter), "d" (__cpu_logical_map[cpu_addr]),
101                   "a" (order_code)
102                 : "cc" , "memory", "1" );
103         return ccode;
104 }
105
106 /*
107  * Signal processor with parameter and return status
108  */
109 extern __inline__ sigp_ccode
110 signal_processor_ps(unsigned long *statusptr, __u64 parameter,
111                     __u16 cpu_addr, sigp_order_code order_code)
112 {
113         sigp_ccode ccode;
114         
115         __asm__ __volatile__(
116                 "    sgr    2,2\n"        /* clear status so it doesn't contain rubbish if not saved. */
117                 "    lgr    3,%2\n"       /* parameter in gpr 3 */
118                 "    sigp   2,%3,0(%4)\n"
119                 "    stg    2,%1\n"
120                 "    ipm    %0\n"
121                 "    srl    %0,28\n"
122                 : "=d" (ccode), "=m" (*statusptr)
123                 : "d" (parameter), "d" (__cpu_logical_map[cpu_addr]),
124                   "a" (order_code)
125                 : "cc" , "memory", "2" , "3"
126                 );
127    return ccode;
128 }
129
130 #endif /* __SIGP__ */
131
132