summaryrefslogtreecommitdiffstats
path: root/cpukit/score/cpu/m32c/context_switch.S
blob: 39d151bd98ccc9a383e41a058f1d48f1079def39 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
 *  Context switch for the Reneas M32C
 *
 *
 */

#define ARG_EXECUTING 8
#define ARG_HEIR      12

#define CTXT_SP  0
#define CTXT_FB  4

	.file	"context_switch.S"
	.text
	.global	__CPU_Context_switch
	.type	__CPU_Context_switch, @function
__CPU_Context_switch:
	enter	#0
	pushm 	a0,a1,r0,r1,r2,r3
	pushc	flg
	pushc	sb

	mov.l	ARG_EXECUTING[fb],a0	; a0 = executing
	stc  	fb,a1
	mov.l	a1,CTXT_FB[a0]		; save fb
	stc  	sp,a1
	mov.l	a1,CTXT_SP[a0]		; save sp

	mov.l	ARG_HEIR[fb],a0		; a0 = heir

restore:
	mov.l	CTXT_SP[a0],a1
	ldc  	a1,sp			; restore sp
	mov.l	CTXT_FB[a0],a1
	ldc  	a1,fb			; restore fb
	popc	sb
	popc	flg
	popm 	a0,a1,r0,r1,r2,r3
	exitd
	.size	__CPU_Context_switch, .-__CPU_Context_switch

#define ARG_RESTART 8

	.global	__CPU_Context_Restart_self
	.type	__CPU_Context_Restart_self, @function
__CPU_Context_Restart_self:
	enter	#0
	mov.l	ARG_RESTART[fb],a0	; a0 = heir
	jmp.s	restore