blob: 7040b8567cd05d89f8d5f0da87b998b6880ba09d [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Heiko Carstensa93b8ec2010-02-26 22:37:35 +01002 * Routines and structures for signalling other processors.
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 *
Heiko Carstensa93b8ec2010-02-26 22:37:35 +01004 * 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>,
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 */
9
Heiko Carstensa93b8ec2010-02-26 22:37:35 +010010#ifndef __ASM_SIGP_H
11#define __ASM_SIGP_H
Linus Torvalds1da177e2005-04-16 15:20:36 -070012
Heiko Carstensfb380aa2010-01-13 20:44:37 +010013#include <asm/system.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070014
Heiko Carstensa93b8ec2010-02-26 22:37:35 +010015/* Get real cpu address from logical cpu number. */
16extern unsigned short __cpu_logical_map[];
Linus Torvalds1da177e2005-04-16 15:20:36 -070017
Heiko Carstensfb380aa2010-01-13 20:44:37 +010018static inline int cpu_logical_map(int cpu)
19{
20#ifdef CONFIG_SMP
21 return __cpu_logical_map[cpu];
22#else
23 return stap();
24#endif
25}
26
Heiko Carstensa93b8ec2010-02-26 22:37:35 +010027enum {
Gerald Schaefer59b69782010-02-26 22:37:40 +010028 sigp_sense = 1,
29 sigp_external_call = 2,
30 sigp_emergency_signal = 3,
31 sigp_start = 4,
32 sigp_stop = 5,
33 sigp_restart = 6,
34 sigp_stop_and_store_status = 9,
35 sigp_initial_cpu_reset = 11,
36 sigp_cpu_reset = 12,
37 sigp_set_prefix = 13,
38 sigp_store_status_at_address = 14,
39 sigp_store_extended_status_at_address = 15,
40 sigp_set_architecture = 18,
41 sigp_conditional_emergency_signal = 19,
42 sigp_sense_running = 21,
Heiko Carstensa93b8ec2010-02-26 22:37:35 +010043};
Linus Torvalds1da177e2005-04-16 15:20:36 -070044
Heiko Carstensa93b8ec2010-02-26 22:37:35 +010045enum {
Gerald Schaefer59b69782010-02-26 22:37:40 +010046 sigp_order_code_accepted = 0,
47 sigp_status_stored = 1,
48 sigp_busy = 2,
49 sigp_not_operational = 3,
Heiko Carstensa93b8ec2010-02-26 22:37:35 +010050};
Linus Torvalds1da177e2005-04-16 15:20:36 -070051
52/*
Heiko Carstensa93b8ec2010-02-26 22:37:35 +010053 * Definitions for external call.
Linus Torvalds1da177e2005-04-16 15:20:36 -070054 */
Heiko Carstensa93b8ec2010-02-26 22:37:35 +010055enum {
56 ec_schedule = 0,
Linus Torvalds1da177e2005-04-16 15:20:36 -070057 ec_call_function,
Heiko Carstensca9fc752008-12-25 13:38:39 +010058 ec_call_function_single,
Martin Schwidefsky85ac7ca2011-12-27 11:27:22 +010059 ec_stop_cpu,
Heiko Carstensa93b8ec2010-02-26 22:37:35 +010060};
Linus Torvalds1da177e2005-04-16 15:20:36 -070061
62/*
Heiko Carstensa93b8ec2010-02-26 22:37:35 +010063 * Signal processor.
Linus Torvalds1da177e2005-04-16 15:20:36 -070064 */
Heiko Carstensa93b8ec2010-02-26 22:37:35 +010065static inline int raw_sigp(u16 cpu, int order)
Linus Torvalds1da177e2005-04-16 15:20:36 -070066{
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020067 register unsigned long reg1 asm ("1") = 0;
Heiko Carstensa93b8ec2010-02-26 22:37:35 +010068 int ccode;
Linus Torvalds1da177e2005-04-16 15:20:36 -070069
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020070 asm volatile(
71 " sigp %1,%2,0(%3)\n"
72 " ipm %0\n"
73 " srl %0,28\n"
74 : "=d" (ccode)
Heiko Carstensa93b8ec2010-02-26 22:37:35 +010075 : "d" (reg1), "d" (cpu),
76 "a" (order) : "cc" , "memory");
Linus Torvalds1da177e2005-04-16 15:20:36 -070077 return ccode;
78}
79
80/*
Heiko Carstensa93b8ec2010-02-26 22:37:35 +010081 * Signal processor with parameter.
Linus Torvalds1da177e2005-04-16 15:20:36 -070082 */
Heiko Carstensa93b8ec2010-02-26 22:37:35 +010083static inline int raw_sigp_p(u32 parameter, u16 cpu, int order)
Linus Torvalds1da177e2005-04-16 15:20:36 -070084{
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020085 register unsigned int reg1 asm ("1") = parameter;
Heiko Carstensa93b8ec2010-02-26 22:37:35 +010086 int ccode;
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020087
88 asm volatile(
89 " sigp %1,%2,0(%3)\n"
90 " ipm %0\n"
91 " srl %0,28\n"
Linus Torvalds1da177e2005-04-16 15:20:36 -070092 : "=d" (ccode)
Heiko Carstensa93b8ec2010-02-26 22:37:35 +010093 : "d" (reg1), "d" (cpu),
94 "a" (order) : "cc" , "memory");
Linus Torvalds1da177e2005-04-16 15:20:36 -070095 return ccode;
96}
97
98/*
Heiko Carstensa93b8ec2010-02-26 22:37:35 +010099 * Signal processor with parameter and return status.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100 */
Heiko Carstensa93b8ec2010-02-26 22:37:35 +0100101static inline int raw_sigp_ps(u32 *status, u32 parm, u16 cpu, int order)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102{
Heiko Carstensa93b8ec2010-02-26 22:37:35 +0100103 register unsigned int reg1 asm ("1") = parm;
104 int ccode;
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200105
106 asm volatile(
107 " sigp %1,%2,0(%3)\n"
108 " ipm %0\n"
109 " srl %0,28\n"
110 : "=d" (ccode), "+d" (reg1)
Heiko Carstensa93b8ec2010-02-26 22:37:35 +0100111 : "d" (cpu), "a" (order)
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200112 : "cc" , "memory");
Heiko Carstensa93b8ec2010-02-26 22:37:35 +0100113 *status = reg1;
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200114 return ccode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115}
116
Heiko Carstensa93b8ec2010-02-26 22:37:35 +0100117static inline int sigp(int cpu, int order)
118{
119 return raw_sigp(cpu_logical_map(cpu), order);
120}
121
122static inline int sigp_p(u32 parameter, int cpu, int order)
123{
124 return raw_sigp_p(parameter, cpu_logical_map(cpu), order);
125}
126
127static inline int sigp_ps(u32 *status, u32 parm, int cpu, int order)
128{
129 return raw_sigp_ps(status, parm, cpu_logical_map(cpu), order);
130}
131
132#endif /* __ASM_SIGP_H */