blob: e3bffd4e2d6662b08e8dab76cd4dc924508ead3d [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,
Heiko Carstensa93b8ec2010-02-26 22:37:35 +010059};
Linus Torvalds1da177e2005-04-16 15:20:36 -070060
61/*
Heiko Carstensa93b8ec2010-02-26 22:37:35 +010062 * Signal processor.
Linus Torvalds1da177e2005-04-16 15:20:36 -070063 */
Heiko Carstensa93b8ec2010-02-26 22:37:35 +010064static inline int raw_sigp(u16 cpu, int order)
Linus Torvalds1da177e2005-04-16 15:20:36 -070065{
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020066 register unsigned long reg1 asm ("1") = 0;
Heiko Carstensa93b8ec2010-02-26 22:37:35 +010067 int ccode;
Linus Torvalds1da177e2005-04-16 15:20:36 -070068
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020069 asm volatile(
70 " sigp %1,%2,0(%3)\n"
71 " ipm %0\n"
72 " srl %0,28\n"
73 : "=d" (ccode)
Heiko Carstensa93b8ec2010-02-26 22:37:35 +010074 : "d" (reg1), "d" (cpu),
75 "a" (order) : "cc" , "memory");
Linus Torvalds1da177e2005-04-16 15:20:36 -070076 return ccode;
77}
78
79/*
Heiko Carstensa93b8ec2010-02-26 22:37:35 +010080 * Signal processor with parameter.
Linus Torvalds1da177e2005-04-16 15:20:36 -070081 */
Heiko Carstensa93b8ec2010-02-26 22:37:35 +010082static inline int raw_sigp_p(u32 parameter, u16 cpu, int order)
Linus Torvalds1da177e2005-04-16 15:20:36 -070083{
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020084 register unsigned int reg1 asm ("1") = parameter;
Heiko Carstensa93b8ec2010-02-26 22:37:35 +010085 int ccode;
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020086
87 asm volatile(
88 " sigp %1,%2,0(%3)\n"
89 " ipm %0\n"
90 " srl %0,28\n"
Linus Torvalds1da177e2005-04-16 15:20:36 -070091 : "=d" (ccode)
Heiko Carstensa93b8ec2010-02-26 22:37:35 +010092 : "d" (reg1), "d" (cpu),
93 "a" (order) : "cc" , "memory");
Linus Torvalds1da177e2005-04-16 15:20:36 -070094 return ccode;
95}
96
97/*
Heiko Carstensa93b8ec2010-02-26 22:37:35 +010098 * Signal processor with parameter and return status.
Linus Torvalds1da177e2005-04-16 15:20:36 -070099 */
Heiko Carstensa93b8ec2010-02-26 22:37:35 +0100100static inline int raw_sigp_ps(u32 *status, u32 parm, u16 cpu, int order)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101{
Heiko Carstensa93b8ec2010-02-26 22:37:35 +0100102 register unsigned int reg1 asm ("1") = parm;
103 int ccode;
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200104
105 asm volatile(
106 " sigp %1,%2,0(%3)\n"
107 " ipm %0\n"
108 " srl %0,28\n"
109 : "=d" (ccode), "+d" (reg1)
Heiko Carstensa93b8ec2010-02-26 22:37:35 +0100110 : "d" (cpu), "a" (order)
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200111 : "cc" , "memory");
Heiko Carstensa93b8ec2010-02-26 22:37:35 +0100112 *status = reg1;
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200113 return ccode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114}
115
Heiko Carstensa93b8ec2010-02-26 22:37:35 +0100116static inline int sigp(int cpu, int order)
117{
118 return raw_sigp(cpu_logical_map(cpu), order);
119}
120
121static inline int sigp_p(u32 parameter, int cpu, int order)
122{
123 return raw_sigp_p(parameter, cpu_logical_map(cpu), order);
124}
125
126static inline int sigp_ps(u32 *status, u32 parm, int cpu, int order)
127{
128 return raw_sigp_ps(status, parm, cpu_logical_map(cpu), order);
129}
130
131#endif /* __ASM_SIGP_H */