1 | #
|
---|
2 | # Copyright (c) 2003-2004 Jakub Jermar
|
---|
3 | # All rights reserved.
|
---|
4 | #
|
---|
5 | # Redistribution and use in source and binary forms, with or without
|
---|
6 | # modification, are permitted provided that the following conditions
|
---|
7 | # are met:
|
---|
8 | #
|
---|
9 | # - Redistributions of source code must retain the above copyright
|
---|
10 | # notice, this list of conditions and the following disclaimer.
|
---|
11 | # - Redistributions in binary form must reproduce the above copyright
|
---|
12 | # notice, this list of conditions and the following disclaimer in the
|
---|
13 | # documentation and/or other materials provided with the distribution.
|
---|
14 | # - The name of the author may not be used to endorse or promote products
|
---|
15 | # derived from this software without specific prior written permission.
|
---|
16 | #
|
---|
17 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
18 | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
19 | # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
20 | # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
21 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
22 | # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
23 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
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
|
---|
26 | # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
27 | #
|
---|
28 |
|
---|
29 | .text
|
---|
30 |
|
---|
31 | .set noat
|
---|
32 | .set noreorder
|
---|
33 |
|
---|
34 | #include <abi/asmtool.h>
|
---|
35 | #include <libarch/fibril_context.h>
|
---|
36 |
|
---|
37 | FUNCTION_BEGIN(__context_save)
|
---|
38 | sw $s0, __CONTEXT_OFFSET_S0($a0)
|
---|
39 | sw $s1, __CONTEXT_OFFSET_S1($a0)
|
---|
40 | sw $s2, __CONTEXT_OFFSET_S2($a0)
|
---|
41 | sw $s3, __CONTEXT_OFFSET_S3($a0)
|
---|
42 | sw $s4, __CONTEXT_OFFSET_S4($a0)
|
---|
43 | sw $s5, __CONTEXT_OFFSET_S5($a0)
|
---|
44 | sw $s6, __CONTEXT_OFFSET_S6($a0)
|
---|
45 | sw $s7, __CONTEXT_OFFSET_S7($a0)
|
---|
46 | sw $s8, __CONTEXT_OFFSET_S8($a0)
|
---|
47 | sw $gp, __CONTEXT_OFFSET_GP($a0)
|
---|
48 |
|
---|
49 | sw $k1, __CONTEXT_OFFSET_TLS($a0)
|
---|
50 |
|
---|
51 | #ifdef CONFIG_FPU
|
---|
52 | mfc1 $t0, $20
|
---|
53 | sw $t0, __CONTEXT_OFFSET_F20($a0)
|
---|
54 |
|
---|
55 | mfc1 $t0, $21
|
---|
56 | sw $t0, __CONTEXT_OFFSET_F21($a0)
|
---|
57 |
|
---|
58 | mfc1 $t0, $22
|
---|
59 | sw $t0, __CONTEXT_OFFSET_F22($a0)
|
---|
60 |
|
---|
61 | mfc1 $t0, $23
|
---|
62 | sw $t0, __CONTEXT_OFFSET_F23($a0)
|
---|
63 |
|
---|
64 | mfc1 $t0, $24
|
---|
65 | sw $t0, __CONTEXT_OFFSET_F24($a0)
|
---|
66 |
|
---|
67 | mfc1 $t0, $25
|
---|
68 | sw $t0, __CONTEXT_OFFSET_F25($a0)
|
---|
69 |
|
---|
70 | mfc1 $t0, $26
|
---|
71 | sw $t0, __CONTEXT_OFFSET_F26($a0)
|
---|
72 |
|
---|
73 | mfc1 $t0, $27
|
---|
74 | sw $t0, __CONTEXT_OFFSET_F27($a0)
|
---|
75 |
|
---|
76 | mfc1 $t0, $28
|
---|
77 | sw $t0, __CONTEXT_OFFSET_F28($a0)
|
---|
78 |
|
---|
79 | mfc1 $t0, $29
|
---|
80 | sw $t0, __CONTEXT_OFFSET_F29($a0)
|
---|
81 |
|
---|
82 | mfc1 $t0, $30
|
---|
83 | sw $t0, __CONTEXT_OFFSET_F30($a0)
|
---|
84 | #endif /* CONFIG_FPU */
|
---|
85 |
|
---|
86 | sw $ra, __CONTEXT_OFFSET_PC($a0)
|
---|
87 | sw $sp, __CONTEXT_OFFSET_SP($a0)
|
---|
88 |
|
---|
89 | # __context_save returns 0
|
---|
90 | j $ra
|
---|
91 | li $v0, 0
|
---|
92 | FUNCTION_END(__context_save)
|
---|
93 |
|
---|
94 | FUNCTION_BEGIN(__context_restore)
|
---|
95 | lw $s0, __CONTEXT_OFFSET_S0($a0)
|
---|
96 | lw $s1, __CONTEXT_OFFSET_S1($a0)
|
---|
97 | lw $s2, __CONTEXT_OFFSET_S2($a0)
|
---|
98 | lw $s3, __CONTEXT_OFFSET_S3($a0)
|
---|
99 | lw $s4, __CONTEXT_OFFSET_S4($a0)
|
---|
100 | lw $s5, __CONTEXT_OFFSET_S5($a0)
|
---|
101 | lw $s6, __CONTEXT_OFFSET_S6($a0)
|
---|
102 | lw $s7, __CONTEXT_OFFSET_S7($a0)
|
---|
103 | lw $s8, __CONTEXT_OFFSET_S8($a0)
|
---|
104 | lw $gp, __CONTEXT_OFFSET_GP($a0)
|
---|
105 | lw $k1, __CONTEXT_OFFSET_TLS($a0)
|
---|
106 |
|
---|
107 | #ifdef CONFIG_FPU
|
---|
108 | lw $t0, __CONTEXT_OFFSET_F20($a0)
|
---|
109 | mtc1 $t0, $20
|
---|
110 |
|
---|
111 | lw $t0, __CONTEXT_OFFSET_F21($a0)
|
---|
112 | mtc1 $t0, $21
|
---|
113 |
|
---|
114 | lw $t0, __CONTEXT_OFFSET_F22($a0)
|
---|
115 | mtc1 $t0, $22
|
---|
116 |
|
---|
117 | lw $t0, __CONTEXT_OFFSET_F23($a0)
|
---|
118 | mtc1 $t0, $23
|
---|
119 |
|
---|
120 | lw $t0, __CONTEXT_OFFSET_F24($a0)
|
---|
121 | mtc1 $t0, $24
|
---|
122 |
|
---|
123 | lw $t0, __CONTEXT_OFFSET_F25($a0)
|
---|
124 | mtc1 $t0, $25
|
---|
125 |
|
---|
126 | lw $t0, __CONTEXT_OFFSET_F26($a0)
|
---|
127 | mtc1 $t0, $26
|
---|
128 |
|
---|
129 | lw $t0, __CONTEXT_OFFSET_F27($a0)
|
---|
130 | mtc1 $t0, $27
|
---|
131 |
|
---|
132 | lw $t0, __CONTEXT_OFFSET_F28($a0)
|
---|
133 | mtc1 $t0, $28
|
---|
134 |
|
---|
135 | lw $t0, __CONTEXT_OFFSET_F29($a0)
|
---|
136 | mtc1 $t0, $29
|
---|
137 |
|
---|
138 | lw $t0, __CONTEXT_OFFSET_F30($a0)
|
---|
139 | mtc1 $t0, $30
|
---|
140 | #endif /* CONFIG_FPU */
|
---|
141 |
|
---|
142 | lw $ra, __CONTEXT_OFFSET_PC($a0)
|
---|
143 | lw $sp, __CONTEXT_OFFSET_SP($a0)
|
---|
144 |
|
---|
145 | # Just for the jump into first function,
|
---|
146 | # but one instruction should not bother us
|
---|
147 | move $t9, $ra
|
---|
148 |
|
---|
149 | # __context_restore returns second argument
|
---|
150 | j $ra
|
---|
151 | move $v0, $a1
|
---|
152 | FUNCTION_END(__context_restore)
|
---|