| Heiko Carstens | 2c2df11 | 2010-02-26 22:37:34 +0100 | [diff] [blame] | 1 | /* | 
 | 2 |  * 31-bit switch cpu code | 
 | 3 |  * | 
 | 4 |  * Copyright IBM Corp. 2009 | 
 | 5 |  * | 
 | 6 |  */ | 
 | 7 |  | 
 | 8 | #include <asm/asm-offsets.h> | 
| Heiko Carstens | 2c2df11 | 2010-02-26 22:37:34 +0100 | [diff] [blame] | 9 | #include <asm/ptrace.h> | 
 | 10 |  | 
 | 11 | # smp_switch_to_cpu switches to destination cpu and executes the passed function | 
 | 12 | # Parameter: %r2 - function to call | 
 | 13 | #	     %r3 - function parameter | 
 | 14 | #	     %r4 - stack poiner | 
 | 15 | #	     %r5 - current cpu | 
 | 16 | #	     %r6 - destination cpu | 
 | 17 |  | 
 | 18 | 	.section .text | 
 | 19 | 	.align 4 | 
 | 20 | 	.globl smp_switch_to_cpu | 
 | 21 | smp_switch_to_cpu: | 
 | 22 | 	stm	%r6,%r15,__SF_GPRS(%r15) | 
 | 23 | 	lr	%r1,%r15 | 
 | 24 | 	ahi	%r15,-STACK_FRAME_OVERHEAD | 
 | 25 | 	st	%r1,__SF_BACKCHAIN(%r15) | 
 | 26 | 	basr	%r13,0 | 
 | 27 | 0:	la	%r1,.gprregs_addr-0b(%r13) | 
 | 28 | 	l	%r1,0(%r1) | 
 | 29 | 	stm	%r0,%r15,0(%r1) | 
 | 30 | 1:	sigp	%r0,%r6,__SIGP_RESTART	/* start destination CPU */ | 
 | 31 | 	brc	2,1b			/* busy, try again */ | 
 | 32 | 2:	sigp	%r0,%r5,__SIGP_STOP	/* stop current CPU */ | 
 | 33 | 	brc	2,2b			/* busy, try again */ | 
 | 34 | 3:	j	3b | 
 | 35 |  | 
 | 36 | 	.globl	smp_restart_cpu | 
 | 37 | smp_restart_cpu: | 
 | 38 | 	basr	%r13,0 | 
 | 39 | 0:	la	%r1,.gprregs_addr-0b(%r13) | 
 | 40 | 	l	%r1,0(%r1) | 
 | 41 | 	lm	%r0,%r15,0(%r1) | 
 | 42 | 1:	sigp	%r0,%r5,__SIGP_SENSE	/* Wait for calling CPU */ | 
 | 43 | 	brc	10,1b			/* busy, accepted (status 0), running */ | 
 | 44 | 	tmll	%r0,0x40		/* Test if calling CPU is stopped */ | 
 | 45 | 	jz	1b | 
 | 46 | 	ltr	%r4,%r4			/* New stack ? */ | 
 | 47 | 	jz	1f | 
 | 48 | 	lr	%r15,%r4 | 
 | 49 | 1:	basr	%r14,%r2 | 
 | 50 |  | 
 | 51 | .gprregs_addr: | 
 | 52 | 	.long	.gprregs | 
 | 53 |  | 
 | 54 | 	.section .data,"aw",@progbits | 
 | 55 | .gprregs: | 
 | 56 | 	.rept	16 | 
 | 57 | 	.long	0 | 
 | 58 | 	.endr |