blob: bfe070bc76594065530cc27aa722aa7ee7308160 [file] [log] [blame]
Heiko Carstens2c2df112010-02-26 22:37:34 +01001/*
2 * 31-bit switch cpu code
3 *
4 * Copyright IBM Corp. 2009
5 *
6 */
7
Jan Glauber144d6342011-07-24 10:48:19 +02008#include <linux/linkage.h>
Heiko Carstens2c2df112010-02-26 22:37:34 +01009#include <asm/asm-offsets.h>
Heiko Carstens2c2df112010-02-26 22:37:34 +010010#include <asm/ptrace.h>
11
12# smp_switch_to_cpu switches to destination cpu and executes the passed function
13# Parameter: %r2 - function to call
14# %r3 - function parameter
15# %r4 - stack poiner
16# %r5 - current cpu
17# %r6 - destination cpu
18
19 .section .text
Jan Glauber144d6342011-07-24 10:48:19 +020020ENTRY(smp_switch_to_cpu)
Heiko Carstens2c2df112010-02-26 22:37:34 +010021 stm %r6,%r15,__SF_GPRS(%r15)
22 lr %r1,%r15
23 ahi %r15,-STACK_FRAME_OVERHEAD
24 st %r1,__SF_BACKCHAIN(%r15)
25 basr %r13,0
260: la %r1,.gprregs_addr-0b(%r13)
27 l %r1,0(%r1)
28 stm %r0,%r15,0(%r1)
291: sigp %r0,%r6,__SIGP_RESTART /* start destination CPU */
30 brc 2,1b /* busy, try again */
312: sigp %r0,%r5,__SIGP_STOP /* stop current CPU */
32 brc 2,2b /* busy, try again */
333: j 3b
34
Jan Glauber144d6342011-07-24 10:48:19 +020035ENTRY(smp_restart_cpu)
Heiko Carstens2c2df112010-02-26 22:37:34 +010036 basr %r13,0
370: la %r1,.gprregs_addr-0b(%r13)
38 l %r1,0(%r1)
39 lm %r0,%r15,0(%r1)
401: sigp %r0,%r5,__SIGP_SENSE /* Wait for calling CPU */
41 brc 10,1b /* busy, accepted (status 0), running */
42 tmll %r0,0x40 /* Test if calling CPU is stopped */
43 jz 1b
44 ltr %r4,%r4 /* New stack ? */
45 jz 1f
46 lr %r15,%r4
Michael Holzheu034e9e92011-04-04 09:43:30 +0200471: lr %r14,%r2 /* r14: Function to call */
48 lr %r2,%r3 /* r2 : Parameter for function*/
49 basr %r14,%r14 /* Call function */
Heiko Carstens2c2df112010-02-26 22:37:34 +010050
51.gprregs_addr:
52 .long .gprregs
53
54 .section .data,"aw",@progbits
55.gprregs:
56 .rept 16
57 .long 0
58 .endr