Subversion Repositories HelenOS

Rev

Rev 1797 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1797 Rev 1864
Line 1... Line 1...
1
#
1
#
2
# Copyright (C) 2006 Martin Decky
2
# Copyright (C) 2005 Jakub Jermar
3
# All rights reserved.
3
# All rights reserved.
4
#
4
#
5
# Redistribution and use in source and binary forms, with or without
5
# Redistribution and use in source and binary forms, with or without
6
# modification, are permitted provided that the following conditions
6
# modification, are permitted provided that the following conditions
7
# are met:
7
# are met:
Line 24... Line 24...
24
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
#
27
#
28
 
28
 
-
 
29
#include <libarch/context_offset.h>
-
 
30
 
-
 
31
/**
-
 
32
 * Both context_save_arch() and context_restore_arch() are
-
 
33
 * leaf-optimized procedures. This kind of optimization
-
 
34
 * is very important and prevents any implicit window
-
 
35
 * spill/fill/clean traps in these very core kernel
-
 
36
 * functions.
-
 
37
 */
-
 
38
	
29
.text
39
.text   
30
 
40
 
31
.global context_save
41
.global context_save
32
.global context_restore
42
.global context_restore
33
 
43
 
-
 
44
.macro CONTEXT_STORE r
-
 
45
	stx %sp, [\r + OFFSET_SP]
-
 
46
	stx %o7, [\r + OFFSET_PC]
-
 
47
	stx %i0, [\r + OFFSET_I0]
-
 
48
	stx %i1, [\r + OFFSET_I1]
-
 
49
	stx %i2, [\r + OFFSET_I2]
-
 
50
	stx %i3, [\r + OFFSET_I3]
-
 
51
	stx %i4, [\r + OFFSET_I4]
-
 
52
	stx %i5, [\r + OFFSET_I5]
-
 
53
	stx %fp, [\r + OFFSET_FP]
-
 
54
	stx %i7, [\r + OFFSET_I7]
-
 
55
	stx %l0, [\r + OFFSET_L0]
-
 
56
	stx %l1, [\r + OFFSET_L1]
-
 
57
	stx %l2, [\r + OFFSET_L2]
-
 
58
	stx %l3, [\r + OFFSET_L3]
-
 
59
	stx %l4, [\r + OFFSET_L4]
-
 
60
	stx %l5, [\r + OFFSET_L5]
-
 
61
	stx %l6, [\r + OFFSET_L6]
-
 
62
	stx %l7, [\r + OFFSET_L7]
-
 
63
	stx %g7, [\r + OFFSET_TP]
-
 
64
.endm
-
 
65
 
-
 
66
.macro CONTEXT_LOAD r
-
 
67
	ldx [\r + OFFSET_SP], %sp
-
 
68
	ldx [\r + OFFSET_PC], %o7
-
 
69
	ldx [\r + OFFSET_I0], %i0
-
 
70
	ldx [\r + OFFSET_I1], %i1
-
 
71
	ldx [\r + OFFSET_I2], %i2
-
 
72
	ldx [\r + OFFSET_I3], %i3
-
 
73
	ldx [\r + OFFSET_I4], %i4
-
 
74
	ldx [\r + OFFSET_I5], %i5
-
 
75
	ldx [\r + OFFSET_FP], %fp
-
 
76
	ldx [\r + OFFSET_I7], %i7
-
 
77
	ldx [\r + OFFSET_L0], %l0
-
 
78
	ldx [\r + OFFSET_L1], %l1
-
 
79
	ldx [\r + OFFSET_L2], %l2
-
 
80
	ldx [\r + OFFSET_L3], %l3
-
 
81
	ldx [\r + OFFSET_L4], %l4
-
 
82
	ldx [\r + OFFSET_L5], %l5
-
 
83
	ldx [\r + OFFSET_L6], %l6
-
 
84
	ldx [\r + OFFSET_L7], %l7
34
#include <libarch/context_offset.h>
85
	ldx [\r + OFFSET_TP], %g7
-
 
86
.endm
35
 
87
 
36
context_save:
88
context_save:
-
 
89
	CONTEXT_STORE %o0
37
 
90
	retl
-
 
91
	mov 1, %o0		! context_save_arch returns 1
38
 
92
 
39
context_restore:
93
context_restore:
-
 
94
	#
-
 
95
	# Flush all active windows.
-
 
96
	# This is essential, because CONTEXT_LOAD overwrites
-
 
97
	# %sp of CWP - 1 with the value written to %fp of CWP.
-
 
98
	# Flushing all active windows mitigates this problem
-
 
99
	# as CWP - 1 becomes the overlap window.
-
 
100
	#		
-
 
101
	flushw
-
 
102
	
-
 
103
	CONTEXT_LOAD %o0
-
 
104
	retl
-
 
105
	xor %o0, %o0, %o0	! context_restore_arch returns 0