blob: f72d611f7e13d7dc0e4856e30ba3e55bb0c4c8f9 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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 * Heiko Carstens (heiko.carstens@de.ibm.com)
9 *
10 * sigp.h by D.J. Barrow (c) IBM 1999
11 * contains routines / structures for signalling other S/390 processors in an
12 * SMP configuration.
13 */
14
15#ifndef __SIGP__
16#define __SIGP__
17
Heiko Carstensfb380aa2010-01-13 20:44:37 +010018#include <asm/system.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070019
20/* get real cpu address from logical cpu number */
Heiko Carstensc6a5f8c2010-01-13 20:44:35 +010021extern int __cpu_logical_map[];
Linus Torvalds1da177e2005-04-16 15:20:36 -070022
Heiko Carstensfb380aa2010-01-13 20:44:37 +010023static inline int cpu_logical_map(int cpu)
24{
25#ifdef CONFIG_SMP
26 return __cpu_logical_map[cpu];
27#else
28 return stap();
29#endif
30}
31
Linus Torvalds1da177e2005-04-16 15:20:36 -070032typedef enum
33{
34 sigp_unassigned=0x0,
35 sigp_sense,
36 sigp_external_call,
37 sigp_emergency_signal,
38 sigp_start,
39 sigp_stop,
40 sigp_restart,
41 sigp_unassigned1,
42 sigp_unassigned2,
43 sigp_stop_and_store_status,
44 sigp_unassigned3,
45 sigp_initial_cpu_reset,
46 sigp_cpu_reset,
47 sigp_set_prefix,
48 sigp_store_status_at_address,
49 sigp_store_extended_status_at_address
50} sigp_order_code;
51
52typedef __u32 sigp_status_word;
53
54typedef enum
55{
56 sigp_order_code_accepted=0,
57 sigp_status_stored,
58 sigp_busy,
59 sigp_not_operational
60} sigp_ccode;
61
62
63/*
64 * Definitions for the external call
65 */
66
67/* 'Bit' signals, asynchronous */
68typedef enum
69{
70 ec_schedule=0,
71 ec_call_function,
Heiko Carstensca9fc752008-12-25 13:38:39 +010072 ec_call_function_single,
Linus Torvalds1da177e2005-04-16 15:20:36 -070073 ec_bit_last
74} ec_bit_sig;
75
76/*
77 * Signal processor
78 */
Adrian Bunk4448aaf2005-11-08 21:34:42 -080079static inline sigp_ccode
Linus Torvalds1da177e2005-04-16 15:20:36 -070080signal_processor(__u16 cpu_addr, sigp_order_code order_code)
81{
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020082 register unsigned long reg1 asm ("1") = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070083 sigp_ccode ccode;
84
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020085 asm volatile(
86 " sigp %1,%2,0(%3)\n"
87 " ipm %0\n"
88 " srl %0,28\n"
89 : "=d" (ccode)
Heiko Carstensfb380aa2010-01-13 20:44:37 +010090 : "d" (reg1), "d" (cpu_logical_map(cpu_addr)),
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020091 "a" (order_code) : "cc" , "memory");
Linus Torvalds1da177e2005-04-16 15:20:36 -070092 return ccode;
93}
94
95/*
96 * Signal processor with parameter
97 */
Adrian Bunk4448aaf2005-11-08 21:34:42 -080098static inline sigp_ccode
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020099signal_processor_p(__u32 parameter, __u16 cpu_addr, sigp_order_code order_code)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100{
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200101 register unsigned int reg1 asm ("1") = parameter;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102 sigp_ccode ccode;
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200103
104 asm volatile(
105 " sigp %1,%2,0(%3)\n"
106 " ipm %0\n"
107 " srl %0,28\n"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108 : "=d" (ccode)
Heiko Carstensfb380aa2010-01-13 20:44:37 +0100109 : "d" (reg1), "d" (cpu_logical_map(cpu_addr)),
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200110 "a" (order_code) : "cc" , "memory");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111 return ccode;
112}
113
114/*
115 * Signal processor with parameter and return status
116 */
Adrian Bunk4448aaf2005-11-08 21:34:42 -0800117static inline sigp_ccode
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200118signal_processor_ps(__u32 *statusptr, __u32 parameter, __u16 cpu_addr,
119 sigp_order_code order_code)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120{
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200121 register unsigned int reg1 asm ("1") = parameter;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122 sigp_ccode ccode;
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200123
124 asm volatile(
125 " sigp %1,%2,0(%3)\n"
126 " ipm %0\n"
127 " srl %0,28\n"
128 : "=d" (ccode), "+d" (reg1)
Heiko Carstensfb380aa2010-01-13 20:44:37 +0100129 : "d" (cpu_logical_map(cpu_addr)), "a" (order_code)
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200130 : "cc" , "memory");
131 *statusptr = reg1;
132 return ccode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133}
134
135#endif /* __SIGP__ */